Commit Graph

13873 Commits

Author SHA1 Message Date
Lubomir Rintel
1f631cd08d contrib/rpm: Don't exclude files that are not built
RPM still insist that they need to exist in order to be excluded.
2014-10-20 11:53:43 +02:00
Lubomir Rintel
44c34a7adc build: Don't leak generated files into distribution
gdbus-codegen will generate code that will need a too recent version of glib.
2014-10-20 11:53:43 +02:00
Lubomir Rintel
461da6fe1a cli: fix getting/setting hostname (bgo #738796)
Create a client instance before it's used.

$ nmcli g hostname
(process:13615): GLib-GObject-CRITICAL **: g_object_get: assertion 'G_IS_OBJECT (object)' failed

https://bugzilla.gnome.org/show_bug.cgi?id=738796
2014-10-20 10:05:59 +02:00
Jiří Klimeš
9c6a510b92 Merge: nmcli fixes for private connections (bgo #738643)
When a user activates a private connection, other users will see the active
connection, but they won't see the backing connection profile.

https://bugzilla.gnome.org/show_bug.cgi?id=738643
2014-10-20 09:20:29 +02:00
Jiří Klimeš
e0c8848f2e cli: get connection ID straight from the active connection
Static connection profile may not be available and using active conection
is easier anyway.
2014-10-20 09:11:57 +02:00
Jiří Klimeš
e130415f2b cli: show active connection even if the connection profile is not visible
$ nmcli con show
2014-10-20 09:11:57 +02:00
Jiří Klimeš
b03518b817 cli: show details for active connection even if the profile is not visible
$ nmcli con show other_user_con
2014-10-20 09:11:57 +02:00
Jiří Klimeš
278ec17448 cli: fix errors and crash for invisible connections
* two users are logged in: user_a and user_b
* user_b creates a connection visible only to him 'user_b_private'
  (permissions: user:user_b)
* user_b activates the connection user_b_private
* user_a does not see the connection profile, but he does see the active
  connection

* user_a calls
  nmcli con
  nmcli con show user_b_private
2014-10-20 09:11:57 +02:00
Dan Winship
7b1aae969d libnm, core: fix problems with device activation (bgo 737993) 2014-10-19 09:27:53 -04:00
Dan Winship
be8060f42f libnm: add an object-creation-failed test 2014-10-19 09:27:48 -04:00
Dan Winship
f96835b83c libnm: add a virtual device creation-and-activation test
Add a test of creating a (virtual) device and activating a connection
on it at the same time.
2014-10-19 09:27:48 -04:00
Dan Winship
ba900f2a44 tools: add a bit of support for VLANs to test-networkmanager-service.py 2014-10-19 09:27:48 -04:00
Dan Winship
e06bd1ef17 libnm: add an active-connection test to test-nm-client
Test NMClient's handling of active connections, and in particular test
that we can correctly resolve the circular reference between an
NMDevice and an NMActiveConnection, both synchronously and
asynchronously.
2014-10-19 09:27:48 -04:00
Dan Winship
b9c09a2b0d tools: add a bit more activation support to test-networkmanager-service.py
Now test-networkmanager-service.py can create ActiveConnections, though
they don't actually finish activating.
2014-10-19 09:27:47 -04:00
Dan Winship
08a344d723 libnm: abstract out duplicated device-creating code in tests 2014-10-19 09:27:47 -04:00
Dan Winship
4779d96685 core: lie about NMActiveConnection:state in new connections
NMActiveConnections start out in state "unknown", but then quickly
switch to "activating". Unfortunately, it's sometimes possible for
this to be externally visible. Fix this by lying and saying that state
is "activating" during the initial "unknown" stage (though not if the
state changes to "unknown" later on).

(Actually changing the initial state to "activating" breaks things
because some code depends on there being a transition into the
"activating" state.)
2014-10-19 09:27:47 -04:00
Dan Winship
d78ea27d36 libnm: postpone activation callback until all objects are ready
In some cases, the nm_client_activate_connection() callback could be
invoked when either the NMActiveConnection or the NMDevice had not
been initialized yet. Fix it to wait for both of them to be fully
initialized before invoking the callback.
2014-10-19 09:26:50 -04:00
Dan Winship
a9e906fcbd libnm: add -added and -removed signals for ACs to NMManager 2014-10-19 09:26:49 -04:00
Dan Winship
2ac83c0e8b libnm: fix async property circular reference handling
3e5b3833 changed various libnm methods to return 0-length arrays
rather than NULL, and changed various other places to assume this
behavior. The guarantee that they didn't return NULL relied on the
assumption that all D-Bus properties would get initialized by NMObject
code before anyone could call their get methods.

However, this assumption was violated in the case where two objects
circularly referenced each other (eg, NMDevice and
NMActiveConnection). f9f9d297 attempted to fix this by slightly
changing the ordering of NMObjectCache operations, but it actually
ended up breaking things and causing infinite loops of object creation
in some cases.

There's no way to guarantee we never return partially-initialized
objects without heavily rewriting the object-creation code, so this
reverts most of f9f9d297 (leaving only the new comment in
_nm_object_create()). The crashes introduced by 3e5b3833 will no
longer happen because we've now fixed the classes to have initialized
their object arrays to non-NULL values even before they get the real
values.
2014-10-19 09:26:49 -04:00
Dan Winship
ab878f7479 libnm: further NULL-vs-empty-array fixes
In some cases, code may look at the value of an array-valued property
during object initialization, before NMObject has set it to its actual
initial value. So ensure that we initialize all such properties to an
empty array, rather than leaving them NULL.

Also fix another bug in NMClient that could result in
priv->active_connections being NULL during certain signal emissions,
and fix nm_client_get_active_connections() to not return NULL when NM
was not running.
2014-10-19 09:26:49 -04:00
Jiří Klimeš
88efa1c437 cli: fix 'nmcli connection up bond0' being stuck
It can happen on activating a master without slaves. Active connection will
not move past activating state.
2014-10-19 09:26:34 -04:00
Dan Winship
edcf067266 tui: clarify the "Device" widget with PPPoE connections (rh #1105753)
PPPoE connections involve two different network connections, making it
ambiguous what the "Device" field refers to. Clarify that it refers to
the Ethernet device, not the PPP device.
2014-10-19 08:45:40 -04:00
Dan Williams
44900a1584 core: ensure interface is up before applying IP configuration (bgo #738479)
Routing configuration fails to apply if the device is not IFF_UP, so if
we're going to apply IP configuration to the device, make sure it's IFF_UP
first.

https://bugzilla.gnome.org/show_bug.cgi?id=738479
2014-10-17 15:21:34 -05:00
Dan Williams
5ad69cb29b core: remove child devices without deconfiguring them (bgo #738479)
When a child device is found and an IP configuration already exists
for it even though it is under NM control (like when pppd applies
IP config to a WWAN device before NM gets the IP details from the pppd
plugin), don't deconfigure the child device when removing it from the
device list, because this breaks the device's configuration.

https://bugzilla.gnome.org/show_bug.cgi?id=738479
2014-10-17 15:21:32 -05:00
Dan Williams
8283672451 core: don't override external route metrics (bgo #738268)
A generated connection contains a copy of the device's existing
configuration, so it's entirely redundant to merge the connection
back into the device's IP config.  But even though that should
result in no changes to the IP config, NMSettingIPxConfig treats a
route metric of '0' as the device priority, while NMIPxConfig
allows 0 as a valid route metric.  Since the setting values
are preferred (they are supposed to be user-supplied and thus
override anythign else, but in this case they are generated and
thus not user-supplied) external routes with a metric of 0 are
overwritten with the device priority metric.

https://bugzilla.gnome.org/show_bug.cgi?id=738268
2014-10-17 15:00:31 -05:00
Florian Müllner
261a3924d3 remote-settings: Mark service as running when using private bus
When using a private bus connection, the service is never marked
as running when settings are initialized asynchronously. Successfully
opening a socket in NM's runtime directory should already imply
a running service, so just mark it as such (as we already do in
the synchronous path).
2014-10-17 09:44:39 -04:00
Dan Williams
2b02eea1a4 trivial: add missing break 2014-10-16 20:10:12 -05:00
Dan Williams
8176af1152 keyfile: fix handling of enum/flags properties after fcfb4b40 (bgo #738585)
When some properties got converted to G_TYPE_ENUM and G_TYPE_FLAGS
the keyfile plugin was not updated to handle these types.

https://bugzilla.gnome.org/show_bug.cgi?id=738585
2014-10-16 19:17:18 -05:00
Dan Williams
b69143b508 build: ensure rl_echo_signal_char() exists in the readline library 2014-10-14 14:30:44 -05:00
Thomas Haller
d5ceb0af15 bluez: fix compiler error due to redefinition of typedef
clang warns:
    make[5]: Entering directory `./NetworkManager/src/devices/bluetooth'
      CC       nm-bluez5-dun.lo
    nm-bluez5-dun.c:50:3: error: redefinition of typedef 'NMBluez5DunContext' is a C11 feature [-Werror,-Wtypedef-redefinition]
    } NMBluez5DunContext;
      ^
    ./nm-bluez5-dun.h:27:36: note: previous definition is here
    typedef struct _NMBluez5DunContext NMBluez5DunContext;
                                       ^

Fixes: f1c9595311
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-14 11:28:19 +02:00
Marius Vollmer
4f950ee569 policy: allow non-local admin sessions to control the network (rh #1145646) 2014-10-13 15:58:46 -05:00
Thomas Haller
d00fed839a bluez: merge branch 'lr-bluez5-dun' (rh #1055628)
https://bugzilla.redhat.com/show_bug.cgi?id=1055628

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-13 14:30:27 +02:00
Lubomir Rintel
f1c9595311 bluez: re-add DUN support for Bluez5
This adds service discovery via SDP and RFCOMM tty management to
NetworkManager, as it was dropped from Bluez.

Based on work by Dan Williams <dcbw@redhat.com>.
The SDP discovery is based on code from Bluez project.
2014-10-13 14:27:33 +02:00
Dan Williams
384ec86064 bluez: track adapter address in NMBluezDevice
We'll need it for bluez5 DUN support.

[lkundrak@v3.sk: Turn the addresses to strings from guint8[ETH_ALEN], as that
is what rest of NetworkManager uses for MAC addresses and what Bluez utility
functions expect as well.]
2014-10-13 14:27:33 +02:00
Dan Williams
5254ac456e bluez: split out errors
We'll use them from more places than nm nm-bt-device.c in the future.
2014-10-13 14:27:33 +02:00
Thomas Haller
ec84e4f00a merge branch 'th/bgo737380_log_connection_diff'
https://bugzilla.gnome.org/show_bug.cgi?id=737380

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-12 22:25:32 +02:00
Thomas Haller
30b1afd73b core: log connection change with nm_utils_log_connection_diff()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-12 21:17:17 +02:00
Thomas Haller
41e0d5b9ce core: add nm_utils_log_connection_diff
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-12 21:17:17 +02:00
Thomas Haller
1cc7b8d027 libnm-util: add _nm_setting_get_property() function
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-12 21:17:17 +02:00
Thomas Haller
1464c5a11e libnm: add function _nm_setting_get_setting_priority()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-12 21:17:17 +02:00
Thomas Haller
68bc95c12f libnm-util: let nm_setting_diff() be symetric not to return properties that are set to default
Previously, nm_setting_diff() (and thus nm_connection_diff()), returned
only properties that are different AND not set to the default value.
However, if the opposite setting 'B' was missing, it would always
include all properties from 'A', even the default ones.

This behaviour was asymetric. Add two new compare flags
@NM_SETTING_COMPARE_FLAG_DIFF_RESULT_WITH_DEFAULT and
@NM_SETTING_COMPARE_FLAG_DIFF_RESULT_NO_DEFAULT to control the
behaviour of whether to include default properties.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-12 21:17:17 +02:00
Thomas Haller
e5194fd346 libnm: hide API for generic handling of secrets
The functions nm_setting_clear_secrets(),
nm_setting_clear_secrets_with_flags(), and nm_setting_need_secrets()
are not used outside of libnm-core. Remove them from public API.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-12 21:17:17 +02:00
Thomas Haller
978724da96 libnm-util: don't assert in nm_setting_get_secret_flags() and avoid assertion in agent_secrets_done_cb()
When secret providers return the connection hash in GetSecrets(),
this hash should only contain secrets. However, some providers also
return non-secret properties.

for_each_secret() iterated over all entries of the @secrets hash
and triggered the assertion in nm_setting_get_secret_flags() (see
below).

NM should not assert against user provided input. Change
nm_setting_get_secret_flags() to silently return FALSE, if the property
is not a secret.

Indeed, handling of secrets is very different for NMSettingVpn and
others. Hence nm_setting_get_secret_flags() has only an inconsistent
behavior and we have to fix all call sites to do the right thing
(depending on whether we have a VPN setting or not).

Now for_each_secret() checks whether the property is a secret
without hitting the assertion. Adjust all other calls of
nm_setting_get_secret_flags(), to anticipate non-secret flags and
assert/warn where appropriate.

Also, agent_secrets_done_cb() clears now all non-secrets properties
from the hash, using the new argument @remove_non_secrets when calling
for_each_secret().

  #0  0x0000003370c504e9 in g_logv () from /lib64/libglib-2.0.so.0
  #1  0x0000003370c5063f in g_log () from /lib64/libglib-2.0.so.0
  #2  0x00007fa4b0c1c156 in get_secret_flags (setting=0x1e3ac60, secret_name=0x1ea9180 "security", verify_secret=1, out_flags=0x7fff7507857c, error=0x0) at nm-setting.c:1091
  #3  0x00007fa4b0c1c2b2 in nm_setting_get_secret_flags (setting=0x1e3ac60, secret_name=0x1ea9180 "security", out_flags=0x7fff7507857c, error=0x0) at nm-setting.c:1124
  #4  0x0000000000463d03 in for_each_secret (connection=0x1deb2f0, secrets=0x1e9f860, callback=0x464f1b <has_system_owned_secrets>, callback_data=0x7fff7507865c) at settings/nm-settings-connection.c:203
  #5  0x000000000046525f in agent_secrets_done_cb (manager=0x1dddf50, call_id=1, agent_dbus_owner=0x1ddb9e0 ":1.39", agent_username=0x1e51710 "thom", agent_has_modify=1, setting_name=0x1e91f90 "802-11-wireless-security",
      flags=NM_SETTINGS_GET_SECRETS_FLAG_ALLOW_INTERACTION, secrets=0x1e9f860, error=0x0, user_data=0x1deb2f0, other_data2=0x477d61 <get_secrets_cb>, other_data3=0x1ea92a0) at settings/nm-settings-connection.c:757
  #6  0x00000000004dc4fd in get_complete_cb (parent=0x1ea6300, secrets=0x1e9f860, agent_dbus_owner=0x1ddb9e0 ":1.39", agent_username=0x1e51710 "thom", error=0x0, user_data=0x1dddf50) at settings/nm-agent-manager.c:1139
  #7  0x00000000004dab54 in req_complete_success (req=0x1ea6300, secrets=0x1e9f860, agent_dbus_owner=0x1ddb9e0 ":1.39", agent_uname=0x1e51710 "thom") at settings/nm-agent-manager.c:502
  #8  0x00000000004db86e in get_done_cb (agent=0x1e89530, call_id=0x1, secrets=0x1e9f860, error=0x0, user_data=0x1ea6300) at settings/nm-agent-manager.c:856
  #9  0x00000000004de9d0 in get_callback (proxy=0x1e47530, call=0x1, user_data=0x1ea10f0) at settings/nm-secret-agent.c:267
  #10 0x000000337380cad2 in complete_pending_call_and_unlock () from /lib64/libdbus-1.so.3
  #11 0x000000337380fdc1 in dbus_connection_dispatch () from /lib64/libdbus-1.so.3
  #12 0x000000342800ad65 in message_queue_dispatch () from /lib64/libdbus-glib-1.so.2
  #13 0x0000003370c492a6 in g_main_context_dispatch () from /lib64/libglib-2.0.so.0
  #14 0x0000003370c49628 in g_main_context_iterate.isra.24 () from /lib64/libglib-2.0.so.0
  #15 0x0000003370c49a3a in g_main_loop_run () from /lib64/libglib-2.0.so.0
  #16 0x000000000042e5c6 in main (argc=1, argv=0x7fff75078e88) at main.c:644

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-12 21:17:17 +02:00
Thomas Haller
a7c8e5c6e9 merge branch 'th/bgo580018_autoconnect_priority'
Add configuration option NMSettingConnection:autoconnect-priority.
This new option is only relevant for connections that are set to
autoconnect. When having more then one candicate for autoconnect, this
new setting allows to always prefer one connection over the other.

If both connections have the same priority setting, the previous
automatism is used to choose the best candidate. That is, NM will
choose the least recently connected candidate.
See also the still unresolved but related bug bgo#737356 that asks
for providing a different automatism.

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-12 20:36:48 +02:00
Thomas Haller
f87e876f79 core: prefer connections with higher priority for autoconnect
https://bugzilla.gnome.org/show_bug.cgi?id=580018

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-12 20:13:18 +02:00
Thomas Haller
59f2c0fb3e core/policy: refactor auto_activate_device() to use a GPtrArray
Next we want to sort the array, g_slist_sort() is not guaranteed to be
stable, while g_ptr_array_sort() is. Also, sorting a GSList has
worse performance.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-12 20:13:18 +02:00
Thomas Haller
91ec7dac90 core: remove nm_device_get_best_auto_connection()
nm_device_get_best_auto_connection() was only used at one place.
It was a very simple function, just iterated over a list finding
the first can_auto_connect() connection. At the very least, the name
was misleading, because it did not return the 'best', but the 'first'
connection.

Get rid of the function altogether.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-12 20:13:18 +02:00
Thomas Haller
f68faccd7f core: add nm_device_can_auto_connect() function
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-12 20:13:18 +02:00
Thomas Haller
2e8a2921e5 core: ensure properly comparing boolean values in connection_sort()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-12 20:13:18 +02:00
Thomas Haller
cf26bb2dea cli: support connection.autoconnect-priority property
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-12 20:13:18 +02:00