Commit graph

856 commits

Author SHA1 Message Date
Marius Vollmer
1bb00ae66a manager: Add "Capabilities" property 2016-09-23 15:49:52 +02:00
Beniamino Galvani
cdedd2b53e manager: emit device-removed signal when a device unrealizes
The 'device-added' and 'device-removed' signals indicate when the
value of the 'Devices' property changes. The property only returns
realized devices and so if a device unrealizes we should emit the
removed signal for it.

Fixes: 5da37a129c

https://bugzilla.gnome.org/show_bug.cgi?id=771324
2016-09-16 16:27:11 +02:00
Thomas Haller
cdf6ad4057 core: use _NM_GET_PRIVATE() macros 2016-09-08 00:21:21 +02:00
Thomas Haller
633344bf27 core: use #define for "rfkill-changed" signal name
(cherry picked from commit 640fbec855)
2016-08-23 11:46:28 +02:00
Beniamino Galvani
772a9cb05d core: check valid uid for D-Bus load_connection(s)/set_logging calls
Commit 4c7fa8dfdc ("core: drop root requirement for
load_connection(s)/set_logging D-Bus calls") removed the enforcing of
permission in the daemon for such methods since the D-Bus daemon
configuration already does that. That change also allows clients to
send a request and not wait for a response, since we don't have to
check the caller credentials in the daemon.

In the future we might switch to polkit for these methods, breaking
clients that don't wait for a reponse, so it seems better to prevent
from beginning such behavior.

Fixes: 4c7fa8dfdc
(cherry picked from commit dd27b79c4e)
2016-08-23 11:24:19 +02:00
Beniamino Galvani
a77ed0de97 core: drop root requirement for load_connection(s)/set_logging D-Bus calls
The D-Bus configuration already ensures that only root can do that;
enforcing the permission at policy level seems better than doing it in
the daemon itself because it allows users to change the policy and
also because callers can exit immediately after issuing the request.

(cherry picked from commit 4c7fa8dfdc)
2016-08-20 10:45:53 +02:00
Thomas Haller
14a7b2a4fe manager: add explicit cast for g_object_set()
Technically, this is not needed because glib requires that
int is at least 32 bits. Thus, uint32 will be safely promoted
to uint.

Just do the cast to be explict about the expected type.
2016-08-17 16:08:21 +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
Beniamino Galvani
a82e514822 checkpoint: add audit support 2016-08-17 14:55:34 +02:00
Beniamino Galvani
a52d4654ec checkpoint: use polkit to check permission 2016-08-17 14:55:34 +02:00
Beniamino Galvani
3e09aed2a0 checkpoint: add create, rollback and destroy D-Bus API
Co-authored-by: Thomas Haller <thaller@redhat.com>
2016-08-17 14:55:34 +02:00
Thomas Haller
5b4581b361 manager: preserve constness in NM_MANAGER_GET_PRIVATE() and add compile-time type check 2016-07-01 15:31:41 +02:00
Thomas Haller
5bded081a4 manager: use priv->config instead of singleton getter nm_config_get() 2016-07-01 14:30:00 +02:00
Thomas Haller
9f22f4e1ee manager: keep reference on NMAuthManager singleton
A singleton (NMManager) subscribing to another singleton (NMAuthManager)
should take a reference on the latter, to ensure its lifetime is
longer.
2016-07-01 14:26:49 +02:00
Thomas Haller
df8cf1462a core: refactor unmanaging devices on shutdown and unmanage Wi-Fi devices
Add new virtual function nm_device_unmanage_on_quit() to determine
whether to unmanage the device on shutdown.

This allows Wi-Fi devices to always be unmanaged. We want that to
reset the initial MAC address.
2016-06-30 08:29:56 +02:00
Thomas Haller
cc4371ef56 device: fix matching MAC address for VLAN and MACVLAN devices
VLAN and MACVLAN devices consider an ethernet.mac-address setting
to find the parent device. This setting shall be the permanent MAC
address of the device, not the current.
2016-06-30 08:29:55 +02:00
Dan Williams
f969193db4 platform/trivial: rename NM_LINK_TYPE_WWAN_ETHERNET to NM_LINK_TYPE_WWAN_NET
Some newer WWAN netdev types are "rawip" which don't bother with
ethernet framing.
2016-06-17 11:00:10 +02:00
Thomas Haller
d91f3b35d7 auth: fix get_permissions() D-Bus call for settings-modify-global-dns 2016-06-01 22:04:37 +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
0acee97220 config,dns: support Reload flags to specify that only parts should be reloaded
Support 3 new flags for Reload:

  - 0x01 (CONF): reload the configuration from disk
  - 0x02 (DNS_RC): write DNS configuration to resolv.conf
  - 0x04 (DNS_FULL): restart DNS plugin

Omitting all flags is the same as reloading everything, thus SIGHUP.
2016-06-01 19:06:34 +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
Beniamino Galvani
ec53ed2cba core: fix some memory leaks 2016-06-01 11:55:17 +02:00
Thomas Haller
5337003c4c core: drop NMConnectionProvider and use NMSettings directly
This is not C# but glib. Using interfaces is so cumbersome, that they
don't simplify code but make it more complicated.

E.g. following signals and its subscribers is complicated enough. It gets
more complicated by having NM_SETTINGS_SIGNAL_CONNECTION_ADDED and
NM_CP_SIGNAL_CONNECTION_ADDED. Of course, your favorite IDE has no idea
about glib interfaces, so figuring out who calls who gets more
complicated.

This undoes commit 4fe48b1273. Originally,
NMConnectionProvider had only one function get_best_connection(). But it
kept growing and more functions were added.

If we want to ~hide~ certain part of the NMSettings API, we should move them
to a separate header which gives internal access.
2016-05-24 12:35:58 +02:00
Thomas Haller
b4e8ce876d core: add nm_settings_get() singleton getter for NMSettings 2016-05-24 12:35:57 +02:00
Thomas Haller
c35164a6a3 settings/trivial: rename nm_settings_get_connections() to nm_settings_get_connections_sorted()
nm_settings_get_connections() returns a sorted list. We have many users
of nm_connection_provider_get_connection(), which returns the same result,
but undefined order.

Next NMConnectionProvider will be dropped. Thus, we don't want to
seamlessly replace nm_connection_provider_get_connection() by a sorted
version nm_settings_get_connections().

Rename nm_settings_get_connections() to make clear it is sorted.
2016-05-24 12:35:57 +02:00
Thomas Haller
7c785a064e device/trivial: rename nm_device_set_unmanaged_by_user_config() to nm_device_set_unmanaged_by_user_settings()
After all, it sets NM_UNMANAGED_USER_SETTINGS flag, so the name should
match with the flag.
2016-05-17 12:12:50 +02:00
Thomas Haller
dab2d46aa2 core: fix wrong rebase
Fixes: 25aaaab3b7
2016-05-13 19:28:04 +02:00
Dan Williams
25aaaab3b7 manager: don't unmanage devices without L3 config on shutdown
Use the following logic when quitting, if the device is managed:

  1) if the connection is assumed, leave it up
  2) if the device has no connection (eg, !req) leave it up
  3) if the device only has L2 leave it up

