summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-01-17 14:27:42 +0100
committerThomas Haller <thaller@redhat.com>2017-01-17 14:27:42 +0100
commit4100fc1d4d79dc1a6800ee31021f28cf6d20050b (patch)
tree7af38332e0e8101083a4fee2e547284d56b5dcb2
parentdaf935fb1baa946c18aa6f5bee23c4a3b61e66cd (diff)
parent49e1fefc35f588ede4e21ee095734803225c0564 (diff)
downloadNetworkManager-4100fc1d4d79dc1a6800ee31021f28cf6d20050b.tar.gz
proxy: merge branch 'jk/proxy-fixes'
https://bugzilla.gnome.org/show_bug.cgi?id=777385
-rw-r--r--Makefile.am1
-rw-r--r--clients/cli/connections.c2
-rw-r--r--clients/cli/settings.c14
-rw-r--r--libnm-core/nm-setting-proxy.c66
-rw-r--r--src/nm-pacrunner-manager.c32
-rw-r--r--src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-read-proxy-basic15
-rw-r--r--src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c78
7 files changed, 173 insertions, 35 deletions
diff --git a/Makefile.am b/Makefile.am
index 609e4be225..2116486485 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2033,6 +2033,7 @@ EXTRA_DIST += \
src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-team-port-1 \
src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-team-port-2 \
src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-team-port-empty-config \
+ src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-read-proxy-basic \
src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-vlan-trailing-spaces \
src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-dns-options \
src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-wired-wake-on-lan \
diff --git a/clients/cli/connections.c b/clients/cli/connections.c
index 02f5ed9e4e..09adf0e812 100644
--- a/clients/cli/connections.c
+++ b/clients/cli/connections.c
@@ -5657,6 +5657,8 @@ should_complete_files (const char *prompt, const char *line)
"phase2-private-key",
/* 'team' and 'team-port' properties */
"config",
+ /* 'proxy' properties */
+ "pac-script",
NULL
};
return _get_and_check_property (prompt, line, file_properties, NULL, NULL);
diff --git a/clients/cli/settings.c b/clients/cli/settings.c
index 5b5822610b..40cf9754ad 100644
--- a/clients/cli/settings.c
+++ b/clients/cli/settings.c
@@ -2354,6 +2354,18 @@ nmc_property_proxy_set_method (NMSetting *setting, const char *prop,
return TRUE;
}
+static const char **
+nmc_property_proxy_allowed_method (NMSetting *setting, const char *prop)
+{
+ static const char **words = NULL;
+
+ if (!words)
+ words = nm_utils_enum_get_values (nm_setting_proxy_method_get_type(),
+ NM_SETTING_PROXY_METHOD_NONE,
+ G_MAXINT);
+ return words;
+}
+
static gboolean
nmc_property_proxy_set_pac_script (NMSetting *setting, const char *prop,
const char *val, GError **error)
@@ -8155,7 +8167,7 @@ nmc_properties_init (void)
nmc_property_proxy_set_method,
NULL,
NULL,
- NULL,
+ nmc_property_proxy_allowed_method,
NULL);
nmc_add_prop_funcs (GLUE (PROXY, BROWSER_ONLY),
nmc_property_proxy_get_browser_only,
diff --git a/libnm-core/nm-setting-proxy.c b/libnm-core/nm-setting-proxy.c
index 907edb8f42..1492892cc4 100644
--- a/libnm-core/nm-setting-proxy.c
+++ b/libnm-core/nm-setting-proxy.c
@@ -27,15 +27,15 @@
/**
* SECTION:nm-setting-proxy
- * @short_description: Describes Proxy Url, Script and other related properties
+ * @short_description: Describes proxy URL, script and other related properties
*
* The #NMSettingProxy object is a #NMSetting subclass that describes properties
- * related to Proxy settings like Pac Url, Pac Script etc.
+ * related to Proxy settings like PAC URL, PAC script etc.
*
* NetworkManager support 2 values for the #NMSettingProxy:method property for
- * proxy. If "auto" is specified then WPAD takes places and the appropriate details
- * are pushed into PacRunner or user can override this URL with a new PAC url or a
- * PAC Script. If "none" is selected then no proxy configuration is given to PacRunner
+ * proxy. If "auto" is specified then WPAD takes place and the appropriate details
+ * are pushed into PacRunner or user can override this URL with a new PAC URL or a
+ * PAC script. If "none" is selected then no proxy configuration is given to PacRunner
* to fulfill client queries.
**/
@@ -81,8 +81,8 @@ nm_setting_proxy_new (void)
* nm_setting_proxy_get_method:
* @setting: the #NMSettingProxy
*
- * Returns the proxy configuration method. By default the value is "NONE".
- * "NONE" should be selected for a connection intended for direct network
+ * Returns the proxy configuration method. By default the value is %NM_SETTING_PROXY_METHOD_NONE.
+ * %NM_SETTING_PROXY_METHOD_NONE should be selected for a connection intended for direct network
* access.
*
* Returns: the proxy configuration method
@@ -101,8 +101,8 @@ nm_setting_proxy_get_method (NMSettingProxy *setting)
* nm_setting_proxy_get_browser_only:
* @setting: the #NMSettingProxy
*
- * Returns: TRUE if this proxy configuration is only for Browser
- * clients/schemes otherwise FALSE.
+ * Returns: %TRUE if this proxy configuration is only for browser
+ * clients/schemes, %FALSE otherwise.
*
* Since: 1.6
**/
@@ -118,7 +118,7 @@ nm_setting_proxy_get_browser_only (NMSettingProxy *setting)
* nm_setting_proxy_get_pac_url:
* @setting: the #NMSettingProxy
*
- * Returns: the PAC url for obtaining PAC file
+ * Returns: the PAC URL for obtaining PAC file
*
* Since: 1.6
**/
@@ -134,7 +134,7 @@ nm_setting_proxy_get_pac_url (NMSettingProxy *setting)
* nm_setting_proxy_get_pac_script:
* @setting: the #NMSettingProxy
*
- * Returns: the PAC Script
+ * Returns: the PAC script
*
* Since: 1.6
**/
@@ -301,10 +301,19 @@ nm_setting_proxy_class_init (NMSettingProxyClass *setting_class)
/**
* NMSettingProxy:method:
*
- * Method for proxy configuration, Default is "NONE"
+ * Method for proxy configuration, Default is %NM_SETTING_PROXY_METHOD_NONE
*
* Since: 1.6
**/
+ /* ---ifcfg-rh---
+ * property: method
+ * variable: PROXY_METHOD(+)
+ * default: none
+ * description: Method for proxy configuration. For "auto", WPAD is used for
+ * proxy configuration, or set the PAC file via PAC_URL or PAC_SCRIPT.
+ * values: none, auto
+ * ---end---
+ */
g_object_class_install_property
(object_class, PROP_METHOD,
g_param_spec_int (NM_SETTING_PROXY_METHOD, "", "",
@@ -316,24 +325,38 @@ nm_setting_proxy_class_init (NMSettingProxyClass *setting_class)
/**
* NMSettingProxy:browser-only:
*
- * TRUE if Proxy is for Browser Stuff.
+ * Whether the proxy configuration is for browser only.
*
* Since: 1.6
**/
+ /* ---ifcfg-rh---
+ * property: browser-only
+ * variable: BROWSER_ONLY(+)
+ * default: no
+ * description: Whether the proxy configuration is for browser only.
+ * ---end---
+ */
g_object_class_install_property
(object_class, PROP_BROWSER_ONLY,
g_param_spec_boolean (NM_SETTING_PROXY_BROWSER_ONLY, "", "",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
/**
* NMSettingProxy:pac-url:
*
- * PAC Url for obtaining PAC File.
+ * PAC URL for obtaining PAC file.
*
* Since: 1.6
**/
+ /* ---ifcfg-rh---
+ * property: pac-url
+ * variable: PAC_URL(+)
+ * description: URL for PAC file.
+ * example: PAC_URL=http://wpad.mycompany.com/wpad.dat
+ * ---end---
+ */
g_object_class_install_property
(object_class, PROP_PAC_URL,
g_param_spec_string (NM_SETTING_PROXY_PAC_URL, "", "",
@@ -344,10 +367,17 @@ nm_setting_proxy_class_init (NMSettingProxyClass *setting_class)
/**
* NMSettingProxy:pac-script:
*
- * PAC Script For the connection.
+ * PAC script for the connection.
*
* Since: 1.6
**/
+ /* ---ifcfg-rh---
+ * property: pac-script
+ * variable: PAC_SCRIPT(+)
+ * description: Path of the PAC script.
+ * example: PAC_SCRIPT=/home/joe/proxy.pac
+ * ---end---
+ */
g_object_class_install_property
(object_class, PROP_PAC_SCRIPT,
g_param_spec_string (NM_SETTING_PROXY_PAC_SCRIPT, "", "",
diff --git a/src/nm-pacrunner-manager.c b/src/nm-pacrunner-manager.c
index 2d1f7deebe..450cf0e3ee 100644
--- a/src/nm-pacrunner-manager.c
+++ b/src/nm-pacrunner-manager.c
@@ -119,7 +119,7 @@ add_ip4_config (NMPacrunnerManager *self, GVariantBuilder *proxy_data, NMIP4Conf
int i;
char *cidr = NULL;
- /* Extract Searches */
+ /* Extract searches */
for (i = 0; i < nm_ip4_config_get_num_searches (ip4); i++)
g_ptr_array_add (priv->domains, g_strdup (nm_ip4_config_get_search (ip4, i)));
@@ -127,7 +127,7 @@ add_ip4_config (NMPacrunnerManager *self, GVariantBuilder *proxy_data, NMIP4Conf
for (i = 0; i < nm_ip4_config_get_num_domains (ip4); i++)
g_ptr_array_add (priv->domains, g_strdup (nm_ip4_config_get_domain (ip4, i)));
- /* Add Addresses and routes in CIDR form */
+ /* Add addresses and routes in CIDR form */
for (i = 0; i < nm_ip4_config_get_num_addresses (ip4); i++) {
const NMPlatformIP4Address *address = nm_ip4_config_get_address (ip4, i);
@@ -164,7 +164,7 @@ add_ip6_config (NMPacrunnerManager *self, GVariantBuilder *proxy_data, NMIP6Conf
for (i = 0; i < nm_ip6_config_get_num_domains (ip6); i++)
g_ptr_array_add (priv->domains, g_strdup (nm_ip6_config_get_domain (ip6, i)));
- /* Add Addresses and routes in CIDR form */
+ /* Add addresses and routes in CIDR form */
for (i = 0; i < nm_ip6_config_get_num_addresses (ip6); i++) {
const NMPlatformIP6Address *address = nm_ip6_config_get_address (ip6, i);
@@ -205,7 +205,7 @@ pacrunner_send_done (GObject *source, GAsyncResult *res, gpointer user_data)
g_variant_get (variant, "(&o)", &path);
/* Replace the old path (if any) of proxy config with the new one returned
- * from CreateProxyConfiguration() DBus method on PacRunner.
+ * from CreateProxyConfiguration() DBus method on pacrunner.
*/
for (iter = g_list_first (priv->remove); iter; iter = g_list_next (iter)) {
struct remove_data *r = iter->data;
@@ -258,12 +258,12 @@ name_owner_changed (GObject *object,
owner = g_dbus_proxy_get_name_owner (G_DBUS_PROXY (object));
if (owner) {
- _LOGD ("PacRunner appeared as %s", owner);
+ _LOGD ("pacrunner appeared as %s", owner);
for (iter = g_list_first(priv->args); iter; iter = g_list_next(iter)) {
send_pacrunner_proxy_data (self, iter->data);
}
} else {
- _LOGD ("PacRunner disappeared");
+ _LOGD ("pacrunner disappeared");
}
}
@@ -293,12 +293,12 @@ pacrunner_proxy_cb (GObject *source, GAsyncResult *res, gpointer user_data)
}
/**
- * nm_pacrunner_manager_send():
+ * nm_pacrunner_manager_send:
* @self: the #NMPacrunnerManager
* @iface: the iface for the connection or %NULL
- * @proxy_config: Proxy config of the connection
- * @ip4_conifg: IP4 Cofig of the connection
- * @ip6_config: IP6 Config of the connection
+ * @proxy_config: proxy config of the connection
+ * @ip4_config: IP4 config of the connection
+ * @ip6_config: IP6 config of the connection
*/
void
nm_pacrunner_manager_send (NMPacrunnerManager *self,
@@ -345,7 +345,7 @@ nm_pacrunner_manager_send (NMPacrunnerManager *self,
priv->domains = g_ptr_array_new_with_free_func (g_free);
- /* Extract stuff from Configs */
+ /* Extract stuff from configs */
add_proxy_config (self, &proxy_data, proxy_config);
if (ip4_config)
@@ -366,9 +366,9 @@ nm_pacrunner_manager_send (NMPacrunnerManager *self,
pacrunner_manager_args = g_variant_ref_sink (g_variant_new ("(a{sv})", &proxy_data));
priv->args = g_list_append (priv->args, pacrunner_manager_args);
- /* Send if PacRunner is available on Bus, otherwise
+ /* Send if pacrunner is available on Bus, otherwise
* argument has already been appended above to be
- * sent when PacRunner appears.
+ * sent when pacrunner appears.
*/
send_pacrunner_proxy_data (self, pacrunner_manager_args);
}
@@ -387,14 +387,14 @@ pacrunner_remove_done (GObject *source, GAsyncResult *res, gpointer user_data)
if (!ret)
_LOGD ("Couldn't remove proxy config from pacrunner: %s", error->message);
else
- _LOGD ("Sucessfully removed proxy config from pacrunner");
+ _LOGD ("Successfully removed proxy config from pacrunner");
}
/**
- * nm_pacrunner_manager_remove():
+ * nm_pacrunner_manager_remove:
* @self: the #NMPacrunnerManager
* @iface: the iface for the connection to be removed
- * from PacRunner
+ * from pacrunner
*/
void
nm_pacrunner_manager_remove (NMPacrunnerManager *self, const char *iface)
diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-read-proxy-basic b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-read-proxy-basic
new file mode 100644
index 0000000000..e2cf6c212c
--- /dev/null
+++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test-read-proxy-basic
@@ -0,0 +1,15 @@
+# Intel Corporation 82540EP Gigabit Ethernet Controller (Mobile)
+TYPE=Ethernet
+DEVICE=eth0
+HWADDR=00:11:22:33:44:ee
+BOOTPROTO=dhcp
+ONBOOT=yes
+USERCTL=yes
+IPV6INIT=no
+NM_CONTROLLED=yes
+PEERDNS=no
+
+# proxy configuration
+PROXY_METHOD=auto
+PAC_URL=http://wpad.mycompany.com/wpad.dat
+BROWSER_ONLY=yes
diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
index c1dab54a4a..1a8439f6ce 100644
--- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
+++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
@@ -8268,6 +8268,81 @@ test_read_team_port_empty_config (void)
g_object_unref (connection);
}
+static void
+test_read_proxy_basic (void)
+{
+ NMConnection *connection;
+ NMSettingProxy *s_proxy;
+
+ /* Test basic proxy configuration */
+
+ connection = _connection_from_file (TEST_IFCFG_DIR"/network-scripts/ifcfg-test-read-proxy-basic",
+ NULL, TYPE_ETHERNET, NULL);
+
+ /* ===== Proxy setting ===== */
+ s_proxy = nm_connection_get_setting_proxy (connection);
+ g_assert (s_proxy);
+
+ /* Proxy method */
+ g_assert_cmpint (nm_setting_proxy_get_method (s_proxy), ==, NM_SETTING_PROXY_METHOD_AUTO);
+ g_assert (nm_setting_proxy_get_browser_only (s_proxy));
+ g_assert_cmpstr (nm_setting_proxy_get_pac_url (s_proxy), ==, "http://wpad.mycompany.com/wpad.dat");
+
+ g_object_unref (connection);
+}
+
+static void
+test_write_proxy_basic (void)
+{
+ nmtst_auto_unlinkfile char *testfile = NULL;
+ gs_unref_object NMConnection *connection = NULL;
+ gs_unref_object NMConnection *reread = NULL;
+ NMSettingConnection *s_con;
+ NMSettingWired *s_wired;
+ NMSettingProxy *s_proxy;
+ const char *expected_url = "https://wpad.neverland.org/wpad.dat";
+ shvarFile *f;
+
+ connection = nm_simple_connection_new ();
+
+ /* Connection setting */
+ s_con = (NMSettingConnection *) nm_setting_connection_new ();
+ nm_connection_add_setting (connection, NM_SETTING (s_con));
+
+ g_object_set (s_con,
+ NM_SETTING_CONNECTION_ID, "Test Write Proxy Basic",
+ NM_SETTING_CONNECTION_UUID, nm_utils_uuid_generate_a (),
+ NM_SETTING_CONNECTION_TYPE, NM_SETTING_WIRED_SETTING_NAME,
+ NULL);
+
+ /* Proxy setting */
+ s_proxy = (NMSettingProxy *) nm_setting_proxy_new ();
+ nm_connection_add_setting (connection, NM_SETTING (s_proxy));
+ g_object_set (s_proxy, NM_SETTING_PROXY_METHOD, NM_SETTING_PROXY_METHOD_AUTO, NULL);
+ g_object_set (s_proxy, NM_SETTING_PROXY_PAC_URL, expected_url, NULL);
+
+ /* Wired setting */
+ s_wired = (NMSettingWired *) nm_setting_wired_new ();
+ nm_connection_add_setting (connection, NM_SETTING (s_wired));
+
+ nmtst_assert_connection_verifies (connection);
+
+ _writer_new_connection (connection,
+ TEST_SCRATCH_DIR "/network-scripts/",
+ &testfile);
+
+ f = _svOpenFile (testfile);
+ _svGetValue_check (f, "TYPE", "Ethernet");
+ _svGetValue_check (f, "PROXY_METHOD", "auto");
+ _svGetValue_check (f, "PAC_URL", expected_url);
+ svCloseFile (f);
+
+ reread = _connection_from_file (testfile, NULL, TYPE_ETHERNET,
+ NULL);
+
+ nmtst_assert_connection_equals (connection, TRUE, reread, FALSE);
+}
+
/*****************************************************************************/
static const char *
@@ -9059,6 +9134,9 @@ int main (int argc, char **argv)
g_test_add_func (TPATH "team/write-port", test_write_team_port);
g_test_add_func (TPATH "team/read-port-empty-config", test_read_team_port_empty_config);
+ g_test_add_func (TPATH "proxy/read-proxy-basic", test_read_proxy_basic);
+ g_test_add_func (TPATH "proxy/write-proxy-basic", test_write_proxy_basic);
+
g_test_add_func (TPATH "sit/read/ignore", test_sit_read_ignore);
/* Stuff we expect to fail for now */