Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Unified Diff: scripts/image_signing/set_chronos_password.sh

Issue 4480001: Refuse to change the chronos password if already set unless explicitly asked. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git@master
Patch Set: review fixes Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « scripts/image_signing/common.sh ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/image_signing/set_chronos_password.sh
diff --git a/scripts/image_signing/set_chronos_password.sh b/scripts/image_signing/set_chronos_password.sh
index ff71e45867bf29f39bac66b1d2fcaf25b9b9f6af..1319dbf5ba9eb55b10417fdb7b6ea8612707724e 100755
--- a/scripts/image_signing/set_chronos_password.sh
+++ b/scripts/image_signing/set_chronos_password.sh
@@ -6,7 +6,7 @@
# Customizes a Chrome OS release image by setting the chronos user password.
-# Usage: ./set_chronos_password.sh <image.bin> <chronos_password>
+# Usage: ./set_chronos_password.sh <image.bin> <chronos_password> [--force]
# Load common constants and variables.
. "$(dirname "$0")/common.sh"
@@ -29,17 +29,25 @@ main() {
local image=$1
local chronos_password=$2
- if [ $# -ne 2 ]; then
- echo "Usage: $PROG <image.bin> <chronos_password>"
+ if [ $# -ne 2 ] && [ $# -ne 3 ] || [ ! $3 = "--force" ] ; then
+ echo "Usage: $PROG <image.bin> <chronos_password> [--force]"
exit 1
fi
- local rootfs=$(mktemp -d)
+ local rootfs=$(make_temp_dir)
+ if [ $# -eq 2 ]; then
+ mount_image_partition_ro "$image" 3 "$rootfs"
+ if ! no_chronos_password "$rootfs"; then
+ echo "Password is already set [use --force if you'd like to update it]"
+ exit 1
+ fi
+ # Prepare for remounting read/write.
+ sudo umount -d $rootfs
+ fi
mount_image_partition "$image" 3 "$rootfs"
- trap "sudo umount -d $rootfs; rm -rf $rootfs" EXIT
change_chronos_password "$rootfs" "$chronos_password"
touch "$image" # Updates the image modification time.
- echo "Done."
+ echo "Password Changed."
}
main $@
« no previous file with comments | « scripts/image_signing/common.sh ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698