Support openrc style configuration
authorMu Qiao <qiaomuf@gentoo.org>
Wed, 7 Dec 2011 03:08:53 +0000 (03:08 +0000)
committerMu Qiao <qiaomuf@gentoo.org>
Wed, 7 Dec 2011 03:08:53 +0000 (03:08 +0000)
Package-Manager: portage-2.1.10.39/cvs/Linux x86_64

net-misc/networkmanager/ChangeLog
net-misc/networkmanager/Manifest
net-misc/networkmanager/files/networkmanager-0.9.2.0-ifnet-openrc-style.patch [new file with mode: 0644]
net-misc/networkmanager/networkmanager-0.9.2.0-r1.ebuild [new file with mode: 0644]

index 178ca13554ccb94551b35187a6b0d47514333e88..a91659c8044b59ee1f9aa6a2f1cd64c6272d8e35 100644 (file)
@@ -1,6 +1,14 @@
 # ChangeLog for net-misc/networkmanager
 # Copyright 1999-2011 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/net-misc/networkmanager/ChangeLog,v 1.121 2011/11/20 10:06:51 xarthisius Exp $
+# $Header: /var/cvsroot/gentoo-x86/net-misc/networkmanager/ChangeLog,v 1.122 2011/12/07 03:08:53 qiaomuf Exp $
+
+*networkmanager-0.9.2.0-r1 (07 Dec 2011)
+
+  07 Dec 2011; Mu Qiao <qiaomuf@gentoo.org> +networkmanager-0.9.2.0-r1.ebuild,
+  +files/networkmanager-0.9.2.0-ifnet-openrc-style.patch:
+  Support openrc style configuration
+
+  The old IP style like 192.168.1.{1..4} is not supported anymore.
 
   20 Nov 2011; Kacper Kowalik <xarthisius@gentoo.org>
   networkmanager-0.8.4.0-r2.ebuild:
index 8e019162e7d7e31193537b08b60c6af52ed9a2bc..9bd096131fc6d11c9a66226e731650a4e7453b44 100644 (file)
@@ -1,5 +1,5 @@
 -----BEGIN PGP SIGNED MESSAGE-----
-Hash: SHA256
+Hash: SHA1
 
 AUX 01-org.freedesktop.NetworkManager.settings.modify.system.pkla 187 RMD160 a6de26825439432c62cfaa7be847fa39181747fa SHA1 cae5a2c5d8ab0af2830f17e7fe375468c8d5b151 SHA256 909356b25e2d887a31c0f9f2a23a466957f27b163bbd5172fa852988a1db1860
 AUX NetworkManagerDispatcher 1198 RMD160 4345870ab40607b9aed80c8da383b604f032b98e SHA1 1dd2250c746b25566fceaab551f4ef8335fe4f55 SHA256 f8cb5d0470619cf1f0812fffcf1bf2091e3c44a757899c07164f80ddd6a2641e
@@ -13,6 +13,7 @@ AUX networkmanager-0.9.1.95-dns-routing-unmanaged-devices.patch 2740 RMD160 014d
 AUX networkmanager-0.9.1.95-force-libnl1.1.patch 1883 RMD160 fc6760cdcba81710c7232c536ee31276fe676062 SHA1 9bb1257b55f7a15d61f6c30d27ec7ded7c49da7a SHA256 1fb9d5bbda83e056c7ea53bcb5463f2f1b1c09d91b05a0df5fcfd948fb4c0007
 AUX networkmanager-0.9.1.95-glib-2.31.patch 4932 RMD160 6d20b856a4c3ce86cc15f10439ac437c1f70e0aa SHA1 2c773a16109e57eddb7bf8a1932c05eb3c5442a1 SHA256 b5a70e9a29d11a0455493d895abeb673042c7bcbc149c16a12b6f70ca8ab4912
 AUX networkmanager-0.9.1.95-keyfile-scheme.patch 927 RMD160 16ea59d436e300f5e453d1f9b027c67704d9ee6b SHA1 6ccf2538dba3e29c1210c6b843ececfd09542581 SHA256 0c1013afe0343a94f2584779737d6b1714c432564e967ca014ba5da552b3d283
+AUX networkmanager-0.9.2.0-ifnet-openrc-style.patch 18656 RMD160 deb7be203b56ba2029763bf34508db584d35df92 SHA1 bdfb8e2c4fadc129171f48eb99330c75354d65da SHA256 9ec9bd94159979ffd17221901299055ec3329886862cca564c9931a7b65fb616
 AUX networkmanager-0.9_rc3-fix-tests.patch 589 RMD160 a63f0d4f908a32356baf78c7e7c9a68cd9e4d68c SHA1 9f1ed4418b124bae89f9849ce2560dd713565abc SHA256 c03a97751762864dc4dcfa6d9eeee1ea70b986bcd5830a6777cd7514ba647540
 AUX nm-system-settings.conf 23 RMD160 6d66c702b345bde668a420a15716feea6005fbd1 SHA1 49ba558d20f5ca5a201e027e13b878dd5ac3569c SHA256 44b048804c7c0b8b3b0c29b8632b6ad613c397d0a1635ec918e10c0fbcdadf21
 AUX nm-system-settings.conf-ifnet 70 RMD160 c0d2be147383999b62cead86ab4333169e4ef277 SHA1 679ec8052b610969c148a2d34cd4da7a41484a76 SHA256 34f53d9ac1ad65eda6942dc3059117f60f6321059ca23f4fbfcc2f2edcae151f
