Commit graph

616 commits

Author SHA1 Message Date
Thomas Haller 3adf782ab5 libnm/vpn: consider VPN service aliases in nm_vpn_plugin_info_new_search_file()
Fixes: 4271c9650c
2016-04-25 11:31:55 +02:00
Beniamino Galvani 7434e6a77b libnm-core: fix compiler warning in nm_vpn_plugin_info_get_auth_dialog()
libnm-core/nm-vpn-plugin-info.c: In function ‘nm_vpn_plugin_info_get_auth_dialog’:
shared/gsystem-local-alloc.h:53:46: error: ‘prog_basename’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

Fixes: a3f94f451b
2016-04-22 16:57:02 +02:00
Thomas Haller 4271c9650c libnm/vpn: add nm_vpn_plugin_info_new_search_file() 2016-04-22 14:17:02 +02:00
Thomas Haller 67415f0c5e libnm/vpn: add nm_vpn_plugin_info_supports_hints() 2016-04-22 14:17:02 +02:00
Thomas Haller a3f94f451b libnm/vpn: add nm_vpn_plugin_info_get_auth_dialog() 2016-04-22 14:17:02 +02:00
Thomas Haller 0d95ed3bb8 libnm/vpn: add nm_vpn_plugin_info_get_service()
Re-add nm_vpn_plugin_info_get_service(). This function *is* useful
and could be used by nm-applet.

This reverts commit 3517084b92.
2016-04-22 14:17:02 +02:00
Thomas Haller 8e59be20d6 libnm/vpn: gracefully handle empty dirname in _nm_vpn_plugin_info_list_load_dir()
No need to assert against an empty dirname. It's not different from
any other non-existing directory and we should be graceful about that.
2016-04-22 14:17:02 +02:00
Lubomir Rintel db6ebe003d docs: include the D-Bus enums reference with the API documentation
Otherwise the types links would be dangling or resolved to slightly
irrelevant documentation in libnm or completely irrelevant documentation
in libnm-util.
2016-04-22 10:02:37 +02:00
Lubomir Rintel c850868faf libnm-core: don't link to NMDevice type from the D-Bus spec
It isn't right in that context -- NMDevice is a libnm-core object,
not a bus object. In rendered documentation this would generate
a dangling link.
2016-04-22 10:02:37 +02:00
Lubomir Rintel 1d66d415b8 libnm-core: empty key is not a pkcs12 file
nmcli> set 802-1x.ca-cert file:///tmp/certs/eaptest_ca_cert.pem
  (process:31015): libnm-CRITICAL **: crypto_is_pkcs12_data: assertion 'data != NULL' failed
  Error: failed to set 'ca-cert' property: PEM certificate had no start tag '-----BEGIN CERTIFICATE-----'.
2016-04-20 10:48:59 +02:00
Thomas Haller 0b128aeced libnm/vpn: search VPN plugin in NMPLUGINDIR
In commit ca000cffbb, we changed to
accept a plugin library name without path. One reason for that
is to keep architecture dependent parts out of the .name file
and possibly support multilib.

However, the shared libraries of VPN plugins are not installed in
a global library search path, but for example into
"/usr/lib64/NetworkManager/libnm-vpn-plugin-openvpn.so".
In that case, specifying "plugin=libnm-vpn-plugin-openvpn.so"
would not be enough to find plugin.

Instead, when configuring a plugin name without path, assume
it is in NMPLUGINDIR directory. Modify nm_vpn_editor_plugin_load_from_file()
to allow path-less plugin-names. Previously such names would be rejected
as not being absolute. This API allows to do file verification
before loading the plugin, but it now supports prepending NMPLUGINDIR
to the plugin name. Basically, this function mangles the plugin_name
argument and checks that such a file exists.

The recently added nm_vpn_editor_plugin_load() continues to behave
as before: it does no checks whatsoever and passes the name directly
to dlopen(). That way, it uses system search paths like LD_LIBRARY_PATH
and performs no checks on the file.

Fixes: ca000cffbb
2016-04-19 14:59:26 +02:00
Thomas Haller e00eac2981 libnm/vpn: add nm_vpn_editor_plugin_load() function
Contrary to nm_vpn_editor_plugin_load_from_file(), this allows
to specify a library name without path. In this case, g_module_open()
(dlopen()) will search for a library in various system directories.
2016-04-19 13:47:42 +02:00
Thomas Haller ca000cffbb libnm/vpn: allow specifying non-absolute plugin name in VPN .name file
Since commit 3dfbbb227e, we enforce that
the plugin path in the .name file is absolute and we perform several
checks on the file before loading it (ownership, etc).

Relax that, to also allow libray names without path component.
In that case, g_module_open()/dlopen() will search for a library
in various search paths. This allows, to omit absolute paths
in the .name file. The latter is problematic, because by default
we install the .name file in the architecture independent location
/usr/lib/NetworkManager. As such, it should not contain paths
to architecture dependent libraries. With this change, a .name
file can contain only the library name and it will be loaded
using the usual mechanism.

However, specifying absolute paths is still possible and works
same as before, including checking file permissions.

As such, distributions probably should package the VPN plugins
to have no path in the .name file. On the other hand, a user
compiling from source probably wants to specify an absolute
path. The reason is, that the user probably doesn't build the
plugin for multiple achitectures and that way, he can install
the plugin in a separate (private) prefix.
2016-04-19 13:47:42 +02:00
Thomas Haller cb22f02588 libnm/vpn: fix code comment for nm_vpn_editor_plugin_load_from_file()
The @plugin_filename argument must be an absolute path.
That was changed later, but forgot to update the comment.

