StackExchange / blackbox

Safely store secrets in Git/Mercurial/Subversion

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

blackbox_addadmin leaves the system in unconsistent state if the GPG key does not exists

kwilczek opened this issue · comments

Hi,

when you run blackbox_addadmin, the code firstly add the admin-to-be to the blackbox-admins.txt, then access GPG database and fails if the key does not exists. Steps to reproduce:

mkdir /dev/shm/empty_repo && cd $_
git init
blackbox_initialize
blackbox_addadmin dummy_admin@dummy_domain.com

The code will fail with GPG warning: nothing were exported and GPG key 'dummy_admin@dummy_domain.com' not found .... But the repo is changed:

cat .blackbox/blackbox-admins.txt
dummy_admin@dummy_domain.com

I think that adding a check for the key existence or simply moving the code:

# Add the email address to the BB_ADMINS file. Remove any duplicates.
# The file must exist for sort to act as we expect.
touch "$BB_ADMINS"
sort -fdu -o "$BB_ADMINS" <(echo "$1") "$BB_ADMINS"

below the GPG import part would be enough.

--
K.