Commit Graph

148 Commits

Author SHA1 Message Date
Thomas Haller
db80ec05ab build: rename directory "include" to "shared"
Up to now, the "include" directory contained (only) header files that were
used project-wide by libs, core, clients, et al.

Since the directory now also contains a non-header file, the "include"
name is misleading. Instead of adding yet another directory that is
project-wide, with non-header-only content, rename the "include"
directory to "shared".
2015-12-24 11:42:37 +01:00
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
7bf10a75db build: extract version macros from "nm-version.h" to new header file "nm-version-macros.h"
For libnm library, "nm-dbus-interface.h" contains defines like the D-Bus
paths of NetworkManager. It is desirable to have this header usable without
having a dependency on "glib.h", for example for a QT application. For that,
commit c0852964a8 removed that dependancy.

For libnm-glib library, the analog to "nm-dbus-interface.h" is
"NetworkManager.h", and the same applies there. Commit
159e827a72 removed that include.
However, that broke build on PackageKit [1] which expected to get the
version macros by including "NetworkManager.h". So at least for libnm-glib,
we need to preserve old behavior so that a user including
"NetworkManager.h" gets the version macros, but not "glib.h".

Extract the version macros to a new header file "nm-version-macros.h".
This header doesn't include "glib.h" and can be included from
"NetworkManager.h". This gives as previous behavior and a glib-free
include.

