[Pkg-clamav-commits] [SCM] Debian repository for ClamAV branch, debian/unstable, updated. debian/0.95+dfsg-1-6156-g094ec9b
Tomasz Kojm
tkojm at clamav.net
Sun Apr 4 00:59:28 UTC 2010
The following commit has been merged in the debian/unstable branch:
commit 2086dc5cab5747c776a099967f62351b8a5b5c16
Author: Tomasz Kojm <tkojm at clamav.net>
Date: Wed Aug 5 16:27:48 2009 +0200
clamd, clamscan: add support for CrossFilesystems/--cross-fs (bb#1607)
diff --git a/ChangeLog b/ChangeLog
index a5d3ae3..2ef2f49 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Wed Aug 5 16:27:06 CEST 2009 (tk)
+----------------------------------
+ * clamd, clamscan: add support for CrossFilesystems/--cross-fs (bb#1607)
+
Tue Aug 4 23:15:26 CEST 2009 (tk)
----------------------------------
* configure, libclamav: fix compile issues on IRIX (bb#1532)
diff --git a/clamd/scanner.c b/clamd/scanner.c
index b886fec..01f9ea2 100644
--- a/clamd/scanner.c
+++ b/clamd/scanner.c
@@ -237,17 +237,29 @@ int scan_pathchk(const char *path, struct cli_ftw_cbdata *data)
{
struct scan_cb_data *scandata = data->data;
const struct optstruct *opt;
+ struct stat statbuf;
if((opt = optget(scandata->opts, "ExcludePath"))->enabled) {
while(opt) {
if(match_regex(path, opt->strarg) == 1) {
if(scandata->type != TYPE_MULTISCAN)
conn_reply_single(scandata->conn, path, "Excluded");
- return 1;
+ return 1;
}
opt = (const struct optstruct *) opt->nextarg;
}
}
+
+ if(!optget(scandata->opts, "CrossFilesystems")->enabled) {
+ if(stat(path, &statbuf) == 0) {
+ if(statbuf.st_dev != scandata->dev) {
+ if(scandata->type != TYPE_MULTISCAN)
+ conn_reply_single(scandata->conn, path, "Excluded (another filesystem)");
+ return 1;
+ }
+ }
+ }
+
return 0;
}
diff --git a/clamd/scanner.h b/clamd/scanner.h
index 694d6e3..a56fc5d 100644
--- a/clamd/scanner.h
+++ b/clamd/scanner.h
@@ -25,6 +25,8 @@
#define TYPE_CONTSCAN 1
#define TYPE_MULTISCAN 2
+#include <sys/types.h>
+
#include "libclamav/clamav.h"
#include "shared/optparser.h"
#include "thrmgr.h"
@@ -46,6 +48,7 @@ struct scan_cb_data {
const struct optstruct *opts;
threadpool_t *thr_pool;
jobgroup_t *group;
+ dev_t dev;
};
int scanfd(const int fd, const client_conn_t *conn, unsigned long int *scanned, const struct cl_engine *engine, unsigned int options, const struct optstruct *opts, int odesc, int stream);
diff --git a/clamd/session.c b/clamd/session.c
index 00ec1f6..b151fbb 100644
--- a/clamd/session.c
+++ b/clamd/session.c
@@ -192,6 +192,7 @@ int command(client_conn_t *conn, int *virus)
struct scan_cb_data scandata;
struct cli_ftw_cbdata data;
unsigned ok, error, total;
+ struct stat sb;
jobgroup_t *group = NULL;
if (thrmgr_group_need_terminate(conn->group)) {
@@ -316,6 +317,11 @@ int command(client_conn_t *conn, int *virus)
flags |= CLI_FTW_FOLLOW_DIR_SYMLINK;
if (optget(opts, "FollowFileSymlinks")->enabled)
flags |= CLI_FTW_FOLLOW_FILE_SYMLINK;
+
+ if(!optget(opts, "CrossFilesystems")->enabled)
+ if(stat(conn->filename, &sb) == 0)
+ scandata.dev = sb.st_dev;
+
ret = cli_ftw(conn->filename, flags, maxdirrec ? maxdirrec : INT_MAX, scan_callback, &data, scan_pathchk);
if (ret == CL_EMEM)
if(optget(opts, "ExitOnOOM")->enabled)
diff --git a/clamscan/clamscan.c b/clamscan/clamscan.c
index d1b3e8f..a37ee7e 100644
--- a/clamscan/clamscan.c
+++ b/clamscan/clamscan.c
@@ -238,6 +238,7 @@ void help(void)
mprintf(" all supported db files from DIR\n");
mprintf(" --log=FILE -l FILE Save scan report to FILE\n");
mprintf(" --recursive[=yes/no(*)] -r Scan subdirectories recursively\n");
+ mprintf(" --cross-fs[=yes(*)/no] Scan files and directories on other filesystems\n");
mprintf(" --file-list=FILE -f FILE Scan files from FILE\n");
mprintf(" --remove[=yes/no(*)] Remove infected files. Be careful!\n");
mprintf(" --move=DIRECTORY Move infected files into DIRECTORY\n");
diff --git a/clamscan/manager.c b/clamscan/manager.c
index 130f768..c8615b2 100644
--- a/clamscan/manager.c
+++ b/clamscan/manager.c
@@ -169,7 +169,7 @@ static int scanfile(const char *filename, struct cl_engine *engine, const struct
return ret;
}
-static int scandirs(const char *dirname, struct cl_engine *engine, const struct optstruct *opts, unsigned int options, unsigned int depth)
+static int scandirs(const char *dirname, struct cl_engine *engine, const struct optstruct *opts, unsigned int options, unsigned int depth, dev_t dev)
{
DIR *dd;
struct dirent *dent;
@@ -228,8 +228,16 @@ static int scandirs(const char *dirname, struct cl_engine *engine, const struct
/* stat the file */
if(lstat(fname, &statbuf) != -1) {
+ if(!optget(opts, "cross-fs")->enabled) {
+ if(statbuf.st_dev != dev) {
+ if(!printinfected)
+ logg("~%s: Excluded\n", fname);
+ free(fname);
+ continue;
+ }
+ }
if(S_ISDIR(statbuf.st_mode) && !S_ISLNK(statbuf.st_mode) && recursion) {
- if(scandirs(fname, engine, opts, options, depth) == 1)
+ if(scandirs(fname, engine, opts, options, depth, dev) == 1)
scanret++;
} else {
if(S_ISREG(statbuf.st_mode))
@@ -593,8 +601,10 @@ int scanmanager(const struct optstruct *opts)
if(!getcwd(cwd, sizeof(cwd))) {
logg("!Can't get absolute pathname of current working directory\n");
ret = 57;
- } else
- ret = scandirs(cwd, engine, opts, options, 1);
+ } else {
+ stat(cwd, &sb);
+ ret = scandirs(cwd, engine, opts, options, 1, sb.st_dev);
+ }
} else if(opts->filename && !optget(opts, "file-list")->enabled && !strcmp(opts->filename[0], "-")) { /* read data from stdin */
ret = scanstdin(engine, opts, options);
@@ -624,7 +634,8 @@ int scanmanager(const struct optstruct *opts)
break;
case S_IFDIR:
- ret = scandirs(file, engine, opts, options, 1);
+ stat(file, &sb);
+ ret = scandirs(file, engine, opts, options, 1, sb.st_dev);
break;
default:
diff --git a/docs/man/clamd.conf.5.in b/docs/man/clamd.conf.5.in
index 1e65ec4..faa2ba6 100644
--- a/docs/man/clamd.conf.5.in
+++ b/docs/man/clamd.conf.5.in
@@ -162,6 +162,11 @@ Follow directory symlinks.
.br
Default: no
.TP
+\fBCrossFilesystems BOOL\fR
+Scan files and directories on other filesystems.
+.br
+Default: yes
+.TP
\fBFollowFileSymlinks BOOL\fR
Follow regular file symlinks.
.br
diff --git a/docs/man/clamscan.1.in b/docs/man/clamscan.1.in
index 807aa1c..e11b07e 100644
--- a/docs/man/clamscan.1.in
+++ b/docs/man/clamscan.1.in
@@ -48,6 +48,9 @@ Scan files listed line by line in FILE.
\fB\-r, \-\-recursive\fR
Scan directories recursively. All the subdirectories in the given directory will be scanned.
.TP
+\fB\-\-cross\-fs=[yes(*)/no]\fR
+Scan files and directories on other filesystems.
+.TP
\fB\-\-bell\fR
Sound bell on virus detection.
.TP
diff --git a/etc/clamd.conf b/etc/clamd.conf
index 566d032..5a32644 100644
--- a/etc/clamd.conf
+++ b/etc/clamd.conf
@@ -156,6 +156,10 @@ LocalSocket /tmp/clamd.socket
# Default: no
#FollowFileSymlinks yes
+# Scan files and directories on other filesystems.
+# Default: yes
+#CrossFilesystems yes
+
# Perform a database check.
# Default: 600 (10 min)
#SelfCheck 600
diff --git a/shared/optparser.c b/shared/optparser.c
index 55a7c37..b062ef2 100644
--- a/shared/optparser.c
+++ b/shared/optparser.c
@@ -211,6 +211,8 @@ const struct clam_option clam_options[] = {
{ "FollowFileSymlinks", NULL, 0, TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD, "Follow symlinks to regular files.", "no" },
+ { "CrossFilesystems", "cross-fs", 0, TYPE_BOOL, MATCH_BOOL, 1, NULL, 0, OPT_CLAMD | OPT_CLAMSCAN, "Scan files and directories on other filesystems.", "yes" },
+
{ "SelfCheck", NULL, 0, TYPE_NUMBER, MATCH_NUMBER, 600, NULL, 0, OPT_CLAMD, "This option specifies the time intervals (in seconds) in which clamd\nshould perform a database check.", "600" },
{ "VirusEvent", NULL, 0, TYPE_STRING, NULL, -1, NULL, 0, OPT_CLAMD, "Execute a command when a virus is found. In the command string %v will be\nreplaced with the virus name. Additionally, two environment variables will\nbe defined: $CLAM_VIRUSEVENT_FILENAME and $CLAM_VIRUSEVENT_VIRUSNAME.", "/usr/bin/mailx -s \"ClamAV VIRUS ALERT: %v\" alert < /dev/null" },
--
Debian repository for ClamAV
More information about the Pkg-clamav-commits
mailing list