summaryrefslogtreecommitdiff
path: root/src/shared/mkdir-label.c
diff options
context:
space:
mode:
authorWaLyong Cho <walyong.cho@samsung.com>2014-10-25 13:28:03 -0400
committerAnthony G. Basile <blueness@gentoo.org>2014-10-25 13:28:03 -0400
commit1b6c7e7255cf5d03d049f63dfdea24f6f64328d1 (patch)
tree610cdafe2c6e04fe7af8d8211d728d9ced85b98e /src/shared/mkdir-label.c
parenta79876e097b87ede8c75301a99e4cd964b83a933 (diff)
label: rearrange mandatory access control(MAC) apis
move label apis to selinux-util.ch or smack-util.ch appropriately. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
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 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);
}