提交 5b04f42c 编写于 作者: L Laine Stump

ignore SELinuxSetFilecon error in SELinuxSetSecurityFileLabel if on nfs

If virDomainAttachDevice() was called with an image that was located
on a root-squashed NFS server, and in a directory that was unreadable
by root on the machine running libvirtd, the attach would fail due to
an attempt to change the selinux label of the image with EACCES (which
isn't covered as an ignore case in SELinuxSetFilecon())

NFS doesn't support SELinux labelling anyway, so we mimic the failure
handling of commit 93a18bba, which
just ignores the errors if the target is on an NFS filesystem (in
SELinuxSetSecurityAllLabel() only, though.)

This can be seen as a follow-on to commit
347d266c, which ignores file open
failures of files on NFS that occur directly in
virDomainDiskDefForeachPath() (also necessary), but does not ignore
failures in functions that are called from there (eg
SELinuxSetSecurityFileLabel()).
上级 a9261567
...@@ -453,20 +453,26 @@ SELinuxSetSecurityFileLabel(virDomainDiskDefPtr disk, ...@@ -453,20 +453,26 @@ SELinuxSetSecurityFileLabel(virDomainDiskDefPtr disk,
void *opaque) void *opaque)
{ {
const virSecurityLabelDefPtr secdef = opaque; const virSecurityLabelDefPtr secdef = opaque;
int ret;
if (depth == 0) { if (depth == 0) {
if (disk->shared) { if (disk->shared) {
return SELinuxSetFilecon(path, default_image_context); ret = SELinuxSetFilecon(path, default_image_context);
} else if (disk->readonly) { } else if (disk->readonly) {
return SELinuxSetFilecon(path, default_content_context); ret = SELinuxSetFilecon(path, default_content_context);
} else if (secdef->imagelabel) { } else if (secdef->imagelabel) {
return SELinuxSetFilecon(path, secdef->imagelabel); ret = SELinuxSetFilecon(path, secdef->imagelabel);
} else { } else {
return 0; ret = 0;
} }
} else { } else {
return SELinuxSetFilecon(path, default_content_context); ret = SELinuxSetFilecon(path, default_content_context);
} }
if (ret < 0 &&
virStorageFileIsSharedFSType(path,
VIR_STORAGE_FILE_SHFS_NFS) == 1)
ret = 0;
return ret;
} }
static int static int
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册