Commit graph

20018 commits

Author SHA1 Message Date
Beniamino Galvani
8a01bdc2d1 Merge commit '23cbce4bc9c70fc33d3413fc1b9a5f3303498036' as 'shared/n-acd'
Imported n-acd code with command:

  git subtree add --prefix shared/n-acd git@github.com:nettools/n-acd.git a68b55992dd7b38bdb9dbbdba4a9284ff2c2cce3 --squash

To update the library use:

  git subtree pull --prefix shared/n-acd git@github.com:nettools/n-acd.git master --squash
2018-04-18 15:21:26 +02:00
Beniamino Galvani
23cbce4bc9 Squashed 'shared/n-acd/' content from commit a68b55992
git-subtree-dir: shared/n-acd
git-subtree-split: a68b55992dd7b38bdb9dbbdba4a9284ff2c2cce3
2018-04-18 15:21:19 +02:00
Beniamino Galvani
b16b4a4362 Merge commit 'afe2594a7799d3113470c40664c6eda88b83c7e5' as 'shared/c-list'
Imported c-list code with command:

  git subtree add --prefix shared/c-list/ git@github.com:c-util/c-list.git master --squash

To update the library use:

  git subtree pull --prefix shared/c-list/ git@github.com:c-util/c-list.git master --squash
2018-04-18 15:20:40 +02:00
Beniamino Galvani
afe2594a77 Squashed 'shared/c-list/' content from commit 317aa1c65
git-subtree-dir: shared/c-list
git-subtree-split: 317aa1c65743ff528a27542f6785d29a05cc6e0c
2018-04-18 15:20:33 +02:00
Beniamino Galvani
579f17cfee Merge commit '1ea09eb549dbd910ea593e01fb6f746ae20b4beb' as 'shared/c-siphash'
Imported c-siphash code with command:

  git subtree add --prefix shared/c-siphash/ git@github.com:c-util/c-siphash.git master --squash

To update the library use:

  git subtree pull --prefix shared/c-siphash/ git@github.com:c-util/c-siphash.git master --squash
2018-04-18 15:20:01 +02:00
Beniamino Galvani
1ea09eb549 Squashed 'shared/c-siphash/' content from commit 24e301e32
git-subtree-dir: shared/c-siphash
git-subtree-split: 24e301e32939be88744a9d0f81d18d9b7b8f4e37
2018-04-18 15:19:58 +02:00
Beniamino Galvani
aca671fff0 all: replace "it's" with "its" where needed 2018-04-18 14:14:07 +02:00
Thomas Haller
b01ebd7399 core: merge branch 'th/manager-cleanup'
https://github.com/NetworkManager/NetworkManager/pull/91
2018-04-18 14:08:43 +02:00
Thomas Haller
c3fb02641a device: set device's sys-iface-state only shortly before activating device
During _new_active_connection() we just create the NMActiveConnection
instance to proceed with authorization. The caller might not even
authorize, so we must not touch the device yet.

Do that only later.
2018-04-18 07:55:15 +02:00
Thomas Haller
9fe4239f33 manager: some refactoring of error paths to return early
Often, functions perform a series of steps, and when they fail,
they bail out. It's simpler if the code is structured that way,
so you can read it from top to bottom and whenever something is
wrong, either return directly (or goto a cleanup label at the
bottom).
2018-04-18 07:55:15 +02:00
Thomas Haller
5c4a6e9b6d manager: ensure valid specific_object path is passed to _new_active_connection()
From the D-Bus layer, no specific-object is represented by "/". We
should early on normalize such values to NULL, and not expect or
handle them later (like during _new_active_connection()).
2018-04-18 07:55:15 +02:00
Thomas Haller
10753c3616 manager: merge VPN handling into _new_active_connection()
Merge _new_vpn_active_connection() into _new_active_connection(). It was the
only caller, and it is simpler to have all the code visible at one place.

