Commit Graph

13873 Commits

Author SHA1 Message Date
Lubomir Rintel
f589c66b12 audit-manager: don't log connection whose addition fails
In AddAndActivate the uuid and id make no sense until authorization succeeds
and the connection is saved.
2015-09-18 16:12:36 +02:00
Thomas Haller
b5a6883c10 vpn-connection: use logging macros _LOG*()
This now gives every logging line of a NMVpnConnection
a fully descriptive prefix.

Especially for non-debug logging, this looks a bit verbose
and repetitive, so we could suppress the prefix in that case.
I still add it because I think the verbose information does help
during debugging.
2015-09-18 16:12:36 +02:00
Thomas Haller
72c85c29a7 vpn-connection: add logging macros _LOG*() 2015-09-18 16:12:36 +02:00
Thomas Haller
d48ed98eb3 vpn-connection/trivial: consistently rename @connection argument to @self 2015-09-18 16:12:36 +02:00
Thomas Haller
6006a0b134 core/manager: use active_connection_get_by_path() in impl_manager_deactivate_connection() 2015-09-18 16:12:36 +02:00
Thomas Haller
31deca0157 libnm: fix missing case in "nm-remote-connection.c"
Fixes: d20bed069c
2015-09-18 16:11:47 +02:00
Jiří Klimeš
d20bed069c libnm: fix initializing of new connections
connection_added() can be called before init_get_settings_cb(), and we can't
complete the connection until it is visible, else it would be uninitialized.

Test case:
* have 'em1' interface
$ nmcli con add type ethernet con-name myeth ifname em1 autoconnect no
(process:9039): libnm-CRITICAL **: nm_connection_get_id: assertion 's_con != NULL' failed
Connection '(null)' ((null)) successfully added.

$ nmcli con add type ethernet con-name myeth ifname em1X autoconnect no
Connection 'myeth' (71159504-c2af-4773-8ca9-a3626aa0da33) successfully added.

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

[lkundrak@v3.sk: This is not quite the correct fix, we shouldn't emit
NMObject:connection-added for an unfinished object. Nevertheless, let's go with
it until we have a better one. Will revert this afterwards. See linked bugs.]
2015-09-18 15:54:39 +02:00
Thomas Haller
6c989bb68f core: merge branch 'th/secret-requests-bgo754508'
https://bugzilla.gnome.org/show_bug.cgi?id=754508
2015-09-18 14:31:31 +02:00
Thomas Haller
1b5664fed4 agent-manager: always invoke complete function for asynchronous nm_agent_manager_get_secrets()
Refactor agent-manager to always invoke the complete function for
nm_agent_manager_get_secrets().

In general, the complete function is always invoked asnychronously
when starting the operation. On the other hand, when cancelling the
operation or disposing the manager with pending operations, we now
(always) synchronously invoke the callback.

This makes it simpler for the user to reliably cancel the request
and perform potential cleanup.

This behavior bubbles up through NMSettingsConnection and NMActRequest,
and other callers that make directly or indicrectly make use of
nm_agent_manager_get_secrets().
2015-09-18 14:31:31 +02:00
Thomas Haller
afb37d706f secret-agent/trivial: add code comment 2015-09-18 14:31:31 +02:00
Thomas Haller
21fd5fa0ab settings: refactor call_id type of async functions for NMAgentManager, NMSettingsConnection and NMActRequest
Instead of having the call_id of type guint32, make it an (opaque)
pointer type.

This has the advantage of strong typing and avoids the possiblity
of reusing an invalid integer (or overflow of the call-id counter).

OTOH, it has the disadvantage, that after a call_id is disposed,
it might be reused for future invocations (because malloc might
reuse the memory).

In fact, it is always an error to use a call_id that is already
completed. This commit also adds assertions to the cancel() calls
that the provided call_id is a pending call. Hence, such a bug
will be uncovered by assertions (that only might not tigger in
certain unlikely cases where a call-id got reused).

Note that for NMAgentManager, save_secrets() and delete_secrets()
both returned a call_id. But they didn't also provide a callback when
the operation completes. So the user trying to cancel such a call,
cannot know whether the operation is still in process and he cannot
avoid triggering an assertion.
Fix that by not returning a call-id for these operations. No caller
cared about it anyway.

For NMSettingsConnection, also track the internally scheduled requests
for so that we can cancel them on dispose.
2015-09-18 14:31:31 +02:00
Thomas Haller
40eda71dc6 agent-manager: fix type of idle_id in Request structure 2015-09-18 14:31:31 +02:00
Thomas Haller
7a8eee99ff agent-manager/refact: return early from _con_get_try_complete_early() instead of if-else-if 2015-09-18 14:31:31 +02:00
Thomas Haller
0205dc9f5a agent-manager/trivial: rename functions 2015-09-18 14:31:31 +02:00
Thomas Haller
4ccae95802 agent-manager/refact: replace get_start() by request_start()
Let all implementations call request_start(), instead of
getting-secrets doing something special and call get_start().
2015-09-18 14:31:31 +02:00
Thomas Haller
ea57ecc8ee agent-manager/refact: replace function callbacks by direct calls or inline
Drop the function pointers. Instead either inline them or
call them explicitly (possibly after switching on the request_type).
2015-09-18 14:31:31 +02:00
Thomas Haller
745d501859 agent-manager/refact: merge the subclasses into Request
Merge ConnectionRequest structure into Request.
2015-09-18 14:31:31 +02:00
Thomas Haller
55d672347f core/trivial: add code comment to nm_utils_get_shared_wifi_permission() 2015-09-18 14:31:31 +02:00
Thomas Haller
9e3d3083d2 auth-utils: some refactoring in nm-auth-utils.c
- move nm_auth_chain_check_done() and nm_auth_chain_remove_call()
  into the only caller auth_call_complete().

