After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 699359 - libproxy glibproxyresolver doesn't translate socks entry to three entries when calling g_libproxy_resolver_lookup_async
libproxy glibproxyresolver doesn't translate socks entry to three entries whe...
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: network
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2013-04-30 23:31 UTC by Joshua Lock
Modified: 2013-07-08 18:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to also perform translation on g_libproxy_resolver_lookup_async (1.91 KB, patch)
2013-04-30 23:32 UTC, Joshua Lock
needs-work Details | Review
libproxy: fix handling of SOCKS in async API, add tests (23.85 KB, patch)
2013-05-01 12:45 UTC, Dan Winship
committed Details | Review

Description Joshua Lock 2013-04-30 23:31:19 UTC
g_libproxy_resolver_lookup_async(), through _lookup_async(), doesn't  perform the same translation steps as g_libproxy_resolver_lookup() to convert a single socks entry into three version specific entries.
Comment 1 Joshua Lock 2013-04-30 23:32:19 UTC
Created attachment 242974 [details] [review]
Patch to also perform translation on g_libproxy_resolver_lookup_async
Comment 2 Alban Crequy 2013-05-01 09:31:34 UTC
I am not a maintainer but the patch looks good to me.
Comment 3 Simon McVittie 2013-05-01 11:41:42 UTC
Review of attachment 242974 [details] [review]:

I am not a maintainer either, but I think this needs a bit of adjustment:

::: proxy/libproxy/glibproxyresolver.c
@@ +156,2 @@
 static gchar **
+_fixup_proxies (gchar **proxies)

This is a sufficiently strange calling convention (consumes its argument) that it deserves a pseudo-doc-comment; you could also move the "We always copy" comment up here too, in fact.

Here's what I'd use:

/*
 * Convert the array of proxies into a GStrv, expanding any "socks" entries
 * into separate entries for "socks5", "socks4a", "socks4".
 *
 * The @proxies argument is consumed.
 *
 * @proxies: (array zero-terminated=1) (transfer full): proxies from
 *   libproxy, freed by this function using free_libproxy_proxies()
 * Returns: (array zero-terminated=1) (transfer full): new set of proxies,
 *   to be freed with g_strfreev()
 */

@@ +210,3 @@
+      if (proxies)
+        proxies = _fixup_proxies (proxies);
+      g_task_return_pointer (task, proxies, (GDestroyNotify)free_libproxy_proxies);

The result of _fixup_proxies() should be freed with g_strfreev(), not free_libproxy_proxies().

This does matter if the underlying allocator used by g_malloc()/g_free() is not the same as the one used by malloc()/free() (although it's usually the same). libproxy always uses malloc()/free() (I think?) whereas GLib can be configured to use an alternative.
Comment 4 Dan Winship 2013-05-01 12:45:48 UTC
Created attachment 242989 [details] [review]
libproxy: fix handling of SOCKS in async API, add tests

Fix the handling of SOCKS proxies with g_proxy_resolver_lookup_async()
and the libproxy resolver. (Also, make the sync proxy resolver
properly cancellable.)

Add some tests of the libproxy resolver, based on the existing gnome
proxy resolver tests. Unfortunately, libproxy doesn't implement ignore
hosts in exactly the same way GProxyResolverGnome does, so we need to
keep track of which URIs they give different results for...
Comment 5 Dan Winship 2013-05-01 12:46:03 UTC
can you try this patch instead?
Comment 6 Joshua Lock 2013-05-01 18:55:21 UTC
Thanks Dan, I can verify this patch works well for my use.
Comment 7 Dan Winship 2013-05-01 19:35:23 UTC
fixed in master. unfortunately it just missed 2.37.1

Attachment 242989 [details] pushed as 1b9f7e0 - libproxy: fix handling of SOCKS in async API, add tests
Comment 8 Jim Nelson 2013-07-05 21:21:49 UTC
As a follow-up, does this patch solve connecting through a SOCKS proxy that wants to use HTTP CONNECT?  A user is reporting an error when Geary attempts to make an IMAP connection with a SOCKS proxy: "Proxy protocol 'http' is not supported".  Geary uses async calls with GSocketClient.  I can't quite tell from this patch if it solves this problem.
Comment 9 Dan Winship 2013-07-06 14:33:46 UTC
(In reply to comment #8)
> A user is reporting an error when Geary attempts to
> make an IMAP connection with a SOCKS proxy: "Proxy protocol 'http' is not
> supported".

I think that error means that the user misconfigured their proxy settings, and claimed to have an http proxy, rather than a SOCKS proxy. (ie, in the control center, they filled in the "HTTP proxy" field rather than the "SOCKS proxy" field).
Comment 10 Jim Nelson 2013-07-08 18:40:33 UTC
The user sent us the contents of their /etc/environment file:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
http_proxy="http://10.0.0.1:80/"
https_proxy="https://10.0.0.1:80/"
ftp_proxy="ftp://10.0.0.1:80/"
socks_proxy="socks://10.0.0.1:80/"
no_proxy="127.0.0.1,localhost,*10.*"
HTTP_PROXY="http://10.0.0.1:80/"
HTTPS_PROXY="https://10.0.0.1:80/"
FTP_PROXY="ftp://10.0.0.1:80/"
SOCKS_PROXY="socks://10.0.0.1:80/"
NO_PROXY="127.0.0.1,localhost,*10.*"

Is it possible the problem is that they have both an HTTP and a SOCKS proxy?
Comment 11 Dan Winship 2013-07-08 18:53:03 UTC
oh. no, the problem is that "socks_proxy" is not a standard environment variable, and libproxy doesn't look at it. (But it returns $http_proxy as a fallback for any non-http, non-ftp request.) It looks like there is no way to get libproxy's environment-variable plugin to return a socks proxy.