That also shows, that the device argument is ignored and not handled.
Ensure that no device is specified for VPN type activations.
2018-04-18 07:55:15 +02:00
Thomas Haller
0458e4bb28 manager: use cleanup attribute in impl_manager_add_and_activate_connection() and related
Also, in _add_and_activate_auth_done(), always steal the connection
from active's user-data. Otherwise, the lifetime of the connection
is extended until active gets destroyed. For example, if we would leak
active, we would also leak connection that way.
2018-04-18 07:55:15 +02:00
Thomas Haller
3e3d53ce69 manager: add is-vpn argument to _new_active_connection() and avoid searching existing activations
- pass is-vpn to _new_active_connection(). It is confusing that _new_active_connection()
  would re-determine whether a connection is a VPN type, although that was already
  established previously. The confusing part is: will they come to the
  same result? Why? What if not?
  Instead pass it as argument and assert that we got it right.

- the check for existing connections should look whether there is an existing
  active connection of type NMVpnConnection. Instead, what matters is,
  - do we have a connection of type VPN (otherwise, don't even bother
    to search for existing-ac)
  - is the connection already active?
  Checking whether the connection is already active, and ask backwards
  whether it's of type NMVpnConnection is odd, maybe even wrong in
  some cases.
2018-04-18 07:55:15 +02:00
Thomas Haller
7fcdca29b6 manager: add _connection_is_vpn() helper to unify checks for VPN type 2018-04-18 07:55:15 +02:00
Thomas Haller
bdc622fd31 manager/trivial: rename boolean variable "vpn" to "is_vpn" 2018-04-18 07:55:15 +02:00
Thomas Haller
bac7a2821f core: cleanup NMManager's validate_activation_request()
- there are only two callers of validate_activation_request(). One of them,
  might already lookup the device before calling the validate function.
  Safe to looking up again. But this is not only an optimization, more importantly,
  it feels odd to first lookup a device, and then later look it up again. Are
  we guaranteed to use the same path? Why? Just avoid that question.
- re-order some error checking for missing device, so that it is clearer.
- use cleanup attribute to handle return value and drop the "goto error".
2018-04-18 07:55:15 +02:00
Thomas Haller
aa86327e45 core: cleanup code by using nm_auth_is_subject_in_acl_set_error() 2018-04-18 07:55:15 +02:00
Thomas Haller
f94167d8b1 core: add nm_auth_is_subject_in_acl_set_error() helper 2018-04-18 07:55:15 +02:00
Thomas Haller
1a33ab17de core: downgrade assertion to nm_assert()
It can be easily verified, that these assertions should not ever fail.
Disable in production builds.
2018-04-18 07:55:15 +02:00
Thomas Haller
580a11da3a core: minor cleanup of handling specific-object in NMActiveConnection
- use nm_assert() for something that ~really~ always should be given.
- use nm_streq0() and nm_clear_g_free().
2018-04-18 07:55:15 +02:00
Thomas Haller
476208d223 core: don't explicitly set D-Bus path properties to "/"
NMDBusObject already gets this right, by calling nm_dbus_utils_get_property(),
which calls g_dbus_gvalue_to_gvariant(), which correctly converts NULL
object paths to "/".

We already rely on that elsewhere. No need for this workaround.
2018-04-18 07:55:15 +02:00
Thomas Haller
5284690f18 core: use nm_utils_dbus_normalize_object_path() to cleanup D-Bus argument 2018-04-18 07:55:15 +02:00
Thomas Haller
34bbcc70b8 core: sort D-Bus paths in nm_dbus_utils_g_value_set_object_path_from_hash() 2018-04-18 07:55:15 +02:00
Thomas Haller
6ec4dfce69 libnm-core: improve documentation for autoconnect and autoconnect-slaves properties 2018-04-18 07:55:15 +02:00
Thomas Haller
56a3f3bba9 shared: add nm_utils_dbus_normalize_object_path() helper 2018-04-18 07:55:15 +02:00
Thomas Haller
be9a5ab308 shared: add nm_utils_strv_sort() helper 2018-04-18 07:55:15 +02:00
Thomas Haller
458b422468 shared: add NM_CAST_STRV_*() helper macros 2018-04-18 07:55:15 +02:00
Thomas Haller
a99d51cb50 auth-manager: fix potential issue iterating modified CList in _dbus_new_proxy_cb()
In the loop, we invoke callbacks. What the callbacks do, is out of control
of NMAuthManager. For example, they could cancel or schedule new
requests. Especially, cancelling invalidate the stored @safe pointer.

