diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-09-21 18:29:23 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-09-21 18:31:42 +0200 |
commit | ce0458be09911e75bfd3b4d802c9594c55a9c98d (patch) | |
tree | edd9bdf44bec9479f7fe8a9e77aa7d5e70bc4723 /src/shared | |
parent | 71a80dcc0b64b01c73e7141c4292ef301543a011 (diff) | |
download | systemd-ce0458be09911e75bfd3b4d802c9594c55a9c98d.tar.gz |
smack: move helper function to smack-util.c
The function was in basic/fileio.c, but it's more appropriate to
keep it out of src/basic.
Fixes compilation with -Dsmack-run-label= set.
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/smack-util.c | 13 | ||||
-rw-r--r-- | src/shared/smack-util.h | 2 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/shared/smack-util.c b/src/shared/smack-util.c index 2ae11e7f9a..01958f0b0d 100644 --- a/src/shared/smack-util.c +++ b/src/shared/smack-util.c @@ -284,3 +284,16 @@ int mac_smack_copy(const char *dest, const char *src) { return 0; } #endif + +int rename_and_apply_smack_floor_label(const char *from, const char *to) { + int r = 0; + if (rename(from, to) < 0) + return -errno; + +#if HAVE_SMACK_RUN_LABEL + r = mac_smack_apply(to, SMACK_ATTR_ACCESS, SMACK_FLOOR_LABEL); + if (r < 0) + return r; +#endif + return r; +} diff --git a/src/shared/smack-util.h b/src/shared/smack-util.h index 36fdc72083..df91c89e01 100644 --- a/src/shared/smack-util.h +++ b/src/shared/smack-util.h @@ -44,3 +44,5 @@ 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); + +int rename_and_apply_smack_floor_label(const char *temp_path, const char *dest_path); |