inotifywait based virus scanning

few months ago I’ve built my NAS and configured it so that my wife can store her files on it, too. Due to the fact that she uses Windows I thought it might be reasonable to scan files on the NAS for viruses. My first approach which I called „hashclamscan“ just searched all files, created checksums and scanned modified files. Here’s an inotifywait based solution, which uses clamscan (and if available sophos savscan) and makes use of CDB for the hashes…
Continue Reading

the state pattern

The state pattern becomes useful if your object needs to react differently to different states. Let us assume you are writing an SMTP Proxy. SMTP works in sequences (connection establishment, ehlo/helo, mail, rcpt, data(, …), quit). Each sequence can have different error/success codes which are not available in another. For example you would only return 220 on connection establishment, not 250. And you would return 221 on quit, not 250. So if you are writing a server which works like this, you will most likely use an if then else or switch. The state-pattern would be another method to solve this. However, a more simple example which shows the pros and cons of the state pattern is an activity-based-sleep.
Continue Reading