@@ -45,23 +45,20 @@ def addRule(proto,port,ipAddress):
4545 ruleProtocol = 'port protocol="' + proto + '"'
4646 rulePort = 'port="' + port + '"'
4747
48- command = "sudo firewall-cmd --permanent --zone=public --add-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
48+ command = "firewall-cmd --permanent --zone=public --add-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
4949
50- if not FirewallUtilities .doCommand (command ):
51- return 0
50+ ProcessUtilities .executioner (command )
5251
5352 ruleFamily = 'rule family="ipv6"'
5453 sourceAddress = ''
5554
56- command = "sudo firewall-cmd --permanent --zone=public --add-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
55+ command = "firewall-cmd --permanent --zone=public --add-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
5756
58- if not FirewallUtilities .doCommand (command ):
59- return 0
57+ ProcessUtilities .executioner (command )
6058
61- command = 'sudo firewall-cmd --reload'
59+ command = 'firewall-cmd --reload'
6260
63- if not FirewallUtilities .doCommand (command ):
64- return 0
61+ ProcessUtilities .executioner (command )
6562
6663 return 1
6764
@@ -72,23 +69,20 @@ def deleteRule(proto, port, ipAddress):
7269 ruleProtocol = 'port protocol="' + proto + '"'
7370 rulePort = 'port="' + port + '"'
7471
75- command = "sudo firewall-cmd --permanent --zone=public --remove-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
72+ command = "firewall-cmd --permanent --zone=public --remove-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
7673
77- if ProcessUtilities .executioner (command ) == 0 :
78- return 0
74+ ProcessUtilities .executioner (command )
7975
8076 ruleFamily = 'rule family="ipv6"'
8177 sourceAddress = ''
8278
83- command = "sudo firewall-cmd --permanent --zone=public --remove-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
79+ command = "firewall-cmd --permanent --zone=public --remove-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
8480
85- if ProcessUtilities .executioner (command ) == 0 :
86- return 0
81+ ProcessUtilities .executioner (command )
8782
88- command = 'sudo firewall-cmd --reload'
83+ command = 'firewall-cmd --reload'
8984
90- if ProcessUtilities .executioner (command ) == 0 :
91- return 0
85+ ProcessUtilities .executioner (command )
9286
9387 return 1
9488
@@ -97,7 +91,7 @@ def saveSSHConfigs(type, sshPort, rootLogin):
9791 try :
9892 if type == "1" :
9993
100- command = 'sudo semanage port -a -t ssh_port_t -p tcp ' + sshPort
94+ command = 'semanage port -a -t ssh_port_t -p tcp ' + sshPort
10195 ProcessUtilities .normalExecutioner (command )
10296
10397 FirewallUtilities .addRule ('tcp' , sshPort , "0.0.0.0/0" )
@@ -127,7 +121,7 @@ def saveSSHConfigs(type, sshPort, rootLogin):
127121 writeToFile .writelines (items )
128122 writeToFile .close ()
129123
130- command = 'sudo systemctl restart sshd'
124+ command = 'systemctl restart sshd'
131125 ProcessUtilities .normalExecutioner (command )
132126
133127 print ("1,None" )
0 commit comments