]> granicus.if.org Git - sudo/commitdiff
Allow the sudoers file to be specified without the -f option.
authorTodd C. Miller <Todd.Miller@sudo.ws>
Mon, 24 Dec 2018 15:26:18 +0000 (08:26 -0700)
committerTodd C. Miller <Todd.Miller@sudo.ws>
Mon, 24 Dec 2018 15:26:18 +0000 (08:26 -0700)
Bug #864

doc/visudo.cat
doc/visudo.man.in
doc/visudo.mdoc.in
plugins/sudoers/visudo.c

index 1c5e10c70e20e7ee9a24af8b28b2cbfe130b0a64..ac5eca33ea9ffe1585ed3f9734db1dedd8458bbb 100644 (file)
@@ -4,7 +4,7 @@ N\bNA\bAM\bME\bE
      v\bvi\bis\bsu\bud\bdo\bo - edit the sudoers file
 
 S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
-     v\bvi\bis\bsu\bud\bdo\bo [-\b-c\bch\bhq\bqs\bsV\bV] [-\b-f\bf _\bs_\bu_\bd_\bo_\be_\br_\bs]
+     v\bvi\bis\bsu\bud\bdo\bo [-\b-c\bch\bhq\bqs\bsV\bV] [[-\b-f\bf] _\bs_\bu_\bd_\bo_\be_\br_\bs]
 
 D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
      v\bvi\bis\bsu\bud\bdo\bo edits the _\bs_\bu_\bd_\bo_\be_\br_\bs file in a safe fashion, analogous to vipw(1m).
@@ -58,8 +58,8 @@ D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
      -\b-c\bc, -\b--\b-c\bch\bhe\bec\bck\bk
                  Enable _\bc_\bh_\be_\bc_\bk_\b-_\bo_\bn_\bl_\by mode.  The existing _\bs_\bu_\bd_\bo_\be_\br_\bs file (and any
                  other files it includes) will be checked for syntax errors.
-                 If the -\b-f\bf option has not been specified, v\bvi\bis\bsu\bud\bdo\bo will also
-                 check the _\bs_\bu_\bd_\bo_\be_\br_\bs file owner and mode.  A message will be
+                 If the path to the _\bs_\bu_\bd_\bo_\be_\br_\bs file was not specified, v\bvi\bis\bsu\bud\bdo\bo
+                 will also check the file owner and mode.  A message will be
                  printed to the standard output describing the status of
                  _\bs_\bu_\bd_\bo_\be_\br_\bs unless the -\b-q\bq option was specified.  If the check
                  completes successfully, v\bvi\bis\bsu\bud\bdo\bo will exit with a value of 0.
@@ -67,15 +67,9 @@ D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
                  1.
 
      -\b-f\bf _\bs_\bu_\bd_\bo_\be_\br_\bs, -\b--\b-f\bfi\bil\ble\be=_\bs_\bu_\bd_\bo_\be_\br_\bs
