Refactor privileges for ssh commands
Remove logic that checks for root login and prepends command with sudo, because we should not use root login at all and all commands (that require higher permissions should be prefixed with sudo anyways). Add sudo prefix to privileged commands that require it. Signed-off-by: Vladimir Domnich <v.domnich@yadro.com>
This commit is contained in:
parent
f9ba463d2e
commit
b6b1644fd6
5 changed files with 22 additions and 18 deletions
|
@ -6,11 +6,11 @@ class IpTablesHelper:
|
|||
@staticmethod
|
||||
def drop_input_traffic_to_port(client: HostClient, ports: list[str]):
|
||||
for port in ports:
|
||||
cmd_output = client.exec(cmd=f'iptables -A INPUT -p tcp --dport {port} -j DROP')
|
||||
cmd_output = client.exec(cmd=f'sudo iptables -A INPUT -p tcp --dport {port} -j DROP')
|
||||
assert cmd_output.rc == 0
|
||||
|
||||
@staticmethod
|
||||
def restore_input_traffic_to_port(client: HostClient, ports: list[str]):
|
||||
for port in ports:
|
||||
cmd_output = client.exec(cmd=f'iptables -D INPUT -p tcp --dport {port} -j DROP')
|
||||
cmd_output = client.exec(cmd=f'sudo iptables -D INPUT -p tcp --dport {port} -j DROP')
|
||||
assert cmd_output.rc == 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue