juanluisbaptiste / docker-otrs

The unofficial Znuny/OTRS Ticketing System docker image
https://www.juanbaptiste.tech/category/otrs
GNU Lesser General Public License v3.0
175 stars 104 forks source link

quoting of env-variables in /.backup.env is stripped, unexpected behaviour #126

Closed rdxmb closed 1 year ago

rdxmb commented 1 year ago

Reporting a bug

The container-env-variables written to /.backup.env are not quoted, and so they have unexpected values.

Image and OTRS versions

juanluisbaptiste/otrs:6.0.37

Describe the issue

When sourcing the /.backup.env like it is done in the backup-cronjob, the values of the variables are set without spaces and - in case of variables with * (cron-statement), expanded.

Expected behavior

Variables are quoted.

Reproduce

set a container-env-variable like

OTRS_BACKUP_TIME: "20 20 * * *"   #  --- quoted

start the container and checkout

# grep TIME /.backup.env
export OTRS_BACKUP_TIME=20 20 * *     #    --- not quoted
# . /.backup.env
bash: export: `20': not a valid identifier
bash: export: `anaconda-ks.cfg': not a valid identifier
bash: export: `otrs_backup.sh': not a valid identifier
bash: export: `anaconda-ks.cfg': not a valid identifier
bash: export: `otrs_backup.sh': not a valid identifier
bash: export: `anaconda-ks.cfg': not a valid identifier
bash: export: `otrs_backup.sh': not a valid identifier
echo $OTRS_BACKUP_TIME
20

Link to code

https://github.com/juanluisbaptiste/docker-otrs/blob/master/otrs/functions.sh#L592

Edited: fix the quotes to show the problem

juanluisbaptiste commented 1 year ago

Hi @rdxmb

Variable values with strings with more than one word, like a cron expression, must be quoted to be evaluated as a single value, this is a bash restriction.

rdxmb commented 1 year ago

Hi @juanluisbaptiste ,

yes of course.

Oh! I have just seen that I forgot the quoting in the description :see_no_evil:

I have just changed that and commented so you should see the problem now.

Regards!

rdxmb commented 1 year ago

Another demonstration:

$ export OTRS_BACKUP_TIME='20 20 * * *'
$ printenv | sed 's/^\(.*\)$/export \1/g' | grep -E "^export OTRS_" | tee /tmp/.backup.env
export OTRS_BACKUP_TIME=20 20 * * *

When sourcing this .backup.env , the * are expanded, of course.

$ source /tmp/.backup.env
bash: export: `20': not a valid identifier
bash: export: `backup.env': not a valid identifier
bash: export: `exthost-0721e8.cpuprofile': not a valid identifier
bash: export: `exthost-098f2e.cpuprofile': not a valid identifier
bash: export: `exthost-0f7391.cpuprofile': not a valid identifier
#  --------- snip

@juanluisbaptiste could this be reopened, please?