Commit Graph

17169 Commits

Author SHA1 Message Date
Thomas Haller
0a1fd88d5a modem: add nm_modem_emit_prepare_result() function
... instead of emitting the signal by name. For one,
we get the casting of the NMDeviceStateReason enum right.
Also, emitting by the guint signal-id is faster then
emitting by name.
2017-02-23 12:33:41 +01:00
Thomas Haller
9a8f8e8a89 modem: remove unused variadic argument when emitting NM_MODEM_STATE_CHANGED signal
The signal only has two arguments, no reason.
2017-02-23 12:33:41 +01:00
Thomas Haller
42f60e30ad modem: emit signal NM_MODEM_AUTH_REQUESTED by id not name 2017-02-23 12:20:19 +01:00
Thomas Haller
6c8eac1a4c modem: use defines for signal names 2017-02-23 12:20:13 +01:00
Beniamino Galvani
fcb0fffb85 libnm-core: require interface name for dummy connections
Fixes: 1bf2d3b049
2017-02-23 10:58:32 +01:00
Beniamino Galvani
36bb22f598 team: merge branch 'bg/team-cloned-mac-rh1424641'
https://bugzilla.redhat.com/show_bug.cgi?id=1424641
2017-02-23 10:23:06 +01:00
Beniamino Galvani
9dac51d9c0 team: support the ethernet.cloned-mac-address property
The only reliable way of setting a MAC address for the team is through
the "hwaddr" property in the configuration passed to teamd. In order
to rewrite the configuration we need Jansson support; since it is
already a requirement for teamd, let the team plugin depend on it.
2017-02-23 10:07:06 +01:00
Beniamino Galvani
029a0a21ea device: split out cloned MAC decision from nm_device_hw_addr_set_cloned()
In this way, we can query the final cloned address (after special
values as 'random', 'stable', etc. have been evaluated) from
subclasses.
2017-02-23 10:05:48 +01:00
Beniamino Galvani
a1b729fddb build: automatically determine Jansson support if not specified
If configure is called without --enable-json-validation or
--disable-json-validation, let's automatically choose a value
depending on the availability of the library.
2017-02-23 10:05:48 +01:00
Beniamino Galvani
de66e15cc9 docs: add missing links to dummy and macsec device/setting
Fixes: b42f780e04
Fixes: d252a99fa2
2017-02-23 08:51:56 +01:00
Thomas Haller
5d336aa1ed device: rename reason argument for NMDeviceDummy
And remove assertion for out-argument to be present.

Follow-up to commit 437c12fc89.
2017-02-22 21:47:12 +01:00
Thomas Haller
8b7d38c8c5 device: remove out-reason argument from device's set-ip-config
The out-reason is only set to NM_DEVICE_STATE_REASON_CONFIG_FAILED.
And there is only one caller who cares about the reason.

If we one day decide to return a more distinguished error reasons,
we can revert this patch. Until then, drop the code.
2017-02-22 21:43:04 +01:00
Thomas Haller
437c12fc89 device: rename device-state-reason argument to out_failure_reason
This argument is only relevant when the NMActStageReturn argument
indicates NM_ACT_STAGE_RETURN_FAILURE. In all other cases it is ignored.

Rename the argument to make the meaning clearer. The argument is passed
through several layers of code, it isn't obvious that this argument only
matters for the failure case. Also, the distinct name makes it easier
to distinguish from other uses of the "reason" name.

While at it, do some drive-by cleanup:

  - use g_return_*() instead of g_assert() to have a more graceful
    assertion.
  - functions like dhcp4_start() don't need to return a failure reason.
    Most callers don't care, and the caller who does can determine the
    proper reason.
  - allow omitting the out-argument via NM_SET_OUT().
2017-02-22 21:37:47 +01:00
Beniamino Galvani
d5911fc551 merge: branch 'bg/dummy-bgo777863'
Implement a new connection type for dummy interfaces.

