-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6334fdf
commit cb26b06
Showing
6 changed files
with
290 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# User Services | ||
|
||
User services can be placed in ~/.config/service/. | ||
|
||
To ensure that a subset of services are started before login can proceed, | ||
these services can be listed in ~/.config/service/turnstile-ready/conf, for | ||
example: | ||
|
||
core_services="dbus foo" | ||
|
||
The turnstile-ready service is created by turnstile on first login. | ||
|
||
# D-Bus Session Bus | ||
|
||
If you want to manage dbus using a turnstile-managed runit user service: | ||
|
||
mkdir ~/.config/service/dbus | ||
cp /usr/share/examples/turnstile/dbus.run ~/.config/service/dbus/run | ||
|
||
# Elogind Replacement | ||
|
||
Turnstile is not (nor ever will be, according to the developer) a complete | ||
replacement for elogind, but it can replace several parts, including | ||
XDG_RUNTIME_DIR management. | ||
|
||
If using turnstile with elogind: | ||
- disable rundir management in /etc/turnstile/turnstiled.conf | ||
(manage_rundir = no) | ||
|
||
If using turnstile without elogind: | ||
- install and enable seatd for seat management | ||
- install and enable acpid for lid switch/button handling |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
|
||
[ -r ./conf ] && . ./conf | ||
|
||
exec dbus-daemon --session --nofork --nopidfile --address="$DBUS_SESSION_BUS_ADDRESS" $OPTS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
|
||
exec 2>&1 | ||
exec turnstiled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
From 88d5778946f5dd6738d706667e76ec2f937c3ff5 Mon Sep 17 00:00:00 2001 | ||
From: q66 <q66@chimera-linux.org> | ||
Date: Wed, 12 Jul 2023 04:21:41 +0200 | ||
Subject: [PATCH] add missing include | ||
|
||
--- | ||
src/pam_turnstile.cc | 1 + | ||
1 file changed, 1 insertion(+) | ||
|
||
diff --git a/src/pam_turnstile.cc b/src/pam_turnstile.cc | ||
index d0d3ae2..27ee53f 100644 | ||
--- a/src/pam_turnstile.cc | ||
+++ b/src/pam_turnstile.cc | ||
@@ -14,6 +14,7 @@ | ||
#include <cstdio> | ||
#include <cstdlib> | ||
#include <cstring> | ||
+#include <cerrno> | ||
#include <algorithm> | ||
|
||
#include <pwd.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,203 @@ | ||
From 370209395d420d54a48a884e81625f9c2c88729d Mon Sep 17 00:00:00 2001 | ||
From: classabbyamp <dev@placeviolette.net> | ||
Date: Wed, 28 Jun 2023 05:05:25 -0400 | ||
Subject: [PATCH] add runit backend | ||
|
||
--- | ||
backend/meson.build | 16 +++++++++ | ||
backend/runit | 86 +++++++++++++++++++++++++++++++++++++++++++++ | ||
backend/runit.conf | 13 +++++++ | ||
meson.build | 14 +++++--- | ||
meson_options.txt | 10 ++++++ | ||
5 files changed, 135 insertions(+), 4 deletions(-) | ||
create mode 100644 backend/runit | ||
create mode 100644 backend/runit.conf | ||
|
||
diff --git a/backend/meson.build b/backend/meson.build | ||
index 681e6a0..e4c63f1 100644 | ||
--- a/backend/meson.build | ||
+++ b/backend/meson.build | ||
@@ -13,3 +13,19 @@ if have_dinit | ||
install_mode: 'rw-r--r--' | ||
) | ||
endif | ||
+ | ||
+# runit backend | ||
+ | ||
+if have_runit | ||
+ install_data( | ||
+ 'runit', | ||
+ install_dir: join_paths(get_option('libexecdir'), 'turnstile'), | ||
+ install_mode: 'rwxr-xr-x' | ||
+ ) | ||
+ | ||
+ install_data( | ||
+ 'runit.conf', | ||
+ install_dir: join_paths(get_option('sysconfdir'), 'turnstile/backend'), | ||
+ install_mode: 'rw-r--r--' | ||
+ ) | ||
+endif | ||
diff --git a/backend/runit b/backend/runit | ||
new file mode 100644 | ||
index 0000000..b293b43 | ||
--- /dev/null | ||
+++ b/backend/runit | ||
@@ -0,0 +1,86 @@ | ||
+#!/bin/sh | ||
+# | ||
+# This is the turnstile runit backend. It accepts the action as its first | ||
+# argument, which is either "ready", "run", or "stop". In case of "run", it's | ||
+# invoked directly through /bin/sh as if it was a login shell, and therefore | ||
+# it has acccess to shell profile, and the shebang is functionally useless but | ||
+# should be preserved as a convention. For "ready", it's a regular shell. | ||
+# | ||
+# Arguments for "ready": | ||
+# | ||
+# ready_sv: path to the readiness service | ||
+# | ||
+# Arguments for "run": | ||
+# | ||
+# ready_p: readiness pipe (fifo). has the path to the ready service written to it. | ||
+# srvdir: unused | ||
+# confdir: the path where turnstile's configuration data resides, used | ||
+# to source the configuration file | ||
+# | ||
+# Arguments for "stop": | ||
+# | ||
+# pid: the PID of the service manager to stop (gracefully); it should | ||
+# terminate the services it's running and then stop itself | ||
+# | ||
+# Copyright 2023 classabbyamp <dev@placeviolette.net> | ||
+# License: BSD-2-Clause | ||
+ | ||
+case "$1" in | ||
+ run) ;; | ||
+ ready) | ||
+ if [ -z "$2" ] || [ ! -d "$2" ]; then | ||
+ echo "runit: invalid readiness service '$2'" >&2 | ||
+ exit 69 | ||
+ fi | ||
+ exec sv start "$2" >&2 | ||
+ ;; | ||
+ stop) | ||
+ # If runsvdir receives a HUP signal, it sends a TERM signal to each | ||
+ # runsv(8) process it is monitoring and then exits with 111. | ||
+ exec kill -s HUP "$2" | ||
+ ;; | ||
+ *) | ||
+ exit 32 | ||
+ ;; | ||
+esac | ||
+ | ||
+RUNIT_READY_PIPE="$2" | ||
+RUNIT_CONF="$4/runit.conf" | ||
+ | ||
+if [ ! -p "$RUNIT_READY_PIPE" ]; then | ||
+ echo "runit: invalid input argument(s)" >&2 | ||
+ exit 69 | ||
+fi | ||
+ | ||
+if [ -z "$HOME" ] || [ ! -d "$HOME" ]; then | ||
+ echo "runit: invalid home directory" >&2 | ||
+ exit 70 | ||
+fi | ||
+ | ||
+shift $# | ||
+ | ||
+# be strict | ||
+set -e | ||
+ | ||
+# source the conf | ||
+[ -r "$RUNIT_CONF" ] && . "$RUNIT_CONF" | ||
+ | ||
+# set some defaults in case the conf cannot be read or is mangled | ||
+: "${ready_sv:="turnstile-ready"}" | ||
+: "${services_dir:="${HOME}/.config/service"}" | ||
+ | ||
+mkdir -p "${services_dir}/${ready_sv}" > /dev/null 2>&1 | ||
+ | ||
+# this must succeed | ||
+cat << EOF > "${services_dir}/${ready_sv}/run" | ||
+#!/bin/sh | ||
+[ -r ./conf ] && . ./conf | ||
+[ -n "\$core_services" ] && SVDIR=".." sv start \$core_services | ||
+[ -p "$RUNIT_READY_PIPE" ] && printf "${services_dir}/${ready_sv}" > "$RUNIT_READY_PIPE" | ||
+exec pause | ||
+EOF | ||
+chmod +x "${services_dir}/${ready_sv}/run" | ||
+ | ||
+exec env DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$(id -u)/bus" \ | ||
+ runsvdir -P "$services_dir" \ | ||
+ 'log: ...........................................................................................................................................................................................................................................................................................................................................................................................................' | ||
diff --git a/backend/runit.conf b/backend/runit.conf | ||
new file mode 100644 | ||
index 0000000..7b258c9 | ||
--- /dev/null | ||
+++ b/backend/runit.conf | ||
@@ -0,0 +1,13 @@ | ||
+# This is the configuration file for turnstile's runit backend. | ||
+# | ||
+# It follows the POSIX shell syntax (being sourced into a script). | ||
+# The complete launch environment available to dinit can be used. | ||
+# | ||
+# It is a low-level configuration file. In most cases, it should | ||
+# not be modified by the user. | ||
+ | ||
+# the name of the service that turnstile will check for login readiness | ||
+ready_sv="turnstile-ready" | ||
+ | ||
+# the directory user service files are read from. | ||
+services_dir="${HOME}/.config/service" | ||
diff --git a/meson.build b/meson.build | ||
index e25ba83..dec58f8 100644 | ||
--- a/meson.build | ||
+++ b/meson.build | ||
@@ -23,6 +23,7 @@ scdoc_dep = dependency( | ||
) | ||
|
||
have_dinit = get_option('dinit').enabled() | ||
+have_runit = get_option('runit').enabled() | ||
|
||
conf_data = configuration_data() | ||
conf_data.set_quoted('RUN_PATH', get_option('rundir')) | ||
@@ -101,10 +102,15 @@ install_data( | ||
) | ||
|
||
# decide the default backend | ||
-if have_dinit | ||
- default_backend = 'dinit' | ||
-else | ||
- default_backend = 'none' | ||
+default_backend = get_option('default_backend') | ||
+if default_backend == '' | ||
+ if have_dinit | ||
+ default_backend = 'dinit' | ||
+ elif have_runit | ||
+ default_backend = 'runit' | ||
+ else | ||
+ default_backend = 'none' | ||
+ endif | ||
endif | ||
|
||
uconf_data = configuration_data() | ||
diff --git a/meson_options.txt b/meson_options.txt | ||
index 9b03995..4325042 100644 | ||
--- a/meson_options.txt | ||
+++ b/meson_options.txt | ||
@@ -3,6 +3,16 @@ option('dinit', | ||
description: 'Whether to install Dinit-related backend and data' | ||
) | ||
|
||
+option('runit', | ||
+ type: 'feature', value: 'disabled', | ||
+ description: 'Whether to install runit-related backend and data' | ||
+) | ||
+ | ||
+option('default_backend', | ||
+ type: 'string', value: '', | ||
+ description: 'Override the default backend' | ||
+) | ||
+ | ||
option('rundir', | ||
type: 'string', value: '/run', | ||
description: 'Where the base directory will be located' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Template file for 'turnstile' | ||
pkgname=turnstile | ||
version=0.1.6 | ||
revision=1 | ||
build_style=meson | ||
configure_args="-Ddinit=disabled -Drunit=enabled -Ddefault_backend=runit | ||
-Dmanage_rundir=true" | ||
hostmakedepends="pkg-config scdoc" | ||
makedepends="pam-devel" | ||
short_desc="Independent session/login tracker and user service manager" | ||
maintainer="classabbyamp <void@placeviolette.net>" | ||
license="BSD-2-Clause" | ||
homepage="https://github.com/chimera-linux/turnstile" | ||
distfiles="https://github.com/chimera-linux/turnstile/archive/refs/tags/v${version}.tar.gz" | ||
# _commit="a0b40dc430e365a96de65afd6ce237b58c7c3a07" | ||
# distfiles="https://github.com/chimera-linux/turnstile/archive/${_commit}.tar.gz" | ||
checksum=ea1b87ad153e97ecda698526eec1cbc9fee1cd2b134c43b449f35d9cec0a61bc | ||
conf_files="/etc/turnstile/turnstiled.conf" | ||
|
||
post_install() { | ||
vsv turnstiled | ||
vsconf "${FILESDIR}/dbus.run" | ||
vdoc "${FILESDIR}/README.voidlinux" | ||
vlicense COPYING.md | ||
} |