Commit graph

641 commits

Author SHA1 Message Date
Lubomir Rintel d441271109 libnm/client: drop some unneeded includes 2016-11-10 18:11:15 +01:00
Lubomir Rintel 1f5b48a59e libnm: use the o.fd.DBus.ObjectManager API for object management
This speeds up the initial object tree load significantly. Also, it
reduces the object management complexity by shifting the duties to
GDBusObjectManager.

The lifetime of all NMObjects is now managed by the NMClient via the
object manager. The NMClient creates the NMObjects for GDBus objects,
triggers the initialization and serves as an object registry (replaces
the nm-cache).

The ObjectManager uses the o.fd.DBus.ObjectManager API to learn of the
object creation, removal and property changes. It takes care of the
property changes so that we don't have to and lets us always see a
consistent object state.  Thus at the time we learn of a new object we
already know its properties.

The NMObject unfortunately can't be made synchronously initializable as
the NMRemoteConnection's settings are not managed with standard
o.fd.DBus Properties and ObjectManager APIs and thus are not known to
the ObjectManager.  Thus most of the asynchronous object property
changing code in nm-object.c is preserved. The objects notify the
properties that reference them of their initialization in from their
init_finish() methods, thus the asynchronously created objects are not
allowed to fail creation (or the dependees would wait forever). Not a
problem -- if a connection can't get its Settings, it's either invisible
or being removed (presumably we'd learn of the removal from the object
manager soon).

The NMObjects can't be created by the object manager itself, since we
can't determine the resulting object type in proxy_type() yet (we can't
tell from the name and can't access the interface list). Therefore the
GDBusObject is coupled with a NMObject later on.

Lastly, now that all the objects are managed by the object manager, the
NMRemoteSettings and NMManager go away when the daemon is stopped. The
complexity of dealing with calls to NMClient that would require any of
the resources that these objects manage (connection or device lists,
etc.) had to be moved to NMClient. The bright side is that his allows
for removal all of the daemon presence tracking from NMObject.
2016-11-10 16:48:48 +01:00
Lubomir Rintel ff3eb24c15 libnm: change the secret agent to use the generated GDBus bindings
It allows us to drop _nm_dbus_register_proxy_type() and _nm_dbus_new_proxy_*()
once they're not used by the rest of libnm anymore.
2016-11-10 16:48:48 +01:00
Lubomir Rintel bbed63213a libnm/tests: work around ObjectManager bogus warning
We should eventually fix this in Gio, but I guess we need to keep the
workaround for the time being anyway.
2016-11-10 16:48:48 +01:00
Lubomir Rintel ed21a820a7 libnm/tests: connection might not be gone at the time manager signals removal
The assumption is not too useful to the library user anyway -- it could easily
be that there's some other link to the object in the object tree.

More importantly, when the objects are managed by the object manager,
we don't destroy the object until we see it actually removed on the
D-Bus. That makes more sense anyway.
2016-11-10 16:48:47 +01:00
Lubomir Rintel 7007c9853c libnm: order the property updates
Don't let a later property update finish than the sooner one.

This wouldn't happen most of time, apart from a special case when the
latter update of a object array property is to an empty list.
In that case the latter update would complete sooner and when the
earlier update finishes the list would contain objects which are
supposed to be gone already.
2016-11-10 16:48:47 +01:00
Lubomir Rintel df46c59775 nm-object: initialize the object buffer to zero 2016-11-10 16:48:47 +01:00
Beniamino Galvani 75127b1348 libnm: add missing device includes in NetworkManager.h
And also sort the setting includes alphabetically.
2016-11-09 17:45:34 +01:00
Thomas Haller e028edd1c5 libnm/trivial: fix code comment for internal header libnm/nm-manager.h 2016-11-08 14:27:07 +01:00
Thomas Haller 95ab69b761 libnm: coerce empty strings to NULL for D-Bus properties
On D-Bus level, string (s) or object paths (o) cannot be NULL.
Thus, whenver server exposes such an object, it gets automatically
coerced to "" or "/", respectively.

On client side, libnm should coerce certain properties back, for which
"" is just not a sensible value.

For example, an empty NM_DEVICE_ETHERNET_HW_ADDRESS should be instead
exposed as NULL.

Technically, this is an API change. However, all users were well advised
to expect both NULL and "" as possible return values and handle them
accordingly.
2016-10-24 10:14:02 +02:00
Thomas Haller 21d7aa9204 libnm: minor refactoring by using g_clear_object() and nm_str_not_empty() 2016-10-24 10:14:02 +02:00
Thomas Haller c4198d45e3 libnm: avoid possibly NULL address for NMDeviceVlan calling nm_utils_hwaddr_matches() 2016-10-24 10:14:02 +02:00
Thomas Haller 7eb054d099 libnm: fix memleak in NMDeviceVxlan 2016-10-24 10:14:02 +02:00
Thomas Haller 7aefbcb622 build: merge "libnm/tests/Makefile.am" into toplevel Makefile 2016-10-19 17:16:08 +02:00
Thomas Haller 9061432d55 build: merge "libnm/Makefile.am" into toplevel Makefile 2016-10-19 17:16:07 +02:00
Thomas Haller cd98705d21 tests: combine "run-test-valgrind.sh" and "run-test-dbus-session.sh" in "run-nm-test.sh"
No need to have two test-runners. Combine them, and call tests always
via "tools/run-nm-test.sh".

Yes, this brings an overhead, that we now always invoke the test with
a test wrapper script, also --without-vagrind. Previously, that was only
necessary for libnm tests that require their own D-Bus session.

Later we will do non-recursive Makefiles, thus all tests should have the
same LOG_COMPILER.
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 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 0a61317870 libnm: disconnect devices' signals when disposing manager
We connect signal handlers to devices when they appear, but don't
disconnect the handlers when the manager instance is destroyed. This
can cause crashes as device_ac_changed() is called on an invalid
manager instance.

Disconnect the handlers from dispose().

https://bugzilla.redhat.com/show_bug.cgi?id=1383758
2016-10-14 10:44:18 +02:00
Thomas Haller c7853a1415 build: add extra dependencies for linker-version-script for NetworkManager and libnm.so 2016-10-14 10:33:30 +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
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 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
Thomas Haller 1b8c201cce cli: reject team.config from files with '\0'
The team-config must be valid utf-8. First of all, JSON
is also defined for other unicode encodings, but libjansson
can only handle utf-8. So, just require that.

A file with a '\0' truncates part of the file and is thus
invalid.
2016-09-27 11:24:47 +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 ede4b1c5e5 libnm: fix symbol versioning
Already released versions must not be extended or modified.
The new symbol is part of upcomming 1.6.0 release.
2016-09-23 15:49:52 +02:00
Marius Vollmer 1bb00ae66a manager: Add "Capabilities" property 2016-09-23 15:49:52 +02:00
Beniamino Galvani b1bf2671b2 build: fix build with address sanitizer
Every program run during the build which loads a NM library must
preload libasan.so if the address sanitizer is enabled.

Add a macro to set the needed environment variables and use it when
performing the shared object link tests.
2016-09-20 13:44:04 +02:00
Beniamino Galvani f4a0ab757f libnm: make waiting objects fail when an object initialization fails
Previously, when the load of an object failed and there were other
objects waiting for it, those objects would remain waiting
forever. Make them fail as well.
2016-09-09 16:40:53 +02:00
Thomas Haller 0bdcab100c 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.

(cherry picked from commit f19aff8909)
2016-08-17 19:51:17 +02:00
Alfonso Sanchez-Beato 6fb0de0a8b auth: check when setting statistics refresh rate 2016-08-17 16:08:20 +02:00
Thomas Haller 2cb18efaea permissions: properly add checkpoint-rollback permission
Fixes: a52d4654ec
2016-08-17 15:50:20 +02:00
Thomas Haller 1f2eeb85d8 build: rename $(LIBDL) to $(DL_LIBS) and modify detection 2016-08-15 17:23:41 +02:00
Beniamino Galvani 765dabd005 libnm: fix introspection annotations for nm_client_load_connections()
Add the "(array zero-terminated=1)" GLib introspection annotation when
the parameter is a NULL-terminated string array.

https://mail.gnome.org/archives/networkmanager-list/2016-August/msg00017.html

Reported-by: Petr Horacek <phoracek@redhat.com>
2016-08-04 13:52:43 +02:00
Lubomir Rintel b01219ad1b libnm: link with libdl
Not default when linking with GOLD linker, but used for loading the VPN
plugins. We still get it when using NSS by dumb luck, but GnuTLS doesn't
drag it in.

https://bugzilla.gnome.org/show_bug.cgi?id=769328
2016-08-01 17:03:07 +02:00
Francesco Giudici 60a82e3ff2 device: enable MAC address check on virtual devices
Virtual devices don't have a valid permanent hw address: when activating
a connection against a specific interface, a check is performed on the
device MAC address too: if it is an empty string, give a try to the
currently assigned MAC address.
2016-07-22 19:36:24 +02:00
Francesco Giudici 65771b80a6 cli: improve devices vs connection compatibility check
report error message on device compatibility failures
2016-07-22 19:36:23 +02:00
Lubomir Rintel 12290252c7 libnm/client: emit signals when active connection disappears
It allows us to reliably track failures to activate a connection.
2016-07-07 11:56:05 +02:00
Thomas Haller 96cabbcbb8 all: make MAC address randomization algorithm configurable
For the per-connection settings "ethernet.cloned-mac-address"
and "wifi.cloned-mac-address", and for the per-device setting
"wifi.scan-rand-mac-address", we may generate MAC addresses using
either the "random" or "stable" algorithm.

Add new properties "generate-mac-address-mask" that allow to configure
which bits of the MAC address will be scrambled.

By default, the "random" and "stable" algorithms scamble all bits
of the MAC address, including the OUI part and generate a locally-
administered, unicast address.

By specifying a MAC address mask, we can now configure to perserve
parts of the current MAC address of the device. For example, setting
"FF:FF:FF:00:00:00" will preserve the first 3 octects of the current
MAC address.

One can also explicitly specify a MAC address to use instead of the
current MAC address. For example, "FF:FF:FF:00:00:00 68:F7:28:00:00:00"
sets the OUI part of the MAC address to "68:F7:28" while scrambling
the last 3 octects.
Similarly, "02:00:00:00:00:00 00:00:00:00:00:00" will scamble
all bits of the MAC address, except clearing the second-least
significant bit. Thus, creating a burned-in address, globally
administered.

One can also supply a list of MAC addresses like
"FF:FF:FF:00:00:00 68:F7:28:00:00:00 00:0C:29:00:00:00 ..." in which
case a MAC address is choosen randomly.

To fully scamble the MAC address one can configure
"02:00:00:00:00:00 00:00:00:00:00:00 02:00:00:00:00:00".
which also randomly creates either a locally or globally administered
address.

With this, the following macchanger options can be implemented:

  `macchanger --random`
   This is the default if no mask is configured.
   -> ""
   while is the same as:
   -> "00:00:00:00:00:00"
   -> "02:00:00:00:00:00 02:00:00:00:00:00"

  `macchanger --random --bia`
   -> "02:00:00:00:00:00 00:00:00:00:00:00"

  `macchanger --ending`
   This option cannot be fully implemented, because macchanger
   uses the current MAC address but also implies --bia.
   -> "FF:FF:FF:00:00:00"
      This would yields the same result only if the current MAC address
      is already a burned-in address too. Otherwise, it has not the same
      effect as --ending.
   -> "FF:FF:FF:00:00:00 <MAC_ADDR>"
      Alternatively, instead of using the current MAC address,
      spell the OUI part out. But again, that is not really the
      same as macchanger does because you explictly have to name
      the OUI part to use.

  `machanger --another`
  `machanger --another_any`
  -> "FF:FF:FF:00:00:00 <MAC_ADDR> <MAC_ADDR> ..."
     "$(printf "FF:FF:FF:00:00:00 %s\n" "$(sed -n 's/^\([0-9a-fA-F][0-9a-fA-F]\) \([0-9a-fA-F][0-9a-fA-F]\) \([0-9a-fA-F][0-9a-fA-F]\) .*/\1:\2:\3:00:00:00/p' /usr/share/macchanger/wireless.list | xargs)")"
2016-06-30 08:32:50 +02:00
Thomas Haller 3f3ea1df21 libnm: add NMSettingConnection:stable-id property
This new property be used as token to generate stable-ids instead
of the connection's UUID.

Later, this will be used by ipv6.addr-gen-mode=stable-privacy,
ethernet.cloned-mac-address=stable, and wifi.cloned-mac-address=stable
setting. Those generate stable addresses based on the connection's
UUID, but allow to use the stable-id instead.

This allows multiple connections to generate the same addresses
-- on the same machine, because in the above cases a machine
dependant key is also hashed.
2016-06-30 08:29:54 +02:00
Dan Williams fdf5b6941a libnm/libnm-glib: use Bluetooth device name as description (bgo #592819)
Abuse the 'name' property for this, for now, so we don't have to grab
a free slot from NMDeviceClass.

https://bugzilla.gnome.org/show_bug.cgi?id=592819
2016-06-21 10:35:53 -05:00
Thomas Haller 2c02f3a8cf shared/tests: build "nm-utils/nm-vpn-plugin-utils.c"
For testing, add a build target to build those files too.
2016-06-16 10:45:54 +02:00
Thomas Haller 4b288136e1 shared: move shared files to subdirectory "shared/nm-utils/"
The "shared" directory contains files that are possibly used by all components
of NetworkManager repository.

Some of these files are even copied as-is to other projects (VPN plugins, nm-applet)
and used there without modification. Move those files to a separate directory.
By moving them to a common directory, it is clearer that they belong
together. Also, you can easier compare the copied versions to their
original via

  $ diff -r ./shared/nm-utils/ /path/to/nm-vpn-plugin/shared/nm-utils/
2016-06-16 10:45:53 +02:00
Thomas Haller cf34211c90 libnm/vpn: add nm_vpn_editor_plugin_load_vt()
Let VPN plugins return a virtual function table to extend
the API while bypassing libnm. This allows to add and use
new functionality to VPN plugins without updating libnm.

The actual definitions are in a header-only file
"nm-vpn-editor-plugin-call.h", which can be copied to the
caller/plugin.
2016-06-15 15:01:12 +02:00
Thomas Haller 1c42375efb libnm/vpn: pass NMVpnPluginInfo to the NMVpnEditorPlugin instance
The NMVpnPluginInfo is essentially the .name file, that is, a
configuration file about the plugin itself. Via NMVpnPluginInfo
instance, the NMVpnEditorPlugin can be created.

Usually, one would create a NMVpnPluginInfo (that is, reading the
.name file) and then create a NMVpnEditorPlugin instance from there.
In this case, usually the editor-plugin is owned by the plugin-info
instance (although the API allows for creating the editor-plugin
independently).

Now, pass the  NMVpnPluginInfo to the editor-plugin too.
This is useful, because then the editor-plugin can look at the .name
file.

The .name file is not user configuration. Instead it is configuration
about the plugin itself. Although the .name file is part of the plugin
build artefacts, it is useful to allow the plugin to access the .name
file. The reason is, that this can allow the user to easily change a
configuration knob of the plugin without requiring to patch or the
plugin.
2016-06-15 10:32:32 +02:00
Thomas Haller 46665898bb libnm/vpn: add nm_vpn_plugin_info_list_find_service_name() function 2016-06-15 10:32:32 +02:00
Thomas Haller 10445bedb8 libnm/vpn: add nm_vpn_plugin_info_get_aliases 2016-06-15 10:32:32 +02:00
Thomas Haller ccc1be34ee libnm: backport symbols nm_setting_ip_config_get_dns_priority to libnm_1_2_4
Commit bdd0e7fec0 which added symbol
nm_setting_ip_config_get_dns_priority to libnm_1_4_0 was backported
to nm-1-2 in commit ad1cdcf657.

Add the backported symbol to master to allow seemless upgrading
from 1.2.4 to 1.4.0.
2016-06-10 11:37:39 +02:00
Beniamino Galvani 01540cf1d3 build: add options to compile with address/undefined sanitizers
This adds two new options to the configure scripts to compile NM,
clients and libraries with the address and undefined-behavior
sanitizers available in recent GCC versions. Clang is not supported at
moment.
2016-06-03 22:19:38 +02:00
Thomas Haller 8e54cfdb27 all: move NM_AUTH_PERMISSION_* defines to "nm-common-macros.h" header 2016-06-01 19:06:35 +02:00
Thomas Haller 1d0e0eeffd manager: add Reload() D-Bus command
Add new Reload D-Bus command to reload NetworkManager configuration.

For now, this is like sending SIGHUP to the process. There are several
advantages here:

  - it is guarded via PolicyKit authentication while signals
    can only be sent by root.

  - the user can wait for the reload to be complete instead of sending
    an asynchronous signal. For now, we operation completes after
    nm_config_reload() returns, but later we could delay the response
    further until specific parts are fully reloaded.

  - SIGHUP reloads everything including re-reading configuration from
    disk while SIGUSR1 reloads just certain parts such as writing out DNS
    configuration anew.
    Now, the Reload command has a flags argument which is more granular
    in selecting parts which are to be reloaded. For example, via
    signals the user can:

      1) send SIGUSR1: this writes out the DNS configuration to
         resolv.conf and possibly reloads other parts without
         re-reading configuration and without restarting the DNS plugin.
      2) send SIGHUP: this reloads configuration from disk,
         writes out resolv.conf and restarts the DNS plugin.

    There is no way, to only restart the DNS plugin without also reloading
    everything else.
2016-06-01 19:06:34 +02:00
Thomas Haller 8913585397 libnm: implement missing NM_AUTH_PERMISSION_SETTINGS_MODIFY_GLOBAL_DNS 2016-06-01 19:06:34 +02:00
Beniamino Galvani f97ffea82e libnm: export nm_setting_ip6_config_get_token() symbol
Fixes: 954d937b2f
2016-05-30 18:27:21 +02:00
Beniamino Galvani 3c649e6429 team: expose current device configuration through D-Bus and nmcli
Add a new "Config" property to the D-Bus interface for team devices
and show its value through "nmcli device show". The property contains
the full JSON configuration from teamd for the device.

https://bugzilla.redhat.com/show_bug.cgi?id=1310435
2016-05-26 09:16:46 +02:00
Beniamino Galvani bdd0e7fec0 libnm-core: add dns-priority to NMSettingIPConfig 2016-05-12 17:13:50 +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 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
Lubomir Rintel 843a05f7cc libnm/vpn-service-plugin: don't register a bus name before creating the VPN object
Otherwise NetworkManager can be too fast calling a method:

  <error> [1461073999.2362] vpn-connection[0x7fe39ec491e0,be049803-a705-438f-b8f5-49db87640c93,"libreswan",0]:
  plugin NeedSecrets request #1 failed: No such interface 'org.freedesktop.NetworkManager.VPN.Plugin'
  on object at path /org/freedesktop/NetworkManager/VPN/Plugin
2016-04-20 10:50:08 +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 d0ed5f83ce libnm: use <> to include in public header
In a public header file ("nm-vpn-editor.h"), other public headers
from NetworkManager must be included with <nm-vpn-editor-plugin.h>
and not quotes.
2016-04-13 19:20:52 +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
Beniamino Galvani 5f7d7ee497 libnm,libnm-core: add coverage support 2016-03-29 18:10:04 +02:00
Lubomir Rintel 0684632936 libnm: don't check if the agent is still registered when unregistering
The name_owner_chagned() unregisters the agent if NetworkManager goes away and
nmc_cleanup() also tries to unregister an agent, resulting in an assertion
failure:

  # nmcli c up conn666
  <daemon terminates>
  Error: Connection activation failed: Message recipient disconnected from message bus without replying
  (process:8746): libnm-CRITICAL **: nm_secret_agent_old_unregister: assertion 'priv->registered == TRUE' failed

_internal_unregister() already contains a priv->registered check and raising an
error on duplicate unregister attempt from a daemon after a restart is not a
problem either, since nmc_cleanup() doesn't care about the error returned
on teardown anyway.
2016-03-29 15:08:19 +02:00
Thomas Haller 52bd08de05 libnm: add code comments to hint that NMConnection might not validate 2016-03-29 11:56:27 +02:00
Thomas Haller 4aa7e09d1f libnm: be more accepting for invalid connections from NetworkManager
Relax our error checking which will allow us to try harder to
make the best out of whatever NetworkManager sends us.

