]> granicus.if.org Git - sudo/commitdiff
Add 'editor' and 'enveditor' sudoers defaults and make visudo honor them.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 16 Feb 2000 00:03:44 +0000 (00:03 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 16 Feb 2000 00:03:44 +0000 (00:03 +0000)
This means that visudo will now parse the sudoers file *before* it is
edited so a bogus sudoers file will cause a warning to go to stderr.
Also, visudo checks the variables once--it does not check them after
each editor run since that could be confusing.

INSTALL
TODO
defaults.c
defaults.h
sudoers.cat
sudoers.man
sudoers.pod
visudo.c

diff --git a/INSTALL b/INSTALL
index 20a1c59da559970e7a711b4e2f102d9dc54a91ab..8b27a8792be146f04acabc0356f58804d5fc93eb 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -229,17 +229,6 @@ Special features/options:
        It should only be used when another, alternate, authentication
        scheme is in use.
 
-  --with-editor=path
-       Specify the default editor used by visudo (and the only editor used
-       unless --with-env-editor is specified).  The default is the path
-       to vi on your system.
-
-  --with-env-editor
-       Makes visudo consult the EDITOR and VISUAL environment variables before
-       falling back on the default editor.  Note that this may create a
-       security hole as most editors allow a user to get a shell (which would
-       be a root shell and hence, no logging).
-
   --with-otp-only
        This option is now just an alias for --without-passwd.
 
@@ -415,6 +404,17 @@ The following options are also configurable at runtime:
   --without-lecture
        Don't print the lecture the first time a user runs sudo.
 
+  --with-editor=path
+       Specify the default editor used by visudo (and the only editor used
+       unless --with-env-editor is specified).  The default is the path
+       to vi on your system.
+
+  --with-env-editor
+       Makes visudo consult the EDITOR and VISUAL environment variables before
+       falling back on the default editor.  Note that this may create a
+       security hole as most editors allow a user to get a shell (which would
+       be a root shell and hence, no logging).
+
   --disable-authentication
         By default, sudo requires the user to authenticate via a
         password or similar means.  This options causes sudo to
diff --git a/TODO b/TODO
index 9c7b448e44e21cf8388cfa46f1b44568bacea85b..2232b9f56b8ef06b6f66b54f6a6bd767a69b55de 100644 (file)
--- a/TODO
+++ b/TODO
@@ -82,3 +82,5 @@ TODO list (most will be addressed in sudo 2.0)
 30) Add support for: Default:user@host
 
 31) Add -S flag to force password read from stdin
+
+32) Do login-style -sh hack for sudo -s?
index a067f280f878df4031c827201e7c12e3a93d8409..8f10be41f75200973791703973912c24357d67a0 100644 (file)
@@ -181,6 +181,9 @@ struct sudo_defs_types sudo_defs_table[] = {
     }, {
        "requiretty", T_FLAG,
        "Only allow the user to run sudo if they have a tty"
+    }, {
+       "enveditor", T_FLAG,
+       "Visudo will honor the EDITOR environment variable"
     }, {
        "loglinelen", T_INT|T_BOOL,
        "Length at which to wrap log file lines (0 for no wrap): %d"
@@ -229,6 +232,9 @@ struct sudo_defs_types sudo_defs_table[] = {
     }, {
        "secure_path", T_STR|T_BOOL,
        "Value to override user's $PATH with: %s"
+    }, {
+       "editor", T_STR|T_PATH,
+       "Path to the editor for use by visudo: %s"
     }, {
        "listpw_i", T_INT, NULL
     }, {
@@ -279,12 +285,6 @@ dump_defaults()
            }
        }
     }
-
-#ifdef ENV_EDITOR
-    (void) printf("Default editor for visudo: %s\n", EDITOR);
-#else
-    (void) printf("Editor for visudo: %s\n", EDITOR);
-#endif
 }
 
 /*
@@ -533,6 +533,9 @@ init_defaults()
 #ifdef USE_INSULTS
     def_flag(I_INSULTS) = TRUE;
 #endif
+#ifdef ENV_EDITOR
+    def_flag(I_ENVEDITOR) = TRUE;
+#endif
 
     /* Syslog options need special care since they both strings and ints */
 #if (LOGGING & SLOG_SYSLOG)
@@ -576,6 +579,7 @@ init_defaults()
 #ifdef SECURE_PATH
     def_str(I_SECURE_PATH) = estrdup(SECURE_PATH);
 #endif
