[packages/openldap] - updated to 2.4.34 - updated contrib-modules patch - added nssov-nss-pam-ldapd-update patch (nss-pa
qboosh
qboosh at pld-linux.org
Sun Mar 10 15:19:00 CET 2013
commit 465066ab8270fbfd5dadc3cfbf468b814bafe00a
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date: Sun Mar 10 15:18:55 2013 +0100
- updated to 2.4.34
- updated contrib-modules patch
- added nssov-nss-pam-ldapd-update patch (nss-pam-ldapd files update,
needed to build current version of nssov extension)
- added am patch (ldapc++ contrib fix for automake 1.13+)
openldap-am.patch | 11 +
openldap-contrib-modules.patch | 183 ------------
openldap-nssov-nss-pam-ldapd-update.patch | 467 ++++++++++++++++++++++++++++++
openldap.spec | 13 +-
4 files changed, 486 insertions(+), 188 deletions(-)
---
diff --git a/openldap.spec b/openldap.spec
index ab77e70..98a9b0e 100644
--- a/openldap.spec
+++ b/openldap.spec
@@ -24,12 +24,12 @@ Summary(pt_BR.UTF-8): Clientes e servidor para LDAP
Summary(ru.UTF-8): Образцы клиентов LDAP
Summary(uk.UTF-8): Зразки клієнтів LDAP
Name: openldap
-Version: 2.4.33
-Release: 4
+Version: 2.4.34
+Release: 1
License: OpenLDAP Public License
Group: Networking/Daemons
Source0: ftp://ftp.openldap.org/pub/OpenLDAP/openldap-release/%{name}-%{version}.tgz
-# Source0-md5: 5adae44897647c15ce5abbff313bc85a
+# Source0-md5: df93a62e396ac312333cdeab0c5b48b6
Source1: http://download.oracle.com/berkeley-db/db-%{db_version}.tar.gz
# Source1-md5: 718082e7e35fc48478a2334b0bc4cd11
Source2: ldap.init
@@ -60,6 +60,8 @@ Patch17: %{name}-contrib-krb5.patch
Patch18: %{name}-format-security.patch
Patch19: %{name}-gcc47.patch
Patch20: enable-mdb.patch
+Patch21: %{name}-nssov-nss-pam-ldapd-update.patch
+Patch22: %{name}-am.patch
# Patch for the evolution library
Patch100: %{name}-ntlm.diff
URL: http://www.openldap.org/
@@ -1217,8 +1219,7 @@ Nakładka śledząca wywołania nakładek.
%prep
%setup -q -c %{!?with_system_db:-a1}
-
-%patch18 -p0
+%{!?with_system_db:%patch18 -p0}
cd %{name}-%{version}
%patch0 -p1
%patch1 -p1
@@ -1239,6 +1240,8 @@ cd %{name}-%{version}
%patch16 -p1
%patch19 -p1
%patch20 -p1
+%patch21 -p1
+%patch22 -p1
%if %{with krb5}
%patch17 -p1
%endif
diff --git a/openldap-am.patch b/openldap-am.patch
new file mode 100644
index 0000000..140be7f
--- /dev/null
+++ b/openldap-am.patch
@@ -0,0 +1,11 @@
+--- openldap-2.4.34/contrib/ldapc++/configure.in.orig 2013-03-03 22:17:30.000000000 +0100
++++ openldap-2.4.34/contrib/ldapc++/configure.in 2013-03-10 14:47:37.632547924 +0100
+@@ -11,7 +11,7 @@
+ AC_INIT(ldapcpplib, [] , [http://www.openldap.org/its/] )
+ AC_CONFIG_SRCDIR(src/LDAPConnection.h)
+ AM_INIT_AUTOMAKE(foreign)
+-AM_CONFIG_HEADER(src/config.h)
++AC_CONFIG_HEADERS(src/config.h)
+
+ eval `$ac_aux_dir/version.sh`
+ if test -z "$OL_CPP_API_RELEASE"; then
diff --git a/openldap-contrib-modules.patch b/openldap-contrib-modules.patch
index 2e7d69b..dbc0ba9 100644
--- a/openldap-contrib-modules.patch
+++ b/openldap-contrib-modules.patch
@@ -54,23 +54,6 @@ diff -urN openldap-2.4.25/contrib/slapd-modules/acl/Makefile.in openldap-2.4.25-
+
+XINCPATH = -I. -I$(srcdir)/. -I../../../servers/slapd
+XDEFS = $(MODULES_CPPFLAGS)
-diff -urN openldap-2.4.25/contrib/slapd-modules/addpartial/Makefile openldap-2.4.25-contrib/contrib/slapd-modules/addpartial/Makefile
---- openldap-2.4.25/contrib/slapd-modules/addpartial/Makefile 2009-01-21 01:18:19.000000000 +0100
-+++ openldap-2.4.25-contrib/contrib/slapd-modules/addpartial/Makefile 1970-01-01 01:00:00.000000000 +0100
-@@ -1,13 +0,0 @@
--# $OpenLDAP$
--OPENLDAP_SRC=../../..
--OPENLDAP_BLD=../../..
--CPPFLAGS+=-I${OPENLDAP_SRC}/include -I${OPENLDAP_SRC}/servers/slapd -I${OPENLDAP_BLD}/include
--CC=gcc
--
--all: addpartial-overlay.so
--
--addpartial-overlay.so: addpartial-overlay.c
-- $(CC) -shared $(CPPFLAGS) $(LDFLAGS) -Wall -o $@ $?
--
--clean:
-- rm addpartial-overlay.so
diff -urN openldap-2.4.25/contrib/slapd-modules/addpartial/Makefile.in openldap-2.4.25-contrib/contrib/slapd-modules/addpartial/Makefile.in
--- openldap-2.4.25/contrib/slapd-modules/addpartial/Makefile.in 1970-01-01 01:00:00.000000000 +0100
+++ openldap-2.4.25-contrib/contrib/slapd-modules/addpartial/Makefile.in 2011-03-28 17:51:20.122152000 +0200
@@ -145,37 +128,6 @@ diff -urN openldap-2.4.25/contrib/slapd-modules/allowed/Makefile.in openldap-2.4
+
+XINCPATH = -I. -I$(srcdir)/. -I../../../servers/slapd
+XDEFS = $(MODULES_CPPFLAGS)
-diff -urN openldap-2.4.25/contrib/slapd-modules/autogroup/Makefile openldap-2.4.25-contrib/contrib/slapd-modules/autogroup/Makefile
---- openldap-2.4.25/contrib/slapd-modules/autogroup/Makefile 2011-01-04 20:29:39.000000000 +0100
-+++ openldap-2.4.25-contrib/contrib/slapd-modules/autogroup/Makefile 1970-01-01 01:00:00.000000000 +0100
-@@ -1,27 +0,0 @@
--LIBTOOL=../../../libtool
--
--CPPFLAGS+=-I../../../include -I../../../servers/slapd
--
--ldap_subdir = openldap
--prefix=/usr/local
--exec_prefix = $(prefix)
--libdir = $(exec_prefix)/lib
--libexecdir = $(exec_prefix)/libexec
--moduledir = $(exec_prefix)/libexec/$(ldap_subdir)
--
--all: autogroup.la
--
--autogroup.lo: autogroup.c
-- $(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -Wall -c $?
--
--autogroup.la: autogroup.lo
-- $(LIBTOOL) --mode=link $(CC) -version-info 0:0:0 \
-- -rpath $(libdir) -module -o $@ $?
--
--clean:
-- rm -f autogroup.lo autogroup.la
--
--install: autogroup.la
-- mkdir -p $(DESTDIR)$(moduledir)
-- $(LIBTOOL) --mode=install cp autogroup.la $(DESTDIR)$(moduledir)
-- $(LIBTOOL) --finish $(DESTDIR)$(moduledir)
diff -urN openldap-2.4.25/contrib/slapd-modules/autogroup/Makefile.in openldap-2.4.25-contrib/contrib/slapd-modules/autogroup/Makefile.in
--- openldap-2.4.25/contrib/slapd-modules/autogroup/Makefile.in 1970-01-01 01:00:00.000000000 +0100
+++ openldap-2.4.25-contrib/contrib/slapd-modules/autogroup/Makefile.in 2011-03-28 17:51:20.127152000 +0200
@@ -200,27 +152,6 @@ diff -urN openldap-2.4.25/contrib/slapd-modules/autogroup/Makefile.in openldap-2
+
+XINCPATH = -I. -I$(srcdir)/. -I../../../servers/slapd
+XDEFS = $(MODULES_CPPFLAGS)
-diff -urN openldap-2.4.25/contrib/slapd-modules/cloak/Makefile openldap-2.4.25-contrib/contrib/slapd-modules/cloak/Makefile
---- openldap-2.4.25/contrib/slapd-modules/cloak/Makefile 2011-03-24 19:15:01.000000000 +0100
-+++ openldap-2.4.25-contrib/contrib/slapd-modules/cloak/Makefile 1970-01-01 01:00:00.000000000 +0100
-@@ -1,17 +0,0 @@
--# $OpenLDAP$
--CPPFLAGS+=-I../../../include -I../../../servers/slapd
--CPPFLAGS+=-DSLAPD_OVER_CLOAK=SLAPD_MOD_DYNAMIC
--LIBS=-lldap_r -llber -lcrypto
--LIBTOOL=../../../libtool
--
--all: cloak.la
--
--cloak.lo: cloak.c
-- $(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -c $?
--
--cloak.la: cloak.lo
-- $(LIBTOOL) --mode=link $(CC) -version-info 0:0:0 \
-- -rpath $(PREFIX)/lib -module -o $@ $? $(LIBS)
--
--clean:
-- rm cloak.lo cloak.la
diff -urN openldap-2.4.25/contrib/slapd-modules/cloak/Makefile.in openldap-2.4.25-contrib/contrib/slapd-modules/cloak/Makefile.in
--- openldap-2.4.25/contrib/slapd-modules/cloak/Makefile.in 1970-01-01 01:00:00.000000000 +0100
+++ openldap-2.4.25-contrib/contrib/slapd-modules/cloak/Makefile.in 2011-03-28 19:59:11.461991161 +0200
@@ -378,44 +309,6 @@ diff -urN openldap-2.4.25/contrib/slapd-modules/kinit/Makefile.in openldap-2.4.2
+
+XINCPATH = -I. -I$(srcdir)/. -I../../../servers/slapd
+XDEFS = $(MODULES_CPPFLAGS)
-diff -urN openldap-2.4.25/contrib/slapd-modules/lastbind/Makefile openldap-2.4.25-contrib/contrib/slapd-modules/lastbind/Makefile
---- openldap-2.4.25/contrib/slapd-modules/lastbind/Makefile 2011-03-25 20:39:47.000000000 +0100
-+++ openldap-2.4.25-contrib/contrib/slapd-modules/lastbind/Makefile 1970-01-01 01:00:00.000000000 +0100
-@@ -1,34 +0,0 @@
--# $OpenLDAP$
--# Copyright 2009 Jonathan Clarke <jonathan at phillipoux.net>.
--# All rights reserved.
--#
--# Redistribution and use in source and binary forms, with or without
--# modification, are permitted only as authorized by the OpenLDAP
--# Public License.
--#
--# A copy of this license is available in the file LICENSE in the
--# top-level directory of the distribution or, alternatively, at
--# <http://www.OpenLDAP.org/license.html>.
--
--CPPFLAGS+=-I../../../include -I../../../servers/slapd
--CPPFLAGS+=-DSLAPD_OVER_LASTBIND=SLAPD_MOD_DYNAMIC
--#LIBTOOL=libtool
--LIBTOOL=../../../libtool
--
--prefix=/usr/local
--
--all: lastbind.la
--
--lastbind.lo: lastbind.c
-- $(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -Wall -c $?
--
--lastbind.la: lastbind.lo
-- $(LIBTOOL) --mode=link $(CC) -version-info 0:0:0 \
-- -rpath $(prefix)/lib -module -o $@ $?
--
--clean:
-- rm -rf lastbind.lo lastbind.la lastbind.o .libs/
--
--install: lastbind.la
-- mkdir -p $(prefix)/libexec/openldap
-- $(LIBTOOL) --mode=install cp lastbind.la $(prefix)/libexec/openldap
diff -urN openldap-2.4.25/contrib/slapd-modules/lastbind/Makefile.in openldap-2.4.25-contrib/contrib/slapd-modules/lastbind/Makefile.in
--- openldap-2.4.25/contrib/slapd-modules/lastbind/Makefile.in 1970-01-01 01:00:00.000000000 +0100
+++ openldap-2.4.25-contrib/contrib/slapd-modules/lastbind/Makefile.in 2011-03-28 19:59:18.355991161 +0200
@@ -519,33 +412,6 @@ diff -urN openldap-2.4.25/contrib/slapd-modules/noopsrch/Makefile.in openldap-2.
+
+XINCPATH = -I. -I$(srcdir)/. -I../../../servers/slapd
+XDEFS = $(MODULES_CPPFLAGS)
-diff -urN openldap-2.4.25/contrib/slapd-modules/nops/Makefile openldap-2.4.25-contrib/contrib/slapd-modules/nops/Makefile
---- openldap-2.4.25/contrib/slapd-modules/nops/Makefile 2009-04-28 01:35:48.000000000 +0200
-+++ openldap-2.4.25-contrib/contrib/slapd-modules/nops/Makefile 1970-01-01 01:00:00.000000000 +0100
-@@ -1,23 +0,0 @@
--# $OpenLDAP$
--CPPFLAGS+=-I../../../include -I../../../servers/slapd
--CPPFLAGS+=-DSLAPD_OVER_NOPS=SLAPD_MOD_DYNAMIC
--LIBS=-L$(PREFIX)/lib -lldap_r -llber -lcrypto
--
--all: nops.la
--
--nops.lo: nops.c
-- $(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -c $?
--
--nops.la: nops.lo
-- $(LIBTOOL) --mode=link $(CC) -version-info 0:0:0 \
-- -rpath $(PREFIX)/lib -module -o $@ $? $(LIBS)
--
--clean:
-- rm -f nops.lo nops.la
--
--install: nops.la
-- mkdir -p $(PREFIX)/lib/openldap
-- mkdir -p $(PREFIX)/man/man5
-- $(LIBTOOL) --mode=install cp nops.la $(PREFIX)/lib/openldap
-- $(LIBTOOL) --finish $(PREFIX)/lib
-- cp nops.5 $(PREFIX)/man/man5
diff -urN openldap-2.4.25/contrib/slapd-modules/nops/Makefile.in openldap-2.4.25-contrib/contrib/slapd-modules/nops/Makefile.in
--- openldap-2.4.25/contrib/slapd-modules/nops/Makefile.in 1970-01-01 01:00:00.000000000 +0100
+++ openldap-2.4.25-contrib/contrib/slapd-modules/nops/Makefile.in 2011-03-28 19:59:27.566991161 +0200
@@ -610,55 +476,6 @@ diff -urN openldap-2.4.25/contrib/slapd-modules/nssov/Makefile.in openldap-2.4.2
+ $(MKDIR) $(DESTDIR)$(schemadir)
+ echo $(INSTALL) $(INSTALLFLAGS) -m 444 ldapns.schema $(DESTDIR)$(schemadir)
+ $(INSTALL) $(INSTALLFLAGS) -m 444 $(srcdir)/ldapns.schema $(DESTDIR)$(schemadir)
---- openldap-2.4.27/contrib/slapd-modules/passwd/Makefile 2009-04-28 03:06:14.000000000 +0200
-+++ openldap-2.4.27-contrib/contrib/slapd-modules/passwd/Makefile 1970-01-01 01:00:00.000000000 +0100
-@@ -1,46 +0,0 @@
--# $OpenLDAP$
--CPPFLAGS+=-I../../../include -I../../../servers/slapd
--
--all: kerberos.la netscape.la radius.la apr1.la
--
--kerberos.lo: kerberos.c
-- $(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -DHAVE_KRB5 -Wall -c $?
--
--kerberos.la: kerberos.lo
-- $(LIBTOOL) --mode=link $(CC) -version-info 0:0:0 \
-- -rpath $(PREFIX)/lib -module -o $@ $? -lkrb5
--
--netscape.lo: netscape.c
-- $(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -Wall -c $?
--
--netscape.la: netscape.lo
-- $(LIBTOOL) --mode=link $(CC) -version-info 0:0:0 \
-- -rpath $(PREFIX)/lib -module -o $@ $?
--
--radius.lo: radius.c
-- $(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -Wall -c $?
--
--radius.la: radius.lo
-- $(LIBTOOL) --mode=link $(CC) -version-info 0:0:0 \
-- -rpath $(PREFIX)/lib -module -o $@ $? -lradius
--
--apr1.lo: apr1.c
-- $(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) -Wall -c $?
--
--apr1.la: apr1.lo
-- $(LIBTOOL) --mode=link $(CC) -version-info 0:0:0 \
-- -rpath $(PREFIX)/lib -module -o $@ $?
--
--clean:
-- rm -f kerberos.lo kerberos.la
-- rm -f netscape.lo netscape.la
-- rm -f radius.lo radius.la
-- rm -f apr1.lo apr1.la
--
--install: kerberos.la netscape.la radius.la apr1.la
-- mkdir -p $(PREFIX)/lib/openldap
-- $(LIBTOOL) --mode=install cp kerberos.la $(PREFIX)/lib/openldap
-- $(LIBTOOL) --mode=install cp netscape.la $(PREFIX)/lib/openldap
-- $(LIBTOOL) --mode=install cp radius.la $(PREFIX)/lib/openldap
-- $(LIBTOOL) --mode=install cp apr1.la $(PREFIX)/lib/openldap
-- $(LIBTOOL) --finish $(PREFIX)/lib
--- openldap-2.4.27/contrib/slapd-modules/passwd/Makefile.in 1970-01-01 01:00:00.000000000 +0100
+++ openldap-2.4.27-contrib/contrib/slapd-modules/passwd/Makefile.in 2011-03-28 17:51:20.148152000 +0200
@@ -0,0 +1,64 @@
diff --git a/openldap-nssov-nss-pam-ldapd-update.patch b/openldap-nssov-nss-pam-ldapd-update.patch
new file mode 100644
index 0000000..15ddc22
--- /dev/null
+++ b/openldap-nssov-nss-pam-ldapd-update.patch
@@ -0,0 +1,467 @@
+--- openldap-2.4.34/contrib/slapd-modules/nssov/nss-pam-ldapd/attrs.h.orig 2013-03-03 22:17:30.000000000 +0100
++++ openldap-2.4.34/contrib/slapd-modules/nssov/nss-pam-ldapd/attrs.h 2010-10-04 21:42:16.000000000 +0200
+@@ -19,8 +19,8 @@
+ 02110-1301 USA
+ */
+
+-#ifndef _COMPAT_ATTRS_H
+-#define _COMPAT_ATTRS_H 1
++#ifndef COMPAT__ATTRS_H
++#define COMPAT__ATTRS_H 1
+
+ /* macro for testing the version of GCC */
+ #define GCC_VERSION(major,minor) \
+@@ -88,4 +88,4 @@
+ #endif /* not __STDC__ */
+ #endif /* not __STRING */
+
+-#endif /* not _COMPAT_ATTRS_H */
++#endif /* not COMPAT__ATTRS_H */
+--- openldap-2.4.34/contrib/slapd-modules/nssov/nss-pam-ldapd/nslcd.h.orig 2013-03-03 22:17:30.000000000 +0100
++++ openldap-2.4.34/contrib/slapd-modules/nssov/nss-pam-ldapd/nslcd.h 2012-07-08 10:34:12.000000000 +0200
+@@ -2,7 +2,7 @@
+ nslcd.h - file describing client/server protocol
+
+ Copyright (C) 2006 West Consulting
+- Copyright (C) 2006, 2007, 2009, 2010 Arthur de Jong
++ Copyright (C) 2006, 2007, 2009, 2010, 2011, 2012 Arthur de Jong
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+@@ -71,6 +71,16 @@
+ 1.0 release of nss-pam-ldapd is made. */
+ #define NSLCD_VERSION 1
+
++/* Get a NSLCD configuration option. There is one request parameter:
++ INT32 NSLCD_CONFIG_*
++ the result value is:
++ STRING value, interpretation depending on request */
++#define NSLCD_ACTION_CONFIG_GET 20006
++
++/* return the message, if any, that is presented to the user when password
++ modification through PAM is prohibited */
++#define NSLCD_CONFIG_PAM_PASSWORD_PROHIBIT_MESSAGE 852
++
+ /* Email alias (/etc/aliases) NSS requests. The result values for a
+ single entry are:
+ STRING alias name
+@@ -187,7 +197,10 @@
+ STRING service name
+ all requests, except the SESSION requests start the result value with:
+ STRING user name (cannonical name)
+- STRING DN (can be used to speed up requests) */
++ STRING DN (can be used to speed up requests)
++ Some functions may return an authorisation message. This message, if
++ supplied will be used by the PAM module instead of a message that is
++ generated by the PAM module itself. */
+
+ /* PAM authentication check request. The extra request values are:
+ STRING password
+@@ -249,8 +262,10 @@
+ #define NSLCD_PAM_NEW_AUTHTOK_REQD 12 /* Password expired */
+ #define NSLCD_PAM_ACCT_EXPIRED 13 /* Account expired */
+ #define NSLCD_PAM_SESSION_ERR 14 /* Cannot make/remove session record */
++#define NSLCD_PAM_AUTHTOK_ERR 20 /* Authentication token manipulation error */
+ #define NSLCD_PAM_AUTHTOK_DISABLE_AGING 23 /* Password aging disabled */
+ #define NSLCD_PAM_IGNORE 25 /* Ignore module */
+ #define NSLCD_PAM_ABORT 26 /* Fatal error */
++#define NSLCD_PAM_AUTHTOK_EXPIRED 27 /* authentication token has expired */
+
+ #endif /* not _NSLCD_H */
+--- openldap-2.4.34/contrib/slapd-modules/nssov/nss-pam-ldapd/nslcd-prot.h.orig 2013-03-03 22:17:30.000000000 +0100
++++ openldap-2.4.34/contrib/slapd-modules/nssov/nss-pam-ldapd/nslcd-prot.h 2012-01-20 17:19:23.000000000 +0100
+@@ -20,8 +20,8 @@
+ 02110-1301 USA
+ */
+
+-#ifndef _NSLCD_PROT_H
+-#define _NSLCD_PROT_H 1
++#ifndef COMMON__NSLCD_PROT_H
++#define COMMON__NSLCD_PROT_H 1
+
+ #include "tio.h"
+
+@@ -180,7 +180,8 @@ static void debug_dump(const void *ptr,s
+ if (((size_t)tmpint32)>=sizeof(buffer)) \
+ { \
+ /* will not fit */ \
+- DEBUG_PRINT("READ : buffer error: %d bytes too large",(tmpint32-sizeof(buffer))+1); \
++ tmpint32=(tmpint32-sizeof(buffer))+1; \
++ DEBUG_PRINT("READ : buffer %d bytes too small",tmpint32); \
+ ERROR_OUT_BUFERROR(fp); \
+ } \
+ /* read string from the stream */ \
+@@ -209,7 +210,8 @@ static void debug_dump(const void *ptr,s
+ if ((bufptr+(size_t)(sz))>buflen) \
+ { \
+ /* will not fit */ \
+- DEBUG_PRINT("READ : buffer error: %d bytes too small",(bufptr+(sz)-(buflen))); \
++ tmpint32=bufptr+(sz)-(buflen); \
++ DEBUG_PRINT("READ : buffer %d bytes too small",tmpint32); \
+ ERROR_OUT_BUFERROR(fp); \
+ }
+
+@@ -353,4 +355,4 @@ TFILE *nslcd_client_open(void)
+ if (tmpint32!=(int32_t)NSLCD_RESULT_BEGIN) \
+ { ERROR_OUT_NOSUCCESS(fp) }
+
+-#endif /* not _NSLCD_PROT_H */
++#endif /* not COMMON__NSLCD_PROT_H */
+--- openldap-2.4.34/contrib/slapd-modules/nssov/nss-pam-ldapd/tio.c.orig 2013-03-03 22:17:30.000000000 +0100
++++ openldap-2.4.34/contrib/slapd-modules/nssov/nss-pam-ldapd/tio.c 2012-10-12 21:50:42.000000000 +0200
+@@ -2,7 +2,7 @@
+ tio.c - timed io functions
+ This file is part of the nss-pam-ldapd library.
+
+- Copyright (C) 2007, 2008 Arthur de Jong
++ Copyright (C) 2007, 2008, 2010, 2011, 2012 Arthur de Jong
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+@@ -20,8 +20,8 @@
+ 02110-1301 USA
+ */
+
+-//#include "config.h"
+-#include "portable.h"
++//#include "config.h"
++#include "portable.h"
+
+ #ifdef HAVE_STDINT_H
+ #include <stdint.h>
+@@ -35,6 +34,8 @@
+ #include <string.h>
+ #include <signal.h>
+ #include <stdio.h>
++#include <limits.h>
++#include <poll.h>
+
+ #include "tio.h"
+
+@@ -63,8 +64,8 @@ struct tio_fileinfo {
+ int fd;
+ struct tio_buffer readbuffer;
+ struct tio_buffer writebuffer;
+- struct timeval readtimeout;
+- struct timeval writetimeout;
++ int readtimeout;
++ int writetimeout;
+ int read_resettable; /* whether the tio_reset() function can be called */
+ #ifdef DEBUG_TIO_STATS
+ /* this is used to collect statistics on the use of the streams
+@@ -74,21 +75,8 @@ struct tio_fileinfo {
+ #endif /* DEBUG_TIO_STATS */
+ };
+
+-/* add the second timeval to the first modifing the first */
+-static inline void tio_tv_add(struct timeval *tv1, const struct timeval *tv2)
+-{
+- /* BUG: we hope that this does not overflow */
+- tv1->tv_usec+=tv2->tv_usec;
+- if (tv1->tv_usec>1000000)
+- {
+- tv1->tv_usec-=1000000;
+- tv1->tv_sec+=1;
+- }
+- tv1->tv_sec+=tv2->tv_sec;
+-}
+-
+ /* build a timeval for comparison to when the operation should be finished */
+-static inline void tio_tv_prepare(struct timeval *deadline, const struct timeval *timeout)
++static inline void tio_get_deadline(struct timeval *deadline,int timeout)
+ {
+ if (gettimeofday(deadline,NULL))
+ {
+@@ -97,39 +85,27 @@ static inline void tio_tv_prepare(struct
+ deadline->tv_usec=0;
+ return;
+ }
+- tio_tv_add(deadline,timeout);
++ deadline->tv_sec+=timeout/1000;
++ deadline->tv_sec+=(timeout%1000)*1000;
+ }
+
+-/* update the timeval to the value that is remaining before deadline
++/* update the timeout to the value that is remaining before deadline
+ returns non-zero if there is no more time before the deadline */
+-static inline int tio_tv_remaining(struct timeval *tv, const struct timeval *deadline)
++static inline int tio_time_remaining(const struct timeval *deadline)
+ {
++ struct timeval tv;
+ /* get the current time */
+- if (gettimeofday(tv,NULL))
++ if (gettimeofday(&tv,NULL))
+ {
+ /* 1 second default if gettimeofday() is broken */
+- tv->tv_sec=1;
+- tv->tv_usec=0;
+- return 0;
++ return 1000;
+ }
+- /* check if we're too late */
+- if ( (tv->tv_sec>deadline->tv_sec) ||
+- ( (tv->tv_sec==deadline->tv_sec) && (tv->tv_usec>deadline->tv_usec) ) )
+- return -1;
+- /* update tv */
+- tv->tv_sec=deadline->tv_sec-tv->tv_sec;
+- if (tv->tv_usec<deadline->tv_usec)
+- tv->tv_usec=deadline->tv_usec-tv->tv_usec;
+- else
+- {
+- tv->tv_sec--;
+- tv->tv_usec=1000000+deadline->tv_usec-tv->tv_usec;
+- }
+- return 0;
++ /* calculate time remaining in miliseconds */
++ return (deadline->tv_sec-tv.tv_sec)*1000 + (deadline->tv_usec-tv.tv_usec)/1000;
+ }
+
+ /* open a new TFILE based on the file descriptor */
+-TFILE *tio_fdopen(int fd,struct timeval *readtimeout,struct timeval *writetimeout,
++TFILE *tio_fdopen(int fd,int readtimeout,int writetimeout,
+ size_t initreadsize,size_t maxreadsize,
+ size_t initwritesize,size_t maxwritesize)
+ {
+@@ -162,10 +138,8 @@ TFILE *tio_fdopen(int fd,struct timeval
+ fp->writebuffer.start=0;
+ fp->writebuffer.len=0;
+ /* initialize other attributes */
+- fp->readtimeout.tv_sec=readtimeout->tv_sec;
+- fp->readtimeout.tv_usec=readtimeout->tv_usec;
+- fp->writetimeout.tv_sec=writetimeout->tv_sec;
+- fp->writetimeout.tv_usec=writetimeout->tv_usec;
++ fp->readtimeout=readtimeout;
++ fp->writetimeout=writetimeout;
+ fp->read_resettable=0;
+ #ifdef DEBUG_TIO_STATS
+ fp->byteswritten=0;
+@@ -176,18 +150,15 @@ TFILE *tio_fdopen(int fd,struct timeval
+
+ /* wait for any activity on the specified file descriptor using
+ the specified deadline */
+-static int tio_select(TFILE *fp, int readfd, const struct timeval *deadline)
++static int tio_wait(TFILE *fp,int readfd,const struct timeval *deadline)
+ {
+- struct timeval tv;
+- fd_set fdset;
++ int timeout;
++ struct pollfd fds[1];
+ int rv;
+ while (1)
+ {
+- /* prepare our filedescriptorset */
+- FD_ZERO(&fdset);
+- FD_SET(fp->fd,&fdset);
+ /* figure out the time we need to wait */
+- if (tio_tv_remaining(&tv,deadline))
++ if ((timeout=tio_time_remaining(deadline))<0)
+ {
+ errno=ETIME;
+ return -1;
+@@ -195,18 +166,21 @@ static int tio_select(TFILE *fp, int rea
+ /* wait for activity */
+ if (readfd)
+ {
++ fds[0].fd=fp->fd;
++ fds[0].events=POLLIN;
+ /* santiy check for moving clock */
+- if (tv.tv_sec>fp->readtimeout.tv_sec)
+- tv.tv_sec=fp->readtimeout.tv_sec;
+- rv=select(FD_SETSIZE,&fdset,NULL,NULL,&tv);
++ if (timeout>fp->readtimeout)
++ timeout=fp->readtimeout;
+ }
+ else
+ {
++ fds[0].fd=fp->fd;
++ fds[0].events=POLLOUT;
+ /* santiy check for moving clock */
+- if (tv.tv_sec>fp->writetimeout.tv_sec)
+- tv.tv_sec=fp->writetimeout.tv_sec;
+- rv=select(FD_SETSIZE,NULL,&fdset,NULL,&tv);
++ if (timeout>fp->writetimeout)
++ timeout=fp->writetimeout;
+ }
++ rv=poll(fds,1,timeout);
+ if (rv>0)
+ return 0; /* we have activity */
+ else if (rv==0)
+@@ -230,11 +204,11 @@ int tio_read(TFILE *fp, void *buf, size_
+ int rv;
+ uint8_t *tmp;
+ size_t newsz;
++ size_t len;
+ /* have a more convenient storage type for the buffer */
+ uint8_t *ptr=(uint8_t *)buf;
+ /* build a time by which we should be finished */
+- /* TODO: probably only set up deadline if we have to do select() */
+- tio_tv_prepare(&deadline,&(fp->readtimeout));
++ tio_get_deadline(&deadline,fp->readtimeout);
+ /* loop until we have returned all the needed data */
+ while (1)
+ {
+@@ -292,12 +266,22 @@ int tio_read(TFILE *fp, void *buf, size_
+ }
+ }
+ /* wait until we have input */
+- if (tio_select(fp,1,&deadline))
++ if (tio_wait(fp,1,&deadline))
+ return -1;
+ /* read the input in the buffer */
+- rv=read(fp->fd,fp->readbuffer.buffer+fp->readbuffer.start,fp->readbuffer.size-fp->readbuffer.start);
++ len=fp->readbuffer.size-fp->readbuffer.start;
++#ifdef SSIZE_MAX
++ if (len>SSIZE_MAX)
++ len=SSIZE_MAX;
++#endif /* SSIZE_MAX */
++ rv=read(fp->fd,fp->readbuffer.buffer+fp->readbuffer.start,len);
+ /* check for errors */
+- if ((rv==0)||((rv<0)&&(errno!=EINTR)&&(errno!=EAGAIN)))
++ if (rv==0)
++ {
++ errno=ECONNRESET;
++ return -1;
++ }
++ else if ((rv<0)&&(errno!=EINTR)&&(errno!=EAGAIN))
+ return -1; /* something went wrong with the read */
+ /* skip the read part in the buffer */
+ fp->readbuffer.len=rv;
+@@ -313,6 +297,46 @@ int tio_skip(TFILE *fp, size_t count)
+ return tio_read(fp,NULL,count);
+ }
+
++/* Read all available data from the stream and empty the read buffer. */
++int tio_skipall(TFILE *fp)
++{
++ struct pollfd fds[1];
++ int rv;
++ size_t len;
++ /* clear the read buffer */
++ fp->readbuffer.start=0;
++ fp->readbuffer.len=0;
++ fp->read_resettable=0;
++ /* read until we can't read no more */
++ len=fp->readbuffer.size;
++#ifdef SSIZE_MAX
++ if (len>SSIZE_MAX)
++ len=SSIZE_MAX;
++#endif /* SSIZE_MAX */
++ while (1)
++ {
++ /* see if any data is available */
++ fds[0].fd=fp->fd;
++ fds[0].events=POLLIN;
++ rv=poll(fds,1,0);
++ /* check the poll() result */
++ if (rv==0)
++ return 0; /* no file descriptor ready */
++ if ((rv<0)&&((errno==EINTR)||(errno==EAGAIN)))
++ continue; /* interrupted, try again */
++ if (rv<0)
++ return -1; /* something went wrong */
++ /* read data from the stream */
++ rv=read(fp->fd,fp->readbuffer.buffer,len);
++ if (rv==0)
++ return 0; /* end-of-file */
++ if ((rv<0)&&(errno==EWOULDBLOCK))
++ return 0; /* we've ready everything we can without blocking */
++ if ((rv<0)&&(errno!=EINTR)&&(errno!=EAGAIN))
++ return -1; /* something went wrong with the read */
++ }
++}
++
+ /* the caller has assured us that we can write to the file descriptor
+ and we give it a shot */
+ static int tio_writebuf(TFILE *fp)
+@@ -370,12 +394,12 @@ int tio_flush(TFILE *fp)
+ {
+ struct timeval deadline;
+ /* build a time by which we should be finished */
+- tio_tv_prepare(&deadline,&(fp->writetimeout));
++ tio_get_deadline(&deadline,fp->writetimeout);
+ /* loop until we have written our buffer */
+ while (fp->writebuffer.len > 0)
+ {
+ /* wait until we can write */
+- if (tio_select(fp,0,&deadline))
++ if (tio_wait(fp,0,&deadline))
+ return -1;
+ /* write one block */
+ if (tio_writebuf(fp))
+@@ -388,17 +412,12 @@ int tio_flush(TFILE *fp)
+ will accept data */
+ static int tio_flush_nonblock(TFILE *fp)
+ {
+- struct timeval tv;
+- fd_set fdset;
++ struct pollfd fds[1];
+ int rv;
+- /* prepare our filedescriptorset */
+- FD_ZERO(&fdset);
+- FD_SET(fp->fd,&fdset);
+- /* set the timeout to 0 to poll */
+- tv.tv_sec=0;
+- tv.tv_usec=0;
+ /* wait for activity */
+- rv=select(FD_SETSIZE,NULL,&fdset,NULL,&tv);
++ fds[0].fd=fp->fd;
++ fds[0].events=POLLOUT;
++ rv=poll(fds,1,0);
+ /* check if any file descriptors were ready (timeout) or we were
+ interrupted */
+ if ((rv==0)||((rv<0)&&(errno==EINTR)))
+--- openldap-2.4.34/contrib/slapd-modules/nssov/nss-pam-ldapd/tio.h.orig 2013-03-03 22:17:30.000000000 +0100
++++ openldap-2.4.34/contrib/slapd-modules/nssov/nss-pam-ldapd/tio.h 2012-10-12 17:43:22.000000000 +0200
+@@ -2,7 +2,7 @@
+ tio.h - timed io functions
+ This file is part of the nss-pam-ldapd library.
+
+- Copyright (C) 2007, 2008 Arthur de Jong
++ Copyright (C) 2007, 2008, 2010, 2012 Arthur de Jong
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+@@ -33,22 +33,21 @@
+
+ */
+
+-#ifndef _TIO_H
+-#define _TIO_H
++#ifndef COMMON__TIO_H
++#define COMMON__TIO_H
+
+ #include <sys/time.h>
+ #include <sys/types.h>
+
+-#include "attrs.h"
++#include "attrs.h"
+
+ /* This is a generic file handle used for reading and writing
+ (something like FILE from stdio.h). */
+ typedef struct tio_fileinfo TFILE;
+
+ /* Open a new TFILE based on the file descriptor. The timeout is set for any
+- operation. The timeout value is copied so may be dereferenced after the
+- call. */
+-TFILE *tio_fdopen(int fd,struct timeval *readtimeout,struct timeval *writetimeout,
++ operation (value in milliseconds). */
++TFILE *tio_fdopen(int fd,int readtimeout,int writetimeout,
+ size_t initreadsize,size_t maxreadsize,
+ size_t initwritesize,size_t maxwritesize)
+ LIKE_MALLOC MUST_USE;
+@@ -59,6 +58,9 @@ int tio_read(TFILE *fp,void *buf,size_t
+ /* Read and discard the specified number of bytes from the stream. */
+ int tio_skip(TFILE *fp,size_t count);
+
++/* Read all available data from the stream and empty the read buffer. */
++int tio_skipall(TFILE *fp);
++
+ /* Write the specified buffer to the stream. */
+ int tio_write(TFILE *fp,const void *buf,size_t count);
+
+@@ -78,4 +80,4 @@ void tio_mark(TFILE *fp);
+ were full). */
+ int tio_reset(TFILE *fp);
+
+-#endif /* _TIO_H */
++#endif /* COMMON__TIO_H */
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/openldap.git/commitdiff/465066ab8270fbfd5dadc3cfbf468b814bafe00a
More information about the pld-cvs-commit
mailing list