diff options
| author | Sebastien Bacher <seb128@ubuntu.com> | 2020-05-19 16:38:36 +0200 |
|---|---|---|
| committer | Sebastien Bacher <seb128@ubuntu.com> | 2020-05-19 17:09:07 +0200 |
| commit | ccf6dc06bbee82c3d49f451545c5317337e0777e (patch) | |
| tree | a8fddc8c6e2b3b99bebab1d5bb2a64581eff4bfd /dispatcher | |
| parent | f109e55ef130ce84054d5ba3acf4b71cd8c7564a (diff) | |
| parent | 7ffed1e6136de75188f10ba8763bcb942f932f8e (diff) | |
Merge remote-tracking branch 'salsa/debian/master' into ubuntu/master
Diffstat (limited to 'dispatcher')
| -rw-r--r-- | dispatcher/meson.build | 3 | ||||
| -rw-r--r-- | dispatcher/nm-dispatcher.c | 27 | ||||
| -rw-r--r-- | dispatcher/tests/meson.build | 2 |
3 files changed, 20 insertions, 12 deletions
diff --git a/dispatcher/meson.build b/dispatcher/meson.build index 7feb9597..9a691082 100644 --- a/dispatcher/meson.build +++ b/dispatcher/meson.build @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: LGPL-2.1+ + dispatcher_inc = include_directories('.') name = 'nm-dispatcher' @@ -17,6 +19,7 @@ install_data( deps = [ libnm_dep, libnm_nm_default_dep, + libnm_libnm_aux_dep, ] c_flags = [ diff --git a/dispatcher/nm-dispatcher.c b/dispatcher/nm-dispatcher.c index c38ea00f..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 @@ -598,7 +601,7 @@ find_scripts (Request *request) else subdir = NULL; - scripts = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); + scripts = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_free); _find_scripts (request, scripts, NMLIBDIR, subdir); _find_scripts (request, scripts, NMCONFDIR, subdir); @@ -1090,7 +1093,7 @@ done: nm_clear_g_source (&signal_id_term); nm_clear_g_source (&signal_id_int); nm_clear_g_source (&gl.quit_id); - g_clear_pointer (&gl.loop, g_main_loop_unref); + nm_clear_pointer (&gl.loop, g_main_loop_unref); g_clear_object (&gl.dbus_connection); if (!gl.debug) diff --git a/dispatcher/tests/meson.build b/dispatcher/tests/meson.build index 83c915e5..5c6f6b12 100644 --- a/dispatcher/tests/meson.build +++ b/dispatcher/tests/meson.build @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: LGPL-2.1+ + test_unit = 'test-dispatcher-envp' deps = [ |