... | ... |
@@ -54,7 +54,10 @@ Build a CVD file. \-s, \-\-server is required. |
54 | 54 |
\fB\-\-server\fR |
55 | 55 |
ClamAV Signing Service address (for virus database maintainers only). |
56 | 56 |
.TP |
57 |
-\fB\-\-unpack FILE, \-u FILE\fR |
|
57 |
+\fB\-\-datadir=DIR\fR |
|
58 |
+Use DIR as the default database directory for all operations. |
|
59 |
+.TP |
|
60 |
+\fB\-\-unpack=FILE, \-u FILE\fR |
|
58 | 61 |
Unpack FILE (CVD) to a current directory. |
59 | 62 |
.TP |
60 | 63 |
\fB\-\-unpack\-current\fR |
... | ... |
@@ -181,7 +181,7 @@ const struct clam_option __clam_options[] = { |
181 | 181 |
|
182 | 182 |
{ "TemporaryDirectory", "tempdir", 0, TYPE_STRING, NULL, -1, NULL, 0, OPT_CLAMD | OPT_MILTER | OPT_CLAMSCAN | OPT_SIGTOOL, "This option allows you to change the default temporary directory.", "/tmp" }, |
183 | 183 |
|
184 |
- { "DatabaseDirectory", "datadir", 0, TYPE_STRING, NULL, -1, DATADIR, 0, OPT_CLAMD | OPT_FRESHCLAM, "This option allows you to change the default database directory.\nIf you enable it, please make sure it points to the same directory in\nboth clamd and freshclam.", "/var/lib/clamav" }, |
|
184 |
+ { "DatabaseDirectory", "datadir", 0, TYPE_STRING, NULL, -1, DATADIR, 0, OPT_CLAMD | OPT_FRESHCLAM | OPT_SIGTOOL, "This option allows you to change the default database directory.\nIf you enable it, please make sure it points to the same directory in\nboth clamd and freshclam.", "/var/lib/clamav" }, |
|
185 | 185 |
|
186 | 186 |
{ "OfficialDatabaseOnly", "official-db-only", 0, TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD | OPT_CLAMSCAN, "Only load the official signatures published by the ClamAV project.", "no" }, |
187 | 187 |
|
... | ... |
@@ -640,7 +640,7 @@ static int build(const struct optstruct *opts) |
640 | 640 |
struct stat foo; |
641 | 641 |
unsigned char buffer[FILEBUFF]; |
642 | 642 |
char *tarfile, header[513], smbuff[32], builder[32], *pt, olddb[512], patch[32], broken[32]; |
643 |
- const char *dbname, *newcvd; |
|
643 |
+ const char *dbname, *newcvd, *localdbdir = NULL; |
|
644 | 644 |
struct cl_engine *engine; |
645 | 645 |
FILE *cvd, *fh; |
646 | 646 |
gzFile *tar; |
... | ... |
@@ -664,6 +664,9 @@ static int build(const struct optstruct *opts) |
664 | 664 |
return -1; |
665 | 665 |
} |
666 | 666 |
|
667 |
+ if(optget(opts, "datadir")->active) |
|
668 |
+ localdbdir = optget(opts, "datadir")->strarg; |
|
669 |
+ |
|
667 | 670 |
if(stat("COPYING", &foo) == -1) { |
668 | 671 |
mprintf("!build: COPYING file not found in current working directory.\n"); |
669 | 672 |
return -1; |
... | ... |
@@ -768,9 +771,9 @@ static int build(const struct optstruct *opts) |
768 | 768 |
|
769 | 769 |
} else { |
770 | 770 |
pt = freshdbdir(); |
771 |
- snprintf(olddb, sizeof(olddb), "%s"PATHSEP"%s.cvd", pt, dbname); |
|
771 |
+ snprintf(olddb, sizeof(olddb), "%s"PATHSEP"%s.cvd", localdbdir ? localdbdir : pt, dbname); |
|
772 | 772 |
if(access(olddb, R_OK)) |
773 |
- snprintf(olddb, sizeof(olddb), "%s"PATHSEP"%s.cld", pt, dbname); |
|
773 |
+ snprintf(olddb, sizeof(olddb), "%s"PATHSEP"%s.cld", localdbdir ? localdbdir : pt, dbname); |
|
774 | 774 |
free(pt); |
775 | 775 |
} |
776 | 776 |
|
... | ... |
@@ -1086,15 +1089,18 @@ static int build(const struct optstruct *opts) |
1086 | 1086 |
static int unpack(const struct optstruct *opts) |
1087 | 1087 |
{ |
1088 | 1088 |
char name[512], *dbdir; |
1089 |
+ const char *localdbdir = NULL; |
|
1089 | 1090 |
|
1091 |
+ if(optget(opts, "datadir")->active) |
|
1092 |
+ localdbdir = optget(opts, "datadir")->strarg; |
|
1090 | 1093 |
|
1091 | 1094 |
if(optget(opts, "unpack-current")->enabled) { |
1092 | 1095 |
dbdir = freshdbdir(); |
1093 |
- snprintf(name, sizeof(name), "%s"PATHSEP"%s.cvd", dbdir, optget(opts, "unpack-current")->strarg); |
|
1096 |
+ snprintf(name, sizeof(name), "%s"PATHSEP"%s.cvd", localdbdir ? localdbdir : dbdir, optget(opts, "unpack-current")->strarg); |
|
1094 | 1097 |
if(access(name, R_OK)) { |
1095 |
- snprintf(name, sizeof(name), "%s"PATHSEP"%s.cld", dbdir, optget(opts, "unpack-current")->strarg); |
|
1098 |
+ snprintf(name, sizeof(name), "%s"PATHSEP"%s.cld", localdbdir ? localdbdir : dbdir, optget(opts, "unpack-current")->strarg); |
|
1096 | 1099 |
if(access(name, R_OK)) { |
1097 |
- mprintf("!unpack: Couldn't find %s CLD/CVD database\n", optget(opts, "unpack-current")->strarg); |
|
1100 |
+ mprintf("!unpack: Couldn't find %s CLD/CVD database in %s\n", optget(opts, "unpack-current")->strarg, localdbdir ? localdbdir : dbdir); |
|
1098 | 1101 |
free(dbdir); |
1099 | 1102 |
return -1; |
1100 | 1103 |
} |
... | ... |
@@ -1366,7 +1372,10 @@ static int listsigs(const struct optstruct *opts, int mode) |
1366 | 1366 |
char *dbdir; |
1367 | 1367 |
struct stat sb; |
1368 | 1368 |
regex_t reg; |
1369 |
+ const char *localdbdir = NULL; |
|
1369 | 1370 |
|
1371 |
+ if(optget(opts, "datadir")->active) |
|
1372 |
+ localdbdir = optget(opts, "datadir")->strarg; |
|
1370 | 1373 |
|
1371 | 1374 |
if(mode == 0) { |
1372 | 1375 |
name = optget(opts, "list-sigs")->strarg; |
... | ... |
@@ -1379,7 +1388,7 @@ static int listsigs(const struct optstruct *opts, int mode) |
1379 | 1379 |
if(S_ISDIR(sb.st_mode)) { |
1380 | 1380 |
if(!strcmp(name, DATADIR)) { |
1381 | 1381 |
dbdir = freshdbdir(); |
1382 |
- ret = listdir(dbdir, NULL); |
|
1382 |
+ ret = listdir(localdbdir ? localdbdir : dbdir, NULL); |
|
1383 | 1383 |
free(dbdir); |
1384 | 1384 |
} else { |
1385 | 1385 |
ret = listdir(name, NULL); |
... | ... |
@@ -1395,7 +1404,7 @@ static int listsigs(const struct optstruct *opts, int mode) |
1395 | 1395 |
} |
1396 | 1396 |
mprintf_stdout = 1; |
1397 | 1397 |
dbdir = freshdbdir(); |
1398 |
- ret = listdir(dbdir, ®); |
|
1398 |
+ ret = listdir(localdbdir ? localdbdir : dbdir, ®); |
|
1399 | 1399 |
free(dbdir); |
1400 | 1400 |
cli_regfree(®); |
1401 | 1401 |
} |
... | ... |
@@ -2570,6 +2579,7 @@ static void help(void) |
2570 | 2570 |
mprintf(" --build=NAME [cvd] -b NAME build a CVD file\n"); |
2571 | 2571 |
mprintf(" --no-cdiff Don't generate .cdiff file\n"); |
2572 | 2572 |
mprintf(" --server=ADDR ClamAV Signing Service address\n"); |
2573 |
+ mprintf(" --datadir=DIR Use DIR as default database directory\n"); |
|
2573 | 2574 |
mprintf(" --unpack=FILE -u FILE Unpack a CVD/CLD file\n"); |
2574 | 2575 |
mprintf(" --unpack-current=SHORTNAME Unpack local CVD/CLD into cwd\n"); |
2575 | 2576 |
mprintf(" --list-sigs[=FILE] -l[FILE] List signature names\n"); |