Commit graph

215 commits

Author SHA1 Message Date
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
Simon Ser
166feaea33 Make libseat_seat_listener const
libseat will never write to that struct. Let's allow callers to
make it read-only.
2021-08-15 13:33:30 +02:00
Kenny Levinsen
309650aa4d seatd: Use path in chmod/chown operations
c8b3a22d4e 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 c8b3a22d4e to fix the
regression on FreeBSD.
2021-08-08 18:22:17 +02:00
Kenny Levinsen
2cfc56d5ed seatd: Improve socket permission error handling
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-08 18:21:28 +02:00
Kenny Levinsen
48727a0b6b seatd-launch: Command line argument support 2021-08-06 23:00:05 +02:00
Simon Ser
369af8f9e4 seatd-launch: check for getpwuid errors 2021-08-06 22:27:42 +02:00
Simon Ser
3a843745c2 seatd-launch: don't use gotos in child processes
While forked (child pid is zero), don't use gotos. These will
execute atexit functions and potentially mess up the stdlib.
Instead, use _exit.
2021-08-06 22:27:42 +02:00
Simon Ser
f2a614dcd3 seatd-launch: propagate child exit status
When the child process exits with a non-zero code or is killed,
return with a non-zero code as well.
2021-08-06 22:27:42 +02:00
Kenny Levinsen
7d06b34ee2 ci: Fix meson flags 2021-08-06 01:29:52 +02:00
Kenny Levinsen
978dec42b0 ci: Use seatd-launch 2021-08-06 01:29:52 +02:00
Kenny Levinsen
1e98727ae9 seatd-launch: Add seatd launch wrapper
This launch wrapper is used to conveniently start a new seatd instance,
wait for it to be ready, and launch a target application.
2021-08-06 01:29:52 +02:00
Kenny Levinsen
c8b3a22d4e seatd: Only set UID/GID when specified
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-06 01:15:55 +02:00
Kenny Levinsen
312d6906ae seatd: s6-style readiness notification support
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-08-06 01:15:55 +02:00
Kenny Levinsen
d03e9d1c35 seatd: We shouldn't poll if predispatch > 0
This condition was accidentally botched as part of
5923e0edc9
2021-08-06 01:15:55 +02:00
Kenny Levinsen
6444da6093 libseat: Rename dispatch_background in backends
This name never made much sense. dispatch_and_execute is more
meaningful, especially when compared to the non-executing dispatch
function.
2021-07-09 00:16:10 +02:00
Kenny Levinsen
5923e0edc9 libseat/seatd: Add dispatch_pending_and_execute
This handler returns the number of dispatched or executed events, or -1
if dispatch_pending failed.

This helper is used to clean up dispatch_background, which now ensures
that all events are executed before we read or poll the connection, and
have improved error handling in the corner case where the second
dispatch_pending failed.
2021-07-09 00:09:14 +02:00
Kenny Levinsen
7a6d12ff7a libseat/seatd: Return executed events
Dispatch needs to report if something has happened, which includes
events executed from the queue as these could have lead to additional
dispatch and queuing.
2021-07-08 23:48:30 +02:00
Simon Ser
2204db5531 build: add prefix to libseat options
The option names are a little bit confusing, because it's not clear
which ones toggle libseat features, and which ones toggle seatd
features.

Add a "libseat-" prefix to libseat-specific features, to make it
more obvious that they only are about the library.
2021-07-06 22:11:43 +02:00
Simeon Schaub
bff09d8859 link with rt
Since seatd uses `clock_gettime`, this is needed when cross-compiling.
This came up in https://github.com/JuliaPackaging/Yggdrasil/pull/3193.
2021-06-20 22:36:33 +02:00
Kenny Levinsen
fc97206df9 readme: Update discuss section 2021-05-19 17:48:12 +02:00
Kenny Levinsen
355cc9c944 meson: Support building builtin without seatd
The builtin backend relies on the seatd backend implementation. When
builtin was enabled without seatd, compilation would fail due to the
implementation not being included.

Include the implementation if either seatd or builtin is enabled.
2021-04-25 20:20:52 +02:00
Simon Ser
36f54adc2c libseat/seatd: downgrade ENOENT log to info
The socket is expected not to be found if seatd is not running.
In general other backends will be attempted after seatd. There is
already an error message in case no backend can be started.
2021-04-25 19:15:24 +02:00
Kenny Levinsen
5535c2c3b1 contrib/systemd: Use a different group
"video" was used for convenience in the example, but a dedicated group
is preferable so that a user does not gain the ability to bypass the
seat manager and open devices directly.
2021-04-17 17:09:45 +02:00
Simon Ser
81ff0a09a9 build: set pkgconfig/dependency variables for features
This allows libseat users to e.g. advise people to chmod a+s the
executable if libseat is built with the builtin backend.

