NetworkManager.git
8 years agocli: process slave parameters after the rest of the settings are set up
Lubomir Rintel [Tue, 21 Apr 2015 14:53:36 +0000 (16:53 +0200)]
cli: process slave parameters after the rest of the settings are set up

This separates setup of the master & slave type and addition of the wired
settings for "bond-slave", "bridge-slave" and "team-slave" connection types
from processing of slave type specific options.

A follow-up commit will make it possible to specify master (and slave type) for
any connection, not relying on "-slave" types.

8 years agomerge branch 'th/misc-bgo752087'
Thomas Haller [Sun, 12 Jul 2015 12:02:11 +0000 (14:02 +0200)]
merge branch 'th/misc-bgo752087'

https://bugzilla.gnome.org/show_bug.cgi?id=752087

8 years agocore: print connection path in nm_utils_log_connection_diff()
Thomas Haller [Fri, 3 Jul 2015 10:23:57 +0000 (12:23 +0200)]
core: print connection path in nm_utils_log_connection_diff()

8 years agosettings: use _LOG() macros in "nm-settings-connection.c"
Thomas Haller [Fri, 3 Jul 2015 09:49:43 +0000 (11:49 +0200)]
settings: use _LOG() macros in "nm-settings-connection.c"

8 years agolibnm-core: don't assert in nm_connection_get_uuid() for valid connection
Thomas Haller [Fri, 3 Jul 2015 10:11:57 +0000 (12:11 +0200)]
libnm-core: don't assert in nm_connection_get_uuid() for valid connection

We want to call nm_connection_get_uuid() also on connections that don't verify.
Otherwise it is chumbersome to check first for verified connection.

8 years agosettings: add _LOG() macros to "nm-settings-connection.h"
Thomas Haller [Fri, 3 Jul 2015 09:47:53 +0000 (11:47 +0200)]
settings: add _LOG() macros to "nm-settings-connection.h"

8 years agosettings/trivial: consistently name @self argument in NMSettingsConnection
Thomas Haller [Fri, 3 Jul 2015 09:41:15 +0000 (11:41 +0200)]
settings/trivial: consistently name @self argument in NMSettingsConnection

8 years agosettings: refactor logging statement in nm_settings_connection_get_secrets()
Thomas Haller [Fri, 3 Jul 2015 09:30:26 +0000 (11:30 +0200)]
settings: refactor logging statement in nm_settings_connection_get_secrets()

8 years agoplatform: assert for valid ifname in ethtool_get()
Thomas Haller [Fri, 3 Jul 2015 07:53:34 +0000 (09:53 +0200)]
platform: assert for valid ifname in ethtool_get()

Add an assert (g_return_val_if_reached()) that the interface name is
valid and shorter then 16 bytes. If it happened to be longer, strncpy()
would not have zero terminated the interface name.

8 years agoall: remove #if GLIB_CHECK_VERSION conditionals around g_type_init()
Thomas Haller [Thu, 10 Jul 2014 08:41:31 +0000 (10:41 +0200)]
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().

8 years agocore: add glib compatibility wrapper nm_g_type_init() for g_type_init()
Thomas Haller [Thu, 10 Jul 2014 08:41:31 +0000 (10:41 +0200)]
core: add glib compatibility wrapper nm_g_type_init() for g_type_init()

8 years agoiface-helper: remove redundant g_type_init() call
Thomas Haller [Fri, 3 Jul 2015 13:18:26 +0000 (15:18 +0200)]
iface-helper: remove redundant g_type_init() call

8 years agotest: initialize tests with nmtst_init()
Thomas Haller [Fri, 3 Jul 2015 13:11:17 +0000 (15:11 +0200)]
test: initialize tests with nmtst_init()

8 years agoplatform: fix wrapper nm_platform_addr_flags2str() for rtnl_addr_flags2str()
Thomas Haller [Fri, 14 Mar 2014 13:46:26 +0000 (14:46 +0100)]
platform: fix wrapper nm_platform_addr_flags2str() for rtnl_addr_flags2str()

The compatibily wrapper for rtnl_addr_flags2str() did not
behave identical because libnl adds a trailing ',' if it
encounters unknown attributes.

Also add test cases.

8 years agoplatform: don't allocate string for flags in nm_platform_ip6_address_to_string()
Thomas Haller [Fri, 3 Jul 2015 14:13:35 +0000 (16:13 +0200)]
platform: don't allocate string for flags in nm_platform_ip6_address_to_string()

8 years agonmtst: add function nmtst_assert_str_has_substr()
Thomas Haller [Mon, 14 Apr 2014 10:03:19 +0000 (12:03 +0200)]
nmtst: add function nmtst_assert_str_has_substr()

