mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-07 13:06:59 +02:00
Added password arg to set_shared_user_password.sh
BUG=none TEST=Ran script, from within chroot, with no args(prompts for password), one password arg, and multiple args(prints usage and exits), and each time echo'd the password before it is encrypted. Each time it is correct. From outside chroot, it only prints an error and exits. Change-Id: I9380511e8784e4979e664281c751fe6e6defe7ab Reviewed-on: https://gerrit.chromium.org/gerrit/25397 Tested-by: Isaac Simha <isimha@nvidia.com> Reviewed-by: Brian Harring <ferringb@chromium.org> Commit-Ready: Isaac Simha <isimha@nvidia.com>
This commit is contained in:
parent
194af5ed99
commit
21c6b03e89
@ -1,22 +1,35 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
|
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
|
||||||
# Use of this source code is governed by a BSD-style license that can be
|
# Use of this source code is governed by a BSD-style license that can be
|
||||||
# found in the LICENSE file.
|
# found in the LICENSE file.
|
||||||
|
|
||||||
# Script to set the password for the shared user account. Stores the MD5crypt'd
|
# Script to set the password for the shared user account. Stores the MD5crypt'd
|
||||||
# password to a file inside chroot, for use by build_image.
|
# password to a file inside chroot, for use by build_image.
|
||||||
|
|
||||||
# This can only run inside the chroot.
|
# Make sure common.sh is here.
|
||||||
. "$(dirname "$0")/common.sh" || exit 1
|
SCRIPT_ROOT=$(dirname $(readlink -f "$0"))
|
||||||
|
. "${SCRIPT_ROOT}/common.sh" || { echo "Unable to load common.sh"; exit 1; }
|
||||||
|
|
||||||
|
assert_inside_chroot
|
||||||
|
|
||||||
# Die on any errors.
|
# Die on any errors.
|
||||||
switch_to_strict_mode
|
switch_to_strict_mode
|
||||||
|
|
||||||
SHARED_USER_PASSWD_FILE="/etc/shared_user_passwd.txt"
|
SHARED_USER_PASSWD_FILE="/etc/shared_user_passwd.txt"
|
||||||
|
|
||||||
# Get password
|
# If optional password argument is supplied, set password to that.
|
||||||
read -p "Enter password for shared user account: " PASSWORD
|
if [[ $# > 1 ]]; then
|
||||||
|
echo "Too many arguments."
|
||||||
|
echo "usage: $0 [password]"
|
||||||
|
exit 1
|
||||||
|
elif [[ $# == 1 ]]; then
|
||||||
|
PASSWORD=$1
|
||||||
|
exec "$0" < <(echo "$PASSWORD")
|
||||||
|
else
|
||||||
|
# Get password
|
||||||
|
read -s -p "Enter password for shared user account: " PASSWORD
|
||||||
|
fi
|
||||||
|
|
||||||
CRYPTED_PASSWD="$(echo "$PASSWORD" | openssl passwd -1 -stdin)"
|
CRYPTED_PASSWD="$(echo "$PASSWORD" | openssl passwd -1 -stdin)"
|
||||||
PASSWORD="gone now"
|
PASSWORD="gone now"
|
||||||
|
Loading…
Reference in New Issue
Block a user