[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}" dialog_yesno "${gpmsg_105}"
case ${result} in case ${result} in
0) 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=$? rc=$?
case $rc in case $rc in
0) 0)

View file

@ -22,6 +22,7 @@ GPG_CONFIG_PATH=bin/config
GPG_TEMPLATE=gpg.config GPG_TEMPLATE=gpg.config
GPG_CONFIG=gpg.conf GPG_CONFIG=gpg.conf
GPG_BACKUP_CFG=gpg.backup GPG_BACKUP_CFG=gpg.backup
GPGP_BACKUP_SECRET=gpg.secret
GPG_SUBKEY_ID="" GPG_SUBKEY_ID=""
GPG_REVOKE_FILES="*.rev" 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 # Local backup of gpp keys
function gpg_backup() { function gpg_backup() {
local ZPASSWORD=$1 local DB_BACKUP=$1
local DB_BACKUP=$2 local BIN_CONFIG=$2
local BIN_CONFIG=$3 local TIMESTAMP=$3
local TIMESTAMP=$4
local rc=0 local rc=0
# Check if backup configuration file exists # Check if backup configuration file exists
@ -112,7 +127,10 @@ function gpg_backup() {
fi fi
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 if [ -z "${ZPASSWORD}" ]; then
return 13 return 13
fi fi