525 Commits

Author SHA1 Message Date
Laurent Bercot
6e6afa1b50 s6-svscanboot: launch s6-svscan with notify=fd:4
Now that the bug that made it fail is fixed, use the
start-stop-daemon readiness notification mechanism when
launching s6-svscan.

(We do not run s6-svscan under supervise-daemon because that
would needlessly lengthen the supervision chain. Yo dawg,
we heard you like supervisors.)
2025-11-18 12:22:07 +01:00
Laurent Bercot
aa456f3827 Add compatibility mode for s6 support
In order to avoid breaking things for the 3 users who use the old
s6 support, add compatibility.
When command= is empty and a service directory exists in /var/svc.d,
use that service directory instead of creating it from the service
file data.
2025-11-18 12:22:07 +01:00
NRK
303bc524e8 do_unmount: add parallel unmounting
this turns mouninfo into a multicall binary which can also do
parallel unmounting. most mountinfo code is unchanged; only
notable change is find_mounts() now returns the number of mounts
found and also takes the "process" function as an argument; so
that is_mounted() can be implemented on top of it.

do_unmount mostly follows the logic of previous code. some
notable changes:

- do_unmount is now "lazy" when it comes to retrying failed
  unmounts. it will greedily keep running unmount as long as it
  can before it looks at the "waiting" queue.
- it will check if the mountpoint is still mounted or not when
  umount returns non-zero exit code. this is due to the fact that
  multiple umount calls might race to unmount a shared mount. so
  if umount fails _but_ the mountpoint is no longer mounted, we
  assume success.
- do_unmount used to fail if fuser did not find any pids using
  the mount. the new code tries one more time; the rationale being
  that there's a gap between the umount call and the fuser call,
  and so whatever was using the mount before might have stopped
  using it now and so it's worth another attempt.

