Commit graph

977 commits

Author SHA1 Message Date
Dan Winship 09da178639 libnm-util: fix build with --with-crypto=gnutls
The non-"_t"-suffixed type names in gnutls have been deprecated since
1.x, and in recent versions will trigger deprecation warnings. Fix by
using "gnutls_datum_t" instead of "gnutls_datum".
2014-07-11 12:09:39 -04:00
Dan Winship da25a788fa trivial: add a missing word to documentation 2014-07-07 14:04:51 -04:00
Thomas Haller 63070fff02 build: call generate-setting-docs.py directly instead of through strace
This was added for debugging, but is no longer necessary.
Also, strace might not be installed on any system so don't depend on it.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-04 13:43:59 +02:00
Dan Williams 6cb6d39725 libnm-util: merge nm-util-private and nm-utils-private
No reason to have two differently named files for the
same general purpose.
2014-07-02 13:33:58 -05:00
Dan Williams 2428401f5e docs: fix multi-line Since notation 2014-07-01 15:47:54 -05:00
Thomas Haller 29d538239f libnm-util: normalize IP settings in connection
This is the same behaviour as nm_utils_normalize_connection(),
which will soon be removed in favor of nm_connection_normalize().

This takes care, that normal connections always have an IP4 and IP6 setting,
and that slave connections never have it.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-30 18:35:46 +02:00
Thomas Haller 794ed1c9ef libnm-util: validate master/slave-type property in NMSettingConnection::verify()
- Before, when setting the slave-type to an invalid type, the setting
  was silently accepted. Now verification fails with "Unknown slave type '%s'"

- Before, the @master property was not checked. So you could have a @slave-type,
  without having @master set. And similarly, you could have @master, but
  no @slave-type. Fix both issues.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-30 18:35:46 +02:00
Thomas Haller 2deaa5397a libnm-util: normalize virtual_iface_name in NMSettings
Some type-specific NMSetting implementations (bond, bridge, team, vlan)
have their own 'interface-name' property. This property will be
deprecated in favour of 'interface-name' in NMSettingConnection.

Change verify() and normalize() to check that the redundant
values match and repair/normalize the properties.

Force the virtual interface name of the type-specific setting to be
equal to NMSettingConnection:interface_name. This way, the depreacted
field stays valid and backward compatible.

NMSettingInfiniband is special, because it does not have a backing
property for the interface name, although it implements
get_virtual_iface_name(). To account for this, some special handling
is needed in order not to change the behaviour of get_virtual_iface_name().

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-30 18:35:46 +02:00
Thomas Haller de5656a570 libnm-util: add function nm_connection_normalize
This function behaves like verify(), but it also performs some
normalization/fixing of inconsistent connections.

Contrary to verify(), this function might modify the settings.
This will be mainly used, to repair connections from older versions
and to fix deprecated options.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-30 18:35:46 +02:00
Thomas Haller 542f1fe3c9 test: nm_connection_verify() sets the interface-name to virtual_iface_name.
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-30 18:35:16 +02:00
Thomas Haller 28169725d7 libnm-util: add function nm_connection_get_interface_name()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-30 18:35:16 +02:00
Thomas Haller 2469601a0e build: 'nm-setting-docs.xml' must depend on 'NetworkManager-1.0.typelib'
Build of 'nm-setting-docs.xml' must depend on 'NetworkManager-1.0.typelib', otherwise
'NetworkManager-1.0.typelib' is not yet created and './generate-setting-docs.py'
fails.

  g-ir-scanner: compile: gcc -Wall -Wno-deprecated-declarations -pthread -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -Wall -std=gnu89 -g -Og -Wshadow -Wmissing-declarations -Wmiss
  g-ir-scanner: link: /bin/sh ../libtool --mode=link --tag=CC gcc -o /NetworkManager/libnm-util/tmp-introspectEda05I/NetworkManager-1.0 -export-dynamic -Wall -std=gnu89 -g -Og -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wdeclarat
  libtool: link: gcc -o /NetworkManager/libnm-util/tmp-introspectEda05I/.libs/NetworkManager-1.0 -Wall -std=gnu89 -g -Og -Wshadow -Wmissing-declarations -Wmissing-prototypes -Wdeclaration-after-statement -Wformat-security -Wfloat-equal -Wn
  export GI_TYPELIB_PATH=/NetworkManager/libnm-util${GI_TYPELIB_PATH:+:$GI_TYPELIB_PATH}; \
  export LD_LIBRARY_PATH=/NetworkManager/libnm-util/.libs${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}; \
  strace -o /tmp/strace.out ./generate-setting-docs.py \
          --gir ./NetworkManager-1.0.gir \
          --output nm-setting-docs.xml
  ERROR:root:Could not find any typelib for NetworkManager
  Traceback (most recent call last):
    File "./generate-setting-docs.py", line 19, in <module>
      from gi.repository import NetworkManager, GObject
  ImportError: cannot import name NetworkManager
  make[4]: *** [nm-setting-docs.xml] Error 1

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-30 17:42:08 +02:00
Dan Winship 9f82c16557 libnm-util: build nm-setting-docs.xml against uninstalled libnm-util
Set GI_TYPELIB_PATH and LD_LIBRARY_PATH so that we build
nm-setting-docs.xml against the just-built typelib and .so, not the
installed ones.
2014-06-27 17:24:58 -04:00
Dan Winship 377f72a66f build: fix nm-setting-docs build in various configurations
Certain build configurations (like --enable-gtk-doc
--disable-introspection) were broken with respect to nm-setting-docs.
Fix this. Also, we don't require just gobject-introspection, we need
pygobject specifically as well.
2014-06-27 17:24:57 -04:00
Dan Williams c3e8ddf075 build: fix multiple definitions of DISTCLEANFILES
Multiple definitions added by dcc109516d
2014-06-26 11:38:30 -05:00
Jiří Klimeš 214f523f3f libnm-util: document "address-labels" property as for internal use only 2014-06-26 14:56:22 +02:00
Dan Winship aa1dce6da2 all: remove remaining GParamSpec name/blurb strings
Remove all remaining GParamSpec name and blurb strings (and fix
indentation while we're there), and add G_PARAM_STATIC_STRINGS to all
paramspecs that were lacking it.
2014-06-19 17:45:03 -04:00
Dan Winship cdc15cb2a6 libnm-util: remove NMSetting* GParamSpec docs
Remove all the GParamSpec docs, since everything now uses the gtk-doc
docs instead, so there's no point in having two copies of each (which
are often out of sync anyway).

