Page MenuHomeFreeBSD

init: Use root's home directory in single-user mode
ClosedPublic

Authored by jilles on Sep 14 2025, 10:08 PM.
Tags
None
Referenced Files
F166527405: D52527.diff
Fri, Aug 14, 1:45 AM
F166408636: D52527.id.diff
Thu, Aug 13, 11:24 AM
Unknown Object (File)
Thu, Aug 13, 2:02 AM
Unknown Object (File)
Mon, Aug 10, 2:39 AM
Unknown Object (File)
Sun, Aug 9, 11:26 PM
Unknown Object (File)
Sat, Aug 8, 7:35 PM
Unknown Object (File)
Sat, Aug 8, 5:12 PM
Unknown Object (File)
Sat, Aug 8, 11:26 AM
Subscribers

Details

Summary

When starting single-user mode, use the home directory from user root as current directory and for the HOME environment variable. If the directory does not exist, set HOME=/.

Also adjust /root/.profile to stop setting HOME, since it should always have been set now.

This is intended to keep shell startup files working in single-user mode after /.profile has been removed by a change like https://reviews.freebsd.org/D52161 .

Test Plan
  • build and install world
  • ensure /.profile does not exist
  • boot in single-user mode
  • verify HOME is /root and the prompt is root@:~ # as set by /root/.shrc

Diff Detail

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

Event Timeline

Yeah, this seems fine to me. I did wonder for a second if the /rescue variants of shells do or should assume setugid behavior and avoid loading dotfiles in case something in the profile or other bits finds a way to make the shell unusable, but I didn't really convince myself.

This revision is now accepted and ready to land.Sep 15 2025, 3:12 AM

i was planning to do this myself at some point, thanks!

I did wonder for a second if the /rescue variants of shells do or should assume setugid behavior and avoid loading dotfiles in case something in the profile or other bits finds a way to make the shell unusable, but I didn't really convince myself.

The /bin/csh and /rescue/csh have different dotfiles and could therefore be used to recover from this kind of issue. Anyway, this was the case before this change as well.