Просмотр исходного кода

fix: prevent empty user variable from affecting multiple scripts (Fixes #4926) (#4928)

sahsanu 11 месяцев назад
Родитель
Сommit
7d51443121
3 измененных файлов с 15 добавлено и 15 удалено
  1. 5 5
      bin/v-list-access-keys
  2. 5 5
      bin/v-update-user-counters
  3. 5 5
      bin/v-update-user-stats

+ 5 - 5
bin/v-list-access-keys

@@ -1,6 +1,6 @@
 #!/bin/bash
 # info: list all API access keys
-# options: [FORMAT]
+# options: [USER] [FORMAT]
 #
 # example: v-list-access-keys json
 
@@ -8,10 +8,6 @@
 #                Variables & Functions                     #
 #----------------------------------------------------------#
 
-# Argument definition
-user="$1"
-format="${2:-shell}"
-
 # Includes
 # shellcheck source=/etc/hestiacp/hestia.conf
 source /etc/hestiacp/hestia.conf
@@ -20,6 +16,10 @@ source $HESTIA/func/main.sh
 # load config file
 source_conf "$HESTIA/conf/hestia.conf"
 
+# Argument definition
+user="$1"
+format="${2:-shell}"
+
 # JSON list function
 json_list() {
 	echo -n '{'

+ 5 - 5
bin/v-update-user-counters

@@ -1,6 +1,6 @@
 #!/bin/bash
 # info: update user usage counters
-# options: USER
+# options: [USER]
 #
 # example: v-update-user-counters admin
 #
@@ -10,9 +10,6 @@
 #                Variables & Functions                     #
 #----------------------------------------------------------#
 
-# Argument definition
-user=$1
-
 # Includes
 # shellcheck source=/etc/hestiacp/hestia.conf
 source /etc/hestiacp/hestia.conf
@@ -21,11 +18,14 @@ source $HESTIA/func/main.sh
 # load config file
 source_conf "$HESTIA/conf/hestia.conf"
 
+# Argument definition
+user=$1
+
 #----------------------------------------------------------#
 #                    Verifications                         #
 #----------------------------------------------------------#
 
-check_args '0' "$#" 'USER'
+check_args '0' "$#" '[USER]'
 if [ -n "$user" ]; then
 	is_format_valid 'user'
 	is_object_valid 'user' 'USER' "$user"

+ 5 - 5
bin/v-update-user-stats

@@ -1,6 +1,6 @@
 #!/bin/bash
 # info: update user statistics
-# options: USER
+# options: [USER]
 #
 # example: v-update-user-stats admin
 #
@@ -10,9 +10,6 @@
 #                Variables & Functions                     #
 #----------------------------------------------------------#
 
-# Argument definition
-user=$1
-
 # Importing system environment  as we run this script
 #       mostly by cron wich not read it by itself
 source /etc/profile.d/hestia.sh
@@ -27,11 +24,14 @@ source $HESTIA/func/domain.sh
 # load config file
 source_conf "$HESTIA/conf/hestia.conf"
 
+# Argument definition
+user=$1
+
 #----------------------------------------------------------#
 #                    Verifications                         #
 #----------------------------------------------------------#
 
-check_args '0' "$#" 'USER'
+check_args '0' "$#" '[USER]'
 if [ ! -z "$user" ]; then
 	is_format_valid 'user'
 	is_object_valid 'user' 'USER' "$user"