瀏覽代碼

kamctl: use VERIFY_USER variable to control if user check is done

- help automating some commands such as acl grant
Daniel-Constantin Mierla 7 年之前
父節點
當前提交
28f107d0eb
共有 3 個文件被更改,包括 27 次插入16 次删除
  1. 20 16
      utils/kamctl/kamctl
  2. 3 0
      utils/kamctl/kamctl.base
  3. 4 0
      utils/kamctl/kamctlrc

+ 20 - 16
utils/kamctl/kamctl

@@ -311,14 +311,16 @@ acl() {
 	case $1 in
 		show)
 			if [ $# -eq 2 ] ; then
-				is_user $2
-				if [ $? -ne 0 ] ; then
-					mecho "Non-existent user '$2'. Still proceeding? [Y|N] "
-					read answer
-					if [ "$answer" = "y" -o "$answer" = "Y" ] ; then
-						minfo "Proceeding with non-local user"
-					else
-						exit 1
+				if [ $VERIFY_USER -eq 1 ] ; then
+					is_user $2
+					if [ $? -ne 0 ] ; then
+						mecho "Non-existent user '$2'. Still proceeding? [Y|N] "
+						read answer
+						if [ "$answer" = "y" -o "$answer" = "Y" ] ; then
+							minfo "Proceeding with non-local user"
+						else
+							exit 1
+						fi
 					fi
 				fi
 				set_user $2
@@ -338,14 +340,16 @@ acl() {
 				usage
 				exit 1
 			fi
-			is_user $2
-			if [ $? -ne 0 ] ; then
-				mecho "Non-existent user '$2'. Still proceeding? [Y|N] "
-				read answer
-				if [ "$answer" = "y" -o "$answer" = "Y" ] ; then
-					minfo "Proceeding with non-local user"
-				else
-					exit 1
+			if [ $VERIFY_USER -eq 1 ] ; then
+				is_user $2
+				if [ $? -ne 0 ] ; then
+					mecho "Non-existent user '$2'. Still proceeding? [Y|N] "
+					read answer
+					if [ "$answer" = "y" -o "$answer" = "Y" ] ; then
+						minfo "Proceeding with non-local user"
+					else
+						exit 1
+					fi
 				fi
 			fi
 			set_user $2

+ 3 - 0
utils/kamctl/kamctl.base

@@ -136,6 +136,9 @@ fi
 if [ -z "$ACL_GROUPS" ] ; then
 	ACL_GROUPS="local ld int voicemail free-pstn"
 fi
+if [ -z "$VERIFY_USER" ] ; then
+	VERIFY_USER=1
+fi
 
 ##### ----------------------------------------------- #####
 #### Defined values

+ 4 - 0
utils/kamctl/kamctlrc

@@ -142,6 +142,10 @@
 ## are accepted
 # ACL_GROUPS="local ld int voicemail free-pstn"
 
+## check if user exists (used by some commands such as acl);
+## - default on (1); off (0)
+# VERIFY_USER=1
+
 ## verbose - debug purposes - default '0'
 # VERBOSE=1