]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuDomainAttachDeviceMknodHelper: Fail on unsupported file type
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 15 Jun 2017 13:50:39 +0000 (15:50 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 11 Jul 2017 12:45:15 +0000 (14:45 +0200)
Currently, we silently assume that file we are creating in the
namespace is either a link or a device (character or block one).
This is not always the case. Therefore instead of doing something
wrong, claim about unsupported file type.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/qemu/qemu_domain.c

index 0b664bb531f67cff9d868041f5ea7385f0727c0b..b7a0b616d3035789a4d0df3aa7fce9aa80d984aa 100644 (file)
@@ -8531,6 +8531,7 @@ qemuDomainAttachDeviceMknodHelper(pid_t pid ATTRIBUTE_UNUSED,
     int ret = -1;
     bool delDevice = false;
     bool isLink = S_ISLNK(data->sb.st_mode);
+    bool isDev = S_ISCHR(data->sb.st_mode) || S_ISBLK(data->sb.st_mode);
 
     qemuSecurityPostFork(data->driver->securityManager);
 
@@ -8552,7 +8553,7 @@ qemuDomainAttachDeviceMknodHelper(pid_t pid ATTRIBUTE_UNUSED,
         } else {
             delDevice = true;
         }
-    } else {
+    } else if (isDev) {
         VIR_DEBUG("Creating dev %s (%d,%d)",
                   data->file, major(data->sb.st_rdev), minor(data->sb.st_rdev));
         if (mknod(data->file, data->sb.st_mode, data->sb.st_rdev) < 0) {
@@ -8569,6 +8570,11 @@ qemuDomainAttachDeviceMknodHelper(pid_t pid ATTRIBUTE_UNUSED,
         } else {
             delDevice = true;
         }
+    } else {
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
+                       _("unsupported device type %s 0%o"),
+                       data->file, data->sb.st_mode);
+        goto cleanup;
     }
 
     if (lchown(data->file, data->sb.st_uid, data->sb.st_gid) < 0) {