Skip to content

Commit be604d8

Browse files
committed
fix missing date/time
1 parent 3c00947 commit be604d8

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

bin/v-check-user-password

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,23 @@ ip=${3-127.0.0.1}
1818
source $VESTA/func/main.sh
1919
source $VESTA/conf/vesta.conf
2020

21+
time_n_date=$(date +'%T %F')
22+
time=$(echo "$time_n_date" |cut -f 1 -d \ )
23+
date=$(echo "$time_n_date" |cut -f 2 -d \ )
24+
2125

2226
#----------------------------------------------------------#
2327
# Verifications #
2428
#----------------------------------------------------------#
2529

30+
2631
check_args '2' "$#" 'USER PASSWORD'
2732
is_format_valid 'user'
2833

2934
# Checking user
3035
if [ ! -d "$VESTA/data/users/$user" ] && [ "$user" != 'root' ]; then
3136
echo "Error: password missmatch"
32-
echo "$DATE $TIME $user $ip failed to login" >> $VESTA/log/auth.log
37+
echo "$date $time $user $ip failed to login" >> $VESTA/log/auth.log
3338
exit 9
3439
fi
3540

@@ -39,7 +44,7 @@ is_password_valid
3944
# Checking empty password
4045
if [[ -z "$password" ]]; then
4146
echo "Error: password missmatch"
42-
echo "$DATE $TIME $user $ip failed to login" >> $VESTA/log/auth.log
47+
echo "$date $time $user $ip failed to login" >> $VESTA/log/auth.log
4348
exit 9
4449
fi
4550

@@ -48,6 +53,7 @@ fi
4853
# Action #
4954
#----------------------------------------------------------#
5055

56+
5157
# Parsing user's salt
5258
shadow=$(grep "^$user:" /etc/shadow | cut -f 2 -d :)
5359

@@ -61,7 +67,7 @@ then
6167
method='sha-512'
6268
else
6369
echo "Error: password missmatch"
64-
echo "$DATE $TIME $user $ip failed to login" >> $VESTA/log/auth.log
70+
echo "$date $time $user $ip failed to login" >> $VESTA/log/auth.log
6571
exit 9
6672
fi
6773
else
@@ -71,23 +77,23 @@ fi
7177

7278
if [ -z "$salt" ]; then
7379
echo "Error: password missmatch"
74-
echo "$DATE $TIME $user $ip failed to login" >> $VESTA/log/auth.log
80+
echo "$date $time $user $ip failed to login" >> $VESTA/log/auth.log
7581
exit 9
7682
fi
7783

7884
# Generating hash
7985
hash=$($BIN/v-generate-password-hash $method $salt <<< $password)
8086
if [[ -z "$hash" ]]; then
8187
echo "Error: password missmatch"
82-
echo "$DATE $TIME $user $ip failed to login" >> $VESTA/log/auth.log
88+
echo "$date $time $user $ip failed to login" >> $VESTA/log/auth.log
8389
exit 9
8490
fi
8591

8692
# Checking hash
8793
result=$(grep "^$user:$hash:" /etc/shadow 2>/dev/null)
8894
if [[ -z "$result" ]]; then
8995
echo "Error: password missmatch"
90-
echo "$DATE $TIME $user $ip failed to login" >> $VESTA/log/auth.log
96+
echo "$date $time $user $ip failed to login" >> $VESTA/log/auth.log
9197
exit 9
9298
fi
9399

@@ -97,6 +103,6 @@ fi
97103
#----------------------------------------------------------#
98104

99105
# Logging
100-
echo "$DATE $TIME $user $ip successfully logged in" >> $VESTA/log/auth.log
106+
echo "$date $time $user $ip successfully logged in" >> $VESTA/log/auth.log
101107

102108
exit

0 commit comments

Comments
 (0)