aboutsummaryrefslogtreecommitdiff
path: root/seatd
AgeCommit message (Collapse)Author
2021-09-21seatd: Implement ping request to wake up laterKenny Levinsen
When device open or close messages are sent to seatd, libseat must read messages from the socket until it sees the associated response message. This means that it may drain enable/disable seat events from the socket, queueing them internally for deferred processing. As the socket is drained, the caller will not wake from a poll and have no reason to dispatch libseat. To ensure that these messages would not be left in the queue, 6fa82930d0c5660eea3102989c765dc864514e36 made it so that open/close calls would execute all queued events just before returning. Unfortunately, this had the side-effect of having events fire from the stack of libseat_open_device or libseat_close_device, which we now see cause problems in compositors. Specifically, an issue has been observed where libinput end up calling libseat_close_device, which in turn dispatch a disable seat event that calls libinput_suspend. libinput does not like this. Instead, remove the execution from libseat_open_device and libseat_close_device, and instead make a "ping" request to seatd if events have been queued. The response to this will wake us up and ensure that dispatch is called.
2021-09-07seat: Allow new clients when active is pending ackKenny Levinsen
New clients could only be added to a VT bound seat if there were no "active" client, regardless of its actual state. This meant that if one switched from an "active" VT to an "inactive" VT, the seat would be blocked while the "active" client was in CLIENT_PENDING_DISABLE, causing new clients to possibly fail should the old client take its time with the ack. Instead, allow new clients to also be added if there is an active client whose state is CLIENT_PENDING_DISABLE, and there is no client with the new VT as its session ID.
2021-09-02seat: Avoid holding a tty fdKenny Levinsen
The kernel Secure Attention Key killer, triggered by SysRq+k, kills all processes that hold an fd referencing the tty. To avoid its attention, we stop storing the fd for the currently active VT in seat state. This has the added benefit of simplifying state a bit.
2021-08-08seatd: Use path in chmod/chown operationsKenny Levinsen
c8b3a22d4ef0f69c3d22f0ec1170b89c93ef1dc3 snuck in a change which converts chown/chmod to fchown/fchmod using the socket fd. This appears to succeed under Linux, but fails with EINVAL on FreeBSD. As the error handling in this area was flawed, CI failed to catch the regression. Partially revert c8b3a22d4ef0f69c3d22f0ec1170b89c93ef1dc3 to fix the regression on FreeBSD.
2021-08-08seatd: Improve socket permission error handlingKenny Levinsen
chmod/chown errors were logged, but did not result in failure opening the seatd socket. This meant that errors would not get caught by CI.
2021-08-06seatd: Only set UID/GID when specifiedKenny Levinsen
The UID/GID defaulted to 0, which results in trying to chown to root when a UID or GID isn't requested. Instead, deafult to -1 so that the unspecified values are left intact.
2021-08-06seatd: s6-style readiness notification supportKenny Levinsen
This adds the ability to specify the number of an fd that is inherited by the process as open. Once seatd is read to serve requests, it will write a single newline and close the fd.
2021-03-21client: enable cr_pid on FreeBSD >= 12.3Jan Beich
https://cgit.freebsd.org/src/commit/?id=925f44f33862908f9a2e72520a17af148c7d0db5 https://cgit.freebsd.org/src/commit/?id=2b61bda2c75f30f6eadd18fb891fd885e4c8d19d
2021-03-16Correct minor misspellingsKenny Levinsen
2021-03-02Normalize log texts a bitKenny Levinsen
2021-02-27clang-formatKenny Levinsen
2021-02-27seatd: Close cur_ttyfd in seat_destroyKenny Levinsen
This fd would only still be set after closing clients if no clients were active on the current VT.
2021-02-27client: Remove link if seat_add_client succeedsKenny Levinsen
Removing the link before before means that we can return without a link, resulting in a double-remove.
2021-02-27seatd: Clean up debug logs a bitKenny Levinsen
2021-02-27Convert a few debug logs to error logsKenny Levinsen
2021-02-27seatd: Set errno in seat_add_clientKenny Levinsen
2021-02-27seatd: Tear down VT when disabled client closesKenny Levinsen
If a client closed while it was disabled, the VT would not be torn down. If the user navigated back to the VT it belonged to, they would be stuck. When a client is disabled, open the fd for the VT it belonged to and perform regular teardown on it.
2021-02-27client: Replace pending_disable with state enumKenny Levinsen
This simplifies logic in seat handling.
2021-02-02seat: Remove unused arg from seat_deactive_deviceKenny Levinsen
2020-12-10client: Fix typo in cr_pid usageKenny Levinsen
2020-12-08client: Use cr_pid if availableKenny Levinsen
This is only available on FreeBSD 13, so test for that version.
2020-12-08client: Do not use SOL_SOCKET for LOCAL_PEERCREDKenny Levinsen
This is wrong, and leads to LOCAL_PEERCRED being interpreted as SO_DEBUG. 0 should be used instead. See: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=246189.
2020-11-23client: More robust handling of client linksKenny Levinsen
2020-11-23poller: Retry poll immediately on EINTRKenny Levinsen
There is nothing for us to dispatch unless we wake on an fd, so just retry poll if it fails with EINTR instead of doing a full dispatch loop.
2020-09-22seat: Only close VT if no new session was foundKenny Levinsen
2020-09-22terminal: Ack both release and acquireKenny Levinsen
Linux only requires acking release and ignores ack of acquire, but FreeBSD is more stringent and will patiently wait for both to be acked. Implement proper acking for both events.
2020-09-22seat: Use current VT for switch and ackKenny Levinsen
2020-09-22meson: Make default seatd socket path configurableKenny Levinsen
FreeBSD and Linux have different preferred socket locations. Expose an option to set the location, and implement simple auto-logic for linux/freebsd.
2020-09-22poller: Add unittestKenny Levinsen
2020-09-22seatd: Log on exitKenny Levinsen
2020-09-22seat: Reuse deactivate logic, more loggingKenny Levinsen
2020-09-22seat: Plug leak of deactivated fdsKenny Levinsen
Only if a device had an fd and was active would an fd be closed. As devices are deactivated early on session switch, this lead to fd leakage. Close fds regardless of active state.
2020-09-22seat: Rework seat activation/switch logicKenny Levinsen
The seat activation logic did not correctly handle VT switching and switching between multiple sessions. Session switching on VT-bound seats is now performed using a VT switch, taking advantage of VT signals to perform the actual switch. This simplifies switching logic and makes it more robust.
2020-09-22client: Remove unnecessary active_client checkKenny Levinsen
2020-09-22poller: Raise signals through self-pipeKenny Levinsen
Signal handling relied on poll(2) being interrupted by signals, followed by a check for signal handlers flagging a signal as received. This only allowed signals that were received during poll(2) to be handled correctly. Implement the usual self-pipe implementation, where signal handlers write an arbitrary byte to a polled file descriptor to ensure proper level-triggered signal handling.
2020-09-01client: Only unlink if on the idle listKenny Levinsen
2020-09-01Move list removal to seat/client destroyKenny Levinsen
2020-08-31client: Do not leak idle clients on exitKenny Levinsen
2020-08-31poller: Remember to remove sources from listKenny Levinsen
2020-08-31server: Remember to remove seat from listKenny Levinsen
2020-08-31poller: Convert to linked_listKenny Levinsen
2020-08-31server: Convert seat list to linked_listKenny Levinsen
2020-08-31poller: Make event sources opaqueKenny Levinsen
2020-08-30seatd: Explicit cast -1 to unsigned gid_tKenny Levinsen
Silences a warning on some architectures.
2020-08-30seatd: Slight error handling cleanupKenny Levinsen
2020-08-30seatd: Remove unused device_closed msg bodyKenny Levinsen
2020-08-29seat: Destroy all clients on teardownKenny Levinsen
2020-08-28Introduce libseat_set_log_levelSimon Ser
The default level is SILENT. log_init no longer takes an initial log level (so that calls to libseat_set_log_level prior to log_init work correctly).
2020-08-28Rename enum log_level to libseat_log_levelSimon Ser
This is preparatory work for exposing a public function to set libseat's log handler.
2020-08-08seatd: Use path-based chmod/chownKenny Levinsen
The fd variants do not seem to work for sockets