Parent: 5b6c096fb859a70a0792b97ad7aca3190404a5a0
Author: Andrew Sayers <kernel.org@pileofstuff.org>
Committer: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Date: 2025-05-01 16:24:52
Tree: 8c2accaec05d329719c661352090906050c3b257
obexd: Unregister profiles when the user is inactive Obexd is usually run as a user service, and can exhibit surprising behaviour if two users are logged in at the same time. Unregister profiles when the user is detected to be off-seat. It may be impossible to detect whether a user is on-seat in some cases. For example, a version of obexd compiled with systemd support might be run outside of a systemd environment. Warn and leave services registered if that happens. Obexd can be run as a system service, in which case this check makes no sense. Disable this check when called with `--system-bus`. Obexd can also be run by a user that does not have an active session. For example, someone could use `ssh` to access the system. There might be a use case where someone needs Bluetooth access but can't log in with a keyboard, or there might be a security issue with doing so. This isn't handled explicitly by this patch, but a future patch could add support by calling `logind_set(FALSE)` in the same way as is currently done with `--system-bus`. Unregister profiles by closing private connections instead of sending UnregisterProfile on the shared connection. Pipewire has apparently found the latter to cause long shutdown delays, because bluetoothd may be shutting down and unable to handle this message. Based in large part on the wireplumber code mentioned by Pauli Virtanen: https://gitlab.freedesktop.org/pipewire/wireplumber/-/blob/master/modules/module-logind.c#L52 Other services are likely to need similar functionality, so I have created a gist to demonstrate the basic technique: https://gist.github.com/andrew-sayers/1c4a24f86a9a4c1b1e38d109f1bd1d1e Suggested-by: Pauli Virtanen <pav@iki.fi>
Diffstat
| M | Makefile.obexd | | | 10 | ++++++++++ |
| M | obexd/client/pbap.c | | | 17 | ++++++++++++++- - - |
| M | obexd/plugins/bluetooth.c | | | 14 | ++++++++++++- - |
| A | obexd/src/logind.c | | | 239 | ++++++++++++++++++++++++++++++++++++++++ |
| A | obexd/src/logind.h | | | 37 | +++++++++++++++++++++++++++++++++++++ |
| M | obexd/src/main.c | | | 4 | ++++ |
6 files changed, 316 insertions(+), 5 deletions(-)