Commit Graph

15047 Commits

Author SHA1 Message Date
Jiří Klimeš
e52f352339 util: fix _log_connection_sort_names_fcn()
Coverity:
Defect type: CONSTANT_EXPRESSION_RESULT
src/NetworkManagerUtils.c:1978: same_on_both_sides: "(v1->diff_result & NM_SETTING_DIFF_RESULT_IN_B) != (v1->diff_result & NM_SETTING_DIFF_RESULT_IN_B)" is always false regardless of the values of its operands because those operands are identical. This occurs as the logical operand of if.
2014-12-05 09:38:40 +01:00
Jiří Klimeš
d637b3efae libnm: missing break on get_property
Coverity:
Defect type: MISSING_BREAK
libnm/nm-dhcp-config.c:117: fallthrough: The above case falls through to this one.
2014-12-05 09:38:40 +01:00
Thomas Haller
87f2b92da3 libnm-util/tests: fix invalid g_test_expect_message() pattern
A failure to g_return_*() prints a critical warning which contains
G_STRFUNC. Depending on the compiler this contains only the function
name or the entire signature.

Relax the assertion pattern to check the function name.
2014-12-04 17:57:35 +01:00
Thomas Haller
69860e5d3a libnm: don't allocate temporary buffer in nm_utils_uuid_generate_from_strings()
crypto_md5_sum() already accepts two separate strings: salt and password.
No need to allocate a temporary buffer. Just pass @ns_uuid and @s
separately.
2014-12-04 17:44:11 +01:00
Thomas Haller
440b9d85b4 libnm: fix leak in nm_utils_uuid_generate_from_strings()
Did not free the GString instance @str. Thereby,
also don't use GString. Just malloc() the temporary
buffer.

Fixes: e7661c9b52
2014-12-04 17:22:40 +01:00
Thomas Haller
da8b201095 libnm: merge branch 'th/uuid-variant3-bgo740865'
https://bugzilla.gnome.org/show_bug.cgi?id=740865
2014-12-04 17:03:22 +01:00
Thomas Haller
924fd189b8 libnm: allow empty strings for nm_utils_uuid_generate_from_string()
Since commit ef3de46c43
crypto_md5_hash() allows empty password. Also support
empty strings for nm_utils_uuid_generate_from_string().
2014-12-04 17:02:22 +01:00
Thomas Haller
74bdaf1ad8 libnm: hide nm_utils_uuid_generate_from_string() from public API 2014-12-04 17:02:22 +01:00
Thomas Haller
b88715e05b libnm: normalize missing connection UUID
Extend nm_connection_normalize() to add a connection UUID
in case it is unset.
2014-12-04 17:02:22 +01:00
Thomas Haller
b159946798 settings: change algorithm for UUID generation based on strings
In several cases, connection uuids are generated based on
some strings. Change the algorithm, to prefix the hashed
identifier differently for each setting type. This makes
collisions very unlikely.

Also, change the algorithm, to create proper Variant3 UUIDs.

This is a behavioral change, but it only affects code places
that were added since nm-0-9-10 and were not yet part of
a stable release.
2014-12-04 17:02:22 +01:00
Thomas Haller
9a08d8602c core: add nm_utils_uuid_generate_from_strings()
Add function to create variant3 UUIDs based on a set
of concatenated strings.
2014-12-04 17:02:22 +01:00
Thomas Haller
e7661c9b52 libnm: implement variant3 UUIDs according to rfc4122
Compare the results:
  perl -e 'use UUID::Tiny ":std"; print(uuid_to_string(create_uuid(UUID_V3, UUID_NS_DNS, "test"))."\n");'
  python -c 'from uuid import *; print(uuid3(UUID("6ba7b810-9dad-11d1-80b4-00c04fd430c8"), "test"))'
2014-12-04 17:02:22 +01:00
Thomas Haller
1e313e000d libnm: add a type argument to nm_utils_uuid_generate_from_string()
There are different types (variants) of UUIDs defined.
Especially variants 3 and 5 are name based variants (rfc4122).

