Browse code

add new directive ExitOnOOM

git-svn: trunk@1073

Tomasz Kojm authored on 2004/11/08 23:26:07
Showing 6 changed files
... ...
@@ -1,3 +1,13 @@
1
+Mon Nov  8 15:24:18 CET 2004 (tk)
2
+---------------------------------
3
+  * clamd: new directive ExitOnOOM (stop deamon when libclamav reports out of
4
+	   memory condition)
5
+
6
+Mon Nov  8 11:32:11 CET 2004 (tk)
7
+---------------------------------
8
+  * clamd/server-th.c: SIGHUP: also re-open log file closed due to exceeded
9
+		       file size
10
+
1 11
 Mon Nov  8 10:29:02 GMT 2004 (njh)
2 12
 ----------------------------------
3 13
   * libclamav/message.c:	Fix crash if the guessed encoder is incorrectly
... ...
@@ -482,6 +482,8 @@ int acceptloop_th(int socketd, struct cl_node *root, const struct cfgstruct *cop
482 482
 		logg("SIGHUP caught: re-opening log file.\n");
483 483
 		logg_close();
484 484
 		sighup = 0;
485
+		if(!logg_file && (cpt = cfgopt(copt, "LogFile")))
486
+		    logg_file = cpt->strarg;
485 487
 	}
486 488
 
487 489
 	if (!progexit && new_sd >= 0) {
... ...
@@ -94,12 +94,14 @@ int command(int desc, const struct cl_node *root, const struct cl_limits *limits
94 94
 
95 95
     if(!strncmp(buff, CMD1, strlen(CMD1))) { /* SCAN */
96 96
 	if(scan(buff + strlen(CMD1) + 1, NULL, root, limits, options, copt, desc, 0) == -2)
97
-	    return COMMAND_SHUTDOWN;
97
+	    if(cfgopt(copt, "ExitOnOOM"))
98
+		return COMMAND_SHUTDOWN;
98 99
 
99 100
     } else if(!strncmp(buff, CMD2, strlen(CMD2))) { /* RAWSCAN */
100 101
 	opt = options & ~CL_SCAN_ARCHIVE;
101 102
 	if(scan(buff + strlen(CMD2) + 1, NULL, root, NULL, opt, copt, desc, 0) == -2)
102
-	    return COMMAND_SHUTDOWN;
103
+	    if(cfgopt(copt, "ExitOnOOM"))
104
+		return COMMAND_SHUTDOWN;
103 105
 
104 106
     } else if(!strncmp(buff, CMD3, strlen(CMD3))) { /* QUIT */
105 107
 	return COMMAND_SHUTDOWN;
... ...
@@ -113,7 +115,8 @@ int command(int desc, const struct cl_node *root, const struct cl_limits *limits
113 113
 
114 114
     } else if(!strncmp(buff, CMD6, strlen(CMD6))) { /* CONTSCAN */
115 115
 	if(scan(buff + strlen(CMD6) + 1, NULL, root, limits, options, copt, desc, 1) == -2)
116
-	    return COMMAND_SHUTDOWN;
116
+	    if(cfgopt(copt, "ExitOnOOM"))
117
+		return COMMAND_SHUTDOWN;
117 118
 
118 119
     } else if(!strncmp(buff, CMD7, strlen(CMD7))) { /* VERSION */
119 120
 	    const char *dbdir;
... ...
@@ -147,7 +150,8 @@ int command(int desc, const struct cl_node *root, const struct cl_limits *limits
147 147
 
148 148
     } else if(!strncmp(buff, CMD8, strlen(CMD8))) { /* STREAM */
149 149
 	if(scanstream(desc, NULL, root, limits, options, copt) == CL_EMEM)
150
-	    return COMMAND_SHUTDOWN;
150
+	    if(cfgopt(copt, "ExitOnOOM"))
151
+		return COMMAND_SHUTDOWN;
151 152
 
152 153
     } else if(!strncmp(buff, CMD9, strlen(CMD9))) { /* SESSION */
153 154
 	do {
... ...
@@ -135,6 +135,12 @@ Execute the COMMAND when virus is found. In the command string %v will be replac
135 135
 .br 
136 136
 Default: disabled
137 137
 .TP 
138
+\fBExitOnOOM\fR
139
+Stop deamon when libclamav reports out of memory condition.
140
+.br 
141
+Default: disabled
142
+.TP 
143
+.TP 
138 144
 \fBUser STRING\fR
139 145
 Run as selected user.
140 146
 .br 
... ...
@@ -136,6 +136,9 @@ FixStaleSocket
136 136
 # Default: disabled
137 137
 #AllowSupplementaryGroups
138 138
 
139
+# Stop deamon when libclamav reports out of memory condition.
140
+#ExitOnOOM
141
+
139 142
 # Don't fork into background.
140 143
 # Default: disabled
141 144
 #Foreground
... ...
@@ -90,6 +90,7 @@ struct cfgstruct *parsecfg(const char *cfgfile, int messages)
90 90
 	    {"MaxDirectoryRecursion", OPT_NUM},
91 91
 	    {"FollowDirectorySymlinks", OPT_NOARG},
92 92
 	    {"FollowFileSymlinks", OPT_NOARG},
93
+	    {"ExitOnOOM", OPT_NOARG},
93 94
 	    {"Foreground", OPT_NOARG},
94 95
 	    {"Debug", OPT_NOARG},
95 96
 	    {"LeaveTemporaryFiles", OPT_NOARG},