[thaller@redhat.com: original patch reworked by bgalvani@redhat.com and me]

https://bugzilla.redhat.com/show_bug.cgi?id=1311988
https://bugzilla.redhat.com/show_bug.cgi?id=1333983
2016-05-13 19:23:30 +02:00
Beniamino Galvani
81ea812362 manager: disconnect devices before unmanaging them on suspend/sleep
So that dispatcher scripts are run and other applications notified of
the change in connectivity.

https://bugzilla.redhat.com/show_bug.cgi?id=1330694
https://bugzilla.gnome.org/show_bug.cgi?id=748531
2016-05-13 14:40:54 +02:00
Thomas Haller
8bc895d5aa manager: embed NMManagerPrivate data directly into NMManager struct
For a type to be inheritable, its public struct (NMManager) must
be known. As nobody inherits NMManager, we can make it private.

As the struct is private anyway, we can also reuse it for the private
data directly, instead of registering NMManagerPrivate in the manager
class.

There are advantages and disadvantages:

  + simplifies debugging, as the self pointer also contains the
    private data.
  + removes a small overhead of tracking the private data separately
  - is a different way to implement the class, contrary to many
    other classes.
  - inheriting from the class later requires reverting this change
    (but we will never inherit from NMManager).
  - as it is now, nobody uses the priv field directly and we still
    access it via NM_MANAGER_GET_PRIVATE(self). However, the presence
    of the priv field might encourage us to use it directly -- which
    increases above disadvantages.
2016-04-28 14:36:24 +02:00
Thomas Haller
d27a80c4df manager: make NMManager's structs private
They are only useful when we want to derive a class
from NM_TYPE_MANAGER -- which we clearly don't.
2016-04-28 14:20:11 +02:00
Thomas Haller
bb8b9ca6f5 manager: remove unused signal slots from NMManagerClass 2016-04-28 14:20:00 +02:00
Thomas Haller
1e3b2cbb77 sleep-monitor: make sleep-monitor not a singleton
The only user of the sleep-monitor singleton was NMManager anyway.
Also, even if we ever get more users that are interested in the SLEEPING
signal, we would hook them onto NMManager -- because NMManager should
collect, coordinate and possibly forward the SLEEPING signal. In no case,
another object should react on the SLEEPING signal and thus bypassing the
NMManager.
2016-04-28 13:45:49 +02:00
Thomas Haller
07db1217a9 sleep-monitor: merge RESUMING signal into NMSleepMonitor's SLEEPING signal
Having two signals is more complicated and everybody who cares about
one signal also cares about the other.
2016-04-28 13:20:09 +02:00
Thomas Haller
e0c272c153 manager: use _LOGx() macros in nm-manager
They give each logging message a "manager: " prefix.
2016-04-27 18:29:51 +02:00
Thomas Haller
2158d6a5a8 manager: fix wrongly removing DNS configuration on shutdown
When NetworkManager exits, it must preserve the DNS configuration of
devices that are left up.

