From 538aa7a11ce19920685e26062aec82a94b3e98d3 Mon Sep 17 00:00:00 2001 From: Greg Schafer Date: Thu, 20 Nov 2003 00:15:47 +0000 Subject: Chapter 6: - Setting up the environment: Reworked the Bash startup files to enforce a clean environment. Closes Bug 714. git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@3115 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689 --- chapter01/changelog.xml | 3 +++ chapter05/chapter05.xml | 38 ++++++++++++++++++++++++++------------ index.xml | 4 ++-- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/chapter01/changelog.xml b/chapter01/changelog.xml index 16462bc06..852fb0b4b 100644 --- a/chapter01/changelog.xml +++ b/chapter01/changelog.xml @@ -35,6 +35,9 @@ +November 19th, 2003 [greg]: Chapter 6: - Setting up the +environment: Reworked the Bash startup files to enforce a clean environment. +Closes Bug 714. November 17th, 2003 [jeremy]: Upgraded Man-Pages to 1.63 diff --git a/chapter05/chapter05.xml b/chapter05/chapter05.xml index 88e71ceb0..6ae7a7d4f 100644 --- a/chapter05/chapter05.xml +++ b/chapter05/chapter05.xml @@ -346,20 +346,36 @@ start a new, clean shell. Setting up the environment -While logged in as user lfs, issue the -following commands to set up a good work environment: +We're going to set up a good working environment by creating two new +startup files for the Bash shell. While logged in as user +lfs, issue the following commands to create a new +.bash_profile: cat > ~/.bash_profile << "EOF" +exec env -i TERM=$TERM /bin/bash +EOF + +The exec env -i TERM=$TERM /bin/bash command +creates a new instance of Bash with a completely empty environment, except for +the TERM variable. This is needed to ensure that no unwanted and potentially +hazardous environment variables from the host system leak into our build +environment. The technique used here is a little non-standard but it achieves +the goal of enforcing a clean environment. By way of explanation, the initial +shell is a login shell which reads the +.bash_profile. The new shell instance is a +non-login shell which reads the +.bashrc (created next). + +Now create a new .bashrc: + +cat > ~/.bashrc << "EOF" set +h umask 022 LFS=/mnt/lfs LC_ALL=POSIX -PATH=/tools/bin:$PATH +PATH=/tools/bin:/bin:/usr/bin export LFS LC_ALL PATH -unset CC CXX CPP LD_LIBRARY_PATH LD_PRELOAD -EOF - -source ~/.bash_profile +EOF The set +h command turns off bash's hash function. Normally hashing is a useful @@ -391,13 +407,11 @@ everything will work as expected in the chroot environment. that, as we move along through this chapter, the tools we build will get used during the rest of the building process. -The CC, CXX, CPP, LD_LIBRARY_PATH and LD_PRELOAD environment variables all -have the potential to cause havoc with our Chapter 5 toolchain. We therefore -unset them to prevent any chance of this happening. - -Now, after sourcing the just-created profile, we're all set to begin +Finally, source the just-created profile so that we're all set to begin building the temporary tools that will support us in later chapters. +source ~/.bash_profile + diff --git a/index.xml b/index.xml index 4a7cba0c0..2e3804ade 100644 --- a/index.xml +++ b/index.xml @@ -3,8 +3,8 @@ "/usr/share/docbook/docbookx.dtd" [ - - + + -- cgit v1.2.3-54-g00ecf