Also, drop the g_warning(). First, now we really don't expect this
function to fail. And even in that case, raising a g_warning() from
the library is not very friendly to the user of libnm.
2016-03-26 12:10:54 +01:00
Thomas Haller 559ab7bd7c libnm: accept invalid connections in NMVpnServicePlugin
When we receive a connection from NetworkManager it is not guaranteed
that the connection verifies. For example, if the current libnm version
is older then the NetworkManager version.

Be more accepting and don't do any verification of the connection.

For NMVpnPluginOld this change is uncritical, because there are probably
no users of this API anyway.

NMVpnServicePlugin is new API since nm-1-1. However, this API is already
strongly used by all the plugins we ported over. So this change is
affecting them.
This should only matter if libnm's and NetworkManager's version differ,
because NetworkManager just doesn't send out an invalid connection. It
actually only matters if NetworkManager is a newer version and sends an
invalid connection to the client. That is anyway badly tested and probably
this changes rather improves compatibility than breaking existing users.
2016-03-26 12:10:54 +01:00
Thomas Haller 9a31bbcbc3 libnm: accept invalid connections in NMSecretAgentOld
When we receive a connection from NetworkManager it is not guaranteed
that the connection verifies. For example, if the current libnm version
is older then the NetworkManager version.

Be more accepting and don't do any verification of the connection.

This is a change in behavior in that we accept also invalid connections
and pass them down to the sub-classes.
2016-03-26 12:10:54 +01:00
Thomas Haller a37c1d1e17 libnm: don't normalize connection for nm_device_get_applied_connection()
Normalizing means that we fail on invalid connections.
Which can happen when the server is newer than the libnm
version. We just want to return whatever we can. The
caller should make sense of this.

This makes libnm more accepting and thus is not going to break
existing applications. Also, nm_device_get_applied_connection()
is new API since nm-1-1.
2016-03-26 12:10:54 +01:00
Thomas Haller c5786f3839 libnm/tests: extend tests for handling invalid connections in NMClient 2016-03-26 12:10:53 +01:00
Lubomir Rintel 84c42aac1b test-nm-client: fix the remaining counter
We're expecting four callbacks: a client::devices change,
client::active-connections change, client::activate callback,
and a device::active-connection change.

We only hook the second one in the callback to the first one, and
only if client::active-connections is not set already. If it is
(when running slowly in valgrind), we just decrement the counter.

However, as the counter is one less than it should be, it would
underflow and we wait forever* instead.

For the value of forever=20s, given that's the timeout of the
mockup service.
2016-03-17 17:37:06 +01:00
Thomas Haller 2778d257cc libnm: declare internal function as static 2016-03-17 11:32:53 +01:00
Beniamino Galvani 64b76ba906 libnm-core: add domain-suffix-match properties to NMSetting8021x
The new domain-suffix-match and phase2-domain-suffix-match properties
can be used to match against a given server domain suffix in the
dNSName elements or in the SubjectName CN of the server certificate.

Also, add a comment to the old subject-match properties documentation
to suggest that they are deprecated and should not be used anymore.
2016-03-16 17:32:17 +01:00
Lubomir Rintel ad8251e3a4 nm-object: delay object property completion until the objects are initialized
We don't want to update the properties until the objects referred are complete.
Otherwise the clients get confused. Very confused:

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

We already delay the notification signals. Let's replace that with delaying the
actual ObjectCreatedData processing instead.
2016-03-14 16:32:44 +01:00
Lubomir Rintel bb35883235 nm-object: don't leak the properties on changed signals
https://bugzilla.redhat.com/show_bug.cgi?id=1314976
2016-03-08 16:02:27 +01:00
Thomas Haller e4af0f6767 libnm: fix clearing real-devices in NMManager's free_devices()
Found by coverity.
2016-03-04 08:56:38 +01:00
Thomas Haller cd4f84b738 all: don't include error->code in log messages
GError codes are only unique per domain, so logging the code without
also indicating the domain is not helpful. And anyway, if the error
messages are not distinctive enough to tell the whole story then we
should fix the error messages.

Based-on-patch-by: Dan Winship <danw@gnome.org>
2016-03-03 18:54:20 +01:00
Thomas Haller 01b9b4104c all: clean-up usage of GError
Functions that take a GError** MUST fill it in on error. There is no
need to check whether error is NULL if the function it was passed to
had a failing return value.

Likewise, a proper GError must have a non-NULL message, so there's no
need to double-check that either.

Based-on-patch-by: Dan Winship <danw@gnome.org>
2016-03-03 18:54:20 +01:00
Dan Williams abc700c5c7 libnm-glib/libnm/vpn: fix handling of ConnectInteractive() failure (rh #1298732)
If the plugin supports interactive mode, but the VPN binary (like vpnc
or openvpn) doesn't support it, then the plugin should return
NM_VPN_PLUGIN_ERROR_INTERACTIVE_NOT_SUPPORTED from its connect_interactive()
hook.  This lets NetworkManager know to fall back to plain Connect().

Since this notification is done through an error return, the VPN service
plugin code sees the failure and moves the plugin state back to
STOPPED.  NetworkManager sees that state change, and terminates the
connection attempt while waiting for a reply to the Connect() method.

(VPN service plugins that don't support interactive mode at all don't
have this problem because that error is returned before the plugin's
state is moved to STARTING.)

To fix this, do two things:

1) if the connect_interactive() hook fails and returns the error
NM_VPN_PLUGIN_ERROR_INTERACTIVE_NOT_SUPPORTED, postpone the STOPPED
state change for a few seconds to allow NM time to fall back to
plain Connect().  We still want to move the plugin state back to
STOPPED eventually, because otherwise it could stay in STARTING
forever.

2) change state to STARTING only if the connect/connect_interactive
plugin hooks were successful.  Otherwise the plugin would still be
in STARTING state, and it's not valid to call Connect()/ConnectInteractive()
during the STARTING state.

https://mail.gnome.org/archives/networkmanager-list/2016-February/msg00091.html
https://bugzilla.redhat.com/show_bug.cgi?id=1298732
2016-03-02 11:27:17 +01:00
Beniamino Galvani 22b3494de6 libnm,core: fix syntax of 'transfer' annotation 2016-02-24 17:23:01 +01:00
Thomas Haller 1b00009169 device: add new NMDeviceType NM_DEVICE_TYPE_VETH
Based-on-patch-by: Jiří Klimeš <jklimes@redhat.com>
2016-02-23 23:15:37 +01:00
Thomas Haller 26718e989e libnm: add missing device types to get_type_name() 2016-02-23 23:15:37 +01:00
Thomas Haller 8bace23beb all: cleanup includes and let "nm-default.h" include "config.h"
- All internal source files (except "examples", which are not internal)
  should include "config.h" first. As also all internal source
  files should include "nm-default.h", let "config.h" be included
  by "nm-default.h" and include "nm-default.h" as first in every
  source file.
  We already wanted to include "nm-default.h" before other headers
  because it might contains some fixes (like "nm-glib.h" compatibility)
  that is required first.

- After including "nm-default.h", we optinally allow for including the
  corresponding header file for the source file at hand. The idea
  is to ensure that each header file is self contained.

- Don't include "config.h" or "nm-default.h" in any header file
  (except "nm-sd-adapt.h"). Public headers anyway must not include
  these headers, and internal headers are never included after
  "nm-default.h", as of the first previous point.

- Include all internal headers with quotes instead of angle brackets.
  In practice it doesn't matter, because in our public headers we must
  include other headers with angle brackets. As we use our public
  headers also to compile our interal source files, effectively the
  result must be the same. Still do it for consistency.

- Except for <config.h> itself. Include it with angle brackets as suggested by
  https://www.gnu.org/software/autoconf/manual/autoconf.html#Configuration-Headers
2016-02-19 17:53:25 +01:00
Beniamino Galvani 206e074863 libnm,core,cli: move dhcp-timeout property to generic NMSettingIPConfig
The property applies to both IPv4 and IPv6 and so it should not be in
NMSettingIP4Config but in the base class.
2016-02-16 11:37:26 +01:00
Thomas Haller 54dc789314 device: fix signature for @flags argument of impl_device_reapply()
Thereby, also adjust the type for libnm's wrapper function -- as
we already broke ABI.
2016-02-16 11:24:49 +01:00
Thomas Haller 4bd45b9458 libnm: add nm_device_get_applied_connection() function 2016-02-16 11:24:49 +01:00
Thomas Haller 6898e2169e all: add version-id argument to device's Reapply method
This breaks API and ABI for the functions related to Reapply,
which got introduced in the current 1.1 development phase.

The version-id is here to allow users to error out if the connection
on the device was changed by a concurrent action.

https://bugzilla.gnome.org/show_bug.cgi?id=761714
2016-02-16 11:24:49 +01:00
Beniamino Galvani 10b222288e wifi: don't touch by default current powersave setting
Some drivers (or things outside NM like 'powertop') may turn powersave
on, so don't touch it unless explicitly configured by user.

To achieve this, add new 'default' and 'ignore' options; the former
can be used to fall back to a globally configured setting, while the
latter tells NM not to touch the current setting.

When 'default' is specified, a missing global default configuration is
equivalent to 'ignore'.

It is possible to enable Wi-Fi power saving for all connections by
dropping a file in /etc/NetworkManager/conf.d with the following
content:

 [connection]
 wifi.powersave=3

https://bugzilla.gnome.org/show_bug.cgi?id=760125
2016-02-16 00:18:06 +01:00
Thomas Haller 2c2d9d2e4c build: cleanup default includes
- "gsystem-local-alloc.h" and <gio/gio.h> are already included via
  "nm-default.h". No need to include them separately.

- include "nm-macros-internal.h" via "nm-default.h" and drop all
  explict includes.

- in the modified files, ensure that we always include "config.h"
  and "nm-default.h" first. As second, include the header file
  for the current source file (if applicable). Then follow external
  includes and finally internal nm includes.

- include nm headers inside source code files with quotes

- internal header files don't need to include default headers.
  They can savely assume that "nm-default.h" is already included
  and with it glib, nm-glib.h, nm-macros-internal.h, etc.
2016-02-12 15:36:01 +01:00
Lubomir Rintel 061edeaea6 vpn-service-plugin: allow VPNs with no IP configuration
Perfectly fine for ethernet-bridged networks (openvpn with tap devices).
2016-01-28 11:50:15 +01:00
Thomas Haller fc7c333d84 libnm: include "nm-vpn-service-plugin.h" in "NetworkManager.h"
"nm-vpn-service-plugin.h" includes "nm-connection.h", so there is already no
way to use "nm-vpn-service-plugin.h" without also pulling in all "NetworkManager.h".

