Commit Graph

165 Commits

Author SHA1 Message Date
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
Dan Winship
6793a32a8c libnm: port to GDBus
Port libnm-core/libnm to GDBus.

The NetworkManager daemon continues to use dbus-glib; the
previously-added connection hash/variant conversion methods are now
moved to NetworkManagerUtils (along with a few other utilities that
are now only needed by the daemon code).
2014-09-18 11:51:09 -04:00
Dan Winship
acf86f68b3 libnm-core: change connection hash tables to variants in API
In preparation for porting to GDBus, make nm_connection_to_dbus(),
etc, represent connections as GVariants of type 'a{sa{sv}}' rather
than as GHashTables-of-GHashTables-of-GValues.

This means we're constantly converting back and forth internally, but
this is just a stepping stone on the way to the full GDBus port, and
all of that code will go away again later.
2014-09-18 11:51:09 -04:00
Dan Winship
8d26c45184 dispatcher: make test-dispatcher-envp not take an argument
Compile srcdir into test-dispatcher-envp rather than passing it on the
command-line, to make it easier to run by hand, and so we can use
automake's TESTS support.
2014-09-18 11:34:21 -04: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
Dan Winship
408e86dd35 dispatcher: trivial code rearrangement
Reorganize some code in preparation for the GDBus port. (Most of the
diff is actually just reindentation.)

This also makes explicit something that was probably a bug;
IP4_NUM_ROUTES is always set, even if it's "0" (while the same is not
true of IP6_NUM_ROUTES). (This behavior is preserved for
compatibility.)
2014-09-18 11:04:26 -04:00
Dan Winship
4fab71b466 callouts: port nm-avahi-autoipd.action to GDBus 2014-09-18 11:04:25 -04:00
Dan Winship
773d3f0ab6 libnm-core: rename NMConnection to/from_hash methods
Rename nm_connection_to_hash() to nm_connection_to_dbus(), and
nm_connection_new_from_hash() to nm_connection_new_from_dbus(). In
addition to clarifying that this is specifically the D-Bus
serialization format, these names will also work better in the
GDBus-based future where the serialization format is GVariant, not
GHashTable.

Also, move NMSettingHashFlags to nm-connection.h, and rename it
NMConnectionSerializationFlags.
2014-09-04 09:17:36 -04:00
Thomas Haller
e1de236db1 build: add configure option not to install udev rules
Previously, user could only change the udev base directory,
but not disabling installation entirely.

Support this now with:
  ./configure --with-udev-dir=no
or
  ./configure --without-udev-dir

Also, just passing '--with-udev-dir' equals '--with-udev-dir=yes'.
Treat 'yes' equal to the default '/lib/udev'.

Also, check that the path is an absolute path starting with a '/'.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-26 19:37:51 +02:00
Thomas Haller
ef32da01fa all: add nm-core-internal.h header
Add a header file to expose private utility functions from libnm-core
that can be used by NetworkManager (core) and libnm.so. The header
is also used to give privileged access to libnm-core. Since NM links
statically, these functions are not exported and not part of public ABI.

This also removes the NM_UTILS_PRIVATE_CALL() macro and libnm.so no
longer exports nm_utils_get_private().

Before, this functionality was partly declared in nm-utils-private.h.
This was wrong because nm-utils-private.h is for functionality
entirely private to libnm-core.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-22 15:22:16 +02:00
Dan Winship
e1ba13a426 libnm-core, libnm, core: make NMConnection an interface
The fact that NMRemoteConnection has to be an NMConnection and
therefore can't be an NMObject means that it needs to reimplement bits
of NMObject functionality (and likewise NMObject needs some special
magic to deal with it). Likewise, we will need a daemon-side
equivalent of NMObject as part of the gdbus port, and we would want
NMSettingsConnection to be able to inherit from this as well.

Solve this problem by making NMConnection into an interface, and
having NMRemoteConnection and NMSettingsConnection implement it. (We
use some hacks to keep the GHashTable of NMSettings objects inside
nm-connection.c rather than having to be implemented by the
implementations.)

Since NMConnection is no longer an instantiable type, this adds
NMSimpleConnection to replace the various non-D-Bus-based uses of
NMConnection throughout the code. nm_connection_new() becomes
nm_simple_connection_new(), nm_connection_new_from_hash() becomes
nm_simple_connection_new_from_hash(), and nm_connection_duplicate()
becomes nm_simple_connection_new_clone().
2014-08-16 10:17:53 -04:00
Dan Winship
c81fb49aa5 all: fix up multiple-include-guard defines
Previously, src/nm-ip4-config.h, libnm/nm-ip4-config.h, and
libnm-glib/nm-ip4-config.h all used "NM_IP4_CONFIG_H" as an include
guard, which meant that nm-test-utils.h could not tell which of them
was being included (and so, eg, if you tried to include
nm-ip4-config.h in a libnm test, it would fail to compile because
nm-test-utils.h was referring to symbols in src/nm-ip4-config.h).

