libvirt/m4
Laine Stump 3b71f2e42d configure: selectively install a firewalld 'libvirt' zone
In the past (when both libvirt and firewalld used iptables), if either
libvirt's rules *OR* firewalld's rules accepted a packet, it would
be accepted. This was because libvirt and firewalld rules were
processed during the same kernel hook, and a single ACCEPT result
would terminate the rule traversal and cause the packet to be
accepted.

But now firewalld can use nftables for its backend, while libvirt's
firewall rules are still using iptables; iptables rules are still
processed, but at a different time during packet processing
(i.e. during a different hook) than the firewalld nftables rules. The
result is that a packet must be accepted by *BOTH* the libvirt
iptables rules *AND* the firewalld nftable rules in order to be
accepted.

This causes pain because

1) libvirt always adds rules to permit DNS and DHCP (and sometimes
TFTP) from guests to the host network's bridge interface. But
libvirt's bridges are in firewalld's "default" zone (which is usually
the zone called "public"). The public zone allows ssh, but doesn't
allow DNS, DHCP, or TFTP. So even though libvirt's rules allow the
DHCP and DNS traffic, the firewalld rules (now processed during a
different hook) dont, thus guests connected to libvirt's bridges can't
acquire an IP address from DHCP, nor can they make DNS queries to the
DNS server libvirt has setup on the host. (This could be solved by
modifying the default firewalld zone to allow DNS and DHCP, but that
would open *all* interfaces in the default zone to those services,
which is most likely not what the host's admin wants.)

2) Even though libvirt adds iptables rules to allow forwarded traffic
to pass the iptables hook, firewalld's higher level "rich rules" don't
yet have the ability to configure the acceptance of forwarded traffic
(traffic that is going somewhere beyond the host), so any traffic that
needs to be forwarded from guests to the network beyond the host is
rejected during the nftables hook by the default zone's "default
reject" policy (which rejects all traffic in the zone not specifically
allowed by the rules in the zone, whether that traffic is destined to
be forwarded or locally received by the host).

libvirt can't send "direct" nftables rules (firewalld only supports
direct/passthrough rules for iptables), so we can't solve this problem
by just sending explicit nftables rules instead of explicit iptables
rules (which, if it could be done, would place libvirt's rules in the
same hook as firewalld's native rules, and thus eliminate the need for
packets to be accepted by both libvirt's and firewalld's own rules).

However, we can take advantage of a quirk in firewalld zones that have
a default policy of "accept" (meaning any packet that doesn't match a
specific rule in the zone will be *accepted*) - this default accept will
also accept forwarded traffic (not just traffic destined for the host).

Of course we don't want to modify firewalld's default zone in that
way, because that would affect the filtering of traffic coming into
the host from other interfaces using that zone. Instead, we will
create a new zone called "libvirt". The libvirt zone will have a
default policy of accept so that forwarded traffic can pass and list
specific services that will be allowed into the host from guests (DNS,
DHCP, SSH, and TFTP).

But the same default accept policy that fixes forwarded traffic also
causes *all* traffic from guest to host to be accepted. To close this
new hole, the libvirt zone can take advantage of a new feature in
firewalld (currently slated for firewalld-0.7.0) - priorities for rich
rules - to add a low priority rule that rejects all local traffic (but
leaves alone all forwarded traffic).

So, our new zone will start with a list of services that are allowed
(dhcp, dns, tftp, and ssh to start, but configurable via any firewalld
management application, or direct editing of the zone file in
/etc/firewalld/zones/libvirt.xml), followed by a low priority
<reject/> rule (to reject all other traffic from guest to host), and
finally with a default policy of accept (to allow forwarded traffic).

This patch only creates the zonefile for the new zone, and implements
a configure.ac option to selectively enable/disable installation of
the new zone. A separate patch contains the necessary code to actually
place bridge interfaces in the libvirt zone.

