[PATCH] Improve WPAD proxy handling

2013-06-12 Thread David Woodhouse
We already request WPAD information from the DHCP server (bug 368423)
but we don't do anything useful with it at all.

The same information can also come from a VPN server, but we don't even
*collect* that.

This patch fixes the latter, and exposes the information in a coherent
fashion. There's no need at this point to overcomplicate matters by
pretending to support complicated manual proxy setups (as discussed in
TODO); this is just for what we can glean automatically, which is *only*
PAC files.

Tested with a local DHCP server that tells me where the proxy is, and
with a slightly modified nm-openconnect-service-openconnect-helper[sic].

This is based largely on the existing handling of NIS domainname.

I see that it's considered acceptable to (ab)use nm-dns-manager to
configure the NIS domain. I'll look at making it prod the PacRunner
dæmon with proxy information too, but this part stands alone.

diff --git a/include/NetworkManagerVPN.h b/include/NetworkManagerVPN.h
index 6e654b3..9b6e5f7 100644
--- a/include/NetworkManagerVPN.h
+++ b/include/NetworkManagerVPN.h
@@ -176,6 +176,9 @@ typedef enum {
 /* boolean: prevent this VPN connection from ever getting the default route */
 #define NM_VPN_PLUGIN_IP4_CONFIG_NEVER_DEFAULT never-default
 
+/* string: Location of PAC file for HTTP proxy */
+#define NM_VPN_PLUGIN_IP4_CONFIG_PROXY_PAC   proxy-pac
+
 /* Deprecated */
 #define NM_VPN_PLUGIN_IP4_CONFIG_GATEWAY   NM_VPN_PLUGIN_IP4_CONFIG_EXT_GATEWAY
 
diff --git a/src/dhcp-manager/nm-dhcp-client.c 
b/src/dhcp-manager/nm-dhcp-client.c
index f4e94a6..ebe9a69 100644
--- a/src/dhcp-manager/nm-dhcp-client.c
+++ b/src/dhcp-manager/nm-dhcp-client.c
@@ -1292,6 +1292,12 @@ ip4_options_to_config (NMDHCPClient *self)
nm_ip4_config_set_nis_domain (ip4_config, str);
}
 
+   str = g_hash_table_lookup (priv-options, new_wpad);
+   if (str) {
+   nm_log_info (LOGD_DHCP4,   Proxy PAC '%s', str);
+   nm_ip4_config_set_proxy_pac (ip4_config, str);
+   }
+
str = g_hash_table_lookup (priv-options, new_nis_servers);
if (str) {
char **searches = g_strsplit (str,  , 0);
diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c
index 0722981..8f86996 100644
--- a/src/nm-ip4-config.c
+++ b/src/nm-ip4-config.c
@@ -59,6 +59,8 @@ typedef struct {
GArray *nis;
char * nis_domain;
 
+   char * proxy_pac;
+
GSList *routes;
 
gboolean never_default;
@@ -569,6 +571,26 @@ nm_ip4_config_get_nis_domain (NMIP4Config *config)
return NM_IP4_CONFIG_GET_PRIVATE (config)-nis_domain;
 }
 
+void
+nm_ip4_config_set_proxy_pac (NMIP4Config *config, const char *uri)
+{
+   NMIP4ConfigPrivate *priv;
+
+   g_return_if_fail (NM_IS_IP4_CONFIG (config));
+
+   priv = NM_IP4_CONFIG_GET_PRIVATE (config);
+   g_free (priv-proxy_pac);
+   priv-proxy_pac = g_strdup (uri);
+}
+
+const char *
+nm_ip4_config_get_proxy_pac (NMIP4Config *config)
+{
+   g_return_val_if_fail (NM_IS_IP4_CONFIG (config), 0);
+
+   return NM_IP4_CONFIG_GET_PRIVATE (config)-proxy_pac;
+}
+
 /* libnl convenience/conversion functions */
 
 static int ip4_addr_to_rtnl_local (guint32 ip4_address, struct rtnl_addr *addr)
@@ -790,6 +812,10 @@ nm_ip4_config_diff (NMIP4Config *a, NMIP4Config *b)
 (g_strcmp0 (a_priv-nis_domain, b_priv-nis_domain) != 0))
flags |= NM_IP4_COMPARE_FLAG_NIS_DOMAIN;
 
+   if (   (a_priv-proxy_pac || b_priv-proxy_pac)
+(g_strcmp0 (a_priv-proxy_pac, b_priv-proxy_pac) != 0))
+   flags |= NM_IP4_COMPARE_FLAG_PROXY_PAC;
+
if (   !route_slist_compare (a_priv-routes, b_priv-routes)
|| !route_slist_compare (b_priv-routes, a_priv-routes))
flags |= NM_IP4_COMPARE_FLAG_ROUTES;
@@ -856,6 +882,10 @@ nm_ip4_config_hash (NMIP4Config *config, GChecksum *sum, 
gboolean dns_only)
s = nm_ip4_config_get_nis_domain (config);
if (s)
g_checksum_update (sum, (const guint8 *) s, strlen (s));
+
+   s = nm_ip4_config_get_proxy_pac (config);
+   if (s)
+   g_checksum_update (sum, (const guint8 *) s, strlen (s));
}
 
