Commit Graph

15211 Commits

Author SHA1 Message Date
Beniamino Galvani
072358dad0 team: check return value of g_dbus_connection_call_sync()
The call can fail; in such case assume that an existing teamd died and
our instance will be able to continue.

https://bugzilla.redhat.com/show_bug.cgi?id=1347015
2016-06-21 14:58:55 +02:00
Thomas Haller
3b155d3cee clients,vpn/trivial: rename argument of nm_vpn_get_secret_names() 2016-06-20 19:04:34 +02:00
Thomas Haller
7e0660bf07 clients,vpn: only accept full service-types in nm_vpn_get_secret_names()
nm_vpn_get_secret_names() has only one caller, which passes
nm_setting_vpn_get_service_type() as @vpn_type argument. That
argument is not a short-name or abbreviation, it must be the
full service-type.

For our well-known, hard-coded list of service-types, all must
start with the same prefix.
2016-06-20 19:02:40 +02:00
Thomas Haller
59269b6925 clients: fix wrong assertion _assert_format_int()
Fixes: 2822f92434
2016-06-18 18:15:41 +02:00
Thomas Haller
062fccf46f all: merge branch 'th/g_strv_contrains' 2016-06-17 12:26:57 +02:00
Thomas Haller
bc1014a93d all: replace _nm_utils_string_in_list() with g_strv_contains() 2016-06-17 12:25:33 +02:00
Thomas Haller
caeaa78918 nm-glib: implement compatibility macro for g_strv_contains() differently
Otherwise, deprecation warnings are not properly suppressed for

  g_return_if_fail (g_strv_contains (strv, str));
2016-06-17 12:25:33 +02:00
Thomas Haller
1b9d60f985 nm-glib: remove G_GNUC_EXTENSION
We use statement expressions all over the place without explicitly
marking them. If that would be a problem, we'd have to change a
*lot* of code. We simply require that as a mandatory feature from
our compiler.
2016-06-17 12:25:15 +02:00
Lubomir Rintel
45d6baac4d shared: backport g_strv_contains() 2016-06-17 12:22:37 +02:00
Didier Raboud
f90abce4d5 wwan: check at runtime whether to start ModemManager
This makes NetworkManager use runtime detection to manage the
ModemManager lifecycle when not run by systemd. Under systemd, we expect
the ModemManager service to be started by systemd, under non-systemd, we
use the dbus activation feature to start ModemManager.

[thaller@redhat.com: original patch heavily modified to check for available
 libsystemd library]

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=770871
https://mail.gnome.org/archives/networkmanager-list/2016-June/msg00086.html
2016-06-17 12:21:20 +02:00
Dan Williams
16c368b8eb platform: recognize rmnet and ccmni interfaces as WWAN network devices
https://mail.gnome.org/archives/networkmanager-list/2016-June/msg00087.html
2016-06-17 11:08:51 +02:00
Dan Williams
f969193db4 platform/trivial: rename NM_LINK_TYPE_WWAN_ETHERNET to NM_LINK_TYPE_WWAN_NET
Some newer WWAN netdev types are "rawip" which don't bother with
ethernet framing.
2016-06-17 11:00:10 +02:00
Thomas Haller
4143fbde17 logging: enable logging domain VPN_PLUGIN up to level <info>
The logging domain VPN_PLUGIN controlls logging of the VPN plugins.
Especially at verbose levels <debug> and <trace>, the plugins might
reveal sensitive information in the logging.

Thus, this level should not be enabled by a

  $ nmcli logging general level DEBUG domains ALL

It should only be enabled when requested explicitly.

  $ nmcli logging general level DEBUG domains ALL,VPN_PLUGIN:DEBUG

Previously, the special level VPN_PLUGIN was entirely excluded from
ALL and DEFAULT domains and it was entirely disabled by default. That
is however to strict, as it completely silences the VPN plugins by
defult. Now, enable them by default up to level INFO.

