Bug 201031 - setsebool broken
setsebool broken
Status: CLOSED CURRENTRELEASE
Product: Fedora
Classification: Fedora
Component: policycoreutils (Show other bugs)
rawhide
All Linux
medium Severity medium
: ---
: ---
Assigned To: Daniel Walsh
Ben Levenson
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-08-02 08:30 EDT by Joe Orton
Modified: 2009-09-11 23:29 EDT (History)
2 users (show)

See Also:
Fixed In Version: Current
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2008-01-21 10:51:54 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Joe Orton 2006-08-02 08:30:52 EDT
Recent Raw Hide/FC6test1-ish install.

[root@trash ~]# setsebool httpd_disable_trans=1
libsemanage.semanage_commit_sandbox: Error while renaming
/etc/selinux/targeted/modules/active to /etc/selinux/targeted/modules/previous.
Could not change policy booleans
[root@trash ~]# rpm -qf /usr/sbin/setsebool
policycoreutils-1.30.17-7
Comment 1 Daniel Walsh 2006-08-02 09:59:28 EDT
I believe this is a labeling problem, in /etc/selinux/targeted directory.

Do you see avc messages?

You can relabel with 

restorecon -R -v /etc/selinux/targeted

Comment 2 Joe Orton 2006-08-02 10:09:15 EDT
That works.

[root@trash ~]# echo MARK >> /var/log/audit/audit.log
[root@trash ~]# setsebool httpd_disable_trans=1
libsemanage.semanage_commit_sandbox: Error while renaming
/etc/selinux/targeted/modules/active to /etc/selinux/targeted/modules/previous.
Could not change policy booleans
[root@trash ~]# tail /var/log/audit/audit.log
type=PATH msg=audit(1154528196.407:678): item=0
name="/etc/selinux/targeted/modules/" inode=2087266 dev=03:03 mode=040755 ouid=0
ogid=0 rdev=00:00 obj=system_u:object_r:selinux_config_t:s0
type=PATH msg=audit(1154528196.407:678): item=1
name="/etc/selinux/targeted/modules/previous" inode=2087266 dev=03:03
mode=040755 ouid=0 ogid=0 rdev=00:00 obj=system_u:object_r:selinux_config_t:s0
type=PATH msg=audit(1154528196.407:678): item=2
name="/etc/selinux/targeted/modules/active" inode=2115588 dev=03:03 mode=040700
ouid=0 ogid=0 rdev=00:00 obj=system_u:object_r:selinux_config_t:s0
MARK
type=AVC msg=audit(1154528220.246:679): avc:  denied  { rename } for  pid=23427
comm="setsebool" name="active" dev=hda3 ino=2115588
scontext=root:system_r:semanage_t:s0-s0:c0.c255
tcontext=system_u:object_r:selinux_config_t:s0 tclass=dir
type=SYSCALL msg=audit(1154528220.246:679): arch=40000003 syscall=38 success=no
exit=-13 a0=99b0628 a1=99b4ab0 a2=4d38a218 a3=bf8a7878 items=3 ppid=12010
pid=23427 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0
tty=pts2 comm="setsebool" exe="/usr/sbin/setsebool"
subj=root:system_r:semanage_t:s0-s0:c0.c255 key=(null)
type=CWD msg=audit(1154528220.246:679):  cwd="/root"
type=PATH msg=audit(1154528220.246:679): item=0
name="/etc/selinux/targeted/modules/" inode=2087266 dev=03:03 mode=040755 ouid=0
ogid=0 rdev=00:00 obj=system_u:object_r:selinux_config_t:s0
type=PATH msg=audit(1154528220.246:679): item=1
name="/etc/selinux/targeted/modules/previous" inode=2087266 dev=03:03
mode=040755 ouid=0 ogid=0 rdev=00:00 obj=system_u:object_r:selinux_config_t:s0
type=PATH msg=audit(1154528220.246:679): item=2
name="/etc/selinux/targeted/modules/active" inode=2115588 dev=03:03 mode=040700
ouid=0 ogid=0 rdev=00:00 obj=system_u:object_r:selinux_config_t:s0
[root@trash ~]#
[root@trash ~]# restorecon -R -v /etc/selinux/targeted
restorecon reset /etc/selinux/targeted/modules/active context
system_u:object_r:selinux_config_t:s0->system_u:object_r:semanage_store_t:s0
restorecon reset /etc/selinux/targeted/modules/active/file_contexts context
system_u:object_r:selinux_config_t:s0->system_u:object_r:semanage_store_t:s0
restorecon reset /etc/selinux/targeted/modules/active/commit_num context
system_u:object_r:selinux_config_t:s0->system_u:object_r:semanage_store_t:s0
restorecon reset /etc/selinux/targeted/modules/active/users_extra context
system_u:object_r:selinux_config_t:s0->system_u:object_r:semanage_store_t:s0restorecon
reset /etc/selinux/targeted/modules/active/modules context
system_u:object_r:selinux_config_t:s0->system_u:object_r:semanage_store_t:s0
restorecon reset /etc/selinux/targeted/modules/active/modules/razor.pp context
system_u:object_r:selinux_config_t:s0->system_u:object_r:semanage_store_t:s0
restorecon reset /etc/selinux/targeted/modules/active/modules/pyzor.pp context
system_u:object_r:selinux_config_t:s0->system_u:object_r:semanage_store_t:s0
restorecon reset /etc/selinux/targeted/modules/active/modules/amavis.pp context
system_u:object_r:selinux_config_t:s0->system_u:object_r:semanage_store_t:s0
restorecon reset /etc/selinux/targeted/modules/active/modules/dcc.pp context
system_u:object_r:selinux_config_t:s0->system_u:object_r:semanage_store_t:s0
restorecon reset /etc/selinux/targeted/modules/active/modules/nagios.pp context
system_u:object_r:selinux_config_t:s0->system_u:object_r:semanage_store_t:s0
restorecon reset /etc/selinux/targeted/modules/active/modules/clamav.pp context
system_u:object_r:selinux_config_t:s0->system_u:object_r:semanage_store_t:s0
restorecon reset /etc/selinux/targeted/modules/active/homedir_template context
system_u:object_r:selinux_config_t:s0->system_u:object_r:semanage_store_t:s0
restorecon reset /etc/selinux/targeted/modules/active/policy.kern context
system_u:object_r:selinux_config_t:s0->system_u:object_r:semanage_store_t:s0restorecon
reset /etc/selinux/targeted/modules/active/base.pp context
system_u:object_r:selinux_config_t:s0->system_u:object_r:semanage_store_t:s0
restorecon reset /etc/selinux/targeted/modules/active/booleans.local context
system_u:object_r:selinux_config_t:s0->system_u:object_r:semanage_store_t:s0
restorecon reset /etc/selinux/targeted/modules/active/base.linked context
system_u:object_r:selinux_config_t:s0->system_u:object_r:semanage_store_t:s0restorecon
reset /etc/selinux/targeted/modules/active/seusers.final context
system_u:object_r:selinux_config_t:s0->system_u:object_r:semanage_store_t:s0
restorecon reset /etc/selinux/targeted/modules/active/file_contexts.template
context system_u:object_r:selinux_config_t:s0->system_u:object_r:semanage_store_t:s0
[root@trash ~]# setsebool httpd_disable_trans=1
zope homedir /opt/zope or its parent directory conflicts with a
defined context in /etc/selinux/targeted/contexts/files/file_contexts,
/usr/sbin/genhomedircon will not create a new context. This usually indicates an
incorrectly defined system account.  If it is a system account please make sure
its login shell is /sbin/nologin.
ptest homedir /local/ptest or its parent directory conflicts with a
defined context in /etc/selinux/targeted/contexts/files/file_contexts,
/usr/sbin/genhomedircon will not create a new context. This usually indicates an
incorrectly defined system account.  If it is a system account please make sure
its login shell is /sbin/nologin.
Comment 3 Daniel Walsh 2006-08-02 13:58:52 EDT
Any idea how it got in this state?

