Permanent Changes

Jiri Popelka jpopelka at redhat.com
Wed Apr 9 12:09:38 UTC 2014


On 04/08/2014 08:58 PM, Justin Brown wrote:
> I'm trying to add a few services to the permanent configuration of a
> zone using Python. I've gone over the DBus interface quite
> extensively, but I can't figure out how to make
> /org/fedoraproject/FirewallD1 addService() persistent.
>
> I thought that /org/fedoraproject/FirewallD1/config addService() might
> be correct, but the method doesn't seem to work (testing in
> qdbusviewer) and has a drastically different method definition:

Yes, .config.addService() creates a completely new service, not sure
why it hasn't been called newService().

> 1) Is there a way through DBus to make a change permanent?

Sure. You need to
- get all zone's settings with .config.zone.getSettings()

- append a service name to the correct field in the structure
   - see IMPORT_EXPORT_STRUCTURE in 
https://git.fedorahosted.org/cgit/firewalld.git/tree/src/firewall/core/io/zone.py
   - or try gdbus call --system --dest org.fedoraproject.FirewallD1 
--object-path /org/fedoraproject/FirewallD1/config/zone/0 --method 
org.fedoraproject.FirewallD1.config.zone.getSettings

- update the settings with .config.zone.update()

If you're using Python you can use our client code.
The following snippet permanently adds samba-client service to default zone.

from firewall.client import *
fw = FirewallClient()
zone = fw.getDefaultZone()
fw_zone = fw.config().getZoneByName(zone)
fw_settings = fw_zone.getSettings()
fw_settings.addService("samba-client")
fw_zone.update(fw_settings)

> 2) If not, how do I make permanent changes to a zone without using
> firewall-cmd shell commands?

You can edit the zone's xml file.

Let me know if you need more help.

--
Jiri


More information about the firewalld-devel mailing list