-                 Specify an alternate _\bs_\bu_\bd_\bo_\be_\br_\bs file location.  With this
-                 option, v\bvi\bis\bsu\bud\bdo\bo will edit (or check) the _\bs_\bu_\bd_\bo_\be_\br_\bs file of your
-                 choice, instead of the default, _\b/_\be_\bt_\bc_\b/_\bs_\bu_\bd_\bo_\be_\br_\bs.  The lock file
-                 used is the specified _\bs_\bu_\bd_\bo_\be_\br_\bs file with ".tmp" appended to
-                 it.  In _\bc_\bh_\be_\bc_\bk_\b-_\bo_\bn_\bl_\by mode only, the argument to -\b-f\bf may be `-',
-                 indicating that _\bs_\bu_\bd_\bo_\be_\br_\bs will be read from the standard input.
-                 Because the policy is evaluated in its entirety, it is not
-                 sufficient to check an individual _\bs_\bu_\bd_\bo_\be_\br_\bs include file for
-                 syntax errors.
+                 Specify an alternate _\bs_\bu_\bd_\bo_\be_\br_\bs file location, see below.  As of
+                 version 1.8.27, the _\bs_\bu_\bd_\bo_\be_\br_\bs path can be specified without
+                 using the -\b-f\bf option.
 
      -\b-h\bh, -\b--\b-h\bhe\bel\blp\bp  Display a short help message to the standard output and exit.
 
@@ -95,6 +89,13 @@ D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
      -\b-V\bV, -\b--\b-v\bve\ber\brs\bsi\bio\bon\bn
                  Print the v\bvi\bis\bsu\bud\bdo\bo and _\bs_\bu_\bd_\bo_\be_\br_\bs grammar versions and exit.
 
+     A _\bs_\bu_\bd_\bo_\be_\br_\bs file may be specified instead of the default, _\b/_\be_\bt_\bc_\b/_\bs_\bu_\bd_\bo_\be_\br_\bs.
+     The lock file used is the specified _\bs_\bu_\bd_\bo_\be_\br_\bs file with ".tmp" appended to
+     it.  In _\bc_\bh_\be_\bc_\bk_\b-_\bo_\bn_\bl_\by mode only, `-' may be used to indicate that _\bs_\bu_\bd_\bo_\be_\br_\bs
+     will be read from the standard input.  Because the policy is evaluated in
+     its entirety, it is not sufficient to check an individual _\bs_\bu_\bd_\bo_\be_\br_\bs include
+     file for syntax errors.
+
    D\bDe\beb\bbu\bug\bgg\bgi\bin\bng\bg a\ban\bnd\bd s\bsu\bud\bdo\boe\ber\brs\bs p\bpl\blu\bug\bgi\bin\bn a\bar\brg\bgu\bum\bme\ben\bnt\bts\bs
      v\bvi\bis\bsu\bud\bdo\bo versions 1.8.4 and higher support a flexible debugging framework
      that is configured via Debug lines in the sudo.conf(4) file.
@@ -222,4 +223,4 @@ D\bDI\bIS\bSC\bCL\bLA\bAI\bIM\bME\bER\bR
      file distributed with s\bsu\bud\bdo\bo or https://www.sudo.ws/license.html for
      complete details.
 
-Sudo 1.8.26                     October 6, 2018                    Sudo 1.8.26
+Sudo 1.8.26                    December 24, 2018                   Sudo 1.8.26
index 79fe65c20d89a96332095ec3fefde4f6fb218380..9d6fc487761ccbf4268af3561f676786b4296e5e 100644 (file)
@@ -19,7 +19,7 @@
 .\" Agency (DARPA) and Air Force Research Laboratory, Air Force
 .\" Materiel Command, USAF, under agreement number F39502-99-1-0512.
 .\"
-.TH "VISUDO" "@mansectsu@" "October 6, 2018" "Sudo @PACKAGE_VERSION@" "System Manager's Manual"
+.TH "VISUDO" "@mansectsu@" "December 24, 2018" "Sudo @PACKAGE_VERSION@" "System Manager's Manual"
 .nh
 .if n .ad l
 .SH "NAME"
@@ -29,7 +29,7 @@
 .HP 7n
 \fBvisudo\fR
 [\fB\-chqsV\fR]
-[\fB\-f\fR\ \fIsudoers\fR]
+[[\fB\-f\fR]\ \fIsudoers\fR]
 .SH "DESCRIPTION"
 \fBvisudo\fR
 edits the
@@ -169,13 +169,11 @@ The existing
 \fIsudoers\fR
 file (and any other files it includes) will be
 checked for syntax errors.
-If the
-\fB\-f\fR
-option has not been specified,
-\fBvisudo\fR
-will also check the
+If the path to the
 \fIsudoers\fR
-file owner and mode.
+file was not specified,
+\fBvisudo\fR
+will also check the file owner and mode.
 A message will be printed to the standard output describing the status of
 \fIsudoers\fR
 unless the