https://bugzilla.gnome.org/show_bug.cgi?id=777863
2017-02-22 21:05:55 +01:00
Beniamino Galvani
4db7890fae cli: support dummy connections 2017-02-22 21:05:04 +01:00
Beniamino Galvani
b42f780e04 core: add support for dummy devices
Add support for creating dummy devices. This commit adds a D-Bus
interface 'org.freedesktop.NetworkManager.Device.Dummy' which is used
primarily for determining the device type but does not carry any
properties.
2017-02-22 21:05:04 +01:00
Beniamino Galvani
1bf2d3b049 libnm-core: add dummy connection setting
The setting must be present in connections with type=dummy. It does
not contain any property.
2017-02-22 21:05:04 +01:00
Thomas Haller
f95b6cadd2 libnm: fix gtk-doc comment for nm_setting_802_1x_get_phase2_ca_cert_password()
Fixes: 538e510473
2017-02-22 13:57:31 +01:00
Thomas Haller
86ac68049a build: ensure libnm-core directory exists for generated files
Since we generate "libnm-core/nm-core-enum-types.h" via GLIB_GENERAED,
there is no obvious place to $(MKDIR_P). Add a dependency to the
.dirstamp of the directory to instruct automake to create the directory.
2017-02-22 13:16:28 +01:00
Thomas Haller
47e55561a7 build: ensure build directories exist for gdbus-codegen targets 2017-02-22 11:48:40 +01:00
Thomas Haller
d440958de1 build: don't depend on libnm-core directory for make target 2017-02-22 11:43:21 +01:00
Thomas Haller
c2f0764c1e build: add slash to directory name for mkdir
Just for consistency with other locations that call
$(MKDIR_P).
2017-02-22 11:42:38 +01:00
Thomas Haller
f93fbc76ec device: avoid assertion in nm_device_get_supplicant_timeout() for Wi-Fi connection
... without 802-1x setting.

    NetworkManager[27913]: <trace> [1487689965.7156] device[0x555555bc0060] (wlp3s0): powersave is set to 3
    NetworkManager[27913]: <info>  [1487689965.7156] Config: added 'ssid' value 'xxx'
    NetworkManager[27913]: <info>  [1487689965.7156] Config: added 'scan_ssid' value '1'
    NetworkManager[27913]: <info>  [1487689965.7156] Config: added 'bssid' value 'xxx'
    NetworkManager[27913]: <info>  [1487689965.7157] Config: added 'key_mgmt' value 'WPA-PSK'
    NetworkManager[27913]: <info>  [1487689965.7157] Config: added 'psk' value '<hidden>'
    NetworkManager[27913]: <debug> [1487689965.7157] sup-iface[0x555555be0010,wlp3s0]: assoc[0x555555ebd800]: starting association...
    NetworkManager[27913]: nm_device_get_supplicant_timeout: assertion 's_8021x' failed

    (gdb) bt
    ...
    #3  0x00007ffff4c70419 in g_return_if_fail_warning (log_domain=log_domain@entry=0x55555577610e "NetworkManager", pretty_function=pretty_function@entry=0x5555557725e0 <__func__.44436> "nm_device_get_supplicant_timeout", expression=expression@entry=0x5555557725bb "s_8021x") at gmessages.c:2536
    #4  0x000055555568af3a in nm_device_get_supplicant_timeout (self=0x555555bc0060 [NMDeviceWifi]) at src/devices/nm-device.c:12963
    #5  0x00007fffe88d7f1e in act_stage2_config (device=<optimized out>, reason=0x7fffffffe000) at src/devices/wifi/nm-device-wifi.c:2651
    #6  0x00005555556879f1 in activate_stage2_device_config (self=0x555555bc0060 [NMDeviceWifi]) at src/devices/nm-device.c:4320
    #7  0x000055555566876b in activation_source_handle_cb (self=self@entry=0x555555bc0060 [NMDeviceWifi], family=family@entry=2) at src/devices/nm-device.c:4060
    #8  0x000055555566882e in activation_source_handle_cb4 (user_data=user_data@entry=0x555555bc0060) at src/devices/nm-device.c:3997
    #9  0x00007ffff4c658e7 in g_idle_dispatch (source=0x555555e228c0, callback=0x555555668820 <activation_source_handle_cb4>, user_data=0x555555bc0060) at gmain.c:5545
    #10 0x00007ffff4c68e52 in g_main_dispatch (context=0x555555a214d0) at gmain.c:3203
    #11 0x00007ffff4c68e52 in g_main_context_dispatch (context=context@entry=0x555555a214d0) at gmain.c:3856
    #12 0x00007ffff4c691d0 in g_main_context_iterate (context=0x555555a214d0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3929
    #13 0x00007ffff4c694f2 in g_main_loop_run (loop=0x555555a1a750) at gmain.c:4125
    #14 0x00005555555821fe in main (argc=<optimized out>, argv=<optimized out>) at src/main.c:423

Fixes: 07570e245a
2017-02-21 16:21:02 +01:00
Thomas Haller
8406455b4d ifcfg: drop strlen() call from svEscape() 2017-02-21 15:47:43 +01:00
Thomas Haller
c9f6cb9fe4 ifcfg: some refactoring of reader using vGetValueStr()/vGetValue_cp() 2017-02-21 15:43:03 +01:00
Thomas Haller
ccbfda5c08 ifcfg: complete shvar API with svGetValue_cp() and svGetValueStr()
Add svGetValue_cp() and svGetValueStr() for completeness.

Currently, we mostly use svGetValueStr_cp(), which I think is wrong
because for most cases we should instead not ignore empty values -- that
is, svGetValue_cp() would be a better choice.

Also, I think that the non *_cp() API should be preferred in many cases
because it avoids cloning the value in many cases. The API is not
necessarily less favorable either:

    gs_free char *value = NULL;

    value = svGetValue_cp (s, key);
    if (value)
        ...

vs.

    gs_free char *value_to_free = NULL;
    const char *value;

    value = svGetValue (s, key, &value_to_free);
    if (value)
        ...

