Page MenuHomeFreeBSD

rc: Disable pathname expansion when calling run_rc_command()
ClosedPublic

Authored by hrs on Jul 3 2024, 9:09 AM.
Tags
Referenced Files
Unknown Object (File)
Mon, Oct 13, 2:23 AM
Unknown Object (File)
Fri, Sep 26, 1:50 PM
Unknown Object (File)
Sep 14 2025, 9:13 AM
Unknown Object (File)
Sep 12 2025, 8:57 AM
Unknown Object (File)
Sep 9 2025, 10:38 AM
Unknown Object (File)
Sep 7 2025, 2:57 PM
Unknown Object (File)
Sep 4 2025, 10:33 PM
Unknown Object (File)
Aug 31 2025, 9:48 PM

Details

Summary

Variables for command-line options like $foo_flags can contain characters
that perform pathname expansions, such as '[', ']', and '*'. They were
passed without escaping, and the matched entries in the working directory
affected the command-line options. This change turns off the expansion
when run_rc_command() is called.

While this changes the current behavior, an invocation of a service
program should not depend on entries in the working directory.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

hrs requested review of this revision.Jul 3 2024, 9:09 AM
This revision was not accepted when it landed; it landed in state Needs Review.Jun 12 2025, 6:20 PM
This revision was automatically updated to reflect the committed changes.

This change introduced a regression where my allscreens_flags settings gets ignored at boot.

This change introduced a regression where my allscreens_flags settings gets ignored at boot.

Could you explain your configuation and behavior change in more detail?

In D45855#1160497, @hrs wrote:

Could you explain your configuation and behavior change in more detail?

Sure thing. I use the following in my rc.conf which enlarges the virtual terminal fonts from being small after loading a drm-kmod driver during the booting process:

allscreens_flags="-f spleen-16x32"

After doing a src tree build upgrade today this functionality had stopped. By manually removing both set -o noglob and set +o noglob lines, I restored the original functionality.

The problem is that allscreens_flags relies on the pathname expansion in two places:
https://github.com/freebsd/freebsd-src/blob/4deb9760a9d84d5861ee45162ffebe83f13503b8/libexec/rc/rc.d/syscons#L237-L243
https://github.com/freebsd/freebsd-src/blob/4deb9760a9d84d5861ee45162ffebe83f13503b8/libexec/rc/rc.d/syscons#L381-L387

In D45855#1160497, @hrs wrote:

Could you explain your configuation and behavior change in more detail?

Sure thing. I use the following in my rc.conf which enlarges the virtual terminal fonts from being small after loading a drm-kmod driver during the booting process:

allscreens_flags="-f spleen-16x32"

After doing a src tree build upgrade today this functionality had stopped. By manually removing both set -o noglob and set +o noglob lines, I restored the original functionality.

The problem is that allscreens_flags relies on the pathname expansion in two places:
https://github.com/freebsd/freebsd-src/blob/4deb9760a9d84d5861ee45162ffebe83f13503b8/libexec/rc/rc.d/syscons#L237-L243
https://github.com/freebsd/freebsd-src/blob/4deb9760a9d84d5861ee45162ffebe83f13503b8/libexec/rc/rc.d/syscons#L381-L387

Does this patch solve your problem?

https://people.allbsd.org/~hrs/FreeBSD/f1692c.diff