lucascbeyeler / zmbackup

A reliable software written in Shell Script to help you in your daily task to backup and restore mails and accounts from Zimbra Open Source Email Platform. Project in deprecation process. Please help me with Waddles.
GNU General Public License v3.0
144 stars 73 forks source link

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

Open krull opened 2 years ago

krull commented 2 years ago
ISSUE TYPE
ENVIRONMENT VERSION
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 commented 2 years ago

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

tofuSCHNITZEL commented 2 years ago

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

milauria commented 3 weeks ago

The version 1.2 still present this issue and these changes resolve the issue. Can somebody release this changes into a new release 1.3 ?

tofuSCHNITZEL commented 3 weeks ago

The version 1.2 still present this issue and these changes resolve the issue. Can somebody release this changes into a new release 1.3 ?

you can just clone and use my fork: https://github.com/tofuSCHNITZEL/zmbackup