Bug 1250842 - firewall-cmd broken with setenforce 1 [NEEDINFO]
firewall-cmd broken with setenforce 1
Status: NEW
Product: Fedora
Classification: Fedora
Component: selinux-policy-targeted (Show other bugs)
23
Unspecified Unspecified
high Severity high
: ---
: ---
Assigned To: Miroslav Grepl
Ben Levenson
: Reopened
Depends On:
Blocks: 1304721 1332122
  Show dependency treegraph
 
Reported: 2015-08-06 02:51 EDT by Marius Vollmer
Modified: 2017-09-05 15:45 EDT (History)
10 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1304721 (view as bug list)
Environment:
Last Closed: 2016-12-20 09:20:38 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
andreas: needinfo? (benl)


Attachments (Terms of Use)

  None (edit)
Description Marius Vollmer 2015-08-06 02:51:40 EDT
Description of problem:

Running firewall.cmd to change the permanent config fails like this with setenforce 1:

# firewall-cmd --add-port 1234/tcp --permanent
Error: Backup of '/etc/firewalld/zones/public.xml' failed: [Errno 13] Permission denied: '/etc/firewalld/zones/public.xml.old'

It succeeds with setenforce 0.

Version-Release number of selected component (if applicable):

firewalld-0.3.14.2-4.fc23.noarch
Comment 1 Marius Vollmer 2015-08-06 03:03:34 EDT
Ahh, selinux version:

selinux-policy-targeted-3.13.1-138.fc23.noarch
Comment 2 Alessandro Suardi 2015-11-13 08:35:22 EST
Just updated to F23, same issue:

[root@torrent ~]# firewall-cmd --runtime-to-permanent
Error: RT_TO_PERM_FAILED: zone 'public' : org.fedoraproject.FirewallD1.Exception: Backup of '/etc/firewalld/zones/public.xml' failed: [Errno 13] Permission denied: '/etc/firewalld/zones/public.xml.old'
[root@torrent ~]# rpm -q firewalld
firewalld-0.3.14.2-4.fc23.noarch
[root@torrent ~]# rpm -q selinux-policy-targeted
selinux-policy-targeted-3.13.1-152.fc23.noarch
[root@torrent ~]# setenforce 0
[root@torrent ~]# firewall-cmd --runtime-to-permanent
success
Comment 3 Alessandro Suardi 2015-11-13 08:42:35 EST
[root@torrent audit]# grep firewalld audit.log|grep AVC | audit2why
type=AVC msg=audit(1447421196.268:487): avc:  denied  { relabelfrom } for  pid=812 comm="firewalld" name="public.xml.old" dev="dm-1" ino=395314 scontext=system_u:system_r:firewalld_t:s0 tcontext=unconfined_u:object_r:firewalld_etc_rw_t:s0 tclass=file permissive=0

	Was caused by:

#Constraint rule:

#	constrain file { create relabelfrom relabelto } ((u1 == u2 -Fail-)  or (t1 == can_change_object_identity -Fail-) ); Constraint DENIED

#	Possible cause is the source user (system_u) and target user (unconfined_u) are different.
Comment 4 Alessandro Suardi 2015-11-30 05:58:01 EST
Good news - Firewall-cmd --permanent has started working for me even with setenforce 1 in recent FC23 updates...

I'm not setting this to CLOSED RESOLVED because I'm not the original bug filer and can't verify the issue on the machine it was originally reported on.
Comment 5 strasharo2000 2015-12-20 17:25:45 EST
Same error here on up to date F23:

[root@T14 ~] # firewall-cmd --runtime-to-permanent
Error: RT_TO_PERM_FAILED: zone 'public' : org.fedoraproject.FirewallD1.Exception: Backup of '/etc/firewalld/zones/public.xml' failed: [Errno 13] Permission denied: '/etc/firewalld/zones/public.xml.old'
[root@T14 ~] # lsb_release -a
LSB Version:	:core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID:	Fedora
Description:	Fedora release 23 (Twenty Three)
Release:	23
Codename:	TwentyThree
[root@T14 ~] # 


