From ab463c0844b89e2b7968e1f5857cec1cb4885334 Mon Sep 17 00:00:00 2001 From: Darin Petkov Date: Thu, 17 Feb 2011 10:42:24 -0800 Subject: [PATCH] Move crypted passwd file to /etc in build_image. This temporary hack is intended to provide to developers a smooth transition to the new crypted password file location. BUG=chromium-os:11664 TEST=build_image Change-Id: I34383f6e08ee8db53e407b30df604c403c72b5eb Review URL: http://codereview.chromium.org/6539019 --- build_image | 4 ++++ set_shared_user_password.sh | 20 ++++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/build_image b/build_image index c6fdac0e2b..271ef62b71 100755 --- a/build_image +++ b/build_image @@ -139,6 +139,10 @@ check_blacklist() { check_blacklist +# TODO(petkov): Remove along with the --move_to_etc flag support once the +# transition dust settles. +"${SCRIPTS_DIR}"/set_shared_user_password.sh --move_to_etc + # Verify user didn't specify incompatible flags for dev install shim if [ "${FLAGS_factory_install}" -eq "${FLAGS_TRUE}" ] && [ "${FLAGS_dev_install}" -eq "${FLAGS_TRUE}" ] ; then diff --git a/set_shared_user_password.sh b/set_shared_user_password.sh index 72d0ab0688..1ec80b5aa9 100755 --- a/set_shared_user_password.sh +++ b/set_shared_user_password.sh @@ -33,6 +33,11 @@ restart_in_chroot_if_needed "$@" FLAGS_HELP="USAGE: $0 [flags]" +# TODO(petkov): This flag and setting of src/scripts/shared_user_passwd.txt can +# go away once the transition dust settles. +DEFINE_boolean move_to_etc ${FLAGS_FALSE} \ + "Move src/scripts/shared_user_passwd.txt to /etc." + # Parse command line FLAGS "$@" || exit 1 eval set -- "${FLAGS_ARGV}" @@ -40,16 +45,23 @@ eval set -- "${FLAGS_ARGV}" # Die on any errors. set -e +CRYPTED_PASSWD_FILE="${SCRIPTS_DIR}/shared_user_passwd.txt" +SHARED_USER_PASSWD_FILE="/etc/shared_user_passwd.txt" + +if [ ${FLAGS_move_to_etc} -eq ${FLAGS_TRUE} ]; then + if [ -r "${CRYPTED_PASSWD_FILE}" ]; then + cat "${CRYPTED_PASSWD_FILE}" | sudo_clobber "${SHARED_USER_PASSWD_FILE}" + echo "Copied ${CRYPTED_PASSWD_FILE} to ${SHARED_USER_PASSWD_FILE}." + fi + exit 0 +fi + # Get password read -p "Enter password for shared user account: " PASSWORD CRYPTED_PASSWD="$(echo "$PASSWORD" | openssl passwd -1 -stdin)" PASSWORD="gone now" -CRYPTED_PASSWD_FILE="${SCRIPTS_DIR}/shared_user_passwd.txt" echo "${CRYPTED_PASSWD}" > "${CRYPTED_PASSWD_FILE}" - -SHARED_USER_PASSWD_FILE="/etc/shared_user_passwd.txt" echo "${CRYPTED_PASSWD}" | sudo_clobber "${SHARED_USER_PASSWD_FILE}" - echo "Password set in ${CRYPTED_PASSWD_FILE} and ${SHARED_USER_PASSWD_FILE}"