VPN plugins should take care that they don't reveal sensitive
information at levels <info> (LOG_NOTICE) and higher (less verbose).
For more verbose levels they may print passwords, but that should
still be avoided as far as possible.
2016-06-17 08:19:44 +02:00
Thomas Haller
af507cd089 shared: add also "shared/nm-utils/nm-vpn-plugin-macros.h"
It has the very similar purpose as "nm-utils/nm-vpn-plugin-utils.[ch]", except
that is is header-only.
2016-06-16 18:06:16 +02:00
Thomas Haller
89d32944af tests: fix checking NM_ASSERT_NO_MSG define in "nm-test-utils.h"
"nm-test-utils.h" may also be used by the VPN plugins, there
we have no NM_ASSERT_NO_MSG define.
2016-06-16 11:04:51 +02:00
Thomas Haller
6dd2b316b5 shared: merge branch 'th/shared-bgo767697'
https://bugzilla.gnome.org/show_bug.cgi?id=767697
2016-06-16 10:52:00 +02:00
Thomas Haller
2c02f3a8cf shared/tests: build "nm-utils/nm-vpn-plugin-utils.c"
For testing, add a build target to build those files too.
2016-06-16 10:45:54 +02:00
Thomas Haller
3bcec4067f shared: include "nm-glib.h" from "nm-macros-internal.h"
"nm-glib.h" is our most basic header. "nm-macros-internal.h" extends
on that. Thus, let "nm-macros-internal.h" include "nm-glib.h".
2016-06-16 10:45:54 +02:00
Thomas Haller
037462e902 shared: include "gsystem-local-alloc.h" from "nm-glib.h"
"nm-glib.h" is the most basic header, the one we cannot do without.
("nm-default.h", is already more generic, the one which every common
source file in NetworkManager repository should include).

Let "gsystem-local-alloc.h" be included by "nm-glib.h" and nowhere
else.
2016-06-16 10:45:54 +02:00
Thomas Haller
5d55492bac shared: add "nm-utils/nm-vpn-plugin-utils.h"
This file is only used by plugins and copied between them.

It's purpose is to contain general utility functions that are
only relevant for implementing NetworkManager's VPN plugins.

In principle the utility functions could be part of libnm, however,
there are a few problems with that:
  - if they are part of libnm, adding and using a new utility function
    requires the plugin to bump the required libnm version. Since you
    usally can work around/reimplement utility functions, this results
    in not using the API from libnm, not adding the API to libnm,
    and reimplementing it over and over in the plugin.
  - plugins compile both against libnm and libnm-glib. Thus, either
    the utility function would also be needed in libnm-glib, or again,
    it is not usable by the plugin.

We must avoid that the utility functions diverge and no local
modifications to these files should be made in the plugin.
Instead, one special location of the utility functions shall be
extended and re-imported (copied) to the plugin as needed.

Add the files to NetworkManager's repository. Although they are not
needed for NetworkManager itself, they are a different API provided
by NetworkManager. An API that is reused and shared by copying the files
around.
2016-06-16 10:45:54 +02:00
Thomas Haller
4b288136e1 shared: move shared files to subdirectory "shared/nm-utils/"
The "shared" directory contains files that are possibly used by all components
of NetworkManager repository.

Some of these files are even copied as-is to other projects (VPN plugins, nm-applet)
and used there without modification. Move those files to a separate directory.
By moving them to a common directory, it is clearer that they belong
together. Also, you can easier compare the copied versions to their
original via

  $ diff -r ./shared/nm-utils/ /path/to/nm-vpn-plugin/shared/nm-utils/
2016-06-16 10:45:53 +02:00
Thomas Haller
b6b84d0442 libnm/vpn,cli: merge branch 'th/vpn-service-info-bgo767197'
https://bugzilla.gnome.org/show_bug.cgi?id=767197
2016-06-15 15:02:45 +02:00
Thomas Haller
cf34211c90 libnm/vpn: add nm_vpn_editor_plugin_load_vt()
Let VPN plugins return a virtual function table to extend
the API while bypassing libnm. This allows to add and use
new functionality to VPN plugins without updating libnm.

The actual definitions are in a header-only file
"nm-vpn-editor-plugin-call.h", which can be copied to the
caller/plugin.
2016-06-15 15:01:12 +02:00
Thomas Haller
1c42375efb libnm/vpn: pass NMVpnPluginInfo to the NMVpnEditorPlugin instance
The NMVpnPluginInfo is essentially the .name file, that is, a
configuration file about the plugin itself. Via NMVpnPluginInfo
instance, the NMVpnEditorPlugin can be created.

Usually, one would create a NMVpnPluginInfo (that is, reading the
.name file) and then create a NMVpnEditorPlugin instance from there.
In this case, usually the editor-plugin is owned by the plugin-info
instance (although the API allows for creating the editor-plugin
independently).

Now, pass the  NMVpnPluginInfo to the editor-plugin too.
This is useful, because then the editor-plugin can look at the .name
file.

