Commit Graph

13873 Commits

Author SHA1 Message Date
Lubomir Rintel
dfdcbfe115 core: don't wipe out VPN secrets if we're changing the connection
The VPN secret properties are hashes and thus the default property value does
not work with them.
2014-12-11 11:15:53 +01:00
Lubomir Rintel
a3f9e51927 agent-manager: don't ever fail the secrets requests from GetSecrets()
VPN connections always return true for nm_connection_need_secrets(), but the
documented behavior of GetSecrets() is just to return any secrets we have
(otherwise nmcli c --show-secrets would not be useful for VPN connections).
2014-12-11 11:15:53 +01:00
Thomas Haller
5849c97c03 platform: avoid conflicts when reinstalling the device-route
Since f32075d2fc, we remove the kernel
added IPv4 device route, and re-add it with appropriate metric.

This could potentially replace existing, conflicting routes. Be more
careful and only take any action when we don't have a conflicting
route and when we add the address for the first time.

The motivation for this was libreswan which might install a VPN route
for a subnet that we also have configured on an interface. But the route
conflict could happen easily for other reasons, for example if you
configure a conflicting route manually.

Don't replace the device route if we have any indication that
a conflict could arise.

https://bugzilla.gnome.org/show_bug.cgi?id=723178
2014-12-11 10:07:00 +01:00
Thomas Haller
e439478ccd device: add logging macro _LOGT() 2014-12-09 16:17:46 +01:00
Thomas Haller
37361a038f dispatcher: refactor constructing environment variables from strv
This also avoids warnings with -O2 -Wstrict-overflow (gcc-4.8.3):

    make[4]: Entering directory `./NetworkManager/callouts'
      CC       libtest_dispatcher_envp_la-nm-dispatcher-utils.lo
    nm-dispatcher-utils.c: In function 'construct_ip6_items':
    nm-dispatcher-utils.c:283:8: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
         if (i != 0)
            ^
    nm-dispatcher-utils.c: In function 'construct_ip4_items':
    nm-dispatcher-utils.c:144:8: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
         if (i != 0)
            ^
    nm-dispatcher-utils.c:168:8: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
         if (i != 0)
            ^

https://bugzilla.gnome.org/show_bug.cgi?id=741168
2014-12-08 19:14:31 +01:00
Thomas Haller
937a5639fc libnm: return 0 for empty address in hwaddr_binary_len()
Motivated by avoiding compiler warning with -O2 -Wstrict-overflow (gcc-4.8.3):

    make[4]: Entering directory `./NetworkManager/libnm-core'
      CC       nm-utils.lo
    ../libnm-core/nm-utils.c: In function 'nm_utils_hwaddr_valid':
    ../libnm-core/nm-utils.c:2725:14: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
       if (length == 0 || length > NM_UTILS_HWADDR_LEN_MAX)
                  ^
    ../libnm-core/nm-utils.c: In function 'nm_utils_hwaddr_canonical':
    ../libnm-core/nm-utils.c:2755:14: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
       if (length == 0 || length > NM_UTILS_HWADDR_LEN_MAX)
                  ^