- take a ref of the "context" argument.

- in nm_auth_chain_add_call(), assert that we didn't yet invoke the
  done-callback. The auth-chain should not be reusued.

- use slice allocator for ChainData, AuthCall and NMAuthChain
2015-09-18 14:31:31 +02:00
Lubomir Rintel
d7614d0bda gitignore: ignore GDBus generated glue 2015-09-18 13:53:30 +02:00
Thomas Haller
b6459ace2f platform: merge branch 'th/platform-permanent-hwaddr-rh1264024'
https://bugzilla.redhat.com/show_bug.cgi?id=1264024
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1256430
2015-09-18 13:32:31 +02:00
Thomas Haller
2733aacd64 platform: don't accept 00:00:00:00:00:00 as valid permanent address
In nmp_utils_ethtool_get_permanent_address(), don' accept a permanent
address of all zeros.

https://bugzilla.redhat.com/show_bug.cgi?id=1264024
2015-09-18 13:29:34 +02:00
Thomas Haller
2e66aea123 platform: stack-allocate request data for nmp_utils_ethtool_get_permanent_address() 2015-09-18 13:29:34 +02:00
Thomas Haller
3a68039232 all: merge branch 'lr/default-unmanaged-bgo746566'
Make the "managed" property of devices mutable via D-Bus.
Also, add a `nmcli device set` command.

https://bugzilla.gnome.org/show_bug.cgi?id=746566
2015-09-18 13:19:53 +02:00
Thomas Haller
aeaf31b7a8 device/trivial: rename nm_device_get_unmanaged_flag() to nm_device_get_unmanaged()
This way, the function matches the other names like nm_device_set_unmanaged().
Arguably, the name currently makes some sense. But future commits will make
nm_device_get_unmanaged() more to be a counterpart of nm_device_set_unmanaged().
2015-09-18 13:18:05 +02:00
Thomas Haller
ef4aa6c555 device/trivial: rename nm_device_set_initial_unmanaged_flag() to nm_device_set_unmanaged_initial()
That way, the name matches better with related functions named
nm_device_set_unmanaged*()
2015-09-18 13:14:44 +02:00
Thomas Haller
7405d5c7b7 nmcli: extend nmcli device set command to accept explicit ifname specifier
Without it, you cannot set the properties of a device named "help".
Now you can with:

  $ nmcli device set ifname help autoconnect no
2015-09-18 13:14:44 +02:00
Lubomir Rintel
4dffbf8f6a cli: add nmcli device set command
Co-Authored-By: Thomas Haller <thaller@redhat.com>
2015-09-18 13:14:35 +02:00
Lubomir Rintel
b2fa116486 libnm,libnm-glib: add Device.Managed setter 2015-09-18 13:14:23 +02:00
Thomas Haller
0eebf580c1 device: allow modifying Managed property
https://bugzilla.redhat.com/show_bug.cgi?id=1114685
https://bugzilla.gnome.org/show_bug.cgi?id=746566
Related: https://bugzilla.gnome.org/show_bug.cgi?id=680909
Related: https://bugzilla.gnome.org/show_bug.cgi?id=731014

Based-on-patch-by: Lubomir Rintel <lkundrak@v3.sk>
2015-09-18 13:14:23 +02:00
Beniamino Galvani
69315953eb core: merge branch 'bg/update-metered-on-the-fly-bgo724041'
https://bugzilla.gnome.org/show_bug.cgi?id=754409
2015-09-18 11:53:21 +02:00
Beniamino Galvani
2562a993c4 policy: react to firewall/metered changes on UPDATED_BY_USER signal
Subscribe to the UPDATED_BY_USER signal (instead of UPDATED) to listen
for changes to the firewall zone and metered properties of a
connection since these modifications are supposed to come from user
intervention.
2015-09-18 11:48:37 +02:00
Beniamino Galvani
d910c94beb policy: update device's metered property when connection changes
If the metered property of a connection is changed, an activated
device associated to the connection must be updated immediately with
the new metered value.

https://bugzilla.gnome.org/show_bug.cgi?id=754409
2015-09-18 11:48:37 +02:00
Beniamino Galvani
94fea0b581 policy: refactor handling of UPDATED signal
Obtain a reference to the device in connection_updated() so that it
will be easier to call other functions needing it.
2015-09-18 11:48:37 +02:00
Thomas Haller
54afd0400b platform: merge branch 'th/platform-refresh-link-bgo754996'
https://bugzilla.gnome.org/show_bug.cgi?id=754996
2015-09-18 11:27:40 +02:00
Thomas Haller
f4f4e1cf09 platform: cancel delayed action REFRESH_LINK when receiving an update
When we receive an update for a link, cancel a scheduled
REFRESH_LINK delayed-action for that ifindex. At the point when we
scheduled refrehing the link, we only cared about receiving a
notification that was newer then the current state.

