zmbackup icon indicating copy to clipboard operation
zmbackup copied to clipboard

Bash For loop in ListAction.sh breaks -d domain full backup of zmbackup with domains that have the letter 's' on them

Open krull opened this issue 4 years ago • 4 comments

ISSUE TYPE
  • Bug Report
ENVIRONMENT VERSION
  • Zmbackup Version: 1.2.6
  • Zimbra Version: 8.8.15_GA_3945.FOSS
  • Linux Distribution & Version: Ubuntu 18.04.4 LTS
SUMMARY
build_listBKP()
line: /usr/local/lib/zmbackup/bash/ListAction.sh:25

build_listRST()
line: /usr/local/lib/zmbackup/bash/ListAction.sh:64

Bash For loop in ListAction.sh breaks -d domain full backup of zmbackup with domains that have the letter 's' on them

STEPS TO REPRODUCE
zmbackup -f -d thesdomain.tld

with #!/bin/bash -x, the result above will have an output:

+ for i in ${4/\s/\n/g}
+ DC=,dc=
+ DOMAIN=dc=then/gdomain,dc=tld
+ ERR='++ ldapsearch -Z -x -H ldap://127.0.0.1:389 -D uid=zimbra,cn=admins,cn=zimbra -w XXXXXXXX -b dc=then/gdomain,dc=tld -LLL '\''(objectclass=zimbraAccount)'\'' zimbraMailDeliveryAddress
No such object (32)
Matched DN: dc=tld'
+ BASHERRCODE=32

ACTUAL RESULTS
tail -f /var/log/syslog

Oct  8 07:55:03 zmb-mbox00 zimbra[31431]: Zmbackup: LDAP - Can't extract accounts from LDAP - Error below:
Oct  8 07:55:03 zmb-mbox00 zimbra[31432]: Zmbackup: No such object (32)#012Matched DN: dc=tld

krull avatar Oct 08 '21 08:10 krull

Hello,

This bug report was reproduced with the following; I have several domains that include the letter 's' and ones without.

The ones without successfully backup, however the ones with 's' did not.

I remedied the issue by changing the following in ListAction.sh file:

for i in ${4//\n/g}; do

Not certain if it will break other logics on your script, but it passed correctly the domain with 's' to the ldapsearch command.

hope this helps.

-krull

krull avatar Oct 08 '21 08:10 krull

it also breaks if there is an "n" in the email adress because it gets substituted with g. "\s" and "\n" does not not work with bash substitution. you can check out the proper fix here: https://github.com/tofuSCHNITZEL/zmbackup/commit/d5028344feb83342d73e5977dfc138c404a913cc

tofuSCHNITZEL avatar Aug 30 '22 15:08 tofuSCHNITZEL