Why do we need a configure option to disable installation of the new
libvirt zone? It uses a new firewalld attribute that sets the priority
of a rich rule; this feature first appears in firewalld-0.7.0 (unless
it has been backported to am earlier firewalld by a downstream
maintainer). If the file were installed on a system with firewalld
that didn't support rule priorities, firewalld would log an error
every time it restarted, causing confusion and lots of extra bug
reports.

So we add two new configure.ac switches to avoid polluting the system
logs with this error on systems that don't support rule priorities -
"--with-firewalld-zone" and "--without-firewalld-zone". A package
builder can use these to include/exclude the libvirt zone file in the
installation. If firewalld is enabled (--with-firewalld), the default
is --with-firewalld-zone, but it can be disabled during configure
(using --without-firewalld-zone). Targets that are using a firewalld
version too old to support the rule priority setting in the libvirt
zone file can simply add --without-firewalld-zone to their configure
commandline.

These switches only affect whether or not the libvirt zone file is
*installed* in /usr/lib/firewalld/zones, but have no effect on whether
or not libvirt looks for a zone called libvirt and tries to use it.

NB: firewalld zones can only be added to the permanent config of
firewalld, and won't be loaded/enabled until firewalld is restarted,
so at package install/upgrade time we have to restart firewalld. For
rpm-based distros, this is done in the libvirt.spec file by calling
the %firewalld_restart rpm macro, which is a part of the
firewalld-filesystem package. (For distros that don't use rpm
packages, the command "firewalld-cmd --reload" will have the same
effect).

