summaryrefslogtreecommitdiff
path: root/network/arpwatch/patches/arpwatch-addr.patch
blob: 5647ff811f2965b2b531b69fbd57fe1a7eda3d78 (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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
--- arpwatch-2.1a11/addresses.h.in.addr	Wed Jun  5 00:40:29 1996
+++ arpwatch-2.1a11/addresses.h.in	Wed Jul 31 17:39:38 2002
@@ -1,2 +1,4 @@
 #define WATCHER "root"
-#define WATCHEE "arpwatch (Arpwatch)"
+#define WATCHEE "root (Arpwatch)"
+extern char *watcher;
+extern char *watchee;
--- arpwatch-2.1a11/arpsnmp.8.addr	Sun Sep 17 15:34:48 2000
+++ arpwatch-2.1a11/arpsnmp.8	Fri Aug  2 15:15:31 2002
@@ -30,6 +30,12 @@
 ] [
 .B -f
 .I datafile
+] [
+.B -e
+.I username
+] [
+.B -s
+.I username
 ]
 .I file
 [
@@ -59,6 +65,27 @@
 .I arp.dat
 file must be created before the first time you run
 .BR arpsnmp .
+.LP
+If the
+.B -e 
+flag is used, 
+.B arpsnmp
+sends e-mail messages to
+.I username
+rather than the default (root).
+If a single `-' character is given for the username,
+sending of e-mail is suppressed,
+but logging via syslog is still done as usual.
+(This can be useful during initial runs, to collect data
+without being flooded with messages about new stations.)
+.LP
+If the
+.B -s 
+flag is used, 
+.B arpsnmp
+sends e-mail messages with
+.I username
+as the return address, rather than the default (root).
 .LP
 .SH "REPORT MESSAGES"
 (See the
--- arpwatch-2.1a11/arpsnmp.c.addr	Sun Jan 17 19:47:40 1999
+++ arpwatch-2.1a11/arpsnmp.c	Fri Aug  2 15:17:16 2002
@@ -59,6 +59,7 @@
 #include "file.h"
 #include "machdep.h"
 #include "util.h"
+#include "addresses.h"
 
 /* Forwards */
 int	main(int, char **);
@@ -90,7 +91,7 @@
 	}
 
 	opterr = 0;
-	while ((op = getopt(argc, argv, "df:")) != EOF)
+	while ((op = getopt(argc, argv, "df:e:s:")) != EOF)
 		switch (op) {
 
 		case 'd':
@@ -105,6 +106,24 @@
 			arpfile = optarg;
 			break;
 
+		case 'e':
+			if ( optarg ) {
+				watcher = strdup(optarg);
+			} else {
+				(void)fprintf(stderr, "%s: Need recipient username/e-mail address after -e\n", prog);
+				usage();
+			}
+			break;
+
+		case 's':
+			if ( optarg ) {
+				watchee = strdup(optarg);
+			} else {
+				(void)fprintf(stderr, "%s: Need sender username/e-mail address after -s\n", prog);
+				usage();
+			}
+			break;
+
 		default:
 			usage();
 		}
@@ -184,6 +203,6 @@
 
 	(void)fprintf(stderr, "Version %s\n", version);
 	(void)fprintf(stderr,
-	    "usage: %s [-d] [-f datafile] file [...]\n", prog);
+	    "usage: %s [-d] [-f datafile] [-e username] [-s username] file [...]\n", prog);
 	exit(1);
 }
--- arpwatch-2.1a11/arpwatch.8.addr	Thu Aug  1 13:45:36 2002
+++ arpwatch-2.1a11/arpwatch.8	Thu Aug  1 14:08:05 2002
@@ -46,6 +46,12 @@
 ] [
 .B -u
 .I username
+] [
+.B -e
+.I username
+] [
+.B -s
+.I username
 ]
 .ad
 .SH DESCRIPTION
@@ -106,6 +112,27 @@
 and group ID to that of the primary group of 
 .IR username .
 This is recommended for security reasons.
+.LP
+If the
+.B -e 
+flag is used, 
+.B arpwatch
+sends e-mail messages to
+.I username
+rather than the default (root).
+If a single `-' character is given for the username,
+sending of e-mail is suppressed,
+but logging via syslog is still done as usual.
+(This can be useful during initial runs, to collect data
+without being flooded with messages about new stations.)
+.LP
+If the
+.B -s 
+flag is used, 
+.B arpwatch
+sends e-mail messages with
+.I username
+as the return address, rather than the default (root).
 .LP
 Note that an empty
 .I arp.dat
--- arpwatch-2.1a11/arpwatch.c.addr	Thu Aug  1 13:45:36 2002
+++ arpwatch-2.1a11/arpwatch.c	Thu Aug  1 13:47:35 2002
@@ -78,6 +78,7 @@
 #include "machdep.h"
 #include "setsignal.h"
 #include "util.h"
+#include "addresses.h"
 
 /* Some systems don't define these */
 #ifndef ETHERTYPE_REVARP
@@ -190,7 +191,7 @@
 	interface = NULL;
 	rfilename = NULL;
 	pd = NULL;
-	while ((op = getopt(argc, argv, "df:i:n:Nr:u:")) != EOF)
+	while ((op = getopt(argc, argv, "df:i:n:Nr:u:e:s:")) != EOF)
 		switch (op) {
 
 		case 'd':
@@ -232,6 +233,26 @@
 			}
 			break;
 
+		case 'e':
+			if ( optarg ) {
+				watcher = strdup(optarg);
+			}
+			else {
+				fprintf(stderr, "%s: Need recipient username/e-mail address after -e\n", prog);
+				usage();
+			}
+			break;
+
+		case 's':
+			if ( optarg ) {
+				watchee = strdup(optarg);
+			}
+			else {
+				fprintf(stderr, "%s: Need sender username/e-mail address after -s\n", prog);
+				usage();
+			}
+			break;
+
 		default:
 			usage();
 		}
@@ -784,6 +805,7 @@
 
 	(void)fprintf(stderr, "Version %s\n", version);
 	(void)fprintf(stderr, "usage: %s [-dN] [-f datafile] [-i interface]"
-	    " [-n net[/width]] [-r file] [-u username]\n", prog);
+	    " [-n net[/width]] [-r file] [-u username]"
+	    " [-e username] [-s username]\n", prog);
 	exit(1);
 }
--- arpwatch-2.1a11/report.c.addr	Sat Sep 30 18:41:10 2000
+++ arpwatch-2.1a11/report.c	Thu Aug  1 14:16:43 2002
@@ -70,6 +70,9 @@
 
 #define PLURAL(n) ((n) == 1 || (n) == -1 ? "" : "s")
 
+char *watcher = WATCHER;
+char *watchee = WATCHEE;
+
 static int cdepth;	/* number of outstanding children */
 
 static char *fmtdate(time_t);
@@ -240,8 +243,6 @@
 	register FILE *f;
 	char tempfile[64], cpu[64], os[64];
 	char *fmt = "%20s: %s\n";
-	char *watcher = WATCHER;
-	char *watchee = WATCHEE;
 	char *sendmail = PATH_SENDMAIL;
 	char *unknown = "<unknown>";
 	char buf[132];
@@ -258,6 +259,9 @@
 		}
 		f = stdout;
 		(void)putc('\n', f);
+	} else if (watcher == NULL || *watcher == NULL || *watcher == '-') {
+		dosyslog(LOG_NOTICE, title, a, e1, e2);
+		return;
 	} else {
 		/* Setup child reaper if we haven't already */
 		if (!init) {