Commit Graph

1021 Commits

Author SHA1 Message Date
Dan Williams
cd5d92705d settings: track whether connection is saved to disk or not
Use the new NMConnection 'changed' signal to mark connections
as dirty/unsaved, and reset that when they get flushed to disk.
Previously, the 'Updated' signal was emitted only when the
connection was changed and flushed to disk, but now we have
more granular needs, and the signal is emitted whenever the
connection actually *is* changed, regardless of whether its
flushed to disk or not.
2013-05-28 12:26:55 -05:00
Dan Williams
87517ba6df libnm-util: sync some 802.1x function arguments with documentation 2013-05-28 12:26:55 -05:00
Dan Williams
f6064e7b74 libnm-util: implement connection changed signal
Emitted whenever settings are added or removed from the connection,
and whenever any property of any setting in the connection is changed.
2013-05-28 12:26:55 -05:00
Jiří Klimeš
18e9fba3d8 libnm-util: correct documentation for NMSettingConnection:timestamp 2013-05-28 18:19:37 +02:00
Dan Williams
1d8ab72a60 libnm-util: fix hashing of secrets broken by 4d326182
4d326182 changed connection hashing slightly such that now base type settings
are always returned even if they are empty. Unfortunately a bunch of code in
the settings hashed connections with the ONLY_SECRETS flag and then checked
whether the returned hash was NULL or not to determine whether there were
any secrets, and then called nm_connection_update_secrets() with the hash.

nm_connection_update_secrets() would fail in the case where a setting
name was given, but the passed-in secrets hash did not contain any secrets
for the requested setting.  Instead, the function should return success
to match the semantics of passing in an entire connection hash which may
not have any secrets either.
2013-05-20 13:56:48 -05:00
Jiří Klimeš
ced61dfc7f libnm-util: add access functions for 'mac-address-blacklist' to wired/wireless
nm_setting_wire(d/less)_get_num_mac_blacklist_items()
nm_setting_wire(d/less)_get_mac_blacklist_item()
nm_setting_wire(d/less)_add_mac_blacklist_item()
nm_setting_wire(d/less)_remove_mac_blacklist_item()
2013-05-07 19:38:31 +02:00
Dan Winship
8b823d7c6a libnm-util: add NMSettingGeneric
Add NMSettingGeneric, a dummy L2 NMSetting for creating NMConnections
for devices that are not specifically recognized.
2013-05-07 12:46:56 -04:00
Dan Williams
0a5f272c35 libnm-util: correct documentation for nm_setting_update_secrets() 2013-05-04 13:18:28 -05:00
Dan Williams
5f61594585 wifi: wep40 and wep104 are invalid algorithms for WPA pairwise
The supplicant rejects them, so any configuration that used them
wasn't working for a long time anyway.  Remove them.
2013-05-03 10:31:50 -05:00
Dan Williams
ccaf5231a2 libnm-util: clarify WiFi security pairwise/group property descriptions 2013-05-03 10:31:50 -05:00
Dan Williams
72ea5dac33 libnm-util: clarify WiFi setting MAC address blacklist description 2013-05-03 10:31:50 -05:00
Dan Williams
229cba8354 libnm-util: clarify 802.1x password and password-raw documentation 2013-05-03 10:31:50 -05:00
Jiří Klimeš
5a50e60ac3 libnm-util: define NM_SETTING_GSM_BANDS_MAX - maximal value for allowed bands
and use it in 'allowed-bands' property installation.

The macro NM_SETTING_GSM_BANDS_MAX also allows libnm-util users to check
if bands are valid (before setting them).
2013-05-03 17:23:41 +02:00
Dan Winship
4d32618264 libnm-util: handle "empty" connection-type settings correctly
nm_setting_to_hash() would return NULL if the setting had entirely
default values, but this effectively meant that you could never have a
connection whose "connection type" setting (eg, NMSettingWired) had
all default values. (This ended up not usually being a problem in
practice because most such settings had at least one property with a
mandatory string value where the GObject property had a default value
of NULL.)

However, NMSettingGeneric will have no properties, so it would always
get stripped out when converting to a hash, invalidating the
connection. Fix that.
2013-05-03 08:39:10 -04:00
Dan Winship
6cb786f569 libnm-util: move setting priority functions to nm-setting.c
None of these take an NMConnection; they logically belong in
NMSetting.
2013-05-03 08:39:06 -04:00
Jiří Klimeš
c35dda8727 libnm-util: fix the maximal value for gsm 'allowed-bands' property
The bitfields have to be OR-ed with the bitwise |, not ||.
2013-05-03 10:11:56 +02:00
Jiří Klimeš
bfc20af513 libnm-util: fix WEP key type comparison in nm_utils_wep_key_valid() 2013-05-03 10:11:56 +02:00
Jiří Klimeš
841c259119 libnm-util: make nm_connection_replace_settings_from_connection() safer
When 'connection' and 'new_connection' arguments are the same object make the
function no-op and simply return true. Otherwise 'connection's settings are
removed, making it invalid.

