Bug 206291

Summary: rc.subr: limits(1) is unavailable before /usr is mounted
Product: Base System Reporter: Jean-Sébastien Pédron <dumbbell>
Component: confAssignee: Adrian Chadd <adrian>
Status: Closed FIXED    
Severity: Affects Only Me CC: citrin+pr, cy, gonzo, kevans, rgrimes
Priority: --- Keywords: patch
Version: CURRENT   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Possible rc.subr patch to only add limit to command string if it can be executed.
none
Possible rc.d/ddb patch to circumvent default start behaviour in rc.subr. none

Description Jean-Sébastien Pédron freebsd_committer freebsd_triage 2016-01-15 14:21:01 UTC
Since r288291, rc.subr calls limits(1), located in /usr/bin/limits. However, for services such as ddb which are started before partitions are mounted, /usr/bin/limits is unavailable.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2016-01-31 12:46:48 UTC
Over to committer of 288291.
Comment 2 Adrian Chadd freebsd_committer freebsd_triage 2016-01-31 16:54:51 UTC
eep, uhm, not sure what to do here. Hm. Suggestions?
Comment 3 Adrian Chadd freebsd_committer freebsd_triage 2016-01-31 16:55:10 UTC
(Could attempt to only run limits if it's found..)
Comment 4 Jean-Sébastien Pédron freebsd_committer freebsd_triage 2016-01-31 20:08:08 UTC
Yes, I thought about that too. I don't know what other parts of rc do about this.
Comment 5 Cy Schubert freebsd_committer freebsd_triage 2016-06-20 05:42:04 UTC
(In reply to Adrian Chadd from comment #3)
That's what my first patch did. The problem is, as you stated, that makes differing system behaviour depending on whether /usr is found or not.

The other option, which I prefer over my first suggestion in the email thread, is to use $start_cmd in rc.d scripts that execute prior to mountcritlocal, which is assigned at line 999 in rc.subr and executed at line 1005. The limits command is only executed if $start_cmd is not specified and the defaults are used. Essentially, This is differing system behaviour depending on whether $start_cmd is specified in the rc.d script or not.

Scanning through the rc.d scripts that execute prior to FILESYSTEMS, only ddb and var do not specify $start_cmd. The var script executes directly, it's not executed by rc.subr. The ddb script doesn't specify start_cmd and is the only script affected by this.

If ddb did specify $start_cmd, it would avoid the code in rc.subr that attempts and fails to execute limits(1). I think adding $start_cmd to either run a function in /etc/rc.d/ddb or run /sbin/ddb directly would circumvent this ticket. Just a thought. Going the function route is probably simpler.

I'll upload my two patches for the record and may the best one, or some other patch, be used.
Comment 6 Cy Schubert freebsd_committer freebsd_triage 2016-06-20 05:47:40 UTC
Created attachment 171592 [details]
Possible rc.subr patch to only add limit to command string if it can be executed.
Comment 7 Cy Schubert freebsd_committer freebsd_triage 2016-06-20 05:51:28 UTC
Created attachment 171593 [details]
Possible rc.d/ddb patch to circumvent default start behaviour in rc.subr.

This is preferred over the rc.subr approach. Both could be used, with the rc.subr patch used as a relief valve.
Comment 8 Cy Schubert freebsd_committer freebsd_triage 2017-06-26 19:18:42 UTC
Ping. Can either of these patches be committed
Comment 9 Rodney W. Grimes freebsd_committer freebsd_triage 2018-04-09 14:43:52 UTC
This bug needs triage back onto a public list, as it stands it is hidden from nag reports.  I would add it, but I am not sure which list would be appropriate.
Comment 10 commit-hook freebsd_committer freebsd_triage 2018-04-19 15:03:40 UTC
A commit references this bug:

Author: kevans
Date: Thu Apr 19 15:02:54 UTC 2018
New revision: 332773
URL: https://svnweb.freebsd.org/changeset/base/332773

Log:
  Fix ddb rc script

  r288291 added a call to limits(1), which isn't available before partitions
  are mounted. This broke the ddb rc script, which does not provide its own
  start_cmd.

  Alleviate the situation here by providing a start_cmd. We still have other
  problems with diskless setups that need to be considered, but this is a
  start.

  PR:		206291
  Submitted by:	cy
  Discussed with:	rgrimes
  MFC after:	3 days

Changes:
  head/etc/rc.d/ddb
Comment 11 commit-hook freebsd_committer freebsd_triage 2018-04-22 00:27:16 UTC
A commit references this bug:

Author: kevans
Date: Sun Apr 22 00:26:35 UTC 2018
New revision: 332864
URL: https://svnweb.freebsd.org/changeset/base/332864

Log:
  MFC r332773: Fix ddb rc script

  r288291 added a call to limits(1), which isn't available before partitions
  are mounted. This broke the ddb rc script, which does not provide its own
  start_cmd.

  Alleviate the situation here by providing a start_cmd. We still have other
  problems with diskless setups that need to be considered, but this is a
  start.

  PR:		206291

Changes:
_U  stable/11/
  stable/11/etc/rc.d/ddb
Comment 12 Oleksandr Tymoshenko freebsd_committer freebsd_triage 2019-01-21 18:07:50 UTC
There is a commit referencing this PR, but it's still not closed and has been inactive for some time. Closing the PR as fixed but feel free to re-open it if the issue hasn't been completely resolved.

Thanks