Commit Graph

20147 Commits

Author SHA1 Message Date
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
Beniamino Galvani
350345fff4 clients: meta: use enum setter for secret flags 2018-04-13 17:02:55 +02:00
Beniamino Galvani
ae54a75298 clients: meta: define ipv6.ip6-privacy as an enum type
Reuse the existing enum type for ipv6.ip6-privacy instead of defining
custom get and set functions. It is now possible to set the enum to
"unknown".
2018-04-13 17:02:55 +02:00
Beniamino Galvani
8b4bb725d7 clients: meta: add enum getter-only nicks
Add a new a new field to enum type descriptors that specify a list of
nicks valid only for getter functions. It is useful when the get
function must return a string different from the enum nick and that
string can't be used to set a value.
2018-04-13 17:02:55 +02:00
Beniamino Galvani
919f6b6d75 shared: use value infos in _nm_utils_enum_to_str_full 2018-04-13 17:02:55 +02:00
Thomas Haller
6fbbb5be74 auth-subject: fix potential memory corruption in nm_auth_subject_to_string()
We don't want to apped the value to @buf, we want to set it.
Also, if @buf happens to be uninitialized, g_strlcat() might
determine there is nothing to append and return the buffer unmodified.
Then, the (non NULL terminated) buffer might be printed.

Note that before recent refactoring, we effectively would only call
nm_auth_subject_to_string() on auth-subjects that were of type
UNIX-PROCESS. Hence, this bug came only to light very recently,
although it was present for a long time.

Fixes: eabe7d856c
2018-04-13 11:34:08 +02:00
Thomas Haller
09e44b96dd policy: fix potential leak of subject in auto_activate_device() 2018-04-13 11:22:17 +02:00
Thomas Haller
378833518a settings: return empty connections list on D-Bus util connections are loaded
We also don't emit the PropertiesChanged signal while connections are
not loaded. Maybe that is wrong, in any case, the property should agree
with the way how we emit notifications. So, for now, make the property
agree with not notifying about connections during startup.
2018-04-13 10:48:37 +02:00
Thomas Haller
e41db3fa55 settings: fix clearing agent-manager in NMSettings' dispose()
dispose() should be re-entrant. When releasing a resource, it must not
leave a dangling pointer. While at it, just move it to finalize() instead.
2018-04-13 10:34:43 +02:00
Thomas Haller
a92543d3b7 settings: use cleanup-attribute in send_agent_owned_secrets() 2018-04-13 10:34:42 +02:00
Thomas Haller
26a8d2a151 settings: fix leaking connection in NMSettings' connection_removed()
Also, take a reference of the NMSettingsConnection while
it is being tracked by NMSettings' list.

Fixes: 1f3b47deea
2018-04-13 10:34:03 +02:00
Thomas Haller
e9de083c64 core/trivial: adjust code comment 2018-04-13 10:18:26 +02:00
Thomas Haller
684bf31150 all: unify spelling of translators hint in source code
Use the same form everywhere: "TRANSLATORS" instead of "Translators".
The manual also seems to prefer the upper-case form [1].

  $ sed 's/\<Translators\>: /TRANSLATORS: /g' $(git grep -l Translators) -i

[1] https://www.gnu.org/software/gettext/manual/gettext.html
2018-04-13 10:00:09 +02:00
Thomas Haller
f69dbd71fe core: merge branch 'th/settings-cleanup'
https://github.com/NetworkManager/NetworkManager/pull/85
2018-04-13 09:24:59 +02:00
Thomas Haller
04a42e2748 auth-chain: create data-hash hashtable only when needed
It makes sense to use NMAuthChain also when not attaching any user-data to
the chain. The main reason would be, the ability to schedule multiple permission
checks in parallel, and wait for them to complete together.

Only allocate the hash-table, when we really need it.
2018-04-13 09:09:46 +02:00
Thomas Haller
457b08bbb6 auth-chain/trivial: rename data field in NMAuthChain
We already use "data" for other places. Let's use unique names
that can be searched within one file.
2018-04-13 09:09:46 +02:00
Thomas Haller
c05088a09b core: don't use NMAuthChain in NMActiveConnection but directly schedule events
More of a proof of concept, how convenient (or not) it is to drop
NMAuthChain and use NMAuthManager's API directly. I think it's
reasonably nice.

As before, when asking for both general network-control permissions
and wifi-shared-permissions, we will not fail with
wifi-shared-permissions, as long as network-control check is still
pending. The effect is, that the error response preferably complains
about no permissions to network-control (in case both permissions
are missing).

One change in behavior is, if network-control authorization check
fails before wifi-shared-permissions, we declare the result and
cancel the pending wifi-shared-permissions. Previously, we would
have waited for both results. The change in behavior is not merely
that we declare the result earlier, but also that NMAuthManager will
actively send a "CancelCheckAuthorization" D-Bus call to cancel the
still pending wifi-shared-permissions check.
2018-04-13 09:09:46 +02:00
Thomas Haller
8722703892 auth-chain: drop logging in NMAuthChain when request fails
For one, we already do <trace> level logging inside NMAuthManager.
So, at trace level we have everything.

If a request fails, it's not up to NMAuthChain to log a warning.
2018-04-13 09:09:46 +02:00
Thomas Haller
9385c7a7cf settings: rework scheduling of authorization requests in settings-connection
Get rid of the NMAuthChain layer.

I think NMAuthChain only makes sense if we schedule multiple requests
together for the same topic. But NMSettingsConnection never does that:
each D-Bus request corresponds to only one polkit authorization request.
So, we can just call NMAuthManager directly.
2018-04-13 09:09:46 +02:00
Thomas Haller
6ab0939e34 settings: cancel pending authorization requests if connection gets removed
Otherwise, the autorization request might succeed and we would
still do something with the connection that is already removed.

https://bugzilla.redhat.com/show_bug.cgi?id=1565030
2018-04-13 09:09:46 +02:00
Thomas Haller
f0bddb44e0 auth-manager: add helper function nm_auth_call_result_eval()
This makes NMAuthCallResult not only usable from within a NMAuthChain.
It makes sense to just call nm-auth-manager directly, but then we need
a way to convert the more detailed result into an NMAuthCallResult
value.
2018-04-13 09:09:46 +02:00
Thomas Haller
798b2a7527 auth-manager: let NMAuthChain always call to NMAuthManager for dummy requests
NMAuthChain's nm_auth_chain_add_call() used to add special handling for
the NMAuthSubject. This handling really belongs to NMAuthManager for two
reasons:
 - NMAuthManager already goes through the effort of scheduling an idle
   handler to handle the case where no GDBusProxy is present. It can
   just as well handle the special cases where polkit-auth is disabled
   or when we have internal requests.
 - by NMAuthChain doing special handling, it makes it more complicated
   to call nm_auth_manager_check_authorization() directly. Previously,
   the NMAuthChain had additional logic, which means you either were
   forced to create an NMAuthChain, or you had to reimplement special
   handling like nm_auth_chain_add_call().
2018-04-13 09:09:46 +02:00