Mon, 28 Jan 2013 17:37:18 +0100
Correct socket error reporting improvement with IPv6 portable code,
after helpful recommendation by Saúl Ibarra Corretgé on OSips devlist.
1 ##
2 ## honeyd.spec -- OpenPKG RPM Package Specification
3 ## Copyright (c) 2000-2008 OpenPKG Foundation e.V. <http://openpkg.net/>
4 ##
5 ## Permission to use, copy, modify, and distribute this software for
6 ## any purpose with or without fee is hereby granted, provided that
7 ## the above copyright notice and this permission notice appear in all
8 ## copies.
9 ##
10 ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
11 ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
12 ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
13 ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
14 ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
15 ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
16 ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
17 ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
18 ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
19 ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
20 ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
21 ## SUCH DAMAGE.
22 ##
24 # package version
25 %define V_honeyd 1.5c
26 %define V_libdnsres 0.1a
28 # package information
29 Name: honeyd
30 Summary: Creates a Virtual Host on Network
31 URL: http://www.honeyd.org/
32 Vendor: Niels Provos
33 Packager: OpenPKG Foundation e.V.
34 Distribution: OpenPKG Community
35 Class: EVAL
36 Group: Security
37 License: BSD
38 Version: %{V_honeyd}
39 Release: 20120800
41 # package options
42 %option with_fsl yes
43 %option with_gui no
45 # list of sources
46 Source0: http://www.citi.umich.edu/u/provos/honeyd/honeyd-%{V_honeyd}.tar.gz
47 Source1: http://www.citi.umich.edu/u/provos/honeyd/contrib/mael/ftp.sh
48 Source2: http://www.citi.umich.edu/u/provos/honeyd/contrib/mael/pop3.sh
49 Source3: http://www.citi.umich.edu/u/provos/honeyd/contrib/mael/smtp.sh
50 Source4: http://www.citi.umich.edu/u/provos/papers/honeyd-eabstract.pdf
51 Source5: http://www.citi.umich.edu/u/provos/papers/honeyd-eabstract.ps
52 Source6: http://www.citi.umich.edu/u/provos/honeyd/ch01-results/1/honeydGUI.tar.gz
53 Source7: honey
54 Source8: svcs.sh
55 Source9: rc.honeyd
56 Source10: fsl.honeyd
57 Source11: honeyd.conf
58 Source12: cdefs.h
59 Source13: setenv.h
60 Source14: setenv.c
61 Source15: vasprintf.c
62 Source16: vasprintf.h
63 Source17: evbuffer.h
64 Source18: http://www.monkey.org/~provos/libdnsres-%{V_libdnsres}.tar.gz
65 Patch0: honeyd.patch
67 # build information
68 BuildPreReq: OpenPKG, openpkg >= 20100101, make
69 PreReq: OpenPKG, openpkg >= 20100101
70 BuildPreReq: libdnet, libpcap, libevent, libedit, zlib, pcre
71 PreReq: libdnet, libpcap, libevent, libedit, zlib, pcre
72 %if "%{with_fsl}" == "yes"
73 BuildPreReq: fsl
74 PreReq: fsl
75 %endif
76 %if "%{with_gui}" == "yes"
77 PreReq: java, JAVA-JDK
78 %endif
80 %description
81 Honeyd is a small daemon that creates virtual hosts on a network.
82 The hosts can be configured to run arbitrary services, and their
83 TCP personality can be adapted so that they appear to be running
84 certain versions of operating systems. Honeyd enables a single host
85 to claim multiple addresses on a LAN for network simulation. It is
86 possible to ping the virtual machines, or to traceroute them. Any
87 type of service on the virtual machine can be simulated according to
88 a simple configuration file. Instead of simulating a service, it is
89 also possible to proxy it to another machine. The package arpd will
90 most certainly be useful as well, although it is not a technical
91 requirement for this package.
93 %track
94 prog honeyd:honeyd = {
95 version = %{V_honeyd}
96 url = http://www.citi.umich.edu/u/provos/honeyd/
97 regex = honeyd-(__VER__)\.tar\.gz
98 }
99 prog honeyd:libdnsres = {
100 version = %{V_libdnsres}
101 url = http://www.monkey.org/~provos/libdnsres/
102 regex = libdnsres-(__VER__)\.tar\.gz
103 }
105 %prep
106 %setup -q
107 %setup -q -D -T -a 18
108 %patch -p0
109 cp -f %{SOURCE setenv.c} .
110 cp -f %{SOURCE setenv.h} .
111 cp -f %{SOURCE vasprintf.c} .
112 cp -f %{SOURCE vasprintf.h} .
113 cp -f %{SOURCE evbuffer.h} .
114 cp -f %{SOURCE cdefs.h} .
115 %{l_shtool} mkdir -f -p -m 755 libdnsres-%{V_libdnsres}/sys
116 cp -f %{SOURCE cdefs.h} libdnsres-%{V_libdnsres}/sys/
117 %{l_shtool} subst \
118 -e 's;AF_LOCAL;AF_UNIX;' \
119 *.c
120 %{l_shtool} subst \
121 -e 's;\(for ac_header in stdarg.h errno.h fcntl.h paths.h stdlib.h string.h time.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h sys/ioccom.h sys/file.h net/bpf.h syslog.h unistd.h assert.h\);\1 sys/cdefs.h;' \
122 -e 's;\(for ac_func in asprintf dup2 fgetln gettimeofday memmove memset strcasecmp strchr strdup strncasecmp strtoul strspn getaddrinfo getnameinfo freeaddrinfo setgroups sendmsg recvmsg setregid setruid\) \(kqueue\);\1 setenv \2;' \
123 configure
124 %{l_shtool} subst \
125 -e 's;^\(honeyd_SOURCES *=[^\\]*\);\1 setenv.c vasprintf.c;' \
126 -e 's;^\(honeyd_OBJECTS *=[^\\]*\);\1 setenv.o vasprintf.o ;' \
127 Makefile.in
128 %{l_shtool} subst \
129 -e 's;/var/run/honeyd.pid;%{l_prefix}/var/honeyd/honeyd.pid;' \
130 honeyd.h
131 %{l_shtool} subst \
132 -e 's;\(encode_int\);loc_\1;g' \
133 tagging.[ch]
134 %{l_shtool} subst \
135 -e '/#include <event.h>/a#include "evbuffer.h"' \
136 honeydstats.c \
137 untagging.c \
138 ui.c
139 %{l_shtool} subst \
140 -e 's;flock(fd, [^)][^)]*);lockf(fd, F_LOCK, 0);g' \
141 subsystems/smtp.c
142 %{l_shtool} subst \
143 -e 's/\(user_target=no\)/\1; pic_mode=no;/' \
144 -e 's;test "*$\(hardcode_into_libs\)"* *\([!=]*\) *"*\([a-zA-Z_][a-zA-Z_]*\)"*;test ".$\1" \2 ".$\3";g' \
145 -e 's;test "*$\(build_libtool_need_lc\)"* *\([!=]*\) *"*\([a-zA-Z_][a-zA-Z_]*\)"*;test ".$\1" \2 ".$\3";g' \
146 ltmain.sh
147 case "%{l_platform -t}" in
148 *-sunos* )
149 %{l_shtool} subst \
150 -e 's;-levent;-levent -lsocket -lnsl;g' \
151 configure
152 %{l_shtool} subst \
153 -e 's;\(\$(honeydctl_LDADD)\);\1 -lsocket -lnsl;g' \
154 Makefile.in
155 %{l_shtool} subst \
156 -e 's;-lsocket;-lsocket -lnsl -lresolv;g' \
157 libdnsres-%{V_libdnsres}/configure
158 ;;
159 esac
160 %{l_shtool} subst \
161 -e 's;#if \((!defined(BSD))\) || \((BSD < [0-9][0-9]*)\);#if (!defined(__sun)) \&\& (!defined(__SVR4)) \&\& \1 \&\& \2;' \
162 libdnsres-%{V_libdnsres}/dnsres.h \
163 libdnsres-%{V_libdnsres}/resolv.h
164 %{l_shtool} subst \
165 -e 's;u_int\([0-9]*\)_t;uint\1_t;g' \
166 libdnsres-%{V_libdnsres}/dnsres.h \
167 libdnsres-%{V_libdnsres}/resolv.h \
168 libdnsres-%{V_libdnsres}/res_random.c
169 %{l_shtool} subst \
170 -e 's;top_buildir;top_builddir;' \
171 -e 's;\(am_simple_test_OBJECTS = simple_test\.\$(OBJEXT)\);\1 arc4random.$(OBJEXT);' \
172 libdnsres-%{V_libdnsres}/Makefile.in
173 %{l_shtool} subst \
174 -e '/#include "config.h"/a#ifndef HAVE_ARC4RANDOM' \
175 libdnsres-%{V_libdnsres}/arc4random.c
176 echo '#endif' >>libdnsres-%{V_libdnsres}/arc4random.c
177 echo '#ifndef MIN' >>keycount.h
178 echo '#define MIN(a,b) (((a) < (b)) ? (a) : (b))' >>keycount.h
179 echo '#endif' >>keycount.h
181 %build
182 ( cd libdnsres-%{V_libdnsres}
183 loc_cppflags=
184 case "%{l_platform -t}" in
185 *-sunos* )
186 loc_cppflags="-D_KERNEL"
187 ;;
188 esac
189 CC="%{l_cc}" \
190 CFLAGS="%{l_cflags -O}" \
191 CPPFLAGS="%{l_cppflags} $loc_cppflags" \
192 ./configure \
193 --with-libevent=%{l_prefix} \
194 --disable-shared
195 %{l_make} %{l_mflags}
196 ) || exit $?
197 CC="%{l_cc}" \
198 CFLAGS="%{l_cflags -O}" \
199 CPPFLAGS="%{l_cppflags} -DREPLACE_GETOPT" \
200 LDFLAGS="%{l_fsl_ldflags}" \
201 LIBS="%{l_fsl_libs}" \
202 ./configure \
203 --prefix=%{l_prefix} \
204 --with-libevent=%{l_prefix} \
205 --with-libdnet=%{l_prefix} \
206 --with-libdnsres=`pwd`/libdnsres-%{V_libdnsres} \
207 --with-libpcre=%{l_prefix} \
208 --without-python
209 %{l_make} %{l_mflags -O}
211 %install
212 # create directories
213 %{l_shtool} mkdir -f -p -m 755 \
214 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
215 $RPM_BUILD_ROOT%{l_prefix}/etc/honeyd \
216 $RPM_BUILD_ROOT%{l_prefix}/lib/honeyd \
217 $RPM_BUILD_ROOT%{l_prefix}/var/honeyd \
218 $RPM_BUILD_ROOT%{l_prefix}/share/honeyd \
219 $RPM_BUILD_ROOT%{l_prefix}/libexec/honeyd
221 # install files
222 %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
223 %{l_shtool} install -c -m 750 %{l_value -s -a} \
224 -e 's;^log=/\(.*/\)*\(.*\)-.*\.log;log=%{l_prefix}/var/honeyd/\2.log;g' \
225 -e 's;^\(host=\).*;\1`%{l_shtool} echo -e %h`;g' \
226 -e 's;^\(domain=\).*;\1`%{l_shtool} echo -e %d | cut -c2-`;g' \
227 -e 's; gawk ; awk ;g' \
228 %{SOURCE ftp.sh} \
229 %{SOURCE pop3.sh} \
230 %{SOURCE smtp.sh} \
231 %{SOURCE svcs.sh} \
232 $RPM_BUILD_ROOT%{l_prefix}/libexec/honeyd/
233 %{l_shtool} install -c -m 644 %{l_value -s -a} \
234 %{SOURCE honeyd.conf} \
235 $RPM_BUILD_ROOT%{l_prefix}/etc/honeyd/
236 %{l_shtool} install -c -m 755 %{l_value -s -a} \
237 %{SOURCE rc.honeyd} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
238 %{l_shtool} install -c -m 644 \
239 %{SOURCE honeyd-eabstract.ps} \
240 $RPM_BUILD_ROOT%{l_prefix}/share/honeyd/honeyd.ps
241 %{l_shtool} install -c -m 644 \
242 %{SOURCE honeyd-eabstract.pdf} \
243 $RPM_BUILD_ROOT%{l_prefix}/share/honeyd/honeyd.pdf
245 # optionally install the Java GUI
246 %if "%{with_gui}" == "yes"
247 %{l_tar} zxf %{SOURCE honeydGUI.tar.gz}
248 mv -f honeydGUI/exec $RPM_BUILD_ROOT%{l_prefix}/lib/honeyd/javagui
249 %{l_shtool} install -c -m 755 %{l_value -s -a} \
250 %{SOURCE honey} \
251 $RPM_BUILD_ROOT%{l_prefix}/bin/
252 %endif
254 # install OSSP fsl configuration
255 %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
256 %{l_shtool} install -c -m 644 %{l_value -s -a} \
257 %{SOURCE fsl.honeyd} \
258 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
260 # remove unwanted files
261 rm -rf $RPM_BUILD_ROOT%{l_prefix}/include
262 rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/honeyd
263 rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/honeyd/README
264 rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/honeyd/config.sample
266 # determine file list
267 %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
268 %{l_files_std} \
269 '%config %attr(0750,%{l_susr},%{l_mgrp}) %{l_prefix}/var/honeyd' \
270 '%config %{l_prefix}/etc/fsl/fsl.honeyd' \
271 '%config %attr(0750,%{l_musr},%{l_mgrp}) %{l_prefix}/etc/honeyd/honeyd.conf'
273 %files -f files
275 %clean
277 %pre
278 # before upgrade, save status and stop service
279 [ $1 -eq 2 ] || exit 0
280 eval `%{l_rc} honeyd status 2>/dev/null | tee %{l_tmpfile}`
281 %{l_rc} honeyd stop 2>/dev/null
282 exit 0
284 %post
285 if [ $1 -eq 1 ]; then
286 # display final hints on initial installation
287 ( echo "Before starting Honey daemon, please set the configuration variable"
288 echo "\"honeyd_if\" in $RPM_INSTALL_PREFIX/etc/rc.conf to the name of the"
289 echo "used network interface."
290 ) | %{l_rpmtool} msg -b -t notice
291 fi
292 if [ $1 -eq 2 ]; then
293 # after upgrade, restore status
294 eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}
295 [ ".$honeyd_active" = .yes ] && %{l_rc} honeyd start
296 fi
297 exit 0
299 %preun
300 # before erase, stop service and remove log files
301 [ $1 -eq 0 ] || exit 0
302 %{l_rc} honeyd stop 2>/dev/null
303 rm -f $RPM_INSTALL_PREFIX/var/honeyd/*.log* >/dev/null 2>&1 || true
304 exit 0