Block empty form submissions

Signed-off-by: Georg <georg@lysergic.dev>
This commit is contained in:
Georg Pfuetzenreuter 2021-09-26 13:50:07 +02:00
parent 7885aa340c
commit 6a0442c8f2
Signed by: Georg
GPG Key ID: 1DAF57F49F8E8F22

View File

@ -16,13 +16,13 @@ menu() {
"1" "Edit active networks" \ "1" "Edit active networks" \
"2" "Edit disabled networks" \ "2" "Edit disabled networks" \
"3" "Add new network" \ "3" "Add new network" \
"4" "Enable network (deprecated)" \
"5" "Disable network (deprecated)" \
"6" "Manage client certificates" \ "6" "Manage client certificates" \
2>&1 1>&3) 2>&1 1>&3)
exit_status=$? exit_status=$?
exec 3>&- exec 3>&-
} }
# "4" "Enable network (deprecated)" \
# "5" "Disable network (deprecated)" \
get_networks() { get_networks() {
exec 3>&1 exec 3>&1
@ -173,28 +173,36 @@ remove_network() {
} }
add_network() { add_network() {
exec 3>&1 tmp_name=""
user_input=$(dialog --ok-label "Submit" \ tmp_hostname=""
--backtitle "LibertaCasa IRC Services - Pounce Division - https://liberta.casa/" \ tmp_nickname=""
--title "New IRC Network" \ tmp_password=""
--form "Network specific details:" \ tmp_channels=""
20 50 0 \ tmp_away=""
"Arbitrary name:" 1 1 "$nw_name" 1 18 33 0 \ while [[ -z $tmp_name || -z $tmp_hostname || -z $tmp_nickname || -z $tmp_password || -z $tmp_channels || -z $tmp_away ]]; do
"Hostname:" 2 1 "$nw_hostname" 2 18 33 0 \ exec 3>&1
"Nickname:" 3 1 "$nw_nickname" 3 18 33 0 \ user_input=$(dialog --ok-label "Submit" \
"SASL Password:" 4 1 "$nw_password" 4 18 33 0 \ --backtitle "LibertaCasa IRC Services - Pounce Division - https://liberta.casa/" \
"Channels:" 5 1 "$nw_channels" 5 18 33 0 \ --title "New IRC Network" \
"Away message:" 6 1 "$nw_away" 6 18 33 0 \ --form "Network specific details:" \
2>&1 1>&3) 20 50 0 \
#3>&1 1>&2 2>&3 3>&-) "Arbitrary name:" 1 1 "$tmp_name" 1 18 33 0 \
exec 3>&- "Hostname:" 2 1 "$tmp_hostname" 2 18 33 0 \
echo $user_input > /tmp/userinput "Nickname:" 3 1 "$tmp_nickname" 3 18 33 0 \
tmp_name=$(echo "$user_input" | sed -n 1p) "SASL Password:" 4 1 "$tmp_password" 4 18 33 0 \
tmp_hostname=$(echo "$user_input" | sed -n 2p) "Channels:" 5 1 "$tmp_channels" 5 18 33 0 \
tmp_nickname=$(echo "$user_input" | sed -n 3p) "Away message:" 6 1 "$tmp_away" 6 18 33 0 \
tmp_password=$(echo "$user_input" | sed -n 4p) 2>&1 1>&3)
tmp_channels=$(echo "$user_input" | sed -n 5p) #3>&1 1>&2 2>&3 3>&-)
tmp_away=$(echo "$user_input" | sed -n 6p) exec 3>&-
echo $user_input > /tmp/userinput
tmp_name=$(echo "$user_input" | sed -n 1p)
tmp_hostname=$(echo "$user_input" | sed -n 2p)
tmp_nickname=$(echo "$user_input" | sed -n 3p)
tmp_password=$(echo "$user_input" | sed -n 4p)
tmp_channels=$(echo "$user_input" | sed -n 5p)
tmp_away=$(echo "$user_input" | sed -n 6p)
done
if [ ! $tmp_name = "TEMPLATE" ]; then if [ ! $tmp_name = "TEMPLATE" ]; then
cp $pouncedir/TEMPLATE $pouncedir/users/$USER/disabled/$tmp_name cp $pouncedir/TEMPLATE $pouncedir/users/$USER/disabled/$tmp_name
sed -e "s+%%POUNCEDIR%%+$pouncedir+" -i $pouncedir/users/$USER/disabled/$tmp_name sed -e "s+%%POUNCEDIR%%+$pouncedir+" -i $pouncedir/users/$USER/disabled/$tmp_name
@ -311,9 +319,9 @@ get_certs() {
0 ) 0 )
add_cert add_cert
;; ;;
1 ) #1 )
get_certs # get_certs
;; # ;;
esac esac
crt_choice="" crt_choice=""
fi fi
@ -329,7 +337,17 @@ add_cert() {
10 60 \ 10 60 \
2>&1 1>&3) 2>&1 1>&3)
echo $crt_input > /tmp/crtinput echo $crt_input > /tmp/crtinput
/usr/local/bin/pounce -a $pouncedir/users/$USER/certs/ca.pem -g $pouncedir/users/$USER/certs/$crt_input.pem case $crt_input in
"")
dialog --title "Error" \
--backtitle "LibertaCasa Pounce Configurator" \
--msgbox "Did you supply a name for the new certificate?" \
10 60
;;
*)
/usr/local/bin/pounce -a $pouncedir/users/$USER/certs/ca.pem -g $pouncedir/users/$USER/certs/$crt_input.pem
;;
esac
crt_input = "" crt_input = ""
exec 3>&- exec 3>&-
get_certs get_certs
@ -387,18 +405,18 @@ while true; do
3 ) 3 )
add_network add_network
;; ;;
4 ) # 4 )
get_networks "disabled" # get_networks "disabled"
if [ ! -z "$user_choice" ]; then # if [ ! -z "$user_choice" ]; then
set_network "disabled" # set_network "disabled"
fi # fi
;; # ;;
5 ) # 5 )
get_networks "enabled" # get_networks "enabled"
if [ ! -z "$user_choice" ]; then # if [ ! -z "$user_choice" ]; then
set_network "enabled" # set_network "enabled"
fi # fi
;; # ;;
6 ) 6 )
certman certman
;; ;;