summaryrefslogtreecommitdiff
path: root/lib/libc/gen
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1997-03-07 02:15:19 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1997-03-07 02:15:19 +0000
commit0b7a08da3bb614e3c17853362d430f0265519262 (patch)
treebf051aed045682409e33da0d6e31bb4de7f9d257 /lib/libc/gen
parent2f2317f1cda67b49ffb5de6533ddd498634d4dee (diff)
From NetBSD (christos) [fixed typo introduced in comment]:
If ``who'' was not specified, set the appropriate bits as the manual page states. ``chmod +s foo'' and ``chmod +t dir'' now work.
Diffstat (limited to 'lib/libc/gen')
-rw-r--r--lib/libc/gen/setmode.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/lib/libc/gen/setmode.c b/lib/libc/gen/setmode.c
index 7a19512deda..bbf50532836 100644
--- a/lib/libc/gen/setmode.c
+++ b/lib/libc/gen/setmode.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: setmode.c,v 1.5 1997/03/07 02:15:18 millert Exp $ */
+/* $NetBSD: setmode.c,v 1.15 1997/02/07 22:21:06 christos Exp $ */
+
/*
* Copyright (c) 1989, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -35,7 +38,11 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: setmode.c,v 1.4 1996/08/19 08:25:55 tholo Exp $";
+#if 0
+static char sccsid[] = "@(#)setmode.c 8.2 (Berkeley) 3/25/94";
+#else
+static char rcsid[] = "$OpenBSD: setmode.c,v 1.5 1997/03/07 02:15:18 millert Exp $";
+#endif
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -87,10 +94,10 @@ getmode(bbox, omode)
mode_t omode;
#endif
{
- register BITCMD *set;
+ register const BITCMD *set;
register mode_t clrval, newmode, value;
- set = (BITCMD *)bbox;
+ set = (const BITCMD *)bbox;
newmode = omode;
for (value = 0;; set++)
switch(set->cmd) {
@@ -258,13 +265,19 @@ getop: if ((op = *p++) != '+' && op != '-' && op != '=') {
perm |= S_IRUSR|S_IRGRP|S_IROTH;
break;
case 's':
- /* If only "other" bits ignore set-id. */
- if (who & ~S_IRWXO)
+ /*
+ * If specific bits where requested and
+ * only "other" bits ignore set-id.
+ */
+ if (who == 0 || (who & ~S_IRWXO))
perm |= S_ISUID|S_ISGID;
break;
case 't':
- /* If only "other" bits ignore sticky. */
- if (who & ~S_IRWXO) {
+ /*
+ * If specific bits where requested and
+ * only "other" bits ignore sticky.
+ */
+ if (who == 0 || (who & ~S_IRWXO)) {
who |= S_ISTXT;
perm |= S_ISTXT;
}
@@ -403,7 +416,7 @@ dumpmode(set)
/*
* Given an array of bitcmd structures, compress by compacting consecutive
* '+', '-' and 'X' commands into at most 3 commands, one of each. The 'u',
- * 'g' and 'o' commands continue to be separate. They could probably be
+ * 'g' and 'o' commands continue to be separate. They could probably be
* compacted, but it's not worth the effort.
*/
static void