Skip to content

Commit d2685e8

Browse files
committed
Added user history log
1 parent b7a47d4 commit d2685e8

11 files changed

+136
-38
lines changed

bin/v_add_cron_job

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@ hour=$3
1717
day=$4
1818
month=$5
1919
wday=$6
20-
command=$7
20+
command=$(echo $7 | sed -e "s/'/%quote%/g")
2121
job=$8
2222

2323
# Includes
2424
source $VESTA/conf/vesta.conf
2525
source $VESTA/func/main.sh
2626

27+
# Assing new value
28+
A7="$command"
29+
2730

2831
#----------------------------------------------------------#
2932
# Verifications #
@@ -45,7 +48,6 @@ is_object_free 'cron' 'JOB' "$job"
4548
#----------------------------------------------------------#
4649

4750
# Concatenating cron string
48-
command=$(echo $command | sed -e "s/'/%quote%/g" -e "s/:/%dots%/g")
4951
str="JOB='$job' MIN='$min' HOUR='$hour' DAY='$day' MONTH='$month' WDAY='$wday'"
5052
str="$str CMD='$command' SUSPENDED='no' TIME='$TIME' DATE='$DATE'"
5153

bin/v_add_database

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ source $VESTA/conf/vesta.conf
3030
source $VESTA/func/main.sh
3131
source $VESTA/func/db.sh
3232

33+
# Hiding password
34+
A4='******'
35+
3336

3437
#----------------------------------------------------------#
3538
# Verifications #
@@ -74,10 +77,6 @@ str="$str DATE='$DATE'"
7477
echo "$str" >> $USER_DATA/db.conf
7578
chmod 660 $USER_DATA/db.conf
7679

77-
# Hiding password
78-
EVENT="DATE='$DATE' TIME='$TIME' COMMAND='$SCRIPT'"
79-
EVENT="$EVENT ARGUMENTS='$user $database $dbuser ***** $type $host $charset'"
80-
8180
# Logging
8281
log_history "$EVENT"
8382
log_event "$OK" "$EVENT"

bin/v_add_database_server

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ host=$2
1919
port=$3
2020
dbuser=$4
2121
dbpass=$5
22-
max_db=${6-300}
22+
A5='******'
2323
charsets=${7-UTF8,LATIN1,WIN1250,WIN1251,WIN1252,WIN1256,WIN1258,KOI8}
2424
template=${8-template1}
2525

@@ -28,6 +28,9 @@ source $VESTA/conf/vesta.conf
2828
source $VESTA/func/main.sh
2929
source $VESTA/func/db.sh
3030

31+
# Hiding password
32+
max_db=${6-500}
33+
3134

3235
#----------------------------------------------------------#
3336
# Verifications #
@@ -69,11 +72,6 @@ chmod 660 $VESTA/conf/$type.conf
6972
# Vesta #
7073
#----------------------------------------------------------#
7174

72-
# Hiding password
73-
EVENT="DATE='$DATE' TIME='$TIME' COMMAND='$SCRIPT'"
74-
EVENT="$EVENT ARGUMENTS='$type $host $port $dbuser ****** $max_db $charsets"
75-
EVENT="$EVENT $tpl'"
76-
7775
# Logging
7876
log_event "$OK" "$EVENT"
7977

bin/v_add_mail_account

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ source $VESTA/conf/vesta.conf
2323
source $VESTA/func/main.sh
2424
source $VESTA/func/domain.sh
2525

26+
# Hiding password
27+
A4='******'
28+
2629

2730
#----------------------------------------------------------#
2831
# Verifications #
@@ -61,10 +64,6 @@ accounts=$(wc -l $USER_DATA/mail/$domain.conf | cut -f 1 -d ' ')
6164
increase_user_value "$user" '$U_MAIL_ACCOUNTS'
6265
update_object_value 'mail' 'DOMAIN' "$domain" '$ACCOUNTS' "$accounts"
6366

64-
# Hiding password
65-
EVENT="DATE='$DATE' TIME='$TIME' COMMAND='$SCRIPT'"
66-
EVENT="$EVENT ARGUMENTS='$user $domain ***** $quota'"
67-
6867
# Logging
6968
log_history "$EVENT"
7069
log_event "$OK" "$EVENT"

bin/v_add_user

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ lname=$6
2121
source $VESTA/conf/vesta.conf
2222
source $VESTA/func/main.sh
2323

