Commit graph

261 commits

Author SHA1 Message Date
Kenny Levinsen
9bbdf0f0b8 seatd: Command-line argument for loglevel
SEATD_LOGLEVEL was used to set the loglevel despite already having
getopt in place. Remove the environment variable and make a command-line
argument for it instead.
2022-02-26 19:17:26 +01:00
Kenny Levinsen
3eb0db57bb seatd-launch: Minor readability improvements 2022-02-21 21:33:06 +01:00
Kenny Levinsen
ed90ed62cd seatd-launch: Use snprintf for socket path
We also reduce the size of the buffer from 256 bytes to a much more
reasonable 32 bytes.
2022-02-21 21:27:14 +01:00
Kenny Levinsen
a44476ce65 seatd: Fix usage rendering 2022-02-21 12:04:09 +01:00
Kenny Levinsen
10658dc543 seatd-launch: Remove socket path command line arg
This should not need to be configured, so remove the argument. If
downstream prefers a different folder, the location can be made
compile-time configurable like for seatd itself.
2022-02-21 12:02:31 +01:00
Kenny Levinsen
32d06482d3 seatd-launch: Do not unlink socket path
seatd cleans up after itself and takes care of stale sockets when
applicable, so seatd-launch should not replicate this functionality.
2022-02-21 12:02:31 +01:00
Kenny Levinsen
0864f6a3ac seatd: Ensure socket gets unlinked on error 2022-02-21 12:02:31 +01:00
Kenny Levinsen
157ce68565 seatd: Remove SOCK_PATH and improve cleanup
SOCK_PATH is made redundant by the -s command-line argument added in
a98e0c4ce9. Support was originally left
behind for short-term compatibility, but it should be fine to remove.

Previous socket cleanup is changed to run unconditionally. The cleanup
now fails if the existing file is not a socket.
2022-02-21 12:02:31 +01:00
Kenny Levinsen
f128359332 logind: Always send ping if data is queued
sd_bus_call_method may have read and queued our ping response, so we
cannot assume that a previous ping will make the socket readable.

Instead, always send a ping if read or write queues are not empty, even
if a ping has already been sent.
2022-02-15 13:51:49 +01:00
Kenny Levinsen
b47c79d731 libseat: Use SOCK_CLOEXEC and SOCK_NONBLOCK
This both simplifies our code and fixes an exec fd leak when using
builtin or noop backends.
2022-02-09 23:22:29 +01:00
Simon Ser
96a5de8859 readme: add irc:// link
This allows users to just click the link to join the IRC channel.
2021-12-16 10:40:53 +01:00
Simon Ser
936ff9dbea build: use meson.override_dependency
This allows downstream users to write:

    dependency('libseat', fallback: 'seatd')

instead of having to rely on the seatd/meson.build's variable name:

    dependency('libseat', fallback: ['seatd', 'libseat'])
2021-12-16 10:40:32 +01:00
Simon Ser
f381e22955 build: don't use sh for scdoc
Just use the built-in feed/capture Meson options instead.
2021-11-28 15:41:53 +01:00
Simon Ser
d92fa01f88 build: use list for logind dep
This reduces the boilerplate a bit. Use logind.name() instead of
having a separate source of truth. Requires adapting the checks a
bit because the dep name has a "lib" prefix.
2021-11-28 15:40:56 +01:00
Simon Ser
69cf5c36e0 build: don't use cc.get_supported_arguments for defines
If the compiler errors out on some -DXXX flag, then we're in
trouble. Avoid using cc.get_supported_arguments for defines we
require. Only use it for detecting support for warning flags.
2021-10-28 16:31:17 +02:00
Simon Ser
88529f0856 seatd: don't log errno on EVENT_ERROR
errno won't be set when poll returns EVENT_ERROR.
2021-10-24 00:55:32 +02:00
Simon Ser
cb7a94378b seatd: avoid overwriting errno in set_nonblock error handling
If close fails, it'll mess up errno, and log_errorf will print a
non-sensical value.
2021-10-24 00:52:08 +02:00
Kenny Levinsen
88db55f606 Bump version to 0.6.3 2021-10-19 21:39:17 +02:00
Kenny Levinsen
e35c9cd02e logind: Set userdata for ping_handler 2021-10-05 10:05:25 +02:00
Kenny Levinsen
ec0d6565bb ci: Add logind smoketest to arch 2021-09-22 23:06:59 +02:00
Kenny Levinsen
8e5c00e7c8 logind: Improve error handling in open_seat
errno was not being set by open_seat in most cases, leading to
simpletest possibly failing with "libseat_open_seat() failed: Success".
2021-09-22 23:04:40 +02:00
Simon Ser
d2193b45ff examples/simpletest: check for libseat_dispatch failures 2021-09-22 21:59:41 +02:00
Simon Ser
262ccef84e logind: check if session is active on startup
Up until now we assumed the session was always active on startup.
This might not be the case. Instead, read the current value of the
Active property.
2021-09-22 21:55:49 +02:00
Kenny Levinsen
1c376ca9b1 ci: Inline smoketest into build scripts
The smoketest script has gotten significantly simpler, and can simply be
inlined into the build scripts if we don't care about running the tests
twice.

This should fix CI for mailing list patches.
2021-09-21 13:11:55 +02:00
Kenny Levinsen
e2baadc230 clang-format: Fix alignment 2021-09-21 12:48:24 +02:00
Kenny Levinsen
db08fb921f logind: Send ping to wake us up later
sd_bus_call drains received messages into the receive queue, and peeks
for its own return value. It does not dispatch the receive queue.

