Commit graph

616 commits

Author SHA1 Message Date
Thomas Haller 9061432d55 build: merge "libnm/Makefile.am" into toplevel Makefile 2016-10-19 17:16:07 +02:00
Thomas Haller 8fdd5dec72 build: merge "libnm-core/tests/Makefile.am" into toplevel Makefile
libnm-core/Makefile.libnm-core still exists, it is used by
libnm/Makefile.am.
2016-10-19 15:26:30 +02:00
Thomas Haller e99978cb54 build: merge "libnm-core/Makefile.am" into toplevel Makefile
libnm-core/Makefile.libnm-core still exists, it is used by
libnm/Makefile.am.

Also, libnm-core/tests/Makefile.am still exists.
2016-10-19 15:26:30 +02:00
Thomas Haller 274de2555b build/trivial: rename VALGRIND_RULES in Makefile.am to NM_LOG_COMPILER 2016-10-19 15:26:30 +02:00
Beniamino Galvani f63e28b147 ifcfg-rh: support the autoconnect-retries property 2016-10-16 12:56:09 +02:00
Beniamino Galvani 51d7a18f2e libnm-core: introduce connection.autoconnect-retries property
While technically it's already possible to implement a fail-over
mechanism using multiple connections (for example, defining a higher
priority DHCP connection with short DHCP timeout and a lower priority
one with static address), in practice this doesn't work well as we try
to autoactivate each connection 4 times before switching to the next
one.

Introduce a connection.autoconnect-retries property that can be used
to change the number of retries. The special value 0 means infinite
and can be used to try the connection forever. A -1 value means the
global configured default, which is equal to 4 unless overridden.

https://bugzilla.gnome.org/show_bug.cgi?id=763524
2016-10-16 10:08:13 +02:00
Beniamino Galvani 185f008521 libnm-core: fix documentation comments
../libnm-core/nm-utils.c:4405: Warning: NM: nm_utils_is_json_object: unknown parameter 'str' in documentation comment, should be 'json'
../libnm-core/nm-connection.c:2208: Warning: NM: nm_connection_get_setting_proxy: return value: Missing (transfer) annotation
2016-10-14 10:05:54 +02:00
Thomas Haller 0e47b327dc libnm: move backported symbols from libnm-core to libnm
Backported symbols only make sense for libnm itself, not for
libnm-core which is statically linked with NetworkManager and
nm-ifcace-helper. Declaring the symbols in libnm-core, means
that NetworkManager binary also contains them, although there
are not used.

Move them to libnm.
2016-10-13 21:33:33 +02:00
Thomas Haller 814b1aec53 libnm/tests: fix bug in test
Fixes: 6b904a51ee
2016-10-11 14:08:36 +02:00
Thomas Haller 6b904a51ee shared: re-define _G_BOOLEAN_EXPR() to allow nesting g_assert()
g_assert() uses G_LIKELY(), which in turn uses _G_BOOLEAN_EXPR().
As glib's version of _G_BOOLEAN_EXPR() uses a local variable
_g_boolean_var_, we cannot nest a G_LIKELY() inside a G_LIKELY(),
or inside a g_assert(), or a g_assert() inside a g_assert().

Workaround that, by redefining the macro.

I already encountered this problem before, when having a nm_assert()
inside a ({...}) block, inside a g_assert(). Then I just avoided that
combination, but this situation is quite easy to encounter.
2016-10-11 13:14:43 +02:00
Thomas Haller 8b51e345af libnm/proxy: add proxy setting for non-slave connection during normalization
And reject slave settings with proxies.
2016-10-05 14:53:21 +02:00
Thomas Haller e2c71c82e7 libnm: cleanup error paths in _nm_connection_verify() 2016-10-05 14:46:18 +02:00
Thomas Haller 29b576bd70 proxy: cleanup handling of proxy-method
The numeric value of NM_SETTING_PROXY_METHOD_NONE should be zero,
as that is the more natural default.

Also, cast all uses of the enum values in g_object_set() to
(int).
2016-10-05 14:46:18 +02:00
Thomas Haller 2de000e1d2 proxy: reject huge pac_script values in verify() 2016-10-04 11:44:44 +02:00
Atul Anand 20098591d9 proxy: change semantics of pac-script
libnm-core: pac-script property in NMSettingProxy now represents the
script itself not the location. It ensures that the connection is
self contained.

