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

Side by Side Diff: scripts/image_signing/set_chronos_password.sh

Issue 5722004: Be less verbose while changing the password. Add a script for checking if password already exists. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git@master
Patch Set: review fixes Created 10 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « scripts/image_signing/ensure_no_password.sh ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/bash 1 #!/bin/bash
2 2
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 # Customizes a Chrome OS release image by setting the chronos user password. 7 # Customizes a Chrome OS release image by setting the chronos user password.
8 8
9 # Usage: ./set_chronos_password.sh <image.bin> <chronos_password> [--force] 9 # Usage: ./set_chronos_password.sh <image.bin> <chronos_password> [--force]
10 10
11 # Load common constants and variables. 11 # Load common constants and variables.
12 . "$(dirname "$0")/common.sh" 12 . "$(dirname "$0")/common.sh"
13 13
14 change_chronos_password() { 14 change_chronos_password() {
15 local rootfs=$1 15 local rootfs=$1
16 local password=$2 16 local password=$2
17 echo "Changing chronos password to '$password'..." 17 echo "Setting chronos password..."
18 local crypted_password="$(echo $password | openssl passwd -1 -stdin)" 18 local crypted_password="$(echo $password | openssl passwd -1 -stdin)"
19 local temp_shadow="$rootfs/etc/tempshadow" 19 local temp_shadow="$rootfs/etc/tempshadow"
20 echo "chronos:$crypted_password:14500:0:99999::::" \ 20 echo "chronos:$crypted_password:14500:0:99999::::" \
21 | sudo tee "$temp_shadow" > /dev/null 21 | sudo tee "$temp_shadow" > /dev/null
22 sudo grep -Ev ^chronos: "$rootfs/etc/shadow" \ 22 sudo grep -Ev ^chronos: "$rootfs/etc/shadow" \
23 | sudo tee -a "$temp_shadow" > /dev/null 23 | sudo tee -a "$temp_shadow" > /dev/null
24 sudo mv -f "$temp_shadow" "$rootfs/etc/shadow" 24 sudo mv -f "$temp_shadow" "$rootfs/etc/shadow"
25 } 25 }
26 26
27 main() { 27 main() {
(...skipping 12 matching lines...) Expand all
40 if ! no_chronos_password "$rootfs"; then 40 if ! no_chronos_password "$rootfs"; then
41 echo "Password is already set [use --force if you'd like to update it]" 41 echo "Password is already set [use --force if you'd like to update it]"
42 exit 1 42 exit 1
43 fi 43 fi
44 # Prepare for remounting read/write. 44 # Prepare for remounting read/write.
45 sudo umount -d $rootfs 45 sudo umount -d $rootfs
46 fi 46 fi
47 mount_image_partition "$image" 3 "$rootfs" 47 mount_image_partition "$image" 3 "$rootfs"
48 change_chronos_password "$rootfs" "$chronos_password" 48 change_chronos_password "$rootfs" "$chronos_password"
49 touch "$image" # Updates the image modification time. 49 touch "$image" # Updates the image modification time.
50 echo "Password Changed." 50 echo "Password Set."
51 } 51 }
52 52
53 main $@ 53 main $@
OLDNEW
« no previous file with comments | « scripts/image_signing/ensure_no_password.sh ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698