clamav - adjust max filesize conditionally

Signed-off-by: Simon L. <szaimen@e.mail.de>
This commit is contained in:
Simon L. 2024-07-09 15:01:27 +02:00
parent 3a691aa9a2
commit 66dc0bc7d6
5 changed files with 25 additions and 10 deletions

View file

@ -1,14 +1,13 @@
# syntax=docker/dockerfile:latest # syntax=docker/dockerfile:latest
# Probably from this file: https://github.com/Cisco-Talos/clamav-docker/blob/main/clamav/1.1/alpine/Dockerfile # Probably from this file: https://github.com/Cisco-Talos/clamav-docker/blob/main/clamav/1.3/alpine/Dockerfile
FROM clamav/clamav:1.3.1-59 FROM clamav/clamav:1.3.1-59
COPY clamav.conf /tmp/clamav.conf COPY clamav.conf /clamav.conf
COPY --chmod=775 start.sh /start.sh
RUN set -ex; \ RUN set -ex; \
apk upgrade --no-cache -a; \ apk upgrade --no-cache -a; \
apk add --no-cache tzdata; \ apk add --no-cache tzdata bash; \
cat /tmp/clamav.conf >> /etc/clamav/clamd.conf; \
rm /tmp/clamav.conf; \
mkdir -p /var/run/clamav /run/lock; \ mkdir -p /var/run/clamav /run/lock; \
chown -R clamav:clamav /var/run/clamav /run/clamav /var/log/clamav /var/lock /run/lock; \ chown -R clamav:clamav /var/run/clamav /run/clamav /var/log/clamav /var/lock /run/lock; \
chmod 777 -R /var/run/clamav /run/clamav /var/log/clamav /var/lock /run/lock /tmp chmod 777 -R /var/run/clamav /run/clamav /var/log/clamav /var/lock /run/lock /tmp
@ -18,3 +17,5 @@ VOLUME /var/lib/clamav
USER clamav USER clamav
LABEL com.centurylinklabs.watchtower.enable="false" LABEL com.centurylinklabs.watchtower.enable="false"
ENTRYPOINT ["/start.sh"]

View file

@ -1,4 +1,5 @@
# AIO settings
MaxDirectoryRecursion 30 MaxDirectoryRecursion 30
MaxFileSize 100M MaxFileSize 10G
PCREMaxFileSize 100M PCREMaxFileSize 10G
StreamMaxLength 100M StreamMaxLength 10G

View file

@ -0,0 +1,11 @@
#!/bin/bash
# Adjust settings
cat /etc/clamav/clamd.conf > /tmp/clamd.conf
CLAMAV_FILE="$(sed "s|10G|$MAX_SIZE|" /clamav.conf)"
echo "$CLAMAV_FILE" >> /tmp/clamd.conf
# Call initial init
exec /init --config-file="/tmp/clamd.conf"
exec "$@"

View file

@ -733,8 +733,8 @@ if [ "$CLAMAV_ENABLED" = 'yes' ]; then
php /var/www/html/occ config:app:set files_antivirus av_mode --value="daemon" php /var/www/html/occ config:app:set files_antivirus av_mode --value="daemon"
php /var/www/html/occ config:app:set files_antivirus av_port --value="3310" php /var/www/html/occ config:app:set files_antivirus av_port --value="3310"
php /var/www/html/occ config:app:set files_antivirus av_host --value="$CLAMAV_HOST" php /var/www/html/occ config:app:set files_antivirus av_host --value="$CLAMAV_HOST"
php /var/www/html/occ config:app:set files_antivirus av_stream_max_length --value="104857600" php /var/www/html/occ config:app:set files_antivirus av_stream_max_length --value="$CLAMAV_MAX_SIZE"
php /var/www/html/occ config:app:set files_antivirus av_max_file_size --value="104857600" php /var/www/html/occ config:app:set files_antivirus av_max_file_size --value="$CLAMAV_MAX_SIZE"
php /var/www/html/occ config:app:set files_antivirus av_infected_action --value="only_log" php /var/www/html/occ config:app:set files_antivirus av_infected_action --value="only_log"
fi fi
else else

View file

@ -204,6 +204,7 @@
"TALK_PORT=%TALK_PORT%", "TALK_PORT=%TALK_PORT%",
"IMAGINARY_ENABLED=%IMAGINARY_ENABLED%", "IMAGINARY_ENABLED=%IMAGINARY_ENABLED%",
"IMAGINARY_HOST=nextcloud-aio-imaginary", "IMAGINARY_HOST=nextcloud-aio-imaginary",
"CLAMAV_MAX_SIZE=%APACHE_MAX_SIZE%",
"PHP_UPLOAD_LIMIT=%NEXTCLOUD_UPLOAD_LIMIT%", "PHP_UPLOAD_LIMIT=%NEXTCLOUD_UPLOAD_LIMIT%",
"PHP_MEMORY_LIMIT=%NEXTCLOUD_MEMORY_LIMIT%", "PHP_MEMORY_LIMIT=%NEXTCLOUD_MEMORY_LIMIT%",
"FULLTEXTSEARCH_ENABLED=%FULLTEXTSEARCH_ENABLED%", "FULLTEXTSEARCH_ENABLED=%FULLTEXTSEARCH_ENABLED%",
@ -575,6 +576,7 @@
"internal_port": "3310", "internal_port": "3310",
"environment": [ "environment": [
"TZ=%TIMEZONE%", "TZ=%TIMEZONE%",
"MAX_SIZE=%NEXTCLOUD_UPLOAD_LIMIT%",
"CLAMD_STARTUP_TIMEOUT=90" "CLAMD_STARTUP_TIMEOUT=90"
], ],
"volumes": [ "volumes": [