Since we're touching so many lines anyway, also fix up the indentation
of the remaining property-installing lines, and add
G_PARAM_STATIC_STRINGS to each paramspec (so the nick strings don't
get strduped). Also, be consistent about starting a new line between
"g_object_class_install_property" and its opening parenthesis.
2014-06-19 17:45:03 -04:00
Dan Winship dcc109516d libnm-util: build nm-setting-docs.xml from gtk-doc and GParamSpecs
Add generate-setting-docs.py, based on tools/generate-settings-spec.c,
which generates a simple XML file describing all libnm setting
properties (still getting the default values via GParamSpec
introspection like generate-settings-spec.c does, but getting the
documentation out of the gtk-doc strings in the GIR file instead).
2014-06-19 17:45:02 -04:00
Dan Winship e8577083ca libnm-util: various NMSetting* property doc fixes/improvements
Fix up various issues with the docs for the NMSetting properties, and
pull in text from the GParamSpec docs where the GParamSpec docs were
better (or contained information that is necessary in the context of
nm-settings.5).

Also, consistently wrap all of the doc comments to the same width (80
columns).
2014-06-19 17:45:02 -04:00
Dan Winship 9de24b16e8 libnm-util: fix gtk-doc bugs in NMSetting* properties
Fix misused gtk-doc annotations and incorrectly-identified properties.

In particular, the upcoming introspection-based generate-settings-spec
expands macro and enum values, so if you use '%' where you should have
used '#', it will fail to find an expansion, and error out.
2014-06-19 17:45:02 -04:00
Dan Winship 8487a4490c libnm-util, libnm-glib: be consistent about "Wi-Fi", "Ethernet", "InfiniBand" in docs
We made the UIs consistent last year, but missed the documentation.
Fix the docs to also consistently use "Wi-Fi" rather than "WiFi",
"Wifi", "wifi", or "WiFI"; "Ethernet" rather than "ethernet"; and
"InfiniBand" rather than "Infiniband".
2014-06-19 17:45:01 -04:00
Dan Winship 3c13d9e3fd misc: remove some dead code
The G_DISABLE_CHECKS version of g_return_if_reached() still returns,
it just doesn't log. So don't include a manual return after a
return-if-reached.
2014-06-12 17:13:56 -04:00
Jiří Klimeš 1b55014468 libnm-util: don't append NULL in g_string_append() 2014-06-09 10:36:54 +02:00
Dan Williams 5e9904f451 libnm-util: bump soname (2.5.0 -> 2.6.0) for added API 2014-06-06 18:28:20 -05:00
Dan Williams 9433a0bfe0 libnm-util: fix an error noticed by coverity 2014-06-06 17:25:36 -05:00
Thomas Haller 48b5ba7cea nmtst: add NMTST_DEBUG=no-expect-message for debugging assert_message tests
Some tests want to assert against the messages logged using g_test_expect_message().
In this mode, nmtst will not log anything itself.

Interpret the option no-expect-message which turns g_test_expect_message()
into a NOP and turns logging on. The use of this is for debugging such
tests, without asserting against the messages but printing them instead.

For tests that are not in the assert_message mode, the option has no
effect.

Example:
  NMTST_DEBUG=debug,no-expect-message make -C src/settings/plugins/keyfile/tests/ check

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:58 +02:00
Thomas Haller ed868a388b core: add compatibility wrapper for g_test_skip() to nm-glib-compat.h
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:57 +02:00
Thomas Haller 8af001eae4 nmtst: combine files nm-test-helpers.h and nm-test-utils.h
Move the content of nm-test-helpers.h to nm-test-utils.h
which completly replaces the older file.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:56 +02:00
Thomas Haller a268b825d7 nmtst: move header file to include/ directory
https://bugzilla.gnome.org/show_bug.cgi?id=706293

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:56 +02:00
Thomas Haller d2ac129d65 nmtst: g_type_init() has been deprecated in GLib 2.35.0
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:56 +02:00
Dan Winship d47b749a75 libnm-utils: remove INFERRABLE flag from properties we don't actually infer
ipv4.never-default, ipv4.may-fail, and ipv6.privacy were marked
INFERRABLE, but NMIP4Config / NMIP6Config didn't actually infer them,
so they could cause connections to not match themselves after a
restart.

