autotest/autotest — pull request #730 by rbbratta (2013-08-28 07:17:33+00:00)
Title: autotest-firewalld-add-service: read firewalld system settings before trying default/fallback settings

Problem: We need to be able to modify firewalld zones on systems that
pre-date the `firewall-cmd --permanent` option.

In order to do this we must manually read/write the xml in
`/etc/firewalld`. The file system layout for firewalld is such that the
default/fallback configuration is stored in `/usr/lib/firewalld` and the
system configuration is stored in `/etc/firewalld/`

To accommodate this default/fallback and system settings behaviour when
we add the service to the zone file we must first attempt to read
existing settings from `/etc/firewalld/zones`, and if no such file exists
in `/etc/firewalld/zones`, only then will we read the default/fallback
settings in `/usr/lib/firewalld/zones`.

This patch implements this behavior using a try/open/except function.
We use open() instead of os.access because open is a more exact test of
file readability. os.access does not attempt access with EUID/EGID or
other effective permissions, whereas open() does.

Lightly tested on Fedora 18.

Signed-off-by: Ross Brattain