On the other hand, we might not include "nm-vpn-service-plugin.h" in
"NetworkManager.h" to keep the overall headers small (by default).
But let's just include it too. We already opted for convenience
over small-include by having one top-level header file.
2016-01-27 17:20:09 +01:00
Thomas Haller 5170d3a760 tests: move common dbus test-runners to tools/ directory 2016-01-22 16:52:41 +01:00
Michael Biebl a9bd5dce1c tests: use dbus-run-session instead of dbus-launch
The dbus-run-session utility was designed to run a process within a
D-Bus session, specifically for running regressions tests and is much
better suited then dbus-launch. As an additional benefit, this avoids
any X dependencies.

https://mail.gnome.org/archives/networkmanager-list/2016-January/msg00023.html
2016-01-22 16:52:41 +01:00
Dan Williams 3254965067 libnm,tests: fix error leak 2016-01-21 11:31:31 -06:00
Dan Williams ec1185d6dd libnm: remove erroneous nm_manager_get_all_devices()
None of the libnm NMManager functions are exported, as they are only
used internally.

Fixes: 4db851f852
2016-01-20 12:27:05 -06:00
Dan Williams 3b3f108dfd docs, trivial: fix some documentation issues 2016-01-20 11:27:22 -06:00
Dan Williams d59c1d4c8a libnm,vpn: restore export of deprecated NMVpnPluginOld symbols
Deprecated of course, but shouldn't have been removed from the ABI.

Fixes: 867227dd4a
2016-01-20 11:26:49 -06:00
Jiří Klimeš 31ea5a99cb libnm: add NMSettingIPConfig 'dad-timeout' property
The property is used to control duplicate address detection:
 * -1 means default value
 * 0 means no DAD is performed
 * > 0 means timeout (in milliseconds) for arping responses

[bgalvani: moved setting from NMSettingIP4Config]
2016-01-20 11:53:47 +01:00
Beniamino Galvani 9b94d33232 libnm: add versioning comments and macros to nm_device_reapply*()
Fixes: 278fd4fb0f
2016-01-12 09:51:44 +01:00
Beniamino Galvani 59dc2eb29a libnm: keep symbols sorted in libnm.ver 2016-01-12 09:51:41 +01:00
Lubomir Rintel 278fd4fb0f libnm: add nm_device_reapply()
Client support for O.FD.NM.Device.Reapply().
2016-01-10 23:13:34 +01:00
Beniamino Galvani fbd3286955 core,libnm: use nm_clear_g_source() where possible
Replacement was done with commands:

spatch --sp-file nm_clear_g_source.cocci --in-place --smpl-spacing --dir src
spatch --sp-file nm_clear_g_source.cocci --in-place --smpl-spacing --dir libnm

where nm_clear_g_source.cocci contains:

@@
expression e;
@@
- if (e) {
-    g_source_remove (e);
-    e = 0;
- }
+ nm_clear_g_source (&e);
2016-01-06 21:25:55 +01:00
Thomas Haller 92f122525d libnm/tests: add tests for libnm handling invalid connections
Add test showing how libnm/libnm-glib handles invalid connections,
i.e. connections that fail nm_connection_verify(). libnm implements
settings a static types (via different NMSetting types). This makes
it unavoidable that eventually a newer server version will
expose connections that fail verification in the client.

For example, master added a new base type NMSettingTun. This setting type
was not backported to legacy libnm-glib, thus such connection will not verify.
Also, we want that newer server versions are backward compatible with older
library versions. Thus also a pre-NMSettingTun libnm version has the same
problem.

The test shows that libnm is agnostic to whether the connection verifies.
That is consistent behavior, but possibly problematic because most
accessors to connections assert against a valid connection. Thus using
the common nm_connection*() functions on an invalid connection can lead
to problems.
Also, due to the static nature of our NMSetting types, some properties
can be silently dropped and thus mangling the connection without the
library user noticing.

libnm-glib prints a g_warning() whenever parsing an invalid connection.
When an invalid connection is added initially, it is exposed to the library
user. When a connection gets later invalidated due to an update, the
connection disappears and it stays missing even if a subsequent update
makes the connection valid again.

libnm-glib's behavior indicates that we might wanted to hide invalid
connections from the user. But it's very broken there.
2015-12-26 19:09:11 +01:00
Thomas Haller db80ec05ab build: rename directory "include" to "shared"
Up to now, the "include" directory contained (only) header files that were
used project-wide by libs, core, clients, et al.

Since the directory now also contains a non-header file, the "include"
name is misleading. Instead of adding yet another directory that is
project-wide, with non-header-only content, rename the "include"
directory to "shared".
2015-12-24 11:42:37 +01:00
Thomas Haller bc06dd9332 libnm/tests: rename test functions to follow common pattern
Like the test utility functions in nm-test-utils.h and
platform's common.h, rename the helper functions to have
a nmtst(c) prefix.
2015-12-24 11:42:37 +01:00
Thomas Haller fa3093e167 libnm/tests: move common testing code to nm-test-libnm-utils
The unit tests for libnm and libnm-glib use a NetworkManager stub
service written in Python (test-networkmanager-service.py). As they
share the same server, it makes sense to also share the same utility
code to drive the stub.

Move the common code to include/.

Note that contrary to "nm-test-utils.h", "nm-test-libnm-utils.h" is not
a header-only file. Instead its implementation is in "nm-test-utils-impl.c".
The reason for that this split is, if we later have yet another non-header-only
test-utility, then all the implementations are in "nm-test-utils-impl.c", requiring
the tests to link only one object file.
2015-12-24 11:42:37 +01:00
Thomas Haller 70713ee197 libnm/tests: unify common test code for libnm and libnm-glib
Unify the common test code to drive the D-Bus stub service
test-networkmanager-service.py. They will be merged in the next
commit.
2015-12-24 11:42:36 +01:00
Beniamino Galvani 1ff712d5d0 ip-tunnel: add a MTU property
Add a new ip-tunnel.mtu property which can be used to change the MTU
of the tunnel interface.
2015-12-19 12:06:33 +01:00
Beniamino Galvani d6a0b2c28f libnm: add NMDeviceVxlan 2015-12-09 16:36:46 +01:00
Beniamino Galvani 95dfd99afc libnm-core: add NMSettingVxlan
Add a new NMSettingVxlan which describes properties of VXLAN
connections.
2015-12-09 16:36:46 +01:00
Beniamino Galvani f841f17882 libnm: add NMDeviceMacvlan 2015-12-09 14:30:08 +01:00
Beniamino Galvani 4d0192e661 libnm-core: add NMSettingMacvlan
The setting contains properties that are specific to macvlans and
macvtaps.
2015-12-09 14:30:08 +01:00
Jiří Klimeš 20e750a3c3 libnm: fix description of NMDeviceIPTunnel:input-key property
Fixes: e2da055f90
2015-12-09 13:33:17 +01:00
Jiří Klimeš 1a48e5d918 libnm: fix indenting in libnm/nm-device-ip-tunnel.c
Fixes: e2da055f90
2015-12-09 13:29:02 +01:00
Lubomir Rintel 08fe8392c7 libnm,device: don't notify of property change when getting vendor & product from udev
I have no idea what was the purpose, however this causes an infinite loop if
udev has not product & vendor and the notify handler gets the property.
2015-12-05 12:05:17 +01:00
Lubomir Rintel 45c5e7626a libnm,nm-object: only send "notify" signal when the object property actually changed 2015-12-05 12:05:17 +01:00
Dan Williams 4db851f852 libnm/libnm-glib: add NMClient.get_all_devices() method and AllDevices property
Mirror new NetworkManager API to return both real devices and
device placeholders.
2015-12-04 12:16:41 +01:00
Dan Williams deb6c5f714 libnm-glib/libnm: add support for "real" NMDevice property 2015-12-04 12:15:12 +01:00
Beniamino Galvani e2da055f90 libnm: add NMDeviceIPTunnel 2015-12-01 17:39:41 +01:00
Beniamino Galvani ae8c7a8967 libnm-core: add NMSettingIPTunnel
Add a generic NMSettingTunnel which describes properties of tunnels
over IPv4 and IPv6 (GRE, SIT, IPIP, IPIP6, IP6GRE, etc.). Since those
tunnel types all have similar properties it makes sense to have a
single setting type for them.
2015-12-01 17:39:40 +01:00
Beniamino Galvani 13a981fc38 libnm-core: add nm_utils_enum_get_values()
Add function nm_utils_enum_get_values() which returns a string array
containing the enum values. It can be used, for example, to build a
list of allowed values for user.
2015-12-01 17:39:40 +01:00
Lubomir Rintel 604711488d libnm: avoid loosing signals
D-Bus has an upper limit on number of Match rules and it's rather easy
to hit as the proxy likes to add one for each object. Let's remove the Match
rule the proxy added and ensure a less granular rule is present instead.

Ideally, we should be able to tell glib not to hook its rules.
Related: https://bugzilla.gnome.org/show_bug.cgi?id=758749

https://bugzilla.gnome.org/show_bug.cgi?id=758751
2015-12-01 14:51:13 +01:00
Beniamino Galvani 337304f19d libnm: add NMDeviceTun 2015-11-25 11:39:57 +01:00
Beniamino Galvani 1f30147a7a libnm-core: add NMSettingTun
Add a new NMSettingTun which contains configuration properties for TUN/TAP
interfaces.
2015-11-25 11:39:57 +01:00
Beniamino Galvani cb40194532 libnm-core: add a 'dhcp-fqdn' property to NMSettingIP4Config
The property contains the fully qualified domain name to be sent to
DHCP server using the FQDN option. The property is mutually exclusive
with 'dhcp-hostname'.
2015-11-23 16:31:52 +01:00
Jiří Klimeš b41b32cb7b libnm: add nm_setting_verify_secrets() and nm_connection_verify_secrets()
for verifying the secrets, because it is not done in plain nm_setting_verify().

