This commit is contained in:
parent
33b7918174
commit
6533d1cccc
239
cracklib-zlib.dif
Normal file
239
cracklib-zlib.dif
Normal file
@ -0,0 +1,239 @@
|
||||
Index: cracklib-2.8.12/lib/packlib.c
|
||||
===================================================================
|
||||
--- cracklib-2.8.12.orig/lib/packlib.c
|
||||
+++ cracklib-2.8.12/lib/packlib.c
|
||||
@@ -7,6 +7,9 @@
|
||||
#include "config.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
+#ifdef HAVE_ZLIB_H
|
||||
+#include <zlib.h>
|
||||
+#endif
|
||||
#ifdef HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
@@ -82,15 +85,46 @@ PWOpen(prefix, mode)
|
||||
snprintf(dname, STRINGSIZE, "%s.pwd", prefix);
|
||||
snprintf(wname, STRINGSIZE, "%s.hwm", prefix);
|
||||
|
||||
- if (!(pdesc.dfp = fopen(dname, mode)))
|
||||
+ if (mode[0] == 'r')
|
||||
{
|
||||
- perror(dname);
|
||||
- return ((PWDICT *) 0);
|
||||
- }
|
||||
+ pdesc.flags &= ~PFOR_USEZLIB;
|
||||
+ /* first try the normal db file */
|
||||
+ if (!(pdesc.dfp = fopen(dname, mode)))
|
||||
+ {
|
||||
+#ifdef HAVE_ZLIB_H
|
||||
+ pdesc.flags |= PFOR_USEZLIB;
|
||||
+ /* try extension .gz */
|
||||
+ snprintf(dname, STRINGSIZE, "%s.pwd.gz", prefix);
|
||||
+ if (!(pdesc.dfp = gzopen(dname, mode)))
|
||||
+ {
|
||||
+ perror(dname);
|
||||
+ return ((PWDICT *) 0);
|
||||
+ }
|
||||
+#else
|
||||
+ perror(dname);
|
||||
+ return ((PWDICT *) 0);
|
||||
+#endif
|
||||
+ }
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ pdesc.flags &= ~PFOR_USEZLIB;
|
||||
+ /* write mode: use fopen */
|
||||
+ if (!(pdesc.dfp = fopen(dname, mode)))
|
||||
+ {
|
||||
+ perror(dname);
|
||||
+ return ((PWDICT *) 0);
|
||||
+ }
|
||||
+ }
|
||||
|
||||
if (!(pdesc.ifp = fopen(iname, mode)))
|
||||
{
|
||||
- fclose(pdesc.dfp);
|
||||
+#ifdef HAVE_ZLIB_H
|
||||
+ if(pdesc.flags & PFOR_USEZLIB)
|
||||
+ gzclose(pdesc.dfp);
|
||||
+ else
|
||||
+#endif
|
||||
+ fclose(pdesc.dfp);
|
||||
perror(iname);
|
||||
return ((PWDICT *) 0);
|
||||
}
|
||||
@@ -122,7 +156,12 @@ PWOpen(prefix, mode)
|
||||
|
||||
pdesc.header.pih_magic = 0;
|
||||
fclose(ifp);
|
||||
- fclose(dfp);
|
||||
+#ifdef HAVE_ZLIB_H
|
||||
+ if(pdesc.flags & PFOR_USEZLIB)
|
||||
+ gzclose(dfp);
|
||||
+ else
|
||||
+#endif
|
||||
+ fclose(dfp);
|
||||
if(wfp)
|
||||
{
|
||||
fclose(wfp);
|
||||
@@ -140,7 +179,12 @@ PWOpen(prefix, mode)
|
||||
|
||||
pdesc.header.pih_magic = 0;
|
||||
fclose(ifp);
|
||||
- fclose(dfp);
|
||||
+#ifdef HAVE_ZLIB_H
|
||||
+ if(pdesc.flags & PFOR_USEZLIB)
|
||||
+ gzclose(dfp);
|
||||
+ else
|
||||
+#endif
|
||||
+ fclose(dfp);
|
||||
if(wfp)
|
||||
{
|
||||
fclose(wfp);
|
||||
@@ -154,7 +198,13 @@ PWOpen(prefix, mode)
|
||||
|
||||
pdesc.header.pih_magic = 0;
|
||||
fclose(ifp);
|
||||
- fclose(dfp);
|
||||
+#ifdef HAVE_ZLIB_H
|
||||
+ if(pdesc.flags & PFOR_USEZLIB)
|
||||
+ gzclose(dfp);
|
||||
+ else
|
||||
+#endif
|
||||
+ fclose(dfp);
|
||||
+
|
||||
if(wfp)
|
||||
{
|
||||
fclose(wfp);
|
||||
@@ -174,7 +224,13 @@ PWOpen(prefix, mode)
|
||||
|
||||
pdesc.header.pih_magic = 0;
|
||||
fclose(ifp);
|
||||
- fclose(dfp);
|
||||
+#ifdef HAVE_ZLIB_H
|
||||
+ if(pdesc.flags & PFOR_USEZLIB)
|
||||
+ gzclose(dfp);
|
||||
+ else
|
||||
+#endif
|
||||
+ fclose(dfp);
|
||||
+
|
||||
if(wfp)
|
||||
{
|
||||
fclose(wfp);
|
||||
@@ -188,7 +244,12 @@ PWOpen(prefix, mode)
|
||||
|
||||
pdesc.header.pih_magic = 0;
|
||||
fclose(ifp);
|
||||
- fclose(dfp);
|
||||
+#ifdef HAVE_ZLIB_H
|
||||
+ if(pdesc.flags & PFOR_USEZLIB)
|
||||
+ gzclose(dfp);
|
||||
+ else
|
||||
+#endif
|
||||
+ fclose(dfp);
|
||||
if(wfp)
|
||||
{
|
||||
fclose(wfp);
|
||||
@@ -202,8 +263,13 @@ PWOpen(prefix, mode)
|
||||
|
||||
pdesc.header.pih_magic = 0;
|
||||
fclose(ifp);
|
||||
- fclose(dfp);
|
||||
- if(wfp)
|
||||
+#ifdef HAVE_ZLIB_H
|
||||
+ if(pdesc.flags & PFOR_USEZLIB)
|
||||
+ gzclose(dfp);
|
||||
+ else
|
||||
+#endif
|
||||
+ fclose(dfp);
|
||||
+ if(wfp)
|
||||
{
|
||||
fclose(wfp);
|
||||
}
|
||||
@@ -286,7 +352,12 @@ PWClose(pwp)
|
||||
}
|
||||
|
||||
fclose(pwp->ifp);
|
||||
- fclose(pwp->dfp);
|
||||
+#ifdef HAVE_ZLIB_H
|
||||
+ if(pwp->flags & PFOR_USEZLIB)
|
||||
+ gzclose(pwp->dfp);
|
||||
+ else
|
||||
+#endif
|
||||
+ fclose(pwp->dfp);
|
||||
if(pwp->wfp)
|
||||
{
|
||||
fclose(pwp->wfp);
|
||||
@@ -414,13 +485,40 @@ GetPW(pwp, number)
|
||||
}
|
||||
}
|
||||
|
||||
- if (fseek(pwp->dfp, datum, 0))
|
||||
+ int r = 1;
|
||||
+#ifdef HAVE_ZLIB_H
|
||||
+ if (pwp->flags & PFOR_USEZLIB)
|
||||
+ {
|
||||
+ r = gzseek(pwp->dfp, datum, 0);
|
||||
+ if(r >= 0)
|
||||
+ r = 0;
|
||||
+ }
|
||||
+ else
|
||||
+#endif
|
||||
+ r = fseek(pwp->dfp, datum, 0);
|
||||
+
|
||||
+
|
||||
+ if (r)
|
||||
{
|
||||
perror("(data fseek failed)");
|
||||
return ((char *) 0);
|
||||
}
|
||||
-
|
||||
- if (!fread(buffer, 1, sizeof(buffer), pwp->dfp))
|
||||
+ r = 0;
|
||||
+
|
||||
+#ifdef HAVE_ZLIB_H
|
||||
+ if (pwp->flags & PFOR_USEZLIB)
|
||||
+ {
|
||||
+ r = gzread(pwp->dfp, buffer, sizeof(buffer));
|
||||
+ if(r < 0)
|
||||
+ r = 0;
|
||||
+ }
|
||||
+ else
|
||||
+#endif
|
||||
+ r = fread(buffer, 1, sizeof(buffer), pwp->dfp);
|
||||
+
|
||||
+
|
||||
+
|
||||
+ if (!r)
|
||||
{
|
||||
perror("(data fread failed)");
|
||||
return ((char *) 0);
|
||||
Index: cracklib-2.8.12/configure.in
|
||||
===================================================================
|
||||
--- cracklib-2.8.12.orig/configure.in
|
||||
+++ cracklib-2.8.12/configure.in
|
||||
@@ -22,6 +22,9 @@ AC_CHECK_HEADERS(fcntl.h)
|
||||
AC_CHECK_HEADERS(inttypes.h)
|
||||
AC_CHECK_HEADERS(stdint.h)
|
||||
AC_CHECK_HEADERS(pthread.h)
|
||||
+AC_CHECK_HEADERS(zlib.h, AC_DEFINE(HAVE_ZLIB_H, [], [found zlib]))
|
||||
+
|
||||
+AC_SEARCH_LIBS(gzopen, z)
|
||||
|
||||
dnl Cygwin workaround
|
||||
AC_MSG_CHECKING(if LINE_MAX is defined)
|
||||
Index: cracklib-2.8.12/lib/packer.h
|
||||
===================================================================
|
||||
--- cracklib-2.8.12.orig/lib/packer.h
|
||||
+++ cracklib-2.8.12/lib/packer.h
|
||||
@@ -61,6 +61,8 @@ typedef struct
|
||||
#define PFOR_FLUSH 0x0002
|
||||
#define PFOR_USEHWMS 0x0004
|
||||
|
||||
+#define PFOR_USEZLIB 0x0008
|
||||
+
|
||||
uint32_t hwms[256];
|
||||
|
||||
struct pi_header header;
|
@ -1,3 +1,10 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri Jun 20 16:46:23 CEST 2008 - mc@suse.de
|
||||
|
||||
- implement reading compressed password databases
|
||||
(FATE#303536)
|
||||
- compress password database
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Jun 6 09:59:27 CEST 2008 - mc@suse.de
|
||||
|
||||
|
@ -12,12 +12,13 @@
|
||||
|
||||
|
||||
Name: cracklib
|
||||
BuildRequires: gzip zlib-devel
|
||||
Url: http://sourceforge.net/projects/cracklib
|
||||
License: Artistic License
|
||||
Group: System/Libraries
|
||||
AutoReqProv: on
|
||||
Version: 2.8.12
|
||||
Release: 25
|
||||
Release: 27
|
||||
Requires: cracklib-dict
|
||||
Summary: Full Dictionary for cracklib
|
||||
Source: http://prdownloads.sourceforge.net/cracklib/cracklib-%{version}.tar.bz2
|
||||
@ -25,6 +26,7 @@ Source1: cracklib-po.tar.gz
|
||||
Patch: cracklib-magic.diff
|
||||
Patch1: cracklib-trans.diff
|
||||
Patch2: datarootdir.patch
|
||||
Patch3: cracklib-zlib.dif
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
|
||||
%description
|
||||
@ -73,6 +75,7 @@ This package contains a small dictionay file used by cracklib.
|
||||
%patch
|
||||
%patch1
|
||||
%patch2
|
||||
%patch3 -p1
|
||||
|
||||
%build
|
||||
AUTOPOINT=true autoreconf -fi
|
||||
@ -94,12 +97,13 @@ chmod 755 ./util/cracklib-format
|
||||
sed "s,/usr/lib/cracklib_dict,%{_datadir}/cracklib/pw_dict,g" lib/crack.h > $RPM_BUILD_ROOT/%{_includedir}/crack.h
|
||||
./util/cracklib-format ./dicts/cracklib-small | \
|
||||
./util/cracklib-packer $RPM_BUILD_ROOT/%{_datadir}/cracklib/pw_dict
|
||||
gzip $RPM_BUILD_ROOT/%{_datadir}/cracklib/pw_dict.pwd
|
||||
ln -s cracklib-format $RPM_BUILD_ROOT/%{_sbindir}/mkdict
|
||||
ln -s cracklib-packer $RPM_BUILD_ROOT/%{_sbindir}/packer
|
||||
rm -f $RPM_BUILD_ROOT/%{_datadir}/cracklib/cracklib-small
|
||||
mkdir -p $RPM_BUILD_ROOT/usr/lib
|
||||
ln -sf %{_datadir}/cracklib/pw_dict.hwm $RPM_BUILD_ROOT/usr/lib/cracklib_dict.hwm
|
||||
ln -sf %{_datadir}/cracklib/pw_dict.pwd $RPM_BUILD_ROOT/usr/lib/cracklib_dict.pwd
|
||||
ln -sf %{_datadir}/cracklib/pw_dict.pwd.gz $RPM_BUILD_ROOT/usr/lib/cracklib_dict.pwd.gz
|
||||
ln -sf %{_datadir}/cracklib/pw_dict.pwi $RPM_BUILD_ROOT/usr/lib/cracklib_dict.pwi
|
||||
%{find_lang} %{name}
|
||||
|
||||
@ -122,7 +126,7 @@ ln -sf %{_datadir}/cracklib/pw_dict.pwi $RPM_BUILD_ROOT/usr/lib/cracklib_dict.pw
|
||||
%dir %{_datadir}/cracklib
|
||||
%{_datadir}/cracklib/cracklib.magic
|
||||
/usr/lib/cracklib_dict.hwm
|
||||
/usr/lib/cracklib_dict.pwd
|
||||
/usr/lib/cracklib_dict.pwd.gz
|
||||
/usr/lib/cracklib_dict.pwi
|
||||
|
||||
%files devel
|
||||
@ -135,10 +139,14 @@ ln -sf %{_datadir}/cracklib/pw_dict.pwi $RPM_BUILD_ROOT/usr/lib/cracklib_dict.pw
|
||||
%files dict-small
|
||||
%defattr(-,root,root)
|
||||
%{_datadir}/cracklib/pw_dict.hwm
|
||||
%{_datadir}/cracklib/pw_dict.pwd
|
||||
%{_datadir}/cracklib/pw_dict.pwd.gz
|
||||
%{_datadir}/cracklib/pw_dict.pwi
|
||||
|
||||
%changelog
|
||||
* Fri Jun 20 2008 mc@suse.de
|
||||
- implement reading compressed password databases
|
||||
(FATE#303536)
|
||||
- compress password database
|
||||
* Fri Jun 06 2008 mc@suse.de
|
||||
- update i18n files
|
||||
* Fri May 09 2008 mc@suse.de
|
||||
|
Loading…
Reference in New Issue
Block a user