+    def_str(I_EDITOR) = estrdup(EDITOR);
 
     /*
      * The following depend on the above values.
index d70a8c925a4b91e9c1c47182e73cac96d03cddb0..869e88d03c47e5336294f2cb3d8de406b506ae8d 100644 (file)
@@ -111,34 +111,36 @@ struct sudo_defs_types {
 #define I_FQDN                 21
 #define I_INSULTS              22
 #define I_REQUIRETTY           23
+#define I_ENVEDITOR            24
 
 /* Integer values */
-#define        I_LOGLEN        24      /* wrap log file line after N chars */
-#define        I_TS_TIMEOUT    25      /* timestamp stale after N minutes */
-#define        I_PW_TIMEOUT    26      /* exit if pass not entered in N minutes */
-#define        I_PW_TRIES      27      /* exit after N bad password tries */
-#define        I_UMASK         28      /* umask to use or 0777 to use user's */
+#define        I_LOGLEN        25      /* wrap log file line after N chars */
+#define        I_TS_TIMEOUT    26      /* timestamp stale after N minutes */
+#define        I_PW_TIMEOUT    27      /* exit if pass not entered in N minutes */
+#define        I_PW_TRIES      28      /* exit after N bad password tries */
+#define        I_UMASK         29      /* umask to use or 0777 to use user's */
 
 /* Strings */
-#define        I_LOGFILE       29      /* path to logfile (or NULL for none) */
-#define        I_MAILERPATH    30      /* path to sendmail or other mailer */
-#define        I_MAILERFLAGS   31      /* flags to pass to the mailer */
-#define        I_MAILTO        32      /* who to send bitch mail to */
-#define        I_MAILSUB       33      /* subject line of mail msg */
-#define        I_BADPASS_MSG   34      /* what to say when passwd is wrong */
-#define        I_TIMESTAMPDIR  35      /* path to timestamp dir */
-#define        I_EXEMPT_GRP    36      /* no password or PATH override for these */
-#define        I_PASSPROMPT    37      /* password prompt */
-#define        I_RUNAS_DEF     38      /* default user to run commands as */
-#define        I_SECURE_PATH   39      /* set $PATH to this if not NULL */
+#define        I_LOGFILE       30      /* path to logfile (or NULL for none) */
+#define        I_MAILERPATH    31      /* path to sendmail or other mailer */
+#define        I_MAILERFLAGS   32      /* flags to pass to the mailer */
+#define        I_MAILTO        33      /* who to send bitch mail to */
+#define        I_MAILSUB       34      /* subject line of mail msg */
+#define        I_BADPASS_MSG   35      /* what to say when passwd is wrong */
+#define        I_TIMESTAMPDIR  36      /* path to timestamp dir */
+#define        I_EXEMPT_GRP    37      /* no password or PATH override for these */
+#define        I_PASSPROMPT    38      /* password prompt */
+#define        I_RUNAS_DEF     39      /* default user to run commands as */
+#define        I_SECURE_PATH   40      /* set $PATH to this if not NULL */
+#define        I_EDITOR        41      /* path to editor used by visudo */
 
 /* Integer versions of list/verify options */
-#define I_LISTPW       40
-#define I_VERIFYPW     41
+#define I_LISTPW       42
+#define I_VERIFYPW     43
 
 /* String versions of list/verify options */