[root@T14 ~] # grep firewalld /var/log/audit/audit.log  | grep AVC
type=AVC msg=audit(1450649588.201:1178): avc:  denied  { relabelfrom } for  pid=2492 comm="firewalld" name="public.xml.old" dev="dm-1" ino=2365085 scontext=system_u:system_r:firewalld_t:s0 tcontext=unconfined_u:object_r:firewalld_etc_rw_t:s0 tclass=file permissive=0
type=AVC msg=audit(1450649602.675:1179): avc:  denied  { relabelfrom } for  pid=2492 comm="firewalld" name="public.xml.old" dev="dm-1" ino=2365085 scontext=system_u:system_r:firewalld_t:s0 tcontext=unconfined_u:object_r:firewalld_etc_rw_t:s0 tclass=file permissive=0
type=AVC msg=audit(1450649690.120:1183): avc:  denied  { relabelfrom } for  pid=2492 comm="firewalld" name="public.xml.old" dev="dm-1" ino=2365085 scontext=system_u:system_r:firewalld_t:s0 tcontext=unconfined_u:object_r:firewalld_etc_rw_t:s0 tclass=file permissive=0
type=AVC msg=audit(1450649722.071:1184): avc:  denied  { relabelfrom } for  pid=2492 comm="firewalld" name="public.xml.old" dev="dm-1" ino=2365085 scontext=system_u:system_r:firewalld_t:s0 tcontext=unconfined_u:object_r:firewalld_etc_rw_t:s0 tclass=file permissive=0
type=AVC msg=audit(1450649843.488:1192): avc:  denied  { relabelfrom } for  pid=2492 comm="firewalld" name="public.xml.old" dev="dm-1" ino=2365085 scontext=system_u:system_r:firewalld_t:s0 tcontext=unconfined_u:object_r:firewalld_etc_rw_t:s0 tclass=file permissive=0
[root@T14 ~] #
Comment 6 Thomas Woerner 2016-01-25 11:38:12 EST
(In reply to strasharo2000 from comment #5)
> Same error here on up to date F23:
> 
> [root@T14 ~] # firewall-cmd --runtime-to-permanent
> Error: RT_TO_PERM_FAILED: zone 'public' :
> org.fedoraproject.FirewallD1.Exception: Backup of
> '/etc/firewalld/zones/public.xml' failed: [Errno 13] Permission denied:
> '/etc/firewalld/zones/public.xml.old'
> [root@T14 ~] # lsb_release -a
> LSB Version:
> :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-
> amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.
> 1-amd64:printing-4.1-noarch
> Distributor ID:	Fedora
> Description:	Fedora release 23 (Twenty Three)
> Release:	23
> Codename:	TwentyThree
> [root@T14 ~] # 
> 
> 
> [root@T14 ~] # grep firewalld /var/log/audit/audit.log  | grep AVC
> type=AVC msg=audit(1450649588.201:1178): avc:  denied  { relabelfrom } for 
> pid=2492 comm="firewalld" name="public.xml.old" dev="dm-1" ino=2365085
> scontext=system_u:system_r:firewalld_t:s0
> tcontext=unconfined_u:object_r:firewalld_etc_rw_t:s0 tclass=file permissive=0
> type=AVC msg=audit(1450649602.675:1179): avc:  denied  { relabelfrom } for 
> pid=2492 comm="firewalld" name="public.xml.old" dev="dm-1" ino=2365085
> scontext=system_u:system_r:firewalld_t:s0
> tcontext=unconfined_u:object_r:firewalld_etc_rw_t:s0 tclass=file permissive=0
> type=AVC msg=audit(1450649690.120:1183): avc:  denied  { relabelfrom } for 
> pid=2492 comm="firewalld" name="public.xml.old" dev="dm-1" ino=2365085
> scontext=system_u:system_r:firewalld_t:s0
> tcontext=unconfined_u:object_r:firewalld_etc_rw_t:s0 tclass=file permissive=0
> type=AVC msg=audit(1450649722.071:1184): avc:  denied  { relabelfrom } for 
> pid=2492 comm="firewalld" name="public.xml.old" dev="dm-1" ino=2365085
> scontext=system_u:system_r:firewalld_t:s0
> tcontext=unconfined_u:object_r:firewalld_etc_rw_t:s0 tclass=file permissive=0
> type=AVC msg=audit(1450649843.488:1192): avc:  denied  { relabelfrom } for 
> pid=2492 comm="firewalld" name="public.xml.old" dev="dm-1" ino=2365085
> scontext=system_u:system_r:firewalld_t:s0
> tcontext=unconfined_u:object_r:firewalld_etc_rw_t:s0 tclass=file permissive=0
> [root@T14 ~] #

Please add the output of "restorecon -rv /etc/firewalld"
Comment 7 strasharo2000 2016-01-27 02:37:23 EST
[root@T14 ~] # restorecon -rv /etc/firewalld
[root@T14 ~] #
Comment 8 Thomas Woerner 2016-02-03 10:23:41 EST
I also managed to run into this now. The backup files are not correctly labeled.

Assingning to selinux-policy-targetd-
Comment 9 Thomas Woerner 2016-02-04 07:57:59 EST
This happens if the root user was running firewalld directly or if the user root copied a file into the firewalld configuration directory.

firewalld will create a backup of the old file by renaming it to <filename>.old

Here are steps to reproduce:
1) cp /usr/lib/firewalld/zones/public.xml /etc/firewalld/zones/foobar.xml
2) After 5 seconds when firewalld picked it up, do a change with firewalld: 
   firewall-cmd --permanent --zone=foobar --add-service=samba

