+/* $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.
*/
#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>
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) {
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;
}
/*
* 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