Skip to content

Commit

Permalink
bug fix: firewalld
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Jan 1, 2020
1 parent 1a95b0d commit db866f2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
34 changes: 14 additions & 20 deletions plogical/firewallUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,20 @@ def addRule(proto,port,ipAddress):
ruleProtocol = 'port protocol="' + proto + '"'
rulePort = 'port="' + port + '"'

command = "sudo firewall-cmd --permanent --zone=public --add-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
command = "firewall-cmd --permanent --zone=public --add-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"

if not FirewallUtilities.doCommand(command):
return 0
ProcessUtilities.executioner(command)

ruleFamily = 'rule family="ipv6"'
sourceAddress = ''

command = "sudo firewall-cmd --permanent --zone=public --add-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
command = "firewall-cmd --permanent --zone=public --add-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"

if not FirewallUtilities.doCommand(command):
return 0
ProcessUtilities.executioner(command)

command = 'sudo firewall-cmd --reload'
command = 'firewall-cmd --reload'

if not FirewallUtilities.doCommand(command):
return 0
ProcessUtilities.executioner(command)

return 1

Expand All @@ -72,23 +69,20 @@ def deleteRule(proto, port, ipAddress):
ruleProtocol = 'port protocol="' + proto + '"'
rulePort = 'port="' + port + '"'

command = "sudo firewall-cmd --permanent --zone=public --remove-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
command = "firewall-cmd --permanent --zone=public --remove-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"

if ProcessUtilities.executioner(command) == 0:
return 0
ProcessUtilities.executioner(command)

ruleFamily = 'rule family="ipv6"'
sourceAddress = ''

command = "sudo firewall-cmd --permanent --zone=public --remove-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"
command = "firewall-cmd --permanent --zone=public --remove-rich-rule='" + ruleFamily + " " + sourceAddress + " " + ruleProtocol + " " + rulePort + " " + "accept'"

if ProcessUtilities.executioner(command) == 0:
return 0
ProcessUtilities.executioner(command)

command = 'sudo firewall-cmd --reload'
command = 'firewall-cmd --reload'

if ProcessUtilities.executioner(command) == 0:
return 0
ProcessUtilities.executioner(command)

return 1

Expand All @@ -97,7 +91,7 @@ def saveSSHConfigs(type, sshPort, rootLogin):
try:
if type == "1":

command = 'sudo semanage port -a -t ssh_port_t -p tcp ' + sshPort
command = 'semanage port -a -t ssh_port_t -p tcp ' + sshPort
ProcessUtilities.normalExecutioner(command)

FirewallUtilities.addRule('tcp', sshPort, "0.0.0.0/0")
Expand Down Expand Up @@ -127,7 +121,7 @@ def saveSSHConfigs(type, sshPort, rootLogin):
writeToFile.writelines(items)
writeToFile.close()

command = 'sudo systemctl restart sshd'
command = 'systemctl restart sshd'
ProcessUtilities.normalExecutioner(command)

print("1,None")
Expand Down
6 changes: 3 additions & 3 deletions static/CLManager/CLManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ app.controller('installCageFS', function ($scope, $http, $timeout, $window) {
};

function getRequestStatus() {
$scope.cyberPanelLoading = false;
$scope.installDockerStatus = false;

url = "/serverstatus/switchTOLSWSStatus";

Expand All @@ -72,7 +72,7 @@ app.controller('installCageFS', function ($scope, $http, $timeout, $window) {
$timeout(getRequestStatus, 1000);
} else {
// Notifications
$scope.cyberPanelLoading = true;
$scope.installDockerStatus = true;
$timeout.cancel();
$scope.requestData = response.data.requestStatus;
if (response.data.installed === 1) {
Expand All @@ -85,7 +85,7 @@ app.controller('installCageFS', function ($scope, $http, $timeout, $window) {
}

function cantLoadInitialDatas(response) {
$scope.cyberPanelLoading = true;
$scope.installDockerStatus = true;
new PNotify({
title: 'Operation Failed!',
text: 'Could not connect to server, please refresh this page',
Expand Down

0 comments on commit db866f2

Please sign in to comment.