summaryrefslogtreecommitdiffstats
path: root/main/arpwatch/18_all_arpwatch-2.1a15-nofork.patch
blob: 83447f794f99b4ed1c9e6c5799d2e7540efb8192 (plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
Origianl idea comes from Matthias Andree.

diff -Naru arpwatch-2.1a15.orig/arpwatch.8 arpwatch-2.1a15/arpwatch.8
--- arpwatch-2.1a15.orig/arpwatch.8	2006-09-24 09:34:36.000000000 +0400
+++ arpwatch-2.1a15/arpwatch.8	2006-09-24 10:06:24.000000000 +0400
@@ -27,7 +27,12 @@
 .na
 .B arpwatch
 [
-.B -dN
+.B -d
+]
+.br
+.ti +9
+[
+.B -F
 ]
 .br
 .ti +9
@@ -50,6 +55,11 @@
 .br
 .ti +9
 [
+.B -N
+]
+.br
+.ti +9
+[
 .B -r
 .I file
 ]
@@ -115,6 +125,14 @@
 .IR stderr .
 .LP
 The
+.B -F
+flag is used to prevent 
+.I arpwatch
+from forking. This is allows to run
+.I arpwatch
+from daemon tools.
+.LP
+The
 .B -f
 flag is used to set the ethernet/ip address database filename.
 The default is
diff -Naru arpwatch-2.1a15.orig/arpwatch.c arpwatch-2.1a15/arpwatch.c
--- arpwatch-2.1a15.orig/arpwatch.c	2006-09-24 09:34:36.000000000 +0400
+++ arpwatch-2.1a15/arpwatch.c	2006-09-24 10:10:17.000000000 +0400
@@ -179,10 +179,12 @@
 	struct bpf_program code;
 	char errbuf[PCAP_ERRBUF_SIZE];
 	char* username = NULL;
+	int nofork = 0;
 	int restart = 0;
 	int restarting_loop = 0;
 	char options[] =
 		"d"
+		"F"
 		"f:"
 		"i:"
 		"n:"
@@ -229,6 +231,10 @@
 #endif
 			break;
 
+		case 'F':
+			++nofork;
+			break;
+
 		case 'f':
 			arpfile = optarg;
 			break;
@@ -319,12 +325,14 @@
 
 		/* Drop into the background if not debugging */
 		if (!debug) {
-			pid = fork();
-			if (pid < 0) {
-				syslog(LOG_ERR, "main fork(): %m");
-				exit(1);
-			} else if (pid != 0)
-				exit(0);
+			if (!nofork) {
+				pid = fork();
+				if (pid < 0) {
+					syslog(LOG_ERR, "main fork(): %m");
+					exit(1);
+				} else if (pid != 0)
+					exit(0);
+			}
 			(void)close(fileno(stdin));
 			(void)close(fileno(stdout));
 			(void)close(fileno(stderr));