Various fixes & enhancements for ldap-3.3 release

Jeff.Hodges@Stanford.EDU
Mon, 15 Jul 96 11:35:34 -0700

Hi,

Here's some more patches for the ldap-3.3 release we utilized in compiling it
for various (eight) architectures. The below patch file also includes (for
completeness) the patches we'd already submitted on 3.2 and 3.3.

thanks,

Jeff

------- Forwarded Message

From: Larry Schwimmer <rosebud@cyclone.Stanford.EDU>
Subject: Re: LDAP 3.3 Released by UMich
To: Jeff.Hodges@Stanford.EDU
Date: Fri, 12 Jul 1996 16:20:03 -0700 (PDT)
In-Reply-To: <199605011643.JAA08764@Breakaway.Stanford.EDU> from
"Jeff.Hodges@Stanford.EDU" at May 1, 96 09:43:24 am
X-Mailer: ELM [version 2.4 PL25]
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

Jeff -- could you bounce this the ldap folks? (Is
ldap-support@umich.edu the address to send patches to?)
Thanks.

You (Jeff.Hodges@Stanford.EDU) wrote a while back...
> I'll work with Larry on getting it compiled and all.

I have it built on eight platforms now: Solaris 2.4, SunOS
4.1.4, Irix 5.3, Linux 1.2.13, Ultrix 4.4, Digital UNIX 3.2c, HPUX
9.05, and AIX 3.2.5. I haven't had time to hack the makefiles to
handle a shared etc files or separate debugging library compiles, so I
did that by hand. There were a few problems with the 3.3
distribution. I'll can send patches.
There was one thing which bothered me, though. ldap.h
contains long for some data types. A timestamp is a time_t not a
long. I haven't spent time looking over the code to tell which data
structures are internal and thus don't matter and which data
structures are network packets and do. But it would seem that the
header is incorrect, and should cause problems for machines with 64
bit longs.

Problems and patches:

1) clients/fax500/Make-template

The install, not runtime, path was encoded in to the
executable.

2) clients/fax500/xrpcomp

Bourne shell scripts should start with "#! /bin/sh" to ensure
the proper shell is used.

3) clients/ud_util.c

exit is not a void function. It does not return, but its
prototype is not void.

4) include/ldap.h

A) Some platforms (I forget but it doesn't really matter since
the rest were happy with the change) needed <sys/types.h>
and <time.h> to compile.

B) I changed long to int for the time types to make the compiler
happy. I have not scrutinized this code thoug, so this is
just a suggestion. The distribution header is not correct,
though.

5) include/portable.h

The "logic" for waitpid is backwards. waitpid is a POSIX
call, and supported by most platforms. wait3 is a BSD call and
neither required nor available on many platforms. waitpid should be
the default, and handling defective systems which lack it the special
case.

6) libraries/libldap/ldap-int.h
7) libraries/libldap/ldapfilter.conf
8) libraries/libldap_test.c
9) servers/slapd/daemon.c
10) servers/slapd/monitor.c

The first three are Jeff's patches to 3.2 and they still seem
to apply with patch on 3.3. The last two are Jeff's patches for the
locking problem. I'm just including them for completeness.

11) servers/slapd/back-ldbm_Make-template

The makefile needs to quote $CC for passing to the make
command. Otherwise, using CC="cc -D__svr4__' (which I needed to
get around a bug in the kerberos headers) or CC='cc -Olimit 100000'
(which I used to ensure that IRIX optimized the files) causes the make
to fail. (I used CC since I didn't want to change Make-common, which
is common for all platforms and since I wanted an expedient solution).

12) build/platforms/osf1-gcc/Make-platform

The distribution is missing a gcc target for Digital UNIX.

yours,
Larry Schwimmer
schwim@cyclone.stanford.edu
Distributed Computing Operations

- --- clients/fax500/Make-template.orig Tue Apr 30 08:05:12 1996
+++ clients/fax500/Make-template Thu May 16 15:17:03 1996
@@ -55,7 +55,7 @@
install: rp500 xrpcomp fax500 FORCE
-$(MKDIR) -p $(ETCDIR) $(BINDIR)
$(INSTALL) $(INSTALLFLAGS) -m 755 rp500 $(ETCDIR)
- - $(SED) -e 's%ETCDIR%$(ETCDIR)%' xrpcomp > /tmp/xrpcomp.tmp
+ $(SED) -e 's%ETCDIR%$(RUNTIMEETCDIR)%' xrpcomp > /tmp/xrpcomp.tmp
$(INSTALL) $(INSTALLFLAGS) -m 755 /tmp/xrpcomp.tmp $(BINDIR)/xrpcomp
$(RM) /tmp/xrpcomp.tmp
$(INSTALL) $(INSTALLFLAGS) -m 755 fax500 $(ETCDIR)
- --- clients/fax500/xrpcomp.orig Fri Jul 30 19:06:53 1993
+++ clients/fax500/xrpcomp Thu May 16 15:17:03 1996
@@ -1,4 +1,4 @@
- -: run this script through /bin/sh
+#! /bin/sh

