3920 Commits

Author SHA1 Message Date
Haelwenn (lanodan) Monnier
584444d1da rc-service: print name of command on exec failure
For example with noexec in the home, it changes:
   $ rc-service -U foo start
    * rc-service: Permission denied

to:
    $ rc-service -U foo start
     * rc-service: Failed executing '/home/haelwenn/.config/rc/init.d/foo': Permission denied
2026-01-17 15:39:13 +01:00
Jesse De Haan
2e1dbd9ebe man/openrc-shutdown.8: correct kexec option
7689106a changed the kexec option for openrc-shutdown from "-k" to "-K"
but the manpage was never updated.
2026-01-07 11:43:11 +01:00
Laurent Bercot
099375266e Remove restart(); add framework for reload() support
OpenRC will never call restart(), so scrap the definition in
openrc-run.sh and s6.sh.
 reload() caused a weird error message when used without
supervisor=s6, so add proper support for generic reload(),
instantiated for s6, and with a better default error message
for other backends - which can now add support for reload()
down the line.

 Also clarify a comment, and add info messages on s6_reload.
2026-01-07 11:42:57 +01:00
Anna (navi) Figueiredo Gomes
a951b9a216 openrc-run.sh: Add missing /conf.d path suffix 2025-12-08 20:15:01 +01:00
Anna (navi) Figueiredo Gomes
3500e6ea60 meson.build: expose initdir and confdir on pkg-config 2025-12-05 00:35:17 +01:00
Anna (navi) Figueiredo Gomes
06e098a4aa openrc-run: load conf.d from RC_PATH
generalizing the logic via RC_PATH makes it more flexible, and allows
better usage of multiple unique init directories

we load the config directories in reverse order so that "overriding"
works as intended, i.e., /etc takes preference over /usr

this also makes config directories additive, while init directories are
completely replace each other, config directories are combine, meaning
to change one setting, only that setting needs to be presented in a
higher-priority conf.d
2025-12-05 00:35:17 +01:00
Anna (navi) Figueiredo Gomes
db54d91126 env_config: export RC_PATH from scriptdirs 2025-12-05 00:35:17 +01:00
Anna (navi) Figueiredo Gomes
696e684c72 librc: add dynamic init.d and conf.d path resolution
the default path now consists of:

$XDG_CONFIG_DIRS/rc
/etc/rc
/usr/{local,pkg}/etc/rc
/usr/libexec/rc

for user services, $XDG_CONFIG_HOME/rc is added at the top of the config
dirs, $XDG_DATA_HOME at the top of data dirs, and /user is append to all
other paths

additionally, RC_PATH is read from the environment, if it is set, it is
split at every semi-colon and used in place of any default path

XDG_CONFIG_DIRS can be used to prepend the default path, rather than
replacing it whole with RC_PATH.

/etc and /usr/local/etc are provided as compatibility and using the
/rc variants is prefered

/usr/libexec/rc is a new location, meant for system packages to install
init.d to, as many distros would like to have all system packages
install to /usr alone and not touch /etc

/run/openrc is also searched, however it is for now left undocummented,
as the behaviour around it is currently only for internal use, and will
suffer breaking changes if/when made public

Closes: https://github.com/OpenRC/openrc/issues/823
2025-12-05 00:35:17 +01:00
Anna (navi) Figueiredo Gomes
dd1b61edd8 librc: read RC_SVCDIR from the environment 2025-12-05 00:35:17 +01:00
Anna (navi) Figueiredo Gomes
7e648545c1 librc: check rc_dirs.*dir directly in rc_*dir functions
rc_dirs.set will become a flag for the cleanup atexit function, so it
can't be used to determine if alternative paths themselves are set
2025-12-05 00:35:17 +01:00
Anna (navi) Figueiredo Gomes
5fc9fe9979 librc: check of invalid rc_dir in rc_dirfd() 2025-12-04 17:58:20 +01:00
Anna (navi) Figueiredo Gomes
2afd857201 supervise-daemon: fix failure when notify fd matches pipe fd
dup2 does not clear cloexec if dup2(n, n), causing the notify fd to be
closed, see commit f09a15d4.
2025-11-19 19:16:13 +01:00
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
f09a15d461 start-stop-daemon.c: fix failure case on --notify fd:4
When the created notified pipe (often on 4) is the same number as
the notification fd target, dup2() does not clear the FD_CLOEXEC
flag, so the fd gets closed right when exec'ing the daemon,
reporting readiness failure. Fix this by explicitly testing for
the case and clearing the flag when necessary.