Fix this by changing the include guards in the non-API-stable parts of
the tree:

  - libnm-glib/nm-ip4-config.h remains   NM_IP4_CONFIG_H
  - libnm/nm-ip4-config.h now uses     __NM_IP4_CONFIG_H__
  - src/nm-ip4-config.h now uses       __NETWORKMANAGER_IP4_CONFIG_H__

And likewise for all other headers.

The two non-"nm"-prefixed headers, libnm/NetworkManager.h and
src/NetworkManagerUtils.h are now __NETWORKMANAGER_H__ and
__NETWORKMANAGER_UTILS_H__ respectively, which, while not entirely
consistent with the general scheme, do still mostly make sense in
isolation.
2014-08-16 10:17:14 -04:00
Dan Winship
d0b05b34d5 libnm: add NetworkManager.h, disallow including individual headers
Add NetworkManager.h, which includes all of the other NM header, and
require all external users of libnm to use that rather than the
individual headers.

(An exception is made for nm-dbus-interface.h,
nm-vpn-dbus-interface.h, and nm-version.h, which can be included
separately.)
2014-08-01 14:34:40 -04:00
Dan Winship
3ddce74803 libnm: rename NetworkManager.h and NetworkManagerVPN.h
"NetworkManager.h"'s name (and non-standard capitalization) suggest
that it's some sort of high-level super-important header, but it's
really just low-level D-Bus stuff. Rename it to "nm-dbus-interface.h"
and likewise "NetworkManagerVPN.h" to "nm-vpn-dbus-interface.h"
2014-08-01 14:34:40 -04:00
Dan Winship
f441cf2b90 libnm: consistently use "INTERFACE" rather than "IFACE" in macros
Most D-Bus interface name macros used "INTERFACE" in their name (eg,
NM_DBUS_INTERFACE), but a few used "IFACE" instead (eg,
NM_DBUS_IFACE_SETTINGS). Make them consistent.
2014-08-01 14:34:06 -04:00
Dan Winship
a7c4d53d03 all: port everything to libnm
Since the API has not changed at this point, this is mostly just a
matter of updating Makefiles, and changing references to the library
name in comments.

NetworkManager cannot link to libnm due to the duplicated type/symbol
names. So it links to libnm-core.la directly, which means that
NetworkManager gets a separate copy of that code from libnm.so.
Everything else links to libnm.
2014-08-01 14:34:05 -04:00
Dan Winship
30c74c6007 build: more srcdir!=builddir fixes
nm-version.h was getting disted, making srcdir!=builddir work for
tarball builds, but not for git builds.

Also, remove "-I${top_builddir}/include" from all Makefile.ams, since
there's nothing generated in include/ any more.
2014-07-15 11:37:19 -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
Thomas Haller
fb88ec99f1 build: create dispatcher directories pre-down.d and pre-up.d
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-07 01:17:16 +02: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
Jiří Klimeš
98ae6e06d2 all: g_type_init() has been deprecated in GLib 2.35.0
g_type_init() deprecation:
https://bugzilla.gnome.org/show_bug.cgi?id=686161
2014-05-27 16:58:21 +02:00
Thomas Haller
ab0c37d042 dispatcher/test: fix tests after adding PATH environment variable
These tests were broken by commit 45ed459ae3.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-22 12:24:25 +02:00
Dan Winship
3b197de59f dispatcher: add better debugging
Add LOGD_DISPATCH, and if it's set to DEBUG, tell nm-dispatcher to log
additional information about each script it runs.
2014-04-18 11:33:15 -04:00
Dan Winship
45ed459ae3 dispatcher: Leave PATH set in the dispatcher script environment
https://bugzilla.gnome.org/show_bug.cgi?id=724657
2014-04-18 11:32:13 -04:00
Dan Winship
731ca771f8 dispatcher: only dispatch one request at a time (rh #1061212)
The dispatcher only runs one script at a time for any given request,
but would dispatch multiple requests in parallel. So if a device was
brought up and then back down quickly, it could end up dispatching the
"down" scripts while the "up" scripts were still running. Or if two
devices came up at the same time, two instances of the same "up"
script might run at the same time, which could cause problems if they
both tried to modify the same file.

Fix this by only dispatching the scripts for a single request at a
time.
2014-04-18 11:32:09 -04:00
Dan Winship
d9334503d7 dispatcher: bump script timeout up to 20 seconds (rh #1048345)
The dispatcher would kill scripts after 3 seconds, but on
heavily-loaded machines, that was sometimes too short even for simple
scripts. Bump the timeout up to 20 seconds instead (and change the
10-second quit-on-idle timer to not run when a script is running).

Also change the D-Bus call timeout in the daemon to 30 seconds, so
that it only triggers if something goes really wrong and the action
timeout fails.
2014-04-18 11:29:14 -04:00
Dan Winship
1d0b50c2c4 build: add some missing -DNM_VERSION_MAX_ALLOWED
Add -DNM_VERSION_MAX_ALLOWED=NM_VERSION_NEXT_STABLE to a bunch of
Makefile.ams that were missing it and might eventually need it.
2014-04-07 11:30:18 -04:00