diff options
author | Rob Landley <rob@landley.net> | 2015-05-19 23:29:18 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2015-05-19 23:29:18 -0500 |
commit | 9720e4dbc9f65c1ebead58ea5e03c552a37e4113 (patch) | |
tree | f5a1ddd3bcf0e42af3f2be1ef97fabb8252ecdf8 /toys/posix | |
parent | b031a3bc269e9cdb7bf307a757896b6ec7c4b3fe (diff) | |
download | toybox-9720e4dbc9f65c1ebead58ea5e03c552a37e4113.tar.gz |
Add -Z support to mkdir, based on a patch from Jose Bollo.
I have no idea why -Z isn't showing up in mkdir --help when enabled, I
need to look at that...
Diffstat (limited to 'toys/posix')
-rw-r--r-- | toys/posix/mkdir.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/toys/posix/mkdir.c b/toys/posix/mkdir.c index 739f961b..df6bacbc 100644 --- a/toys/posix/mkdir.c +++ b/toys/posix/mkdir.c @@ -4,7 +4,7 @@ * * See http://opengroup.org/onlinepubs/9699919799/utilities/mkdir.html -USE_MKDIR(NEWTOY(mkdir, "<1vpm:", TOYFLAG_BIN|TOYFLAG_UMASK)) +USE_MKDIR(NEWTOY(mkdir, "<1"USE_MKDIR_Z("Z")"vpm:", TOYFLAG_BIN|TOYFLAG_UMASK)) config MKDIR bool "mkdir" @@ -17,6 +17,15 @@ config MKDIR -m set permissions of directory to mode. -p make parent directories as needed. -v verbose + +config MKDIR_Z + bool + default y + depends on MKDIR && !TOYBOX_LSM_NONE + help + usage: [-Z context] + + -Z set security context */ #define FOR_mkdir @@ -24,6 +33,7 @@ config MKDIR GLOBALS( char *arg_mode; + char *arg_context; ) void mkdir_main(void) @@ -36,7 +46,14 @@ void mkdir_main(void) // Note, -p and -v flags line up with mkpathat() flags - for (s=toys.optargs; *s; s++) + for (s=toys.optargs; *s; s++) { if (mkpathat(AT_FDCWD, *s, mode, toys.optflags|1)) perror_msg("'%s'", *s); + else if (CFG_MKDIR_Z && (toys.optflags & FLAG_Z)) { + if (lsm_set_context(*s, TT.arg_context)) { + rmdir(*s); + error_msg("'%s': bad -Z '%s'", *s, TT.arg_context); + } + } + } } |