Error: Backup of '/etc/firewalld/zones/foobar.xml' failed: [Errno 13] Permission denied: '/etc/firewalld/zones/foobar.xml.old'

# ls -Z /etc/firewalld/zones/foobar.xml*
unconfined_u:object_r:firewalld_etc_rw_t:s0 /etc/firewalld/zones/foobar.xml
    system_u:object_r:firewalld_etc_rw_t:s0 /etc/firewalld/zones/foobar.xml.old
Comment 10 strasharo2000 2016-02-06 10:46:37 EST
[root@T14 zones] # ls -lZ
total 24
-rw-r--r--. 1 root root system_u:object_r:firewalld_etc_rw_t:s0     315 Dec 21 00:17 FedoraServer.xml
-rw-r--r--. 1 root root system_u:object_r:firewalld_etc_rw_t:s0     525 Dec 21 00:17 FedoraWorkstation.xml
-rw-r--r--. 1 root root system_u:object_r:firewalld_etc_rw_t:s0     369 Dec 21 00:17 home.xml
-rw-r--r--. 1 root root system_u:object_r:firewalld_etc_rw_t:s0     384 Dec 21 00:17 internal.xml
-rw-rw-r--. 1 root root system_u:object_r:firewalld_etc_rw_t:s0     340 Feb 15  2015 public.xml
-rw-rw-r--. 1 root root unconfined_u:object_r:firewalld_etc_rw_t:s0 340 Feb 15  2015 public.xml.old
[root@T14 zones] #
Comment 11 fredg_@_bdx 2016-03-09 00:47:33 EST
Same error here on up to date F23, with firewall-config
Comment 12 Andrew Spurrier 2016-03-21 00:35:11 EDT
I ran into this today.  As per above the context is wrong on the public.xml file so I copied the context from one of the other correct xml files:

# chcon --reference=/etc/firewalld/zones/internal.xml /etc/firewalld/zones/public.xml
# firewall-cmd --runtime-to-permanent

All works and I did not have to drop SELinux Enforcing.
There is something wrong in the policy since the following does not correct the issue:
# restorecon -Rv /etc/firewalld/zones
Comment 13 Fedora End Of Life 2016-11-24 07:16:10 EST
This message is a reminder that Fedora 23 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 23. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '23'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 23 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.
Comment 14 Fedora End Of Life 2016-12-20 09:20:38 EST
Fedora 23 changed to end-of-life (EOL) status on 2016-12-20. Fedora 23 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.
Comment 15 Andreas Thienemann 2017-09-05 15:45:55 EDT
Bug still exists with F26:

[root@index01 ~]# firewall-cmd --set-log-denied off
Error: Backup of '/etc/firewalld/firewalld.conf' failed: [Errno 13] Permission denied: '/etc/firewalld/firewalld.conf.old'
[root@index01 ~]#

[root@index01 ~]# ausearch -m avc -ts recent
----
time->Tue Sep  5 21:41:00 2017
type=AVC msg=audit(1504640460.494:11400): avc:  denied  { relabelto } for  pid=26293 comm="firewalld" name="firewalld.conf.old" dev="xvda3" ino=201898453 scontext=system_u:system_r:firewalld_t:s0 tcontext=unconfined_u:object_r:firewalld_etc_rw_t:s0 tclass=file permissive=0
[root@index01 ~]#

[root@index01 ~]# ausearch -m avc -ts recent | audit2why
type=AVC msg=audit(1504640460.494:11400): avc:  denied  { relabelto } for  pid=26293 comm="firewalld" name="firewalld.conf.old" dev="xvda3" ino=201898453 scontext=system_u:system_r:firewalld_t:s0 tcontext=unconfined_u:object_r:firewalld_etc_rw_t:s0 tclass=file permissive=0

	Was caused by:

#Constraint rule:

#	constrain file { create relabelfrom relabelto } ((u1 == u2 -Fail-)  or (t1 == can_change_object_identity -Fail-) ); Constraint DENIED

#	Possible cause is the source user (system_u) and target user (unconfined_u) are different.

type=AVC msg=audit(1504640517.161:11401): avc:  denied  { relabelto } for  pid=26293 comm="firewalld" name="firewalld.conf.old" dev="xvda3" ino=201898453 scontext=system_u:system_r:firewalld_t:s0 tcontext=unconfined_u:object_r:firewalld_etc_rw_t:s0 tclass=file permissive=0

	Was caused by:

#Constraint rule:

#	constrain file { create relabelfrom relabelto } ((u1 == u2 -Fail-)  or (t1 == can_change_object_identity -Fail-) ); Constraint DENIED

#	Possible cause is the source user (system_u) and target user (unconfined_u) are different.

[root@index01 ~]#

Note You need to log in before you can comment on or make changes to this bug.