Commit Graph

29 Commits

Author SHA1 Message Date
Jiří Klimeš
6cd5cc595f dispatcher: fix abort in case of an error (rh #1275813)
request_free() can be called on an error.

Oct 27 20:27:46 localhost.localdomain nm-dispatcher[2328]: #1 'pre-up': completed: invalid request: Missing or invalid required value path!
Oct 27 20:27:46 localhost.localdomain nm-dispatcher[2328]: **
Oct 27 20:27:46 localhost.localdomain nm-dispatcher[2328]: ERROR:nm-dispatcher.c:203:request_free: assertion failed (request->num_scripts_done == request->scripts->len): (0 == 1)

Fixes: 1999723241

https://bugzilla.redhat.com/show_bug.cgi?id=1275813
2015-10-30 14:00:15 +01:00
Thomas Haller
e7685f4304 dispatcher: refactor logging of nm-dispatcher
Refactor logging so that all logging lines for a request/script
have the same prefix, indicating the event to which they belong.

Previously, we only scheduled one script at a time so it was always
clear for which request a script belongs. Now we schedule scripts
in parallel, so we must know the event (request) for which we log
a message.
2015-08-25 15:27:19 +02:00
Thomas Haller
e81ba75949 dispatcher: return error reason from nm_dispatcher_utils_construct_envp()
Also, error out in handle_action() when nm_dispatcher_utils_construct_envp()
indicates a failure.
2015-08-25 15:27:19 +02:00
Thomas Haller
199754a845 dispatcher: remove local @iface variable from handle_action() 2015-08-25 15:27:18 +02:00
Thomas Haller
38fa197bab dispatcher: move clearing @quit_id in handle_action()
First create and initialize @request, and then start it.
2015-08-25 15:27:18 +02:00
Thomas Haller
8143d895ca dispatcher: use slice allocator for Request and ScriptInfo 2015-08-25 15:27:18 +02:00
Thomas Haller
e97a334e37 dispatcher: run "wait" scripts only after "no-wait" scripts complete
Previously, dispatcher would start all "no-wait" script right away,
but it would also start the first "wait" script while the "no-wait"
script are still running (unless, there are other "wait" scripts that
delay the execution).

Now, do not start processing the "wait" scripts, as long as there are
any "no-wait" scripts from the same request running.
2015-08-25 15:27:18 +02:00
Beniamino Galvani
1999723241 nm-dispatcher: allow scripts to be marked as no-wait
When a script is a symbolic link to the 'no-wait.d' subdirectory, the
dispatcher now schedules it immediately and in parallel with other
no-wait scripts.

https://bugzilla.gnome.org/show_bug.cgi?id=746703
2015-08-25 15:27:18 +02:00
Beniamino Galvani
2e2e588cd5 nm-dispatcher: fix memory leaks 2015-08-25 15:27:18 +02:00
Thomas Haller
4c80e322ae dispatcher: explicitly set missing interface argument for device actions
The first argument for dispatcher actions is the interface name, except
for the "hostname" action, where no interface is available.

For "hostname" actions continue to pass "none", as there is no interface
available. But for device actions, it may happen that the interface name
is missing too. In this case, don't pass "none" but instead an empty
name.
2015-08-19 23:36:36 +02:00
Thomas Haller
19c3ea948a all: make use of new header file "nm-default.h" 2015-08-05 15:32:40 +02:00
Dan Winship
3452ee2a0e all: rename nm-glib-compat.h to nm-glib.h, use everywhere
Rather than randomly including one or more of <glib.h>,
<glib-object.h>, and <gio/gio.h> everywhere (and forgetting to include
"nm-glib-compat.h" most of the time), rename nm-glib-compat.h to
nm-glib.h, include <gio/gio.h> from there, and then change all .c
files in NM to include "nm-glib.h" rather than including the glib
headers directly.

(Public headers files still have to include the real glib headers,
since nm-glib.h isn't installed...)

Also, remove glib includes from header files that are already
including a base object header file (which must itself already include
the glib headers).
2015-07-24 13:25:47 -04:00
Thomas Haller
904e961464 all: remove #if GLIB_CHECK_VERSION conditionals around g_type_init()
g_type_init() is now provided by nm-glib-compat.h as nm_g_type_init().
2015-07-12 13:56:52 +02:00
Thomas Haller
8fdf198632 dispatcher: don't exit with failure in case D-Bus service stops
The initsystem should stop nm-dispatcher before stopping D-Bus
service. However, on some systems that is not implemented, so
nm-dispatcher should not exit with a failure message when the
system bus disappears.
Instead just assume that D-Bus service was stopped during shutdown
and exit gracefully.

Based-on-patch-by: Jacob <jacobgodserv@gmail.com>

https://bugzilla.gnome.org/show_bug.cgi?id=751017
2015-07-01 17:13:52 +02:00
Thomas Haller
22bfe2feb2 dispatcher: repeat waitpid() call on EINTR
Also, no use of first trying to kill() with signal zero. Just
send SIGKILL right away.
2015-05-05 16:39:18 +02:00
Dan Winship
c22e3f327a core, dispatcher: drop unnecessary setpgid() calls
There's no point in calling setpgid() on short-lived processes, so
remove the setpgid() calls when spawning dispatcher scripts, iptables,
iscsiadmin, and netconf.
2015-01-19 11:29:13 -05:00
Jiří Klimeš
28599331e3 callout: ignore waitpid() return value
Coverity:
Defect type: CHECKED_RETURN
2014-12-05 09:38:40 +01:00
Dan Winship
3bfb163a74 all: consistently include config.h
config.h should be included from every .c file, and it should be
included before any other include. Fix that.

(As a side effect of how I did this, this also changes us to
consistently use "config.h" rather than <config.h>. To the extent that
it matters [which is not much], quotes are more correct anyway, since
we're talking about a file in our own build tree, not a system
include.)
2014-11-13 17:18:42 -05:00
Jiří Klimeš
4ad7cda7a4 dispatcher: fix crash on missing scripts (bgo #738654)
GLib-CRITICAL **: g_variant_type_checked_: assertion `g_variant_type_string_is_valid (type_string)' failed
GLib-CRITICAL **: g_variant_new_array: assertion `n_children > 0 || child_type != NULL' failed

https://bugzilla.gnome.org/show_bug.cgi?id=738654
2014-10-21 08:57:02 +02:00
Dan Winship
1a5cfc1f45 dispatcher: port to GDBus
Port nm-dispatcher to GDBus, mostly, using dbus-glib's GVariant
utilities to translate the return value of nm_connection_to_dbus().
2014-09-18 11:26:59 -04:00
Thomas Haller
02747203c6 dispatcher: silence warning about sub-directories in dispatcher directory
Especially now that we have the 'pre-up.d/' and 'pre-down.d/' directories,
silently skip over any sub directories inside the dispatcher directory.

Fixes warning:
  nm-dispatcher: Cannot execute '/etc/NetworkManager/dispatcher.d/pre-up.d': not a regular file.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-17 19:15:31 +02:00
Thomas Haller
589272facf dispatcher: fix leak in callouts/nm-dispatcher
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-17 19:09:56 +02:00
Thomas Haller
c8e7953333 dispatcher/trivial: rename variables for script directory to NMD_SCRIPT_DIR_* 2014-06-16 19:18:57 +02:00
Dan Williams
33e5e1c500 dispatcher: don't warn on non-critical missing directory error 2014-06-06 18:28:03 -05:00
Dan Williams
02252224e2 dispatcher: bump overall timeout to 10 minutes (rh #982734) (rh #1048345)
Since NM now handles long-running dispatcher scripts better, allow them
to run for really long times.
2014-06-06 13:43:47 -05:00
Dan Williams
fd5761ecb2 dispatcher: don't use NULL error domains
glib doesn't like it, plus we don't use the error anyway, so just
return the constant error string.
2014-06-06 13:43:47 -05:00
Dan Williams
1383f4bc14 dispatcher: use separate directories for pre-up/pre-down events
To ensure that NetworkManager does not block needlessly for events
which have no scripts, require scripts that respond to blocking
events to opt into the action.
2014-06-06 13:43:46 -05:00
Dan Williams
5150cb88c2 dispatcher: only dispatch if scripts exist
If there are no dispatcher scripts, don't bother dispatching any
events.  This saves some time configuring networking if the event
would have no effect anyway.
2014-06-06 13:43:45 -05:00
Dan Williams
4cc13befd3 dispatcher: rename executable to 'nm-dispatcher' 2014-06-06 13:43:45 -05:00