Signed-off-by: Laine Stump <laine@laine.org>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2019-02-01 12:08:37 -05:00
..
virt-acl.m4 m4: Fix missing with_acl variable 2017-05-26 11:37:44 +02:00
virt-apparmor.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-arg.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-atomic.m4 configure: move atomic check to its own file 2016-12-21 15:39:38 +01:00
virt-attr.m4 Fix include for xattr.h 2018-08-06 11:50:53 +02:00
virt-audit.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-avahi.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-bash-completion.m4 m4: Don't enable bash-completion by default 2018-01-12 10:43:30 +01:00
virt-blkid.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-capng.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-chrdev-lock-files.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-compile-pie.m4 Fix '-pie' build with clang 2016-02-09 13:29:53 +01:00
virt-compile-warnings.m4 m4: enforce that all enum cases are listed in switch statements 2018-02-21 16:59:48 +00:00
virt-curl.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-dbus.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-debug.m4 configure: move debug check to its own file 2016-12-21 15:39:40 +01:00
virt-default-editor.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-devmapper.m4 m4/virt-devmapper: use LIBVIRT_CHECK_(PKG|LIB) 2016-12-21 15:39:39 +01:00
virt-dlopen.m4 configure: move dlopen check to its own file 2016-12-21 15:39:38 +01:00
virt-driver-bhyve.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-driver-esx.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-driver-hyperv.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-driver-interface.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-driver-libvirtd.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-driver-libxl.m4 libxl: add support for PVH 2018-11-26 16:31:21 -07:00
virt-driver-lxc.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-driver-modules.m4 make: Drop building without driver modules 2017-07-27 12:00:35 +02:00
virt-driver-network.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-driver-openvz.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-driver-phyp.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-driver-qemu.m4 Revert "build: switch --with-qemu default from yes to check" 2018-08-13 15:50:01 +02:00
virt-driver-remote.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-driver-test.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-driver-vbox.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-driver-vmware.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-driver-vz.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-driver-xenapi.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-dtrace.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-external-programs.m4 docs: make xmllint & xsltproc compulsory 2017-08-02 17:00:11 +01:00
virt-firewalld-zone.m4 configure: selectively install a firewalld 'libvirt' zone 2019-02-01 12:08:37 -05:00
virt-firewalld.m4 configure: change HAVE_FIREWALLD to WITH_FIREWALLD 2019-02-01 12:08:37 -05:00
virt-fuse.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-gluster.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-gnutls.m4 configure: Require GnuTLS 2018-06-05 14:32:03 +02:00
virt-hal.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-host-validate.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-init-script.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-lib.m4 m4/virt-arg: Move LIBVIRT_ARG_* macros to their own file 2016-12-22 15:20:05 +01:00
virt-libiscsi.m4 configure: Introduce libiscsi in build system 2018-08-06 12:23:55 +02:00
virt-libnl.m4 configure: move libnl check to its own file 2016-12-21 15:39:39 +01:00
virt-libpcap.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-libssh.m4 m4: checking if ssh_get_server_publickey() exists. 2018-05-11 10:38:08 +02:00
virt-libxml.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-linker-no-indirect.m4 Check for --no-copy-dt-needed linker flag 2013-08-22 16:17:36 +02:00
virt-linker-no-undefined.m4 build: passing the "-z defs" linker flag to prevent undefined symbols 2018-02-09 11:05:10 +00:00
virt-linker-relro.m4 Simplify RELRO_LDFLAGS 2013-08-22 16:17:35 +02:00
virt-loader-nvram.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-login-shell.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-macvtap.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-netcf.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-nls.m4 po: don't install gmo files when --disable-nls is given 2018-06-05 17:36:42 +01:00
virt-nss.m4 Revert "Switch from yajl to Jansson" 2018-08-13 15:50:01 +02:00
virt-numactl.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-numad.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-nwfilter.m4 configure: move nwfilter check to its own file 2016-12-21 15:39:39 +01:00
virt-openwsman.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-parted.m4 m4/virt-parted: use LIBVIRT_CHECK_PKG 2016-12-21 15:39:40 +01:00
virt-pciaccess.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-pm-utils.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-polkit.m4 polkit: reintroduce check for pkcheck 2018-03-25 22:27:22 +02:00
virt-pthread.m4 configure: move pthread check it its own file 2016-12-21 15:39:38 +01:00
virt-readline.m4 m4: Check for rl_completion_quote_character 2018-01-15 17:59:26 +01:00
virt-result.m4 Add some autoconf helper macros for checking for libraries 2013-01-11 11:03:22 +00:00
virt-sanlock.m4 locking: Add support for sanlock_strerror 2017-04-27 11:44:11 +02:00
virt-sasl.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-secdriver-apparmor.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-secdriver-selinux.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-selinux.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-ssh2.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-storage-dir.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-storage-disk.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-storage-fs.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-storage-gluster.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-storage-iscsi-direct.m4 storage: Implement iscsi_direct pool backend 2018-08-06 12:23:55 +02:00
virt-storage-iscsi.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-storage-lvm.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-storage-mpath.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-storage-rbd.m4 virt-storage-rbd: fix typo s/RDB/RBD/ in configure check 2017-04-19 15:01:17 +01:00
virt-storage-scsi.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-storage-sheepdog.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-storage-vstorage.m4 configure: Fix copy-paste error in vstorage backend check 2017-01-27 10:37:56 +01:00
virt-storage-zfs.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-sysctl.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-tls-priority.m4 configure: fix indentation in TLS priority result 2017-01-24 17:24:14 +01:00
virt-udev.m4 udev: Fix build on older platforms 2017-05-31 13:28:24 +02:00
virt-virtualport.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-win-common.m4 configure: move windows common check to its own file 2016-12-21 15:39:39 +01:00
virt-win-cygwin.m4 configure: move Cygwin check to its own file 2016-12-21 15:39:39 +01:00
virt-win-mingw.m4 configure: move MinGW check to its own file 2016-12-21 15:39:39 +01:00
virt-win-symbols.m4 configure: move windows symbols check to its own file 2016-12-21 15:39:39 +01:00
virt-win-windres.m4 configure: move windres check to its own file 2016-12-21 15:39:39 +01:00
virt-wireshark.m4 m4/virt-arg: Rename LIBVIRT_ARG_WITH* macros 2016-12-22 15:20:05 +01:00
virt-xdr.m4 configure: move XDR check to its own file 2016-12-21 15:39:38 +01:00
virt-yajl.m4 Revert "Switch from yajl to Jansson" 2018-08-13 15:50:01 +02:00