Fix that, by always iterate from the start of the list.

Fixes: d0563f0733
2018-04-18 07:51:29 +02:00
Beniamino Galvani
0fa57069ad auth-manager: fix processing calls in _dbus_new_proxy_cb()
In the first loop, the element is removed only when the callback is
executed. The second loop never removes the current element. Use the
for_each macro for both.

Fixes: d0563f0733
2018-04-17 16:22:34 +02:00
Beniamino Galvani
cbeabaa000 core: fix wrong assertion when disposing NMAuthManager
The list should be empty on disposal.

Fixes: 2ea2df3184
2018-04-17 16:01:36 +02:00
Richard Schütz
9326902cf1 dhcp: don't enforce broadcast flag
Requesting broadcast replies from the DHCP server can be problematic in
filtered environments like some wireless networks. Don't override the
default of using unicast. This matches the behaviour of the external DHCP
clients.

https://github.com/NetworkManager/NetworkManager/pull/93
2018-04-17 11:03:04 +02:00
Beniamino Galvani
d0563f0733 auth-manager: don't process idle calls when the proxy creation finishes
The list of calls contains two kinds of elements: (1) calls that don't
need a D-Bus request and are only waiting for the asynchronous
invocation of the callback in an idle function; (2) calls that need a
D-Bus request and are waiting for the D-Bus proxy.

When the proxy creation finishes, only (2) calls must be canceled (if
the creation failed) or started (if the proxy was created).

Fixes: 798b2a7527

https://bugzilla.redhat.com/show_bug.cgi?id=1567807
2018-04-17 10:17:25 +02:00
Thomas Haller
41e0ca6824 cli/polkit: merge branch 'th/polkit-cleanup'
https://github.com/NetworkManager/NetworkManager/pull/90
2018-04-16 16:35:20 +02:00
Thomas Haller
347118138d cli: rework callbacks in NMPolkitListener to use one vtable structure
Instead of setting multiple callbacks, just let the user set one
vtable with callbacks. Usually, GObject would implement this via
signals. While that makes sense for public objects, for example to
work better with GIR and allow intercepting the signal, this is
overkill for our internal type. And NMPolkitListener already did
not make use of signals, for good reason.

Instead of passing multiple callbacks, must pass one structure with
callback pointers.

Also, extend the signature of the callbacks to always contain a
@self argument and a @user_data.
2018-04-16 16:03:14 +02:00
Thomas Haller
86ab96989d clients: move code around in "nm-polkit-listener.c"
Follow a standard order for the code.
2018-04-16 16:03:14 +02:00
Thomas Haller
0ee8e2f57b clients: cleanup includes for polkit sources
Some cleanup of the includes. For example, immediately after
"nm-default.h" include the header file for the current source.

Also, move the use of the "#if WITH_POLKIT_AGENT" conditionals
closer together. E.g. don't use the #if in "nmcli.h".
2018-04-16 16:03:14 +02:00
Thomas Haller
44d638d69d auth-subject: minor cleanup of _new_unix_process()
Drop the g_assert(), which is always compiled in, but obviously
can never fail.
2018-04-16 16:03:14 +02:00
Thomas Haller
e5e8f86c3d shared: move nm_utils_get_start_time_for_pid() to shared/nm-utils
We will also use it in nmcli later. It will be needed when we replace
polkit_unix_process_new_for_owner(). Which is still far down the road.
2018-04-16 16:03:14 +02:00
Thomas Haller
313f47c915 all: merge branch 'th/settings-flags-rh1460295'
https://bugzilla.redhat.com/show_bug.cgi?id=1460295
https://github.com/NetworkManager/NetworkManager/pull/88
2018-04-16 15:30:23 +02:00
Thomas Haller
aae483c0a9 settings: add NMSettingsConnectionFlags flags
Up to now, it was not visible on D-Bus whether a connection
was generated by NetworkManager and/or volatile.

