Antoni Segura Puimedon has uploaded a new change for review.

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. 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/908916
Signed-off-by: Antoni S. Puimedon <[email protected]>
---
M vdsm/network/configurators/ifcfg.py
1 file changed, 4 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/88/31388/1

diff --git a/vdsm/network/configurators/ifcfg.py 
b/vdsm/network/configurators/ifcfg.py
index 66aee20..0f83fca 100644
--- a/vdsm/network/configurators/ifcfg.py
+++ b/vdsm/network/configurators/ifcfg.py
@@ -533,7 +533,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/31388
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibca42d47d5a241f864fa5818996734cce9955fe6
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Antoni Segura Puimedon <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to