The way we create our UUIDs in nm_utils_uuid_generate_from_string()
however does not create them according to RFC and does not set
the flags to indicate the variant.

Modify the signature of nm_utils_uuid_generate_from_string() to accept
a "uuid_type" argument, so that we later can add other algorithms without
breaking API.
2014-12-04 17:02:22 +01:00
Thomas Haller
21eb6b5d0d libnm: accept additional length argument in nm_utils_uuid_generate_from_string()
This makes the function also useful for non C-strings,
non UTF-8-strings, and generic blobs.
2014-12-04 17:02:22 +01:00
Thomas Haller
50d1de13cb libnm: don't heap allocate uuid temporary variable 2014-12-04 17:02:22 +01:00
Thomas Haller
e67425347a libnm/test: add test for nm_utils_uuid_generate_from_string() 2014-12-04 17:02:22 +01:00
Thomas Haller
ea14a0136f crypto/test: test crypto_md5_hash() for empty passwords
Empty passwords are allowed since commit
ef3de46c43 .
2014-12-04 17:00:55 +01:00
Thomas Haller
94af5e76bc libnm/crypto: fix uninitialized variable in crypto_md5_hash()
@digest_len passed to g_checksum_get_digest() must be
initialized to the size of the digest. It is an in-out paramter.

Fixes: 48ff21b5bc
2014-12-04 16:24:05 +01:00
Jiří Klimeš
9a6e1e86cc core: don't bounce disable_ipv6 when assuming connections (rh #1170530)
Don't call set_nm_ipv6ll(self, TRUE) on any assumed connection since it
would bounce disable_ipv6, which would break IPv6 connectivity.
That is critical, for example, for installations via NFS.

Fixes: d37b7bed30

https://bugzilla.redhat.com/show_bug.cgi?id=1170530
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1052157
2014-12-04 15:50:36 +01:00
Dan Winship
ddcd6dda55 libnm-core: merge branch 'nm-utils-init-bgo740893'
Drop nm_utils_init() and nm_utils_deinit(), and do some things via
constructors and other things via just-in-time initialization.

(Among other things, this fixes the fact that the daemon was failing
to call nm_utils_init().)

https://bugzilla.gnome.org/show_bug.cgi?id=740893
2014-12-04 08:50:57 -05:00
Dan Winship
d91bcc4960 libnm-core: drop nm_utils_rsa_key_encrypt(), _encrypt_aes()
In general, we shouldn't end up with an unencrypted copy of a
certificate key anyway, so this function ought to be unnecessary (or
at least, not broadly useful enough to be in the public API).
nm-applet's GConf migration tool needs it, but that will eventually go
away, and until then it can just use libnm-util.
2014-12-04 08:39:54 -05:00
Thomas Haller
ef3de46c43 libnm-core: relax restrictions on input arguments for crypto_md5_hash()
crypto_md5_hash() only has two users:
 (a) crypto_make_des_aes_key()
 (b) nm_utils_uuid_generate_from_string()

For (b) it is just a complicated way to compute the MD5 hash. The
restrictions on salt and password don't matter. Actually they
are harmful because we cannot compute the MD5 hash of the empty
word.
For (a), the caller should make sure to pass whatever restrictions
he wants to enforce on the data.

For example, it is counterintuitive, that crypto_md5_hash() would
require @salt_len, enforce it to be at least 8 bytes, and then just
use the first 8 bytes. If the caller (a) wants that behavior, he
should make sure that he passes in 8 bytes.
Likewise for the empty word. If the caller does not want to compute
the hash of empty passwords, he must not hash them.

Indeed, all of this was enforced by assertions, any caller already
did the right thing.
2014-12-04 08:39:54 -05:00
Thomas Haller
4460386800 libnm-core: combine duplicate crypto_make_des_aes_key() function 2014-12-04 08:39:54 -05:00
Dan Winship
3b86cc047e libnm: remove nm_utils_init() from the public API
Remove nm_utils_init() from the public API, and just do it as a
constructor instead.
2014-12-04 08:39:54 -05:00
Dan Winship
bddc0de51e libnm-core: call crypto_init() on the fly
Rather than requiring crypto_init() to have been called beforehand,
just have every method that depends on it call it itself.