That is for example interesting for firewalld, which aims
to store persistant configuration in NetworkManager's profile.
However, that doesn't make sense for external connections
(which are nm-generated & volatile). In fact, it probably
makes no sense for volatile connections in general, because
modifying them, likely makes them non-volatile (depending on
how the profile is modified).

Also, the Update2() D-Bus operation allows to carefully
make connections volatile and unsaved. As we have public
API to set these flags, we should also expose them on D-Bus.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1460295
2018-04-16 15:30:07 +02:00
Thomas Haller
acc8244ca2 all: add D-Bus property "Flags" for Settings.Connection interface
The D-Bus interface already has a boolean property "Unsaved".

While that is nicer too look at (in the API), adding a new flag
is very cumbersome, and also has more overhead. For example,
it requires extending the D-Bus API, all the way down to libnm.

Add a flags argument, that will allow to add future boolean
flags easier.
2018-04-16 15:30:07 +02:00
Thomas Haller
8df245d773 settings: make NM_SETTINGS_CONNECTION_FLAGS property NM_SETTINGS_CONNECTION_FLAGS_CHANGED signal
For one, these flags are "internal" flags. Soon, we will gain
a new NMSettingsConnectionFlags type that is exported on D-Bus
and partly overlaps with these internal flags. However, then we
will need the "flags" properties to expose the public bits.

This property only exists because other parts are interested in
notification signals. Note that we encourage NMDbusObject types
to freeze/thaw property-changed notifications. As freezing the
notifications also delays the signals, this is not desired for
the purpose where internal users subscribe to the signal.
2018-04-16 15:30:07 +02:00
Thomas Haller
417c7ebe4a core/trivial: rename "NMSettingsConnectionFlags" to "NMSettingsConnectionIntFlags"
"NMSettingsConnectionFlags" was an internal enum. Soon, we will add such
a type in libnm. Avoid the naming conflict by renaming. The "Int" stands
for "internal".
2018-04-16 15:30:07 +02:00
Beniamino Galvani
95340f6c6d cli: merge branch 'bg/nmcli-overview-rh1434527'
https://bugzilla.redhat.com/show_bug.cgi?id=1434527
2018-04-13 17:21:01 +02:00
Thomas Haller
c9a574f12f clients: use nm_utils_strv_make_deep_copied() to deep copy const strv array 2018-04-13 17:02:55 +02:00
Beniamino Galvani
9a19bbcb2f nmcli: add overview option to skip default values in output
Add a new 'overview' command line option to make the output more
compact and display only properties that have non-default
values. Currently the option has only effect for the "connection show
$CON" sub-command.

 $ nmcli -o connection show wifi-home
 connection.id:                          wifi-home
 connection.uuid:                        8308c425-f2a7-4021-9afc-37bde7253c6d
 connection.type:                        802-11-wireless
 connection.timestamp:                   1519264421
 connection.permissions:                 user:me
 802-11-wireless.ssid:                   home
 802-11-wireless.mode:                   infrastructure
 802-11-wireless-security.key-mgmt:      wpa-psk
 802-11-wireless-security.auth-alg:      open
 ipv4.method:                            auto
 ipv6.method:                            auto

https://bugzilla.redhat.com/show_bug.cgi?id=1434527
2018-04-13 17:02:55 +02:00
Beniamino Galvani
50414353e1 clients: set @out_is_default in property getters 2018-04-13 17:02:55 +02:00
Beniamino Galvani
1f2319dcb9 clients: change nm_meta_abstract_info_get() to report defaults
Return a boolean to indicate whether the value is the default one, so
that the caller can choose to hide it.
2018-04-13 17:02:55 +02:00
Beniamino Galvani
defe869ee3 clients: meta: consolidate wep-key get functions 2018-04-13 17:02:55 +02:00