-#define I_LISTPWSTR    42
-#define I_VERIFYPWSTR  43
+#define I_LISTPWSTR    44
+#define I_VERIFYPWSTR  45
 
 /*
  * Macros for accessing sudo_defs_table.
index 6fe75ea7a654f0835e1f467d51857210f9079f09..6acac7c4118a691cf01d0fcdc8b82096ae5f292e 100644 (file)
@@ -61,7 +61,7 @@ D\bD\bD\bDE\bE\bE\bES\bS\bS\bSC\bC\bC\bCR\bR\bR\bRI\bI\bI\bIP\bP\bP\bPT\bT\bT\bTI\bI\bI\bIO\bO\bO\bON\bN\bN\bN
 
 
 
-26/Jan/2000                   1.6.2                             1
+15/Feb/2000                   1.6.2                             1
 
 
 
@@ -127,7 +127,7 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
 
 
 
-26/Jan/2000                   1.6.2                             2
+15/Feb/2000                   1.6.2                             2
 
 
 
@@ -193,7 +193,7 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
 
 
 
-26/Jan/2000                   1.6.2                             3
+15/Feb/2000                   1.6.2                             3
 
 
 
@@ -259,7 +259,7 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
 
 
 
-26/Jan/2000                   1.6.2                             4
+15/Feb/2000                   1.6.2                             4
 
 
 
@@ -325,7 +325,7 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
 
 
 
-26/Jan/2000                   1.6.2                             5
+15/Feb/2000                   1.6.2                             5
 
 
 
@@ -374,6 +374,13 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
                    flag to prevent a user from entering a visible
                    password.  This flag is off by default.
 
+       enveditor   If set, visudo will use the value of the
+                   EDITOR or VISUAL environment falling back on
+                   the default editor.  Note that this may create
+                   a security hole as most editors allow a user
+                   to get a shell (which would be a root shell
+                   and not be logged).
+
        I\bI\bI\bIn\bn\bn\bnt\bt\bt\bte\be\be\beg\bg\bg\bge\be\be\ber\br\br\brs\bs\bs\bs:
 
        passwd_tries
@@ -381,17 +388,10 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
                    his/her password before sudo logs the failure
                    and exits.  The default is 3.
 
-       I\bI\bI\bIn\bn\bn\bnt\bt\bt\bte\be\be\beg\bg\bg\bge\be\be\ber\br\br\brs\bs\bs\bs t\bt\bt\bth\bh\bh\bha\ba\ba\bat\bt\bt\bt c\bc\bc\bca\ba\ba\ban\bn\bn\bn b\bb\bb\bbe\be\be\be u\bu\bu\bus\bs\bs\bse\be\be\bed\bd\bd\bd i\bi\bi\bin\bn\bn\bn a\ba\ba\ba b\bb\bb\bbo\bo\bo\boo\bo\bo\bol\bl\bl\ble\be\be\bea\ba\ba\ban\bn\bn\bn c\bc\bc\bco\bo\bo\bon\bn\bn\bnt\bt\bt\bte\be\be\bex\bx\bx\bxt\bt\bt\bt:
 
-       loglinelen  Number of characters per line for the file
-                   log.  This value is used to decide when to
-                   wrap lines for nicer log files.  This has no
-                   effect on the syslog log file, only the file
-                   log.  The default is 80 (use 0 or negate to
 
 
-
-26/Jan/2000                   1.6.2                             6
+15/Feb/2000                   1.6.2                             6
 
 
 
@@ -400,6 +400,13 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
 sudoers(5)                 FILE FORMATS                sudoers(5)
 
 
+       I\bI\bI\bIn\bn\bn\bnt\bt\bt\bte\be\be\beg\bg\bg\bge\be\be\ber\br\br\brs\bs\bs\bs t\bt\bt\bth\bh\bh\bha\ba\ba\bat\bt\bt\bt c\bc\bc\bca\ba\ba\ban\bn\bn\bn b\bb\bb\bbe\be\be\be u\bu\bu\bus\bs\bs\bse\be\be\bed\bd\bd\bd i\bi\bi\bin\bn\bn\bn a\ba\ba\ba b\bb\bb\bbo\bo\bo\boo\bo\bo\bol\bl\bl\ble\be\be\bea\ba\ba\ban\bn\bn\bn c\bc\bc\bco\bo\bo\bon\bn\bn\bnt\bt\bt\bte\be\be\bex\bx\bx\bxt\bt\bt\bt:
+
+       loglinelen  Number of characters per line for the file
+                   log.  This value is used to decide when to
+                   wrap lines for nicer log files.  This has no
+                   effect on the syslog log file, only the file
+                   log.  The default is 80 (use 0 or negate to
                    disable word wrap).
 
        timestamp_timeout
@@ -447,17 +454,10 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
                    flag is not specified on the command line.
                    This defaults to "root".
 
-       syslog_goodpri
-                   Syslog priority to use when user authenticates
-                   successfully.  Defaults to "notice".
-
-       syslog_badpri
-                   Syslog priority to use when user authenticates
-                   unsuccessfully.  Defaults to "alert".
 
 
 
-26/Jan/2000                   1.6.2                             7
+15/Feb/2000                   1.6.2                             7
 
 
 
@@ -466,6 +466,17 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
 sudoers(5)                 FILE FORMATS                sudoers(5)
 
 
+       syslog_goodpri
+                   Syslog priority to use when user authenticates
+                   successfully.  Defaults to "notice".
+
+       syslog_badpri
+                   Syslog priority to use when user authenticates
+                   unsuccessfully.  Defaults to "alert".
+
+       editor      Path to the editor to be used by visudo.  The
+                   default is the path to vi on your system.
+
        S\bS\bS\bSt\bt\bt\btr\br\br\bri\bi\bi\bin\bn\bn\bng\bg\bg\bgs\bs\bs\bs t\bt\bt\bth\bh\bh\bha\ba\ba\bat\bt\bt\bt c\bc\bc\bca\ba\ba\ban\bn\bn\bn b\bb\bb\bbe\be\be\be u\bu\bu\bus\bs\bs\bse\be\be\bed\bd\bd\bd i\bi\bi\bin\bn\bn\bn a\ba\ba\ba b\bb\bb\bbo\bo\bo\boo\bo\bo\bol\bl\bl\ble\be\be\bea\ba\ba\ban\bn\bn\bn c\bc\bc\bco\bo\bo\bon\bn\bn\bnt\bt\bt\bte\be\be\bex\bx\bx\bxt\bt\bt\bt:
 
        syslog      Syslog facility if syslog is being used for
@@ -510,27 +521,25 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
                        never       The user need never enter a password to use
                                    the B<-v> flag.
 
-                       always      The user must always enter a password to use
-                                   the B<-v> flag.
-
-                   The default value is `all'.
 
-       listpw      This option controls when a password will be
-                   required when a user runs sudo with the -\b-\b-\b-l\bl\bl\bl.
-                   It has the following possible values:
 
+15/Feb/2000                   1.6.2                             8
 
 
 
 
-26/Jan/2000                   1.6.2                             8
-
 
+sudoers(5)                 FILE FORMATS                sudoers(5)
 
 
+                       always      The user must always enter a password to use
+                                   the B<-v> flag.
 
-sudoers(5)                 FILE FORMATS                sudoers(5)
+                   The default value is `all'.
 
+       listpw      This option controls when a password will be
+                   required when a user runs sudo with the -\b-\b-\b-l\bl\bl\bl.
+                   It has the following possible values:
 
                        all         All the user's I<sudoers> entries for the
                                    current host must have the C<NOPASSWD>
@@ -577,26 +586,26 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
 
        Let's break that down into its constituent parts:
 
-       R\bR\bR\bRu\bu\bu\bun\bn\bn\bna\ba\ba\bas\bs\bs\bs_\b_\b_\b_S\bS\bS\bSp\bp\bp\bpe\be\be\bec\bc\bc\bc
 
-       A Runas_Spec is simply a Runas_List (as defined above)
-       enclosed in a set of parentheses.  If you do not specify a
-       Runas_Spec in the user specification, a default Runas_Spec
-       of r\br\br\bro\bo\bo\boo\bo\bo\bot\bt\bt\bt will be used.  A Runas_Spec sets the default for
-       commands that follow it.  What this means is that for the
-       entry:
 
 
+15/Feb/2000                   1.6.2                             9
 
 
-26/Jan/2000                   1.6.2                             9
 
 
 
+sudoers(5)                 FILE FORMATS                sudoers(5)
 
 
-sudoers(5)                 FILE FORMATS                sudoers(5)
+       R\bR\bR\bRu\bu\bu\bun\bn\bn\bna\ba\ba\bas\bs\bs\bs_\b_\b_\b_S\bS\bS\bSp\bp\bp\bpe\be\be\bec\bc\bc\bc
 
+       A Runas_Spec is simply a Runas_List (as defined above)
+       enclosed in a set of parentheses.  If you do not specify a
+       Runas_Spec in the user specification, a default Runas_Spec
+       of r\br\br\bro\bo\bo\boo\bo\bo\bot\bt\bt\bt will be used.  A Runas_Spec sets the default for
+       commands that follow it.  What this means is that for the
+       entry:
 
         dgb    boulder = (operator) /bin/ls, /bin/kill, /usr/bin/who
 
@@ -643,26 +652,26 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
        pertain to the current host.  This behavior may be
        overridden via the verifypw and listpw options.
 
-       W\bW\bW\bWi\bi\bi\bil\bl\bl\bld\bd\bd\bdc\bc\bc\bca\ba\ba\bar\br\br\brd\bd\bd\bds\bs\bs\bs (\b(\b(\b(a\ba\ba\bak\bk\bk\bka\ba\ba\ba m\bm\bm\bme\be\be\bet\bt\bt\bta\ba\ba\ba c\bc\bc\bch\bh\bh\bha\ba\ba\bar\br\br\bra\ba\ba\bac\bc\bc\bct\bt\bt\bte\be\be\ber\br\br\brs\bs\bs\bs)\b)\b)\b):\b:\b:\b:
 
-       s\bs\bs\bsu\bu\bu\bud\bd\bd\bdo\bo\bo\bo allows shell-style _\bw_\bi_\bl_\bd_\bc_\ba_\br_\bd_\bs to be used in pathnames
-       as well as command line arguments in the _\bs_\bu_\bd_\bo_\be_\br_\bs file.
-       Wildcard matching is done via the P\bP\bP\bPO\bO\bO\bOS\bS\bS\bSI\bI\bI\bIX\bX\bX\bX fnmatch(3)
-       routine.  Note that these are _\bn_\bo_\bt regular expressions.
 
-       *       Matches any set of zero or more characters.
 
+15/Feb/2000                   1.6.2                            10
 
 
 
-26/Jan/2000                   1.6.2                            10
 
 
+sudoers(5)                 FILE FORMATS                sudoers(5)
 
 
+       W\bW\bW\bWi\bi\bi\bil\bl\bl\bld\bd\bd\bdc\bc\bc\bca\ba\ba\bar\br\br\brd\bd\bd\bds\bs\bs\bs (\b(\b(\b(a\ba\ba\bak\bk\bk\bka\ba\ba\ba m\bm\bm\bme\be\be\bet\bt\bt\bta\ba\ba\ba c\bc\bc\bch\bh\bh\bha\ba\ba\bar\br\br\bra\ba\ba\bac\bc\bc\bct\bt\bt\bte\be\be\ber\br\br\brs\bs\bs\bs)\b)\b)\b):\b:\b:\b:
 
-sudoers(5)                 FILE FORMATS                sudoers(5)
+       s\bs\bs\bsu\bu\bu\bud\bd\bd\bdo\bo\bo\bo allows shell-style _\bw_\bi_\bl_\bd_\bc_\ba_\br_\bd_\bs to be used in pathnames
+       as well as command line arguments in the _\bs_\bu_\bd_\bo_\be_\br_\bs file.
+       Wildcard matching is done via the P\bP\bP\bPO\bO\bO\bOS\bS\bS\bSI\bI\bI\bIX\bX\bX\bX fnmatch(3)
+       routine.  Note that these are _\bn_\bo_\bt regular expressions.
 
+       *       Matches any set of zero or more characters.
 
        ?       Matches any single character.
 
@@ -709,19 +718,10 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
        dangerous since in a command context, it allows the user
        to run a\ba\ba\ban\bn\bn\bny\by\by\by command on the system.
 
-       An exclamation point ('!') can be used as a logical _\bn_\bo_\bt
-       operator both in an _\ba_\bl_\bi_\ba_\bs and in front of a Cmnd.  This
-       allows one to exclude certain values.  Note, however, that
-       using a ! in conjunction with the built in ALL alias to
-       allow a user to run "all but a few" commands rarely works
-       as intended (see SECURITY NOTES below).
-
-       Long lines can be continued with a backslash ('\') as the
-       last character on the line.
 
 
 
-26/Jan/2000                   1.6.2                            11
+15/Feb/2000                   1.6.2                            11
 
 
 
@@ -730,6 +730,16 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
 sudoers(5)                 FILE FORMATS                sudoers(5)
 
 
+       An exclamation point ('!') can be used as a logical _\bn_\bo_\bt
+       operator both in an _\ba_\bl_\bi_\ba_\bs and in front of a Cmnd.  This
+       allows one to exclude certain values.  Note, however, that
+       using a ! in conjunction with the built in ALL alias to
+       allow a user to run "all but a few" commands rarely works
+       as intended (see SECURITY NOTES below).
+
+       Long lines can be continued with a backslash ('\') as the
+       last character on the line.
+
        Whitespace between elements in a list as well as specicial
        syntactic characters in a _\bU_\bs_\be_\br _\bS_\bp_\be_\bc_\bi_\bf_\bi_\bc_\ba_\bt_\bi_\bo_\bn ('=', ':',
        '(', ')') is optional.
@@ -774,20 +784,10 @@ E\bE\bE\bEX\bX\bX\bXA\bA\bA\bAM\bM\bM\bMP\bP\bP\bPL\bL\bL\bLE\bE\bE\bES\bS\bS\bS
                                 /usr/local/bin/zsh
         Cmnd_Alias     SU = /usr/bin/su
 
-       Here we override some of the compiled in default values.
-       We want sudo to log via _\bs_\by_\bs_\bl_\bo_\bg(3) using the _\ba_\bu_\bt_\bh facility
-       in all cases.  We don't want to subject the full time
-       staff to the s\bs\bs\bsu\bu\bu\bud\bd\bd\bdo\bo\bo\bo lecture, and user m\bm\bm\bmi\bi\bi\bil\bl\bl\bll\bl\bl\ble\be\be\ber\br\br\brt\bt\bt\bt need not give
-       a password.  In addition, on the machines in the _\bS_\bE_\bR_\bV_\bE_\bR_\bS
-       Host_Alias, we keep an additional local log file and make
-       sure we log the year in each log line since the log
-       entries will be kept around for several years.
 
 
 
-
-
-26/Jan/2000                   1.6.2                            12
+15/Feb/2000                   1.6.2                            12
 
 
 
@@ -796,6 +796,15 @@ E\bE\bE\bEX\bX\bX\bXA\bA\bA\bAM\bM\bM\bMP\bP\bP\bPL\bL\bL\bLE\bE\bE\bES\bS\bS\bS
 sudoers(5)                 FILE FORMATS                sudoers(5)
 
 
+       Here we override some of the compiled in default values.
+       We want sudo to log via _\bs_\by_\bs_\bl_\bo_\bg(3) using the _\ba_\bu_\bt_\bh facility
+       in all cases.  We don't want to subject the full time
+       staff to the s\bs\bs\bsu\bu\bu\bud\bd\bd\bdo\bo\bo\bo lecture, and user m\bm\bm\bmi\bi\bi\bil\bl\bl\bll\bl\bl\ble\be\be\ber\br\br\brt\bt\bt\bt need not give
+       a password.  In addition, on the machines in the _\bS_\bE_\bR_\bV_\bE_\bR_\bS
+       Host_Alias, we keep an additional local log file and make
+       sure we log the year in each log line since the log
+       entries will be kept around for several years.
+
         # Override builtin defaults
         Defaults               syslog=auth
         Defaults:FULLTIMERS    !lecture
@@ -841,26 +850,27 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
                        /usr/oper/bin/
 
        The o\bo\bo\bop\bp\bp\bpe\be\be\ber\br\br\bra\ba\ba\bat\bt\bt\bto\bo\bo\bor\br\br\br user may run commands limited to simple
-       maintenance.  Here, those are commands related to backups,
-       killing processes, the printing system, shutting down the
-       system, and any commands in the directory _\b/_\bu_\bs_\br_\b/_\bo_\bp_\be_\br_\b/_\bb_\bi_\bn_\b/.
 
-        joe            ALL = /usr/bin/su operator
 
-       The user j\bj\bj\bjo\bo\bo\boe\be\be\be may only _\bs_\bu(1) to operator.
 
-        pete           HPPA = /usr/bin/passwd [A-z]*, !/usr/bin/passwd root
+15/Feb/2000                   1.6.2                            13
+
 
 
 
-26/Jan/2000                   1.6.2                            13
 
+sudoers(5)                 FILE FORMATS                sudoers(5)
 
 
+       maintenance.  Here, those are commands related to backups,
+       killing processes, the printing system, shutting down the
+       system, and any commands in the directory _\b/_\bu_\bs_\br_\b/_\bo_\bp_\be_\br_\b/_\bb_\bi_\bn_\b/.
 
+        joe            ALL = /usr/bin/su operator
 
-sudoers(5)                 FILE FORMATS                sudoers(5)
+       The user j\bj\bj\bjo\bo\bo\boe\be\be\be may only _\bs_\bu(1) to operator.
 
+        pete           HPPA = /usr/bin/passwd [A-z]*, !/usr/bin/passwd root
 
        The user p\bp\bp\bpe\be\be\bet\bt\bt\bte\be\be\be is allowed to change anyone's password
        except for root on the _\bH_\bP_\bP_\bA machines.  Note that this
@@ -907,26 +917,26 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
        any commands in the directory /usr/bin/ except for those
        commands belonging to the _\bS_\bU and _\bS_\bH_\bE_\bL_\bL_\bS Cmnd_Aliases.
 
-        steve          CSNETS = (operator) /usr/local/op_commands/
 
-       The user s\bs\bs\bst\bt\bt\bte\be\be\bev\bv\bv\bve\be\be\be may run any command in the directory
-       /usr/local/op_commands/ but only as user operator.
 
-        matt           valkyrie = KILL
+15/Feb/2000                   1.6.2                            14
 
-       On his personal workstation, valkyrie, m\bm\bm\bma\ba\ba\bat\bt\bt\btt\bt\bt\bt needs to be
-       able to kill hung processes.
 
 
 
-26/Jan/2000                   1.6.2                            14
 
+sudoers(5)                 FILE FORMATS                sudoers(5)
 
 
+        steve          CSNETS = (operator) /usr/local/op_commands/
 
+       The user s\bs\bs\bst\bt\bt\bte\be\be\bev\bv\bv\bve\be\be\be may run any command in the directory
+       /usr/local/op_commands/ but only as user operator.
 
-sudoers(5)                 FILE FORMATS                sudoers(5)
+        matt           valkyrie = KILL
 
+       On his personal workstation, valkyrie, m\bm\bm\bma\ba\ba\bat\bt\bt\btt\bt\bt\bt needs to be
+       able to kill hung processes.
 
         WEBMASTERS     www = (www) ALL, (root) /usr/bin/su www
 
@@ -971,6 +981,19 @@ C\bC\bC\bCA\bA\bA\bAV\bV\bV\bVE\bE\bE\bEA\bA\bA\bAT\bT\bT\bTS\bS\bS\bS
        hostname be fully-qualified as returned by the hostname
        command or use the _\bf_\bq_\bd_\bn option in _\bs_\bu_\bd_\bo_\be_\br_\bs.
 
+
+
+
+
+15/Feb/2000                   1.6.2                            15
+
+
+
+
+
+sudoers(5)                 FILE FORMATS                sudoers(5)
+
+
 F\bF\bF\bFI\bI\bI\bIL\bL\bL\bLE\bE\bE\bES\bS\bS\bS
         /etc/sudoers           List of who can run what
         /etc/group             Local groups file
@@ -985,7 +1008,50 @@ S\bS\bS\bSE\bE\bE\bEE\bE\bE\bE A\bA\bA\bAL\bL\bL\bLS\bS\bS\bSO\bO\bO\bO
 
 
 
-26/Jan/2000                   1.6.2                            15
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+15/Feb/2000                   1.6.2                            16
 
 
 
@@ -1051,6 +1117,6 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
 
 
 
-26/Jan/2000                   1.6.2                            16
+15/Feb/2000                   1.6.2                            17
 
 
index 310c28852173375fbe8086ceaae98a4dc01da205..5d8c08f2be7ed94048d1c331763b8ecbaa8f0585 100644 (file)
@@ -2,8 +2,12 @@
 ''' $RCSfile$$Revision$$Date$
 '''
 ''' $Log$
-''' Revision 1.23  2000/01/26 21:21:28  millert
-''' Expanded docs on sudoers 'defaults' options based on INSTALL file info.
+''' Revision 1.24  2000/02/16 00:03:44  millert
+''' Add 'editor' and 'enveditor' sudoers defaults and make visudo honor them.
+''' This means that visudo will now parse the sudoers file *before* it is
+''' edited so a bogus sudoers file will cause a warning to go to stderr.
+''' Also, visudo checks the variables once--it does not check them after
+''' each editor run since that could be confusing.
 '''
 '''
 .de Sh
 .nr % 0
 .rr F
 .\}
-.TH sudoers 5 "1.6.2" "26/Jan/2000" "FILE FORMATS"
+.TH sudoers 5 "1.6.2" "15/Feb/2000" "FILE FORMATS"
 .UC
 .if n .hy 0
 .if n .na
@@ -464,6 +468,11 @@ tty.  This will disallow things like \f(CW"rsh somehost sudo ls"\fR since
 of echo when there is no tty present, some sites may with to set
 this flag to prevent a user from entering a visible password.  This
 flag is off by default.
+.Ip "enveditor" 12
+If set, visudo will use the value of the \s-1EDITOR\s0 or \s-1VISUAL\s0 environment
+falling back on the default editor.  Note that this may create a
+security hole as most editors allow a user to get a shell (which
+would be a root shell and not be logged).
 .PP
 \fBIntegers\fR:
 .Ip "passwd_tries" 12
@@ -511,6 +520,9 @@ Defaults to \*(L"notice\*(R".
 .Ip "syslog_badpri" 12
 Syslog priority to use when user authenticates unsuccessfully.
 Defaults to \*(L"alert\*(R".
+.Ip "editor" 12
+Path to the editor to be used by visudo.  The default is the path
+to vi on your system.
 .PP
 \fBStrings that can be used in a boolean context\fR:
 .Ip "syslog" 12
@@ -999,6 +1011,8 @@ as returned by the \f(CWhostname\fR command or use the \fIfqdn\fR option in
 
 .IX Item "requiretty"
 
+.IX Item "enveditor"
+
 .IX Item "passwd_tries"
 
 .IX Item "loglinelen"
@@ -1023,6 +1037,8 @@ as returned by the \f(CWhostname\fR command or use the \fIfqdn\fR option in
 
 .IX Item "syslog_badpri"
 
+.IX Item "editor"
+
 .IX Item "syslog"
 
 .IX Item "mailerpath"
index 851dac58e1e79e418e10791841e0d10fa69de319..66c9a745f1ba12de0a739857eec3b0ee7a7fd501 100644 (file)
@@ -346,6 +346,13 @@ of echo when there is no tty present, some sites may with to set
 this flag to prevent a user from entering a visible password.  This
 flag is off by default.
 
+=item enveditor
+
+If set, visudo will use the value of the EDITOR or VISUAL environment
+falling back on the default editor.  Note that this may create a
+security hole as most editors allow a user to get a shell (which
+would be a root shell and not be logged).
+
 =back
 
 B<Integers>:
@@ -429,6 +436,11 @@ Defaults to "notice".
 Syslog priority to use when user authenticates unsuccessfully.
 Defaults to "alert".
 
+=item editor
+
+Path to the editor to be used by visudo.  The default is the path
+to vi on your system.
+
 =back 12
 
 B<Strings that can be used in a boolean context>:
index f972e3c5c7bb8e950e5fd5dbd37122a13b7f61d4..752bf2561a7d44820339c64cca2bbcef11b4b1ac 100644 (file)
--- a/visudo.c
+++ b/visudo.c
@@ -121,7 +121,7 @@ main(argc, argv)
     char **argv;
 {
     char buf[MAXPATHLEN*2];            /* buffer used for copying files */
