NetworkManager/libnm
Thomas Haller f0d3243f2b libnm/secret-agent: fix race registering secret agent
When NetworkManager starts, NMSecretAgentOld gets a name-owner changed
signal and registers right away.

Especially since commit ce0e898fb4 ('libnm: refactor caching of D-Bus
objects in NMClient') this hits a race where NetworkManager does not yet
export the org.freedesktop.NetworkManager.AgentManager interface and
the registration fails:

   GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such interface “org.freedesktop.NetworkManager.AgentManager” on object at path /org/freedesktop/NetworkManager/AgentManager

Previously, when NMClient recevied a name-owner changed, that would
block the main loop long enough to avoid the race. Note that NMClient
has nothing to do with NMSecretAgentOld, however in practice all
applications that use NMSecretAgentOld also use NMClient.

While we should fix the race server-side, we also need to work around it
in the client. Retry.

Also, make the async request actually cancellable and actually honor the passed
GCancellable.

Check output:

    $ LIBNM_CLIENT_DEBUG=trace ./clients/cli/nmcli agent secret |& grep secret-agent
    libnm-dbus: <trace> [21399.04862] secret-agent[2f2af4ee102d7570]: create new instance
    libnm-dbus: <trace> [21399.04863] secret-agent[2f2af4ee102d7570]: init-sync
    libnm-dbus: <trace> [21404.08147] secret-agent[2f2af4ee102d7570]: name owner changed: (null)
    libnm-dbus: <trace> [21404.09085] secret-agent[2f2af4ee102d7570]: name owner changed: ":1.2504"
    libnm-dbus: <trace> [21404.09085] secret-agent[2f2af4ee102d7570]: register: starting asynchronous registration...
    libnm-dbus: <trace> [21404.09178] secret-agent[2f2af4ee102d7570]: register: registration failed with error "GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such interface “org.freedesktop.NetworkManager.AgentManager” on object at path /org/freedesktop/NetworkManager/AgentManager". Retry in 0 msec...
    libnm-dbus: <trace> [21404.09178] secret-agent[2f2af4ee102d7570]: register: retry registration...
    libnm-dbus: <trace> [21404.09195] secret-agent[2f2af4ee102d7570]: register: registration failed with error "GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such interface “org.freedesktop.NetworkManager.AgentManager” on object at path /org/freedesktop/NetworkManager/AgentManager". Retry in 4 msec...
    libnm-dbus: <trace> [21404.09236] secret-agent[2f2af4ee102d7570]: register: retry registration...
    [...]
    libnm-dbus: <trace> [21405.01782] secret-agent[2f2af4ee102d7570]: register: registration failed with error "GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such interface “org.freedesktop.NetworkManager.AgentManager” on object at path /org/freedesktop/NetworkManager/AgentManager". Retry in 128 msec...
    libnm-dbus: <trace> [21405.03063] secret-agent[2f2af4ee102d7570]: register: retry registration...
    libnm-dbus: <trace> [21405.03068] secret-agent[2f2af4ee102d7570]: register: registration failed with error "GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such interface “org.freedesktop.NetworkManager.AgentManager” on object at path /org/freedesktop/NetworkManager/AgentManager". Retry in 128 msec...
    libnm-dbus: <trace> [21405.04354] secret-agent[2f2af4ee102d7570]: register: retry registration...
    libnm-dbus: <trace> [21406.01097] secret-agent[2f2af4ee102d7570]: register: registration succeeded
2019-12-16 18:38:49 +01:00
..
tests all: rename time related function to spell out nsec/usec/msec/sec 2019-12-13 16:54:40 +01:00
generate-plugin-docs.pl all: unify format of our Copyright source code comments 2019-10-02 17:03:52 +02:00
generate-setting-docs.py all: unify format of our Copyright source code comments 2019-10-02 17:03:52 +02:00
libnm.pc.in libnm,pkg-config: provide a variable with VPN service directory 2015-08-19 15:13:11 +02:00
libnm.ver libnm: allow to enable/disable fetching of permissions in NMClient 2019-12-10 09:17:17 +01:00
meson.build shared: add "shared/nm-libnm-aux" static library 2019-12-10 09:17:17 +01:00
NetworkManager.h all: unify format of our Copyright source code comments 2019-10-02 17:03:52 +02:00
nm-access-point.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-access-point.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-active-connection.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-active-connection.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-autoptr.h all: unify format of our Copyright source code comments 2019-10-02 17:03:52 +02:00
nm-checkpoint.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-checkpoint.h all: unify format of our Copyright source code comments 2019-10-02 17:03:52 +02:00
nm-client.c libnm: allow to enable/disable fetching of permissions in NMClient 2019-12-10 09:17:17 +01:00
nm-client.h libnm: allow to enable/disable fetching of permissions in NMClient 2019-12-10 09:17:17 +01:00
nm-dbus-helpers.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-dbus-helpers.h libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-device-6lowpan.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-device-6lowpan.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-device-adsl.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-device-adsl.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-device-bond.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-device-bond.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-device-bridge.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-device-bridge.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-device-bt.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-device-bt.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-device-dummy.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-device-dummy.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-device-ethernet.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-device-ethernet.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-device-generic.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-device-generic.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-device-infiniband.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-device-infiniband.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-device-ip-tunnel.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-device-ip-tunnel.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-device-macsec.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-device-macsec.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-device-macvlan.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-device-macvlan.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-device-modem.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-device-modem.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-device-olpc-mesh.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-device-olpc-mesh.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-device-ovs-bridge.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-device-ovs-bridge.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-device-ovs-interface.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-device-ovs-interface.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-device-ovs-port.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-device-ovs-port.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-device-ppp.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-device-ppp.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-device-private.h libnm: use the o.fd.DBus.ObjectManager API for object management 2016-11-10 16:48:48 +01:00
nm-device-team.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-device-team.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-device-tun.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-device-tun.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-device-vlan.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-device-vlan.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-device-vxlan.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-device-vxlan.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-device-wifi-p2p.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-device-wifi-p2p.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-device-wifi.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-device-wifi.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-device-wimax.c libnm: retire deprecated WiMAX NMObject types 2019-10-23 15:31:51 +02:00
nm-device-wimax.h libnm: retire deprecated WiMAX NMObject types 2019-10-23 15:31:51 +02:00
nm-device-wireguard.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-device-wireguard.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-device-wpan.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-device-wpan.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-device.c libnm: add assertion for object returned by nm_device_get_active_connection() 2019-11-28 12:47:07 +01:00
nm-device.h libnm: export interface flags 2019-11-22 10:18:26 +01:00
nm-dhcp-config.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-dhcp-config.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-dhcp4-config.c libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-dhcp4-config.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-dhcp6-config.c libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-dhcp6-config.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-dns-manager.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-dns-manager.h libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-enum-types.c.template build: use template files for enum types' sources generation 2017-12-18 11:25:06 +01:00
nm-enum-types.h.template build: use template files for enum types' sources generation 2017-12-18 11:25:06 +01:00
nm-ip-config.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-ip-config.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-ip4-config.c libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-ip4-config.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-ip6-config.c libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-ip6-config.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-libnm-utils.c all: rename time related function to spell out nsec/usec/msec/sec 2019-12-13 16:54:40 +01:00
nm-libnm-utils.h libnm: allow using _LOGx() macros in libnm 2019-12-16 18:38:49 +01:00
nm-object-private.h libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-object.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-object.h libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-remote-connection-private.h all: unify format of our Copyright source code comments 2019-10-02 17:03:52 +02:00
nm-remote-connection.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-remote-connection.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-secret-agent-old.c libnm/secret-agent: fix race registering secret agent 2019-12-16 18:38:49 +01:00
nm-secret-agent-old.h all: unify format of our Copyright source code comments 2019-10-02 17:03:52 +02:00
nm-types.h all: unify format of our Copyright source code comments 2019-10-02 17:03:52 +02:00
nm-vpn-connection.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-vpn-connection.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-vpn-editor.c all: unify format of our Copyright source code comments 2019-10-02 17:03:52 +02:00
nm-vpn-editor.h all: unify format of our Copyright source code comments 2019-10-02 17:03:52 +02:00
nm-vpn-plugin-old.c libnm: use obj_properties array in libnm and cleanup 2019-10-18 22:09:18 +02:00
nm-vpn-plugin-old.h all: unify format of our Copyright source code comments 2019-10-02 17:03:52 +02:00
nm-vpn-service-plugin.c libnm: use obj_properties array in libnm and cleanup 2019-10-18 22:09:18 +02:00
nm-vpn-service-plugin.h all: unify format of our Copyright source code comments 2019-10-02 17:03:52 +02:00
nm-wifi-p2p-peer.c libnm: refactor caching of D-Bus objects in NMClient 2019-11-25 15:08:00 +01:00
nm-wifi-p2p-peer.h libnm: hide GObject structs from public API and embed private data 2019-10-22 10:58:52 +02:00
nm-wimax-nsp.c libnm: retire deprecated WiMAX NMObject types 2019-10-23 15:31:51 +02:00
nm-wimax-nsp.h libnm: retire deprecated WiMAX NMObject types 2019-10-23 15:31:51 +02:00