diff options
author | Eric Jackson <ericj@cvs.openbsd.org> | 2000-02-02 05:09:02 +0000 |
---|---|---|
committer | Eric Jackson <ericj@cvs.openbsd.org> | 2000-02-02 05:09:02 +0000 |
commit | 6ead3373fdd3f136aefedec5ee2e05f125596a5a (patch) | |
tree | 8fa20678c87d722e58c72b0e8561c6c77a08b47f | |
parent | 17e4fae3fc7757341505ae85fde173cfd4116c61 (diff) |
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); |