summaryrefslogtreecommitdiff
path: root/src/shared/mkdir-label.c
diff options
context:
space:
mode:
authorWaLyong Cho <walyong.cho@samsung.com>2014-10-23 17:23:45 +0900
committerLennart Poettering <lennart@poettering.net>2014-10-23 17:10:05 +0200
commit66b6d9d5b5b13a97c9f275aed0d9fe5608495be9 (patch)
tree209b0f3122dffa9c8985aa4e2ed1c45d83bb6849 /src/shared/mkdir-label.c
parent99a1ab10b05251220ff94a867f198b9302afe346 (diff)
label: rearrange mandatory access control(MAC) apis
move label apis to selinux-util.ch or smack-util.ch appropriately.
Diffstat (limited to 'src/shared/mkdir-label.c')
-rw-r--r--src/shared/mkdir-label.c26
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);
}