From c25ff2dde84d2af5744a1dc7d0dbd2c14cbaae62 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Mon, 6 Jan 2020 12:48:28 -0600 Subject: SebiderSushi reported that chmod g+s wasn't working. --- lib/lib.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/lib.c b/lib/lib.c index 26ba546f..b14e2e9f 100644 --- a/lib/lib.c +++ b/lib/lib.c @@ -922,12 +922,12 @@ mode_t string_to_mode(char *modestr, mode_t mode) // If who isn't specified, like "a" but honoring umask. if (!dowho) { dowho = 8; - umask(amask=umask(0)); + umask(amask = umask(0)); } + if (!*str || !(s = strchr(hows, *str))) goto barf; - dohow = *(str++); + if (!(dohow = *(str++))) goto barf; - if (!dohow) goto barf; while (*str && (s = strchr(whats, *str))) { dowhat |= 1<<(s-whats); str++; @@ -945,7 +945,7 @@ mode_t string_to_mode(char *modestr, mode_t mode) // Are we ready to do a thing yet? if (*str && *(str++) != ',') goto barf; - // Ok, apply the bits to the mode. + // Loop through what=xwrs and who=ogu to apply bits to the mode. for (i=0; i<4; i++) { for (j=0; j<3; j++) { mode_t bit = 0; @@ -955,13 +955,12 @@ mode_t string_to_mode(char *modestr, mode_t mode) // Figure out new value at this location if (i == 3) { - // suid/sticky bit. - if (j) { - if ((dowhat & 8) && (dowho&(8|(1<