Add the two missing variants, so that future code can use what fits
best, not following undesired practices because seemingly there is
no alternative.
2017-02-21 15:30:23 +01:00
Thomas Haller
c0c9b3dbcd ifcfg/trivial: rename svGetValueString() to svGetValueStr_cp()
We have

 - svGetValue()
    - returns the original string
    - avoids copying the string unless necessary

 - svGetValueStr_cp() (formerly svGetValueString())
    - returns the original string, unless it is empty ""
    - always clones the string

I think the behavior svGetValueStr*() of coercing "" to NULL is wrongly
used in most places. We should better handle "" like any other value,
not treat it as unset.

That would require another function svGetValue_cp(), which is like svGetValue()
but always copies the string. Rename svGetValueString() so that there is a place
for names like

  - svGetValue_cp()
  - svGetValueStr()

Also rename svSetValueString() to svSetValueStr().
2017-02-21 12:34:36 +01:00
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
7e79e913ad merge: branch 'bg/802-1x-auth-timeout-bgo723084'
Make the 802.1x authentication timeout configurable to allow a faster
fallback to other connections.

https://bugzilla.gnome.org/show_bug.cgi?id=723084
2017-02-21 09:34:23 +01:00
Thomas Haller
8588630c26 settings: log changes to NMSettingsConnection's autoconnect_retries 2017-02-21 09:18:53 +01:00
Beniamino Galvani
4a6fd0e83e device: honor the connection.autoconnect-retries for 802.1X
NMDeviceEthernet and NMDeviceMacsec implement their own retry policy
for connection using 802.1X, and consider the credentials wrong when
the authentication fails for 3 times. In such case, they also disable
autoconnection for the device by setting the state reason NO_SECRETS.

This means that it's not possible at the moment to choose how many
times the authentication will be retried since they don't use the
standard reconnection logic.

Change NMDeviceEthernet and NMDeviceMacsec to use the number of
retries from connection.autoconnect-retries instead of a hardcoded
value to decide how many times the authentication must be restarted.
2017-02-21 09:18:53 +01:00
Beniamino Galvani
07570e245a device: add support for 802-1x.auth-timeout
Use the per-connection authentication timeout for 802.1X Ethernet,
MACsec and Wi-Fi connections. In case the value is not defined, fall
back to the global one.
2017-02-21 09:18:53 +01:00
Beniamino Galvani
556a46959f ifcfg-rh: add support for 802-1x.auth-timeout property 2017-02-21 09:18:53 +01:00
Beniamino Galvani
9a215d332b cli: add support for 802-1x.auth-timeout property 2017-02-21 09:18:53 +01:00
Beniamino Galvani
078bd7b1a9 libnm-core: add auth-timeout property to the 802.1x setting
The property can be used to tune the authentication timeout. It's
especially useful to speed up the failure in case the port doesn't
support 802.1X and make NM try a different, non-authenticated
connection.
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
e824dd34f0 build: fix type on Makefile.am
Fixes: 3cc00dd550
2017-02-21 00:37:48 +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
Lubomir Rintel
ff46158d9e tui: generate names for bonds, teams and bridges
This makes it more likely that the user will end up with a master
connection that has connection.interface-name property. This makes it
possible for ifcfg plugin to specify the master in the for of device
name (as opposed to UUID) for compatibility with the legacy network
tooling.

This is equivalent to what nmcli does.

https://bugzilla.redhat.com/show_bug.cgi?id=1369091
2017-02-20 16:07:43 +01:00
Thomas Haller
a184c25cb9 merge branch 'th/8021x-auth-flags-tls-disable-bgo765059'
https://bugzilla.gnome.org/show_bug.cgi?id=765059
2017-02-20 14:11:55 +01:00
Beniamino Galvani
436eec6083 ifcfg-rh: support 802-1x.phase1-auth-alg 2017-02-20 14:06:14 +01:00
Beniamino Galvani
bb72409e9f cli: support 802-1x.phase1-auth-flags 2017-02-20 14:06:14 +01:00
Thomas Haller
2a11c57c4e libnm/wifi: rework NMSetting8021xAuthFlags to explicitly disable TLS version
The wpa_supplicant API supports to enable/disable each TLS version
individually, or leave it at the default. Currently, the default
means to enable a TLS version, thus, the only meaningful option
for the momemnt means to explicitly disable it.

In the future, supplicant may disable options by default, and
the inverse option can become interesting to configure
"tls_disable_tlsv1_0=0". When that happens, we can solve it by
adding another flag NM_SETTING_802_1X_AUTH_FLAGS_TLS_1_0_ENABLE.

Change the previous behavior of the NMSetting8021xAuthFlags.
Previously, when not specifying TLS_DISABLE_DEFAULT, all
options were unspecified. On the other hand, when specifying
a single TLS disable flag, all versions were explicitly enabled
or disabled.

Instead, change the meaning of the disable flags. When present,
it explicitly disables an option. But it does not explicitly enable
it.
2017-02-20 14:06:14 +01:00
Leorize
8ce60a302a supplicant: allows disabling select TLS versions on phase 1 authentication
Some AAA servers have issues interoperating with select TLS versions,
which wpa_supplicant negotiates by default.

This commit allows disabling troubling versions of TLS so that
connecting to broken authentication servers could be possible.
2017-02-20 14:06:14 +01:00