The .name file is not user configuration. Instead it is configuration
about the plugin itself. Although the .name file is part of the plugin
build artefacts, it is useful to allow the plugin to access the .name
file. The reason is, that this can allow the user to easily change a
configuration knob of the plugin without requiring to patch or the
plugin.
2016-06-15 10:32:32 +02:00
Thomas Haller
4cb57964d9 cli: fix handling of VPN names in nmcli by using libnm functions
At various places, nmcli requires to specify a VPN type by name, for example

  $ nmcli connection add type vpn ifname '*' vpn-type $VPN_TYPE

This $VPN_TYPE used to be a hard-coded list of known VPN plugin names.
But actually, it should be a VPN service-type. A service-type used to be
the D-Bus name of the VPN plugin. Now, with multiple VPN support that
is no longer the case, but it still has the form of a D-Bus bus name.
Alternativley, it could be an alias, which is just a way for plugins
to support multiple service-types.

Fix that, to support fully qualified service-types in the form
of D-Bus bus names. Also, support lookup by name, in which case
the present plugin-info instances are searched.
Finally, support a list of hard-code short-names.

All the logic how to translate a short-name to a fully qualified
service-type is now inside libnm, so that various user agree on
those names and don't have to hard-code them each.
2016-06-15 10:32:32 +02:00
Thomas Haller
46665898bb libnm/vpn: add nm_vpn_plugin_info_list_find_service_name() function 2016-06-15 10:32:32 +02:00
Thomas Haller
57783347bd libnm/vpn: refactor nm_vpn_plugin_info_list_find_by_service() and prefer aliases first
Refactor code to add function _list_find_by_service(), which will be used in the
next commit.

A notable change is that we now search also through the aliases
together with the service-name.

That makes a difference, if one plugin privdes an "alias" which another
plugin provides as "service". Due to that change, we would also find the
aliased plugin first.

In practice it shouldn't matter, because different plugins are
not supposed to provide identical services.
2016-06-15 10:32:32 +02:00
Thomas Haller
a2b34f7f12 clients/trivial: rename nm_vpn_get_plugins() to nm_vpn_get_plugin_infos() 2016-06-15 10:32:32 +02:00
Thomas Haller
971a8181f6 nmcli: fix VPN export to find plugin by service-type 2016-06-15 10:32:32 +02:00
Thomas Haller
10445bedb8 libnm/vpn: add nm_vpn_plugin_info_get_aliases 2016-06-15 10:32:32 +02:00
Thomas Haller
d37945b064 all: use nm_strcmp_p() for sorting strings 2016-06-15 10:32:32 +02:00
Thomas Haller
c629378d2e clients: fix potential crash due to wrong sort function
g_qsort_with_data() passes the pointers to the compared items to the
compare function, that is not the "const char *" pointers itself.

Fixes: 41976e3069
2016-06-15 10:32:32 +02:00
Thomas Haller
e108f1cfaf shared: add nm_strcmp_p() utils macro 2016-06-15 10:32:31 +02:00
Thomas Haller
ccc1be34ee libnm: backport symbols nm_setting_ip_config_get_dns_priority to libnm_1_2_4
Commit bdd0e7fec0 which added symbol
nm_setting_ip_config_get_dns_priority to libnm_1_4_0 was backported
to nm-1-2 in commit ad1cdcf6571da23e3197b09f1b4b14d23b8899d1.

Add the backported symbol to master to allow seemless upgrading
from 1.2.4 to 1.4.0.
2016-06-10 11:37:39 +02:00
Thomas Haller
4e6f466fd3 all: merge branch 'th/assert-expr-strings-bgo767296'
https://bugzilla.gnome.org/show_bug.cgi?id=767296
2016-06-09 12:17:34 +02:00
Thomas Haller
00f58adb16 build: remove assertion messages in non-debug build
Assertions like g_assert*() and g_return_*() contain the stringified
test expression. This string ends up in the binary and increases its
size.

We usually don't have failing assertions. These string are a waste,
instead the file and line number shall suffice.

It reduces the striped size of the NetworkManager binary from 2500k
to 2392k, that is -108k, -4.3%.

This changes

 - "g_assert (1 == 2);"
   from: NetworkManager:ERROR:source.c:347:some_function: assertion failed: (1 == 2)
   to:   NetworkManager:ERROR:source.c:347:<unknown-fcn>: assertion failed: (<dropped>)

 - "g_return_if_fail (1 == 2);"
   from: (process:21024): NetworkManager-CRITICAL **: some_function: assertion '1 == 2' failed
   to:   (process:21024): NetworkManager-CRITICAL **: ((source.c:347)): assertion '<dropped>' failed

