Commit graph

688 commits

Author SHA1 Message Date
Marius Vollmer 2ca1ce5d88 team: Add NM_CAPABILITY_TEAM 2016-09-23 15:49:52 +02:00
Marius Vollmer 1bb00ae66a manager: Add "Capabilities" property 2016-09-23 15:49:52 +02:00
Thomas Haller c3ecca225c core: add _nm_utils_array_find_binary_search()
Also add nm_cmp_uint32_p_with_data(). Will be used later.
2016-09-23 15:49:29 +02:00
Thomas Haller 08f5681b0e core: const arguments for _nm_utils_ptrarray_find_*() functions 2016-09-23 15:34:17 +02:00
Thomas Haller 0fb723e720 libnm: relax comparison of bond-option for INFERRABLE match
When comparing the bond-settings of an activated device against
the settings from the connection, some properties might easily
differ. Hack them around in NMSettingBond:compare_property().

For example:

the setting in the connection has:
    [bond]
    mode=active-backup

later, the device gets:
    [bond]
    active_slave=inf_ib0
    fail_over_mac=active
    mode=active-backup

Note that the fail_over_mac changes due to:
  kernel: nm-bond: enslaved VLAN challenged slave inf_ib0. Adding VLANs will be blocked as long as inf_ib0 is part of bond nm-bond
  kernel: nm-bond: The slave device specified does not support setting the MAC address
  kernel: nm-bond: Setting fail_over_mac to active for active-backup mode

https://bugzilla.redhat.com/show_bug.cgi?id=1375558
2016-09-22 18:32:54 +02:00
Thomas Haller b1fd5a06c4 macros: simplify NM_IN_SET() and NM_IN_STRSET() macros
and support up to 16 arguments.
2016-09-22 16:34:22 +02:00
Beniamino Galvani eaad7ae431 libnm-core: drop extra IPs from shared connections during normalization
The core only consider the first address for shared connections, don't
pretend we accept multiple addresses.  This change doesn't prevent
supporting multiple addresses in the future.

