Skip to content

Commit

Permalink
Fix IPv6 address support in OUTPUT_URL/BACKUP_URL
Browse files Browse the repository at this point in the history
Currently there is no proper support for IPv6 addresses in
OUTPUT_URL/BACKUP_URL properties:
- OUTPUT_URL=nfs://2001:db8:ca2:6::101/root/REAR is not recognized (and
  should not be)
- OUTPUT_URL=nfs://[2001:db8:ca2:6::101]/root/REAR fails because of bash
  substitutions occurring in various places
- OUTPUT_URL="nfs://\[2001:db8:ca2:6::101\]/root/REAR" works but is somehow
  cumbersome (double quotes + square brackets quoting).

This patch makes the following (proper) scheme work with both NFS and SSHFS:
OUTPUT_URL=nfs://[2001:db8:ca2:6::101]/root/REAR
OUTPUT_URL=sshfs://[2001:db8:ca2:6::101]/root/REAR

For this to occur, a lot of bash quoting had to be fixed.

Signed-off-by: Renaud Métrich <[email protected]>
  • Loading branch information
rmetrich committed Jun 10, 2024
1 parent 24680de commit a543e9d
Show file tree
Hide file tree
Showing 48 changed files with 228 additions and 228 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ if [ -z "$BLOCKCLONE_SAVE_MBR_DEV" ]; then
return
fi

local backup_path=$( url_path $BACKUP_URL )
local opath=$(backup_path $scheme $path)
local backup_path=$( url_path "$BACKUP_URL" )
local opath=$( backup_path "$scheme" "$path" )

