Bug 197152 - rc(8) config files under /usr/local/etc/rc.d/rc.conf.d/ are not sourced at startup
Summary: rc(8) config files under /usr/local/etc/rc.d/rc.conf.d/ are not sourced at st...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: conf (show other bugs)
Version: 10.1-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: Fernando Apesteguía
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-28 10:26 UTC by Jason Mann
Modified: 2023-02-17 13:19 UTC (History)
2 users (show)

See Also:


Attachments
patch-share_man_man5_rc.subr.5 (777 bytes, patch)
2015-07-18 14:04 UTC, Jamie Landeg-Jones
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Mann 2015-01-28 10:26:48 UTC
OVERVIEW:

The rc.conf(5) man page states the following:

"In addition to /etc/rc.conf.local you can also place smaller configuration files for each rc(8) script in the /etc/rc.conf.d directory or <dir>/rc.conf.d directories specified in local_startup, which will be included by the load_rc_config function."

I have successfully split the contents of my /etc/rc.conf file into multiple files under /etc/rc.conf.d/ and these are all sourced and correctly acted upon at system startup.

However, if I relocate the port/package specific files to /usr/local/etc/rc.d/rc.conf.d/, but they are not acted upon at startup.

The default value of local_startup is "/usr/local/etc/rc.d", as defined in /etc/defaults/rc.conf.

This departs from the expected behaviour as described in rc.conf(5).


STEPS TO REPRODUCE:

- Relocate a working rc config file from /etc/rc.conf.d/ to /usr/local/etc/rc.d/rc.conf.d/
- Reboot the system.
- Verify whether the service in question starts on boot.


ACTUAL RESULTS:

- Service is not started at system startup.


EXPECTED RESULTS:

- Service should be started at system startup.


ADDITIONAL INFORMATION:

I tested this on my system with the openntpd and dnsmasq packages.  Both started fine when their rc config files were under /etc/rc.conf.d/.  Neither started when those files were moved to /usr/local/etc/rc.d/rc.conf.d/.
Comment 1 Jason Mann 2015-01-28 11:21:23 UTC
Examination of the 'load_rc_config' function in /etc/subr reveals that any "rc.d" suffix would be removed from any paths specified in the local_startup parameter.

This means that the default local_startup value of /usr/local/etc/rc.d/ would instead result in rc config files being sourced from /usr/local/etc/rc.conf.d/, not /usr/local/etc/rc.d/rc.conf.d/.

The wording of the rc.conf(5) man page is misleading regarding this.  It states that scripts can be placed in "<dir>/rc.conf.d", where <dir> is the path specified in local_startup.  It follows that /usr/local/etc/rc.d/rc.conf.d would be where rc config scripts should be put.


I tested this by moving the rc config files from /usr/local/etc/rc.d/rc.conf.d/ to /usr/local/etc/rc.conf.d/ and rebooted.  Services then started as expected.


This bug might be reclassified as a documentation bug if this was the intended behaviour.
Comment 2 Jamie Landeg-Jones 2015-07-18 14:01:09 UTC
Yeah, it's a documentation bug - the rc.conf.d directory sits alongside rather than within any rc.d directory - as demonstrated by an example a few lines after the text you quoted.

However, this example is also buggy, in that a "/etc" is missing!

Attached is a proposed fix for both issues

cheers, Jamir
Comment 3 Jamie Landeg-Jones 2015-07-18 14:04:53 UTC
Created attachment 158941 [details]
patch-share_man_man5_rc.subr.5
Comment 4 Fernando Apesteguía freebsd_committer freebsd_triage 2023-02-09 17:41:54 UTC
This was addressed in 454adf0fa4d787bf6e6ff7be0aa6c27a91d2be8e
Comment 5 Jamie Landeg-Jones 2023-02-16 11:11:10 UTC
No, only the missing 'etc' was fixed. The original reported error (that my patch also fixed) still exists.
Comment 6 Fernando Apesteguía freebsd_committer freebsd_triage 2023-02-16 12:24:40 UTC
Thanks for the feedback. I'll look into it.
Comment 7 Fernando Apesteguía freebsd_committer freebsd_triage 2023-02-16 13:04:26 UTC
FYI:

https://reviews.freebsd.org/D38627
Comment 8 Jamie Landeg-Jones 2023-02-17 00:24:29 UTC
(In reply to Fernando Apesteguía from comment #7)

Brilliant!

Cheers
Comment 9 commit-hook freebsd_committer freebsd_triage 2023-02-17 13:18:31 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=9e0d41c8f063111803c36e5aaff1126c99e8c7ea

commit 9e0d41c8f063111803c36e5aaff1126c99e8c7ea
Author:     Jamie Landeg-Jones <jamie@catflap.org>
AuthorDate: 2023-02-16 11:55:01 +0000
Commit:     Fernando Apesteguía <fernape@FreeBSD.org>
CommitDate: 2023-02-17 12:17:54 +0000

    rc.conf.5: clarify source directories

    In 454adf0fa4d787bf6e6ff7be0aa6c27a91d2be8e some of the issues reported in the
    PR where addressed. This commit adds a clarification about how the prefix of the
    directories to be sourced actually behave.

    PR:             197152
    Reported by:    jason.mann+freebsd@gmail.com
    Approved by:    manpages (bcr@)
    Differential Revision:  https://reviews.freebsd.org/D38627

 share/man/man5/rc.conf.5 | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
Comment 10 Fernando Apesteguía freebsd_committer freebsd_triage 2023-02-17 13:19:14 UTC
Committed,

Thanks!