@@ -191,32 +189,12 @@ will exit with a value of 1.
 \fB\-f\fR \fIsudoers\fR, \fB\--file\fR=\fIsudoers\fR
 Specify an alternate
 \fIsudoers\fR
-file location.
-With this option,
-\fBvisudo\fR
-will edit (or check) the
+file location, see below.
+As of version 1.8.27, the
 \fIsudoers\fR
-file of your choice,
-instead of the default,
-\fI@sysconfdir@/sudoers\fR.
-The lock file used is the specified
-\fIsudoers\fR
-file with
-\(lq\.tmp\(rq
-appended to it.
-In
-\fIcheck-only\fR
-mode only, the argument to
+path can be specified without using the
 \fB\-f\fR
-may be
-\(oq-\(cq,
-indicating that
-\fIsudoers\fR
-will be read from the standard input.
-Because the policy is evaluated in its entirety, it is not sufficient
-to check an individual
-\fIsudoers\fR
-include file for syntax errors.
+option.
 .TP 12n
 \fB\-h\fR, \fB\--help\fR
 Display a short help message to the standard output and exit.
@@ -253,6 +231,27 @@ Print the
 and
 \fIsudoers\fR
 grammar versions and exit.
+.PP
+A
+\fIsudoers\fR
+file may be specified instead of the default,
+\fI@sysconfdir@/sudoers\fR.
+The lock file used is the specified
+\fIsudoers\fR
+file with
+\(lq\.tmp\(rq
+appended to it.
+In
+\fIcheck-only\fR
+mode only,
+\(oq-\(cq
+may be used to indicate that
+\fIsudoers\fR
+will be read from the standard input.
+Because the policy is evaluated in its entirety, it is not sufficient
+to check an individual
+\fIsudoers\fR
+include file for syntax errors.
 .SS "Debugging and sudoers plugin arguments"
 \fBvisudo\fR
 versions 1.8.4 and higher support a flexible debugging framework
index 4551357e985cfd8fbccad48f78bdc5ea57f0a1ac..140d5d6f8a8b97d777e5fde8e4f12192e0e4be30 100644 (file)
@@ -18,7 +18,7 @@
 .\" Agency (DARPA) and Air Force Research Laboratory, Air Force
 .\" Materiel Command, USAF, under agreement number F39502-99-1-0512.
 .\"
-.Dd October 6, 2018
+.Dd December 24, 2018
 .Dt VISUDO @mansectsu@
 .Os Sudo @PACKAGE_VERSION@
 .Sh NAME
@@ -27,7 +27,7 @@
 .Sh SYNOPSIS
 .Nm visudo
 .Op Fl chqsV
-.Op Fl f Ar sudoers
+.Op Bo Fl f Bc Ar sudoers
 .Sh DESCRIPTION
 .Nm
 edits the
@@ -167,13 +167,11 @@ The existing
 .Em sudoers
 file (and any other files it includes) will be
 checked for syntax errors.
-If the
-.Fl f
-option has not been specified,
-.Nm
-will also check the
+If the path to the
 .Em sudoers
-file owner and mode.
+file was not specified,
+.Nm
+will also check the file owner and mode.
 A message will be printed to the standard output describing the status of
 .Em sudoers
 unless the
@@ -188,32 +186,12 @@ will exit with a value of 1.
 .It Fl f Ar sudoers , Fl -file Ns = Ns Ar sudoers
 Specify an alternate
 .Em sudoers
-file location.
-With this option,
-.Nm
-will edit (or check) the
+file location, see below.
+As of version 1.8.27, the
 .Em sudoers
-file of your choice,
-instead of the default,
-.Pa @sysconfdir@/sudoers .
-The lock file used is the specified
-.Em sudoers
-file with
-.Dq \.tmp
-appended to it.
-In
-.Em check-only
-mode only, the argument to
+path can be specified without using the
 .Fl f
-may be
-.Ql - ,
-indicating that
-.Em sudoers
-will be read from the standard input.
-Because the policy is evaluated in its entirety, it is not sufficient
-to check an individual
-.Em sudoers
-include file for syntax errors.
+option.
 .It Fl h , -help
 Display a short help message to the standard output and exit.
 .It Fl q , -quiet
@@ -247,6 +225,27 @@ and
 .Em sudoers
 grammar versions and exit.
 .El
+.Pp
+A
+.Em sudoers
+file may be specified instead of the default,
+.Pa @sysconfdir@/sudoers .
+The lock file used is the specified
+.Em sudoers
+file with
+.Dq \.tmp
+appended to it.
+In
+.Em check-only
+mode only,
+.Ql -
+may be used to indicate that
+.Em sudoers
+will be read from the standard input.
+Because the policy is evaluated in its entirety, it is not sufficient
+to check an individual
+.Em sudoers
+include file for syntax errors.
 .Ss Debugging and sudoers plugin arguments
 .Nm
 versions 1.8.4 and higher support a flexible debugging framework
index 5257a9b7d481a9c6c3d78b17e06524d299ac351e..50dda5980c9f82af2ca7e966a162ab0d1bc68208 100644 (file)
@@ -135,7 +135,7 @@ main(int argc, char *argv[])
     char *editor, **editor_argv;
     const char *export_path = NULL;
     int ch, oldlocale, editor_argc, exitcode = 0;
-    bool quiet, strict, oldperms;
+    bool quiet, strict, fflag;
     debug_decl(main, SUDOERS_DEBUG_MAIN)
 
 #if defined(SUDO_DEVEL) && defined(__OpenBSD__)
@@ -175,7 +175,7 @@ main(int argc, char *argv[])
     /*
      * Arg handling.
      */
-    checkonly = oldperms = quiet = strict = false;
+    checkonly = fflag = quiet = strict = false;
     while ((ch = getopt_long(argc, argv, short_opts, long_opts, NULL)) != -1) {
        switch (ch) {
            case 'V':
@@ -189,7 +189,7 @@ main(int argc, char *argv[])
                break;
            case 'f':
                sudoers_file = optarg;  /* sudoers file path */
-               oldperms = true;
+               fflag = true;
                break;
            case 'h':
                help();
@@ -207,9 +207,23 @@ main(int argc, char *argv[])
                usage(1);
        }
     }
-    /* There should be no other command line arguments. */
-    if (argc - optind != 0)
+    argc -= optind;
+    argv += optind;
+
+    /* Check for optional sudoers file argument. */
+    switch (argc) {
+    case 0:
+       break;
+    case 1:
+       /* Only accept sudoers file if no -f was specified. */
+       if (!fflag) {
+           sudoers_file = *argv;
+           fflag = true;
+       }
+       break;
+    default:
        usage(1);
+    }
 
     if (export_path != NULL) {
        /* Backwards compatibility for the time being. */
@@ -238,7 +252,7 @@ main(int argc, char *argv[])
        sudo_fatalx(U_("unable to initialize sudoers default values"));
 
     if (checkonly) {
-       exitcode = check_syntax(sudoers_file, quiet, strict, oldperms) ? 0 : 1;
+       exitcode = check_syntax(sudoers_file, quiet, strict, fflag) ? 0 : 1;
        goto done;
     }
 
@@ -278,7 +292,7 @@ main(int argc, char *argv[])
      */
     if (reparse_sudoers(editor, editor_argc, editor_argv, strict, quiet)) {
        TAILQ_FOREACH(sp, &sudoerslist, entries) {
-           (void) install_sudoers(sp, oldperms);
+           (void) install_sudoers(sp, fflag);
        }
     }
     free(editor);
@@ -1265,7 +1279,7 @@ static void
 usage(int fatal)
 {
     (void) fprintf(fatal ? stderr : stdout,
-       "usage: %s [-chqsV] [-f sudoers]\n", getprogname());
+       "usage: %s [-chqsV] [[-f] sudoers ]\n", getprogname());
     if (fatal)
        exit(1);
 }