Commit graph

155 commits

Author SHA1 Message Date
Kenny Levinsen
6cf751af2b logind: Fix return values from close_device/get_fd 2021-02-27 19:35:01 +01:00
Kenny Levinsen
da3cbcc943 libseat: Fix typo in doc string 2021-02-27 19:28:32 +01:00
Aleksei Bavshin
152ee5102a meson: ignore 'man-pages' if 'server' is disabled
`seatd.1` is the only man page, so it's not necessary to install it or
require scdoc when the server is not built.
2021-02-27 17:45:07 +01:00
Kenny Levinsen
65d91351ab seatd: Tear down VT when disabled client closes
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-27 16:58:44 +01:00
Kenny Levinsen
45bab8b258 client: Replace pending_disable with state enum
This simplifies logic in seat handling.
2021-02-27 15:51:13 +01:00
Kenny Levinsen
b1f7ec1c4d seat: Remove unused arg from seat_deactive_device 2021-02-02 21:03:42 +01:00
Kenny Levinsen
61b086511f logind: Send ReleaseControl when closing seat
This is not strictly speaking necessary as detaching from the bus should
trigger this automatically, but elogind apparently has issues with this.

Doing this explicitly does no harm, so let's just do that.
2020-12-23 00:34:02 +01:00
Kenny Levinsen
1ececbbf36 simpletest: Close fd after closing device 2020-12-14 23:41:17 +01:00
Kenny Levinsen
3755eea668 client: Fix typo in cr_pid usage 2020-12-10 10:07:43 +01:00
Kenny Levinsen
9b3bdcb12d client: Use cr_pid if available
This is only available on FreeBSD 13, so test for that version.
2020-12-08 16:42:13 +01:00
Kenny Levinsen
e99e7d71f7 client: Do not use SOL_SOCKET for LOCAL_PEERCRED
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-12-08 16:38:17 +01:00
Simon Ser
e3a357bade libseat/backend/logind: stop waiting for CanGraphical
Upstream says compositors should wait for DRM nodes using udev instead.
2020-12-04 23:39:39 +01:00
Kenny Levinsen
1dbf100205 logind: switch_session should return 0 on success
It currently returned -1 on failure and 1 on success. The API is
intended to return -1 on failure and 0 on success, so fix that.
2020-11-24 13:12:31 +01:00
Kenny Levinsen
0d5f48f433 terminal: Improve logging 2020-11-23 17:56:55 +01:00
Kenny Levinsen
e0782a825e client: More robust handling of client links 2020-11-23 17:56:55 +01:00
Kenny Levinsen
df8494af61 poller: Retry poll immediately on EINTR
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-11-23 16:48:18 +01:00
Isaac Freund
3c80a9db96 libseat: log error when failing to open socket
The most common pain point I've seen with people trying out seat is
forgetting to add themselves to whatever group the distro has chosen
to own the socket.

Logging this error and path of the socket should make it easier to tell
why things aren't working.
2020-11-21 21:03:55 +01:00
Kenny Levinsen
2185e8f180 ci: Clean up build manifests 2020-11-03 15:42:09 +01:00
Kenny Levinsen
271305a15f Bump version to 0.4.0 2020-10-19 23:11:07 +02:00
Kenny Levinsen
26eff322d4 readme: Update mailing list link 2020-10-16 21:38:32 +02:00
Kenny Levinsen
e0945eb840 connection: Add unittest 2020-10-12 18:02:00 +02:00
Kenny Levinsen
29ba210958 libseat: Better error reporting from open_seat 2020-10-11 23:31:07 +02:00
Kenny Levinsen
7d785ea993 logind: clang-format 2020-10-11 01:41:34 +02:00
Kenny Levinsen
daffed0955 logind: Use seat_path for SwitchTo 2020-10-10 19:39:28 +02:00
Kenny Levinsen
7bf91a5f9f logind: close_device should not close fd 2020-09-28 18:53:38 +02:00
Kenny Levinsen
ca6478716d seat: Only close VT if no new session was found 2020-09-22 01:33:45 +02:00
Kenny Levinsen
be45c480ec terminal: Ack both release and acquire
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-22 01:14:24 +02:00
Kenny Levinsen
ba4c422659 seat: Use current VT for switch and ack 2020-09-22 01:14:24 +02:00
Kenny Levinsen
521d95349f terminal: Fix VT numbering on FreeBSD
FreeBSD adds one to the VT number returned by the GET_ACTIVE ioctl, so
to match things up, the wrapper here subtracted by one. This lead to
ttyv0 being named VT 0. This had the side-effect of VT numbering not
matching expectations, and switching not behaving as intended.

