stain / jena-docker

Docker image for Apache Jena riot
Apache License 2.0
99 stars 86 forks source link

docker-entrypoint.sh having ADMIN_PASSWORD with slash #32

Closed infinite-dao closed 3 years ago

infinite-dao commented 4 years ago

Playing around with this docker image I found that it disrupts running through to the end of a working container if the ADMIN_PASSWORD contains a backslash ;-) it then tells something like sed: -e expression #1, char 30: unknown option to 's'. The code to be responsible seems here:

https://github.com/stain/jena-docker/blob/0074865d53f710d85f72af14c103aaef595a2244/jena-fuseki/docker-entrypoint.sh#L37

A way around this is to substitute the \ in ADMIN_PASSWORD as I found here https://stackoverflow.com/questions/27787536/how-to-pass-a-variable-containing-slashes-to-sed/27789993#27788661 … so following this idea, this should do it (untested):

sed -i "s/^admin=.*/admin=${ADMIN_PASSWORD//\//\\/}/" "$FUSEKI_BASE/shiro.ini"
stain commented 4 years ago

Thanks, first time I've seen regex to make regex!

We would presumably also need to escape any / " etc in the ADMIN_PASSWORD? This could get a bit tricky.. Perhaps it's better to delete the line and then echo it in at the right place, as in sed command r

       r filename
              Append text read from filename.