Note that this happens because of a call to close_range() right
before the test. close_range() is the real problem, it should
never be used and this bug is a perfect illustration of why; but
getting rid of close_range() is a much more invasive change that
I don't want to commit to right now, especially since navi's plan
is to eventually deprecate start-stop-daemon.
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
Anna (navi) Figueiredo Gomes
39eb8a9da7 openrc-run: error check posix_spawn_file_actions_* calls 2025-11-13 17:16:49 +01:00
Anna (navi) Figueiredo Gomes
f09ca47fe5 init.d/*: check if RC_CACHEDIR is writtable
Bug: https://github.com/OpenRC/openrc/issues/890
Fixes: https://github.com/OpenRC/openrc/issues/936
2025-11-13 17:02:31 +01:00
Anna (navi) Figueiredo Gomes
ef1cd9255a checkpath: allow -W with -f, -d, -p
check for writtability after the open attempt, and still creating the
file beforehand if it doesn't exist
2025-11-13 17:02:31 +01:00
Anna (navi) Figueiredo Gomes
b8c244654f checkpath: don't break the format string 2025-11-13 17:02:31 +01:00
Anna (navi) Figueiredo Gomes
1416a477fa checkpath: use goto err 2025-11-13 17:02:31 +01:00
Anna (navi) Figueiredo Gomes
52974f7fe4 checkpath: use mkfifoat 2025-11-13 17:02:31 +01:00
Anna (navi) Figueiredo Gomes
920e03bb33 checkpath: factor openat call out of switch 2025-11-13 17:02:31 +01:00
Anna (navi) Figueiredo Gomes
9b39243da5 checkpath: split out create code into a function 2025-11-13 17:02:31 +01:00
Anna (navi) Figueiredo Gomes
4fdde6c39d checkpath: pass TRUNC to initial opening flags if used 2025-11-13 17:02:31 +01:00
Anna (navi) Figueiredo Gomes
7f9f45d175 checkpath: unify default mode check 2025-11-13 17:02:31 +01:00
Anna (navi) Figueiredo Gomes
68c7bf0e21 checkpath: formatting: check conditions in-place 2025-11-13 17:02:31 +01:00
Anna (navi) Figueiredo Gomes
0ce58d7abe checkpath: remove unnecessary memset 2025-11-13 17:02:31 +01:00
Anna (navi) Figueiredo Gomes
7598d72e2e checkpath: unify umask call when creating $path 2025-11-13 17:02:31 +01:00
Anna (navi) Figueiredo Gomes
27181f4152 checkpath: simplify open flags
O_CLOEXEC and O_NOFOLLOW are posix for a while now, no need to check.
2025-11-13 17:02:31 +01:00
Anna (navi) Figueiredo Gomes
8aa8fa1731 checkpath: use result of basename_c(path) directly
path is not modified in that function, and basename_c already returns a
null-terminated string, so there's no need to allocate a copy
2025-11-13 17:02:31 +01:00
Anna (navi) Figueiredo Gomes
f3f3f14248 checkpath: formatting: unify variable declarations 2025-11-13 17:02:31 +01:00
Anna (navi) Figueiredo Gomes
787997b7b8 checkpath: use switch over if-else chain 2025-11-13 17:02:31 +01:00
Anna (navi) Figueiredo Gomes
1b0ff45769 checkpath: use early returns 2025-11-13 17:02:31 +01:00
Anna (navi) Figueiredo Gomes
fbac8c54d3 checkpath: formatting: use single quotes over backtick 2025-11-13 17:02:31 +01:00
Anna (navi) Figueiredo Gomes
9549926422 checkpath: formatting: remove odd line breaks 2025-11-13 17:02:31 +01:00
Anna (navi) Figueiredo Gomes
2e04c7241a init.d/localmount: remove sourcing of rc-mount.sh 2025-11-13 14:16:28 +01:00
Anna (navi) Figueiredo Gomes
19c784cea0 shared/misc: close exclusive fd on exec_service 2025-11-13 02:08:06 +01:00
Anna (navi) Figueiredo Gomes
a16ea753cf openrc-run: fix path to openrc-run.sh 2025-11-12 21:43:45 +01:00
Anna (navi) Figueiredo Gomes
4088073a75 openrc-user: use /bin/sh if user's login shell is not in /etc/shells
Bug: https://github.com/OpenRC/openrc/issues/940
2025-11-12 21:28:10 +01:00
Anna (navi) Figueiredo Gomes
bf972af8a0 openrc-run: formatting changes
odd line breaks were annoying me a lot
2025-11-12 21:23:59 +01:00
Anna (navi) Figueiredo Gomes
ff1b121dac shared/misc.c: use posix_spawn in exec_service 2025-11-12 21:23:59 +01:00
Anna (navi) Figueiredo Gomes
d9b1e65418 openrc-run: use posix_spawn
makes the code simpler, since we don't have to care about signals and
forking directly, and faster.
2025-11-12 21:23:59 +01:00
Anna (navi) Figueiredo Gomes
2dc132584f openrc-run: cleanup svc_exec 2025-11-12 21:23:59 +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
NRK
a477d469eb rc.conf: change default fuser_timeout to 20 seconds
openrc-run has a (hardcoded) 60 seconds timeout, it a service
fails to start/stop within that time, it will be SIGKILL-ed. so
a default 60 seconds fuser_timeout is kind of bad. change it to
20seconds which is somewhat more sensible.
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
Aster Boese
215ffbc192 supervise-daemon: reverse meaning of respawn-delay value warning
Currently, the warning states that the user should increase the value of respawn-delay,
even though the code checks if respawn-delay is more than the cap and period value.
Thus, the correct warning is to recommend the opposite.

Fixes https://github.com/OpenRC/openrc/issues/939
2025-11-08 01:25:45 +01:00
Sam James
e1573d2aa1 init.d/net-online: pass -n to ping to avoid rDNS overhead
e21b01b97e84f81589f52e087d2b2ac53f0bf144 fixed one of the issues mentioned
in Gentoo bug #650584 but not the other one. `ping` without `-n` will perform
reverse DNS lookups for IPs which we don't want, as it introduces a delay
and confuses the calculation we make.

Bug: https://bugs.gentoo.org/650584
Bug: https://github.com/OpenRC/openrc/issues/353
2025-10-30 17:16:49 +01:00
Tomas Fabrizio Orsi
8d34e3f952 Expand minimum padding to 26 in rc-update
Originally, rc-update displayed service names with a padding of 20
characters. However, some services like "systemd-tmpfiles-setup-dev"
required longer padding and caused the displayed service table to
be missaligned.

Therefore, padding is increased to 26 characters.

Bug: https://github.com/OpenRC/openrc/issues/937

Signed-off-by: Tomas Fabrizio Orsi <torsi@fi.uba.ar>
2025-10-18 21:28:49 +02:00
nilninull
d67595b01e Added missing options to the zsh completion definitions
Added missing options to the completion definition files for the
rc-service, rc-status, and rc-update commands.
(Including --user and -U):

Added status to the cmd option for rc-service.
2025-10-18 17:17:55 +02:00