1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-26 03:22:00 +03:00

Merge pull request #1212 from again4you/devel/fix_smack_label_#3

Wrong smack label of the symlink in CGROUP root directory when enabling '--with-smack-run-label' (v3)
This commit is contained in:
Lennart Poettering 2015-09-09 14:01:26 +02:00
commit 542a69a284
3 changed files with 27 additions and 1 deletions

View File

@ -185,6 +185,23 @@ int mac_smack_fix(const char *path, bool ignore_enoent, bool ignore_erofs) {
return r;
}
int mac_smack_copy(const char *dest, const char *src) {
int r = 0;
_cleanup_free_ char *label = NULL;
assert(dest);
assert(src);
r = mac_smack_read(src, SMACK_ATTR_ACCESS, &label);
if (r < 0)
return r;
r = mac_smack_apply(dest, SMACK_ATTR_ACCESS, label);
if (r < 0)
return r;
return r;
}
#else
bool mac_smack_use(void) {
@ -214,4 +231,8 @@ int mac_smack_apply_pid(pid_t pid, const char *label) {
int mac_smack_fix(const char *path, bool ignore_enoent, bool ignore_erofs) {
return 0;
}
int mac_smack_copy(const char *dest, const char *src) {
return 0;
}
#endif

View File

@ -48,5 +48,5 @@ int mac_smack_read(const char *path, SmackAttr attr, char **label);
int mac_smack_read_fd(int fd, SmackAttr attr, char **label);
int mac_smack_apply(const char *path, SmackAttr attr, const char *label);
int mac_smack_apply_fd(int fd, SmackAttr attr, const char *label);
int mac_smack_apply_pid(pid_t pid, const char *label);
int mac_smack_copy(const char *dest, const char *src);

View File

@ -303,6 +303,11 @@ int mount_cgroup_controllers(char ***join_controllers) {
r = symlink(options, t);
if (r < 0 && errno != EEXIST)
return log_error_errno(errno, "Failed to create symlink %s: %m", t);
#ifdef SMACK_RUN_LABEL
r = mac_smack_copy(t, options);
if (r < 0 && r != -EOPNOTSUPP)
return log_error_errno(r, "Failed to copy smack label from %s to %s: %m", options, t);
#endif
}
}
}