Commit Graph

528 Commits

Author SHA1 Message Date
Thomas Haller
81499355b0 libnm: don't require initialized @out_encrypted argument in nm_utils_file_is_private_key()
No need to require the caller to initialize the optional out-argument.
Otherwise we get:

  (nm-connection-editor:2471): libnm-CRITICAL **: nm_utils_file_is_private_key: assertion 'out_encrypted == NULL || *out_encrypted == FALSE' failed

https://bugzilla.gnome.org/show_bug.cgi?id=763578

Fixes: 1c4f41c610
2016-05-13 14:26:32 +02:00
Beniamino Galvani
c5f17531b9 ifcfg-rh: add support for DNS priority 2016-05-12 17:13:50 +02:00
Beniamino Galvani
bdd0e7fec0 libnm-core: add dns-priority to NMSettingIPConfig 2016-05-12 17:13:50 +02:00
Thomas Haller
ba90c9601c all: replace nm_unauto() by g_steal_pointer()
They do essentially the same.
2016-05-12 14:28:44 +02:00
Beniamino Galvani
f1d23c32c3 docs: libnm: add doc comment to types
This is required to add objects in the "Types and Values" section and
in the API index. Later, we may want to add useful content in those
empty comments.
2016-05-05 17:01:57 +02:00
Thomas Haller
c5ac691744 build: cleanup includes of <gmodule.h>
<gmodule.h> is implicitly included by <gio/gio.h> which is available
everywhere. For that reason, we would not have to include this header
at all. However, it is recommended to explicitly include <gmodule.h>
where needed.

So, include it where needed -- if <gio/gio.h> wouldn't be there --
and drop it from where it is not needed.
2016-04-30 03:42:16 +02:00
Thomas Haller
264189e756 libnm/vpn: don't close the VPN plugin library on cleanup
Closing the library will interfere badly as the glib types cannot be
unregistered. We must leak the library handle.

Switch to dlopen() instead of g_module_open(), because the former
supports RTLD_NOLOAD. This is useful for two reasons:

  - checking the file prior loading only makes any sense when
    dlopen() would actually load a file anew.

  - if the library was loaded before, we want to return the handle.
    On the other hand, if the library was not loaded, we leak the
    handle.

Thereby, refactor the code from if-else blocks to return-early, because
the function nicely does individual steps and if one fails just error
out.
2016-04-29 15:38:29 +02:00
Thomas Haller
b52485b34b libnm/vpn: fix checking service name in nm_vpn_plugin_info_new_search_file()
Fixes: 3adf782ab5
2016-04-29 15:28:04 +02:00
Thomas Haller
c1147fc71b libnm/vpn: don't leak editor-plugin if nm_vpn_editor_plugin_load() fails 2016-04-28 15:00:04 +02:00
Thomas Haller
d350d72a2e libnm: store NMConnectionPrivate via g_object_set_qdata()
g_object_get_data() and g_object_get_qdata() end up to be identical,
except that g_object_get_data() also requires to intern the string
on every lookup (which involves a hash lookup and locking).
2016-04-28 14:58:17 +02:00
Beniamino Galvani
c1907a218a libnm-core: remove gateway when never-default=yes in NMSettingIPConfig
Having a gateway defined when never-default=yes causes troubles in
connection matching and anyway makes no sense.

If the combination is found, remove the gateway during the
normalization phase.

https://bugzilla.redhat.com/show_bug.cgi?id=1313091
2016-04-27 17:15:49 +02:00
Thomas Haller
bad9becf99 libnm/doc: fix documentation of NMSettingIP6Config:addr-gen-mode
The value cannot be unset. It must be set to one of the two currently
supported values.
2016-04-25 16:52:34 +02:00
Thomas Haller
3adf782ab5 libnm/vpn: consider VPN service aliases in nm_vpn_plugin_info_new_search_file()
Fixes: 4271c9650c
2016-04-25 11:31:55 +02:00
Beniamino Galvani
7434e6a77b libnm-core: fix compiler warning in nm_vpn_plugin_info_get_auth_dialog()
libnm-core/nm-vpn-plugin-info.c: In function ‘nm_vpn_plugin_info_get_auth_dialog’:
shared/gsystem-local-alloc.h:53:46: error: ‘prog_basename’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