Align numbers with expectations, and move the required subtraction to
terminal_open, so that VT 1 matches ttyv0.
2020-09-22 01:14:24 +02:00
Kenny Levinsen
0132841987 libseat/seatd: Fix socket path bounds 2020-09-22 01:14:24 +02:00
Kenny Levinsen
884c1416b3 meson: Make default seatd socket path configurable
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-22 01:14:20 +02:00
Kenny Levinsen
a763e16f26 drm: Relax drm file detection, support FreeBSD
Path check was done on /dev/dri/card and /dev/dri/renderD. However,
/dev/dri/by-path is a thing, and on FreeBSD, /dev/dri/ symlinks to
/dev/drm/.

Relax Linux check to /dev/dri/, and add FreeBSD check for /dev/drm/.
2020-09-22 01:01:46 +02:00
Kenny Levinsen
6da52fff23 poller: Add unittest 2020-09-22 01:01:46 +02:00
Kenny Levinsen
6fa82930d0 libseat: Execute bg events after IPC calls
If a background event was queued during call dispatch, and no unread
data was left on the socket, there would be no incentive for the user to
call dispatch, and as a result, the events would never be executed.

Execute events at the end of IPC calls that read from the socket to
avoid stalls.
2020-09-22 01:01:46 +02:00
Kenny Levinsen
4c22c7b004 libseat: Dispatch all non-bg events on IPC call
Dispatch on IPC call only dispatched until the first message was
successfully processed. This could lead to premature dispatch
termination if a background event was received during an IPC call.

Instead, continue dispatching until a non-bg opcode is reported or an
error is received.
2020-09-22 01:01:46 +02:00
Kenny Levinsen
9c6682a831 seatd: Log on exit 2020-09-22 01:01:46 +02:00
Kenny Levinsen
695a86aaa8 seat: Reuse deactivate logic, more logging 2020-09-22 01:01:46 +02:00
Kenny Levinsen
8cb076d0a4 seat: Plug leak of deactivated fds
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-22 01:01:46 +02:00
Kenny Levinsen
51c7467516 seat: Rework seat activation/switch logic
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-22 01:01:46 +02:00
Kenny Levinsen
d16122e98a client: Remove unnecessary active_client check 2020-09-22 01:01:46 +02:00
Kenny Levinsen
6747c5f3f8 poller: Raise signals through self-pipe
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-22 01:01:46 +02:00
Kenny Levinsen
fb5743971c Bump version to 0.3.0 2020-09-08 00:03:59 +02:00
Kenny Levinsen
d4b1f4d449 libseat: Version the .so file 2020-09-08 00:00:48 +02:00
Kenny Levinsen
8813671486 man: Mention assistance from other contributors 2020-09-07 23:54:52 +02:00
Kenny Levinsen
047d8b284c libseat: Handle SERVER_ERROR correctly
The connection buffer position was erroneously rewinded before reading
the protocol message when the message was a SERVER_ERROR.
2020-09-07 23:35:24 +02:00
Isaac Freund
1867f29d42 meson: fix manpage generation for cross builds
We want to use the scdoc of the host system not the target system, so
pass the `native: true` parameter to meson.
2020-09-01 21:32:36 +02:00
Kenny Levinsen
ad214dc3fe client: Only unlink if on the idle list 2020-09-01 02:47:03 +02:00
Kenny Levinsen
34d0c87ea8 ci: ASan smoketest on FreeBSD 2020-09-01 02:27:05 +02:00
Kenny Levinsen
d53b3a87ec ci: ASan all build steps on arch 2020-09-01 02:26:53 +02:00
Kenny Levinsen
5d4036e9bd Move list removal to seat/client destroy 2020-09-01 00:33:20 +02:00