RP500=ETCDIR/rp500

- --- clients/ud/util.c.orig Tue Dec 12 11:57:07 1995
+++ clients/ud/util.c Thu Jul 11 11:15:30 1996
@@ -226,8 +226,6 @@
fatal(s)
char *s;
{
- - void exit();
- -
if (errno != 0)
perror(s);
#ifdef KERBEROS
- --- include/ldap.h.orig Thu Apr 4 06:41:52 1996
+++ include/ldap.h Fri Jul 12 15:04:31 1996
@@ -295,7 +295,7 @@
BerElement *lm_ber; /* the ber encoded message contents */
struct ldapmsg *lm_chain; /* for search - next msg in the resp */
struct ldapmsg *lm_next; /* next response */
- - unsigned long lm_time; /* used to maintain cache */
+ unsigned int lm_time; /* used to maintain cache */
} LDAPMessage;
#define NULLMSG ((LDAPMessage *) NULL)

@@ -318,7 +318,7 @@
typedef struct ldap_conn {
Sockbuf *lconn_sb;
int lconn_refcnt;
- - unsigned long lconn_lastused; /* time */
+ unsigned int lconn_lastused; /* time */
int lconn_status;
#define LDAP_CONNST_NEEDSOCKET 1
#define LDAP_CONNST_CONNECTING 2
@@ -569,6 +569,8 @@

#else /* NEEDPROTOS */
#if !defined(MACOS) && !defined(DOS) && !defined(_WIN32) && !defined(WINSOCK)
+#include <sys/types.h>
+#include <time.h>
#include <sys/time.h>
#endif
#if defined(WINSOCK)
- --- include/portable.h.orig Tue Apr 30 12:55:39 1996
+++ include/portable.h Thu May 16 15:23:09 1996
@@ -61,9 +61,9 @@
#endif

/*
- - * on many systems, we should use waitpid() instead of waitN()
+ * on most systems, we should use waitpid() instead of waitN()
*/
- -#if !defined( USE_WAITPID ) && ( defined( SYSV ) || defined( sunos4 ) ||
defined( ultrix ) || defined( aix ))
+#if !defined( USE_WAITPID ) && !defined( nextstep )
#define USE_WAITPID
#endif

- --- libraries/libldap/ldap-int.h.orig Fri Apr 5 17:01:20 1996
+++ libraries/libldap/ldap-int.h Thu May 16 15:17:02 1996
@@ -187,3 +187,26 @@
char **getdxbyname();
#endif /* NEEDPROTOS */
#endif /* LDAP_DNS */
+
+#if defined( STR_TRANSLATION ) && defined( LDAP_DEFAULT_CHARSET )
+/*
+ * in charset.c
+ *
+ * added-in this stuff so that libldap.a would build, i.e. refs to
+ * these routines from open.c would resolve.
+ * hodges@stanford.edu 5-Feb-96
+ */
+#if LDAP_CHARSET_8859 == LDAP_DEFAULT_CHARSET
+#ifdef NEEDPROTOS
+extern
+int ldap_t61_to_8859( char **bufp, unsigned long *buflenp, int free_input );
+extern
+int ldap_8859_to_t61( char **bufp, unsigned long *buflenp, int free_input );
+#else /* NEEDPROTOS */
+extern
+int ldap_t61_to_8859();
+extern
+int ldap_8859_to_t61();
+#endif /* NEEDPROTOS */
+#endif /* LDAP_CHARSET_8859 == LDAP_DEFAULT_CHARSET */
+#endif /* STR_TRANSLATION && LDAP_DEFAULT_CHARSET */
- --- libraries/libldap/ldapfilter.conf.orig Thu Apr 13 08:32:33 1995
+++ libraries/libldap/ldapfilter.conf Thu May 16 15:17:03 1996
@@ -24,33 +24,35 @@
#

"finger and ud and go500 and go500gw subtree and web500gw subtree and rp500
and rcpt500 and ufn last"
+ "^$" "" "(objectclass=*)" "default filter"
"=" " " "%v" "arbitrary filter"

