Deleted Added
full compact
mustberoot.subr (240783) mustberoot.subr (241653)
1if [ ! "$_MUSTBEROOT_SUBR" ]; then _MUSTBEROOT_SUBR=1
2#
3# Copyright (c) 2006-2012 Devin Teske
4# All Rights Reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:

--- 10 unchanged lines hidden (view full) ---

19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25# SUCH DAMAGE.
26#
1if [ ! "$_MUSTBEROOT_SUBR" ]; then _MUSTBEROOT_SUBR=1
2#
3# Copyright (c) 2006-2012 Devin Teske
4# All Rights Reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:

--- 10 unchanged lines hidden (view full) ---

19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25# SUCH DAMAGE.
26#
27# $FreeBSD: head/usr.sbin/bsdconfig/share/mustberoot.subr 240783 2012-09-21 19:03:25Z dteske $
27# $FreeBSD: head/usr.sbin/bsdconfig/share/mustberoot.subr 241653 2012-10-17 21:48:45Z dteske $
28#
29############################################################ INCLUDES
30
31BSDCFG_SHARE="/usr/share/bsdconfig"
32. $BSDCFG_SHARE/common.subr || exit 1
33f_include $BSDCFG_SHARE/dialog.subr
34
35BSDCFG_LIBE="/usr/libexec/bsdconfig"

--- 42 unchanged lines hidden (view full) ---

78{
79 local msg hline size
80
81 [ "$( id -u )" = "0" ] && return $SUCCESS
82
83 f_have sudo || f_die 1 "$msg_must_be_root_to_execute" "$pgm"
84
85 #
28#
29############################################################ INCLUDES
30
31BSDCFG_SHARE="/usr/share/bsdconfig"
32. $BSDCFG_SHARE/common.subr || exit 1
33f_include $BSDCFG_SHARE/dialog.subr
34
35BSDCFG_LIBE="/usr/libexec/bsdconfig"

--- 42 unchanged lines hidden (view full) ---

78{
79 local msg hline size
80
81 [ "$( id -u )" = "0" ] && return $SUCCESS
82
83 f_have sudo || f_die 1 "$msg_must_be_root_to_execute" "$pgm"
84
85 #
86 # Ask the user if it's OK to become root via sudo(8) and give them
87 # the option to save this preference (by touch(1)ing a file in the
88 # user's $HOME directory).
89 #
90 local checkpath="${HOME%/}/.bsdconfig_uses_sudo"
91 if [ ! -e "$checkpath" ]; then
92 msg=$( printf "$msg_always_try_sudo_when_run_as" "$USER" )
93 local menu_list="
94 'X' '$msg_cancel_exit'
95 '1' '$msg'
96 '2' '$msg_try_sudo_only_this_once'
97 " # END-QUOTE
98 msg=$( printf "$msg_you_are_not_root_but" bsdconfig )
99 hline="$hline_arrows_tab_enter"
100 size=$( eval f_dialog_menu_size \
101 \"\$DIALOG_TITLE\" \
102 \"\$DIALOG_BACKTITLE\" \
103 \"\$msg\" \
104 \"\$hline\" \
105 $menu_list )
106
107 local dialog_menu mtag retval
108 dialog_menu=$( eval $DIALOG \
109 --title \"\$DIALOG_TITLE\" \
110 --backtitle \"\$DIALOG_BACKTITLE\" \
111 --hline \"\$hline\" \
112 --ok-label \"\$msg_ok\" \
113 --cancel-label \"\$msg_cancel\" \
114 --menu \"\$msg\" $size \
115 $menu_list \
116 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD
117 )
118 retval=$?
119 setvar DIALOG_MENU_$$ "$dialog_menu"
120 mtag=$( f_dialog_menutag )
121
122 [ $retval -eq 0 ] || f_die
123
124 case "$mtag" in
125 X) # Cancel/Exit
126 f_die ;;
127 1) # Always try sudo(8) when run as $user
128 local err
129 if ! err=$( touch "$checkpath" 2>&1 ); then
130 f_show_msg "%s" "$err"
131 else
132 f_show_msg "$msg_created_path" "$checkpath"
133 fi
134 esac
135 else
136 #
137 # This user has created the path signing-off on sudo(8)-use
138 # but let's still give them a short/quick/unobtrusive reminder
139 #
140 f_dialog_info "$msg_becoming_root_via_sudo"
141 [ "$USE_XDIALOG" ] || sleep 0.6
142 fi
143
144 #
86 # Check sudo(8) access before prompting for password.
87 #
88 :| sudo -S -v 2> /dev/null
89 if [ $? -ne $SUCCESS ]; then
90 #
91 # sudo(8) access denied. Prompt for their password.
92 #
93 msg="$msg_please_enter_password"

--- 272 unchanged lines hidden ---
145 # Check sudo(8) access before prompting for password.
146 #
147 :| sudo -S -v 2> /dev/null
148 if [ $? -ne $SUCCESS ]; then
149 #
150 # sudo(8) access denied. Prompt for their password.
151 #
152 msg="$msg_please_enter_password"

--- 272 unchanged lines hidden ---