https://bugzilla.gnome.org/show_bug.cgi?id=741168
2014-12-08 19:02:55 +01:00
Dan Winship
5bfb4c8c23 tui: fix deletion of slaves with master (rh #1131574)
We wait for each deletion to complete, so the connections were getting
removed from the connections array as we edited it (unlike with the
old transfer-container GSList-based code). Fix this by copying the
slaves out into their own list first.
2014-12-05 16:16:53 +01:00
Thomas Haller
820e41645f libnm: fix wrong g_return_if_fail() in nm_utils_file_search_in_paths()
Fixes: 6399170ff3
https://bugzilla.gnome.org/show_bug.cgi?id=740783
2014-12-05 15:01:01 +01:00
Thomas Haller
490eb51f0a libnm: merge branch 'th/libnm-version-script-bgo741069'
https://bugzilla.gnome.org/show_bug.cgi?id=741069
2014-12-05 11:56:55 +01:00
Thomas Haller
2788c344c3 libnm/build: add versioning to linker script
https://bugzilla.gnome.org/show_bug.cgi?id=741069
2014-12-05 11:56:37 +01:00
Thomas Haller
256662f701 build: adjust tools/check-exports.sh
Now that the version scripts might have different
sections, the previous check-exports.sh script no
longer works.
2014-12-05 11:56:37 +01:00
Thomas Haller
005b83de47 libnm: fix gtkdoc annotations for nm_utils_file_search_in_paths()
Fixes: 6399170ff3
2014-12-05 11:53:29 +01:00
Thomas Haller
540a30ef96 libnm: merge branch 'th/file_search_in_path_bgo740783'
https://bugzilla.gnome.org/show_bug.cgi?id=740783
2014-12-05 11:09:21 +01:00
Thomas Haller
cb8af29f0b core: implement nm_utils_find_helper() based on nm_utils_file_search_in_paths()
This also changes behavior in that we now only find files that
are executable.

https://bugzilla.gnome.org/show_bug.cgi?id=740783
2014-12-05 11:07:42 +01:00
Thomas Haller
6399170ff3 libnm: add function nm_utils_file_search_in_paths()
We now also use a similar function in VPN plugins. It makes
sense to provide a generic implementation in libnm.

Signed-off-by: Thomas Haller <thaller@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=740783
2014-12-05 11:07:42 +01:00
Thomas Haller
cd025f05f7 libnm: normalize connections in nm_simple_connection_new_from_dbus()
Before we would just call verify() and only return valid connections
without attempting to fix them.

It is better to use normalize(), because that function is especially there to
accept and repair deprecated configurations that would no longer verify().

This changes behavior in the way that the function now accepts connections
that would have been rejected before.

Since commit b88715e05b normalize() also
adds a missing UUID. Hence this also affects the DBUS method 'AddConnection'
in that it now accepts connections without UUID. Previously, clients were
required to set a UUID for the new connection, now NM core can create a random
one if no UUID is set.

https://bugzilla.gnome.org/show_bug.cgi?id=740813
2014-12-05 11:04:20 +01:00
Jiří Klimeš
9e2203c418 merge: fix number of defects found by Coverity scan (bgo #741122)
https://bugzilla.gnome.org/show_bug.cgi?id=741122
2014-12-05 09:39:12 +01:00
Jiří Klimeš
49bbafbb16 utils: fix converting milliseconds to microseconds
Coverity:
Defect type: CONSTANT_EXPRESSION_RESULT
/src/NetworkManagerUtils.c:726: result_independent_of_operands: "18446744073709551615UL /* 9223372036854775807L * 2UL + 1UL */ < (gulong)sleep_duration_msec * 1000UL" is always false regardless of the values of its operands. This occurs as the logical first operand of '?:'.
2014-12-05 09:38:40 +01:00
Jiří Klimeš
448b073bda bluetooth: the code cannot be reached
because either GSM or CDMA is present. It is checked just above.

Coverity:
Defect type: DEADCODE
src/devices/bluetooth/nm-device-bt.c:312: dead_error_line: Execution cannot reach this statement: "fallback_prefix = dcgettext...".
2014-12-05 09:38:40 +01:00
Jiří Klimeš
b11416de6a libnm: check pspec before accessing it in handle_property_changed()
Fixes: 1f8ec6122e

Coverity:
libnm/nm-object.c:926: var_deref_op: Dereferencing null pointer "pspec".
libnm/nm-object.c:924: var_deref_op: Dereferencing null pointer "pspec".
2014-12-05 09:38:40 +01:00
Jiří Klimeš
28599331e3 callout: ignore waitpid() return value
Coverity:
Defect type: CHECKED_RETURN
2014-12-05 09:38:40 +01:00
Jiří Klimeš
43b4c8f826 platform: ignore nm_platform_ip4_route_add/delete return value
Coverity:
Defect type: CHECKED_RETURN
2014-12-05 09:38:40 +01:00
Jiří Klimeš
7744bd0f85 utils: initialize timespec structure
Coverity:
Defect type: UNINIT
src/NetworkManagerUtils.c:1906: uninit_use_in_call: Using uninitialized value "tp.tv_nsec" when calling "monotonic_timestamp_get".
src/NetworkManagerUtils.c:1879: uninit_use_in_call: Using uninitialized value "tp.tv_nsec" when calling "monotonic_timestamp_get".
src/NetworkManagerUtils.c:1852: uninit_use_in_call: Using uninitialized value "tp.tv_nsec" when calling "monotonic_timestamp_get".
src/NetworkManagerUtils.c:1825: uninit_use_in_call: Using uninitialized value "tp.tv_nsec" when calling "monotonic_timestamp_get".
2014-12-05 09:38:40 +01:00
Jiří Klimeš
d80bb52872 tui: width and height parameters was swapped, but they are ignored anyway
Coverity: Defect type: SWAPPED_ARGUMENTS
clients/tui/newt/nmt-newt-section.c:328: swapped_arguments: The positions of arguments in the call to "nmt_newt_widget_size_request" do not match the ordering of the parameters: * "&border_height" is passed to "width" * "&border_width" is passed to "height"
2014-12-05 09:38:40 +01:00
Jiří Klimeš
f93128194e tui: set GError so that it is not NULL later
Coverity:
Defect type: FORWARD_NULL
clients/tui/nmtui-edit.c:467: var_deref_op: Dereferencing null pointer "error".
2014-12-05 09:38:40 +01:00
Jiří Klimeš
0da3b96ab5 libnm-core: do not access array if it is NULL
Coverity:
Defect type: FORWARD_NULL
libnm-core/nm-setting-8021x.c:1684: var_deref_op: Dereferencing null pointer "array".
2014-12-05 09:38:40 +01:00
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