summaryrefslogtreecommitdiff
path: root/sbin/pflogd
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2001-08-23 04:06:13 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2001-08-23 04:06:13 +0000
commite9f39b4619674bae96bc058768eb1a8d84e4f746 (patch)
tree6cc389b46db090e8872287404b3d4fbbdb5b06d8 /sbin/pflogd
parentd6a2e7898240409a30abca2a2b99c4cbca6968c1 (diff)
do not permit snaplen change on an active log file
Diffstat (limited to 'sbin/pflogd')
-rw-r--r--sbin/pflogd/pflogd.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/sbin/pflogd/pflogd.c b/sbin/pflogd/pflogd.c
index d9c00d97ebb..8ddfa5f47cb 100644
--- a/sbin/pflogd/pflogd.c
+++ b/sbin/pflogd/pflogd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pflogd.c,v 1.2 2001/08/22 14:49:37 deraadt Exp $ */
+/* $OpenBSD: pflogd.c,v 1.3 2001/08/23 04:06:12 deraadt Exp $ */
/*
* Copyright (c) 2001 Theo de Raadt
@@ -175,6 +175,26 @@ reset_dump(void)
return (0);
#define TCPDUMP_MAGIC 0xa1b2c3d4
+
+ /*
+ * XXX Must read the file, compare the header against our new
+ * options (in particular, snaplen) and adjust our options so
+ * that we generate a correct file.
+ */
+ (void) fseek(fp, 0L, SEEK_SET);
+ if (fread((char *)&hdr, sizeof(hdr), 1, fp) == 1) {
+ if (hdr.magic == TCPDUMP_MAGIC &&
+ hdr.version_major == PCAP_VERSION_MAJOR &&
+ hdr.version_minor == PCAP_VERSION_MINOR &&
+ hdr.snaplen != snaplen) {
+ logmsg(LOG_WARNING,
+ "Existing file specifies a snaplen of %d, using it",
+ hdr.snaplen);
+ snaplen = hdr.snaplen;
+ }
+ }
+ (void) fseek(fp, 0L, SEEK_END);
+
hdr.magic = TCPDUMP_MAGIC;
hdr.version_major = PCAP_VERSION_MAJOR;
hdr.version_minor = PCAP_VERSION_MINOR;