[FIXED] Generación de archivo de contraseña para backup

This commit is contained in:
Mauro Rosero P. 2024-12-13 00:29:48 -05:00
parent ff7c68ef5c
commit 77d7355497
Signed by: mrosero
GPG key ID: 83BD2A5F674B7E26
2 changed files with 24 additions and 6 deletions

View file

@ -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)

View file

@ -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