struct stat sb;
int error;
- if ((yyin = fopen(sudoers_path, "r")) == NULL) {
+ if (strcmp(sudoers_path, "-") == 0) {
+ yyin = stdin;
+ sudoers_path = "stdin";
+ } else if ((yyin = fopen(sudoers_path, "r")) == NULL) {
if (!quiet)
warning("unable to open %s", sudoers_path);
exit(1);
}
/* Check mode and owner in strict mode. */
#ifdef HAVE_FSTAT
- if (strict && fstat(fileno(yyin), &sb) == 0)
+ if (strict && yyin != stdin && fstat(fileno(yyin), &sb) == 0)
#else
- if (strict && stat(sudoers_path, &sb) == 0)
+ if (strict && yyin != stdin && stat(sudoers_path, &sb) == 0)
#endif
{
if (sb.st_uid != SUDOERS_UID || sb.st_gid != SUDOERS_GID) {
B<visudo> will edit (or check) the I<sudoers> file of your choice,
instead of the default, F<@sysconfdir@/sudoers>. The lock file used
is the specified I<sudoers> file with ".tmp" appended to it.
+In B<check-only> mode only, the argument to B<-f> may be "-",
+indicating that I<sudoers> will be read from the standard input.
=item -q