aboutsummaryrefslogtreecommitdiff
path: root/src/openrc/rc.c
AgeCommit message (Collapse)Author
2023-10-19openrc: rework pathing functionsAnna (navi) Figueiredo Gomes
this simplifies the allocation of path string. also fixes some memory leaks from the ealier commit also changes the log path for users to XDG_CACHE_HOME, default ~/.cache/openrc Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
2023-10-19openrc: create lockfile for --user.Anna (navi) Figueiredo Gomes
the pam module sets a variable that when in user mode, openrc should pick up and either create/increment, or decrement. this is done so that multiple session_open and session_close from pam doesn't randomly change the user runlevel for the current user. only the first session open starts the default runlevel, and only the last session close switches to the none runlevel. Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
2023-10-19openrc: Add support for user services.Anna (navi) Figueiredo Gomes
Modifies many functions where filesystem paths were hardcoded. In non-user-services mode, they still are. In user-services mode, they are allocated, since XDG_ dirs are to be set via environment variables. Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
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-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-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
2023-01-29openrc: missing includes from IWYUSam James
2023-01-28openrc: avoid unnecessary malloc inside sig-handlerNRK
malloc (called by xasprintf) is not async-signal-safe. beside, the string here is constant, so there's no need to malloc it all. eerrorx isn't async-signal-safe either (due to calling fprintf and exit) but consequence of them are _typically_ not as grave as calling malloc while it's internal state is inconsistent. Bug: https://github.com/OpenRC/openrc/issues/589
2023-01-25openrc: mark handle_bad_signal as noreturnSam James
For -Wmissing-noreturn.
2023-01-25openrc: fix double-assignment to dirSam James
This one is a bit odd, it didn't get fixed in e273b4e08ee0ebc1a001d60e2a5b65a9553a8a8a, and goes all the way back to cb9da6a262b60255cd037f20b4cde3ab2c8a1e6a.
2023-01-25openrc, openrc-run: Fix -Wstrict-prototypesSam James
These become fine with C23 because () starts to mean (void) then, but for previous language versions, it's deprecated, and it causes an annoying warning when building with Clang by default. Plus, GCC lacks specific flags to trigger what C23 *does* ban, so a lot of people are going around building with -Wstrict-prototypes, so let's just fix this to be consistent with the rest of the codebase anyway to fend off false positive reports.
2022-07-21openrc: fix help messagesxdavidwu
The two lines seem to both belong to --override, but made into seperate array elements accidentally, making options after --override and their help mismatch. This fixes it.
2022-04-30multiple spelling and typo fixesJosh Soref
This fixes #516.
2022-04-06migrate fully to meson build systemWilliam Hubbs
- 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.