diff options
Diffstat (limited to 'src/shared/mkdir-label.c')
-rw-r--r-- | src/shared/mkdir-label.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/shared/mkdir-label.c b/src/shared/mkdir-label.c index df501046dd..2fdcae4127 100644 --- a/src/shared/mkdir-label.c +++ b/src/shared/mkdir-label.c @@ -30,6 +30,32 @@ #include "path-util.h" #include "mkdir.h" +static int label_mkdir(const char *path, mode_t mode) { + int r; + + if (use_selinux()) { + r = label_mkdir_selinux(path, mode); + if (r < 0) + return r; + } + + if (use_smack()) { + r = mkdir(path, mode); + if (r < 0 && errno != EEXIST) + return -errno; + + r = smack_relabel_in_dev(path); + if (r < 0) + return r; + } + + r = mkdir(path, mode); + if (r < 0 && errno != EEXIST) + return -errno; + + return 0; +} + int mkdir_parents_label(const char *path, mode_t mode) { return mkdir_parents_internal(NULL, path, mode, label_mkdir); } |