diff --git a/mod_for_test_scripts/000recordRootFsSize b/mod_for_test_scripts/000recordRootFsSize index e926695a66..983ee00116 100755 --- a/mod_for_test_scripts/000recordRootFsSize +++ b/mod_for_test_scripts/000recordRootFsSize @@ -10,7 +10,7 @@ # Record the size, but don't overwrite the file as its existence indicates # that this image is not a production image. echo "Recording production image size." -FILE="/root/bytes-rootfs-prod" +FILE="${ROOT_FS_DIR}/root/bytes-rootfs-prod" if [[ ! -f "${FILE}" ]]; then # This will complain it cannot find a valid mtab so keep it quiet. df -B1 / 2>/dev/null | tail -1 | awk '{ print $3 }' > "${FILE}" diff --git a/mod_for_test_scripts/300changePassword b/mod_for_test_scripts/300changePassword index 44f08c3d7e..5e5b6d080d 100755 --- a/mod_for_test_scripts/300changePassword +++ b/mod_for_test_scripts/300changePassword @@ -4,11 +4,11 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -# reset password for root and shared user account. - -LOCAL_ACCOUNT="chronos" -echo "Reset password for root." -passwd root < test_account.passwd 2> /dev/null -echo "Reset password for ${LOCAL_ACCOUNT}." -passwd ${LOCAL_ACCOUNT} < test_account.passwd 2> /dev/null +# reset root password to test0000 (4 zeroes). +TEMP_SHADOWFILE=${ROOT_FS_DIR}/etc/newshadow +CRYPTED_PASSWD="$(echo "test0000" | openssl passwd -1 -stdin)" +echo "root:${CRYPTED_PASSWD}:14500:0:::::" > ${TEMP_SHADOWFILE} +echo "chronos:${CRYPTED_PASSWD}:14500:0:99999::::" > ${TEMP_SHADOWFILE} +sed '/^root/ d;/^chronos/ d' ${ROOT_FS_DIR}/etc/shadow >> ${TEMP_SHADOWFILE} +mv -f ${TEMP_SHADOWFILE} ${ROOT_FS_DIR}/etc/shadow diff --git a/mod_for_test_scripts/350addTestAuthKeys b/mod_for_test_scripts/350addTestAuthKeys index 13e30d122b..cc3967db22 100755 --- a/mod_for_test_scripts/350addTestAuthKeys +++ b/mod_for_test_scripts/350addTestAuthKeys @@ -9,8 +9,8 @@ echo "Copying public keys" -KEYS_DIR=ssh_keys -ROOT_AUTHKEYS=/root/.ssh/authorized_keys - -mkdir -p /root/.ssh +KEYS_DIR=${GCLIENT_ROOT}/src/scripts/mod_for_test_scripts/ssh_keys +mkdir -p ${ROOT_FS_DIR}/root/.ssh +ROOT_AUTHKEYS=${ROOT_FS_DIR}/root/.ssh/authorized_keys cat ${KEYS_DIR}/*.pub >> ${ROOT_AUTHKEYS} + diff --git a/mod_for_test_scripts/700enableAutoxLogin b/mod_for_test_scripts/700enableAutoxLogin index 7a2380ce3e..f4aee61bb8 100755 --- a/mod_for_test_scripts/700enableAutoxLogin +++ b/mod_for_test_scripts/700enableAutoxLogin @@ -6,4 +6,5 @@ # enable autox login by disabling remembering of last username echo "Enabling autologin using autox." -touch "/root/.forget_usernames" \ No newline at end of file +touch "${ROOT_FS_DIR}/root/.forget_usernames" + diff --git a/mod_for_test_scripts/test_account.passwd b/mod_for_test_scripts/test_account.passwd deleted file mode 100644 index 4dc15cfa94..0000000000 --- a/mod_for_test_scripts/test_account.passwd +++ /dev/null @@ -1,3 +0,0 @@ -test0000 -test0000 - diff --git a/mod_for_test_scripts/test_setup.sh b/mod_for_test_scripts/test_setup.sh index a02d72d8e2..93560c6824 100755 --- a/mod_for_test_scripts/test_setup.sh +++ b/mod_for_test_scripts/test_setup.sh @@ -4,9 +4,9 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -cd `dirname $0` -for SCRIPT in [0-9][0-9][0-9]*[!$~] +for SCRIPT in \ + ${GCLIENT_ROOT}/src/scripts/mod_for_test_scripts/[0-9][0-9][0-9]*[!$~] do - ./${SCRIPT} + ${SCRIPT} done diff --git a/mod_image_for_test.sh b/mod_image_for_test.sh index ef783a98d0..fb35572443 100755 --- a/mod_image_for_test.sh +++ b/mod_image_for_test.sh @@ -50,10 +50,6 @@ cleanup_rootfs_mounts() { echo "Killing process that has open file on our rootfs: $cmdline" ! sudo kill $pid # Preceded by ! to disable ERR trap. done - if [[ -d "${ROOT_FS_DIR}/modify_scripts" ]]; then - echo "Cleaned up modify_scripts mount" - ! sudo umount "${ROOT_FS_DIR}/modify_scripts" - fi } cleanup_rootfs_loop() { @@ -100,15 +96,9 @@ else fi MOD_SCRIPTS_ROOT="${GCLIENT_ROOT}/src/scripts/mod_for_test_scripts" -sudo mkdir -p "${ROOT_FS_DIR}/modify_scripts" - -sudo mount --bind "${MOD_SCRIPTS_ROOT}" "${ROOT_FS_DIR}/modify_scripts" - # Run test setup script inside chroot jail to modify the image -sudo chroot "${ROOT_FS_DIR}" "/modify_scripts/test_setup.sh" - -sudo umount "${ROOT_FS_DIR}/modify_scripts" -sudo rmdir "${ROOT_FS_DIR}/modify_scripts" +sudo GCLIENT_ROOT=${GCLIENT_ROOT} ROOT_FS_DIR=${ROOT_FS_DIR} \ + "${MOD_SCRIPTS_ROOT}/test_setup.sh" cleanup trap - EXIT