736 Commits

Author SHA1 Message Date
Anna (navi) Figueiredo Gomes
478a1868d6 init.d/sysctl: manually load sysctl config if --system fails
busybox's and toybox's sysctl do not have --system

currently we simply check for return success, this if fragile as
failures unrelated to "missing --system" would also trigger the manually
loading path, alternatively we could have some hard knob, though an
automated detection method would be preferred

Fixes: https://github.com/OpenRC/openrc/issues/947
2025-11-14 15:32:04 +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
2e04c7241a init.d/localmount: remove sourcing of rc-mount.sh 2025-11-13 14:16:28 +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
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
Lauri Tirkkonen
85214aec18 sysfs: mount tracefs explicitly if available
for rationale, see
https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9ba817fb7c6afd3c86a6d4c3b822924b87ef0348
2025-09-03 16:11:50 +02:00
John R. Graham
6c3f879d9c init.d/net-online: Support tun/tap devices
Added a single line that allows tun/tap interfaces to be properly handled. It
turns out that /sys/class/net/${interface}/operstate shows "unknown" for tun/tap
interfaces, not "up", which is the value that net-online depends on. So tun/tap
interfaces need minor special handling.
2025-08-23 16:26:21 +02:00
John R. Graham
b62a2a8ea8 init.d/net-online: Minor bug fix
The code that reads interface status from the sysfs had stderr redirection in
the wrong order, which means that, in the event that the interface does not yet
exist, the read will display an error message that was meant to be suppressed.
2025-08-23 16:26:21 +02:00
Anna (navi) Figueiredo Gomes
8c6d0e06c2 init.d/*: add -wsl depend keywords
by the list in !871 it mostly seemed to match docker and similar, so for
now let's add -wsl to all services that have -docker

Closes: https://github.com/OpenRC/openrc/issues/871
2025-08-23 03:24:58 +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
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
William Hubbs
0026e6a1ee build: fix installation of getty symlinks
The getty symlinks are installed both in the init.d directory and the
default runlevel directory. This makes the getty installation consistent
with the rest of the runlevel setup.
2025-04-29 19:31:36 +02:00
William Hubbs
a0d71145fe build: install functions.sh init.d symlink with meson 2025-04-29 16:58:03 +02:00
Anna (navi) Figueiredo Gomes
a7069c0757 Revert "init.d/user: add a respawn_delay value"
this reverts commit 1146ee616c55751db4350c389757862d67e7a1b0.

safe-guarding against new defaults in /etc/rc.conf isn't really great in
retrospect, so ideally we improve the defaults so that rc.conf presets
are not needed.

Bug: https://github.com/OpenRC/openrc/issues/852
2025-04-29 16:25:41 +02:00
Anna (navi) Figueiredo Gomes
1146ee616c init.d/user: add a respawn_delay value
Fixes: https://github.com/OpenRC/openrc/issues/852
2025-04-27 15:53:39 +02:00
Anna (navi) Figueiredo Gomes
21b341c1fa init.d/user: use longer respawn period
some setups could actually take more than a second to fail 3 times "in a row"

Bug: https://bugs.gentoo.org/952108
2025-04-26 10:37:30 +02:00
Anna (navi) Figueiredo Gomes
dcf1099d89 init.d/meson.build: install agetty as a relative symlink
it's the standard for symlinks to exist as relative pointers. absolute
symlinks at install time also triggers an issue with meson[1]

1: https://github.com/mesonbuild/meson/issues/12253
Fixes: https://github.com/OpenRC/openrc/issues/847
2025-04-25 19:43:10 +02:00
NRK
6411b4b0cc init.d/user: quit fast if it's failing rapidly
Ref: https://bugs.gentoo.org/952108
Ref: https://github.com/OpenRC/openrc/issues/817
2025-04-15 11:53:42 +02:00
Lauri Tirkkonen
295d6bd776 sysfs: mount /sys/fs/bpf if available
eg. cilium expects /sys/fs/bpf to be mounted. systemd mounts it here as
well.
2025-04-15 02:45:25 +02:00
NRK
0e81a514e8 init.d/user: use notify (fixes 3527c772) 2025-04-13 13:55:54 +02:00
NRK
e56171b2a1 install agetty symlinks via meson
also adds a 'agetty' array option so that user can specify which
symlinks to create.

Closes: https://github.com/OpenRC/openrc/pull/355
2025-04-09 02:36:08 +02:00
Pablo Correa Gómez
9faaaa93cc cgroups: set (irrelenvant) device string to cgroup2
Just a cosmetic change with no real changes, more than the visual impact
when running mount
2025-04-05 14:24:21 +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
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
283fd3cf6e init.d/savecache: remove softlevel from save list
there's no point in saving a copy of softlevel, it'll always be the
runlevel 'savecache' is running under, and it'll always be re-written to
"sysinit" early at boot
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
Ulrich Müller
2992cfa375 init.d/*: Quote the argument of ":" commands
This avoids globbing, see: https://www.shellcheck.net/wiki/SC2223
2025-03-08 21:56:37 +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
ea310b2e58 init.d/root.in: fix eend message 2024-07-28 04:07:36 +02:00
Dominique Martinet
6bfef87736 init.d/root: add support for 'r?shared' fstab option on /
containers on linux might require filesystems to be mounted with
different propagation than the kernel default of 'private':
by setting 'shared' in fstab for / options, one can now make the
fs hierarchy shared.

Note we use 'rshared' to make other existing mounts shared as well
because the setting is contagious and it seemed more logical to
behave as if the setting was set on / immediately (and thus inherited
by other mounts)

This fixes #525.
2024-07-28 04:06:23 +02:00
Kanako the Gay
b94dc7d8ab Podman detection 2024-07-25 14:09:10 +02:00
Forza-tng
f9c92d7822 enable confd cgroups mount options
This fixes #684.
2024-01-12 11:17:14 -06:00
Sam James
6f180e9424 init.d/cgroups.in: fix inconsistency between mount_cgroups and mount_cgroups
965de92b37cbe8d8670f6cc956e1d10677551e19 changed the default cgroup mode which
exposes an issue in init.d/cgroups.in.

While mount_cgroups defaults to 'unified' if rc_cgroup_mode is unset, cgroup2_controllers
has no default and therefore has a mismatch with the logic in mount_cgroups. The
two should be consistent so the flow makes sense, as mount_cgroups expects a certain
path to be taken in cgroup2_controllers.

Make cgroup2_controllers default to 'unified' if rc_cgroup_mode is unset, just
like mount_cgroups.

Bug: https://bugs.gentoo.org/916964
Thanks-to: acab@digitalfuture.it
2023-11-14 14:31:22 -06: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
William Hubbs
b9241988a7 init.d/rc.conf: make unicode default to yes 2023-03-07 00:48:43 -06:00
William Hubbs
839083bb52 make the location of the swclock reference file configurable
This fixes #565.
2022-12-08 09:56:40 -06:00
Stefan Linke
9380347f04 Avoid warning on grep 3.8 in hwclock
Starting with grep version 3.8, the hwclock init script logs warnings
about stray backslashes:

> hwclock | * Setting system clock using the hardware clock [UTC] ...
> hwclock |grep: warning: stray \ before -
> hwclock |grep: warning: stray \ before -

This is caused by the check for existence of the `--noadjfile` argument
in function `get_noadjfile()`.

Replacing the affected logic with an explicit argument denoting the
pattern as such resolves the issue.

Fixes #548
2022-09-07 11:59:30 -04:00
Sören Tempel
d21dde73ba init.d/root: don't remount swap
While refactoring the changes proposed in #533 a minor error was
introduced were the root service will now attempt to remount swap.
This will fail with the error message `mountinfo: 'swap' is not a
mountpoint`.

This fixes #546
2022-09-04 18:44:47 -05:00
Sören Tempel
f60d42e901 init.d/root: also remount / with options provided in /etc/fstab
Without this commit, the root OpenRC service remounts all mounted
filesystems (except /) with the options defined in /etc/fstab via
fstabinfo. It is presently unclear to me why / was excluded from
remounting in 497ff7ee41168d863971efb52e2ca6b42f765832 and unfortunately
neither the commit nor the associated Bugzilla issue [1] provides
further information on this.

At Alpine, our initramfs does currently not remount / with all options
defined in /etc/fstab [2]. As part of the discussion on the Alpine side
of things we wondered why OpenRC does not remount / since this would be
the easier solution for us. For this reason, this commit changes the
behavior of the OpenRC root services accordingly to also remount / with
the options defined in /etc/fstab.

[1]: https://bugs.gentoo.org/401573
[2]: https://gitlab.alpinelinux.org/alpine/mkinitfs/-/merge_requests/103
This fixes #533.
2022-09-02 13:41:44 -05:00
William Hubbs
3cc4c01485 remove trailing space 2022-06-28 17:21:54 -05:00
William Hubbs
414f398498 modules.in: always return 0, make loading more verbose 2022-06-27 17:32:42 -05:00
William Hubbs
d2b3144070 clean up hostname service script
- use _ throw-away variable to get rid of a shellcheck warning
- remove tests for /etc/hostname and just try to read it
- drop reference to bash HOSTNAME variable.
- make source of host name more accurate

X-Gentoo-Bug: 850577
X-Gentoo-Bug-URL: https://bugs.gentoo.org/850577
2022-06-08 13:40:29 -05:00
Josh Soref
3054046e18 multiple spelling and typo fixes
This fixes #516.
2022-04-30 21:32:32 -05:00
Jason A. Donenfeld
f81bb7e2c4 seedrng: use posix positional params to avoid space splitting
The value of ${seed_dir} may have spaces in it, making the current
argument string building method unsafe. Instead, use positional
parameters to pass these arguments safely.
2022-04-21 13:44:44 -04:00
Jason A. Donenfeld
9b16bfe0e7 seedrng: incorporate various improvements
There have been a number of subtle improvements and cleanups to seedrng,
including using openat and locking the directory fd instead of a
separate lock file. Also various stylistic cleanups.

This fixes #519.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2022-04-20 15:45:20 -05: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
Sam James
0efc1b133e init.d/seedrng.in: fix rc_yesno typo
This fixes #512.
2022-03-31 09:57:01 -05:00