Mailing List Archive

[clamav-users] On Access Scanning Configuration
*Hello all,*



*I’m trying to setup OnAccessScanning on my VM but I’m running in a lot of
problems.*

*Every time I do “sudo clamonacc” I get next:*

*ERROR: ClamClient: Could not connect to clamd, Couldn't connect to server*

*ERROR: Clamonacc: daemon is local, but a connection could not be
established*



*I saw in one of conversations it is needed to provide this so i’ll do that
forhand.*

clamconf -n

Checking configuration files in /etc/clamav



Config file: clamd.conf

-----------------------

LogFile = "/tmp/clamav.log"

LogFileUnlock = "yes"

LogFileMaxSize = "5242880"

LogSyslog = "yes"

LogVerbose = "yes"

LogRotate = "yes"

ExtendedDetectionInfo = "yes"

PidFile = "/var/run/clam.pid"

LocalSocket = "/tmp/clamd.socket"

TCPSocket = "3310"

TCPAddr = "127.0.0.1"

VirusEvent = "/usr/bin/mailx -s "ClamAV VIRUS ALERT: %v" alert < /dev/null"

OnAccessMountPath = "/", "/home/user"

OnAccessIncludePath = "/home", "/students"

OnAccessExcludeUname = "clamuser"

OnAccessPrevention = "yes"

OnAccessExtraScanning = "yes"



Config file: freshclam.conf

---------------------------

DatabaseMirror = "database.clamav.net"



Config file: clamav-milter.conf

-------------------------------

ERROR: Please edit the example config file /etc/clamav/clamav-milter.conf



Software settings

-----------------

Version: 0.103.6

Optional features supported: MEMPOOL IPv6 FRESHCLAM_DNS_FIX AUTOIT_EA06
BZIP2 LIBXML2 PCRE ICONV JSON JIT



Database information

--------------------

Database directory: /var/lib/clamav

daily.cvd: version 26721, sigs: 2010985, built on Tue Nov 15 00:54:13 2022

main.cvd: version 62, sigs: 6647427, built on Thu Sep 16 05:32:42 2021

bytecode.cvd: version 333, sigs: 92, built on Mon Mar 8 07:21:51 2021

Total number of signatures: 8658504



Platform information

--------------------

uname: Linux 5.4.0-132-generic #148~18.04.1-Ubuntu SMP Mon Oct 24 20:41:14
UTC 2022 x86_64

OS: linux-gnu, ARCH: x86_64, CPU: x86_64

Full OS version: Ubuntu 18.04.6 LTS

zlib version: 1.2.11 (1.2.11), compile flags: a9

Triple: x86_64-pc-linux-gnu

CPU: haswell, Little-endian

platform id: 0x0a217f7f0807050001070500



Build information

-----------------

GNU C: 7.5.0 (7.5.0)

GNU C++: 7.5.0 (7.5.0)

CPPFLAGS: -Wdate-time -D_FORTIFY_SOURCE=2

CFLAGS: -g -O2
-fdebug-prefix-map=/build/clamav-6gS6Mc/clamav-0.103.6+dfsg=.
-fstack-protector-strong -Wformat -Werror=format-security -Wall
-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
-D_FILE_OFFSET_BITS=64

CXXFLAGS: -g -O2
-fdebug-prefix-map=/build/clamav-6gS6Mc/clamav-0.103.6+dfsg=.
-fstack-protector-strong -Wformat -Werror=format-security -Wall
-D_FILE_OFFSET_BITS=64

LDFLAGS: -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed

