X-Git-Url: http://git.ipfire.org/?p=people%2Fms%2Fnetwork.git;a=blobdiff_plain;f=src%2Ffunctions%2Ffunctions.ipsec;h=ed889a648756eed98523b585beb1e738a7b131be;hp=c090a93d9dea27a1e6b03dbcf8833873de93a23c;hb=1bfc4f565106d6bfa8b5199026b2f635d15a81c8;hpb=f03f29b7b8887dcdaae596d316ff5ea09db1be73 diff --git a/src/functions/functions.ipsec b/src/functions/functions.ipsec index c090a93d..ed889a64 100644 --- a/src/functions/functions.ipsec +++ b/src/functions/functions.ipsec @@ -334,12 +334,23 @@ ipsec_connection_authentication_psk() { log ERROR "Not enough arguments" return ${EXIT_ERROR} fi + local connection=${1} local psk=${2} - # TODO Check if psk is valid + local length=${#psk} + + if [ ${length} -lt 4 ]; then + error "The PSK must be longer than four characters" + return ${EXIT_ERROR} + fi + + if [ ${length} -gt 128 ]; then + error "The PSK cannot be longer than 128 characters" + return ${EXIT_ERROR} + fi - if ! ipsec_connection_write_config_key "${connection}" "PSK" ${psk}; then + if ! ipsec_connection_write_config_key "${connection}" "PSK" "${psk}"; then log ERROR "Could not write configuration settings" return ${EXIT_ERROR} fi