[Spice-commits] 3 commits - gtk/channel-usbredir.c gtk/spice-client-glib-usb-acl-helper.c gtk/spicy.c gtk/usb-device-manager.c
Hans de Goede
jwrdegoede at kemper.freedesktop.org
Fri Dec 2 05:09:51 PST 2011
gtk/channel-usbredir.c | 30 +++++++++++++++---------------
gtk/spice-client-glib-usb-acl-helper.c | 25 +++++++++++++++++--------
gtk/spicy.c | 3 +++
gtk/usb-device-manager.c | 2 +-
4 files changed, 36 insertions(+), 24 deletions(-)
New commits:
commit dee8fe83a917412b2c641b5b13be0a0fa2c8d32a
Author: Hans de Goede <hdegoede at redhat.com>
Date: Sat Nov 19 16:26:50 2011 +0100
usb-device-manager: Don't g_warning on autoconnect failure
We already emit a signal for this, either the app using spice-client-glib
listens to this signals and does something with it, or it is not interested
in this happening, at which point logging a g_warning for it is not really
useful.
Signed-off-by: Hans de Goede <hdegoede at redhat.com>
diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c
index db16971..313b6ab 100644
--- a/gtk/usb-device-manager.c
+++ b/gtk/usb-device-manager.c
@@ -443,7 +443,7 @@ static void spice_usb_device_manager_auto_connect_cb(GObject *gobject,
g_prefix_error(&err, "Could not auto-redirect %s: ", desc);
g_free(desc);
- g_warning("%s", err->message);
+ SPICE_DEBUG("%s", err->message);
g_signal_emit(self, signals[AUTO_CONNECT_FAILED], 0, device, err);
g_error_free(err);
}
commit 72490b407c93898248fa1c56c9b30437f4dc3a62
Author: Hans de Goede <hdegoede at redhat.com>
Date: Tue Nov 29 23:11:15 2011 +0100
spicy: Don't show an error dialog on a cancelled device open
If for example the user plugs in a new device, then gets the policykit agent
authentication dialog and then unplugs the device, spice-gtk will cancel
the acl-helper request, which in turn will dismiss the policykit agent
authentication dialog. Which is all a nice and smooth user experience,
except that when this happens spicy throws a dialog with an error
that the open was cancelled. Since a cancel usually is done deliberately
(such as on the user unpluging the device) no error dialog should be thrown
for it.
Signed-off-by: Hans de Goede <hdegoede at redhat.com>
diff --git a/gtk/spicy.c b/gtk/spicy.c
index 427b8d1..c662983 100644
--- a/gtk/spicy.c
+++ b/gtk/spicy.c
@@ -1618,6 +1618,9 @@ static void auto_connect_failed(SpiceUsbDeviceManager *manager,
{
GtkWidget *dialog;
+ if (error->domain == G_IO_ERROR && error->code == G_IO_ERROR_CANCELLED)
+ return;
+
dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
"USB redirection error");
commit 63c8526c699692b6fdca15db8209730fca7eb817
Author: Hans de Goede <hdegoede at redhat.com>
Date: Sat Nov 26 10:48:15 2011 +0100
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 at redhat.com>
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);
diff --git a/gtk/spice-client-glib-usb-acl-helper.c b/gtk/spice-client-glib-usb-acl-helper.c
index 2e31bd3..698820b 100644
--- a/gtk/spice-client-glib-usb-acl-helper.c
+++ b/gtk/spice-client-glib-usb-acl-helper.c
@@ -229,14 +229,23 @@ static void stdin_read_complete(GObject *src, GAsyncResult *res, gpointer data)
break;
}
- state = STATE_WAITING_FOR_POL_KIT;
-
- polkit_cancellable = g_cancellable_new();
- polkit_authority_check_authorization(
- authority, subject, "org.spice-space.lowlevelusbaccess", NULL,
- POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,
- polkit_cancellable, (GAsyncReadyCallback)check_authorization_cb,
- loop);
+ /*
+ * The set_facl() call is a no-op for root, so no need to ask PolKit
+ * and then if ok call set_facl(), when called by a root process.
+ */
+ if (getuid() != 0) {
+ polkit_cancellable = g_cancellable_new();
+ polkit_authority_check_authorization(
+ authority, subject, "org.spice-space.lowlevelusbaccess", NULL,
+ POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,
+ polkit_cancellable,
+ (GAsyncReadyCallback)check_authorization_cb, NULL);
+ state = STATE_WAITING_FOR_POL_KIT;
+ } else {
+ fprintf(stdout, "SUCCESS\n");
+ fflush(stdout);
+ state = STATE_WAITING_FOR_STDIN_EOF;
+ }
g_data_input_stream_read_line_async(stdin_stream, G_PRIORITY_DEFAULT,
NULL, stdin_read_complete, NULL);
More information about the Spice-commits
mailing list