Max has uploaded this change for review. ( https://gerrit.osmocom.org/13253


Change subject: Use dumpcap for ttcn3-tcpdump-*.sh if available
......................................................................

Use dumpcap for ttcn3-tcpdump-*.sh if available

Check if dumpcap is installed and use it for packet capture instead of
'sudo tcpdump' if available. This makes it easier to use TTCN-3
testsuite as regular user without altering sudoers.

Change-Id: I77df04d51a469c924cf727f0596cc33565909746
---
M ttcn3-tcpdump-start.sh
M ttcn3-tcpdump-stop.sh
2 files changed, 11 insertions(+), 7 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/53/13253/1

diff --git a/ttcn3-tcpdump-start.sh b/ttcn3-tcpdump-start.sh
index b8ad01a..14773d9 100755
--- a/ttcn3-tcpdump-start.sh
+++ b/ttcn3-tcpdump-start.sh
@@ -16,12 +16,16 @@
        rm $PIDFILE
 fi

-if [ "$(id -u)" = "0" ]; then
-       CMD="$TCPDUMP -U"
-else
-# NOTE: This requires you to be root or something like
-# "laforge ALL=NOPASSWD: /usr/sbin/tcpdump, /bin/kill" in your sudoers file
-       CMD="sudo $TCPDUMP -U"
+if [ -x /usr/bin/dumpcap ]; then
+   CMD=/usr/bin/dumpcap
+   else
+       if [ "$(id -u)" = "0" ]; then
+          CMD="$TCPDUMP -U"
+       else
+       # NOTE: This requires you to be root or something like
+       # "laforge ALL=NOPASSWD: /usr/sbin/tcpdump, /bin/kill" in your sudoers 
file
+          CMD="sudo $TCPDUMP -U"
+       fi
 fi
 $CMD -s 1500 -n -i any -w "$TTCN3_PCAP_PATH/$TESTCASE.pcap" 
>$TTCN3_PCAP_PATH/$TESTCASE.pcap.stdout 2>&1 &
 PID=$!
diff --git a/ttcn3-tcpdump-stop.sh b/ttcn3-tcpdump-stop.sh
index f53cf5d..2dd1e2d 100755
--- a/ttcn3-tcpdump-stop.sh
+++ b/ttcn3-tcpdump-stop.sh
@@ -32,7 +32,7 @@
 done

 if [ -e $PIDFILE ]; then
-       if [ "$(id -u)" = "0" ]; then
+       if [ "$(id -u)" = "0" -o -x /usr/bin/dumpcap ]; then
                kill "$(cat "$PIDFILE")"
        else
        # NOTE: This requires you to be root or something like

--
To view, visit https://gerrit.osmocom.org/13253
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I77df04d51a469c924cf727f0596cc33565909746
Gerrit-Change-Number: 13253
Gerrit-PatchSet: 1
Gerrit-Owner: Max <[email protected]>

Reply via email to