Skip to content

Commit fd52d98

Browse files
OGLE-TR-123 Pre-Release
2 parents 3c81394 + b48f739 commit fd52d98

File tree

6 files changed

+78
-12
lines changed

6 files changed

+78
-12
lines changed

bin/v_add_db_base

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ db_password=$4
2323
type=$5
2424
host=$6
2525
encoding=${7-UTF8}
26-
26+
encoding=$(echo "$encoding" |tr '[:lower:]' '[:upper:]')
2727
# Importing variables
2828
source $VESTA/conf/vars.conf
2929
source $V_CONF/vesta.conf
@@ -89,11 +89,12 @@ increase_user_value "$user" '$U_DATABASES'
8989

9090
# Adding db to db conf
9191
v_str="DB='$database' USER='$db_user' HOST='$host' TYPE='$type'"
92-
v_str="$v_str U_DISK='0' SUSPEND='no' DATE='$V_DATE'"
92+
v_str="$v_str CHARSET='$encoding' U_DISK='0' SUSPEND='no' DATE='$V_DATE'"
9393
echo "$v_str">>$V_USERS/$user/db.conf
9494

9595
# Hiding password
9696
V_EVENT="$V_DATE $V_SCRIPT $user $database $db_user ***** $type $host"
97+
V_EVENT="$V_EVENT $encoding"
9798

9899
# Logging
99100
log_history "$V_EVENT" "v_delete_db_base $user $database"

bin/v_add_dns_domain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ domain=$(idn -t --quiet -u "$2" )
1919
domain_idn=$(idn -t --quiet -a "$domain")
2020
ip=$3
2121
template=${4-default}
22-
next_year=$(date +F -d "+ 1 year")
22+
next_year=$(date +%F -d "+ 1 year")
2323
exp=${5-$next_year}
2424
soa=$6
2525
ttl=${7-14400}

bin/v_change_user_shell

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,21 @@ is_user_suspended
4040
# Action #
4141
#----------------------------------------------------------#
4242

43-
# Changing user shell
44-
update_user_value "$user" '$SHELL' "$shell"
45-
4643
# Get shell full path
4744
shell_path=$(/usr/bin/chsh --list-shells | grep -w "$shell" )
4845

4946
# Changing passwd file
5047
/usr/bin/chsh -s "$shell_path" "$user" >/dev/null 2>&1
5148

5249

50+
5351
#----------------------------------------------------------#
5452
# Vesta #
5553
#----------------------------------------------------------#
5654

55+
# Changing user shell
56+
update_user_value "$user" '$SHELL' "$shell"
57+
5758
# Logging
5859
log_event 'system' "$V_EVENT"
5960

bin/v_list_db_base

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ is_db_valid
107107
conf=$V_USERS/$user/db.conf
108108

109109
# Defining fileds to select
110-
fields='$DB $USER $HOST $TYPE $U_DISK $SUSPEND $DATE'
110+
fields='$DB $USER $HOST $TYPE $CHARSET $U_DISK $SUSPEND $DATE'
111111

112112
# Listing database
113113
case $format in

bin/v_list_db_bases

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,14 @@ is_user_valid
4040
conf=$V_USERS/$user/db.conf
4141

4242
# Defining fileds to select
43-
fields='$DB $USER $HOST $TYPE $U_DISK $SUSPEND $DATE'
43+
fields='$DB $USER $HOST $TYPE $CHARSET $U_DISK $SUSPEND $DATE'
4444

4545
# Listing databases
4646
case $format in
4747
json) json_list ;;
4848
plain) nohead=1; shell_list ;;
49-
shell) shell_list | column -t ;;
49+
shell) fields='$DB $USER $HOST $TYPE $U_DISK $DATE';
50+
shell_list | column -t ;;
5051
*) check_args '1' '0' 'user [format]'
5152
esac
5253

func/shared.func

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ format_validation() {
6161

6262
# Checking shell
6363
check_shell=$(/usr/bin/chsh --list-shells | grep -w "$val" )
64-
if [ -z "$check_shell" ]; then
64+
if [ -z "$1"] || [ -z "$check_shell" ]; then
6565
echo "Error: shell not found"
66-
log_event 'debug' "$E_INVALID $V_EVENT"
67-
exit $E_INVALID
66+
log_event 'debug' "$E_NOTEXIST $V_EVENT"
67+
exit $E_NOTEXIST
6868
fi
6969
}
7070

