Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions clamdscan/clamdscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ int main(int argc, char **argv)
int ds, dms, ret, infected = 0, err = 0;
struct timeval t1, t2;
time_t starttime;
char *config_file;
struct optstruct *opts;
const struct optstruct *opt;
#ifndef _WIN32
Expand All @@ -70,8 +71,30 @@ int main(int argc, char **argv)
return 2;
}

if((clamdopts = optparse(optget(opts, "config-file")->strarg, 0, NULL, 1, OPT_CLAMD, 0, NULL)) == NULL) {
logg("!Can't parse clamd configuration file %s\n", optget(opts, "config-file")->strarg);
/* XXX: if the user-specified config file does not exist,
* try the clamd.conf file. */
config_file = optget(opts, "config-file")->strarg;
/* XXX: assert: config_file contains either
* /etc/clamdscan.conf or user-provided string */
if ( access(config_file,R_OK) ) {
/* XXX: file not found or readable: abort if the user provided the filename
* (one bug here: user specifies CONFDIR_CLAMDSCAN which is not found
* and then we read CONFDIR_CLAMD ) */
if (strcmp(config_file,CONFDIR_CLAMDSCAN)) {
logg("!Can't find or read requested clamd configuration file %s\n", config_file);
return 2;
}
else {
config_file = CONFDIR_CLAMD;
if ( access(config_file,R_OK) ) {
logg("!Can't find any readable clamd configuration file");
return 2;
}
}
}

if((clamdopts = optparse(config_file, 0, NULL, 1, OPT_CLAMD, 0, NULL)) == NULL) {
logg("!Can't parse clamd configuration file %s\n", config_file);
return 2;
}

Expand Down
6 changes: 5 additions & 1 deletion docs/man/clamdscan.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ Be quiet \- only output error messages.
Write all messages (except for libclamav output) to the standard output (stdout).
.TP
\fB\-\-config\-file=FILE\fR
Read clamd settings from FILE.
Read clamd settings from FILE. If this option is not specified, the program
tries @CFGDIR@/clamdscan.conf, and if that is not found, it tries
@CFGDIR@/clamd.conf. The program recognizes a small subset of clamd.conf's
configuration directives, and ignores all others. See the provided configuration
sample.
.TP
\fB\-l FILE, \-\-log=FILE\fR
Save the scan report to FILE.
Expand Down
4 changes: 2 additions & 2 deletions etc/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.

EXTRA_DIST = clamd.conf.sample freshclam.conf.sample clamav-milter.conf.sample
EXTRA_DIST = clamd.conf.sample freshclam.conf.sample clamav-milter.conf.sample clamdscan.conf.sample
CFGINST = @CFGDIR@

sysconf_DATA = clamd.conf.sample freshclam.conf.sample
sysconf_DATA = clamd.conf.sample freshclam.conf.sample clamdscan.conf.sample

if BUILD_CLAMD
if HAVE_MILTER
Expand Down
4 changes: 2 additions & 2 deletions etc/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,9 @@ target_vendor = @target_vendor@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
EXTRA_DIST = clamd.conf.sample freshclam.conf.sample clamav-milter.conf.sample
EXTRA_DIST = clamd.conf.sample freshclam.conf.sample clamav-milter.conf.sample clamdscan.conf.sample
CFGINST = @CFGDIR@
sysconf_DATA = clamd.conf.sample freshclam.conf.sample $(am__append_1)
sysconf_DATA = clamd.conf.sample freshclam.conf.sample clamdscan.conf.sample $(am__append_1)
all: all-am

.SUFFIXES:
Expand Down
40 changes: 40 additions & 0 deletions etc/clamdscan.conf.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
##
## Sample clamdscan.conf file for a clamdscan program to
## work with a remote clamd scanner.
##
## Please read the clamd.conf(5) manual before editing this file.
## The options in this sample file are all those that the clamdscan
## program recognizes
##

## Connection information for daemon
# Use local socket (unix only)
# Default: yes
LocalSocket yes

## Or use TCP sockets
# TCPSocket 3310
# TCPAddr 127.0.0.1

# Close the connection when the data size limit is exceeded.
# The value should match your MTA's limit for a maximum attachment size.
# <This option also used by clamdscan>
# Default: 25M
StreamMaxLength 200M

# Maximum depth directories are scanned at.
# Default: 15
MaxDirectoryRecursion 250

# This directive can be used multiple times
# Default: scan all
#ExcludePath ^/proc/
#ExcludePath ^/sys/

# Follow directory symlinks.
# Default: no
#FollowDirectorySymlinks yes

# Follow regular file symlinks.
# Default: no
#FollowFileSymlinks yes
1 change: 1 addition & 0 deletions platform.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ typedef unsigned int in_addr_t;
#endif

#define CONFDIR_CLAMD CONFDIR PATHSEP "clamd.conf"
#define CONFDIR_CLAMDSCAN CONFDIR PATHSEP "clamdscan.conf"
#define CONFDIR_FRESHCLAM CONFDIR PATHSEP "freshclam.conf"
#define CONFDIR_MILTER CONFDIR PATHSEP "clamav-milter.conf"

Expand Down
3 changes: 2 additions & 1 deletion shared/optparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ const struct clam_option __clam_options[] = {

/* cmdline only */
{ NULL, "help", 'h', TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD | OPT_FRESHCLAM | OPT_CLAMSCAN | OPT_CLAMDSCAN | OPT_SIGTOOL | OPT_MILTER | OPT_CLAMCONF | OPT_CLAMDTOP | OPT_CLAMBC, "", "" },
{ NULL, "config-file", 'c', TYPE_STRING, NULL, 0, CONFDIR_CLAMD, FLAG_REQUIRED, OPT_CLAMD | OPT_CLAMDSCAN | OPT_CLAMDTOP, "", "" },
{ NULL, "config-file", 'c', TYPE_STRING, NULL, 0, CONFDIR_CLAMD, FLAG_REQUIRED, OPT_CLAMD | OPT_CLAMDTOP, "", "" },
{ NULL, "config-file", 'c', TYPE_STRING, NULL, 0, CONFDIR_CLAMDSCAN, FLAG_REQUIRED, OPT_CLAMDSCAN, "", "" },
{ NULL, "config-file", 0, TYPE_STRING, NULL, 0, CONFDIR_FRESHCLAM, FLAG_REQUIRED, OPT_FRESHCLAM, "", "" },
{ NULL, "config-file", 'c', TYPE_STRING, NULL, 0, CONFDIR_MILTER, FLAG_REQUIRED, OPT_MILTER, "", "" },
{ NULL, "version", 'V', TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD | OPT_FRESHCLAM | OPT_CLAMSCAN | OPT_CLAMDSCAN | OPT_SIGTOOL | OPT_MILTER | OPT_CLAMCONF | OPT_CLAMDTOP | OPT_CLAMBC, "", "" },
Expand Down