[MERGED] osmo-gsm-tester[master]: util: Add setcap_net_raw API

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Mon Nov 6 17:43:02 UTC 2017


Pau Espin Pedrol has submitted this change and it was merged.

Change subject: util: Add setcap_net_raw API
......................................................................


util: Add setcap_net_raw API

Some binaries such as osmo-bts-ocpty require specific capabilities, and
we need to provide them in case osmo-gsm-tester is not run as root.

Process class from process module is imported inside the method after
module initialization in order to avoid circular dependency of relative
imports, which is only available since python 3.5.

Change-Id: If3eb24461c02173dc80837a4cc83f9f2420c7816
---
M src/osmo_gsm_tester/util.py
1 file changed, 13 insertions(+), 0 deletions(-)

Approvals:
  Pau Espin Pedrol: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/osmo_gsm_tester/util.py b/src/osmo_gsm_tester/util.py
index c07bcf2..1ecbf41 100644
--- a/src/osmo_gsm_tester/util.py
+++ b/src/osmo_gsm_tester/util.py
@@ -49,6 +49,19 @@
         pass
     return None
 
+def setcap_net_raw(binary, run_dir):
+    '''
+    This functionality requires specific setup on the host running
+    osmo-gsm-tester. See osmo-gsm-tester manual for more information.
+    '''
+    from .process import Process
+    SETCAP_NET_BIN = 'osmo-gsm-tester_setcap_net_raw.sh'
+    proc = Process(SETCAP_NET_BIN, run_dir, ['sudo', 'osmo-gsm-tester_setcap_net_raw.sh', binary])
+    proc.launch()
+    proc.wait()
+    if proc.result != 0:
+        raise RuntimeError('%s finished with err code %d' % (SETCAP_NET_BIN, proc.result))
+
 class listdict(dict):
     'a dict of lists { "a": [1, 2, 3],  "b": [1, 2] }'
 

-- 
To view, visit https://gerrit.osmocom.org/4423
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: If3eb24461c02173dc80837a4cc83f9f2420c7816
Gerrit-PatchSet: 3
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>



More information about the gerrit-log mailing list