Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sanitize find(1) calls. #48

Merged
merged 2 commits into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/011-Tool_Chain-Kernel_Headers
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ make mrproper
ARCH=${MLFS_ARCH} make headers

# For kernels up to 5.2.x:
# find dest/include \( -name .install -o -name ..install.cmd \) -delete
# find dest/include \( -name .install -o -name ..install.cmd \) -exec rm -rvf {} \;

# For kernels 5.3.x and newer:
find usr/include \( -name .install -o -name ..install.cmd \) -delete
find usr/include \( -name .install -o -name ..install.cmd \) -exec rm -rvf {} \;

# Install
cp -rv usr/include/* /tools/include
Expand Down
52 changes: 26 additions & 26 deletions doc/039-Stripping_and_Ownership
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
# Stripping
# This step is optional, but if the LFS partition
# is rather small, it is beneficial to learn that
# unnecessary items can be removed. The executables
# and libraries built so far contain about 70 MB
# of unneeded debugging symbols.
# Stripping
# This step is optional, but if the LFS partition
# is rather small, it is beneficial to learn that
# unnecessary items can be removed. The executables
# and libraries built so far contain about 70 MB
# of unneeded debugging symbols.

# Remove debug symbols with:
# Remove debug symbols with:
strip --strip-debug /tools/lib/*
/usr/bin/strip --strip-unneeded /tools/{,s}bin/*

# Remove the documentation:
rm -rf /tools/{,share}/{info,man,doc}

# Remove unneeded files:
find /tools/{lib,libexec} -name \*.la -delete
find /tools/{lib,libexec} -name \*.la -exec rm -rvf {} \;

# Changing Ownership
# Currently, the $MLFS/tools directory is owned by
# the user mlfs, a user that exists only on the
# host system. If the $MLFS/tools directory is kept
# as is, the files are owned by a user ID without
# a corresponding account. This is dangerous because
# a user account created later could get this same
# user ID and would own the $MLFS/tools directory
# and all the files therein, thus exposing these
# Changing Ownership
# Currently, the $MLFS/tools directory is owned by
# the user mlfs, a user that exists only on the
# host system. If the $MLFS/tools directory is kept
# as is, the files are owned by a user ID without
# a corresponding account. This is dangerous because
# a user account created later could get this same
# user ID and would own the $MLFS/tools directory
# and all the files therein, thus exposing these
# files to possible malicious manipulation.

# To avoid this issue, you could add the lfs user
# to the new MLFS system later when creating the
# /etc/passwd file, taking care to assign it the
# same user and group IDs as on the host system.
# To avoid this issue, you could add the lfs user
# to the new MLFS system later when creating the
# /etc/passwd file, taking care to assign it the
# same user and group IDs as on the host system.

# ************************************************
# The commands in the remainder of this build must
# be performed while logged in as user root and
# no longer as user mlfs. Also, double check that
# The commands in the remainder of this build must
# be performed while logged in as user root and
# no longer as user mlfs. Also, double check that
# $MLFS is set in root's environment.
# ************************************************

# Change the ownership of the $MLFS/tools directory
# Change the ownership of the $MLFS/tools directory
# to user root by running the following command:
chown -R root:root $MLFS/tools
chown -R root:root $MLFS/tools
12 changes: 6 additions & 6 deletions doc/044-Final_System-Kernel_Headers
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
make mrproper

# Extract headers
# !! The recommended make target “headers_install” cannot
# !! be used, because it requires rsync, which is not
# !! The recommended make target “headers_install” cannot
# !! be used, because it requires rsync, which is not
# !! available in /tools. The headers are first placed in ./usr
#
# For kernels up to 5.2.x:
Expand All @@ -17,14 +17,14 @@ make mrproper
# For kernels 5.3.x and newer:
make headers

# There are also some hidden files used by the kernel
# developers and not needed by MLFS that are removed
# There are also some hidden files used by the kernel
# developers and not needed by MLFS that are removed
# from the intermediate directory.
# Kernels up to 5.2.x:
# find dest/include \( -name .install -o -name ..install.cmd \) -delete
# find dest/include \( -name .install -o -name ..install.cmd \) -exec rm -rvf {} \;

# Kernels 5.3.x and newer:
find usr/include -name '.*' -delete
find usr/include -name '.*' -exec rm -rvf {} \;

# Install Headers
# Kernel up to 5.2.x:
Expand Down
2 changes: 1 addition & 1 deletion doc/128-Final_System-Clean_up
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ rm -fv /usr/lib/lib{com_err,e2p,ext2fs,ss}.a
rm -fv /usr/lib/libltdl.a
rm -fv /usr/lib/libfl.a
rm -fv /usr/lib/libz.a
find /usr/lib /usr/libexec -name \*.la -delete
find /usr/lib /usr/libexec -name \*.la -exec rm -rvf {} \;

# It is also safe to remove /tools and /cross-tools directories as they're not required anymore
34 changes: 34 additions & 0 deletions download_sources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
# Simple shell hack to download and MD5 check source tarballs.
# Copyright 2021: Luiz Antônio (takusuman).
# This particular script is dual-licensed between BSD 2-Clause
# and GPL3, at your preference.
# n() function taken from otto-pkg's posix-alt.shi lib.

# USAGE: ./download_sources.sh sources.list sources.md5sum

MD5CHECK=${MD5CHECK:-YES};

# Workaround to the # macro in arrays
# which doesn't work properly in bash 4.3 for some reason.
n(){
echo ${@} | tr " " "\n" | wc -l;
}

main(){
PARENTDIR=${PWD};
test ! -e src && mkdir src;
urls=( `cat ${1} | tr "\n" " "` );
n_urls=`n ${urls[*]}`;
cd src;
for (( i=0; i < ${n_urls}; i++ )){
printf '%s\n' "Downloading $(basename ${urls[${i}]})";
curl -L ${urls[${i}]} -O;
}
[ ${MD5CHECK} == 'YES' ] &&
md5sum -c ${2};
cd ${PARENTDIR};
return 0;
}

main "${1}" "${2}";