diff --git a/board/common/rootfs/usr/bin/askpass b/board/common/rootfs/usr/bin/askpass index c2896e88..7c47f1d2 100755 --- a/board/common/rootfs/usr/bin/askpass +++ b/board/common/rootfs/usr/bin/askpass @@ -1,23 +1,49 @@ #!/bin/sh +# Prompt for a secret with confirmation, then encode and output it. +# +# Default mode: hash with mkpasswd (for system passwords) +# askpass [OUTPUT] +# +# Base64 mode (-b): base64-encode (for keystore passphrases) +# askpass -b [OUTPUT] +# +# If OUTPUT is given, result is written to the file. +# If omitted, result is written to stdout. # shellcheck disable=SC3045 +LABEL="New password" +MODE=hash +if [ "$1" = "-b" ]; then + LABEL="Passphrase" + MODE=base64 + shift +fi OUTPUT=$1 -read -r -s -p "New password: " password +read -r -s -p "$LABEL: " secret >&2 echo -read -r -s -p "Retype password: " password_again +read -r -s -p "Retype $LABEL: " secret_again >&2 echo -if [ "$password" != "$password_again" ]; then - echo "Passwords do not match, try again." +if [ "$secret" != "$secret_again" ]; then + echo "${LABEL}s do not match, try again." exit 1 fi -if [ -z "$OUTPUT" ]; then - echo "$password" - exit 0 +if [ -z "$secret" ]; then + echo "Empty $LABEL, try again." + exit 1 +fi + +if [ "$MODE" = "base64" ]; then + encoded=$(printf '%s' "$secret" | base64 -w 0) +else + encoded=$(printf '%s\n' "$secret" | mkpasswd -s) fi umask 0177 -echo "$password" | mkpasswd -s > "$OUTPUT" -exit 0 +if [ -z "$OUTPUT" ]; then + echo "$encoded" +else + printf '%s' "$encoded" > "$OUTPUT" +fi diff --git a/package/klish-plugin-sysrepo/klish-plugin-sysrepo.hash b/package/klish-plugin-sysrepo/klish-plugin-sysrepo.hash index c38d7e9c..c652e519 100644 --- a/package/klish-plugin-sysrepo/klish-plugin-sysrepo.hash +++ b/package/klish-plugin-sysrepo/klish-plugin-sysrepo.hash @@ -1,3 +1,3 @@ # Locally calculated sha256 9d9d33b873917ca5d0bdcc47a36d2fd385971ab0c045d1472fcadf95ee5bcf5b LICENCE -sha256 6e098390be2a78a56cf94eecb9d28b11c1791dd2c364e59602bbd664b508fd57 klish-plugin-sysrepo-a4b1fae697b51614dc75989e8f4fc8d277689d16-git4.tar.gz +sha256 7bfdaef838ee8bd3995140c40144abe79ff1c6391c7b48445e6728cd4e7e56a8 klish-plugin-sysrepo-2f14503c7ea6eb24c8adaf0cf2cf7a511114b09e-git4.tar.gz diff --git a/package/klish-plugin-sysrepo/klish-plugin-sysrepo.mk b/package/klish-plugin-sysrepo/klish-plugin-sysrepo.mk index 0c6b1daa..488407ff 100644 --- a/package/klish-plugin-sysrepo/klish-plugin-sysrepo.mk +++ b/package/klish-plugin-sysrepo/klish-plugin-sysrepo.mk @@ -4,7 +4,7 @@ # ################################################################################ -KLISH_PLUGIN_SYSREPO_VERSION = a4b1fae697b51614dc75989e8f4fc8d277689d16 +KLISH_PLUGIN_SYSREPO_VERSION = 2f14503c7ea6eb24c8adaf0cf2cf7a511114b09e KLISH_PLUGIN_SYSREPO_SITE = https://github.com/kernelkit/klish-plugin-sysrepo.git #KLISH_PLUGIN_SYSREPO_VERSION = cdd3eb51a7f7ee0ed5bd925fa636061d3b1b85fb #KLISH_PLUGIN_SYSREPO_SITE = https://src.libcode.org/pkun/klish-plugin-sysrepo.git