Commit Graph

3541 Commits

Author SHA1 Message Date
Sven Wegener
86efc43d0e rc: fix automatic restart with runlevel-specific conf.d files
Commit fc4f15d6cd broke the automatic restart of
services having runlevel-specific conf.d files.

The double dirname() was not a mistake, but the way of getting from the
service script in init.d to the upper directory containing the conf.d
directory. dirname() modifies the argument in-place, so the second call
operated on a modified value. To make it more obvious what is going on,
have the second call operate on the returned value from the first call.

Fixes: fc4f15d ("openrc: fix double-assignment to dir")
Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
2023-07-26 22:41:42 -05:00
Jernej Jakob
cd53239701 bash-completion/rc-service: don't set or unset extglob
It breaks bash-completion.
It's not necessary to set extglob as patterns in '[[' after '=='
are always matched as if extglob were set.

Closes: #636
Signed-off-by: Jernej Jakob <jernej.jakob@gmail.com>
2023-07-26 22:41:19 -05:00
William Hubbs
92662ddc44 version 0.48 2023-07-05 16:28:44 -05:00
William Hubbs
1b6a35488d update news for 0.48 release 2023-07-05 16:25:28 -05:00
Petr Vaněk
1eccb7f5e6 man: Remove Duplicate Description of -2/--stderr Flag
This commit removes the secondary mention of the -2/--stderr flag in the
start-stop-daemon man page. The flag's functionality was already
sufficiently described in an earlier section of the text.

Signed-off-by: Petr Vaněk <arkamar@atlas.cz>
2023-05-21 10:57:53 -04:00
Oskari Pirhonen
fe37fc9322 einfo: fix vewend applet args
Fix typo preventing the args for the vewend applet from being handled.
2023-05-14 00:50:03 -04:00
Sam James
edf5f830e3 librc: allow overriding rc_interactive on kernel command line
This was originally introduced in 14625346c0 with
an example list (just one for rc_parallel) of options. Let's add in rc_interactive
as it's a pretty obvious thing one might want to override.

See https://forums.gentoo.org/viewtopic-p-8694588.html.
2023-05-10 21:39:25 -04:00
Dominique Martinet
863e1a5c87 openrc-run: fix rc_parallel race in svc_exec
svc_exec waits until SIGCHLD comes in to close its input, but in
rc_parallel case the SIGCHLD might be unrelated.

Checking the proper pid is found in signal handler and only signaling
signal_pipe the status code directly avoids this problem.
2023-04-24 22:06:53 -05:00
Dominique Martinet
0b9c3c0803 openrc-run: silence lock failures with --no-deps
work around scary warnings described in previous commit
2023-04-24 22:06:41 -05:00
Dominique Martinet
a3c721b682 openrc-run: remove kludge in restart --no-deps
restarting a service with --no-deps ran into a "hairy workaround", which
had a few problems discussed in [1]:
 - it ignores --dry-run, really restarting the requested service
 - if the service was stopped, the program is started but the service
status stays stopped. This makes long-lived services impossible to
(re)start again (pid already exists and running), and the service also
won't stop on shutdown.

The kludge had a long comment describing the following situation:
 - openvpn needs net and dns
 - net restarts dns
 - dns needs net

If the restart in net handled deps, openrc would deadlock waiting for
net in dns' restart, as net won't be started until that is done.

Restarting with --nodeps works around the deadlock, but can display
errors without the kludge (note that the services did start properly
anyway, the problem is that the default service path tries to lock dns
twice from openvn's dep's start and net's start's restart):
---
alpine:~# rc-service openvn start
openvn                   | * Caching service dependencies ...                                                                                                      [ ok ]
net                      |net starting
net                      |dns                       | * Call to flock failed: Resource temporarily unavailable
net                      |dns                       | * ERROR: dns stopped by something else
net                      |net started
dns                      |dns started
openvn                   |openvn started
alpine:~# rc-status | grep s[1-3]
 net                                                               [  started  ]
 dns                                                               [  started  ]
 openvn                                                            [  started  ]
---

Locking again in restart --nodep can fail in two patterns:
 - openvpn's need dependency start was first, and the restart in net
failed (case above): we can just silence locking failures and exit quietly
with restart --no-deps, which is not worse than trying to restart while
another process hold the lock.
 - the restart in net's start was first, and openvpn's need dependency
start failed: not much can be done here short of adding a new status
that a no-deps restart is in progress as in the comment, but this case
can actually just be solved by adjusting dependencies -- and it actually
has already been fixed: the current openvpn init script in alpine only
'use dns', so it will not try to start it, and that will start just
fine with openvpn -> net -> dns only each starting each other once
sequentially.

Another failure pattern is just starting dns directly: that will start
net, which will try to restart dns while we are starting it.
Silencing messages on restart also solves this.

Link: https://github.com/OpenRC/openrc/issues/224 [1]
2023-04-24 22:06:41 -05:00
NRK
3f82d5b1a3 rc: use LIST_FOREACH_SAFE in cleanup()
according to the linux manpage, the "safe" variant may not be available
on all platform. however we bundle our own `queue.h` so this should not
be an issue.
2023-04-24 19:20:19 -05:00
NRK
0b4732520f rc: block SIGCHLD during pid list operations
the pid list will be accessed inside the SIGCHLD signal handler. so we
must ensure SIGCHLD handler doesn't get invoked while the list is at an
inconsistent state making it unsafe to interact with.

Co-authored-by: Dominique MARTINET <dominique.martinet@atmark-techno.com>
Bug: https://github.com/OpenRC/openrc/issues/589#issuecomment-1406588576
2023-04-24 19:20:19 -05:00
NRK
bbd3acfc67 rc: avoid calling free inside SIGCHLD handler
`free` is not async-signal-safe and calling it inside a signal handler
can have bad effects, as reported in the musl ML:
https://www.openwall.com/lists/musl/2023/01/23/1

the solution:

- keep track of weather remove_pid() is being called from inside a
  signal handler or not.
- if it's inside a signal handler then DO NOT call free - instead put
  that pointer into a "to be freed later" list.
- if it's not inside a signal handler then take the "to be freed later"
  list and free anything in it.

Bug: https://github.com/OpenRC/openrc/issues/589
Reported-by: Dominique MARTINET <dominique.martinet@atmark-techno.com>
2023-04-24 19:20:19 -05:00
NRK
910e3e2a0e fstabinfo: deal with EINTR in waitpid call 2023-04-24 19:18:18 -05:00
NRK
5f04dcc951 fstabinfo: replace vfork with posix_spawnp
problem:
* vfork has been removed from POSIX [0].
* clang-tidy flags the `strerror` and `eerror` call inside the vfork-ed
  child as undefined behavior.

solution: use posix_spawnp, which is serves similar purpose and is
specified in posix. and as an added bonus, it's also easier to use and
less lines of code.

[0]: https://www.man7.org/linux/man-pages/man2/vfork.2.html#CONFORMING_TO
2023-04-24 19:18:18 -05:00
Oskari Pirhonen
8f52c64c37 einfo.h: fix EINFO_RESTRICT macro usage
Make function declarations use the EINFO_RESTRICT macro instead of
__EINFO_RESTRICT which gets treated as the name of the argument.
2023-04-23 16:11:15 -04:00
Sam James
09d405fb3e shared: fix pointer type in UNCONST
Thanks to vapier for noticing.
2023-04-20 07:50:49 -04:00
Sam James
36e4e04ba9 meson.build: add -Werror=... for modern C issues
Clang 16 makes these warnings fatal and GCC 14 is likely to as well.
2023-04-19 16:44:51 -04:00
Sam James
eb8831a141 Rename attribute macros to namespaced RC_*
This conflicts with linux-headers which uses __unused for some padding members
on ppc64le at least.

Closes: https://github.com/OpenRC/openrc/issues/622
2023-04-19 16:44:51 -04:00
William Hubbs
0b5cb3abcb version 0.47 2023-04-18 00:14:28 -05:00
William Hubbs
f6ed2c660c update news 2023-04-18 00:13:16 -05:00
Doug Freed
002bcf0b67 rc.conf: note SSD_* vars need exporting 2023-04-17 23:53:18 -05:00
William Hubbs
b9241988a7 init.d/rc.conf: make unicode default to yes 2023-03-07 00:48:43 -06:00
psykose
5ae4d4edb5 rc.conf: default to unicode console
it's the high year of 2023, after all.

closes #607
2023-03-06 22:41:36 -05:00
NRK
95b2948e6e seedrng: fix copyright year
this was mistakenly changed to 2023 instead of 2022-2023 in 63a5ee3d
2023-02-16 07:54:17 -05:00
anon
b73d326387 rc-status: comment consistecy 2023-02-15 22:51:40 -05:00
anon
476272be0c rc-status: all flags respect '-f' 2023-02-15 22:51:40 -05:00
NRK
63a5ee3d8c seedrng: fix memory leak reported by clang-tidy
`seed_dir` gets allocated via xstrdup but never gets freed - which
clang-tidy flags as a memory leak.

instead of free-ing the allocation, just don't allocate to begin with
since there's no need for it.

also bump the copyright year.
2023-02-05 00:38:20 -05:00
NRK
36cc40a9d6 bash-completions/rc-service: don't use grep
Co-authored-by: Mike Frysinger <vapier@gentoo.org>
Closes: https://github.com/OpenRC/openrc/issues/344
2023-02-02 19:37:09 -05:00
NRK
ae5e38dce5 start-stop-daemon: avoid malloc inside sig-handler
same rational as 459783bb

Bug: https://github.com/OpenRC/openrc/issues/589
2023-01-30 22:54:20 -05:00
NRK
5858f980c8 openrc-run: avoid malloc inside sig-handler
same rational as 459783bb

Bug: https://github.com/OpenRC/openrc/issues/589
2023-01-30 22:54:20 -05:00
Sam James
db96295e00 value: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
f5ed484920 swclock: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
00f90f2b0e supervise-daemon: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
b405681926 start-stop-daemon: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
d5700d036a shell_var: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
616f756ca8 shared: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
17cfb41d81 service: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
1bc87b7a7c seedrng: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
f3be11a00d rc-update: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
406ab2a4ca rc-status: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
7878a53542 rc-service: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
084e6b5e20 rc-depend: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
a7bd13145b rc-abort: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
28ecb38515 openrc-shutdown: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
91737be1ab openrc-run: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
fb6ffc5713 openrc: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
01acbe3c27 openrc-init: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
aa5c3ccd0b mountinfo: missing includes from IWYU 2023-01-29 11:32:22 -06:00
Sam James
d795ea183f mark_service: missing includes from IWYU 2023-01-29 11:32:22 -06:00