Fixes: a3f94f451b
2016-04-22 16:57:02 +02:00
Thomas Haller
4271c9650c libnm/vpn: add nm_vpn_plugin_info_new_search_file() 2016-04-22 14:17:02 +02:00
Thomas Haller
67415f0c5e libnm/vpn: add nm_vpn_plugin_info_supports_hints() 2016-04-22 14:17:02 +02:00
Thomas Haller
a3f94f451b libnm/vpn: add nm_vpn_plugin_info_get_auth_dialog() 2016-04-22 14:17:02 +02:00
Thomas Haller
0d95ed3bb8 libnm/vpn: add nm_vpn_plugin_info_get_service()
Re-add nm_vpn_plugin_info_get_service(). This function *is* useful
and could be used by nm-applet.

This reverts commit 3517084b92.
2016-04-22 14:17:02 +02:00
Thomas Haller
8e59be20d6 libnm/vpn: gracefully handle empty dirname in _nm_vpn_plugin_info_list_load_dir()
No need to assert against an empty dirname. It's not different from
any other non-existing directory and we should be graceful about that.
2016-04-22 14:17:02 +02:00
Lubomir Rintel
db6ebe003d docs: include the D-Bus enums reference with the API documentation
Otherwise the types links would be dangling or resolved to slightly
irrelevant documentation in libnm or completely irrelevant documentation
in libnm-util.
2016-04-22 10:02:37 +02:00
Lubomir Rintel
c850868faf libnm-core: don't link to NMDevice type from the D-Bus spec
It isn't right in that context -- NMDevice is a libnm-core object,
not a bus object. In rendered documentation this would generate
a dangling link.
2016-04-22 10:02:37 +02:00
Lubomir Rintel
1d66d415b8 libnm-core: empty key is not a pkcs12 file
nmcli> set 802-1x.ca-cert file:///tmp/certs/eaptest_ca_cert.pem
  (process:31015): libnm-CRITICAL **: crypto_is_pkcs12_data: assertion 'data != NULL' failed
  Error: failed to set 'ca-cert' property: PEM certificate had no start tag '-----BEGIN CERTIFICATE-----'.
2016-04-20 10:48:59 +02:00
Thomas Haller
0b128aeced libnm/vpn: search VPN plugin in NMPLUGINDIR
In commit ca000cffbb, we changed to
accept a plugin library name without path. One reason for that
is to keep architecture dependent parts out of the .name file
and possibly support multilib.

However, the shared libraries of VPN plugins are not installed in
a global library search path, but for example into
"/usr/lib64/NetworkManager/libnm-vpn-plugin-openvpn.so".
In that case, specifying "plugin=libnm-vpn-plugin-openvpn.so"
would not be enough to find plugin.

Instead, when configuring a plugin name without path, assume
it is in NMPLUGINDIR directory. Modify nm_vpn_editor_plugin_load_from_file()
to allow path-less plugin-names. Previously such names would be rejected
as not being absolute. This API allows to do file verification
before loading the plugin, but it now supports prepending NMPLUGINDIR
to the plugin name. Basically, this function mangles the plugin_name
argument and checks that such a file exists.

The recently added nm_vpn_editor_plugin_load() continues to behave
as before: it does no checks whatsoever and passes the name directly
to dlopen(). That way, it uses system search paths like LD_LIBRARY_PATH
and performs no checks on the file.

Fixes: ca000cffbb
2016-04-19 14:59:26 +02:00
Thomas Haller
e00eac2981 libnm/vpn: add nm_vpn_editor_plugin_load() function
Contrary to nm_vpn_editor_plugin_load_from_file(), this allows
to specify a library name without path. In this case, g_module_open()
(dlopen()) will search for a library in various system directories.
2016-04-19 13:47:42 +02:00
Thomas Haller
ca000cffbb libnm/vpn: allow specifying non-absolute plugin name in VPN .name file
Since commit 3dfbbb227e, we enforce that
the plugin path in the .name file is absolute and we perform several
checks on the file before loading it (ownership, etc).

