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 ## sasl.spec -- OpenPKG RPM Package Specification
3 ## Copyright (c) 2000-2010 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 information
25 Name: sasl
26 Summary: Simple Authentication and Security Layer (SASL)
27 URL: http://www.cyrusimap.org/
28 Vendor: Cyrus Project, CMU
29 Packager: OpenPKG Foundation e.V.
30 Distribution: OpenPKG Community
31 Class: BASE
32 Group: Cryptography
33 License: BSD
34 Version: 2.1.25
35 Release: 20120800
37 # package options
38 %option with_fsl yes
39 %option with_sasldb yes
40 %option with_pam no
41 %option with_login no
42 %option with_ldap no
43 %option with_mysql no
44 %option with_pgsql no
45 %option with_sqlite no
46 %option with_ntlm no
47 %option with_otp no
48 %option with_srp no
49 %option with_kerberos no
51 # list of sources
52 Source0: ftp://ftp.cyrusimap.org/cyrus-sasl/cyrus-sasl-%{version}.tar.gz
53 Source1: rc.sasl
54 Source2: fsl.sasl
55 Source3: saslauthd.conf
56 Source4: sasl.pc
57 Patch0: sasl.patch
59 # build information
60 BuildPreReq: OpenPKG, openpkg >= 20100101, gcc, make, groff
61 PreReq: OpenPKG, openpkg >= 20100101
62 BuildPreReq: db >= 4.1.24, openssl
63 PreReq: db >= 4.1.24, openssl
64 %if "%{with_fsl}" == "yes"
65 BuildPreReq: fsl
66 PreReq: fsl
67 %endif
68 %if "%{with_pam}" == "yes"
69 BuildPreReq: PAM
70 PreReq: PAM
71 %endif
72 %if "%{with_ldap}" == "yes"
73 BuildPreReq: openldap
74 PreReq: openldap
75 %endif
76 %if "%{with_mysql}" == "yes"
77 BuildPreReq: mysql
78 PreReq: mysql
79 %endif
80 %if "%{with_pgsql}" == "yes"
81 BuildPreReq: postgresql
82 PreReq: postgresql
83 %endif
84 %if "%{with_sqlite}" == "yes"
85 BuildPreReq: sqlite
86 PreReq: sqlite
87 %endif
88 %if "%{with_otp}" == "yes"
89 BuildPreReq: opie
90 PreReq: opie
91 %endif
92 %if "%{with_kerberos}" == "yes"
93 BuildPreReq: KERBEROS
94 PreReq: KERBEROS
95 %endif
97 %description
98 SASL is the Simple Authentication and Security Layer, a method
99 for adding authentication support to connection-based protocols.
100 To use SASL, a protocol includes a command for identifying and
101 authenticating a user to a server and for optionally negotiating
102 protection of subsequent protocol interactions. If its use is
103 negotiated, a security layer is inserted between the protocol and
104 the connection.
106 %track
107 prog sasl = {
108 version = %{version}
109 url = ftp://ftp.cyrusimap.org/cyrus-sasl/
110 regex = cyrus-sasl-(\d+\.\d+\.\d+)\.tar\.gz
111 }
113 %prep
114 %setup -q -n cyrus-sasl-%{version}
115 %{l_shtool} subst \
116 -e 's;u_int\([0-9]*\)_t;uint\1_t;g' \
117 sasldb/db_berkeley.c
118 %{l_shtool} subst \
119 -e 's;extern int gethostname(char \*,\) int;\1 size_t;' \
120 lib/saslutil.c
121 %patch -p0
123 %build
124 # ensure the OpenPKG Berkeley-DB is picked up only
125 %{l_shtool} subst \
126 -e 's;for dbname in db-.*db$;for dbname in db;' \
127 saslauthd/configure configure
129 # disable some unwanted configure checks
130 %{l_shtool} subst \
131 -e 's;\(SASL_DB_UTILS="saslpasswd2 sasldblistusers2\);\1 dbconverter-2;' \
132 -e "s;javac;javac-xxx;g" \
133 -e "s;javah;javah-xxx;g" \
134 -e "s;javadoc;javadoc-xxx;g" \
135 configure
137 # fix OpenLDAP support
138 %if "%{with_ldap}" == "yes"
139 echo 'ac_cv_lib_ldap_ldap_initialize=yes' >config.cache
140 %{l_shtool} subst \
141 -e "s;\(\$LDAP_LIBS\) *\(-lcrypto\);\1 -lssl -lcrypto \2;" \
142 saslauthd/configure
143 %endif
145 # fix GSS/Kerberos support
146 %if "%{with_kerberos}" == "yes"
147 %{l_shtool} subst \
148 -e 's;\(-lk5crypto\);\1 -lkrb5support;' \
149 configure
150 %endif
152 # enforce disabled Kerberos 5 support in saslauthd
153 echo 'ac_cv_header_krb5_h=no' >config.cache
155 # configure path to sasl-server config files
156 %{l_shtool} subst \
157 -e 's;@l_sysconfdir@;%{l_prefix}/etc/sasl/sasl.d;g' \
158 lib/server.c
160 # determine build flags
161 cflags="%{l_cflags -O} %{l_cppflags}"
162 ldflags="%{l_ldflags} %{l_fsl_ldflags}"
163 libs="-ldb %{l_fsl_libs}"
164 %if "%{with_ldap}" == "yes"
165 cflags="$cflags -DAUTH_LDAP"
166 %endif
167 %if "%{with_mysql}" == "yes"
168 libs="$libs -lz -lm"
169 %endif
170 %if "%{with_pgsql}" == "yes"
171 cflags="$cflags -I%{l_cppflags postgresql}"
172 libs="$libs -lssl -lcrypto -lcrypt"
173 %endif
174 %if "%{with_kerberos}" == "yes"
175 cflags="$cflags `krb5-config --cflags gssapi`"
176 libs="$libs `krb5-config --libs gssapi`"
177 %endif
178 case "%{l_platform -t}" in
179 *-sunos* ) libs="$libs -lrt" ;;
180 esac
182 # configure package
183 CC="%{l_cc}" \
184 CFLAGS="$cflags" \
185 CPPFLAGS="%{l_cppflags}" \
186 LDFLAGS="$ldflags" \
187 LIBS="$libs" \
188 ./configure \
189 --cache-file=./config.cache \
190 --prefix=%{l_prefix} \
191 --sysconfdir=%{l_prefix}/etc/sasl \
192 --with-configdir=%{l_prefix}/etc/sasl/sasl.d \
193 --with-plugindir=%{l_prefix}/lib/sasl \
194 --with-saslauthd=%{l_prefix}/var/sasl/run/saslauthd \
195 --enable-digest \
196 --enable-cram \
197 --enable-anon \
198 %if "%{with_sasldb}" == "yes"
199 --enable-auth-sasldb \
200 --with-dbpath=%{l_prefix}/var/sasl/run/sasl.db \
201 --with-dblib=berkeley \
202 --with-bdb-incdir=%{l_prefix}/include \
203 --with-bdb-libdir=%{l_prefix}/lib \
204 %else
205 --with-dblib=none \
206 %endif
207 --with-openssl=%{l_prefix} \
208 %if "%{with_pam}" == "yes"
209 --with-pam \
210 %else
211 --without-pam \
212 %endif
213 %if "%{with_login}" == "yes"
214 --enable-login \
215 %else
216 --disable-login \
217 %endif
218 %if "%{with_ldap}" == "yes"
219 --with-ldap=%{l_prefix} \
220 %else
221 --without-ldap \
222 %endif
223 %if "%{with_otp}" == "yes"
224 --enable-otp \
225 --with-opie=%{l_prefix} \
226 %else
227 --disable-otp \
228 --without-opie \
229 %endif
230 %if "%{with_srp}" == "yes"
231 --enable-srp \
232 %else
233 --disable-srp \
234 %endif
235 %if "%{with_kerberos}" == "yes"
236 --enable-gssapi \
237 --with-gss_impl=`if [ -d %{l_prefix}/include/heimdal ]; then echo "heimdal"; else echo "mit"; fi` \
238 %else
239 --disable-gssapi \
240 --without-gss_impl \
241 %endif
242 %if "%{with_mysql}" == "yes" || "%{with_pgsql}" == "yes" || "%{with_sqlite}" == "yes"
243 --enable-sql \
244 %if "%{with_mysql}" == "yes"
245 --with-mysql=%{l_prefix} \
246 %else
247 --without-mysql \
248 %endif
249 %if "%{with_pgsql}" == "yes"
250 --with-pgsql=%{l_prefix} \
251 %else
252 --without-pgsql \
253 %endif
254 %if "%{with_sqlite}" == "yes"
255 --with-sqlite=%{l_prefix} \
256 %else
257 --without-sqlite \
258 %endif
259 %endif
260 %if "%{with_ntlm}" == "yes"
261 --enable-ntlm \
262 %else
263 --disable-ntlm \
264 %endif
265 --enable-shared \
266 --enable-static \
267 --enable-staticdlopen \
268 --enable-sample \
269 --disable-java \
270 --disable-krb4 \
271 --without-des
273 # post adjustment: trust me, libtool, I know what I am doing
274 %{l_shtool} subst \
275 -e 's;^\(deplibs_check_method=\).*;\1"pass_all";' \
276 -e 's/\(eval libobjs=.*$whole_archive_flag_spec.*\)$/case $archive_cmds in \\$LD* ) wl= ;; esac; \1/' \
277 libtool
279 # post adjustment: do not reference static plugins
280 %{l_shtool} subst \
281 -e '58s;.*;#define PIC;' \
282 lib/dlopen.c
284 # post adjustment: do not pull static plugins into static library
285 %{l_shtool} subst \
286 -e 's;-ln -s $(SASL_STATIC_SRCS) .;-ln ../sasldb/*.o ../plugins/*.o $(SASL_STATIC_SRCS) .;' \
287 lib/Makefile
289 # post adjustment: build utils against static library
290 %{l_shtool} subst \
291 -e 's;\(\$(CCLD)\);\1 -static;' \
292 -e 's;\(noinst.*=\) *dbconverter.*;\1;' \
293 utils/Makefile \
294 sample/Makefile
296 # post adjustment: fix OpenLDAP support
297 %if "%{with_ldap}" == "yes"
298 %{l_shtool} subst \
299 -e "s;^\(saslauthd_LDADD[ ]*=[ ]*[^\\]*\);\1 -lcrypt -lldap -llber -lssl -lcrypto ;" \
300 saslauthd/Makefile
301 %endif
303 # build package
304 %{l_make} %{l_mflags -O}
305 ( cd saslauthd
306 %{l_make} %{l_mflags -O} testsaslauthd
307 ) || exit $?
308 ( cd sample
309 %{l_make} %{l_mflags -O} sample-client sample-server
310 ) || exit $?
312 %install
313 # install package
314 %{l_make} %{l_mflags} install DESTDIR="$RPM_BUILD_ROOT"
316 # remove libtool cruft
317 rm -f \
318 $RPM_BUILD_ROOT%{l_prefix}/lib/*.la \
319 $RPM_BUILD_ROOT%{l_prefix}/lib/*.s[ol] \
320 $RPM_BUILD_ROOT%{l_prefix}/lib/*.s[ol].* \
321 $RPM_BUILD_ROOT%{l_prefix}/lib/sasl2/*.a
323 # post-adjust installation
324 mv $RPM_BUILD_ROOT%{l_prefix}/lib/sasl2 \
325 $RPM_BUILD_ROOT%{l_prefix}/lib/sasl
326 mv $RPM_BUILD_ROOT%{l_prefix}/sbin/testsaslauthd \
327 $RPM_BUILD_ROOT%{l_prefix}/sbin/saslauthd-test
328 mv $RPM_BUILD_ROOT%{l_prefix}/sbin/pluginviewer \
329 $RPM_BUILD_ROOT%{l_prefix}/sbin/sasl-pluginviewer
330 mv $RPM_BUILD_ROOT%{l_prefix}/man/man8/pluginviewer.8 \
331 $RPM_BUILD_ROOT%{l_prefix}/man/man8/sasl-pluginviewer.8
332 mv $RPM_BUILD_ROOT%{l_prefix}/sbin/saslpasswd2 \
333 $RPM_BUILD_ROOT%{l_prefix}/sbin/saslpasswd
334 mv $RPM_BUILD_ROOT%{l_prefix}/man/man8/saslpasswd2.8 \
335 $RPM_BUILD_ROOT%{l_prefix}/man/man8/saslpasswd.8
336 mv $RPM_BUILD_ROOT%{l_prefix}/sbin/sasldblistusers2 \
337 $RPM_BUILD_ROOT%{l_prefix}/sbin/sasldblistusers
338 mv $RPM_BUILD_ROOT%{l_prefix}/man/man8/sasldblistusers2.8 \
339 $RPM_BUILD_ROOT%{l_prefix}/man/man8/sasldblistusers.8
340 rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/dbconverter-2
341 strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
343 # install sample client/server programs
344 %{l_shtool} install -c -m 755 \
345 sample/sample-client \
346 $RPM_BUILD_ROOT%{l_prefix}/sbin/sasl-sample-client
347 %{l_shtool} install -c -m 755 \
348 sample/sample-server \
349 $RPM_BUILD_ROOT%{l_prefix}/sbin/sasl-sample-server
351 # install saslauthd default configuration
352 %{l_shtool} mkdir -f -p -m 755 \
353 $RPM_BUILD_ROOT%{l_prefix}/etc/sasl
354 %{l_shtool} install -c -m 755 \
355 %{SOURCE saslauthd.conf} \
356 $RPM_BUILD_ROOT%{l_prefix}/etc/sasl/
358 # create necessary additional directories
359 %{l_shtool} mkdir -f -p -m 755 \
360 $RPM_BUILD_ROOT%{l_prefix}/var/sasl/log \
361 $RPM_BUILD_ROOT%{l_prefix}/var/sasl/run/saslauthd \
362 $RPM_BUILD_ROOT%{l_prefix}/etc/sasl/sasl.d
364 # install run-command script
365 %if "%{with_pam}" == "yes"
366 l_authmech="pam"
367 %else
368 case "%{l_platform -t}" in
369 *-linux* | *-sunos* ) l_authmech="shadow" ;;
370 * ) l_authmech="getpwent" ;;
371 esac
372 %endif
373 %{l_shtool} mkdir -f -p -m 755 \
374 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
375 %{l_shtool} install -c -m 755 \
376 -e "s;@l_authmech@;${l_authmech};g" %{l_value -s -a} \
377 %{SOURCE rc.sasl} \
378 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
380 # install OSSP fsl configuration
381 %{l_shtool} mkdir -f -p -m 755 \
382 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
383 %{l_shtool} install -c -m 644 %{l_value -s -a} \
384 %{SOURCE fsl.sasl} \
385 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
387 # install pkg-config configuration
388 libs="-lsasl2"
389 case "%{l_platform -t}" in
390 *-linux* ) libs="$libs -ldl" ;;
391 esac
392 %{l_shtool} mkdir -f -p -m 755 \
393 $RPM_BUILD_ROOT%{l_prefix}/lib/pkgconfig
394 %{l_shtool} install -c -m 644 %{l_value -s -a} \
395 -e "s;@version@;%{version};" \
396 -e "s;@libs@;$libs;" \
397 %{SOURCE sasl.pc} \
398 $RPM_BUILD_ROOT%{l_prefix}/lib/pkgconfig/
400 # determine installation files
401 %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
402 %{l_files_std} \
403 '%config %{l_prefix}/etc/fsl/fsl.sasl' \
404 '%config %{l_prefix}/etc/sasl/saslauthd.conf' \
405 '%dir %attr(0755,%{l_musr},%{l_rgrp}) %{l_prefix}/var/sasl' \
406 '%dir %attr(0755,%{l_musr},%{l_rgrp}) %{l_prefix}/var/sasl/run' \
407 '%dir %attr(0755,%{l_musr},%{l_rgrp}) %{l_prefix}/var/sasl/run/saslauthd' \
408 '%dir %attr(0700,%{l_susr},%{l_sgrp}) %{l_prefix}/var/sasl/log'
410 %files -f files
412 %clean
414 %pre
415 # before upgrade, save status and stop service
416 [ $1 -eq 2 ] || exit 0
417 eval `%{l_rc} sasl status 2>/dev/null | tee %{l_tmpfile}`
418 %{l_rc} sasl stop 2>/dev/null
419 exit 0
421 %post
422 %if "%{with_pam}" == "yes"
423 if [ $1 -eq 1 ]; then
424 # after install, add PAM configuration entry
425 $RPM_INSTALL_PREFIX/sbin/pamtool --add --smart --name=sasl
426 fi
427 %endif
428 if [ $1 -eq 2 ]; then
429 # after upgrade, restore status
430 eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}
431 [ ".$sasl_active" = .yes ] && %{l_rc} sasl start
432 fi
433 exit 0
435 %preun
436 # before erase, stop service and remove log files
437 [ $1 -eq 0 ] || exit 0
438 %{l_rc} sasl stop 2>/dev/null
439 rm -f $RPM_INSTALL_PREFIX/var/sasl/log/*.log* >/dev/null 2>&1 || true
440 %if "%{with_pam}" == "yes"
441 # remove PAM configuration entry
442 $RPM_INSTALL_PREFIX/sbin/pamtool --remove --smart --name=sasl
443 %endif
444 exit 0