[network-manager-applet] gconf: don't save gateway if it's not given
- From: Dan Williams <dcbw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet] gconf: don't save gateway if it's not given
- Date: Sun, 2 May 2010 20:41:07 +0000 (UTC)
commit 6d8cf8f00052c8aa8f7ff58cb3c351cd602a36bf
Author: Dan Williams <dcbw redhat com>
Date: Sun May 2 13:39:04 2010 -0700
gconf: don't save gateway if it's not given
src/gconf-helpers/gconf-helpers.c | 23 ++++++++++++++++-------
1 files changed, 16 insertions(+), 7 deletions(-)
---
diff --git a/src/gconf-helpers/gconf-helpers.c b/src/gconf-helpers/gconf-helpers.c
index f1c549c..309be67 100644
--- a/src/gconf-helpers/gconf-helpers.c
+++ b/src/gconf-helpers/gconf-helpers.c
@@ -1401,6 +1401,8 @@ nm_gconf_set_ip6addr_array_helper (GConfClient *client,
guint prefix;
char addr[INET6_ADDRSTRLEN];
char gw[INET6_ADDRSTRLEN];
+ gboolean have_gw = FALSE;
+ char *gconf_str;
if (elements->n_values < 1 || elements->n_values > 3) {
g_warning ("%s: invalid IPv6 address!", __func__);
@@ -1433,17 +1435,24 @@ nm_gconf_set_ip6addr_array_helper (GConfClient *client,
goto out;
}
- if (elements->n_values == 2) {
- list = g_slist_append (list, g_strdup_printf ("%s/%u", addr, prefix));
- } else {
+ if (elements->n_values == 3) {
tmp = g_value_array_get_nth (elements, 2);
ba = g_value_get_boxed (tmp);
- if (!inet_ntop (AF_INET6, ba->data, gw, sizeof (gw))) {
- g_warning ("%s: invalid IPv6 gateway!", __func__);
- goto out;
+ if (ba && !IN6_IS_ADDR_UNSPECIFIED (ba->data)) {
+ if (!inet_ntop (AF_INET6, ba->data, gw, sizeof (gw))) {
+ g_warning ("%s: invalid IPv6 gateway!", __func__);
+ goto out;
+ }
+ have_gw = TRUE;
}
- list = g_slist_append (list, g_strdup_printf ("%s/%u,%s", addr, prefix, gw));
}
+
+ gconf_str = g_strdup_printf ("%s/%u%s%s",
+ addr,
+ prefix,
+ have_gw ? "," : "",
+ have_gw ? gw : "");
+ list = g_slist_append (list, gconf_str);
}
gconf_client_set_list (client, gc_key, GCONF_VALUE_STRING, list, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]