summaryrefslogtreecommitdiff
path: root/gtk/channel-usbredir.c
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2011-11-26 10:48:15 +0100
committerHans de Goede <hdegoede@redhat.com>2011-12-02 14:09:32 +0100
commit63c8526c699692b6fdca15db8209730fca7eb817 (patch)
treef055925bcfb96b1c1354e913faded9fd61402a59 /gtk/channel-usbredir.c
parente83f5a7c2c98aae96bee57bda9590e70dbbcb62e (diff)
channel-usbredir: Call the acl helper without first trying to open the device
Normally opening the USB device without first calling the helper will fail, except when the process using spice-gtk is running as root. So the current code which first tries to open the USB device before calling the helper is optimizing for an exception rather then for the default code path. More over it also causes libusb to print the following errors to stderr: libusb:error [op_open] libusb couldn't open USB device /dev/bus/usb/002/017: Permission denied. libusb:error [op_open] libusb requires write access to USB device nodes. So this patch changes things to first call the helper and only then try to open the device node. This patch also modifies the helper to not call policykit when called by a root process, since the set_facl which it will do, if policykit says it is ok, is a no-op for root anyways. Instead it directly returns a success status without doing anything when called by a root process. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'gtk/channel-usbredir.c')
-rw-r--r--gtk/channel-usbredir.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/gtk/channel-usbredir.c b/gtk/channel-usbredir.c
index 00647b6..fce4783 100644
--- a/gtk/channel-usbredir.c
+++ b/gtk/channel-usbredir.c
@@ -245,7 +245,6 @@ void spice_usbredir_channel_connect_async(SpiceUsbredirChannel *channel,
{
SpiceUsbredirChannelPrivate *priv = channel->priv;
GSimpleAsyncResult *result;
- GError *err = NULL;
g_return_if_fail(SPICE_IS_USBREDIR_CHANNEL(channel));
g_return_if_fail(context != NULL);
@@ -265,26 +264,27 @@ void spice_usbredir_channel_connect_async(SpiceUsbredirChannel *channel,
priv->context = g_object_ref(context);
priv->device = g_object_ref(device);
- if (!spice_usbredir_channel_open_device(channel, &err)) {
#if USE_POLKIT
- priv->result = result;
- priv->state = STATE_WAITING_FOR_ACL_HELPER;
- priv->acl_helper = spice_usb_acl_helper_new();
- g_object_set(spice_channel_get_session(SPICE_CHANNEL(channel)),
- "inhibit-keyboard-grab", TRUE, NULL);
- spice_usb_acl_helper_open_acl(priv->acl_helper,
- g_usb_device_get_bus(device),
- g_usb_device_get_address(device),
- cancellable,
- spice_usbredir_channel_open_acl_cb,
- channel);
- return;
+ priv->result = result;
+ priv->state = STATE_WAITING_FOR_ACL_HELPER;
+ priv->acl_helper = spice_usb_acl_helper_new();
+ g_object_set(spice_channel_get_session(SPICE_CHANNEL(channel)),
+ "inhibit-keyboard-grab", TRUE, NULL);
+ spice_usb_acl_helper_open_acl(priv->acl_helper,
+ g_usb_device_get_bus(device),
+ g_usb_device_get_address(device),
+ cancellable,
+ spice_usbredir_channel_open_acl_cb,
+ channel);
+ return;
#else
+ GError *err = NULL;
+ if (!spice_usbredir_channel_open_device(channel, &err)) {
g_simple_async_result_take_error(result, err);
g_clear_object(&priv->context);
g_clear_object(&priv->device);
-#endif
}
+#endif
done:
g_simple_async_result_complete_in_idle(result);