https://bugzilla.gnome.org/show_bug.cgi?id=763937
2016-09-14 23:30:41 +02:00
Thomas Haller fae5ecec5a device: change default value for cloned-mac-address to "preserve" (bgo#770611)
Long ago before commit 1b49f94, NetworkManager did not touch the
MAC address at all. Since 0.8.2 NetworkManager would modify the
MAC address, and eventually it would reset the permanent MAC address
of the device.

This prevents a user from externally setting the MAC address via tools
like macchanger and rely on NetworkManager not to reset it to the
permanent MAC address. This is considered a security regression in
bgo#708820.

This only changed with commit 9a354cd and 1.4.0. Since then it is possible
to configure "cloned-mac-address=preserve", which instead uses the "initial"
MAC address when the device activates.
That also changed that the "initial" MAC address is the address which was
externally configured on the device as last. In other words, the
"initial" MAC address is picked up from external changes, unless it
was NetworkManager itself who configured the address when activating a
connection.

However, in absence of an explicit configuration the default for
"cloned-mac-address" is still "permanent". Meaning, the user has to
explicitly configure that NetworkManager should not touch the MAC address.
It makes sense to change the upstream default to "preserve". Although this
is a change in behavior since 0.8.2, it seems a better default.

This change has the drastic effect that all the existing connections
out there with "cloned-mac-address=$(nil)" change behavior after upgrade.
I think most users won't notice, because their devices have the permanent
address set by default anyway. I would think that there are few users
who intentionally configured "cloned-mac-address=" to have NetworkManager
restore the permanent address.

https://bugzilla.gnome.org/show_bug.cgi?id=770611
2016-09-12 14:01:57 +02:00
Thomas Haller 9cf9c3a88e libnm-core: fix crash in nm_vpn_plugin_info_list_get_service_types()
Coverity says, "Dereference after null check". Indeed, @aliases
is usually NULL.

Fixes: 46665898bb
2016-09-09 01:23:11 +02:00
Thomas Haller 814784aa46 libnm: fix regression serializing empty "cloned-mac-address"
For "cloned-mac-address", the empty string "" is an invalid
value that is rejected by verify().

Commit 8eed671 changed how the property is serialized to D-Bus.
Before, it was serialized using _nm_utils_hwaddr_to_dbus().
For invalid or empty addresses, this would not serialize the
value on D-Bus (or before commit 76aa6f8e0, it would create
a bogus value with no array elements).

With commit 8eed671, the cloned-mac-address gets also serialized
as "assigned-mac-address" via _nm_utils_hwaddr_cloned_data_synth(),
which would pass on invalid strings that the server would then reject.

That breaks for example nmtui. Try editing a connection with
"cloned-mac-address" set to NULL. Note, as long as you don't edit
the cloned MAC address in nmtui, you can save the modification.
Once you start modifying the entry, you can no longer set an empty
MAC address as the server now receives the invalid empty string.
Thus, the "OK" button fails with
   Unable to save connection:
   802-3-ethernet.cloned-mac-address:
   is not a valid MAC address
It also means, nmtui cannot modify the "cloned-mac-address" field to
become empty.

Fix that problem at various places by coercing "" to NULL.

Fixes: 8eed67122c

https://bugzilla.redhat.com/show_bug.cgi?id=1372799
2016-09-06 16:11:23 +02:00
Thomas Haller f4d7db964e libnm-core: replace local helper with nm_stdup_not_empty() 2016-09-06 16:07:02 +02:00
Beniamino Galvani d06279f3db libnm: restore verify() comments in team/team-port settings
Restore the comments removed in commit
a524091966afb884cdb8db48067d5599a685a8eb.
2016-08-30 18:20:28 +02:00
Beniamino Galvani d6ec009afd team: normalize invalid configuration during load
Now that we validate the JSON syntax of a team/team-port
configuration, any existing connection with invalid JSON configuration
would fail to load and disappear upon upgrade. Instead, modify the
setting plugins to emit a warning but still load the connection with
empty configuration.
2016-08-30 18:20:28 +02:00
Beniamino Galvani 39ad134b0c Revert "libnm-core/team: normalize invalid config to NULL"
It's better to fail the validation of any invalid configuration
instead of silently ignoring it.

This reverts commit 476810c290.
2016-08-30 18:20:28 +02:00
Thomas Haller f3a60e14e7 doc: clearify deprecated "cloned-mac-address" field in documentation 2016-08-30 14:32:10 +02:00
Yuri Chornoivan 297ade2745 all: fix typos in documentation and translated strings
https://bugzilla.gnome.org/show_bug.cgi?id=770445
2016-08-26 19:00:12 +02:00
Thomas Haller 476810c290 libnm-core/team: normalize invalid config to NULL
A user may very well have connections on disk with bogus json.
Such connections may have failed to activate before, but rejecting
them now as invalid means that we stop loading them from disk. That is,
they disappear after upgrade.

Instead of doing that, also accept invalid json (beside "") and
normalize/coerce it to NULL.

https://bugzilla.redhat.com/show_bug.cgi?id=1366300
2016-08-24 10:58:02 +02:00
Lubomir Rintel 0fc8b856c3 libnm-core/team: treat "" team config as no config
https://bugzilla.redhat.com/show_bug.cgi?id=1366300
2016-08-24 10:57:54 +02:00
Thomas Haller f19aff8909 all: cleanup includes in header files
- don't include "nm-default.h" in header files. Every source file must
  include as first header "nm-default.h", thus our headers get the
  default include already implicitly.

- we don't support compiling NetworkManager itself with a C++ compiler. Remove
  G_BEGIN_DECLS/G_END_DECLS from internal headers. We do however support
  users of libnm to use C++, thus they stay in public headers.
2016-08-17 19:09:50 +02:00
Lubomir Rintel b2eb64a439 release: bump version to 1.5.0 (development) 2016-08-17 16:20:42 +02:00
Alfonso Sanchez-Beato 24b193ab64 device: add statistics interface
Add statistics interface to all device instances. When active, the
properties of this interface are refreshed whenever there is network
activity for the device.

Activation is performed by changing RefreshRateMs property. If set to
zero, the interface is deactivated. If set to other value, the rest of
the interface properties are refreshed whenever the related network
metric changes, being RefreshRateMs the minimum time between property
changes, in milliseconds.
2016-08-17 15:50:20 +02:00
Beniamino Galvani 3e09aed2a0 checkpoint: add create, rollback and destroy D-Bus API
Co-authored-by: Thomas Haller <thaller@redhat.com>
2016-08-17 14:55:34 +02:00
Jiří Klimeš 8fc199ae96 libnm-core: fix invalid return annotation for nm_vpn_editor_plugin_set_plugin_info() 2016-08-10 22:30:50 +02:00
Jiří Klimeš 560f810bf5 libnm-core: add missing element-type annotation 2016-08-10 22:24:10 +02:00
Jiří Klimeš 3a50a46fb9 libnm-core: fix GObject introspection transfer annotations 2016-08-10 22:24:10 +02:00
Lubomir Rintel 9b96bfaa72 setting-vpn: whatever is in vpn.secrets always is a secrets
Even when there's no <secret>-flags key for it in vpn-data.

This is essentially to fix regression in the way openconnect uses the VPN
secrets:

Openconnect auth helper is essentially a web browser that fills in an arbitrary
HTML (or XML) form that's used to get the session cookie. The actual secret the
service needs is the cookie itself.

However, what needs to be remembered includes the form data. What data can be
in the form is installation dependent and can not be known in advance. Thus the
flags for it can't be currently set in the connection. The auth helper is not
capable of setting the flags either, because it can only return secrets.

Prior to 1424f249e we treated vpn.secrets without the flags as system secrets
and store them in the connection. Since that commit we just filter them away,
which broke user configurations.

This restores the behavior or treating everyting in vpn.secrets as secrets and
falling back to system secrets.

Another way would be to find a way to flag the secrets, perhaps by
extending the auth helper protocol to be able to store non-secret
properties too.

https://bugzilla.gnome.org/show_bug.cgi?id=768737
2016-07-19 16:14:51 +02:00
poma 846dc443ce doc: fix typo for cloned-mac-address documentation
https://mail.gnome.org/archives/networkmanager-list/2016-July/msg00006.html
2016-07-11 21:24:04 +02:00
Thomas Haller d060958a6d libnm: minor cleanup of _bin2str() 2016-07-10 13:51:57 +02:00
Thomas Haller 36856ba610 all: reuse _nm_utils_hwaddr_ntoa() for converting binary to string 2016-07-10 13:44:58 +02:00
Lubomir Rintel f24d44ee87 libnm-core: drop unused variable
Fixes: ac73758305
2016-07-07 11:41:41 +02:00
Beniamino Galvani f33a620b97 bond: fix default value for 'ad_actor_system' option
Even if the 'ad_actor_system' option is only valid for the 802.3ad
mode, the sysfs file is always present and has a default value of
''. But in 802.3ad mode the default value is
'00:00:00:00:00:00'. Return the correct value in
nm_setting_bond_get_option_default().

Furthermore, writing a empty string to the file will generate an
error, don't do it.
2016-07-06 15:20:53 +02:00
Beniamino Galvani dd1c453ff7 bond: improve compatibility check of options and modes
We print an error when the write of a bond options fails as this is
considered an effect of a wrong configuration (or a bug in the checks
done by NM) that the user should notice. But not all options are
supported in all bonding modes and so we ignore some unsupported
options for the current mode to avoid populating logs with useless
errors.

Improve the code there by using a more generic approach and
synchronize the mode/option compatibility table with kernel (file
drivers/net/bonding/bond_options.c).

https://bugzilla.gnome.org/show_bug.cgi?id=767776
https://bugzilla.redhat.com/show_bug.cgi?id=1352131
2016-07-06 15:20:53 +02:00
Beniamino Galvani ac73758305 libnm-core: ip-config: normalize may-fail for disabled IP methods
Since commit 7d1709d7f6 ("device: check may_fail when progressing to
IP_CHECK") NM correctly checks the may-fail properties to decide
whether a connection must fail after the completion of IP
configuration. But for ipv4.method=disabled and ipv6.method=ignore the
IP configuration is always considered failed and thus setting
may-fail=no results in a connection that can never succeed.

To prevent such wrong configuration, force may-fail to TRUE for those
methods during connection normalization.

https://bugzilla.redhat.com/show_bug.cgi?id=1334884
2016-07-06 09:52:35 +02:00
Thomas Haller 375d3e1cb8 vpn: support option to preserve previous routing information on VPN config update
On openvpn restart, the VPN helper script is invoked without full routing information.
Thus, the routes will be dropped because the helper script cannot provide them
on update.

Add an option "preserve-route" which tells NetworkManager to preserve
and reuse the previous configuration.

https://bugzilla.redhat.com/show_bug.cgi?id=1231338
https://bugzilla.gnome.org/show_bug.cgi?id=750873
2016-07-04 10:31:05 +02:00
Beniamino Galvani c827ad64cf libnm-core: suppress compiler warning in mac_address_parser()
@buf_len is always initialized when @buf_arr is set but gcc fails to
recognize it:

../libnm-core/nm-keyfile-reader.c: In function 'mac_address_parser':
../libnm-core/nm-keyfile-reader.c:654:36: error: 'buf_len' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  tmp_string = nm_utils_hwaddr_ntoa (buf_arr, buf_len);

Fixes: 8eed67122c
2016-07-01 09:42:50 +02:00
Thomas Haller 96cabbcbb8 all: make MAC address randomization algorithm configurable
For the per-connection settings "ethernet.cloned-mac-address"
and "wifi.cloned-mac-address", and for the per-device setting
"wifi.scan-rand-mac-address", we may generate MAC addresses using
either the "random" or "stable" algorithm.

Add new properties "generate-mac-address-mask" that allow to configure
which bits of the MAC address will be scrambled.

By default, the "random" and "stable" algorithms scamble all bits
of the MAC address, including the OUI part and generate a locally-
administered, unicast address.

By specifying a MAC address mask, we can now configure to perserve
parts of the current MAC address of the device. For example, setting
"FF:FF:FF:00:00:00" will preserve the first 3 octects of the current
MAC address.

One can also explicitly specify a MAC address to use instead of the
current MAC address. For example, "FF:FF:FF:00:00:00 68:F7:28:00:00:00"
sets the OUI part of the MAC address to "68:F7:28" while scrambling
the last 3 octects.
Similarly, "02:00:00:00:00:00 00:00:00:00:00:00" will scamble
all bits of the MAC address, except clearing the second-least
significant bit. Thus, creating a burned-in address, globally
administered.

One can also supply a list of MAC addresses like
"FF:FF:FF:00:00:00 68:F7:28:00:00:00 00:0C:29:00:00:00 ..." in which
case a MAC address is choosen randomly.

To fully scamble the MAC address one can configure
"02:00:00:00:00:00 00:00:00:00:00:00 02:00:00:00:00:00".
which also randomly creates either a locally or globally administered
address.

With this, the following macchanger options can be implemented:

  `macchanger --random`
   This is the default if no mask is configured.
   -> ""
   while is the same as:
   -> "00:00:00:00:00:00"
   -> "02:00:00:00:00:00 02:00:00:00:00:00"

  `macchanger --random --bia`
   -> "02:00:00:00:00:00 00:00:00:00:00:00"

  `macchanger --ending`
   This option cannot be fully implemented, because macchanger
   uses the current MAC address but also implies --bia.
   -> "FF:FF:FF:00:00:00"
      This would yields the same result only if the current MAC address
      is already a burned-in address too. Otherwise, it has not the same
      effect as --ending.
   -> "FF:FF:FF:00:00:00 <MAC_ADDR>"
      Alternatively, instead of using the current MAC address,
      spell the OUI part out. But again, that is not really the
      same as macchanger does because you explictly have to name
      the OUI part to use.

  `machanger --another`
  `machanger --another_any`
  -> "FF:FF:FF:00:00:00 <MAC_ADDR> <MAC_ADDR> ..."
     "$(printf "FF:FF:FF:00:00:00 %s\n" "$(sed -n 's/^\([0-9a-fA-F][0-9a-fA-F]\) \([0-9a-fA-F][0-9a-fA-F]\) \([0-9a-fA-F][0-9a-fA-F]\) .*/\1:\2:\3:00:00:00/p' /usr/share/macchanger/wireless.list | xargs)")"
2016-06-30 08:32:50 +02:00
Thomas Haller b7d76b2277 libnm: deprecated wireless.mac-address-randomization property for wireless.cloned-mac-address 2016-06-30 08:29:56 +02:00
Thomas Haller 8eed67122c device: extend MAC address handling including randomization for ethernet and wifi
Extend the "ethernet.cloned-mac-address" and "wifi.cloned-mac-address"
settings. Instead of specifying an explicit MAC address, the additional
special values "permanent", "preserve", "random", "random-bia", "stable" and
"stable-bia" are supported.

"permanent" means to use the permanent hardware address. Previously that
was the default if no explict cloned-mac-address was set. The default is
thus still "permanent", but it can be overwritten by global
configuration.

"preserve" means not to configure the MAC address when activating the
device. That was actually the default behavior before introducing MAC
address handling with commit 1b49f941a6.

"random" and "random-bia" use a randomized MAC address for each
connection. "stable" and "stable-bia" use a generated, stable
address based on some token. The "bia" suffix says to generate a
burned-in address. The stable method by default uses as token the
connection UUID, but the token can be explicitly choosen via
"stable:<TOKEN>" and "stable-bia:<TOKEN>".

On a D-Bus level, the "cloned-mac-address" is a bytestring and thus
cannot express the new forms. It is replaced by the new
"assigned-mac-address" field. For the GObject property, libnm's API,
nmcli, keyfile, etc. the old name "cloned-mac-address" is still used.
Deprecating the old field seems more complicated then just extending
the use of the existing "cloned-mac-address" field, although the name
doesn't match well with the extended meaning.

There is some overlap with the "wifi.mac-address-randomization" setting.

https://bugzilla.gnome.org/show_bug.cgi?id=705545
https://bugzilla.gnome.org/show_bug.cgi?id=708820
https://bugzilla.gnome.org/show_bug.cgi?id=758301
2016-06-30 08:29:56 +02:00
Thomas Haller 76aa6f8e0d libnm: don't serialize empty hardware address on D-Bus
_nm_utils_hwaddr_to_dbus() would serialize invalid hardware addresses
as "'cloned-mac-address': <@ay []>".

An empty array is treated the same as no hardware address set,
so we should not serialize it in the first place.

This is a change in behavior on how the connection is exported
on D-Bus, but it should not have any bad consequences.

We need this as we later want to deprecate the 'cloned-mac-address'
D-Bus field and overwrite it via a 'assigned-mac-address' field.
In this case, the "<@ay []>" is interfering. While it could be worked
around by treating an empty MAC address as "unset", fix it instead
and just not serialize it.
2016-06-30 08:29:54 +02:00
Thomas Haller fc527a237c libnm: add internal util function _nm_utils_hwaddr_length() 2016-06-30 08:29:54 +02:00
Thomas Haller 807f846610 libnm: fix comparing NMSettingIPConfig for address and route properties
When comparing settings, nm_setting_compare() performs a complicated
logic, which basically serializes each GObject property to a GVariant
for the D-Bus representation.
That is wrong for example for ipv4.addresses, which don't contain
address labels. That is, the GObject property is called "addresses",
but the D-Bus field "addresses" cannot encode every information
and thus comparison fails. Instead, it would have to look into
"address-data".

Traditionally, we have virtual functions like compare_property() per
NMSetting to do the comparison. That comparison is based on the GObject
properties. I think that is wrong, because we should have a generic
concept of what a property is, independent from GObject properties.
With libnm, we added NMSettingProperty, which indeed is such an
GObject independent representation to define properties.
However, it is not used thoroughly, instead compare_property() is a hack
of special cases, overloads from NMSettingProperty, overloads of
compare_property(), and default behavior based on GParamSpec.
This should be cleaned up.

For now, just hack it by handle the properties with the problems
explicitly.
2016-06-30 08:29:54 +02:00
Thomas Haller 0a5af391e0 core: prefer connection.stable-id to generate IPv6 stable privacy addresses
The Network_ID for generating RFC 7217 stable privacy IPv6 addresses
is by default the UUID of the connection.

Alternatively, prefer "connection.stable-id" as Network_ID to generate
the stable addresses. This allows to configure a set of connections that
all use the same Network_ID for generating stable addresses.

Note that the stable-id and the UUID do no overlap, that is two
connections
    [connection]
    uuid=uuid1
    stable-id=
and
    [connection]
    uuid=uuid2
    stable-id=uuid1
generate distinct addresses.
2016-06-30 08:29:54 +02:00
Thomas Haller 3f3ea1df21 libnm: add NMSettingConnection:stable-id property
This new property be used as token to generate stable-ids instead
of the connection's UUID.

Later, this will be used by ipv6.addr-gen-mode=stable-privacy,
ethernet.cloned-mac-address=stable, and wifi.cloned-mac-address=stable
setting. Those generate stable addresses based on the connection's
UUID, but allow to use the stable-id instead.

This allows multiple connections to generate the same addresses
-- on the same machine, because in the above cases a machine
dependant key is also hashed.
2016-06-30 08:29:54 +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 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 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 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 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 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 ad1cdcf657.

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 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
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 aa04e04c83 libnm/tests: fix memleak in test test_nm_utils_check_valid_json()
Fixes: 82f8a54854
2016-06-02 10:01:58 +02:00
Thomas Haller 1d0e0eeffd manager: add Reload() D-Bus command
Add new Reload D-Bus command to reload NetworkManager configuration.

For now, this is like sending SIGHUP to the process. There are several
advantages here:

  - it is guarded via PolicyKit authentication while signals
    can only be sent by root.

  - the user can wait for the reload to be complete instead of sending
    an asynchronous signal. For now, we operation completes after
    nm_config_reload() returns, but later we could delay the response
    further until specific parts are fully reloaded.

  - SIGHUP reloads everything including re-reading configuration from
    disk while SIGUSR1 reloads just certain parts such as writing out DNS
    configuration anew.
    Now, the Reload command has a flags argument which is more granular
    in selecting parts which are to be reloaded. For example, via
    signals the user can:

      1) send SIGUSR1: this writes out the DNS configuration to
         resolv.conf and possibly reloads other parts without
         re-reading configuration and without restarting the DNS plugin.
      2) send SIGHUP: this reloads configuration from disk,
         writes out resolv.conf and restarts the DNS plugin.

    There is no way, to only restart the DNS plugin without also reloading
    everything else.
