]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
smack: move helper function to smack-util.c
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 21 Sep 2021 16:29:23 +0000 (18:29 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 21 Sep 2021 16:31:42 +0000 (18:31 +0200)
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.

src/basic/fileio.c
src/basic/fileio.h
src/firstboot/firstboot.c
src/shared/smack-util.c
src/shared/smack-util.h

index 60a98851082fe481c9e24a375b92958cec699494..6a4a65723f008f53285e9f66ca3349cb0bf2ed13 100644 (file)
@@ -1434,16 +1434,3 @@ int warn_file_is_world_accessible(const char *filename, struct stat *st, const c
                             filename, st->st_mode & 07777);
         return 0;
 }
-
-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;
-}
index 4295b84a85c59494a091795dc65035471a19164e..9defa4e6bc0e2400995fc2eec6141ea08929bb7b 100644 (file)
@@ -124,5 +124,3 @@ static inline int read_nul_string(FILE *f, size_t limit, char **ret) {
 int safe_fgetc(FILE *f, char *ret);
 
 int warn_file_is_world_accessible(const char *filename, struct stat *st, const char *unit, unsigned line);
-
-int rename_and_apply_smack_floor_label(const char *temp_path, const char *dest_path);
index 93ce800bd7b4876d006f8d4c11b2568358e541ef..6fdba66f578abfbf26e44aed279f5e5532c0e261 100644 (file)
@@ -32,6 +32,7 @@
 #include "proc-cmdline.h"
 #include "pwquality-util.h"
 #include "random-util.h"
+#include "smack-util.h"
 #include "string-util.h"
 #include "strv.h"
 #include "terminal-util.h"
index 2ae11e7f9a7dcffac34aa3bdf4d9aa3ad26a0fc0..01958f0b0d9b8547f93f555fdeee69bc4e9cfe0d 100644 (file)
@@ -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;
+}
index 36fdc720839a594c73929b3b2177c2cd6d223baa..df91c89e01bac2e2ae5717e413e4e90a9cad1897 100644 (file)
@@ -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);