nmcli: Supports loading of PAC Script via file path or written explicitly.
2016-10-04 11:44:44 +02:00
Atul Anand 812b8774f6 proxy: remove unnecessary APIs
Unnecessary APIs have been removed from nm-setting-proxy, client like
nm-connection-editor are expected to create a PAC script snippet the load
the location of file in NM.
2016-10-04 11:44:44 +02:00
Atul Anand 2a40112ebe libnm: API for Proxy Feature
libnm-core has been expanded to include proxy settings which clients
like nmcli, nm-connection-editor use to configure proxy in PacRunner. It
offers three modes i.e 'auto', 'manual'and 'none' and accordingly take
data to configure PacRunner. The modes matches on the PacRunner side too.
2016-10-04 11:44:13 +02:00
Thomas Haller b4e66c4818 shared: add nm_clear_g_free() 2016-10-03 12:02:34 +02:00
Thomas Haller a83eb773ce all: modify line separator comments to be 80 chars wide
sed 's#^/\*\{5\}\*\+/$#/*****************************************************************************/#' $(git grep -l '\*\{5\}' | grep '\.[hc]$') -i
2016-10-03 12:01:15 +02:00
Lubomir Rintel 67999ef2d3 libnm-core/tests: disable the JSON validation check without jansson 2016-09-27 18:37:22 +02:00
Pellaeon Lin 4d7cf9a16d libnm: fix typo g_size to gsize
Fixes: 32f78ae6c3

https://bugzilla.gnome.org/show_bug.cgi?id=772062
2016-09-27 18:08:13 +02:00
Thomas Haller 146e0d23bc libnm: reject too large team-config JSON 2016-09-27 10:56:57 +02:00
Thomas Haller 32f78ae6c3 libnm: expose nm_utils_is_json_object() utility function
Since we possibly already link against libjansson, we can also expose some
helper utils which allows nmcli to do basic validation of JSON without
requiring to duplicate the effort of using libjansson.

Also, tighten up the cecks to ensure that we have a JSON object at hand.
We are really interested in that and not of arrays or literals.
2016-09-27 10:56:42 +02:00
Thomas Haller ee86069601 shared: add test for NM_SET_OUT() 2016-09-26 17:00:38 +02:00
Thomas Haller e152eea218 build: fix breakage of enums-to-docbook.pl script for NMCapability enum
GEN      nm-dbus-types.xml
    Documentation for value '*' missing at ../tools/enums-to-docbook.pl line 134, <> line 95.
    Makefile:1579: recipe for target 'nm-dbus-types.xml' failed

Fixes: 93a753e311
2016-09-23 19:11:45 +02:00
Beniamino Galvani 0e96d23733 crypto: don't try to decrypt PKCS#8 key if no password is supplied
crypto_verify_private_key_data() must try to decrypt the key only when
a password is supplied.

Previously the decrypt test always passed because we detected an
unsupported cipher and faked success. Now since version 3.5.4 gnutls
supports PBES1-DES-CBC-MD5 and the key is actually decrypted when a
password is supplied.

Also, don't assert that a wrong password works because we're now able
to actually verify it (only with recent gnutls).

https://bugzilla.gnome.org/show_bug.cgi?id=771623
2016-09-23 18:05:54 +02:00
Thomas Haller 93a753e311 capabilities: add comment about capability range 2016-09-23 16:09:06 +02:00
Thomas Haller ab26248080 capabilities: fix number for NM_CAPABILITY_TEAM
The enum defines should name their numerical value explicitly,
so that it can be easily seen by looking at the code. Also,
they are public, stable API. They must not change.

