about summary refs log tree commit diff
path: root/dispatcher
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2020-05-08 21:40:53 +0200
committerMichael Biebl <biebl@debian.org>2020-05-08 21:40:53 +0200
commitd460892bbfece74fb6d3cd846bf6ef548290be41 (patch)
tree0474e5be0b5e5fac0d2f3a1e554382e8d1aa6397 /dispatcher
parent1e5977b62f896e844b548c3007ace9e1dfa7f9ed (diff)
New upstream version 1.24.0 upstream/1.24.0
Diffstat (limited to 'dispatcher')
-rw-r--r--dispatcher/nm-dispatcher.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/dispatcher/nm-dispatcher.c b/dispatcher/nm-dispatcher.c
index 27647c1b..e1737d85 100644
--- a/dispatcher/nm-dispatcher.c
+++ b/dispatcher/nm-dispatcher.c
@@ -482,7 +482,7 @@ check_filename (const char *file_name)
 static gboolean
 script_dispatch (ScriptInfo *script)
 {
-	GError *error = NULL;
+	gs_free_error GError *error = NULL;
 	char *argv[4];
 	Request *request = script->request;
 
@@ -491,27 +491,30 @@ script_dispatch (ScriptInfo *script)
 
 	script->dispatched = TRUE;
 
+	/* Only for "hostname" action we coerce the interface name to "none". We don't
+	 * do so for "connectivity-check" action. */
+
 	argv[0] = script->script;
-	argv[1] = request->iface ?: (!strcmp(request->action, NMD_ACTION_HOSTNAME) ? "none" : "");
+	argv[1] =    request->iface
+	          ?: (nm_streq (request->action, NMD_ACTION_HOSTNAME) ? "none" : "");
 	argv[2] = request->action;
 	argv[3] = NULL;
 
 	_LOG_S_T (script, "run script%s", script->wait ? "" : " (no-wait)");
 
-	if (g_spawn_async ("/", argv, request->envp, G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &script->pid, &error)) {
-		script->watch_id = g_child_watch_add (script->pid, (GChildWatchFunc) script_watch_cb, script);
-		script->timeout_id = g_timeout_add_seconds (SCRIPT_TIMEOUT, script_timeout_cb, script);
-		if (!script->wait)
-			request->num_scripts_nowait++;
-		return TRUE;
-	} else {
+	if (!g_spawn_async ("/", argv, request->envp, G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &script->pid, &error)) {
 		_LOG_S_W (script, "complete: failed to execute script: %s", error->message);
 		script->result = DISPATCH_RESULT_EXEC_FAILED;
 		script->error = g_strdup (error->message);
 		request->num_scripts_done++;
-		g_clear_error (&error);
 		return FALSE;
 	}
+
+	script->watch_id = g_child_watch_add (script->pid, (GChildWatchFunc) script_watch_cb, script);
+	script->timeout_id = g_timeout_add_seconds (SCRIPT_TIMEOUT, script_timeout_cb, script);
+	if (!script->wait)
+		request->num_scripts_nowait++;
+	return TRUE;
 }
 
 static gboolean