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" \
"2" "Edit disabled networks" \
"3" "Add new network" \
"4" "Enable network (deprecated)" \
"5" "Disable network (deprecated)" \
"6" "Manage client certificates" \
2>&1 1>&3)
exit_status=$?
exec 3>&-
}
# "4" "Enable network (deprecated)" \
# "5" "Disable network (deprecated)" \
get_networks() {
exec 3>&1
@ -173,28 +173,36 @@ remove_network() {
}
add_network() {
exec 3>&1
user_input=$(dialog --ok-label "Submit" \
--backtitle "LibertaCasa IRC Services - Pounce Division - https://liberta.casa/" \
--title "New IRC Network" \
--form "Network specific details:" \
20 50 0 \
"Arbitrary name:" 1 1 "$nw_name" 1 18 33 0 \
"Hostname:" 2 1 "$nw_hostname" 2 18 33 0 \
"Nickname:" 3 1 "$nw_nickname" 3 18 33 0 \
"SASL Password:" 4 1 "$nw_password" 4 18 33 0 \
"Channels:" 5 1 "$nw_channels" 5 18 33 0 \
"Away message:" 6 1 "$nw_away" 6 18 33 0 \
2>&1 1>&3)
#3>&1 1>&2 2>&3 3>&-)
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)
tmp_name=""
tmp_hostname=""
tmp_nickname=""
tmp_password=""
tmp_channels=""
tmp_away=""
while [[ -z $tmp_name || -z $tmp_hostname || -z $tmp_nickname || -z $tmp_password || -z $tmp_channels || -z $tmp_away ]]; do
exec 3>&1
user_input=$(dialog --ok-label "Submit" \
--backtitle "LibertaCasa IRC Services - Pounce Division - https://liberta.casa/" \
--title "New IRC Network" \
--form "Network specific details:" \
20 50 0 \
"Arbitrary name:" 1 1 "$tmp_name" 1 18 33 0 \
"Hostname:" 2 1 "$tmp_hostname" 2 18 33 0 \
"Nickname:" 3 1 "$tmp_nickname" 3 18 33 0 \
"SASL Password:" 4 1 "$tmp_password" 4 18 33 0 \
"Channels:" 5 1 "$tmp_channels" 5 18 33 0 \
"Away message:" 6 1 "$tmp_away" 6 18 33 0 \
2>&1 1>&3)
#3>&1 1>&2 2>&3 3>&-)
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
cp $pouncedir/TEMPLATE $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 )
add_cert
;;
1 )
get_certs
;;
#1 )
# get_certs
# ;;
esac
crt_choice=""
fi
@ -329,7 +337,17 @@ add_cert() {
10 60 \
2>&1 1>&3)
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 = ""
exec 3>&-
get_certs
@ -387,18 +405,18 @@ while true; do
3 )
add_network
;;
4 )
get_networks "disabled"
if [ ! -z "$user_choice" ]; then
set_network "disabled"
fi
;;
5 )
get_networks "enabled"
if [ ! -z "$user_choice" ]; then
set_network "enabled"
fi
;;
# 4 )
# get_networks "disabled"
# if [ ! -z "$user_choice" ]; then
# set_network "disabled"
# fi
# ;;
# 5 )
# get_networks "enabled"
# if [ ! -z "$user_choice" ]; then
# set_network "enabled"
# fi
# ;;
6 )
certman
;;