Page MenuHomeFreeBSD

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

Authored by jilles on Sun, Sep 14, 10:08 PM.
Tags
None
Referenced Files
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
Unknown Object (File)
Sat, Sep 27, 8:38 AM
Unknown Object (File)
Wed, Sep 24, 6:28 AM
Unknown Object (File)
Wed, Sep 24, 6:12 AM
Unknown Object (File)
Fri, Sep 19, 11:03 AM
Unknown Object (File)
Mon, Sep 15, 1:11 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.Mon, Sep 15, 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.