From de41bbd471cbac5ef1a9da20fe990a5bd7d4b271 Mon Sep 17 00:00:00 2001 From: Jouke Witteveen Date: Sat, 26 Oct 2013 10:45:17 +0200 Subject: 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 --- src/wifi-menu | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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],,} -- cgit v1.2.3-24-g4f1b