[jhalfs] 01/03: BLFS: Prevent HOME to be passed to commands run as root
"Git Owner" ([email protected] via alfs-discuss Mailing List) <[email protected]> Sun, 24 May 2026 14:01:03 +0000
| Newsgroups | gmane.linux.lfs.automated |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format... ------------=_1779631277-28454-32093 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit This is an automated email from the git hooks/post-receive script. git pushed a commit to branch trunk in repository jhalfs. commit c7dca6049598c247918f3d4fb0ee9465e7074943 Author: Pierre Labastie <[email protected]> AuthorDate: Sun May 24 13:28:23 2026 +0200 BLFS: Prevent HOME to be passed to commands run as root Otherwise, it is possible that files owned by root are created in the user's directory --- BLFS/xsl/process-install.xsl | 2 +- README.BLFS | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/BLFS/xsl/process-install.xsl b/BLFS/xsl/process-install.xsl index 6f7e557..ecf904f 100644 --- a/BLFS/xsl/process-install.xsl +++ b/BLFS/xsl/process-install.xsl @@ -508,7 +508,7 @@ echo Time before test: ${SECONDS} >> $INFOLOG <xsl:template name="begin-root"> <xsl:if test="$sudo='y'"> <xsl:text> -sudo -E sh -e << ROOT_EOF +sudo -E -H sh -e << ROOT_EOF PATH=$PATH:/usr/sbin</xsl:text> </xsl:if> </xsl:template> diff --git a/README.BLFS b/README.BLFS index 54af736..b50994a 100644 --- a/README.BLFS +++ b/README.BLFS @@ -364,7 +364,7 @@ For commands necessitating root privileges, the generated scripts wrap them with the construct: - sudo -E sh -e << ROOT_EOF + sudo -E -H sh -e << ROOT_EOF <commands to be executed as root with `$', ``', and `\' escaped> ROOT_EOF The "-e" switch to sh ensures the command block exits with error if an @@ -374,7 +374,10 @@ the user attributes (this is implicit if the command the user is allowed to run is `ALL'). If you think it is a security issue, you may forbid this flag in /etc/sudoers, but then, you have to un-escape `$' for - variables coming from the environment in the instructions. Although this + variables coming from the environment in the instructions. The "-H" switch + prevents HOME to be passed in the environment, and sets it to root's + home. This prevents creating some files owned by root in the user's + home. Although this construct is rather strong, it can fail in some corner cases, so carefully review those instructions. -- To stop receiving notification emails like this one, please contact the administrator of this repository. ------------=_1779631277-28454-32093 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- http://lists.linuxfromscratch.org/sympa/info/alfs-discuss Unsubscribe: See the above information page ------------=_1779631277-28454-32093--