diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2000-01-03 22:05:55 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2000-01-03 22:05:55 +0000 |
commit | 02551f7a49a08155ef60e15220eca099a8e0a6d2 (patch) | |
tree | 220c6d4730fdc220fe0b2b00b521d05d506cc2be | |
parent | f852901877b536d72fa1b7f448df92728896855e (diff) |
When a mode is specified via the -m flag, don't allow the umask
to modify the mode.
-rw-r--r-- | sbin/mknod/mknod.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/sbin/mknod/mknod.c b/sbin/mknod/mknod.c index bf8ac60a0f1..19e8ed89b7e 100644 --- a/sbin/mknod/mknod.c +++ b/sbin/mknod/mknod.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mknod.c,v 1.6 1999/04/18 19:40:41 millert Exp $ */ +/* $OpenBSD: mknod.c,v 1.7 2000/01/03 22:05:54 millert Exp $ */ /* $NetBSD: mknod.c,v 1.8 1995/08/11 00:08:18 jtc Exp $ */ /* @@ -47,7 +47,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)mknod.c 8.1 (Berkeley) 6/5/93"; #else -static char rcsid[] = "$OpenBSD: mknod.c,v 1.6 1999/04/18 19:40:41 millert Exp $"; +static char rcsid[] = "$OpenBSD: mknod.c,v 1.7 2000/01/03 22:05:54 millert Exp $"; #endif #endif /* not lint */ @@ -93,7 +93,7 @@ main(argc, argv) * interpreted relative to an assumed initial mode of * a=rw. */ - mode = getmode (set, 0666); + mode = getmode (set, DEFFILEMODE); free(set); break; case '?': @@ -116,10 +116,17 @@ main(argc, argv) } } - /* The default mode is the value of the bitwise inclusive or of - S_IRUSR, S_IWUSR, S_IRGRP, S_IWGRP, S_IROTH, and S_IWOTH */ - if (!set) - mode = 0666; + /* + * If the user specified a mode via `-m', don't allow the umask + * to modified it. If no `-m' flag was specified, the default + * mode is the value of the bitwise inclusive or of S_IRUSR, + * S_IWUSR, S_IRGRP, S_IWGRP, S_IROTH, and S_IWOTH as modified by + * the umask. + */ + if (set) + (void)umask(0); + else + mode = DEFFILEMODE; if (ismkfifo) exit(domkfifo(argc, argv, mode)); |