Fixes: 9498ea507e
2016-04-20 17:53:58 +02:00
Beniamino Galvani
34964273ee audit: log changed properties when updating a connection
The main purpose of audit logging is to understand who did what to the
system configuration, so it is useful to log also the list of changed
properties when a connection is updated:

 op="connection-update"
 uuid="2f3e48fc-5f47-41d9-9278-d2871378df43"
 name="pppoe1"
 args="pppoe.username,pppoe.password"         <========
 pid=9523
 uid=1001
 result="success"
2016-04-20 17:31:01 +02:00
Dan Williams
2b0e5cd6e6 Revert "core: don't leak ActiveConnection object on AddAndActivate failure"
This reverts commit 8b6a1ac62f.

Original patch was in error; 'active' is already gs_unref_object.
2016-04-19 14:14:25 -05:00
Thomas Haller
3164c026a2 settings: merge "connection-updated" and "connection-updated-by-user" signals
This is mostly interesting of NMPolicy, which no longer needs to
subscribe to two almost identical signals (where the by-user signal
was always invoked together with the plain "updated" signal).
2016-04-14 12:25:41 +02:00
Francesco Giudici
7796c489fd device: minor logging change in platform_link_added()
Show ignored devices in debug level.
2016-04-12 11:24:19 +02:00
Thomas Haller
d0836be0eb core: rename nm_config_run_state* to nm_config_state*
After all, this state is stored persistently to /var/lib/NetworkManager,
and not to volatile storage in /var/run. Hence the name is better.
It's also shorter, so rename it.

The commit is mostly trivial, including update of code comments
and logging messages.

Fixes: 1b43c880ba
2016-04-07 18:52:12 +02:00
Thomas Haller
1b43c880ba config: let NMConfig handle "NetworkManager.state" file (bgo#764474)
Move reading and writing of the state file to NMConfig
("/var/lib/NetworkManager/NetworkManager.state" file).

Originally, I intended to persist more state, thus it made
sense to cleanup handling of the state file and move it all
at one place. Now, it's not clear that will happen anytime soon.

Still, the change is a worthy cleanup, so do it anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=764474
2016-04-07 10:15:01 +02:00
Lubomir Rintel
9498ea507e manager: ensure IP config of device is cleared before removal
If the manager removes the device, the IP config objects must
be cleared. The reason is that NMPolicy registers to the IP config
changed signal and passes these object on to NMDnsManager.

If the INTERNAL_DEVICE_REMOVED signal is emited with IP configuration
object pending, those objects will be leaked.

This partly redoes commit f72816bf10,
which was reverted.

Co-Authored-By: Thomas Haller <thaller@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=764483
2016-04-04 23:10:20 +02:00
Thomas Haller
fe6940b692 manager: refactor error variable in platform_link_added()
Free the error via gs_free_error and create separate instances.
2016-04-04 21:26:51 +02:00
Thomas Haller
ccda474a02 manager: remove unused signal "user-permissions-changed" 2016-04-04 16:45:48 +02:00
Thomas Haller
9cc00d9e26 manager: use defines for signal names 2016-04-04 16:45:48 +02:00
Lubomir Rintel
a6fb37bae2 Revert "manager: don't remove the device before policy learns of ip config change"
This doesn't unexport the connection on disconnect (as opposed to device
removal).

This reverts commit f72816bf10.
2016-04-04 12:52:56 +02:00
Lubomir Rintel
f72816bf10 manager: don't remove the device before policy learns of ip config change
First let the device know it's being removed soon so that it has a
chance to clean up the IP configuration early.

If the manager removes the device fist, the policy never learns of
config removal and doesn't unhook it from the DNS manager resulting in a
IPConfig leak and possible wrong DNS configuration in effect.

Also adjust the route manager to skip over devices without IP
configuration when determining the best connection; it is perhaps
just due to being removed.

https://bugzilla.gnome.org/show_bug.cgi?id=764483
2016-04-04 12:40:40 +02:00
Thomas Haller
a6af426271 manager: fix memleak in error-path of _internal_enable() 2016-04-01 18:55:15 +02:00