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
Unknown Object (File)
Wed, Oct 15, 6:18 AM
Unknown Object (File)
Fri, Oct 10, 10:21 AM
Unknown Object (File)
Fri, Oct 10, 10:21 AM
Unknown Object (File)
Fri, Oct 10, 10:21 AM
Unknown Object (File)
Fri, Oct 10, 3:48 AM
Unknown Object (File)
Thu, Oct 2, 4:56 AM
Unknown Object (File)
Tue, Sep 30, 7:51 AM
Unknown Object (File)
Sat, Sep 27, 6:46 PM
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.