X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;ds=sidebyside;f=src%2Fshared%2Fsmack-util.c;h=0c3697b61b841b29b5c9504d336c47034058362f;hb=1c41caca9ff73085513b988edbb341e076244298;hp=a62c479900efd3b58b6f8ee7bbabb741287dc375;hpb=56f64d95763a799ba4475daf44d8e9f72a1bd474;p=elogind.git diff --git a/src/shared/smack-util.c b/src/shared/smack-util.c index a62c47990..0c3697b61 100644 --- a/src/shared/smack-util.c +++ b/src/shared/smack-util.c @@ -24,6 +24,7 @@ #include #include "util.h" +#include "process-util.h" #include "path-util.h" #include "fileio.h" #include "smack-util.h" @@ -125,8 +126,11 @@ int mac_smack_apply_ip_in_fd(int fd, const char *label) { } int mac_smack_apply_pid(pid_t pid, const char *label) { - int r = 0; + +#ifdef HAVE_SMACK const char *p; +#endif + int r = 0; assert(label); @@ -135,7 +139,7 @@ int mac_smack_apply_pid(pid_t pid, const char *label) { return 0; p = procfs_file_alloca(pid, "attr/current"); - r = write_string_file(p, label); + r = write_string_file(p, label, WRITE_STRING_FILE_CREATE); if (r < 0) return r; #endif @@ -144,13 +148,15 @@ int mac_smack_apply_pid(pid_t pid, const char *label) { } int mac_smack_fix(const char *path, bool ignore_enoent, bool ignore_erofs) { - int r = 0; #ifdef HAVE_SMACK struct stat st; +#endif + int r = 0; assert(path); +#ifdef HAVE_SMACK if (!mac_smack_use()) return 0; @@ -182,7 +188,7 @@ int mac_smack_fix(const char *path, bool ignore_enoent, bool ignore_erofs) { r = lsetxattr(path, "security.SMACK64", label, strlen(label), 0); /* If the FS doesn't support labels, then exit without warning */ - if (r < 0 && errno == ENOTSUP) + if (r < 0 && errno == EOPNOTSUPP) return 0; } @@ -194,8 +200,7 @@ int mac_smack_fix(const char *path, bool ignore_enoent, bool ignore_erofs) { if (ignore_erofs && errno == EROFS) return 0; - log_debug_errno(errno, "Unable to fix SMACK label of %s: %m", path); - r = -errno; + r = log_debug_errno(errno, "Unable to fix SMACK label of %s: %m", path); } #endif