From b5597e4e74999886a532e71251be9571b0f748a8 Mon Sep 17 00:00:00 2001 From: Paul Kocialkowski Date: Sun, 25 Dec 2016 16:46:56 +0100 Subject: cros-scripts: cros-boot-keys: Confirm overriding keys when generating Signed-off-by: Paul Kocialkowski --- projects/cros-scripts/install/cros-boot-keys | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'projects') diff --git a/projects/cros-scripts/install/cros-boot-keys b/projects/cros-scripts/install/cros-boot-keys index eed01c56..07ec2cb9 100755 --- a/projects/cros-scripts/install/cros-boot-keys +++ b/projects/cros-scripts/install/cros-boot-keys @@ -43,6 +43,38 @@ usage() { printf " VBOOT_TOOLS_PATH - Path to vboot tools\n" >&2 } +keys_override_confirm() { + local override=0 + local confirm + + for key in $KEYS + do + if [ -f "$VBOOT_KEYS_PATH/$key.$VBPUBK" ] || [ -f "$VBOOT_KEYS_PATH/$key.$VBPRIVK" ] + then + override=1 + fi + done + + for keyblock in $KEYBLOCKS + do + if [ -f "$VBOOT_KEYS_PATH/$keyblock.$KEYBLOCK" ] + then + override=1 + fi + done + + if [ $override -ne 1 ] + then + return 0 + fi + + printf "This is going to override keys stored in the following directory:\n" + printf " $VBOOT_KEYS_PATH\n" + printf "Press enter to confirm: " + + read confirm +} + generate() { local algorithms=$ALGORITHMS local subkeys=$SUBKEYS @@ -53,6 +85,8 @@ generate() { local privkey local mode + keys_override_confirm + for key in $KEYS do algorithm=$( echo "$algorithms" | sed "s/$REGEXP/\1/g" ) -- cgit v1.2.3-70-g09d2