When doing a non-debug build, those string are now removed. Debug-builds
can be enabled by setting --with-more-assert=$LEVEL to larger then zero.

https://bugzilla.gnome.org/show_bug.cgi?id=767296
2016-06-09 12:03:39 +02:00
Thomas Haller
fa973afa19 tests: add macro NMTST_G_RETURN_MSG for expecting g_return*() failures
A failure to g_return*() by default prints a g_critical() with stringifing the
condition. Add a macro NMTST_G_RETURN_MSG() that reproduces that line to more
accurately match the failure message.
2016-06-09 12:03:39 +02:00
Beniamino Galvani
21bdb82555 platform: tests: skip already used macvtap ifindexes
In old kernel versions the creation of a macvtap can fail if its
ifindex is already used by a macvtap in another namespace, because of
a conflict in sysfs entries generation [1].

Try to detect this situation in platform tests and skip an ifindex if
already in use.

[1] http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=17af2bce88d31e65ed73d638bb752d2e13c66ced
2016-06-07 14:44:30 +02:00
Beniamino Galvani
ff3cd5aaf5 dns: merge branch 'bg/dnsmasq-rdns-bgo767174'
https://bugzilla.gnome.org/show_bug.cgi?id=767174
2016-06-07 11:45:06 +02:00
Beniamino Galvani
6c5a5c9f2a dns: remove nm-dns-utils.c and nm-dns-utils.h
The functions in the two files seem to belong to nm-dns-dnsmasq.c as
nobody else is using them.
2016-06-07 11:20:09 +02:00
Beniamino Galvani
ae763642d8 dns: add reverse DNS IPv6 entries to dnsmasq
https://bugzilla.gnome.org/show_bug.cgi?id=767174
2016-06-07 11:20:09 +02:00
Beniamino Galvani
4d1e7dc23c dns: add CIDR reverse DNS IPv4 entries to dnsmasq
When a reverse DNS entry must be added to dnsmasq, instead of
considering IP addresses as classful use the prefix to compute one or
more "in-addr.arpa" according to CIDR rules.

https://bugzilla.gnome.org/show_bug.cgi?id=767174
2016-06-07 10:52:50 +02:00
Thomas Haller
24430e4b07 contrib/rpm: don't enable sanitizer for debug build
There are valid failures, for which sanitizer would kill
NetworkManager:

  audit[1380]: AVC avc:  denied  { setrlimit } for  pid=1380 comm="NetworkManager" scontext=system_u:system_r:NetworkManager_t:s0 tcontext=system_u:system_r:NetworkManager_t:s0 tclass=process permissive=0
  NetworkManager[1380]: ==1380==ERROR: AddressSanitizer setrlimit() failed 13

Disable sanitizer to make debug builds working again, at least for now.
2016-06-07 09:15:26 +02:00
Thomas Haller
b769b4dfcb tests: use absolute path for certs test directory
Allows to run the test without first switching directory
  ./libnm-core/tests/test-secrets
2016-06-06 16:35:23 +02:00
Thomas Haller
2822f92434 clients: fix wrong assertion _assert_format_int()
Fixes: 466bf2f633
2016-06-06 14:21:42 +02:00
Thomas Haller
b8b68e212d build: disable warning "-Wformat-y2k"
https://bugzilla.gnome.org/show_bug.cgi?id=767207
2016-06-06 14:07:23 +02:00
Thomas Haller
fa6b1070fc Revert "build: fix autogen.sh for builddir != srcdir"
This breaks build with older versions of gtkdocize that don't understand
yet --srcdir.

This reverts commit ed7ee64d4e.
2016-06-06 13:52:57 +02:00
Thomas Haller
2dc0ee29f6 clients: fix compilation without NM_MORE_ASSERTS
It would render _assert_format_int() unused and warn.

Fixes: 466bf2f633
2016-06-06 13:12:50 +02:00
Bastien Nocera
ed7ee64d4e build: fix autogen.sh for builddir != srcdir
https://bugzilla.gnome.org/show_bug.cgi?id=767207
2016-06-06 12:35:35 +02:00
Thomas Haller
348e505b3a macros: add macro _nm_printf() for function attribute 2016-06-05 12:22:01 +02:00