Commit graph

19004 commits

Author SHA1 Message Date
Thomas Haller
1cbbefcddd core/trivial: unify names of internal NMActRequestGetSecretsCallId as "call_id" 2017-11-24 16:44:28 +01:00
Thomas Haller
966ac03668 core: drop internal typedef Result for NMSecretAgentCallId
Using an internal alias for the type is just confusing. Drop it.
2017-11-24 16:44:28 +01:00
Thomas Haller
370dc8883f core: drop internal typedef GetSecretsInfo for NMSecretAgentCallId
Using an internal alias for the type is just confusing. Drop it.
2017-11-24 16:31:58 +01:00
Thomas Haller
e5e291b65f core: refactor NMActRequestGetSecretsCallId typedef not to be a pointer to struct
Typedefs to structs are fine, but a typedef for a pointer seems confusing to
me. Let's avoid it.
2017-11-24 16:31:29 +01:00
Thomas Haller
6cb40da2f0 core: refactor NMSecretAgentCallId typedef not to be a pointer to struct
Typedefs to structs are fine, but a typedef for a pointer seems confusing to
me. Let's avoid it.
2017-11-24 16:24:40 +01:00
Thomas Haller
26e7abc65e libnm: be more accepting parsing boolean values in nm_utils_parse_variant_attributes()
We should use the same str2bool parser everywhere: _nm_utils_ascii_str_to_bool().
Incidentally, this function allows more forms of expressing a boolean
value.

  $ nmcli connection modify "$CON" ipv4.routes '1.2.3.4/32 1.2.3.1 onlink=1'
  Error: failed to modify ipv4.routes: invalid option 'onlink=1': invalid boolean value '1' for attribute 'onlink'.
2017-11-24 12:28:56 +01:00
Beniamino Galvani
bcf374e75f ifcfg-rh: merge branch 'bg/ifcfg-rh-bridge-mac-rh1516659'
https://bugzilla.redhat.com/show_bug.cgi?id=1516659
2017-11-24 08:24:17 +01:00
Thomas Haller
b074fd23b4 ifcfg-rh: check integer value for other bridge options 2017-11-23 18:43:49 +01:00
Thomas Haller
ff239c1652 ifcfg-rh: check integer value when reading handle_bridge_option()
We cannot just call g_object_set() with an integer that is out of bound.
Otherwise, glib will warn. We can use nm_g_object_set_property*() to return
an error without asserting.
2017-11-23 18:43:48 +01:00
Thomas Haller
5befde7d7d shared: add nm_g_object_set_property_*() helper 2017-11-23 18:43:48 +01:00
Thomas Haller
901520af85 libnm: move bridge min/max defines to header file 2017-11-23 18:43:48 +01:00
Thomas Haller
30ce598fb5 ifcfg-rh: fix range and size when parsing integer values in reader 2017-11-23 18:43:48 +01:00
Thomas Haller
12788db4ee ifcfg-rh/trivial: rename get_uint() to get_uint32() 2017-11-23 18:43:48 +01:00
Thomas Haller
3a67b496ca ifcfg-rh: avoid string copies in make_bridge_setting()
Also, don't g_strstrip(value) for BRIDGE_MACADDR.
2017-11-23 18:43:48 +01:00
Beniamino Galvani
fb191fc282 ifcfg-rh: use distinct variables for bridge and wired mac address
Currently both bridge.mac-address and ethernet.cloned-mac-address get
written to the same MACADDR ifcfg-rh variable; the ethernet property
wins if both are present.

When one property is set and the connection is saved (and thus reread)
both properties are populated with the same value. This is wrong
because, even if the properties have the same meaning, the setting
plugin should not read something different from what was written. Also
consider that after the following steps:

 $ nmcli con mod c ethernet.cloned-mac-address 00:11:22:33:44:55
 $ nmcli con mod c ethernet.cloned-mac-address ""

the connection will still have the new mac address set in the
bridge.mac-address property, which is certainly unexpected.

In general, mapping multiple properties to the same variable is
harmful and must be avoided. Therefore, let's use a different variable
for bridge.mac-address. This changes behavior, but not so much:

 - connections that have MACADDR set will behave as before; the only
   difference will be that the MAC will be present in the wired
   setting instead of the bridge one;

 - initscripts compatibility is not relevant because MACADDR for
   bridges was a NM extension;

 - if someone creates a new connection and sets bridge.mac-address NM
   will set the BRIDGE_MACADDR property instead of MACADDR. But this
   shouldn't be a big concern as bridge.mac-address is documented as
   deprecated and should not be used for new connections.

https://bugzilla.redhat.com/show_bug.cgi?id=1516659
2017-11-23 18:43:48 +01:00
Beniamino Galvani
56a02c9baf ifcfg-rh: read wired properties for bridge connections
A bridge connection can have ethernet settings, read them from the
ifcfg file.
2017-11-23 18:43:48 +01:00
Beniamino Galvani
563ead4974 libnm-core: document bridge.mac-address as deprecated
The description already says that. Also add the deprecation tag.
2017-11-23 18:43:48 +01:00
Thomas Haller
ca26d1ae07 all: merge branch 'th/vpn-secrets-bgo790655'
https://bugzilla.gnome.org/show_bug.cgi?id=790655
2017-11-23 14:51:21 +01:00
Thomas Haller
272439cb20 shared/compat: add compat for nm_setting_vpn_get_data_keys() and nm_setting_vpn_get_secret_keys() 2017-11-23 14:44:25 +01:00
Thomas Haller
1cb147663b shared: add nm-utils/nm-compat.h 2017-11-23 14:44:25 +01:00
Thomas Haller
01015efde3 libnm: cleanup NMSettingVpn's foreach functions
Previously, g_hash_table_get_keys() would already allocate a
GList list, which then gets copied to another GSList.

Don't do that. Just allocate one array to keep all the
elements.

Also, as we now use nm_setting_vpn_get_secret_keys() and
nm_setting_vpn_get_data_keys(), note that the keys are sorted
and hence the order is stable.
2017-11-23 14:44:25 +01:00
Thomas Haller
2be6515dd0 libnm: add nm_setting_vpn_get_data_keys() and nm_setting_vpn_get_secret_keys() API
It's rather limiting that the only API to access *all* keys
is nm_setting_vpn_foreach_data_item() and nm_setting_vpn_foreach_secret().

API like nm_setting_vpn_get_num_secrets() is not useful, at least as
long as you cannot access the item by index.
2017-11-23 14:44:25 +01:00
Thomas Haller
0601b5d725 clients: some cleanup of requesting VPN secrets 2017-11-23 14:44:25 +01:00
Thomas Haller
f76dbfc1a6 core/vpn: mark secret hints as const 2017-11-23 14:44:25 +01:00
Thomas Haller
c09a069ca3 libnm: use cleanup attribute in nm_vpn_service_plugin_read_vpn_details() 2017-11-23 14:44:24 +01:00
Thomas Haller
5c21e17c16 libnm: use nm_free_secret() 2017-11-23 14:44:24 +01:00
Thomas Haller
0f3873d01c libnm: use stack allocated temporary string for property name 2017-11-23 14:44:24 +01:00
Thomas Haller
898567adfe platform: don't return zero from nmp_object_id_hash()
There is no principle problem with returning zero has hash
value. But just don't do it. Our hash functions should not
return zero. Instead, return nm_hash_static(). This is why
the function exists.
2017-11-23 14:44:24 +01:00
Thomas Haller
f7d83e681f platform: move nmp_object_equal() to header for inline 2017-11-23 14:44:24 +01:00
Thomas Haller
48960ba8da shared: add nm_construct_name_a() macro 2017-11-23 14:44:24 +01:00
Thomas Haller
63e6326285 libnm: reuse implementation for NMVpnPluginOld's util functions
They are identical, and both public API. Merge.
2017-11-22 10:34:34 +01:00
Thomas Haller
8649fcf02a contrib: use less in NM-log to pre-process input
GNU less supports filters. That makes it nice to use instead of cat.
Also, less is well suited for output to a pipe.

With this, `NM-log nm-log.txt.gz` works as you would expect
2017-11-21 15:14:32 +01:00
Thomas Haller
6fe2bf9cc7 libnm: merge branch 'th/bond-stable-strdict-order' 2017-11-21 14:11:17 +01:00
Thomas Haller
7ce8a1e677 libnm: cache lookup index for nm_setting_bond_get_option() 2017-11-21 14:01:09 +01:00
Thomas Haller
3c8c63dcca libnm: stable order in _nm_utils_strdict_to_dbus() 2017-11-21 13:48:49 +01:00
Thomas Haller
6b319cd072 ifcfg-rh: avoid duplicate lookup of bond-option in write_bond_setting()
Now that nm_setting_bond_get_option() has a stable order
(alphabetically), we no longer need to sort it.
2017-11-21 13:48:49 +01:00
Thomas Haller
d5b3c6ee53 libnm: sort entries in nm_setting_bond_get_option()
Since the order was arbitrary before, we can also sort it.

Also rework it, to avoid the creating a temporary GList of keys.
2017-11-21 13:48:49 +01:00
Thomas Haller
02d1ffa9ca libnm/trivial: reorder code in libnm-core/nm-setting-bond.c 2017-11-21 13:48:49 +01:00
Thomas Haller
3adce12898 shared: add NMUtilsNamedEntry
It is common to have some data indexed by a name.
If you want to sort a list of such data, you would
have to re-implement your own compare function each time.

Instead, add NMUtilsNamedEntry which as first field has
the name. So, you can create your own struct:

  struct my_data {
    const char *name;
    ... other fields
  }

and compare them with with nm_utils_named_entry_cmp().

For convenience, add another struct NMUtilsNamedValue, which
has only one data field, a pointer.
2017-11-21 13:48:48 +01:00
Thomas Haller
7328976a02 ifcfg-rh/tests: test writing multiple bond options 2017-11-21 13:40:13 +01:00
Beniamino Galvani
62141d59cb settings: preserve agent-owned secrets on connection add
Settings plugins now return the connection that was reread from file
when adding a connection, which means that any agent-owned secret is
lost. Ensure that we don't forget agent-owned secrets by caching them
and readding them to the new connection returned by plugins.

Fixes: 8a1d483ca8
Fixes: b4594af55e

https://bugzilla.gnome.org/show_bug.cgi?id=789383
2017-11-21 13:27:59 +01:00
Beniamino Galvani
9a631a068e ifcfg-rh: sort bond options when writing a connection
Bond options are stored in a hash table and the order in which they
are returned by the API is not guaranteed. Sort them alphabetically so
that a connection will always be written in the same way, even if the
internal implementation of the hash table or the hashing function
changes, as it did in commit a6be2f4aa9 ("all: use nm_str_hash()
instead of g_str_hash()").
2017-11-21 11:27:54 +01:00
Beniamino Galvani
60f57ebe4a cli: fix connection type completion
Don't show completion for all setting types but only for base ones.

Before:
 $ nmcli connection add type <TAB>
 802-11-olpc-mesh          ethernet                  ppp
 802-11-wireless           generic                   pppoe
 802-11-wireless-security  gsm                       proxy
 802-1x                    infiniband                serial
 802-3-ethernet            ip-tunnel                 team
 adsl                      ipv4                      team-port
 bluetooth                 ipv6                      tun
 bond                      macsec                    user
 bridge                    macvlan                   vlan
 bridge-port               olpc-mesh                 vpn
 cdma                      ovs-bridge                vxlan
 connection                ovs-interface             wifi
 dcb                       ovs-patch                 wifi-sec
 dummy                     ovs-port                  wimax

After:
 $ nmcli connection add type <TAB>
 802-11-olpc-mesh  cdma              macsec            team
 802-11-wireless   dummy             macvlan           tun
 802-3-ethernet    ethernet          olpc-mesh         vlan
 adsl              generic           ovs-bridge        vpn
 bluetooth         gsm               ovs-interface     vxlan
 bond              infiniband        ovs-port          wifi
 bridge            ip-tunnel         pppoe             wimax
2017-11-20 21:58:58 +01:00
Thomas Haller
b8c87a7ceb test: conditionally enable assertion macros depending on libnm version
The test utility library "nm-utils/nm-test-utils.h" is also used
by applet and VPN plugins. They may not yet use 1.10 API.
2017-11-20 19:52:59 +01:00
Thomas Haller
89c89143b5 keyfile: fix escaping ascii control characters in nm_keyfile_key_encode()
Matters when backslash escaping ascii charaters <= 0xF, to
produce "\\XX" instead of "\\ X". For example tabulator is "\\09".

This also can trigger an nm_assert() failure, when building with
--with-more-asserts=5 (or higher).
2017-11-20 15:39:48 +01:00
Thomas Haller
97f8d21674 shared: add nm_auto_free_secret macro 2017-11-20 11:37:24 +01:00
Beniamino Galvani
a7c97d58db device: check captured IPv6 configuration in check_and_add_ipv6ll_addr()
check_and_add_ipv6ll_addr() checks whether a link-local address is
already present in priv->ip6_config and if so, it returns with no
action.

priv->ip6_config is only updated after a merge-and-apply or (in an
idle source) when the external configuration changes and so there is
no guarantee that the addresses there are up-to-date.

priv->ext_ip6_config_captured should be checked instead, because it is
updated from platform right before starting the generation of a
link-local address. Note that also linklocal6_start() already checks
the captured external configuration rather than priv->ip6_config.

https://bugzilla.redhat.com/show_bug.cgi?id=1500350
2017-11-20 10:50:13 +01:00
Thomas Haller
25267f9d27 dns: don't stat relative paths when detecting resolved use
NetworkManager daemon has no defined working directory.
It makes no sense to ever open or stat relative paths.
Just skip them.

https://bugzilla.gnome.org/show_bug.cgi?id=790446
2017-11-19 14:29:16 +01:00
Dimitri John Ledkov
e09503dcc4 dns: check for relative paths and stub-resolve.conf when detecting systemd-resolved
Fix resolved detection, the symlink target is usually relative to the
root, such that in chroots the file points to a file inside the
chroot. But keep absolute targets too, as these may have been in use
with older version of systemd. Add support for stub-resolv.conf
detection.

https://bugzilla.gnome.org/show_bug.cgi?id=790446
2017-11-19 14:25:59 +01:00
Beniamino Galvani
60334a2893 device: don't touch external devices
If a device is 'external' (which means that NM generated an in-memory
connection to only to track the device state) we should not change its
IP configuration.

https://bugzilla.redhat.com/show_bug.cgi?id=1512316
2017-11-17 18:19:32 +01:00