From: Todd C. Miller Date: Mon, 29 Apr 1996 02:38:36 +0000 (+0000) Subject: now fixes mode on sudoers if set to 0400 to aid in upgrade X-Git-Tag: SUDO_1_5_0~199 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=afe3f2749a3549fb73a1846972e4c0e8421f9e59;p=sudo now fixes mode on sudoers if set to 0400 to aid in upgrade --- diff --git a/sudo.c b/sudo.c index 4ca65feae..a5ab643b9 100644 --- a/sudo.c +++ b/sudo.c @@ -717,8 +717,20 @@ static int check_sudoers() 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) - rtn = SUDOERS_WRONG_MODE; + 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); + } else { + fprintf(stderr, "%s: Unable to fix mode on %s: ", Argv[0], + _PATH_SUDO_SUDOERS); + perror(""); + } + } else { + rtn = SUDOERS_WRONG_MODE; + } + } (void) close(fd);