From: Todd C. Miller Date: Thu, 9 Sep 2010 21:09:54 +0000 (-0400) Subject: Make "visudo -c -f -" check the standard input. X-Git-Tag: SUDO_1_7_5~166 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fca5753cf90b9b53420cd33c0d35b4e18b6e9401;p=sudo Make "visudo -c -f -" check the standard input. --HG-- branch : 1.7 --- diff --git a/visudo.c b/visudo.c index e2ca61a11..c320602cb 100644 --- a/visudo.c +++ b/visudo.c @@ -694,7 +694,10 @@ check_syntax(sudoers_path, quiet, strict) 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); @@ -724,9 +727,9 @@ check_syntax(sudoers_path, quiet, strict) } /* 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) { diff --git a/visudo.pod b/visudo.pod index ccc5c00b2..55e0c7c06 100644 --- a/visudo.pod +++ b/visudo.pod @@ -82,6 +82,8 @@ Specify and alternate I file location. With this option B will edit (or check) the I file of your choice, instead of the default, F<@sysconfdir@/sudoers>. The lock file used is the specified I file with ".tmp" appended to it. +In B mode only, the argument to B<-f> may be "-", +indicating that I will be read from the standard input. =item -q