For libnm we still don't include "nm-version-macros.h" to "nm-dbus-interface.h".
Very few users will actually need the version macros, but not using
libnm.
Users that use libnm, should just include (libnm's) "NetworkManager.h" to
get all headers.
As a special case, a user who doesn't want to use glib/libnm, but still
needs both "nm-dbus-interface.h" and "nm-version-macros.h", can include
them both separately.

[1] https://github.com/hughsie/PackageKit/issues/85

Fixes: 4545a7fe96
2015-09-30 23:10:29 +02:00
Lubomir Rintel
ded65c7168 test: fix a format-security error
test-dispatcher-envp.c: In function 'test_generic':
test-dispatcher-envp.c:507:3: error: format not a string literal and no format arguments [-Werror=format-security]
2015-08-26 10:57:09 +02: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
Dan Winship
1cf35cb26b core: final gdbus porting
Port remaining bits to gdbus and remove stray dbus-glib references

Drop the dbus-glib version check from configure, since nothing depends
on new dbus-glib any more.

Move nm-dbus-glib-types.h and nm-gvaluearray-compat.h from include/ to
libnm-util/ since they are now only used by libnm-util and libnm-glib.
2015-08-10 09:41:26 -04: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
Lubomir Rintel
a9996c4f1d vpn-plugin-old,dispatcher: cast unchecked g_variant_lookup() calls to void
This is done to silence coverity. In the dispatcher the existence of the
key is checked before and we're fine with leaving the value untouched
in the vpn-plugin-old.
2015-07-14 13:18:07 +02: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
7a3ab5c02f test: initialize tests with nmtst_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
Lubomir Rintel
c47c06470a builds: only enable TAP driver for glib >= 2.37.6
No TAP support for previous versions and --tap argument is silently ignored,
confusing the TAP driver.
2015-05-28 12:51:24 +02:00
Lubomir Rintel
6463ce5dd9 tests: use the TAP formatter
The test results in standard format are easily integrated into CI systems.
2015-05-26 13:51:45 +02:00
Beniamino Galvani
3376952ef9 callouts: avahi-autoipd-action is no more 2015-05-11 10:48:48 +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
7b17faaa3f dispatcher: belatedly remove no-longer-used dbus-glib define 2015-04-04 08:23:48 -04:00
Lubomir Rintel
ceea3c6782 data: move OLPC MESH udev rules away from callouts
No idea why was it there in the first place.

This also fixes a bug that the rules file was conditionally included in dist
depending on presence of udev dir at configure time.
2015-03-23 15:13:02 +01:00
Dan Williams
acd6226e8a dispatcher: fix memleak in construct_device_dhcp4_items()
When iterating over a container variant, the children values
must be unrefed when no longer used.
2015-03-12 13:24:32 -05:00
Thomas Haller
c50f30e79c tests: enable valgrind tests for tests 2015-02-09 11:51:07 +01:00
Thomas Haller
1ba16f44cf callouts/tests: fix memleak in test code for valgrind 2015-02-09 11:51:06 +01:00
Thomas Haller
14040b1cea callouts/tests: fix parsing dhcp in get_dispatcher_file() 2015-02-06 12:58:22 +01: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
Dan Winship
849ae9eed6 dispatcher: add an env var indicating a connection is "external"
Add CONNECTION_EXTERNAL=1 to the environment when dispatching actions
on a "generated-assumed" connection (ie, one that was created outside
of NM).
2015-01-19 11:19:33 -05:00
Dan Winship
995da9a5a6 dispatcher: expose connection D-Bus path
src/nm-dispatcher.c was passing the connection's D-Bus path to the
dispatcher, which was then ignoring it. Meanwhile,
test-dispatcher-envp was passing a fake D-Bus path with the wrong name
(which didn't actually matter since
nm_dispatcher_utils_construct_envp() ignored it anyway).

Fix it so that the path gets exposed as CONNECTION_DBUS_PATH, and
adjust the tests for that.
2015-01-19 11:17:37 -05:00
Dan Winship
9cfd9d376f dispatcher: remove "old" from the test names
There's no reason the dispatcher test files should have "old" in their
names, since they're testing the current dispatcher interface.
2015-01-19 11:09:26 -05:00
Dan Winship
bd2deace70 dispatcher: pass CONNECTION_FILENAME to dispatcher scripts 2015-01-12 09:53:21 -05:00
Thomas Haller
37361a038f dispatcher: refactor constructing environment variables from strv
This also avoids warnings with -O2 -Wstrict-overflow (gcc-4.8.3):

    make[4]: Entering directory `./NetworkManager/callouts'
      CC       libtest_dispatcher_envp_la-nm-dispatcher-utils.lo
    nm-dispatcher-utils.c: In function 'construct_ip6_items':
    nm-dispatcher-utils.c:283:8: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
         if (i != 0)
            ^
    nm-dispatcher-utils.c: In function 'construct_ip4_items':
    nm-dispatcher-utils.c:144:8: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
         if (i != 0)
            ^
    nm-dispatcher-utils.c:168:8: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
         if (i != 0)
            ^

https://bugzilla.gnome.org/show_bug.cgi?id=741168
2014-12-08 19:14:31 +01:00
Jiří Klimeš
28599331e3 callout: ignore waitpid() return value
Coverity:
Defect type: CHECKED_RETURN
2014-12-05 09:38:40 +01:00
Lubomir Rintel
01ca15993b dispatcher: Fix tests
IP4_GATEWAY variable was added to the environment.

Fixes: 9a13378753
2014-11-20 11:59:56 +01:00
Jiří Klimeš
9a13378753 dispatcher: introduce new env variables for gateway address (bgo #740363)
IP4_GATEWAY
VPN_IP4_GATEWAY
IP6_GATEWAY
VPN_IP6_GATEWAY

We still put gateway into IP[46]_ADDRESS_N for backward compatibility.

https://bugzilla.gnome.org/show_bug.cgi?id=740363
2014-11-19 16:52:25 +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
Dan Winship
e374923bbe all: allow route metrics to be "0"
Change NMIPRoute to use "-1" for "default", so that "0" is a valid
metric. Update everything for that.
2014-11-07 07:49:41 -05:00
Dan Winship
f17699f4e3 libnm-core: add NMSettingIPConfig:gateway, drop NMIPAddress:gateway
The gateway is a global property of the IPv4/IPv6 configuration, not
an attribute of any particular address. So represent it as such in the
API; remove the gateway from NMIPAddress, and add it to
NMSettingIPConfig.

Behind the scenes, the gateway is still serialized along with the
first address in NMSettingIPConfig:addresses, and is deserialized from
that if the settings dictionary doesn't contain a 'gateway' key.

Adjust nmcli's interactive mode to prompt for IP addresses and gateway
separately. (Patch partly from Jirka Klimeš.)
2014-11-07 07:49:40 -05:00
Dan Winship
21c8a6b20e libnm-core, all: merge IPv4 and IPv6 address/route types
Merge NMIP4Address and NMIP6Address into NMIPAddress, and NMIP4Route
and NMIP6Route into NMIPRoute. The new types represent IP addresses as
strings, rather than in binary, and so are address-family agnostic.
2014-11-07 07:49:40 -05:00
Lubomir Rintel
48b4f6f830 Merge branch 'lr/rpm-make-check'
https://bugzilla.gnome.org/show_bug.cgi?id=739127
2014-10-30 14:40:47 +01:00
Colin Walters
6d1912ff2e callouts: Mark nmdbus-dispatcher.[ch] as BUILT_SOURCES
Otherwise we might hit race conditions during build.
2014-10-28 17:50:24 -04:00
Dan Winship
b108790833 libnm-core: add nm-core-types.h, remove cross-includes
Add nm-core-types.h, typedefing all of the GObject types in
libnm-core; this is needed so that nm-setting.h can reference
NMConnection in addition to nm-connection.h referencing NMSetting.

Removing the cross-includes from the various headers causes lots of
fallout elsewhere. (In particular, nm-utils.h used to include
nm-connection.h, which included every setting header, so any file that
included nm-utils.h automatically got most of the rest of libnm-core
without needing to pay attention to specifics.) Fix this up by
including nm-core-internal.h from those files that are now missing
includes.
2014-10-28 17:17:17 -04:00
Dan Winship
dc46e2c67b build: fix srcdir != builddir
callouts/tests/ needs -I$(top_builddir)/callouts to get
nmdbus-dispatcher.h
2014-10-24 14:41:19 -04: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
Lubomir Rintel
72cafb8ca3 build: Don't conditionally omit files from distribution 2014-10-20 18:24:55 +02:00
Lubomir Rintel
44c34a7adc build: Don't leak generated files into distribution
gdbus-codegen will generate code that will need a too recent version of glib.
2014-10-20 11:53:43 +02:00