Commit Graph

528 Commits

Author SHA1 Message Date
Thomas Haller
137e496ef1 libnm: fix memleaks in nm_setting_802_1x 2015-02-09 11:51:05 +01:00
Thomas Haller
7a82d64e47 libnm: fix memleak in nm_setting_wired_get_s390_option() and refactor
@keys was leaked. Also refactor the function to iterate the hash only
once.
2015-02-09 11:51:05 +01:00
Thomas Haller
f1bfe459ee libnm: fix memleak in find_virtual_interface_name() 2015-02-09 11:51:05 +01:00
Thomas Haller
fffd93b5c4 libnm: fix memleak in nm_connection_replace_settings() 2015-02-09 11:51:05 +01:00
Thomas Haller
66be46309a libnm: fix memleak in nm_utils_ip_addresses_from_variant() 2015-02-09 11:51:05 +01:00
Thomas Haller
8cb6d70e5b libnm: fix memleak for config in NMSettingTeamPort 2015-02-09 11:51:05 +01:00
Thomas Haller
052198f4b9 libnm: fix memleak for app_fcoe_mode in NMSettingDcb 2015-02-09 11:51:04 +01:00
Thomas Haller
c4e197d064 libnm: fix memleak in nm_utils_hwaddr_canonical() 2015-01-29 14:59:42 +01:00
Dan Winship
3debf80d82 libnm-core: fix docs typo 2015-01-29 07:01:41 -05:00
Jiří Klimeš
0acdd0e1e3 libnm-core: coverity fix
var_deref_op: Dereferencing null pointer "property->param_spec".
2015-01-28 08:57:23 +01:00
Dan Williams
5293683e4a libnm/libnm-util: add Wi-Fi 'powersave' property 2015-01-21 14:31:04 -06:00
Dan Winship
6da3b3a5a5 libnm: fix versioning on new APIs, bump soname
The newly added bond mode APIs in nm-utils will be new in 1.2, so mark
them as such in the headers and docs, move them to a new section in
libnm.ver.