Signed-off-by: Jiří Klimeš <jklimes@redhat.com>
2013-04-22 10:15:53 -05:00
Dan Winship
649d2e4c1b libnm-util: fix doc bug in NMSettingIP6Config 2013-04-19 15:37:48 -04:00
Martin Pitt
57a9fb3c89 Use %NULL macro in doc strings
Mass-converted "NULL" to "%NULL" in docstrings with

  find -name '*.c'| xargs sed -i '/^ \*.*[^%]NULL/ s/NULL\b/%NULL/g'
2013-04-19 10:08:17 -04:00
Martin Pitt
6226fb9b59 libnm-util: Fix transfer annotations of nm_{connection,setting}_need_secrets()
The various need_secrets() implementation do allocate a fresh GPtrArray, but
add static strings to them without dup'ing. Thus callers must _not_ free the
array elements, only the array itself. Adjust documentation and annotations
accordingly.

Also adjust the corresponding comment in the goi-list-connections.py example.

https://bugzilla.gnome.org/show_bug.cgi?id=698175
2013-04-19 09:43:56 -04:00
Dan Williams
bafd0d557d libnm-util: add nm_connection_replace_settings_from_connection() (bgo #696387)
Convenience function to replace settings in one conneciton with settings
from another, without having to go through the nm_connection_to_hash()
steps, which are just inefficient and kinda pointless.
2013-04-17 12:23:34 -05:00
Dan Williams
4aa91e22a0 libnm-util: fix mis-freed VLAN priority list element
We want to free the element data, then remove the element from the
list.  Instead the code freed the element data, then treated the
element data pointer as a GSList link, which is completely wrong.
2013-04-11 19:11:51 -05:00
Dan Winship
5fec30d98e Revert :carrier-detect properties and associated code
Ignoring carrier is generally something you want at the machine level
(eg, for a server), not at the connection level.
2013-04-03 10:23:49 -04:00
Jiří Klimeš
f17ab954f6 libnm-util: make nm_setting_vpn_remove_*() return gboolean instead of void
to match other property removal functions, like nm_setting_bond_remove_option()
or nm_setting_wired_remove_s390_option().

Note:
This is an API change, make sure to bump soname when releasing libnm-util.
2013-04-03 08:35:47 +02:00
Dan Williams
a492d29ceb libnm-util: convert remaining NMConnection users to GHashTableIter 2013-04-01 17:18:54 -05:00
Dan Williams
6c7c2b874d libnm-util: convert nm_setting_new_from_hash() to GHashTableIter 2013-04-01 17:18:54 -05:00
Dan Williams
a8d33c7e2c libnm-util: convert nm_connection_duplicate() to GHashTableIter 2013-04-01 17:18:54 -05:00
Dan Williams
7a7ce3b8e2 libnm-util: convert nm_connection_dump() to GHashTableIter 2013-04-01 17:18:54 -05:00
Dan Williams
df02e7324c libnm-util: convert nm_connection_compare() to GHashTableIter
And finally add some testcases for it too.
2013-04-01 17:18:54 -05:00
Dan Williams
66230eb2f6 libnm-util: reduce memory used by NMConnection
The setting names used when inserting a setting into the hash
table are const since they are derived from GObject internals,
so there's no need to strdup them.
2013-04-01 17:18:53 -05:00
Dan Williams
faf376dad1 libnm-util: fix memory leaks of dhcp_hostname and dhcp_client_id 2013-04-01 17:18:53 -05:00
Dan Williams
c00e2f1d9d libnm-util: fix some memory leaks in testcases
Helps suppress valgrind false positives.
2013-04-01 17:18:53 -05:00
Dan Williams
0ab00b895b libnm-util: make nm_setting_wired_add_s390_option() argument names consistent 2013-04-01 17:12:22 -05:00
Jiří Klimeš
2109f41cc6 libnm-util: consolidate hex-string <-> bin conversion functions
and move them to libnm-util's nm-utils.s so that they are easily available.
2013-03-28 16:59:58 +01:00
Dan Winship
6ff924f82f libnm-utils: change the GValue transforms to match nmcli's outputs
That way, nmcli can use them...
2013-03-26 12:15:49 -04:00
Dan Winship
331b69bd90 libnm-util: split GValue transforms out of nm-utils.c
nm-utils.c is really big, so split the GValue transforms out into
their own file.
2013-03-26 12:15:49 -04:00
Jiří Klimeš
dc58072f7b libnm-util: install :pin and :pin-flags as properties for NMSetting8021x
GLib-GObject-WARNING **: g_object_get_property: object class `NMSetting8021x' has no property named `pin'
GLib-GObject-WARNING **: g_object_get_property: object class `NMSetting8021x' has no property named `pin-flags'
2013-03-26 16:49:37 +01:00
Jiří Klimeš
82fb1978a4 all: use G_VALUE_INIT to initialize GValue variables
It makes the initializations more explicit.
G_VALUE_INIT is available since glib 2.30, and NM now require glib >= 2.32
2013-03-25 08:41:18 +01:00
Jiří Klimeš
d7d2015dfd libnm-util: add nm_setting_wired_get_valid_s390_options() 2013-03-19 08:59:50 +01:00
Jiří Klimeš
cc1de4676e libnm-util: fix documentation of add(remove)_s390_option() 2013-03-18 18:11:29 +01:00
Colin Walters
ffb6df6f4a libnm-glib,libnm-util: -glib requires -util, -util requires NetworkManager
libnm-glib's public headers include headers from libnm-util. While it
does work to just $(pkg-config --cflags --libs libnm-glib), this is
only because libnm-glib has a requires on NetworkManager which happens
to use the same include directory as libnm-util.

The correct dependency chain is thus:
libnm-glib -> libnm-util -> NetworkManager

Signed-off-by: Colin Walters <walters@verbum.org>
2013-03-14 10:23:19 -05:00
Jiří Klimeš
f36c7301f0 libnm-util: more verbose verification errors for :interface-name 2013-03-14 11:00:45 +01:00
Jiří Klimeš
2295e5fbe0 libnm-util: add the detailed description of interface-name to blurb as well
So that the description is in the generated documentation and nm-settings(5)
manual page.
2013-03-14 10:36:50 +01:00
Dan Winship
2d668d763e libnm-util: add NMSettingConnection:interface-name
https://bugzilla.gnome.org/show_bug.cgi?id=693684
2013-03-13 16:45:18 -04:00
Jiří Klimeš
df142a5dc4 libnm-util: make property verification errors more descriptive
- fix g_set_error()/g_set_error_literal() usage
- make the error messages translatable
- use g_prefix_error() to prepend property name
2013-03-13 17:47:11 +01:00
Dan Williams
fa97543186 libnm-util: free temporary decoded base64 data when parsing OpenSSL key files
==7347== 1,201 bytes in 1 blocks are definitely lost in loss record 5,016 of 5,107
==7347==    at 0x4A06B0F: calloc (vg_replace_malloc.c:593)
==7347==    by 0x39B90548E6: g_malloc0 (gmem.c:189)
==7347==    by 0x39B9026F8D: g_base64_decode (gbase64.c:407)
==7347==    by 0x4C51CA1: parse_old_openssl_key_file (crypto.c:227)
==7347==    by 0x4C51EC3: crypto_decrypt_private_key_data (crypto.c:497)
==7347==    by 0x4C529BE: crypto_verify_private_key_data (crypto.c:706)
==7347==    by 0x4C52B7B: crypto_verify_private_key (crypto.c:735)
==7347==    by 0x4C5CCC5: nm_setting_802_1x_set_private_key (nm-setting-8021x.c:1633)
==7347==    by 0xC8F64D4: eap_tls_reader (reader.c:2270)
==7347==    by 0xC8F4886: fill_8021x (reader.c:2704)
==7347==    by 0xC8F8311: wireless_connection_from_ifcfg (reader.c:2825)
==7347==    by 0xC8FAFD2: connection_from_file (reader.c:4303)
2013-03-08 09:27:51 -06:00
Dan Williams
c22e4da986 libnm-util: free PPPoE setting private data members
==23089== 342 bytes in 38 blocks are definitely lost in loss record 4,870 of 5,123
==23089==    at 0x4A0881C: malloc (vg_replace_malloc.c:270)
==23089==    by 0x39B905488E: g_malloc (gmem.c:159)
==23089==    by 0x39B906A4BB: g_strdup (gstrfuncs.c:356)
==23089==    by 0x31FC02DA90: set_property (nm-setting-pppoe.c:220)
==23089==    by 0x39B9819972: g_object_set_property (gobject.c:1352)
==23089==    by 0x31FC01A9A7: nm_setting_enumerate_values (nm-setting.c:589)
==23089==    by 0x31FC01AA81: nm_setting_duplicate (nm-setting.c:264)
==23089==    by 0x31FC01633B: duplicate_cb (nm-connection.c:1182)
==23089==    by 0x39B903F8DF: g_hash_table_foreach (ghash.c:1524)
==23089==    by 0x31FC01756C: nm_connection_duplicate (nm-connection.c:1203)
==23089==    by 0x4A7BE3: get_settings_auth_cb (nm-settings-connection.c:1062)
==23089==    by 0x4A5624: auth_start (nm-settings-connection.c:1008)
2013-03-08 09:27:51 -06:00
Dan Williams
ca00badb03 libnm-util: free temporary string when parsing OpenSSL key files
'str' was not freed anywhere.

==23089== 2,072 (24 direct, 2,048 indirect) bytes in 1 blocks are definitely lost in loss record 5,063 of 5,123
==23089==    at 0x4A0881C: malloc (vg_replace_malloc.c:270)
==23089==    by 0x39B905488E: g_malloc (gmem.c:159)
==23089==    by 0x39B9068CA1: g_slice_alloc (gslice.c:1003)
==23089==    by 0x39B906C7FA: g_string_sized_new (gstring.c:121)
==23089==    by 0x39B906CE75: g_string_new_len (gstring.c:186)
==23089==    by 0x31FC0149CE: parse_old_openssl_key_file (crypto.c:150)
==23089==    by 0x31FC014E33: crypto_decrypt_private_key_data (crypto.c:494)
==23089==    by 0x31FC01592E: crypto_verify_private_key_data (crypto.c:703)
==23089==    by 0x31FC015AEB: crypto_verify_private_key (crypto.c:732)
==23089==    by 0x31FC0200E5: nm_setting_802_1x_set_private_key (nm-setting-8021x.c:1640)
==23089==    by 0xC694304: eap_tls_reader (reader.c:2280)
==23089==    by 0xC692756: fill_8021x (reader.c:2714)
2013-03-08 09:27:51 -06:00
Dan Williams
2878481c09 libnm-util: free temporary GByteArray when using NM_SETTING_802_1X_CK_SCHEME_PATH
If the certificate's format was valid, but we're asked to refer to it by
paths instead of using the raw data, 'data' would be leaked.

==23089== 8,232 (40 direct, 8,192 indirect) bytes in 1 blocks are definitely lost in loss record 5,109 of 5,123
==23089==    at 0x4A0881C: malloc (vg_replace_malloc.c:270)
==23089==    by 0x39B905488E: g_malloc (gmem.c:159)
==23089==    by 0x39B9068CA1: g_slice_alloc (gslice.c:1003)
==23089==    by 0x39B9024539: g_array_sized_new (garray.c:195)
==23089==    by 0x31FC0146EA: file_to_g_byte_array (crypto.c:319)
==23089==    by 0x31FC01543B: crypto_load_and_verify_certificate (crypto.c:606)
==23089==    by 0x31FC01ED26: nm_setting_802_1x_set_client_cert (nm-setting-8021x.c:819)
==23089==    by 0xC6944A4: eap_tls_reader (reader.c:2316)
==23089==    by 0xC692756: fill_8021x (reader.c:2714)
==23089==    by 0xC696151: wireless_connection_from_ifcfg (reader.c:2832)
==23089==    by 0xC698E3A: connection_from_file (reader.c:4316)
==23089==    by 0xC69135C: nm_ifcfg_connection_new (nm-ifcfg-connection.c:119)
==23089==
==23089== 8,352 (160 direct, 8,192 indirect) bytes in 4 blocks are definitely lost in loss record 5,110 of 5,123
==23089==    at 0x4A0881C: malloc (vg_replace_malloc.c:270)
==23089==    by 0x39B905488E: g_malloc (gmem.c:159)
==23089==    by 0x39B9068CA1: g_slice_alloc (gslice.c:1003)
==23089==    by 0x39B9024539: g_array_sized_new (garray.c:195)
==23089==    by 0x31FC0146EA: file_to_g_byte_array (crypto.c:319)
==23089==    by 0x31FC01543B: crypto_load_and_verify_certificate (crypto.c:606)
==23089==    by 0x31FC01E5E6: nm_setting_802_1x_set_ca_cert (nm-setting-8021x.c:538)
==23089==    by 0xC694DD8: eap_peap_reader (reader.c:2358)
==23089==    by 0xC692756: fill_8021x (reader.c:2714)
==23089==    by 0xC696151: wireless_connection_from_ifcfg (reader.c:2832)
==23089==    by 0xC698E3A: connection_from_file (reader.c:4316)
==23089==    by 0xC69135C: nm_ifcfg_connection_new (nm-ifcfg-connection.c:119)
2013-03-08 09:27:51 -06:00