2016-06-01 19:06:34 +02:00
Beniamino Galvani 0dc999d80e libnm-core: fix comparison of team configuration
NMSettingTeam implements a custom compare_property() method in order
to perform a relaxed matching on team configurations when it is
necessary to assume a connection. However, the method is called also
when the core needs to check if a connection has changed before an
update. In that case it is better to use the default string comparison
on the property, otherwise the second of these commands would not have
effect:

 $ nmcli connection modify team0 team.config ''
 $ nmcli connection modify team0 team.config '{ }'

because compare_property() returns TRUE. Use the @flags argument to
distinguish the two cases.

Fixes: 82f8a54854
2016-05-31 10:59:43 +02:00
Lubomir Rintel 954d937b2f setting-ip6-config: add token property 2016-05-30 16:32:06 +02:00
Lubomir Rintel 0c40bce314 core-utils: add conversions of ipv6 tokens
From/to strings and interface identifiers.
2016-05-30 16:19:20 +02:00
Thomas Haller f664c04973 libnm/keyfile: sort entries for writing hash-of-strings
This sorts the entries of the [vpn] section alphabetically.

The sorting order doesn't really matter, but having a defined,
stable way to export a connection is preferred. Also, it looks
better when looking at the keyfile with an editor.
2016-05-23 10:15:17 +02:00
Thomas Haller 81499355b0 libnm: don't require initialized @out_encrypted argument in nm_utils_file_is_private_key()
No need to require the caller to initialize the optional out-argument.
Otherwise we get:

  (nm-connection-editor:2471): libnm-CRITICAL **: nm_utils_file_is_private_key: assertion 'out_encrypted == NULL || *out_encrypted == FALSE' failed

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

