From: Todd C. Miller Date: Wed, 16 Feb 2000 00:03:44 +0000 (+0000) Subject: Add 'editor' and 'enveditor' sudoers defaults and make visudo honor them. X-Git-Tag: SUDO_1_6_3~48 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=020125336c1358525afe9233f98c6eece0048603;p=sudo 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. --- diff --git a/INSTALL b/INSTALL index 20a1c59da..8b27a8792 100644 --- 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 9c7b448e4..2232b9f56 100644 --- 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? diff --git a/defaults.c b/defaults.c index a067f280f..8f10be41f 100644 --- a/defaults.c +++ b/defaults.c @@ -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. diff --git a/defaults.h b/defaults.h index d70a8c925..869e88d03 100644 --- a/defaults.h +++ b/defaults.h @@ -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. diff --git a/sudoers.cat b/sudoers.cat index 6fe75ea7a..6acac7c41 100644 --- a/sudoers.cat +++ b/sudoers.cat @@ -61,7 +61,7 @@ DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN -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). + IIIInnnntttteeeeggggeeeerrrrssss: 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. - IIIInnnntttteeeeggggeeeerrrrssss tttthhhhaaaatttt ccccaaaannnn bbbbeeee uuuusssseeeedddd iiiinnnn aaaa bbbboooooooolllleeeeaaaannnn ccccoooonnnntttteeeexxxxtttt: - 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) + IIIInnnntttteeeeggggeeeerrrrssss tttthhhhaaaatttt ccccaaaannnn bbbbeeee uuuusssseeeedddd iiiinnnn aaaa bbbboooooooolllleeeeaaaannnn ccccoooonnnntttteeeexxxxtttt: + + 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. + SSSSttttrrrriiiinnnnggggssss tttthhhhaaaatttt ccccaaaannnn bbbbeeee uuuusssseeeedddd iiiinnnn aaaa bbbboooooooolllleeeeaaaannnn ccccoooonnnntttteeeexxxxtttt: 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 ----llll. - 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 ----llll. + It has the following possible values: all All the user's I entries for the current host must have the C @@ -577,26 +586,26 @@ sudoers(5) FILE FORMATS sudoers(5) Let's break that down into its constituent parts: - RRRRuuuunnnnaaaassss____SSSSppppeeeecccc - 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 rrrrooooooootttt 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) + RRRRuuuunnnnaaaassss____SSSSppppeeeecccc + 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 rrrrooooooootttt 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. - WWWWiiiillllddddccccaaaarrrrddddssss ((((aaaakkkkaaaa mmmmeeeettttaaaa cccchhhhaaaarrrraaaacccctttteeeerrrrssss)))):::: - ssssuuuuddddoooo allows shell-style _w_i_l_d_c_a_r_d_s to be used in pathnames - as well as command line arguments in the _s_u_d_o_e_r_s file. - Wildcard matching is done via the PPPPOOOOSSSSIIIIXXXX fnmatch(3) - routine. Note that these are _n_o_t 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) + WWWWiiiillllddddccccaaaarrrrddddssss ((((aaaakkkkaaaa mmmmeeeettttaaaa cccchhhhaaaarrrraaaacccctttteeeerrrrssss)))):::: -sudoers(5) FILE FORMATS sudoers(5) + ssssuuuuddddoooo allows shell-style _w_i_l_d_c_a_r_d_s to be used in pathnames + as well as command line arguments in the _s_u_d_o_e_r_s file. + Wildcard matching is done via the PPPPOOOOSSSSIIIIXXXX fnmatch(3) + routine. Note that these are _n_o_t 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 aaaannnnyyyy command on the system. - An exclamation point ('!') can be used as a logical _n_o_t - operator both in an _a_l_i_a_s 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 _n_o_t + operator both in an _a_l_i_a_s 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 _U_s_e_r _S_p_e_c_i_f_i_c_a_t_i_o_n ('=', ':', '(', ')') is optional. @@ -774,20 +784,10 @@ EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS /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 _s_y_s_l_o_g(3) using the _a_u_t_h facility - in all cases. We don't want to subject the full time - staff to the ssssuuuuddddoooo lecture, and user mmmmiiiilllllllleeeerrrrtttt need not give - a password. In addition, on the machines in the _S_E_R_V_E_R_S - 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 @@ EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS sudoers(5) FILE FORMATS sudoers(5) + Here we override some of the compiled in default values. + We want sudo to log via _s_y_s_l_o_g(3) using the _a_u_t_h facility + in all cases. We don't want to subject the full time + staff to the ssssuuuuddddoooo lecture, and user mmmmiiiilllllllleeeerrrrtttt need not give + a password. In addition, on the machines in the _S_E_R_V_E_R_S + 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 ooooppppeeeerrrraaaattttoooorrrr 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 _/_u_s_r_/_o_p_e_r_/_b_i_n_/. - joe ALL = /usr/bin/su operator - The user jjjjooooeeee may only _s_u(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 _/_u_s_r_/_o_p_e_r_/_b_i_n_/. + joe ALL = /usr/bin/su operator -sudoers(5) FILE FORMATS sudoers(5) + The user jjjjooooeeee may only _s_u(1) to operator. + pete HPPA = /usr/bin/passwd [A-z]*, !/usr/bin/passwd root The user ppppeeeetttteeee is allowed to change anyone's password except for root on the _H_P_P_A 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 _S_U and _S_H_E_L_L_S Cmnd_Aliases. - steve CSNETS = (operator) /usr/local/op_commands/ - The user sssstttteeeevvvveeee 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, mmmmaaaatttttttt 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 sssstttteeeevvvveeee 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, mmmmaaaatttttttt needs to be + able to kill hung processes. WEBMASTERS www = (www) ALL, (root) /usr/bin/su www @@ -971,6 +981,19 @@ CCCCAAAAVVVVEEEEAAAATTTTSSSS hostname be fully-qualified as returned by the hostname command or use the _f_q_d_n option in _s_u_d_o_e_r_s. + + + + +15/Feb/2000 1.6.2 15 + + + + + +sudoers(5) FILE FORMATS sudoers(5) + + FFFFIIIILLLLEEEESSSS /etc/sudoers List of who can run what /etc/group Local groups file @@ -985,7 +1008,50 @@ SSSSEEEEEEEE AAAALLLLSSSSOOOO -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 diff --git a/sudoers.man b/sudoers.man index 310c28852..5d8c08f2b 100644 --- a/sudoers.man +++ b/sudoers.man @@ -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 @@ -96,7 +100,7 @@ .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" diff --git a/sudoers.pod b/sudoers.pod index 851dac58e..66c9a745f 100644 --- a/sudoers.pod +++ b/sudoers.pod @@ -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: @@ -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: diff --git a/visudo.c b/visudo.c index f972e3c5c..752bf2561 100644 --- 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) */