summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'net-misc/networkmanager/files/networkmanager-0.8.1-fix-ifnet1.patch')
-rw-r--r--net-misc/networkmanager/files/networkmanager-0.8.1-fix-ifnet1.patch414
1 files changed, 0 insertions, 414 deletions
diff --git a/net-misc/networkmanager/files/networkmanager-0.8.1-fix-ifnet1.patch b/net-misc/networkmanager/files/networkmanager-0.8.1-fix-ifnet1.patch
deleted file mode 100644
index b6eda01..0000000
--- a/net-misc/networkmanager/files/networkmanager-0.8.1-fix-ifnet1.patch
+++ /dev/null
@@ -1,414 +0,0 @@
-From 283dba290ad1dd98526080c2d1ce565c2ff64c41 Mon Sep 17 00:00:00 2001
-From: Mu Qiao <qiaomuf@gmail.com>
-Date: Wed, 18 Aug 2010 17:38:38 +0800
-Subject: [PATCH] reading & writing: reserve functions defined in /etc/conf.d/net
- Signed-off-by: Mu Qiao <qiaomuf@gmail.com>
-
----
- system-settings/plugins/ifnet/net_parser.c | 173 +++++++++++++++++++-----
- system-settings/plugins/ifnet/tests/net | 80 +++++++++++
- system-settings/plugins/ifnet/tests/test_all.c | 1 +
- 3 files changed, 222 insertions(+), 32 deletions(-)
-
-diff --git a/system-settings/plugins/ifnet/net_parser.c b/system-settings/plugins/ifnet/net_parser.c
-index d4bc461..b4a381d 100644
---- a/system-settings/plugins/ifnet/net_parser.c
-+++ b/system-settings/plugins/ifnet/net_parser.c
-@@ -31,6 +31,9 @@ static GHashTable *conn_table;
- /* Save global settings which are used for writing*/
- static GHashTable *global_settings_table;
-
-+/* Save functions */
-+static GList *functions_list;
-+
- /* Used to decide whether to write changes to file*/
- static gboolean net_parser_data_changed = FALSE;
-
-@@ -213,6 +216,71 @@ ifnet_get_global_setting (gchar * group, gchar * key)
- return result;
- }
-
-+static void
-+strip_function (GIOChannel * channel, gchar * line)
-+{
-+
-+ int counter = 0;
-+ gchar *p, *tmp;
-+ gboolean begin = FALSE;
-+ GString *function_str = g_string_new (line);
-+
-+ g_string_append (function_str, "\n");
-+ while (1) {
-+ p = line;
-+ while (*p != '\0') {
-+ if (*p == '{') {
-+ counter++;
-+ begin = TRUE;
-+ } else if (*p == '}')
-+ counter--;
-+ p++;
-+ }
-+ if (begin && counter == 0) {
-+ g_free (line);
-+ goto done;
-+ }
-+ while (1) {
-+ g_free (line);
-+ if (g_io_channel_read_line
-+ (channel, &line, NULL, NULL,
-+ NULL) == G_IO_STATUS_EOF)
-+ goto done;
-+ g_string_append (function_str, line);
-+ tmp = g_strdup (line);
-+ g_strstrip (tmp);
-+ if (tmp[0] != '#' && tmp[0] != '\0') {
-+ g_free (tmp);
-+ break;
-+ } else
-+ g_free (tmp);
-+ }
-+ }
-+ done:
-+ functions_list =
-+ g_list_append (functions_list, g_strdup (function_str->str));
-+ g_string_free (function_str, TRUE);
-+}
-+
-+static gboolean
-+is_function (gchar * line)
-+{
-+ static gchar *func_names[] =
-+ { "preup", "predown", "postup", "postdown", "failup", "faildown",
-+ NULL,
-+ };
-+ int i;
-+
-+ for (i = 0; func_names[i]; i++) {
-+ if (g_str_has_prefix (line, func_names[i])) {
-+ PLUGIN_PRINT (IFNET_PLUGIN_NAME,
-+ "Ignoring function: %s", func_names[i]);
-+ return TRUE;
-+ }
-+ }
-+ return FALSE;
-+}
-+
- gboolean
- ifnet_init (gchar * config_file)
- {
-@@ -229,12 +297,13 @@ ifnet_init (gchar * config_file)
-
- conn_table = g_hash_table_new (g_str_hash, g_str_equal);
- global_settings_table = g_hash_table_new (g_str_hash, g_str_equal);
-+ functions_list = NULL;
-
- if (g_file_test (config_file, G_FILE_TEST_IS_REGULAR))
- channel = g_io_channel_new_file (config_file, "r", NULL);
- if (channel == NULL) {
-- PLUGIN_WARN (IFNET_PLUGIN_NAME, "Error: Can't open %s\n",
-- config_file);
-+ PLUGIN_WARN (IFNET_PLUGIN_NAME,
-+ "Error: Can't open %s\n", config_file);
- return FALSE;
- }
-
-@@ -244,6 +313,10 @@ ifnet_init (gchar * config_file)
- g_strstrip (line);
- /* convert multiple lines to a complete line and
- * pass it to init_block_by_line() */
-+ if (is_function (line)) {
-+ strip_function (channel, line);
-+ continue;
-+ }
- if (line[0] != '#' && line[0] != '\0') {
- gchar *pos = NULL;
-
-@@ -255,15 +328,16 @@ ifnet_init (gchar * config_file)
- *pos = '\0';
- g_strstrip (line);
- if (line[0] != '\0') {
-- g_string_append_printf (buf, " %s",
-- line);
-+ g_string_append_printf (buf,
-+ " %s", line);
- }
- g_free (line);
- if (!complete)
- continue;
- } else {
-- complete = (g_strrstr (line, "(") != NULL
-- && g_strrstr (line, ")") != NULL)
-+ complete =
-+ (g_strrstr (line, "(") != NULL
-+ && g_strrstr (line, ")") != NULL)
- || g_strrstr (line, "(") == NULL;
- if ((pos = strchr (line, '#')) != NULL)
- *pos = '\0';
-@@ -305,8 +379,8 @@ ifnet_set_data (gchar * conn_name, gchar * key, gchar * value)
- GHashTable *conn = g_hash_table_lookup (conn_table, conn_name);
-
- if (!conn) {
-- PLUGIN_WARN (IFNET_PLUGIN_NAME, "%s does not exsit!",
-- conn_name);
-+ PLUGIN_WARN (IFNET_PLUGIN_NAME,
-+ "%s does not exsit!", conn_name);
- return;
- }
- /* Remove existing key value pair */
-@@ -371,8 +445,8 @@ format_ips (gchar * value, gchar ** out_line, gchar * key, gchar * name)
- // Multiple lines
- 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_printf (formated_string,
-+ "\t\"%s\"\n", ipset[i]);
- g_string_append (formated_string, ")\n");
- *out_line = g_strdup (formated_string->str);
- done:
-@@ -387,6 +461,7 @@ ifnet_flush_to_file (gchar * config_file)
- GError **error = NULL;
- gpointer key, value, name, network;
- GHashTableIter iter, iter_network;
-+ GList *list_iter;
- gchar *out_line;
- gsize bytes_written;
- gboolean result = FALSE;
-@@ -412,22 +487,22 @@ ifnet_flush_to_file (gchar * config_file)
- while (g_hash_table_iter_next (&iter, &key, &value)) {
- out_line =
- g_strdup_printf ("%s=%s\n", (gchar *) key, (gchar *) value);
-- g_io_channel_write_chars (channel, out_line, -1, &bytes_written,
-- error);
-+ g_io_channel_write_chars (channel, out_line, -1,
-+ &bytes_written, error);
- if (bytes_written == 0 || (error && *error))
- break;
- g_free (out_line);
- }
- if (error && *error) {
-- PLUGIN_WARN (IFNET_PLUGIN_NAME, "Found error: %s",
-- (*error)->message);
-+ PLUGIN_WARN (IFNET_PLUGIN_NAME,
-+ "Found error: %s", (*error)->message);
- goto done;
- }
-+
-+ /* Writing connection data */
- g_io_channel_write_chars (channel,
- "\n###### Connection Configuration ######\n",
- -1, &bytes_written, error);
--
-- /* Writing connection data */
- g_hash_table_iter_init (&iter, conn_table);
- while (g_hash_table_iter_next (&iter, &name, &network)) {
- g_hash_table_iter_init (&iter_network, (GHashTable *) network);
-@@ -439,22 +514,26 @@ ifnet_flush_to_file (gchar * config_file)
- if (!g_str_has_prefix ((gchar *) key, "name")
- && !g_str_has_prefix ((gchar *) key, "type")) {
- /* These keys contain brackets */
-- if (strcmp ((gchar *) key, "config") == 0
-- || strcmp ((gchar *) key, "routes") == 0
-- || strcmp ((gchar *) key, "pppd") == 0
-+ if (strcmp
-+ ((gchar *) key,
-+ "config") == 0
-+ || strcmp ((gchar *) key,
-+ "routes") == 0
-+ || strcmp ((gchar *) key,
-+ "pppd") == 0
- || strcmp ((gchar *) key, "chat") == 0)
-- format_ips (value, &out_line,
-- (gchar *) key,
-- (gchar *) name);
-+ format_ips (value, &out_line, (gchar *)
-+ key, (gchar *)
-+ name);
- else
- out_line =
- g_strdup_printf
- ("%s_%s=\"%s\"\n",
-- (gchar *) key, (gchar *) name,
-- (gchar *) value);
-- g_io_channel_write_chars (channel, out_line, -1,
-- &bytes_written,
-- error);
-+ (gchar *) key,
-+ (gchar *) name, (gchar *) value);
-+ g_io_channel_write_chars
-+ (channel, out_line, -1,
-+ &bytes_written, error);
- if (bytes_written == 0 || (error && *error))
- break;
- g_free (out_line);
-@@ -462,14 +541,38 @@ ifnet_flush_to_file (gchar * config_file)
- }
- }
- if (error && *error) {
-- PLUGIN_WARN (IFNET_PLUGIN_NAME, "Found error: %s",
-- (*error)->message);
-+ PLUGIN_WARN (IFNET_PLUGIN_NAME,
-+ "Found error: %s", (*error)->message);
- goto done;
- }
-+
-+ /* Writing reserved functions */
-+ if (functions_list) {
-+ g_io_channel_write_chars (channel,
-+ "\n###### Reserved Functions ######\n",
-+ -1, &bytes_written, error);
-+ /* Writing functions */
-+ for (list_iter = functions_list; list_iter;
-+ list_iter = g_list_next (list_iter)) {
-+ out_line =
-+ g_strdup_printf ("%s\n", (gchar *) list_iter->data);
-+ g_io_channel_write_chars (channel, out_line, -1,
-+ &bytes_written, error);
-+ if (bytes_written == 0 || (error && *error))
-+ break;
-+ g_free (out_line);
-+ }
-+ if (error && *error) {
-+ PLUGIN_WARN (IFNET_PLUGIN_NAME,
-+ "Found error: %s", (*error)->message);
-+ goto done;
-+ }
-+ }
-+
- g_io_channel_flush (channel, error);
- if (error && *error) {
-- PLUGIN_WARN (IFNET_PLUGIN_NAME, "Found error: %s",
-- (*error)->message);
-+ PLUGIN_WARN (IFNET_PLUGIN_NAME,
-+ "Found error: %s", (*error)->message);
- goto done;
- }
- result = TRUE;
-@@ -502,12 +605,14 @@ ifnet_destroy (void)
- GHashTableIter iter;
- gpointer key;
- gpointer value;
-+ GList *list_iter;
-
- /* Destroy connection setting */
- if (conn_table) {
- g_hash_table_iter_init (&iter, conn_table);
- while (g_hash_table_iter_next (&iter, &key, &value)) {
-- destroy_connection_config ((GHashTable *) value);
-+ destroy_connection_config ((GHashTable *)
-+ value);
- }
- g_hash_table_destroy (conn_table);
- conn_table = NULL;
-@@ -523,4 +628,8 @@ ifnet_destroy (void)
- g_hash_table_destroy (global_settings_table);
- global_settings_table = NULL;
- }
-+ for (list_iter = functions_list; list_iter;
-+ list_iter = g_list_next (list_iter))
-+ g_free (list_iter->data);
-+ g_list_free (functions_list);
- }
-diff --git a/system-settings/plugins/ifnet/tests/net b/system-settings/plugins/ifnet/tests/net
-index 1d8042c..e755000 100644
---- a/system-settings/plugins/ifnet/tests/net
-+++ b/system-settings/plugins/ifnet/tests/net
-@@ -65,3 +65,83 @@ bridge_br0="eth0 kvm0 kvm1"
- config_br0=( "192.168.1.10/24" )
- brctl_br0=( "setfd 0")
- dhcp_eth1="nosendhost nontp -I"
-+
-+predown() {
-+ # The default in the script is to test for NFS root and disallow
-+ # downing interfaces in that case. Note that if you specify a
-+ # predown() function you will override that logic. Here it is, in
-+ # case you still want it...
-+ if is_net_fs /; then
-+ eerror "root filesystem is network mounted -- can't stop ${IFACE}"
-+ return 1
-+ fi
-+
-+ # Remember to return 0 on success
-+ return 0
-+}
-+
-+postup() {
-+ # This function could be used, for example, to register with a
-+ # dynamic DNS service. Another possibility would be to
-+ # send/receive mail once the interface is brought up.
-+
-+ # Here is an example that allows the use of iproute rules
-+ # which have been configured using the rules_eth0 variable.
-+ #rules_eth0=" \
-+ # 'from 24.80.102.112/32 to 192.168.1.0/24 table localnet priority 100' \
-+ # 'from 216.113.223.51/32 to 192.168.1.0/24 table localnet priority 100' \
-+ #"
-+ eval set -- \$rules_${IFVAR}
-+ if [ $# != 0 ]; then
-+ einfo "Adding IP policy routing rules"
-+ eindent
-+ # Ensure that the kernel supports policy routing
-+ if ! ip rule list | grep -q "^"; then
-+ eerror "You need to enable IP Policy Routing (CONFIG_IP_MULTIPLE_TABLES)"
-+ eerror "in your kernel to use ip rules"
-+ else
-+ for x; do
-+ ebegin "${x}"
-+ ip rule add ${x}
-+ eend $?
-+ done
-+ fi
-+ eoutdent
-+ # Flush the cache
-+ ip route flush cache dev "${IFACE}"
-+ fi
-+
-+}
-+
-+postdown() {
-+ # Enable Wake-On-LAN for every interface except for lo
-+ # Probably a good idea to set ifdown="no" in /etc/conf.d/net
-+ # as well ;)
-+ [ "${IFACE}" != "lo" ] && ethtool -s "${IFACE}" wol g
-+
-+ Automatically erase any ip rules created in the example postup above
-+ if interface_exists "${IFACE}"; then
-+ # Remove any rules for this interface
-+ local rule
-+ ip rule list | grep " iif ${IFACE}[ ]*" | {
-+ while read rule; do
-+ rule="${rule#*:}"
-+ ip rule del ${rule}
-+ done
-+ }
-+ # Flush the route cache
-+ ip route flush cache dev "${IFACE}"
-+ fi
-+
-+ # Return 0 always
-+ return 0
-+}
-+
-+failup() {
-+ # This function is mostly here for completeness... I haven't
-+ # thought of anything nifty to do with it yet ;-)
-+}
-+
-+faildown()
-+{}
-+
-diff --git a/system-settings/plugins/ifnet/tests/test_all.c b/system-settings/plugins/ifnet/tests/test_all.c
-index a0218bd..ba98397 100644
---- a/system-settings/plugins/ifnet/tests/test_all.c
-+++ b/system-settings/plugins/ifnet/tests/test_all.c
-@@ -369,6 +369,7 @@ main (void)
- wpa_parser_destroy ();
- ifnet_init ("net");
- wpa_parser_init ("wpa_supplicant.conf");
-+ printf("Initialization complete\n");
-
- run_all (TRUE);
-
---
-1.6.1
-