From: millert Date: Fri, 7 Mar 1997 02:15:18 +0000 (+0000) Subject: From NetBSD (christos) [fixed typo introduced in comment]: X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=b77d6fc782a099cca49c4e6fc8fb38dfd910e951;p=openbsd 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. --- 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 @@ -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