extremeshok/clamav-unofficial-sigs

testing if file is readable with -r fails

eilandert opened this issue · 5 comments

Hello

I found something strange.

You are testing if a configfile is readable

if [ -r "${config_dir}/master.conf" ] ; then
config_files+=( "${config_dir}/master.conf" )
else
xshok_pretty_echo_and_log "ERROR: ${config_dir}/master.conf is not readable"
exit 1
fi

but for some reason that doesn't work in alpine linux

bash-5.1# touch bla
bash-5.1# chmod 777 bla
bash-5.1# if [ -r "bla" ] ; then echo "ok"; else echo "not ok"; fi
not ok

Any idea what's going on?

same for -w

bash-5.1# if [ -w "bla" ] ; then echo "ok"; else echo "not ok"; fi
not ok

ulab commented

Does alpine linux have /usr/bin/[?
Can you run just [ -r "bla" ] && echo "OK"?

Does alpine linux have /usr/bin/[?
Can you run just [ -r "bla" ] && echo "OK"?

Seems to be busybox
/usr/bin/[ -> /bin/busybox

bash-5.1# touch bla
bash-5.1# [ -r "bla" ] && echo "OK"
bash-5.1# [ -f "bla" ] && echo "OK"
OK

Other flags seem to work, except -w and -r

If I do this, and render the -w and -r checks invalid, the script works as intended
sed -i s/"if [ -r "/"if [ -f "/g /usr/local/sbin/clamav-unofficial-sigs.sh
sed -i s/"if [ ! -w "/"if [ -z "/g /usr/local/sbin/clamav-unofficial-sigs.sh

ulab commented

I am guessing /usr/bin/test is a link to busybox too?
Perhaps -r is just no t compiled into the test commands? On first glance they should though. Perhaps you can install a "proper" test program?

I have no idea how to install a proper test program with Alpine. I choose it because of its low footprint for my docker.
For now I'll go with the sed-solution, might convert the whole docker with ubuntu or debian-slim where I am sure things will work ;-)

It seems it's not an issue with clamav-unofficial-sigs, so it's probably better to close this issue.

Thanks for your time