Fixes: 3dfbbb227e
2016-04-19 13:47:42 +02:00
Thomas Haller 4003edbbf9 libnm/vpn: clear internal "keyfile" from NMVpnPluginInfo
The GKeyFile is no longer needed after constuction. All strings are
copied over to the "keys" hash.
2016-04-19 13:47:42 +02:00
Thomas Haller 6878999ca3 libnm/vpn: lookup nm_vpn_plugin_info_supports_multiple() from cached values
Instead of looking into the keyfile, lookup the "supports-multiple-connections" setting
in the "keys" hash. This has some behavioral difference:

  - g_key_file_get_boolean() first does g_key_file_get_value(), and then
    converts the string using the private g_key_file_parse_value_as_boolean()
    function -- which is case-sensitive, accepts "true|false|0|1" and
    considers only the text until the first whitespace.

  - now, we put g_key_file_get_string() into the cache "keys" and
    parse it with _nm_utils_ascii_str_to_bool(). The latter is
    case insensitive, allows also "yes|no|on|off", strips whitespaces.

However, the difference is subtle and shouldn't matter.

The point of this change is to free "keyfile" after construction.
2016-04-19 13:47:42 +02:00
Beniamino Galvani 82f8a54854 libnm-core: use jansson to compare and check team configurations
Optionally link libnm-core against jansson JSON library and use it to
validate and compare team configurations.
2016-04-18 21:50:51 +02:00
Thomas Haller 6b8729a599 libnm-core: drup unused @allow_zero_prefix argument from valid_prefix() 2016-04-11 12:40:35 +02:00
Thomas Haller 57860c329e libnm-core: allow zero prefix length in NMIPAddress
Adding addresses with a prefix of zero is valid. Don't
reject them.

Note that this is an actual bug. If you configure an
address with prefix length zero, nmcli will report:

  $nmcli connection
  (process:1040): libnm-WARNING **: Ignoring invalid IP4 address: Invalid IPv4 address prefix '0'
2016-04-11 12:33:07 +02:00
Thomas Haller d68ccb84f1 libnm-core/trivial: add code comment 2016-04-11 12:29:33 +02:00
Lubomir Rintel f4b4e35c79 release: add version 1.4 macros 2016-04-05 22:22:58 +02:00
Thomas Haller 9152dec99f build: disable deprecation checks for internal compilation
For internal compilation we want to be able to use deprecated
API without warnings.

Define the version min/max macros to effectively disable deprecation
warnings.

However, don't do it via CFLAGS option in the makefiles, instead hack it
to "nm-default.h". After all, *every* source file that is for internal
compilation needs to include this header as first.
2016-04-05 22:22:58 +02:00
Lubomir Rintel 2c3c83370b dbus: move NMWimaxNspNetworkType to nm-dbus-interface.h
It's an enum used on D-Bus.
2016-04-05 14:37:51 +02:00
Lubomir Rintel ccf1d5bd94 dbus: remove the telepathy annotations
We now generate documentation with gdbus-codegen and these are now
useless.
2016-04-05 14:37:51 +02:00
Beniamino Galvani d6d42e0825 libnm-core: add 'use-vc' DNS option
The option forces the use of TCP for DNS resolutions.
2016-04-03 23:08:38 +02:00
Thomas Haller 5f83ef9925 build: drop internal field __nm_git_sha from libraries
The problem is that you cannot be sure which patches
were applied on top of a source tree, so the __nm_git_sha
value is unreliable.

Also, after running autoreconf during the package build,
NM_GIT_SHA is reset as well.
2016-03-30 15:48:56 +02:00
Beniamino Galvani a0206a4f5e man,libnm-core: fix typos 2016-03-30 12:03:36 +02:00
Beniamino Galvani b717c5503b libnm-core: remove trailing quote from message in nm-setting-macvlan.c
Reported-by: Anders Jonsson <anders.jonsson@norsjovallen.se>
2016-03-30 00:33:20 +02:00
Beniamino Galvani efa559bcc8 libnm-core: add test cases for NMSettingBond
The setting well deserves some testing.
2016-03-29 18:10:05 +02:00
Beniamino Galvani 4839c747c2 libnm-core: implement option matching for NMSettingBond
We cannot simply compare the single values of option hashes to match
connections because some keys are equivalent to others and also
because keys having a default value should be ignored.

Add the compare_property method to implement custom comparison logic.
2016-03-29 18:10:05 +02:00
Beniamino Galvani 260fcc52a8 bond: add some missing options
https://bugzilla.redhat.com/show_bug.cgi?id=1299103
2016-03-29 18:10:05 +02:00
Beniamino Galvani 2324410a75 bond: fix re-assuming of connections
When a value of a TYPE_BOTH option is read back from kernel it
contains both string and numeric values ("balance-rr 0"), so we must
chop off the number before adding the option to the setting. Also
change the default values of options to the string form so that the
option matching logic works.
2016-03-29 18:10:05 +02:00
Beniamino Galvani 5f7d7ee497 libnm,libnm-core: add coverage support 2016-03-29 18:10:04 +02:00
Beniamino Galvani e196f2257d libnm-core: fix check in verification of NMSettingBond 2016-03-29 18:10:04 +02:00
Thomas Haller df405942de libnm-core/tests: refactor call to nm_simple_connection_new_from_dbus()
No actual change, let's just not directly call nm_simple_connection_new_from_dbus().
Instead, add a wrapper to define in once place the flags we use for loading the
connection.
2016-03-26 12:10:54 +01:00
Thomas Haller 3d8776108c libnm-core: add _nm_simple_connection_new_from_dbus() function
Contary to nm_simple_connection_new_from_dbus(), this internal
function allows to specify parse-flags.
2016-03-26 12:10:54 +01:00
Thomas Haller 737c8cc532 libnm-core: allow strict and relaxed error behavior for _nm_setting_new_from_dbus()
In some situations, we want strict checking of errors, for example when
NetworkManager receives a new connection from a client, the connection
must make sense as a whole (and since NetworkManager service is backward
compatible to the clients and not the other way around, there is no
excuse for sending invalid data to the server).

