run clamav on mount of flashdrive
Hello,
I am working on a production system on which it is not advisable to enable on-access scan with use of Dazuko. However, I want to do an automatic scan with clamscan when the flashdrive is mounted. As far as I know, Kudzu is arranging the automount of the flashdrives. Does somebody have an idea how this can be done best? The distro I am using is RHEL5u3. |
look into udev rules http://reactivated.net/writing_udev_rules.html
|
Dear Smoker,
I read the document to which your link was pointing and I will try this. Thank you |
I am trying the following rule.
Code:
KERNEL=="sd*1", DRIVER=="usb-storage", RUN+="/usr/local/bin/clamscan /media* > /tmp/clamav.log" I tried udevtest and it will show: Code:
main: looking at device '/block/sdd/sdd1' from subsystem 'block' |
You are not matching properly.
I would have used something like Code:
SUBSYSTEM=="usb", ATTRS{name}=="usb-Kingston_DataTraveler_2.0_0019E06B58BBA941D2CF029F-part1", RUN+="/home/myusername/myscript.sh" You can't put complicated run rules in so it's best to do it in a separate script which contains the real commands. Bear in mind that this will delay the accessing of the drive until clam has finished scanning. There are various tools to use to get a good match pattern, the site I gave you suggests using udevinfo but there are others like udevadm I would also consider putting a simple naming rule in which gets applied before the RUN rule so that your script will know exactly which drive to scan. for example : Code:
SUBSYSTEM=="usb", ATTRS{name}=="usb-Kingston_DataTraveler_2.0_0019E06B58BBA941D2CF029F-part1", NAME="my_flash_drive" Again, that will not work as it is, you have to find out what the appropriate name is using the udevadm tool. |
I finished the udev rule and the script to scan a flash-drive for viruses when mounted.
They are working now. "/etc/udev/rulles.d/99-scan-UsbStorage.rules" Code:
KERNEL=="sd*1", SUBSYSTEM=="block", DRIVER=="usb-storage", NAME="flash_drive" RUN+="/etc/udev/scripts/clamscan.sh &" Code:
#!/bin/ksh |
All times are GMT -5. The time now is 01:54 PM. |