for (i = 0; i  nm_ip4_config_get_num_nameservers (config); i++)
@@ -900,6 +930,7 @@ finalize (GObject *object)
g_ptr_array_free (priv-searches, TRUE);
g_array_free (priv-nis, TRUE);
g_free (priv-nis_domain);
+   g_free (priv-proxy_pac);
 
G_OBJECT_CLASS (nm_ip4_config_parent_class)-finalize (object);
 }
diff --git a/src/nm-ip4-config.h b/src/nm-ip4-config.h
index 5433768..c66aece 100644
--- a/src/nm-ip4-config.h
+++ b/src/nm-ip4-config.h
@@ -107,6 +107,9 @@ void  nm_ip4_config_reset_nis_servers   
(NMIP4Config *config);
 void  nm_ip4_config_set_nis_domain  (NMIP4Config *config, const 
char *domain);
 const char *  nm_ip4_config_get_nis_domain  (NMIP4Config *config);

[PATCH] build: Remove libndp for now

2013-06-12 Thread Colin Walters
It's installing itself into $(prefix), whereas we need a private
library in $(pkglibdir).

I think libgsystem is a pretty good example of a useful git submodule;
it's designed for nonrecursive automake; it provides a
Makefile-libgsystem.am that one can include, but doesn't force the use
of SUBDIRS and particularly that the *containing* module does e.g.

include libgsystem/Makefile-libgsystem.am
pkglibdir_LTLIBRARIES += libgsystem.la

So the containing module is choosing where to install.
---
 .gitmodules  |3 ---
 Makefile.am  |1 -
 configure.ac |1 -
 libndp   |1 -
 4 files changed, 0 insertions(+), 6 deletions(-)
 delete mode 16 libndp


From 36d83e054b8bf90dc8b0e820617e3ff17f134ba7 Mon Sep 17 00:00:00 2001
From: Colin Walters walt...@verbum.org
Date: Wed, 12 Jun 2013 08:36:29 -0400
Subject: [PATCH] build: Remove libndp for now

It's installing itself into $(prefix), whereas we need a private
library in $(pkglibdir).

I think libgsystem is a pretty good example of a useful git submodule;
it's designed for nonrecursive automake; it provides a
Makefile-libgsystem.am that one can include, but doesn't force the use
of SUBDIRS and particularly that the *containing* module does e.g.

include libgsystem/Makefile-libgsystem.am
pkglibdir_LTLIBRARIES += libgsystem.la

So the containing module is choosing where to install.
---
 .gitmodules  |3 ---
 Makefile.am  |1 -
 configure.ac |1 -
 libndp   |1 -
 4 files changed, 0 insertions(+), 6 deletions(-)
 delete mode 16 libndp

diff --git a/.gitmodules b/.gitmodules
index c31ff2a..e93bbea 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,6 +1,3 @@
 [submodule libgsystem]
 	path = libgsystem
 	url = git://git.gnome.org/libgsystem
-[submodule libndp]
-	path = libndp
-	url = git://github.com/jpirko/libndp.git
diff --git a/Makefile.am b/Makefile.am
index 3fcc135..9976a2a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -6,7 +6,6 @@ SUBDIRS = \
 	libnm-util \
 	libnm-glib \
 	introspection \
-	libndp \
 	src \
 	callouts \
 	cli \
diff --git a/configure.ac b/configure.ac
index 51f4aec..4f1649f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -715,7 +715,6 @@ examples/C/qt/Makefile
 examples/dispatcher/Makefile
 vapi/Makefile
 ])
-AC_CONFIG_SUBDIRS([libndp])
 AC_OUTPUT
 
 # Print build configuration
diff --git a/libndp b/libndp
deleted file mode 16
index 39e1f53..000
--- a/libndp
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 39e1f53dd4efc00b84ff097b15558747c92593f2
-- 
1.7.1

___
networkmanager-list mailing list
networkmanager-list@gnome.org
https://mail.gnome.org/mailman/listinfo/networkmanager-list


Does Network Manager use wpa_supplicant for wired connections?

2013-06-12 Thread Pengcheng Chen
Hi all,

Does Network Manager use wpa_supplicant, or X Supplicant? or does it
implement 802.1x Supplicant in itself?

Thanks,
Pengcheng
___
networkmanager-list mailing list
networkmanager-list@gnome.org
https://mail.gnome.org/mailman/listinfo/networkmanager-list