This required adding a GError argument to crypto_is_pkcs12_data(),
which in turn required a few other changes elsewhere.
2014-12-04 08:39:54 -05:00
Dan Winship
48ff21b5bc libnm-core: reimplement crypto_md5_hash() using GChecksum
Reimplement crypto_md5_hash() using GChecksum. Remove the gboolean
return value and GError argument, since it cannot fail now.
2014-12-04 08:39:54 -05:00
Dan Winship
34519eee13 tests: add a test of libnm-core's crypto_md5_hash() 2014-12-04 08:39:54 -05:00
Dan Winship
539fac8b67 libnm-util: Note that nm_utils_deinit() is a no-op
nm_utils_deinit() is a no-op, so don't suggest that people need to
call it.
2014-12-04 08:39:54 -05:00
Dan Winship
926f4e1473 libnm: drop nm_utils_deinit()
It was a no-op anyway.
2014-12-04 08:39:54 -05:00
Dan Winship
cb025dba5b libnm-core: fix the rule for parsing 'gateway' out of 'addresses' (rh #1170199)
We were always using the gateway field of the first address in
ipv4.addresses / ipv6.addresses to set the gateway, but to be
compatible with old behavior, we should actually be using the first
non-0 gateway field (if the first one is 0).
2014-12-03 16:31:50 -05:00
Dan Williams
3cf2fbbf47 core: fix leak of generated connection if device is active
Don't generate (and add to settings) a connection if we aren't going
to use it anyway.
2014-12-03 14:25:45 -06:00
Dan Winship
5dd48f7527 devices: don't release slaves on exit (rh #1169936)
nm_device_removed() calls nm_device_release_one_slave() in order to
fix up NetworkManager's master/slave bookkeeping, but we don't want to
tell the kernel to actually unslave the device, since that would
happen automatically anyway if the device was really removed, and
shouldn't happen if the device is just being removed from NM's device
list.

(In particular, don't remove all libvirt-created virtual network
devices from virbr0 when NetworkManager exits.)
2014-12-03 13:19:48 -05:00
Thomas Haller
6d6c433bab ifcfg-rh: don't include nm-utils-private.h outside of libnm-core/ 2014-12-03 17:36:08 +01:00
Jiří Klimeš
0e727062fc cli: g_strdup(NULL) returns NULL; simplify code for that 2014-12-03 16:03:19 +01:00
Thomas Haller
09130c5693 contrib/rpm: ignore libgsystem/ repository in build_clean.sh 2014-12-03 15:01:12 +01:00
Jiří Klimeš
1a4259d23a cli: additional fix for nmcli connection down
nmcli crashed when a timeout was hit, because 'info' was used after freeing
in down_timeout_cb().

Fixes 4a7c88621d.
2014-12-03 13:22:29 +01:00
Jiří Klimeš
4a7c88621d cli: fix deactivation for multiple connections (bgo #740775) (rh #1168383)
$ nmcli connection down aa bb cc

It has been broken by commit 20566c76de.

Fixups by dcbw.

https://bugzilla.gnome.org/show_bug.cgi?id=740775
https://bugzilla.redhat.com/show_bug.cgi?id=1168383
2014-12-03 10:54:49 +01:00
Lubomir Rintel
e257744f9e device: Deal with links that vanish during initialization
nm_device_get_hw_address() may return NULL and nm_platform_link_get_type may
return NM_LINK_TYPE_NONE. While it might be a good idea to check for such cases
at the init time it seems easier to just ignore it and prevent blowing up in
subsequent deactivation.

A quick test case:

  # while :; do ip link add moo0 type veth peer moo1; ip link del moo0 ; done

Yields:

  NetworkManager:ERROR:devices/nm-device-ethernet.c:268:constructor:
    assertion failed: (link_type == NM_LINK_TYPE_ETHERNET ||
    link_type == NM_LINK_TYPE_VETH)

  nm_device_set_hw_addr: assertion 'addr != NULL' failed

https://bugzilla.gnome.org/show_bug.cgi?id=740992
2014-12-02 11:44:49 +01:00
Dan Williams
20566c76de cli: wait for "con down" to deactivate the connection (bgo #740775) (rh #1168383)
nmcli currently does not wait for the connection to fully deactivate, which
can take some time due to dispatcher scripts or cleanup operations like
DCB.  Change it to wait until the connection is deactivated, or until
a short timeout has expired.  The user can adjust the timeout with
"--wait" if they want.

https://bugzilla.gnome.org/show_bug.cgi?id=740775
https://bugzilla.redhat.com/show_bug.cgi?id=1168383
2014-12-01 10:04:50 -06:00
Thomas Haller
711c0eab5b iface-helper: disambiguate route priority for IPv4 and IPv6
https://bugzilla.gnome.org/show_bug.cgi?id=740780
2014-12-01 16:58:31 +01:00
Thomas Haller
ae2b8d6353 core: rename NM_PLATFORM_ROUTE_METRIC_DEFAULT to NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP6
For IPv4, iproute for example defaults to a metric of 0.
Hence, the name NM_PLATFORM_ROUTE_METRIC_DEFAULT was misleading.

Also add a NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP4 define for completeness.

https://bugzilla.gnome.org/show_bug.cgi?id=740780
2014-12-01 16:38:05 +01:00
Thomas Haller
c3246d962d nmcli/bash-completion: complete [+-] modifier for connection modify property
Fixes
  nmcli connection modify CONNECTION +conn<TAB>
2014-12-01 15:22:10 +01:00
Thomas Haller
f6fba86984 keyfile: assert in writer to have valid connection id
Few lines above we already verify the connection. We must
have an @id.
2014-11-28 18:39:54 +01:00
Jiří Klimeš
72156ba1c5 cli: fix setting ethernet.s390-subchannels
It was not properly updated in a7c4d53d03 (when
updating stuff to ne libnm).

And allow 2 subchannels (libnm and ifcfg-rh allow it too).
2014-11-28 14:27:31 +01:00
Jiří Klimeš
313a4081b5 devices: NM_SETTING_WIRED_S390_SUBCHANNELS is now G_TYPE_STRV (rh #1168764)
Fixes crash on s390.
The type change of the property was done in 6a4127cfa0,
but we forgot to update this function.

https://bugzilla.redhat.com/show_bug.cgi?id=1168764
2014-11-28 12:20:04 +01:00
Thomas Haller
4bf04700bb core: adjust values for default route-metrics per device type
We recently changed default values for route metrics. Revise that
again and increase the space between the default values.

No strong reason to do this, but it seems better to have larger
gaps and make use of the available range.
2014-11-26 20:39:18 +01:00
Thomas Haller
3210bb93a1 vpn: don't choose route priority for VPN connections based on the parent device
The parent device is just the device that happens to be the best device.
It does not mean, that its route metric should be inherited to the VPN
connection.

This also makes the resulting route metric for VPN connections much
more predictable: now it is either ipv4.route-metric from the connection,
or it falls back to NM_VPN_ROUTE_METRIC_DEFAULT (10).
2014-11-26 19:25:12 +01:00
Jiří Klimeš
382906c391 libnm: (trivial) correct an example in NMSecretAgentOldGetSecretsFunc docs 2014-11-26 14:07:46 +01:00
Thomas Haller
94274c6fcd build: fix wrongly linking against libreadline in all applications
Every Makefile in the subtrees would include -lreadline
as part of LIBS, hence every application would link against
the library.

This was broken since we added 'm4/ax_lib_readline.m4'.

Fixes: 29297f8531
2014-11-26 11:43:23 +01:00
Thomas Haller
f32075d2fc core: merge branch 'th/bgo723178_device_route_metric'
https://bugzilla.gnome.org/show_bug.cgi?id=723178
2014-11-26 00:18:49 +01:00