Repository :
http://git.fedorahosted.org/cgit/firewalld-recode.git
On branch : master
---------------------------------------------------------------
commit 08be60cfcdd082eac586cbd4f4e0f21fce8f17fb
Author: Daniel Kopecek <dkopecek(a)redhat.com>
Date: Mon Oct 6 14:02:33 2014 +0200
Implemented the getServiceSettings DBus method
---------------------------------------------------------------
src/Daemon/DBus/getServiceSettings.cpp | 50 ++++++++++++++++++++++++++++++--
1 files changed, 47 insertions(+), 3 deletions(-)
diff --git a/src/Daemon/DBus/getServiceSettings.cpp
b/src/Daemon/DBus/getServiceSettings.cpp
index 2c809a2..5e209b5 100644
--- a/src/Daemon/DBus/getServiceSettings.cpp
+++ b/src/Daemon/DBus/getServiceSettings.cpp
@@ -17,6 +17,7 @@
// Authors: Daniel Kopecek <dkopecek(a)redhat.com>
//
#include "Daemon/FirewallD.hpp"
+#include "Daemon/Backends/Linux/KernelModule.hpp"
#include "Daemon/DBus.hpp"
#include "Common/Types.hpp"
@@ -24,10 +25,53 @@ namespace firewalld
{
FIREWALLD_DBUS_METHOD(getServiceSettings)
{
- result.setTypeSignature("(sssa(ss)asa{ss})");
+ result.setTypeSignature("((sssa(ss)asa{ss}))");
- UString service;
- parameters.get(0, service);
+ UString service_identifier;
+ parameters.get(0, service_identifier);
+
+ try {
+ Pointer<Service> service = lookupService(service_identifier);
+
+ if (service == nullptr) {
+ throw FirewallError("INVALID_SERVICE", "Unknown service");
+ }
+
+ result << service->version();
+ result << service->name();
+ result << service->description();
+
+ DBusResultBuilder& port_array = result.addBuilder();
+ int port_index = 0;
+
+ for (auto const& port : service->ports()) {
+ port_array[port_index] << UString(port->range().toString());
+ switch(port->protocol()) {
+ case Port::Protocol::TCP:
+ port_array[port_index] << UString("tcp");
+ break;
+ case Port::Protocol::UDP:
+ port_array[port_index] << UString("udp");
+ break;
+ default:
+ throw FirewallError("INVALID_SERVICE", "Ambiguous port protocol
specification");
+ }
+ ++port_index;
+ }
+
+ UStringVector modules;
+ for (auto const& module : service->modules()) {
+ modules.push_back(module->name());
+ }
+ result << modules;
+
+ // TODO: Implement destinations in Service class
+ UStringKeyMap<UString> destinations;
+ result << destinations;
+
+ } catch(const FirewallError& ex) {
+ result = DBusError(ex);
+ }
return;
}