LogPrint "Copying $VAR_DIR/layout/$BLOCKCLONE_PARTITIONS_CONF_FILE to $opath"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ if [ -n "$BACKUP_DUPLICITY_NETFS_URL" -o -n "$BACKUP_DUPLICITY_NETFS_UMOUNTCMD"
BACKUP_DUPLICITY_NETFS_URL="var://BACKUP_DUPLICITY_NETFS_UMOUNTCMD"
fi

umount_url $BACKUP_DUPLICITY_NETFS_URL $BUILD_DIR/outputfs
umount_url "$BACKUP_DUPLICITY_NETFS_URL" $BUILD_DIR/outputfs
fi
6 changes: 3 additions & 3 deletions usr/share/rear/backup/NETFS/GNU/Linux/600_start_selinux.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Start SELinux if it was stopped - check presence of $TMP_DIR/selinux.mode
[[ -f $TMP_DIR/selinux.mode ]] && {
local scheme=$(url_scheme $BACKUP_URL)
local path=$(url_path $BACKUP_URL)
local opath=$(backup_path $scheme $path)
local scheme="$( url_scheme "$BACKUP_URL" )"
local path="$( url_path "$BACKUP_URL" )"
local opath="$( backup_path "$scheme" "$path" )"
cat $TMP_DIR/selinux.mode > $SELINUX_ENFORCE
Log "Restored original SELinux mode"
touch "${opath}/selinux.autorelabel"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ if [[ "$BACKUP_MOUNTCMD" ]] ; then
BACKUP_URL="var://BACKUP_MOUNTCMD"
fi

mount_url $BACKUP_URL $BUILD_DIR/outputfs $BACKUP_OPTIONS
mount_url "$BACKUP_URL" $BUILD_DIR/outputfs $BACKUP_OPTIONS
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
[ -z "${NETFS_KEEP_OLD_BACKUP_COPY}" ] && return

# do not do this for tapes and special attention for file:///path
local scheme=$( url_scheme $BACKUP_URL )
local path=$( url_path $BACKUP_URL )
local opath=$( backup_path $scheme $path )
local scheme="$( url_scheme "$BACKUP_URL" )"
local path="$( url_path "$BACKUP_URL" )"
local opath="$( backup_path "$scheme" "$path" )"

# if $opath is empty return silently (e.g. scheme tape)
[ -z "$opath" ] && return 0
Expand Down
6 changes: 3 additions & 3 deletions usr/share/rear/backup/NETFS/default/200_make_prefix_dir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# to $HOSTNAME

# do not do this for tapes and special attention for file:///path
local scheme=$( url_scheme $BACKUP_URL )
local path=$( url_path $BACKUP_URL )
local opath=$( backup_path $scheme $path )
local scheme="$( url_scheme "$BACKUP_URL" )"
local path="$( url_path "$BACKUP_URL" )"
local opath="$( backup_path "$scheme" "$path" )"

# if $opath is empty return silently (e.g. scheme tape)
[ -z "$opath" ] && return 0
Expand Down
6 changes: 3 additions & 3 deletions usr/share/rear/backup/NETFS/default/250_create_lock.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# made by a previous mkbackup run when the variable NETFS_KEEP_OLD_BACKUP_COPY has been set

# do not do this for tapes and special attention for file:///path
local scheme=$( url_scheme $BACKUP_URL )
local path=$( url_path $BACKUP_URL )
local opath=$( backup_path $scheme $path )
local scheme="$( url_scheme "$BACKUP_URL" )"
local path="$( url_path "$BACKUP_URL" )"
local opath="$( backup_path "$scheme" "$path" )"

# if $opath is empty return silently (e.g. scheme tape)
[ -z "$opath" ] && return 0
Expand Down
18 changes: 9 additions & 9 deletions usr/share/rear/backup/NETFS/default/500_make_backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function set_tar_features () {
# Test for features in tar
# true if at supports the --warning option (v1.23+)
FEATURE_TAR_WARNINGS=
local tar_version=$( get_version tar --version )
local tar_version="$( get_version tar --version )"
if version_newer "$tar_version" 1.23 ; then
FEATURE_TAR_WARNINGS="y"
TAR_OPTIONS+=" --warning=no-xdev"
Expand All @@ -18,9 +18,9 @@ function set_tar_features () {

local backup_prog_rc

local scheme=$( url_scheme $BACKUP_URL )
local path=$( url_path $BACKUP_URL )
local opath=$( backup_path $scheme $path )
local scheme="$( url_scheme "$BACKUP_URL" )"
local path="$( url_path "$BACKUP_URL" )"
local opath="$( backup_path "$scheme" "$path" )"
test "$opath" && mkdir $v -p "$opath"

# In any case show an initial basic info what is currently done
Expand Down Expand Up @@ -222,12 +222,12 @@ case "$(basename ${BACKUP_PROG})" in
Log "Using unsupported backup program '$BACKUP_PROG'"
Log $BACKUP_PROG "${BACKUP_PROG_COMPRESS_OPTIONS[@]}" \
$BACKUP_PROG_OPTIONS_CREATE_ARCHIVE $TMP_DIR/backup-exclude.txt \
"${BACKUP_PROG_OPTIONS[@]}" $backuparchive \
$(cat $TMP_DIR/backup-include.txt) $RUNTIME_LOGFILE > $backuparchive
"${BACKUP_PROG_OPTIONS[@]}" "$backuparchive" \
$(cat $TMP_DIR/backup-include.txt) $RUNTIME_LOGFILE > "$backuparchive"
$BACKUP_PROG "${BACKUP_PROG_COMPRESS_OPTIONS[@]}" \
$BACKUP_PROG_OPTIONS_CREATE_ARCHIVE $TMP_DIR/backup-exclude.txt \
"${BACKUP_PROG_OPTIONS[@]}" $backuparchive \
$(cat $TMP_DIR/backup-include.txt) $RUNTIME_LOGFILE > $backuparchive
"${BACKUP_PROG_OPTIONS[@]}" "$backuparchive" \
$(cat $TMP_DIR/backup-include.txt) $RUNTIME_LOGFILE > "$backuparchive"
;;
esac 2> "${TMP_DIR}/${BACKUP_PROG_ARCHIVE}.log"
# For the rsync and default case the backup prog is the last in the case entry
Expand Down Expand Up @@ -292,7 +292,7 @@ wait $BackupPID
backup_prog_rc=$?

if [[ $BACKUP_INTEGRITY_CHECK =~ ^[yY1] && "$(basename ${BACKUP_PROG})" = "tar" ]] ; then
(cd $(dirname $backuparchive) && md5sum $(basename $backuparchive) > ${backuparchive}.md5 || md5sum $(basename $backuparchive).?? > ${backuparchive}.md5)
(cd $(dirname "$backuparchive") && md5sum $(basename "$backuparchive") > "${backuparchive}".md5 || md5sum $(basename "$backuparchive").?? > "${backuparchive}".md5)
fi

# TODO: Why do we sleep here after 'wait $BackupPID'?
Expand Down
6 changes: 3 additions & 3 deletions usr/share/rear/backup/NETFS/default/970_remove_lock.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# remove the lockfile
local scheme=$( url_scheme $BACKUP_URL )
local path=$( url_path $BACKUP_URL )
local opath=$( backup_path $scheme $path )
local scheme="$( url_scheme "$BACKUP_URL" )"
local path="$( url_path "$BACKUP_URL" )"
local opath="$( backup_path "$scheme" "$path" )"

# if $opath is empty return silently (e.g. scheme tape)
[ -z "$opath" ] && return 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ if [[ "$BACKUP_UMOUNTCMD" ]] ; then
BACKUP_URL="var://BACKUP_UMOUNTCMD"
fi

umount_url $BACKUP_URL $BUILD_DIR/outputfs
umount_url "$BACKUP_URL" $BUILD_DIR/outputfs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ local backup_prog_rc
;;

(*)
local scheme=$(url_scheme $BACKUP_URL)
local path=$(url_path $BACKUP_URL)
local opath=$(backup_path $scheme $path)
local scheme="$(url_scheme "$BACKUP_URL")"
local path="$(url_path "$BACKUP_URL")"
local opath="$(backup_path "$scheme" "$path")"
# probably using the BACKUP=NETFS workflow instead
if [ -d "${opath}" ]; then
if [ ! -f "${opath}/selinux.autorelabel" ]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ is_true "$ZVM_NAMING" || return 0
VM_UID=( $( vmcp q userid ) )
test $VM_UID || Error "Could not set VM_UID ('vmcp q userid' did not return the VM user id)"

scheme=$( url_scheme $OUTPUT_URL )
path=$( url_path $OUTPUT_URL )
opath=$( output_path $scheme $path )
scheme="$( url_scheme "$OUTPUT_URL" )"
path="$( url_path "$OUTPUT_URL" )"
opath="$( output_path "$scheme" "$path" )"
test $opath || Error "Could not determine output path from OUTPUT_URL='$OUTPUT_URL'"

LogPrint "s390 disklayout.conf will be saved as $opath/$VM_UID.disklayout.conf"
mkdir $v -p $opath
mkdir $v -p "$opath"
cp $v $DISKLAYOUT_FILE $opath/$VM_UID.disklayout.conf || Error "Failed to copy '$DISKLAYOUT_FILE' to $opath/$VM_UID.disklayout.conf"
10 changes: 5 additions & 5 deletions usr/share/rear/layout/save/default/310_autoexclude_usb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

for URL in "$OUTPUT_URL" "$BACKUP_URL" ; do
if [[ ! -z "$URL" ]] ; then
local host=$(url_host $URL)
local scheme=$(url_scheme $URL)
local path=$(url_path $URL)
local host="$(url_host "$URL")"
local scheme="$(url_scheme "$URL")"
local path="$(url_path "$URL")"

case $scheme in
(usb)
Expand All @@ -35,9 +35,9 @@ for URL in "$OUTPUT_URL" "$BACKUP_URL" ; do

grep -q "^$REAL_USB_DEVICE " /proc/mounts
if [[ $? -eq 0 ]] ; then
local usb_mntpt=$( grep "^$REAL_USB_DEVICE " /proc/mounts | cut -d" " -f2 | tail -1 )
local usb_mntpt="$( grep "^$REAL_USB_DEVICE " /proc/mounts | cut -d" " -f2 | tail -1 )"
if ! IsInArray "$usb_mntpt" "${AUTOEXCLUDE_USB_PATH[@]}" ; then
AUTOEXCLUDE_USB_PATH+=( $usb_mntpt )
AUTOEXCLUDE_USB_PATH+=( "$usb_mntpt" )
Log "Auto-excluding USB path $usb_mntpt [device $REAL_USB_DEVICE]"
fi
fi
Expand Down
Loading

0 comments on commit a543e9d

Please sign in to comment.