%define cs1_version 1.5.28
%define _plugindir %{_libdir}/sasl
%define _plugindir2 %{_libdir}/sasl2

Summary: The Cyrus SASL library.
Name: cyrus-sasl
Version: 2.1.10
Release: 4
License: Freely Distributable
Group: System Environment/Libraries
Source0: ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/cyrus-sasl-%{version}.tar.gz
Source1: ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/cyrus-sasl-%{version}.tar.gz.sig
Source2: ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/cyrus-sasl-%{cs1_version}.tar.gz
Source3: ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/cyrus-sasl-%{cs1_version}.tar.gz.sig
Source4: saslauthd.init
URL: http://asg.web.cmu.edu/sasl/sasl-library.html
Patch0: cyrus-sasl-1.5.24-rpath.patch
Patch1: cyrus-sasl-2.1.7-gdbm.patch
Patch2: cyrus-sasl-2.1.10-des.patch
Buildroot: %{_tmppath}/%{name}-root
BuildPrereq: autoconf213, automake15, libtool
# Note: berkeley db for sasl2, gdbm for sasl1.
BuildPrereq: db4-devel, gdbm-devel, krb5-devel, openssl-devel, pam-devel
BuildPrereq: pkgconfig
Prereq: /sbin/ldconfig, chkconfig, /sbin/service

The %{name} package contains the Cyrus implementation of SASL.
SASL is the Simple Authentication and Security Layer, a method for
adding authentication support to connection-based protocols.

%package devel
Requires: %{name} = %{version}-%{release}
Group: Development/Libraries
Summary: Files needed for developing applications with Cyrus SASL.

%description devel
The %{name}-devel package contains files needed for developing and
compiling applications which use the Cyrus SASL library.

%package gssapi
Requires: %{name} = %{version}-%{release}
Group: System Environment/Libraries
Summary: GSSAPI support for Cyrus SASL.

%description gssapi
The %{name}-gssapi package contains the Cyrus SASL plugins which
support GSSAPI authentication. GSSAPI is commonly used for Kerberos

%package plain
Requires: %{name} = %{version}-%{release}
Group: System Environment/Libraries
Summary: PLAIN and LOGIN support for Cyrus SASL.

%description plain
The %{name}-plain package contains the Cyrus SASL plugins which support
PLAIN and LOGIN authentication schemes.

%package md5
Requires: %{name} = %{version}-%{release}
Group: System Environment/Libraries
Summary: CRAM-MD5 and DIGEST-MD5 support for Cyrus SASL.

%description md5
The %{name}-md5 package contains the Cyrus SASL plugins which support
CRAM-MD5 and DIGEST-MD5 authentication schemes.

%setup -q -c -a 2
pushd cyrus-sasl-%{cs1_version}
%patch0 -p1 -b .rpath
libtoolize -f
aclocal-1.5 -I ./config -I ./cmulocal
automake-1.5 -a

pushd cyrus-sasl-%{version}
%patch1 -p1 -b .gdbm
%patch2 -p1 -b .des
libtoolize -f
aclocal-1.5 -I ./config -I ./cmulocal
automake-1.5 -a --include-deps

pushd saslauthd
libtoolize -f
aclocal-1.5 -I ../config -I ../cmulocal
automake-1.5 -a --include-deps

