sasl.spec 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. ##
  2. ## sasl.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2007 OpenPKG Foundation e.V. <http://openpkg.net/>
  4. ## Copyright (c) 2000-2007 Ralf S. Engelschall <http://engelschall.com/>
  5. ##
  6. ## Permission to use, copy, modify, and distribute this software for
  7. ## any purpose with or without fee is hereby granted, provided that
  8. ## the above copyright notice and this permission notice appear in all
  9. ## copies.
  10. ##
  11. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  12. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  13. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  14. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  15. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  16. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  17. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  18. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  19. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  20. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  21. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  22. ## SUCH DAMAGE.
  23. ##
  24. # package information
  25. Name: sasl
  26. Summary: Simple Authentication and Security Layer (SASL)
  27. URL: http://asg.web.cmu.edu/sasl/
  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.22
  35. Release: 20070505
  36. # package options
  37. %option with_fsl yes
  38. %option with_pam no
  39. %option with_login no
  40. %option with_ldap no
  41. %option with_mysql no
  42. %option with_pgsql no
  43. %option with_sqlite no
  44. %option with_ntlm no
  45. %option with_otp no
  46. %option with_gss no
  47. %option with_sasldb no
  48. # list of sources
  49. Source0: ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/cyrus-sasl-%{version}.tar.gz
  50. Source1: rc.sasl
  51. Source2: fsl.sasl
  52. Source3: saslauthd.conf
  53. Patch0: sasl.patch
  54. # build information
  55. Prefix: %{l_prefix}
  56. BuildRoot: %{l_buildroot}
  57. BuildPreReq: OpenPKG, openpkg >= 20060823, gcc, make, groff
  58. PreReq: OpenPKG, openpkg >= 20060823
  59. BuildPreReq: db >= 4.1.24, openssl
  60. PreReq: db >= 4.1.24, openssl
  61. %if "%{with_fsl}" == "yes"
  62. BuildPreReq: fsl >= 1.2.0
  63. PreReq: fsl >= 1.2.0
  64. %endif
  65. %if "%{with_pam}" == "yes"
  66. BuildPreReq: PAM
  67. PreReq: PAM
  68. %endif
  69. %if "%{with_ldap}" == "yes"
  70. BuildPreReq: openldap
  71. PreReq: openldap
  72. %endif
  73. %if "%{with_mysql}" == "yes"
  74. BuildPreReq: mysql
  75. PreReq: mysql
  76. %endif
  77. %if "%{with_pgsql}" == "yes"
  78. BuildPreReq: postgresql
  79. PreReq: postgresql
  80. %endif
  81. %if "%{with_sqlite}" == "yes"
  82. BuildPreReq: sqlite
  83. PreReq: sqlite
  84. %endif
  85. %if "%{with_otp}" == "yes"
  86. BuildPreReq: opie
  87. PreReq: opie
  88. %endif
  89. %if "%{with_gss}" == "yes"
  90. BuildPreReq: kerberos
  91. PreReq: kerberos
  92. %endif
  93. AutoReq: no
  94. AutoReqProv: no
  95. %description
  96. SASL is the Simple Authentication and Security Layer, a method
  97. for adding authentication support to connection-based protocols.
  98. To use SASL, a protocol includes a command for identifying and
  99. authenticating a user to a server and for optionally negotiating
  100. protection of subsequent protocol interactions. If its use is
  101. negotiated, a security layer is inserted between the protocol and
  102. the connection.
  103. %track
  104. prog sasl = {
  105. version = %{version}
  106. url = ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/
  107. regex = cyrus-sasl-(\d+\.\d+\.\d+)\.tar\.gz
  108. }
  109. %prep
  110. %setup -q -n cyrus-sasl-%{version}
  111. %patch -p0
  112. %build
  113. # disable some unwanted configure checks
  114. %{l_shtool} subst \
  115. -e 's;\(SASL_DB_UTILS="saslpasswd2 sasldblistusers2\);\1 dbconverter-2;' \
  116. -e "s;javac;javac-xxx;g" \
  117. -e "s;javah;javah-xxx;g" \
  118. -e "s;javadoc;javadoc-xxx;g" \
  119. configure
  120. # fix OpenLDAP support
  121. %if "%{with_ldap}" == "yes"
  122. echo 'ac_cv_lib_ldap_ldap_initialize=yes' >config.cache
  123. %{l_shtool} subst \
  124. -e "s;\(\$LDAP_LIBS\) *\(-lcrypto\);\1 -lssl -lcrypto \2;" \
  125. saslauthd/configure
  126. %endif
  127. # fix GSS/Kerberos support
  128. %if "%{with_gss}" == "yes"
  129. %{l_shtool} subst \
  130. -e 's;\(-lk5crypto\);\1 -lkrb5support;' \
  131. configure
  132. %endif
  133. # enforce disabled Kerberos 5 support in saslauthd
  134. echo 'ac_cv_header_krb5_h=no' >config.cache
  135. # configure path to sasl-server config files
  136. %{l_shtool} subst \
  137. -e 's;@l_sysconfdir@;%{l_prefix}/etc/sasl/apps;g' \
  138. lib/server.c
  139. # determine build flags
  140. cppflags="%{l_cppflags}"
  141. case "%{l_platform -t}" in
  142. sparc64-freebsd* ) cppflags="$cppflags -fPIC" ;;
  143. esac
  144. cflags="%{l_cflags -O} %{l_cppflags}"
  145. ldflags="%{l_ldflags} %{l_fsl_ldflags}"
  146. libs="-ldb %{l_fsl_libs}"
  147. %if "%{with_ldap}" == "yes"
  148. cflags="$cflags -DAUTH_LDAP"
  149. %endif
  150. %if "%{with_mysql}" == "yes"
  151. libs="$libs -lz -lm"
  152. %endif
  153. %if "%{with_gss}" == "yes"
  154. ldflags="$ldflags %{l_ldflags kerberos}"
  155. %endif
  156. case "%{l_platform -t}" in
  157. *-sunos* ) libs="$libs -lrt" ;;
  158. esac
  159. # configure package
  160. CC="%{l_cc}" \
  161. CFLAGS="$cflags" \
  162. CPPFLAGS="$cppflags" \
  163. LDFLAGS="$ldflags" \
  164. LIBS="$libs" \
  165. ./configure \
  166. --cache-file=./config.cache \
  167. --prefix=%{l_prefix} \
  168. --sysconfdir="%{l_prefix}/etc/sasl" \
  169. --with-plugindir=%{l_prefix}/lib/sasl \
  170. --with-saslauthd=%{l_prefix}/var/sasl/saslauthd \
  171. %if "%{with_sasldb}" == "yes"
  172. --enable-auth-sasldb \
  173. --with-dbpath=%{l_prefix}/var/sasl/sasldb \
  174. --with-dblib=berkeley \
  175. --with-bdb-incdir=%{l_prefix}/include \
  176. --with-bdb-libdir=%{l_prefix}/lib \
  177. %else
  178. --with-dblib=none \
  179. %endif
  180. --with-openssl=%{l_prefix} \
  181. %if "%{with_pam}" == "yes"
  182. --with-pam \
  183. %else
  184. --without-pam \
  185. %endif
  186. %if "%{with_login}" == "yes"
  187. --enable-login \
  188. %else
  189. --disable-login \
  190. %endif
  191. %if "%{with_ldap}" == "yes"
  192. --with-ldap=%{l_prefix} \
  193. %else
  194. --without-ldap \
  195. %endif
  196. %if "%{with_otp}" == "yes"
  197. --enable-otp \
  198. --with-opie=%{l_prefix} \
  199. %else
  200. --disable-otp \
  201. --without-opie \
  202. %endif
  203. %if "%{with_gss}" == "yes"
  204. --enable-gssapi \
  205. --with-gss_impl=mit \
  206. %else
  207. --disable-gssapi \
  208. --without-gss_impl \
  209. %endif
  210. %if "%{with_mysql}" == "yes" || "%{with_pgsql}" == "yes" || "%{with_pgsql}" == "yes" || "%{with_sqlite}" == "yes"
  211. --enable-sql \
  212. %if "%{with_mysql}" == "yes"
  213. --with-mysql=%{l_prefix} \
  214. %else
  215. --without-mysql \
  216. %endif
  217. %if "%{with_pgsql}" == "yes"
  218. --with-pgsql=%{l_prefix} \
  219. %else
  220. --without-pgsql \
  221. %endif
  222. %if "%{with_sqlite}" == "yes"
  223. --with-sqlite=%{l_prefix} \
  224. %else
  225. --without-sqlite \
  226. %endif
  227. %endif
  228. %if "%{with_ntlm}" == "yes"
  229. --enable-ntlm \
  230. %else
  231. --disable-ntlm \
  232. %endif
  233. --enable-shared \
  234. --enable-static \
  235. --enable-staticdlopen \
  236. --disable-java \
  237. --disable-sample \
  238. --disable-krb4 \
  239. --without-des
  240. # post adjustment: trust me, libtool, I know what I am doing
  241. %{l_shtool} subst \
  242. -e 's;^\(deplibs_check_method=\).*;\1"pass_all";' \
  243. -e 's/\(eval libobjs=.*$whole_archive_flag_spec.*\)$/case $archive_cmds in \\$LD* ) wl= ;; esac; \1/' \
  244. libtool
  245. # post adjustment: do not reference static plugins
  246. %{l_shtool} subst \
  247. -e '58s;.*;#define PIC;' \
  248. lib/dlopen.c
  249. # post adjustment: do not pull static plugins into static library
  250. %{l_shtool} subst \
  251. -e 's;-ln -s $(SASL_STATIC_SRCS) .;-ln ../sasldb/*.o ../plugins/*.o $(SASL_STATIC_SRCS) .;' \
  252. lib/Makefile
  253. # post adjustment: build utils against static library
  254. %{l_shtool} subst \
  255. -e 's;\(\$(CCLD)\);\1 -static;' \
  256. -e 's;\(noinst.*=\) *dbconverter.*;\1;' \
  257. utils/Makefile \
  258. sample/Makefile
  259. # post adjustment: fix OpenLDAP support
  260. %if "%{with_ldap}" == "yes"
  261. %{l_shtool} subst \
  262. -e "s;^\(saslauthd_LDADD[ ]*=[ ]*[^\\]*\);\1 -lcrypt -lldap -llber -lssl -lcrypto ;" \
  263. saslauthd/Makefile
  264. %endif
  265. # build package
  266. %{l_make} %{l_mflags}
  267. cd saslauthd
  268. %{l_make} %{l_mflags} testsaslauthd
  269. %install
  270. rm -rf $RPM_BUILD_ROOT
  271. # install package
  272. %{l_make} %{l_mflags} install AM_MAKEFLAGS="DESTDIR=$RPM_BUILD_ROOT"
  273. # remove libtool cruft
  274. rm -f \
  275. $RPM_BUILD_ROOT%{l_prefix}/lib/*.la \
  276. $RPM_BUILD_ROOT%{l_prefix}/lib/*.s[ol] \
  277. $RPM_BUILD_ROOT%{l_prefix}/lib/*.s[ol].* \
  278. $RPM_BUILD_ROOT%{l_prefix}/lib/sasl2/*.la \
  279. $RPM_BUILD_ROOT%{l_prefix}/lib/sasl2/*.a
  280. # post-adjust installation
  281. mv $RPM_BUILD_ROOT%{l_prefix}/lib/sasl2 \
  282. $RPM_BUILD_ROOT%{l_prefix}/lib/sasl
  283. strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true
  284. # install saslauthd test program
  285. %{l_shtool} mkdir -f -p -m 755 \
  286. $RPM_BUILD_ROOT%{l_prefix}/sbin
  287. %{l_shtool} install -c -m 755 \
  288. saslauthd/testsaslauthd \
  289. $RPM_BUILD_ROOT%{l_prefix}/sbin/
  290. # install saslauthd default configuration
  291. %{l_shtool} mkdir -f -p -m 755 \
  292. $RPM_BUILD_ROOT%{l_prefix}/etc/sasl
  293. %{l_shtool} install -c -m 755 \
  294. %{SOURCE saslauthd.conf} \
  295. $RPM_BUILD_ROOT%{l_prefix}/etc/sasl/
  296. # install missing manual pages
  297. %{l_shtool} mkdir -f -p -m 755 \
  298. $RPM_BUILD_ROOT%{l_prefix}/man/man8
  299. %{l_shtool} install -c -m 644 \
  300. utils/saslpasswd2.8 \
  301. utils/sasldblistusers2.8 \
  302. $RPM_BUILD_ROOT%{l_prefix}/man/man8/
  303. # create necessary additional directories
  304. %{l_shtool} mkdir -f -p -m 755 \
  305. $RPM_BUILD_ROOT%{l_prefix}/var/sasl/log \
  306. $RPM_BUILD_ROOT%{l_prefix}/var/sasl/saslauthd \
  307. $RPM_BUILD_ROOT%{l_prefix}/etc/sasl/apps
  308. # install run-command script
  309. %if "%{with_pam}" == "yes"
  310. l_authmech="pam"
  311. %else
  312. case "%{l_platform -t}" in
  313. *-linux* | *-sunos* ) l_authmech="shadow" ;;
  314. * ) l_authmech="getpwent" ;;
  315. esac
  316. %endif
  317. %{l_shtool} mkdir -f -p -m 755 \
  318. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  319. %{l_shtool} install -c -m 755 \
  320. -e "s;@l_authmech@;${l_authmech};g" %{l_value -s -a} \
  321. %{SOURCE rc.sasl} \
  322. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  323. # install OSSP fsl configuration
  324. %{l_shtool} mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/etc/fsl
  325. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  326. %{SOURCE fsl.sasl} \
  327. $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/
  328. # determine installation files
  329. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  330. %{l_files_std} \
  331. '%not %dir %{l_prefix}/etc/fsl' \
  332. '%config %{l_prefix}/etc/fsl/fsl.sasl' \
  333. '%config %{l_prefix}/etc/sasl/saslauthd.conf' \
  334. '%dir %attr(0750,%{l_musr},%{l_rgrp}) %{l_prefix}/var/sasl' \
  335. '%dir %attr(0750,%{l_musr},%{l_rgrp}) %{l_prefix}/var/sasl/saslauthd' \
  336. '%dir %attr(0700,%{l_susr},%{l_sgrp}) %{l_prefix}/var/sasl/log'
  337. %files -f files
  338. %clean
  339. rm -rf $RPM_BUILD_ROOT
  340. %pre
  341. # before upgrade, save status and stop service
  342. [ $1 -eq 2 ] || exit 0
  343. eval `%{l_rc} sasl status 2>/dev/null | tee %{l_tmpfile}`
  344. %{l_rc} sasl stop 2>/dev/null
  345. exit 0
  346. %post
  347. %if "%{with_pam}" == "yes"
  348. if [ $1 -eq 1 ]; then
  349. # after install, add PAM configuration entry
  350. $RPM_INSTALL_PREFIX/sbin/pamtool --add --smart --name=sasl
  351. fi
  352. %endif
  353. if [ $1 -eq 2 ]; then
  354. # after upgrade, restore status
  355. eval `cat %{l_tmpfile}`; rm -f %{l_tmpfile}
  356. [ ".$sasl_active" = .yes ] && %{l_rc} sasl start
  357. fi
  358. exit 0
  359. %preun
  360. # before erase, stop service and remove log files
  361. [ $1 -eq 0 ] || exit 0
  362. %{l_rc} sasl stop 2>/dev/null
  363. rm -f $RPM_INSTALL_PREFIX/var/sasl/log/*.log* >/dev/null 2>&1 || true
  364. %if "%{with_pam}" == "yes"
  365. # remove PAM configuration entry
  366. $RPM_INSTALL_PREFIX/sbin/pamtool --remove --smart --name=sasl
  367. %endif
  368. exit 0