summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouke Witteveen <j.witteveen@gmail.com>2013-10-26 10:45:17 +0200
committerJouke Witteveen <j.witteveen@gmail.com>2013-10-26 17:29:32 +0200
commitde41bbd471cbac5ef1a9da20fe990a5bd7d4b271 (patch)
treecf29ddd51df862d647b4c359efc1276555986d8e
parent120d94020aed8d8b5e1b76dc7ee03fa062fab26c (diff)
downloadnetctl-de41bbd471cbac5ef1a9da20fe990a5bd7d4b271.tar.gz
netctl-de41bbd471cbac5ef1a9da20fe990a5bd7d4b271.tar.xz
wifi-menu: ask for a name for the new profile
Some abuse of the stack, but that should be no problem: the user has to enter around 10000 existing profile names which (s)he does not want to overwrite before a stack overflow occurs. Feature suggested by: Paul Bienkowski <opatutlol@aol.com>
-rwxr-xr-xsrc/wifi-menu16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/wifi-menu b/src/wifi-menu
index a62881e..455cdc9 100755
--- a/src/wifi-menu
+++ b/src/wifi-menu
@@ -93,12 +93,28 @@ ssid_to_profile()
return 1
}
+# Ask the user for the name of the new profile
+confirm_profile()
+{
+ local msg="Enter a name for the new profile\n"
+ PROFILE=$(dialog --inputbox "$msg" 10 50 "$PROFILE" --stdout) || return $?
+ if [[ $PROFILE = */* ]]; then
+ PROFILE=${PROFILE//\//_}
+ confirm_profile
+ elif [[ -e "$PROFILE_DIR/$PROFILE" ]]; then
+ msg="A profile by the name '$PROFILE' already exists.
+Do you want to overwrite it?"
+ dialog --yesno "$msg" 10 50 --stdout || confirm_profile
+ fi
+}
+
# Creates a profile for ssid $1.
create_profile()
{
local box flags key msg security
PROFILE="$INTERFACE-${1//\//_}"
[[ -e "$PROFILE_DIR/$PROFILE" ]] && PROFILE+=".wifi-menu"
+ confirm_profile || return $?
flags=$(grep -m 1 $'\t'"$1\$" "$NETWORKS" | cut -f 2)
if [[ "$flags" =~ WPA|WEP ]]; then
security=${BASH_REMATCH[0],,}