In other situations, we want a best-effort behavior. Like when
NetworkManager sends a connection to its clients, those clients
want to extract as many properties as they understand, but in order
to be forward compatible against newer server versions, invalid
or unknown properties must be accepted.

Previously, a mixture of both was done. Some issues caused a failure
to create a new NMSetting, other invalid parts were just silently
ignored or triggered a g_warning() in glib.

Now allow for both. When doing strict-validation, be more strict and
reject all unknown properties and catch when the user sets an invalid
argument. On the other hand, allow for a best-effort mode that
effectively cannot fail and will return a new NMSetting instance.

For now, add NMSettingParseFlags so that the caller can choose the
old behavior, strict parsing, or best effort.

This patch doesn't have any externally visible change except that
no more g_warnings will be emitted.
2016-03-26 12:10:54 +01:00
Thomas Haller fafc90526b shared: move _nm_utils_ascii_str_to_int64() to "shared/nm-shared-utils.h"
_nm_utils_ascii_str_to_int64() was declared in libnm-core's internal
header "nm-core-internal.h" and thus available for libnm-core, libnm,
NetworkManager and related.

It also means, the function was not available in libnm-util, libnm-glib,
clients or dispatcher. So, we either reimplemented it (nmc_string_to_int_base)
or struggle with the awkward strtol* API.
2016-03-26 12:10:53 +01:00
Thomas Haller 5de30dd029 shared: include "nm-shared-utils.h"
Include it via "nm-default.h" to all projects.
2016-03-26 12:10:53 +01:00
Thomas Haller 98c772f0bc man: document IPv4 subnet for "shared" method 2016-03-20 11:18:37 +01:00
Beniamino Galvani 46f8045c9e libnm-core: nm-setting-8021x: treat some empty properties as NULL
For some properties as *subject-match and *domain-suffix-match an
empty string means that we don't want to do any filtering and should
be stored as NULL.
2016-03-16 17:32:17 +01:00
Beniamino Galvani a4b4e0bc5b ifcfg-rh: add support for domain-suffix-match properties 2016-03-16 17:32:17 +01:00
Beniamino Galvani 64b76ba906 libnm-core: add domain-suffix-match properties to NMSetting8021x
The new domain-suffix-match and phase2-domain-suffix-match properties
can be used to match against a given server domain suffix in the
dNSName elements or in the SubjectName CN of the server certificate.

Also, add a comment to the old subject-match properties documentation
to suggest that they are deprecated and should not be used anymore.
2016-03-16 17:32:17 +01:00
Thomas Haller 3802fd46dd lldp: fix name of NM_LLDP_ATTR_IEEE_802_1_VID string
Fixes: 07a9364d9c
2016-03-10 16:46:50 +01:00
Beniamino Galvani 551c5de120 libnm-core: fix memory leak in nm-setting-ip-tunnel.c
Fixes: ae8c7a8967
2016-03-09 23:16:23 +01:00
Lubomir Rintel 1c5d8d0aec all: fix a couple more gvariant iteration leaks 2016-03-08 17:44:15 +01:00
Thomas Haller cd4f84b738 all: don't include error->code in log messages
GError codes are only unique per domain, so logging the code without
also indicating the domain is not helpful. And anyway, if the error
messages are not distinctive enough to tell the whole story then we
should fix the error messages.

Based-on-patch-by: Dan Winship <danw@gnome.org>
2016-03-03 18:54:20 +01:00
Beniamino Galvani da70fbd7d5 libnm-core: remove special handling of missing VLAN_FLAGS
On older NM versions the default value for vlan.flags was 0, but then
the actual value set on interfaces was REORDER_HDR. In order to
maintain backwards compatibility in behavior, remove the special
handling of vlan.flags so that a missing key is treated as the default
value REORDER_HDR.

https://bugzilla.gnome.org/show_bug.cgi?id=762626
2016-02-29 18:11:17 +01:00
Beniamino Galvani 2e5e7285a8 ifcfg-rh: change the handling of REORDER_HDR flag
On NM 1.0 connections were created by default without the REORDER_HDR
flag, but then due to a bug in platform code (fixed in [1]), the
kernel interface always had the flag set.

Now that the setting is honored, users upgrading to the new version of
NM will see a change from the previous behavior, since interfaces will
not have REORDER_HDR and this will certainly break functionality.

The only solution here seems to be to ignore the REORDER_HDR variable
in ifcfg files (since it never had any effect) and introduce a new
NO_REORDER_HDR option for the VLAN_FLAGS variable which allows to turn
the flag off. The consequence is that the flag will be set for all old
connections.

This change introduces an incompatibility with initscripts, however is
necessary to avoid breaking user functionality upon upgrade.
Connections created through NetworkManager will still be parsed
correctly by initscripts (since we always write the REORDER_HDR
variable).

[1] db62fc9d72 ("platform: fix adding VLAN flags")

https://bugzilla.gnome.org/show_bug.cgi?id=762626
2016-02-29 18:11:17 +01:00
Thomas Haller 1b00009169 device: add new NMDeviceType NM_DEVICE_TYPE_VETH
Based-on-patch-by: Jiří Klimeš <jklimes@redhat.com>
2016-02-23 23:15:37 +01:00
Thomas Haller 8bace23beb all: cleanup includes and let "nm-default.h" include "config.h"
- All internal source files (except "examples", which are not internal)
  should include "config.h" first. As also all internal source
  files should include "nm-default.h", let "config.h" be included
  by "nm-default.h" and include "nm-default.h" as first in every
  source file.
  We already wanted to include "nm-default.h" before other headers
  because it might contains some fixes (like "nm-glib.h" compatibility)
  that is required first.

- After including "nm-default.h", we optinally allow for including the
  corresponding header file for the source file at hand. The idea
  is to ensure that each header file is self contained.

- Don't include "config.h" or "nm-default.h" in any header file
  (except "nm-sd-adapt.h"). Public headers anyway must not include
  these headers, and internal headers are never included after
  "nm-default.h", as of the first previous point.

- Include all internal headers with quotes instead of angle brackets.
  In practice it doesn't matter, because in our public headers we must
  include other headers with angle brackets. As we use our public
  headers also to compile our interal source files, effectively the
  result must be the same. Still do it for consistency.

- Except for <config.h> itself. Include it with angle brackets as suggested by
  https://www.gnu.org/software/autoconf/manual/autoconf.html#Configuration-Headers
2016-02-19 17:53:25 +01:00
Beniamino Galvani b6f98126c7 libnm-core: fix ifcfg-rh documentation for dhcp-timeout property
Fixes: 3f0d595cc8
2016-02-16 11:37:26 +01:00
Beniamino Galvani 1bb3b6a4c6 libnm-core: make ipvx.dhcp-timeout signed
Change the dhcp-timeout property in NMSettingIPConfig to int type for
consistency with the dad-timeout property. For dad-timeout -1 means
"use default value", while for dhcp-timeout probably we will never use
negative values, but it seems more correct to use the same type for
the two properties.
2016-02-16 11:37:26 +01:00
Beniamino Galvani 206e074863 libnm,core,cli: move dhcp-timeout property to generic NMSettingIPConfig
The property applies to both IPv4 and IPv6 and so it should not be in
NMSettingIP4Config but in the base class.
2016-02-16 11:37:26 +01:00
Thomas Haller 6898e2169e all: add version-id argument to device's Reapply method
This breaks API and ABI for the functions related to Reapply,
which got introduced in the current 1.1 development phase.

The version-id is here to allow users to error out if the connection
on the device was changed by a concurrent action.

https://bugzilla.gnome.org/show_bug.cgi?id=761714
2016-02-16 11:24:49 +01:00
Beniamino Galvani 10b222288e wifi: don't touch by default current powersave setting
Some drivers (or things outside NM like 'powertop') may turn powersave
on, so don't touch it unless explicitly configured by user.

To achieve this, add new 'default' and 'ignore' options; the former
can be used to fall back to a globally configured setting, while the
latter tells NM not to touch the current setting.

When 'default' is specified, a missing global default configuration is
equivalent to 'ignore'.

It is possible to enable Wi-Fi power saving for all connections by
dropping a file in /etc/NetworkManager/conf.d with the following
content:

 [connection]
 wifi.powersave=3

https://bugzilla.gnome.org/show_bug.cgi?id=760125
2016-02-16 00:18:06 +01:00
Thomas Haller b4cced2cea nmtst: add nmtst_assert_connection_verify() and don't normalize connection in assert
It is ugly that nmtst_assert_connection_verifies_after_normalization() would
normalize the argument and modify it. An assertion should not have side-effects.
2016-02-15 14:26:26 +01:00
Thomas Haller 34b7d49ea6 libnm/tests: convert test cases to use g_assert() instead of ASSERT() (test-setting-8021x.c) 2016-02-14 23:48:00 +01:00
Thomas Haller fde5f7bfab libnm/tests: convert test cases to use g_assert() instead of ASSERT() (test-secrets.c) 2016-02-14 20:43:21 +01:00
Thomas Haller 29aa13dc84 libnm/tests: convert test cases to use g_assert() instead of ASSERT() 2016-02-14 14:57:19 +01:00
Thomas Haller e663b88c59 all/trivial: rename STRLEN() macro to NM_STRLEN()
We should not have defines/macros in header files without a nm/NM
prefix. STRLEN() was one of the few offenders.

https://mail.gnome.org/archives/networkmanager-list/2016-February/msg00048.html
2016-02-14 11:34:42 +01:00
Thomas Haller afaa27ddbb libnm/keyfile/trivial: rename VPN_SECRETS_GROUP define to NM_KEYFILE_GROUP_VPN_SECRETS
It is a define from an internal header. Still, all defines in headers
should be named with a NM prefix.
2016-02-14 11:14:35 +01:00
Thomas Haller 2c2d9d2e4c build: cleanup default includes
- "gsystem-local-alloc.h" and <gio/gio.h> are already included via
  "nm-default.h". No need to include them separately.

- include "nm-macros-internal.h" via "nm-default.h" and drop all
  explict includes.

- in the modified files, ensure that we always include "config.h"
  and "nm-default.h" first. As second, include the header file
  for the current source file (if applicable). Then follow external
  includes and finally internal nm includes.

- include nm headers inside source code files with quotes

- internal header files don't need to include default headers.
  They can savely assume that "nm-default.h" is already included
  and with it glib, nm-glib.h, nm-macros-internal.h, etc.
2016-02-12 15:36:01 +01:00
Thomas Haller dc394a6537 macros: add NM_IN_STRSET()
Add macro similar to NM_IN_SET() that checks for C strings.
NULL values are allowed and handled as one would expect.
2016-02-11 17:54:38 +01:00
Thomas Haller 1211b5b631 macros: simplify NM_IN_SET() macro
Also fix NM_IN_SET_SE() to guaranteed return 0 or 1.
2016-02-11 17:54:38 +01:00
Dan Williams 80d9a43a25 tests: get rid of FAIL macro 2016-02-11 09:50:29 -06:00
Beniamino Galvani f57dd6735e libnm-core: fix documentation for MAC_ADDRESS_RANDOMIZATION property
Fixes: 6a46dfca26
2016-02-11 12:01:29 +01:00
Dan Williams 170b94598a libnm: fix NMSettingVxlan ageing and limit max values
They are actually u32 in the kernel.  Plus if we use G_MAXINT32 it
causes gtkdoc to write out "Allowed values: <= G_MAXLONG" on i386
and "Allowed values: <= G_MAXINT" on x86_64, breaking multilib.

