aboutsummaryrefslogtreecommitdiff
path: root/coreutils/mkdir.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-03-10 16:58:49 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-03-10 16:58:49 +0000
commit49622d784672bf2f7b2fe80589714cdef5adde0c (patch)
tree892bb79b0ef031d729e688d6be4950f6d17f13b9 /coreutils/mkdir.c
parent4eb8b936cb0aeb27c3e12f9a93fc43aa1e9668f5 (diff)
downloadbusybox-w32-49622d784672bf2f7b2fe80589714cdef5adde0c.tar.gz
busybox-w32-49622d784672bf2f7b2fe80589714cdef5adde0c.tar.bz2
busybox-w32-49622d784672bf2f7b2fe80589714cdef5adde0c.zip
selinux support by Yuichi Nakamura <ynakam@hitachisoft.jp> (HitachiSoft)
Diffstat (limited to 'coreutils/mkdir.c')
-rw-r--r--coreutils/mkdir.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/coreutils/mkdir.c b/coreutils/mkdir.c
index 67819e784..93ded1dd5 100644
--- a/coreutils/mkdir.c
+++ b/coreutils/mkdir.c
@@ -16,6 +16,9 @@
16 * conjunction with -m. 16 * conjunction with -m.
17 */ 17 */
18 18
19/* Nov 28, 2006 Yoshinori Sato <ysato@users.sourceforge.jp>: Add SELinux Support.
20 */
21
19#include <stdlib.h> 22#include <stdlib.h>
20#include <unistd.h> 23#include <unistd.h>
21#include <getopt.h> /* struct option */ 24#include <getopt.h> /* struct option */
@@ -25,6 +28,9 @@
25static const struct option mkdir_long_options[] = { 28static const struct option mkdir_long_options[] = {
26 { "mode", 1, NULL, 'm' }, 29 { "mode", 1, NULL, 'm' },
27 { "parents", 0, NULL, 'p' }, 30 { "parents", 0, NULL, 'p' },
31#if ENABLE_SELINUX
32 { "context", 1, NULL, 'Z' },
33#endif
28 { 0, 0, 0, 0 } 34 { 0, 0, 0, 0 }
29}; 35};
30#endif 36#endif
@@ -37,11 +43,14 @@ int mkdir_main(int argc, char **argv)
37 int flags = 0; 43 int flags = 0;
38 unsigned opt; 44 unsigned opt;
39 char *smode; 45 char *smode;
46#if ENABLE_SELINUX
47 security_context_t scontext;
48#endif
40 49
41#if ENABLE_FEATURE_MKDIR_LONG_OPTIONS 50#if ENABLE_FEATURE_MKDIR_LONG_OPTIONS
42 applet_long_options = mkdir_long_options; 51 applet_long_options = mkdir_long_options;
43#endif 52#endif
44 opt = getopt32(argc, argv, "m:p", &smode); 53 opt = getopt32(argc, argv, "m:p" USE_SELINUX("Z:"), &smode USE_SELINUX(,&scontext));
45 if (opt & 1) { 54 if (opt & 1) {
46 mode = 0777; 55 mode = 0777;
47 if (!bb_parse_mode(smode, &mode)) { 56 if (!bb_parse_mode(smode, &mode)) {
@@ -50,6 +59,15 @@ int mkdir_main(int argc, char **argv)
50 } 59 }
51 if (opt & 2) 60 if (opt & 2)
52 flags |= FILEUTILS_RECUR; 61 flags |= FILEUTILS_RECUR;
62#if ENABLE_SELINUX
63 if (opt & 4) {
64 selinux_or_die();
65 if (setfscreatecon(scontext)) {
66 bb_error_msg_and_die("cannot set default file creation context "
67 "to %s", scontext);
68 }
69 }
70#endif
53 71
54 if (optind == argc) { 72 if (optind == argc) {
55 bb_show_usage(); 73 bb_show_usage();