For simple verification of free-form string secrets,
_nm_setting_verify_secret_string() helper is used.
2015-11-20 10:35:10 +01:00
Dan Williams 4b412218e6 libnm/wwan: add GSM setting device-id, sim-id, and sim-operator-id properties
These properties limit whether the connection applies to a certain WWAN modem
based on the modem's device ID or SIM ID (as reported by the WWAN management
service), or through the MCC/MNC ID of the operator that issued the SIM card.
2015-11-18 15:50:52 +01:00
Dan Williams 0222822134 libnm: add Wi-Fi MAC address randomization property 2015-11-18 15:37:42 +01:00
Lubomir Rintel 2146c60996 libnm: stop using the private socket 2015-11-18 15:15:04 +01:00
Lubomir Rintel 42ee2e6792 vpn-service-plugin: correctly emit ip6-config signal on dbus skeleton 2015-11-13 16:13:40 +01:00
Thomas Haller 8d1233e67e python: use gi.require_version() in generate-setting-docs.py and examples
gi now emits a warning when not loading a specific library
version [1]:

  ./generate-setting-docs.py:21: PyGIWarning: NM was imported without specifying a version first. Use gi.require_version(NM, 1.0) before import to ensure that the right version gets loaded.
    from gi.repository import NM, GObject

Seems require_version() is reasonably old to just always use it without
breaking on older versions [2].

[1] Related: https://bugzilla.gnome.org/show_bug.cgi?id=727379
[2] https://git.gnome.org/browse/pygobject/commit/?id=76758efb6579752237a0dc4d56cf9518de6c6e55
2015-11-11 10:56:05 +01:00
Lubomir Rintel 60811b4809 setting-ip6-config: add addr-gen-mode property 2015-11-02 20:27:00 +01:00
Lubomir Rintel 3517084b92 vpn-plugin-info: drop nm_vpn_plugin_info_get_service()
It is not used externally and its use might be confusing and undesired when we
add plugin aliases. The external users should only use the name when idenfiying
the plugin and nm_vpn_plugin_info_list_find_by_service() when matchin the plugin.
2015-11-02 16:01:21 +01:00
Thomas Haller 204fcd33d8 macros: add nm_clear_g_cancellable() utility 2015-11-01 17:28:07 +01:00
Lubomir Rintel a5feb44a44 libnm,vpn-service-plugin: remove old connect timer when adding new one
If the plugin didn't succeed connecting once, don't let the old timer fire
during a subsequent connection.

https://bugzilla.redhat.com/show_bug.cgi?id=1271973
2015-10-23 18:24:45 +02:00
Beniamino Galvani 2f780dc1b5 libnm: define NMLldpNeighbor as boxed type
GLib introspection requires all types returned by public functions to
be GObjects, basic types or boxed types in order to correctly manage
resources. NMLldpNeighbor was a plain struct and GI complained with:

Warning: NM: nm_lldp_neighbor_new: return value: Invalid non-constant return of bare structure or union; register as boxed type or (skip)

To fix this define NMLldpNeighbor as a boxed type.

Fixes: d3d2b49400
2015-10-16 17:33:12 +02:00
Beniamino Galvani 1136de4221 libnm,libnm-core: fix GTK-Doc warnings 2015-10-16 17:33:12 +02:00
Lubomir Rintel 700061f270 libnm/vpn-service-plugin: leave the state property in place
It's part of the DBus API; the skeleton has it and we can't remove it.

This partially reverts commit fd61b21706.
2015-10-14 18:44:57 +02:00
Lubomir Rintel fd61b21706 libnm/vpn-service-plugin: remove nm_vpn_service_plugin_{get,set}_state()
The plugins set state only on failures and often forget to do that. Do the
correct status transition to STOPPED in nm_vpn_service_plugin_failure() instead.

The get_state() is only used to find out whether to fail or orderly disconnect
depending on whether we're STARTING or already STARTED. Handle that in
nm_vpn_service_plugin_disconnect() in a generic manner instead.
2015-10-13 18:20:55 +02:00
Lubomir Rintel 78f263a5fd libnm/vpn-service-plugin: quit when the peer we watch disconnects
We're of no use anymore as another user would start an instance with
a different bus name.
2015-10-13 18:20:55 +02:00
Lubomir Rintel 9f15abbda7 libnm/vpn-service-plugin: add watch-peer property
Make it possible to construct the plugin instance in a way that disconnects the
connection if the DBus client that activated it drops off the bus. This makes the
plugins conveniently clean up when NetworkManager crashes.

We need this, as with multiple VPN support we can loose track of the client bus
names when the daemon crashes leaving to nice way to clean up on respawn.

However, this behavior is not desired for debugging or hypotetical VPN plugin
users other than NetworkManager (say; "gdbus call -m o.fd.NM.VPN.Plugin.Connect").
Let the plugin decide when to use it.
2015-10-13 18:20:55 +02:00
Lubomir Rintel 1bb553798c libnm/vpn-service-plugin: add a missing return 2015-10-13 18:20:55 +02:00
Beniamino Galvani 83ac84cd7a libnm: document that some return values are immutable
Document that the GPtrArray returned by

  - nm_device_get_lldp_neighbors()
  - nm_ip_config_get_addresses()
  - nm_ip_config_get_routes()

is immutable and can be used by callers without the need of a copy.
2015-10-12 14:44:31 +02:00
Beniamino Galvani d3d2b49400 libnm: add LLDP support
Add functions to libnm for retrieving a list of LLDP neighbors and
accessor functions to get their attributes.
2015-10-12 14:44:31 +02:00
Beniamino Galvani c364ef0b97 libnm: add 'lldp' property to NMSettingConnection
Add the 'lldp' property to NMSettingConnection, which specifies
whether the reception and parsing of LLDP frames to discover neighbor
devices should be enabled.
2015-10-12 14:44:19 +02:00
Lubomir Rintel 3f0d595cc8 libnm,ip4-config: add ipv4.dhcp-timeout property
This is intentionally IPv4 specific since this is used for a quick fallback to
method=link-local -- something that's not needed for IPv6 since the link local
address is always there.

https://bugzilla.redhat.com/show_bug.cgi?id=1262922
2015-10-06 14:16:55 +02:00
Lubomir Rintel 8c9b791768 libnm: avoid notifying for objects until they're async-inited
Otherwise the uninitializeded objects could be prematurely signalled if their
paths are seen twice in quick succession. This happens when you have ethernet
hardware and add an ethernet connection -- it's immediatelly added to
AvialableConnections and the property reload signals the object addition
before the NMRemoteSettings's GetSettings() finishes:

  # nmcli c add type ethernet autoconnect no ifname '*'
  (process:4610): libnm-CRITICAL **: nm_connection_get_id: assertion 's_con != NULL' failed
  Connection '(null)' ((null)) successfully added.
  #

https://bugzilla.gnome.org/show_bug.cgi?id=754794
2015-10-06 14:10:55 +02:00
Lubomir Rintel 4691101517 Revert "libnm: fix initializing of new connections"
This reverts commit d20bed069c.
2015-10-06 14:10:32 +02:00
Thomas Haller 6b40108418 libnm: use nm_clear_g_source() in nm-object.c 2015-10-03 18:12:11 +02:00
Lubomir Rintel b1512221bc nm-vpn-service-plugin: increase the quit timer
We now (since 3272ff6 libnm/libnm-glib: don't quit in the middle of asking for
secrets) always hook on the quit timer when NM asks the plugin if it needs
secrets. The timer is 20 seconds, which seems too short.

Let's make it three minutes. Don't bother adding another timer or using a
distinct timeout: it does no harm for the plugin to remain unused for three
minutes on a bus.

Another option would be to completely unhook it; however the plugin wouldn't
learn if the user cancelled the NM's secrets request and would remain unused
on the bus forever.
2015-10-01 17:17:52 +02:00
Thomas Haller 7bf10a75db build: extract version macros from "nm-version.h" to new header file "nm-version-macros.h"
For libnm library, "nm-dbus-interface.h" contains defines like the D-Bus
paths of NetworkManager. It is desirable to have this header usable without
having a dependency on "glib.h", for example for a QT application. For that,
commit c0852964a8 removed that dependancy.

For libnm-glib library, the analog to "nm-dbus-interface.h" is
"NetworkManager.h", and the same applies there. Commit
159e827a72 removed that include.
However, that broke build on PackageKit [1] which expected to get the
version macros by including "NetworkManager.h". So at least for libnm-glib,
we need to preserve old behavior so that a user including
"NetworkManager.h" gets the version macros, but not "glib.h".

Extract the version macros to a new header file "nm-version-macros.h".
This header doesn't include "glib.h" and can be included from
"NetworkManager.h". This gives as previous behavior and a glib-free
include.