As the socket is drained, the caller will not wake from a poll and have
no reason to dispatch libseat. This has gone unnoticed largely due to
logind sending an event for every device, making it unlikely that no
unread message will be left on the socket.

Like we have done for seatd, we fix this by sending a "ping" request to
logind if anything is left in our receive queue as reported by
sd_bus_get_events. The response to this will wake us up and ensure that
dispatch is called.
2021-09-21 11:18:18 +02:00
Kenny Levinsen
2eee9aa445 seatd: Implement ping request to wake up later
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, 6fa82930d0 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-21 11:18:18 +02:00
Kenny Levinsen
0f20175752 Bump version to 0.6.2 2021-09-16 01:07:42 +02:00
Kenny Levinsen
ebf512c2bf seatd-launch: Specify exact environment to seatd
The parent environment might contain nasty things. Create a new
environment for the seatd process containing only the environment
variables we care about. For now, that's only SEATD_LOGLEVEL.
2021-09-16 00:55:43 +02:00
Kenny Levinsen
907b75de1a seatd-launch: Use absolute path for seatd
We previously used execlp to execute seatd, which had the effect of
searching PATH for the executable. This allowed the caller to control
what executable was run, which is bad if SUID has been set.

Instead, expose the absolute install path for seatd from meason as a
define, and use that in a call to execv.
2021-09-16 00:46:49 +02:00
Kenny Levinsen
4091ba2c07 ci: Install seatd instead of manipulating PATH 2021-09-16 00:46:42 +02:00
Kenny Levinsen
66becee6da Bump version to 0.6.1 2021-09-14 11:58:56 +02:00
Simon Ser
4e3b7b3bb6 seatd-launch: print unlink/kill errors
Makes it easier to find out that something went wrong.
2021-09-13 13:40:00 +02:00
Simon Ser
fe600eac2b seatd-launch: exit with status >128 if child is signalled
Mimick shells and exit with a status >128 if our child has been
signalled. Exiting with 128 + signal number is what most shells do
(POSIX only requires them to exit with >128).
2021-09-13 13:39:20 +02:00
Kenny Levinsen
8c85c46d2d man/seatd-launch: Make mssage about root clearer 2021-09-12 12:06:05 +02:00
Kenny Levinsen
483dbf76fa seatd-launch: Use optind to find the command
The command indexing had not been updated afer the introduction of
getopt, so combining a command with flags would fail.

Add error handling for if no command was specified while we're at it.
2021-09-12 12:06:05 +02:00
Jan Beich
d5c1a7811b seatd-launch: respect PATH when looking for command
$ seatd-launch sway -c /dev/null
Could not start target: No such file or directory
2021-09-12 12:06:05 +02:00
Kenny Levinsen
da59bea775 man: Add seatd-launch(1) to SEE ALSO of seatd(1) 2021-09-11 15:55:26 +02:00
Kenny Levinsen
3ad9164a89 Bump version to 0.6.0 2021-09-11 14:02:44 +02:00
Kenny Levinsen
d1c6bb9a15 seatd-launch: Fix chmod error goto 2021-09-08 20:54:18 +02:00
Kenny Levinsen
e7343ca96f man: Add simple seatd-launch(1) page 2021-09-08 20:45:42 +02:00
Kenny Levinsen
17cdbe0ad2 seatd-launch: Set socket permissions directly
Instead of relying on seatd's user/group arguments, which require
turning our UID back into a username, just chmod/chown the socket
ourselves once seatd is ready.

We also reduce the permissions to just user access, instead of user and
group like seatd specifies.
2021-09-08 20:40:09 +02:00
Kenny Levinsen
60c370d4ec seat: Allow new clients when active is pending ack
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-07 22:24:24 +02:00
Simon Ser
29a6832ca0 Add .editorconfig
Allows text editor auto-configuration.
2021-09-02 20:41:47 +02:00
Kenny Levinsen
df3f307b8e seat: Avoid holding a tty fd
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-09-02 20:02:55 +02:00
Fabrice Fontaine
15b0972bd3 meson.build: fix build with gcc < 7
Test if arguments (e.g. -Wimplicit-fallthrough) is available before
using it as -Wimplicit-fallthrough has been added only since gcc 7.1 and
81fea426da
and so it will raise the following build failure with gcc < 7:

arm-none-linux-gnueabi-gcc: error: unrecognized command line option '-Wimplicit-fallthrough'

Fixes:
 - http://autobuild.buildroot.org/results/0ee6816a7cceebdafd07612677a594bdf68e0790

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2021-09-02 20:00:03 +02:00
Kenny Levinsen
038c30f9b1 libseat: Fix build of builtin backend
This was regressed by 166feaea33 which
missed the builtin backend when changing struct libseat_seat_listener to
being passed around as const.
2021-08-15 14:32:05 +02:00
Greg Depoire--Ferrer
d78859bc9a libseat: Update builtin backend root requirement documentation
The builtin backend no longer requires root, setuid or CAP_SYS_ADMIN.
This commit updates the documentation accordingly.
2021-08-15 14:03:23 +02:00
Greg Depoire--Ferrer
d9ae4c3010 Revert "libseat: Check euid before using builtin"
This reverts commit 1ae6c3b3dd.

A user might want to run the builtin server as non root, if they have
permission to use the devices.

The check was originally copied from wlroots's direct backend. It was reverted
in fa05d3cde68d with a detailed explanation of why root priviledges are not
always necessary to use the DRM device.
2021-08-15 14:03:23 +02:00
Kenny Levinsen
6e7a1db32d logind: Remove redundant null check 2021-08-15 13:34:26 +02:00