Change in vdsm[ovirt-3.5]: selinux.restorecon: encode filename to utf-8 string
danken at redhat.com
danken at redhat.com
Wed Aug 13 09:09:53 UTC 2014
Hello Antoni Segura Puimedon,
I'd like you to do a code review. Please visit
http://gerrit.ovirt.org/31438
to review the following change.
Change subject: selinux.restorecon: encode filename to utf-8 string
......................................................................
selinux.restorecon: encode filename to utf-8 string
selinux python bindings take only a char * as input, not a unicode
string (C.f. https://bugzilla.redhat.com/908916). For this reason, we
need to encode a potential unicode string into a utf-8 char string.
Change-Id: Ibca42d47d5a241f864fa5818996734cce9955fe6
Bug-Url: https://bugzilla.redhat.com/1128074
Signed-off-by: Antoni S. Puimedon <asegurap at redhat.com>
Reviewed-on: http://gerrit.ovirt.org/31388
Reviewed-by: Dan Kenigsberg <danken at redhat.com>
---
M vdsm/network/configurators/ifcfg.py
1 file changed, 4 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/38/31438/1
diff --git a/vdsm/network/configurators/ifcfg.py b/vdsm/network/configurators/ifcfg.py
index 315b1da..2b60253 100644
--- a/vdsm/network/configurators/ifcfg.py
+++ b/vdsm/network/configurators/ifcfg.py
@@ -543,7 +543,10 @@
confFile.write(configuration)
os.chmod(fileName, 0o664)
try:
- selinux.restorecon(fileName)
+ # filname can be of 'unicode' type. restorecon calls into a C API
+ # that needs a char *. Thus, it is necessary to encode unicode to
+ # a utf-8 string.
+ selinux.restorecon(fileName.encode('utf-8'))
except:
logging.debug('ignoring restorecon error in case '
'SElinux is disabled', exc_info=True)
--
To view, visit http://gerrit.ovirt.org/31438
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibca42d47d5a241f864fa5818996734cce9955fe6
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Antoni Segura Puimedon <asegurap at redhat.com>
More information about the vdsm-patches
mailing list