lib/clamby/command.rb in clamby-1.6.10 vs lib/clamby/command.rb in clamby-1.6.11
- old
+ new
@@ -10,10 +10,15 @@
def self.scan_executable
return 'clamdscan' if Clamby.config[:daemonize]
return 'clamscan'
end
+ # $CHILD_STATUS maybe nil if the execution itself (not the client process)
+ def self.scan_status
+ $CHILD_STATUS && $CHILD_STATUS.exitstatus
+ end
+
# Perform a ClamAV scan on the given path.
def self.scan(path)
return nil unless file_exists?(path)
args = [Shellwords.escape(path), '--no-summary']
@@ -26,20 +31,18 @@
args << "-d #{Clamby.config[:datadir]}" if Clamby.config[:datadir]
new.run scan_executable, *args
- # $CHILD_STATUS maybe nil if the execution itself (not the client process)
- # fails
- case $CHILD_STATUS && $CHILD_STATUS.exitstatus
+ case self.scan_status
when 0
return false
when nil, 2
# clamdscan returns 2 whenever error other than a detection happens
if Clamby.config[:error_clamscan_client_error] && Clamby.config[:daemonize]
raise Clamby::ClamscanClientError.new("Clamscan client error")
end
-
+
# returns true to maintain legacy behavior
return true
else
return true unless Clamby.config[:error_file_virus]