Fixes: 95dfd99afc
2016-02-05 16:24:40 -06:00
Dan Williams 2eabd61f7f libnm: fix copy & paste error in NMSettingVxlan properties
Fixes: 95dfd99afc
2016-02-05 16:18:05 -06:00
Thomas Haller c510323368 all/tests: fix messages for ASSERT() macro
These places pass an invalid arguments for the given
format string. Fix them, by dropping the overly verbose
ASSERT() macro.
2016-02-03 12:37:43 +01:00
Jiří Klimeš 3cb3fedef8 vpn-plugin-info: add description for @filename parameter 2016-02-03 09:58:16 +01:00
Thomas Haller bb86877031 libnm-core: cleanup handling IP address in NMIPRoute
The change to canonicalize_ip() has actually no effect
because all callers that pass null_any==TRUE, ensure
already that they don't pass NULL.
2016-01-29 13:49:27 +01:00
Thomas Haller 862be319a8 libnm-core: use utility function in NMIPRoute for getting size of addresses per family 2016-01-28 21:15:59 +01:00
Thomas Haller 0ba4322eec libnm-core: ensure any next_hop in NMIPRoute is NULL
NMIPRoute has the convention that a next-hop 0.0.0.0/:: is stored
as NULL. However, the binary setters could violate that.
2016-01-28 21:15:59 +01:00
Thomas Haller 8715d61437 libnm-core: fail verify() for NMSettingVlan for invalid vlan id
Point in case:

    # ip link add link dummy0 name dummy0.vlan type vlan id 4095
    RTNETLINK answers: Numerical result out of range

This potentially causes existing (invalid) connections to disappear
as they now fail verification.

Instead of adjusting the range of the GObject property
NM_SETTING_VLAN_ID, reject it during vlan. This is a bit more
forgiving to an older client that isn't aware of this new restriction,
so he can first set the value without raising a critical warning.
2016-01-22 12:02:39 +01:00
Thomas Haller 0c7fa89439 libnm: assert against valid dest in NMIPRoute 2016-01-22 10:14:02 +01:00
Dan Williams 3b3f108dfd docs, trivial: fix some documentation issues 2016-01-20 11:27:22 -06:00
Dan Williams 0a12a1711c libnm-core,core,cli: fix spelling of NM_IP_TUNNEL_MODE_UNKNOWN
Fixes: b614a5ec61
Fixes: ae8c7a8967
Fixes: 570fdce93f
2016-01-20 11:27:22 -06:00
Jiří Klimeš adbbf3aa5c ifcfg-rh: read/write ipv4.dad-timeout using ARPING_WAIT
ARPING_WAIT is used for DAD by Red Hat initscrips (ifup-eth).
2016-01-20 11:53:47 +01:00
Jiří Klimeš 31ea5a99cb libnm: add NMSettingIPConfig 'dad-timeout' property
The property is used to control duplicate address detection:
 * -1 means default value
 * 0 means no DAD is performed
 * > 0 means timeout (in milliseconds) for arping responses

[bgalvani: moved setting from NMSettingIP4Config]
2016-01-20 11:53:47 +01:00
Thomas Haller db80ec05ab build: rename directory "include" to "shared"
Up to now, the "include" directory contained (only) header files that were
used project-wide by libs, core, clients, et al.

Since the directory now also contains a non-header file, the "include"
name is misleading. Instead of adding yet another directory that is
project-wide, with non-header-only content, rename the "include"
directory to "shared".
2015-12-24 11:42:37 +01:00
Beniamino Galvani 1ff712d5d0 ip-tunnel: add a MTU property
Add a new ip-tunnel.mtu property which can be used to change the MTU
of the tunnel interface.
2015-12-19 12:06:33 +01:00
Jiří Klimeš 9ec9e4e72a libnm-core/docs: add/fix missing descriptions 2015-12-18 11:16:22 +01:00
Jiří Klimeš 3ca758790e libnm: fix documentation of NMSettingIP6ConfigAddrGenMode values 2015-12-18 10:27:27 +01:00
Jiří Klimeš 174d66a3d0 libnm-core: add missing transfer annotation for nm_utils_enum_get_values()
Fixes: 13a981fc38
2015-12-12 22:24:35 +01:00
Beniamino Galvani a448854b44 device/vxlan: support device creation 2015-12-09 16:36:46 +01:00
Beniamino Galvani 95dfd99afc libnm-core: add NMSettingVxlan
Add a new NMSettingVxlan which describes properties of VXLAN
connections.
2015-12-09 16:36:46 +01:00
Beniamino Galvani 4de8851eca device/macvlan: support device creation 2015-12-09 14:30:08 +01:00
Beniamino Galvani 4d0192e661 libnm-core: add NMSettingMacvlan
The setting contains properties that are specific to macvlans and
macvtaps.
2015-12-09 14:30:08 +01:00
Lubomir Rintel 9dbf549c64 vpn-editor-plugin: improve the error handling a bit 2015-12-07 11:20:14 +01:00
Beniamino Galvani 570fdce93f device: add NMDeviceIPTunnel
The new object type represents tunnels over IPv4 and IPv6.

We have a single setting type (NMSettingIPTunnel) for tunnels and it
can't be shared among different device factories. So we define also a
single device type for all tunnels.