Anyway, the capability 0 shall be reserved. Change NM_CAPABILITY_TEAM
to value 1.
2016-09-23 15:49:52 +02:00
Marius Vollmer 2ca1ce5d88 team: Add NM_CAPABILITY_TEAM 2016-09-23 15:49:52 +02:00
Marius Vollmer 1bb00ae66a manager: Add "Capabilities" property 2016-09-23 15:49:52 +02:00
Thomas Haller c3ecca225c core: add _nm_utils_array_find_binary_search()
Also add nm_cmp_uint32_p_with_data(). Will be used later.
2016-09-23 15:49:29 +02:00
Thomas Haller 08f5681b0e core: const arguments for _nm_utils_ptrarray_find_*() functions 2016-09-23 15:34:17 +02:00
Thomas Haller 0fb723e720 libnm: relax comparison of bond-option for INFERRABLE match
When comparing the bond-settings of an activated device against
the settings from the connection, some properties might easily
differ. Hack them around in NMSettingBond:compare_property().

For example:

the setting in the connection has:
    [bond]
    mode=active-backup

later, the device gets:
    [bond]
    active_slave=inf_ib0
    fail_over_mac=active
    mode=active-backup

Note that the fail_over_mac changes due to:
  kernel: nm-bond: enslaved VLAN challenged slave inf_ib0. Adding VLANs will be blocked as long as inf_ib0 is part of bond nm-bond
  kernel: nm-bond: The slave device specified does not support setting the MAC address
  kernel: nm-bond: Setting fail_over_mac to active for active-backup mode

https://bugzilla.redhat.com/show_bug.cgi?id=1375558
2016-09-22 18:32:54 +02:00
Thomas Haller b1fd5a06c4 macros: simplify NM_IN_SET() and NM_IN_STRSET() macros
and support up to 16 arguments.
2016-09-22 16:34:22 +02:00
Beniamino Galvani eaad7ae431 libnm-core: drop extra IPs from shared connections during normalization
The core only consider the first address for shared connections, don't
pretend we accept multiple addresses.  This change doesn't prevent
supporting multiple addresses in the future.

