]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
39bdfa31 KS |
2 | /*** |
3 | This file is part of systemd. | |
4 | ||
5 | Copyright 2010 Lennart Poettering | |
6 | Copyright 2013 Kay Sievers | |
39bdfa31 KS |
7 | ***/ |
8 | ||
39bdfa31 | 9 | #include <stdio.h> |
785dde09 | 10 | #include <sys/stat.h> |
11c3a366 | 11 | #include <sys/types.h> |
cf0fbc49 | 12 | #include <unistd.h> |
39bdfa31 KS |
13 | |
14 | #include "label.h" | |
785dde09 | 15 | #include "macro.h" |
39bdfa31 | 16 | #include "mkdir.h" |
785dde09 ZJS |
17 | #include "selinux-util.h" |
18 | #include "smack-util.h" | |
19 | ||
20 | int mkdir_label(const char *path, mode_t mode) { | |
21 | int r; | |
22 | ||
23 | assert(path); | |
24 | ||
25 | r = mac_selinux_create_file_prepare(path, S_IFDIR); | |
26 | if (r < 0) | |
27 | return r; | |
28 | ||
29 | r = mkdir_errno_wrapper(path, mode); | |
30 | mac_selinux_create_file_clear(); | |
31 | if (r < 0) | |
32 | return r; | |
33 | ||
08c84981 | 34 | return mac_smack_fix(path, 0); |
785dde09 | 35 | } |
39bdfa31 | 36 | |
d50b5839 ZJS |
37 | int mkdir_safe_label(const char *path, mode_t mode, uid_t uid, gid_t gid, MkdirFlags flags) { |
38 | return mkdir_safe_internal(path, mode, uid, gid, flags, mkdir_label); | |
39bdfa31 KS |
39 | } |
40 | ||
41 | int mkdir_parents_label(const char *path, mode_t mode) { | |
c34255bd | 42 | return mkdir_parents_internal(NULL, path, mode, mkdir_label); |
39bdfa31 KS |
43 | } |
44 | ||
39bdfa31 | 45 | int mkdir_p_label(const char *path, mode_t mode) { |
c34255bd | 46 | return mkdir_p_internal(NULL, path, mode, mkdir_label); |
39bdfa31 | 47 | } |