Compare commits
6 Commits
42165319b1
...
3cd4459003
Author | SHA1 | Date |
---|---|---|
Lennart Poettering | 3cd4459003 | |
Yu Watanabe | 0ded0e40ab | |
Lennart Poettering | 330f899079 | |
Lennart Poettering | 89a5385fb7 | |
Lennart Poettering | 8d5bb13d78 | |
Christian Göttsche | aeba8dd523 |
|
@ -272,7 +272,7 @@ int path_is_mount_point(const char *t, const char *root, int flags) {
|
||||||
|
|
||||||
fd = open_parent(t, O_PATH|O_CLOEXEC, 0);
|
fd = open_parent(t, O_PATH|O_CLOEXEC, 0);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return -errno;
|
return fd;
|
||||||
|
|
||||||
return fd_is_mount_point(fd, last_path_component(t), flags);
|
return fd_is_mount_point(fd, last_path_component(t), flags);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,14 +35,14 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(context_t, context_free);
|
||||||
static int mac_selinux_reload(int seqno);
|
static int mac_selinux_reload(int seqno);
|
||||||
|
|
||||||
static int cached_use = -1;
|
static int cached_use = -1;
|
||||||
static int cached_enforcing = -1;
|
|
||||||
static struct selabel_handle *label_hnd = NULL;
|
static struct selabel_handle *label_hnd = NULL;
|
||||||
|
|
||||||
#define log_enforcing(...) log_full(mac_selinux_enforcing() ? LOG_ERR : LOG_WARNING, __VA_ARGS__)
|
#define log_enforcing(...) \
|
||||||
|
log_full(security_getenforce() != 0 ? LOG_ERR : LOG_WARNING, __VA_ARGS__)
|
||||||
|
|
||||||
#define log_enforcing_errno(error, ...) \
|
#define log_enforcing_errno(error, ...) \
|
||||||
({ \
|
({ \
|
||||||
bool _enforcing = mac_selinux_enforcing(); \
|
bool _enforcing = security_getenforce() != 0; \
|
||||||
int _level = _enforcing ? LOG_ERR : LOG_WARNING; \
|
int _level = _enforcing ? LOG_ERR : LOG_WARNING; \
|
||||||
int _e = (error); \
|
int _e = (error); \
|
||||||
\
|
\
|
||||||
|
@ -66,41 +66,12 @@ bool mac_selinux_use(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mac_selinux_enforcing(void) {
|
|
||||||
#if HAVE_SELINUX
|
|
||||||
if (_unlikely_(cached_enforcing < 0)) {
|
|
||||||
cached_enforcing = security_getenforce();
|
|
||||||
if (cached_enforcing < 0) {
|
|
||||||
log_debug_errno(errno, "Failed to get SELinux enforced status, continuing in enforcing mode: %m");
|
|
||||||
return true; /* treat failure as enforcing mode */
|
|
||||||
}
|
|
||||||
|
|
||||||
log_debug("SELinux enforcing state cached to: %s", cached_enforcing ? "enforcing" : "permissive");
|
|
||||||
}
|
|
||||||
|
|
||||||
return cached_enforcing > 0;
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void mac_selinux_retest(void) {
|
void mac_selinux_retest(void) {
|
||||||
#if HAVE_SELINUX
|
#if HAVE_SELINUX
|
||||||
cached_use = -1;
|
cached_use = -1;
|
||||||
cached_enforcing = -1;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if HAVE_SELINUX
|
|
||||||
static int setenforce_callback(int enforcing) {
|
|
||||||
cached_enforcing = enforcing;
|
|
||||||
|
|
||||||
log_debug("SELinux enforcing state updated to: %s", cached_enforcing ? "enforcing" : "permissive");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int mac_selinux_init(void) {
|
int mac_selinux_init(void) {
|
||||||
#if HAVE_SELINUX
|
#if HAVE_SELINUX
|
||||||
usec_t before_timestamp, after_timestamp;
|
usec_t before_timestamp, after_timestamp;
|
||||||
|
@ -109,7 +80,6 @@ int mac_selinux_init(void) {
|
||||||
int l;
|
int l;
|
||||||
|
|
||||||
selinux_set_callback(SELINUX_CB_POLICYLOAD, (union selinux_callback) mac_selinux_reload);
|
selinux_set_callback(SELINUX_CB_POLICYLOAD, (union selinux_callback) mac_selinux_reload);
|
||||||
selinux_set_callback(SELINUX_CB_SETENFORCE, (union selinux_callback) setenforce_callback);
|
|
||||||
|
|
||||||
if (label_hnd)
|
if (label_hnd)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -16,7 +16,6 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(char*, freecon);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool mac_selinux_use(void);
|
bool mac_selinux_use(void);
|
||||||
bool mac_selinux_enforcing(void);
|
|
||||||
void mac_selinux_retest(void);
|
void mac_selinux_retest(void);
|
||||||
|
|
||||||
int mac_selinux_init(void);
|
int mac_selinux_init(void);
|
||||||
|
|
|
@ -1725,7 +1725,8 @@ static int build_environment(
|
||||||
assert(p);
|
assert(p);
|
||||||
assert(ret);
|
assert(ret);
|
||||||
|
|
||||||
our_env = new0(char*, 15 + _EXEC_DIRECTORY_TYPE_MAX);
|
#define N_ENV_VARS 15
|
||||||
|
our_env = new0(char*, N_ENV_VARS + _EXEC_DIRECTORY_TYPE_MAX);
|
||||||
if (!our_env)
|
if (!our_env)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
@ -1873,7 +1874,8 @@ static int build_environment(
|
||||||
}
|
}
|
||||||
|
|
||||||
our_env[n_env++] = NULL;
|
our_env[n_env++] = NULL;
|
||||||
assert(n_env <= 14 + _EXEC_DIRECTORY_TYPE_MAX);
|
assert(n_env <= N_ENV_VARS + _EXEC_DIRECTORY_TYPE_MAX);
|
||||||
|
#undef N_ENV_VARS
|
||||||
|
|
||||||
*ret = TAKE_PTR(our_env);
|
*ret = TAKE_PTR(our_env);
|
||||||
|
|
||||||
|
|
|
@ -4218,7 +4218,7 @@ int config_parse_exec_directories(
|
||||||
|
|
||||||
r = unit_full_printf(u, word, &k);
|
r = unit_full_printf(u, word, &k);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
log_syntax(unit, LOG_ERR, filename, line, r,
|
log_syntax(unit, LOG_WARNING, filename, line, r,
|
||||||
"Failed to resolve unit specifiers in \"%s\", ignoring: %m", word);
|
"Failed to resolve unit specifiers in \"%s\", ignoring: %m", word);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -4228,7 +4228,7 @@ int config_parse_exec_directories(
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (path_startswith(k, "private")) {
|
if (path_startswith(k, "private")) {
|
||||||
log_syntax(unit, LOG_ERR, filename, line, 0,
|
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||||
"%s= path can't be 'private', ignoring assignment: %s", lvalue, word);
|
"%s= path can't be 'private', ignoring assignment: %s", lvalue, word);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,8 +144,9 @@ static int access_init(sd_bus_error *error) {
|
||||||
|
|
||||||
if (avc_open(NULL, 0) != 0) {
|
if (avc_open(NULL, 0) != 0) {
|
||||||
int saved_errno = errno;
|
int saved_errno = errno;
|
||||||
const bool enforce = mac_selinux_enforcing();
|
bool enforce;
|
||||||
|
|
||||||
|
enforce = security_getenforce() != 0;
|
||||||
log_full_errno(enforce ? LOG_ERR : LOG_WARNING, saved_errno, "Failed to open the SELinux AVC: %m");
|
log_full_errno(enforce ? LOG_ERR : LOG_WARNING, saved_errno, "Failed to open the SELinux AVC: %m");
|
||||||
|
|
||||||
/* If enforcement isn't on, then let's suppress this
|
/* If enforcement isn't on, then let's suppress this
|
||||||
|
@ -197,7 +198,7 @@ int mac_selinux_generic_access_check(
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
/* delay call until we checked in `access_init()` if SELinux is actually enabled */
|
/* delay call until we checked in `access_init()` if SELinux is actually enabled */
|
||||||
enforce = mac_selinux_enforcing();
|
enforce = security_getenforce() != 0;
|
||||||
|
|
||||||
r = sd_bus_query_sender_creds(
|
r = sd_bus_query_sender_creds(
|
||||||
message,
|
message,
|
||||||
|
|
|
@ -2015,7 +2015,7 @@ int sd_dhcp_client_send_renew(sd_dhcp_client *client) {
|
||||||
assert_return(client, -EINVAL);
|
assert_return(client, -EINVAL);
|
||||||
assert_return(client->fd >= 0, -EINVAL);
|
assert_return(client->fd >= 0, -EINVAL);
|
||||||
|
|
||||||
if (IN_SET(client->state, DHCP_STATE_INIT, DHCP_STATE_INIT_REBOOT, DHCP_STATE_STOPPED))
|
if (!client->lease)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
client->start_delay = 0;
|
client->start_delay = 0;
|
||||||
|
|
|
@ -489,7 +489,7 @@ int dhcp6_request_prefix_delegation(Link *link) {
|
||||||
if (enabled == 0) {
|
if (enabled == 0) {
|
||||||
r = sd_dhcp6_client_set_prefix_delegation(l->dhcp6_client, 1);
|
r = sd_dhcp6_client_set_prefix_delegation(l->dhcp6_client, 1);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
log_link_warning_errno(l, r, "Cannot enable prefix delegation when adding new link: 5m");
|
log_link_warning_errno(l, r, "Cannot enable prefix delegation when adding new link: %m");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue