Commit graph

927 commits

Author SHA1 Message Date
Thomas Haller
d37c77234f ifcfg: set error for failure reading unrecognized connection in connection_from_file_full() 2017-02-21 12:17:30 +01:00
Thomas Haller
9b8e56180f ifcfg: don't g_strstrip() value in read_dcb_bool_array()
Ifcfg reader now properly handles escaping and quoting. We don't
need to stip whitespace, if somebody explicitly configures

  prop=" value"

it is a configuration error.
2017-02-21 12:17:30 +01:00
Thomas Haller
b1c8c9cbaf ifcfg: return early on error using cleanup attributes in reader 2017-02-21 12:17:30 +01:00
Thomas Haller
19c9d1bafd ifcfg: add nm_auto_shvar_file_close cleanup macro 2017-02-21 11:46:23 +01:00
Beniamino Galvani
556a46959f ifcfg-rh: add support for 802-1x.auth-timeout property 2017-02-21 09:18:53 +01:00
Thomas Haller
9952280d40 ifcfg: don't check for empty string after svGetValueString()
svGetValueString() precisely filters out empty strings. No need to
check for that afterwards.
2017-02-21 01:17:41 +01:00
Thomas Haller
601700dedf ifcfg: stack-allocate tag for DNS value lookup 2017-02-21 00:57:38 +01:00
Thomas Haller
03eab8bf92 ifcfg: return binary address from read_ip4_address()
This allows us to avoid cloning the string at several places.
2017-02-21 00:53:56 +01:00
Thomas Haller
3cc00dd550 ifcfg: also read DEFROUTE and GATEWAY from alias files
Also accept DEFROUTE and GATEWAY when they are defined in
alias files -- provided, that they are not yet defined
in the main ifcfg file.
2017-02-20 23:18:36 +01:00
Thomas Haller
de42bde695 ifcfg: refactor creation of numered tag lables to use stack allocated buffer
and use gs_free attribute and return-early on error.
2017-02-20 19:43:52 +01:00
Beniamino Galvani
436eec6083 ifcfg-rh: support 802-1x.phase1-auth-alg 2017-02-20 14:06:14 +01:00
Thomas Haller
2c9ef8cf2e shared: move NMSetting8021xSchemeVtable to "shared/nm-setting-metadata.h" 2017-02-17 19:52:13 +01:00
Thomas Haller
324cf7ce82 ifcfg-rh: reuse file-suffix from NMSetting8021xSchemeVtable
Keyfile writer computes the file extension and only uses
the file suffix from the vtable.

Do that for ifcfg-rh too. No change in behavior.
2017-02-17 14:24:34 +01:00
Thomas Haller
7a21ae3e77 keyfile: reuse NMSetting8021xSchemeVtable in NMKeyfileWriteTypeDataCert 2017-02-17 14:24:34 +01:00
Thomas Haller
199524e426 ifnet: merge ObjectType with NMSetting8021xSchemeVtable in ifnet parser
ifnet has two extra instances @p12_type/@phase2_p12_type, that only
differed from @pk_type/@phase2_pk_type by their suffix.

But as the suffix field as unused, we can drop that entirely.
2017-02-17 14:24:34 +01:00
Thomas Haller
01b8520447 ifcfg-rh: merge ObjectType with NMSetting8021xSchemeVtable in ifcfg-rh writer 2017-02-17 14:24:34 +01:00
Thomas Haller
6627fef1a6 ifcfg-rh: refactor duplicate ObjectType instance to handle PKCS#12 types
If one property has multiple ways to be handled, we should not create
two ObjectType instances, instead let the ObjectType have enough
information to act accordingly.
2017-02-17 14:24:34 +01:00
Thomas Haller
a77e6f1f5d ifcfg-rh: refactor ObjectType structs to make it more similar to NMSetting8021xSchemeVtable 2017-02-17 14:24:34 +01:00
Lubomir Rintel
e599e96572 ifcfg-rh: add support for certificate passwords 2017-02-17 14:24:34 +01:00
Lubomir Rintel
70b370f52c ifcfg-rh: support the pkcs11 scheme for certs/keys
The PKCS#11 URIs start with the "pkcs11:" scheme. There's a slight
possiblity of a clash with file names relative to the ifcfg file, but
that's probably is unlikely enough the leave us not worried.

The alteratives are probably more horrible (using a different key, or
using a separate key for the scheme alone) and it's already simple
enough to avoid a clash by using an absolute file name.
2017-02-17 14:24:34 +01:00
Thomas Haller
a8f0d88596 ifcfg: ensure ipv4.method is not "disabled" when reading IP addresses from alias files
When the main ifcfg file contains no IP addresses, the method
will be "disabled". Later, when reading IP addresses for the
aliases, we must ensure that the method is manual.

Otherwise, validation fails with

  ip.addresses: this property is not allowed for method=disabled
2017-02-16 21:55:40 +01:00
Thomas Haller
27cba47957 ifcfg-rh: fix interpreting missing 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 setting as "NEVER" -- which due to
normalization also results in cloned-mac-address=permanent.

See also commit 46d53e1101 which does
something similar for keyfile.

This bug also prevents a user from clearing the cloned-mac-address:

  $ nmcli connection show "$CONN"
  ...
  802-11-wireless.cloned-mac-address:        permanent
  802-11-wireless.mac-address-randomization: never
  ...
  $ nmcli connection modify "$CONN: wifi.cloned-mac-address ''
  # ^ takes no effect

As workaround, you also need to clear mac-address-randomization:

  $ nmcli connection modify "$CONN: wifi.cloned-mac-address '' \
          wifi.mac-address-randomization default

https://mail.gnome.org/archives/networkmanager-list/2017-January/msg00060.html
2017-01-28 16:04:32 +01:00
Thomas Haller
c218fd44bc tests: fix tests without libjansson support (--enable-json-validation=no)
(cherry picked from commit a5acd0bdc6)
2017-01-17 23:52:18 +01:00
Jiří Klimeš
49e1fefc35 ifcfg-rh: add a basic test for Proxy setting 2017-01-17 14:27:31 +01:00
Lubomir Rintel
cb8e70546b ifupdown: remove redundant error check
The presence of a parameter is checked above.

CID 59899 (#1 of 1): Logically dead code (DEADCODE)
2017-01-16 22:14:47 +01:00
Lubomir Rintel
9b9a180597 ifcfg-rh: unknown scheme means no certificate at all
Fixes: 30db08d38e
2017-01-11 15:12:29 +01:00
Lubomir Rintel
30db08d38e ifcfg-rh: don't ignore certificates with unknown scheme 2017-01-10 23:30:18 +01:00
Beniamino Galvani
a9384452ed settings: fix assertion when changing connection managed state
When a ifcfg-rh connection becomes unamanaged it is removed from the
connection list in NMSettings and marked as removed; it is however
kept alive in the plugin and can become managed again later. To avoid
failed assertions, the @removed flag of the NMSettingsConnection must
be cleared if the connection is not being disposed.
2017-01-10 14:26:32 +01:00
Lubomir Rintel
faed200b2b keyfile: add support for pkcs11: URI scheme 2017-01-06 15:56:11 +01:00
Lubomir Rintel
260563a7d9 all: use nm_utils_is_valid_iface_name() 2017-01-06 15:11:56 +01:00
Thomas Haller
f4fb4d271f keyfile/tests: add test for reading dcb connection
Catches previously fixed memleak in read_array_of_uint()
2017-01-05 11:13:17 +01:00
Thomas Haller
a2dce28fc8 device: do nothing in NMDevice's link_changed() function
All implementations of link_changed() chain up to NMDevice's
base implementation. Thus, everybody wants to set the carrier.

Refactor the code to set the carrier outside of link_changed().
2017-01-04 14:18:01 +01:00
Thomas Haller
ca3cb90fc2 ifcfg-rh: refactor svOpenFile() to use nm_utils_fd_get_contents()
Use nm_utils_fd_get_contents() which has precisely all the steps implemented
to read data from a file descriptor.

There is a downside to this: previously you could compile shvar.c without
nm-core-utils.c. Now, the ifcfg implementation gained a dependency
on NM core utils. That would matter if we one day would like to build
shvar.c without core NetworkManager utils (but that is not planned).
2017-01-02 17:00:52 +01:00
Thomas Haller
1bfbe9383f ifcfg-rh: add assertions for handling lines in "shvar.c"
Just assert that the shvarLine instances are in a valid state.
2017-01-02 17:00:52 +01:00
Thomas Haller
de9e78cc50 ifcfg-rh: refactor handling of lines in shvar.c
Pre-process each line and parse the key and value.
Thus, keep the key already prepared.

The point is to do the parsing early and keep the
data in a more suitable format in shvarLine.
2017-01-02 17:00:51 +01:00
Thomas Haller
a6a39af8ca ifcfg-rh: refactor searching and replacing shvarLine in svhar.c
The shlist_delete*() are now named wrong, as they don't delete
the list entry. Anyway, they have only one caller, it's clearer
to inline them.

This way, during svSetValue() we need to iterate the entire
list only once.
2017-01-01 22:16:44 +01:00
Francesco Giudici
f124048b80 ifcfg-rh/tests: avoid using g_assert_null() API
Fixes: 2852b50945
2016-12-15 13:34:54 +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
Lubomir Rintel
96988f8deb ifcfg-rh: add test case for remembering the unset values
Validates the previous commit.
2016-12-15 11:45:34 +01:00
Lubomir Rintel
d36c6d2892 ifcfg-rh: remember where the keys have been when we remove them
We may want to re-add them right away, let's remember the original
contents so that we can add it at the right place.
2016-12-15 11:45:34 +01:00
Francesco Giudici
2ee6b7bf82 ifcfg-rh: merge branch 'fg/dhcp_hostname_bgo775622'
https://bugzilla.gnome.org/show_bug.cgi?id=775622
2016-12-15 11:29:05 +01:00
Francesco Giudici
6bf69d0fa1 ifcfg-rh/tests: add ipv6 hostname legacy support read test 2016-12-14 16:21:26 +01:00
Francesco Giudici
2852b50945 ifcfg-rh: add DHCPV6_HOSTNAME and DHCPV6_SEND_HOSTNAME vars
Currently ipv4 and ipv6 settings share the ifcfg plugin vars for the
dhcp-hostname and dhcp-send-hostname options (DHCP_HOSTNAME and
DHCP_SEND_HOSTNAME). Add brand new vars DHCPV6_HOSTNAME and
DHCPV6_SEND_HOSTNAME to have var-property one to one mappings.
2016-12-14 16:21:26 +01:00
Francesco Giudici
08bd3feed0 ifcfg-rh: write [IPV6_]PEERDNS and [IPV6_]PEERROUTES only when they are "no"
When those values are missing they are already considered as TRUE.
As they are written also when DHCP is not enabled, write them only
if they have a value different from the default.
2016-12-14 16:14:24 +01:00
Francesco Giudici
dbb9cd3ca8 ifcfg-rh: save/restore dhcp related properties also when ip method != DHCP/AUTO
affected properties are: ipv4.dhcp-client-id, ipv4.fqdn,
ipv4.dhcp-timeout, ipvX.ignore-auto-routes, ipvX.ignore-auto-dns,
ipvX.dhcp-hostname and ipvX.dhcp-send-hostname.
2016-12-14 15:27:42 +01:00
Thomas Haller
4bdee37771 all: use O_CLOEXEC for file descriptors 2016-12-13 11:26:59 +01:00
Thomas Haller
61c6ccaad4 config: drop nm_config_get_dhcp_client() and access config directly
Also, ifnet plugin would read the configuration value, which is just wrong
because:

  - the configuration might not be set and ifnet would fail to fallback
    to the compile time default.
  - the configuration only is in effect if the plugin is also available.
    Otherwise, we fallback to the next plugin.

Only the dhcp-manager knows which DHCP plugin is in use.
2016-11-25 18:02:38 +01:00
Francesco Giudici
5da352c5e8 ifupdown/trivial: whitespace fixup 2016-11-24 18:31:02 +01:00
Francesco Giudici
3bcca564c7 ifcfg-rh/tests: add tests for link negotiation options
Thanks to Thomas Haller for making test code much more compact taking
advantage of the nmtst_create_minimal_connection function.
2016-11-22 15:24:47 +01:00
Francesco Giudici
12b9d30ae6 ifcfg-rh: add support to 802-3.[auto-negotiate,speed,duplex] properties
NOTE: changed the default value for auto-negotiate from TRUE to FALSE.

Normalization enforces that no values for speed and duplex are there
when autonegotiation is on. This is required as autoneg on with specific
speed and duplex set means to ethtool to use autonegotiation but
advertise that specific speed and duplex only.

autoneg off, speed 0 and duplex NULL means to ignore link negotiation.
2016-11-22 15:24:47 +01:00