@@ -263,6 +263,64 @@ format_validation() {
263263
fi
264264
}
265265

266+
# Define minute/hour/day/month validator
267+
format_mhd() {
268+
val="$1"
269+
digit=$val
270+
limit=60
271+
272+
if [ "$var" = 'day' ]; then
273+
limit=31
274+
fi
275+
if [ "$var" = 'month' ]; then
276+
limit=12
277+
fi
278+
if [ "$var" = 'wday' ]; then
279+
limit=7
280+
fi
281+
282+
letters=$(echo "$val"|grep -c "[a-Z]")
283+
lslash=$(echo "$val"| grep "^/")
284+
if [ -z "$val" ] || [ 0 -ne "$letters" ] || [ -n "$lslash" ]; then
285+
echo "Error: $var is out of range"
286+
log_event 'debug' "$E_INVALID $V_EVENT"
287+
exit $E_INVALID
288+
fi
289+
290+
special_chars=$(echo "$val" | \
291+
grep -c "[!|@|#|$|^|&|(|)|+|=|{|}|:|,|.|<|>|?|\|\"|'|;|%| ]" )
292+
if [[ 0 -ne "$special_chars" ]] || [ 5 -le ${#val} ]; then
293+
echo "Error: $var is out of range"
294+
log_event 'debug' "$E_INVALID $V_EVENT"
295+
exit $E_INVALID
296+
fi
297+
298+
star=$(echo "$val" |grep '*')
299+
if [ ! -z "$star" ]; then
300+
slash=$(echo $val |grep "^*/")
301+
if [ "$val" != '*' ] && [ -z "$slash" ]; then
302+
echo "Error: $var is out of range"
303+
log_event 'debug' "$E_INVALID $V_EVENT"
304+
exit $E_INVALID
305+
else
306+
if [ -n "$slash" ]; then
307+
digit=$(echo $val | cut -f 2 -d / )
308+
fi
309+
if [ "$val" = '*' ]; then
310+
digit=0
311+
fi
312+
fi
313+
fi
314+
315+
if [ "$limit" -lt "$digit" ]; then
316+
echo "Error: $var is out of range"
317+
log_event 'debug' "$E_INVALID $V_EVENT"
318+
exit $E_INVALID
319+
fi
320+
}
321+
322+
323+
266324
# Defining format_ext function
267325
format_ext() {
268326
val="$1"
@@ -313,6 +371,7 @@ format_validation() {
313371
ssl) format_usr "$v" ;;
314372
domain) format_dom "$v" ;;
315373
database) format_db "$v" ;;
374+
day) format_mhd "$v" ;;
316375
db_user) format_dbu "$v" ;;
317376
dvalue) format_dvl "$v" ;;
318377
fname) format_usr "$v" ;;
@@ -328,6 +387,7 @@ format_validation() {
328387
ns8) format_dom "$v" ;;
329388
email) format_eml "$v" ;;
330389
extentions) format_ext "$v" ;;
390+
hour) format_mhd "$v" ;;
331391
host) format_usr "$v" ;;
332392
interface) format_ifc "$v" ;;
333393
ip) format_ip "$v" ;;
@@ -337,6 +397,8 @@ format_validation() {
337397
mask) format_ip "$v" ;;
338398
max_usr) format_int "$v" ;;
339399
max_db) format_int "$v" ;;
400+
min) format_mhd "$v" ;;
401+
month) format_mhd "$v" ;;
340402
lname) format_usr "$v" ;;
341403
owner) format_usr "$v" ;;
342404
package) format_usr "$v" ;;
@@ -349,6 +411,7 @@ format_validation() {
349411
template) format_usr "$v" ;;
350412
ttl) format_int "$v" ;;
351413
user) format_usr "$v" ;;
414+
wday) format_mhd "$v" ;;
352415
esac
353416
done
354417
}

0 commit comments

Comments
 (0)