Commit Graph

1021 Commits

Author SHA1 Message Date
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