Relax that, to also allow libray names without path component.
In that case, g_module_open()/dlopen() will search for a library
in various search paths. This allows, to omit absolute paths
in the .name file. The latter is problematic, because by default
we install the .name file in the architecture independent location
/usr/lib/NetworkManager. As such, it should not contain paths
to architecture dependent libraries. With this change, a .name
file can contain only the library name and it will be loaded
using the usual mechanism.

However, specifying absolute paths is still possible and works
same as before, including checking file permissions.

As such, distributions probably should package the VPN plugins
to have no path in the .name file. On the other hand, a user
compiling from source probably wants to specify an absolute
path. The reason is, that the user probably doesn't build the
plugin for multiple achitectures and that way, he can install
the plugin in a separate (private) prefix.
2016-04-19 13:47:42 +02:00
Thomas Haller
cb22f02588 libnm/vpn: fix code comment for nm_vpn_editor_plugin_load_from_file()
The @plugin_filename argument must be an absolute path.
That was changed later, but forgot to update the comment.

Fixes: 3dfbbb227e
2016-04-19 13:47:42 +02:00
Thomas Haller
4003edbbf9 libnm/vpn: clear internal "keyfile" from NMVpnPluginInfo
The GKeyFile is no longer needed after constuction. All strings are
copied over to the "keys" hash.
2016-04-19 13:47:42 +02:00
Thomas Haller
6878999ca3 libnm/vpn: lookup nm_vpn_plugin_info_supports_multiple() from cached values
Instead of looking into the keyfile, lookup the "supports-multiple-connections" setting
in the "keys" hash. This has some behavioral difference:

  - g_key_file_get_boolean() first does g_key_file_get_value(), and then
    converts the string using the private g_key_file_parse_value_as_boolean()
    function -- which is case-sensitive, accepts "true|false|0|1" and
    considers only the text until the first whitespace.

  - now, we put g_key_file_get_string() into the cache "keys" and
    parse it with _nm_utils_ascii_str_to_bool(). The latter is
    case insensitive, allows also "yes|no|on|off", strips whitespaces.

However, the difference is subtle and shouldn't matter.

The point of this change is to free "keyfile" after construction.
2016-04-19 13:47:42 +02:00
Beniamino Galvani
82f8a54854 libnm-core: use jansson to compare and check team configurations
Optionally link libnm-core against jansson JSON library and use it to
validate and compare team configurations.
2016-04-18 21:50:51 +02:00
Thomas Haller
6b8729a599 libnm-core: drup unused @allow_zero_prefix argument from valid_prefix() 2016-04-11 12:40:35 +02:00
Thomas Haller
57860c329e libnm-core: allow zero prefix length in NMIPAddress
Adding addresses with a prefix of zero is valid. Don't
reject them.

Note that this is an actual bug. If you configure an
address with prefix length zero, nmcli will report:

  $nmcli connection
  (process:1040): libnm-WARNING **: Ignoring invalid IP4 address: Invalid IPv4 address prefix '0'
2016-04-11 12:33:07 +02:00
Thomas Haller
d68ccb84f1 libnm-core/trivial: add code comment 2016-04-11 12:29:33 +02:00
Lubomir Rintel
f4b4e35c79 release: add version 1.4 macros 2016-04-05 22:22:58 +02:00
Thomas Haller
9152dec99f build: disable deprecation checks for internal compilation
For internal compilation we want to be able to use deprecated
API without warnings.

Define the version min/max macros to effectively disable deprecation
warnings.

However, don't do it via CFLAGS option in the makefiles, instead hack it
to "nm-default.h". After all, *every* source file that is for internal
compilation needs to include this header as first.
2016-04-05 22:22:58 +02:00
Lubomir Rintel
2c3c83370b dbus: move NMWimaxNspNetworkType to nm-dbus-interface.h
It's an enum used on D-Bus.
2016-04-05 14:37:51 +02:00
Lubomir Rintel
ccf1d5bd94 dbus: remove the telepathy annotations
We now generate documentation with gdbus-codegen and these are now
useless.
2016-04-05 14:37:51 +02:00
Beniamino Galvani
d6d42e0825 libnm-core: add 'use-vc' DNS option
The option forces the use of TCP for DNS resolutions.
2016-04-03 23:08:38 +02:00
Thomas Haller
5f83ef9925 build: drop internal field __nm_git_sha from libraries
The problem is that you cannot be sure which patches
were applied on top of a source tree, so the __nm_git_sha
value is unreliable.

