3909 Commits

Author SHA1 Message Date
Anna (navi) Figueiredo Gomes
500a52218d *-daemon: always call setgroups, defaulting to count = 0
services started by init don't get any supplementary groups, but anything
started from a shell would inherit the groups, causing inconsistent
behaviour

we can either clear all groups, or always initalize root's groups. since
other init systems does not initialize anything, including us at boot,
let's just always clear them unconditionally
2025-11-19 19:39:47 +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
Anna (navi) Figueiredo Gomes
e50e4a8189 release 0.63 0.63 2025-09-20 03:47:26 +02:00
Anna (navi) Figueiredo Gomes
1d4fc1c1ed librc: use xasprintf in rc_service_description 2025-09-20 03:39:31 +02:00
Anna (navi) Figueiredo Gomes
77fb635c59 librc: use xasprintf in rc_service_extra_commands 2025-09-20 03:39:31 +02:00
Anna (navi) Figueiredo Gomes
6903d0214d librc: use statically sized array over constant xmalloc in file_regex 2025-09-20 03:39:31 +02:00
Anna (navi) Figueiredo Gomes
94ee0d0f84 librc: remove d->d_name, not pathname, in rm_dir loop
Fixes: https://bugs.gentoo.org/963052
2025-09-20 03:08:53 +02:00
Mark Hindley
b886fa58c1 Fix typo/mismerge in variable name. 2025-09-20 02:19:16 +02:00
Sertonix
ecddfc98b0 librc-depend: fix rc.conf.d/*.conf mtime not checked 2025-09-16 20:26:38 +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
ec544781e1 openrc: disable --override and krunlevel for user services
we don't support it for user sessions yet, so this will silence some
unnecessary errors when the system instance is using krunlevels
2025-09-10 03:27:01 +02:00
Anna (navi) Figueiredo Gomes
817c70b374 pam_openrc: don't unlock non-initialized lockfd.
this passed by unnoticed during a refactor, where svc_lock was moved
down. defer would've prevented this.
2025-09-07 14:16:10 +02:00
SetiQyu
459db56ce0 librc, mountinfo: fix build headers for netbsd 2025-09-07 04:40:27 +02:00