diff options
author | Rob Landley <rob@landley.net> | 2015-05-28 01:43:47 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2015-05-28 01:43:47 -0500 |
commit | 2d66e6a23822a500ecf6610411941e99127129c8 (patch) | |
tree | a1742937f24691332b05ad2100cb2a816d575b8f /toys/posix | |
parent | a65a7f4241f1cc9b4963a285e3a2137cffae62ad (diff) | |
download | toybox-2d66e6a23822a500ecf6610411941e99127129c8.tar.gz toybox-2d66e6a23822a500ecf6610411941e99127129c8.tar.bz2 toybox-2d66e6a23822a500ecf6610411941e99127129c8.zip |
Attempt to fix the mkdir LSM race.
Doing a world writeable mkdir and _then_ adding a label seems like a race
window, so set the global "create stuff with these labels" context, then
do the creates.
Diffstat (limited to 'toys/posix')
-rw-r--r-- | toys/posix/mkdir.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/toys/posix/mkdir.c b/toys/posix/mkdir.c index 6e95e54..438e38e 100644 --- a/toys/posix/mkdir.c +++ b/toys/posix/mkdir.c @@ -41,19 +41,15 @@ void mkdir_main(void) char **s; mode_t mode = (0777&~toys.old_umask); + if (CFG_MKDIR_Z && (toys.optflags&FLAG_Z)) + if (0>lsm_set_create(TT.arg_context)) + error_exit("bad -Z '%s'", TT.arg_context); if (TT.arg_mode) mode = string_to_mode(TT.arg_mode, 0777); // Note, -p and -v flags line up with mkpathat() flags - 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); - } - } } } |