For libnm we still don't include "nm-version-macros.h" to "nm-dbus-interface.h".
Very few users will actually need the version macros, but not using
libnm.
Users that use libnm, should just include (libnm's) "NetworkManager.h" to
get all headers.
As a special case, a user who doesn't want to use glib/libnm, but still
needs both "nm-dbus-interface.h" and "nm-version-macros.h", can include
them both separately.

[1] https://github.com/hughsie/PackageKit/issues/85

Fixes: 4545a7fe96
2015-09-30 23:10:29 +02:00
Jiří Klimeš 82e4364480 tests: add a test for connection_compatible() for wired devices
Allow setting MAC address and S390 subchannels for ethernet devices in
testing NM service.
2015-09-29 09:31:41 +02:00
Jiří Klimeš 9abe74d98e libnm: match s390 subchannels and MAC blacklist in connection_compatible()
Basically, make it the same as check_connection_compatible()
in src/devices/nm-device-ethernet.c
2015-09-29 09:31:25 +02:00
Jiří Klimeš bbaca1b24e libnm: add 390-subchannels property to NMDeviceEthernet 2015-09-29 09:31:25 +02:00
Jiří Klimeš ffe16c958f libnm-core: add vpn.timeout property for establishing connections
[1] https://mail.gnome.org/archives/networkmanager-list/2015-April/msg00007.html
2015-09-21 16:59:04 +02:00
Thomas Haller 31deca0157 libnm: fix missing case in "nm-remote-connection.c"
Fixes: d20bed069c
2015-09-18 16:11:47 +02:00
Jiří Klimeš d20bed069c libnm: fix initializing of new connections
connection_added() can be called before init_get_settings_cb(), and we can't
complete the connection until it is visible, else it would be uninitialized.

Test case:
* have 'em1' interface
$ nmcli con add type ethernet con-name myeth ifname em1 autoconnect no
(process:9039): libnm-CRITICAL **: nm_connection_get_id: assertion 's_con != NULL' failed
Connection '(null)' ((null)) successfully added.

$ nmcli con add type ethernet con-name myeth ifname em1X autoconnect no
Connection 'myeth' (71159504-c2af-4773-8ca9-a3626aa0da33) successfully added.

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

[lkundrak@v3.sk: This is not quite the correct fix, we shouldn't emit
NMObject:connection-added for an unfinished object. Nevertheless, let's go with
it until we have a better one. Will revert this afterwards. See linked bugs.]
2015-09-18 15:54:39 +02:00
Lubomir Rintel b2fa116486 libnm,libnm-glib: add Device.Managed setter 2015-09-18 13:14:23 +02:00
Thomas Haller 0e5af7fa46 Revert "libnm: don't add objects to cache until they're async-inited"
Reverting, because patch breaks tests for "libnm/tests".

This reverts commit 88f0d646d5.
2015-09-15 23:11:47 +02:00
Lubomir Rintel 88f0d646d5 libnm: don't add objects to cache until they're async-inited
Otherwise the uninitializeded objects could be prematurely signalled if their
paths are seen twice in quick succession. This happens when you have ethernet
hardware and add an ethernet connection -- it's immediatelly added to
AvialableConnections and the property reload signals the object addition
before the NMRemoteSettings's GetSettings() finishes:

  # nmcli c add type ethernet autoconnect no ifname '*'
  (process:4610): libnm-CRITICAL **: nm_connection_get_id: assertion 's_con != NULL' failed
  Connection '(null)' ((null)) successfully added.
  #

https://bugzilla.gnome.org/show_bug.cgi?id=754794
2015-09-15 16:53:26 +02:00
Thomas Haller 803fc616fd libnm: properly handle floating references in nm_vpn_service_plugin_set_ip6_config() 2015-08-25 18:53:39 +02:00
Lubomir Rintel b823a6b533 libnm: export nm_vpn_service_plugin_set_{ip6_,}config
Seems to be forgotten.
2015-08-25 18:21:36 +02:00
Beniamino Galvani 0bc335cfbe libnm: backport NMSettingWired Wake-on-LAN symbols to 1.0.6
Backport to 1.0.6 the following symbols:

  - nm_setting_wired_get_wake_on_lan
  - nm_setting_wired_get_wake_on_lan_password
  - nm_setting_wired_wake_on_lan_get_type

added to 1.0.6 with commit d449d82304
2015-08-25 10:23:57 +02:00
Beniamino Galvani 0969d16ad8 libnm: backport enum conversion utilities to 1.0.6
Backport to 1.0.6 the following symbols:

  - nm_utils_enum_from_str
  - nm_utils_enum_to_str

added to 1.0.6 with commit f4ce6760e0
2015-08-25 10:23:57 +02:00
Thomas Haller b2a66d59c8 Revert "all: change "Since: 1.2" to "Since: 1.0.4"/"Since: 1.0.6" for backported API"
API should be added with "Since:" of the next release on the same branch.
That means, new API on 1.1 branch (development), should be "Since: 1.2"
and new API on 1.0 branch (stable) will be "Since: 1.0.x". Similarly, new
API on master is NM_AVAILABLE_IN_1_2 and will be added with the linker
version libnl_1_2 -- never the versions of minor releases.

It is also strongly advised that for the 1.0 branch, we only add API
that was previously formerly added on master. IOW, that we only do true
backports of API that already exists on master.

API that gets backported, must also be added to master via NM_BACKPORT_SYMBOL().
That gives ABI compatibility and an application that was build against 1.0.x
will work with 1.y.z version (y > 0) without need for recompiling -- provided
that 1.y.z also contains that API.

There is one important caveat: if a major branch (e.g. current master) has a
linker section of backported APIs (e.g. libnm_1_0_6), we must do the minor release
(1.0.6) before the next major release (1.2). The reason is that after the major
release, the linker section (libnm_1_0_6) must not be extended and thus
the minor release (1.0.6) must be already released at that point.

In general, users should avoid using backported API because it limits
the ability to upgrade to arbitrary later versions. But together with the
previous point (that we only backport API to minor releases), a user that
uses backported API can be sure that a 1.y.z version is ABI compatible with
1.0.x, if the 1.y.z release date was after the release date of 1.0.x.

This reverts commit 02a136682c.
2015-08-25 09:04:35 +02:00
Jiří Klimeš 79db8e83e1 libnm: fix the callback in g_simple_async_result_new() 2015-08-21 13:36:05 +02:00
Jiří Klimeš 02a136682c all: change "Since: 1.2" to "Since: 1.0.4"/"Since: 1.0.6" for backported API 2015-08-21 10:43:53 +02:00
Jiří Klimeš 3d044b443a libnm: symbols for getting Wi-Fi frequencies have been backported to 1.0.6
Backport to 1.0.6 the following symbols:
  - nm_utils_wifi_2ghz_freqs;
  - nm_utils_wifi_5ghz_freqs;

Backported by commit 77bf69c3dc
2015-08-21 10:22:31 +02:00
Jiří Klimeš 1a6b631690 libnm: add utility functions for getting 2.4 GHz and 5 GHz Wi-Fi frequencies
nm_utils_wifi_2ghz_freqs()
nm_utils_wifi_5ghz_freqs()
2015-08-21 09:32:09 +02:00
Lubomir Rintel 64e37a6249 libnm,pkg-config: provide a variable with VPN service directory 2015-08-19 15:13:11 +02:00
Lubomir Rintel 1eedcb44fe libnm,vpn-service-plugin: fix double address-of for variants
They are already GVariant pointers.
2015-08-17 17:10:42 +02:00
Lubomir Rintel bcf2b1295c libnm,vpn-service-plugin: emit signals also for the dbus skeleton
Otherwise they won't just reach the bus.

https://bugzilla.gnome.org/show_bug.cgi?id=753663
2015-08-17 17:10:42 +02:00
Lubomir Rintel 81cc4d27b1 tests: raise the mock service startup timeout
Python is just too slow on some machines. Needed around twice the previous
limit on BCM2835 with Pidora 20, let's add some safety margin too.
2015-08-17 10:53:11 +02:00
Jiří Klimeš acfa07a37d libnm: symbols for request scanning backported to 1.0.6
Backport to 1.0.6 the following symbols:
 - nm_device_wifi_request_scan_options
 - nm_device_wifi_request_scan_options_async

Backported by commit 91c0555afa
2015-08-14 14:29:05 +02:00
Jiří Klimeš 7691fe5753 libnm: add new functions allowing passing options to RequestScan() D-Bus call
nm_device_wifi_request_scan_options()
nm_device_wifi_request_scan_options_async()
2015-08-14 11:27:15 +02:00
Thomas Haller b503b02cac libnm: add NM_AVAILABLE_IN_1_2 for API nm_access_point_get_last_seen()
Fixes: 1e85c35846
2015-08-09 14:37:10 +02:00
Thomas Haller 8bce48d8bf libnm: backport symbol nm_access_point_get_last_seen@libnm_1_0_6
nm_access_point_get_last_seen() was backported for 1.0.6 in
commit fade4ded37.
2015-08-09 12:20:01 +02:00
Dan Winship 22e1a97e12 all: drop includes to <glib/gi18n.h> for "nm-default.h"
The localization headers are now included via "nm-default.h".

Also fixes several places, where we wrongly included <glib/gi18n-lib.h>
instead of <glib/gi18n.h>. For example under "clients/" directory.
2015-08-05 15:35:51 +02:00
Thomas Haller 7363dc94c6 nm-default: include i18n headers via "nm-default.h" 2015-08-05 15:32:40 +02:00
Thomas Haller 19c3ea948a all: make use of new header file "nm-default.h" 2015-08-05 15:32:40 +02:00
Thomas Haller 6be8a1f549 libnm/vpn: add annotations for new NMVpnServicePlugin API 2015-07-29 22:34:35 +02:00
Thomas Haller 6ea0b9efee libnm/vpn: deprecated NMVpnPluginOld
In hindsight, the NMVpnPluginOld should never have made public for
nm-1-0 as there are no users and we don't want to support this API.

For now, just deprecate it.
2015-07-29 22:34:35 +02:00
Thomas Haller 867227dd4a libnm/vpn: add new NMVpnServicePlugin class
After copying "nm-vpn-plugin-old.*" to "nm-vpn-service-plugin.*",
rename the class and add it to the Makefile.

This will become the new VPN Service API for libnm 1.2. No changes
done yet except renaming of the classes and functions.

Rename the previous classes NMVpnPlugin(Old) to NMVpnServicePlugin
to have a distinct name from NMVpnEditorPlugin. Buth are plugins, but
with a different use.

https://bugzilla.gnome.org/show_bug.cgi?id=749951
2015-07-29 22:34:35 +02:00
Thomas Haller 87f631f2f1 libnm/vpn: copy 'nm-vpn-plugin-old' files to 'nm-vpn-service-plugin'
Files are yet unchanged, only copy them to get a nicer history.

  /bin/cp libnm/nm-vpn-plugin-old.c libnm/nm-vpn-service-plugin.c
  /bin/cp libnm/nm-vpn-plugin-old.h libnm/nm-vpn-service-plugin.h
2015-07-29 22:34:35 +02:00
Thomas Haller eafa6c3584 libnm: add load method to NMVpnPluginInfo
https://bugzilla.gnome.org/show_bug.cgi?id=749877
2015-07-29 22:34:35 +02:00
Thomas Haller eed0d0c58f libnm: add nm_vpn_editor_plugin_load_from_file() function 2015-07-29 22:34:35 +02:00
Thomas Haller bce040daa2 libnm: move NMVpnEditorPlugin to libnm-core/
Split the content of libnm/nm-vpn-editor-plugin.h and
move NMVpnEditorPlugin to libnm-core/nm-vpn-editor-plugin.h.

VPN plugins allow us to extend functionality about VPNs.
This can be also useful for NetworkManager core, hence
move that part to libnm-core.

The name NMVpnEditorPlugin is slightly misleading but not completely
wrong. The "editor" part stands no longer for bringing nm-applet
functionality (alone), but enable general VPN functionality in
the client.

Especially because we already have NMVpnPluginOld with a different
meaning (i.e. a base class of the plugin server implementation).
2015-07-29 22:34:35 +02:00
Thomas Haller d6226bd987 libnm: add NMVpnPluginInfo class
NMVpnPluginInfo is little more then a wrapper around
the GKeyFile that describes the VPN plugin settings,
i.e. the name files under "/etc/NetworkManager/VPN/".

Add this class to make the VPN API more explicit. Clients
now can use NMVpnPluginInfo instead of concerning themselves
with loading the keyfile and the meaning of its properties.

Also add support for a new VPN plugins directory
"/usr/lib/NetworkManager/VPN", which should replace
"/etc/NetworkManager/VPN" in the future. But we have to
consider both locations for backward compatibility.

The content of the VPN directory is not user configuration,
hence it should not be under "/etc". See related bug 738853.
2015-07-29 22:34:35 +02:00
Jiří Klimeš 4f98910848 libnm: NMVpnPluginOld fixes
Change a{ss} to a{sv} because not all values are strings and never were.

https://bugzilla.gnome.org/show_bug.cgi?id=749686
2015-07-29 22:34:34 +02:00
Dan Winship 3452ee2a0e all: rename nm-glib-compat.h to nm-glib.h, use everywhere
Rather than randomly including one or more of <glib.h>,
<glib-object.h>, and <gio/gio.h> everywhere (and forgetting to include
"nm-glib-compat.h" most of the time), rename nm-glib-compat.h to
nm-glib.h, include <gio/gio.h> from there, and then change all .c
files in NM to include "nm-glib.h" rather than including the glib
headers directly.

(Public headers files still have to include the real glib headers,
since nm-glib.h isn't installed...)

Also, remove glib includes from header files that are already
including a base object header file (which must itself already include
the glib headers).
2015-07-24 13:25:47 -04:00
Dan Winship dd0e198955 include: add nm-dbus-compat.h
Add a file containing the defines like DBUS_INTERFACE_DBUS from
dbus-shared.h, and use it from the gdbus-using files.

Also, convert a bunch of other places that were previously hardcoding
the string values to use the defines instead, and fix the ifcfg-rh
plugin to properly namespace its own D-Bus-related defines.
2015-07-24 13:25:47 -04:00
Beniamino Galvani 5622461c04 libnm-core: add Wake-on-LAN properties to NMSettingWired 2015-07-24 14:02:59 +02:00
Beniamino Galvani 8be9814793 libnm-core: add enum conversion utilities
Add functions nm_utils_enum_to_str() and nm_utils_enum_from_str()
which can be used to perform conversions between enum values and
strings, passing the GType automatically generated for every enum by
glib-mkenums.
2015-07-24 14:02:59 +02:00
Beniamino Galvani 3a7c641b02 libnm: backport symbols for metered connections support to 1.0.6
Backport to 1.0.6 the following symbols:
 - nm_device_get_metered
 - nm_metered_get_type
 - nm_setting_connection_get_metered
2015-07-22 14:06:31 +02:00
Dan Williams 70f5968e9c libnm: fix nm_access_point_get_last_seen() code doc after 1e85c358
Fixes: 1e85c358
2015-07-17 17:32:28 -05:00
Dan Williams 3272ff6fc5 libnm/libnm-glib: don't quit in the middle of asking for secrets (bgo #752237)
If the VPN plugin terminated and the user started it again, then the
quit timer will still be running and it sometimes happens that the
VPN plugin will quit while the UI is asking the user for secrets.
That's not very nice, so don't do that.

Reproducer: while connect to the VPN, suspend your laptop.  Then
resume it, and immediately re-start the VPN connection.  Watch the
secrets dialog disappear within a very short time.

https://bugzilla.gnome.org/show_bug.cgi?id=752237
2015-07-16 16:50:10 -05:00
Dan Williams aa7ab4b056 libnm/libnm-glib: clean up VPN plugin timeouts
Use nm_clear_g_source().
2015-07-16 16:46:27 -05:00
Lubomir Rintel a9996c4f1d vpn-plugin-old,dispatcher: cast unchecked g_variant_lookup() calls to void
This is done to silence coverity. In the dispatcher the existence of the
key is checked before and we're fine with leaving the value untouched
in the vpn-plugin-old.
2015-07-14 13:18:07 +02:00
Thomas Haller 7a3ab5c02f test: initialize tests with nmtst_init() 2015-07-12 13:56:52 +02:00
Thomas Haller f5cc6da8cf libnm: backport autoconnect-slaves symbols to libnm_1_0_4
https://bugzilla.gnome.org/show_bug.cgi?id=751535
2015-06-26 16:28:33 +02:00
Jiří Klimeš 6caafab258 libnm: add autoconnect-slaves property to NMSettingConnection
The property is used for controlling whether slaves should be brought up with
a master connection. If 0, activating the master will not activate slaves.
But if set to 1, activating the master will bring up slaves as well.
The property can have the third state (-1), meaning that the value is default.
That is either a value set in the configuration file for the property, or 0.
2015-06-19 09:32:58 +02:00
Beniamino Galvani 04d5804dd5 nm-manager: add 'metered' property
This introduces a global metered property which makes easier for
clients to obtain the metered status of the current primary
connection.
2015-06-09 18:23:19 +02:00
Beniamino Galvani 6f647fe689 libnm-core: add 'metered' property to NMSettingConnection
Add a 'metered' enum property to NMSettingConnection with possible
values: unknown,yes,no. The value indicates the presence of limitations
in the amount of traffic flowing through the connection.
2015-06-09 18:11:25 +02:00
Beniamino Galvani bbbf522941 core,libnm: add 'metered' property to NMDevice 2015-06-09 18:11:25 +02:00
Thomas Haller e9e9d44468 device: add nm_device_get_type_description() function
Add a function to get a concise representation of the
device type.

libnm already has nm_device_get_type_description() for that
and it is shown by

  nmcli -f GENERAL.TYPE device show

Reimplement that function for nm-core. Just take care that the
two implementations don't diverge.
2015-06-05 12:38:29 +02:00
Thomas Haller a8dd1b5358 libnm: make dns-options support an "undefined" default value
We want to distinguish between "no-options/empty" and "unset/default".
The latter can be interpreted by NM to use a default set of options.
2015-06-05 12:26:48 +02:00
Thomas Haller 2071e4794f libnm: fix take ownership of floating argument in NMSecretAgentOld:get_secrets_cb()
The previous patch 9ffcecf86a was
completely wrong.

It tried to fix callers that provided a floating GVariant reference.
We require the caller to unref @secrets, so the correct fix it to
ensure that the reference is not floating.

Fixes: 9ffcecf86a
Fixes: 6793a32a8c
2015-06-03 19:34:38 +02:00
Thomas Haller 9ffcecf86a libnm: don't take ownership of input argument in NMSecretAgentOld:get_secrets_cb()
Fixes: 6793a32a8c
2015-06-03 18:07:21 +02:00
Lubomir Rintel c47c06470a builds: only enable TAP driver for glib >= 2.37.6
No TAP support for previous versions and --tap argument is silently ignored,
confusing the TAP driver.
2015-05-28 12:51:24 +02:00
Lubomir Rintel 4a4f703c94 libnm,dbus-helpers: include glib-compat for g_test_initialized() 2015-05-26 14:17:31 +02:00
Lubomir Rintel 02e3d6c286 tests: don't try to connect to the private socket
Even if we're running the tests as root we still want to use the mock
service instead of whatever version of daemon runs on the test host.
2015-05-26 13:51:45 +02:00
Lubomir Rintel 6463ce5dd9 tests: use the TAP formatter
The test results in standard format are easily integrated into CI systems.
2015-05-26 13:51:45 +02:00
Lubomir Rintel 380ed63318 build: switch to parallel test harness
This will make it possible to use the TAP formatter.
2015-05-26 13:51:45 +02:00
Lubomir Rintel d0e25ac8be tests: always spawn private d-bus
Parallel test runs would not be possible without this.
2015-05-26 13:51:44 +02:00
Thomas Haller a915b57876 libnm: fix libnm.ver by putting new symbols into appropriate section
Fixes: 019943bb5d
2015-05-20 15:01:11 +02:00
Jiří Klimeš 08fbe75edd libnm: fix nm_vpn_plugin_old_set_connection() for connection == NULL 2015-05-19 14:48:37 +02:00
Jiří Klimeš dbf1794070 libnm: NMVpnPluginOld: return service name as const string in need_secrets() 2015-05-19 14:48:25 +02:00
Jiří Klimeš 4bab4294a6 libnm: fix NMVpnPluginOld registering VPN service
RequestName DBus call takes two agruments:
http://dbus.freedesktop.org/doc/dbus-specification.html#message-bus-names

timeout in g_dbus_proxy_call_sync() can't be 0 because it means literally zero
milliseconds and the call times out.
2015-05-19 14:46:27 +02:00
Beniamino Galvani 019943bb5d libnm-core: add dns-options property to NMSettingIPConfig 2015-05-13 17:15:34 +02:00
Dan Williams 1e85c35846 libnm: add Wi-Fi AP 'last-seen' property 2015-04-29 07:51:26 +02:00
Lubomir Rintel 0ea1fb4e5e libnm: set error when failing registration of old secret agent
We return FALSE, we ought to return a meaningful error.
2015-04-28 12:28:36 +02:00
Jiří Klimeš 4c398ab03f libnm: add nm-plugin-missing property indicating NM device plugin not available 2015-04-20 10:04:15 +02:00
Dan Winship 721e917cb6 wimax: drop WiMAX support (bgo #747846)
Even Fedora is no longer shipping the WiMAX SDK, so it's likely we'll
eventually accidentally break some of the code in src/devices/wimax/
(if we haven't already). Discussion on the list showed a consensus for
dropping support for WiMAX.

So, remove the SDK checks from configure.ac, remove the WiMAX device
plugin and associated manager support, and deprecate all the APIs.

For compatibility reasons, it is still possible to create and save
WiMAX connections, to toggle the software WiMAX rfkill state, and to
change the "WIMAX" log level, although none of these have any effect,
since no NMDeviceWimax will ever be created.

nmcli was only compiling in support for most WiMAX operations when NM
as a whole was built with WiMAX support, so that code has been removed
now as well. (It is still possible to use nmcli to create and edit
WiMAX connections, but those connections will never be activatable.)
2015-04-17 12:42:23 -04:00
Lubomir Rintel 9d3b31e1ae nm-remote-connection: take a reference to self while calling get_settings
(process:6888): GLib-GObject-WARNING **: invalid unclassed pointer in cast to 'GDBusProxy'

  Program received signal SIGTRAP, Trace/breakpoint trap.
  g_logv (log_domain=0x3149a3b224 "GLib-GObject", log_level=G_LOG_LEVEL_WARNING, format=<optimized out>, args=args@entry=0x7fffffffda70) at gmessages.c:1046
  1046              g_private_set (&g_log_depth, GUINT_TO_POINTER (depth));
  (gdb) bt
  #0  0x0000003148e50c70 in g_logv (log_domain=0x3149a3b224 "GLib-GObject", log_level=G_LOG_LEVEL_WARNING, format=<optimized out>, args=args@entry=0x7fffffffda70) at gmessages.c:1046
  #1  0x0000003148e50eaf in g_log (log_domain=log_domain@entry=0x3149a3b224 "GLib-GObject", log_level=log_level@entry=G_LOG_LEVEL_WARNING, format=format@entry=0x3149a42690 "invalid unclassed pointer in cast to '%s'") at gmessages.c:1079
  #2  0x0000003149a34171 in g_type_check_instance_cast (type_instance=type_instance@entry=0x6fc530, iface_type=<optimized out>) at gtype.c:4030
  #3  0x00007ffff7d6b016 in nmdbus_settings_connection_call_get_settings_finish (proxy=0x6fc530, out_settings=out_settings@entry=0x7fffffffdbb8, res=res@entry=0x6fe150, error=error@entry=0x0)
      at nmdbus-settings-connection.c:1303
  #4  0x00007ffff7ce8813 in updated_get_settings_cb (proxy=<optimized out>, result=0x6fe150, user_data=user_data@entry=0x6fc650) at nm-remote-connection.c:588
  #5  0x000000314a27640d in g_simple_async_result_complete (simple=0x6fe150 [GSimpleAsyncResult]) at gsimpleasyncresult.c:763
  #6  0x000000314a2df47c in reply_cb (connection=<optimized out>, res=0x6fe0e0, user_data=user_data@entry=0x6fe150) at gdbusproxy.c:2623
  #7  0x000000314a27640d in g_simple_async_result_complete (simple=0x6fe0e0 [GSimpleAsyncResult]) at gsimpleasyncresult.c:763
  #8  0x000000314a2d48cc in g_dbus_connection_call_done (source=<optimized out>, result=<optimized out>, user_data=user_data@entry=0x7fffec01a320) at gdbusconnection.c:5502
  #9  0x000000314a27640d in g_simple_async_result_complete (simple=0x6e5f40 [GSimpleAsyncResult]) at gsimpleasyncresult.c:763
  #10 0x000000314a27647c in complete_in_idle_cb (data=0x6e5f40) at gsimpleasyncresult.c:775
  #11 0x0000003148e49b6b in g_main_context_dispatch (context=0x687970) at gmain.c:3064
  #12 0x0000003148e49b6b in g_main_context_dispatch (context=context@entry=0x687970) at gmain.c:3663
  #13 0x0000003148e49f08 in g_main_context_iterate (context=0x687970, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3734
  #14 0x0000003148e4a232 in g_main_loop_run (loop=0x687a80) at gmain.c:3928
  #15 0x00000000004136a1 in main (argc=<optimized out>, argv=<optimized out>) at nmcli.c:632
  (gdb)
2015-04-17 13:03:03 +02:00
Dan Winship 9926ba376a libnm, core: use typechecked proxy_call methods 2015-04-03 16:58:40 -04:00
Dan Winship 1a0bc83c39 libnm, core: use _nm_dbus_signal_connect() 2015-04-03 16:58:40 -04:00
Lubomir Rintel fd41aa451b libnm,core: don't mix up enum types
Touches a weak spot on clang's soul.
2015-03-19 11:48:49 +01:00
Thomas Haller 2e86c37dd3 trivial: do an assignment before the conditional instead of in both branches
[lkundrak@v3.sk: An improvement suggested in bugzilla, but I failed to apply
it to the commit.]

https://bugzilla.redhat.com/show_bug.cgi?id=1079353
2015-03-16 15:44:14 +01:00
Lubomir Rintel dba4e8ece8 libnm,nm-object: fix tracing of object removal
When a new connection is activated and presently active connection goes away,
the active-connection-removed signal is not emitted for the old connection.
This is what happens:

1.) Initially, nm-manager::active-connections = [ActiveConnection/old]

2.) First PropertyChange is signalled for the new connection addition:
nm-manager::active-connections = [ActiveConnection/old,ActiveConnection/new]

This triggers load of ActiveConnection/new object.

3.) Another PropertyChange is signalled for the old connection removal:
nm-manager::active-connections = [ActiveConnection/new]

This removes the ActiveConnection/old object from
nm-manager::active-connections and enqueues active-connection-removed
signal. The signal is not emmitted as there's a reload from 2.) in progress.

4.) ActiveConnection/new reload finished