While bumping the Meson version, adjust the scdoc logic to avoid
the following warnings:

    WARNING: Project targeting '>=0.56.0' but tried to use feature deprecated since '0.56.0': Dependency.get_pkgconfig_variable. use Dependency.get_variable(pkgconfig : ...) instead
    WARNING: Project targeting '>=0.56.0' but tried to use feature deprecated since '0.55.0': ExternalProgram.path. use ExternalProgram.full_path() instead
2021-04-10 15:16:40 +02:00
Simon Ser
5884a6003a build: disable logind on -Dauto_features=disabled -Dlogind=auto
Setting auto_features=disabled is supposed to disable all optional
dependencies. Since we aren't using a feature option here, we need
to manually add logic to disable logind in this case.
2021-04-10 15:16:26 +02:00
Simon Ser
753c5276cf build: don't allow "auto" for seatd, builtin, server and examples
These features don't have any dependencies, so "auto" doesn't make
sense.
2021-04-08 23:07:35 +02:00
Simon Ser
ee40913810 build: don't explicitly search for sh
This removes the "Program sh found" line in the build logs, and
should not change anything else.
2021-04-08 23:07:35 +02:00
Simon Ser
392da918e6 build: fix logind feature summary when auto-detected
If -Dlogind=auto but systemd/elogind isn't available,
logind_provider would get set to the last item of the foreach loop.
This would incorrectly report "systemd: YES".
2021-04-08 23:07:35 +02:00
Simon Ser
385cc0039d build: add explicit logind provider option, auto-detect by default
Allow package maintainers to explicitly select a logind provider
by passing -Dlogind=systemd or -Dlogind=elogind. In case both are
available (e.g. for distributions which support both), this makes
it possible to gte deterministic behavior.

By default, auto-detect the logind provider. That way, users which
have systemd or elogind installed get the backend built by default.
2021-04-08 23:07:35 +02:00
Kenny Levinsen
3ce4c57814 meson: make 'logind' var always available 2021-04-08 23:07:35 +02:00
Kenny Levinsen
50da164ddc ci: Use 'auto' for arch linux logind 2021-04-08 23:07:35 +02:00
Kenny Levinsen
f9ba8b57bc Avoid a clang-format quirk
clang-format wants to put the terminating NULLs on the same line as the
noop backend when it doens't have any immediate non-NULL neighbors.

Add a newline to stop it.
2021-03-26 11:34:13 +01:00
Simon Ser
fa2700126f meson: declare libseat dependency
This can be used by parent projects when seatd is a subproject:

    libseat = dependency('libseat', fallback: ['seatd', 'libseat'])
2021-03-26 11:21:05 +01:00
Simon Ser
9a7824b7c3 Add no-op session
This is useful for headless testing, for instance with VKMS:

    modprobe vkms
    export WLR_DRM_DEVICES=/dev/dri/card1
    export WLR_BACKENDS=drm
    export LIBSEAT_BACKEND=noop
    sway

We don't need any of the VT handling in this case.
2021-03-26 11:11:26 +01:00
Jan Beich
5ad91ae9da client: enable cr_pid on FreeBSD >= 12.3
https://cgit.freebsd.org/src/commit/?id=925f44f33862908f9a2e72520a17af148c7d0db5
https://cgit.freebsd.org/src/commit/?id=2b61bda2c75f30f6eadd18fb891fd885e4c8d19d
2021-03-21 16:27:21 +01:00
Kenny Levinsen
0d855a28f2 readme: Remove alpha label 2021-03-18 15:45:40 +01:00
Kenny Levinsen
34f55a3e24 contrib: Add Documentation to systemd unit 2021-03-16 14:27:45 +01:00
Kenny Levinsen
a9865adb5f ci: Remove unnecessary env vars 2021-03-16 13:36:26 +01:00
Kenny Levinsen
745d662920 ci: Reduce test runs from 5 to 2 2021-03-16 13:36:26 +01:00
Kenny Levinsen
1f457b1df8 meson: Disable examples by default 2021-03-16 13:36:26 +01:00
Kenny Levinsen
4e65e1bf47 Correct minor misspellings 2021-03-16 13:03:57 +01:00
Kenny Levinsen
75cb20e891 meson: Minor cleanup 2021-03-16 13:03:57 +01:00
Kenny Levinsen
e802d381a1 meson: Fix logind backend auto mode 2021-03-16 13:03:57 +01:00
Kenny Levinsen
e303e11334 Bump version to 0.5.0 2021-03-15 20:32:27 +01:00
Kenny Levinsen
9492054920 ci: Add clang-extra-tools to alpine
Needed for the clang-format target.
2021-03-15 20:31:51 +01:00
Kenny Levinsen
c53c94985e meson: Fix indentation 2021-03-15 20:26:06 +01:00
Kenny Levinsen
a9b2079319 meson: Make summary prettier 2021-03-15 20:23:09 +01:00