From 77d7355497d074c57eb9f63fb113ea158eb91be9 Mon Sep 17 00:00:00 2001 From: Mauro Rosero P Date: Fri, 13 Dec 2024 00:29:48 -0500 Subject: [PATCH] =?UTF-8?q?[FIXED]=20Generaci=C3=B3n=20de=20archivo=20de?= =?UTF-8?q?=20contrase=C3=B1a=20para=20backup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/gpg_backup.sh | 2 +- bin/lib/gpg.lib | 28 +++++++++++++++++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) 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