Fixes: 1c4f41c610
2016-05-13 14:26:32 +02:00
Beniamino Galvani c5f17531b9 ifcfg-rh: add support for DNS priority 2016-05-12 17:13:50 +02:00
Beniamino Galvani bdd0e7fec0 libnm-core: add dns-priority to NMSettingIPConfig 2016-05-12 17:13:50 +02:00
Thomas Haller ba90c9601c all: replace nm_unauto() by g_steal_pointer()
They do essentially the same.
2016-05-12 14:28:44 +02:00
Beniamino Galvani f1d23c32c3 docs: libnm: add doc comment to types
This is required to add objects in the "Types and Values" section and
in the API index. Later, we may want to add useful content in those
empty comments.
2016-05-05 17:01:57 +02:00
Thomas Haller c5ac691744 build: cleanup includes of <gmodule.h>
<gmodule.h> is implicitly included by <gio/gio.h> which is available
everywhere. For that reason, we would not have to include this header
at all. However, it is recommended to explicitly include <gmodule.h>
where needed.

So, include it where needed -- if <gio/gio.h> wouldn't be there --
and drop it from where it is not needed.
2016-04-30 03:42:16 +02:00
Thomas Haller 264189e756 libnm/vpn: don't close the VPN plugin library on cleanup
Closing the library will interfere badly as the glib types cannot be
unregistered. We must leak the library handle.

