Commit Graph

15047 Commits

Author SHA1 Message Date
Dan Winship
69099f3e80 libnm: merge device-type-specific errors into NMDeviceError
As with the settings, each device type was defining its own error
type, containing either redundant or non-useful error codes. Drop all
of the subtype-specific errors, and reduce things to just
NM_DEVICE_ERROR_FAILED, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, and
NM_DEVICE_ERROR_INVALID_CONNECTION.

The device-type-specific errors were only returned from their
nm_device_connection_compatible() implementations, so this is also a
good opportunity to simplify those, by moving duplicated functionality
into the base NMDevice implementation, and then allowing the
subclasses to assume that the connection has already been validated in
their own code. Most of the implementations now just check that the
connection has the correct type for the device (which can't be done at
the NMDevice level since some device types (eg, Ethernet) support
multiple connection types.)

Also, make sure that all of the error messages are localized.
2014-10-22 08:29:08 -04:00
Dan Winship
5632ac6730 libnm: drop unused NMRemoteConnectionError
NMRemoteConnection used to return
NM_REMOTE_CONNECTION_ERROR_DISCONNECTED if you tried to operate on a
connection that had been disconnected from its D-Bus proxy. But this
disappeared in the gdbus port (since gdbus doesn't emit a signal when
it happens, so it's harder to notice. And it's not clear why
NMRemoteConnection did this when no other class did anyway...).
2014-10-22 08:29:08 -04:00
Dan Winship
9c67b6fb08 libnm-core, core: register NMConnectionError with D-Bus
Register NMConnectionError with D-Bus on both sides, so that, eg,
connection validation failures in the daemon will translate to the
correct error codes in the client.
2014-10-22 08:29:08 -04:00
Dan Winship
b1bcfa8fed libnm-core: add nm-errors.[ch]
Add nm-errors.[ch], and move libnm-core's two error domains
(NMConnectionError and NMCryptoError) there.

NMCryptoError wasn't previously visible, but it can be returned from
some public API, so it should be.
2014-10-22 08:29:08 -04:00
Dan Winship
663a06b6d9 libnm-core: fix up/simplify NMCryptoError
Many of NMCryptoError's codes would basically never be useful for
programs to distinguish between. Streamline the codes, and fix the
enumeration member names to start with "NM_CRYPTO_ERROR_" rather than
"NM_CRYPTO_ERR_".
2014-10-22 08:29:08 -04:00
Dan Winship
2d8e7bd247 libnm-core: merge NMSetting*Error into NMConnectionError
Each setting type was defining its own error type, but most of them
had exactly the same three errors ("unknown", "missing property", and
"invalid property"), and none of the other values was of much use
programmatically anyway.

So, this commit merges NMSettingError, NMSettingAdslError, etc, all
into NMConnectionError. (The reason for merging into NMConnectionError
rather than NMSettingError is that we also already have
"NMSettingsError", for errors related to the settings service, so
"NMConnectionError" is a less-confusable name for settings/connection
errors than "NMSettingError".)

Also, make sure that all of the affected error messages are localized,
and (where appropriate) prefix them with the relevant property name.

Renamed error codes:

NM_SETTING_ERROR_PROPERTY_NOT_FOUND -> NM_CONNECTION_ERROR_PROPERTY_NOT_FOUND
NM_SETTING_ERROR_PROPERTY_NOT_SECRET -> NM_CONNECTION_ERROR_PROPERTY_NOT_SECRET

Remapped error codes:

NM_SETTING_*_ERROR_MISSING_PROPERTY -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_*_ERROR_INVALID_PROPERTY -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_INVALID_SETTING
NM_SETTING_BOND_ERROR_INVALID_OPTION -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BOND_ERROR_MISSING_OPTION -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_CONNECTION_ERROR_SLAVE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_VLAN_ERROR_INVALID_PARENT -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND -> NM_CONNECTION_ERROR_MISSING_PROPERTY

Dropped error codes (were previously defined but unused):

NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED
NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED
NM_SETTING_PPPOE_ERROR_MISSING_PPP_SETTING
NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING
NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING
2014-10-22 08:29:07 -04:00
Dan Winship
aeb3d093f6 libnm-core: clean up NMConnectionError
Rename NM_CONNECTION_ERROR_UNKNOWN to NM_CONNECTION_ERROR_FAILED,
following GError best practices.

