Commit graph

688 commits

Author SHA1 Message Date
Thomas Haller dc40288849 all: use NM_CACHED_QUARK_FCN() to define cached quarks 2017-02-10 14:33:52 +01:00
Thomas Haller 7d6b8bab70 all: use NM_CACHED_QUARK_FCN() instead of G_DEFINE_QUARK()
I think NM_CACHED_QUARK_FCN() is better because:

- the implementation is in our hand, meaning it is clear that
  putting a "static" before NM_CACHED_QUARK_FCN() is guaranteed to
  work -- without relying on G_DEFINE_QUARK() to be defined in a way
  that this works (in fact, we currently never do that and instead
  make all functions non-static).
- it does not construct function names by appending "_quark".
  Thus you can grep for the entire function name and finding
  the place where it is implemented.
- same with the stings, where the new macro doesn't stringify the
  argument, which is less surpising. Again, now you can grep
  for the string including the double quoting.

(yes, I really use grep to understand the source-code)
2017-02-10 14:33:52 +01:00
Thomas Haller cb365b33f3 build: fix -Wold-style-declaration warnings
libnm-core/nm-setting-bond.c:502:1: error: ‘static’ is not at beginning of declaration [-Werror=old-style-declaration]
     const static struct {
     ^~~~~

    In file included from clients/cli/common.c:32:0:
    ./clients/common/nm-vpn-helpers.h:27:1: error: ‘typedef’ is not at beginning of declaration [-Werror=old-style-declaration]
     } typedef VpnPasswordName;
    ^
2017-02-06 19:27:21 +01:00
Thomas Haller 31c0c66c0e settings: drop redundant range check from NMSettingBridgePort::verify()
priv->path_cost and priv->priority can only be set as GObject properties,
which already does the same range check. Hence, the checks are never reached.

