Commit graph

12208 commits

Author SHA1 Message Date
Thomas Haller
0eef608cd1 device: fix regression for ignored search domains in ip._config_merge_and_apply()
Reported-by: Fabrice Bellet <fabrice@bellet.info>
Fixes: 2a5eea7e76

https://bugzilla.gnome.org/show_bug.cgi?id=752193
(cherry picked from commit d6831efc6b)
2015-07-09 23:16:52 +02:00
Lubomir Rintel
6f6a8a85c9 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.

(cherry picked from commit db44539912)
2015-07-09 18:11:52 +02:00
Lubomir Rintel
8455d42684 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.

(cherry picked from commit f44ac46485)
2015-07-09 18:11:52 +02:00
Jiří Klimeš
c73eeb39f5 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

(cherry picked from commit 640eb8f284)
2015-07-08 17:12:19 +02:00
Jiří Klimeš
1111b867ce utils: fix error logging in ASSERT_VALID_PATH_COMPONENT()
(cherry picked from commit 43a50fd5f2)
2015-07-08 16:55:56 +02:00
Jiří Klimeš
65a585beba device: use NULL instead of 0 in g_return_val_if_fail() for pointer
(cherry picked from commit 46f29a4abc)
2015-07-08 16:55:52 +02:00
Jiří Klimeš
61b4bec803 device: trivial: fix a copy/paste error in comment
(cherry picked from commit dce050a45d)
2015-07-08 16:55:48 +02:00
Thomas Haller
0d0fa7ead6 route-manager: restore shadowed gateway routes after direct routes
(cherry picked from commit ce2964c021)
2015-07-08 12:01:53 +02:00
Jiří Klimeš
292f0105b2 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 04caae735f.
But still this is better.

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

(cherry picked from commit bb1692707f)
2015-07-07 18:53:21 +02:00
Thomas Haller
e3bd4e1d44 route-manager/trivial: move code
Have related functions closer together.

Fixes: 635eea60cf
(cherry picked from commit ce9d8e0817)
2015-07-07 17:29:47 +02:00
Thomas Haller
ca861152b5 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.

(cherry picked from commit 08b99eea10)
2015-07-07 17:22:15 +02:00
Thomas Haller
a1df05662a route-manager/logging: fix wording in logging statement
(cherry picked from commit 80a0ec76b9)
2015-07-07 16:33:45 +02:00
Thomas Haller
3562e600fb route-manager: merge branch 'th/direct-route-conflict-bgo752062'
https://bugzilla.gnome.org/show_bug.cgi?id=752062

(cherry picked from commit ad2809cf6a)
2015-07-07 16:32:30 +02:00
Thomas Haller
cce7884fe6 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.

(cherry picked from commit f5c087c8e9)
2015-07-07 16:31:50 +02:00
Thomas Haller
7a0ec8c8ff route-manager: add optional @r2_metric argument to _route_equals_ignoring_ifindex()
(cherry picked from commit 700bb96523)
2015-07-07 16:30:38 +02:00
Thomas Haller
abebc340cc platform: add optional @metric argument to route_add() function
Allow overwriting the route metric.

(cherry picked from commit 09fdf58f4d)
2015-07-07 16:30:38 +02:00
Thomas Haller
29f3432d01 route-manager: add compare function for route-destination
(cherry picked from commit 635eea60cf)
2015-07-07 16:30:38 +02:00
Thomas Haller
b3c41f4829 route-manager: fix trace logging statement
(cherry picked from commit 0055a7dd74)
2015-07-07 16:30:38 +02:00
Thomas Haller
cf15f2a4a8 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=750558

(cherry picked from commit 65753dbc13)
2015-07-03 09:24:05 +02:00
Thomas Haller
500f590033 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).

(cherry picked from commit a1ea678f78)
2015-07-03 09:24:05 +02:00
Thomas Haller
e896817d80 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.

(cherry picked from commit bd57d76af8)
2015-07-03 09:24:05 +02:00
Thomas Haller
0cbcf21e80 libnm: add @deep_copy argument to _nm_utils_strv_to_slist() and _nm_utils_slist_to_strv()
(cherry picked from commit ed632207cd)
2015-07-03 09:24:05 +02:00
Thomas Haller
1dec33e2af libnm: expose strv utils function in internal header nm-core-internal.h
(cherry picked from commit 93e4a8d102)
2015-07-03 09:24:05 +02:00
Thomas Haller
045841b66c config/trivial: add code comment
(cherry picked from commit 0c6a011e34)
2015-07-03 09:24:05 +02:00
Thomas Haller
1b66696f6a 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.

