hopefully last one; more corner cases. Thanks to Mark Weaver for

inspiration, for demanding that i put one of these fixes in, and
for double-checking.
This commit is contained in:
cgd 1994-02-11 05:55:45 +00:00
parent a082d3d959
commit f70e42e2ee
1 changed files with 18 additions and 8 deletions

View File

@ -33,7 +33,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)setmode.c 5.6 (Berkeley) 5/27/91";*/
static char *rcsid = "$Id: setmode.c,v 1.7 1994/02/10 23:42:09 cgd Exp $";
static char *rcsid = "$Id: setmode.c,v 1.8 1994/02/11 05:55:45 cgd Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@ -103,12 +103,17 @@ getmode(bbox, omode)
case 'o':
value = newmode & S_IRWXO;
common: if (set->cmd2 & CMD2_CLR) {
mode_t clrval;
clrval =
(set->cmd2 & CMD2_SET) ? S_IRWXO : value;
if (set->cmd2 & CMD2_UBITS)
newmode &= ~((value<<6) & set->bits);
newmode &= ~((clrval<<6) & set->bits);
if (set->cmd2 & CMD2_GBITS)
newmode &= ~((value<<3) & set->bits);
newmode &= ~((clrval<<3) & set->bits);
if (set->cmd2 & CMD2_OBITS)
newmode &= ~(value & set->bits);
newmode &= ~(clrval & set->bits);
}
if (set->cmd2 & CMD2_SET) {
if (set->cmd2 & CMD2_UBITS)
@ -276,11 +281,12 @@ getop: if ((op = *p++) != '+' && op != '-' && op != '=') {
* to flush out any partial mode that we have,
* and then do the copying of the mode bits.
*/
if (perm || (op == '=' && !equalopdone)) {
equalopdone = 1;
if (perm) {
ADDCMD(op, who, perm, mask);
perm = 0;
}
if (op == '=')
equalopdone = 1;
if (op == '+' && permXbits) {
ADDCMD('X', who, permXbits, mask);
permXbits = 0;
@ -294,7 +300,8 @@ getop: if ((op = *p++) != '+' && op != '-' && op != '=') {
* done.
*/
if (perm || (op == '=' && !equalopdone)) {
equalopdone = 1;
if (op == '=')
equalopdone = 1;
ADDCMD(op, who, perm, mask);
perm = 0;
}
@ -367,7 +374,10 @@ addcmd(set, op, who, oparg, mask)
set->bits = ~0;
} else {
set->cmd2 = CMD2_UBITS | CMD2_GBITS | CMD2_OBITS;
set->bits = mask;
if (oparg == '-')
set->bits = (S_IRWXU|S_IRWXG|S_IRWXO);
else
set->bits = mask;
}
if (oparg == '+')