- - "^[0-9][0-9-]*$" " " "(telephoneNumber=*%v)" "phone number"
+ "^[0-9][0-9\-]*$" " " "(telephoneNumber=*%v)" "phone number"

"@" " " "(mail=%v)" "email address"
"(mail=%v*)" "start of email address"

- - "^.[. _].*" ". _" "(cn=%v1* %v2-)" "first initial"
+ "^.[\. _].*" ". _" "(cn=%v1* %v2-)" "first initial"

".*[. _].$" ". _" "(cn=%v1-*)" "last initial"

"[. _]" ". _" "(|(sn=%v1-)(cn=%v1-))" "exact"
"(|(sn~=%v1-)(cn~=%v1-))" "approximate"

- - ".*" ". " "(|(cn=%v1)(sn=%v1)(uid=%v1))" "exact"
- - "(|(cn~=%v1)(sn~=%v1))" "approximate"
+ ".*" ". " "(|(cn=%v1)(sn=%v1)(ou=%v1))" "exact"
+ "(|(cn~=%v1)(sn~=%v1)(ou~=%v1))" "approximate"

"go500gw onelevel and web500gw onelevel and ufn first and ufn intermediate"
+ "^$" "" "(!(objectclass=dSA))" "default filter"
"=" " " "%v" "arbitrary filter"

- - "^..$" " " "(|(o=%v)(c=%v)(l=%v)(co=%v))" "exact"
- - "(|(o~=%v)(c~=%v)(l~=%v)(co~=%v))" "approximate"
+ "^..$" " " "(|(o=%v)(c=%v)(l=%v)(co=%v))" "exact2"
+ "(|(o~=%v)(c~=%v)(l~=%v)(co~=%v))" "approximate2"

" " " " "(|(o=%v)(l=%v)(co=%v)(ou=%v))" "exact"
"(|(o~=%v)(l~=%v)(co~=%v)(ou~=%v))" "approximate"

- - "\." " " "(associatedDomain=%v)" "exact"
+ "\." " " "(associatedDomain=%v)" "exact"

".*" " " "(|(o=%v)(l=%v)(co=%v)(ou=%v))" "exact"
"(|(o~=%v)(l~=%v)(co~=%v)(ou~=%v))" "approximate"
- --- libraries/libldap/open.c.orig Thu Mar 28 08:28:35 1996
+++ libraries/libldap/open.c Thu May 16 15:17:02 1996
@@ -148,6 +148,10 @@
ld->ld_lberoptions = LBER_USE_DER;
ld->ld_refhoplimit = LDAP_DEFAULT_REFHOPLIMIT;

+#ifdef LDAP_REFERRALS
+ ld->ld_options |= LDAP_OPT_REFERRALS;
+#endif /* LDAP_REFERRALS */
+
#if defined( STR_TRANSLATION ) && defined( LDAP_DEFAULT_CHARSET )
ld->ld_lberoptions |= LBER_TRANSLATE_STRINGS;
#if LDAP_CHARSET_8859 == LDAP_DEFAULT_CHARSET
- --- libraries/libldap/test.c.orig Thu Feb 29 13:15:59 1996
+++ libraries/libldap/test.c Thu May 16 15:17:02 1996
@@ -31,6 +31,12 @@
#include "lber.h"
#include "ldap.h"

+/* including the "internal" defs is legit and nec. since this test routine
has
+ * a-priori knowledge of libldap internal workings.
+ * hodges@stanford.edu 5-Feb-96
+ */
+#include "ldap-int.h"
+
#if !defined( PCNFS ) && !defined( WINSOCK ) && !defined( MACOS )
#define MOD_USE_BVALS
#endif /* !PCNFS && !WINSOCK && !MACOS */
- --- servers/slapd/back-ldbm/Make-template.orig Tue Apr 30 08:07:29 1996
+++ servers/slapd/back-ldbm/Make-template Thu Jul 11 11:22:45 1996
@@ -34,7 +34,7 @@
all: FORCE
-@echo "$(SLAPD_BACKENDS)" | grep LDAP_LDBM 2>&1 > /dev/null; \
if [ $$? = 0 ]; then \
- - $(MAKE) $(MFLAGS) CC=$(CC) libback-ldbm.a; \
+ $(MAKE) $(MFLAGS) CC="$(CC)" libback-ldbm.a; \
else \
echo "Include -DLDAP_LDBM in SLAPD_BACKENDS in the"; \
echo "Make-common file to build the ldbm backend"; \
- --- servers/slapd/daemon.c.orig Fri Mar 29 13:27:22 1996
+++ servers/slapd/daemon.c Wed Jul 10 22:28:12 1996
@@ -1,3 +1,10 @@
+
+/* Revision history
+ *
+ * 5-Jun-96 hodges
+ * Added locking of new_conn_mutex when traversing the c[] array.
+ */
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
@@ -164,6 +171,8 @@
Debug( LDAP_DEBUG_CONNS,
"listening for connections on %d, activity on:",
tcps, 0, 0 );
+
+ pthread_mutex_lock( &new_conn_mutex );
for ( i = 0; i < dtblsize; i++ ) {
if ( c[i].c_sb.sb_sd != -1 ) {
FD_SET( c[i].c_sb.sb_sd, &readfds );
@@ -176,6 +185,7 @@
}
}
Debug( LDAP_DEBUG_CONNS, "\n", 0, 0, 0 );
+ pthread_mutex_unlock( &new_conn_mutex );