We scheduled requesting this new notification to resync the cache.
It is not necessary to actually request a new update, any update we
receive *after* requesting a new update will suffice.

This potentially saves extra round-trips re-requesting the link.
2015-09-18 11:24:21 +02:00
Thomas Haller
2cd6aaa918 platform: refresh links when parent gets removed
When moving a link to another netns, it gets removed from
NMPlatform's view.

Currently kernel does not sent a notification to inform about
that change (see related bug rh#1262908).

Ensure that we reload all linked interfaces which now might
have an invisible parent.
2015-09-18 11:05:37 +02:00
Thomas Haller
eee240ffe8 platform: fix handling refresh-link delayed actions
Due to a bug, we would only handle one REFRESH_LINK delayed action
and ignore the ones queued afterwards.

Fixes: 051cf8bbde
2015-09-18 11:01:21 +02:00
Jiří Klimeš
0f694f1a9a coverity: calm coverity for clock_gettime() return value check
Defect type: CHECKED_RETURN
3. NetworkManager-1.0.6/src/platform/nm-linux-platform.c:1145: check_return: Calling "clock_gettime" without checking return value (as is done elsewhere 6 out of 7 times).
2015-09-18 08:40:08 +02:00
Thomas Haller
d20948647c exported-object: fix type of @interface variables to be GDBusInterfaceSkeleton 2015-09-17 16:59:16 +02:00
Jiří Klimeš
ed85fcc711 ifcfg-rh: ignore GATEWAY from network file for DHCP connections (rh #1262972)
The GATEWAY from /etc/sysconfig/network file is used as a default value when
no GATEWAY is in ifcfg file. However, we have to ignore that GATEWAY for
connections without static addresses. Otherwise such connections would be
invalid and would disappear after restart/reaload.

Some notes:
Putting GATEWAY into /etc/sysconfig/network is not recommended, because it
inherently belongs to the ifcfg file as it is a per-interface property.
The recommended practice is to specify GATEWAY in individual ifcfg files and
define DEFROUTE=no if the interface should not get the default route.
But we continue to read GATEWAY from /etc/sysconfig/network for compatibility
reasons.
See also
https://bugzilla.redhat.com/show_bug.cgi?id=896198#c25
https://bugzilla.redhat.com/show_bug.cgi?id=896198#c27

Fixes: f17699f4e3

https://bugzilla.redhat.com/show_bug.cgi?id=1262972
2015-09-17 15:02:35 +02:00
Jiří Klimeš
64e3873faf ifcfg-rh: (trivial) remove unused network_file parameter 2015-09-17 15:02:35 +02:00
Jiří Klimeš
8e3ae81566 examples: generate UUID in add-wifi-eap-connection.py
so that it can be run multiple times.
2015-09-17 14:49:04 +02:00
Jiří Klimeš
a25bbde641 examples: add a python example for adding WPA PSK Wi-Fi connection
and rename add-system-wifi-connection.py to add-wifi-eap-connection.py
2015-09-17 14:46:19 +02:00
Thomas Haller
9e52613612 dhcp/systemd: fix leaking leases after dhcp_lease_load()
Fixes: d2dd3b2c90
2015-09-17 12:14:22 +02:00
Thomas Haller
ed5577f762 dhcp/systemd: fix unrefing lease after API change of sd_dhcp_client_get_lease()
sd_dhcp_client_get_lease() no longer refs the lease as of
e6b18ffaea

Fixes: c05557971c
2015-09-17 12:05:50 +02:00
Thomas Haller
597efc7687 Revert "systemd/dhcp: make sd_dhcp_lease_*() functions public again"
Upstream systemd made a previously "public" API internal. In commit
e82f430eae I fixed that up by reverting
the upstream patch. Revise that, and instead adjust our usage of the
API to use the internal API.

After all, we anyway make use of systemd API that is not (currently)
intended to become part of the public API. Before the systemd library
happens, we must revisit this.

This reverts commit e82f430eae.
2015-09-16 17:11:39 +02:00
Thomas Haller
2ca1021168 systemd/build: split CPPFLAGS to only include needed paths
Optimally, we only make use of systemd API that is intended to be public
and that will be later part of the system-library. That is currently
not yet possible and we need "-Isrc/systemd/src/basic" to build
"nm-dhcp-systemd.h". Still, split the include paths to build systemd
code itself, contrary to the user of the API.
2015-09-16 16:55:43 +02:00
Thomas Haller
3ba1c8e297 systemd/build: use separate NETWORKMANAGER_COMPILATION define for systemd build 2015-09-16 16:54:51 +02:00
Thomas Haller
c05557971c systemd: merge branch 'systemd-integration' into master 2015-09-16 16:54:03 +02:00