From 3a3c4bc49351641c9bf4fbd67497d782da53a361 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Wed, 14 Jul 2010 08:56:06 -0400 Subject: [PATCH] Substitute the value of EDITOR into the sudoers and visudo manuals. --HG-- branch : 1.7 --- aclocal.m4 | 32 ++++++------- configure | 92 ++++++++++++++----------------------- configure.in | 9 ++-- sudoers.cat | 122 ++++++++++++++++++++++++------------------------- sudoers.man.in | 13 ++++-- sudoers.pod | 11 +++-- visudo.cat | 34 +++++++------- visudo.man.in | 11 ++--- visudo.pod | 9 ++-- 9 files changed, 158 insertions(+), 175 deletions(-) diff --git a/aclocal.m4 b/aclocal.m4 index 75381e1b9..6901da05f 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -35,25 +35,19 @@ fi ])dnl dnl -dnl check for vi -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 +dnl check for vi in well-known locations +dnl +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 34afc03ca..83043f8ab 100755 --- a/configure +++ b/configure @@ -784,6 +784,7 @@ OBJEXT EXEEXT ac_ct_CC CC +editor secure_path netsvc_conf nsswitch_conf @@ -2768,6 +2769,7 @@ $as_echo "$as_me: Configuring Sudo version $PACKAGE_VERSION" >&6;} + # @@ -4670,6 +4672,7 @@ _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_editor" >&5 $as_echo "$with_editor" >&6; } + editor="$with_editor" ;; esac else @@ -5070,10 +5073,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:6628: $ac_compile\"" >&5) + (eval echo "\"\$as_me:6630: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:6631: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:6633: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:6634: output\"" >&5) + (eval echo "\"\$as_me:6636: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -7836,7 +7838,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 7839 "configure"' > conftest.$ac_ext + echo '#line 7841 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -9229,11 +9231,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:9232: $lt_compile\"" >&5) + (eval echo "\"\$as_me:9234: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:9236: \$? = $ac_status" >&5 + echo "$as_me:9238: \$? = $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. @@ -9568,11 +9570,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:9571: $lt_compile\"" >&5) + (eval echo "\"\$as_me:9573: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:9575: \$? = $ac_status" >&5 + echo "$as_me:9577: \$? = $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. @@ -9673,11 +9675,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:9676: $lt_compile\"" >&5) + (eval echo "\"\$as_me:9678: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:9680: \$? = $ac_status" >&5 + echo "$as_me:9682: \$? = $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 @@ -9728,11 +9730,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:9731: $lt_compile\"" >&5) + (eval echo "\"\$as_me:9733: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:9735: \$? = $ac_status" >&5 + echo "$as_me:9737: \$? = $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 @@ -12095,7 +12097,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12098 "configure" +#line 12100 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12191,7 +12193,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12194 "configure" +#line 12196 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -13614,42 +13616,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" -EOF - -elif test -f "/usr/ucb/vi"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: /usr/ucb/vi" >&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" +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 "not found" >&6; } fi @@ -18290,18 +18270,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 @@ -1357,7 +1356,13 @@ I/O log files =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/visudo.cat b/visudo.cat index e72311c46..c99374f8f 100644 --- a/visudo.cat +++ b/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.7.4 July 12, 2010 1 +1.7.4 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.7.4 July 12, 2010 2 +1.7.4 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.7.4 July 12, 2010 3 + + +1.7.4 July 14, 2010 3 diff --git a/visudo.man.in b/visudo.man.in index 1423451c4..563fd3bce 100644 --- a/visudo.man.in +++ b/visudo.man.in @@ -144,7 +144,7 @@ .\" ======================================================================== .\" .IX Title "VISUDO @mansectsu@" -.TH VISUDO @mansectsu@ "July 12, 2010" "1.7.4" "MAINTENANCE COMMANDS" +.TH VISUDO @mansectsu@ "July 14, 2010" "1.7.4" "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/visudo.pod b/visudo.pod index b68723c86..ccc5c00b2 100644 --- a/visudo.pod +++ b/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 -- 2.40.0