@@ -25,23 +26,18 @@ EBUILD networkmanager-0.8-r1.ebuild 3718 RMD160 abf962bc9f2368b13d28432994383e37
 EBUILD networkmanager-0.8.4.0-r2.ebuild 4335 RMD160 7f413e48de262b71f692c0585e2e70b64c467249 SHA1 8cd00862bac4a3218cbb45d011cb394d91563d97 SHA256 654a9a55d1683afa579df435df9df4b6d439c496c80900039773e5588433280d
 EBUILD networkmanager-0.9.0.ebuild 3945 RMD160 cd897dc8dc3fa92d4f4694a5acd703be6f9b5be1 SHA1 ef7eaa7e68bf01c2f4ea280742f30f856ef76ef6 SHA256 ab67f7f112c3b415c70f08b1ea9d6c029b7733203bafb512250e483b91c61bc8
 EBUILD networkmanager-0.9.1.95.ebuild 4926 RMD160 2a93cf7a8e56c5a5717dfbe44eb782c6a71efa94 SHA1 47cb6a9354dcc37eba1b56b286cbbd6d56fb1e7e SHA256 2beb60a101e6a8ee920b20f7ffa711f4250073cb10369d829e1c3f17b40fa8f1
+EBUILD networkmanager-0.9.2.0-r1.ebuild 4683 RMD160 e1716e1b9149a41c5aa8ad9e57b1b9baa1bc97a1 SHA1 d6d94db24c3ddfd5f4e8af237013a72060296a4c SHA256 fa3152516b00d9270adb85cafb498dcb524ba88610d85df477361f04e223d155
 EBUILD networkmanager-0.9.2.0.ebuild 4603 RMD160 3debbefb4e568c8f9a88afbe99c9b396c23e2c8a SHA1 ac79b40c257c8f35785de76abd642dc57d3a2a42 SHA256 dc3ed6e10b182eaf4630e819a413c07a2193da9d2d575a4dac8ab2a443ead44e
-MISC ChangeLog 26980 RMD160 f7d78ffcba0309d3ae34fc23615a6d108c54715b SHA1 381e5860865ffb04932a8def26cdad415f8fd0ee SHA256 70e443ced9936aa8d4f189ac30a8c35ab853fdab8fd2a48dd768263cb1827071
+MISC ChangeLog 27262 RMD160 93147dec8c0ee57a30d79b7ac069594d7162bf3b SHA1 508cf3e39ce2a2c6450f3721f9d46157714ee141 SHA256 41b914ce6e9e587efcdb280d0987a6e23b3d95f48fbfc6072ac10a1086a3e5fe
 MISC metadata.xml 1330 RMD160 e4f803e3c28dc220a820f908667df763a4320097 SHA1 541270c3f3c902f9378451bd47d00379c725af6b SHA256 d7e9e19f1ebd28e9058f8ef868bc6298b77c45461bfbc93c155a5aa9166c65c4
 -----BEGIN PGP SIGNATURE-----
-Version: GnuPG v2.0.18 (GNU/Linux)
+Version: GnuPG v2.0.17 (GNU/Linux)
 
-iQIcBAEBCAAGBQJOyNFGAAoJEF0huFKJUZL5q/cP/3i4jKEscJxHEaMk+eTuRe4Z
-SjgcGNKG9UfTMMUMlIPyDa9i0YVYPbbMGtNcvtVJH6EuLp/UT0C4mpa5V4jtue0S
-9Iji0o1Rs3K4vdmD+4oKQmzaBc6VA1/6wLy2B7SHMcnUrvNaSEGk9AXpr/b0zNZZ
-Mj3pRLAVTtgQOnqluYIyCc/nQuKQ2dlYEJG6lf4pdYW9pPXHkGRbMVKW1tp+B0oY
-idZarmFapo1Bg5Ewd53beQfbgNpEkj9tGkEExp6pUX3UmdcjzVMFKIn9gmJoxzkG
-oWL3VOz5Qcux7mlZgLB4Qhn5JFZvkGTXHicumdx7vCdp+iZR04UmhuLeFZsjfLYq
-CDGUDNQyXiL+ptf8a0KQoI1WKqs7TI/vQYc9Di883gYY6+Vpp/ii2uo5ksLjNEEe
-8cq4FXsXiB822onf+N5jSEn9kA/losiCAIkCMGNXtYATeGm2P02um8ok/zzDg/9r
-3Mlv/SHzVsSrgLSZzfUEDErLIUPlvPIm51LbK/ANg//92zM3uSSXCgLyH9TeRlb1
-iyZXVLedPef0AdgtKyomfil7j2edbAHBXTiMfWnrUktK5m+qel2lUaYpPrbdAQpt
-wsBV9EQkoTd1UEOnqqWlDsyV/73dlJyoB0/tm0L/tI/hiWLJFAh9qSPilkvi2Vwz
-MX9/VjT+WpYFesrNjd8M
-=74B8
+iQEcBAEBAgAGBQJO3tjTAAoJEDCzDeQXsVfpq54IALTx+DRtmXYDTgAi5jOuNZr2
+YEWUAskjcfyi980H0ywrZx1dylGKfGHV1y/s0ZPT4e4Y4SXT+OOkRf4UsdnD4PX7
+JVX2Z1s43XiADn2OF9roqz8cswjSvDdrIrRv+PMRSCNIJejch8x0JtNt1bxlDOkz
+zBxlDFYiVty26BZ8E0PgRD1u+C4qFxRPGFkC/ZFH5iZbNlJs9WUQiW9FcEaUsAsk
+dYgNR+rUF/lymeSB8mxhJVjOH8QQMRZ9559mMe17V+SrYu165/Dtc8GViW1D7J0o
+lqWId7dBGcekqHhk2rX6upL5SQBRP2jaDj4Q2a/XDoSnqeUVvhhchtbO5X2QXa0=
+=+ie+
 -----END PGP SIGNATURE-----
