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 43ea2c25b7..c41045e5b5 100644 --- a/src/shared/mkdir-label.c +++ b/src/shared/mkdir-label.c @@ -32,6 +32,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_label(const char *path, mode_t mode) { return label_mkdir(path, mode); } |