freebsd/usr.sbin/jail
Jamie Gritton 5cf7054917 jail: only chdir to user's home directory when user is specified
jail(8) with the "exec.clean" parameter not only cleans the enviromnent
variables before running commands, but also changes to the user's home
directory.  While this makes sense when auser is specified (via one of
the exec.*_user parameters), it leads to all commands being run in the
jail's /root directory even in the absence of an explicitly specified
user.  This can lead to problems when e.g. rc scripts are run from that
non-world-readable directory, and run counter to expectations that jail
startup is analogous to system startup.

Restrict this behvaiour to only users exlicitly specified, either via
the command line or jail parameters, but not the implicit root user.
While this changes long-stand practice, it's the more intuitive action.

jexec(8) has the same problem, and the same fix.

PR:		277210
Reported by:	johannes.kunde at gmail
Differential Revision:	https://reviews.freebsd.org/D46226
2024-08-12 15:23:28 -07:00
..
tests
Makefile
Makefile.depend
command.c
config.c
jail.8
jail.c
jail.conf.5
jaillex.l
jailp.h
jailparse.y
state.c