object_property_complete() compares
[ActiveConnection/old,ActiveConnection/new] from its odata to current
nm-manager::active-connections and incorrectly concludes that
ActiveConnection/old was just added and removes the enqueued
active-connection-removed signal.

This patch fixes the issue by remembering the original
nm-manager::active-connections property value at 2.).

[thaller@redhat.com: fixed an integer overflow and odata->array unreffing]

https://bugzilla.redhat.com/show_bug.cgi?id=1079353
2015-03-16 10:54:57 +01:00
Thomas Haller 15926e9eb3 libnm: add function nm_setting_802_1x_check_cert_scheme()
When setting the certificate glib properties directly,
we raise a g_warning() when the binary data is invalid.
But since the caller has no access to the validation function,
he cannot easily check whether his action will result
in a warning. Add nm_setting_802_1x_check_cert_scheme() for
that.
2015-03-12 18:12:26 +01:00
Thomas Haller fe0bd1b91f libnm: fix version script to add new API to proper linker section
Fixes: 5293683e4a
2015-02-26 10:21:22 +01:00
Jiří Klimeš 11efde3b40 libnm-core: add multicast-snooping property to bridge setting 2015-02-26 09:08:13 +01:00
Lubomir Rintel 2981839bde test: initialize auto-destructed pointers
Otherwise the compiler complains that they could be left uninitialized in case
the function returns too early.

