summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel J. Bergman <noel@devtech.com>2009-10-06 16:45:39 -0700
committerDan Williams <dcbw@redhat.com>2009-10-06 16:46:46 -0700
commit59d89050f255f5a15c1bdcbb33dffa638cfaf695 (patch)
treef81ddff9463211e54cf1814fb90eaf0d24409d2d
parent72a98c5b29ef53c054bffc53ee89b9d3b35a520b (diff)
sharing: fix sharing after 715ddd2045cf786e6c80e6d3d8617fe70ad24552 (lp:444756)
Commit 715ddd2045cf786e6c80e6d3d8617fe70ad24552 broke sharing because sometimes a multi-argument string gets passed in rule->rule. Revert most of that commit. A bunch of cleanups by dcbw too.
-rw-r--r--src/nm-activation-request.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/src/nm-activation-request.c b/src/nm-activation-request.c
index 8d97e37499..f85c12d610 100644
--- a/src/nm-activation-request.c
+++ b/src/nm-activation-request.c
@@ -575,35 +575,35 @@ nm_act_request_set_shared (NMActRequest *req, gboolean shared)
for (iter = list; iter; iter = g_slist_next (iter)) {
ShareRule *rule = (ShareRule *) iter->data;
char *envp[1] = { NULL };
- char *argv[6];
+ char **argv;
char *cmd;
- int status;
- GError *error = NULL;
- argv[0] = IPTABLES_PATH;
- argv[1] = "--table";
- argv[2] = rule->table;
-
- if (shared)
- argv[3] = "--insert";
- else
- argv[3] = "--delete";
-
- argv[4] = rule->rule;
- argv[5] = NULL;
-
- cmd = g_strjoinv (" ", argv);
- nm_info ("Executing: %s", cmd);
+ cmd = g_strdup_printf ("%s --table %s %s %s",
+ IPTABLES_PATH,
+ rule->table,
+ shared ? "--insert" : "--delete",
+ rule->rule);
+ if (!cmd)
+ continue;
+
+ argv = g_strsplit (cmd, " ", 0);
+ if (argv && argv[0]) {
+ int status;
+ GError *error = NULL;
+
+ nm_info ("Executing: %s", cmd);
+ if (!g_spawn_sync ("/", argv, envp, G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
+ share_child_setup, NULL, NULL, NULL, &status, &error)) {
+ nm_info ("Error executing command: (%d) %s",
+ error ? error->code : -1,
+ (error && error->message) ? error->message : "(unknown)");
+ g_clear_error (&error);
+ } else if (WEXITSTATUS (status))
+ nm_info ("** Command returned exit status %d.", WEXITSTATUS (status));
+ }
g_free (cmd);
-
- if (!g_spawn_sync ("/", argv, envp, G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
- share_child_setup, NULL, NULL, NULL, &status, &error)) {
- nm_info ("Error executing command: (%d) %s",
- error ? error->code : 0, (error && error->message) ? error->message : "unknown");
- if (error)
- g_error_free (error);
- } else if (WEXITSTATUS (status))
- nm_info ("** Command returned exit status %d.", WEXITSTATUS (status));
+ if (argv)
+ g_strfreev (argv);
}
g_slist_free (list);