summaryrefslogtreecommitdiff
path: root/src/shared
AgeCommit message (Collapse)Author
2025-11-13shared/misc: close exclusive fd on exec_serviceAnna (navi) Figueiredo Gomes
2025-11-12shared/misc.c: use posix_spawn in exec_serviceAnna (navi) Figueiredo Gomes
2025-06-27shared/misc: open svcdir dirfd after update_neededAnna (navi) Figueiredo Gomes
otherwise /run/openrc might not exist, and result on svcdirfd being -1 Fixes: https://github.com/OpenRC/openrc/issues/888
2025-06-16helpers: remove existss, unused internal functionAnna (navi) Figueiredo Gomes
2025-06-16checkpath,shared/misc: remove is_writable helperAnna (navi) Figueiredo Gomes
only one consumer, checkpath, and can easily be done directly with the access syscall
2025-06-16*: use access(..., F_OK) instead of exists/stat.2Anna (navi) Figueiredo Gomes
the exists() helper uses stat.2 unnecessarily, while calling access is simpler and does not require filling a struct stat for no reason. since this would make exists() into a wrapper that calls a single function and nothing else, let's just inline the calls to access and remove the helper.
2025-06-11Fix error message in parse_scheduleYury Vostrikov
Make it consistent with the other one: in case of error report failed input. Also change quoting from `%s' to '%s'.
2025-06-03shared/misc.c: update mtime on deptree, not the clock-skew fileAnna (navi) Figueiredo Gomes
Fixes: https://github.com/OpenRC/openrc/issues/874
2025-06-03shared/misc.c: print correct file for skewAnna (navi) Figueiredo Gomes
2025-05-27build: drop 'os' option and use host_machine.system()Anna (navi) Figueiredo Gomes
to specify a different host, meson's machine files should be used instead.
2025-05-27build: add project arguments instead of adhoc c_argsAnna (navi) Figueiredo Gomes
2025-05-27build: use declare_dependency for librcAnna (navi) Figueiredo Gomes
2025-05-27build: use declare_dependency for libeinfoAnna (navi) Figueiredo Gomes
2025-05-27build: use static_library and declare_dependency for shared codeAnna (navi) Figueiredo Gomes
2025-04-26shared/misc: handle EOF when waiting for notify.Anna (navi) Figueiredo Gomes
Bug: https://bugs.gentoo.org/952108
2025-04-19shared/misc: required `ready` tag for socket notify methodAnna (navi) Figueiredo Gomes
with this we can define `notify=socket` as an overall systemd "notify-socket" compatibility flag. in the future, `nofiy=socket` will simply enable access to the basic STATUS= command, `socket:ready` enables READY=1, `socket:fdstore` would enable fd-store compat, `socket:watchdog:<timeout>` for the watchdog and so on. the format of the variable would end up being: `notify="protocol[:option[,option ...]]"`
2025-04-19shared/misc: Unmask all signals before execl.Anna (navi) Figueiredo Gomes
openrc-run can be called from places that don't reset the signal mask before exec, example being the pam close_session session hook called from runuser, which leads to svc_exec hanging, as SIGCHLD is never delivered. Bug: https://bugs.gentoo.org/953748
2025-04-19shared/misc: remove unused signal_setup_restart.Anna (navi) Figueiredo Gomes
2025-04-15supervise-daemon: set default respawn-delay-step to 128msNRK
avoids wasting resources by spamming restarts on a service which would've failed anyways.
2025-04-15supervise-daemon: add --respawn-delay-{step,cap}NRK
allows specifying increasing respawn delay. for example, to try respawn immediately at first and then slowly backing off if the service continues to keep failing within respawn-period to avoid misusing system resource on trying to keep restarting a bad service too fast.
2025-04-15shared/misc: remove semicolon from service_{start,stop} macrosAnna (navi) Figueiredo Gomes
2025-04-15shared/misc: close lockfd in parent of exec_serviceAnna (navi) Figueiredo Gomes
it makes no sense for the parent to hold the lock, even with cloexec, and that makes attempts to wait on flock useless. it only worked so far due to busy-polling with open, so basically, we were waiting for an unlink, not a lockfile.
2025-04-15shared/misc: fix UAF on futimensatAnna (navi) Figueiredo Gomes
2025-04-15shared/misc: use rc_dirfdAnna (navi) Figueiredo Gomes
2025-04-15librc: use rc_dirfd internallyAnna (navi) Figueiredo Gomes
this also fixes the behaviour of rc_service_scheduled_by, returning a stringlist of service names, instead of the script that is being scheduled.
2025-04-09timeutils: add parse_duration()NRK
Co-authored-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
2025-04-09timeutils: add this fileNRK
2025-04-08openrc-run: rename ready -> notifyAnna (navi) Figueiredo Gomes
readiness notification is experimental, and imo naming it 'ready' was a mistake, most other projects call them notify-fd, notify-socket, etc systemd's protocol in particular, we plan to support a few more keys than just "READY=1" (namely "STATUS" to begin with), so 'notify' is a better variable name in my view
2025-04-06misc: add missing const on pointerNRK
2025-04-06rc-status: add --in-state flagNRK
Fixes: https://github.com/OpenRC/openrc/issues/612
2025-04-04misc: fix off by oneNRK
snprintf return value does not include the nul-byte, so return of `== size` is also a truncation case. Fixes: 010b0d5e1b1a20ce4708173bc325d3297b609da7
2025-04-04helpers: add memstream functionsNRK
the goal is to provide a safe and easy string building api for new code and to replace some of the old code doing error prone, ad-hoc coded and manual string building at the moment.
2025-04-04openrc: don't use libexec for data cacheAnna (navi) Figueiredo Gomes
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-04shared: add "socket" ready protocol.Anna (navi) Figueiredo Gomes
based on the systemd notify socket protocol, although at the moment we only support READY=1.
2025-04-04*: fix some typosAnna (navi) Figueiredo Gomes
a few matches were not typos (e.g. ahd), or not changes i'd care to make (e.g. bootup vs boot up). Closes: https://github.com/OpenRC/openrc/issues/812
2025-03-26rc_exec: add a `cmd` argNRK
avoids assuming argv[0] is the command
2025-03-26rc_exec: allow setting child's uid and gidNRK
2025-03-26treewide: move rc_waitpid() to rc_exec.cNRK
more suitable here since this is exec related and not necessarily plugin related.
2025-03-23rc_pipe_command: implement it on top of rc_execNRK
since rc_exec uses an `execpipe` to detect exec failures inside the child, this fixes the issue described in 792, but only for the first layer of exec. there's a /bin/sh in the middle and we won't be able to detect whether /bin/sh failed to exec the command without inspecting the (unreliable) exit code. Ref: https://github.com/OpenRC/openrc/issues/792
2025-03-23rc_exec: add a centralized exec functionNRK
currently there's a lot of ad-hoc fork exec going around. the goal of this is to centralize most of the typical cases.
2025-03-22plugin: use pipe2NRK
2025-03-22build: define _GNU_SOURCE inside meson if requiredNRK
2025-03-18*-daemon: redirect logger's std{out,err} to devnullNRK
Closes: https://github.com/OpenRC/openrc/issues/540
2025-03-13pipes: use _exit insteadNRK
it's generally advisable to use `_exit` rather than `exit` from forked child to avoid triggering things like `atexit` handlers and whatnot.
2025-03-13pipes: don't leak pipes on fork errorNRK
2025-03-11shared/misc: fix types on close_range wrapper (#789)Doug Freed
The syscall expects unsigned integers.
2025-03-08shared: allow LOGNAME variable for user-modeAnna (navi) Figueiredo Gomes
2025-03-07shared: allow user, shell, and xdg state/cache home vars for usersAnna (navi) Figueiredo Gomes
Closes: https://github.com/OpenRC/openrc/issues/781
2025-03-07shared: only allow XDG and user variables when in user modeAnna (navi) Figueiredo Gomes
2025-02-22misc, *-daemon: Implement s6-style readiness notification.Anna (navi) Figueiredo Gomes
Adds two helper functions, and allows scripts to wait until services are ready before proceeding with it's dependees by setting `ready=fd:<num>`, where <num> is the file descriptor the daemon should write a new line to.