This new object will also represent GRE tunnels, which before were
instantiated as NMDeviceGre and had a ".Device.Gre" D-Bus
interface. This commit introduces a change in behavior.
2015-12-01 17:39:41 +01:00
Beniamino Galvani ae8c7a8967 libnm-core: add NMSettingIPTunnel
Add a generic NMSettingTunnel which describes properties of tunnels
over IPv4 and IPv6 (GRE, SIT, IPIP, IPIP6, IP6GRE, etc.). Since those
tunnel types all have similar properties it makes sense to have a
single setting type for them.
2015-12-01 17:39:40 +01:00
Beniamino Galvani 13a981fc38 libnm-core: add nm_utils_enum_get_values()
Add function nm_utils_enum_get_values() which returns a string array
containing the enum values. It can be used, for example, to build a
list of allowed values for user.
2015-12-01 17:39:40 +01:00
Beniamino Galvani 337304f19d libnm: add NMDeviceTun 2015-11-25 11:39:57 +01:00
Beniamino Galvani 9110ad39c5 device/tun: support device creation
Allow the creation of a new TUN/TAP interface when a tun connection is
activated.
2015-11-25 11:39:57 +01:00
Beniamino Galvani 1f30147a7a libnm-core: add NMSettingTun
Add a new NMSettingTun which contains configuration properties for TUN/TAP
interfaces.
2015-11-25 11:39:57 +01:00
Beniamino Galvani 5002342d94 ifcfg-rh: support the DHCP_FQDN variable
Add support for the DHCP_FQDN ifcfg-rh variable which maps to the
ipv4.dhcp-fqdn property.
2015-11-23 22:08:22 +01:00
Beniamino Galvani cb40194532 libnm-core: add a 'dhcp-fqdn' property to NMSettingIP4Config
The property contains the fully qualified domain name to be sent to
DHCP server using the FQDN option. The property is mutually exclusive
with 'dhcp-hostname'.
2015-11-23 16:31:52 +01:00
Jiří Klimeš b41b32cb7b libnm: add nm_setting_verify_secrets() and nm_connection_verify_secrets()
for verifying the secrets, because it is not done in plain nm_setting_verify().

For simple verification of free-form string secrets,
_nm_setting_verify_secret_string() helper is used.
2015-11-20 10:35:10 +01:00
Thomas Haller ecadff700e libnm-core: fix memleak in NMSettingGsm
Fixes: 4b412218e6
2015-11-19 15:09:41 +01:00
Joel Holdsworth 312c72f761 crypto_gnutls: removed dead code
https://mail.gnome.org/archives/networkmanager-list/2015-November/msg00061.html
2015-11-19 13:58:12 +01:00
Dan Williams 4b412218e6 libnm/wwan: add GSM setting device-id, sim-id, and sim-operator-id properties
These properties limit whether the connection applies to a certain WWAN modem
based on the modem's device ID or SIM ID (as reported by the WWAN management
service), or through the MCC/MNC ID of the operator that issued the SIM card.
2015-11-18 15:50:52 +01:00
Thomas Haller 4f6c91d696 wifi: enable mac-address-randomization by default for new connections
But ensure that old keyfiles that did not yet understand
the new key continue to have it disabled.
2015-11-18 15:37:42 +01:00
Thomas Haller 6a46dfca26 ifcfg-rh: add support for NMSettingWireless:mac-address-randomization
Old init-scripts that did not yet understand this key will have
mac-address-randomization explicitly disabled. This is to ensure
that old connections don't change behavior.
Thus, the writer must always write the value explicitly.

