Bug 747345
Summary: | semanage is changing permissions of /etc/selinux files | ||||||
---|---|---|---|---|---|---|---|
Product: | Red Hat Enterprise Linux 6 | Reporter: | Miroslav Vadkerti <mvadkert> | ||||
Component: | libsemanage | Assignee: | Daniel Walsh <dwalsh> | ||||
Status: | CLOSED ERRATA | QA Contact: | Miroslav Vadkerti <mvadkert> | ||||
Severity: | urgent | Docs Contact: | |||||
Priority: | urgent | ||||||
Version: | 6.2 | CC: | dwalsh, ebenes, eparis, jrieden, ksrot, mgrepl, mmalik, sdsmall, sgrubb, tmraz | ||||
Target Milestone: | rc | Keywords: | TestBlocker | ||||
Target Release: | --- | ||||||
Hardware: | All | ||||||
OS: | Linux | ||||||
Whiteboard: | |||||||
Fixed In Version: | libsemanage-2.0.43-4.1.el6 | Doc Type: | Bug Fix | ||||
Doc Text: | Story Points: | --- | |||||
Clone Of: | Environment: | ||||||
Last Closed: | 2011-12-06 19:04:13 UTC | Type: | --- | ||||
Regression: | --- | Mount Type: | --- | ||||
Documentation: | --- | CRM: | |||||
Verified Versions: | Category: | --- | |||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
Cloudforms Team: | --- | Target Upstream Version: | |||||
Embargoed: | |||||||
Bug Depends On: | |||||||
Bug Blocks: | 584498, 750914, 846801, 846802 | ||||||
Attachments: |
|
Description
Miroslav Vadkerti
2011-10-19 14:51:56 UTC
I am not sure if this is a bug or not. Users generally should not be running restorecon. Currently we do not have hard coded permissions for these files. This is an issue with semanage changing permissions on several files in /etc/selinux according to umask. Is this on purpose? For example if user wants to use ssh-copy-id he ends up with permission denied because it runs restorecon: # grep -n restorecon $(which ssh-copy-id) 41:{ eval "$GET_ID" ; } | ssh $1 "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys; test -x /sbin/restorecon && /sbin/restorecon .ssh .ssh/authorized_keys" || exit 1 I would say, if an admin sets umask, then probably is expected the restorecon won't work for users. If this won't be fixed in semanage, we will need to fix openssh. Maybe libsemanage should save and restore umask() when creating files? It already allows file mode to be specified via semanage.conf, but doesn't save/restore umask and thus is subject to caller's umask. I'd say this is similar to the situation when someone runs adduser and /etc/passwd gets re-created; the permissions of /etc/passwd aren't subject to the caller's umask, right? So libsemanage ought to save and clear the umask before creating files and restore it afterward. Simple patch to semanage_copy_file(). (In reply to comment #5) > Maybe libsemanage should save and restore umask() when creating files? It > already allows file mode to be specified via semanage.conf, but doesn't > save/restore umask and thus is subject to caller's umask. I agree, you are reading my thoughts. I think that unless there is another way how to preserve the correct contexts for ssh-copy-id this is the most appropriate solution. Created attachment 529059 [details]
Save, clear, and restore umask around file creation by libsemanage.
Or it should copy the permissions from the original file with chmod() call. Patch applied in libsemanage-2.0.45-1.1.el6 Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. http://rhn.redhat.com/errata/RHBA-2011-1770.html |