517157 fix selinux problem with images on NFS

* src/security_selinux.c: ignores EOPNOTSUPP when attempting to access an
  NFS share
This commit is contained in:
Darryl L. Pierce 2009-08-21 16:57:29 +02:00 committed by Daniel Veillard
parent ce1783ccc1
commit 777fc2e9d6
1 changed files with 17 additions and 8 deletions

View File

@ -323,6 +323,8 @@ SELinuxSetFilecon(virConnectPtr conn, const char *path, char *tcon)
VIR_INFO("Setting SELinux context on '%s' to '%s'", path, tcon); VIR_INFO("Setting SELinux context on '%s' to '%s'", path, tcon);
if (setfilecon(path, tcon) < 0) { if (setfilecon(path, tcon) < 0) {
int setfilecon_errno = errno;
if (getfilecon(path, &econ) >= 0) { if (getfilecon(path, &econ) >= 0) {
if (STREQ(tcon, econ)) { if (STREQ(tcon, econ)) {
freecon(econ); freecon(econ);
@ -331,6 +333,12 @@ SELinuxSetFilecon(virConnectPtr conn, const char *path, char *tcon)
} }
freecon(econ); freecon(econ);
} }
/* if the error complaint is related to an image hosted on
* an nfs mount, then ignore it.
* rhbz 517157
*/
if (setfilecon_errno != EOPNOTSUPP) {
virSecurityReportError(conn, VIR_ERR_ERROR, virSecurityReportError(conn, VIR_ERR_ERROR,
_("%s: unable to set security context " _("%s: unable to set security context "
"'\%s\' on %s: %s."), __func__, "'\%s\' on %s: %s."), __func__,
@ -340,6 +348,7 @@ SELinuxSetFilecon(virConnectPtr conn, const char *path, char *tcon)
if (security_getenforce() == 1) if (security_getenforce() == 1)
return -1; return -1;
} }
}
return 0; return 0;
} }