Commit Graph

528 Commits

Author SHA1 Message Date
Lubomir Rintel
f627d6db8e tests: move all asserts into tests
Otherwise the TAP formatter would produce a plan-less output.
2015-05-26 13:51:44 +02:00
Thomas Haller
89c6abc7ab libnm/test: include "nm-keyfile-internal.h" in test-general.c
This enables special code in "nm-test-utils.h" that is useful
for tests.
2015-05-20 18:39:04 +02:00
Thomas Haller
d43be83aaa libnm: enforce that "nm-utils-private.h" header is not used inside src/
Let "nm-utils-private.h" and "nm-types.h" conflict.
2015-05-20 12:42:19 +02:00
Thomas Haller
670ca44721 libnm: rename DNSOptionDesc and @dns_option_descs to have an "nm"-prefix
Declarations in header files should always have an "nm" related
prefix.

Fixes: 019943bb5d
2015-05-20 12:42:19 +02:00
Thomas Haller
533f9fa2d2 libnm: move internal dns-option helpers to "nm-core-internal.h"
"nm-utils-private.h" should not be used outside of libnm-core/.
core/ should only use public API or "nm-core-internal.h".

Also, "nm-setting-ip-config.h" is a public header and should
not contain internal defines. Move them to "nm-core-internal.h"
too.

Fixes: 019943bb5d
2015-05-20 12:42:14 +02:00
Beniamino Galvani
8d9776997b libnm-core/trivial: rename 'i' function argument to 'idx' 2015-05-13 17:15:34 +02:00
Beniamino Galvani
262c27935d libnm-core/test: add tests for DNS option utilities 2015-05-13 17:15:34 +02:00
Beniamino Galvani
019943bb5d libnm-core: add dns-options property to NMSettingIPConfig 2015-05-13 17:15:34 +02:00
Jiří Klimeš
e07efa836f libnm: add ifcfg-rh description for 802-11-wireless.powersave property
so that it is displayed in nm-settings-ifcfg-rh manual page.
2015-05-12 15:42:51 +02:00
Dan Williams
cd3df12c8f vlan: don't fail if parent isn't found at construct time for existing devices
For existing devices, depending on the order that netlink sends interfaces to
us, the parent may be found after the VLAN interface and not be available when
the VLAN interface is constructed.  Instead of failing construction, when a
NMDeviceVlan has no parent keep it unavailable for activation.  Then have
the Manager notify existing devices when a new device is found, and let
NMDeviceVlan find the parent later and become available via that mechanism.

