File tree Expand file tree Collapse file tree 1 file changed +25
-9
lines changed
Expand file tree Collapse file tree 1 file changed +25
-9
lines changed Original file line number Diff line number Diff line change 1212# Variable&Function #
1313# ----------------------------------------------------------#
1414
15- if [ -z " $1 " ]; then
15+ [[ -z $HESTIA ]] && HESTIA=" /usr/local/hestia"
16+
17+ source $HESTIA /func/main.sh
18+
19+ new_timestamp
20+
21+ abort_missmatch () {
1622 echo " Error: key missmatch"
17- exit 9
18- fi
19- key=$( basename $1 )
23+ echo " $date $time api $ip failed to login" >> $HESTIA /log/auth.log
24+ exit $E_PASSWORD
25+ }
26+
2027ip=${2-127.0.0.1}
2128time_n_date=$( date +' %T %F' )
2229time=$( echo " $time_n_date " | cut -f 1 -d \ )
@@ -27,11 +34,20 @@ date=$(echo "$time_n_date" |cut -f 2 -d \ )
2734# Action #
2835# ----------------------------------------------------------#
2936
30- if [ ! -e $HESTIA /data/keys/$key ]; then
31- echo " Error: key missmatch"
32- echo " $date $time api $ip failed to login" >> $HESTIA /log/auth.log
33- exit 9
34- fi
37+ key=" $( basename " $1 " ) "
38+
39+ # Exit if Key is unset or to short
40+ [[ -z $key || ${# key} -lt 16 ]] && abort_missmatch
41+
42+ # Key file must exist
43+ maybe_key_path=" $( readlink -e " ${HESTIA} /data/keys/${key} " ) "
44+ [[ -z $maybe_key_path ]] && abort_missmatch
45+
46+ # Key file cannot be the key store
47+ [[ $maybe_key_path == " ${HESTIA} /data/keys" ]] && abort_missmatch
48+
49+ # Key file must be in the key store
50+ [[ $maybe_key_path == " ${HESTIA} /data/keys/" * ]] || abort_missmatch
3551
3652
3753# ----------------------------------------------------------#
You can’t perform that action at this time.
0 commit comments