Commit graph

133 commits

Author SHA1 Message Date
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
Kenny Levinsen
5b8117f3d4 client: Do not leak idle clients on exit 2020-08-31 23:13:16 +02:00
Kenny Levinsen
c9ce7c71aa poller: Remember to remove sources from list 2020-08-31 22:08:59 +02:00
Kenny Levinsen
704d1ccd0b server: Remember to remove seat from list 2020-08-31 22:04:32 +02:00
Kenny Levinsen
aef19fe383 test: Add test_run and test_assert macros
test_run and test_assert replaces regular assert with better logging
which include the currently running test name. The tests can now also be
built without DEBUG.
2020-08-31 14:40:58 +02:00
Kenny Levinsen
8610ec4aac Remove unused list implementation 2020-08-31 14:14:39 +02:00
Kenny Levinsen
d17632fadd poller: Convert to linked_list 2020-08-31 14:09:59 +02:00
Kenny Levinsen
bbfb770c73 linked_list: linked_list_take should concat lists 2020-08-31 14:09:59 +02:00
Kenny Levinsen
d75b617faf server: Convert seat list to linked_list 2020-08-31 14:09:59 +02:00
Kenny Levinsen
7d88315fea poller: Make event sources opaque 2020-08-31 01:33:41 +02:00
Kenny Levinsen
8e1bf10d9d seatd: Explicit cast -1 to unsigned gid_t
Silences a warning on some architectures.
2020-08-30 23:16:47 +02:00
Kenny Levinsen
c9503ef35d seatd: Slight error handling cleanup 2020-08-30 03:26:52 +02:00
Kenny Levinsen
e86c9ec2b7 seatd: Remove unused device_closed msg body 2020-08-30 03:26:32 +02:00
Kenny Levinsen
c36cc962e6 linked_list: Implement linked_list_take 2020-08-30 00:05:19 +02:00
Kenny Levinsen
5470c48113 seat: Destroy all clients on teardown 2020-08-29 23:49:22 +02:00
Kenny Levinsen
b7b28f0628 protocol: Add note to remove device_closed msg
The content of this message is unused, so it should be converted to a
content-less message.
2020-08-29 23:12:18 +02:00
Kenny Levinsen
1ae6c3b3dd libseat: Check euid before using builtin 2020-08-29 23:01:56 +02:00
Kenny Levinsen
52fe75d5a4 libseat: Remove pointless check 2020-08-29 22:55:17 +02:00
Kenny Levinsen
98506d2ba4 libseat: Keep track of error state
Store if an error has occurred and return -1 with ENOTCONN from all
future calls, avoiding attempts to use a broken connection.
2020-08-29 22:45:01 +02:00
Kenny Levinsen
8b4d139873 libseat: Improve logging with seatd conn helpers
Add helpers around connection access to have all logging centralized and
reduce code duplication. Improve existing helpers to further reduce code
duplication.

The seatd backend should have much better logging after this.
2020-08-29 20:56:42 +02:00
Kenny Levinsen
69d57aaf33 libseat: Assert that listener is non-NULL 2020-08-29 20:29:35 +02:00
Kenny Levinsen
de96b3938b Bump version to 0.2.0 2020-08-28 23:09:14 +02:00
Kenny Levinsen
6e6903829e logind: Merge PropertiesChanged handlers 2020-08-28 22:55:25 +02:00