=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/sudo/Attic/sudo.c,v retrieving revision 1.39 retrieving revision 1.40 diff -c -r1.39 -r1.40 *** src/usr.bin/sudo/Attic/sudo.c 2009/06/21 14:48:42 1.39 --- src/usr.bin/sudo/Attic/sudo.c 2009/12/07 18:43:10 1.40 *************** *** 648,654 **** } } ! if ((p = ttyname(STDIN_FILENO)) || (p = ttyname(STDOUT_FILENO))) { user_tty = user_ttypath = estrdup(p); if (strncmp(user_tty, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0) user_tty += sizeof(_PATH_DEV) - 1; --- 648,655 ---- } } ! if ((p = ttyname(STDIN_FILENO)) || (p = ttyname(STDOUT_FILENO)) || ! (p = ttyname(STDERR_FILENO))) { user_tty = user_ttypath = estrdup(p); if (strncmp(user_tty, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0) user_tty += sizeof(_PATH_DEV) - 1; *************** *** 1139,1155 **** log_error(NO_EXIT, "%s is owned by gid %lu, should be %lu", sudoers, (unsigned long) statbuf.st_gid, (unsigned long) SUDOERS_GID); else if ((fp = fopen(sudoers, "r")) == NULL) ! log_error(USE_ERRNO, "can't open %s", sudoers); else { /* * Make sure we can actually read sudoers so we can present the * user with a reasonable error message (unlike the lexer). */ ! if (statbuf.st_size != 0) { ! if (fgetc(fp) == EOF) ! log_error(USE_ERRNO, "can't read %s", sudoers); ! rewind(fp); } (void) fcntl(fileno(fp), F_SETFD, 1); } --- 1140,1160 ---- log_error(NO_EXIT, "%s is owned by gid %lu, should be %lu", sudoers, (unsigned long) statbuf.st_gid, (unsigned long) SUDOERS_GID); else if ((fp = fopen(sudoers, "r")) == NULL) ! log_error(USE_ERRNO|NO_EXIT, "can't open %s", sudoers); else { /* * Make sure we can actually read sudoers so we can present the * user with a reasonable error message (unlike the lexer). */ ! if (statbuf.st_size != 0 && fgetc(fp) == EOF) { ! log_error(USE_ERRNO|NO_EXIT, "can't read %s", sudoers); ! fclose(fp); ! fp = NULL; } + } + + if (fp != NULL) { + rewind(fp); (void) fcntl(fileno(fp), F_SETFD, 1); }