zero.tv_sec = 0;
zero.tv_usec = 0;
- --- servers/slapd/monitor.c.orig Wed Apr 24 06:32:06 1996
+++ servers/slapd/monitor.c Wed Jul 10 22:28:12 1996
@@ -10,8 +10,16 @@
* is provided ``as is'' without express or implied warranty.
*/

+/* Revision history
+ *
+ * 5-Jun-96 jeff.hodges@stanford.edu
+ * Added locking of new_conn_mutex when traversing the c[] array.
+ * Added locking of currenttime_mutex to protect call(s) to localtime().
+ */
+
#include <stdio.h>
#include <string.h>
+#include <time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include "slap.h"
@@ -32,13 +40,11 @@
extern time_t starttime;
extern int num_conns;

+extern pthread_mutex_t new_conn_mutex;
+extern pthread_mutex_t currenttime_mutex;

extern char Versionstr[];

- -/*
- - * no mutex protection in here - take our chances!
- - */
- -
void
monitor_info( Connection *conn, Operation *op )
{
@@ -73,6 +79,8 @@
nconns = 0;
nwritewaiters = 0;
nreadwaiters = 0;
+
+ pthread_mutex_lock( &new_conn_mutex );
for ( i = 0; i < dtblsize; i++ ) {
if ( c[i].c_sb.sb_sd != -1 ) {
nconns++;
@@ -82,8 +90,11 @@
if ( c[i].c_gettingber ) {
nreadwaiters++;
}
+ pthread_mutex_lock( &currenttime_mutex );
ltm = localtime( &c[i].c_starttime );
strftime( buf2, sizeof(buf2), "%y%m%d%H%M%SZ", ltm );
+ pthread_mutex_unlock( &currenttime_mutex );
+
pthread_mutex_lock( &c[i].c_dnmutex );
sprintf( buf, "%d : %s : %ld : %ld : %s : %s%s", i,
buf2, c[i].c_opsinitiated, c[i].c_opscompleted,
@@ -96,6 +107,8 @@
attr_merge( e, "connection", vals );
}
}
+ pthread_mutex_unlock( &new_conn_mutex );
+
sprintf( buf, "%d", nconns );
val.bv_val = buf;
val.bv_len = strlen( buf );
@@ -141,14 +154,18 @@
val.bv_len = strlen( buf );
attr_merge( e, "bytessent", vals );

+ pthread_mutex_lock( &currenttime_mutex );
ltm = localtime( &currenttime );
strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm );
+ pthread_mutex_unlock( &currenttime_mutex );
val.bv_val = buf;
val.bv_len = strlen( buf );
attr_merge( e, "currenttime", vals );

+ pthread_mutex_lock( &currenttime_mutex );
ltm = localtime( &starttime );
strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm );
+ pthread_mutex_unlock( &currenttime_mutex );
val.bv_val = buf;
val.bv_len = strlen( buf );
attr_merge( e, "starttime", vals );
- --- /dev/null Fri Jul 12 15:58:31 1996
+++ build/platforms/osf1-gcc/Make-platform Thu Jul 11 11:45:48 1996
@@ -0,0 +1,25 @@
+#
+# LDAP OSF1 gcc Make-platform file
+#
+
+#
+# add any platform-specific overrides below here
+#
+
+
+#
+# -------------------------------------------------------------------------
+# you will probably not need to edit anything below this point
+# -------------------------------------------------------------------------
+
+CC = gcc
+
+PLATFORMCFLAGS= -Dosf1
+PLATFORMLDFLAGS=
+
+THREADS= -DTHREAD_DCE_PTHREADS
+THREADSLIB= -lpthreads
+
+# the BSD-like install under OSF/1 is called installbsd
+INSTALL=installbsd
+

------- End of Forwarded Message