From 26ca852a98c2d69262851ebbbada78dd1f18d0b9 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Wed, 14 Jul 2010 09:33:53 -0400 Subject: [PATCH] Substitute the value of EDITOR into the sudoers and visudo manuals. --- aclocal.m4 | 30 ++++------ configure | 93 ++++++++++++----------------- configure.in | 9 ++- doc/sudoers.cat | 144 ++++++++++++++++++++++----------------------- doc/sudoers.man.in | 13 ++-- doc/sudoers.pod | 11 +++- doc/visudo.cat | 34 +++++------ doc/visudo.man.in | 11 ++-- doc/visudo.pod | 9 ++- 9 files changed, 169 insertions(+), 185 deletions(-) diff --git a/aclocal.m4 b/aclocal.m4 index 7a4bdca93..373632c6a 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -35,25 +35,19 @@ fi ])dnl dnl -dnl check for vi +dnl check for vi in well-known locations dnl -AC_DEFUN(SUDO_PROG_VI, [AC_MSG_CHECKING(for vi) -if test -f "/usr/bin/vi"; then - AC_MSG_RESULT(/usr/bin/vi) - SUDO_DEFINE(_PATH_VI, "/usr/bin/vi") -elif test -f "/usr/ucb/vi"; then - AC_MSG_RESULT(/usr/ucb/vi) - SUDO_DEFINE(_PATH_VI, "/usr/ucb/vi") -elif test -f "/usr/bsd/vi"; then - AC_MSG_RESULT(/usr/bsd/vi) - SUDO_DEFINE(_PATH_VI, "/usr/bsd/vi") -elif test -f "/bin/vi"; then - AC_MSG_RESULT(/bin/vi) - SUDO_DEFINE(_PATH_VI, "/bin/vi") -elif test -f "/usr/local/bin/vi"; then - AC_MSG_RESULT(/usr/local/bin/vi) - SUDO_DEFINE(_PATH_VI, "/usr/local/bin/vi") -else +AC_DEFUN(SUDO_PROG_VI, [AC_MSG_CHECKING([for vi]) +found=no +for editor in "/usr/bin/vi" "/bin/vi" "/usr/ucb/vi" "/usr/bsd/vi" "/usr/local/bin/vi"; do + if test -f "$editor"; then + found=yes + AC_MSG_RESULT([$editor]) + SUDO_DEFINE_UNQUOTED(_PATH_VI, "$editor") + break + fi +done +if test X"$found" != X"no"; then AC_MSG_RESULT(not found) fi ])dnl diff --git a/configure b/configure index f1650fd07..8d11ea265 100755 --- a/configure +++ b/configure @@ -785,6 +785,7 @@ OBJEXT EXEEXT ac_ct_CC CC +editor secure_path netsvc_conf nsswitch_conf @@ -2780,6 +2781,7 @@ $as_echo "$as_me: Configuring Sudo version $PACKAGE_VERSION" >&6;} + # @@ -2807,6 +2809,7 @@ badpass_message="Sorry, try again." fqdn=off runas_default=root env_editor=off +editor=vi passwd_tries=3 tty_tickets=off insults=off @@ -4682,6 +4685,7 @@ _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_editor" >&5 $as_echo "$with_editor" >&6; } + editor="$with_editor" ;; esac else @@ -5082,10 +5086,9 @@ if test "${with_askpass+set}" = set; then : yes) as_fn_error "\"--with-askpass takes a path as an argument.\"" "$LINENO" 5 ;; no) ;; - *) -cat >>confdefs.h <<_ACEOF + *) cat >>confdefs.h < conftest.$ac_ext - (eval echo "\"\$as_me:6937: $ac_compile\"" >&5) + (eval echo "\"\$as_me:6940: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:6940: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:6943: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:6943: output\"" >&5) + (eval echo "\"\$as_me:6946: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -8145,7 +8148,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 8148 "configure"' > conftest.$ac_ext + echo '#line 8151 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -9406,11 +9409,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:9409: $lt_compile\"" >&5) + (eval echo "\"\$as_me:9412: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:9413: \$? = $ac_status" >&5 + echo "$as_me:9416: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -9745,11 +9748,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:9748: $lt_compile\"" >&5) + (eval echo "\"\$as_me:9751: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:9752: \$? = $ac_status" >&5 + echo "$as_me:9755: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -9850,11 +9853,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:9853: $lt_compile\"" >&5) + (eval echo "\"\$as_me:9856: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:9857: \$? = $ac_status" >&5 + echo "$as_me:9860: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -9905,11 +9908,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:9908: $lt_compile\"" >&5) + (eval echo "\"\$as_me:9911: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:9912: \$? = $ac_status" >&5 + echo "$as_me:9915: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -12272,7 +12275,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12275 "configure" +#line 12278 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12368,7 +12371,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12371 "configure" +#line 12374 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -13792,42 +13795,20 @@ fi if test -z "$with_editor"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for vi" >&5 $as_echo_n "checking for vi... " >&6; } -if test -f "/usr/bin/vi"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: /usr/bin/vi" >&5 -$as_echo "/usr/bin/vi" >&6; } - cat >>confdefs.h <<\EOF -#define _PATH_VI "/usr/bin/vi" +found=no +for editor in "/usr/bin/vi" "/bin/vi" "/usr/ucb/vi" "/usr/bsd/vi" "/usr/local/bin/vi"; do + if test -f "$editor"; then + found=yes + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $editor" >&5 +$as_echo "$editor" >&6; } + cat >>confdefs.h <&5 -$as_echo "/usr/ucb/vi" >&6; } - cat >>confdefs.h <<\EOF -#define _PATH_VI "/usr/ucb/vi" -EOF - -elif test -f "/usr/bsd/vi"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: /usr/bsd/vi" >&5 -$as_echo "/usr/bsd/vi" >&6; } - cat >>confdefs.h <<\EOF -#define _PATH_VI "/usr/bsd/vi" -EOF - -elif test -f "/bin/vi"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: /bin/vi" >&5 -$as_echo "/bin/vi" >&6; } - cat >>confdefs.h <<\EOF -#define _PATH_VI "/bin/vi" -EOF - -elif test -f "/usr/local/bin/vi"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: /usr/local/bin/vi" >&5 -$as_echo "/usr/local/bin/vi" >&6; } - cat >>confdefs.h <<\EOF -#define _PATH_VI "/usr/local/bin/vi" -EOF - -else + break + fi +done +if test X"$found" != X"no"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } fi @@ -18234,18 +18215,16 @@ if test X"$with_noexec" != X"no" -o X"$with_selinux" != X"no"; then INSTALL_NOEXEC="install-noexec" eval noexec_file="$with_noexec" - -cat >>confdefs.h <<_ACEOF + cat >>confdefs.h <>confdefs.h <<_ACEOF + cat >>confdefs.h < unless insults are enabled. A colon (':') separated list of editors allowed to be used with B. B will choose the editor that matches the user's EDITOR environment variable if possible, or the first editor in the -list that exists and is executable. The default is the path to vi -on your system. +list that exists and is executable. The default is C<"@editor@">. =item mailsub @@ -1483,7 +1482,13 @@ Initial environment for B<-i> mode on Linux and AIX =head1 EXAMPLES Below are example I entries. Admittedly, some of -these are a bit contrived. First, we define our I: +these are a bit contrived. First, we allow a few environment +variables to pass and then define our I: + + # Run X applications through sudo; HOME is used to find .Xauthority file + # Note that some programs may use HOME for other purposes too and + # this may lead to privilege escalation! + Defaults env_keep = "DISPLAY HOME" # User alias specification User_Alias FULLTIMERS = millert, mikef, dowdy diff --git a/doc/visudo.cat b/doc/visudo.cat index b4af190db..35e9fe527 100644 --- a/doc/visudo.cat +++ b/doc/visudo.cat @@ -17,17 +17,16 @@ DDEESSCCRRIIPPTTIIOONN _s_u_d_o_e_r_s file is currently being edited you will receive a message to try again later. - There is a hard-coded list of editors that vviissuuddoo will use set at - compile-time that may be overridden via the _e_d_i_t_o_r _s_u_d_o_e_r_s Default - variable. This list defaults to the path to _v_i(1) on your system, as - determined by the _c_o_n_f_i_g_u_r_e script. Normally, vviissuuddoo does not honor - the VISUAL or EDITOR environment variables unless they contain an - editor in the aforementioned editors list. However, if vviissuuddoo is - configured with the _-_-_w_i_t_h_-_e_n_v_e_d_i_t_o_r option or the _e_n_v___e_d_i_t_o_r Default - variable is set in _s_u_d_o_e_r_s, vviissuuddoo will use any the editor defines by - VISUAL or EDITOR. Note that this can be a security hole since it - allows the user to execute any program they wish simply by setting - VISUAL or EDITOR. + There is a hard-coded list of one or more editors that vviissuuddoo will use + set at compile-time that may be overridden via the _e_d_i_t_o_r _s_u_d_o_e_r_s + Default variable. This list defaults to "vi". Normally, vviissuuddoo does + not honor the VISUAL or EDITOR environment variables unless they + contain an editor in the aforementioned editors list. However, if + vviissuuddoo is configured with the _-_-_w_i_t_h_-_e_n_v_-_e_d_i_t_o_r option or the + _e_n_v___e_d_i_t_o_r Default variable is set in _s_u_d_o_e_r_s, vviissuuddoo will use any the + editor defines by VISUAL or EDITOR. Note that this can be a security + hole since it allows the user to execute any program they wish simply + by setting VISUAL or EDITOR. vviissuuddoo parses the _s_u_d_o_e_r_s file after the edit and will not save the changes if there is a syntax error. Upon finding an error, vviissuuddoo will @@ -58,10 +57,11 @@ OOPPTTIIOONNSS appended to it. -q Enable qquuiieett mode. In this mode details about syntax + errors are not printed. This option is only useful when -1.8.0b1 June 11, 2010 1 +1.8.0b1 July 14, 2010 1 @@ -70,7 +70,6 @@ OOPPTTIIOONNSS VISUDO(1m) MAINTENANCE COMMANDS VISUDO(1m) - errors are not printed. This option is only useful when combined with the --cc option. -s Enable ssttrriicctt checking of the _s_u_d_o_e_r_s file. If an alias is @@ -124,10 +123,11 @@ SSEEEE AALLSSOO AAUUTTHHOORR Many people have worked on _s_u_d_o over the years; this version of vviissuuddoo + was written by: -1.8.0b1 June 11, 2010 2 +1.8.0b1 July 14, 2010 2 @@ -136,8 +136,6 @@ AAUUTTHHOORR VISUDO(1m) MAINTENANCE COMMANDS VISUDO(1m) - was written by: - Todd Miller See the HISTORY file in the sudo distribution or visit @@ -193,6 +191,8 @@ DDIISSCCLLAAIIMMEERR -1.8.0b1 June 11, 2010 3 + + +1.8.0b1 July 14, 2010 3 diff --git a/doc/visudo.man.in b/doc/visudo.man.in index 0754b8c1f..fc0124ca7 100644 --- a/doc/visudo.man.in +++ b/doc/visudo.man.in @@ -144,7 +144,7 @@ .\" ======================================================================== .\" .IX Title "VISUDO @mansectsu@" -.TH VISUDO @mansectsu@ "June 11, 2010" "1.8.0b1" "MAINTENANCE COMMANDS" +.TH VISUDO @mansectsu@ "July 14, 2010" "1.8.0b1" "MAINTENANCE COMMANDS" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -162,13 +162,12 @@ simultaneous edits, provides basic sanity checks, and checks for parse errors. If the \fIsudoers\fR file is currently being edited you will receive a message to try again later. .PP -There is a hard-coded list of editors that \fBvisudo\fR will use set -at compile-time that may be overridden via the \fIeditor\fR \fIsudoers\fR -\&\f(CW\*(C`Default\*(C'\fR variable. This list defaults to the path to \fIvi\fR\|(1) on -your system, as determined by the \fIconfigure\fR script. Normally, +There is a hard-coded list of one or more editors that \fBvisudo\fR will +use set at compile-time that may be overridden via the \fIeditor\fR \fIsudoers\fR +\&\f(CW\*(C`Default\*(C'\fR variable. This list defaults to \f(CW"@editor@"\fR. Normally, \&\fBvisudo\fR does not honor the \f(CW\*(C`VISUAL\*(C'\fR or \f(CW\*(C`EDITOR\*(C'\fR environment variables unless they contain an editor in the aforementioned editors -list. However, if \fBvisudo\fR is configured with the \fI\-\-with\-enveditor\fR +list. However, if \fBvisudo\fR is configured with the \fI\-\-with\-env\-editor\fR option or the \fIenv_editor\fR \f(CW\*(C`Default\*(C'\fR variable is set in \fIsudoers\fR, \&\fBvisudo\fR will use any the editor defines by \f(CW\*(C`VISUAL\*(C'\fR or \f(CW\*(C`EDITOR\*(C'\fR. Note that this can be a security hole since it allows the user to diff --git a/doc/visudo.pod b/doc/visudo.pod index 474b72d3d..d5d51f1a7 100644 --- a/doc/visudo.pod +++ b/doc/visudo.pod @@ -36,13 +36,12 @@ simultaneous edits, provides basic sanity checks, and checks for parse errors. If the I file is currently being edited you will receive a message to try again later. -There is a hard-coded list of editors that B will use set -at compile-time that may be overridden via the I I -C variable. This list defaults to the path to L on -your system, as determined by the I script. Normally, +There is a hard-coded list of one or more editors that B will +use set at compile-time that may be overridden via the I I +C variable. This list defaults to C<"@editor@">. Normally, B does not honor the C or C environment variables unless they contain an editor in the aforementioned editors -list. However, if B is configured with the I<--with-enveditor> +list. However, if B is configured with the I<--with-env-editor> option or the I C variable is set in I, B will use any the editor defines by C or C. Note that this can be a security hole since it allows the user to