https://bugzilla.gnome.org/show_bug.cgi?id=763937
2016-09-14 23:30:41 +02:00
Thomas Haller fae5ecec5a device: change default value for cloned-mac-address to "preserve" (bgo#770611)
Long ago before commit 1b49f94, NetworkManager did not touch the
MAC address at all. Since 0.8.2 NetworkManager would modify the
MAC address, and eventually it would reset the permanent MAC address
of the device.

This prevents a user from externally setting the MAC address via tools
like macchanger and rely on NetworkManager not to reset it to the
permanent MAC address. This is considered a security regression in
bgo#708820.

This only changed with commit 9a354cd and 1.4.0. Since then it is possible
to configure "cloned-mac-address=preserve", which instead uses the "initial"
MAC address when the device activates.
That also changed that the "initial" MAC address is the address which was
externally configured on the device as last. In other words, the
"initial" MAC address is picked up from external changes, unless it
was NetworkManager itself who configured the address when activating a
connection.

However, in absence of an explicit configuration the default for
"cloned-mac-address" is still "permanent". Meaning, the user has to
explicitly configure that NetworkManager should not touch the MAC address.
It makes sense to change the upstream default to "preserve". Although this
is a change in behavior since 0.8.2, it seems a better default.

This change has the drastic effect that all the existing connections
out there with "cloned-mac-address=$(nil)" change behavior after upgrade.
I think most users won't notice, because their devices have the permanent
address set by default anyway. I would think that there are few users
who intentionally configured "cloned-mac-address=" to have NetworkManager
restore the permanent address.

https://bugzilla.gnome.org/show_bug.cgi?id=770611
2016-09-12 14:01:57 +02:00
Thomas Haller 9cf9c3a88e libnm-core: fix crash in nm_vpn_plugin_info_list_get_service_types()
Coverity says, "Dereference after null check". Indeed, @aliases
is usually NULL.

Fixes: 46665898bb
2016-09-09 01:23:11 +02:00
Thomas Haller 814784aa46 libnm: fix regression serializing empty "cloned-mac-address"
For "cloned-mac-address", the empty string "" is an invalid
value that is rejected by verify().

Commit 8eed671 changed how the property is serialized to D-Bus.
Before, it was serialized using _nm_utils_hwaddr_to_dbus().
For invalid or empty addresses, this would not serialize the
value on D-Bus (or before commit 76aa6f8e0, it would create
a bogus value with no array elements).

With commit 8eed671, the cloned-mac-address gets also serialized
as "assigned-mac-address" via _nm_utils_hwaddr_cloned_data_synth(),
which would pass on invalid strings that the server would then reject.

That breaks for example nmtui. Try editing a connection with
"cloned-mac-address" set to NULL. Note, as long as you don't edit
the cloned MAC address in nmtui, you can save the modification.
Once you start modifying the entry, you can no longer set an empty
MAC address as the server now receives the invalid empty string.
Thus, the "OK" button fails with
   Unable to save connection:
   802-3-ethernet.cloned-mac-address:
   is not a valid MAC address
It also means, nmtui cannot modify the "cloned-mac-address" field to
become empty.

Fix that problem at various places by coercing "" to NULL.

Fixes: 8eed67122c

https://bugzilla.redhat.com/show_bug.cgi?id=1372799
2016-09-06 16:11:23 +02:00
Thomas Haller f4d7db964e libnm-core: replace local helper with nm_stdup_not_empty() 2016-09-06 16:07:02 +02:00
Beniamino Galvani d06279f3db libnm: restore verify() comments in team/team-port settings
Restore the comments removed in commit
a524091966afb884cdb8db48067d5599a685a8eb.
2016-08-30 18:20:28 +02:00
Beniamino Galvani d6ec009afd team: normalize invalid configuration during load
Now that we validate the JSON syntax of a team/team-port
configuration, any existing connection with invalid JSON configuration
would fail to load and disappear upon upgrade. Instead, modify the
setting plugins to emit a warning but still load the connection with
empty configuration.
2016-08-30 18:20:28 +02:00
Beniamino Galvani 39ad134b0c Revert "libnm-core/team: normalize invalid config to NULL"
It's better to fail the validation of any invalid configuration
instead of silently ignoring it.

This reverts commit 476810c290.
2016-08-30 18:20:28 +02:00
Thomas Haller f3a60e14e7 doc: clearify deprecated "cloned-mac-address" field in documentation 2016-08-30 14:32:10 +02:00
Yuri Chornoivan 297ade2745 all: fix typos in documentation and translated strings
https://bugzilla.gnome.org/show_bug.cgi?id=770445
2016-08-26 19:00:12 +02:00
Thomas Haller 476810c290 libnm-core/team: normalize invalid config to NULL
A user may very well have connections on disk with bogus json.
Such connections may have failed to activate before, but rejecting
them now as invalid means that we stop loading them from disk. That is,
they disappear after upgrade.

Instead of doing that, also accept invalid json (beside "") and
normalize/coerce it to NULL.

https://bugzilla.redhat.com/show_bug.cgi?id=1366300
2016-08-24 10:58:02 +02:00
Lubomir Rintel 0fc8b856c3 libnm-core/team: treat "" team config as no config
https://bugzilla.redhat.com/show_bug.cgi?id=1366300
2016-08-24 10:57:54 +02:00
Thomas Haller f19aff8909 all: cleanup includes in header files
- don't include "nm-default.h" in header files. Every source file must
  include as first header "nm-default.h", thus our headers get the
  default include already implicitly.

- we don't support compiling NetworkManager itself with a C++ compiler. Remove
  G_BEGIN_DECLS/G_END_DECLS from internal headers. We do however support
  users of libnm to use C++, thus they stay in public headers.
2016-08-17 19:09:50 +02:00
Lubomir Rintel b2eb64a439 release: bump version to 1.5.0 (development) 2016-08-17 16:20:42 +02:00
Alfonso Sanchez-Beato 24b193ab64 device: add statistics interface
Add statistics interface to all device instances. When active, the
properties of this interface are refreshed whenever there is network
activity for the device.

Activation is performed by changing RefreshRateMs property. If set to
zero, the interface is deactivated. If set to other value, the rest of
the interface properties are refreshed whenever the related network
metric changes, being RefreshRateMs the minimum time between property
changes, in milliseconds.
2016-08-17 15:50:20 +02:00
Beniamino Galvani 3e09aed2a0 checkpoint: add create, rollback and destroy D-Bus API
Co-authored-by: Thomas Haller <thaller@redhat.com>
2016-08-17 14:55:34 +02:00