This also avoids a compiler warning:

    libnm-core/nm-setting-bridge-port.c: In function ‘verify’:
    libnm-core/nm-setting-bridge-port.c:132:22: error: comparison is always false due to limited range of data type [-Werror=type-limits]
      if (priv->path_cost > BR_MAX_PATH_COST) {
                          ^
2017-02-06 19:27:21 +01:00
Thomas Haller 7c6c8f0d8b all: cleanup switch fall-through comments for -Wimplicit-fallthrough warning
The -Wimplicit-fallthrough=3 warning is quite flexible of accepting
a fall-through warning.

Some comments were missing or not detected correctly.

Thereby, also change all other comments to follow the exact
same pattern.
2017-02-06 16:45:20 +01:00
Thomas Haller 11bc3f191e all: use nm_utils_strv_find_first() from shared/nm-utils 2017-02-04 17:55:30 +01:00
Beniamino Galvani 660bb1a48f libnm-core: return NULL from _nm_utils_slist_to_strv for empty lists
The function is used, among others, in the get_property() of many
objects to return a boxed strv from a list. The default value for a
boxed strv property is NULL, but _nm_utils_slist_to_strv() returns a
pointer to an array with zero elements when the list is empty.

Change the function to return NULL if the input list is empty.
2017-02-02 13:45:27 +01:00
Thomas Haller 7f63c875f9 libnm-core: clear wifi.mac-address-randomization when unsetting wifi.cloned-mac-address
When a client clears wifi.cloned-mac-address, he clearly also want
to clear the deprected wifi.mac-address-randomization property.

Do that automatically in libnm.

https://mail.gnome.org/archives/networkmanager-list/2017-January/msg00060.html
2017-01-28 17:17:14 +01:00
Thomas Haller d5685c183c release: bump version to 1.7.0 (development)
belatedly...
2017-01-18 18:37:06 +01:00
Thomas Haller a5acd0bdc6 tests: fix tests without libjansson support (--enable-json-validation=no) 2017-01-17 23:51:57 +01:00
Jiří Klimeš 8ac33b02b3 libnm-core: add ifcfg-rh documentation for proxy settings
PROXY_METHOD
BROWSER_ONLY
PAC_URL
PAC_SCRIPT
2017-01-17 14:27:31 +01:00
Jiří Klimeš addac21270 libnm-core: adjust the documentation of proxy setting
* fix capitalization of abbreviations and normal words
 * use % for Gtk-Doc values
 * and other adjustmens
2017-01-17 14:27:31 +01:00
Jiří Klimeš e2c4d4d2c9 libnm-core: (trivial) fix white spaces in proxy setting 2017-01-17 14:27:31 +01:00
Beniamino Galvani d252a99fa2 libnm-core: add NMSettingMacsec
The new NMSettingMacsec contains information necessary to establish a
MACsec connection. At the moment we support two different MACsec
modes, both using wpa_supplicant: PSK and EAP.

PSK mode is based on a static CAK key for the MACsec key agreement
protocol, while EAP mode derives keys from a 802.1x authentication and
thus requires the presence of a NMSetting8021x in the connection.
2017-01-16 17:37:14 +01:00
Beniamino Galvani 67adbda83e core,libnm: introduce NMDeviceMacsec
At the moment the device only exposes the current link status, but
cannot create new links.
2017-01-16 17:37:14 +01:00
Thomas Haller 803467fe93 libnm: fix leak in nm_setting_802_1x_set_phase2_ca_cert()
Fixes: 2b09cee6fa
2017-01-16 17:20:35 +01:00
Beniamino Galvani 334a8a54be libnm-core: fix documentation warnings
libnm-core/nm-setting-8021x.c:658: Warning: NM: nm_setting_802_1x_set_ca_cert: unknown parameter 'value' in documentation comment, should be 'cert_path'
libnm-core/nm-setting-8021x.c:1023: Warning: NM: nm_setting_802_1x_set_client_cert: unknown parameter 'value' in documentation comment, should be 'cert_path'
libnm-core/nm-setting-8021x.c:1331: Warning: NM: nm_setting_802_1x_set_phase2_ca_cert: unknown parameter 'value' in documentation comment, should be 'cert_path'
libnm-core/nm-setting-8021x.c:1702: Warning: NM: nm_setting_802_1x_set_phase2_client_cert: unknown parameter 'value' in documentation comment, should be 'cert_path'
libnm-core/nm-setting-8021x.c:2027: Warning: NM: nm_setting_802_1x_set_private_key: unknown parameter 'value' in documentation comment, should be 'key_path'
libnm-core/nm-setting-8021x.c:2374: Warning: NM: nm_setting_802_1x_set_phase2_private_key: unknown parameter 'value' in documentation comment, should be 'key_path'

Fixes: 2b09cee6fa
2017-01-12 14:38:26 +01:00
Lubomir Rintel 33c3ed8991 libnm-core/8021x: don't prefix PKCS#11 URIs with "pkcs11:"
They already include the scheme prefix.
2017-01-10 23:30:18 +01:00
Thomas Haller f0d40525df device: support dynamic "connection.stable-id" in form of text-substitution
Usecase: when connecting to a public Wi-Fi with MAC address randomization
("wifi.cloned-mac-address=random") you get on every re-connect a new
IP address due to the changing MAC address.
"wifi.cloned-mac-address=stable" is the solution for that. But that
means, every time when reconnecting to this network, the same ID will
be reused. We want an ID that is stable for a while, but at a later
point a new ID should e generated when revisiting the Wi-Fi network.

Extend the stable-id to become dynamic and support templates/substitutions.
Currently supported is "${CONNECTION}", "${BOOT}" and "${RANDOM}".
Any unrecognized pattern is treated verbaim/untranslated.

"$$" is treated special to allow escaping the '$' character. This allows
the user to still embed verbatim '$' characters with the guarantee that
future versions of NetworkManager will still generate the same ID.
Of course, a user could just avoid '$' in the stable-id unless using
it for dynamic substitutions.

Later we might want to add more recognized substitutions. For example, it
could be useful to generate new IDs based on the current time. The ${} syntax
is extendable to support arguments like "${PERIODIC:weekly}".

Also allow "connection.stable-id" to be set as global default value.
Previously that made no sense because the stable-id was static
and is anyway strongly tied to the identity of the connection profile.
Now, with dynamic stable-ids it gets much more useful to specify
a global default.

Note that pre-existing stable-ids don't change and still generate
the same addresses -- unless they contain one of the new ${} patterns.
2017-01-09 14:50:33 +01:00
Thomas Haller 46d53e1101 keyfile: fix interpreting missing wifi.mac-address-randomization as permanent address
With commit 4f6c91d696, we aimed to
enable mac-address-randomization by default for Wi-Fi. That however
is not possible by default because it breaks various scenarios.
Also, later wifi.mac-address-randomization was deprecated in favor
of wifi.cloned-mac-address setting.

Both wifi.mac-address-randomization and wifi.cloned-mac-address support
global default values, so it is wrong to read a missing
mac-address-randomization as "NEVER" -- which due to
normalization also results in cloned-mac-address=permanent.
2017-01-09 14:50:33 +01:00
Lubomir Rintel 2b09cee6fa libnm-core/8021x: fix up scheme handling in setters
Fixes: 690e33bdf2
2017-01-06 16:14:13 +01:00
Lubomir Rintel faed200b2b keyfile: add support for pkcs11: URI scheme 2017-01-06 15:56:11 +01:00
Lubomir Rintel 690e33bdf2 libnm-core/8021x: make cert/key setters handle pkcs11 URI scheme 2017-01-06 15:56:11 +01:00
Lubomir Rintel 84c57c34bc libnm-core/8021x: add pkcs11: scheme for certificates and keys
The getters just return the whole URI as-is, without any mangling.
2017-01-06 15:56:11 +01:00
Lubomir Rintel f9be6540b0 libnm-core: deprecate nm_utils_iface_valid_name()
We don't use it internally and a better version exists. Not like we
could drop it or anything.
2017-01-06 15:11:56 +01:00
Lubomir Rintel 260563a7d9 all: use nm_utils_is_valid_iface_name() 2017-01-06 15:11:56 +01:00
Lubomir Rintel ac0563d784 libnm-core: add nm_utils_is_valid_iface_name()
Version of nm_utils_iface_valid_name() with error reporting.
2017-01-06 15:11:56 +01:00
Thomas Haller e844df1099 keyfile: write also empty byte arrays to keyfiles
It's not the job of keyfile writer to enforce certain settings. A
%NULL GBytes property is shall be treated distinct from a byte array
with zero length.

The NMSetting may or may not reject such settings as invalid during
verify() or mangle them during normalize(). But reader/writer should
just serialize every property as-is.
2017-01-05 12:26:18 +01:00
Thomas Haller 932da77b5b keyfile: assert that write_array_of_uint() writes valid integer list
We use write_array_of_uint() for G_TYPE_ARRAY. In practice, only
NMSettingDcb has any properties of this type.

Furthermore, all valid values are either gboolean or guints of
restricted range. Thus, no valid NMSettingDcb should violate the
range check.

Same for reader.

It's really ugly to blindly use uint-list reader for G_TYPE_ARRAY.
Especially, because certain G_TYPE_ARRAY properties of NMSettingDcb
are actually arrays of gboolean, which only ~accidentally~ has the same
memory layout as guint.
2017-01-05 12:00:54 +01:00
Thomas Haller 138d1e3b7b keyfile: use nm_keyfile_plugin_kf_set_integer_list_uint8() helper 2017-01-05 12:00:54 +01:00
Thomas Haller e965718ddd keyfile: add nm_keyfile_plugin_kf_set_integer_list_uint8() helper 2017-01-05 12:00:54 +01:00
Thomas Haller 5e7b14af03 keyfile: refactor parsing in get_bytes() to replace regex
No longer use a regex to pre-evaluate whether @tmp_string looks
like a integer list. Instead, parse the integer list ourself.

First, drop the nm_keyfile_plugin_kf_has_key() check.
Note that this merely verifies that such a key exits. It's rather
pointless, because get_bytes() is only called for existing keys.
Still, in case the check would actually yield differing results
from the following nm_keyfile_plugin_kf_get_string(), we want to
act depending on what nm_keyfile_plugin_kf_get_string() returns.

Note that nm_keyfile_plugin_kf_get_string() looks up the key, alternatively
fallback to the settings alias. Then, GKeyFile would parse the raw keyfile
value and return it as string.
Previously, we would first decide whether @tmp_string look like a integer list
to decide wether to parse it via nm_keyfile_plugin_kf_get_integer_list().

But note that it's not clear that nm_keyfile_plugin_kf_get_integer_list()
operates on the same string as nm_keyfile_plugin_kf_get_string().
Could it decide to return different strings based on whether such
a key exists?
E.g. when setting "802-11-wireless.ssid=foo" and "wifi.ssid=60;" they
clearly would yield differing results: "foo" vs. [60].
Ok, probably it is not an issue because we call first
nm_keyfile_plugin_kf_get_string(), decide whether it looks like a
integer list, and return "foo" right away.
This is still confusing and relyies on knowledge about how the value
is encoded as string-list.

Likewise, could our regex determine that the value looks like a integer
list but then the integer list is unable to parse it? Certainly that can
happen for values larger then 255.

Just make it consistent. Get *one* @tmp_string. Try (manually) to
interpret it as string list, or bail using it as plain text.

Also, allow returning empty GBytes arrays. If somebody specifies an
empty list, it's empty. Not NULL.
2017-01-05 12:00:54 +01:00
Thomas Haller 8239edbb9b keyfile: fix memleak in keyfile reader's read_array_of_uint()
Fixes: 9559a7a260
2017-01-05 11:13:17 +01:00
Thomas Haller 9d2207b46d libnm: explicitly set enum values in public nm-dbus-interface.h headers
Previously, due to a bug in "tools/enums-to-docbook.pl", enum values
without explicit numeric value were wrongly parsed. That is fixed,
but still explicitly set the value in the public header.
2017-01-04 09:33:57 +01:00
Thomas Haller 16aeac5c3e libnm: add nm_utils_version() function to query libnm version at runtime
if (nm_utils_version () < NM_ENCODE_VERSION (1, 5, 0))
        g_error ("Requires at least version 1.5.0");
2016-12-20 16:51:58 +01:00
Thomas Haller d136f0fedc libnm/docs: clarify "ipvx.dns-priority" setting in documentation
https://bugzilla.redhat.com/show_bug.cgi?id=1403594
2016-12-19 13:26:23 +01:00
Jiří Klimeš 3803739808 libnm-core: (trivial) fix a typo 2016-12-15 15:31:56 +01:00
Jiří Klimeš 7a6ed633fb man/ifcfg-rh: mark some ifcfg-rh variables with (+) as NM extensions 2016-12-15 15:08:03 +01:00
Lubomir Rintel 8b7b0d3fc2 ifcfg-rh: write the master device name even if the master property is an UUID
We used MASTER, BRIDGE and TEAM_MASTER keys for a differnet purpose than the
network.service did, confusing the legacy tooling. Let's do our best to write
compatible configuration files:

* Add *_UUID properties that won't clash with initscripts
* Ignore non-*_UUID keys on read if *_UUID is present
* If the connection.master is an UUID of a connection with a
  connection.interface-name, write the uuid into the *_UUID key while setting
  the non-*_UUID key to the interface name for compatibility

https://bugzilla.redhat.com/show_bug.cgi?id=1369091
2016-12-15 11:45:34 +01:00
Thomas Haller eb77d4ed28 libnm-core/utils: remove unused code from nm_utils_hwaddr_matches()
Makes coverity complain.
2016-12-13 18:49:34 +01:00
Thomas Haller f2355633a9 man: clarify NMSettingIPConfig:dns-options in documentation 2016-12-13 12:55:07 +01:00
Beniamino Galvani a8d6005256 libnm: implement support for DNS manager properties 2016-12-12 22:06:24 +01:00
Thomas Haller 92ea1bdb06 proxy: stricter validate the proxy pac script in NMSettingProxy 2016-12-06 22:01:41 +01:00
Beniamino Galvani 025235e00f ppp: split ppp manager into a plugin
Moving the PPP manager to a separate plugin that is loaded when needed
has the advantage of slightly reducing memory footprint and makes it
possible to install the PPP support only where needed.

https://bugzilla.gnome.org/show_bug.cgi?id=773482
2016-12-06 11:08:11 +01:00
poma fde46d7e65 libnm-core/man: add a warning on static link negotiation parameters
When disabling link autonegotiation and setting speed and duplex manually,
the user is alone: no check is performed against supplied values.
So, the user is supposed to check that the device supports those values.
Explicit this in nm-settings man page.

[fgiudici@redhat.com: added the commit message]
2016-12-01 10:41:06 +01:00
Thomas Haller 55fb25f59d libnm: force unsigned integer comparisong in nm_utils_bin2hexstr()
Not really a big issue, without the case the intergers
would be compared as ssize_t, which is large enough for
final_len, but possibly not for buflen.
2016-11-28 10:21:24 +01:00
Thomas Haller 3aa41c6e17 libnm: merge hwaddr_aton() and nm_utils_hexstr2bin()
Have nm_utils_hexstr2bin() take over the allocated buffer
via g_bytes_new_take().
2016-11-28 10:06:27 +01:00
Thomas Haller d7e535aee5 libnm/trivial: rename internal function _bin2str() 2016-11-28 08:50:35 +01:00
Thomas Haller 4cc2f8906c libnm: drop _bin2str() util
It was only used by two places, inline it.
2016-11-27 13:57:13 +01:00
Thomas Haller 542d1c257d libnm: implement nm_utils_bin2hexstr() via _bin2str_buf() 2016-11-27 13:54:23 +01:00