[clamav-users] Question on GUI notifications of virus detection

Bryan Everly bryan at bceassociates.com
Tue Jun 20 15:43:00 UTC 2017


On Mon, 2017-06-19 at 20:44 +0200, Michael D. wrote:
> 
Hi Bryan,
> 
> The problem isn't with ClamAV, it's the difference in sessions between a 
> daemon and a user.
> 
> A user that is logged in, is in a shell with lot's of environment 
> variables set, whereas a daemon is running in a bare-minimum environment.
> 
> You probably need to set the variable DBUS_SESSION_BUS_ADDRESS in your 
> script as described here:
> 
> https://askubuntu.com/questions/298608/notify-send-doesnt-work-from-crontab
> 
> Best regards
>    Michael
> _______________________________________________
> clamav-users mailing list
> clamav-users at lists.clamav.net
> http://lists.clamav.net/cgi-bin/mailman/listinfo/clamav-users
> 
> 
> Help us build a comprehensive ClamAV guide:
> https://github.com/vrtadmin/clamav-faq
> 
> http://www.clamav.net/contact.html#ml


Michael,

Thanks for your help.  I ended up with the following for my script. 
Thought I would put it in this thread in case some future person was
searching for a solution to this as well:

#!/usr/bin/bash

USER=your_user_name

eval "export $(egrep -z DBUS_SESSION_BUS_ADDRESS /proc/$(pgrep -u $USER
gnome-session)/environ)";

su $USER -c '/usr/bin/notify-send -u critical "Virus Found
$CLAM_VIRUSEVENT_VIRUSNAME" "$CLAM_VIRUSEVENT_FILENAME has been
removed"'
echo "$(date) - $CLAM_VIRUSEVENT_VIRUSNAME > $CLAM_VIRUSEVENT_FILENAME"
>> /var/log/clamav/infected.log
rm $CLAM_VIRUSEVENT_FILENAME


More information about the clamav-users mailing list