From e4482079f52a6fc6d3e6172b1c1a6b6889d8dc31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Gon=C3=A7alves?= Date: Wed, 14 Jun 2023 11:55:48 +0200 Subject: feat(vault): scope gopass per user session --- vault.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vault.sh b/vault.sh index bac110e..6bf443a 100755 --- a/vault.sh +++ b/vault.sh @@ -5,4 +5,12 @@ set -ex password_bin=$(command -v pass || command -v gopass) password_name="${2:-infrastructure/ansible/root}" -"${password_bin}" show "${password_name}" | head -n 1 +set +x + +if [ "$(logname)" != "$(whoami)" ]; then + password_string="$(su "$(logname)" -c "${password_bin} show ${password_name}")" +else + password_string="$("${password_bin}" show "${password_name}")" +fi + +echo "${password_string}" | head -n 1 -- cgit v1.2.3