dispatcher: merge branch 'th/dispatcher-doc-connectivity-change-arg'

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/485
This commit is contained in:
Thomas Haller 2020-04-30 21:51:49 +02:00
commit 2a319c5dbb
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
2 changed files with 15 additions and 12 deletions

View file

@ -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

View file

@ -80,8 +80,8 @@
device an operation just happened on, and second the action. For device actions,
the interface is the name of the kernel interface suitable for IP configuration.
Thus it is either VPN_IP_IFACE, DEVICE_IP_IFACE, or DEVICE_IFACE, as applicable.
For the <varname>hostname</varname> and <varname>connectivity-change</varname>
actions it is always "none".
For the <varname>hostname</varname> action the device name is always <literal>"none"</literal>
and for <varname>connectivity-change</varname> it is empty.
</para>
<para>The actions are:</para>
<variablelist class="dispatcher-options">