Also, after running autoreconf during the package build,
NM_GIT_SHA is reset as well.
2016-03-30 15:48:56 +02:00
Beniamino Galvani
a0206a4f5e man,libnm-core: fix typos 2016-03-30 12:03:36 +02:00
Beniamino Galvani
b717c5503b libnm-core: remove trailing quote from message in nm-setting-macvlan.c
Reported-by: Anders Jonsson <anders.jonsson@norsjovallen.se>
2016-03-30 00:33:20 +02:00
Beniamino Galvani
efa559bcc8 libnm-core: add test cases for NMSettingBond
The setting well deserves some testing.
2016-03-29 18:10:05 +02:00
Beniamino Galvani
4839c747c2 libnm-core: implement option matching for NMSettingBond
We cannot simply compare the single values of option hashes to match
connections because some keys are equivalent to others and also
because keys having a default value should be ignored.

Add the compare_property method to implement custom comparison logic.
2016-03-29 18:10:05 +02:00
Beniamino Galvani
260fcc52a8 bond: add some missing options
https://bugzilla.redhat.com/show_bug.cgi?id=1299103
2016-03-29 18:10:05 +02:00
Beniamino Galvani
2324410a75 bond: fix re-assuming of connections
When a value of a TYPE_BOTH option is read back from kernel it
contains both string and numeric values ("balance-rr 0"), so we must
chop off the number before adding the option to the setting. Also
change the default values of options to the string form so that the
option matching logic works.
2016-03-29 18:10:05 +02:00
Beniamino Galvani
5f7d7ee497 libnm,libnm-core: add coverage support 2016-03-29 18:10:04 +02:00
Beniamino Galvani
e196f2257d libnm-core: fix check in verification of NMSettingBond 2016-03-29 18:10:04 +02:00
Thomas Haller
df405942de libnm-core/tests: refactor call to nm_simple_connection_new_from_dbus()
No actual change, let's just not directly call nm_simple_connection_new_from_dbus().
Instead, add a wrapper to define in once place the flags we use for loading the
connection.
2016-03-26 12:10:54 +01:00
Thomas Haller
3d8776108c libnm-core: add _nm_simple_connection_new_from_dbus() function
Contary to nm_simple_connection_new_from_dbus(), this internal
function allows to specify parse-flags.
2016-03-26 12:10:54 +01:00
Thomas Haller
737c8cc532 libnm-core: allow strict and relaxed error behavior for _nm_setting_new_from_dbus()
In some situations, we want strict checking of errors, for example when
NetworkManager receives a new connection from a client, the connection
must make sense as a whole (and since NetworkManager service is backward
compatible to the clients and not the other way around, there is no
excuse for sending invalid data to the server).

In other situations, we want a best-effort behavior. Like when
NetworkManager sends a connection to its clients, those clients
want to extract as many properties as they understand, but in order
to be forward compatible against newer server versions, invalid
or unknown properties must be accepted.

Previously, a mixture of both was done. Some issues caused a failure
to create a new NMSetting, other invalid parts were just silently
ignored or triggered a g_warning() in glib.

Now allow for both. When doing strict-validation, be more strict and
reject all unknown properties and catch when the user sets an invalid
argument. On the other hand, allow for a best-effort mode that
effectively cannot fail and will return a new NMSetting instance.

For now, add NMSettingParseFlags so that the caller can choose the
old behavior, strict parsing, or best effort.

This patch doesn't have any externally visible change except that
no more g_warnings will be emitted.
2016-03-26 12:10:54 +01:00
Thomas Haller
fafc90526b shared: move _nm_utils_ascii_str_to_int64() to "shared/nm-shared-utils.h"
_nm_utils_ascii_str_to_int64() was declared in libnm-core's internal
header "nm-core-internal.h" and thus available for libnm-core, libnm,
NetworkManager and related.

It also means, the function was not available in libnm-util, libnm-glib,
clients or dispatcher. So, we either reimplemented it (nmc_string_to_int_base)
or struggle with the awkward strtol* API.
2016-03-26 12:10:53 +01:00