]> granicus.if.org Git - pgbouncer/commitdiff
test.sh: Wrap all sudo calls in CAN_SUDO check
authorPeter Eisentraut <peter@eisentraut.org>
Mon, 23 Jul 2018 11:00:45 +0000 (13:00 +0200)
committerPeter Eisentraut <peter@eisentraut.org>
Mon, 23 Jul 2018 11:29:26 +0000 (13:29 +0200)
One call had been missed.

test/test.sh

index 5fd7c1e97424fdafc7ae269e912f88cad37aeaa6..330af7b1104d76bf475fabffa17125e6a73c34b8 100755 (executable)
@@ -37,19 +37,24 @@ which initdb > /dev/null || {
 # System configuration checks
 grep -q "^\"${USER}\"" userlist.txt || echo "\"${USER}\" \"01234\"" >> userlist.txt
 
-case `uname` in
-Darwin|OpenBSD)
-       sudo pfctl -a pgbouncer -F all -q 2>&1 | grep -q "pfctl:" && {
-               cat <<-EOF
-               Please enable PF and add the following rule to /etc/pf.conf
-               
-                 anchor "pgbouncer/*"
-               
-               EOF
-               exit 1
-       }
-       ;;
-esac
+echo "Testing for sudo access."
+sudo true && CAN_SUDO=1
+
+if test -n "$CAN_SUDO"; then
+       case `uname` in
+       Darwin|OpenBSD)
+               sudo pfctl -a pgbouncer -F all -q 2>&1 | grep -q "pfctl:" && {
+                       cat <<-EOF
+                       Please enable PF and add the following rule to /etc/pf.conf
+                       
+                         anchor "pgbouncer/*"
+                       
+                       EOF
+                       exit 1
+               }
+               ;;
+       esac
+fi
 
 # System configuration checks
 SED_ERE_OP='-E'
@@ -466,9 +471,6 @@ test_auth_user() {
        return 0
 }
 
-echo "Testing for sudo access."
-sudo true && CAN_SUDO=1
-
 testlist="
 test_server_login_retry
 test_auth_user