summaryrefslogtreecommitdiffstats
path: root/bin/mkdir/mkdir.c
diff options
context:
space:
mode:
authormsmith <msmith@FreeBSD.org>1998-10-20 06:37:01 +0000
committermsmith <msmith@FreeBSD.org>1998-10-20 06:37:01 +0000
commitd58bc5bf6e146c4472d6ebf854549c9f78a3ed65 (patch)
tree94d6fc43ae6f4a8c25a87d42eff9de21cbb7e8cf /bin/mkdir/mkdir.c
parent0dac499ae3061d10a40e480f31d75789c090c6a3 (diff)
downloadFreeBSD-src-d58bc5bf6e146c4472d6ebf854549c9f78a3ed65.zip
FreeBSD-src-d58bc5bf6e146c4472d6ebf854549c9f78a3ed65.tar.gz
- mkdir -m should call chmod because the high-order bits get ignored
by the kernel as a security feature of some sort. Submitted by: Wilfredo Sanchez <wsanchez@apple.com>
Diffstat (limited to 'bin/mkdir/mkdir.c')
-rw-r--r--bin/mkdir/mkdir.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/bin/mkdir/mkdir.c b/bin/mkdir/mkdir.c
index ed26dc8..e11cfb0 100644
--- a/bin/mkdir/mkdir.c
+++ b/bin/mkdir/mkdir.c
@@ -42,7 +42,7 @@ static char const copyright[] =
static char sccsid[] = "@(#)mkdir.c 8.2 (Berkeley) 1/25/94";
#endif
static const char rcsid[] =
- "$Id$";
+ "$Id: mkdir.c,v 1.11 1998/05/15 06:23:45 charnier Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -105,6 +105,15 @@ main(argc, argv)
warn("%s", *argv);
exitval = 1;
}
+ /*
+ * The mkdir() and umask() calls both honor only the low
+ * nine bits, so if you try to set a mode including the
+ * sticky, setuid, setgid bits you lose them. So chmod().
+ */
+ if (chmod(*argv, mode) == -1) {
+ warn("%s", *argv);
+ exitval = 1;
+ }
}
exit(exitval);
}
@@ -160,6 +169,15 @@ build(path, omode)
retval = 1;
break;
}
+ /*
+ * The mkdir() and umask() calls both honor only the low
+ * nine bits, so if you try to set a mode including the
+ * sticky, setuid, setgid bits you lose them. So chmod().
+ */
+ if (chmod(*path, mode) == -1) {
+ warn("%s", *path);
+ exitval = 1;
+ }
}
else if ((sb.st_mode & S_IFMT) != S_IFDIR) {
if (last)
OpenPOWER on IntegriCloud