(cherry picked from commit d3e2193783)
2015-07-03 09:24:04 +02:00
Thomas Haller
93ff88fff1 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
(cherry picked from commit 076ffda6f3)
2015-07-03 09:24:04 +02:00
Thomas Haller
fb71d7c2fd 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.

(cherry picked from commit 7498b670a8)
2015-07-03 09:24:04 +02:00
Thomas Haller
109f6756b8 config: add config utility accessors
(cherry picked from commit 11c0e107b9)
2015-07-03 09:24:04 +02:00
Thomas Haller
e713fb5e99 config: ensure nm_config_get_plugins() to return stripped values
(cherry picked from commit 7e94785f28)
2015-07-03 09:24:04 +02:00
Thomas Haller
df1cd73128 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.

(cherry picked from commit 0abb502ff3)
2015-07-03 09:24:04 +02:00
Thomas Haller
bd83daf408 config: log configuration at startup and on reload
(cherry picked from commit b506c29fe1)
2015-07-03 09:24:04 +02:00
Thomas Haller
cbace6fe06 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.

(cherry picked from commit 6d6ab20be0)
2015-07-03 09:24:04 +02:00
Thomas Haller
c4b1156b04 config: use nm_config_data_get_value_boolean()
This removes duplicate parsing, but also makes all places use the
same str-to-boolean convention.

(cherry picked from commit 1b0ab2129c)
2015-07-03 09:24:04 +02:00
Thomas Haller
76ca6d86ec config: add nm_config_data_get_value_boolean()
(cherry picked from commit a0e92799af)
2015-07-03 09:24:04 +02:00
Thomas Haller
5eeaf4df91 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.

(cherry picked from commit 35d2981546)
2015-07-03 09:24:04 +02:00
Thomas Haller
a771e2ffcf config: add macros NM_CONFIG_GET_DATA and NM_CONFIG_GET_DATA_ORIG
(cherry picked from commit 2c46003e99)
2015-07-03 09:24:04 +02:00
Thomas Haller
4ba8dd09ac 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.

(cherry picked from commit a5f7abb842)
2015-07-03 09:24:03 +02:00
Thomas Haller
b1246efc60 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.

(cherry picked from commit 7fbfaf567d)
2015-07-03 09:24:03 +02:00
Thomas Haller
016d46265f libnm-keyfile/test: fix missing assertion in test
(cherry picked from commit e1b0195c67)
2015-07-03 09:24:03 +02:00
Thomas Haller
582ef15d3e libnm/keyfile: fix compile warning about uninitialized variable
Fixes: 71323122c6
(cherry picked from commit 47551df352)
2015-07-03 09:24:03 +02:00
Thomas Haller
41d0902dc9 libnm: add keyfile utility functions
(cherry picked from commit 71323122c6)
2015-07-03 09:24:03 +02:00
Thomas Haller
bee9b7e327 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.

(cherry picked from commit 4a8a0b0918)
2015-07-03 09:24:03 +02:00
Thomas Haller
4adecd466e 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.

(cherry picked from commit 3e4458659b)
2015-07-03 09:24:03 +02:00
Thomas Haller
a325abc425 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.

(cherry picked from commit fab5c6a372)
2015-07-03 09:24:03 +02:00
Thomas Haller
4c45642b8b config: add nm_config_keyfile_set_string_list() utils function
(cherry picked from commit bb4ae800a1)
2015-07-03 09:24:03 +02:00
Thomas Haller
bd2df64bac config: add NM_CONFIG_KEYFILE_LIST_SEPARATOR define
(cherry picked from commit a05e80913e)
2015-07-03 09:24:03 +02:00
Thomas Haller
68a1c54fa2 config/trivial: rename defines for default settings
Make them match to the variable names that we assign them to.

(cherry picked from commit 3c8abc2d5b)
2015-07-03 09:24:03 +02:00
Thomas Haller
0a2325ded0 config: change examples for command line arguments to system default
(cherry picked from commit 27bd7dc938)
2015-07-03 09:24:03 +02:00
Thomas Haller
53dcdf8516 config: backport refactoring to no_auto_default_merge_from_file()
The original backport was different then what was done on master.
Make 'nm-config.c' more similar to what we have on master.

Fixes: d510f0a039

(cherry picked from commit 643f042b9b)
2015-07-03 09:24:02 +02:00
Thomas Haller
0b10fb15a0 test: add nmtst_assert_success() util
(cherry picked from commit f5177dbf7a)
2015-07-03 09:24:02 +02:00