Bug 248865 - rc scripts in /usr/local/etc/rc.d/ may be ignored
Summary: rc scripts in /usr/local/etc/rc.d/ may be ignored
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: conf (show other bugs)
Version: Unspecified
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-rc (Nobody)
Depends on:
Reported: 2020-08-24 04:23 UTC by unitrunker
Modified: 2020-08-26 04:37 UTC (History)
2 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description unitrunker 2020-08-24 04:23:09 UTC
rc.subr uses grep to look for rc scripts with '^# PROVIDE:'

See "find_local_scripts_new" and "find_local_scripts_old".

RC scripts in /usr/local/etc/rc.d/* without the "# PROVIDE:" clause are ignored by /etc/rc.

I think this is a mistake. Per the docs, the "PROVIDE" clause is optional. This is certainly the case for rc scripts in base (eg. /etc/rc.d/).

To fix this, either ...

1. Update the docs (see bug https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=121440).

Note that an empty "# PROVIDE:" clause will work. Only scripts under /usr/local/etc/rc.d/ are affected by this quirk.

... or ...

2. Update rc.subr to detect scripts that contain ANY of the well-known rc script clauses: PROVIDE, REQUIRE, BEFORE, or KEYWORD (or some other heuristic to detect a valid RC script).

In any case, the documentation should be updated to say that - because /usr may not yet be mounted when /etc/rc first runs, scripts under /usr/local are not visible. Such scripts are run in a second pass made by /etc/rc (after the root file system has been made read-write). This has the same effect as adding ...


... to any RC script under /usr/local/etc/rc.d/

The reason is /etc/rc only runs scripts up to and including FILESYSTEMS in the first pass.
Comment 1 unitrunker 2020-08-24 04:36:20 UTC
To reproduce, paste the following into a file named /usr/local/etc/rc.d/placebo

------------>8 snip 8<---------

. /etc/rc.subr


  sleep 5

  sleep 5

load_rc_config $name
run_rc_command "$1"
------------>8 snip 8<---------

Enable the service in /etc/rc.conf ...

# sysrc placebo="YES"

Verify the service runs ...

# service placebo start
# service placebo stop

... now reboot.

# reboot

The above service is NOT run by /etc/rc because it does not contain a '# PROVIDE: ' clause.
Comment 2 unitrunker 2020-08-24 15:55:05 UTC
Typo fix:
# sysrc placebo_enable="YES"