#1008773 ftpsync: Using commands with parameters as hooks breaks ftpsync on bullseye/debian 11

Package:
ftpsync
Source:
archvsync
Submitter:
Raphaël Hertzog
Date:
2023-09-23 17:21:04 UTC
Severity:
important
Tags:
#1008773#5
Date:
2022-04-01 07:40:16 UTC
From:
To:
In Kali we have started to switch some mirrors to Debian 11 and ftpsync
started to fail with errors like this:

Apr 01 06:19:32 poseidon ftpsync-kali[191329]: Mirrorsync start
Apr 01 06:19:32 poseidon ftpsync-kali[191329]: We got pushed from 192.99.45.140
/home/archvsync/bin/ftpsync: line 276: local: `--regex=^.*\.hook1$': not a valid identifier
/home/archvsync/bin/ftpsync: line 276: local: `--arg=kali': not a valid identifier
/home/archvsync/bin/ftpsync: line 276: local: `/home/archvsync/hooks': not a valid identifier
Apr 01 06:19:32 poseidon ftpsync-kali[191329]: Mirrorsync done with errors

Our ftpsync.conf contains entries like this:

## Configure hooks
HOOK1="run-parts --regex=^.*\\.hook1\$ --arg=kali /home/archvsync/hooks"
HOOK2="run-parts --regex=^.*\\.hook2\$ --arg=kali /home/archvsync/hooks"
HOOK3="run-parts --regex=^.*\\.hook3\$ --arg=kali /home/archvsync/hooks"
HOOK4="run-parts --regex=^.*\\.hook4\$ --arg=kali /home/archvsync/hooks"
HOOK5="run-parts --regex=^.*\\.hook5\$ --arg=kali /home/archvsync/hooks"

From a quick glance, it looks like the bash version in bullseye doesn't
like some construct. Here's a minimal reproducer:

$ cat ~/tmp/test.sh
#!/bin/bash

set -e
set -u
set -E

hook () {
    ARGS='HOOK[@]'
    local "${!ARGS}"
    echo "HOOKSCR='$HOOKSCR'"
}

HOOK1="run-parts --regex=^.*\\.hook1\$ --arg=kali /home/archvsync/hooks"

HOOK=(
    HOOKNR=1
    HOOKSCR=${HOOK1}
)
hook $HOOK

In buster it works fine:
$ bash ~/tmp/test.sh
HOOKSCR='run-parts --regex=^.*\.hook1$ --arg=kali /home/archvsync/hooks'
$ echo $?
0

In bullseye it fails:
$ bash ~/tmp/test.sh
/home/rhertzog/tmp/test.sh: line 9: local: `--regex=^.*\.hook1$': not a valid identifier
/home/rhertzog/tmp/test.sh: line 9: local: `--arg=kali': not a valid identifier
/home/rhertzog/tmp/test.sh: line 9: local: `/home/archvsync/hooks': not a valid identifier
$ echo $?
1

It seems that you can quote the variable assignation for HOOKSCR and it
works again:
HOOK=(
    HOOKNR=1
    HOOKSCR="${HOOK1}"
)

$ bash ~/tmp/test.sh
HOOKSCR='run-parts --regex=^.*\.hook1$ --arg=kali /home/archvsync/hooks'

#1008773#12
Date:
2022-04-01 08:03:26 UTC
From:
To:
Control: tags -1 + patch

I have prepared a merge request with a fix for this issue:
https://salsa.debian.org/mirror-team/archvsync/-/merge_requests/4

(Note that there's another outstanding merge request there that you might
want to merge too)

I'm attaching the patch as well.

#1008773#19
Date:
2023-09-23 16:34:37 UTC
From:
To:
That MR was merged some time ago, so I'm going to close this bug now.

Thanks for your contribution.

Regards,

Adam