pash: Use a heredoc instead of printf
This commit is contained in:
parent
7b3be8069c
commit
638a011f2a
13
pash
13
pash
|
@ -39,8 +39,17 @@ pw_add() {
|
|||
fi
|
||||
|
||||
# Use 'gpg' to store the password in an encrypted file.
|
||||
printf %s "$pass" | "$gpg" "$@" -o "$name.gpg" &&
|
||||
printf '%s\n' "Saved '$name' to the store."
|
||||
# A heredoc is used here instead of a 'printf' to avoid
|
||||
# leaking the password through the '/proc' filesystem.
|
||||
#
|
||||
# Heredocs are sometimes implemented via temporary files,
|
||||
# however this is typically done using 'mkstemp()' which
|
||||
# is more secure than '/proc'.
|
||||
"$gpg" "$@" -o "$name.gpg" <<-EOF
|
||||
$pass
|
||||
EOF
|
||||
|
||||
[ $# = 0 ] && printf '%s\n' "Saved '$name' to the store."
|
||||
}
|
||||
|
||||
pw_del() {
|
||||
|
|
Loading…
Reference in New Issue