提交 777fc2e9 编写于 作者: D Darryl L. Pierce 提交者: Daniel Veillard

517157 fix selinux problem with images on NFS

* src/security_selinux.c: ignores EOPNOTSUPP when attempting to access an
  NFS share
上级 ce1783cc
...@@ -323,6 +323,8 @@ SELinuxSetFilecon(virConnectPtr conn, const char *path, char *tcon) ...@@ -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,14 +333,21 @@ SELinuxSetFilecon(virConnectPtr conn, const char *path, char *tcon) ...@@ -331,14 +333,21 @@ SELinuxSetFilecon(virConnectPtr conn, const char *path, char *tcon)
} }
freecon(econ); freecon(econ);
} }
virSecurityReportError(conn, VIR_ERR_ERROR,
_("%s: unable to set security context " /* if the error complaint is related to an image hosted on
"'\%s\' on %s: %s."), __func__, * an nfs mount, then ignore it.
tcon, * rhbz 517157
path, */
virStrerror(errno, ebuf, sizeof ebuf)); if (setfilecon_errno != EOPNOTSUPP) {
if (security_getenforce() == 1) virSecurityReportError(conn, VIR_ERR_ERROR,
return -1; _("%s: unable to set security context "
"'\%s\' on %s: %s."), __func__,
tcon,
path,
virStrerror(errno, ebuf, sizeof ebuf));
if (security_getenforce() == 1)
return -1;
}
} }
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册