File pam-modules.spec of Package pam-modules

#
# spec file for package pam-modules
#
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


%if %{suse_version} >= 1100
%define enable_selinux 1
%else
%define enable_selinux 0
%endif

Name:           pam-modules
Summary:        Additional PAM Modules
License:        BSD-3-Clause and GPL-2.0
Group:          System/Libraries
Version:        12.1
Release:        0
#
Source0:        pam_unix2-2.9.1.tar.bz2
Source1:        pam_pwcheck-3.13.tar.bz2
Source2:        pam_homecheck-2.0.tar.bz2
Source3:        default.passwd
Source6:        baselibs.conf
Source21:       unix2_chkpwd.c
Source41:       unix2_chkpwd.8
Source50:       dlopen.sh
Patch0:         0003-use-crypt_gensalt_rn-from-glibc.diff
Patch1:         0004-add-workarounds-for-blowfish-signedness-bug.diff
Patch2:         pam_unix2-glibc216.patch
Patch3:         pam_unix2-selinux.patch
Patch4:         pam-modules-automake.patch
#
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
PreReq:         permissions
BuildRequires:  cracklib-devel
BuildRequires:  libtool
BuildRequires:  pam-devel
%if %{enable_selinux}
BuildRequires:  libselinux-devel
%endif
# bug437293
%ifarch ppc64
Obsoletes:      pam-modules-64bit
%endif

%description
PAM (Pluggable Authentication Modules) is a system security tool that
allows system administrators to set authentication policies without
having to recompile programs that do authentication.

This package contains additional, obsolete PAM Modules sometimes
needed for migration: pam_unix2 and pam_pwcheck


%prep
%setup -q -c %{name} -b1 -b2
pushd pam_unix2-*
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
popd
%patch4
%build
pushd pam_unix2-*
gettextize -f
popd
for i in * ; do
  cd $i;
  autoreconf -fiv
  %configure --enable-selinux \
		--libdir=/%{_lib}
  make %{?_smp_mflags}
  cd ..
done
%__cc -fwhole-program -fpie -pie -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE %{optflags} %{SOURCE21} -o $RPM_BUILD_DIR/unix2_chkpwd -lpam

%install
mkdir -p $RPM_BUILD_ROOT/sbin
install -m 755 $RPM_BUILD_DIR/unix2_chkpwd $RPM_BUILD_ROOT/sbin/
install -d -m 755 $RPM_BUILD_ROOT%{_libdir}
for i in * ; do
  cd $i;
  make DESTDIR=$RPM_BUILD_ROOT install
  cd ..
done
#
# Remove stuff we don't wish to have now:
#
rm -rf $RPM_BUILD_ROOT/usr/{include,lib}
rm -rf $RPM_BUILD_ROOT/%{_lib}/security/*.la
# Check for module problems.  Specifically, check that every module we just
# installed can actually be loaded by a minimal PAM-aware application.
export CC=%__cc
for module in $RPM_BUILD_ROOT/%{_lib}/security/pam*.so ; do
   if ! sh $RPM_SOURCE_DIR/dlopen.sh -lpam -ldl ${module} ; then
      exit 1
   fi
done
#
# Install READMEs of PAM modules
#
DOC=$RPM_BUILD_ROOT%{_defaultdocdir}/pam
mkdir -p $DOC/modules
for i in pam_*/README ; do
  cp -fpv ${i} $DOC/modules/README.`dirname ${i}`
done
install -m 644 $RPM_SOURCE_DIR/unix2_chkpwd.8 $RPM_BUILD_ROOT%{_mandir}/man8/
# Replace default/passwd file
install -m 644 %SOURCE3 $RPM_BUILD_ROOT/etc/default/passwd
# Find lang files
%{find_lang} pam_unix2
%{find_lang} pam_pwcheck pam_unix2.lang

%post
%set_permissions /sbin/unix2_chkpwd

%verifyscript
%verify_permissions -e /sbin/unix2_chkpwd

%files -f pam_unix2.lang
%defattr(-,root,root,755)
%doc %{_defaultdocdir}/pam
%attr(644,root,root) %config(noreplace) /etc/default/passwd
%verify(not mode) %attr(4755,root,shadow) /sbin/unix2_chkpwd
%attr(755,root,root) /%{_lib}/security/pam_homecheck.so
%attr(755,root,root) /%{_lib}/security/pam_pwcheck.so
%attr(755,root,root) /%{_lib}/security/pam_unix2.so
%attr(644,root,root) %doc %{_mandir}/man8/pam_pwcheck.8.gz
%attr(644,root,root) %doc %{_mandir}/man8/pam_unix2.8.gz
%attr(644,root,root) %doc %{_mandir}/man8/unix2_chkpwd.8.gz

%changelog