You might want to change the shell on zope and  ptest to /bin/false to eliminate
the genhomedircon warnings.

Comment 4 Joe Orton 2006-08-03 04:20:59 EDT
It's a fresh @Everything install of Raw Hide so presumably you can reproduce
this at will to debug further?
Comment 5 Daniel Walsh 2006-08-03 11:40:51 EDT
Yes the problem was in anaconda policy.  Basically it was not transitioning to
semanage_t so the context was not getting setup correctly.

Fixes in selinux-policy-2.3.3-19
Comment 6 Todd Thomas 2009-09-11 16:21:22 EDT
I have selinux-policy-2.4.6-203 and I'm still seeing this behavior. Example: 

# setsebool -P allow_ftpd_anon_write 1
zimbra homedir /opt/zimbra or its parent directory conflicts with a
defined context in /etc/selinux/targeted/contexts/files/file_contexts,
/usr/sbin/genhomedircon will not create a new context. This usually indicates an incorrectly defined system account.  If it is a system account please make sure its login shell is /sbin/nologin.
===

It really doesn't matter if you try to change allow_ftpd_anon_write or another one, they always error with 'zimbra homedir /opt/zimbra or its parent directory conflicts...'
Comment 7 Daniel Walsh 2009-09-11 16:26:41 EDT
Todd the problem is that /opt/zimbra is not a real login, so the shell should be /sbin/nologin

genhomedircon thinks you have a real user on your system named zimbra, but this is most likely a system account.  If you change the shell to /sbin/nologin, genhomedircon will ignore the account.
Comment 8 Daniel Walsh 2009-09-11 16:34:44 EDT
zimbra should probably install it self as a --system with a UID < 500.  Then SELinux will ignore it also.
Comment 9 Todd Thomas 2009-09-11 23:29:19 EDT
I'll respond for the purposes of posterity:

#7) You're right. But the shell is /bin/bash. /opt/zimbra is the home directory. Here's the layout:
zimbra:x:500:500::/opt/zimbra:/bin/bash
postfix:x:501:501::/opt/zimbra/postfix:/bin/bash

#8) It probably should be < 500 but that's how the install script install both zimbra and posfix accounts. There may be design reasons for doing this. 

I know that Zimbra interacts with the system and there are buzillions of command line tools for the app so /bin/bash is necessary. Setting the home directory just standardizes a starting place to build an environment. I would guess also necessary.

I haven't had time to test it but as I understand it some logging and statistical functionality would be lost by removing /bin/bash but there are better people to ask than me, I'm sure.

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