Fixes: 76745817c3
2015-02-09 15:19:30 +01:00
Thomas Haller e7356ef0a6 libnm/tests: enable valgrind for libnm tests 2015-02-09 12:10:13 +01:00
Thomas Haller 76745817c3 libnm/tests: fix memleaks in test code for valgrind 2015-02-09 11:51:08 +01:00
Thomas Haller c50f30e79c tests: enable valgrind tests for tests 2015-02-09 11:51:07 +01:00
Thomas Haller 1567a9f712 libnm: fix memleak in _nm_dbus_bind_properties() 2015-02-09 11:51:05 +01:00
Dan Winship 8bbda5cdff Currently if we have two paired bluetooth devices,
nm_device_disambiguate_names() will disambiguate them by their
hardware address. This is not very helpful, so detect this case and
use the Bluetooth device name instead.

This function is used by System Settings when showing the list of
network devices.

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

(Port of a libnm-gtk patch written by Ryan Lortie.)
2015-01-27 17:07:49 -05:00
Lubomir Rintel 799820f859 libnm: drop libdbus-glib from pkg-config file
libnm uses GIO DBus library instead.

https://mail.gnome.org/archives/networkmanager-list/2015-January/msg00065.html
2015-01-22 19:17:46 +01:00
Dan Williams 5293683e4a libnm/libnm-util: add Wi-Fi 'powersave' property 2015-01-21 14:31:04 -06:00
Dan Winship 6da3b3a5a5 libnm: fix versioning on new APIs, bump soname
The newly added bond mode APIs in nm-utils will be new in 1.2, so mark
them as such in the headers and docs, move them to a new section in
libnm.ver.

Since we're adding the new section to libnm.ver, this also seems like
a good time to bump the soname.
2015-01-21 12:54:36 -05:00
Jiří Klimeš d787f0391b utils: add functions for converting string <-> numeric bonding modes 2015-01-13 09:35:49 +01:00
Lubomir Rintel 4615d74de0 libnm: make NMDhcp6Config inherit from NMDhcpConfig
Otherwise it does not register the "options" property and an assertion fails
when the user prints connection that has DHCPv6 options:

  $ LIBNM_GLIB_DEBUG=properties-changed nmcli c show yolo
  ...
  libnm-Message: Property 'options' unhandled.
  ...
  (process:13522): libnm-CRITICAL **: nm_dhcp_config_get_options: assertion 'NM_IS_DHCP_CONFIG (config)' failed
2015-01-02 19:50:54 +01:00
Dan Winship 2d29c0527e docs: misc small fixes
Cleans up all of the warnings that aren't overly annoying to clean up.
2014-12-18 13:47:03 -05:00
Dan Winship 8d96273870 libnm: remove __libnm_local section from version script
I had argued for putting the local symbols in their own section, since
it doesn't make sense to have local symbols introduced in 1.2 in the
libnm_1_0_0 section... but apparently even if the section has no
exported symbols, rpm's find-provides still picks it up if it's there,
creating an ugly additional "provides" for libnm. So get rid of that.
2014-12-15 15:49:39 -05:00
Jiří Klimeš ce6323d4df tests: mute coverity INFINITE_LOOP error
Error: INFINITE_LOOP (CWE-835): [#def17]
NetworkManager-0.9.11.0/libnm/tests/test-nm-client.c:93: loop_top: Top of the loop.
NetworkManager-0.9.11.0/libnm/tests/test-nm-client.c:94: loop_bottom: Bottom of the loop.
NetworkManager-0.9.11.0/libnm/tests/test-nm-client.c:93: loop_condition: If "notified" is initially true then it will remain true.

Error: INFINITE_LOOP (CWE-835): [#def18]
NetworkManager-0.9.11.0/libnm/tests/test-nm-client.c:191: loop_top: Top of the loop.
NetworkManager-0.9.11.0/libnm/tests/test-nm-client.c:192: loop_bottom: Bottom of the loop.
NetworkManager-0.9.11.0/libnm/tests/test-nm-client.c:191: loop_condition: If "result & NOTIFY_MASK" is initially true then it will remain true.
NetworkManager-0.9.11.0/libnm/tests/test-nm-client.c:191: loop_condition: If "result & SIGNAL_MASK" is initially true then it will remain true.
2014-12-15 16:25:27 +01:00