Switch to dlopen() instead of g_module_open(), because the former
supports RTLD_NOLOAD. This is useful for two reasons:

  - checking the file prior loading only makes any sense when
    dlopen() would actually load a file anew.

  - if the library was loaded before, we want to return the handle.
    On the other hand, if the library was not loaded, we leak the
    handle.

Thereby, refactor the code from if-else blocks to return-early, because
the function nicely does individual steps and if one fails just error
out.
2016-04-29 15:38:29 +02:00
Thomas Haller b52485b34b libnm/vpn: fix checking service name in nm_vpn_plugin_info_new_search_file()
Fixes: 3adf782ab5
2016-04-29 15:28:04 +02:00
Thomas Haller c1147fc71b libnm/vpn: don't leak editor-plugin if nm_vpn_editor_plugin_load() fails 2016-04-28 15:00:04 +02:00
Thomas Haller d350d72a2e libnm: store NMConnectionPrivate via g_object_set_qdata()
g_object_get_data() and g_object_get_qdata() end up to be identical,
except that g_object_get_data() also requires to intern the string
on every lookup (which involves a hash lookup and locking).
2016-04-28 14:58:17 +02:00
Beniamino Galvani c1907a218a libnm-core: remove gateway when never-default=yes in NMSettingIPConfig
Having a gateway defined when never-default=yes causes troubles in
connection matching and anyway makes no sense.

If the combination is found, remove the gateway during the
normalization phase.

https://bugzilla.redhat.com/show_bug.cgi?id=1313091
2016-04-27 17:15:49 +02:00
Thomas Haller bad9becf99 libnm/doc: fix documentation of NMSettingIP6Config:addr-gen-mode
The value cannot be unset. It must be set to one of the two currently
supported values.
2016-04-25 16:52:34 +02:00
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