File: runAV.c

package info (click to toggle)
modsecurity 3.0.3-1%2Bdeb10u2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 42,032 kB
  • sloc: cpp: 25,953; ansic: 15,785; sh: 5,357; python: 3,556; yacc: 2,896; makefile: 1,394; lex: 1,344; perl: 464; ruby: 69; javascript: 53; php: 42
file content (48 lines) | stat: -rwxr-xr-x 1,265 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "common.h"

main(int argc, char *argv[])
{
	char cmd[MAX_OUTPUT_SIZE];
	char output[MAX_OUTPUT_SIZE];
	int error;
	char *colon;
	char *keyword;

	if (argc > 1) {
		sprintf (cmd, "/usr/bin/clamscan --no-summary %s", argv[1]);
		output[0] = '\0';
		error = run_cmd(cmd,output,MAX_OUTPUT_SIZE);
		if (error != 0) {
			printf ("1 exec error %d: OK", error);
		} else if (!*output) {
			printf ("1 exec empty: OK"); 
		}
		else {
		    colon = strstr(output, ":");
		    if (colon) { colon += 2; }
			if (!colon) {
				printf ("0 unable to parse clamscan output [%s] for cmd [%s]", output, cmd);
			}
			else if (keyword = strstr(colon, " FOUND")) {
				*keyword = '\0';
				printf ("0 clamscan: %s", colon);
			}
			else if (keyword = strstr(colon, " ERROR")) {
				*keyword = '\0';
				printf ("0 clamscan: %s", colon);
			}
			else if (keyword = strstr(colon, "OK")) {
				printf ("1 clamscan: OK");
			}
			else if (keyword = strstr(colon, "Empty file")) {
				printf ("1 empty file");
			}
			else if (keyword = strstr(colon, "Can't access file ")) {
				printf ("0 invalid file %s", keyword+18);
			}
			else { 
				printf ("0 unable to parse clamscan output [%s] for cmd [%s]", output, cmd);
			}
		}
	}
}