8 years agoclients: fix bad array loop in nm-secret-agent-simple.c:strv_has (bgo #752137)
Jiří Klimeš [Fri, 10 Jul 2015 10:35:55 +0000 (12:35 +0200)]
clients: fix bad array loop in nm-secret-agent-simple.c:strv_has (bgo #752137)

https://bugzilla.gnome.org/show_bug.cgi?id=752137

8 years agopo: update Polish (pl) translation (bgo #751998)
Piotr Drąg [Sun, 5 Jul 2015 22:21:44 +0000 (00:21 +0200)]
po: update Polish (pl) translation (bgo #751998)

https://bugzilla.gnome.org/show_bug.cgi?id=751998

8 years agodevice: fix regression for ignored search domains in ip._config_merge_and_apply()
Thomas Haller [Thu, 9 Jul 2015 21:13:10 +0000 (23:13 +0200)]
device: fix regression for ignored search domains in ip._config_merge_and_apply()

Reported-by: Fabrice Bellet <fabrice@bellet.info>
Fixes: 79630c11e502c3b0b958abc0b1b5d777a3db2a98

https://bugzilla.gnome.org/show_bug.cgi?id=752193

8 years agocontrib/rpm: always drag in bluez-libs-devel
Lubomir Rintel [Thu, 9 Jul 2015 15:16:38 +0000 (17:16 +0200)]
contrib/rpm: always drag in bluez-libs-devel

We don't really know which version it's going to be -- and thus if we're going
to actually need it (version 5), or not (version 4). It's going to be decided
at configure time.

Also, drop the bogus Fedora 19 conditionals; Fedora < 20 has ModemManager that's
too old for the WWAN code anyway.

8 years agobluetooth: avoid an assertion failure if built w/o bluez5 support
Lubomir Rintel [Thu, 9 Jul 2015 15:18:50 +0000 (17:18 +0200)]
bluetooth: avoid an assertion failure if built w/o bluez5 support

Fail with a proper error if we built without Bluez 5 support, but detect it at
runtime.

8 years agosystemd: fix compiler warning about uninitialized variable
Thomas Haller [Thu, 9 Jul 2015 14:12:31 +0000 (16:12 +0200)]
systemd: fix compiler warning about uninitialized variable

  make[4]: Entering directory './NetworkManager/src'
    CC       libsystemd_nm_la-util.lo
  systemd/src/basic/util.c: In function 'cunescape_length_with_prefix':
  systemd/src/basic/util.c:1271:30: error: 'u' may be used uninitialized in this function [-Werror=maybe-uninitialized]
                           t += utf8_encode_unichar(t, u);
                                ^
  systemd/src/basic/util.c:1230:26: note: 'u' was declared here
                   uint32_t u;
                            ^

8 years agosystemd: merge branch 'systemd'
Beniamino Galvani [Sun, 5 Jul 2015 10:04:21 +0000 (12:04 +0200)]
systemd: merge branch 'systemd'

8 years agosupplicant: allow with_system_ca_path to be a file name (rh #1236548)
Jiří Klimeš [Wed, 1 Jul 2015 12:11:12 +0000 (14:11 +0200)]
supplicant: allow with_system_ca_path to be a file name (rh #1236548)

NetworkManager uses wpa_supplicant, which in turn calls OpenSSL for verifying
certificates. wpa_supplicant calls
SSL_CTX_load_verify_locations(ctx, CAfile, CApath)
using its ca_cert and ca_path options as CAfile and CApath parameters.

We have a configure time option with_system_ca_path to override ca_path.
However, it doesn't work when a system (like Fedora) only uses bundled PEM
certificates instead of a directory with hashed certificates ([1], [2]).

So this commit allows setting --with_system_ca_path to a file name (the
trusted certificate bundle). Then the name is used to populate wpa_supplicant's
ca_cert instead of ca_path.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1053882
[2] https://www.happyassassin.net/2015/01/12/a-note-about-ssltls-trusted-certificate-stores-and-platforms/

https://bugzilla.redhat.com/show_bug.cgi?id=1236548

8 years agoutils: fix error logging in ASSERT_VALID_PATH_COMPONENT()
Jiří Klimeš [Fri, 12 Jun 2015 19:46:46 +0000 (21:46 +0200)]
utils: fix error logging in ASSERT_VALID_PATH_COMPONENT()

8 years agodevice: use NULL instead of 0 in g_return_val_if_fail() for pointer
Jiří Klimeš [Wed, 8 Jul 2015 14:49:19 +0000 (16:49 +0200)]
device: use NULL instead of 0 in g_return_val_if_fail() for pointer

8 years agodevice: trivial: fix a copy/paste error in comment
Jiří Klimeš [Wed, 27 May 2015 09:20:31 +0000 (11:20 +0200)]
device: trivial: fix a copy/paste error in comment

8 years agoexamples: add python+dbus example to print active access point
Dan Williams [Wed, 8 Jul 2015 14:29:59 +0000 (09:29 -0500)]
examples: add python+dbus example to print active access point

8 years agoroute-manager: restore shadowed gateway routes after direct routes
Thomas Haller [Wed, 8 Jul 2015 09:42:54 +0000 (11:42 +0200)]
route-manager: restore shadowed gateway routes after direct routes

8 years agodevice: just get ip_iface in the place where it is needed
Jiří Klimeš [Tue, 7 Jul 2015 14:04:09 +0000 (16:04 +0200)]
device: just get ip_iface in the place where it is needed

priv->iface could change in device_link_changed() which reacts on platform link
changes caused by nm_platform_link_set_user_ipv6ll_enabled(). (The variable could
change between obtaining and using its value, because emitting a glib signal runs
callbacks synchronously).

Actually, the problem is already fixed by commit 04caae735fabe00e19a05d49e065514114b59d40.
But still this is better.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1224366

8 years agoroute-manager/trivial: move code
Thomas Haller [Tue, 7 Jul 2015 15:26:54 +0000 (17:26 +0200)]
route-manager/trivial: move code

Have related functions closer together.

Fixes: 635eea60cfb340cbefec67732467f9075e7dc6c2

8 years agosettings: get_plugin() should return plugin that has all requested capabilities
Thomas Haller [Tue, 7 Jul 2015 14:54:05 +0000 (16:54 +0200)]
settings: get_plugin() should return plugin that has all requested capabilities

This bug had no real consequences because we only called
get_plugin() with one capability at a time.

8 years agoroute-manager: merge branch 'th/direct-route-conflict-bgo752062'
Thomas Haller [Tue, 7 Jul 2015 14:28:09 +0000 (16:28 +0200)]
route-manager: merge branch 'th/direct-route-conflict-bgo752062'

https://bugzilla.gnome.org/show_bug.cgi?id=752062

8 years agoroute-manager: always add conflicting direct routes and bump the route-metric if...
Thomas Haller [Sun, 5 Jul 2015 08:04:03 +0000 (10:04 +0200)]
route-manager: always add conflicting direct routes and bump the route-metric if necessary

Kernel does not allow to add the same route (as determined by network/plen,metric)
on two different interfaces (ifindex). In case of conflict, NMRouteManager used to
ignore any but the firstly added route.

On the other hand, we cannot add a gateway-route, if there is no direct
route to the gateway. Hence, skipping duplicate routes can mean that we
skip a direct route what was necessary to add another gateway-route,
which then leads to a failure to add that route.

This also applies to IPv4 device routes that since recently are managed
by NMRouteManager.

For example, say you connect two interfaces to the same IP subnet.
The route-metric can conflict if the interfaces are of the same type
or if the user explicitly configured a conflict.
In case of conflicts, NMRouteManager would only configure the first
appearing route and skip the shadowed route on the second interface.
Now we cannot configure gateway-routes on the second interface because
the gateway is unreachable.

There are many scenarios where this issue can happen, especially with
default-routes and user-configured-routes.
For example with default-routes, ip4_config_merge_and_apply() would check
if the default-gateway requires an explict route and possibly add it.
But then NMRouteManager might not add the route because it is shadowed
by a route on an other interface.

This patch solves the issue by having NMRouteManager configure shadowed
routes too, similar to what NMDefaultRouteManager does.
It does that by searching for an unused, non-conflicting, higher metric
for the route, i.e. bump the metric by 1 until we can add it without
conflict.

Also note that NMRouteManager still ensures that for conflicting routes
the best route sticks to the interface that configured it first. That
means if you later add the conflicting route on another interface, it
will be added with higher metric and the data is still routed along the
first interface.

8 years agoroute-manager: add optional @r2_metric argument to _route_equals_ignoring_ifindex()
Thomas Haller [Sun, 5 Jul 2015 16:04:08 +0000 (18:04 +0200)]
route-manager: add optional @r2_metric argument to _route_equals_ignoring_ifindex()

8 years agoplatform: add optional @metric argument to route_add() function
Thomas Haller [Sun, 5 Jul 2015 11:25:49 +0000 (13:25 +0200)]
platform: add optional @metric argument to route_add() function

Allow overwriting the route metric.

8 years agoroute-manager: add compare function for route-destination
Thomas Haller [Sun, 5 Jul 2015 09:42:59 +0000 (11:42 +0200)]
route-manager: add compare function for route-destination

8 years agoroute-manager: fix trace logging statement
Thomas Haller [Sun, 5 Jul 2015 10:32:37 +0000 (12:32 +0200)]
route-manager: fix trace logging statement

8 years agosystemd: update code from upstream
Beniamino Galvani [Sun, 5 Jul 2015 07:47:12 +0000 (09:47 +0200)]
systemd: update code from upstream

This is a direct dump from systemd git on 2015-07-03, git commit
2812dcba8543.

SYSTEMD_DIR=../systemd
COMMIT=2812dcba85435c59203268ab54901a72c6c24a69

(
cd "$SYSTEMD_DIR"
git checkout "$COMMIT"
git reset --hard
git clean -fdx
)

git ls-files :/src/systemd/src/ | xargs -d '\n' rm -f
mkdir src/systemd/src/basic

cp "$SYSTEMD_DIR"/src/libsystemd/sd-id128/sd-id128.c ./src/systemd/src/libsystemd/sd-id128/sd-id128.c
cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-identifier.c ./src/systemd/src/libsystemd-network/dhcp-identifier.c
cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-identifier.h ./src/systemd/src/libsystemd-network/dhcp-identifier.h
cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-internal.h ./src/systemd/src/libsystemd-network/dhcp-internal.h
cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-lease-internal.h ./src/systemd/src/libsystemd-network/dhcp-lease-internal.h
cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-network.c ./src/systemd/src/libsystemd-network/dhcp-network.c
cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-option.c ./src/systemd/src/libsystemd-network/dhcp-option.c
cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-packet.c ./src/systemd/src/libsystemd-network/dhcp-packet.c
cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-protocol.h ./src/systemd/src/libsystemd-network/dhcp-protocol.h
cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp6-internal.h ./src/systemd/src/libsystemd-network/dhcp6-internal.h
cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp6-lease-internal.h ./src/systemd/src/libsystemd-network/dhcp6-lease-internal.h
cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp6-network.c ./src/systemd/src/libsystemd-network/dhcp6-network.c
cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp6-option.c ./src/systemd/src/libsystemd-network/dhcp6-option.c
cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp6-protocol.h ./src/systemd/src/libsystemd-network/dhcp6-protocol.h
cp "$SYSTEMD_DIR"/src/libsystemd-network/network-internal.c ./src/systemd/src/libsystemd-network/network-internal.c
cp "$SYSTEMD_DIR"/src/libsystemd-network/network-internal.h ./src/systemd/src/libsystemd-network/network-internal.h
cp "$SYSTEMD_DIR"/src/libsystemd-network/sd-dhcp-client.c ./src/systemd/src/libsystemd-network/sd-dhcp-client.c
cp "$SYSTEMD_DIR"/src/libsystemd-network/sd-dhcp-lease.c ./src/systemd/src/libsystemd-network/sd-dhcp-lease.c
cp "$SYSTEMD_DIR"/src/libsystemd-network/sd-dhcp6-client.c ./src/systemd/src/libsystemd-network/sd-dhcp6-client.c
cp "$SYSTEMD_DIR"/src/libsystemd-network/sd-dhcp6-lease.c ./src/systemd/src/libsystemd-network/sd-dhcp6-lease.c
cp "$SYSTEMD_DIR"/src/libsystemd-network/ipv4ll-internal.h ./src/systemd/src/libsystemd-network/ipv4ll-internal.h
cp "$SYSTEMD_DIR"/src/libsystemd-network/ipv4ll-internal.h ./src/systemd/src/libsystemd-network/ipv4ll-internal.h
cp "$SYSTEMD_DIR"/src/libsystemd-network/ipv4ll-network.c ./src/systemd/src/libsystemd-network/ipv4ll-network.c
cp "$SYSTEMD_DIR"/src/libsystemd-network//ipv4ll-packet.c ./src/systemd/src/libsystemd-network//ipv4ll-packet.c
cp "$SYSTEMD_DIR"/src/libsystemd-network/sd-ipv4ll.c ./src/systemd/src/libsystemd-network/sd-ipv4ll.c
cp "$SYSTEMD_DIR"/src/basic/async.h ./src/systemd/src/basic/async.h
cp "$SYSTEMD_DIR"/src/basic/fileio.c ./src/systemd/src/basic/fileio.c
cp "$SYSTEMD_DIR"/src/basic/fileio.h ./src/systemd/src/basic/fileio.h
cp "$SYSTEMD_DIR"/src/basic/list.h ./src/systemd/src/basic/list.h
cp "$SYSTEMD_DIR"/src/basic/log.h ./src/systemd/src/basic/log.h
cp "$SYSTEMD_DIR"/src/basic/macro.h ./src/systemd/src/basic/macro.h
cp "$SYSTEMD_DIR"/src/basic/path-util.c ./src/systemd/src/basic/path-util.c
cp "$SYSTEMD_DIR"/src/basic/path-util.h ./src/systemd/src/basic/path-util.h
cp "$SYSTEMD_DIR"/src/basic/refcnt.h ./src/systemd/src/basic/refcnt.h
cp "$SYSTEMD_DIR"/src/basic/siphash24.c ./src/systemd/src/basic/siphash24.c
cp "$SYSTEMD_DIR"/src/basic/siphash24.h ./src/systemd/src/basic/siphash24.h
cp "$SYSTEMD_DIR"/src/basic/socket-util.h ./src/systemd/src/basic/socket-util.h
cp "$SYSTEMD_DIR"/src/basic/sparse-endian.h ./src/systemd/src/basic/sparse-endian.h
cp "$SYSTEMD_DIR"/src/basic/strv.c ./src/systemd/src/basic/strv.c
cp "$SYSTEMD_DIR"/src/basic/strv.h ./src/systemd/src/basic/strv.h
cp "$SYSTEMD_DIR"/src/basic/time-util.c ./src/systemd/src/basic/time-util.c
cp "$SYSTEMD_DIR"/src/basic/time-util.h ./src/systemd/src/basic/time-util.h
cp "$SYSTEMD_DIR"/src/basic/utf8.c ./src/systemd/src/basic/utf8.c
cp "$SYSTEMD_DIR"/src/basic/utf8.h ./src/systemd/src/basic/utf8.h
cp "$SYSTEMD_DIR"/src/basic/util.c ./src/systemd/src/basic/util.c
cp "$SYSTEMD_DIR"/src/basic/util.h ./src/systemd/src/basic/util.h
cp "$SYSTEMD_DIR"/src/basic/unaligned.h ./src/systemd/src/basic/unaligned.h
cp "$SYSTEMD_DIR"/src/basic/in-addr-util.c ./src/systemd/src/basic/in-addr-util.c
cp "$SYSTEMD_DIR"/src/basic/in-addr-util.h ./src/systemd/src/basic/in-addr-util.h
cp "$SYSTEMD_DIR"/src/basic/hostname-util.c ./src/systemd/src/basic/hostname-util.c
cp "$SYSTEMD_DIR"/src/basic/hostname-util.h ./src/systemd/src/basic/hostname-util.h
cp "$SYSTEMD_DIR"/src/basic/random-util.c ./src/systemd/src/basic/random-util.c
cp "$SYSTEMD_DIR"/src/basic/random-util.h ./src/systemd/src/basic/random-util.h
cp "$SYSTEMD_DIR"/src/shared/dns-domain.c ./src/systemd/src/shared/dns-domain.c
cp "$SYSTEMD_DIR"/src/shared/dns-domain.h ./src/systemd/src/shared/dns-domain.h
cp "$SYSTEMD_DIR"/src/systemd/_sd-common.h ./src/systemd/src/systemd/_sd-common.h
cp "$SYSTEMD_DIR"/src/systemd/sd-dhcp-client.h ./src/systemd/src/systemd/sd-dhcp-client.h
cp "$SYSTEMD_DIR"/src/systemd/sd-dhcp-lease.h ./src/systemd/src/systemd/sd-dhcp-lease.h
cp "$SYSTEMD_DIR"/src/systemd/sd-dhcp6-client.h ./src/systemd/src/systemd/sd-dhcp6-client.h
cp "$SYSTEMD_DIR"/src/systemd/sd-dhcp6-lease.h ./src/systemd/src/systemd/sd-dhcp6-lease.h
cp "$SYSTEMD_DIR"/src/systemd/sd-event.h ./src/systemd/src/systemd/sd-event.h
cp "$SYSTEMD_DIR"/src/systemd/sd-id128.h ./src/systemd/src/systemd/sd-id128.h
cp "$SYSTEMD_DIR"/src/systemd/sd-ipv4ll.h ./src/systemd/src/systemd/sd-ipv4ll.h

8 years agoplatform: avoid assuming a permanent address is an ethernet address
Lubomir Rintel [Thu, 2 Jul 2015 21:00:29 +0000 (23:00 +0200)]
platform: avoid assuming a permanent address is an ethernet address

This gets called for all links via link_get_permanent_address(). This could
easily be an infiniband address and we don't want to assert it's not.

8 years agoinfiniband: don't crash if the parent interface is not yet there
Lubomir Rintel [Thu, 2 Jul 2015 20:58:12 +0000 (22:58 +0200)]
infiniband: don't crash if the parent interface is not yet there

Just bail politely just like vlans do.

8 years agobuild: fix $nmlibdir to be "/usr/lib/NetworkManager"
Thomas Haller [Thu, 2 Jul 2015 16:19:32 +0000 (18:19 +0200)]
build: fix $nmlibdir to be "/usr/lib/NetworkManager"

Was detected as "/usr/lib64/NetworkManager".

Fixes: 32dbc51dbd2842a6196bc84f9c303bee9c16a2de

8 years agoconfig/test: fix test failiure due to invalid paths for out-of-tree build
Thomas Haller [Thu, 2 Jul 2015 15:49:16 +0000 (17:49 +0200)]
config/test: fix test failiure due to invalid paths for out-of-tree build

Fixes: 25b23f931ec0d26b3f68720e8d9ab299d4c43cdb

8 years agoplatform: fix wrong removal of generated enums
Thomas Haller [Thu, 2 Jul 2015 14:57:28 +0000 (16:57 +0200)]
platform: fix wrong removal of generated enums

Fixes: a130f72d745bcfef8aca228f40e8d94ce18bbaef

8 years agolibnm/keyfile: fix compile warning about uninitialized variable
Thomas Haller [Thu, 2 Jul 2015 14:53:06 +0000 (16:53 +0200)]
libnm/keyfile: fix compile warning about uninitialized variable

Fixes: 71323122c6b755cfc50ce93c07d6758b45c19cba

8 years agoplatform: mark internal enums to be skipped by glib-mkenums
Thomas Haller [Thu, 2 Jul 2015 13:43:26 +0000 (15:43 +0200)]
platform: mark internal enums to be skipped by glib-mkenums

No need to generate glib type information for these internal
enums.

8 years agoconfig: merge branch 'th/nm-config-intern-bgo750558'
Thomas Haller [Thu, 2 Jul 2015 14:02:36 +0000 (16:02 +0200)]
config: merge branch 'th/nm-config-intern-bgo750558'

Add write support to NMConfig.

Also, add a new configuration directory /usr/lib/NetworkManager/conf.d/
which allows us to install configuration snippets under /usr, instead
of /etc.

https://bugzilla.gnome.org/show_bug.cgi?id=738853
https://bugzilla.gnome.org/show_bug.cgi?id=750558

8 years agoconfig/test: add test for set_values()
Thomas Haller [Sat, 13 Jun 2015 09:37:21 +0000 (11:37 +0200)]
config/test: add test for set_values()

8 years agoconfig: add write support to atomic-sections
Thomas Haller [Wed, 10 Jun 2015 09:59:46 +0000 (11:59 +0200)]
config: add write support to atomic-sections

We already support setting configuration values, either:
 (1) set any internal section, i.e. groups starting with [.intern*].
     Those values don't ever interfere with that the user can
     configure.
 (2) set individual properties that overwrite user configuration.
     When doing that, we record the value from user configuration
     and on load, we reject our internal overwrite if the user
     configuration changed in the meantime.
     This is done by storing the values with ".set." and ".was." prefixes.

Now add support for "atomic sections". In this case, certain groups
can be marked as "atomic". When writing to such sections, we overwrite
the entire user-provided setting.
We also record the values from user configuration, and reject our
internal value if we notice modifications. This basically extends
(2) from individual properties to the entire section.

8 years agoconfig: add write support for NMConfig
Thomas Haller [Wed, 24 Jun 2015 18:11:42 +0000 (20:11 +0200)]
config: add write support for NMConfig

Internal configuration is written as keyfile to
NMSTATEDIR"/NetworkManager-intern.conf"

Basically, the content of this file is merged with user
configuration from "NetworkManager.conf" files. After loading
the configuration, NMConfig exposes a merged view of user-provided
settings and internal overwrites.

All sections/groups named [.intern*] are reserved for internal
configuration values. They can be written by API, but are ignored
when the user sets them via "NetworkManager.conf". For these
internal sections, no conflicts can arise.

We can also overwrite individual properties from user configuration.
In this case, we store the value we want to set, but also remember
the value that the user configuration had, at the time of setting.
If on a later reload the user configuration changed, we ignore our
internal value -- as we assume that the user modified the value
afterwards.
We can also hide/delete value from user configuration.
This works on a per-setting basis.

8 years agosettings: enable "ibft" plugin by default together with "ifcfg-rh"
Thomas Haller [Tue, 9 Jun 2015 17:27:55 +0000 (19:27 +0200)]
settings: enable "ibft" plugin by default together with "ifcfg-rh"

Originally, ibft settings were handled by "ifcfg-rh" plugin. Later, we added
a separate "ibft" plugin and moved the functionality there.

The problem was that users quite possibly had a configuration like
  [main]
  plugins=ifcfg-rh
in their "NetworkManager.conf". That meant, after upgrade users would
no longer have ibft support.

We fixed that by installing "/etc/NetworkManager/conf.d/10-ibft-plugin.conf"
which was read after the main file and contained:
  [main]
  plugins+=ibft

We no longer want to install configuration snippets with our core packages to
/etc. Avoid the regression by changing the meaning of "ifcfg-rh". By enabling
"ifcfg-rh" you now implicitly enable "ibft" plugin as well. This can be
turned off via "no-ibft". And you can continue to enable "ibft" plugin
alone.

8 years agoconfig: fix setting default configuration for 'main.plugins'
Thomas Haller [Sat, 6 Jun 2015 22:02:20 +0000 (00:02 +0200)]
config: fix setting default configuration for 'main.plugins'

'main.plugins' is the only configuration options for which we
have a default value and which we always want to set.

This property has a compile time default and can be set via command line,
fix the logic to set the value.

The proper way is:

  - first set it (always) to the compile time default
  - then read the configuration files, which potentially modify
    the value.
  - finally, if set via command line, overwrite it because
    command line always wins.

Also comment-out the setting from our default file in
"contrib/fedora/rpm/NetworkManager.conf". We don't really need it to be
configured there, as we have a compile time default. Commenting it out
makes this clearer to the user.

Note that we cannot drop "10-ibft-plugin.conf" snippet from
NetworkManager package, because many users might have an old
"NetworkManager.conf" file with "plugin=ifcfg-rh".

This is a change in behavior if the user has no explicit
"plugins=ifcfg-rh" setting but followed by "plugins+=ibft".

8 years agocontrib/rpm: update spec file to install configuration snippets in "/usr/lib/NetworkM...
Thomas Haller [Sun, 7 Jun 2015 13:58:11 +0000 (15:58 +0200)]
contrib/rpm: update spec file to install configuration snippets in "/usr/lib/NetworkManager/conf.d"

Don't move "10-ibft-plugin.conf", because we need it to be
read *after* "NetworkManager.conf". Many users might have
an old "NetworkManager.conf" file that contains "plugin=ifcfg-rh".

8 years agoconfig: read configuration directory "/usr/lib/NetworkManager/conf.d"
Thomas Haller [Mon, 8 Jun 2015 15:51:04 +0000 (17:51 +0200)]
config: read configuration directory "/usr/lib/NetworkManager/conf.d"

This allows packages to install their configuration snippets to
"/usr/", which is a better place for system-provided configuration
files then "/etc".

"/usr/lib/NetworkManager/conf.d/" is read first, so that the values
in /etc have higher priority.

In general, we want to move system-provided configuration away from
/etc, so that a user can do a "factory-reset" by purging /etc.

https://bugzilla.gnome.org/show_bug.cgi?id=738853

8 years agobuild: add nmlibdir define
Thomas Haller [Mon, 8 Jun 2015 15:40:54 +0000 (17:40 +0200)]
build: add nmlibdir define

8 years agoconfig: merge branch 'th/nm-config-intern-bgo750558' (early part)
Thomas Haller [Thu, 2 Jul 2015 13:54:11 +0000 (15:54 +0200)]
config: merge branch 'th/nm-config-intern-bgo750558' (early part)

Early part of fixes and improvements to NMConfig.

This is mostly refactoring and adding of new utility functions.

But it also fixes the way how to parse configuration options from
"NetworkManager.conf" keyfile. So this brings behavioral changes
in the way how we parse the configuration. But unless the user had
unusual configurations (whitespaces, backslash escapes), there should
be no visible changes.

https://bugzilla.gnome.org/show_bug.cgi?id=738853

8 years agoconfig: only handle 'option+' and 'option-' keys for known settings
Thomas Haller [Wed, 1 Jul 2015 11:59:06 +0000 (13:59 +0200)]
config: only handle 'option+' and 'option-' keys for known settings

It is wrong to blindly merge keys that have an 'option+' or 'option-'.
Merging options is only possibly when we understand what the option
means and how to merge it.

No longer handle every setting but only those that are explicitly known
to be string-lists (or device-specs).

8 years agocore: add nm_match_spec_join() function
Thomas Haller [Wed, 1 Jul 2015 15:01:44 +0000 (17:01 +0200)]
core: add nm_match_spec_join() function

We have a special implemenation nm_match_spec_split() to split
a string. We also need the reverse operation to be able to convert
a list of specs to string without loss.

8 years agolibnm: add @deep_copy argument to _nm_utils_strv_to_slist() and _nm_utils_slist_to_strv()
Thomas Haller [Wed, 1 Jul 2015 12:08:51 +0000 (14:08 +0200)]
libnm: add @deep_copy argument to _nm_utils_strv_to_slist() and _nm_utils_slist_to_strv()

8 years agolibnm: expose strv utils function in internal header nm-core-internal.h
Thomas Haller [Wed, 1 Jul 2015 12:02:31 +0000 (14:02 +0200)]
libnm: expose strv utils function in internal header nm-core-internal.h

8 years agoconfig/trivial: add code comment
Thomas Haller [Tue, 16 Jun 2015 13:33:13 +0000 (15:33 +0200)]
config/trivial: add code comment

8 years agoconfig: add NMConfigGetValueFlags argument to nm_config_data_get_value()
Thomas Haller [Tue, 16 Jun 2015 13:13:26 +0000 (15:13 +0200)]
config: add NMConfigGetValueFlags argument to nm_config_data_get_value()

In some cases we want the returned value to be stripped. In some cases,
we want to read the raw value instead of the string parsed by GKeyFile.
Add an flags argument to nm_config_data_get_value(). It is up to the caller
to determine the exact meaning (and whether to strip).

By adding the flags argument, the caller can get the desired behavior easier
without having to workaround it afterwards. But more importantly, it becomes
apparent that there are different ways to retrieve the value and the caller
should decide on the details.

8 years agoconfig: strip white space from configuration values
Thomas Haller [Tue, 16 Jun 2015 12:59:29 +0000 (14:59 +0200)]
config: strip white space from configuration values

https://bugzilla.gnome.org/show_bug.cgi?id=750659
https://bugzilla.redhat.com/show_bug.cgi?id=1229861

8 years agoutils: strip whitespace for device spec in nm_match_spec_split()
Thomas Haller [Tue, 16 Jun 2015 12:06:48 +0000 (14:06 +0200)]
utils: strip whitespace for device spec in nm_match_spec_split()

Via escape sequences, the user still can specify trailing and leading
white spaces: such as "\s \s" will result in 3 spaces.

8 years agoconfig: add config utility accessors
Thomas Haller [Thu, 11 Jun 2015 21:43:29 +0000 (23:43 +0200)]
config: add config utility accessors

8 years agoconfig: ensure nm_config_get_plugins() to return stripped values
Thomas Haller [Wed, 10 Jun 2015 15:27:15 +0000 (17:27 +0200)]
config: ensure nm_config_get_plugins() to return stripped values

8 years agoconfig: fix usage of g_key_file_get_value() vs. g_key_file_get_string()
Thomas Haller [Tue, 9 Jun 2015 10:06:14 +0000 (12:06 +0200)]
config: fix usage of g_key_file_get_value() vs. g_key_file_get_string()

g_key_file_get_value() returns the raw value as stored in the file.
When accessing a string value, in most cases it is correct to use
g_key_file_get_string() instead.

When working with internals, such as comparing two keyfiles for
equality, g_key_file_get_value() is correct.

When parsing booleans, we parse it based on the raw value.

Fix the usages. This is a change in behavior if the config file
contained unusual strings.

8 years agoconfig: log configuration at startup and on reload
Thomas Haller [Tue, 9 Jun 2015 07:59:18 +0000 (09:59 +0200)]
config: log configuration at startup and on reload

8 years agoconfig: add defines for keyfile groups to "nm-config.h"
Thomas Haller [Tue, 9 Jun 2015 07:24:28 +0000 (09:24 +0200)]
config: add defines for keyfile groups to "nm-config.h"

Some plugins had their local defines for the name of the sections and
keys in NMConfig. Move those defines to "nm-config.h".

Usually plugins make use of code in core, but not the other
way round. Defining the names inside "nm-config.h" is no violation of
that because the config section names are anyway not local to the
plugin, but global in the shared name-space with other settings.
For example, another plugins shouldn't reuse the section "ifnet".
For that reason, it is correct and consistent to move these defines
to "nm-config.h".
We don't use those names in core, we merely signal their existance.

8 years agoconfig: use nm_config_data_get_value_boolean()
Thomas Haller [Tue, 9 Jun 2015 07:12:01 +0000 (09:12 +0200)]
config: use nm_config_data_get_value_boolean()

This removes duplicate parsing, but also makes all places use the
same str-to-boolean convention.

8 years agoconfig: add nm_config_data_get_value_boolean()
Thomas Haller [Tue, 9 Jun 2015 07:06:53 +0000 (09:06 +0200)]
config: add nm_config_data_get_value_boolean()

8 years agoconfig: add nm_config_parse_boolean() function
Thomas Haller [Tue, 9 Jun 2015 07:02:32 +0000 (09:02 +0200)]
config: add nm_config_parse_boolean() function

Add function to parse as boolean according our NMConfig convention.
Split this out from nm_config_keyfile_get_boolean() so that we can use
it independently. Also, change the return type to gint, so that one might
pass -1 to indicate an invalid/missing boolean value.

Thereby also don't log a warning in nm_config_keyfile_get_boolean()
We don't want to log a warning every time we access a keyfile value.
If we want to warn about invalid values, we should do it once after
the configuration is loaded. And then we should not only do it
for booleans, but for other types as well.

8 years agoconfig: add macros NM_CONFIG_GET_DATA and NM_CONFIG_GET_DATA_ORIG
Thomas Haller [Tue, 9 Jun 2015 06:47:41 +0000 (08:47 +0200)]
config: add macros NM_CONFIG_GET_DATA and NM_CONFIG_GET_DATA_ORIG

8 years agoconfig: get rid of @error argument to nm_config_data_get_value()
Thomas Haller [Tue, 9 Jun 2015 06:17:28 +0000 (08:17 +0200)]
config: get rid of @error argument to nm_config_data_get_value()

We don't use this argument. A failure to retrieve a key is (for
every practical purpose) the same as no such key.

8 years agolibnm: consider ordering for _nm_keyfile_equals()
Thomas Haller [Thu, 11 Jun 2015 19:12:00 +0000 (21:12 +0200)]
libnm: consider ordering for _nm_keyfile_equals()

GKeyFile considers the order of the files, so add a possibility
to check whether to keyfiles are equal -- also with respect to
the order of the elements.

8 years agolibnm-keyfile/test: fix missing assertion in test
Thomas Haller [Wed, 24 Jun 2015 15:16:22 +0000 (17:16 +0200)]
libnm-keyfile/test: fix missing assertion in test

8 years agolibnm: add keyfile utility functions
Thomas Haller [Mon, 8 Jun 2015 11:30:30 +0000 (13:30 +0200)]
libnm: add keyfile utility functions

8 years agoconfig: reload also no-auto-default state
Thomas Haller [Mon, 8 Jun 2015 14:58:22 +0000 (16:58 +0200)]
config: reload also no-auto-default state

The content of the no-auto-default state file is part of NMConfig.
During a reload, also reload that.

This way, a user could edit the no-auto-default file and it would
be properly reloaded.

8 years agoconfig: fix evaluation of no-auto-default setting
Thomas Haller [Sun, 7 Jun 2015 21:27:01 +0000 (23:27 +0200)]
config: fix evaluation of no-auto-default setting

We used to merge the spec list for no-auto-default from keyfile with the
content of the state file. Since the addition of the "except:" spec this
is wrong.
For example, if the user configured:

  no-auto-default=except:mac:11:11:11:11:11

and statefile contained "11:11:11:11:11" and "22:22:22:22:22", we would
wrongly not match "11:11:11:11:11". The two lists must be kept separate,
so that devices that are blocked by internal decision always match.

This separation is also clearer. Now the spec list is devided into a
part that comes from user configuration, and a part that comes from
internal decision.

8 years agoconfig: refactor processing of 'option+' and 'option-' config settings
Thomas Haller [Sun, 7 Jun 2015 10:03:19 +0000 (12:03 +0200)]
config: refactor processing of 'option+' and 'option-' config settings

We have a hack to extend GKeyFile to support specifying an 'option+'
key. Also add support for 'option-'.

Options that make use of these modifiers can only be string lists.
So do the concatenation not based on plain strings, but by treating
the values as string lists. Also, don't add duplicates.

8 years agoconfig: add nm_config_keyfile_set_string_list() utils function
Thomas Haller [Mon, 15 Jun 2015 10:30:44 +0000 (12:30 +0200)]
config: add nm_config_keyfile_set_string_list() utils function

8 years agoconfig: add NM_CONFIG_KEYFILE_LIST_SEPARATOR define
Thomas Haller [Thu, 2 Jul 2015 07:46:35 +0000 (09:46 +0200)]
config: add NM_CONFIG_KEYFILE_LIST_SEPARATOR define

8 years agoconfig/trivial: rename defines for default settings
Thomas Haller [Sat, 6 Jun 2015 19:47:29 +0000 (21:47 +0200)]
config/trivial: rename defines for default settings

Make them match to the variable names that we assign them to.

8 years agoconfig: change examples for command line arguments to system default
Thomas Haller [Sat, 6 Jun 2015 19:29:01 +0000 (21:29 +0200)]
config: change examples for command line arguments to system default

8 years agotest: add nmtst_assert_success() util
Thomas Haller [Sat, 13 Jun 2015 19:53:49 +0000 (21:53 +0200)]
test: add nmtst_assert_success() util

8 years agomacros: add nm_strstrip() util
Thomas Haller [Tue, 16 Jun 2015 12:55:19 +0000 (14:55 +0200)]
macros: add nm_strstrip() util

8 years agolibnm: add _nm_utils_strv_cleanup() function
Thomas Haller [Tue, 16 Jun 2015 12:46:17 +0000 (14:46 +0200)]
libnm: add _nm_utils_strv_cleanup() function

8 years agoglib-compat: backport g_key_file_save_to_file()
Thomas Haller [Sat, 13 Jun 2015 19:42:46 +0000 (21:42 +0200)]
glib-compat: backport g_key_file_save_to_file()

8 years agoconfig: fix order of processing [connection] sections in NMConfig
Thomas Haller [Thu, 25 Jun 2015 11:02:10 +0000 (13:02 +0200)]
config: fix order of processing [connection] sections in NMConfig

We support the "NetworkManager.conf" sections '[connection]' and
'[connection.\+]' (with arbitrary suffix).

Fix the order of how we evaluate these section.

Note that the literal '[connection]' section is always evaluated lastly
after any other '[connection.\+]' section.

Within one file, we want to evaluate the sections in top-to-bottom
order. But accross multiple files, we want to order them
later-files-first. That gives a reasonable behavior if the user
looks at one file, and also if he wants to overwrite configuration
via configuration snippets like "conf.d/99-last.conf".

Note that if a later file extends/overwrites a section defined in an
earlier file, the section is still considered with lower priority
This is intentional, because the user ~extends~ a lower priority
section. If he wants to add a higher priority section, he should
choose a new suffix.

Fixes: dc0193ac023e30a9a3794e78c66f8c5266695a60

8 years agolibnm-keyfile: ensure g_key_file_get_groups() sets the length argument
Thomas Haller [Thu, 25 Jun 2015 13:36:43 +0000 (15:36 +0200)]
libnm-keyfile: ensure g_key_file_get_groups() sets the length argument

Under certain cases, if g_key_file_get_groups() fails, it might not set the
out argument @length. Play it safe and initialize it.

8 years agoifcfg-rh: correct the error handling for NM_CONTROLLED=no connections
Lubomir Rintel [Thu, 2 Jul 2015 12:46:58 +0000 (14:46 +0200)]
ifcfg-rh: correct the error handling for NM_CONTROLLED=no connections

We ought to set an error if we're returning NULL from
connection_from_file_full(). Also, printing out a warning ourselves makes no
sense -- the caller communicates this if we signal an error by returning NULL.

8 years agoifcfg-rh: don't signal removal of the connection we didn't register
Lubomir Rintel [Thu, 2 Jul 2015 12:44:44 +0000 (14:44 +0200)]
ifcfg-rh: don't signal removal of the connection we didn't register

Removal of a NM_CONTROLLED=no connection and subsequent 'nmcli c reload' would
cause a crash.

8 years agoplatform: minor refactor to logging and nm_platform_link_get_all()
Thomas Haller [Thu, 2 Jul 2015 13:02:44 +0000 (15:02 +0200)]
platform: minor refactor to logging and nm_platform_link_get_all()

Add trace logging to nm_platform_link_get_all().

8 years agoplatform: remove unreachable code in nm_platform_link_get_all()
Thomas Haller [Thu, 2 Jul 2015 13:00:37 +0000 (15:00 +0200)]
platform: remove unreachable code in nm_platform_link_get_all()

Linux platform tracks links by ifindex. Hence an ifindex must be unique
and positive. Just assert against it.

8 years agoplatform/test: add test to call nm_platform_link_get_all()
Thomas Haller [Thu, 2 Jul 2015 12:52:21 +0000 (14:52 +0200)]
platform/test: add test to call nm_platform_link_get_all()

8 years agoplatform: add trace-logging to nm_platform_link_get_all()
Thomas Haller [Thu, 2 Jul 2015 12:42:08 +0000 (14:42 +0200)]
platform: add trace-logging to nm_platform_link_get_all()

8 years agoplatform: replace debug() log macro with _LOGD()
Thomas Haller [Thu, 2 Jul 2015 12:35:38 +0000 (14:35 +0200)]
platform: replace debug() log macro with _LOGD()

8 years agoplatform: add logging macros _LOGx() to nm-platform.c
Thomas Haller [Thu, 2 Jul 2015 12:33:37 +0000 (14:33 +0200)]
platform: add logging macros _LOGx() to nm-platform.c

8 years agoautogen.sh: print errors to stderr, printf instead echo -n
Petr Vorel [Thu, 18 Jun 2015 23:25:27 +0000 (01:25 +0200)]
autogen.sh: print errors to stderr, printf instead echo -n

Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
8 years agomerge,cli: branch 'lr/cli-add-properties'
Lubomir Rintel [Thu, 2 Jul 2015 07:34:09 +0000 (09:34 +0200)]
merge,cli: branch 'lr/cli-add-properties'

Make it possible to specify properties upon connection addition.

Addresses all these:

https://bugzilla.gnome.org/show_bug.cgi?id=750590
https://bugzilla.gnome.org/show_bug.cgi?id=698076
https://bugzilla.gnome.org/show_bug.cgi?id=740749