24+
# Hiding password
25+
A2='******'
26+
2427
is_user_free() {
2528
check_sysuser=$(cut -f 1 -d : /etc/passwd | grep -w "$user" )
2629
if [ ! -z "$check_sysuser" ] || [ -e "$USER_DATA" ]; then
@@ -205,10 +208,6 @@ if [ "$user" != 'admin' ]; then
205208
increase_user_value 'admin' '$U_USERS'
206209
fi
207210

208-
# Hiding password
209-
EVENT="DATE='$DATE' TIME='$TIME' COMMAND='$SCRIPT'"
210-
EVENT="$EVENT ARGUMENTS='$user ***** $email $package $fname $lname'"
211-
212211
# Logging
213212
log_event "$OK" "$EVENT"
214213

bin/v_add_web_domain_stats_user

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ source $VESTA/conf/vesta.conf
2020
source $VESTA/func/main.sh
2121
source $VESTA/func/domain.sh
2222

23+
# Hiding password
24+
A4='******'
25+
2326

2427
#----------------------------------------------------------#
2528
# Verifications #
@@ -61,10 +64,6 @@ stats_crypt=$(grep $stats_user: $stats_dir/.htpasswd |cut -f 2 -d :)
6164
update_object_value 'web' 'DOMAIN' "$domain" '$STATS_USER' "$stats_user"
6265
update_object_value 'web' 'DOMAIN' "$domain" '$STATS_CRYPT' "$stats_crypt"
6366

64-
# Hiding password
65-
EVENT="DATE='$DATE' TIME='$TIME' COMMAND='$SCRIPT'"
66-
EVENT="$EVENT ARGUMENTS='$user $domain $stats_user *****'"
67-
6867
# Logging
6968
log_history "$EVENT"
7069
log_event "$OK" "$EVENT"

bin/v_change_database_password

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ source $VESTA/conf/vesta.conf
2020
source $VESTA/func/main.sh
2121
source $VESTA/func/db.sh
2222

23+
# Hiding password
24+
A3='******'
25+
2326

2427
#----------------------------------------------------------#
2528
# Verifications #
@@ -53,10 +56,6 @@ esac
5356
# Update config value
5457
update_object_value 'db' 'DB' "$database" '$MD5' "$md5"
5558

56-
# Hiding password
57-
EVENT="DATE='$DATE' TIME='$TIME' COMMAND='$SCRIPT'"
58-
EVENT="$EVENT ARGUMENTS='$user $database *****'"
59-
6059
# Logging
6160
log_event "$OK" "$EVENT"
6261

bin/v_change_mail_account_password

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ source $VESTA/conf/vesta.conf
2222
source $VESTA/func/main.sh
2323
source $VESTA/func/domain.sh
2424

25+
# Hiding password
26+
A4='******'
27+
2528

2629
#----------------------------------------------------------#
2730
# Verifications #
@@ -54,10 +57,6 @@ echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd
5457
# Update md5
5558
update_object_value "mail/$domain" 'ACCOUNT' "$account" '$MD5' "$md5"
5659

57-
# Hiding password
58-
EVENT="DATE='$DATE' TIME='$TIME' COMMAND='$SCRIPT'"
59-
EVENT="$EVENT ARGUMENTS='$user $domain *****'"
60-
6160
# Logging
6261
log_history "$EVENT"
6362
log_event "$OK" "$EVENT"

bin/v_change_user_password

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ password=$2
1717
source $VESTA/conf/vesta.conf
1818
source $VESTA/func/main.sh
1919

20+
# Hiding password
21+
A2='******'
22+
2023

2124
#----------------------------------------------------------#
2225
# Verifications #
@@ -45,9 +48,6 @@ md5=$(awk -v user=$user -F : 'user == $1 {print $2}' /etc/shadow)
4548
update_user_value "$user" '$RKEY' "$(gen_password)"
4649
update_user_value "$user" '$MD5' "$md5"
4750

48-
# Hiding password
49-
EVENT="DATE='$DATE' TIME='$TIME' COMMAND='$SCRIPT' ARGUMENTS='$user *****'"
50-
5151
# Logging
5252
log_event "$OK" "$EVENT"
5353

bin/v_list_user_log

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/bin/bash
2+
# info: list user log
3+
# options: user [format]
4+
#
5+
# The function of obtaining the list of 100 last users commands.
6+
7+
8+
#----------------------------------------------------------#
9+
# Variable&Function #
10+
#----------------------------------------------------------#
11+
12+
# Argument defenition
13+
user=$1
14+
format=${2-shell}
15+
16+
# Includes
17+
source $VESTA/func/main.sh
18+
19+
# Json func
20+
json_list_history() {
21+
echo '{'
22+
fileds_count=$(echo $fields| wc -w )
23+
while read line; do
24+
IFS=$'\n'
25+
eval $line
26+
if [ -n "$data" ]; then
27+
echo -e ' },'
28+
fi
29+
i=1
30+
IFS=' '
31+
for field in $fields; do
32+
eval value=\"$field\"
33+
value=$(echo "$value" | sed -e 's/"/\\"/g' -e "s/%quote%/'/g")
34+
if [ $i -eq 1 ]; then
35+
(( ++i))
36+
echo -e "\t\"$value\": {"
37+
else
38+
if [ $i -lt $fileds_count ]; then
39+
(( ++i))
40+
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
41+
else
42+
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\""
43+
data=1
44+
fi
45+
fi
46+
done
47+
done < $conf
48+
if [ -n "$data" ]; then
49+
echo -e ' }'
50+
fi
51+
echo -e '}'
52+
}
53+
54+
55+
#----------------------------------------------------------#
56+
# Verifications #
57+
#----------------------------------------------------------#
58+
59+
check_args '1' "$#" 'user [format]'
60+
validate_format 'user'
61+
is_object_valid 'user' 'USER' "$user"
62+
63+
64+
#----------------------------------------------------------#
65+
# Action #
66+
#----------------------------------------------------------#
67+
68+
# Defining config
69+
conf=$USER_DATA/history.log
70+
71+
# Defining fileds to select
72+
fields="\$CMD \$A1 \$A2 \$A3 \$A4 \$A5 \$A6 \$A7 \$A8 \$A9 \$TIME \$DATE"
73+
74+
# Listing domains
75+
case $format in
76+
json) json_list_history ;;
77+
plain) nohead=1; shell_list ;;
78+
shell) fields="\$DATE \$TIME \$CMD \$A1 \$A2 \$A3 \$A4 \$A5 \$A6 \$A7"
79+
shell_list ;;
80+
*) check_args '1' '0' 'user [format]'
81+
esac
82+
83+
84+
#----------------------------------------------------------#
85+
# Vesta #
86+
#----------------------------------------------------------#
87+
88+
exit

0 commit comments

Comments
 (0)