summaryrefslogtreecommitdiff
path: root/helpers
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2020-03-26 17:53:01 +0100
committerRuben Pollan <meskio@sindominio.net>2020-03-26 17:53:01 +0100
commit4c5fbd10a4ddf551162154ffd815a9c4eb6ed818 (patch)
treebedb5da701d89e85a08838a471ee16da7a1b30e4 /helpers
parentfc304c9181de4811246ea1a2c16767f928d438f1 (diff)
[feat] bitmask-root: search for the system commands in the common paths
Find the right path of the system commands looking into /sbin, /usr/sbin and /usr/local/sbin - Resolves: #254
Diffstat (limited to 'helpers')
-rw-r--r--helpers/bitmask-root21
1 files changed, 17 insertions, 4 deletions
diff --git a/helpers/bitmask-root b/helpers/bitmask-root
index 3376ce7..13ba407 100644
--- a/helpers/bitmask-root
+++ b/helpers/bitmask-root
@@ -100,10 +100,23 @@ LOCAL_INTERFACE = "lo"
IMAP_PORT = "1984"
SMTP_PORT = "2013"
-IP = "/sbin/ip"
-IPTABLES = "/sbin/iptables"
-IP6TABLES = "/sbin/ip6tables"
-SYSCTL = "/sbin/sysctl"
+def swhich(binary):
+ """
+ Find the path to binary in sbin
+
+ :rtype: str
+ """
+ for folder in ["/sbin", "/usr/sbin", "/usr/local/sbin"]:
+ path = os.path.join(folder, binary)
+ if os.path.isfile(path):
+ return path
+
+ raise Exception("Can't find %s" % (binary,))
+
+IP = swhich("ip")
+IPTABLES = swhich("iptables")
+IP6TABLES = swhich("ip6tables")
+SYSCTL = swhich("sysctl")
OPENVPN_USER = "nobody"
OPENVPN_GROUP = get_no_group_name()