diff options
author | 2000-02-02 05:09:01 +0000 | |
---|---|---|
committer | 2000-02-02 05:09:01 +0000 | |
commit | d34117cc81ac4a8d2654c2a99ec6d05a7032a627 (patch) | |
tree | e2c3a9952d65db8776ba4e4d0e8b4b67cf081a33 | |
parent | o Don't call nfs_sillyrename() form nfs_remove if v_type == VDIR (diff) | |
download | wireguard-openbsd-d34117cc81ac4a8d2654c2a99ec6d05a7032a627.tar.xz wireguard-openbsd-d34117cc81ac4a8d2654c2a99ec6d05a7032a627.zip |
Make mkdir -m 1777 foo and the like work. From how Netbsd/Freebsd do it.
-rw-r--r-- | bin/mkdir/mkdir.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/bin/mkdir/mkdir.c b/bin/mkdir/mkdir.c index 01d0cbc4e31..83c200fdef3 100644 --- a/bin/mkdir/mkdir.c +++ b/bin/mkdir/mkdir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkdir.c,v 1.8 1998/09/26 09:04:43 deraadt Exp $ */ +/* $OpenBSD: mkdir.c,v 1.9 2000/02/02 05:09:01 ericj Exp $ */ /* $NetBSD: mkdir.c,v 1.14 1995/06/25 21:59:21 mycroft Exp $ */ /* @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)mkdir.c 8.2 (Berkeley) 1/25/94"; #else -static char rcsid[] = "$OpenBSD: mkdir.c,v 1.8 1998/09/26 09:04:43 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: mkdir.c,v 1.9 2000/02/02 05:09:01 ericj Exp $"; #endif #endif /* not lint */ @@ -118,7 +118,19 @@ main(argc, argv) if (mkdir(*argv, mode) < 0) { warn("%s", *argv); exitval = 1; - } + } else { + /* + * 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. Don't do + * this unless the user has specifically requested a mode + * as chmod will (obviously) ignore the umask. + */ + if (mode > 0777 && chmod(*argv, mode) == -1) { + warn("%s", *argv); + exitval = 1; + } + } } } exit(exitval); |