Clear master password after use
This commit is contained in:
parent
4f752ec349
commit
daafbef7a1
|
@ -277,18 +277,6 @@ if [ ! -d /home/$CURR_USERNAME ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
if [[ "$CURR_USERNAME" == "root" ]]; then
|
||||
if [ ! -d /root/.passwords/root ]; then
|
||||
mkdir -p /root/.passwords/root
|
||||
fi
|
||||
if [ ! -f /root/.passwords/root/master ]; then
|
||||
MASTER_PASSWORD=$(openssl rand -base64 32 | cut -c1-30)
|
||||
echo "$MASTER_PASSWORD" > /root/.passwords/root/master
|
||||
chmod 700 /root/.passwords/root/master
|
||||
fi
|
||||
MASTER_PASSWORD=$(cat /root/.passwords/root/master)
|
||||
fi
|
||||
|
||||
if [ ${REMOVE_APP} ]; then
|
||||
if [ -d ~/.passwords/${CURR_USERNAME}/${REMOVE_APP} ]; then
|
||||
shred -zu ~/.passwords/${CURR_USERNAME}/${REMOVE_APP}
|
||||
|
@ -301,9 +289,21 @@ if [ ! $CURR_APP ]; then
|
|||
exit 3
|
||||
fi
|
||||
|
||||
if [[ "$CURR_USERNAME" == "root" ]]; then
|
||||
if [ ! -d /root/.passwords/root ]; then
|
||||
mkdir -p /root/.passwords/root
|
||||
fi
|
||||
if [ ! -f /root/.passwords/root/master ]; then
|
||||
echo "$(openssl rand -base64 32 | cut -c1-30)" > /root/.passwords/root/master
|
||||
chmod 700 /root/.passwords/root/master
|
||||
fi
|
||||
MASTER_PASSWORD=$(cat /root/.passwords/root/master)
|
||||
fi
|
||||
|
||||
if [ ${#CURR_PASSWORD} -eq 0 ]; then
|
||||
# retrieve password
|
||||
if [ ! -f ~/.passwords/$CURR_USERNAME/$CURR_APP ]; then
|
||||
MASTER_PASSWORD=
|
||||
echo ""
|
||||
exit 4
|
||||
else
|
||||
|
@ -314,6 +314,7 @@ else
|
|||
# store password
|
||||
if [ -f $NO_PASSWORD_STORE_FILE ]; then
|
||||
if [[ "$CURR_USERNAME" != 'root' ]]; then
|
||||
MASTER_PASSWORD=
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
@ -323,8 +324,10 @@ else
|
|||
# padding helps to ensure than nothing can be learned from the length of the cyphertext
|
||||
pad_string "${CURR_PASSWORD}" | gpg -ca --cipher-algo AES256 --passphrase "$MASTER_PASSWORD" > ~/.passwords/$CURR_USERNAME/$CURR_APP
|
||||
if [ ! -f ~/.passwords/$CURR_USERNAME/$CURR_APP ]; then
|
||||
MASTER_PASSWORD=
|
||||
exit 5
|
||||
fi
|
||||
fi
|
||||
|
||||
MASTER_PASSWORD=
|
||||
exit 0
|
||||
|
|
Loading…
Reference in New Issue