diff options
author | Lennart Poettering <lennart@poettering.net> | 2021-11-12 15:44:50 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2021-11-16 17:03:28 +0100 |
commit | 35cd0ba516fb0e2ee5744b9185f7df903962c726 (patch) | |
tree | b2bd0411918b1c38b8b5997a6e5c17c2e5f3ddd8 | |
parent | mkdir: drop mkdir_errno_wrapper(), use mkdirat_errno_wrapper() instead (diff) | |
download | systemd-35cd0ba516fb0e2ee5744b9185f7df903962c726.tar.xz systemd-35cd0ba516fb0e2ee5744b9185f7df903962c726.zip |
shared: clean up mkdir.h/label.h situation
Previously the mkdir_label() family of calls was implemented in
src/shared/mkdir-label.c but its functions partly declared ins
src/shared/label.h and partly in src/basic/mkdir.h (!!). That's weird
(and wrong).
Let's clean this up, and add a proper mkdir-label.h matching the .c
file.
58 files changed, 80 insertions, 77 deletions
diff --git a/src/basic/mkdir.h b/src/basic/mkdir.h index 837e493c6b..34a5227577 100644 --- a/src/basic/mkdir.h +++ b/src/basic/mkdir.h @@ -9,21 +9,16 @@ typedef enum MkdirFlags { } MkdirFlags; int mkdirat_errno_wrapper(int dirfd, const char *pathname, mode_t mode); + int mkdir_safe(const char *path, mode_t mode, uid_t uid, gid_t gid, MkdirFlags flags); int mkdir_parents(const char *path, mode_t mode); int mkdir_parents_safe(const char *prefix, const char *path, mode_t mode, uid_t uid, gid_t gid, MkdirFlags flags); int mkdir_p(const char *path, mode_t mode); int mkdir_p_safe(const char *prefix, const char *path, mode_t mode, uid_t uid, gid_t gid, MkdirFlags flags); +int mkdir_p_root(const char *root, const char *p, uid_t uid, gid_t gid, mode_t m); -/* mandatory access control(MAC) versions */ -int mkdir_safe_label(const char *path, mode_t mode, uid_t uid, gid_t gid, MkdirFlags flags); -int mkdir_parents_label(const char *path, mode_t mod); -int mkdir_p_label(const char *path, mode_t mode); - -/* internally used */ +/* The following are used to implement the mkdir_xyz_label() calls, don't use otherwise. */ typedef int (*mkdirat_func_t)(int dir_fd, const char *pathname, mode_t mode); int mkdir_safe_internal(const char *path, mode_t mode, uid_t uid, gid_t gid, MkdirFlags flags, mkdirat_func_t _mkdir); int mkdir_parents_internal(const char *prefix, const char *path, mode_t mode, uid_t uid, gid_t gid, MkdirFlags flags, mkdirat_func_t _mkdir); int mkdir_p_internal(const char *prefix, const char *path, mode_t mode, uid_t uid, gid_t gid, MkdirFlags flags, mkdirat_func_t _mkdir); - -int mkdir_p_root(const char *root, const char *p, uid_t uid, gid_t gid, mode_t m); diff --git a/src/core/automount.c b/src/core/automount.c index 550a350a45..0bb58fdcd1 100644 --- a/src/core/automount.c +++ b/src/core/automount.c @@ -21,7 +21,7 @@ #include "format-util.h" #include "io-util.h" #include "label.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "mount-util.h" #include "mount.h" #include "mountpoint-util.h" diff --git a/src/core/core-varlink.c b/src/core/core-varlink.c index ab0d455380..8c54cc0663 100644 --- a/src/core/core-varlink.c +++ b/src/core/core-varlink.c @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include "core-varlink.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "strv.h" #include "user-util.h" #include "varlink.h" diff --git a/src/core/dbus.c b/src/core/dbus.c index f876433c00..2c5bda58f9 100644 --- a/src/core/dbus.c +++ b/src/core/dbus.c @@ -33,7 +33,7 @@ #include "fd-util.h" #include "fs-util.h" #include "log.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "process-util.h" #include "selinux-access.h" #include "serialize.h" diff --git a/src/core/execute.c b/src/core/execute.c index 6192a2d33e..ba66b9e6ec 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -71,7 +71,7 @@ #include "memory-util.h" #include "missing_fs.h" #include "missing_ioprio.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "mount-util.h" #include "mountpoint-util.h" #include "namespace.h" diff --git a/src/core/generator-setup.c b/src/core/generator-setup.c index 9173951735..00d6ad61fa 100644 --- a/src/core/generator-setup.c +++ b/src/core/generator-setup.c @@ -4,7 +4,7 @@ #include "generator-setup.h" #include "macro.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "rm-rf.h" int lookup_paths_mkdir_generator(LookupPaths *p) { diff --git a/src/core/main.c b/src/core/main.c index 72dd199ddb..57aedb9b93 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -60,7 +60,7 @@ #include "manager.h" #include "manager-dump.h" #include "manager-serialize.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "mount-setup.h" #include "os-util.h" #include "pager.h" diff --git a/src/core/manager.c b/src/core/manager.c index b21747daea..c94f032cc0 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -58,7 +58,7 @@ #include "manager-dump.h" #include "manager-serialize.h" #include "memory-util.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "parse-util.h" #include "path-lookup.h" #include "path-util.h" diff --git a/src/core/mount.c b/src/core/mount.c index 4f76b552c2..90b11347f7 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -17,7 +17,7 @@ #include "libmount-util.h" #include "log.h" #include "manager.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "mount-setup.h" #include "mount.h" #include "mountpoint-util.h" diff --git a/src/core/namespace.c b/src/core/namespace.c index c01975b9de..a84060c682 100644 --- a/src/core/namespace.c +++ b/src/core/namespace.c @@ -21,7 +21,7 @@ #include "list.h" #include "loop-util.h" #include "loopback-setup.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "mount-util.h" #include "mountpoint-util.h" #include "namespace-util.h" diff --git a/src/core/path.c b/src/core/path.c index cdab9dcf8c..999cecc96c 100644 --- a/src/core/path.c +++ b/src/core/path.c @@ -14,7 +14,7 @@ #include "glob-util.h" #include "inotify-util.h" #include "macro.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "path.h" #include "path-util.h" #include "serialize.h" diff --git a/src/core/socket.c b/src/core/socket.c index f265aab594..e6d168188a 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -28,7 +28,7 @@ #include "ip-protocol-list.h" #include "label.h" #include "log.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "parse-util.h" #include "path-util.h" #include "process-util.h" diff --git a/src/core/unit.c b/src/core/unit.c index 27d7503332..fa21b8acb2 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -37,7 +37,7 @@ #include "log.h" #include "macro.h" #include "missing_audit.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "path-util.h" #include "process-util.h" #include "rm-rf.h" diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c index 62a622a6ca..27b8f7754b 100644 --- a/src/coredump/coredump.c +++ b/src/coredump/coredump.c @@ -37,7 +37,7 @@ #include "macro.h" #include "main-func.h" #include "memory-util.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "parse-util.h" #include "process-util.h" #include "signal-util.h" diff --git a/src/debug-generator/debug-generator.c b/src/debug-generator/debug-generator.c index a8f3422dd4..a724ae510d 100644 --- a/src/debug-generator/debug-generator.c +++ b/src/debug-generator/debug-generator.c @@ -5,7 +5,7 @@ #include "alloc-util.h" #include "dropin.h" #include "generator.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "parse-util.h" #include "path-util.h" #include "proc-cmdline.h" @@ -138,7 +138,7 @@ static int generate_wants_symlinks(void) { if (!f) return log_oom(); - mkdir_parents_label(p, 0755); + (void) mkdir_parents_label(p, 0755); if (symlink(f, p) < 0) r = log_error_errno(errno, diff --git a/src/getty-generator/getty-generator.c b/src/getty-generator/getty-generator.c index aa5a0a6ddb..b4d4952f99 100644 --- a/src/getty-generator/getty-generator.c +++ b/src/getty-generator/getty-generator.c @@ -10,7 +10,7 @@ #include "fileio.h" #include "generator.h" #include "log.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "path-util.h" #include "process-util.h" #include "strv.h" @@ -31,7 +31,7 @@ static int add_symlink(const char *fservice, const char *tservice) { from = strjoina(SYSTEM_DATA_UNIT_DIR "/", fservice); to = strjoina(arg_dest, "/getty.target.wants/", tservice); - mkdir_parents_label(to, 0755); + (void) mkdir_parents_label(to, 0755); r = symlink(from, to); if (r < 0) { diff --git a/src/hibernate-resume/hibernate-resume-generator.c b/src/hibernate-resume/hibernate-resume-generator.c index 5e986db2b0..ee320909ee 100644 --- a/src/hibernate-resume/hibernate-resume-generator.c +++ b/src/hibernate-resume/hibernate-resume-generator.c @@ -10,7 +10,7 @@ #include "generator.h" #include "log.h" #include "main-func.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "proc-cmdline.h" #include "special.h" #include "string-util.h" @@ -84,7 +84,7 @@ static int process_resume(void) { if (!lnk) return log_oom(); - mkdir_parents_label(lnk, 0755); + (void) mkdir_parents_label(lnk, 0755); if (symlink(SYSTEM_DATA_UNIT_DIR "/systemd-hibernate-resume@.service", lnk) < 0) return log_error_errno(errno, "Failed to create symlink %s: %m", lnk); diff --git a/src/import/import-fs.c b/src/import/import-fs.c index cacd48fe96..ff7f51a60a 100644 --- a/src/import/import-fs.c +++ b/src/import/import-fs.c @@ -14,7 +14,7 @@ #include "import-util.h" #include "install-file.h" #include "main-func.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "parse-argument.h" #include "ratelimit.h" #include "rm-rf.h" diff --git a/src/import/import-raw.c b/src/import/import-raw.c index 153b74d123..a0208e505c 100644 --- a/src/import/import-raw.c +++ b/src/import/import-raw.c @@ -18,7 +18,7 @@ #include "install-file.h" #include "io-util.h" #include "machine-pool.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "path-util.h" #include "qcow2-util.h" #include "ratelimit.h" diff --git a/src/import/import-tar.c b/src/import/import-tar.c index 8cbdbaa35f..f31d3d75a1 100644 --- a/src/import/import-tar.c +++ b/src/import/import-tar.c @@ -18,7 +18,7 @@ #include "install-file.h" #include "io-util.h" #include "machine-pool.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "path-util.h" #include "process-util.h" #include "qcow2-util.h" diff --git a/src/import/importd.c b/src/import/importd.c index 0400d41b14..66771f63e2 100644 --- a/src/import/importd.c +++ b/src/import/importd.c @@ -19,7 +19,7 @@ #include "machine-pool.h" #include "main-func.h" #include "missing_capability.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "parse-util.h" #include "path-util.h" #include "percent-util.h" diff --git a/src/import/pull-raw.c b/src/import/pull-raw.c index 6a0c2c8b17..0623afcc84 100644 --- a/src/import/pull-raw.c +++ b/src/import/pull-raw.c @@ -17,7 +17,7 @@ #include "import-util.h" #include "install-file.h" #include "macro.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "path-util.h" #include "pull-common.h" #include "pull-job.h" diff --git a/src/import/pull-tar.c b/src/import/pull-tar.c index 9608129e5e..fd866fc514 100644 --- a/src/import/pull-tar.c +++ b/src/import/pull-tar.c @@ -16,7 +16,7 @@ #include "import-util.h" #include "install-file.h" #include "macro.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "path-util.h" #include "process-util.h" #include "pull-common.h" diff --git a/src/locale/keymap-util.c b/src/locale/keymap-util.c index 1bd8f5c0ae..10d2ed7aec 100644 --- a/src/locale/keymap-util.c +++ b/src/locale/keymap-util.c @@ -18,7 +18,7 @@ #include "keymap-util.h" #include "locale-util.h" #include "macro.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "nulstr-util.h" #include "process-util.h" #include "string-util.h" diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index 6e9dde1c15..331dcd2a05 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -36,7 +36,7 @@ #include "logind-user-dbus.h" #include "logind.h" #include "missing_capability.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "parse-util.h" #include "path-util.h" #include "process-util.h" diff --git a/src/login/logind-inhibit.c b/src/login/logind-inhibit.c index 1de71c2481..dbb58e4ac3 100644 --- a/src/login/logind-inhibit.c +++ b/src/login/logind-inhibit.c @@ -17,7 +17,7 @@ #include "io-util.h" #include "logind-dbus.h" #include "logind-inhibit.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "parse-util.h" #include "path-util.h" #include "string-table.h" diff --git a/src/login/logind-seat.c b/src/login/logind-seat.c index 2d54681745..58912b85b3 100644 --- a/src/login/logind-seat.c +++ b/src/login/logind-seat.c @@ -16,7 +16,7 @@ #include "logind-seat-dbus.h" #include "logind-seat.h" #include "logind-session-dbus.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "parse-util.h" #include "path-util.h" #include "stdio-util.h" diff --git a/src/login/logind-session.c b/src/login/logind-session.c index d6d67af05a..ab98a5055d 100644 --- a/src/login/logind-session.c +++ b/src/login/logind-session.c @@ -26,7 +26,7 @@ #include "logind-session-dbus.h" #include "logind-session.h" #include "logind-user-dbus.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "parse-util.h" #include "path-util.h" #include "process-util.h" diff --git a/src/login/logind-user.c b/src/login/logind-user.c index 5266f55775..6d250be321 100644 --- a/src/login/logind-user.c +++ b/src/login/logind-user.c @@ -21,7 +21,7 @@ #include "logind-dbus.h" #include "logind-user-dbus.h" #include "logind-user.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "parse-util.h" #include "path-util.h" #include "percent-util.h" diff --git a/src/login/logind.c b/src/login/logind.c index 6e1ebbf9c5..57a8604b7f 100644 --- a/src/login/logind.c +++ b/src/login/logind.c @@ -27,6 +27,7 @@ #include "logind-user-dbus.h" #include "logind.h" #include "main-func.h" +#include "mkdir-label.h" #include "parse-util.h" #include "process-util.h" #include "selinux-util.h" diff --git a/src/login/user-runtime-dir.c b/src/login/user-runtime-dir.c index a1087ed31c..5ce5b35e17 100644 --- a/src/login/user-runtime-dir.c +++ b/src/login/user-runtime-dir.c @@ -12,7 +12,7 @@ #include "label.h" #include "limits-util.h" #include "main-func.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "mount-util.h" #include "mountpoint-util.h" #include "path-util.h" diff --git a/src/machine/machine.c b/src/machine/machine.c index a42478e874..80f73da94a 100644 --- a/src/machine/machine.c +++ b/src/machine/machine.c @@ -19,7 +19,7 @@ #include "hashmap.h" #include "machine-dbus.h" #include "machine.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "parse-util.h" #include "path-util.h" #include "process-util.h" diff --git a/src/machine/machined.c b/src/machine/machined.c index 4ab459d3ca..6ffa4191ec 100644 --- a/src/machine/machined.c +++ b/src/machine/machined.c @@ -18,10 +18,10 @@ #include "fd-util.h" #include "format-util.h" #include "hostname-util.h" -#include "label.h" #include "machined-varlink.h" #include "machined.h" #include "main-func.h" +#include "mkdir-label.h" #include "process-util.h" #include "service-util.h" #include "signal-util.h" diff --git a/src/network/networkd.c b/src/network/networkd.c index d274885264..7d63786f48 100644 --- a/src/network/networkd.c +++ b/src/network/networkd.c @@ -11,7 +11,7 @@ #include "daemon-util.h" #include "firewall-util.h" #include "main-func.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "networkd-conf.h" #include "networkd-manager.h" #include "signal-util.h" diff --git a/src/nspawn/nspawn-mount.c b/src/nspawn/nspawn-mount.c index 2bfff79cde..40773d90c1 100644 --- a/src/nspawn/nspawn-mount.c +++ b/src/nspawn/nspawn-mount.c @@ -10,7 +10,7 @@ #include "format-util.h" #include "fs-util.h" #include "label.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "mount-util.h" #include "mountpoint-util.h" #include "nspawn-mount.h" diff --git a/src/rc-local-generator/rc-local-generator.c b/src/rc-local-generator/rc-local-generator.c index 99cffee3ec..c2b9e64217 100644 --- a/src/rc-local-generator/rc-local-generator.c +++ b/src/rc-local-generator/rc-local-generator.c @@ -6,7 +6,7 @@ #include "generator.h" #include "log.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "string-util.h" #include "util.h" diff --git a/src/resolve/resolved.c b/src/resolve/resolved.c index 85ab917c4f..d3bc902752 100644 --- a/src/resolve/resolved.c +++ b/src/resolve/resolved.c @@ -11,7 +11,7 @@ #include "capability-util.h" #include "daemon-util.h" #include "main-func.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "resolved-bus.h" #include "resolved-conf.h" #include "resolved-manager.h" diff --git a/src/shared/ask-password-api.c b/src/shared/ask-password-api.c index 367c1df240..07e301276f 100644 --- a/src/shared/ask-password-api.c +++ b/src/shared/ask-password-api.c @@ -33,7 +33,7 @@ #include "macro.h" #include "memory-util.h" #include "missing_syscall.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "process-util.h" #include "random-util.h" #include "signal-util.h" diff --git a/src/shared/copy.c b/src/shared/copy.c index 51dd08eccd..fd83d74265 100644 --- a/src/shared/copy.c +++ b/src/shared/copy.c @@ -20,6 +20,7 @@ #include "io-util.h" #include "macro.h" #include "missing_syscall.h" +#include "mkdir-label.h" #include "mountpoint-util.h" #include "nulstr-util.h" #include "rm-rf.h" diff --git a/src/shared/dev-setup.c b/src/shared/dev-setup.c index 0390abbfdc..a340524510 100644 --- a/src/shared/dev-setup.c +++ b/src/shared/dev-setup.c @@ -8,6 +8,7 @@ #include "dev-setup.h" #include "label.h" #include "log.h" +#include "mkdir-label.h" #include "nulstr-util.h" #include "path-util.h" #include "umask-util.h" diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c index 6b2289defa..18c7991570 100644 --- a/src/shared/dissect-image.c +++ b/src/shared/dissect-image.c @@ -46,7 +46,7 @@ #include "hostname-setup.h" #include "id128-util.h" #include "import-util.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "mount-util.h" #include "mountpoint-util.h" #include "namespace-util.h" diff --git a/src/shared/generator.c b/src/shared/generator.c index 3967edfa06..014b34747d 100644 --- a/src/shared/generator.c +++ b/src/shared/generator.c @@ -13,7 +13,7 @@ #include "generator.h" #include "log.h" #include "macro.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "path-util.h" #include "special.h" #include "specifier.h" @@ -63,7 +63,7 @@ int generator_add_symlink(const char *dir, const char *dst, const char *dep_type from = path_is_absolute(src) ? src : strjoina("../", src); to = strjoina(dir, "/", dst, ".", dep_type, "/", basename(src)); - mkdir_parents_label(to, 0755); + (void) mkdir_parents_label(to, 0755); if (symlink(from, to) < 0) if (errno != EEXIST) return log_error_errno(errno, "Failed to create symlink \"%s\": %m", to); diff --git a/src/shared/hwdb-util.c b/src/shared/hwdb-util.c index d7626aed95..a7929bccb0 100644 --- a/src/shared/hwdb-util.c +++ b/src/shared/hwdb-util.c @@ -12,7 +12,7 @@ #include "hwdb-internal.h" #include "hwdb-util.h" #include "label.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "nulstr-util.h" #include "path-util.h" #include "sort-util.h" diff --git a/src/shared/install.c b/src/shared/install.c index 268cbd9602..6e77a72bde 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -26,7 +26,7 @@ #include "locale-util.h" #include "log.h" #include "macro.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "path-lookup.h" #include "path-util.h" #include "rm-rf.h" @@ -461,7 +461,7 @@ static int create_symlink( * the right place, or negative on error. */ - mkdir_parents_label(new_path, 0755); + (void) mkdir_parents_label(new_path, 0755); if (symlink(old_path, new_path) >= 0) { unit_file_changes_add(changes, n_changes, UNIT_FILE_SYMLINK, new_path, old_path); diff --git a/src/shared/label.h b/src/shared/label.h index b198e140d0..ec5160284d 100644 --- a/src/shared/label.h +++ b/src/shared/label.h @@ -15,12 +15,6 @@ static inline int label_fix(const char *path, LabelFixFlags flags) { return label_fix_container(path, path, flags); } -int mkdirat_label(int dirfd, const char *path, mode_t mode); - -static inline int mkdir_label(const char *path, mode_t mode) { - return mkdirat_label(AT_FDCWD, path, mode); -} - int symlink_label(const char *old_path, const char *new_path); int symlink_atomic_label(const char *from, const char *to); int mknod_label(const char *pathname, mode_t mode, dev_t dev); diff --git a/src/shared/meson.build b/src/shared/meson.build index 1fd1d711b0..00485e6543 100644 --- a/src/shared/meson.build +++ b/src/shared/meson.build @@ -209,6 +209,7 @@ shared_sources = files(''' macvlan-util.h main-func.h mkdir-label.c + mkdir-label.h mkfs-util.c mkfs-util.h module-util.h diff --git a/src/shared/mkdir-label.c b/src/shared/mkdir-label.c index 3c332d1007..d36a6466d7 100644 --- a/src/shared/mkdir-label.c +++ b/src/shared/mkdir-label.c @@ -1,13 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include <stdio.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <unistd.h> - -#include "label.h" -#include "macro.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "selinux-util.h" #include "smack-util.h" #include "user-util.h" diff --git a/src/shared/mkdir-label.h b/src/shared/mkdir-label.h new file mode 100644 index 0000000000..0b1a3894bd --- /dev/null +++ b/src/shared/mkdir-label.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once + +#include <fcntl.h> +#include <sys/types.h> + +#include "mkdir.h" + +int mkdirat_label(int dirfd, const char *path, mode_t mode); + +static inline int mkdir_label(const char *path, mode_t mode) { + return mkdirat_label(AT_FDCWD, path, mode); +} + +int mkdir_safe_label(const char *path, mode_t mode, uid_t uid, gid_t gid, MkdirFlags flags); +int mkdir_parents_label(const char *path, mode_t mod); +int mkdir_p_label(const char *path, mode_t mode); diff --git a/src/shared/mount-setup.c b/src/shared/mount-setup.c index da6bf27426..7917968497 100644 --- a/src/shared/mount-setup.c +++ b/src/shared/mount-setup.c @@ -20,7 +20,7 @@ #include "label.h" #include "log.h" #include "macro.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "mount-setup.h" #include "mount-util.h" #include "mountpoint-util.h" diff --git a/src/shared/mount-util.c b/src/shared/mount-util.c index fcc900bdce..8d4a6cd25a 100644 --- a/src/shared/mount-util.c +++ b/src/shared/mount-util.c @@ -22,7 +22,7 @@ #include "libmount-util.h" #include "missing_mount.h" #include "missing_syscall.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "mount-util.h" #include "mountpoint-util.h" #include "namespace-util.h" diff --git a/src/shared/socket-label.c b/src/shared/socket-label.c index 1669dec50e..8094ad7643 100644 --- a/src/shared/socket-label.c +++ b/src/shared/socket-label.c @@ -14,7 +14,7 @@ #include "log.h" #include "macro.h" #include "missing_socket.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "selinux-util.h" #include "socket-util.h" #include "umask-util.h" diff --git a/src/shared/switch-root.c b/src/shared/switch-root.c index 7edb9d7ff2..99cd574197 100644 --- a/src/shared/switch-root.c +++ b/src/shared/switch-root.c @@ -13,7 +13,7 @@ #include "fd-util.h" #include "log.h" #include "missing_syscall.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "mount-util.h" #include "mountpoint-util.h" #include "path-util.h" diff --git a/src/systemctl/systemctl-edit.c b/src/systemctl/systemctl-edit.c index 2503bddb96..b59a67ac22 100644 --- a/src/systemctl/systemctl-edit.c +++ b/src/systemctl/systemctl-edit.c @@ -5,7 +5,7 @@ #include "fd-util.h" #include "fileio.h" #include "fs-util.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "pager.h" #include "path-util.h" #include "pretty-print.h" diff --git a/src/test/test-udev.c b/src/test/test-udev.c index 1a113a94c3..c0e779a813 100644 --- a/src/test/test-udev.c +++ b/src/test/test-udev.c @@ -15,7 +15,7 @@ #include "fs-util.h" #include "log.h" #include "main-func.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "mount-util.h" #include "namespace-util.h" #include "selinux-util.h" diff --git a/src/timesync/timesyncd.c b/src/timesync/timesyncd.c index 94e99b42de..6f316746f5 100644 --- a/src/timesync/timesyncd.c +++ b/src/timesync/timesyncd.c @@ -12,7 +12,7 @@ #include "fd-util.h" #include "fs-util.h" #include "main-func.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "network-util.h" #include "process-util.h" #include "signal-util.h" diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index d6206ffd6a..4f1ce1f73f 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -42,7 +42,7 @@ #include "main-func.h" #include "missing_stat.h" #include "missing_syscall.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "mount-util.h" #include "mountpoint-util.h" #include "offline-passwd.h" diff --git a/src/tty-ask-password-agent/tty-ask-password-agent.c b/src/tty-ask-password-agent/tty-ask-password-agent.c index 37cfd8bb72..56110ba375 100644 --- a/src/tty-ask-password-agent/tty-ask-password-agent.c +++ b/src/tty-ask-password-agent/tty-ask-password-agent.c @@ -30,7 +30,7 @@ #include "macro.h" #include "main-func.h" #include "memory-util.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "path-util.h" #include "pretty-print.h" #include "process-util.h" diff --git a/src/udev/udev-node.c b/src/udev/udev-node.c index 809db14e60..760c3a4448 100644 --- a/src/udev/udev-node.c +++ b/src/udev/udev-node.c @@ -17,7 +17,7 @@ #include "format-util.h" #include "fs-util.h" #include "hexdecoct.h" -#include "mkdir.h" +#include "mkdir-label.h" #include "parse-util.h" #include "path-util.h" #include "random-util.h" |