(Found while debugging https://bugzilla.redhat.com/show_bug.cgi?id=1086237,
though this is not actually the problem there.)

Related: rh#1086237
2014-06-04 11:23:54 -04:00
Thomas Haller 891eb83f45 libnm-util: add property NM_SETTING_BRIDGE_MAC_ADDRESS to NMSettingBridge
https://bugzilla.gnome.org/show_bug.cgi?id=729844

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-05-30 17:02:31 +02:00
Thomas Haller fedf7ca303 libnm-util: optimize nm_utils_hwaddr_ntoa_len()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-05-30 11:32:20 +02:00
Thomas Haller 3cda194b44 libnm-util: make hwaddr functions more robust against invalid arguments
- nm_utils_hwaddr_len() and nm_utils_hwaddr_type() no longer assert
  against known input types/lengths. Now they can be used to detect the
  hwaddr type, returning -1 on unknown.
- more checking of input arguments in nm_utils_hwaddr_aton() and
  related. Also note, that nm_utils_hwaddr_aton_len() has @len of type
  gsize, so we cannot pass on the output of nm_utils_hwaddr_len()
  without checking for -1.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-05-29 19:00:59 +02:00
Jiří Klimeš 98ae6e06d2 all: g_type_init() has been deprecated in GLib 2.35.0
g_type_init() deprecation:
https://bugzilla.gnome.org/show_bug.cgi?id=686161
2014-05-27 16:58:21 +02:00
Jiří Klimeš e3d1e176c2 libnm-util: make explicit that we only allow VPN as secondaries (rh #1094296)
https://bugzilla.redhat.com/show_bug.cgi?id=1094296
2014-05-23 12:19:29 +02:00
Jiří Klimeš 810e934892 libnm-util: add nm_utils_rsa_key_encrypt_aes() encrypting RSA key with AES 2014-05-12 10:46:41 +02:00
Jiří Klimeš b3e39d4275 libnm-util: allow AES cipher for private keys
and add a testcase to check the encryption with AES.
2014-05-12 10:46:41 +02:00
Jiří Klimeš a9f5494d4d libnm-util: do not call crypto_md5_hash() for empty passwords
It happens when one selected private key, but didn't provide the password yet
in nm-connection-editor.

(nm-connection-editor:11080): libnm-util-CRITICAL **: crypto_md5_hash: assertion `password_len > 0' failed
2014-05-12 10:46:41 +02:00
Jiří Klimeš 31cd3fe444 libnm-util: return better error messages on failures for _set_ functions 2014-05-12 10:46:41 +02:00
Thomas Haller 815245320d libnm-util: fix crash in NMSettingInfiniband when setting key or parent property
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-05-07 09:13:33 +02:00
Jiří Klimeš b764766517 trivial: fix typo BBSID -> BSSID 2014-05-06 16:55:50 +02:00
Thomas Haller 9ef23947cc all: fix various warnings detected with coverity
https://bugzilla.gnome.org/show_bug.cgi?id=728320

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-05-02 15:20:30 +02:00
Thomas Haller 785c2a8c95 all/test: modify makefiles to run tests (without arguments) via autoconf TESTS=
This results in some nice coloring. Only move the tests that are called
without arguments from check-local to TESTS.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-23 21:28:55 +02:00
Dan Winship 4618a07304 libnm-util: use g_test_expect_message() in tests
Use g_test_expect_message(), to avoid spewing tons of error messages
when (successfully) running "make check".
2014-04-23 10:19:17 -04:00
Dan Winship bea82ca98b all: set G_LOG_DOMAIN appropriately, for better g_log() messages 2014-04-23 10:19:17 -04:00
Thomas Haller c65ed2dd6c libnm-util: add private header file nm-test-utils.h
This is intended to contain utility functions for tests. It will
be header only (containing inline functions).

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-11 11:09:10 +02:00
Dan Winship 55c6d76c54 libnm-util: fix leaks in test-general 2014-04-01 15:00:33 -04:00
Dan Winship e0832bdb79 libnm-util: add (private API) support for address labels to NMSettingIP4Config 2014-03-26 10:39:36 -04:00
Dan Winship 6f61b3b934 libnm-util: add nm-util-private.h header with nm_util_get_private() 2014-03-26 10:39:36 -04:00
Dan Williams 13c348dcd9 libnm-util: fix Bridge priority default (rh #1073664)
Due to a misread of the kernel code, the bridge priority default
when STP was enabled was 0x80 instead of 0x8000.
2014-03-14 15:29:11 -05:00
Thomas Haller b73783b4a4 trivial: fix invalid code comment
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-14 17:06:19 +01:00
Thomas Haller 2f67105a91 libnm-util: remove assert to nm_utils_ip4_netmask_to_prefix
Commit 240c92ddb5 added an assert
to check that the input netmask is valid. Revert that commit for
the most part, some changes to the test function are not reverted.

We don't want to assert for a valid netmask, because it's
common to read the netmask from (untrusted) user input, so we
don't want to assert against it.

The caller *could* validate the netmask from untrusted sources, but
with the assert in place it cannot validate it in the most obvious way:

    prefix = nm_utils_ip4_netmask_to_prefix (netmask);
    if (netmask != nm_utils_ip4_prefix_to_netmask (prefix))
        goto fail;

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-14 16:55:51 +01:00
Thomas Haller 269ab02081 test: fix failure in make check due to invalid sorting of libnm-util/libnm-util.ver
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-06 20:09:45 +01:00
Dan Winship 4a5e2ced08 libnm-util: add nm_utils_check_virtual_device_compatibility()
Add a function encoding the logic of what virtual types support what
slave/parent types, so clients don't need to encode it themselves.
2014-03-06 09:37:20 -05:00
Dan Winship 50dea202a8 libnm-util: fix minor bugs in nm_setting_vlan_remove_priority_str_by_value()
Plug a leak, remove some dead code.
2014-03-05 11:20:54 -05:00
Jiří Klimeš 28bd3cab28 core: add 'type' and 'id' property for NMActiveConnection (rh #1061822)
https://bugzilla.redhat.com/show_bug.cgi?id=1061822
2014-03-05 16:17:13 +01:00
Jiří Klimeš d98a34dcda libnm-util: more specific error for missing ipv[46].adddress when method=manual 2014-03-03 12:42:05 +01:00
Dan Winship e4a8cfd502 libnm-util: fix some parameter names to kill gtk-doc warnings 2014-02-28 16:12:49 -05:00
Jiří Klimeš 642cfdeebf libnm-util: add *_remove_*_by_value() functions for 'vlan' setting
nm_setting_vlan_remove_priority_by_value()
nm_setting_vlan_remove_priority_str_by_value()
2014-02-28 10:39:09 +01:00
Jiří Klimeš 1e5370b4d2 libnm-util: add *_remove_*_by_value() functions for '802-11-wireless-security' setting
nm_setting_wireless_security_remove_proto_by_value()
nm_setting_wireless_security_remove_pairwise_by_value()
nm_setting_wireless_security_remove_group_by_value()
2014-02-28 10:39:09 +01:00
Jiří Klimeš de646d9588 libnm-util: add *_remove_*_by_value() functions for '802-11-wireless' setting
nm_setting_wired_remove_mac_blacklist_item_by_value()

Also add missing function nm_setting_wired_clear_mac_blacklist_items() and notify
about mac-address-blacklist changes.
2014-02-28 10:39:09 +01:00
Jiří Klimeš ca0aa8139c libnm-util: add *_remove_*_by_value() functions for '802-3-ethernet' setting
nm_setting_wired_remove_mac_blacklist_item_by_value()
and missing
nm_setting_wired_clear_mac_blacklist_items()
2014-02-28 10:39:09 +01:00
Jiří Klimeš b59bd75956 libnm-util: add *_remove_*_by_value() functions for 'connection' setting
nm_setting_connection_remove_permission_by_value()
nm_setting_connection_remove_secondary_by_value()
2014-02-28 10:39:09 +01:00
Jiří Klimeš 7c817d4176 libnm-util: add *_remove_*_by_value() functions for '802-1x' setting
nm_setting_802_1x_remove_eap_method_by_value()
nm_setting_802_1x_remove_altsubject_match_by_value()
nm_setting_802_1x_remove_phase2_altsubject_match_by_value()
2014-02-28 10:38:53 +01:00
Jiří Klimeš 1303ac3e9c libnm-util: add *_remove_*_by_value() functions for 'ipv4' and 'ipv6' settings
nm_setting_ip4_config_remove_dns_by_value()
nm_setting_ip4_config_remove_dns_search_by_value()
nm_setting_ip4_config_remove_address_by_value()
nm_setting_ip4_config_remove_route_by_value()

nm_setting_ip6_config_remove_dns_by_value()
nm_setting_ip6_config_remove_dns_search_by_value()
nm_setting_ip6_config_remove_address_by_value()
nm_setting_ip6_config_remove_route_by_value()
2014-02-28 10:31:41 +01:00
Jiří Klimeš 3789412160 libnm-util: fix adding values to 'phase2-altsubject-matches'
It was mixed up with 'altsubject-matches'.
2014-02-25 18:42:24 +01:00
Jiří Klimeš 68066b40f2 libnm-util: fix verify_identity() in '802-1x' setting
We need to return FALSE on error, otherwise we pile GErrors and assert in
nm_setting_verify().
2014-02-25 15:57:54 +01:00
Jiří Klimeš c2a1cb1a44 docs: use %TRUE, %FALSE macros instead of plain TRUE, FALSE values for gtkdoc 2014-02-24 17:00:39 +01:00
Dan Winship 9c4d86ee80 libnm-util, libnm-glib: add versioned deprecation/availability macros
Add versioned NM_DEPRECATED_IN_* and NM_AVAILABLE_IN_* macros, and tag
new/deprecated functions accordingly. (All currently-deprecated
functions are assumed to have been deprecated in 0.9.10.)

Add NM_VERSION_MIN_REQUIRED and NM_VERSION_MAX_ALLOWED macros which
can be set to determine which versions will cause warnings.

With the current settings, external consumers of the
libnm-util/libnm-glib APIs will have MIN_REQUIRED and MAX_ALLOWED both
set to NM_VERSION_0_9_8 by default, meaning they will get warnings
about functions added in 0.9.10. NM internally sets
NM_VERSION_MAX_ALLOWED to NM_VERSION_NEXT_STABLE to ensure that it is
always allowed to use all APIs.
2014-02-13 11:24:37 -05:00
Dan Winship 95be722e54 libnm-util, libnm-glib: add some missing "Since: 0.9.10" tags
Based on diffing libnm-util.ver and libnm-glib.ver with their 0.9.8
versions.
2014-02-13 11:24:37 -05:00
Dan Winship f7b1b28202 libnm-util, libnm-glib: add device/connection describing functions
Add functions to describe and disambiguate devices and connections for
display to the user. Originally from libnm-gtk.
2014-01-27 15:39:51 -05:00
Dan Williams 32a001f526 core: allow custom IP address ranges for Shared connections (bgo #675973)
Given an IPv4 address and prefix for a shared config, figure out
the DHCP address range automatically.  To keep things simple we
allow a max of 252 addresses (not including network address,
broadcast address, and the hotspot) no matter what prefix you use,
so if the address is 10.0.10.1, you still only get a range of
10.0.10.2 -> 10.0.10.254.

But we also leave some addresses available above the host address
for static stuff, like we did before.  This is done on a sliding
scale from 0 to 8 addresses, where about 1/10th the number of
available addresses are reserved.

https://bugzilla.gnome.org/show_bug.cgi?id=675973
2014-01-23 16:21:01 -06:00
Thomas Haller 240c92ddb5 libnm-util: add assert to nm_utils_ip4_netmask_to_prefix
g_return if the user provides an invalid netmask.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-21 21:01:56 +01:00
Dan Williams a52c3e2e5f libnm-util: fix trivial GOI copy & paste issue 2014-01-21 10:18:23 -06:00
Jiří Klimeš 7ffbbae3a0 libnm-glib; fix introspection annotations so that <ipv6>.get_address() worked
Without the correct annotation, the functions didn't work correctly in Python
(causing segmentation fault).
2014-01-16 17:37:16 +01:00
Dan Winship 4c0ac46a99 libnm-util: add a missing GValue transform needed by nmtui 2014-01-16 09:19:06 -05:00
Thomas Haller ff6315cbab libnm-util: only emit one CHANGED signal when adding several settings
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-15 17:01:53 +01:00
Thomas Haller 123bf9eea4 libnm-util: raise CHANGED signal in nm_connection_update_secrets only on change
This changes behaviour of nm_connection_update_secrets() in that it will
now return %TRUE, if there are no secrets to be cleared. Seems more
correct, to return success if there is nothing to do.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-15 17:01:53 +01:00
Thomas Haller 0f38213129 libnm-util: raise CHANGED signal in nm_connection_clear_secrets only on change
Often, nm_connection_clear_secrets does have no consequences, because
there is nothing to be cleared. Only raise a signal, if something
actually changed.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-15 17:01:53 +01:00
Thomas Haller 4dd6ab8f4b libnl-util: refactor nm_utils_ip4_prefix_to_netmask/netmask_to_prefix
- use a more efficient implementation for prefix_to_netmask
- fix netmask_to_prefix to behave consistently in case of
  invalid netmask
- remove unused duplicated functions from NetworkManagerUtils.c
- add test functions

Based-on-patch-by: Pavel Šimerda <psimerda@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
Related: https://bugzilla.gnome.org/show_bug.cgi?id=721771
2014-01-10 13:34:57 -06:00
Jiří Klimeš eac3c36bbf trivial: fix erroneous copy&paste value in libnm-glib 2013-12-18 10:06:06 +01:00
Thomas Haller b7f6169dbd libnm-util: minor refactoring in nm_connection_compare()
Evaluate a cheaper comparison first, to fail early

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-12-17 17:18:14 -06:00
Dan Winship d174825412 libnm-util: don't introspect nm_utils_inet[46]_ntop
nm_utils_inet4_ntop() and nm_utils_inet6_ntop() have arguments of
non-introspected types, so mark them (skip) to avoid warnings from
g-ir-scanner.
2013-12-16 13:06:52 -05:00
Thomas Haller 9d319e6da0 libnm-util: refactor NMSetting name and register_settings
- refactor register_settings to allow lookup by GType and
  add the settings name to SettingInfo.

- setting NM_SETTING_NAME is deprecated and should not be set anymore.
  Indeed it has always be a bug, to reset the name to a different value.
  The only valid place to set the name was in the _init() function of
  the derived class itself.
  This is now no longer needed/possible. Instead the name get's
  detected based on the registered setting types. This makes use of
  the registered metadata that is available anyway since every
  usable setting has to register itself.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-12-12 21:47:13 +01:00
Jiří Klimeš b5b49a4bc0 trivial: fix typo in pppoe::service property 2013-12-12 13:14:11 +01:00
Jiří Klimeš 98bcbd2d24 libnm-util: don't touch dhcp-send-hostname when setting dhcp-hostname (rh #1001529)
It is better to leave it to user whether he wants to enable sending hostname,
because he probably disabled it manually (dhcp-send-hostname is TRUE by default).
Also, this would not work for plugins that read and set dhcp-hostname after
dhcp-send-hostname.

https://bugzilla.redhat.com/show_bug.cgi?id=1001529
2013-12-12 08:32:13 +01:00
Thomas Haller 6f2cfe263e all: refactor to make use of nm_utils_inet[46]_ntop functions
https://bugzilla.gnome.org/show_bug.cgi?id=711684

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-12-09 17:21:22 +01:00
Thomas Haller 41f8114359 libnm-util: add nm_utils_inet[46]_ntop functions
https://bugzilla.gnome.org/show_bug.cgi?id=711684

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-12-09 17:21:21 +01:00
Thomas Haller 1c031cddf7 libnm-util: bugfix wrong diff result in nm_connection_diff
Commit 6abc7b78f6 introduced a
bug in nm_connection_diff() by not reading the property value with
g_object_get_property().

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-12-09 11:26:33 +01:00
Thomas Haller 6abc7b78f6 libnm-util: call virtual compare_property in nm_connection_diff
nm_connection_diff must also use the virtual functions like
nm_connection_compare. This way, settings can overwrite the default
comparison of individual properties.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-12-05 17:09:46 -06:00
Dan Williams 5f15409684 libnm-util: add INFERRABLE flag and remove CANDIDATE
INFERRABLE means the opposite of CANDIDATE; a property which NetworkManager
can read ("infer") from the system or the kernel when generating
connections.  CANDIDATE isn't a great name and thus dies.
2013-12-05 16:07:24 -06:00
Dan Williams 983079cd59 libnm-util: remove usage of NM_SETTING_PARAM_SERIALIZE
The only property that is not serializes is each settings' 'name'
property, so the flag serves no purpose.
2013-12-02 15:26:12 -06:00
Jiří Klimeš 0d4a5f0328 Revert "libnm-util: refactor NMSetting construction, assert of setting name"
This reverts commit f43586fc17.

This broke stuff as "name" was set on various places after construction. So we
revert the commit for now, and will rework it.
2013-11-28 11:18:54 +01:00
Thomas Haller f43586fc17 libnm-util: refactor NMSetting construction, assert of setting name
Make the name property CONSTRUCT_ONLY. With this there is also no more
need to overwrite the constructor().

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-27 23:10:17 +01:00
Thomas Haller b8b8af38c1 libnm-util: fix minor memory leak in infiniband setting
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-27 21:19:11 +01:00
Thomas Haller 5cdd592457 libnm-util: trivial: rename private field and enum value in NMSettingVlan
The public property is called NM_SETTING_VLAN_INTERFACE_NAME,
so also the internal field and the PROP_* enum should carry
the same name.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-27 21:01:41 +01:00
Thomas Haller 63c9c399c5 libnm-util: fix minor memory leaks in bond and team setting
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-27 20:55:58 +01:00
Jiří Klimeš 0f02392123 doc: fix description of nm_setting_set_secret_flags() 2013-11-18 15:59:05 +01:00
Thomas Haller 97935382f4 coverity: fix various warnings detected with Coverity
These are (most likely) only warnings and not severe bugs.
Some of these changes are mostly made to get a clean run of
Coverity without any warnings.

Error found by running Coverity scan

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

Co-Authored-By: Jiří Klimeš <jklimes@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-13 15:29:24 +01:00
Thomas Haller f059298896 trivial: whitespace fix
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-07 21:32:08 +01:00
Thomas Haller 03943e2854 trivial: make nm_connection_dump more forgiving when passing NULL
nm_connection_dump is mainly used for printf debugging, so
no need about being overly critical about not accepting NULL.
Just don't dump anything.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-07 19:30:38 +01:00
Dan Winship 16e824fe34 libnm-util: belatedly export nm_setting_generic_new() 2013-11-01 13:04:11 -04:00
Jiří Klimeš 8ec031fb0e core: again allow calling AddAndActivateConnection() without a connection
When settings are NULL or empty in impl_manager_add_and_activate_connection(),
the connection is created and completed by nm_utils_complete_generic() or
nm_device_complete_connection().

Also, do not assert in nm_connection_is_type(). Returning FALSE there is
sufficient.

Related commit a878cd8145
2013-11-01 14:07:04 +01:00
Jiří Klimeš abe4f4daf5 libnm-util: do not assert valid connection type in nm_connection_is_type()
That is not useful, simply return FALSE.
2013-11-01 12:38:25 +01:00
Dan Williams 77e50740a8 libnm-util: add Data Center Bridging (DCB) setting
Includes various fixes & cleanups from Thomas Haller.
2013-10-31 13:28:42 -05:00
Jiří Klimeš a9ea67185e libnm-util: validate "primary" bonding option as an interface name
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-25 22:32:47 +02:00
Thomas Haller 0c6a98df78 libnm-util: do not g_warn when trying to set invalid bond option
nm_setting_bond_add_option returns TRUE or FALSE indicating, whether
the bond option was properly set. So, the API already kind of expects
invalid values, so there is no reason to warn about it.

Co-Authored-By: Jiří Klimeš <jklimes@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-25 22:32:47 +02:00
Thomas Haller df4e159728 libnm-util: expose nm_setting_bond_validate_option as public API
Co-Authored-By: Jiří Klimeš <jklimes@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-25 22:32:47 +02:00
Thomas Haller 4b85408e34 bond: handle bond options more gracefully
Support new bonding options and set them carefully. The options cannot
be set arbitrarily because they interfere with each other.

This commit is forward-ported from rhel-6.5, see patch
rh901662-bond-more-options.patch, originally written by Dan Williams.

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

Co-Authored-By: Dan Williams <dcbw@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-25 22:32:47 +02:00
Dan Winship 3b97185ff8 libnm-util: fix slave IP config checking
NMSettingConnection was making sure that bond slaves didn't have an IP
configuration, but it should have been making that check for bridge
and team slaves too.
2013-10-24 12:25:08 -04:00
Dan Winship f4c3e2f643 libnm-util: centralize find_setting_by_name code
Several settings types' verify() functions need to find a particular
setting from the all_settings list that NMConnection passes them. Add
a convenience function for this.
2013-10-24 12:25:08 -04:00
Dan Winship 83c5a69126 libnm-util: fix a leak in NMSettingIP6Config 2013-10-24 12:25:08 -04:00
jvoisin 00ffb78c8d core: add support for EAP-PWD authentication 2013-10-23 21:07:30 -05:00
Thomas Haller 3eb1d5e902 core: cleanup freeing of glib collections of pointers
When freeing one of the collections such as GArray, GPtrArray, GSList,
etc. it is common that the items inside the connections must be
freed/unrefed too.

The previous code often iterated over the collection first with
e.g. g_ptr_array_foreach and passing e.g. g_free as GFunc argument.
For one, this has the problem, that g_free has a different signature
GDestroyNotify then the expected GFunc. Moreover, this can be
simplified either by setting a clear function
(g_ptr_array_set_clear_func) or by passing the destroy function to the
free function (g_slist_free_full).

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-22 19:53:57 +02:00
Yuri Chornoivan 61de24ba35 Fix typos
https://bugzilla.gnome.org/show_bug.cgi?id=710505
2013-10-19 11:49:18 -04:00
Dan Winship 5bcdfd3985 libnm-util: remove reference to non-existent "Posix" namespace
There's no way in gobject-introspection to annotate something as
returning an arbitrary C struct type, so don't try.
2013-10-11 10:16:41 -04:00
Dan Winship 76cc2bd9df libnm-util, libnm-glib: fix up some gtk-doc comments
gtk-doc recognizes that #NMFoos is the plural of #NMFoo now, so you
don't need to put an empty comment between the type name and the "s"
to make it work. (Unfortunately, it's not smart enough to realize that
"NMIP4Addresses" is the plural of "NMIP4Address".)

Also, add some missing "#"s noticed along the way.
2013-10-11 10:16:14 -04:00
Thomas Haller 2b25d0d3e0 core: avoid use-after-free in libnm-util/bond.verify()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-08 22:33:19 +02:00
Dan Winship cbe261caa2 libnm: more valgrinding fixes 2013-10-03 11:04:45 -04:00
Jiří Klimeš 6d2e033a0e libnm-util: only remove ARP when MIIMON is being set to non-zero and vice versa
miimon or arp_interval == 0 means 'disable'. So we should not remove options of
one mode when the other mode is actually being disabled (set to zero).
2013-10-01 17:26:03 +02:00
Dan Winship e69727bf8a libnm-util: support the "primary" bond option 2013-09-27 09:34:41 -04:00
Dan Winship 4959936704 libnm-util, libnm-glib: bump .so versions to be higher than 0.9.8.4's 2013-09-25 10:16:55 -04:00
Jiří Klimeš 2e8746aab2 core: remove 'wep40' and 'wep104' from several places in NM
wep40 and wep104 are not valid values for 'pairwise' property and they are not
used for dynamic WEP as 'group' ciphers as well.

See https://bugzilla.redhat.com/show_bug.cgi?id=1005171 for some details.
2013-09-18 12:07:29 +02:00
Dan Winship 066b592241 all: standardize on NMSettingWired:mac-address for all VLANs
Currently, ethernet-based VLANs can specify the hardware address of
the parent device (and, in theory, the cloned hardware address and MTU
of the VLAN device) by using an NMSettingWired in addition to the
NMSettingVlan.

The theory was that non-ethernet-based VLANs, when we eventually
supported them, would likewise use the setting type corresponding to
their parent device. However, this turns out to be both complicated
(the settings plugins and connection editor would have a
hard-to-impossible time figuring out which setting type to use in some
cases) and incorrect (for most L2 settings [eg, BSSID, bond mode,
etc], the VLAN can't have its own values separate from the parent
device).

What we should have done was just have :mac-address,
:cloned-mac-address, and :mtu properties on NMSettingVlan. However, at
this point, for backward-compatibility, we will just stick with using
a combination of NMSettingVlan and NMSettingWired, but we will use
NMSettingWired regardless of the underlying hardware type.
2013-09-12 18:34:23 -04:00
Daniel Drake 3f4811be22 libnm-util: accept old-style UUIDs as valid
Old versions such as 0.9.4 generated 40-character UUIDs with no
hashes, but libnm-util regards them as invalid. That means that
existing connections stop working when upgrading from 0.9.4.

Continue accepting such UUIDs as valid, and add a test so that
we don't forget in future.
2013-09-09 08:20:37 -05:00
Jiří Klimeš 9835da7c74 libnm-util: update description of team:config and team-port:config properties 2013-09-06 13:52:27 +02:00
Jiří Klimeš 8e050a3a77 trivial: fix a typo in description of ipv6.method in libnm-util 2013-09-04 12:56:17 +02:00
Dan Winship 5094d00b1e libnm-util: fix nm_setting_wireless_ap_security_compatible()
It was still looking at priv->security.
2013-09-03 13:47:46 -04:00
Jiří Klimeš 0e57603e43 libnm-util: nm_utils_hwaddr_aton_len() allow hyphens in MAC string (rh #1002553)
http://en.wikipedia.org/wiki/MAC_address#Notational_conventions
Both 01:23:45:67:89:ab and 01-23-45-67-89-ab are used and valid.
2013-09-02 10:08:02 +02:00
Jiří Klimeš 0185e8371f libnm-util: deprecate 'security' property of '802-11-wireless' setting
'security' property is redundant, because the security restrictions are easily
recognized by the presence of '802-11-wireless-security' in a Wi-Fi connection.
The setting has to be present anyway, but we also had to set and check whether
the value in 'security' matches the security setting.
Following the KISS principle, it is best not to use the 'security' property
altogether.
2013-09-02 09:46:31 +02:00
Jiří Klimeš 284cce0405 test: remove deprecated 'security' property from tests
Adjust tests not to use deprecated 'security' property.
2013-09-02 09:46:31 +02:00
Pavel Šimerda 2a4a359eb1 libnm-util: add NM_SETTING_COMPARE_FLAG_CANDIDATE flag
Acked-by: Dan Winship <danw@gnome.org>
Acked-by: Thomas Haller <thaller@redhat.com>
2013-08-22 22:06:47 +02:00
Dan Winship bfce3f7dc8 build: switch from $(INCLUDES) to $(AM_CPPFLAGS) to make automake happy
Unfortunately, $(AM_CPPFLAGS) gets overridden by per-target _CPPFLAGS
variables, which $(INCLUDES) did not, so this requires some additional
changes.

In most places, I have just gotten rid of the per-target _CPPFLAGS
variables; in directories with a single target, the per-target
variable is unnecessary, and in directories with multiple targets, the
per-target variable is often undesirable, since it forces some files
to be compiled twice, even though there ends up being no difference
between the two files.
2013-08-22 11:49:16 -04:00
Jiri Pirko 886c760f8b ifcfg-rh: reader: allow device to not have ipv4 setting.
If BOOTPROTO is set to "none", user states that no ipv4 setting should
be set. So respect that.

Introduce helper is_any_ip4_address_defined() along the way to make the
code more readable.

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
2013-08-22 08:51:48 -04:00
Jiri Pirko 64cdb1a7f0 libnm-util: add setting for team port
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
2013-08-15 10:54:14 -05:00
Jiri Pirko 3dcb7935a5 libnm-util: add team device setting
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
2013-08-15 10:53:03 -05:00
Pavel Šimerda 320a9d16a3 all: replace struct in_addr with guint32 2013-08-03 00:15:07 -05:00
Jiří Klimeš 72e65ef45c trivial: use capital "B" in InfiniBand 2013-07-22 10:34:38 +02:00
Jiří Klimeš b40e5f4aa9 libnm-util: fix possible crash when IP method is NULL 2013-07-03 16:50:18 +02:00
Jiří Klimeš c8d5f73218 libnm-util: fix description comment for 'read-only' property 2013-07-01 17:52:25 +02:00
Jiří Klimeš 44b6a441b9 libnm-util: update 'timestamp' property description, noting it is read-only 2013-07-01 17:07:24 +02:00
Jiří Klimeš 236155d9c9 libnm-util: remove 'downdelay' and 'updelay' when setting 'arp_interval'
Both 'downdelay' and 'updelay' bonding options are only valid with 'miimon'
that is being removed when setting 'arp_interval'.
2013-06-25 18:03:11 +02:00
Jiří Klimeš 128c9d788f libnm-util: verify() - can't set both IPv4 'disabled' and IPv6 'ignore' method 2013-06-25 18:03:02 +02:00
Jiří Klimeš 71b5b77b3a libnm-util: add Since tag to interface-name property 2013-06-24 12:39:01 +02:00
Jiří Klimeš 2cc42bad06 libnm-util: fix tests after 'gateway-ping-timeout' addition 2013-06-24 12:24:17 +02:00
Dan Williams 00203a8798 libnm-util: add gateway-ping-timeout property to connection setting
To better handle broken hardware, like switches which don't pass
traffic for a few seconds after a carrier has been negotiated,
add a timeout to control how long to wait for successful pings
of the gateway before giving up and proceeding with IP config.
Default is 0, which means don't ping the gateway, just assume
the NIC/switch aren't lying and can pass traffic immediately.
2013-06-21 16:17:18 -05:00
Dan Winship 84468ad653 libnm-util: fix alphabetization in libnm-util.ver
to fix "make check"
2013-06-14 12:24:40 -03:00
Dan Winship 6854481fe8 libnm-util: add P_Key support to NMSettingInfiniband
Add p-key and parent properties to NMSettingInfiniband, for specifying
additional interfaces using alternate IPoIB partitions.
2013-06-13 15:52:51 -03:00