diff options
author | Zac Medico <zmedico@gentoo.org> | 2009-12-17 02:20:58 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2009-12-17 02:20:58 +0000 |
commit | 802efcc73d0636964a76ae70ea96f2aaf9e5b089 (patch) | |
tree | 7f624d08e48400255aa2a276dcb4647825f7c6bc | |
parent | 76a4c81848a5faebf4a6d611dec2f0610022d3e5 (diff) | |
download | portage-802efcc73d0636964a76ae70ea96f2aaf9e5b089.tar.gz portage-802efcc73d0636964a76ae70ea96f2aaf9e5b089.tar.bz2 portage-802efcc73d0636964a76ae70ea96f2aaf9e5b089.zip |
Bug #286497 - Make setexec() warn/nonfatal in permissive mode. Thanks to
Chris PeBenito <pebenito@gentoo.org> for this patch.
svn path=/main/trunk/; revision=15100
-rw-r--r-- | pym/portage/_selinux.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/pym/portage/_selinux.py b/pym/portage/_selinux.py index d013fa969..5367afc9c 100644 --- a/pym/portage/_selinux.py +++ b/pym/portage/_selinux.py @@ -8,8 +8,10 @@ import os import shutil from portage import _encodings +from portage import _unicode_decode from portage import _unicode_encode from portage.localization import _ +from portage.util import writemsg import selinux from selinux import is_selinux_enabled @@ -70,7 +72,14 @@ def settype(newtype): def setexec(ctx="\n"): ctx = _unicode_encode(ctx, encoding=_encodings['content'], errors='strict') if selinux.setexeccon(ctx) < 0: - raise OSError(_("setexec: Failed setting exec() context \"%s\".") % ctx) + ctx = _unicode_decode(ctx, encoding=_encodings['content'], + errors='replace') + if selinux.security_getenforce() == 1: + raise OSError(_("Failed setting exec() context \"%s\".") % ctx) + else: + writemsg("!!! " + \ + _("Failed setting exec() context \"%s\".") % ctx, \ + noiselevel=-1) def setfscreate(ctx="\n"): ctx = _unicode_encode(ctx, |