Browse code

clamd: add AllowAllMatchScan config option for permit/deny ALLMATCHSCAN command

David Raynor authored on 2013/06/12 00:20:31
Showing 3 changed files
... ...
@@ -362,13 +362,18 @@ int command(client_conn_t *conn, int *virus)
362 362
 	     cli_unlink(conn->filename);
363 363
 	     return ret;
364 364
 	 case COMMAND_ALLMATCHSCAN:
365
-	     thrmgr_setactivetask(NULL, "ALLMATCHSCAN");
366
-	     scandata.options |= CL_SCAN_ALLMATCHES;
367
-	     type = TYPE_SCAN;
368
-	     break;
365
+	     if (!optget(opts, "AllowAllMatchScan")->enabled) {
366
+		logg("$Rejecting ALLMATCHSCAN command.\n");
367
+		conn_reply(conn, conn->filename, "ALLMATCHSCAN command disabled by clamd configuration.", "ERROR");
368
+		return 1;
369
+	    }
370
+	    thrmgr_setactivetask(NULL, "ALLMATCHSCAN");
371
+	    scandata.options |= CL_SCAN_ALLMATCHES;
372
+	    type = TYPE_SCAN;
373
+	    break;
369 374
 	 default:
370
-	     logg("!Invalid command distpached: %d\n", conn->cmdtype);
371
-	     return 1;
375
+	    logg("!Invalid command dispatched: %d\n", conn->cmdtype);
376
+	    return 1;
372 377
      }
373 378
 
374 379
      scandata.type = type;
... ...
@@ -212,6 +212,11 @@ Example
212 212
 # Default: no
213 213
 #LeaveTemporaryFiles yes
214 214
 
215
+# Permit use of the ALLMATCHSCAN command. If set to no, clamd will reject
216
+# any ALLMATCHSCAN command as invalid.
217
+# Default: yes
218
+#AllowAllMatchScan no
219
+
215 220
 # Detect Possibly Unwanted Applications.
216 221
 # Default: no
217 222
 #DetectPUA yes
... ...
@@ -253,6 +253,8 @@ const struct clam_option __clam_options[] = {
253 253
 
254 254
     { "ExitOnOOM", NULL, 0, TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD, "Stop the daemon when libclamav reports an out of memory condition.", "yes" },
255 255
 
256
+    { "AllowAllMatchScan", NULL, 0, TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD, "Permit use of the ALLMATCHSCAN command.", "yes" },
257
+
256 258
     { "Foreground", NULL, 0, TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD | OPT_FRESHCLAM | OPT_MILTER, "Don't fork into background.", "no" },
257 259
 
258 260
     { "Debug", NULL, 0, TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD | OPT_FRESHCLAM, "Enable debug messages in libclamav.", "no" },