diff options
author | dteske <dteske@FreeBSD.org> | 2013-04-22 05:52:06 +0000 |
---|---|---|
committer | dteske <dteske@FreeBSD.org> | 2013-04-22 05:52:06 +0000 |
commit | 8f385d0e89111ca1716767f7dc0bdffe3225b3d0 (patch) | |
tree | cbdec6b0e95d9d7f693f2585627e66aaf3fa13ff /usr.sbin/bsdconfig/security | |
parent | 2cbbbe9342ffd4b6a5fc07b551f747bfb7d8172c (diff) | |
download | FreeBSD-src-8f385d0e89111ca1716767f7dc0bdffe3225b3d0.zip FreeBSD-src-8f385d0e89111ca1716767f7dc0bdffe3225b3d0.tar.gz |
UI improvements. First, implement --default-item whenever and wherever
possible to save keystrokes. Second, overhaul startup/rcdelete for much
improved performance. Last, but not least, kill-off useage of --clear
and implement --keep-tite in harmony to minimize jarring transitions.
Also, fix local variable names where necessary while we're here with
other minor comment-enhancements/typo-corrections.
Diffstat (limited to 'usr.sbin/bsdconfig/security')
-rwxr-xr-x | usr.sbin/bsdconfig/security/kern_securelevel | 17 | ||||
-rwxr-xr-x | usr.sbin/bsdconfig/security/security | 54 |
2 files changed, 52 insertions, 19 deletions
diff --git a/usr.sbin/bsdconfig/security/kern_securelevel b/usr.sbin/bsdconfig/security/kern_securelevel index 5307bca..61ad9bf 100755 --- a/usr.sbin/bsdconfig/security/kern_securelevel +++ b/usr.sbin/bsdconfig/security/kern_securelevel @@ -51,12 +51,11 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ) # dialog_menu_main() { - local menu_list size + local menu_list size defaultitem= local hline="$hline_select_securelevel_to_operate_at" local prompt="$msg_securelevels_menu_text" menu_list=" - 'X $msg_exit' '$msg_exit_this_menu' '$msg_disabled' '$msg_disable_securelevels' '$msg_secure' '$msg_secure_mode' '$msg_highly_secure' '$msg_highly_secure_mode' @@ -70,9 +69,20 @@ dialog_menu_main() \"\$hline\" \ $menu_list ) + case "$( f_sysrc_get kern_securelevel_enable )" in + [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) + case "$( f_sysrc_get kern_securelevel )" in + 1) defaultitem="$msg_secure" ;; + 2) defaultitem="$msg_highly_secure" ;; + 3) defaultitem="$msg_network_secure" ;; + esac ;; + *) + defaultitem="$msg_disabled" + esac + local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ + --title \"\$DIALOG_TITLE\" \ --backtitle \"\$DIALOG_BACKTITLE\" \ --hline \"\$hline\" \ --ok-label \"\$msg_ok\" \ @@ -80,6 +90,7 @@ dialog_menu_main() --help-button \ --help-label \"\$msg_help\" \ ${USE_XDIALOG:+--help \"\"} \ + --default-item \"\$defaultitem\" \ --menu \"\$prompt\" $size \ $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD diff --git a/usr.sbin/bsdconfig/security/security b/usr.sbin/bsdconfig/security/security index ff582ad..ba9f9e2 100755 --- a/usr.sbin/bsdconfig/security/security +++ b/usr.sbin/bsdconfig/security/security @@ -49,36 +49,53 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" ) # dialog_menu_main() { - local menu_list size + local menu_list size mark=" " defaultitem= local hline="$hline_arrows_tab_enter" local prompt="$msg_menu_text" + # Obtain default-item (adjusted below for dynamic tags) + f_getvar DEFAULTITEM_$$ defaultitem + local ditem="${defaultitem%%[$IFS]*}" + menu_list=" 'X <<< $msg_exit' '$msg_exit_this_menu' " # END-QUOTE + # + # Add dynamically tagged entry for kern_securelevels + # case "$( f_sysrc_get kern_securelevel_enable )" in [Yy][Ee][Ss]) local kern_securelevel="$( f_sysrc_get kern_securelevel )" if [ ${#kern_securelevel} -eq 1 ] && - f_isinteger "$kern_securelevel" - then menu_list="$menu_list - '2 [$kern_securelevel] $msg_securelevel'" - else menu_list="$menu_list - '2 [X] $msg_securelevel'" - fi - menu_list="$menu_list '$msg_securelevel_desc'" - ;; - *) menu_list="$menu_list - '2 [ ] $msg_securelevel' '$msg_securelevel_desc'" + f_isinteger "$kern_securelevel" && + [ $kern_securelevel -lt 9 ] + then + mark="$kern_securelevel" + else + mark="X" + fi ;; + *) + mark=" " esac + menu_list="$menu_list + '2 [$mark] $msg_securelevel' '$msg_securelevel_desc'" + + # Update default-item if appropriate + [ "$ditem" = 2 ] && defaultitem="2 [$mark] $msg_securelevel" + # + # Add dynamically tagged entry for nfs_reserved_port_only + # case "$( f_sysrc_get nfs_reserved_port_only )" in - [Yy][Ee][Ss]) menu_list="$menu_list - '3 [X] $msg_nfs_port' '$msg_nfs_port_desc'";; - *) menu_list="$menu_list - '3 [ ] $msg_nfs_port' '$msg_nfs_port_desc'";; + [Yy][Ee][Ss]) mark="X" ;; + *) mark=" " ;; esac + menu_list="$menu_list + '3 [$mark] $msg_nfs_port' '$msg_nfs_port_desc'" + + # Update default-item if appropriate + [ "$ditem" = 3 ] && defaultitem="3 [$mark] $msg_nfs_port" size=$( eval f_dialog_menu_size \ \"\$DIALOG_TITLE\" \ @@ -89,17 +106,22 @@ dialog_menu_main() local dialog_menu dialog_menu=$( eval $DIALOG \ - --clear --title \"\$DIALOG_TITLE\" \ + --title \"\$DIALOG_TITLE\" \ --backtitle \"\$DIALOG_BACKTITLE\" \ --hline \"\$hline\" \ --ok-label \"\$msg_ok\" \ --cancel-label \"\$msg_cancel\" \ + --default-item \"\$defaultitem\" \ --menu \"\$prompt\" $size \ $menu_list \ 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) local retval=$? setvar DIALOG_MENU_$$ "$dialog_menu" + + # Only update default-item on success + [ $retval -eq 0 ] && setvar DEFAULTITEM_$$ "$dialog_menu" + return $retval } |