summaryrefslogtreecommitdiff
path: root/etc/rc.d/rc.subr
AgeCommit message (Collapse)Author
2020-02-22Do not run _rc_parse_conf of /var/run/rc.d/foobar on "start".Antoine Jacoutot
This is needed in case a foobar fails to start but still returns 0. Changing its flags (in rc.conf.local) would then get ignored because of this cache (which is around to handle stop/check/reload on flags changes). claudio@ reported this issue when struggling with prometheus several weeks ago
2019-09-07Remove dependency on basename(1).Antoine Jacoutot
prodded by deraadt@ ok kn@ deraadt@ tb@
2019-03-21Start in the daemon configured routing table and not in the one we're currentlyAntoine Jacoutot
in. This fixes the case where one would be in a non default rdomain shell then run an rdomain 0 rc.d daemon. reported by YASUOKA Masahiko and Pierre Emeriaud ok sthen@ claudio@ benno@
2019-01-20The shell will strip the quotes from daemon_flags when starting a daemon so makeAntoine Jacoutot
sure pexp matches the process (i.e. doesn't include the quotes). It's a bit hackish but it allows things like these in rc.conf.local: relayd_flags=-D IPS="1.2.3.4 2.3.4.5" And we properly end up with... $ grep ^pexp /var/run/rc.d/relayd pexp=/usr/sbin/relayd -D IPS=1.2.3.4 1.2.3.5 ... which matches what is in the process list: root 14217 <snip> 0:00.01 /usr/sbin/relayd -D IPS=1.2.3.4 1.2.3.5 There's always the possibility that we have introduced a regressions with hand crafted functions in rc.d scripts (mostly from packags), so watch out. reported by and debugged with claudio@
2018-10-29Revert previous (for now).Antoine Jacoutot
semarie found a few regressions with daemon that will fail if cwd is not accessible.
2018-10-16Change the way we call su(1) in rcexec:Antoine Jacoutot
- drop `-'l' to prevent simulating a full login and running /root/.profile (prodded by a mail from J Greely) - use `-m' to preserve the environment because we now set HOME to "/" like /etc/rc does; note that we now also clear the environment using `env -i' before running su(1) which leaves us with only HOME, PATH and SHELL Committing early to catch regressions fast, if any. ok halex@
2017-06-05Temporarily disable the second call to rc_check until I figure out whatAntoine Jacoutot
is going on. Should fix another case of false negative reported by sthen (redis).
2017-06-05Fix logic in _rc_wait to properly cope with setproctitle(3) daemons. It was aAntoine Jacoutot
regression from my recent rc.subr changes. reported by deraadt@ and naddy@ : pflogd was marked as failed during boot while it was properly running
2017-05-30Introduce a scary rc.conf(8) knob library_aslr=(YES|NO) to turn off theTheo Buehler
reordering of libraries by rc(8). This way machines with very slow disk I/O have a chance of booting within reasonable time now that libcrypto is also randomized. Discussed with various; input & ok from deraadt ajacoutot
2017-05-28Move check later to mitigate a possible race.Antoine Jacoutot
2017-05-28Indent and rename var; no functional change.Antoine Jacoutot
2017-05-28When a daemon reaches its timeout when starting, display "timeout" insteadAntoine Jacoutot
of "ok" so the user is warned and has a chance to fix it (most of the time due to bogus flags). Daemons reaching the timeout without being able to start are still marked as "failed" (which should also give a clue to the user that some investigation is needed). prodded by beck@ a while ago discussed with and ok sthen@
2017-05-28Drop useless lines continuation; no functional change.Antoine Jacoutot
2017-05-27Ok turns out we still want to keep the rc_bg variable around but we needAntoine Jacoutot
to know which daemon cannot background themselves (actually we want to know the opposite, but there are much more). However, it's only needed in _rc_wait and rc.subr still does its magic without the need to add `&'.
2017-05-27Add an ALRM timer to cope with 2 annoying issues in rc.d(8):Antoine Jacoutot
- prevent a daemon from hanging the boot (typo in your flagsm e.g. httpd_flags=-d) - make sure we can get the status of a backgrounded daemon instead of always returning success Side effect of this is that we can kill a knob! rip rc_bg :-) Ports will need love, and a second commit is coming for that. The diff is small yet not trivial so I am committing early in the release process in one shot so it can easily be reverted if needed. I started working on this during g2k16 in Cambridge then finished it in Brisbane for a2k17 where robert@, beck@ and sthen@ agreed it was the correct way to go and I should move ahead with it post 6.1. If you see any regression, please talk to me!
2017-02-17Stop supporting the historical way of starting ypbind(8); that is settingAntoine Jacoutot
'ypbind_flags=""' when domainname is set and /var/yp/binding exists. This can lead to inconsistent behavior at startup since /var may not be mounted yet and /etc/rc's start_daemon() will not start ypbind. A.K.A. make ypbind startup consistent with all other OpenBSD daemons. ok deraadt@
2017-01-24Whitespace.Antoine Jacoutot
2016-09-07Introduce an _rc_check_name() function to check the input script name so thatAntoine Jacoutot
we don't end up with cryptic error messages. Regex help from rpe@ Issue reported by Anthony Coulter in rcctl(8), but better fix the root cause. Also clarify the mage page that rc.d script name must follow ksh(1) variable naming. ok robert@ sthen@
2016-08-31use tab.Antoine Jacoutot
2016-05-03signal name should be first, fixes reload; ok deraadt@Otto Moerbeek
2016-04-28Experiment on matching on the daemon_user is over. It needs more work.Antoine Jacoutot
portmap isn't happy with it as reported by naddy@
2016-04-27Revert the revert and match on the daemon_user again.Antoine Jacoutot
We'll see if something else breaks but it's the right thing to do. discussed with robert@
2016-04-27Revert matching on the daemon user for now; it breaks sndiod handling whichAntoine Jacoutot
does start as root but does not have a root master process and instead changed its uid. reported by deraadt@
2016-04-26Bump copyright.Antoine Jacoutot
2016-04-26Introduce rtable(4) support to rc.subr(8).Antoine Jacoutot
It works by adding daemon_rtable=$id in /etc/rc.conf.local. rcctl(8) support coming in a few and so are the man pages bits. If you want multiple instances of the same daemon running in different routing tables, just symlink the original rc.d script. e.g. # cd /etc/rc.d && ln -s dhcpd dhcpd42 Then enable your daemons as such in rc.conf.local: dhcpd_flags= dhcpd42_flags= dhcpd42_rtable=42 most work done by Jiri B <jirib@devio.us>; with a few tweaks and simplifications by yours truly ok robert@ ... should make henning happy ;-)
2016-04-26Extend _RC_RUNFILE (/var/run/rc.d/scriptname) content with:Antoine Jacoutot
daemon_class, daemon_flags, daemon_timeout, daemon_user, pexp Add "pexp" as a valid variable to _rc_parse_conf() and sort the list while here. Besides having an easy way to see how a daemon was started exactly, it opens the door to rdomain/rtable support in rc.d(8). We need to have as much information on a daemon as possible if we want to target a specific rtable (using -T) and it also makes it easier to start multiple instances of the same daemon with similar flags as a different user... Of course that only works with rc.d scripts *not* overwritting the default rc_* functions. Man page tweaks coming later. discussed with and ok robert@
2016-03-26Make it possible to get usage as a non-root user.Antoine Jacoutot
ok robert@
2016-03-26Handle the rc_stop=NO => rc_restart=NO case within _rc_not_supported().Antoine Jacoutot
2015-12-21Revert, rc.d scripts have been fixed.Antoine Jacoutot
2015-12-21Comment the wait for start until I fix the x11 managers rc.d script.Antoine Jacoutot
2015-12-19After starting, unconditionally wait up to $daemon_timeout seconds to check thatAntoine Jacoutot
the daemon is actually running (instead of only when using rc_bg). This *may* trigger the following side effect: if a daemon starts then stops right away (because of a config parsing issue for e.g.), then it will slow down the boot process because rc will wait a bit before considering the start action failed. But at least it will allow us to detect those daemons and fix them or their rc.d(8) script. At least as far as I can tell, all base daemons should cope with it just fine. ok sthen@ robert@ on an earlier diff
2015-12-19Tidy up _rc_wait().Antoine Jacoutot
ok sthen@ robert@
2015-12-05It does not make sense to insert a specific route for 224/4 when theMartin Pieuchot
default one is good enough. So merge rc.conf(8)'s 'multicast_router' and 'multicast_host' into a single 'multicast'. If set to YES the reject route for 224/4 is not inserted by netstart(8). Manual bits from jmc@ ok henning@, ajacoutot@
2015-10-16Missing local.Antoine Jacoutot
ok schwarze@
2015-07-15By default, require an exact match of the process name and argument list.Antoine Jacoutot
This allows running several instances of the same rc.d(8) script by just linking it to different name. e.g. ln -s ftpproxy ftpproxy6 echo 'ftpproxy6_flags=-6' >>/etc/rc.conf.local This is likely to break some rc.d scripts in ports. I will try and fix them all in the next few days but I'd appreciate reports if I missed some. ok halex@
2015-07-15Always use the default flags when running !start.Antoine Jacoutot
This is necessary so that rc.d scripts launched with `-f' can be properly stopped, checked and reloaded. ok schwarze@
2015-07-15Merge comments.Antoine Jacoutot
2015-06-17Really make daemon_class read-only; it's set to "daemon" of a matchingAntoine Jacoutot
login class.
2015-05-02No more pf_rules ipsec_rules.Antoine Jacoutot
2015-04-29Check arguments before eval so we don't end up with a cryptic error message.Antoine Jacoutot
reported by jasper@ While here: _rc_is_supported() -> _rc_not_supported() - saves a fork - reduces triple negation to double negation in _rc_not_supported() - simplifie condition for rc_restart=NO from schwarze@ ok jasper@ schwarze@
2015-03-28_rc_err(): only display error message if there's an actual one.Antoine Jacoutot
Remove an exit() statement that could never be reached.
2015-01-02Fix return code of _rc_quirks().Antoine Jacoutot
ok robert@
2015-01-02Add a comment about the default values being duplicated in rcctl(8).Antoine Jacoutot
discussed with schwarze@
2014-11-17"reload" should fail if the service is not running in the first place.Antoine Jacoutot
ok robert@ sthen@
2014-08-30Make it possible to pass a specific error code to _rc_err().Antoine Jacoutot
ok robert@ schwarze@
2014-08-25Put _rc_err argument under quotes to respect the syntax we are passing.Antoine Jacoutot
2014-08-24Fix reversed logic.Antoine Jacoutot
ok schwarze@
2014-08-24Drop uneeded parenthesis in usage().Antoine Jacoutot
ok schwarze@
2014-08-24Drop unused variables.Antoine Jacoutot
2014-08-24In debug mode, make it clear when we are using the default flags whenAntoine Jacoutot
none are set. initial patch from me but reworked by schwarze@ ok schwarze@