Don't try to read from a zero-length sudoers file. Remove the bogus
Solaris work-around for EAGAIN. Since we now use fgetc() it should not be a problem.
This commit is contained in:
29
sudo.c
29
sudo.c
@@ -1030,7 +1030,7 @@ open_sudoers(sudoers, keepopen)
|
|||||||
{
|
{
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
int rootstat, i;
|
int rootstat;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fix the mode and group on sudoers file from old default.
|
* Fix the mode and group on sudoers file from old default.
|
||||||
@@ -1075,25 +1075,18 @@ open_sudoers(sudoers, keepopen)
|
|||||||
else if (statbuf.st_gid != SUDOERS_GID)
|
else if (statbuf.st_gid != SUDOERS_GID)
|
||||||
log_error(NO_EXIT, "%s is owned by gid %lu, should be %lu", sudoers,
|
log_error(NO_EXIT, "%s is owned by gid %lu, should be %lu", sudoers,
|
||||||
(unsigned long) statbuf.st_gid, (unsigned long) SUDOERS_GID);
|
(unsigned long) statbuf.st_gid, (unsigned long) SUDOERS_GID);
|
||||||
else {
|
else if ((fp = fopen(sudoers, "r")) == NULL)
|
||||||
/* Solaris sometimes returns EAGAIN so try 10 times */
|
log_error(USE_ERRNO, "can't open %s", sudoers);
|
||||||
for (i = 0; i < 10 ; i++) {
|
else if (statbuf.st_size != 0) {
|
||||||
errno = 0;
|
/*
|
||||||
if ((fp = fopen(sudoers, "r")) == NULL || fgetc(fp) == EOF) {
|
* Make sure we can actually read sudoers so we can present the
|
||||||
if (fp != NULL)
|
* user with a reasonable error message.
|
||||||
fclose(fp);
|
*/
|
||||||
fp = NULL;
|
if (fgetc(fp) == EOF)
|
||||||
if (errno != EAGAIN && errno != EWOULDBLOCK)
|
log_error(USE_ERRNO, "can't read %s", sudoers);
|
||||||
break;
|
|
||||||
} else
|
|
||||||
break;
|
|
||||||
sleep(1);
|
|
||||||
}
|
|
||||||
if (fp == NULL)
|
|
||||||
log_error(USE_ERRNO, "can't open %s", sudoers);
|
|
||||||
rewind(fp);
|
rewind(fp);
|
||||||
(void) fcntl(fileno(fp), F_SETFD, 1);
|
|
||||||
}
|
}
|
||||||
|
(void) fcntl(fileno(fp), F_SETFD, 1);
|
||||||
|
|
||||||
set_perms(PERM_ROOT); /* change back to root */
|
set_perms(PERM_ROOT); /* change back to root */
|
||||||
return(fp);
|
return(fp);
|
||||||
|
Reference in New Issue
Block a user