Fixes: https://github.com/OpenRC/openrc/issues/662
Closes: https://github.com/OpenRC/openrc/pull/698
2025-11-12 20:27:33 +01:00
Anna (navi) Figueiredo Gomes
3e25dd6659 sh/init.sh.Linux: make uucp group configurable
Closes: https://github.com/OpenRC/openrc/pull/730
2025-11-12 19:23:00 +01:00
Mark Hindley
b886fa58c1 Fix typo/mismerge in variable name. 2025-09-20 02:19:16 +02:00
Sertonix
947eee8424 sh/openrc-run: fix ~/.config/rc/rc.conf.d/*.conf not sourced
Fixes ae9d743207f2 openrc-run: Load user configs when using system-provided user sevices.
2025-09-16 20:26:38 +02:00
Anna (navi) Figueiredo Gomes
5a95fe737d sh/openrc-run: remove unnecessary loops
openrc-ruh.sh is only ever called from openrc-run.c, with a single
command, so looping over "$@" is unnecessary
2025-08-28 21:57:52 +02:00
Anna (navi) Figueiredo Gomes
3936b3437b sh/openrc-run: use $# for argument checking 2025-08-28 21:57:52 +02:00
Anna (navi) Figueiredo Gomes
563ef1641a librc: add wsl detection
probing procfs is the recommeded method on github[1], as well as the one
used by systemd[2], though we also do two additional checks mentioned by
Kangie in https://github.com/OpenRC/openrc/issues/871.

1: https://github.com/microsoft/WSL/issues/423#issuecomment-221627364
2: https://github.com/systemd/systemd/blob/main/src/basic/virt.c#L658
2025-08-23 03:24:58 +02:00
Arusekk
7fce20675c binfmt: also look in /usr/local/lib/binfmt.d
This is consistent with systemd, and kind of natural.
2025-06-07 12:27:49 +02:00
Anna (navi) Figueiredo Gomes
3e65b8ca0a build: drop 'os' option and use host_machine.system()
to specify a different host, meson's machine files should be used
instead.
2025-05-27 13:38:43 +02:00
Anna (navi) Figueiredo Gomes
452c29585b build: drop GNU-kFreeBSD support
Debian GNU-kFreeBSD was the only known distribution, and they dropped
support for GNU-kFreeBSD back in 2023[1]

1: https://lists.debian.org/debian-devel/2023/07/msg00176.html
2025-05-27 13:38:43 +02:00
Ulrich Müller
4fdb883a3d libeinfo.c, functions.sh: Drop upper limit for EINFO_INDENT
_eindent() already limits the width, so the additional limit in eindent
is not needed. It also prevented proper alignment of corresponding
eindent and eoutdent calls when the limit was exceeded.
2025-05-26 12:14:53 +02:00
Laurent Bercot
4043ce6524 supervisor=s6: fix indentation, add more paranoid hardening 2025-05-20 13:30:13 +02:00
Laurent Bercot
ad78eee78a supervisor=s6 support: additional small bugfixes 2025-05-20 13:30:13 +02:00
Laurent Bercot
2a2e6be1b7 supervisor=s6: rework support
This commit modernizes the support for the supervisor=s6
backend. It reworks how the supervision tree is started and
how the services are defined.

 The s6-svscan service now runs its own catch-all logger,
logging to $RC_SVCDIR/s6-logs.

 A service defining supervisor=s6 now has an automatic "need"
dependency to s6-svscan. A service directory will be automatically
built from the information in the service file, under the
$RC_SVCDIR/s6-services repository. These service directories are
cached until the service file (or config) changes. So, services
don't need to provide their service directories themselves
anymore; they still can, but they'll need to do the s6-sv[un]link
thing themselves.

 The documentation has been updated.

 Anna, please add yourself to the AUTHORS file, because it is
ridiculous that I am now in it and you are not.
2025-05-20 13:30:13 +02:00
Anna (navi) Figueiredo Gomes
31d3e719c0 sh/openrc-user.sh: log unset XDG_RUNTIME_DIR when failing
avoids confused users seeing the service failing in their logs
2025-04-19 03:09:13 +02:00
Anna (navi) Figueiredo Gomes
22efbb7112 sh/openrc-user.sh: log errors to syslog
users can't really see the stdout of the user.$USER service
2025-04-19 03:09:13 +02:00
Anna (navi) Figueiredo Gomes
3527c772ff openrc-run: rename ready -> notify
readiness notification is experimental, and imo naming it 'ready' was a
mistake, most other projects call them notify-fd, notify-socket, etc

systemd's protocol in particular, we plan to support a few more keys
than just "READY=1" (namely "STATUS" to begin with), so 'notify' is a
better variable name in my view
2025-04-08 16:20:20 +02:00
NRK
e7e7620efd openrc-user: fix typpo
Fixes: a154efbc0b50075592e2f4152549cfdab976a53d
2025-04-05 17:58:24 +02:00
Anna (navi) Figueiredo Gomes
2fe4abaf34 sh/init.sh: use RC_CACHEDIR in BSD/GNU 2025-04-05 16:19:34 +02:00
Anna (navi) Figueiredo Gomes
b532c3fa6f sh/init.sh: restore cache recusivelly 2025-04-05 15:51:42 +02:00
Anna (navi) Figueiredo Gomes
2c6ab9d5bf openrc-user: use ready=fd to notify the sesion when user 'boot' finished
this means users can reliably do checks like `--ifstarted status` from
profile scripts at login, and be sure certain environment variables can
be set as the listening services for them will already be running if
they're on the boot user runlevel
2025-04-04 17:10:24 +02:00
Anna (navi) Figueiredo Gomes
0da7326d6b openrc-user: start 'boot' runlevel for users
this runlevel is meant to setup services that are required for the
login session to start, and should hang the login until started.
2025-04-04 17:10:24 +02:00
Anna (navi) Figueiredo Gomes
a154efbc0b openrc-user: remove unnecessary leading underscore 2025-04-04 17:10:24 +02:00
Anna (navi) Figueiredo Gomes
68857a1c6d init.d/savecache, sh/openrc-user.sh: cache init.d and conf.d from svcdir as well
this avoids regenerating the deptree cache for services in there, if
they're always created
2025-04-04 03:39:33 +02:00
Anna (navi) Figueiredo Gomes
dab1e849c9 openrc-user: save and restore dep{tree,config} on start/stop 2025-04-04 03:39:33 +02:00
Anna (navi) Figueiredo Gomes
b71db40536 openrc: don't use libexec for data cache
instead, move caches to /var/cache/openrc. If /var is not mounted, cache
will not be used and the deptree would be regenerated

user services use ${XDG_CACHE_HOME}/rc, defaulting to ~/.cache

Closes: https://github.com/OpenRC/openrc/issues/339
2025-04-04 03:39:33 +02:00
Sören Tempel
9aceaee18f openrc-run: Support standard input redirection too
OpenRC already supports redirecting standard output/error of services.
This patch adds support for redirecting standard input as well. I
encountered the lack of this feature while working on a user service for
a Wayland compositor status bar which reads status text to be displayed
from stdin. Input redirection allows me to connect this user services to
another user service providing the status text via a named pipe.

Note that input redirection is also supported by SystemD (and
potentially other service supervisors) through the `StandardInput=`
directive [1].

[1]: https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#StandardInput=
2025-03-24 23:06:56 +01:00
Sören Tempel
028eadec44 openrc-run: Fix loading of user configs for system-supplied user services
Without this patch, OpenRC loads user configuration files for
system-supplied services from `~/.config/rc/$SERVICE` instead of
`~/.config/rc/conf.d/$SERVICE`. Since the latter is documented in the
user-guide, and used for user services not supplied by the system, I
believe it to be the correct location.

Note that the `_usr_conf_d` variable is probably a bit inappropriately
named as the similarly named `_conf_d` points to the system conf.d
directory while `_usr_conf_d` points to the base rc configuration
directory. Therefore, while at it, rename `_usr_conf_d` to `_usr_conf`
to avoid this confusion in the future.

This is a fixup for ae9d743207f27481efe2c80593eea51cd8742ab2.
2025-03-16 20:41:22 +01:00
Anna (navi) Figueiredo Gomes
ae9d743207 openrc-run: Load user configs when using system-provided user sevices. 2025-02-27 02:01:49 +01:00
Anna (navi) Figueiredo Gomes
4aec301e59 openrc-user, pam_openrc, init.d/user: Add autostart for user services. 2025-02-27 02:01:49 +01:00
Anna (navi) Figueiredo Gomes
b15076dec4 sh/*-daemon: Add --ready flag support. 2025-02-22 03:37:16 +01:00
Anna (navi) Figueiredo Gomes
e8fba17bd9 openrc-run: Disable cgroups for user services due to lack of permissions. 2025-01-07 20:24:35 +01:00
Anna (navi) Figueiredo Gomes
5d186b34a1 librc-depend, gendepends: Use rc_scriptdirs for lookup of services. 2024-10-26 20:24:55 +02:00
Mark Hindley
5874b2ca75 rc_ulimit: support multiple limits.
Fixes https://github.com/OpenRC/openrc/issues/399#issuecomment-810461921
2024-10-26 16:09:00 +02:00
William Hubbs
7c31e504d5 build: drop ROOTPREFIX setting
This change removes the ROOTPREFIX build setting.

If your OS expects to have / mounted earlier in the boot process than
/usr, you will need to pass the appropriate directory settings to "meson
setup" as part of the build process, for example:

$ meson setup \
    --bindir /bin --libdir /lib64 --libexecdir /lib --sbindir /sbin \
    build

also, move plugins  to ```libdir/rc/plugins``` which is the standard
location for plugins accessed via dlopen.
2024-09-23 13:23:12 -05:00
Kanako the Gay
b94dc7d8ab Podman detection 2024-07-25 14:09:10 +02:00
Natanael Copa
97689d6c44 sh/rc-cgroup.sh: add openrc. prefix the cgroupv2 path
Some services, like docker, creates and manages /sys/fs/cgroup/<service>
themselves. Avoid conflict with the openrc created cgroup path by adding
a `openrc.` prefix.

Fixes: https://github.com/OpenRC/openrc/issues/680
2024-01-09 10:09:59 -06:00
Haelwenn (lanodan) Monnier
1433552435 sh/supervise-daemon.sh: Proper casing for --no-new-privs 2023-11-02 13:35:37 -04:00
William Hubbs
965de92b37 change default RC_CGROUP_MODE to unified
This improves resource management by assigning services to individual
cgroups.

X-Gentoo-Bug: https://bugs.gentoo.org/914972
2023-10-10 12:50:09 -05:00
Lexxy Fox
9934e9f96e supervise-daemon: implement output_logger and error_logger.
Allows redirecting process stdin and stdout to another process,
just like is already possible with start-stop-daemon.

Also added --stdout-logger and --stderr-logger to the man page.
2023-10-03 16:43:39 -05:00
Mike Frysinger
52dcb4aaa3 netmount: add fuse.glusterfs
Fixes #495.
2023-01-15 15:24:51 -05:00
Mike Frysinger
ec04e08707 init: add missing eend to /run mount #554
Fixes #554.
2023-01-15 14:58:27 -05:00
Jakub Jirutka
953172c6c6 supervise-daemon: don't overwrite empty supervise_daemon_args
If supervise_daemon_args is not set *or empty*, it defaults to
`start_stop_daemon_args`. This is bad because supervise-daemon doesn't
accept the same options as `start-stop-daemon`. So if we set e.g.
`start_stop_daemon_args="--wait 50"`, but not `supervise_daemon_args`,
and the user adds `supervisor=supervise-daemon` to the corresponding
/etc/conf.d/<service> file, the service will fail to start due to
unrecognized option "wait".

It would be best to remove this fallback, but that might break some
existing scripts that depend on it. So this commit just changes it to
use `start_stop_daemon_args` as the default for `supervise_daemon_args`
only if `supervise_daemon_args` is not set at all, but not if it's
empty.

This at least simplifies workarounds; we can just add
`supervise_daemon_args="$supervise_daemon_args"` to init scripts.

This fixes #558.
2022-12-07 16:42:14 -06:00
psykose
14b153c1a4 fix quoting of loggers in start-stop-daemon
previously broken in 6034866d1c74d5a23eb9f3e0ebf40c9d278aac93
caused *_logger options to be passed unquoted, so
`error_logger="logger -t .."` would pass -t to s-s-d and fail to start
the service.

Fixes: #531
2022-07-03 12:40:34 -05:00
mochaaP
39eb3384f6 binfmt: ignore empty lines (#492) 2022-04-09 14:36:47 -04:00
William Hubbs
391d12db48 migrate fully to meson build system
- drop old build system
- move shared include and source files to common directory
- drop "rc-" prefix from shared include and source files
- move executable-specific code to individual directories under src
- adjust top-level .gitignore file for new build system

This closes #489.
2022-04-06 10:51:55 -05:00
LinkTed
6034866d1c Use consistent args passing in start-stop-daemon 2022-03-05 13:14:59 -05:00
LinkTed
8115f3274e linux: Add support for No New Privs flag
This add No New Privs flag for start-stop-daemon and supervise-daemon
by adding --no-new-privs flag. As a result, the user set the No New
Privs flag for the program should run with.
see PR_SET_NO_NEW_PRIVS prctl(2)
2022-02-06 17:17:46 -05:00