Bug 239692 - rc: Environment variables set via ${name}_env are not passed to ${rc_arg}_cmd (e.g., start_cmd)
Summary: rc: Environment variables set via ${name}_env are not passed to ${rc_arg}_cmd...
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: conf (show other bugs)
Version: 11.2-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-rc mailing list
URL:
Keywords: needs-qa
Depends on:
Blocks:
 
Reported: 2019-08-07 12:12 UTC by Mateusz Piotrowski
Modified: 2019-08-23 03:41 UTC (History)
2 users (show)

See Also:
koobs: mfc-stable11?
koobs: mfc-stable12?


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mateusz Piotrowski freebsd_committer 2019-08-07 12:12:40 UTC
Here are the steps to reproduce:

1. Save the following script as /usr/local/etc/rc.d/teststartcmd and make it executable:

```
#!/bin/sh
# PROVIDE: teststartcmd
. /etc/rc.subr
name=teststartcmd
load_rc_config $name
start_cmd="teststartcmd_start"
teststartcmd_start() {
	env
}
run_rc_command "$1"
```

2. Run `sysrc teststartcmd_env="TESTVARIABLE=foo"` to modify rc.conf.

3. Run `service teststartcmd onestart` and observe that TESTVARIABLE is not in the output.

4. Save the following script as /usr/local/etc/rc.d/testcommand and make it executable:

```
#!/bin/sh
# PROVIDE: testcommand
. /etc/rc.subr
name=testcommand
load_rc_config $name
command="/usr/bin/env"
run_rc_command "$1"
```

5. Run `sysrc testcommand_env="TESTVARIABLE=foo"` to modify rc.conf.

6. Run `service testcommand onestart` and observe that TESTVARIABLE is in the output this time.
Comment 1 Mateusz Piotrowski freebsd_committer 2019-08-12 15:29:43 UTC
I've posted an attempt at addressing this issue: https://reviews.freebsd.org/D21228