aboutsummaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2024-07-20librc.c: return "none" from rc_runlevel_get when in user mode.Anna (navi) Figueiredo Gomes
Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
2024-07-20openrc-pam: use full path to mark the serviceAnna (navi) Figueiredo Gomes
Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
2024-07-20openrc-pam: add loggingAnna (navi) Figueiredo Gomes
Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
2024-07-20openrc-pam: do not start a login shellAnna (navi) Figueiredo Gomes
Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
2024-07-20openrc-pam: fix session count logicAnna (navi) Figueiredo Gomes
Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
2024-07-20librc.c: use rc_runlevel_dir for rc_service_addAnna (navi) Figueiredo Gomes
Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
2024-07-20openrc-run.c: allow --user on shebangsAnna (navi) Figueiredo Gomes
Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
2024-07-20start-stop-daemon: open syslogDoug Freed
The stop schedule code calls syslog, so we need to open a syslog connection so the process name will get properly logged on musl, and we can ensure the pid gets logged and the right facility is used.
2024-07-20shared/plugin.c: fix incompatible function warning.Anna (navi) Figueiredo Gomes
Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
2024-07-20openrc-shutdown: simplify broadcast functionMike Gilbert
Get rid of the alarm/setjmp/longjmp. Trust that the kernel will not block with O_NDELAY. Use write() instead of stdio. Bug: https://bugs.gentoo.org/923326 Signed-off-by: Mike Gilbert <floppym@gentoo.org>
2024-07-20openrc-pam: use 'shared_module' for pam_openrcAnna (navi) Figueiredo Gomes
fixes the undefined reference build failure on freebsd, allowing the module to build while referencing 'environ' in misc.c. it also is the more correct meson function for pam modules. Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
2024-07-20openrc/rc-logger.c: set log path for user dynamicallyAnna (navi) Figueiredo Gomes
since it's not possible to differentiate the option set from an user configuration file versus the system wide, for user-mode openrc, use XDG_STATE_DIR (~/.local/state) unconditionally for now. Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
2024-07-20libeinfo.c: add footAnna (navi) Figueiredo Gomes
Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
2024-07-20librc-misc.c, rc.c, rc-status.c: fix memory leaksAnna (navi) Figueiredo Gomes
Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
2024-07-20librc, openrc-pam: instantiate user.<username> service automaticallyAnna (navi) Figueiredo Gomes
it's created in /run/openrc/dynamic and linked to the service in /etc at login. Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
2024-07-20librc/librc-depend.c: small refactorAnna (navi) Figueiredo Gomes
some changes for code redability, and fixing leaking the whole internals of the deptree at the end of rc_deptree_update. Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
2024-07-20openrc-run: allow multiplexed symlinks to live outside init.dAnna (navi) Figueiredo Gomes
use the realpath of the target to locate which sysconf dir it's in, using it as a base to load the config file. the service path is then normalized from the symlink without dereferencing it. Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
2024-07-20openrc-pam: auto-launch user services via pamAnna (navi) Figueiredo Gomes
Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
2024-07-19openrc-user: init script for usersAnna (navi) Figueiredo Gomes
adds a new multiplexed script for starting user sessions. it also sets up XDG_RUNTIME_DIR. Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
2024-07-19openrc: dynamic paths for user servicesAnna (navi) Figueiredo Gomes
add two api functions, `rc_service_dir` and `rc_sysconf_dir`, both are generate paths (and sub-paths) for resources, and meant to replace the hardcoded variables like `RC_SVCDIR`. those functions differ by dynamically switching between the system path, or the user path, set in their home folder or runtime directory. this lays out the intial support for user services. Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
2024-06-03librc: avoid using fixed-size buffers for pathsMike Gilbert
Use heap allocations instead. This avoids warnings: ``` ../src/librc/librc.c: In function ‘rc_service_mark’: ../src/librc/librc.c:817:58: warning: ‘/’ directive output may be truncated writing 1 byte into a region of size between 0 and 4095 [-Wformat-truncation=] 817 | snprintf(was, sizeof(was), "%s/%s/%s", | ^ ../src/librc/librc.c:817:25: note: ‘snprintf’ output 3 or more bytes (assuming 4098) into a destination of size 4096 817 | snprintf(was, sizeof(was), "%s/%s/%s", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 818 | file, dir->value, base); | ~~~~~~~~~~~~~~~~~~~~~~~ ../src/librc/librc.c:822:58: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=] 822 | snprintf(was, sizeof(was), "%s/%s", file, dir->value); | ^ ../src/librc/librc.c:822:25: note: ‘snprintf’ output 2 or more bytes (assuming 4097) into a destination of size 4096 822 | snprintf(was, sizeof(was), "%s/%s", file, dir->value); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ```
2024-04-05Add xterm-kitty to color capable term listJohn Einar Reitan
2024-03-31Touch up docs/commentsOskari Pirhonen
Remove the mention of linking with libtermcap from einfo(3), and fix some comments in libeinfo.c to more accurately reflect the new situation.
2024-03-31Trivial curses/termcap removalOskari Pirhonen
Remove the curses code and make the HAVE_TERMCAP-gated "fallbacks" always present. This makes an ANSI terminal required for colors. X-Gentoo-Bug: https://bugs.gentoo.org/904277 Closes: https://github.com/OpenRC/openrc/issues/619
2023-12-04change info words "remove" to "delete" in delete sub-commandZhao Yongming
This close #664
2023-11-15remove warning for runscript deprecationWilliam Hubbs
2023-11-15drop the deprecated "rc" binaryWilliam Hubbs
This binary is a copy of the openrc binary. Referring to it as rc was deprecated in 2016, so we should be able to drop it at this point.
2023-11-14Skip already processed files in rc_service_daemon_setAlexander Maltsev
Fixes the problem described in https://bugs.gentoo.org/916947 - start-stop-daemon hangs in infinite loop when stopping some daemons on linux 6.6+ It appears linux 6.6 reworked tmpfs, and since then it triggers this problem in openrc: when iterating over files via readdir, running rename on a file could result in reading the same file again with next readdir call. The Open Group manual for readdir explicitly states "If a file is removed from or added to the directory after the most recent call to opendir() or rewinddir(), whether a subsequent call to readdir() returns an entry for that file is unspecified.". Linux man page don't seem to mention that, but don't seem to say anything to contradict that either. So I presume we can't rely on some specific behaviour here. Bug: https://bugs.gentoo.org/916947
2023-11-14drop the deprecated runscript binaryWilliam Hubbs
2023-10-03Relocate pipes.c and pipes.h file to shared directory.Lexxy Fox
With the addition of logger process redirect in supervise-daemon, pipes.c and pipes.h are now included in both s-s-d and supervise-daemon. Thus it makes sense to move the source files to the src/shared dir.
2023-10-03supervise-daemon: implement output_logger and error_logger.Lexxy Fox
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-09-12misc: add syscall fallback for close_range for musl libcNatanael Copa
Add fallback for the close_range syscall wrapper. This is needed for musl libc, which currently does not have a close_range wrapper. Also set errno on errors.
2023-09-12start-stop-daemon: set fds to CLOEXEC instead of closingNatanael Copa
Set file descriptors to CLOEXEC instead of closing them before exec, similar to what we do in supervise-daemon. Use the share cloexec_fds_from() helper for this. closefrom() is no longer used so remove the test.
2023-09-12misc: add cloexec_fds_from() helper functionNatanael Copa
Move logic to set file descriptors to a cloexec_fds_from() function in misc.c so it can be shared by both supervisor-daemon and start-stop-daemon, and hide the details behind.
2023-09-12supervise-daemon: rename HAVE_CLOSE_RANGE_EXEC to HAVE_CLOSE_RANGENatanael Copa
Use HAVE_CLOSE_RANGE to tell if system provides a close_range(2) wrapper, which better explains the purpose. Add a compat inline which returns -1 if close_range is unavailable.
2023-08-29Don't re-define strlcpy/strlcat with >=glibc-2.38Sam James
`>=glibc-2.38` implements strlcpy, strlcat, etc so check for those functions with Meson and don't provide conflicting prototypes. Technically, it doesn't need _GNU_SOURCE, but it's easier because it's not clear right now what glibc wants to guard it with. Note that these are in POSIX next anyway. Fixes: https://github.com/OpenRC/openrc/issues/643 Signed-off-by: Sam James <sam@gentoo.org>
2023-07-26rc: fix automatic restart with runlevel-specific conf.d filesSven Wegener
Commit fc4f15d6cd8e7884f7094e5d3749b01f2d5a448f 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-05-14einfo: fix vewend applet argsOskari Pirhonen
Fix typo preventing the args for the vewend applet from being handled.
2023-05-10librc: allow overriding rc_interactive on kernel command lineSam James
This was originally introduced in 14625346c07a2a66fe77ce578c9423918bec1d97 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-04-24openrc-run: fix rc_parallel race in svc_execDominique Martinet
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-24openrc-run: silence lock failures with --no-depsDominique Martinet
work around scary warnings described in previous commit
2023-04-24openrc-run: remove kludge in restart --no-depsDominique Martinet
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-24rc: use LIST_FOREACH_SAFE in cleanup()NRK
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-24rc: block SIGCHLD during pid list operationsNRK
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-24rc: avoid calling free inside SIGCHLD handlerNRK
`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-24fstabinfo: deal with EINTR in waitpid callNRK
2023-04-24fstabinfo: replace vfork with posix_spawnpNRK
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-23einfo.h: fix EINFO_RESTRICT macro usageOskari Pirhonen
Make function declarations use the EINFO_RESTRICT macro instead of __EINFO_RESTRICT which gets treated as the name of the argument.
2023-04-20shared: fix pointer type in UNCONSTSam James
Thanks to vapier for noticing.
2023-04-19Rename attribute macros to namespaced RC_*Sam James
This conflicts with linux-headers which uses __unused for some padding members on ppc64le at least. Closes: https://github.com/OpenRC/openrc/issues/622