API CHANGE: last sysadm/firewall action

Final action for the sysadm/firewall class: "action" = "reset-defaults"
This will reset all the firewall settings back to defaults and restart the firewall.
NOTE: This will only work on TrueOS - plain FreeBSD does not have any concept of default firewall settings and this API call will return an error in that case.

REST Request (example):
-------------------------------
PUT /sysadm/firewall
{
   "action" : "reset-defaults"
}

WebSocket Request:
-------------------------------
{
   "id" : "fooid",
   "args" : {
      "action" : "reset-defaults"
   },
   "namespace" : "sysadm",
   "name" : "firewall"
}

Response:
-------------------------------
{
  "args": {
    "result": "success"
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
This commit is contained in:
Ken Moore
2016-09-13 08:07:31 -04:00
parent c089525bf7
commit c9f227eebc
3 changed files with 7 additions and 2 deletions

View File

@@ -1190,6 +1190,9 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmFirewallRequest(const QJsonV
ok = true;
FMGR.Disable();
}else if(action=="reset-defaults"){
ok = FMGR.RestoreDefaults();
}

View File

@@ -182,14 +182,16 @@ void Firewall::Disable()
serviceManager.Disable( serviceManager.GetService("ipfw") );
}
void Firewall::RestoreDefaults()
bool Firewall::RestoreDefaults()
{
if(QFile::exists("/usr/local/share/trueos/scripts/reset-firewall")){
//refresh/restart the rules files
QStringList args;
args << "/usr/local/share/trueos/scripts/reset-firewall";
General::RunCommand("sh",args);
return true;
}
return false;
}
void Firewall::readServicesFile()

View File

@@ -120,7 +120,7 @@ public:
/**
* @brief Restores the Default Configuration
*/
void RestoreDefaults();
bool RestoreDefaults();
///#endsection
private: