update to darkstat 3.0.619.

ok rui
This commit is contained in:
ckuethe 2007-05-14 21:42:47 +00:00
parent b5b4c072dd
commit 3c2be6022b
10 changed files with 13 additions and 253 deletions

View File

@ -1,4 +1,4 @@
$OpenBSD: user.list,v 1.72 2007/04/27 21:12:25 ajacoutot Exp $ $OpenBSD: user.list,v 1.73 2007/05/14 21:42:47 ckuethe Exp $
This file lists all users and groups that are created by ports or that This file lists all users and groups that are created by ports or that
users are encouraged to create after installing a port (these are marked users are encouraged to create after installing a port (these are marked
@ -95,3 +95,4 @@ id user group port options
584 _nepenthes _nepenthes net/nepenthes 584 _nepenthes _nepenthes net/nepenthes
585 _lighttpd _lighttpd www/lighttpd 585 _lighttpd _lighttpd www/lighttpd
586 _gnugk _gnugk net/gnugk 586 _gnugk _gnugk net/gnugk
587 _darkstat _darkstat net/darkstat

View File

@ -1,9 +1,8 @@
# $OpenBSD: Makefile,v 1.5 2007/02/12 18:07:12 ckuethe Exp $ # $OpenBSD: Makefile,v 1.6 2007/05/14 21:42:47 ckuethe Exp $
COMMENT= "network statistics gatherer with graphs" COMMENT= "network statistics gatherer with graphs"
DISTNAME= darkstat-3.0.540 DISTNAME= darkstat-3.0.619
PKGNAME= ${DISTNAME}p1
CATEGORIES= net www CATEGORIES= net www
HOMEPAGE= http://dmr.ath.cx/net/darkstat/ HOMEPAGE= http://dmr.ath.cx/net/darkstat/
@ -20,6 +19,7 @@ MASTER_SITES= ${HOMEPAGE}
EXTRACT_SUFX= .tar.bz2 EXTRACT_SUFX= .tar.bz2
CONFIGURE_STYLE= gnu CONFIGURE_STYLE= gnu
CONFIGURE_ARGS+= --with-privdrop-user=_darkstat
NO_REGRESS= Yes NO_REGRESS= Yes

View File

@ -1,5 +1,5 @@
MD5 (darkstat-3.0.540.tar.bz2) = SYJWxme0+nmlUaw2JqK6hg== MD5 (darkstat-3.0.619.tar.bz2) = sw5rUcs8+EJUR2wRQPCOFw==
RMD160 (darkstat-3.0.540.tar.bz2) = ye42pTgb/CbIF1n0zeYVOrrEJkw= RMD160 (darkstat-3.0.619.tar.bz2) = OfyPqeSbfP5zkX2XoGLNiFXziCg=
SHA1 (darkstat-3.0.540.tar.bz2) = qsoroHyEebe/I5MmGwCT9Wh0Z2Y= SHA1 (darkstat-3.0.619.tar.bz2) = 04rrbGp3syTNHiZ2JfQFCbNYqDo=
SHA256 (darkstat-3.0.540.tar.bz2) = DbGyaE6ohxxYfInD3cTZMC9+iF/w7EAVEMQkRfWne7Q= SHA256 (darkstat-3.0.619.tar.bz2) = 5QrTQx+MPIFyyHi3uQc+maSAKtICc5ptrXksuPfPwb4=
SIZE (darkstat-3.0.540.tar.bz2) = 75293 SIZE (darkstat-3.0.619.tar.bz2) = 82508

View File

@ -1,112 +0,0 @@
$OpenBSD: patch-cap_c,v 1.4 2007/02/12 18:07:12 ckuethe Exp $
--- cap.c.orig Mon Feb 12 10:50:08 2007
+++ cap.c Mon Feb 12 10:50:23 2007
@@ -43,7 +43,7 @@ static const linkhdr_t *linkhdr = NULL;
* Init pcap. Exits on failure.
*/
void
-cap_init(const char *device, const char *filter)
+cap_init(const char *device, const char *filter, int promisc)
{
char errbuf[PCAP_ERRBUF_SIZE], *tmp_device;
int linktype, caplen;
@@ -79,7 +79,7 @@ cap_init(const char *device, const char
pcap = pcap_open_live(
tmp_device,
caplen, /* snaplen */
- 1, /* promisc, FIXME */
+ promisc, /* promisc */
CAP_TIMEOUT,
errbuf);
@@ -91,6 +91,11 @@ cap_init(const char *device, const char
free(tmp_device);
+ if (promisc)
+ verbosef("capturing in promiscuous mode");
+ else
+ verbosef("capturing in non-promiscuous mode");
+
/* Set filter expression, if any. */
if (filter != NULL)
{
@@ -112,28 +117,13 @@ cap_init(const char *device, const char
free(tmp_filter);
}
-#ifdef HAVE_PCAP_GET_SELECTABLE_FD
- if (pcap_setnonblock(pcap, 1, errbuf) == -1)
- errx(1, "pcap_setnonblock(): %s", errbuf);
-
- pcap_fd = pcap_get_selectable_fd(pcap);
- if (pcap_fd == -1)
- errx(1, "pcap_get_selectable_fd(): there isn't one!");
-
- verbosef("pcap_got_selectable_fd");
-#else
- /* hax */
pcap_fd = pcap_fileno(pcap);
+ /* set non-blocking */
{ int one = 1;
if (ioctl(pcap_fd, FIONBIO, &one) == -1)
err(1, "ioctl(pcap_fd, FIONBIO)"); }
-{ struct timeval t = { 0, CAP_TIMEOUT * 1000 }; /* msec -> usec */
- if (ioctl(pcap_fd, BIOCSRTIMEOUT, &t) == -1)
- err(1, "ioctl(pcap_fd, BIOCSRTIMEOUT)"); }
-#endif
-
#ifdef BIOCSETWF
{
/* Deny all writes to the socket */
@@ -151,6 +141,7 @@ cap_init(const char *device, const char
#endif
#ifdef BIOCLOCK
+ /* set "locked" flag (no reset) */
if (ioctl(pcap_fd, BIOCLOCK) == -1)
err(1, "ioctl(pcap_fd, BIOCLOCK)");
verbosef("locked down BPF for security");
@@ -190,7 +181,7 @@ cap_poll(fd_set *read_set)
#ifndef linux /* We don't use select() on Linux. */
if (!FD_ISSET(pcap_fd, read_set)) {
- dverbosef("cap_poll premature");
+ verbosef("cap_poll premature");
return;
}
#endif
@@ -202,19 +193,29 @@ cap_poll(fd_set *read_set)
localip_update(); /* FIXME: this might even be too often */
total = 0;
- do {
+ for (;;) {
ret = pcap_dispatch(
pcap,
-1, /* count, -1 = entire buffer */
linkhdr->handler, /* callback func from decode.c */
NULL); /* user */
+ verbosef("ret = %d", ret); /* FIXME: debugging the FIONBIO change */
+
if (ret < 0)
errx(1, "pcap_dispatch(): %s", pcap_geterr(pcap));
/* Despite count = -1, Linux will only dispatch one packet at a time. */
total += ret;
- } while (ret != 0);
+
+#ifdef linux
+ /* keep looping until we've dispatched all the outstanding packets */
+ if (ret == 0) break;
+#else
+ /* we get them all on the first shot */
+ break;
+#endif
+ }
/*FIXME*/fprintf(stderr, "%-20d\r", total);
}

View File

@ -1,15 +0,0 @@
$OpenBSD: patch-cap_h,v 1.3 2007/02/12 18:07:12 ckuethe Exp $
--- cap.h.orig Mon Feb 12 10:50:08 2007
+++ cap.h Mon Feb 12 10:50:21 2007
@@ -5,9 +5,10 @@
*/
#include <sys/types.h> /* OpenBSD needs this before select */
+#include <sys/time.h> /* FreeBSD 4 needs this for struct timeval */
#include <sys/select.h>
-void cap_init(const char *device, const char *filter);
+void cap_init(const char *device, const char *filter, int promisc);
void cap_fd_set(fd_set *read_set, int *max_fd,
struct timeval *timeout, int *need_timeout);
void cap_poll(fd_set *read_set);

View File

@ -1,31 +0,0 @@
$OpenBSD: patch-configure_ac,v 1.1 2006/11/11 18:11:09 ckuethe Exp $
--- configure.ac.orig Sun Aug 6 20:20:54 2006
+++ configure.ac Fri Nov 3 17:59:07 2006
@@ -114,27 +114,6 @@ fi
-# Check for pcap_get_selectable_fd()
-AC_CHECK_LIB(pcap, pcap_get_selectable_fd,
- [AC_DEFINE(HAVE_PCAP_GET_SELECTABLE_FD, 1,
- [Define to 1 if libpcap has pcap_get_selectable_fd().])],
- [cat <<END_MSG
-$RULE
-
-Your libpcap doesn't implement pcap_get_selectable_fd()
-This is indicative of an outdated libpcap.
-
-A workaround for this has been enabled (in cap.c) which may
-or may not work in your situation. Either way, I would
-suggest that you upgrade the libpcap on your system and
-re-run configure.
-
-$RULE
-END_MSG
-])
-
-
-
# A real OS will have err.h
AC_CHECK_HEADERS(err.h)

View File

@ -1,26 +0,0 @@
$OpenBSD: patch-darkstat_1,v 1.1 2007/02/12 17:38:03 ckuethe Exp $
--- darkstat.1.orig Sun Jul 2 03:22:13 2006
+++ darkstat.1 Mon Feb 12 10:29:53 2007
@@ -14,6 +14,9 @@ darkstat v3 \- network statistics gather
[
.BI \-d
]
+[
+.BI \-n
+]
.BI \-i " interface"
[
.BI \-p " port"
@@ -37,6 +40,12 @@ All settings are passed on the commandli
.TP
.BI \-d
Detach from the controlling terminal and run in the background.
+.\"
+.TP
+.BI \-n
+Do not use promiscuous mode to capture.
+Note that an interface may already be in promiscuous mode.
+If this is a problem, use an appropriate bpf(4) filter.
.\"
.TP
.BI \-i " interface"

View File

@ -1,46 +0,0 @@
$OpenBSD: patch-darkstat_c,v 1.1 2007/02/12 17:38:03 ckuethe Exp $
--- darkstat.c.orig Mon Jun 26 07:19:31 2006
+++ darkstat.c Mon Feb 12 10:29:53 2007
@@ -54,7 +54,7 @@ parse_port(const char *str)
static void
usage(const char *arg0)
{
- printf("usage: %s [-d] -i interface [-p port] [-b bindaddr] [-f filter]\n",
+ printf("usage: %s [-d] [-n] -i interface [-p port] [-b bindaddr] [-f filter]\n",
arg0);
exit(EXIT_FAILURE);
}
@@ -68,7 +68,7 @@ main(int argc, char **argv)
int maxconn = -1;
const char *interface = NULL;
const char *filter = NULL;
- int ch, want_daemonize = 0;
+ int ch, want_daemonize = 0, want_promisc = 1;
printf(PACKAGE_STRING " using libpcap %d.%d\n",
PCAP_VERSION_MAJOR, PCAP_VERSION_MINOR);
@@ -76,11 +76,14 @@ main(int argc, char **argv)
if (close(STDIN_FILENO) == -1)
warn("close(stdin)");
- while ((ch = getopt(argc, argv, "di:p:b:f:")) != -1) {
+ while ((ch = getopt(argc, argv, "dni:p:b:f:")) != -1) {
switch (ch) {
case 'd':
want_daemonize = 1;
break;
+ case 'n':
+ want_promisc = 0;
+ break;
case 'i':
interface = optarg;
break;
@@ -113,7 +116,7 @@ main(int argc, char **argv)
dns_init(); /* do this first as it forks - minimize memory use */
/* Need root privs for these: */
- cap_init(interface, filter);
+ cap_init(interface, filter, want_promisc);
http_init(bindaddr, bindport, maxconn);
ncache_init(); /* don't need priv, but must do before chroot */

View File

@ -1,13 +0,0 @@
$OpenBSD: patch-decode_c,v 1.1 2006/11/11 18:11:09 ckuethe Exp $
--- decode.c.orig Sun Aug 6 18:26:32 2006
+++ decode.c Fri Nov 3 17:58:32 2006
@@ -70,7 +70,9 @@ static const linkhdr_t linkhdrs[] = {
{ DLT_PPP, PPP_HDR_LEN, NULL },
{ DLT_FDDI, FDDI_HDR_LEN, NULL },
{ DLT_PPP_ETHER, PPPOE_HDR_LEN, decode_pppoe },
+#ifdef DLT_LINUX_SLL
{ DLT_LINUX_SLL, SLL_HDR_LEN, decode_linux_sll },
+#endif
{ -1, -1, NULL }
};

View File

@ -1,3 +1,5 @@
@comment $OpenBSD: PLIST,v 1.1.1.1 2006/06/18 17:26:20 jasper Exp $ @comment $OpenBSD: PLIST,v 1.2 2007/05/14 21:42:47 ckuethe Exp $
@newgroup _darkstat:587
@newuser _darkstat:587:_darkstat::Darkstat Network Monitor Account:/nonexistent:/sbin/nologin
@man man/man1/darkstat.1 @man man/man1/darkstat.1
sbin/darkstat sbin/darkstat