-    char *Editor = EDITOR;             /* editor to use (default is EDITOR */
+    char *Editor;                      /* editor to use */
     int sudoers_fd;                    /* sudoers file descriptor */
     int stmp_fd;                       /* stmp file descriptor */
     int n;                             /* length parameter */
@@ -158,15 +158,8 @@ main(argc, argv)
        exit(1);
     }
 
-#ifdef ENV_EDITOR
-    /*
-     * If we are allowing EDITOR and VISUAL envariables set Editor
-     * base on whichever exists...
-     */
-    if (!(Editor = getenv("EDITOR")))
-       if (!(Editor = getenv("VISUAL")))
-           Editor = EDITOR;
-#endif /* ENV_EDITOR */
+    /* Setup defaults data structures. */
+    init_defaults();
 
     /*
      * Open sudoers, lock it and stat it.  
@@ -216,9 +209,28 @@ main(argc, argv)
 
        (void) close(stmp_fd);
        (void) touch(stmp, sudoers_sb.st_mtime);
+
+       /* Parse sudoers to pull in editor and enveditor conf values. */
+       if ((yyin = fopen(stmp, "r"))) {
+           yyout = stdout;
+           init_defaults();
+           init_parser();
+           yyparse();
+           parse_error = FALSE;
+           yyrestart(yyin);
+           fclose(yyin);
+       }
     } else
        (void) close(stmp_fd);
 
+    /*
+     * If we are allowing EDITOR and VISUAL envariables set Editor
+     * base on whichever exists...
+     */
+    if (!def_flag(I_ENVEDITOR) ||
+       (!(Editor = getenv("EDITOR")) && !(Editor = getenv("VISUAL"))))
+       Editor = def_str(I_EDITOR);
+
     /*
      * Edit the temp file and parse it (for sanity checking)
      */