diff --git a/bin/v_add_cron_job b/bin/v_add_cron_job index 6b228eeb..197c9057 100755 --- a/bin/v_add_cron_job +++ b/bin/v_add_cron_job @@ -17,13 +17,16 @@ hour=$3 day=$4 month=$5 wday=$6 -command=$7 +command=$(echo $7 | sed -e "s/'/%quote%/g") job=$8 # Includes source $VESTA/conf/vesta.conf source $VESTA/func/main.sh +# Assing new value +A7="$command" + #----------------------------------------------------------# # Verifications # @@ -45,7 +48,6 @@ is_object_free 'cron' 'JOB' "$job" #----------------------------------------------------------# # Concatenating cron string -command=$(echo $command | sed -e "s/'/%quote%/g" -e "s/:/%dots%/g") str="JOB='$job' MIN='$min' HOUR='$hour' DAY='$day' MONTH='$month' WDAY='$wday'" str="$str CMD='$command' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" diff --git a/bin/v_add_database b/bin/v_add_database index 632156eb..8be920d1 100755 --- a/bin/v_add_database +++ b/bin/v_add_database @@ -30,6 +30,9 @@ source $VESTA/conf/vesta.conf source $VESTA/func/main.sh source $VESTA/func/db.sh +# Hiding password +A4='******' + #----------------------------------------------------------# # Verifications # @@ -74,10 +77,6 @@ str="$str DATE='$DATE'" echo "$str" >> $USER_DATA/db.conf chmod 660 $USER_DATA/db.conf -# Hiding password -EVENT="DATE='$DATE' TIME='$TIME' COMMAND='$SCRIPT'" -EVENT="$EVENT ARGUMENTS='$user $database $dbuser ***** $type $host $charset'" - # Logging log_history "$EVENT" log_event "$OK" "$EVENT" diff --git a/bin/v_add_database_server b/bin/v_add_database_server index 72c5b4c8..d747c5b5 100755 --- a/bin/v_add_database_server +++ b/bin/v_add_database_server @@ -19,7 +19,7 @@ host=$2 port=$3 dbuser=$4 dbpass=$5 -max_db=${6-300} +A5='******' charsets=${7-UTF8,LATIN1,WIN1250,WIN1251,WIN1252,WIN1256,WIN1258,KOI8} template=${8-template1} @@ -28,6 +28,9 @@ source $VESTA/conf/vesta.conf source $VESTA/func/main.sh source $VESTA/func/db.sh +# Hiding password +max_db=${6-500} + #----------------------------------------------------------# # Verifications # @@ -69,11 +72,6 @@ chmod 660 $VESTA/conf/$type.conf # Vesta # #----------------------------------------------------------# -# Hiding password -EVENT="DATE='$DATE' TIME='$TIME' COMMAND='$SCRIPT'" -EVENT="$EVENT ARGUMENTS='$type $host $port $dbuser ****** $max_db $charsets" -EVENT="$EVENT $tpl'" - # Logging log_event "$OK" "$EVENT" diff --git a/bin/v_add_mail_account b/bin/v_add_mail_account index e4e50ef0..e032f145 100755 --- a/bin/v_add_mail_account +++ b/bin/v_add_mail_account @@ -23,6 +23,9 @@ source $VESTA/conf/vesta.conf source $VESTA/func/main.sh source $VESTA/func/domain.sh +# Hiding password +A4='******' + #----------------------------------------------------------# # Verifications # @@ -61,10 +64,6 @@ accounts=$(wc -l $USER_DATA/mail/$domain.conf | cut -f 1 -d ' ') increase_user_value "$user" '$U_MAIL_ACCOUNTS' update_object_value 'mail' 'DOMAIN' "$domain" '$ACCOUNTS' "$accounts" -# Hiding password -EVENT="DATE='$DATE' TIME='$TIME' COMMAND='$SCRIPT'" -EVENT="$EVENT ARGUMENTS='$user $domain ***** $quota'" - # Logging log_history "$EVENT" log_event "$OK" "$EVENT" diff --git a/bin/v_add_user b/bin/v_add_user index 15ef4f8c..db613e74 100755 --- a/bin/v_add_user +++ b/bin/v_add_user @@ -21,6 +21,9 @@ lname=$6 source $VESTA/conf/vesta.conf source $VESTA/func/main.sh +# Hiding password +A2='******' + is_user_free() { check_sysuser=$(cut -f 1 -d : /etc/passwd | grep -w "$user" ) if [ ! -z "$check_sysuser" ] || [ -e "$USER_DATA" ]; then @@ -205,10 +208,6 @@ if [ "$user" != 'admin' ]; then increase_user_value 'admin' '$U_USERS' fi -# Hiding password -EVENT="DATE='$DATE' TIME='$TIME' COMMAND='$SCRIPT'" -EVENT="$EVENT ARGUMENTS='$user ***** $email $package $fname $lname'" - # Logging log_event "$OK" "$EVENT" diff --git a/bin/v_add_web_domain_stats_user b/bin/v_add_web_domain_stats_user index cc7c1f38..0e2007b1 100755 --- a/bin/v_add_web_domain_stats_user +++ b/bin/v_add_web_domain_stats_user @@ -20,6 +20,9 @@ source $VESTA/conf/vesta.conf source $VESTA/func/main.sh source $VESTA/func/domain.sh +# Hiding password +A4='******' + #----------------------------------------------------------# # Verifications # @@ -61,10 +64,6 @@ stats_crypt=$(grep $stats_user: $stats_dir/.htpasswd |cut -f 2 -d :) update_object_value 'web' 'DOMAIN' "$domain" '$STATS_USER' "$stats_user" update_object_value 'web' 'DOMAIN' "$domain" '$STATS_CRYPT' "$stats_crypt" -# Hiding password -EVENT="DATE='$DATE' TIME='$TIME' COMMAND='$SCRIPT'" -EVENT="$EVENT ARGUMENTS='$user $domain $stats_user *****'" - # Logging log_history "$EVENT" log_event "$OK" "$EVENT" diff --git a/bin/v_change_database_password b/bin/v_change_database_password index 3dcdc74a..34d04cb4 100755 --- a/bin/v_change_database_password +++ b/bin/v_change_database_password @@ -20,6 +20,9 @@ source $VESTA/conf/vesta.conf source $VESTA/func/main.sh source $VESTA/func/db.sh +# Hiding password +A3='******' + #----------------------------------------------------------# # Verifications # @@ -53,10 +56,6 @@ esac # Update config value update_object_value 'db' 'DB' "$database" '$MD5' "$md5" -# Hiding password -EVENT="DATE='$DATE' TIME='$TIME' COMMAND='$SCRIPT'" -EVENT="$EVENT ARGUMENTS='$user $database *****'" - # Logging log_event "$OK" "$EVENT" diff --git a/bin/v_change_mail_account_password b/bin/v_change_mail_account_password index 7b3caf05..ecfe679e 100755 --- a/bin/v_change_mail_account_password +++ b/bin/v_change_mail_account_password @@ -22,6 +22,9 @@ source $VESTA/conf/vesta.conf source $VESTA/func/main.sh source $VESTA/func/domain.sh +# Hiding password +A4='******' + #----------------------------------------------------------# # Verifications # @@ -54,10 +57,6 @@ echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd # Update md5 update_object_value "mail/$domain" 'ACCOUNT' "$account" '$MD5' "$md5" -# Hiding password -EVENT="DATE='$DATE' TIME='$TIME' COMMAND='$SCRIPT'" -EVENT="$EVENT ARGUMENTS='$user $domain *****'" - # Logging log_history "$EVENT" log_event "$OK" "$EVENT" diff --git a/bin/v_change_user_password b/bin/v_change_user_password index e13544a1..aaa18a0b 100755 --- a/bin/v_change_user_password +++ b/bin/v_change_user_password @@ -17,6 +17,9 @@ password=$2 source $VESTA/conf/vesta.conf source $VESTA/func/main.sh +# Hiding password +A2='******' + #----------------------------------------------------------# # Verifications # @@ -45,9 +48,6 @@ md5=$(awk -v user=$user -F : 'user == $1 {print $2}' /etc/shadow) update_user_value "$user" '$RKEY' "$(gen_password)" update_user_value "$user" '$MD5' "$md5" -# Hiding password -EVENT="DATE='$DATE' TIME='$TIME' COMMAND='$SCRIPT' ARGUMENTS='$user *****'" - # Logging log_event "$OK" "$EVENT" diff --git a/bin/v_list_user_log b/bin/v_list_user_log new file mode 100755 index 00000000..92280b5a --- /dev/null +++ b/bin/v_list_user_log @@ -0,0 +1,88 @@ +#!/bin/bash +# info: list user log +# options: user [format] +# +# The function of obtaining the list of 100 last users commands. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + +# Json func +json_list_history() { + echo '{' + fileds_count=$(echo $fields| wc -w ) + while read line; do + IFS=$'\n' + eval $line + if [ -n "$data" ]; then + echo -e ' },' + fi + i=1 + IFS=' ' + for field in $fields; do + eval value=\"$field\" + value=$(echo "$value" | sed -e 's/"/\\"/g' -e "s/%quote%/'/g") + if [ $i -eq 1 ]; then + (( ++i)) + echo -e "\t\"$value\": {" + else + if [ $i -lt $fileds_count ]; then + (( ++i)) + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," + else + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" + data=1 + fi + fi + done + done < $conf + if [ -n "$data" ]; then + echo -e ' }' + fi + echo -e '}' +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'user [format]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config +conf=$USER_DATA/history.log + +# Defining fileds to select +fields="\$CMD \$A1 \$A2 \$A3 \$A4 \$A5 \$A6 \$A7 \$A8 \$A9 \$TIME \$DATE" + +# Listing domains +case $format in + json) json_list_history ;; + plain) nohead=1; shell_list ;; + shell) fields="\$DATE \$TIME \$CMD \$A1 \$A2 \$A3 \$A4 \$A5 \$A6 \$A7" + shell_list ;; + *) check_args '1' '0' 'user [format]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/func/main.sh b/func/main.sh index 343b0dfb..d1f2bc96 100644 --- a/func/main.sh +++ b/func/main.sh @@ -2,7 +2,17 @@ DATE=$(date +%F) TIME=$(date +%T) SCRIPT=$(basename $0) -EVENT="DATE='$DATE' TIME='$TIME' COMMAND='$SCRIPT' ARGUMENTS='$*'" +A1=$1 +A2=$2 +A3=$3 +A4=$4 +A5=$5 +A6=$6 +A7=$7 +A8=$8 +A9=$9 +EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'" +EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'" BACKUP_GZIP=5 BACKUP_DISK_LIMIT=95 BACKUP_LA_LIMIT=5 @@ -40,12 +50,18 @@ E_RESTART=20 # Log event function log_event() { - echo "$1 $2" >> $VESTA/log/system.log + echo "RC='$1' $2" >> $VESTA/log/system.log } # Log user history log_history() { - echo "$1" >> $USER_DATA/history.log + touch $USER_DATA/history.log + if [ '99' -lt "$(wc -l $USER_DATA/history.log |cut -f 1 -d ' ')" ]; then + tail -n 99 $USER_DATA/history.log > $USER_DATA/history.log.mv + mv -f $USER_DATA/history.log.mv $USER_DATA/history.log + chmod 660 $USER_DATA/history.log + fi + echo "$1 UNDO='$2'" >> $USER_DATA/history.log } # Argument list checker