diff --git a/net-misc/networkmanager/files/networkmanager-0.9.2.0-ifnet-openrc-style.patch b/net-misc/networkmanager/files/networkmanager-0.9.2.0-ifnet-openrc-style.patch
new file mode 100644 (file)
index 0000000..e89ec74
--- /dev/null
@@ -0,0 +1,596 @@
+From c5f080923f0c52084a929b4125e8fbe19f6e7279 Mon Sep 17 00:00:00 2001
+From: Mu Qiao <qiaomuf@gentoo.org>
+Date: Tue, 6 Dec 2011 14:55:03 +0800
+Subject: [PATCH] ifnet: support reading openrc style
+
+IP configuration like 192.168.1.{2..4} is not supported anymore.
+---
+ src/settings/plugins/ifnet/connection_parser.c |   14 +-
+ src/settings/plugins/ifnet/net_parser.c        |   84 ++++++++++----
+ src/settings/plugins/ifnet/net_utils.c         |  144 ++++++++++--------------
+ src/settings/plugins/ifnet/tests/net           |   11 ++-
+ src/settings/plugins/ifnet/tests/test_all.c    |   30 ++++-
+ 5 files changed, 163 insertions(+), 120 deletions(-)
+
+diff --git a/src/settings/plugins/ifnet/connection_parser.c b/src/settings/plugins/ifnet/connection_parser.c
+index b4aaa8d..66ce318 100644
+--- a/src/settings/plugins/ifnet/connection_parser.c
++++ b/src/settings/plugins/ifnet/connection_parser.c
+@@ -567,7 +567,7 @@ make_wired_connection_setting (NMConnection *connection,
+               nm_connection_add_setting (connection, NM_SETTING (s_wired));
+ }
+ 
+-/* add NM_SETTING_IP4_CONFIG_DHCP_HOSTNAME, 
++/* add NM_SETTING_IP4_CONFIG_DHCP_HOSTNAME,
+  * NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID in future*/
+ static void
+ make_ip4_setting (NMConnection *connection,
+@@ -596,19 +596,19 @@ make_ip4_setting (NMConnection *connection,
+                       g_object_unref (ip4_setting);
+                       return;
+               }
+-              if (!strcmp (method, "dhcp"))
++              if (strstr (method, "dhcp"))
+                       g_object_set (ip4_setting,
+                                                 NM_SETTING_IP4_CONFIG_METHOD,
+                                                 NM_SETTING_IP4_CONFIG_METHOD_AUTO,
+                                                 NM_SETTING_IP4_CONFIG_NEVER_DEFAULT, FALSE, NULL);
+-              else if (!strcmp (method, "autoip")){
++              else if (strstr (method, "autoip")){
+                       g_object_set (ip4_setting,
+                                                 NM_SETTING_IP4_CONFIG_METHOD,
+                                                 NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL,
+                                                 NM_SETTING_IP4_CONFIG_NEVER_DEFAULT, FALSE, NULL);
+                       nm_connection_add_setting (connection, NM_SETTING (ip4_setting));
+                       return;
+-              } else if (!strcmp (method, "shared")){
++              } else if (strstr (method, "shared")){
+                       g_object_set (ip4_setting,
+                                                 NM_SETTING_IP4_CONFIG_METHOD,
+                                                 NM_SETTING_IP4_CONFIG_METHOD_SHARED,
+@@ -663,7 +663,7 @@ make_ip4_setting (NMConnection *connection,
+       }
+ 
+       /* add dhcp hostname and client id */
+-      if (!is_static_block && !strcmp (method, "dhcp")) {
++      if (!is_static_block && strstr (method, "dhcp")) {
+               gchar *dhcp_hostname, *client_id;
+ 
+               get_dhcp_hostname_and_client_id (&dhcp_hostname, &client_id);
+@@ -868,7 +868,7 @@ make_ip6_setting (NMConnection *connection,
+               nm_ip6_route_set_dest (route, iblock->ip);
+               nm_ip6_route_set_next_hop (route, iblock->next_hop);
+               nm_ip6_route_set_prefix (route, iblock->prefix);
+-              /* metric is not per routes configuration right now 
++              /* metric is not per routes configuration right now
+                * global metric is also supported (metric="x") */
+               if ((metric_str = ifnet_get_data (conn_name, "metric")) != NULL) {
+                       metric = strtol (metric_str, NULL, 10);
+@@ -995,7 +995,7 @@ make_wireless_connection_setting (const char *conn_name,
+               goto error;
+       }
+ 
+-      /* mode=0: infrastructure 
++      /* mode=0: infrastructure
+        * mode=1: adhoc */
+       value = wpa_get_value (conn_name, "mode");
+       if (value)
+diff --git a/src/settings/plugins/ifnet/net_parser.c b/src/settings/plugins/ifnet/net_parser.c
+index a48103d..4befc37 100644
+--- a/src/settings/plugins/ifnet/net_parser.c
++++ b/src/settings/plugins/ifnet/net_parser.c
+@@ -169,12 +169,10 @@ init_block_by_line (gchar * buf)
+                       conn = add_new_connection_config ("wireless", pos);
+       }
+       data = g_strdup (key_value[1]);
+-      tmp = strip_string (data, '(');
+-      tmp = strip_string (tmp, ')');
+-      strip_string (tmp, '"');
++      tmp = strip_string (data, '"');
+       strip_string (tmp, '\'');
+       if (conn)
+-              g_hash_table_insert (conn, g_strdup (key_value[0]),
++              g_hash_table_insert (conn, strip_string (g_strdup (key_value[0]), ' '),
+                                    g_strdup (tmp));
+       g_free (data);
+       g_strfreev (key_value);
+@@ -283,6 +281,22 @@ is_function (gchar * line)
+       return FALSE;
+ }
+ 
++static void
++append_line (GString *buf, gchar* line)
++{
++      gchar *pos = NULL;
++
++      if ((pos = strchr (line, '#')) != NULL)
++              *pos = '\0';
++      g_strstrip (line);
++
++      if (line[0] != '\0') {
++              g_string_append_printf (buf,
++                                      " %s", line);
++      }
++      g_free (line);
++}
++
+ gboolean
+ ifnet_init (gchar * config_file)
+ {
+@@ -292,6 +306,8 @@ ifnet_init (gchar * config_file)
+       /* Handle multiple lines with brackets */
+       gboolean complete = TRUE;
+ 
++      gboolean openrc_style = TRUE;
++
+       /* line buffer */
+       GString *buf;
+ 
+@@ -319,36 +335,60 @@ ifnet_init (gchar * config_file)
+                       strip_function (channel, line);
+                       continue;
+               }
+-              if (line[0] != '#' && line[0] != '\0') {
+-                      gchar *pos = NULL;
+ 
++              // New openrc style, bash arrays are not allowed. We only care about '"'
++              if (openrc_style && line[0] != '#' && line[0] != '\0'
++                              && !strchr (line, '(') && !strchr (line, ')')) {
++                      gchar *tmp = line;
++
++                      while ((tmp = strchr (tmp, '"')) != NULL) {
++                              complete = !complete;
++                              ++tmp;
++                      }
++
++                      append_line (buf, line);
++                      // Add "(separator) for routes. It will be easier for later parsing
++                      if (strstr (buf->str, "via"))
++                              g_string_append_printf (buf, "\"");
++
++                      if (!complete)
++                              continue;
++
++                      strip_string (buf->str, '"');
++
++                      init_block_by_line (buf->str);
++                      g_string_free (buf, TRUE);
++                      buf = g_string_new (NULL);
++              }
++              // Old bash arrays for baselayout-1, to be deleted
++              else if (line[0] != '#' && line[0] != '\0') {
+                       if (!complete) {
+                               complete =
+                                   g_strrstr (line,
+                                              ")") == NULL ? FALSE : TRUE;
+-                              if ((pos = strchr (line, '#')) != NULL)
+-                                      *pos = '\0';
+-                              g_strstrip (line);
+-                              if (line[0] != '\0') {
+-                                      g_string_append_printf (buf,
+-                                                              " %s", line);
+-                              }
+-                              g_free (line);
+-                              if (!complete)
++
++                              append_line (buf, line);
++                              if (!complete) {
++                                      openrc_style = FALSE;
+                                       continue;
++                              }
++                              else {
++                                      openrc_style = TRUE;
++                              }
+                       } else {
+                               complete =
+                                   (g_strrstr (line, "(") != NULL
+                                    && g_strrstr (line, ")") != NULL)
+                                   || g_strrstr (line, "(") == NULL;
+-                              if ((pos = strchr (line, '#')) != NULL)
+-                                      *pos = '\0';
+-                              g_strstrip (line);
+-                              if (line[0] != '\0')
+-                                      g_string_append (buf, line);
+-                              g_free (line);
++
++                              append_line (buf, line);
+                               if (!complete)
++                              {
++                                      openrc_style = FALSE;
+                                       continue;
++                              } else {
++                                      openrc_style = TRUE;
++                              }
+                       }
+                       init_block_by_line (buf->str);
+                       g_string_free (buf, TRUE);
+@@ -391,7 +431,7 @@ ifnet_set_data (const char *conn_name, const char *key, const char *value)
+       }
+       /* Remove existing key value pair */
+       if (g_hash_table_lookup_extended (conn, key, &old_key, &old_value)) {
+-              if (stripped && !strcmp(old_value, stripped)){
++              if (stripped && !strcmp (old_value, stripped)){
+                       g_free (stripped);
+                       return;
+               }
+diff --git a/src/settings/plugins/ifnet/net_utils.c b/src/settings/plugins/ifnet/net_utils.c
+index b533ae3..fc7e283 100644
+--- a/src/settings/plugins/ifnet/net_utils.c
++++ b/src/settings/plugins/ifnet/net_utils.c
+@@ -352,6 +352,49 @@ is_ip6_address (const char *in_address)
+ 
+ }
+ 
++// 'c' is only used for openrc style
++static gchar **
++split_addresses_by_char (const gchar *addresses, const gchar *c)
++{
++      gchar **ipset;
++
++      if (addresses == NULL)
++              return NULL;
++
++      if (strchr (addresses, '(') != NULL) { // old baselayout style
++              gchar *tmp = g_strdup (addresses);
++              strip_string (tmp, '(');
++              strip_string (tmp, ')');
++              strip_string (tmp, '"');
++              strip_string (tmp, '\'');
++              ipset = g_strsplit (tmp, "\" \"", 0);
++              g_free(tmp);
++      } else { // openrc style
++              if (strstr (addresses, "netmask"))
++                      // There is only one ip address if "netmask" is specified.
++                      // '\n' is not used in config so there will be only one split.
++                      ipset = g_strsplit (addresses, "\n", 0);
++              else
++                      ipset = g_strsplit (addresses, c, 0);
++      }
++
++      return ipset;
++}
++
++static gchar **
++split_addresses (const gchar* addresses)
++{
++      // " " is only used by openrc style
++      return split_addresses_by_char (addresses, " ");
++}
++
++static gchar **
++split_routes (const gchar* routes)
++{
++      // "\"" is only used by openrc style
++      return split_addresses_by_char (routes, "\"");
++}
++
+ gboolean
+ has_ip6_address (const char *conn_name)
+ {
+@@ -360,7 +403,7 @@ has_ip6_address (const char *conn_name)
+       guint i;
+ 
+       g_return_val_if_fail (conn_name != NULL, FALSE);
+-      ipset = g_strsplit (ifnet_get_data (conn_name, "config"), "\" \"", 0);
++      ipset = split_addresses (ifnet_get_data (conn_name, "config"));
+       length = g_strv_length (ipset);
+       for (i = 0; i < length; i++) {
+               if (!is_ip6_address (ipset[i]))
+@@ -512,8 +555,11 @@ get_ip4_gateway (gchar * gateway)
+       tmp = g_strdup (tmp);
+       strip_string (tmp, ' ');
+       strip_string (tmp, '"');
++
++      // Only one gateway is selected
+       if ((split = strstr (tmp, "\"")) != NULL)
+               *split = '\0';
++
+       if (!inet_pton (AF_INET, tmp, &tmp_ip4_addr))
+               goto error;
+       g_free (tmp);
+@@ -567,14 +613,11 @@ convert_ip4_config_block (const char *conn_name)
+       gchar *ip;
+       guint32 def_gateway = 0;
+       const char *routes;
+-      gchar *pos;
+       ip_block *start = NULL, *current = NULL, *iblock = NULL;
+-      const char *pattern =
+-          "((\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.)\\{(\\d{1,3})\\.\\.(\\d{1,3})\\}(/\\d{1,2}))";
+ 
+       g_return_val_if_fail (conn_name != NULL, NULL);
+ 
+-      ipset = g_strsplit (ifnet_get_data (conn_name, "config"), "\" \"", 0);
++      ipset = split_addresses (ifnet_get_data (conn_name, "config"));
+       length = g_strv_length (ipset);
+ 
+       routes = ifnet_get_data (conn_name, "routes");
+@@ -584,73 +627,16 @@ convert_ip4_config_block (const char *conn_name)
+       for (i = 0; i < length; i++) {
+               ip = ipset[i];
+               ip = strip_string (ip, '"');
+-              //Handle ip like 192.168.4.{1..3}
+-              if ((pos = strchr (ip, '{')) != NULL) {
+-                      gchar *ip_start, *ip_prefix;
+-                      gchar *begin_str, *end_str;
+-                      int begin, end, j;
+-                      GRegex *regex;
+-                      GMatchInfo *match_info;
+-
+-                      regex = g_regex_new (pattern, 0, 0, NULL);
+-                      g_regex_match (regex, ip, 0, &match_info);
+-                      g_regex_unref (regex);
+-
+-                      if (!g_match_info_matches (match_info)) {
+-                              g_match_info_free (match_info);
+-                              continue;
+-                      }
+-                      begin_str = g_match_info_fetch (match_info, 3);
+-                      end_str = g_match_info_fetch (match_info, 4);
+-                      begin = atoi (begin_str);
+-                      end = atoi (end_str);
+-                      ip_start = g_match_info_fetch (match_info, 2);
+-                      ip_prefix = g_match_info_fetch (match_info, 5);
+-                      if (end < begin || begin < 1 || end > 254) {
+-                              g_match_info_free (match_info);
+-                              continue;
+-                      }
+-
+-                      for (j = begin; j <= end; j++) {
+-                              char suf[4];
+-                              gchar *newip;
+-
+-                              sprintf (suf, "%d", j);
+-                              newip =
+-                                  g_strconcat (ip_start, suf, ip_prefix,
+-                                               NULL);
+-                              iblock = create_ip4_block (newip);
+-                              if (iblock == NULL) {
+-                                      g_free (newip);
+-                                      continue;
+-                              }
+-                              if (!iblock->gateway && def_gateway != 0)
+-                                      iblock->gateway = def_gateway;
+-                              if (start == NULL)
+-                                      start = current = iblock;
+-                              else {
+-                                      current->next = iblock;
+-                                      current = iblock;
+-                              }
+-                              g_free (newip);
+-                      }
+-                      g_free (begin_str);
+-                      g_free (end_str);
+-                      g_free (ip_start);
+-                      g_free (ip_prefix);
+-                      g_match_info_free (match_info);
+-              } else {
+-                      iblock = create_ip4_block (ip);
+-                      if (iblock == NULL)
+-                              continue;
+-                      if (!iblock->gateway && def_gateway != 0)
+-                              iblock->gateway = def_gateway;
+-                      if (start == NULL)
+-                              start = current = iblock;
+-                      else {
+-                              current->next = iblock;
+-                              current = iblock;
+-                      }
++              iblock = create_ip4_block (ip);
++              if (iblock == NULL)
++                      continue;
++              if (!iblock->gateway && def_gateway != 0)
++                      iblock->gateway = def_gateway;
++              if (start == NULL)
++                      start = current = iblock;
++              else {
++                      current->next = iblock;
++                      current = iblock;
+               }
+       }
+       g_strfreev (ipset);
+@@ -667,7 +653,7 @@ convert_ip6_config_block (const char *conn_name)
+       ip6_block *start = NULL, *current = NULL, *iblock = NULL;
+ 
+       g_return_val_if_fail (conn_name != NULL, NULL);
+-      ipset = g_strsplit (ifnet_get_data (conn_name, "config"), "\" \"", 0);
++      ipset = split_addresses (ifnet_get_data (conn_name, "config"));
+       length = g_strv_length (ipset);
+       for (i = 0; i < length; i++) {
+               ip = ipset[i];
+@@ -693,15 +679,11 @@ convert_ip4_routes_block (const char *conn_name)
+       guint length;
+       guint i;
+       gchar *ip;
+-      const char *routes;
+       ip_block *start = NULL, *current = NULL, *iblock = NULL;
+ 
+       g_return_val_if_fail (conn_name != NULL, NULL);
+ 
+-      routes = ifnet_get_data (conn_name, "routes");
+-      if (!routes)
+-              return NULL;
+-      ipset = g_strsplit (routes, "\" \"", 0);
++      ipset = split_routes (ifnet_get_data (conn_name, "routes"));
+       length = g_strv_length (ipset);
+       for (i = 0; i < length; i++) {
+               ip = ipset[i];
+@@ -731,15 +713,11 @@ convert_ip6_routes_block (const char *conn_name)
+       guint length;
+       guint i;
+       gchar *ip, *tmp_addr;
+-      const char *routes;
+       ip6_block *start = NULL, *current = NULL, *iblock = NULL;
+       struct in6_addr *tmp_ip6_addr;
+ 
+       g_return_val_if_fail (conn_name != NULL, NULL);
+-      routes = ifnet_get_data (conn_name, "routes");
+-      if (!routes)
+-              return NULL;
+-      ipset = g_strsplit (routes, "\" \"", 0);
++      ipset = split_routes (ifnet_get_data (conn_name, "routes"));
+       length = g_strv_length (ipset);
+       for (i = 0; i < length; i++) {
+               ip = ipset[i];
+diff --git a/src/settings/plugins/ifnet/tests/net b/src/settings/plugins/ifnet/tests/net
+index 0eef399..27d39f4 100644
+--- a/src/settings/plugins/ifnet/tests/net
++++ b/src/settings/plugins/ifnet/tests/net
+@@ -27,10 +27,9 @@ config_eth2=(
+ routes_eth2=("default via  4321:0:1:2:3:4:567:89ab")
+ enable_ipv6_eth2="true"
+ config_eth3=("nufjlsjlll")
+-managed_eth4=("false")
++managed_eth4="false"
+ routes_eth4=("default via 4321:0:1:2:3:4:567:89ab")
+ config_eth5=("dhcp")
+-config_eth6=("192.168.4.{1..101}/24")
+ 
+ config_eth7=( "dhcp" )
+ auto_eth7="true"
+@@ -38,6 +37,14 @@ auto_eth7="true"
+ # missing config_eth8
+ auto_eth8="true"
+ 
++#new openrc style
++config_eth9="202.117.16.10/24 202.117.17.10/24"
++routes_eth9="default via 202.117.16.1
++10.0.0.0/8 via 192.168.0.1
++"
++config_eth10="202.117.16.2 netmask 255.255.255.0"
++routes_eth10="10.0.0.0/8 via 192.168.0.1"
++
+ config_myxjtu2=("202.117.16.121/24 brd 202.117.16.255")
+ routes_myxjtu2=("default via 202.117.16.1")
+ dns_servers_myxjtu2="202.117.0.20 202.117.0.21"
+diff --git a/src/settings/plugins/ifnet/tests/test_all.c b/src/settings/plugins/ifnet/tests/test_all.c
+index 52d9ce2..9ca5f65 100644
+--- a/src/settings/plugins/ifnet/tests/test_all.c
++++ b/src/settings/plugins/ifnet/tests/test_all.c
+@@ -37,7 +37,7 @@ static void
+ test_getdata ()
+ {
+       ASSERT (ifnet_get_data ("eth1", "config")
+-              && strcmp (ifnet_get_data ("eth1", "config"), "dhcp") == 0,
++              && strcmp (ifnet_get_data ("eth1", "config"), "( \"dhcp\" )") == 0,
+               "get data", "config_eth1 is not correct");
+       ASSERT (ifnet_get_data ("ppp0", "username")
+               && strcmp (ifnet_get_data ("ppp0", "username"), "user") == 0,
+@@ -84,7 +84,7 @@ test_is_static ()
+       ASSERT (is_static_ip4 ("eth0") == TRUE, "is static",
+               "a static interface is recognized as dhcp");
+       ASSERT (!is_static_ip6 ("eth0") == TRUE, "is static",
+-              "a static interface is recognized as dhcp");
++              "a dhcp interface is recognized as static");
+ }
+ 
+ static void
+@@ -182,10 +182,6 @@ test_convert_ipv4_config_block ()
+       ASSERT (iblock == NULL, "convert config_block",
+               "convert error configuration");
+       destroy_ip_block (iblock);
+-      iblock = convert_ip4_config_block ("eth6");
+-      ASSERT (iblock != NULL, "convert config_block",
+-              "convert error configuration");
+-      destroy_ip_block (iblock);
+ }
+ 
+ static void
+@@ -200,6 +196,16 @@ test_convert_ipv4_routes_block ()
+       destroy_ip_block (tmp);
+       ASSERT (iblock == NULL, "convert ip4 routes",
+               "should only get one route");
++
++      iblock = convert_ip4_routes_block ("eth9");
++      tmp = iblock;
++
++      ASSERT (iblock != NULL, "convert ip4 routes", "should get one route");
++      check_ip_block (iblock, "10.0.0.0", "255.0.0.0", "192.168.0.1");
++      iblock = iblock->next;
++      destroy_ip_block (tmp);
++      ASSERT (iblock == NULL, "convert ip4 routes",
++              "should only get one route");
+ }
+ 
+ static void
+@@ -272,6 +278,18 @@ test_new_connection ()
+               "new connection failed: %s",
+               error ? error->message : "NONE");
+       g_object_unref (connection);
++
++      connection = ifnet_update_connection_from_config_block ("eth9", &error);
++      ASSERT (connection != NULL, "new connection",
++              "new connection(eth9) failed: %s",
++              error ? error->message : "NONE");
++      g_object_unref (connection);
++
++      connection = ifnet_update_connection_from_config_block ("eth10", &error);
++      ASSERT (connection != NULL, "new connection",
++              "new connection(eth10) failed: %s",
++              error ? error->message : "NONE");
++      g_object_unref (connection);
+ }
+ 
+ #define NET_GEN_NAME "net.generate"
+-- 
+1.7.3.4
+
+From 73a17edee3ba1f378166e0eee69f25b28902ce8d Mon Sep 17 00:00:00 2001
+From: Mu Qiao <qiaomuf@gentoo.org>
+Date: Wed, 7 Dec 2011 10:39:26 +0800
+Subject: [PATCH 2/2] ifnet: support writing for openrc style
+
+---
+ src/settings/plugins/ifnet/net_parser.c |   20 +++++++++++++-------
+ 1 files changed, 13 insertions(+), 7 deletions(-)
+
+diff --git a/src/settings/plugins/ifnet/net_parser.c b/src/settings/plugins/ifnet/net_parser.c
+index 4befc37..abca89c 100644
+--- a/src/settings/plugins/ifnet/net_parser.c
++++ b/src/settings/plugins/ifnet/net_parser.c
+@@ -476,22 +476,28 @@ format_ips (gchar * value, gchar ** out_line, gchar * key, gchar * name)
+       guint length, i;
+       GString *formated_string = g_string_new (NULL);
+ 
++      strip_string (value, '(');
++      strip_string (value, ')');
+       strip_string (value, '"');
+-      ipset = g_strsplit (value, "\" \"", 0);
++      ipset = g_strsplit (value, "\"", 0);
+       length = g_strv_length (ipset);
+ 
+       //only one line
+       if (length < 2) {
+               *out_line =
+-                  g_strdup_printf ("%s_%s=( \"%s\" )\n", key, name, value);
++                  g_strdup_printf ("%s_%s=\"%s\"\n", key, name, value);
+               goto done;
+       }
+       // Multiple lines
+-      g_string_append_printf (formated_string, "%s_%s=(\n", key, name);
++      g_string_append_printf (formated_string, "%s_%s=\"\n", key, name);
+       for (i = 0; i < length; i++)
+-              g_string_append_printf (formated_string,
+-                                      "\t\"%s\"\n", ipset[i]);
+-      g_string_append (formated_string, ")\n");
++      {
++              strip_string (ipset[i], ' ');
++              if (ipset[i][0] != '\0')
++                      g_string_append_printf (formated_string,
++                                              "%s\n", ipset[i]);
++      }
++      g_string_append (formated_string, "\"\n");
+       *out_line = g_strdup (formated_string->str);
+ done:
+       g_string_free (formated_string, TRUE);
+@@ -506,7 +512,7 @@ ifnet_flush_to_file (const char *config_file)
+       gpointer key, value, name, network;
+       GHashTableIter iter, iter_network;
+       GList *list_iter;
+-      gchar *out_line;
++      gchar *out_line = NULL;
+       gsize bytes_written;
+       gboolean result = FALSE;
+ 
+-- 
+1.7.3.4
+
diff --git a/net-misc/networkmanager/networkmanager-0.9.2.0-r1.ebuild b/net-misc/networkmanager/networkmanager-0.9.2.0-r1.ebuild
new file mode 100644 (file)
index 0000000..e63c16a
--- /dev/null
@@ -0,0 +1,157 @@
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-misc/networkmanager/networkmanager-0.9.2.0-r1.ebuild,v 1.1 2011/12/07 03:08:53 qiaomuf Exp $
+
+EAPI="4"
+GNOME_ORG_MODULE="NetworkManager"
+
+inherit autotools eutils gnome.org linux-info systemd
+
+DESCRIPTION="Network configuration and management in an easy way. Desktop environment independent."
+HOMEPAGE="http://www.gnome.org/projects/NetworkManager/"
+
+LICENSE="GPL-2"
+SLOT="0"
+IUSE="avahi bluetooth doc +nss gnutls dhclient +dhcpcd +introspection
+       kernel_linux +ppp resolvconf connection-sharing wimax"
+KEYWORDS="~amd64 ~arm ~ppc ~ppc64 ~x86"
+
+REQUIRED_USE="
+       ^^ ( nss gnutls )
+       ^^ ( dhclient dhcpcd )"
+
+# gobject-introspection-0.10.3 is needed due to gnome bug 642300
+# wpa_supplicant-0.7.3-r3 is needed due to bug 359271
+# libnl:1.1 is needed for linking to net-wireless/wimax libraries
+# XXX: on bump, check that net-wireless/wimax is still using libnl:1.1 !
+# TODO: Qt support?
+COMMON_DEPEND=">=sys-apps/dbus-1.2
+       >=dev-libs/dbus-glib-0.75
+       >=net-wireless/wireless-tools-28_pre9
+       || ( >=sys-fs/udev-171[gudev] >=sys-fs/udev-147[extras] )
+       >=dev-libs/glib-2.26
+       >=sys-auth/polkit-0.97
+       dev-libs/libnl:1.1
+       >=net-wireless/wpa_supplicant-0.7.3-r3[dbus]
+       bluetooth? ( >=net-wireless/bluez-4.82 )
+       avahi? ( net-dns/avahi[autoipd] )
+       gnutls? (
+               dev-libs/libgcrypt
+               net-libs/gnutls )
+       nss? ( >=dev-libs/nss-3.11 )
+       dhclient? ( net-misc/dhcp )
+       dhcpcd? ( >=net-misc/dhcpcd-4.0.0_rc3 )
+       introspection? ( >=dev-libs/gobject-introspection-0.10.3 )
+       ppp? (
+               >=net-misc/modemmanager-0.4
+               >=net-dialup/ppp-2.4.5 )
+       resolvconf? ( net-dns/openresolv )
+       connection-sharing? (
+               net-dns/dnsmasq
+               net-firewall/iptables )
+       wimax? ( >=net-wireless/wimax-1.5.1 )"
+
+RDEPEND="${COMMON_DEPEND}
+       sys-auth/consolekit"
+
+DEPEND="${COMMON_DEPEND}
+       dev-util/pkgconfig
+       >=dev-util/intltool-0.40
+       >=sys-devel/gettext-0.17
+       doc? ( >=dev-util/gtk-doc-1.8 )"
+
+sysfs_deprecated_check() {
+       ebegin "Checking for SYSFS_DEPRECATED support"
+
+       if { linux_chkconfig_present SYSFS_DEPRECATED_V2; }; then
+               eerror "Please disable SYSFS_DEPRECATED_V2 support in your kernel config and recompile your kernel"
+               eerror "or NetworkManager will not work correctly."
+               eerror "See http://bugs.gentoo.org/333639 for more info."
+               die "CONFIG_SYSFS_DEPRECATED_V2 support detected!"
+       fi
+       eend $?
+}
+
+pkg_pretend() {
+       if use kernel_linux; then
+               get_version
+               if linux_config_exists; then
+                       sysfs_deprecated_check
+               else
+                       ewarn "Was unable to determine your kernel .config"
+                       ewarn "Please note that if CONFIG_SYSFS_DEPRECATED_V2 is set in your kernel .config, NetworkManager will not work correctly."
+                       ewarn "See http://bugs.gentoo.org/333639 for more info."
+               fi
+
+       fi
+}
+
+pkg_setup() {
+       enewgroup plugdev
+}
+
+src_prepare() {
+       # Don't build tests
+       epatch "${FILESDIR}/${PN}-0.9_rc3-fix-tests.patch"
+       # Build against libnl:1.1 for net-wireless/wimax-1.5.2 compatibility
+       epatch "${FILESDIR}/${PN}-0.9.1.95-force-libnl1.1.patch"
+       # Migrate to openrc style
+       epatch "${FILESDIR}/${P}-ifnet-openrc-style.patch"
+
+       eautoreconf
+       default
+}
+
+src_configure() {
+       ECONF="--disable-more-warnings
+               --disable-static
+               --localstatedir=/var
+               --with-distro=gentoo
+               --with-dbus-sys-dir=/etc/dbus-1/system.d
+               --with-udev-dir=/lib/udev
+               --with-iptables=/sbin/iptables
+               $(use_enable doc gtk-doc)
+               $(use_enable introspection)
+               $(use_enable ppp)
+               $(use_enable wimax)
+               $(use_with dhclient)
+               $(use_with dhcpcd)
+               $(use_with doc docs)
+               $(use_with resolvconf)
+               $(systemd_with_unitdir)"
+
+               if use nss ; then
+                       ECONF="${ECONF} $(use_with nss crypto=nss)"
+               else
+                       ECONF="${ECONF} $(use_with gnutls crypto=gnutls)"
+               fi
+
+       econf ${ECONF}
+}
+
+src_install() {
+       default
+       # Need to keep the /var/run/NetworkManager directory
+       keepdir /var/run/NetworkManager
+
+       # Need to keep the /etc/NetworkManager/dispatched.d for dispatcher scripts
+       keepdir /etc/NetworkManager/dispatcher.d
+
+       # Add keyfile plugin support
+       keepdir /etc/NetworkManager/system-connections
+       chmod 0600 "${ED}"/etc/NetworkManager/system-connections/.keep* # bug #383765
+       insinto /etc/NetworkManager
+       newins "${FILESDIR}/nm-system-settings.conf-ifnet" nm-system-settings.conf
+
+       # Allow users in plugdev group to modify system connections
+       insinto /etc/polkit-1/localauthority/10-vendor.d
+       doins "${FILESDIR}/01-org.freedesktop.NetworkManager.settings.modify.system.pkla"
+
+       # Remove useless .la files
+       find "${D}" -name '*.la' -exec rm -f {} + || die "la file removal failed"
+}
+
+pkg_postinst() {
+       elog "To modify system network connections without needing to enter the"
+       elog "root password, add your user account to the 'plugdev' group."
+}