Configure: '--build=x86_64-linux-gnu' '--prefix=/usr'
'--includedir=/usr/include' '--mandir=/usr/share/man'
'--infodir=/usr/share/info' '--sysconfdir=/etc' '--localstatedir=/var'
'--disable-silent-rules' '--libdir=/usr/lib/x86_64-linux-gnu'
'--libexecdir=/usr/lib/x86_64-linux-gnu' '--runstatedir=/run'
'--disable-maintainer-mode' '--disable-dependency-tracking' 'CFLAGS=-g -O2
-fdebug-prefix-map=/build/clamav-6gS6Mc/clamav-0.103.6+dfsg=.
-fstack-protector-strong -Wformat -Werror=format-security -Wall
-D_FILE_OFFSET_BITS=64' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2'
'CXXFLAGS=-g -O2
-fdebug-prefix-map=/build/clamav-6gS6Mc/clamav-0.103.6+dfsg=.
-fstack-protector-strong -Wformat -Werror=format-security -Wall
-D_FILE_OFFSET_BITS=64' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro
-Wl,-z,now -Wl,--as-needed' '--with-dbdir=/var/lib/clamav'
'--sysconfdir=/etc/clamav' '--disable-clamav' '--disable-unrar'
'--enable-milter' '--enable-dns-fix' '--with-libjson'
'--with-system-libmspack' '--with-libcurl=/usr' '--with-gnu-ld'
'-with-system-llvm=/usr/bin/llvm-config-3.9' '--with-llvm-linking=dynamic'
'--with-systemdsystemunitdir=/lib/systemd/system'
'build_alias=x86_64-linux-gnu' 'OBJCFLAGS=-g -O2
-fdebug-prefix-map=/build/clamav-6gS6Mc/clamav-0.103.6+dfsg=.
-fstack-protector-strong -Wformat -Werror=format-security'

sizeof(void*) = 8

Engine flevel: 127, dconf: 127



*Also I have written script to install clamav maybe there is problem, here
is it:*

#sudo apt-get uptade -y

#sudo apt-get upgrade -y



#sudo apt-get install clamav clamav-daemon -y



clamconf -g freshclam.conf > freshclam.conf

clamconf -g clamd.conf > clamd.conf

clamconf -g clamav-milter.conf > clamav-milter.conf



sudo mv freshclam.conf /etc/clamav

sudo mv clamd.conf /etc/clamav

sudo mv clamav-milter.conf /etc/clamav



cd /etc/clamav



sudo grep -i "Example" clamd.conf |sudo sed -i 's/Example/#Example/g'
clamd.conf

sudo grep -i "#LogFile" clamd.conf |sudo sed -i 's/#LogFile/LogFile/g'
clamd.conf

sudo grep -i "#TCPSocket" clamd.conf |sudo sed -i
's/#TCPSocket/TCPSocket/g' clamd.conf

sudo grep -i "#TCPAddr" clamd.conf |sudo sed -i 's/#TCPAddr/TCPAddr/g'
clamd.conf

sudo grep -i "#OnAccessPrevention" clamd.conf |sudo sed -i
's/#OnAccessPrevention/OnAccessPrevention/g' clamd.conf

sudo grep -i "#OnAccessExcludeUname" clamd.conf |sudo sed -i
's/#OnAccessExcludeUname/OnAccessExcludeUname/g' clamd.conf

sudo grep -i "#OnAccessExtraScanning" clamd.conf |sudo sed -i
's/#OnAccessExtraScanning/OnAccessExtraScanning/g' clamd.conf

sudo grep -i "#OnAccessDisableDDD" clamd.conf |sudo sed -i
's/#OnAccessDisableDDD/OnAccessDisableDDD/g' clamd.conf

sudo grep -i "#OnAccessIncludePath" clamd.conf |sudo sed -i
's/#OnAccessIncludePath/OnAccessIncludePath/g' clamd.conf



sudo grep -i "Example" freshclam.conf |sudo sed -i 's/Example/#Example/g'
freshclam.conf

sudo grep -i "#DatabaseMirror" freshclam.conf |sudo sed -i
's/#DatabaseMirror/DatabaseMirror/g' freshclam.conf



sudo freshclam

sudo clamonacc



Thanks in advanced,