# Sort of merge the docs.
mkdir cyrus-sasl-%{version}/%{cs1_version}
mkdir cyrus-sasl-%{version}/%{cs1_version}-devel
cp %{name}-%{cs1_version}/{AUTHORS,COPYING,NEWS,README,doc/*.html} cyrus-sasl-%{version}/%{cs1_version}
cp %{name}-%{cs1_version}/doc/*.txt cyrus-sasl-%{version}/%{cs1_version}-devel
# Remove duplicate RFCs.
pushd cyrus-sasl-%{version}/%{cs1_version}-devel
for file in * ; do
        if [ -f ../doc/${file} ] ; then
                rm -f ${file}

CPPFLAGS="-I%{_prefix}/kerberos/include $CPPFLAGS"; export CPPFLAGS
LDFLAGS="-L%{_prefix}/kerberos/%{_lib} $LDFLAGS"; export LDFLAGS

pushd cyrus-sasl-%{cs1_version}
%configure \
        --enable-static --with-pic --enable-shared \
        --with-plugindir=%{_plugindir} \
        --disable-krb4 \
        --enable-gssapi=/usr/kerberos \
        --with-rc4 \
        --with-dblib=gdbm \
        --enable-anon \
        --enable-cram \
        --enable-digest \
        --enable-plain \
make sasldir=%{_plugindir}

pushd cyrus-sasl-%{version}
LIBS=-lcrypt; export LIBS
%configure \
        --enable-static --with-pic --enable-shared --disable-java \
        --with-plugindir=%{_plugindir2} \
        --disable-krb4 \
        --enable-gssapi=/usr/kerberos \
        --with-rc4 \
        --with-dblib=berkeley \
        --with-saslauthd=/var/run/saslauthd --without-pwcheck \
        --enable-anon \
        --enable-cram \
        --enable-digest \
        --enable-plain \
        # --enable-auth-sasldb -- EXPERIMENTAL
make -C sasldb allockey.o allockey.lo db_berkeley.o db_berkeley.lo sasldir=%{_plugindir2}
make JAV= sasldir=%{_plugindir2}

pushd cyrus-sasl-%{cs1_version}
%makeinstall sasldir=$RPM_BUILD_ROOT/%{_plugindir}
install -m755 -d $RPM_BUILD_ROOT%{_bindir}
libtool --mode=install \
install -m755 sample/client $RPM_BUILD_ROOT%{_bindir}/sasl-sample-client
libtool --mode=install \
install -m755 sample/server $RPM_BUILD_ROOT%{_bindir}/sasl-sample-server

pushd cyrus-sasl-%{version}
%makeinstall JAV= sasldir=$RPM_BUILD_ROOT/%{_plugindir2}
install -m755 -d $RPM_BUILD_ROOT%{_bindir}

libtool --mode=install \
install -m755 sample/client $RPM_BUILD_ROOT%{_bindir}/sasl2-sample-client
libtool --mode=install \
install -m755 sample/server $RPM_BUILD_ROOT%{_bindir}/sasl2-sample-server
libtool --mode=install \
install -m755 utils/dbconverter-2 $RPM_BUILD_ROOT%{_sbindir}/dbconverter-2

# Install the saslauthd man page in the expected location, even if it's
# pre-formatted.
install -m755 -d $RPM_BUILD_ROOT%{_mandir}/man8/
install -m644 saslauthd/*.8 $RPM_BUILD_ROOT%{_mandir}/man8/

# Create the saslauthd listening directory.
install -m755 -d $RPM_BUILD_ROOT/var/run/saslauthd
install -m755 -d $RPM_BUILD_ROOT/etc/rc.d/init.d
install -m755 $RPM_SOURCE_DIR/saslauthd.init $RPM_BUILD_ROOT/etc/rc.d/init.d/saslauthd

# Remove unpackaged files from the buildroot.
rm -f $RPM_BUILD_ROOT%{_libdir}/sasl2/libotp.*
rm -f $RPM_BUILD_ROOT%{_mandir}/cat8/saslauthd.8


/sbin/chkconfig --add saslauthd

if [ $1 = 0 ] ; then
        /sbin/chkconfig --del saslauthd

if [ $1 != 0 ] ; then
        /sbin/service saslauthd condrestart 2>&1 > /dev/null

%doc %{name}-%{version}/%{cs1_version}
%doc %{name}-%{version}/{AUTHORS,COPYING,NEWS,README,doc/*.html}
%dir %{_plugindir}/
%dir %{_plugindir2}/
%config /etc/rc.d/init.d/saslauthd

%files plain

%files md5

%files gssapi

%files devel
%doc %{name}-%{version}/%{cs1_version}-devel
%doc %{name}-%{version}/doc/*.txt

* Wed Jan 22 2003 Tim Powers <timp@redhat.com>
- rebuilt

* Tue Jan  7 2003 Nalin Dahyabhai <nalin@redhat.com> 2.1.10-3
- rebuild

* Thu Dec 12 2002 Nalin Dahyabhai <nalin@redhat.com>
- consider either des_cbc_encrypt or DES_cbc_encrypt to be sufficient when
  searching for a DES implementation in libcrypto
- pull in CPPFLAGS and LDFLAGS from openssl's pkg-config data, if it exists

* Mon Dec  9 2002 Nalin Dahyabhai <nalin@redhat.com> 2.1.10-2
- rebuild

* Mon Dec  9 2002 Nalin Dahyabhai <nalin@redhat.com> 2.1.10-1
- update to 2.1.10, fixing buffer overflows in libsasl2 noted by Timo Sirainen

* Tue Nov 12 2002 Tim Powers <timp@redhat.com> 2.1.7-5
- remove files from $RPM_BUILD_ROOT that we don't intend to include

* Tue Oct  9 2002 Nalin Dahyabhai <nalin@redhat.com> 2.1.7-4
- update to SASLv1 to final 1.5.28

* Fri Sep 13 2002 Nalin Dahyabhai <nalin@redhat.com> 2.1.7-3
- rebuild, overriding sasldir when running make so that on multilib systems
  applications will be able to load modules for the right arch

* Mon Sep  2 2002 Nalin Dahyabhai <nalin@redhat.com> 2.1.7-2
- include dbconverter-2 (#68741)

* Fri Aug  9 2002 Nalin Dahyabhai <nalin@redhat.com> 2.1.7-1
- update to 2.1.7, fixing a race condition in digest-md5

* Wed Jul 17 2002 Nalin Dahyabhai <nalin@redhat.com> 2.1.6-1
- update to 2.1.6 and 1.5.28

* Fri Jun 21 2002 Tim Powers <timp@redhat.com>
- automated rebuild

* Thu Jun 13 2002 Nalin Dahyabhai <nalin@redhat.com> 2.1.5-1
- update to 2.1.5

* Mon Jun 10 2002 Nalin Dahyabhai <nalin@redhat.com> 2.1.4-1
- update to 2.1.4

* Sun May 26 2002 Tim Powers <timp@redhat.com>
- automated rebuild

* Thu May 16 2002 Nalin Dahyabhai <nalin@redhat.com> 2.1.2-1
- modify to build with db 4.x

* Thu Apr 18 2002 Nalin Dahyabhai <nalin@redhat.com>
- update cyrus-sasl 2 to 2.1.2
- change buildreq to db3-devel

* Tue Feb 12 2002 Nalin Dahyabhai <nalin@redhat.com> 2.1.1-3
- suppress output to stdout/stderr in %%postun

* Sun Feb 10 2002 Nalin Dahyabhai <nalin@redhat.com> 2.1.1-2
- configure sasldb2 to use berkeley DB instead of gdbm

* Wed Feb  6 2002 Nalin Dahyabhai <nalin@redhat.com> 2.1.1-1
- update to 2.1.1

* Thu Jan 31 2002 Nalin Dahyabhai <nalin@redhat.com> 2.1.0-1
- marge 1.5.24 back in, making a note that it should be removed at some
  point in the future

* Wed Jan 30 2002 Nalin Dahyabhai <nalin@redhat.com>
- update to 2.1.0, which is designed to be installed in parallel with cyrus sasl
  1.x, so fork the package and rename it to cyrus-sasl2
- add the sasldb auxprop plugin to the main package
- add disabled-by-default saslauthd init script
- move the .la files for plugins into their respective packages -- they're
  needed by the library

* Wed Jan 23 2002 Nalin Dahyabhai <nalin@redhat.com> 1.5.24-24
- free ride through the build system

* Fri Nov  2 2001 Nalin Dahyabhai <nalin@redhat.com> 1.5.24-23
- patch to fix possible syslog format-string vulnerability

* Mon Oct 29 2001 Nalin Dahyabhai <nalin@redhat.com> 1.5.24-22
- add pam-devel as a buildprereq

* Wed Aug 29 2001 Nalin Dahyabhai <nalin@redhat.com> 1.5.24-21
- include sample programs in the -devel subpackage, prefixing their names
  with "sasl-" to reduce future potential naming conflicts

* Tue Aug 14 2001 Nalin Dahyabhai <nalin@redhat.com> 1.5.24-20
- build without -ggdb

* Fri Aug  3 2001 Nalin Dahyabhai <nalin@redhat.com>
- add gdbm-devel as a build dependency (#44990)
- split off CRAM-MD5 and DIGEST-MD5 into a subpackage of their own (#43079,
  and dialogs with David L. Parsley)

* Fri Apr 27 2001 Nalin Dahyabhai <nalin@redhat.com>
- split out the PLAIN and LOGIN mechanisms into their own package (this allows
  an administrator to disable them by simply removing the package)

* Fri Jan 19 2001 Nalin Dahyabhai <nalin@redhat.com>
- rebuild in new environment

* Wed Dec  6 2000 Nalin Dahyabhai <nalin@redhat.com>
- fix gssapi-over-tls

* Fri Oct 27 2000 Nalin Dahyabhai <nalin@redhat.com>
- enable static libraries, but always build with -fPIC

* Wed Oct 25 2000 Nalin Dahyabhai <nalin@redhat.com>
- make sure the version of 1.5.24 in the package matches the masters (#18968)

* Mon Oct  9 2000 Nalin Dahyabhai <nalin@redhat.com>
- re-add the libsasl.so symlink to the -devel package (oops)

* Fri Oct  6 2000 Nalin Dahyabhai <nalin@redhat.com>
- move .so files for modules to their respective packages -- they're not -devel
  links meant for use by ld anyway

* Thu Oct  5 2000 Nalin Dahyabhai <nalin@redhat.com>
- split off -devel subpackage
- add a -gssapi subpackage for the gssapi plugins

* Wed Aug 16 2000 Nalin Dahyabhai <nalin@redhat.com>
- fix the summary text

* Sun Aug 13 2000 Nalin Dahyabhai <nalin@redhat.com>
- re-enable arcfour and CRAM

* Fri Aug  4 2000 Nalin Dahyabhai <nalin@redhat.com>
- force use of gdbm for database files to avoid DB migration weirdness
- enable login mechanism
- disable gssapi until it can coexist peacefully with non-gssapi setups
- actually do a make in the build section (#15410)

* Fri Jul 21 2000 Nalin Dahyabhai <nalin@redhat.com>
- update to 1.5.24

* Wed Jul 12 2000 Prospector <bugzilla@redhat.com>
- automatic rebuild

* Tue Jun 27 2000 Nalin Dahyabhai <nalin@redhat.com>
- rebuild in new environment (release 3)

* Mon Jun 19 2000 Nalin Dahyabhai <nalin@redhat.com>
- don't muck with syslogd in post
- remove patch for db-3.0 wackiness, no longer needed

* Thu Jun  8 2000 Nalin Dahyabhai <nalin@redhat.com>
- FHS cleanup
- don't strip anything by default

* Fri Feb 11 2000 Tim Powers <timp@redhat.com>
- fixed man pages not being gzipped

* Tue Nov 16 1999 Tim Powers <timp@redhat.com>
- incorporated changes from Mads Kiilerich
- release number is 1, not mk1

* Tue Nov 10 1999 Mads Kiilerich <mads@kiilerich.com>
- updated to sasl 1.5.11
- configure --disable-krb4 --without-rc4 --disable-cram
  because of missing libraries and pine having cram as default...
- handle changing libsasl.so versions

* Mon Aug 30 1999 Tim Powers <timp@redhat.com>
- changed group

* Fri Aug 13 1999 Tim Powers <timp@redhat.com>
- first build for Powertools