Since we're adding the new section to libnm.ver, this also seems like
a good time to bump the soname.
2015-01-21 12:54:36 -05:00
Dan Winship
5756c65c6f libnm-core, libnm-util: belatedly update version macros
Add version macros for NM 1.2, and change NM_VERSION_CUR_STABLE to
1.0, and NEXT_STABLE to 1.2.
2015-01-21 12:54:36 -05:00
Thomas Haller
05212419e1 libnm-core: fix compile error in set_property_from_dbus() for missing return value
Fixes: 76d9fc9167
2015-01-16 13:39:33 +01:00
Dan Winship
76d9fc9167 libnm-core: validate property types from D-Bus (rh #1182567)
In _nm_setting_new_from_dbus(), verify that the properties have the
right types, and return an error if not. (In particular, don't crash
if someone tries to assign a GBytes-valued property a non-'ay' value.)
2015-01-15 14:46:30 -05:00
Dan Winship
d80e100179 libnm-core: simplify _nm_setting_new_from_dbus()
libnm-util's nm_setting_new_from_hash() needed to call
g_type_class_ref(setting_type) to ensure that the class had been
initialized by the time we fetched its properties. But in libnm-core's
version, we create the setting object before fetching the list of
properties, so we know the class will already have been initialized by
that point.
2015-01-15 14:46:30 -05:00
Dan Winship
bbbbca2778 libnm-core: fix a leak in _nm_setting_new_from_dbus() 2015-01-15 14:46:30 -05:00
Jiří Klimeš
3d1b6bd4d8 bond: normalize bond mode to string notation (rh #1171009)
Use descriptive string value as preferred bond mode representation.
Numeric modes still verify but with NM_SETTING_VERIFY_NORMALIZABLE,
suggesting a normalization action.

https://bugzilla.redhat.com/show_bug.cgi?id=1171009
2015-01-13 09:35:49 +01:00
Jiří Klimeš
93438dd092 libnm-core: accept numeric bond modes (bgo #704666) (rh #1133544)
https://bugzilla.gnome.org/show_bug.cgi?id=704666
https://bugzilla.redhat.com/show_bug.cgi?id=1133544
2015-01-13 09:35:49 +01:00
Jiří Klimeš
d787f0391b utils: add functions for converting string <-> numeric bonding modes 2015-01-13 09:35:49 +01:00
Thomas Haller
3e33a5a6c5 ifcfg-rh: support ipvx.route-metric property as IPVX_ROUTE_METRIC
Write ipv4.route-metric and ipv6.route-metric property of
NMSettingConnection as IPV4_ROUTE_METRIC and IPV6_ROUTE_METRIC,
respectively.
2015-01-10 21:10:52 +01:00
Lubomir Rintel
2f82bf537b bridge: Properly check range of STP properties (rh #1160815)
If zero is out of range, only allow it when STP is disabled.

https://bugzilla.redhat.com/show_bug.cgi?id=1160815
2015-01-09 12:13:53 +01:00
Thomas Haller
fc5a66b14b libnm: fix documentation for nm_utils_file_search_in_paths() 2015-01-08 13:08:56 +01:00
Thomas Haller
1bef194302 libnm/tests: make tested IPv4 addresses non-palindromic
For IPv4 addresses, the binary representation is in network-order,
contrary to host-order. It's better to choose addresses for testing
that are differently on big and little endian systems.
2014-12-19 13:53:26 +01:00
Thomas Haller
7990add493 libnm/tests: fix build failure on big-endian machines
`make check` fails:

  make  check-TESTS
  make[4]: Entering directory `/builddir/build/BUILD/NetworkManager-1.1.0/libnm-core/tests'
  ...
  /core/general/test_setting_802_1x_changed_signal: OK
  /core/general/test_setting_ip4_gateway: **
  ERROR:test-general.c:3652:test_setting_ip4_gateway: assertion failed (nm_setting_ip_config_get_gateway (s_ip4) == "192.168.1.1"): ("1.1.168.192" == "192.168.1.1")
  /bin/sh: line 5: 44957 Aborted                 (core dumped) ${dir}$tst
2014-12-19 13:53:26 +01:00
Dan Winship
2d29c0527e docs: misc small fixes
Cleans up all of the warnings that aren't overly annoying to clean up.
2014-12-18 13:47:03 -05:00
Thomas Haller
924f7b2064 build: embed git-commit-id as string inside libnm binary
In the 'configure.ac' script we already detect the git commit id
for the current source version. When creating a tarball, it is also
included inside the generated 'configure' script.

Add the commit id as a  static string to nm-utils.c. That way, having
a build of libnm.so or NetworkManager, you can quickly find the
corresponding git commit:

    strings src/NetworkManager | grep NM_GIT_SHA

Note that this only works after a new `autogen.sh` run. Only rebuilding
is not enough. Hence, you must rebuild all to ensure that the correct
commit id is embedded.

https://bugzilla.gnome.org/show_bug.cgi?id=741651
2014-12-18 17:36:57 +01:00
Jiří Klimeš
6603e7ffde tests: mute coverity for CHECKED_RETURN (CWE-252) in tests
Error: CHECKED_RETURN (CWE-252): [#def12]
NetworkManager-0.9.11.0/libnm-core/tests/test-general.c:348: check_return: Calling "nm_setting_verify" without checking return value (as is done elsewhere 37 out of 45 times).
...
2014-12-15 14:11:03 +01:00
Jiří Klimeš
afb0e2c53c libnm-core: mute coverity for RESOURCE_LEAK (CWE-772) in g_return_val_if_fail()
Error: RESOURCE_LEAK (CWE-772): [#def10]
NetworkManager-0.9.11.0/libnm-core/nm-setting-vlan.c:225: alloc_fn: Storage is returned from allocation function "priority_map_new_from_str".
NetworkManager-0.9.11.0/libnm-core/nm-setting-vlan.c:154:4: alloc_fn: Storage is returned from allocation function "g_malloc0".
NetworkManager-0.9.11.0/libnm-core/nm-setting-vlan.c:154:4: var_assign: Assigning: "p" = "g_malloc0(8UL)".
NetworkManager-0.9.11.0/libnm-core/nm-setting-vlan.c:164:2: return_alloc: Returning allocated memory "p".
NetworkManager-0.9.11.0/libnm-core/nm-setting-vlan.c:225: var_assign: Assigning: "item" = storage returned from "priority_map_new_from_str(map, str)".
NetworkManager-0.9.11.0/libnm-core/nm-setting-vlan.c:226: leaked_storage: Variable "item" going out of scope leaks the storage it points to.

Error: RESOURCE_LEAK (CWE-772): [#def11]
NetworkManager-0.9.11.0/libnm-core/nm-utils.c:2056: alloc_fn: Storage is returned from allocation function "crypto_make_des_aes_key".
NetworkManager-0.9.11.0/libnm-core/crypto.c:405:2: alloc_fn: Storage is returned from allocation function "g_malloc0".
NetworkManager-0.9.11.0/libnm-core/crypto.c:405:2: var_assign: Assigning: "key" = "g_malloc0(digest_len + 1U)".
NetworkManager-0.9.11.0/libnm-core/crypto.c:407:2: noescape: Resource "key" is not freed or pointed-to in function "crypto_md5_hash".
NetworkManager-0.9.11.0/libnm-core/crypto.c:769:24: noescape: "crypto_md5_hash(char const *, gssize, char const *, gssize, char *, gsize)" does not free or save its pointer parameter "buffer".
NetworkManager-0.9.11.0/libnm-core/crypto.c:415:2: return_alloc: Returning allocated memory "key".
NetworkManager-0.9.11.0/libnm-core/nm-utils.c:2056: var_assign: Assigning: "key" = storage returned from "crypto_make_des_aes_key("DES-EDE3-CBC", &salt[0], salt_len, in_password, &key_len, NULL)".
NetworkManager-0.9.11.0/libnm-core/nm-utils.c:2057: leaked_storage: Variable "key" going out of scope leaks the storage it points to.
2014-12-15 14:10:55 +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
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
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
005b83de47 libnm: fix gtkdoc annotations for nm_utils_file_search_in_paths()
Fixes: 6399170ff3
2014-12-05 11:53:29 +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š
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
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
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
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
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