Replace NM_CONNECTION_ERROR_CONNECTION_SETTING_NOT_FOUND ("no
NMSettingConnection") with a more generic
NM_CONNECTION_ERROR_MISSING_SETTING. Use that new code in a few places
that had previously been using NM_CONNECTION_ERROR_SETTING_NOT_FOUND,
which was supposed to mean "the setting that you asked about doesn't
exist", not "the connection is invalid because it's missing a required
setting".

Clarify that NM_CONNECTION_ERROR_INVALID_SETTING can be used for any
"invalid or inappropriate NMSetting", not just a "conflicting" one.
(But fix a case in nm_connection_update_secrets() that was returning
INVALID_SETTING when it should have been return-if-failing instead.)

For both MISSING_SETTING and INVALID_SETTING, always prefix the error
message with "setting-name: ", just like we do with the various
NMSetting MISSING_PROPERTY and INVALID_PROPERTY errors. And make sure
that the error message is marked for localization.

Drop NM_CONNECTION_ERROR_CONNECTION_TYPE_INVALID, which is pretty
pointless; it was only used in the case where connection.type was the
name of a valid setting type that is not a base setting type. Instead,
just return NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY for
connection.type in this case (which is what the code already did when
connection.type was completely unrecognized).
2014-10-22 08:29:07 -04:00
Dan Winship
a7b1ee77db libnm-core: drop nm_setting_lookup_type_by_quark()
nm_setting_lookup_type_by_quark() was only ever used in places that
were still mistakenly assuming the old style of nm_connection_verify()
errors, where the error message would contain only a property name and
no further explanation. Fix those places to assume that the error will
contain a real error message, and include both the setting name and
the property name.

Given that, there's no longer any need for
nm_setting_lookup_type_by_quark(), so drop it.
2014-10-22 08:29:07 -04:00
Dan Williams
63957e0ed2 tui: fix incorrect chain up to parent 2014-10-21 18:51:05 -05:00
Dan Williams
d37b7bed30 core: let kernel add IPv6LL address when method=ignore (rh #1132938)
The IPv6LL address handling in userspace patches failed to handle the
case where the IPv6 method was 'ignore'.  Previously the kernel would
usually add the IPv6LL address itself, but if NM has turned off kernel
IPv6LL then obviously this wouldn't happen.  So when the method is
'ignore', turn off userspace IPv6LL handling and bounce disable_ipv6
to make the kernel add the IPv6LL address if it wants to.
2014-10-21 13:46:43 -05:00
Dan Winship
7e548d962a nmtst: fix a bug in NMTST_VARIANT_EDITOR
NMTST_VARIANT_EDITOR would crash if you tried to drop different
properties (or two different settings).
2014-10-21 09:45:23 -04:00
Dan Winship
1f8ec6122e libnm: fix NMActiveConnection:specific-object-path
NMActiveConnection:specific-object was renamed to
NMActiveConnection:specific-object-path in 677314c5, but it didn't
actually work, because of assumptions NMObject makes. Fix that.
2014-10-21 09:45:20 -04:00
Jiří Klimeš
5d66f91de8 contrib/rpm: do not override configuration files on updates (rh #1153901)
Rather leave modified configuration files untouched and save the new files
with .rpmnew suffix.

http://stackoverflow.com/questions/14511334/rpm-upgrade-handling-of-config-files

https://bugzilla.redhat.com/show_bug.cgi?id=1153901
2014-10-21 15:15:46 +02:00
Thomas Haller
7d04618645 settings: pass valid error domain to g_set_error() in load_plugins()
glib asserts that the error domain parameter is a non-zero quark.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-21 14:35:22 +02:00
Jiří Klimeš
4ad7cda7a4 dispatcher: fix crash on missing scripts (bgo #738654)
GLib-CRITICAL **: g_variant_type_checked_: assertion `g_variant_type_string_is_valid (type_string)' failed
GLib-CRITICAL **: g_variant_new_array: assertion `n_children > 0 || child_type != NULL' failed

https://bugzilla.gnome.org/show_bug.cgi?id=738654
2014-10-21 08:57:02 +02:00
Thomas Haller
08c0e73ec5 cli/bash-completion: normalize OPTIONS_TYPE to use it inside _nmcli_compl_ARGS()
Later _nmcli_compl_ARGS() wants to check $OPTIONS_TYPE to behave differently
depending on the type. As we accept abbreviations of $OPTIONS_TYPE, let's normalize
the value, so that we don't have to consider abbrevations later on.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-21 08:28:02 +02:00
Lubomir Rintel
72cafb8ca3 build: Don't conditionally omit files from distribution 2014-10-20 18:24:55 +02:00
Thomas Haller
60aee59f18 rdisc: merge branch 'lkundrak/lr-rdisc-mtu' (bgo#738104)
https://bugzilla.gnome.org/show_bug.cgi?id=738104

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-20 14:33:47 +02:00
Lubomir Rintel
7d57793004 rdisc,device: set MTU if an appropriate option is present in a RA
https://bugzilla.gnome.org/show_bug.cgi?id=738104

Reported-by: Charles R. Anderson <cra@wpi.edu>
2014-10-20 14:32:38 +02:00
Lubomir Rintel
810dc260ef core: track origin of MTU
Only override MTU if it came from a source of higher priority or is of equal
priority but of lower value.
2014-10-20 14:32:38 +02:00
Lubomir Rintel
33866e4030 core: Move NMPlatformSource to nm-types.h
...and rename it while at it. It's going to be useful outside nm-platform,
to weight MTU options from various sources.
2014-10-20 12:41:50 +02:00
Thomas Haller
d60f593b3e build: merge branch 'lkundrak/lr-rpm-build' (bgo#738507)
https://bugzilla.gnome.org/show_bug.cgi?id=738507

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-20 12:39:24 +02:00
Lubomir Rintel
479dd171ae contrib/rpm: Count all predecessors in revision number
The revision number of the RPM (as build by contrib/rpm) should
be increasing so that newer packages can be installed using
`yum install` and older packages can be downgraded using
`yum downgrade`.
By counting only --first-parent, the following example turns
out wrong. Note the duplicate revision numbers.

  -- A(100)----------------------------F(101)----G(102)
      \                               /
       B(101)----C(102)----D(103)----E(104)

Just count *all* parent commits
2014-10-20 12:38:00 +02:00
Lubomir Rintel
5d763a8375 contrib/rpm: Fix Fedora 19 build
Too old to have recent enough ModemManager.
2014-10-20 11:53:43 +02:00
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