This doesn't apply to VLANs created by NM itself, because the kernel requires
a parent ifindex when creating a VLAN device.  Thus this fix only applies to
VLANs created outside NetworkManager, or existing when NM starts up.
2015-05-06 16:14:24 -05:00
Yuri Chornoivan
f851a741a6 fix typo and do not translate an empty string
https://bugzilla.gnome.org/show_bug.cgi?id=748906
2015-05-04 18:36:54 +02:00
Dan Winship
4bac5afa2b libnm-core: trivial error message fixes 2015-04-17 14:55:42 -04:00
Dan Winship
721e917cb6 wimax: drop WiMAX support (bgo #747846)
Even Fedora is no longer shipping the WiMAX SDK, so it's likely we'll
eventually accidentally break some of the code in src/devices/wimax/
(if we haven't already). Discussion on the list showed a consensus for
dropping support for WiMAX.

So, remove the SDK checks from configure.ac, remove the WiMAX device
plugin and associated manager support, and deprecate all the APIs.

For compatibility reasons, it is still possible to create and save
WiMAX connections, to toggle the software WiMAX rfkill state, and to
change the "WIMAX" log level, although none of these have any effect,
since no NMDeviceWimax will ever be created.

nmcli was only compiling in support for most WiMAX operations when NM
as a whole was built with WiMAX support, so that code has been removed
now as well. (It is still possible to use nmcli to create and edit
WiMAX connections, but those connections will never be activatable.)
2015-04-17 12:42:23 -04:00
Thomas Haller
1eaddced10 make use of NM_MORE_ASSERTS, nm_assert() and NM_MORE_LOGGING 2015-04-10 18:09:32 +02:00
Beniamino Galvani
aabc6fc57b wifi: indicate 2ghz and 5ghz wifi device capabilities
Add new capabilities CAP_FREQ_2GHZ and CAP_FREQ_5GHZ to indicate the
frequency bands supported by a Wifi device.

Add also CAP_FREQ_VALID, which is set when the values of the other 2
capabilities are available.

Original patch by Dan Williams <dcbw@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=723295
2015-04-08 10:48:38 +02:00
Lubomir Rintel
1ad193a017 device,libnm,cli: add "new-activation" reason for device state change
It will be used when the device is disconnected for new connection activation.
2015-04-08 10:00:11 +02:00
Dan Winship
773f047eef libnm-core: fix VPN error domain (bgo #745997)
In theory, NM_VPN_PLUGIN_ERROR should have names under
org.freedesktop.NetworkManager.VPN.Plugin, but for historical reasons,
it's actually org.freedesktop.NetworkManager.VPN.Error.
2015-04-07 11:30:36 -04:00
Dan Winship
ec6f350f44 libnm-core: add _nm_dbus_error_has_name()
Add a method for checking the D-Bus error name of an error.
2015-04-03 16:58:40 -04:00
Dan Winship
9668bfd682 libnm-core: add _nm_dbus_proxy_call_sync(), _nm_dbus_proxy_call_finish()
Add versions of g_dbus_proxy_call_sync() and
g_dbus_proxy_call_finish() that also typecheck the response and return
an error if it is incorrect.
2015-04-03 16:58:40 -04:00
Dan Winship
4e61f4bf35 libnm-core: add _nm_dbus_signal_connect()
Add _nm_dbus_signal_connect(), for connecting to D-Bus signals on a
GDBusProxy, with typechecking and pre-parsing of the parameters
variant.
2015-04-03 16:58:40 -04:00
Jiří Klimeš
b6f5f03033 crypto: only use gnutls crypto API, remove libgcrypt dependency (bgo #730294)
We don't need libgcrypt, because gnutls provides an API for encryption and
hashing. (Anyway gnutls itself now uses nettle instead of libgcrypt).

https://bugzilla.gnome.org/show_bug.cgi?id=730294
2015-04-01 13:23:45 +02:00
Thomas Haller
a928ff860f libnl/trivial: add code comment to NM_UTILS_UUID_NS
Clearify, that the value was choosen arbitrarily.
2015-03-30 10:46:49 +02:00
Thomas Haller
c6011cde14 trivial: remove semicolon after macro definition
Fixes: 58f08c8c9c
2015-03-20 13:38:44 +01:00
Thomas Haller
58f08c8c9c libnm: sort properties for nm_setting_enumerate_values()
The sort order of nm_setting_enumerate_values() affects the
order in which keyfile writer serializes the properties.

Have a defined, stable sort order by sorting the properties
by name (with prefering id,uuid,type for NMSettingConnection).
2015-03-20 13:19:20 +01:00
Thomas Haller
e50fbe466b libnm: sort settings for nm_connection_for_each_setting_value()
nm_connection_for_each_setting_value() is used by keyfile writer to iterate
over the settings and write the keyfile entires. The order there is important
as g_key_file_to_data() prints the groups in the order they were created.

To have a stable order and to have the [connection] entry first, sort the
settings.
2015-03-20 13:19:20 +01:00
Thomas Haller
81119c69d8 keyfile/test: refactor and cleanup _keyfile_convert()
_keyfile_convert() should really test for successful round-trip
conversion of keyfile-connection and vice versa.
2015-03-20 13:19:20 +01:00
Thomas Haller
628f47285d libnm: accept unknown WEP key type in nm_utils_wep_key_valid()
libnm-core treated the UNKNOWN WEP key type as KEY. Relax that
and try to guess the correct type based on the key.

This is for example important if you have a valid connection with
  wep-key-type=0 (unknown)
If you request passwords for such a connection, the user cannot
enter them in password format -- but there is no UI indication
that the password must be KEY.
2015-03-20 13:02:04 +01:00
Thomas Haller
dbbedce21f libnm: don't check for valid passwords in NMSetting:verify()
We must never fail verification of a connection based on a password
because the password is re-requested during activation.

Otherwise, if the user enters an invalid password for a (previously)
valid connection, the connection becomes invalid. NetworkManager does
not expect or handle that requesting password can make a connection
invalid.
Invalid passwords should be treated as wrong passwords. Only a UI
(such as nm-connection-editor or nmcli) should validate passwords
against a certain scheme.

Note that there is need_secrets() which on the contrary must check for
valid passwords.

Error scenario:

  Connect to a WEP Wi-Fi, via `nmcli device wifi connect SSID`. The
  generated connection has wep-key-type=0 (UNKNOWN) and wep-key-flags=0.
  When trying to connect, NM will ask for secrets and set the wep-key0
  field. After that, verification can fail (e.g. if the password is longer
  then 64 chars).
2015-03-20 13:01:04 +01:00
Thomas Haller
d05bedbc0d libnm/keyfile: fix format string for unsigned integer
Fixes: 04df4edf48
2015-03-17 13:00:16 +01:00
Thomas Haller
d198618aa7 libnm: fix error prefix in NMSettingGsm:verify() 2015-03-17 11:49:55 +01:00
Thomas Haller
997fc07ca5 test: add nmtst_create_connection_from_keyfile() 2015-03-12 18:16:58 +01:00
Thomas Haller
c9a8764ad2 keyfile: support writing certificates as blob inside the keyfile
keyfile should become our main import/export format. It is desirable,
that a keyfile can contain every aspect of a connection.

For blob certificates, the writer in core daemon would always write
them to a file and convert the scheme to path.
This behavior is not great for a (hyptetical) `nmcli connection export`
command because it would have to export them somehow outside of keyfile,
e.g. by writing them to temporary files.

Instead, if the write handler does not handle a certificate, use a
default implementation in nm_keyfile_write() which adds the blob inside
the keyfile.

Interestingly, keyfile reader already supported reading certificate
blobs. But this legacy format accepts the blob as arbitrary
binary without marking the format and without scheme prefix.
Instead of writing the binary data directly, write it with a new
uri scheme "data:;base64," and encode it in base64.

Also go through some lengths to make sure that whatever path
keyfile plugin writes, can be read back again. That is, because
keyfile writer preferably writes relative paths without prefix.
Add nm_keyfile_detect_unqualified_path_scheme() to encapsulate
the detection of pathnames without file:// prefix and use it to
check whether the path name must be fully qualified.
2015-03-12 18:16:58 +01:00
Thomas Haller
a49680dacd libnm: add define for cert scheme prefix file:// for NMSetting8021x 2015-03-12 18:12:27 +01:00
Thomas Haller
57a432fa8a keyfile: refactor to use reading and writing of keyfile from libnm-core 2015-03-12 18:12:26 +01:00
Thomas Haller
5e5afcffce libnm: merge nm-keyfile-reader.h and nm-keyfile-writer.h to internal header
These headers are not entirely private to libnm-core as they are also
used by keyfile plugin. Merge them to a new header file
nm-keyfile-internal.h so that the name makes the internal nature of the
header more apparent.
2015-03-12 18:12:26 +01:00
Thomas Haller
04df4edf48 libnm: add keyfile support to libnm-core
https://bugzilla.gnome.org/show_bug.cgi?id=744699
2015-03-12 18:12:26 +01:00
Thomas Haller
1fc9bc401e keyfile: copy read/writer files to libnm-core
This is the first step to move keyfile to libnm. For now, only
copy the files to make later changes nicer in git-history.

  /bin/cp src/settings/plugins/keyfile/reader.c libnm-core/nm-keyfile-reader.c
  /bin/cp src/settings/plugins/keyfile/reader.h libnm-core/nm-keyfile-reader.h
  /bin/cp src/settings/plugins/keyfile/utils.c  libnm-core/nm-keyfile-utils.c
  /bin/cp src/settings/plugins/keyfile/utils.h  libnm-core/nm-keyfile-utils.h
  /bin/cp src/settings/plugins/keyfile/writer.c libnm-core/nm-keyfile-writer.c
  /bin/cp src/settings/plugins/keyfile/writer.h libnm-core/nm-keyfile-writer.h
2015-03-12 18:12:26 +01:00
Thomas Haller
e82293ebf6 libnm: move _nm_utils_uuid_generate_from_strings() from src/ to libnm-core/ 2015-03-12 18:12:26 +01:00
Thomas Haller
c5d23737fd libnm: move _nm_utils_ascii_str_to_int64() from src/ to libnm-core/ 2015-03-12 18:12:26 +01:00
Thomas Haller
15926e9eb3 libnm: add function nm_setting_802_1x_check_cert_scheme()
When setting the certificate glib properties directly,
we raise a g_warning() when the binary data is invalid.
But since the caller has no access to the validation function,
he cannot easily check whether his action will result
in a warning. Add nm_setting_802_1x_check_cert_scheme() for
that.
2015-03-12 18:12:26 +01:00
Thomas Haller
0f1fe69422 trivial: add FIXME code comment about potential race 2015-03-12 18:12:26 +01:00
Thomas Haller
11371b5470 libnm: only call strlen() once in NMSetting8021x:path_to_scheme_value()
Also assert that path is not empty.
2015-03-12 18:12:25 +01:00
Thomas Haller
88a79625a6 libnm: fix clearing memory in file_to_secure_bytes()
If we go through the lengths of clearing the allocated
memory, we must not forget @contents.
2015-03-12 18:12:25 +01:00
Thomas Haller
cda7b158e2 libnm: ensure valid blob for nm_setting_802_1x_set_*_cert()
A valid blob cannot start with "file://", otherwise it would
break the implementation of the certificate properties in
NMSetting8021x. Simply reject every blob in nm_setting_802_1x_set_ca_cert()
et al. that is not valid according to get_cert_scheme().
2015-03-12 18:12:25 +01:00
Thomas Haller
e59e68c528 libnm: combine get_cert_scheme() and verify_cert() and ensure valid paths for NMSetting8021x
get_cert_scheme() would return PATH scheme for binary data that
later will be rejected by verify_cert(). Even worse, get_cert_scheme()
would not check whether the path is NUL terminated, hence the following
can crash for an invalid connection:

  if (nm_setting_802_1x_get_ca_cert_scheme (s_8021x) == NM_SETTING_802_1X_CK_SCHEME_PATH)
      g_print ("path: %s", nm_setting_802_1x_get_ca_cert_path (s_8021x))

Combine the two functions so that already get_cert_scheme() does
the same validation as verify_cert().

Also change behavior and be more strict about invalid paths:

 - Now, the value is considered a PATH candidate if it starts with "file://",
   (sans NUL character).
   A change is that before, the "file://" (without NUL) would have
   been treated as BLOB, now it is an invalid PATH (UNKNOWN).

 - If the binary starts with "file://" it is considered as PATH but it
   is only valid, if all the fllowing is true:
   (a) the last character must be NUL.
   (b) there is no other intermediate NUL character.
       Before, an intermediate NUL character would have been accepted
       and the remainder would be ignored.
   (c) there is at least one non-NUL character after "file://".
   (d) the string must be fully valid utf8.

   The conditions (b) and (c) are new and some invalid(?) paths
   might no longer validate.
   Checking (d) moved from verify_cert() to get_cert_scheme().
   As set_cert_prop_helper() already called verify_cert(), this
   causes no additional change beyond (b).
2015-03-12 18:12:25 +01:00
Thomas Haller
ad4e6f7fad build/trivial: cleanup Makefile.am by sorting EXTRA_DIST entries 2015-03-12 18:12:25 +01:00
Jiří Klimeš
11efde3b40 libnm-core: add multicast-snooping property to bridge setting 2015-02-26 09:08:13 +01:00
Lubomir Rintel
2981839bde test: initialize auto-destructed pointers
Otherwise the compiler complains that they could be left uninitialized in case
the function returns too early.

Fixes: 76745817c3
2015-02-09 15:19:30 +01:00
Thomas Haller
c50f30e79c tests: enable valgrind tests for tests 2015-02-09 11:51:07 +01:00
Thomas Haller
ae73320b8c libnm/tests: fix memleaks in tests for valgrind 2015-02-09 11:51:07 +01:00