Commit graph

319 commits

Author SHA1 Message Date
Lubomir Rintel
12af09b779 test: fix duplicate test names
New glib complains.

(cherry picked from commit 874f455d6d)
2015-09-08 13:13:36 +02:00
Jiří Klimeš
7cfd6fc641 libnm-core: fix a crash in priority_strv_to_maplist()
strv can be NULL.

Reproducer:
$ nmcli con mod my-vlan vlan.ingress 1:5

(cherry picked from commit 71c8c2e587)
2015-09-01 16:13:01 +02:00
Jiří Klimeš
71104eefdc doc: fix the names of [in|e]gress-priority-map properties in ifcfg-rh man page
(cherry picked from commit 5e3582c6b1)
2015-08-31 09:08:32 +02:00
Lubomir Rintel
8ce6c3c0ce release: bump version to 1.0.6 2015-08-27 18:21:26 +02:00
Thomas Haller
14a726e9e6 libnm-core: fix return value in nm_utils_enum_to_str()
Fixes: 8be9814793
(cherry picked from commit a67c1ec4b5)
2015-08-24 16:39:37 +02:00
Beniamino Galvani
ac9d087278 libnm-core: trivial: fix glib-mkenums parse warning
Avoid a new line in the definition of enum value to fix the following
glib-mkenums warning:

  glib-mkenums: nm-setting-wired.h:71:
  Failed to parse ` - 1 - NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT) '

Fixes: 5622461c04
(cherry picked from commit f8ae5f1671)
2015-08-21 18:12:36 +02:00
Beniamino Galvani
2757891b57 libnm-core: strip nm_utils_enum_from_str() input string
(cherry picked from commit e65854f609)
2015-08-21 18:12:36 +02:00
Thomas Haller
ea7063dbc2 libnm: fix gtkdoc for nm_utils_enum_to_str() and nm_utils_enum_from_str()
Fixes: 8be9814793
(cherry picked from commit 97ec44f593)
2015-08-21 18:12:36 +02:00
Beniamino Galvani
d449d82304 libnm-core: add Wake-on-LAN properties to NMSettingWired
(cherry picked from commit 5622461c04)
2015-08-21 18:12:36 +02:00
Beniamino Galvani
f4ce6760e0 libnm-core: add enum conversion utilities
Add functions nm_utils_enum_to_str() and nm_utils_enum_from_str()
which can be used to perform conversions between enum values and
strings, passing the GType automatically generated for every enum by
glib-mkenums.

(cherry picked from commit 8be9814793)
2015-08-21 18:12:36 +02:00
Jiří Klimeš
77bf69c3dc libnm: add utility functions for getting 2.4 GHz and 5 GHz Wi-Fi frequencies
nm_utils_wifi_2ghz_freqs()
nm_utils_wifi_5ghz_freqs()

(cherry picked from commit 1a6b631690)
2015-08-21 09:50:49 +02:00
Thomas Haller
e125603450 libnm-core: don't assert in nm_connection_get_uuid() for valid connection
We want to call nm_connection_get_uuid() also on connections that don't verify.
Otherwise it is chumbersome to check first for verified connection.

(cherry picked from commit 61eed191a9)
2015-08-20 18:05:43 +02:00
Dan Winship
2b78a1d53b libnm-core: add _nm_dbus_error_has_name()
Add a method for checking the D-Bus error name of an error.

(cherry picked from commit ec6f350f44)
2015-08-19 12:59:39 +02:00
Thomas Haller
6d2a1edc38 macros: use short-circuit evaluation in NM_IN_SET()
All current users of NM_IN_SET() would rather use short-circuit evalation
(or don't care). It seems that doing it by default seems favorable.

The only downside is, that this might have somewhat unexpected behavior
to a user who expects a regular function (which would evaluate always
all arguments).

Fixes: 7860ef959a
(cherry picked from commit 96cacc07e8)
2015-08-12 16:07:22 +02:00
Thomas Haller
69b276d6d1 macros: rework NM_IN_SET() macro to expand to a plain logical expression
Let the preprocessor do more work, but generate a simple expression that
the compiler can optimize (presumably) better.

(cherry picked from commit 7860ef959a)
2015-08-12 16:07:02 +02:00
Lubomir Rintel
6f616d4c4b libnm-core,libnm-util: drag in glib.h for nm-version.h
G_UNAVAILABLE defines need it.

Fix building of the Qt example.
2015-07-23 10:06:41 +02:00
Thomas Haller
9cfdbf6a06 libnm-core: don't assert against non-NULL @ip argument to canonicalize_ip()
Remove an assertion in canonicalize_ip() to assert that either a
non-NULL @ip is given, or @null_any is TRUE.

The condition of the assert is not easy to understand without context.
Instead the caller should already handle %NULL properly.

All callers that pass @null_any=FALSE to canonicalize_ip(), already assert
that the argument is not %NULL. With the exception of nm_ip_route_new()
which however checks for a valid @dest early on.

(cherry picked from commit 7f129b976c)
2015-07-22 14:50:51 +02:00
Lubomir Rintel
2958b3d1af libnm-core: 0.0.0.0 is a valid gateway too
It makes sense for point-to point links.

https://bugzilla.redhat.com/show_bug.cgi?id=1244483
(cherry picked from commit f14fd048ff)
2015-07-22 14:50:51 +02:00
Thomas Haller
89b630ff32 libnm-core: fix nm-setting-ip-config.c:valid_ip() to handle %NULL argument
We call valid_ip() from nm_ip_route_new() to check whether an untrusted string
is a valid ip address. Properly handle %NULL argument.

Fixes: 21c8a6b20e
(cherry picked from commit 9342568694)
2015-07-22 14:50:51 +02:00
Thomas Haller
fa2b8fdbdf libnm-core: properly handle %NULL @ip in nm_utils_ipaddr_valid()
A is_valid() function should just accept NULL as input and
return "invalid". It certainly should not crash.

Fixes: 21c8a6b20e
(cherry picked from commit 2b55de8560)
2015-07-22 14:50:51 +02:00
Beniamino Galvani
975afac6a4 ifcfg-rh: add support for CONNECTION_METERED
(cherry picked from commit 7e5e624daf)
2015-07-22 13:52:46 +02:00
Beniamino Galvani
4eb05767ee libnm-core: add 'metered' property to NMSettingConnection
Add a 'metered' enum property to NMSettingConnection with possible
values: unknown,yes,no. The value indicates the presence of limitations
in the amount of traffic flowing through the connection.

(cherry picked from commit 6f647fe689)
2015-07-22 13:52:45 +02:00
Beniamino Galvani
77a7e913a2 core,libnm: add 'metered' property to NMDevice
(cherry picked from commit bbbf522941)
2015-07-22 13:52:45 +02:00
Beniamino Galvani
1fa10e9766 build: add NM_AVAILABLE_IN_1_0_6 define 2015-07-22 13:49:31 +02:00
Jiří Klimeš
3af6be7aa6 docs: fix a copy/paste error in description of VLAN flags
(cherry picked from commit 2af10ef444)
2015-07-17 11:50:42 +02:00
David Shea
bfb6c78430 libnm: handle illegal characters in nm_utils_ssid_to_utf8() (rh #1243078)
g_convert_with_fallback() will fail if the SSID contains characters that
are not legal in the source encoding, which, if $LANG is not set, will
be ASCII. If this happens, replace all non-ASCII and non-printable
characters with '?'. It is possible that nm_utils_ssid_to_utf8() will
now return an empty string (e.g., the source string is actually
big-endian UTF-16 and g_strcanon() stops on the first byte), but it will
not return NULL.

https://bugzilla.redhat.com/show_bug.cgi?id=1243078

(cherry picked from commit 568b4ad31f)
2015-07-16 14:24:47 +02:00
Thomas Haller
a51a95b7b3 build/trivial: move declaration of NM_AVAILABLE_IN_0_9_10 macro
Move the declaration of the macro to make it more similar to the
version file on master.
2015-07-15 10:41:27 +02:00
Thomas Haller
c27385b401 build: add NM_VERSION_1_0_6 macro and bump NM_VERSION_CUR_STABLE 2015-07-15 10:36:45 +02:00
Jiří Klimeš
c73eeb39f5 supplicant: allow with_system_ca_path to be a file name (rh #1236548)
NetworkManager uses wpa_supplicant, which in turn calls OpenSSL for verifying
certificates. wpa_supplicant calls
SSL_CTX_load_verify_locations(ctx, CAfile, CApath)
using its ca_cert and ca_path options as CAfile and CApath parameters.

We have a configure time option with_system_ca_path to override ca_path.
However, it doesn't work when a system (like Fedora) only uses bundled PEM
certificates instead of a directory with hashed certificates ([1], [2]).

So this commit allows setting --with_system_ca_path to a file name (the
trusted certificate bundle). Then the name is used to populate wpa_supplicant's
ca_cert instead of ca_path.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1053882
[2] https://www.happyassassin.net/2015/01/12/a-note-about-ssltls-trusted-certificate-stores-and-platforms/

https://bugzilla.redhat.com/show_bug.cgi?id=1236548

(cherry picked from commit 640eb8f284)
2015-07-08 17:12:19 +02:00
Thomas Haller
0cbcf21e80 libnm: add @deep_copy argument to _nm_utils_strv_to_slist() and _nm_utils_slist_to_strv()
(cherry picked from commit ed632207cd)
2015-07-03 09:24:05 +02:00
Thomas Haller
1dec33e2af libnm: expose strv utils function in internal header nm-core-internal.h
(cherry picked from commit 93e4a8d102)
2015-07-03 09:24:05 +02:00
Thomas Haller
b1246efc60 libnm: consider ordering for _nm_keyfile_equals()
GKeyFile considers the order of the files, so add a possibility
to check whether to keyfiles are equal -- also with respect to
the order of the elements.

(cherry picked from commit 7fbfaf567d)
2015-07-03 09:24:03 +02:00
Thomas Haller
016d46265f libnm-keyfile/test: fix missing assertion in test
(cherry picked from commit e1b0195c67)
2015-07-03 09:24:03 +02:00
Thomas Haller
582ef15d3e libnm/keyfile: fix compile warning about uninitialized variable
Fixes: 71323122c6
(cherry picked from commit 47551df352)
2015-07-03 09:24:03 +02:00
Thomas Haller
41d0902dc9 libnm: add keyfile utility functions
(cherry picked from commit 71323122c6)
2015-07-03 09:24:03 +02:00
Thomas Haller
5cf8d6fd19 libnm: add _nm_utils_strv_cleanup() function
(cherry picked from commit 885d187d23)
2015-07-03 09:24:02 +02:00
Thomas Haller
519ea3f0d4 libnm-keyfile: ensure g_key_file_get_groups() sets the length argument
Under certain cases, if g_key_file_get_groups() fails, it might not set the
out argument @length. Play it safe and initialize it.

(cherry picked from commit aa7a53bc67)
2015-07-03 09:24:02 +02:00
Thomas Haller
06395568e7 keyfile/test: refactor and cleanup _keyfile_convert()
_keyfile_convert() should really test for successful round-trip
conversion of keyfile-connection and vice versa.

(cherry picked from commit 81119c69d8)
2015-07-03 09:24:01 +02:00
Yuri Chornoivan
7eeb6ec593 fix typo and do not translate an empty string
https://bugzilla.gnome.org/show_bug.cgi?id=748906
(cherry picked from commit f851a741a6)
2015-07-03 09:24:01 +02:00
Thomas Haller
c91ca73c9b libnm/keyfile: fix format string for unsigned integer
Fixes: 04df4edf48
(cherry picked from commit d05bedbc0d)
2015-07-03 09:24:01 +02:00
Thomas Haller
e977e55e94 test: add nmtst_create_connection_from_keyfile()
(cherry picked from commit 997fc07ca5)
2015-07-03 09:24:01 +02:00
Thomas Haller
a1abe76aec 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.

(cherry picked from commit c9a8764ad2)
2015-07-03 09:24:01 +02:00
Thomas Haller
46ebed64f4 libnm: add define for cert scheme prefix file:// for NMSetting8021x
(cherry picked from commit a49680dacd)
2015-07-03 09:24:01 +02:00
Thomas Haller
a18e6c81af keyfile: refactor to use reading and writing of keyfile from libnm-core
(cherry picked from commit 57a432fa8a)
2015-07-03 09:24:01 +02:00
Thomas Haller
176e4a3f54 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.

(cherry picked from commit 5e5afcffce)
2015-07-03 09:24:01 +02:00
Thomas Haller
45aba0fe73 libnm: add keyfile support to libnm-core
https://bugzilla.gnome.org/show_bug.cgi?id=744699
(cherry picked from commit 04df4edf48)
2015-07-03 09:24:01 +02:00
Thomas Haller
d086b5e928 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

(cherry picked from commit 1fc9bc401e)
2015-07-03 09:24:00 +02:00
Thomas Haller
7617637086 libnm: move _nm_utils_uuid_generate_from_strings() from src/ to libnm-core/
(cherry picked from commit e82293ebf6)
2015-07-03 09:24:00 +02:00
Thomas Haller
21849d73ee 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.

While backporting, hide public API from 1.2.

(cherry picked from commit 15926e9eb3)
2015-07-03 09:24:00 +02:00
Thomas Haller
7c6da95f14 trivial: add FIXME code comment about potential race
(cherry picked from commit 0f1fe69422)
2015-07-03 09:24:00 +02:00