select libgcc, report from datenmaulwurf
[openwrt.git] / openwrt / package / dsniff / patches / gdbm.patch
1 diff -Nur dsniff-2.3/configure dsniff-2.3.patched/configure
2 --- dsniff-2.3/configure 2005-06-11 18:13:59.000000000 +0200
3 +++ dsniff-2.3.patched/configure 2005-06-11 18:14:37.000000000 +0200
4 @@ -16,6 +16,8 @@
5 ac_help="$ac_help
6 --with-db=DIR use Berkeley DB (with --enable-compat185) in DIR"
7 ac_help="$ac_help
8 + --with-gdbm=DIR use GNU DBM in DIR"
9 +ac_help="$ac_help
10 --with-libpcap=DIR use libpcap in DIR"
11 ac_help="$ac_help
12 --with-libnet=DIR use libnet in DIR"
13 @@ -3051,7 +3053,40 @@
14
15 fi
16
17 +echo $ac_n "checking for libgdbm""... $ac_c" 1>&6
18 +echo "configure:3059: checking for libgdbm" >&5
19 +# Check whether --with-gdbm or --without-gdbm was given.
20 +if test "${with_gdbm+set}" = set; then
21 + withval="$with_gdbm"
22 + case "$withval" in
23 + yes|no)
24 + echo "$ac_t""no" 1>&6
25 + ;;
26 + *)
27 + echo "$ac_t""$withval" 1>&6
28 + if test -f $withval/include/gdbm.h -a -f $withval/lib/libgdbm.a; then
29 + owd=`pwd`
30 + if cd $withval; then withval=`pwd`; cd $owd; fi
31 + DBINC="-I$withval/include"
32 + DBLIB="-L$withval/lib -lgdbm"
33 + else
34 + { echo "configure: error: gdbm.h or libgdbm.a not found in $withval" 1>&2; exit 1; }
35 + fi
36 + ;;
37 + esac
38 +else
39 + if test -f ${prefix}/include/gdbm.h; then
40 + LNETINC="-I${prefix}/include"
41 + LNETLIB="-L${prefix}/lib -lgdbm"
42 + elif test -f /usr/include/gdbm.h; then
43 + LNETLIB="-lgdbm"
44 + else
45 + echo "$ac_t""no" 1>&6
46 + { echo "configure: error: libgdbm not found" 1>&2; exit 1; }
47 + fi
48 + echo "$ac_t""yes" 1>&6
49
50 +fi
51
52
53 echo $ac_n "checking for libnet""... $ac_c" 1>&6
54 diff -Nur dsniff-2.3/record.c dsniff-2.3.patched/record.c
55 --- dsniff-2.3/record.c 2000-11-14 16:51:02.000000000 +0100
56 +++ dsniff-2.3.patched/record.c 2005-06-11 18:14:56.000000000 +0200
57 @@ -13,12 +13,7 @@
58 #include <stdio.h>
59 #include <time.h>
60 #include <md5.h>
61 -#ifdef HAVE_DB_185_H
62 -#define DB_LIBRARY_COMPATIBILITY_API
63 -#include <db_185.h>
64 -#elif HAVE_DB_H
65 -#include <db.h>
66 -#endif
67 +#include <gdbm.h>
68 #include <libnet.h>
69 #include "options.h"
70 #include "record.h"
71 @@ -34,7 +29,7 @@
72 struct netobj data;
73 };
74
75 -static DB *db;
76 +GDBM_FILE dbf;
77
78 static int
79 xdr_rec(XDR *xdrs, struct rec *rec)
80 @@ -61,7 +56,6 @@
81
82 tm = localtime(&rec->time);
83 strftime(tstr, sizeof(tstr), "%x %X", tm);
84 -
85 srcp = libnet_host_lookup(rec->src, Opt_dns);
86 dstp = libnet_host_lookup(rec->dst, Opt_dns);
87
88 @@ -86,10 +80,10 @@
89 fflush(stdout);
90 }
91
92 -static DBT *
93 +static datum
94 record_hash(struct rec *rec)
95 {
96 - static DBT key;
97 + static datum key;
98 static u_char hash[16];
99 MD5_CTX ctx;
100
101 @@ -102,16 +96,16 @@
102 MD5Update(&ctx, rec->data.n_bytes, rec->data.n_len);
103 MD5Final(hash, &ctx);
104
105 - key.data = hash;
106 - key.size = sizeof(hash);
107 + key.dptr = hash;
108 + key.dsize = sizeof(hash);
109
110 - return (&key);
111 + return (key);
112 }
113
114 static int
115 record_save(struct rec *rec)
116 {
117 - DBT *key, data;
118 + datum key, data;
119 XDR xdrs;
120 u_char buf[2048];
121
122 @@ -120,15 +114,15 @@
123 if (!xdr_rec(&xdrs, rec))
124 return (0);
125
126 - data.data = buf;
127 - data.size = xdr_getpos(&xdrs);
128 + data.dptr = buf;
129 + data.dsize = xdr_getpos(&xdrs);
130
131 xdr_destroy(&xdrs);
132
133 key = record_hash(rec);
134
135 - if (db->put(db, key, &data, R_NOOVERWRITE) == 0)
136 - db->sync(db, 0);
137 + if (gdbm_store(dbf, key, data, GDBM_INSERT) == 0)
138 + gdbm_sync(dbf);
139
140 return (1);
141 }
142 @@ -136,18 +130,22 @@
143 void
144 record_dump(void)
145 {
146 - DBT key, data;
147 + datum nextkey, key, content;
148 XDR xdrs;
149 struct rec rec;
150
151 - while (db->seq(db, &key, &data, R_NEXT) == 0) {
152 + key = gdbm_firstkey(dbf);
153 + while (key.dptr) {
154 + nextkey = gdbm_nextkey(dbf, key);
155 + content = gdbm_fetch(dbf, key);
156 memset(&rec, 0, sizeof(rec));
157 - xdrmem_create(&xdrs, data.data, data.size, XDR_DECODE);
158 -
159 + xdrmem_create(&xdrs, content.dptr, content.dsize, XDR_DECODE);
160 if (xdr_rec(&xdrs, &rec)) {
161 record_print(&rec);
162 }
163 xdr_destroy(&xdrs);
164 + free(key.dptr);
165 + key = nextkey;
166 }
167 }
168
169 @@ -155,16 +153,23 @@
170 record_init(char *file)
171 {
172 int flags, mode;
173 -
174 + // needed for gdbm_open, which does not have the option to create
175 + // a database in memory
176 + if(file == NULL) {
177 + char *record_file = "/tmp/.dsniff.db";
178 + file = record_file;
179 + }
180 +
181 if (Opt_read) {
182 - flags = O_RDONLY;
183 + flags = GDBM_READER;
184 mode = 0;
185 }
186 else {
187 - flags = O_RDWR|O_CREAT;
188 + flags = GDBM_WRCREAT;
189 mode = S_IRUSR|S_IWUSR;
190 }
191 - if ((db = dbopen(file, flags, mode, DB_BTREE, NULL)) == NULL)
192 +
193 + if ((dbf = gdbm_open(file, 1024, flags, mode, NULL)) == NULL)
194 return (0);
195
196 return (1);
197 @@ -203,6 +208,6 @@
198 void
199 record_close(void)
200 {
201 - db->close(db);
202 + gdbm_close(dbf);
203 }
204
This page took 0.050999 seconds and 5 git commands to generate.