Browse Source

new: [rsync-backup-target] prevent duplicate key for different identifier

Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>
0k/dev/master
Valentin Lab 5 years ago
parent
commit
890bd4e595
  1. 12
      rsync-backup-target/hooks/init

12
rsync-backup-target/hooks/init

@ -29,9 +29,14 @@ local_path_key=/etc/rsync/keys
host_path_key="$SERVICE_CONFIGSTORE${local_path_key}"
key_nb=0
volume_keys=()
all_keys=" "
## ident are unique by construction (they are struct keys)
## but keys need to be also unique
declare -A keys
while read-0 ident key; do
if [ "${keys[$key]}" ]; then
err "Duplicate key: key for ident '$ident' is same as ident '${keys["$key"]}'."
exit 1
fi
if ! [[ "$ident" =~ ^[a-zA-Z0-9._-]+$ ]]; then
err "Invalid identifier '$ident'," \
"please use only alphanumerical char, dots, dash or underscores."
@ -39,10 +44,9 @@ while read-0 ident key; do
fi
debug "Creating access key for ${ident}" || true
echo "$key" | file_put "$host_path_key/${ident}.pub"
keys["$key"]="$ident"
done < <(echo "$keys" | shyaml key-values-0)
volume_keys+=("$host_path_key:$local_path_key:ro")
init-config-add "\
$SERVICE_NAME:
volumes:

Loading…
Cancel
Save