From 59692c7142ae9ba5ce846d53b3f3cca92d7b157f Mon Sep 17 00:00:00 2001 From: Keith Irwin Date: Sat, 30 Dec 2023 19:48:12 -0700 Subject: [PATCH] fix: :bug: Fixed test order --- back/lib/dashboard/ssl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/back/lib/dashboard/ssl b/back/lib/dashboard/ssl index 3b82028..f32f694 100755 --- a/back/lib/dashboard/ssl +++ b/back/lib/dashboard/ssl @@ -11,11 +11,7 @@ ip="${1}"; qs="$(<<<"${2}" tr '&' '\n' | sed 's/?//')" hostname="$(<<<"${qs}" grep -oP 'host=(.*)' | sed 's/^host=//' | xargs)" type="$(<<<"${qs}" grep -oP 'type=(.*)' | sed 's/^type=//' | xargs)" -# Make sure type is 'cert' or 'key' -if [ "${type}" != 'cert' ] && [ "${type}" != 'key' ]; then - printf 'Invalid type: %s\n' "${type}" | tee >(cat 1>&2) | /usr/lib/wagon/http_res 400; exit -fi - +# Check args exist if ! file="${hostname:?}/${type:?}.pem"; then printf 'ERROR! Hostname "%s" or type "%s" missing!\n' "${hostname}" "${type}" >&2 printf 'Hostname or type missing!\n' | /usr/lib/wagon/http_res 400; exit @@ -23,6 +19,11 @@ else printf 'User %s requested SSL file %s\n' "${ip}" "${file}" >&2 fi +# Make sure type is 'cert' or 'key' +if [ "${type}" != 'cert' ] && [ "${type}" != 'key' ]; then + printf 'Invalid type: %s\n' "${type}" | tee >(cat 1>&2) | /usr/lib/wagon/http_res 400; exit +fi + # Get username if ! domain="$(/usr/lib/wagon/ns_lookup_rdns "${ip}")"; then printf 'ERROR! Failed to lookup domain from user IP %s\n' "${ip}" | tee >(cat 1>&2) | /usr/lib/wagon/http_res 500