diff --git a/bin/gpg_backup.sh b/bin/gpg_backup.sh index 4a90868..af36faa 100755 --- a/bin/gpg_backup.sh +++ b/bin/gpg_backup.sh @@ -82,7 +82,7 @@ fi dialog_yesno "${gpmsg_105}" case ${result} in 0) - gpg_backup "PASSWORD" "$DB_GPG_PATH/$DB_GPG_FILE" "$BIN_HOME/$GPG_CONFIG_PATH" "$DATEBAK" + gpg_backup "$DB_GPG_PATH/$DB_GPG_FILE" "$BIN_HOME/$GPG_CONFIG_PATH" "$DATEBAK" rc=$? case $rc in 0) diff --git a/bin/lib/gpg.lib b/bin/lib/gpg.lib index bf39176..84069b0 100644 --- a/bin/lib/gpg.lib +++ b/bin/lib/gpg.lib @@ -22,6 +22,7 @@ GPG_CONFIG_PATH=bin/config GPG_TEMPLATE=gpg.config GPG_CONFIG=gpg.conf GPG_BACKUP_CFG=gpg.backup +GPGP_BACKUP_SECRET=gpg.secret GPG_SUBKEY_ID="" GPG_REVOKE_FILES="*.rev" @@ -81,13 +82,27 @@ function gpg_setting() { } +# Generate token for backup file +function gpg_backup_token() { + local SECRET_FILE=$1 + + if [[ ! -e $archivo_token ]] + then + local BACKUP_TOKEN=$(uuidgen) + echo "$BACKUP_TOKEN" > "$SECRET_FILE" + chmod 600 "$SECRET_FILE" + fi + + return 0 + +} + # Local backup of gpp keys function gpg_backup() { - local ZPASSWORD=$1 - local DB_BACKUP=$2 - local BIN_CONFIG=$3 - local TIMESTAMP=$4 + local DB_BACKUP=$1 + local BIN_CONFIG=$2 + local TIMESTAMP=$3 local rc=0 # Check if backup configuration file exists @@ -112,7 +127,10 @@ function gpg_backup() { fi fi - # Verificar que la contraseƱa no este en blanco + gpg_backup_token "${LOCAL_BACKUP}/$GPGP_BACKUP_SECRET" + + # Get secret backup + ZPASSWORD=$(cat < "${LOCAL_BACKUP}/$GPGP_BACKUP_SECRET") if [ -z "${ZPASSWORD}" ]; then return 13 fi