usbfilter for USB Select dialog

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hello, everyone. 
I found if I disable some USB device use usb_filter, it’s just take effect for the auto_connect.
but when I open the USBSelectDialog, I can see the disabled device, and even I can checked it. 
So, I just modified a little code let the disabled device disappear in the USBSelectDialog. 

the code diff is:

diff --git a/spice-common b/spice-common
--- a/spice-common
+++ b/spice-common
@@ -1 +1 @@
-Subproject commit af682b1b06dea55007d9aa7c37cd443e4349e43f
+Subproject commit af682b1b06dea55007d9aa7c37cd443e4349e43f-dirty
diff --git a/src/usb-device-manager.c b/src/usb-device-manager.c
index bbe2391..1645497 100644
--- a/src/usb-device-manager.c
+++ b/src/usb-device-manager.c
@@ -966,6 +966,19 @@ static void spice_usb_device_manager_add_dev(SpiceUsbDeviceManager  *self,
                                    device, NULL,
                                    spice_usb_device_manager_auto_connect_cb,
                                    spice_usb_device_ref(device));
+    }else{
+        gboolean auto_ok;
+        auto_ok = usbredirhost_check_device_filter(
+                            priv->auto_conn_filter_rules,
+                            priv->auto_conn_filter_rules_count,
+                            libdev, 0) == 0;
+        if (!auto_ok){
+            SPICE_DEBUG("device denied %04x:%04x (%p)",
+                spice_usb_device_get_vid(device),
+                spice_usb_device_get_pid(device),
+                device);
+            return;
+        }
     }
 
     SPICE_DEBUG("device added %04x:%04x (%p)",
@@ -1348,7 +1361,11 @@ GPtrArray* spice_usb_device_manager_get_devices_with_filter(
  */
 GPtrArray* spice_usb_device_manager_get_devices(SpiceUsbDeviceManager *self)
 {
-    return spice_usb_device_manager_get_devices_with_filter(self, NULL);
+    SpiceUsbDeviceManager *udm = SPICE_USB_DEVICE_MANAGER(self);
+    SpiceUsbDeviceManagerPrivate *udm_priv;
+    udm_priv = udm->priv;
+
+    return spice_usb_device_manager_get_devices_with_filter(self, udm_priv->auto_connect_filter);
 }


_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]