Nikola
Re: [clamav-users] On Access Scanning Configuration [ In reply to ]
Hi there,

On Wed, 16 Nov 2022, Nikola Nikoli? via clamav-users wrote:

> *I’m trying to setup OnAccessScanning on my VM but I’m running in a lot of
> problems.*
>
> *Every time I do “sudo clamonacc” I get next:*
>
> *ERROR: ClamClient: Could not connect to clamd, Couldn't connect to server*
>
> *ERROR: Clamonacc: daemon is local, but a connection could not be
> established*

Before we deep-dive into your configuration and scripting, can you
confirm that the clamd daemon is actually running?

--

73,
Ged.
_______________________________________________

Manage your clamav-users mailing list subscription / unsubscribe:
https://lists.clamav.net/mailman/listinfo/clamav-users


Help us build a comprehensive ClamAV guide:
https://github.com/Cisco-Talos/clamav-documentation

https://docs.clamav.net/#mailing-lists-and-chat
Re: [clamav-users] On Access Scanning Configuration [ In reply to ]
How can i provide that informatio, if you can lead me with instructions.

sre, 16. nov 2022. 10:09 G.W. Haywood via clamav-users <
clamav-users@lists.clamav.net> ?? ???????/??:

> Hi there,
>
> On Wed, 16 Nov 2022, Nikola Nikoli? via clamav-users wrote:
>
> > *I’m trying to setup OnAccessScanning on my VM but I’m running in a lot
> of
> > problems.*
> >
> > *Every time I do “sudo clamonacc” I get next:*
> >
> > *ERROR: ClamClient: Could not connect to clamd, Couldn't connect to
> server*
> >
> > *ERROR: Clamonacc: daemon is local, but a connection could not be
> > established*
>
> Before we deep-dive into your configuration and scripting, can you
> confirm that the clamd daemon is actually running?
>
> --
>
> 73,
> Ged.
> _______________________________________________
>
> Manage your clamav-users mailing list subscription / unsubscribe:
> https://lists.clamav.net/mailman/listinfo/clamav-users
>
>
> Help us build a comprehensive ClamAV guide:
> https://github.com/Cisco-Talos/clamav-documentation
>
> https://docs.clamav.net/#mailing-lists-and-chat
>
Re: [clamav-users] On Access Scanning Configuration [ In reply to ]
systemctl status clamav-daemon
? clamav-daemon.service - Clam AntiVirus userspace daemon
Loaded: loaded (/lib/systemd/system/clamav-daemon.service; enabled;
vendor p
Drop-In: /etc/systemd/system/clamav-daemon.service.d
??extend.conf
Active: failed (Result: exit-code) since Wed 2022-11-16 02:25:33 PST;
34s ag
Docs: man:clamd(8)
man:clamd.conf(5)
https://docs.clamav.net/
Main PID: 2266 (code=exited, status=2)

Nov 16 02:25:33 ubuntu systemd[1]: Starting Clam AntiVirus userspace
daemon...
Nov 16 02:25:33 ubuntu systemd[1]: Started Clam AntiVirus userspace daemon.
Nov 16 02:25:33 ubuntu clamd[2266]: ERROR: Can't save PID to file
/var/run/clam
Nov 16 02:25:33 ubuntu systemd[1]: clamav-daemon.service: Main process
exited,
Nov 16 02:25:33 ubuntu systemd[1]: clamav-daemon.service: Failed with
result 'e

On Wed, Nov 16, 2022 at 10:09 AM G.W. Haywood via clamav-users <
clamav-users@lists.clamav.net> wrote:

> Hi there,
>
> On Wed, 16 Nov 2022, Nikola Nikoli? via clamav-users wrote:
>
> > *I’m trying to setup OnAccessScanning on my VM but I’m running in a lot
> of
> > problems.*
> >
> > *Every time I do “sudo clamonacc” I get next:*
> >
> > *ERROR: ClamClient: Could not connect to clamd, Couldn't connect to
> server*
> >
> > *ERROR: Clamonacc: daemon is local, but a connection could not be
> > established*
>
> Before we deep-dive into your configuration and scripting, can you
> confirm that the clamd daemon is actually running?
>
> --
>
> 73,
> Ged.
> _______________________________________________
>
> Manage your clamav-users mailing list subscription / unsubscribe:
> https://lists.clamav.net/mailman/listinfo/clamav-users
>
>
> Help us build a comprehensive ClamAV guide:
> https://github.com/Cisco-Talos/clamav-documentation
>
> https://docs.clamav.net/#mailing-lists-and-chat
>
Re: [clamav-users] On Access Scanning Configuration [ In reply to ]
Hi there,

On Wed, 16 Nov 2022, Nikola Nikoli? via clamav-users wrote:
> sre, 16. nov 2022. G.W. Haywood via clamav-users ?? ???????/??:
>> On Wed, 16 Nov 2022, Nikola Nikoli? via clamav-users wrote:
>>
>>> I’m trying to setup OnAccessScanning on my VM but I’m running in a
>>> lot of problems.
>>>
>>> Every time I do “sudo clamonacc” I get next:
>>>
>>> ERROR: ClamClient: Could not connect to clamd, Couldn't connect to server
>>> ERROR: Clamonacc: daemon is local, but a connection could not be established
>>
>> Before we deep-dive into your configuration and scripting, can you
>> confirm that the clamd daemon is actually running?
>
> How can i provide that informatio, if you can lead me with instructions.

You'll probably need to do some more reading. Quite a lot, I'm afraid.
There are very many ways to do what I asked. Below are three. It's a
cut-n-paste from a 'bash' shell session on my clamd server. In case
your mail reader has done something helpful with it, there are three
commands (on the lines which begin with a '$' symbol), and six lines
of command output making nine lines in total between the ASCII art
'cut' marks. The output from the second and third commands is shown
in nice neat columns:

8<----------------------------------------------------------------------
$ pidof clamd
745
$ ps aux | grep clam
clamav 723 0.0 0.1 63316 6844 ? Ss Nov04 0:44 /usr/local/bin/freshclam -d --config-file=/etc/mail/clamav/freshclam.conf
clamav 745 0.2 32.9 1636312 1293948 ? Dsl Nov04 35:54 /usr/local/sbin/clamd --config-file=/etc/mail/clamav/clamd_tcp3.conf
root 1265 0.0 0.0 7344 552 pts/2 S+ 11:38 0:00 grep clam
$ top -b -n 1 | grep clam
723 clamav 20 0 63316 6844 6112 S 0.0 0.2 0:44.72 freshclam
745 clamav 20 0 1636312 1.2g 5720 S 0.0 32.9 35:53.17 clamd
8<----------------------------------------------------------------------

You can see that the clamd process ID on this machine is 745 and the
process is using 1.2Gbytes of memory. That's probably a bit more than
most clamd daemons will be using (the official signatures will use in
the region of a gigabyte, but I use many unofficial signatures). The
same memory consumption is also reasonable for any 'clamscan' process,
but you probably won't want to run both clamd and clamscan at the same
time. There's a tool called 'clamdscan' which does most of the work
that clamscan does. Instead of doing the scan itself it uses clamd to
do the bulk of the work. For a system running a single clamd daemon,
you should budget at least four gigabytes of memory. You can get away
with less, but to do that safely you'll need to be a lot more familiar
with your systems than you are at the moment.

Just to be clear, when the 'clamonacc' tool decides that something
needs to be scanned, it uses the 'clamd' daemon to do the actual
scanning. The clamd daemon takes a while to start because it has to
read, check and compile something approaching ten million signatures,
and then it runs indefinitely on the system just waiting for another
process to connect to it to tell it what to do. Because the clamd
process is already running, the process which tells it what to do
doesn't have to wait a long time for clamd to start up. That would
impose an unacceptable preformance penalty. Again just to be clear,
I'm not saying that the performance penalty that you will pay in any
case with "scan on access" will be acceptable to you. Only you can
know that, in the light of your experiences when you try it.

The output from the commands I showed above is terse, but there's a
lot of information in the output and you'll become familiar will it
all eventually. With some practice, quite soon you'll absorb it at a
glance; what takes minutes (even hours) now will soon sometimes take
only seconds.

There's online documentation for ClamAV at

https://docs.clamav.net/

but that requires Internet access of course. On most Linux systems
you can learn a lot, quickly, just by using the 'man' command. The
name is short for 'manual' and what you get when for example you type

man top

is the "man page" for the 'top' command. The 'grep' command is one
you'll want to learn about early in your linux career:

man grep

Apart obviously from getting the tools and documentation onto your
machine in the first place, after installation all use of the 'man'
command is entirely local to your machine and no Internet access is
needed to read the documentation. There are 'man' pages for all the
ClamAV tools. Although they're a work in progress and the odd error
or omission still surfaces, generally they're pretty good. If you
don't have the 'man' command or the "man pages" you should be able to
install them easily using the package management tools which come with
whatever distribution of Linux you have. It would help if you could
tell us things like that. Usually the 'man' pages come with the
package of tools when you install the tools, but occasionally (perhaps
when the documentation is very substantial) there's a separate package
just for the docs.

Most people find 'man' a little terse when they first start to use it,
and so it is. But generally speaking, if you're reasonably proficient
with the rest of the system, for any tool it should contain pretty
much all you need to know to use the tool effectively. Unfortunately
with a Linux system becoming "reasonably proficient" if starting from
scratch will take anywhere between months and years, depending on the
effort you put into it.

Can I suggest that you spend some quality time with a Linux primer?
I don't know how up-to-date the TLDP is nowadays but many things are
unlikely to change:

https://tldp.org/LDP/sag/html/system-monitoring.html

There are many, many tutorial sites around the Internet. Most leave a
lot to be desired but equally most will get you going with the basics.
This isn't the right list for this kind of thing, you should look for
alternatives for general system administration, but if you keep the
questions specific to ClamAV we'll usually be able to help. My own
preference for this kind of learning is printed books - I freely admit
that I'm a dinosaur and I'll happily read a printed manual while I'm
waiting for the kettle to boil over the camp fire...

HTH

--

73,
Ged.
_______________________________________________

Manage your clamav-users mailing list subscription / unsubscribe:
https://lists.clamav.net/mailman/listinfo/clamav-users


Help us build a comprehensive ClamAV guide:
https://github.com/Cisco-Talos/clamav-documentation

https://docs.clamav.net/#mailing-lists-and-chat
Re: [clamav-users] On Access Scanning Configuration [ In reply to ]
Hi there,

On Wed, 16 Nov 2022, Nikola Nikoli? via clamav-users wrote:

> ...
> Nov 16 02:25:33 ubuntu systemd[1]: Started Clam AntiVirus userspace daemon.
> Nov 16 02:25:33 ubuntu clamd[2266]: ERROR: Can't save PID to file /var/run/clam
> Nov 16 02:25:33 ubuntu systemd[1]: clamav-daemon.service: Main process exited,

Good error message report, thanks. :)

That looks like a simple one. You need to make sure that the clamd
daemon can write its PID file to the place where it's configured to
write it. That might not be the only issue that you'll come across
but we'll cross those bridges if we come to them.

How did you install ClamAV? I'd have expected this stuff should all
be taken care of for you by the package installation process.

--

73,
Ged.
_______________________________________________

Manage your clamav-users mailing list subscription / unsubscribe:
https://lists.clamav.net/mailman/listinfo/clamav-users


Help us build a comprehensive ClamAV guide:
https://github.com/Cisco-Talos/clamav-documentation

https://docs.clamav.net/#mailing-lists-and-chat