From: Todd C. Miller Date: Tue, 28 May 1996 16:50:34 +0000 (+0000) Subject: now sets sudoers to correct group if mode is 0400 X-Git-Tag: SUDO_1_5_0~179 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=47f7ef9f3f7c68c0753fedae3094c56eb7278bac;p=sudo now sets sudoers to correct group if mode is 0400 --- diff --git a/sudo.c b/sudo.c index 9905141d9..c2492f75c 100644 --- a/sudo.c +++ b/sudo.c @@ -752,22 +752,32 @@ static int check_sudoers() rtn = NO_SUDOERS_FILE; else if (!S_ISREG(statbuf.st_mode)) rtn = SUDOERS_NOT_FILE; - else if (statbuf.st_uid != SUDOERS_UID || statbuf.st_gid != SUDOERS_GID) - rtn = SUDOERS_WRONG_OWNER; else if ((statbuf.st_mode & 0007777) != SUDOERS_MODE) { if ((statbuf.st_mode & 0007777) == 0400) { if (chmod(_PATH_SUDO_SUDOERS, SUDOERS_MODE) == 0) { - fprintf(stderr, "%s: fixed mode on %s\n", Argv[0], - _PATH_SUDO_SUDOERS); + (void) fprintf(stderr, "%s: fixed mode on %s\n", + Argv[0], _PATH_SUDO_SUDOERS); + if (statbuf.st_gid != SUDOERS_GID) { + if (!chown(_PATH_SUDO_SUDOERS,GID_NO_CHANGE,SUDOERS_GID)) { + (void) fprintf(stderr, "%s: set group on %s\n", + Argv[0], _PATH_SUDO_SUDOERS); + statbuf.st_gid = SUDOERS_GID; + } else { + (void) fprintf(stderr,"%s: Unable to set group on %s: ", + Argv[0], _PATH_SUDO_SUDOERS); + perror(""); + } + } } else { - fprintf(stderr, "%s: Unable to fix mode on %s: ", Argv[0], - _PATH_SUDO_SUDOERS); + (void) fprintf(stderr, "%s: Unable to fix mode on %s: ", + Argv[0], _PATH_SUDO_SUDOERS); perror(""); } } else { rtn = SUDOERS_WRONG_MODE; } - } + } else if (statbuf.st_uid != SUDOERS_UID || statbuf.st_gid != SUDOERS_GID) + rtn = SUDOERS_WRONG_OWNER; if (fd != -1) (void) close(fd);