summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsdconfig/usermgmt
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/bsdconfig/usermgmt')
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/groupadd4
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/groupdel4
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/groupedit4
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/groupinput46
-rw-r--r--usr.sbin/bsdconfig/usermgmt/share/group_input.subr9
-rw-r--r--usr.sbin/bsdconfig/usermgmt/share/user_input.subr8
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/useradd4
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/userdel4
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/useredit4
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/userinput93
-rwxr-xr-xusr.sbin/bsdconfig/usermgmt/usermgmt4
11 files changed, 74 insertions, 110 deletions
diff --git a/usr.sbin/bsdconfig/usermgmt/groupadd b/usr.sbin/bsdconfig/usermgmt/groupadd
index 6f806a6..62f062d 100755
--- a/usr.sbin/bsdconfig/usermgmt/groupadd
+++ b/usr.sbin/bsdconfig/usermgmt/groupadd
@@ -36,8 +36,8 @@ f_include $BSDCFG_SHARE/dialog.subr
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt"
-ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
-[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
+ pgm="${ipgm:-$pgm}"
############################################################ MAIN
diff --git a/usr.sbin/bsdconfig/usermgmt/groupdel b/usr.sbin/bsdconfig/usermgmt/groupdel
index 2f41164..aa1c305 100755
--- a/usr.sbin/bsdconfig/usermgmt/groupdel
+++ b/usr.sbin/bsdconfig/usermgmt/groupdel
@@ -39,8 +39,8 @@ f_include $BSDCFG_SHARE/usermgmt/group_input.subr
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt"
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
-ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
-[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
+ pgm="${ipgm:-$pgm}"
############################################################ MAIN
diff --git a/usr.sbin/bsdconfig/usermgmt/groupedit b/usr.sbin/bsdconfig/usermgmt/groupedit
index 3eacaff..953f4f5 100755
--- a/usr.sbin/bsdconfig/usermgmt/groupedit
+++ b/usr.sbin/bsdconfig/usermgmt/groupedit
@@ -39,8 +39,8 @@ f_include $BSDCFG_SHARE/usermgmt/group_input.subr
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt"
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
-ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
-[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
+ pgm="${ipgm:-$pgm}"
############################################################ MAIN
diff --git a/usr.sbin/bsdconfig/usermgmt/groupinput b/usr.sbin/bsdconfig/usermgmt/groupinput
index 5b60bb2..f98e890 100755
--- a/usr.sbin/bsdconfig/usermgmt/groupinput
+++ b/usr.sbin/bsdconfig/usermgmt/groupinput
@@ -39,8 +39,8 @@ f_include $BSDCFG_SHARE/usermgmt/group_input.subr
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt"
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
-ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
-[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
+ pgm="${ipgm:-$pgm}"
############################################################ CONFIGURATION
@@ -56,16 +56,12 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
#
save_changes()
{
- local err retval=$SUCCESS
+ local funcname=save_changes
case "$mode" in
Delete)
- err=$( pw groupdel "$group_name" 2>&1 )
- retval=$?
- if [ $retval -ne $SUCCESS ]; then
- f_dialog_msgbox "$msg_error $err\n"
- return $retval
- fi
+ f_eval_catch $funcname pw 'pw groupdel "%s"' "$group_name" ||
+ return $?
f_show_msg "$msg_group_deleted"
;;
Add)
@@ -74,17 +70,13 @@ save_changes()
[ "$group_members" != "$cur_group_members" ] &&
cmd="$cmd -M '$group_members'"
if [ "$pw_group_password_disable" ]; then
- cmd="$cmd -h -"
+ f_eval_catch $funcname pw '%s -h -' "$cmd"
elif [ "$group_password" ]; then
- cmd="echo \"\$group_password\" | $cmd -h 0"
- fi
- f_dprintf "cmd=%s" "$cmd"
- err=$( eval $cmd 2>&1 )
- retval=$?
- if [ $retval -ne $SUCCESS ]; then
- f_dialog_msgbox "$msg_error $err\n"
- return $retval
- fi
+ echo "$group_password" |
+ f_eval_catch $funcname pw '%s -h 0' "$cmd"
+ else
+ f_eval_catch $funcname pw '%s' "$cmd"
+ fi || return $?
f_show_msg "$msg_group_added"
;;
Edit/View)
@@ -93,17 +85,13 @@ save_changes()
[ "$group_members" != "$cur_group_members" ] &&
cmd="$cmd -M '$group_members'"
if [ "$pw_group_password_disable" ]; then
- cmd="$cmd -h -"
+ f_eval_catch $funcname pw '%s -h -' "$cmd"
elif [ "$group_password" ]; then
- cmd="echo \"\$group_password\" | $cmd -h 0"
- fi
- f_dprintf "cmd=%s" "$cmd"
- err=$( eval $cmd 2>&1 )
- retval=$?
- if [ $retval -ne $SUCCESS ]; then
- f_dialog_msgbox "$msg_error $err\n"
- return $retval
- fi
+ echo "$group_password" |
+ f_eval_catch $funcname pw '%s -h 0' "$cmd"
+ else
+ f_eval_catch $funcname pw '%s' "$cmd"
+ fi || return $?
f_show_msg "$msg_group_updated"
;;
esac
diff --git a/usr.sbin/bsdconfig/usermgmt/share/group_input.subr b/usr.sbin/bsdconfig/usermgmt/share/group_input.subr
index 2ca141e..e0f47f7 100644
--- a/usr.sbin/bsdconfig/usermgmt/share/group_input.subr
+++ b/usr.sbin/bsdconfig/usermgmt/share/group_input.subr
@@ -371,15 +371,12 @@ f_dialog_input_group_members()
# pressed ESC or chose Cancel/No
f_dialog_data_sanitize _group_members
+ #
# Convert the newline separated list into a comma-
# separated one so that if the user switches over to
# manual editing, list reflects checklist selections
- _group_members=$( echo "$_group_members" |
- tr '\n' ' ' |
- sed -e 's/[[:space:]]\{1,\}/,/g;s/^,//;s/,$//'
- )
-
- _input="$_group_members"
+ #
+ f_replaceall "$_group_members" "[$IFS]" "," _input
;;
2) # Enter Group Members manually
local p="$msg_group_members ($msg_separated_by_commas)"
diff --git a/usr.sbin/bsdconfig/usermgmt/share/user_input.subr b/usr.sbin/bsdconfig/usermgmt/share/user_input.subr
index bd2fc9b..c95685c 100644
--- a/usr.sbin/bsdconfig/usermgmt/share/user_input.subr
+++ b/usr.sbin/bsdconfig/usermgmt/share/user_input.subr
@@ -599,8 +599,8 @@ f_dialog_input_expire_password()
4) # Enter value manually
local msg ret_secs
- msg=$( printf "$msg_number_of_seconds_since_epoch" \
- "$( date -r 1 "+%c %Z" )" )
+ f_sprintf msg "$msg_number_of_seconds_since_epoch" \
+ "$( date -r 1 "+%c %Z" )"
# Return to menu if either ESC or Cancel/No
f_dialog_input ret_secs \
@@ -783,8 +783,8 @@ f_dialog_input_expire_account()
4) # Enter value manually
local msg ret_secs
- msg=$( printf "$msg_number_of_seconds_since_epoch" \
- "$( date -r 1 "+%c %Z" )" )
+ f_sprintf msg "$msg_number_of_seconds_since_epoch" \
+ "$( date -r 1 "+%c %Z" )"
# Return to menu if either ESC or Cancel/No
f_dialog_input ret_secs "$msg" \
diff --git a/usr.sbin/bsdconfig/usermgmt/useradd b/usr.sbin/bsdconfig/usermgmt/useradd
index b8cac27..2d6b4d0 100755
--- a/usr.sbin/bsdconfig/usermgmt/useradd
+++ b/usr.sbin/bsdconfig/usermgmt/useradd
@@ -36,8 +36,8 @@ f_include $BSDCFG_SHARE/dialog.subr
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt"
-ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
-[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
+ pgm="${ipgm:-$pgm}"
############################################################ MAIN
diff --git a/usr.sbin/bsdconfig/usermgmt/userdel b/usr.sbin/bsdconfig/usermgmt/userdel
index 299e25b..33aa062 100755
--- a/usr.sbin/bsdconfig/usermgmt/userdel
+++ b/usr.sbin/bsdconfig/usermgmt/userdel
@@ -39,8 +39,8 @@ f_include $BSDCFG_SHARE/usermgmt/user_input.subr
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt"
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
-ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
-[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
+ pgm="${ipgm:-$pgm}"
############################################################ MAIN
diff --git a/usr.sbin/bsdconfig/usermgmt/useredit b/usr.sbin/bsdconfig/usermgmt/useredit
index a4bee68..30ee578 100755
--- a/usr.sbin/bsdconfig/usermgmt/useredit
+++ b/usr.sbin/bsdconfig/usermgmt/useredit
@@ -39,8 +39,8 @@ f_include $BSDCFG_SHARE/usermgmt/user_input.subr
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt"
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
-ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
-[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
+ pgm="${ipgm:-$pgm}"
############################################################ MAIN
diff --git a/usr.sbin/bsdconfig/usermgmt/userinput b/usr.sbin/bsdconfig/usermgmt/userinput
index aad6ef3..5cf5554 100755
--- a/usr.sbin/bsdconfig/usermgmt/userinput
+++ b/usr.sbin/bsdconfig/usermgmt/userinput
@@ -39,8 +39,8 @@ f_include $BSDCFG_SHARE/usermgmt/user_input.subr
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="070.usermgmt"
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
-ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
-[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
+ pgm="${ipgm:-$pgm}"
############################################################ CONFIGURATION
@@ -74,29 +74,24 @@ copy_dotfiles()
#
save_changes()
{
- local err retval=$SUCCESS
+ local funcname=save_changes
case "$mode" in
Delete)
- err=$( pw userdel -u "$pw_uid" 2>&1 )
- retval=$?
- if [ $retval -ne $SUCCESS ]; then
- f_dialog_msgbox "$msg_error $err\n"
- return $retval
- fi
+ f_eval_catch $funcname pw 'pw userdel -u "%s"' "$pw_uid" ||
+ return $?
f_show_msg "$msg_login_deleted"
if [ "$pw_group_delete" = "$msg_yes" ] &&
f_quietly pw groupshow -g "$pw_gid"
then
- err=$( pw groupdel -g "$pw_gid" 2>&1 ) ||
- f_dialog_msgbox "$msg_warning $err\n"
+ f_eval_catch $funcname pw \
+ 'pw groupdel -g "%s"' "$pw_gid"
fi
if [ "$pw_home_delete" = "$msg_yes" ]; then
f_dialog_info "$msg_deleting_home_directory"
- err=$( rm -Rf "$pw_home_dir" 2>&1 ) ||
- f_dialog_msgbox "$msg_warning $err\n"
+ f_eval_catch $funcname rm 'rm -Rf "%s"' "$pw_home_dir"
fi
;;
Add)
@@ -111,35 +106,27 @@ save_changes()
[ "$pw_shell" ] && cmd="$cmd -s '$pw_shell'"
[ "$pw_uid" ] && cmd="$cmd -u '$pw_uid'"
if [ "$pw_password_disable" ]; then
- cmd="$cmd -h -"
+ f_eval_catch $funcname pw '%s -h -' "$cmd"
elif [ "$pw_password" ]; then
- cmd="echo \"\$pw_password\" | $cmd -h 0"
- fi
- f_dprintf "cmd=%s" "$cmd"
- err=$( eval $cmd 2>&1 )
- retval=$?
- if [ $retval -ne $SUCCESS ]; then
- f_dialog_msgbox "$msg_error $err\n"
- return $retval
- fi
+ echo "$pw_password" |
+ f_eval_catch $funcname pw '%s -h 0' "$cmd"
+ else
+ f_eval_catch $funcname pw '%s' "$cmd"
+ fi || return $?
f_show_msg "$msg_login_added"
if [ "$pw_home_create" = "$msg_yes" ]; then
- err=$( mkdir -p "$pw_home_dir" 2>&1 )
- if [ $? -ne $SUCCESS ]; then
- f_dialog_msgbox "$msg_warning $err\n"
- elif [ -e "$pw_home_dir" ]; then
- err=$( chown -R "$pw_uid:$pw_gid" \
- "$pw_home_dir" 2>&1 )
- [ $? -eq $SUCCESS ] ||
- f_dialog_msgbox "$msg_warning $err\n"
+ if f_eval_catch $funcname mkdir \
+ 'mkdir -p "%s"' "$pw_home_dir"
+ then
+ f_eval_catch $funcname chown \
+ 'chown -R "%s" "%s"' \
+ "$pw_uid:$pw_gid" "$pw_home_dir"
fi
fi
- if [ "$pw_dotfiles_create" = "$msg_yes" ]; then
- err=$( copy_dotfiles 2>&1 ) ||
- f_dialog_msgbox "$msg_warning $err\n"
- fi
+ [ "$pw_dotfiles_create" = "$msg_yes" ] &&
+ f_eval_catch $funcname copy_dotfiles copy_dotfiles
user="$pw_name"
f_quietly pw usershow -n "$pw_name" &&
@@ -157,35 +144,27 @@ save_changes()
[ "$pw_shell" ] && cmd="$cmd -s '$pw_shell'"
[ "$pw_uid" ] && cmd="$cmd -u '$pw_uid'"
if [ "$pw_password_disable" ]; then
- cmd="$cmd -h -"
+ f_eval_catch $funcname pw '%s -h -' "$cmd"
elif [ "$pw_password" ]; then
- cmd="echo \"\$pw_password\" | $cmd -h 0"
- fi
- f_dprintf "cmd=%s" "$cmd"
- err=$( eval $cmd 2>&1 )
- retval=$?
- if [ $retval -ne $SUCCESS ]; then
- f_dialog_msgbox "$msg_error $err\n"
- return $retval
- fi
+ echo "$pw_password" |
+ f_eval_catch $funcname pw '%s -h 0' "$cmd"
+ else
+ f_eval_catch $funcname pw '%s' "$cmd"
+ fi || return $?
f_show_msg "$msg_login_updated"
if [ "$pw_home_create" = "$msg_yes" ]; then
- err=$( mkdir -p "$pw_home_dir" )
- if [ $? -ne $SUCCESS ]; then
- f_dialog_msgbox "$msg_warning $err\n"
- elif [ -e "$pw_home_dir" ]; then
- err=$( chown -R "$pw_uid:$pw_gid" \
- "$pw_home_dir" 2>&1 )
- [ $? -eq $SUCCESS ] ||
- f_dialog_msgbox "$msg_warning $err\n"
+ if f_eval_catch $funcname mkdir \
+ 'mkdir -p "%s"' "$pw_home_dir"
+ then
+ f_eval_catch $funcname chown \
+ 'chown -R "%i:%i" "%s"' \
+ "$pw_uid" "$pw_gid" "$pw_home_dir"
fi
fi
- if [ "$pw_dotfiles_create" = "$msg_yes" ]; then
- err=$( copy_dotfiles 2>&1 ) ||
- f_dialog_msgbox "$msg_warning $err\n"
- fi
+ [ "$pw_dotfiles_create" = "$msg_yes" ] &&
+ f_eval_catch $funcname copy_dotfiles copy_dotfiles
;;
esac
diff --git a/usr.sbin/bsdconfig/usermgmt/usermgmt b/usr.sbin/bsdconfig/usermgmt/usermgmt
index 5335bd6..79fbc95 100755
--- a/usr.sbin/bsdconfig/usermgmt/usermgmt
+++ b/usr.sbin/bsdconfig/usermgmt/usermgmt
@@ -40,8 +40,8 @@ f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
USERMGMT_HELPFILE=$BSDCFG_LIBE/$APP_DIR/include/usermgmt.hlp
-ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
-[ $? -eq $SUCCESS -a "$ipgm" ] && pgm="$ipgm"
+f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ipgm &&
+ pgm="${ipgm:-$pgm}"
############################################################ FUNCTIONS
OpenPOWER on IntegriCloud