| ... | ... |
@@ -70,6 +70,7 @@ Michael Dankov <misha*btrc.ru> |
| 70 | 70 |
Maxim Dounin <mdounin*rambler-co.ru> |
| 71 | 71 |
Alejandro Dubrovsky <s328940*student.uq.edu.au> |
| 72 | 72 |
Magnus Ekdahl <magnus*debian.org> |
| 73 |
+Jens Elkner <elkner*linofee.org> |
|
| 73 | 74 |
Jason Englander <jason*englanders.cc> |
| 74 | 75 |
Tony Finch <dot*dotat.at> |
| 75 | 76 |
David Ford <david+cert*blue-labs.org> |
| ... | ... |
@@ -94,6 +95,7 @@ Joe Maimon <jmaimon*ttec.com> |
| 94 | 94 |
Andrey V. Malyshev <amal*krasn.ru> |
| 95 | 95 |
Everton da Silva Marques <everton*lab.ipaccess.diveo.net.br> |
| 96 | 96 |
Andrey J. Melnikoff <temnota*kmv.ru> |
| 97 |
+Damian Menscher <menscher*uiuc.edu> |
|
| 97 | 98 |
Denis De Messemacker <ddm*clamav.net> |
| 98 | 99 |
Mark Mielke <mark*mark.mielke.cc> |
| 99 | 100 |
Arkadiusz Miskiewicz <misiek*pld.org.pl> |
| ... | ... |
@@ -1,3 +1,10 @@ |
| 1 |
+Thu May 13 02:22:50 CEST 2004 (tk) |
|
| 2 |
+---------------------------------- |
|
| 3 |
+ * libclamav: move putenv(TMPDIR) code from clamd to cl_settempdir() |
|
| 4 |
+ * clamd: new directive LeaveTemporaryFiles (Debug no longer leaves temporary |
|
| 5 |
+ files not removed) |
|
| 6 |
+ * clamscan: respect --tempdir in libclamav; add --leave-temps |
|
| 7 |
+ |
|
| 1 | 8 |
Wed May 12 15:25:47 BST 2004 (trog) |
| 2 | 9 |
----------------------------------- |
| 3 | 10 |
* libclamav/vba_extract.c: fix error path bug (spotted by Tomasz Klim) |
| ... | ... |
@@ -214,15 +214,11 @@ void clamd(struct optstruct *opt) |
| 214 | 214 |
} |
| 215 | 215 |
|
| 216 | 216 |
/* set the temporary dir */ |
| 217 |
- if((cpt = cfgopt(copt, "TemporaryDirectory"))) {
|
|
| 218 |
- var = (char *) mcalloc(8 + strlen(cpt->strarg), sizeof(char)); |
|
| 219 |
- sprintf(var, "TMPDIR=%s", cpt->strarg); |
|
| 220 |
- if(!putenv(var)) |
|
| 221 |
- logg("Setting %s as global temporary directory\n", cpt->strarg);
|
|
| 222 |
- else |
|
| 223 |
- logg("!Can't set TMPDIR variable - insufficient space in the environment.\n");
|
|
| 224 |
- /* DON'T CALL free(var) - see putenv(3) */ |
|
| 225 |
- } |
|
| 217 |
+ if((cpt = cfgopt(copt, "TemporaryDirectory"))) |
|
| 218 |
+ cl_settempdir(cpt->strarg, 0); |
|
| 219 |
+ |
|
| 220 |
+ if(cfgopt(copt, "LeaveTemporaryFiles")) |
|
| 221 |
+ cl_settempdir(NULL, 1); |
|
| 226 | 222 |
|
| 227 | 223 |
/* load the database(s) */ |
| 228 | 224 |
if((cpt = cfgopt(copt, "DatabaseDirectory")) || (cpt = cfgopt(copt, "DataDirectory"))) |
| ... | ... |
@@ -99,6 +99,12 @@ int clamscan(struct optstruct *opt) |
| 99 | 99 |
if(optl(opt, "bell")) |
| 100 | 100 |
bell = 1; |
| 101 | 101 |
|
| 102 |
+ if(optl(opt, "tempdir")) |
|
| 103 |
+ cl_settempdir(getargl(opt, "tempdir"), 0); |
|
| 104 |
+ |
|
| 105 |
+ if(optl(opt, "leave-temps")) |
|
| 106 |
+ cl_settempdir(NULL, 1); |
|
| 107 |
+ |
|
| 102 | 108 |
/* initialize logger */ |
| 103 | 109 |
|
| 104 | 110 |
if(optc(opt, 'l')) {
|
| ... | ... |
@@ -229,8 +229,7 @@ int scanmanager(const struct optstruct *opt) |
| 229 | 229 |
} |
| 230 | 230 |
#endif |
| 231 | 231 |
|
| 232 |
- if((tmpdir = getargl(opt, "tempdir")) == NULL) |
|
| 233 |
- tmpdir = getenv("TMPDIR");
|
|
| 232 |
+ tmpdir = getenv("TMPDIR");
|
|
| 234 | 233 |
|
| 235 | 234 |
if(tmpdir == NULL) |
| 236 | 235 |
#ifdef P_tmpdir |
| ... | ... |
@@ -543,9 +542,7 @@ int scancompressed(const char *filename, struct cl_node *root, const struct pass |
| 543 | 543 |
|
| 544 | 544 |
/* check write access */ |
| 545 | 545 |
|
| 546 |
- if((tmpdir = getargl(opt, "tempdir")) == NULL) |
|
| 547 |
- /* njh@bandsman.co.uk: use TMPDIR as an alternative */ |
|
| 548 |
- tmpdir = getenv("TMPDIR");
|
|
| 546 |
+ tmpdir = getenv("TMPDIR");
|
|
| 549 | 547 |
|
| 550 | 548 |
if(tmpdir == NULL) |
| 551 | 549 |
#ifdef P_tmpdir |
| ... | ... |
@@ -745,8 +742,7 @@ int scandenied(const char *filename, struct cl_node *root, const struct passwd * |
| 745 | 745 |
|
| 746 | 746 |
/* check write access */ |
| 747 | 747 |
|
| 748 |
- if((tmpdir = getargl(opt, "tempdir")) == NULL) |
|
| 749 |
- tmpdir = getenv("TMPDIR");
|
|
| 748 |
+ tmpdir = getenv("TMPDIR");
|
|
| 750 | 749 |
|
| 751 | 750 |
if(tmpdir == NULL) |
| 752 | 751 |
#ifdef P_tmpdir |
| ... | ... |
@@ -144,6 +144,8 @@ extern int cl_statfree(struct cl_stat *dbstat); |
| 144 | 144 |
/* enable debug information */ |
| 145 | 145 |
extern void cl_debug(void); |
| 146 | 146 |
|
| 147 |
+extern void cl_settempdir(const char *dir, short leavetemps); |
|
| 148 |
+ |
|
| 147 | 149 |
/* build a trie */ |
| 148 | 150 |
extern int cl_buildtrie(struct cl_node *root); |
| 149 | 151 |
|
| ... | ... |
@@ -51,7 +51,7 @@ pthread_mutex_t cl_gentemp_mutex = PTHREAD_MUTEX_INITIALIZER; |
| 51 | 51 |
#define CL_FLEVEL 2 /* don't touch it */ |
| 52 | 52 |
|
| 53 | 53 |
|
| 54 |
-int cli_debug_flag = 0; |
|
| 54 |
+short cli_debug_flag = 0, cli_leavetemps_flag = 0; |
|
| 55 | 55 |
|
| 56 | 56 |
static unsigned char oldmd5buff[16] = { 16, 38, 97, 12, 8, 4, 72, 196, 217, 144, 33, 124, 18, 11, 17, 253 };
|
| 57 | 57 |
|
| ... | ... |
@@ -269,6 +269,24 @@ unsigned int cl_rndnum(unsigned int max) |
| 269 | 269 |
return rand() % max; |
| 270 | 270 |
} |
| 271 | 271 |
|
| 272 |
+void cl_settempdir(const char *dir, short leavetemps) |
|
| 273 |
+{
|
|
| 274 |
+ char *var; |
|
| 275 |
+ |
|
| 276 |
+ if(dir) {
|
|
| 277 |
+ var = (char *) cli_malloc(8 + strlen(dir)); |
|
| 278 |
+ sprintf(var, "TMPDIR=%s", dir); |
|
| 279 |
+ if(!putenv(var)) |
|
| 280 |
+ cli_dbgmsg("Setting %s as global temporary directory\n", dir);
|
|
| 281 |
+ else |
|
| 282 |
+ cli_warnmsg("Can't set TMPDIR variable - insufficient space in the environment.\n");
|
|
| 283 |
+ |
|
| 284 |
+ /* WARNING: var must not be released - see putenv(3) */ |
|
| 285 |
+ } |
|
| 286 |
+ |
|
| 287 |
+ cli_leavetemps_flag = leavetemps; |
|
| 288 |
+} |
|
| 289 |
+ |
|
| 272 | 290 |
char *cl_gentemp(const char *dir) |
| 273 | 291 |
{
|
| 274 | 292 |
char *name, *tmp; |
| ... | ... |
@@ -320,7 +338,7 @@ int cli_rmdirs(const char *dirname) |
| 320 | 320 |
char *fname; |
| 321 | 321 |
|
| 322 | 322 |
|
| 323 |
- if(cli_debug_flag) |
|
| 323 |
+ if(cli_leavetemps_flag) |
|
| 324 | 324 |
return 0; |
| 325 | 325 |
|
| 326 | 326 |
chmod(dirname, 0700); |
| ... | ... |
@@ -87,6 +87,7 @@ struct cfgstruct *parsecfg(const char *cfgfile) |
| 87 | 87 |
{"FollowFileSymlinks", OPT_NOARG},
|
| 88 | 88 |
{"Foreground", OPT_NOARG},
|
| 89 | 89 |
{"Debug", OPT_NOARG},
|
| 90 |
+ {"LeaveTemporaryFiles", OPT_NOARG},
|
|
| 90 | 91 |
{"FixStaleSocket", OPT_NOARG},
|
| 91 | 92 |
{"User", OPT_STR},
|
| 92 | 93 |
{"AllowSupplementaryGroups", OPT_NOARG},
|