summaryrefslogtreecommitdiff
path: root/sbin/mknod
diff options
context:
space:
mode:
authornatano <natano@cvs.openbsd.org>2016-03-04 16:48:14 +0000
committernatano <natano@cvs.openbsd.org>2016-03-04 16:48:14 +0000
commita52a1211354d427f7b4bf634b7c81f4ebe7863f5 (patch)
tree6a7f8eefd23eb2aa5d177fa7e1969c701cefe8ce /sbin/mknod
parent9a9010afeddf5793ded8e993a3fdc321feb0104a (diff)
Invert the pledge() condition.
The only case where we don't want to pledge() is when a mode containing the suid, sgid or sticky is is passed on the command line. mknod() in a pledged binary would always strip those bits. discussion and ok espie@ ok deraadt@ semarie@ tb@
Diffstat (limited to 'sbin/mknod')
-rw-r--r--sbin/mknod/mknod.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/sbin/mknod/mknod.c b/sbin/mknod/mknod.c
index 24f16d07a0d..525e095751e 100644
--- a/sbin/mknod/mknod.c
+++ b/sbin/mknod/mknod.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mknod.c,v 1.19 2015/12/18 15:34:27 deraadt Exp $ */
+/* $OpenBSD: mknod.c,v 1.20 2016/03/04 16:48:13 natano Exp $ */
/* $NetBSD: mknod.c,v 1.8 1995/08/11 00:08:18 jtc Exp $ */
/*
@@ -53,7 +53,7 @@ main(int argc, char *argv[])
{
int ch, ismkfifo = 0;
void *set = NULL;
- mode_t mode = 0;
+ mode_t mode = DEFFILEMODE;
setlocale (LC_ALL, "");
@@ -83,7 +83,7 @@ main(int argc, char *argv[])
argc -= optind;
argv += optind;
- if (set)
+ if ((mode & ACCESSPERMS) == mode)
if (pledge("stdio rpath wpath cpath dpath fattr", NULL) == -1)
err(1, "pledge");
@@ -102,15 +102,13 @@ main(int argc, char *argv[])
/*
* If the user specified a mode via `-m', don't allow the umask
- * to modified it. If no `-m' flag was specified, the default
+ * to modify 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(argv, mode));