Downside is, if somebody creates a quick ifcfg-file, the feature
is disabled by default.
2015-11-18 15:37:42 +01:00
Dan Williams 0222822134 libnm: add Wi-Fi MAC address randomization property 2015-11-18 15:37:42 +01:00
Thomas Haller 37824def11 all: add C99's "bool" define
https://mail.gnome.org/archives/networkmanager-list/2015-November/msg00036.html
2015-11-18 13:25:21 +01:00
Jiří Klimeš b92397f925 all: fix typos in the code and update translations for that (bgo #758102)
Found by Anders Jonsson <anders.jonsson@norsjovallen.se>

https://bugzilla.gnome.org/show_bug.cgi?id=758102
2015-11-16 14:29:14 +01:00
Beniamino Galvani ac78c18855 libnm-core/tests: fix bit shift
Use a maximum shift amount of 63 for guint64.

Fixes: 0a3c1f5774
2015-11-15 11:13:41 +01:00
Thomas Haller 549ec35d7b libnm/keyfile: fix leak in ip6-addr-gen-mode writer
Fixes: f70c8f3d29
2015-11-11 16:15:41 +01:00
Lubomir Rintel 05dad07978 libnm-core: fix make dist with --enable-tests=no
We still need BUILT_SOURCES.
2015-11-02 21:05:11 +01:00
Lubomir Rintel e9dfdfe9fe libnm-core: default to ip6.addr-gen-mode=stable-privacy
Take a missing value in keyfile/ifcfg-rh as EUI-64 to keep the compatibility
with the old conneciton. Nevertheless, the new connections should default to
the RFC7217 addresses.
2015-11-02 20:27:36 +01:00
Lubomir Rintel f70c8f3d29 keyfile: add support for addr-gen-mode property 2015-11-02 20:27:00 +01:00
Lubomir Rintel 60811b4809 setting-ip6-config: add addr-gen-mode property 2015-11-02 20:27:00 +01:00
Lubomir Rintel cde053c0b0 vpn-plugin-info: add vpn plugin service aliases 2015-11-02 16:01:21 +01:00
Lubomir Rintel 3517084b92 vpn-plugin-info: drop nm_vpn_plugin_info_get_service()
It is not used externally and its use might be confusing and undesired when we
add plugin aliases. The external users should only use the name when idenfiying
the plugin and nm_vpn_plugin_info_list_find_by_service() when matchin the plugin.
2015-11-02 16:01:21 +01:00
Thomas Haller 5feda42813 vlan: handle vlan flags, ingress and egress map in NMDeviceVlan
In update_connection(), pickup the configuration of
the vlan interface from platform and create the proper
NMSettingVlan setting.

And during stage1, configure the flags of the device.

Also, change all the ingress/egress mappings at once
instead of having a netlink request for each mapping.
Also, ensure we *clear* all other mappings so that
only those are set, that were configured (done by
the *gress_reset_all argument).
2015-11-02 13:57:02 +01:00
Thomas Haller d2650a88bd libnm: don't re-sort the vlan priorities every time in set_map() 2015-11-02 13:57:02 +01:00
Thomas Haller 17aa8c0fc8 libnm: internally expose NMVlanQosMapping struct in "nm-core-internal.h" 2015-11-02 13:57:02 +01:00
Thomas Haller d61875c960 libnm: add internal header file "nm-core-types-internal.h"
This shall contain type definitions, with similar use
to "nm-core-internal.h".

However, it should contain a minimal set, so that we can include this
header in other headers under "src/", without including the whole
"nm-core-internal.h" in headers.
2015-11-02 13:57:02 +01:00
Thomas Haller 204fcd33d8 macros: add nm_clear_g_cancellable() utility 2015-11-01 17:28:07 +01:00
Thomas Haller da7cc97f5e libnm/tests: avoid invalid compiler warning about uninitialized variable
make[5]: Entering directory './NetworkManager/libnm-core/tests'
    CC       test-general.o
  test-general.c: In function ‘test_g_hash_table_get_keys_as_array’:
  test-general.c:4552:69: error: ‘length’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  test-general.c:4543:8: note: ‘length’ was declared here
    guint length;
          ^
2015-10-31 13:42:51 +01:00
Thomas Haller ee7414ebc8 platform: NM defines for vlan header flags equal the linux headers 2015-10-27 17:24:52 +01:00
Jiří Klimeš 689de5c94a vlan: (all) add VLAN MVRP flag
http://patchwork.ozlabs.org/patch/219364/
2015-10-27 17:17:05 +01:00
Jiří Klimeš 93b8871f56 libnm: sort INGRESS_PRIORITY_MAP, EGRESS_PRIORITY_MAP properties
This fixes comparing the properties.

Priority map { 1:2, 2:5 } is actually the same as { 2:5, 1:2 }.
2015-10-27 17:17:05 +01:00
Jiří Klimeš 704930a045 libnm: do not add duplicates to VLAN priority mappings 2015-10-27 16:31:29 +01:00
Jiří Klimeš 22a0136bcb ifcfg-rh: read/write VLAN GVRP flags with GVRP= ifcfg file variable
initscripts uses GVRP variable for the flag (since 2011):
https://git.fedorahosted.org/cgit/initscripts.git/commit/?id=f662d4777625cd3bedea19cccabea7741a8b45c9

But continue reading "GVRP" from VLAN_FLAG= if GVRP= is missing.
2015-10-27 16:26:37 +01:00
Thomas Haller 21674d5bfb libnm: treat missing NMSettingVlan:flags property as old default value
We changed the default value of MSettingVlan:flags from 0 to
1 (NM_VLAN_FLAG_REORDER_HEADERS). That means, that old libnm
clients will not serialize 0 (their default).
This change broke the D-Bus API. The D-Bus API allows to omit a value
when meaning the default value. That means, we cannot change the
default value (in the D-Bus API!) without breaking previous assumptions.

A newer libnm version should treat a missing flags argument as the
old default value and thus preserve the original default value (in the
D-Bus API).

This has the downside that for the future we will continue to treat a missing
value as the old default value (0), and in order to get the new default
value (1), the client must explicitly set the flags.

We also must restore the original default value in libnm-glib.
libnm-glib does not support _nm_setting_class_override_property()
and thus it must keep thinking that the default value for the GObject
property continues to be 0. Otherwise, it would not serialize a 1, which
a new libnm would now interpret as 0.

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

Fixes: 687b651598
2015-10-23 11:23:46 +02:00
Thomas Haller 7a14f19e09 libnm: always serialize NMSettingVlan:flags property for D-Bus
We changed the default value for the NMSettingVlan:flags from 0 to
1 (NM_VLAN_FLAG_REORDER_HEADERS). That means, we will no longer serialize
a value of 1 over D-Bus.

This breaks older libnm clients, which treat a missing flags property as
the old default (0).

-- old clients here means: clients that still use an older version of libnm
   or clients that don't use libnm, but depend on the previous default value
   in the D-Bus API.

Enforce to always serialize the flags properties. This workaround has almost
no downsides except that for new clients we serialize more then absolutely
necessary.
But it ensures that old clients still receive the proper value.

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

Fixes: 687b651598
2015-10-23 11:22:59 +02:00
Beniamino Galvani 1136de4221 libnm,libnm-core: fix GTK-Doc warnings 2015-10-16 17:33:12 +02:00
Beniamino Galvani e587dcb16e wake-on-lan: add option to keep existing settings
Add a new 'ignore' option to NMSettingWired.wake-on-lan which disables
management of wake-on-lan by NetworkManager (i.e. the pre-existing
option will not be touched). Also, change the default behavior to be
'ignore' instead of 'disabled'.

https://bugzilla.gnome.org/show_bug.cgi?id=755182
2015-10-16 17:11:26 +02:00
Lubomir Rintel 5b48befaad vpn-manager: support multiple VPN connections of the same type
A separate instance of the support plugin is spawned for each connection with
a different bus name. The bus name is passed via --bus-name <name> argument.
Plugins that support the feature indicate it with
support-multiple-connections=true key in the [VPN Connection] section.

The bus name is currently generated by adding a .<connection.uuid> to the VPN
service name. It's guarranteed unique, but if it proves to be too long or ugly
it can easily be replaced with something more meaningful (such as the same number
as is used for connection's DBus name).

NMVpnService has been removed and folded into NMVpnConnection. A
NMVpnConnection will spawn a service plugin instance whenever it is activated
and notices the bus name it needs is not provided.

The NMVpnManager no longer needs to keep track of the connections in use apart
for compatibility purposes with plugins that don't support the feature.
2015-10-13 18:20:56 +02:00
Lubomir Rintel 6c213e3cb4 libnm-core/vpn-plugin-info: add nm_vpn_plugin_info_supports_multiple() 2015-10-13 18:20:56 +02:00
Beniamino Galvani 0650b0b147 libnm-core: fix documentation for DHCP_TIMEOUT ifcfg-rh variable
Fixes: 3f0d595cc8
2015-10-13 15:36:46 +02:00
Beniamino Galvani 5966e14abf ifcfg-rh: add support for 'LLDP' connection property 2015-10-12 14:44:31 +02:00
Beniamino Galvani 07a9364d9c device: export list of LLDP neighbors through D-Bus
This adds a LldpNeighbors property to the Device D-Bus interface
carrying information about devices discovered through LLDP. The
property is an array of hashes and each hash describes the values of
LLDP TLVs for a specific neighbor.
2015-10-12 14:44:30 +02:00
Beniamino Galvani c364ef0b97 libnm: add 'lldp' property to NMSettingConnection
Add the 'lldp' property to NMSettingConnection, which specifies
whether the reception and parsing of LLDP frames to discover neighbor
devices should be enabled.
2015-10-12 14:44:19 +02:00
Jiří Klimeš 237030ce2b libnm: specify (transfer none) introspection annotation (bgo #756380)
Otherwise the callers would free the address and it would result in
double-free.

Ideally, the function would return const pointer, but changing it now
would require changing also other prototypes and much code due to
snowball effect of const.

https://bugzilla.gnome.org/show_bug.cgi?id=756380
2015-10-12 12:29:31 +02:00
Thomas Haller 68b3790ad3 libnm: explicitly cast enum type for g_object_set()
Fixes: 687b651598
2015-10-08 13:11:44 +02:00
Jiří Klimeš 687b651598 libnm/vlan: default to vlan.flags=REORDER_HDR for new connections (rh #1250225)
The kernel defaults REORDER_HDR to 1 when creating a new VLAN, but
NetworkManager's VLAN flags property defaulted to 0. Thus REORDER_HDR was not
set for NM-created VLANs with default values.

We want to match the kernel default, so we change the default value for the
vlan.flags property. However, we do not want to change the flags for existing
connections if the property is missing in connection files. Thus we have to
update plugins for that. We also make sure that vlan.flags is always written
by 'keyfile' when the value is default. That way new connections have flags
property explicitly written and it will be loaded as expected.

https://bugzilla.redhat.com/show_bug.cgi?id=1250225
2015-10-07 13:45:30 +02:00
Lubomir Rintel 3f0d595cc8 libnm,ip4-config: add ipv4.dhcp-timeout property
This is intentionally IPv4 specific since this is used for a quick fallback to
method=link-local -- something that's not needed for IPv6 since the link local
address is always there.

https://bugzilla.redhat.com/show_bug.cgi?id=1262922
2015-10-06 14:16:55 +02:00
Beniamino Galvani bd27c110a3 glib-compat: add g_hash_table_get_keys_as_array() compat function 2015-10-01 09:05:08 +02:00
Thomas Haller 7bf10a75db build: extract version macros from "nm-version.h" to new header file "nm-version-macros.h"
For libnm library, "nm-dbus-interface.h" contains defines like the D-Bus
paths of NetworkManager. It is desirable to have this header usable without
having a dependency on "glib.h", for example for a QT application. For that,
commit c0852964a8 removed that dependancy.

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

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

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

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

Fixes: 4545a7fe96
2015-09-30 23:10:29 +02:00
Thomas Haller c60ff9e7e0 libnm: add NM_AVAILABLE_IN_1_2 to "nm-dbus-interface.h"
"nm-dbus-interface.h" can be used without glib/libnm, hence we must
workaround a missing NM_AVAILABLE_IN_1_2 macro.
2015-09-25 16:22:47 +02:00
Jiří Klimeš 12e6cf1f20 libnm-core/libnm-util: fix an erroneous error message
ipv6.dns: 'this property is not allowed for '%s=%s'' not allowed for method=ignore
2015-09-25 16:11:24 +02:00
Thomas Haller 0e223d4961 libnm: include "glib.h" in "nm-version.h"
This is a forward port of commit 6f616d4c4b
which added this patch on nm-1-0 branch.

However, the reason stated there is wrong because we don't need this
to fix Qt examples. Building Qt examples was fixed in that "nm-dbus-interface.h"
no longer drags in "nm-version.h".

On the other hand, we still want "nm-version.h" to be self-contained,
and include "glib.h" as it needs it.
2015-09-25 15:48:09 +02:00
Thomas Haller c0852964a8 libnm: don't include "nm-version.h" in "nm-dbus-interface.h"
We want "nm-dbus-interface.h" to have no dependancy on libnm and glib.
That way, it is usable for example in the QT examples without dragging
in dependencies to glib.

Also drop all the unneccessary include to "nm-dbus-interface.h", which
we already get by directly or indirectly including "nm-core-types.h".
2015-09-25 15:42:15 +02:00
Jiří Klimeš ffe16c958f libnm-core: add vpn.timeout property for establishing connections
[1] https://mail.gnome.org/archives/networkmanager-list/2015-April/msg00007.html
2015-09-21 16:59:04 +02:00
Jiří Klimeš 3d64d45d16 libnm-core/libnm-util: fix an assertion in adsl setting
(process:7799): GLib-CRITICAL **: g_ascii_strdown: assertion 'str != NULL' failed
2015-09-21 15:21:50 +02:00
Thomas Haller c9b3617c35 libnm: mark properties that take effect immediately on active connection (REAPPLY_IMMEDIATELY)
The flag is still unused.
2015-09-18 17:31:51 +02:00
Thomas Haller b1ebbf4c80 libnm: use NM_FLAGS_HAS() in nm_setting_compare() 2015-09-18 16:37:48 +02:00