From: dev Date: Tue, 18 Oct 2022 10:59:16 +0000 (+0000) Subject: /etc/profile.d/{which2.sh,which2.sh} 削除 /proc配下を見ている為 X-Git-Url: https://www.chovits.jp/git/?a=commitdiff_plain;h=2fa0d8e40cbc4fd4da50aed27a62510280ed44a3;p=chroot_mk.git /etc/profile.d/{which2.sh,which2.sh} 削除 /proc配下を見ている為 --- diff --git a/chroot.sh b/chroot.sh index e86a4f9..e78674f 100755 --- a/chroot.sh +++ b/chroot.sh @@ -14,7 +14,7 @@ # - このスクリプトでchroot環境を構築後に、スクリプト再実行すると上書きされる # ので、chroot環境のファイルを修正した場合は、注意する事 # -# $Id: chroot.sh,v 1.2 2022/10/18 08:43:47 dev Exp $ +# $Id: chroot.sh,v 1.3 2022/10/18 10:59:16 dev Exp $ # ##################################################################################### @@ -48,6 +48,7 @@ LINKED_DIRS=( /etc/profile.d /usr/share/terminfo ) + LINKED_FILES=( /etc/profile /etc/bashrc @@ -59,8 +60,14 @@ LINKED_FILES=( /usr/libexec/grepconf.sh ) +DELETE_FILES=( + /etc/profile.d/which2.csh + /etc/profile.d/which2.sh +) + # Init -FLG=0 +ALL_CMDLIST=("${CMD_LIST[@]} ${REQUIRED_CMD[@]}") + EXEC_CMD=( /usr/bin/which /usr/bin/install @@ -70,17 +77,18 @@ EXEC_CMD=( /usr/bin/chmod ) +FLG=0 for valf in ${EXEC_CMD[@]} do - if [ ! -x $valf ]; then - echo "File ($valf) not found" - FLG=1 - fi + if [ ! -x $valf ]; then + echo "File ($valf) not found" + FLG=1 + fi done if [ $FLG -eq 1 ]; then - echo "--- Error ---" - exit 1 + echo "--- Error ---" + exit 1 fi # Main @@ -110,7 +118,7 @@ do done # 利用コマンドとライブラリーのコピー -for valp in `which $CMD_LIST`; +for valp in `which $ALL_CMDLIST`; do # command test -e ./$valp && continue @@ -119,11 +127,11 @@ do # library LIBS=`ldd $valp | awk '{ print $3 }'` if [ ${#LIBS[*]} -gt 0 ]; then - for valf in $LIBS; - do - test ! -d `dirname ${CHG_ROOT}$valf` && install -m 0755 -o root -g root -d `dirname ${CHG_ROOT}$valf` - test ! -f ${CHG_ROOT}$valf && cp -p $valf ./$valf - done + for valf in $LIBS; + do + test ! -d `dirname ${CHG_ROOT}$valf` && install -m 0755 -o root -g root -d `dirname ${CHG_ROOT}$valf` + test ! -f ${CHG_ROOT}$valf && cp -p $valf ./$valf + done fi done @@ -140,6 +148,12 @@ test ! -c ${CHG_ROOT}/dev/random && mknod ${CHG_ROOT}/dev/random c 1 8 test ! -c ${CHG_ROOT}/dev/urandom && mknod ${CHG_ROOT}/dev/urandom c 1 9 chmod 0666 ${CHG_ROOT}/dev/{null,zero,random,urandom} +# ディレクトリコピー後の指定ファイルの削除 +for valf in ${DELETE_FILES[@]} +do + test -f ${CHG_ROOT}$valf && rm -f ${CHG_ROOT}$valf +done + # rootユーザー情報の追加 grep /etc/passwd -e "^root" > ${CHG_ROOT}/etc/passwd grep /etc/group -e "^root" > ${CHG_ROOT}/etc/group