fixed logical error when try to get iptables path with nf_tables thanks @cjb900

This commit is contained in:
mh4x0f 2021-10-09 21:38:49 -03:00
parent 6c8e5a64ae
commit d6cf0a80b1
2 changed files with 14 additions and 3 deletions

View File

@ -28,6 +28,7 @@ All notable changes to this project will be documented in this file.
- fixed wirelesscontroller not started into restAPI mode
- fixed locale error in docker container
- fixed logical error dhcpd server implementation #158
- fixed logical error when try to get iptables path with nf_tables thanks @cjb900
## [Released]

View File

@ -193,15 +193,25 @@ class Linux(QtCore.QObject):
return my_id
@staticmethod
def getBinaryPath(command: str):
binary_path = popen("which {}".format(command)).read()
def getCommandOutput(command: str):
""" get the first line of command executed on bash"""
binary_path = popen("{}".format(command)).read()
if not binary_path:
return ""
return binary_path.split("\n")[0]
@staticmethod
def getBinaryPath(binary_name: str):
""" get the path of binary linux"""
binary_path = popen("which {}".format(binary_name)).read()
if not binary_path:
return ""
return binary_path.split("\n")[0]
@staticmethod
def checkIfIptablesVersion():
if "nf_tables" in Linux.getBinaryPath("iptables"):
""" check if iptables version is nf_tables """
if "nf_tables" in Linux.getCommandOutput("iptables --version"):
return Linux.getBinaryPath("iptables-legacy")
return Linux.getBinaryPath("iptables")