diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index bd77a34ef90496a2617bba17e98fc34bc881211e..430c7c107fecb8be8153fd0cedddcaa35c1a7d02 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -689,6 +689,7 @@ virStorageFileFormatTypeToString; virStorageFileGetMetadata; virStorageFileGetMetadataFromFD; virStorageFileIsSharedFS; +virStorageFileIsSharedFSType; virStorageFileProbeFormat; virStorageFileProbeFormatFromFD; diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index a9dd836e6f27c060eb59ee298e8b740445421ded..0612ce375f644ba28b2660b31b5b814bf948a8f4 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1023,9 +1023,12 @@ SELinuxSetSecurityAllLabel(virSecurityDriverPtr drv, SELinuxSetFilecon(vm->def->os.initrd, default_content_context) < 0) return -1; - if (stdin_path && - SELinuxSetFilecon(stdin_path, default_content_context) < 0) - return -1; + if (stdin_path) { + if (SELinuxSetFilecon(stdin_path, default_content_context) < 0 && + virStorageFileIsSharedFSType(stdin_path, + VIR_STORAGE_FILE_SHFS_NFS) != 1) + return -1; + } return 0; } diff --git a/src/util/storage_file.c b/src/util/storage_file.c index 3cd5dbcf8de46673ae6b8b72da0d15f32d216809..e4f1eaa071de404e2f09e798163cca189c64c0d8 100644 --- a/src/util/storage_file.c +++ b/src/util/storage_file.c @@ -804,7 +804,8 @@ virStorageFileGetMetadata(const char *path, # endif -int virStorageFileIsSharedFS(const char *path) +int virStorageFileIsSharedFSType(const char *path, + int fstypes) { char *dirpath, *p; struct statfs sb; @@ -853,19 +854,36 @@ int virStorageFileIsSharedFS(const char *path) VIR_DEBUG("Check if path %s with FS magic %lld is shared", path, (long long int)sb.f_type); - if (sb.f_type == NFS_SUPER_MAGIC || - sb.f_type == GFS2_MAGIC || - sb.f_type == OCFS2_SUPER_MAGIC || - sb.f_type == AFS_FS_MAGIC) { + if ((fstypes & VIR_STORAGE_FILE_SHFS_NFS) && + (sb.f_type == NFS_SUPER_MAGIC)) + return 1; + + if ((fstypes & VIR_STORAGE_FILE_SHFS_GFS2) && + (sb.f_type == GFS2_MAGIC)) + return 1; + if ((fstypes & VIR_STORAGE_FILE_SHFS_OCFS) && + (sb.f_type == OCFS2_SUPER_MAGIC)) + return 1; + if ((fstypes & VIR_STORAGE_FILE_SHFS_AFS) && + (sb.f_type == AFS_FS_MAGIC)) return 1; - } return 0; } #else -int virStorageFileIsSharedFS(const char *path ATTRIBUTE_UNUSED) +int virStorageFileIsSharedFSType(const char *path ATTRIBUTE_UNUSED, + int fstypes ATTRIBUTE_UNUSED) { /* XXX implement me :-) */ return 0; } #endif + +int virStorageFileIsSharedFS(const char *path) +{ + return virStorageFileIsSharedFSType(path, + VIR_STORAGE_FILE_SHFS_NFS | + VIR_STORAGE_FILE_SHFS_GFS2 | + VIR_STORAGE_FILE_SHFS_OCFS | + VIR_STORAGE_FILE_SHFS_AFS); +} diff --git a/src/util/storage_file.h b/src/util/storage_file.h index 6853182f78b52b8f135bf4b92f7a5e05becbc8e2..ba44111d99264cf89c9ff8515874c049fdc9eeab 100644 --- a/src/util/storage_file.h +++ b/src/util/storage_file.h @@ -68,6 +68,15 @@ int virStorageFileGetMetadataFromFD(const char *path, int format, virStorageFileMetadata *meta); +enum { + VIR_STORAGE_FILE_SHFS_NFS = (1 << 0), + VIR_STORAGE_FILE_SHFS_GFS2 = (1 << 1), + VIR_STORAGE_FILE_SHFS_OCFS = (1 << 2), + VIR_STORAGE_FILE_SHFS_AFS = (1 << 3), +}; + int virStorageFileIsSharedFS(const char *path); +int virStorageFileIsSharedFSType(const char *path, + int fstypes); #endif /* __VIR_STORAGE_FILE_H__ */