Includes everything but ldapext & ldap.conf changes.
OpenLDAP Change Log
Changes included in OpenLDAP 1.1-Alpha (from -devel)
- CVS Tag: OPENLDAP_REL_ENG_1_1
+ CVS Tag: OPENLDAP_REL_ENG_1_1_ALPHA3
Changed LDBM default to sync on writes
Added mail500 BOUNCEFROM patch
Added dbcachenowsync option
Fixed slapd/ldbm id2children bug
Fixed slapd/shell newline bug
Fixed whois++ get_dn leak
- Fixed DEC OSF1 (alpha) support
+ Fixed pointer truncation to int bugs
+ Fixed DEC OSF/1 support bugs
Fixed r/w lock initialization on non-final Pthreads
Fixed slapd/slurpd file unlock bugs
Fixed slurpd string translation bug
Added pwd.h & getpwuid() tests
Added sys/resource.h test
Updated NT support (now builds ud)
+ Added function prototypes
+ Removed library externs
Removed lint
--- /dev/null
+#ifndef FAX500_H
+#define FAX500_H 1
+
+/* in faxtotpc.c */
+void strip_nonnum ( char *str );
+char *remove_parens( char *ibuf, char *obuf );
+char *munge_phone ( char *ibuf, char *obuf );
+char *faxtotpc ( char *phone, char *userinfo );
+
+#endif
#include "portable.h"
#include <stdio.h>
-#include <ctype.h>
-
#include <sys/types.h>
+
+#include <ac/ctype.h>
#include <ac/string.h>
+#include "fax500.h"
+
#define TPCDOMAIN "tpc.int"
/*
* Remove everything from 'str' which is not a digit
*/
-void strip_nonnum(str)
-char *str;
+void
+strip_nonnum( char *str )
{
char *p, *q;
p = q = str;
* Remove anything of the form (blah) where
* "blah" contains a non-numeric character.
*/
-char *remove_parens(ibuf, obuf)
-char *ibuf;
-char *obuf;
+char *
+remove_parens( char *ibuf, char *obuf )
{
char *p = ibuf;
char *q = obuf;
* 6 93
* 8 99
*/
-char *munge_phone(ibuf, obuf)
-char *ibuf;
-char *obuf;
+char *
+munge_phone( char *ibuf, char *obuf )
{
#define UMAREACODE "1313"
-
-
-
-
-
/*
* Convert string to "tpc.int" domain name.
*/
-char *faxtotpc(phone, userinfo)
-char *phone;
-char *userinfo;
+char *
+faxtotpc( char *phone, char *userinfo )
{
char *p;
char *q;
strcat(obuf, TPCDOMAIN); /* tack on domain name */
p = strdup(obuf);
return(p);
-
}
#include <stdio.h>
#include <stdlib.h>
-#include <ctype.h>
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/syslog.h>
#include <ac/time.h>
#include <ac/wait.h>
+#include <ac/unistd.h>
+#include <ac/errno.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
-
+#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
+#endif
+
#include <sysexits.h>
#include "lber.h"
#include "ldap.h"
+
+#include "fax500.h"
+
#include <ldapconfig.h>
#define USER 0
char *mailfrom = NULL;
char *host = NULL;
int hostlen = 0;
-char *faxtotpc();
int identity;
#define MAIL500 1
"rfc822RequestsTo", "joinable", "cn", "member",
"facsimileTelephoneNumber", NULL };
-static do_address();
-static do_group();
-static do_group_members();
-static send_message();
-static send_errors();
-static do_noemailorfax();
-static do_ambiguous();
-static add_to();
-static isgroup();
-static add_error();
-static add_group();
-static unbind_and_exit();
-static group_loop();
-static send_group();
-static has_attributes();
-static char **get_attributes_mail_dn();
-static char *canonical();
-
-main (argc, argv)
-int argc;
-char **argv;
+
+static void do_address(char *name, char ***to, int *nto, Group **togroups, int *ngroups, Error **err, int *nerr, int type);
+static int do_group(LDAPMessage *e, char *dn, char ***to, int *nto, Group **togroups, int *ngroups, Error **err, int *nerr);
+static void do_group_members(LDAPMessage *e, char *dn, char ***to, int *nto, Group **togroups, int *ngroups, Error **err, int *nerr);
+static void send_message(char **to);
+static void send_errors(Error *err, int nerr);
+static void do_noemailorfax(FILE *fp, Error *err, int namelen, int errtype);
+static void do_ambiguous(FILE *fp, Error *err, int namelen);
+static int count_values(char **list);
+static void add_to(char ***list, int *nlist, char **new);
+static int isgroup(LDAPMessage *e);
+static void add_error(Error **err, int *nerr, int code, char *addr, LDAPMessage *msg);
+static void add_group(char *dn, Group **list, int *nlist);
+static void unbind_and_exit(int rc);
+static int group_loop(char *dn);
+static void send_group(Group *group, int ngroup);
+static int has_attributes(LDAPMessage *e, char *attr1, char *attr2);
+static char **get_attributes_mail_dn(LDAPMessage *e, char *attr1, char *attr2);
+static char *canonical(char *s);
+static int connect_to_x500 (void);
+static void do_group_errors (LDAPMessage *e, char *dn, char ***to, int *nto, Error **err, int *nerr);
+static void do_group_request (LDAPMessage *e, char *dn, char ***to, int *nto, Error **err, int *nerr);
+static void add_member (char *gdn, char *dn, char ***to, int *nto, Group **togroups, int *ngroups, Error **err, int *nerr);
+
+
+int
+main ( int argc, char **argv )
{
char *myname;
char **tolist;
Group *togroups;
int numto, ngroups, numerr, nargs;
int i, j;
- FILE *fp;
- extern int optind, errno;
- extern char *optarg;
while ( (i = getopt( argc, argv, "f:h:m:" )) != EOF ) {
switch( i ) {
*/
if ( numerr > 0 && numto > nargs || ngroups > 0 ) {
- int fd;
+ FILE *fp;
char buf[BUFSIZ];
umask( 077 );
return( EX_OK );
}
-connect_to_x500()
+static int
+connect_to_x500( void )
{
if ( (ld = ldap_open( LDAPHOST, LDAP_PORT )) == NULL ) {
syslog( LOG_ALERT, "ldap_open failed" );
}
-static
-do_address( name, to, nto, togroups, ngroups, err, nerr, type )
- char *name;
- char ***to;
- int *nto;
- Group **togroups;
- int *ngroups;
- Error **err;
- int *nerr;
- int type;
+static void
+do_address(
+ char *name,
+ char ***to,
+ int *nto,
+ Group **togroups,
+ int *ngroups,
+ Error **err,
+ int *nerr,
+ int type
+)
{
int rc, b, f, match;
LDAPMessage *e, *res;
return;
}
-static
-do_group( e, dn, to, nto, togroups, ngroups, err, nerr )
- LDAPMessage *e;
- char *dn;
- char ***to;
- int *nto;
- Group **togroups;
- int *ngroups;
- Error **err;
- int *nerr;
+static int
+do_group(
+ LDAPMessage *e,
+ char *dn,
+ char ***to,
+ int *nto,
+ Group **togroups,
+ int *ngroups,
+ Error **err,
+ int *nerr
+)
{
/*
* If this group has an rfc822ErrorsTo attribute, we need to
}
/* ARGSUSED */
-static
-do_group_members( e, dn, to, nto, togroups, ngroups, err, nerr )
- LDAPMessage *e;
- char *dn;
- char ***to;
- int *nto;
- Group **togroups;
- int *ngroups;
- Error **err;
- int *nerr;
+static void
+do_group_members(
+ LDAPMessage *e,
+ char *dn,
+ char ***to,
+ int *nto,
+ Group **togroups,
+ int *ngroups,
+ Error **err,
+ int *nerr
+)
{
int i, rc;
char *ndn;
return;
}
-add_member( gdn, dn, to, nto, togroups, ngroups, err, nerr )
- char *gdn;
- char *dn;
- char ***to;
- int *nto;
- Group **togroups;
- int *ngroups;
- Error **err;
- int *nerr;
+static void
+add_member(
+ char *gdn,
+ char *dn,
+ char ***to,
+ int *nto,
+ Group **togroups,
+ int *ngroups,
+ Error **err,
+ int *nerr
+)
{
char *ndn;
char **mail;
return;
}
-do_group_request( e, dn, to, nto, err, nerr )
- LDAPMessage *e;
- char *dn;
- char ***to;
- int *nto;
- Error **err;
- int *nerr;
+static void
+do_group_request(
+ LDAPMessage *e,
+ char *dn,
+ char ***to,
+ int *nto,
+ Error **err,
+ int *nerr
+)
{
char **requeststo;
} else {
add_error( err, nerr, E_NOREQUEST, dn, NULLMSG );
}
-
- return;
}
-do_group_errors( e, dn, to, nto, err, nerr )
- LDAPMessage *e;
- char *dn;
- char ***to;
- int *nto;
- Error **err;
- int *nerr;
+static void
+do_group_errors(
+ LDAPMessage *e,
+ char *dn,
+ char ***to,
+ int *nto,
+ Error **err,
+ int *nerr
+)
{
char **errorsto;
} else {
add_error( err, nerr, E_NOERRORS, dn, NULLMSG );
}
-
- return;
}
-static
-send_message( to )
- char **to;
+static void
+send_message( char **to )
{
int pid;
#ifndef HAVE_WAITPID
/* parent */
- if ( pid = fork() ) {
+ if ( (pid = fork()) != 0 ) {
#ifdef HAVE_WAITPID
waitpid( pid, (int *) NULL, 0 );
#else
}
}
-static
-send_group( group, ngroup )
- Group *group;
- int ngroup;
+static void
+send_group( Group *group, int ngroup )
{
int i, pid;
char **argv;
/* parent */
- if ( pid = fork() ) {
+ if ( (pid = fork()) != 0 ) {
#ifdef HAVE_WAITPID
waitpid( pid, (int *) NULL, 0 );
#else
return;
}
-static
-send_errors( err, nerr )
- Error *err;
- int nerr;
+static void
+send_errors( Error *err, int nerr )
{
int i, namelen;
FILE *fp;
}
-static
-do_noemailorfax( fp, err, namelen, errtype )
- FILE *fp;
- Error *err;
- int namelen;
- int errtype;
+static void
+do_noemailorfax( FILE *fp, Error *err, int namelen, int errtype )
{
int i, last;
char *dn, *rdn;
}
/* ARGSUSED */
-static
-do_ambiguous( fp, err, namelen )
- FILE *fp;
- Error *err;
- int namelen;
+static void
+do_ambiguous( FILE *fp, Error *err, int namelen )
{
int i, last;
char *dn, *rdn;
}
}
-static
-count_values( list )
- char **list;
+static int
+count_values( char **list )
{
int i;
return( i );
}
-static
-add_to( list, nlist, new )
- char ***list;
- int *nlist;
- char **new;
+static void
+add_to( char ***list, int *nlist, char **new )
{
int i, nnew, oldnlist;
return;
}
-static
-isgroup( e )
- LDAPMessage *e;
+static int
+isgroup( LDAPMessage *e )
{
int i;
char **oclist;
return( 0 );
}
-static
-add_error( err, nerr, code, addr, msg )
- Error **err;
- int *nerr;
- int code;
- char *addr;
- LDAPMessage *msg;
+static void
+add_error( Error **err, int *nerr, int code, char *addr, LDAPMessage *msg )
{
if ( *nerr == 0 ) {
*err = (Error *) malloc( sizeof(Error) );
return;
}
-static
-add_group( dn, list, nlist )
- char *dn;
- Group **list;
- int *nlist;
+static void
+add_group( char *dn, Group **list, int *nlist )
{
int i, namelen;
char **ufn;
return;
}
-static
-unbind_and_exit( rc )
- int rc;
+static void
+unbind_and_exit( int rc )
{
int i;
}
static char *
-canonical( s )
- char *s;
+canonical( char *s )
{
char *saves = s;
return( saves );
}
-static
-group_loop( dn )
- char *dn;
+static int
+group_loop( char *dn )
{
int i;
static char **groups;
return( 0 );
}
-static
-has_attributes( e, attr1, attr2 )
- LDAPMessage *e;
- char *attr1;
- char *attr2;
+static int
+has_attributes( LDAPMessage *e, char *attr1, char *attr2 )
{
char **attr;
}
static char **
-get_attributes_mail_dn( e, attr1, attr2 )
- LDAPMessage *e;
- char *attr1;
- char *attr2; /* this one is dn-valued */
+get_attributes_mail_dn( LDAPMessage *e, char *attr1, char *attr2 )
{
LDAPMessage *ee, *res;
char **vals, **dnlist, **mail;
#include "portable.h"
-#include <stdio.h>
-#include <signal.h>
+#include <stdlib.h>
+#include <ac/signal.h>
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/syslog.h>
#include <ac/time.h>
+#include <ac/unistd.h>
#include <ac/wait.h>
+#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
+#endif
#include <lber.h>
#include <ldap.h>
+#include "fax500.h"
+
#include <ldapconfig.h>
#define DEFAULT_PORT 79
int sizelimit;
LDAPFiltDesc *filtd;
-static print_entry();
+static void print_entry(LDAP *ld, LDAPMessage *e);
-static
-usage( name )
- char *name;
+static void
+usage( char *name )
{
fprintf( stderr, "usage: %s [-d debuglevel] [-x ldaphost] [-b searchbase] [-a] [-z sizelimit] [-f filterfile] searchstring\r\n", name );
exit( -1 );
}
-main (argc, argv)
- int argc;
- char **argv;
+int
+main( int argc, char **argv )
{
int i, rc, matches;
char *filterfile = FILTERFILE;
- struct timeval timeout;
char buf[10];
char *key;
LDAP *ld;
static char *attrs[] = { "title", "o", "ou", "postalAddress",
"telephoneNumber", "mail",
"facsimileTelephoneNumber", NULL };
- extern char *optarg;
- extern int optind;
deref = LDAP_DEREF_ALWAYS;
while ( (i = getopt( argc, argv, "ab:d:f:x:z:" )) != EOF ) {
rdn++;
if ( strcasecmp( rdn, buf ) == 0 ) {
char **cn;
- char *s;
int i, last;
cn = ldap_get_values( ld, e, "cn" );
return( 0 );
}
-static
-print_entry( ld, e )
- LDAP *ld;
- LDAPMessage *e;
+static void
+print_entry( LDAP *ld, LDAPMessage *e )
{
int i;
char *dn, *rdn;
char **ufn;
char **title, **dept, **addr, **phone, **fax, **mail;
- char *faxmail, *org, *faxtotpc();
+ char *faxmail, *org;
dn = ldap_get_dn( ld, e );
ufn = ldap_explode_dn( dn, 0 );
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <ac/ctype.h>
+#include <ac/signal.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/syslog.h>
+#include <ac/time.h>
+#include <ac/unistd.h>
+#include <ac/wait.h>
+
+#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#endif
+
#include "lber.h"
#include "ldap.h"
#include "disptmpl.h"
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <syslog.h>
-#include <sys/resource.h>
-#include <sys/wait.h>
-#ifdef aix
-#include <sys/select.h>
-#endif /* aix */
-#include <signal.h>
-#include "portable.h"
+
#include "ldapconfig.h"
-#ifdef USE_SYSCONF
-#include <unistd.h>
-#endif /* USE_SYSCONF */
int dosyslog = 1;
char *ldaphost = LDAPHOST;
char *templatefile = TEMPLATEFILE;
int rdncount = FINGER_RDNCOUNT;
-static do_query();
-static do_search();
-static do_read();
-static print_attr();
+static void do_query(void);
+static void do_search(LDAP *ld, char *buf);
+static void do_read(LDAP *ld, LDAPMessage *e);
-static usage( name )
-char *name;
+static void
+usage( char *name )
{
fprintf( stderr, "usage: %s [-l] [-x ldaphost] [-p ldapport] [-f filterfile] [-t templatefile] [-c rdncount]\r\n", name );
exit( 1 );
}
-main (argc, argv)
-int argc;
-char **argv;
+int
+main( int argc, char **argv )
{
int i;
char *myname;
struct sockaddr_in peername;
int peernamelen;
int interactive = 0;
- extern char *optarg;
deref = FINGER_DEREF;
while ( (i = getopt( argc, argv, "f:ilp:t:x:p:c:" )) != EOF ) {
#endif
}
- if ( dosyslog && mypeer != -1 ) {
+ if ( dosyslog && mypeer != (unsigned long) -1 ) {
struct in_addr addr;
hp = gethostbyaddr( (char *) &mypeer, sizeof(mypeer), AF_INET );
return( 0 );
}
-static do_query()
+static void
+do_query( void )
{
char buf[256];
int len, rc, tblsize;
ld->ld_sizelimit = FINGER_SIZELIMIT;
ld->ld_deref = deref;
- if ( ldap_simple_bind_s( ld, FINGER_BINDDN, NULL ) != LDAP_SUCCESS ) {
+ if ( ldap_simple_bind_s( ld, FINGER_BINDDN, FINGER_BIND_CRED )
+ != LDAP_SUCCESS )
+ {
fprintf( stderr, FINGER_UNAVAILABLE );
ldap_perror( ld, "ldap_simple_bind_s" );
exit( 1 );
}
-#ifdef USE_SYSCONF
+#ifdef HAVE_SYSCONF
tblsize = sysconf( _SC_OPEN_MAX );
-#else /* USE_SYSCONF */
+#elif HAVE_GETDTABLESIZE
tblsize = getdtablesize();
-#endif /* USE_SYSCONF */
+#else
+ tblsize = FD_SETSIZE;
+#endif
+
+#ifdef FD_SETSIZE
+ if (tblsize > FD_SETSIZE) {
+ tblsize = FD_SETSIZE;
+ }
+#endif /* FD_SETSIZE*/
timeout.tv_sec = FINGER_TIMEOUT;
timeout.tv_usec = 0;
}
static void
-spaces2dots( s )
- char *s;
+spaces2dots( char *s )
{
for ( ; *s; s++ ) {
if ( *s == ' ' ) {
}
}
-static do_search( ld, buf )
-LDAP *ld;
-char *buf;
+static void
+do_search( LDAP *ld, char *buf )
{
char *dn, *rdn;
char **title;
FINGER_SORT_ATTR,
#endif
0 };
- extern int strcasecmp();
ufn = 0;
#ifdef FINGER_UFN
}
-static do_read( ld, e )
-LDAP *ld;
-LDAPMessage *e;
+static void
+do_read( LDAP *ld, LDAPMessage *e )
{
static struct ldap_disptmpl *tmpllist;
static char *defattrs[] = { "mail", NULL };
+++ /dev/null
-/*
- * Copyright (c) 1990, 1994 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/file.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-#include <signal.h>
-#include "portable.h"
-
-#ifdef USE_SYSCONF
-#include <unistd.h>
-#endif /* USE_SYSCONF */
-
-detach( debug )
-int debug;
-{
- int i, sd, nbits;
-
-#ifdef USE_SYSCONF
- nbits = sysconf( _SC_OPEN_MAX );
-#else /* USE_SYSCONF */
- nbits = getdtablesize();
-#endif /* USE_SYSCONF */
-
- if ( debug == 0 || !(isatty( 1 )) ) {
- for ( i = 0; i < 5; i++ ) {
- switch ( fork() ) {
- case -1:
- sleep( 5 );
- continue;
-
- case 0:
- break;
-
- default:
- _exit( 0 );
- }
- break;
- }
-
- for ( i = 3; i < nbits; i++ )
- close( i );
-
- (void) chdir( "/" );
-
- if ( (sd = open( "/dev/null", O_RDWR )) == -1 ) {
- if ( debug ) perror( "/dev/null" );
- exit( 1 );
- }
- if ( isatty( 0 ) )
- (void) dup2( sd, 0 );
- if ( isatty( 1 ) )
- (void) dup2( sd, 1 );
- if ( isatty(2) )
- (void) dup2( sd, 2 );
- close( sd );
-
-#ifdef USE_SETSID
- (void) setsid();
-#else /* USE_SETSID */
- if ( (sd = open( "/dev/tty", O_RDWR )) != -1 ) {
- (void) ioctl( sd, TIOCNOTTY, NULL );
- (void) close( sd );
- }
-#endif /* USE_SETSID */
- }
-
- (void) signal( SIGPIPE, SIG_IGN );
-}
#include "portable.h"
#include <stdio.h>
+#include <stdlib.h>
#include <ac/ctype.h>
#include <ac/signal.h>
#include <sys/param.h>
#endif
+#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
+#endif
#include "ldapconfig.h"
#include "lber.h"
char myhost[MAXHOSTNAMELEN];
int myport;
-static set_socket();
-static RETSIGTYPE wait4child();
-static do_queries();
-static do_error();
-static do_search();
-static do_read();
-extern int strcasecmp();
+static void usage ( char *name );
+static int set_socket (int port);
+static RETSIGTYPE wait4child(int sig);
+static void do_queries (int s);
+static void do_error (FILE *fp, char *s);
+static void do_search (LDAP *ld, FILE *fp, char *buf);
+static void do_read (LDAP *ld, FILE *fp, char *dn);
-static usage( name )
-char *name;
+static void
+usage( char *name )
{
fprintf( stderr, "usage: %s [-d debuglevel] [-f filterfile] [-t templatefile]\r\n\t[-a] [-l] [-p port] [-x ldaphost] [-b searchbase] [-c rdncount]\r\n", name );
exit( 1 );
}
-main (argc, argv)
-int argc;
-char **argv;
+int
+main( int argc, char **argv )
{
int s, ns, rc;
int port = -1;
struct hostent *hp;
struct sockaddr_in from;
int fromlen;
- RETSIGTYPE wait4child();
- extern char *optarg;
#if defined( LDAP_PROCTITLE ) && !defined( HAVE_SETPROCTITLE )
/* for setproctitle */
/* NOT REACHED */
}
-static
-set_socket( port )
-int port;
+static int
+set_socket( int port )
{
int s, one;
struct sockaddr_in addr;
}
static RETSIGTYPE
-wait4child()
+wait4child( int sig )
{
#ifndef HAVE_WAITPID
WAITSTATUSTYPE status;
(void) SIGNAL( SIGCHLD, wait4child );
}
-static
-do_queries( s )
-int s;
+static void
+do_queries( int s )
{
char buf[1024], *query;
int len;
fprintf( fp, ".\r\n" );
rewind(fp);
- if( ld == NULL ) {
+ if ( ld != NULL) {
ldap_unbind( ld );
}
/* NOT REACHED */
}
-static
-do_error( fp, s )
-FILE *fp;
-char *s;
+static void
+do_error( FILE *fp, char *s )
{
int code;
fprintf( fp, ".\r\n" );
}
-static
-do_search( ld, fp, buf )
-LDAP *ld;
-FILE *fp;
-char *buf;
+static void
+do_search( LDAP *ld, FILE *fp, char *buf )
{
char *dn, *rdn;
char **title;
static int
entry2textwrite( void *fp, char *buf, int len )
{
- return( fwrite( buf, len, 1, (FILE *)fp ) == 0 ? -1 : len );
+ return( fwrite( buf, len, 1, (FILE *)fp ) == 0 ? -1 : len );
}
-static
-do_read( ld, fp, dn )
-LDAP *ld;
-FILE *fp;
-char *dn;
+static void
+do_read( LDAP *ld, FILE *fp, char *dn )
{
static struct ldap_disptmpl *tmpllist;
#include "portable.h"
#include <stdio.h>
+#include <stdlib.h>
#include <ac/ctype.h>
#include <ac/signal.h>
#include <ac/setproctitle.h>
-#include <sys/resource.h>
-
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
+#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#endif
+
+
#include "lber.h"
#include "ldap.h"
#include "lutil.h"
char *friendlyfile = FRIENDLYFILE;
int rdncount = GO500GW_RDNCOUNT;
-static set_socket();
-static RETSIGTYPE wait4child();
-static do_queries();
-static do_menu();
-static do_list();
-static do_search();
-static do_read();
-static do_help();
-static do_sizelimit();
-static do_error();
-extern int strcasecmp();
+static void usage ( char *name );
+static int set_socket (int port);
+static RETSIGTYPE wait4child(int sig);
+static void do_queries (int s);
+static char *pick_oc ( char **oclist );
+static int isnonleaf ( LDAP *ld, char **oclist, char *dn );
+static void do_menu (LDAP *ld, FILE *fp, char *dn);
+static void do_list (LDAP *ld, FILE *fp, char *dn);
+static int isoc ( char **ocl, char *oc );
+static int make_scope ( LDAP *ld, char *dn );
+static void do_search (LDAP *ld, FILE *fp, char *query);
+static int entry2textwrite( void *fp, char *buf, int len );
+static void do_read (LDAP *ld, FILE *fp, char *dn);
+static void do_help (FILE *op);
+static void do_sizelimit(FILE *fp, char type);
+static void do_error (FILE *fp, char *s);
char myhost[MAXHOSTNAMELEN];
int myport = GO500GW_PORT;
-static usage( name )
-char *name;
+static void
+usage( char *name )
{
fprintf( stderr, "usage: %s [-d debuglevel] [-I] [-p port] [-P ldapport] [-l]\r\n\t[-x ldaphost] [-a] [-h helpfile] [-f filterfile] [-t templatefile] [-c rdncount]\r\n", name );
exit( 1 );
}
-main (argc, argv)
-int argc;
-char **argv;
+int
+main (int argc, char **argv )
{
int s, ns, rc;
int port = -1;
struct hostent *hp;
struct sockaddr_in from;
int fromlen;
- RETSIGTYPE wait4child();
- extern char *optarg;
#if defined( LDAP_PROCTITLE ) && !defined( HAVE_SETPROCTITLE )
/* for setproctitle */
/* NOT REACHED */
}
-static set_socket( port )
-int port;
+static int
+set_socket( int port )
{
int s, one;
struct sockaddr_in addr;
}
static RETSIGTYPE
-wait4child()
+wait4child( int sig )
{
#ifndef HAVE_WAITPID
WAITSTATUSTYPE status;
(void) SIGNAL( SIGCHLD, wait4child );
}
-static do_queries( s )
-int s;
+static void
+do_queries( int s )
{
char buf[1024], *query;
int len;
break;
case 'S': /* search */
- do_search( ld, fp, query, 1 );
+ do_search( ld, fp, query );
break;
case 'M': /* X.500 menu */
/* NOT REACHED */
}
-static char *pick_oc( oclist )
-char **oclist;
+static char *
+pick_oc( char **oclist )
{
int i;
return( "unknown" );
}
-static isnonleaf( ld, oclist, dn )
-LDAP *ld;
-char **oclist;
-char *dn;
+static int
+isnonleaf( LDAP *ld, char **oclist, char *dn )
{
int i, quipuobject = 0;
#endif
}
-static do_menu( ld, fp, dn )
-LDAP *ld;
-FILE *fp;
-char *dn;
+static void
+do_menu( LDAP *ld, FILE *fp, char *dn )
{
char **s;
char *rdn = NULL;
ldap_free_friendlymap( &fm );
}
-static do_list( ld, fp, dn )
-LDAP *ld;
-FILE *fp;
-char *dn;
+static void
+do_list( LDAP *ld, FILE *fp, char *dn )
{
int rc;
LDAPMessage *e, *res;
}
}
-static isoc( ocl, oc )
-char **ocl;
-char *oc;
+static int
+isoc( char **ocl, char *oc )
{
int i;
return( 0 );
}
-static int make_scope( ld, dn )
-LDAP *ld;
-char *dn;
+static int
+make_scope( LDAP *ld, char *dn )
{
int scope;
char **oc;
return( scope );
}
-static do_search( ld, fp, query )
-LDAP *ld;
-FILE *fp;
-char *query;
+static void
+do_search( LDAP *ld, FILE *fp, char *query )
{
int scope;
char *base, *filter;
!= LDAP_SUCCESS && rc != LDAP_SIZELIMIT_EXCEEDED ) {
fprintf(fp, "0An error occurred (explanation)\tE%d\t%s\t%d\r\n",
rc, myhost, myport );
- return( 1 );
+ return;
}
if ( (count = ldap_count_entries( ld, res )) != 0 )
break;
#endif
if ( count == 0 ) {
- return( 0 );
+ return;
}
if ( count == 1 ) {
dn = ldap_get_dn( ld, e );
if ( isnonleaf( ld, oc, dn ) ) {
- rc = do_menu( ld, fp, dn );
+ do_menu( ld, fp, dn );
free( dn );
- return( rc );
+ return;
}
free( dn );
return( fwrite( buf, len, 1, (FILE *)fp ) == 0 ? -1 : len );
}
-static do_read( ld, fp, dn )
-LDAP *ld;
-FILE *fp;
-char *dn;
+static void
+do_read( LDAP *ld, FILE *fp, char *dn )
{
static struct ldap_disptmpl *tmpllist;
}
}
-static do_help( op )
-FILE *op;
+static void
+do_help( FILE *op )
{
FILE *fp;
char line[BUFSIZ];
fclose( fp );
}
-static do_sizelimit( fp, type )
-FILE *fp;
-char type;
+static void
+do_sizelimit( FILE *fp, char type )
{
if ( type == 'S' ) {
fprintf( fp, "The query you specified was not specific enough, causing a size limit\r\n" );
fprintf( fp, ".\r\n" );
}
-static do_error( fp, s )
-FILE *fp;
-char *s;
+static void
+do_error( FILE *fp, char *s )
{
int code;
+++ /dev/null
-/*
- * Copyright (c) 1990,1991 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-char **Argv; /* pointer to original (main's) argv */
-int Argc; /* original argc */
-
-/*
- * takes a printf-style format string (fmt) and up to three parameters (a,b,c)
- * this clobbers the original argv...
- */
-
-/* VARARGS */
-setproctitle( fmt, a, b, c )
-char *fmt;
-{
- static char *endargv = (char *)0;
- char *s;
- int i;
- char buf[ 1024 ];
-
- if ( endargv == (char *)0 ) {
- /* set pointer to end of original argv */
- endargv = Argv[ Argc-1 ] + strlen( Argv[ Argc-1 ] );
- }
- sprintf( buf, fmt, a, b, c );
- /* make ps print "([prog name])" */
- s = Argv[0];
- *s++ = '-';
- i = strlen( buf );
- if ( i > endargv - s - 2 ) {
- i = endargv - s - 2;
- buf[ i ] = '\0';
- }
- strcpy( s, buf );
- s += i;
- while ( s < endargv ) *s++ = ' ';
-}
#include <stdio.h>
#include <stdlib.h>
-#include <ctype.h>
+#include <ac/ctype.h>
#include <ac/string.h>
#include <ac/syslog.h>
#include <ac/time.h>
#include <ac/wait.h>
+#include <ac/unistd.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
+#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
+#endif
#include <sysexits.h>
"moderator", "onVacation", "uid",
"suppressNoEmailError", NULL };
-static do_address();
-static do_group();
-static do_group_members();
-static send_message();
-static send_errors();
-static do_noemail();
-static do_ambiguous();
-static add_to();
-static isgroup();
-static add_error();
-static add_group();
-static unbind_and_exit();
-static group_loop();
-static send_group();
-static has_attributes();
-static char **get_attributes_mail_dn();
-static char *canonical();
-
-main (argc, argv)
-int argc;
-char **argv;
+static void do_address( char *name, char ***to, int *nto, Group **togroups, int *ngroups, Error **err, int *nerr, int type );
+static int do_group( LDAPMessage *e, char *dn, char ***to, int *nto, Group **togroups, int *ngroups, Error **err, int *nerr );
+static void do_group_members( LDAPMessage *e, char *dn, char ***to, int *nto, Group **togroups, int *ngroups, Error **err, int *nerr );
+static void send_message( char **to );
+static void send_errors( Error *err, int nerr );
+static void do_noemail( FILE *fp, Error *err, int namelen );
+static void do_ambiguous( FILE *fp, Error *err, int namelen );
+static void add_to( char ***list, int *nlist, char **new );
+static int isgroup( LDAPMessage *e );
+static void add_error( Error **err, int *nerr, int code, char *addr, LDAPMessage *msg );
+static void add_group( char *dn, Group **list, int *nlist );
+static void unbind_and_exit( int rc );
+static int group_loop( char *dn );
+static void send_group( Group *group, int ngroup );
+static int has_attributes( LDAPMessage *e, char *attr1, char *attr2 );
+static char **get_attributes_mail_dn( LDAPMessage *e, char *attr1, char *attr2 );
+static char *canonical( char *s );
+static int connect_to_x500( void );
+
+static void do_group_errors( LDAPMessage *e, char *dn, char ***to, int *nto, Error **err, int *nerr );
+static void do_group_request( LDAPMessage *e, char *dn, char ***to, int *nto, Error **err, int *nerr );
+static void do_group_owner( LDAPMessage *e, char *dn, char ***to, int *nto, Error **err, int *nerr );
+static void add_member( char *gdn, char *dn, char ***to, int *nto, Group **togroups, int *ngroups, Error **err, int *nerr, char **suppress );
+
+int
+main ( int argc, char **argv )
{
char *myname;
char **tolist;
Group *togroups;
int numto, ngroups, numerr, nargs;
int i, j;
- FILE *fp;
- extern int optind, errno;
- extern char *optarg;
if ( (myname = strrchr( argv[0], '/' )) == NULL )
myname = strdup( argv[0] );
*/
if ( numerr > 0 && numto > nargs || ngroups > 0 ) {
- int fd;
+ FILE *fp;
char buf[BUFSIZ];
umask( 077 );
return( EX_OK );
}
-connect_to_x500()
+static int
+connect_to_x500( void )
{
if ( (ld = ldap_open( ldaphost, LDAP_PORT )) == NULL ) {
syslog( LOG_ALERT, "ldap_open failed" );
return( 0 );
}
-static
-mailcmp( a, b )
- char *a;
- char *b;
+static int
+mailcmp( char *a, char *b )
{
int i;
return( 0 );
}
-static
-do_address( name, to, nto, togroups, ngroups, err, nerr, type )
- char *name;
- char ***to;
- int *nto;
- Group **togroups;
- int *ngroups;
- Error **err;
- int *nerr;
- int type;
+static void
+do_address(
+ char *name,
+ char ***to,
+ int *nto,
+ Group **togroups,
+ int *ngroups,
+ Error **err,
+ int *nerr,
+ int type
+)
{
int rc, b, f, match;
LDAPMessage *e, *res;
ldap_value_free( uid );
}
free( dn );
-
- return;
}
-static
-do_group( e, dn, to, nto, togroups, ngroups, err, nerr )
- LDAPMessage *e;
- char *dn;
- char ***to;
- int *nto;
- Group **togroups;
- int *ngroups;
- Error **err;
- int *nerr;
+static int
+do_group(
+ LDAPMessage *e,
+ char *dn,
+ char ***to,
+ int *nto,
+ Group **togroups,
+ int *ngroups,
+ Error **err,
+ int *nerr
+)
{
int i;
char **moderator;
}
/* ARGSUSED */
-static
-do_group_members( e, dn, to, nto, togroups, ngroups, err, nerr )
- LDAPMessage *e;
- char *dn;
- char ***to;
- int *nto;
- Group **togroups;
- int *ngroups;
- Error **err;
- int *nerr;
+static void
+do_group_members(
+ LDAPMessage *e,
+ char *dn,
+ char ***to,
+ int *nto,
+ Group **togroups,
+ int *ngroups,
+ Error **err,
+ int *nerr
+)
{
int i, rc, anymembers;
char *ndn;
if ( ! anymembers ) {
add_error( err, nerr, E_NOMEMBERS, dn, NULLMSG );
}
-
- return;
}
-add_member( gdn, dn, to, nto, togroups, ngroups, err, nerr, suppress )
- char *gdn;
- char *dn;
- char ***to;
- int *nto;
- Group **togroups;
- int *ngroups;
- Error **err;
- int *nerr;
- char **suppress;
+static void
+add_member(
+ char *gdn,
+ char *dn,
+ char ***to,
+ int *nto,
+ Group **togroups,
+ int *ngroups,
+ Error **err,
+ int *nerr,
+ char **suppress
+)
{
char *ndn;
char **mail;
}
free( ndn );
-
- return;
}
-do_group_request( e, dn, to, nto, err, nerr )
- LDAPMessage *e;
- char *dn;
- char ***to;
- int *nto;
- Error **err;
- int *nerr;
+static void
+do_group_request(
+ LDAPMessage *e,
+ char *dn,
+ char ***to,
+ int *nto,
+ Error **err,
+ int *nerr
+)
{
char **requeststo;
} else {
add_error( err, nerr, E_NOREQUEST, dn, NULLMSG );
}
-
- return;
}
-do_group_errors( e, dn, to, nto, err, nerr )
- LDAPMessage *e;
- char *dn;
- char ***to;
- int *nto;
- Error **err;
- int *nerr;
+static void
+do_group_errors(
+ LDAPMessage *e,
+ char *dn,
+ char ***to,
+ int *nto,
+ Error **err,
+ int *nerr
+)
{
char **errorsto;
} else {
add_error( err, nerr, E_NOERRORS, dn, NULLMSG );
}
-
- return;
}
-do_group_owner( e, dn, to, nto, err, nerr )
- LDAPMessage *e;
- char *dn;
- char ***to;
- int *nto;
- Error **err;
- int *nerr;
+static void
+do_group_owner(
+ LDAPMessage *e,
+ char *dn,
+ char ***to,
+ int *nto,
+ Error **err,
+ int *nerr
+)
{
char **owner;
} else {
add_error( err, nerr, E_NOOWNER, dn, NULLMSG );
}
- return;
}
-static
-send_message( to )
- char **to;
+static void
+send_message( char **to )
{
int pid;
#ifndef HAVE_WAITPID
}
/* parent */
- if ( pid = fork() ) {
+ if ( (pid = fork()) != 0 ) {
#ifdef HAVE_WAITPID
waitpid( pid, (int *) NULL, 0 );
#else
}
}
-static
-send_group( group, ngroup )
- Group *group;
- int ngroup;
+static void
+send_group( Group *group, int ngroup )
{
int i, pid;
char **argv;
}
/* parent */
- if ( pid = fork() ) {
+ if ( (pid = fork()) != 0 ) {
#ifdef HAVE_WAITPID
waitpid( pid, (int *) NULL, 0 );
#else
exit( EX_TEMPFAIL );
}
}
-
- return;
}
-static
-send_errors( err, nerr )
- Error *err;
- int nerr;
+static void
+send_errors( Error *err, int nerr )
{
int pid, i, namelen;
FILE *fp;
exit( EX_TEMPFAIL );
}
- if ( pid = fork() ) {
+ if ( (pid = fork()) != 0 ) {
if ( (fp = fdopen( fd[1], "w" )) == NULL ) {
syslog( LOG_ALERT, "cannot fdopen pipe" );
exit( EX_TEMPFAIL );
exit( EX_TEMPFAIL );
}
-
- return;
}
-static
-do_noemail( fp, err, namelen )
- FILE *fp;
- Error *err;
- int namelen;
+static void
+do_noemail( FILE *fp, Error *err, int namelen )
{
int i, last;
char *dn, *rdn;
}
/* ARGSUSED */
-static
-do_ambiguous( fp, err, namelen )
- FILE *fp;
- Error *err;
- int namelen;
+static void
+do_ambiguous( FILE *fp, Error *err, int namelen )
{
int i, last;
char *dn, *rdn;
}
}
-static
-count_values( list )
- char **list;
+static int
+count_values( char **list )
{
int i;
return( i );
}
-static
-add_to( list, nlist, new )
- char ***list;
- int *nlist;
- char **new;
+static void
+add_to( char ***list, int *nlist, char **new )
{
int i, nnew, oldnlist;
for ( i = 0; i < nnew; i++ )
(*list)[i + oldnlist] = strdup( new[i] );
(*list)[*nlist] = NULL;
-
- return;
}
-static
-isgroup( e )
- LDAPMessage *e;
+static int
+isgroup( LDAPMessage *e )
{
int i;
char **oclist;
return( 0 );
}
-static
-add_error( err, nerr, code, addr, msg )
- Error **err;
- int *nerr;
- int code;
- char *addr;
- LDAPMessage *msg;
+static void
+add_error( Error **err, int *nerr, int code, char *addr, LDAPMessage *msg )
{
if ( *nerr == 0 ) {
*err = (Error *) malloc( sizeof(Error) );
(*err)[*nerr].e_addr = strdup( addr );
(*err)[*nerr].e_msg = msg;
(*nerr)++;
-
- return;
}
-static
-add_group( dn, list, nlist )
- char *dn;
- Group **list;
- int *nlist;
+static void
+add_group( char *dn, Group **list, int *nlist )
{
int i, namelen;
char **ufn;
(*nlist)++;
ldap_value_free( ufn );
-
- return;
}
-static
-unbind_and_exit( rc )
- int rc;
+static void
+unbind_and_exit( int rc )
{
int i;
}
static char *
-canonical( s )
- char *s;
+canonical( char *s )
{
char *saves = s;
return( saves );
}
-static
-group_loop( dn )
- char *dn;
+static int
+group_loop( char *dn )
{
int i;
static char **groups;
return( 0 );
}
-static
-has_attributes( e, attr1, attr2 )
- LDAPMessage *e;
- char *attr1;
- char *attr2;
+static int
+has_attributes( LDAPMessage *e, char *attr1, char *attr2 )
{
char **attr;
}
static char **
-get_attributes_mail_dn( e, attr1, attr2 )
- LDAPMessage *e;
- char *attr1;
- char *attr2; /* this one is dn-valued */
+get_attributes_mail_dn(
+ LDAPMessage *e,
+ char *attr1,
+ char *attr2 /* this one is dn-valued */
+)
{
LDAPMessage *ee, *res;
char **vals, **dnlist, **mail, **grname, **graddr;
* All Rights Reserved
*/
+#include "portable.h"
+
#include <stdio.h>
-#include <syslog.h>
-#include <string.h>
+
+#include <ac/syslog.h>
+#include <ac/string.h>
+#include <ac/unistd.h>
+
+#ifdef HAVE_FCNTL_H
#include <fcntl.h>
+#endif
-#include "portable.h"
#include "ldapconfig.h"
#include "rcpt500.h"
-extern int dosyslog;
-
int
-help_cmd( msgp, reply )
- struct msginfo *msgp;
- char *reply;
+help_cmd(struct msginfo *msgp, char *reply)
{
int fd, len;
#include <ac/ctype.h>
#include <ac/string.h>
#include <ac/syslog.h>
+#include <ac/unistd.h>
#include "ldapconfig.h"
#include "rcpt500.h"
char *dapuser = RCPT500_BINDDN;
char *filterfile = FILTERFILE;
char *templatefile = TEMPLATEFILE;
-char reply[ MAXSIZE * RCPT500_LISTLIMIT ];
-
+static char reply[ MAXSIZE * RCPT500_LISTLIMIT ];
/*
* functions
*/
-int read_msg();
-char *read_hdr();
-int send_reply();
+static int read_msg(FILE *fp, struct msginfo *msgp);
+static char *read_hdr(FILE *fp, int off, char *buf, int MAXSIZEe, char **ln_p);
+static int send_reply(struct msginfo *msgp, char *body);
+static int find_command(char *text, char **argp);
/*
* main is invoked by sendmail via the alias file
* the entire incoming message gets piped to our standard input
*/
-main( argc, argv )
- int argc;
- char **argv;
+int
+main( int argc, char **argv )
{
char *prog, *usage = "%s [-l] [-U] [-h ldaphost] [-p ldapport] [-b searchbase] [-a] [-z sizelimit] [-u dapuser] [-f filterfile] [-t templatefile] [-c rdncount]\n";
struct msginfo msg;
int c, errflg;
char *replytext;
- extern int optind;
- extern char *optarg;
-
*reply = '\0';
if (( prog = strrchr( argv[ 0 ], '/' )) == NULL ) {
}
-int
-read_msg( fp, msgp )
- FILE *fp;
- struct msginfo *msgp;
+static int
+read_msg( FILE *fp, struct msginfo *msgp )
{
char buf[ MAXSIZE ], *line;
int command = -1;
}
-char *
-read_hdr( fp, offset, buf, MAXSIZEe, linep )
- FILE *fp;
- int offset;
- char *buf;
- int MAXSIZEe;
- char **linep;
+static char *
+read_hdr( FILE *fp, int offset, char *buf, int MAXSIZEe, char **linep )
{
char *hdr;
}
-int
-send_reply( msgp, body )
- struct msginfo *msgp;
- char *body;
+static int
+send_reply( struct msginfo *msgp, char *body )
{
char buf[ MAXSIZE ];
FILE *cmdpipe;
}
-int
-find_command( text, argp )
- char *text;
- char **argp;
+static int
+find_command( char *text, char **argp )
{
int i;
char *s, *p;
* All Rights Reserved
*/
+#include "portable.h"
+
#include <stdio.h>
-#include <syslog.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/time.h>
+#include <stdlib.h>
+
+#include <ac/ctype.h>
+#include <ac/string.h>
+#include <ac/syslog.h>
+#include <ac/time.h>
#include "lber.h"
#include "ldap.h"
-#include "portable.h"
-#include "ldapconfig.h"
#include "disptmpl.h"
-#include "rcpt500.h"
-extern int dosyslog;
-extern int do_cldap;
-extern int rdncount;
-extern int derefaliases;
-extern int sizelimit;
-extern int ldapport;
-extern char *ldaphost;
-extern char *searchbase;
-extern char *dapuser;
-extern char *filterfile;
-extern char *templatefile;
+#include "rcpt500.h"
+#include "ldapconfig.h"
static char buf[ MAXSIZE ];
static char *errpreface = "Your query failed: ";
-extern int strcasecmp();
+static void close_ldap(LDAP *ld);
+static void append_entry_list(char *rep, char *qu, LDAP *ld, LDAPMessage *msg);
+static int append_text(void *reply, char *text, int len);
+static int do_read (LDAP *ld, char *dn, char *rep, struct ldap_disptmpl *tmp);
+static void report_ldap_err (LDAP *ldp, char *reply);
+static void remove_trailing_space (char *s);
void close_ldap();
int
-query_cmd( msgp, reply )
- struct msginfo *msgp;
- char *reply;
+query_cmd( struct msginfo *msgp, char *reply )
{
LDAP *ldp;
LDAPMessage *ldmsgp, *entry;
/*
* open connection to LDAP server and bind as dapuser
*/
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
if ( do_cldap )
ldp = cldap_open( ldaphost, ldapport );
else
-#endif /* CLDAP */
+#endif /* LDAP_CONNECTIONLESS */
ldp = ldap_open( ldaphost, ldapport );
if ( ldp == NULL ) {
return( 0 );
}
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
if ( !do_cldap )
-#endif /* CLDAP */
+#endif /* LDAP_CONNECTIONLESS */
if ( ldap_simple_bind_s( ldp, dapuser, NULL ) != LDAP_SUCCESS ) {
report_ldap_err( ldp, reply );
close_ldap( ldp );
matches = 0;
#ifdef RCPT500_UFN
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
if ( !do_cldap && strchr( msgp->msg_arg, ',' ) != NULL ) {
-#else /* CLDAP */
+#else /* LDAP_CONNECTIONLESS */
if ( strchr( msgp->msg_arg, ',' ) != NULL ) {
-#endif /* CLDAP */
+#endif /* LDAP_CONNECTIONLESS */
struct timeval tv;
ldap_ufn_setprefix( ldp, searchbase );
for ( lfi = ldap_getfirstfilter( lfdp, "rcpt500", msgp->msg_arg );
lfi != NULL; lfi = ldap_getnextfilter( lfdp )) {
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
if ( do_cldap )
rc = cldap_search_s( ldp, searchbase, LDAP_SCOPE_SUBTREE,
lfi->lfi_filter, attrs, 0, &ldmsgp, dapuser );
else
-#endif /* CLDAP */
+#endif /* LDAP_CONNECTIONLESS */
rc = ldap_search_s( ldp, searchbase, LDAP_SCOPE_SUBTREE,
lfi->lfi_filter, attrs, 0, &ldmsgp );
}
-void
+static void
close_ldap( LDAP *ld )
{
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
if ( do_cldap )
cldap_close( ld );
else
-#endif /* CLDAP */
+#endif /* LDAP_CONNECTIONLESS */
ldap_unbind( ld );
}
-append_entry_list( reply, query, ldp, ldmsgp )
- char *reply;
- char *query;
- LDAP *ldp;
- LDAPMessage *ldmsgp;
+static void
+append_entry_list( char *reply, char *query, LDAP *ldp, LDAPMessage *ldmsgp )
{
LDAPMessage *e;
char *dn, *rdn, *s, **title;
}
-int
-append_text( reply, text, len )
- char *reply;
- char *text;
- int len;
+static int
+append_text( void *reply, char *text, int len )
{
- strcat( reply, text );
+ strcat( (char *) reply, text );
return( len );
}
-int
-do_read( ldp, dn, reply, tmpll )
- LDAP *ldp;
- char *dn;
- char *reply;
- struct ldap_disptmpl *tmpll;
+static int
+do_read( LDAP *ldp, char *dn, char *reply, struct ldap_disptmpl *tmpll )
{
int rc;
static char *maildefvals[] = { "None registered in this service", NULL };
rc = ldap_entry2text_search( ldp, dn, searchbase, NULLMSG, tmpll,
- defattrs, defvals, (void *)append_text, (void *)reply, "\n",
+ defattrs, defvals, append_text, (void *)reply, "\n",
rdncount, LDAP_DISP_OPT_DOSEARCHACTIONS );
return( rc );
}
-report_ldap_err( ldp, reply )
- LDAP *ldp;
- char *reply;
+static void
+report_ldap_err( LDAP *ldp, char *reply )
{
strcat( reply, errpreface );
strcat( reply, ldap_err2string( ldp->ld_errno ));
}
-remove_trailing_space( s )
- char *s;
+static void
+remove_trailing_space( char *s )
{
char *p = s + strlen( s ) - 1;
* All Rights Reserved
*/
+#include <ldap_cdefs.h>
+
+LDAP_BEGIN_DECL
+
struct msginfo {
char *msg_subject;
char *msg_replyto; /* actually could be from From: line */
};
struct command {
- char *cmd_text; /* text for command, e.g. "HELP" */
- int (*cmd_handler)(); /* pointer to handler function */
+ char *cmd_text; /* text for command, e.g. "HELP" */
+ /* pointer to handler function */
+ int (*cmd_handler) LDAP_P((struct msginfo *msgp, char *reply));
};
/*
* functions
*/
-int help_cmd();
-int query_cmd();
+int help_cmd LDAP_P((struct msginfo *msgp, char *reply));
+int query_cmd LDAP_P((struct msginfo *msgp, char *reply));
/*
* externs
*/
+
+/* cmds.c */
extern struct command cmds[];
+/* main.c */
+extern int dosyslog;
+#ifdef LDAP_CONNECTIONLESS
+extern int do_cldap;
+#endif
+extern int derefaliases;
+extern int sizelimit;
+extern int rdncount;
+extern int ldapport;
+extern char *ldaphost;
+extern char *searchbase;
+extern char *dapuser;
+extern char *filterfile;
+extern char *templatefile;
+
+LDAP_END_DECL
static int not, verbose, contoper;
static LDAP *ld;
-#ifdef LDAP_DEBUG
-extern int ldap_debug, lber_debug;
-#endif /* LDAP_DEBUG */
-
#define safe_realloc( ptr, size ) ( ptr == NULL ? malloc( size ) : \
realloc( ptr, size ))
char *dn));
int
-main( argc, argv )
- int argc;
- char **argv;
+main( int argc, char **argv )
{
char *usage = "usage: %s [-n] [-v] [-k] [-d debug-level] [-f file] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [dn]...\n";
char buf[ 4096 ];
FILE *fp;
int i, rc, kerberos, authmethod;
- extern char *optarg;
- extern int optind;
-
kerberos = not = verbose = contoper = 0;
fp = NULL;
static int new, replace, not, verbose, contoper, force, valsfromfiles;
static LDAP *ld;
-#ifdef LDAP_DEBUG
-extern int ldap_debug, lber_debug;
-#endif /* LDAP_DEBUG */
-
#define safe_realloc( ptr, size ) ( ptr == NULL ? malloc( size ) : \
realloc( ptr, size ))
int rc, i, kerberos, use_ldif, authmethod;
char *usage = "usage: %s [-abcknrvF] [-d debug-level] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [ -f file | < entryfile ]\n";
- extern char *optarg;
- extern int optind;
-
if (( prog = strrchr( argv[ 0 ], '/' )) == NULL ) {
prog = argv[ 0 ];
} else {
static int not, verbose, contoper;
static LDAP *ld;
-#ifdef LDAP_DEBUG
-extern int ldap_debug, lber_debug;
-#endif /* LDAP_DEBUG */
-
#define safe_realloc( ptr, size ) ( ptr == NULL ? malloc( size ) : \
realloc( ptr, size ))
int remove)); /* flag: remove old RDN */
int
-main( argc, argv )
- int argc;
- char **argv;
+main(int argc, char **argv)
{
char *usage = "usage: %s [-nvkc] [-d debug-level] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [ -f file | < entryfile | dn newrdn ]\n";
char *myname,*infile, *entrydn, *rdn, buf[ 4096 ];
FILE *fp;
int rc, i, kerberos, remove, havedn, authmethod;
- extern char *optarg;
- extern int optind;
-
infile = NULL;
kerberos = not = contoper = verbose = remove = 0;
#define DEFSEP "="
-#ifdef LDAP_DEBUG
-extern int ldap_debug, lber_debug;
-#endif /* LDAP_DEBUG */
-
-static void usage( s )
-char *s;
+static void
+usage( char *s )
{
fprintf( stderr, "usage: %s [options] filter [attributes...]\nwhere:\n", s );
fprintf( stderr, " filter\tRFC-1558 compliant LDAP search filter\n" );
static int verbose, not, includeufn, allow_binary, vals2tmp, ldif;
int
-main( argc, argv )
-int argc;
-char **argv;
+main( int argc, char **argv )
{
char *infile, *filtpattern, **attrs, line[ BUFSIZ ];
FILE *fp;
int rc, i, first, scope, kerberos, deref, attrsonly;
int ldap_options, timelimit, sizelimit, authmethod;
LDAP *ld;
- extern char *optarg;
- extern int optind;
infile = NULL;
deref = verbose = allow_binary = not = kerberos = vals2tmp =
ldap_perror( ld, "ldap_search" );
}
if ( sortattr != NULL ) {
- extern int strcasecmp();
-
(void) ldap_sort_entries( ld, &res,
( *sortattr == '\0' ) ? NULL : sortattr, strcasecmp );
matches = 0;
BerElement *ber;
struct berval **bvals;
FILE *tmpfp;
- extern char *mktemp();
dn = ldap_get_dn( ld, entry );
if ( ldif ) {
#include <ac/krb.h>
#include <ac/string.h>
#include <ac/time.h>
+#include <ac/unistd.h>
#ifdef HAVE_PWD_H
#include <pwd.h>
#include "ud.h"
-extern LDAP *ld; /* our LDAP descriptor */
-extern int verbose; /* verbosity indicator */
-extern char *mygetpass(); /* getpass() passwds are too short */
-
-#ifdef DEBUG
-extern int debug; /* debug flag */
-#endif
-
#ifdef HAVE_KERBEROS
static char tktpath[20]; /* ticket file path */
static int kinit();
static int valid_tgt();
#endif
-static void set_bound_dn();
+static void set_bound_dn(char *s);
-auth(who, implicit)
-char *who;
-int implicit;
+
+int
+auth( char *who, int implicit )
{
int rc; /* return code from ldap_bind() */
char *passwd = NULL; /* returned by mygetpass() */
static char prompt[MED_BUF_SIZE]; /* place for us to sprintf the prompt */
static char name[MED_BUF_SIZE]; /* place to store the user's name */
static char password[MED_BUF_SIZE]; /* password entered by user */
- extern struct entry Entry; /* look here for a name if needed */
- extern LDAPMessage *find(); /* for looking up 'name' */
- extern char *search_base; /* for printing later */
- extern char *default_bind_object; /* bind as this on failure */
- extern void printbase(); /* used to pretty-print a base */
- extern int bind_status;
- extern void Free();
#ifdef DEBUG
if (debug & D_TRACE)
#define FIVEMINS ( 5 * 60 )
#define TGT "krbtgt"
-static void str2upper( s )
- char *s;
+static void
+str2upper( char *s )
{
char *p;
}
-static valid_tgt( names )
- char **names;
+static int
+valid_tgt( char **names )
{
int i;
char name[ ANAME_SZ ], inst[ INST_SZ ], realm[ REALM_SZ ];
/*ARGSUSED*/
int
-krbgetpass( user, inst, realm, pw, key )
- char *user, *inst, *realm, *pw;
- C_Block key;
+krbgetpass( char *user, char *inst, char *realm, char *pw, C_Block key )
{
char *p, lcrealm[ REALM_SZ ], prompt[256], *passwd;
return( 0 );
}
-static kinit( kname )
- char *kname;
+static int
+kinit( char *kname )
{
int rc;
char name[ ANAME_SZ ], inst[ INST_SZ ], realm[ REALM_SZ ];
return( 0 );
}
-void destroy_tickets(void)
+void
+destroy_tickets( void )
{
if ( *tktpath != '\0' ) {
unlink( tktpath );
}
#endif
-static void set_bound_dn(char *s)
+static void
+set_bound_dn( char *s )
{
- extern void Free();
- extern char *bound_dn;
-
if (bound_dn != NULL)
Free(bound_dn);
bound_dn = (s == NULL) ? NULL : strdup(s);
#include <ac/signal.h>
#include <ac/string.h>
+#include <ac/ctype.h>
#include <ac/time.h>
#include <ac/wait.h>
+#include <ac/unistd.h>
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#include <ldap.h>
#include <ldapconfig.h>
#include "ud.h"
-extern void *Malloc();
-extern struct entry Entry;
-extern int verbose;
-extern LDAP *ld;
-
-extern LDAPMessage *find();
-
-static int load_editor();
-static int modifiable();
-static int print_attrs_and_values();
-static int ovalues();
-static int write_entry();
+static int load_editor( void );
+static int modifiable( char *s, short flag );
+static int print_attrs_and_values( FILE *fp, struct attribute *attrs, short flag );
+static int ovalues( char *attr );
+static void write_entry( void );
static char *entry_temp_file;
-#ifdef DEBUG
-extern int debug;
-#endif
-edit(who)
-char *who;
+void
+edit( char *who )
{
LDAPMessage *mp; /* returned from find() */
char *dn, **rdns; /* distinguished name */
char name[MED_BUF_SIZE]; /* entry to modify */
- extern int bind_status;
#ifdef DEBUG
if (debug & D_TRACE)
(void) ldap_value_free(rdns);
if (load_editor() < 0)
return;
- (void) write_entry();
+ write_entry();
(void) unlink(entry_temp_file);
ldap_uncache_entry(ld, Entry.DN);
return;
}
-static load_editor()
+static int
+load_editor( void )
{
FILE *fp;
char *cp, *editor = UD_DEFAULT_EDITOR;
static char template[MED_BUF_SIZE];
- extern char * mktemp();
- extern int isgroup(), fatal();
int pid;
int status;
int rc;
return(0);
}
-static int print_attrs_and_values(fp, attrs, flag)
-FILE *fp;
-struct attribute attrs[];
-short flag;
+static int
+print_attrs_and_values( FILE *fp, struct attribute *attrs, short int flag )
{
register int i, j;
return( 0 );
}
-static modifiable(s, flag)
-char *s;
-short flag;
+static int
+modifiable( char *s, short int flag )
{
register int i;
- extern struct attribute attrlist[];
for (i = 0; attrlist[i].quipu_name != NULL; i++) {
if (strcasecmp(s, attrlist[i].quipu_name))
return(FALSE);
}
-static write_entry()
+static void
+write_entry( void )
{
int i = 0, j, number_of_values = -1;
LDAPMod *mods[MAX_ATTRS + 1];
LDAPMod *modp = NULL;
- extern char * code_to_str();
- extern void free_mod_struct();
-
/* parse the file and write the values to the Directory */
if ((fp = fopen(entry_temp_file, "r")) == NULL) {
perror("fopen");
return;
}
-static ovalues(attr)
-char *attr;
+static int
+ovalues( char *attr )
{
struct attribute *ap;
#include "portable.h"
#include <stdio.h>
+#include <stdlib.h>
#include <ac/ctype.h>
#include <ac/string.h>
#include "ud.h"
-extern char *search_base; /* search base */
-extern int verbose; /* verbose mode flag */
-extern LDAP *ld; /* our ldap descriptor */
-
static int num_picked = 0; /* used when user picks entry at More prompt */
-#ifdef DEBUG
-extern int debug; /* debug flag */
-#endif
-vrfy(dn)
-char *dn;
+int
+vrfy( char *dn )
{
LDAPMessage *results;
static char *attrs[2] = { "objectClass", NULL };
}
-static LDAPMessage * disambiguate( result, matches, read_attrs, who )
-LDAPMessage *result;
-int matches;
-char **read_attrs;
-char *who;
+static LDAPMessage *
+disambiguate( LDAPMessage *result, int matches, char **read_attrs, char *who )
{
int choice; /* entry that user chooses */
int i;
char response[SMALL_BUF_SIZE]; /* results from user */
char *name = NULL; /* DN to lookup */
LDAPMessage *mp;
- extern void Free();
#ifdef DEBUG
if (debug & D_TRACE)
}
}
-LDAPMessage * find(who, quiet)
-char *who;
-int quiet;
+LDAPMessage *
+find( char *who, int quiet )
{
register int i, j, k; /* general ints */
int matches; /* from ldap_count_entries() */
char response[SMALL_BUF_SIZE];
char *cp, *dn, **rdns;
LDAPFiltInfo *fi;
- extern LDAPFiltDesc *lfdp; /* LDAP filter descriptor */
- extern struct attribute attrlist[]; /* complete list of attrs */
- extern void Free();
#ifdef DEBUG
if (debug & D_TRACE)
return(NULL);
}
-pick_one(i)
-int i;
+int
+pick_one( int i )
{
int n;
char user_pick[SMALL_BUF_SIZE];
/* NOTREACHED */
}
-print_list(list, names, matches)
-LDAPMessage *list;
-char *names[];
-int *matches;
+void
+print_list( LDAPMessage *list, char **names, int *matches )
{
char **rdns, **cpp;
- extern int lpp;
char resp[SMALL_BUF_SIZE];
register LDAPMessage *ep;
register int i = 1;
return;
}
-find_all_subscribers(sub, group)
-char *sub[];
-char *group;
+int
+find_all_subscribers( char **sub, char *group )
{
int count;
LDAPMessage *result;
return(count);
}
-char * fetch_boolean_value(who, attr)
-char *who;
-struct attribute attr;
+char *
+fetch_boolean_value( char *who, struct attribute attr )
{
LDAPMessage *result; /* from the search below */
register LDAPMessage *ep; /* entry pointer */
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#include <stdio.h>
+#include <ac/time.h> /* portable.h+ldap.h needs time_t */
+#include <lber.h>
+#include <ldap.h>
#include "ud.h"
-extern void set_boolean(),
- change_field(),
-#ifdef UOFM
- set_updates(),
-#endif
- mod_addrDN();
-
struct attribute attrlist[] = {
/*
* Field 3 = function used to modify this field (if any)
* Field 4 = Flags specifying how this field is displayed
*/
- { "memberOfGroup", "Subscriptions", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_IS_A_DN },
- { "acl", "Access Control", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ },
+ { "memberOfGroup", "Subscriptions", 0, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_IS_A_DN },
+ { "acl", "Access Control", 0, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ },
{ "cn", "Aliases", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ | ATTR_FLAG_SEARCH | ATTR_FLAG_GROUP_MOD },
{ "title", "Title", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_SEARCH | ATTR_FLAG_PERSON_MOD },
{ "postalAddress", "Business address", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD | ATTR_FLAG_GROUP_MOD | ATTR_FLAG_IS_MULTILINE },
{ "member", "Members", mod_addrDN, ATTR_FLAG_GROUP | ATTR_FLAG_READ | ATTR_FLAG_IS_A_DN | ATTR_FLAG_GROUP_MOD },
{ "homePhone", "Home phone", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD },
{ "homePostalAddress", "Home address", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD | ATTR_FLAG_IS_MULTILINE },
- { "objectClass", "Object class", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ | ATTR_FLAG_SEARCH },
+ { "objectClass", "Object class", 0, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ | ATTR_FLAG_SEARCH },
#ifdef UOFM
{ "multiLineDescription", "Description", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD | ATTR_FLAG_GROUP_MOD | ATTR_FLAG_IS_MULTILINE },
#endif
-#ifdef KERBEROS
- { "krbName", "Kerberos name", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_READ },
+#ifdef HAVE_KERBEROS
+ { "krbName", "Kerberos name", 0, ATTR_FLAG_PERSON | ATTR_FLAG_READ },
#endif
- { "description", "Brief description", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ },
+ { "description", "Brief description", 0, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ },
{ "facsimileTelephoneNumber", "Fax number", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD | ATTR_FLAG_GROUP_MOD },
{ "pager", "Pager number", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD },
- { "uid", "Uniqname", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ },
- { "userPassword", "Password", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ },
+ { "uid", "Uniqname", 0, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ },
+ { "userPassword", "Password", 0, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ },
#ifdef UOFM
{ "noBatchUpdates", "No batch updates", set_updates, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD },
#endif
{ "onVacation", "On Vacation", set_boolean, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD | ATTR_FLAG_IS_A_BOOL },
{ "vacationMessage", "Vacation Message", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD | ATTR_FLAG_IS_MULTILINE },
{ "drink", "Favorite Beverage", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD },
- { "lastModifiedBy", "Last modified by", NULL, ATTR_FLAG_GROUP | ATTR_FLAG_PERSON | ATTR_FLAG_IS_A_DN | ATTR_FLAG_READ },
- { "lastModifiedTime", "Last modified at", NULL, ATTR_FLAG_GROUP | ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_IS_A_DATE },
- { NULL, NULL, NULL, ATTR_FLAG_NONE }
+ { "lastModifiedBy", "Last modified by", 0, ATTR_FLAG_GROUP | ATTR_FLAG_PERSON | ATTR_FLAG_IS_A_DN | ATTR_FLAG_READ },
+ { "lastModifiedTime", "Last modified at", 0, ATTR_FLAG_GROUP | ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_IS_A_DATE },
+ { NULL, NULL, 0, ATTR_FLAG_NONE }
};
*
*/
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
+
+#include <ac/string.h>
+#include <ac/ctype.h>
+#include <ac/time.h>
+#include <ac/unistd.h>
+
#include <lber.h>
#include <ldap.h>
#include <ldapconfig.h>
#include "ud.h"
-extern LDAPMessage * find();
-
-#ifdef DEBUG
-extern int debug;
-#endif
-
-extern char *bound_dn, *group_base;
-extern int verbose, bind_status;
-extern struct entry Entry;
-extern LDAP *ld;
+static char * bind_and_fetch(char *name);
-extern void Free();
-void add_group(name)
-char *name;
+void
+add_group( char *name )
{
register int i, idx = 0, prompt = 0;
char tmp[BUFSIZ], dn[BUFSIZ];
char *init_rdn_value[2], *init_owner_value[2], *init_domain_value[2],
*init_errors_value[MAX_VALUES], *init_joinable_value[2],
*init_request_value[MAX_VALUES];
- extern void ldap_flush_cache();
- extern char * strip_ignore_chars();
#ifdef DEBUG
if (debug & D_TRACE) {
register LDAPMod **lpp;
register char **cpp;
register int j;
- extern char * code_to_str();
printf(" About to call ldap_add()\n");
printf(" ld = 0x%x\n", ld);
printf(" dn = [%s]\n", dn);
#endif
/*
- * Now add this to the X.500 Directory.
+ * Now add this to the LDAP Directory.
*/
if (ldap_add_s(ld, dn, attrs) != 0) {
ldap_perror(ld, " ldap_add_s");
return;
}
-void remove_group(name)
-char *name;
+void
+remove_group( char *name )
{
char *dn, tmp[BUFSIZ];
- static char * bind_and_fetch();
#ifdef DEBUG
if (debug & D_TRACE) {
return;
/*
- * Now remove this from the X.500 Directory.
+ * Now remove this from the LDAP Directory.
*/
if (ldap_delete_s(ld, dn) != 0) {
if (ld->ld_errno == LDAP_INSUFFICIENT_ACCESS)
return;
}
-void x_group(action, name)
-int action;
-char *name;
+void
+x_group( int action, char *name )
{
char **vp;
char *values[2], *group_name;
LDAPMod mod, *mods[2];
static char *actions[] = { "join", "resign from", NULL };
- static char * bind_and_fetch();
#ifdef DEBUG
if (debug & D_TRACE) {
return;
}
-void bulk_load(group)
-char *group;
+void
+bulk_load( char *group )
{
register int idx_mail, idx_x500;
register int count_mail, count_x500;
}
/*
- * Add the X.500 style names.
+ * Add the LDAP style names.
*/
if (count_x500 > 0) {
mods[0] = &mod;
return;
}
-void purge_group(group)
-char *group;
+void
+purge_group( char *group )
{
int isclean = TRUE;
LDAPMessage *lm;
LDAPMod mod, *mods[2];
char dn[BUFSIZ], tmp[BUFSIZ], *values[2], **vp, **rdns;
- extern char * my_ldap_dn2ufn();
- extern int col_size;
#ifdef DEBUG
if (debug & D_TRACE) {
vp = Entry.attrs[attr_to_index("member")].values;
if (vp == NULL) {
if (verbose)
- printf(" \"%s\" has no X.500 members. There is nothing to purge.\n", group);
+ printf(" \"%s\" has no LDAP members. There is nothing to purge.\n", group);
return;
}
for (; *vp != NULL; vp++) {
return;
}
-void tidy_up()
+void
+tidy_up( void )
{
register int i = 0;
int found_one = 0;
* Names or e-mail addresses. This includes things like group members,
* the errors-to field in groups, and so on.
*/
-void mod_addrDN(group, offset)
-char *group;
-int offset;
+void
+mod_addrDN( char *group, int offset )
{
- extern struct attribute attrlist[];
char s[BUFSIZ], *new_value /* was member */, *values[2];
char attrtype[ 64 ];
int i;
}
if (verbose) {
printf("\n");
- format("Values may be specified as a name (which is then looked up in the X.500 Directory) or as a domain-style (i.e., user@domain) e-mail address. Simply hit the RETURN key at the prompt when finished.\n", 75, 2);
+ format("Values may be specified as a name (which is then looked up in the LDAP Directory) or as a domain-style (i.e., user@domain) e-mail address. Simply hit the RETURN key at the prompt when finished.\n", 75, 2);
printf("\n");
}
}
}
-my_ldap_modify_s(ldap, group, mods)
-LDAP *ldap;
-char *group;
-LDAPMod *mods[];
+int
+my_ldap_modify_s( LDAP *ldap, char *group, LDAPMod **mods )
{
int was_rfc822member, rc;
return(rc);
}
-void list_groups(who)
-char *who;
+void
+list_groups( char *who )
{
LDAPMessage *mp;
char name[BUFSIZ], filter[BUFSIZ], *search_attrs[2];
return;
}
-static char * bind_and_fetch(name)
-char *name;
+static char *
+bind_and_fetch( char *name )
{
LDAPMessage *lm;
char tmp[MED_BUF_SIZE];
- extern char * strip_ignore_chars();
#ifdef DEBUG
if (debug & D_TRACE) {
return(strdup(Entry.DN));
}
-void list_memberships(who)
-char *who;
+void
+list_memberships( char *who )
{
LDAPMessage *mp;
char name[BUFSIZ], filter[BUFSIZ], *search_attrs[2];
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
+
+#include <ac/ctype.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
#include <lber.h>
#include <ldap.h>
+
#include "ud.h"
-#ifdef DEBUG
-extern int debug;
-#endif
-print_help(s)
-char *s;
+void
+print_help( char *s )
{
int len; /* command length */
format("should be specified as a ordinary name (e.g., 'Friends of maX500').", 75, 15);
printf("\n");
printf(" [where] A place in the Directory needs to be specified. This name\n");
- format("should be specified as an X.500-style name (e.g., 'ou=people, o=University of Michigan, c=United States of America'). In most cases, it is easier to omit the [where] and allow the program to guide you.", 75, 15);
+ format("should be specified as an LDAP-style name (e.g., 'ou=people, o=University of Michigan, c=United States of America'). In most cases, it is easier to omit the [where] and allow the program to guide you.", 75, 15);
printf("\n");
printf(" [who] A person in the Directory needs to be specified. This name\n");
format("can be specified as either a ordinary name (e.g., 'Jane Doe'), or as some other identifying characteristic (e.g., 'uid=babs').", 75, 15);
}
else if (!strncasecmp("groupbase", s, len)) {
printf(" groupbase [where]\n\n");
- format("The syntax and use of this command is identical to the more commonly used 'cb' command. This command sets the base which is used to create groups in the X.500 Directory. Setting the base to a certain value does not necessarily grant the person write-access to that part of the Directory in order to successfully create a group.", 75, 2);
+ format("The syntax and use of this command is identical to the more commonly used 'cb' command. This command sets the base which is used to create groups in the LDAP Directory. Setting the base to a certain value does not necessarily grant the person write-access to that part of the Directory in order to successfully create a group.", 75, 2);
}
else if (!strncasecmp("cd", s, len) || !strncasecmp("cb", s,len)) {
printf(" cb [where]\n");
printf("\n * cb default\n\n");
format("sets the search base to its original default value.", 75, 2);
printf("\n * cb o=Merit Computer Network, c=US\n\n");
- format("sets the search base to organization given, the Merit Computer Network in this case. This comamnd checks the validity of the specified search base, and rejects it if it is not a valid Distinguished Name (DN). A DN uniquely identifies a portion of the global X.500 namespace.", 75, 2);
+ format("sets the search base to organization given, the Merit Computer Network in this case. This comamnd checks the validity of the specified search base, and rejects it if it is not a valid Distinguished Name (DN). A DN uniquely identifies a portion of the global LDAP namespace.", 75, 2);
}
else if (!strncasecmp("quit", s, len) || !strncasecmp("stop",s, len)) {
printf(" quit\n");
else if (!strncasecmp("modify", s, len) || !strncasecmp("change", s, len)) {
printf(" modify [entry]\n");
printf(" change [entry]\n\n");
- format("Changes information associated with an entry in the X.500 Directory. 'change' is an alias for 'modify'.", 75, 2);
+ format("Changes information associated with an entry in the LDAP Directory. 'change' is an alias for 'modify'.", 75, 2);
}
else if (!strncasecmp("verbose", s, len)) {
printf(" verbose\n\n");
}
else if (!strncasecmp("tidy", s, len)) {
printf(" tidy\n\n");
- format("Unsubscribes you from non-existent groups. Useful when you cannot resign from a group because, while your X.500 entry still contains a pointer to it, someone has removed a group of which you were a subscriber.", 75, 2);
+ format("Unsubscribes you from non-existent groups. Useful when you cannot resign from a group because, while your LDAP entry still contains a pointer to it, someone has removed a group of which you were a subscriber.", 75, 2);
}
else if (*s == '?') {
format("Prints out a brief description of each command. Same as typing 'help help'.", 75, 2);
#include <ac/signal.h>
#include <ac/string.h>
+#include <ac/ctype.h>
#include <ac/termios.h>
#include <ac/time.h>
#include <ac/unistd.h>
int debug; /* debug flag */
#endif
-extern void initialize_client();
-extern void initialize_attribute_strings();
-main(argc, argv)
-int argc;
-char *argv[];
+int
+main( int argc, char **argv )
{
- extern char Version[]; /* version number */
- extern char *optarg; /* for parsing argv */
register int c; /* for parsing argv */
register char *cp; /* for parsing Version */
/* NOTREACHED */
}
-do_commands()
+void
+do_commands( void )
{
LDAPMessage *mp; /* returned by find() */
register char *cp; /* misc char pointer */
static char buf[MED_BUF_SIZE]; /* for prompting */
static char cmd[MED_BUF_SIZE]; /* holds the command */
static char input[MED_BUF_SIZE]; /* buffer for input */
- extern LDAPMessage *find();
- extern void purge_group(), add_group(), remove_group(), x_group(),
- tidy_up(), list_groups(), list_memberships(), edit();
- extern char *nextstr();
#ifdef DEBUG
if (debug & D_TRACE)
/* NOTREACHED */
}
-status()
+void
+status( void )
{
- void printbase();
register char **rdns;
#ifdef DEBUG
}
}
-change_base(type, base, s)
-int type;
-char **base, *s;
+void
+change_base( int type, char **base, char *s )
{
register char *cp; /* utility pointers */
char **rdns; /* for parsing */
static char *choices[MED_BUF_SIZE]; /* bases from which to choose */
static char resp[SMALL_BUF_SIZE]; /* for prompting user */
static char buf[MED_BUF_SIZE];
- void printbase();
static char *attrs[] = { "objectClass", NULL };
LDAPMessage *mp; /* results from a search */
LDAPMessage *ep; /* for going thru bases */
- extern char * friendly_name();
- extern void StrFreeDup();
- extern void Free();
#ifdef DEBUG
if (debug & D_TRACE)
}
}
-void initialize_client()
+void
+initialize_client( void )
{
FILE *fp; /* for config file */
static char buffer[MED_BUF_SIZE]; /* for input */
char *term; /* for tty set-up */
char *config; /* config file to use */
static char bp[1024]; /* for tty set-up */
- extern RETSIGTYPE attn(); /* ^C signal handler */
- extern char *getenv();
- extern void Free();
#ifdef DEBUG
if (debug & D_TRACE)
#ifndef NO_TERMCAP
{
struct winsize win; /* for tty set-up */
- extern RETSIGTYPE chwinsz(); /* WINSZ signal handler */
if (((term = getenv("TERM")) == NULL) || (tgetent(bp, term) <= 0))
return;
#endif
}
-RETSIGTYPE attn()
+RETSIGTYPE
+attn( int sig )
{
fflush(stderr);
fflush(stdout);
longjmp(env, 1);
}
-#ifndef NO_TERMCAP
-RETSIGTYPE chwinsz()
+#if !defined(NO_TERMCAP) && defined(TIOCGWINSZ)
+RETSIGTYPE
+chwinsz( int sig )
{
struct winsize win;
#include "portable.h"
#include <stdio.h>
+#include <stdlib.h>
#include <ac/ctype.h>
#include <ac/string.h>
#include <lber.h>
#include <ldap.h>
#include "ud.h"
-extern void Free();
-extern struct entry Entry;
-extern int verbose;
-extern LDAP *ld;
+static char *get_URL( void );
+static int check_URL( char *url );
-extern LDAPMessage *find();
-extern void * Malloc();
-static char * get_URL();
-static int check_URL();
-
-#ifdef DEBUG
-extern int debug;
-#endif
-
-modify(who)
-char *who;
+void
+modify( char *who )
{
-#ifdef UOFM
- void set_updates(); /* routine to modify noBatchUpdates */
-#endif
LDAPMessage *mp; /* returned from find() */
char *dn; /* distinguished name */
char **rdns; /* for fiddling with the DN */
#ifdef UOFM
static char printed_warning = 0; /* for use with the */
struct attribute no_batch_update_attr;
- extern char * fetch_boolean_value();
#endif
int is_a_group; /* TRUE if it is; FALSE otherwise */
- extern void Free();
- extern int bind_status;
#ifdef DEBUG
if (debug & D_TRACE)
}
/* generic routine for changing any field */
-void change_field(who, attr)
-char *who; /* DN of entry we are changing */
-struct attribute attr; /* attribute to change */
+void
+change_field(
+ char *who, /* DN of entry we are changing */
+ int attr_idx /* attribute to change */
+)
{
+ struct attribute attr = Entry.attrs[attr_to_index(attrlist[attr_idx].quipu_name)];
#define IS_MOD(x) (!strncasecmp(resp, (x), strlen(resp)))
- char *get_value(); /* routine to extract values */
static char buf[MED_BUF_SIZE]; /* for printing things */
static char resp[SMALL_BUF_SIZE]; /* for user input */
char *prompt, *prompt2, *more;
static LDAPMod mod;
static LDAPMod *mods[2] = { &mod }; /* passed to ldap_modify */
static char *values[MAX_VALUES]; /* passed to ldap_modify */
- extern void Free();
#ifdef DEBUG
if (debug & D_TRACE)
#define MAX_DESC_LINES 24
#define INTL_ADDR_LIMIT 30
-char *get_value(id, prompt)
-char *id, *prompt;
+char *
+get_value( char *id, char *prompt )
{
char *cp; /* for the Malloc() */
int count; /* line # of new value -- if multiline */
return(cp);
}
-void set_boolean(who, attr)
-char *who; /* DN of entry we are changing */
-struct attribute attr; /* boolean attribute to change */
+void
+set_boolean(
+ char *who, /* DN of entry we are changing */
+ int attr_idx /* boolean attribute to change */
+)
{
+ struct attribute attr = Entry.attrs[attr_to_index(attrlist[attr_idx].quipu_name)];
+
char *cp, *s;
- extern char * fetch_boolean_value();
static char response[16];
static char *newsetting[2] = { NULL, NULL };
LDAPMod mod, *mods[2];
#ifdef UOFM
-void set_updates(who)
-char *who;
+void
+set_updates( char *who, int dummy )
{
char *cp, *s;
- extern char * fetch_boolean_value();
static char response[16];
static char value[6];
static char *newsetting[2] = { value, NULL };
#endif
-print_mod_list(group)
-int group;
+void
+print_mod_list( int group )
{
register int i, j = 1;
- extern struct attribute attrlist[];
if (group == TRUE) {
for (i = 0; attrlist[i].quipu_name != NULL; i++) {
#endif
}
-perform_action(choice, dn, group)
-char choice[];
-char *dn;
-int group;
+int
+perform_action( char *choice, char *dn, int group )
{
int selection;
register int i, j = 1;
- extern struct attribute attrlist[];
- extern void mod_addrDN(), change_field(), set_boolean();
selection = atoi(choice);
if (selection < 1) {
return(1);
/* NOTREACHED */
}
- if (attrlist[i].mod_func == change_field)
- (*attrlist[i].mod_func)(dn, Entry.attrs[attr_to_index(attrlist[i].quipu_name)]);
- else if (attrlist[i].mod_func == mod_addrDN)
- (*attrlist[i].mod_func)(dn, i);
- else if (attrlist[i].mod_func == set_boolean)
- (*attrlist[i].mod_func)(dn, Entry.attrs[attr_to_index(attrlist[i].quipu_name)]);
- else
- (*attrlist[i].mod_func)(dn);
+ (*attrlist[i].mod_func)(dn, i);
return(0);
}
-static char * get_URL()
+static char *
+get_URL( void )
{
char *rvalue, label[MED_BUF_SIZE], url[MED_BUF_SIZE];
return((char *) rvalue);
}
-static check_URL(url)
-char *url;
+static int
+check_URL( char *url )
{
register char *cp;
}
+void
mod_perror( LDAP *ld )
{
if ( ld == NULL || ( ld->ld_errno != LDAP_UNAVAILABLE &&
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#ifndef __STDC__
-#include <memory.h>
-#endif
-#include <time.h>
+
+#include <ac/ctype.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
#include <lber.h>
#include <ldap.h>
-#include "ud.h"
-#ifdef DEBUG
-extern int debug;
-#endif
+#include "ud.h"
struct entry Entry;
-extern LDAP *ld;
-extern void * Malloc();
-extern void Free();
-extern char * my_ldap_dn2ufn();
+static char *time2text(char *ldtimestr, int dateonly);
+static long gtime(struct tm *tm);
/*
* When displaying entries, display only these attributes, and in this
NULL
};
-parse_answer(s)
-LDAPMessage *s;
+
+void
+parse_answer( LDAPMessage *s )
{
int idx;
char **rdns;
BerElement *cookie;
register LDAPMessage *ep;
register char *ap;
- void clear_entry();
#ifdef DEBUG
if (debug & D_TRACE)
#endif
}
-add_value(attr, ep, ap)
-struct attribute *attr;
-LDAPMessage *ep;
-char *ap;
+void
+add_value( struct attribute *attr, LDAPMessage *ep, char *ap )
{
register int i = 0;
char **vp, **tp, **avp;
ldap_value_free(vp);
}
-print_an_entry()
+void
+print_an_entry( void )
{
int n = 0, i, idx;
char is_a_group, **order;
char *sub_list[MAX_VALUES], buf[SMALL_BUF_SIZE];
- extern int col_size, isaurl(), isadn();
- static char *time2text();
#ifdef DEBUG
if (debug & D_TRACE)
#define OUT_LABEL_LEN 20
/* prints the values associated with an attribute */
-print_values(A)
-struct attribute A;
+void
+print_values( struct attribute A )
{
register int i, k;
register char *cp, **vp;
}
/* prints the DN's associated with an attribute */
-print_DN(A)
-struct attribute A;
+void
+print_DN( struct attribute A )
{
int i, lead;
register char **vp;
char out_buf[MED_BUF_SIZE], *padding = NULL;
- extern int col_size;
#ifdef DEBUG
if (debug & D_TRACE)
return;
}
-void clear_entry()
+void
+clear_entry( void )
{
register int i;
- extern struct attribute attrlist[];
#ifdef DEBUG
if (debug & D_TRACE)
}
}
-attr_to_index(s)
-char *s;
+int
+attr_to_index( char *s )
{
register int i;
- extern struct attribute attrlist[];
for (i = 0; attrlist[i].quipu_name != NULL; i++)
if (!strcasecmp(s, attrlist[i].quipu_name))
return(-1);
}
-void initialize_attribute_strings()
+void
+initialize_attribute_strings( void )
{
register int i;
- extern struct entry Entry;
- extern struct attribute attrlist[];
for (i = 0; attrlist[i].quipu_name != NULL; i++)
Entry.attrs[i].quipu_name = attrlist[i].quipu_name;
}
/* prints the URL/label pairs associated with an attribute */
-print_URL(A)
-struct attribute A;
+void
+print_URL( struct attribute A )
{
int i, lead;
register char **vp;
return;
}
-print_one_URL(s, label_lead, tag, url_lead)
-char *s;
-int label_lead;
-char *tag;
-int url_lead;
+void
+print_one_URL( char *s, int label_lead, char *tag, int url_lead )
{
register int i;
char c, *cp, *url;
- extern int col_size;
- extern void Free();
for (cp = s; !isspace(*cp) && (*cp != '\0'); cp++)
;
struct tm t;
char *p, *timestr, zone, *fmterr = "badly formatted time";
time_t gmttime;
- static long gtime();
memset( (char *)&t, 0, sizeof( struct tm ));
if ( strlen( ldtimestr ) < 13 ) {
/* gtime.c - inverse gmtime */
-#if !defined( MACOS ) && !defined( _WIN32 ) && !defined( DOS )
-#include <sys/time.h>
-#endif /* !MACOS */
+#include <ac/time.h>
/* gtime(): the inverse of localtime().
This routine was supplied by Mike Accetta at CMU many years ago.
/* \f */
-static long gtime ( struct tm *tm )
+static long
+gtime( struct tm *tm )
{
register int i,
sec,
-#ifdef KERBEROS
+#include "portable.h"
+
+#if defined(HAVE_KERBEROS) && !defined(openbsd)
/*
- * $Source: /usr/local/src/ldap/clients/ud/RCS/string_to_key.c,v $
- * $Author: lsloan $
+ * $Source: /repo/OpenLDAP/pkg/ldap/clients/ud/string_to_key.c,v $
+ * $Author: hallvard $
*
* Copyright 1985, 1986, 1987, 1988, 1989 by the Massachusetts Institute
* of Technology.
* spm 8/85 MIT project athena
*/
-#ifndef lint
-static char rcsid_string_to_key_c[] =
-"$Id: string_to_key.c,v 1.5 1995/11/09 20:29:55 lsloan Exp $";
-#endif
-
-#include <mit-copyright.h>
#include <stdio.h>
-#include <des.h>
-/* #include "des_internal.h" */
-#if 1
-#include <krb.h>
-#endif
+#include <ac/krb.h>
extern int des_debug;
extern int des_debug_print();
extern void des_fixup_key_parity();
-#ifndef AFSKERBEROS
+#ifndef HAVE_AFS_KERBEROS
#define WORLDPEACEINOURTIME
#endif
#if defined(WORLDPEACEINOURTIME) /* Use original, not ifs version */
+#ifndef HAVE_KERBEROS_V
/*
* convert an arbitrary length string to a DES key
*/
int
-des_string_to_key(str,key)
- char *str;
- register des_cblock *key;
+des_string_to_key( char *str, register des_cblock *key )
{
register char *in_str;
register unsigned temp,i;
*((unsigned long *) key+1));
}
+#endif /* HAVE_KERBEROS_V */
#else /* Use ifs version */
#if 0
encryption key. It is compatible with the original Andrew authentication
service password database. */
-static void Andrew_StringToKey (str, cell, key)
- char *str;
- char *cell; /* cell for password */
- des_cblock *key;
+static void
+Andrew_StringToKey(
+ char *str,
+ char *cell, /* cell for password */
+ des_cblock *key
+)
{ char password[8+1]; /* crypt is limited to 8 chars anyway */
int i;
int passlen;
des_fixup_key_parity (key);
}
-static void StringToKey (str, cell, key)
- char *str;
- char *cell; /* cell for password */
- des_cblock *key;
+static void
+StringToKey(
+ char *str,
+ char *cell, /* cell for password */
+ des_cblock *key
+)
{ des_key_schedule schedule;
char temp_key[8];
char ivec[8];
des_fixup_key_parity (key);
}
-/* static */ void
-ka_StringToKey (str, cell, key)
- char *str;
- char *cell; /* cell for password */
- des_cblock *key;
+void
+ka_StringToKey (
+ char *str,
+ char *cell, /* cell for password */
+ des_cblock *key
+)
{ char realm[REALM_SZ];
#if NOWAYOUTTODAY
long code;
- /* code = ka_CellToRealm (cell, realm, 0/*local*/); */
+#if 0
+ code = ka_CellToRealm (cell, realm, 0/*local*/);
+#endif
if (code) strcpy (realm, "");
else lcstring (realm, realm, sizeof(realm)); /* for backward compatibility */
#else
* convert an arbitrary length string to a DES key
*/
int
-des_string_to_key(str,key)
- char *str;
- register des_cblock *key;
+des_string_to_key( char *str, register des_cblock *key )
{
/* NB: i should probably call routine to get local cell here */
ka_StringToKey(str, "umich.edu", key);
struct attribute {
char *quipu_name;
char *output_string;
- void (*mod_func)();
+ void (*mod_func) LDAP_P(( char *who, int attr_idx ));
unsigned short flags;
int number_of_values;
char **values;
struct attribute attrs[MAX_ATTRS];
};
+
+
+/*
+ * Variables
+ */
+
+/* in globals.c: */
+extern struct attribute attrlist[];/* complete list of attrs */
+/* in main.c: */
+extern char copyright[];
+extern char *default_bind_object;
+extern char *bound_dn;
+extern char *group_base;
+extern char *search_base; /* search base */
+extern int lpp;
+extern int verbose; /* verbose mode flag */
+extern int col_size;
+extern int bind_status;
+extern LDAP *ld; /* our ldap descriptor */
+extern LDAPFiltDesc *lfdp; /* LDAP filter descriptor */
+#ifdef DEBUG
+extern int debug; /* debug flag */
+#endif
+/* in print.c: */
+extern struct entry Entry;
+extern int dmsize[];
+/* in version.c: */
+extern char Version[];
+
+
+/*
+ * Functions
+ */
+
+/* in auth.c: */
+int auth LDAP_P(( char *who, int implicit ));
+#if defined(HAVE_KERBEROS) && defined(_AC_KRB_H)
+int krbgetpass LDAP_P(( char *u, char *in, char *re, char *pw, C_Block key ));
+void destroy_tickets LDAP_P(( void ));
+#endif
+
+/* in edit.c: */
+void edit LDAP_P(( char *who ));
+
+/* in find.c: */
+int vrfy LDAP_P(( char *dn ));
+LDAPMessage *find LDAP_P(( char *who, int quiet ));
+int pick_one LDAP_P(( int i ));
+void print_list LDAP_P(( LDAPMessage *list, char **names, int *matches ));
+int find_all_subscribers LDAP_P(( char **sub, char *group ));
+char *fetch_boolean_value LDAP_P(( char *who, struct attribute attr ));
+
+/* in globals.c: */
+
+/* in group.c: */
+void add_group LDAP_P(( char *name ));
+void remove_group LDAP_P(( char *name ));
+void x_group LDAP_P(( int action, char *name ));
+void bulk_load LDAP_P(( char *group ));
+void purge_group LDAP_P(( char *group ));
+void tidy_up LDAP_P(( void ));
+void mod_addrDN LDAP_P(( char *group, int offset ));
+int my_ldap_modify_s LDAP_P(( LDAP *ldap, char *group, LDAPMod **mods ));
+void list_groups LDAP_P(( char *who ));
+void list_memberships LDAP_P(( char *who ));
+
+/* in help.c: */
+void print_help LDAP_P(( char *s ));
+
+/* in main.c: */
+#ifdef DEBUG
+#endif
+
+void do_commands LDAP_P(( void ));
+void status LDAP_P(( void ));
+void change_base LDAP_P(( int type, char **base, char *s ));
+void initialize_client LDAP_P(( void ));
+RETSIGTYPE attn LDAP_P(( int sig ));
+#ifndef NO_TERMCAP
+RETSIGTYPE chwinsz LDAP_P(( int sig ));
+#endif
+
+/* in mod.c: */
+void modify LDAP_P(( char *who ));
+void change_field LDAP_P(( char *who, int attr_idx ));
+char *get_value LDAP_P(( char *id, char *prompt ));
+void set_boolean LDAP_P(( char *who, int attr_idx ));
+#ifdef UOFM
+void set_updates LDAP_P(( char *who, int dummy ));
+#endif
+void print_mod_list LDAP_P(( int group ));
+int perform_action LDAP_P(( char *choice, char *dn, int group ));
+void mod_perror LDAP_P(( LDAP *ld ));
+
+/* in print.c: */
+void parse_answer LDAP_P(( LDAPMessage *s ));
+void add_value LDAP_P(( struct attribute *attr, LDAPMessage *ep, char *ap ));
+void print_an_entry LDAP_P(( void ));
+void print_values LDAP_P(( struct attribute A ));
+void print_DN LDAP_P(( struct attribute A ));
+void clear_entry LDAP_P(( void ));
+int attr_to_index LDAP_P(( char *s ));
+void initialize_attribute_strings LDAP_P(( void ));
+void print_URL LDAP_P(( struct attribute A ));
+void print_one_URL LDAP_P(( char *s, int l_lead, char *tag, int u_lead ));
+
+/* in string_to_key.c: */
+#if defined(HAVE_KERBEROS) && !defined(openbsd) && defined(_AC_KRB_H)
+#if defined(HAVE_AFS_KERBEROS) || !defined(HAVE_KERBEROS_V)
+int des_string_to_key LDAP_P(( char *str, des_cblock *key ));
+#endif
+#if defined(HAVE_AFS_KERBEROS)
+void ka_StringToKey LDAP_P(( char *str, char *cell, des_cblock *key ));
+#endif
+#endif
+
+/* in util.c: */
+char *mygetpass LDAP_P(( char *prompt ));
+void printbase LDAP_P(( char *lead, char *s ));
+void fetch_buffer LDAP_P(( char *buffer, int length, FILE *where ));
+void fatal LDAP_P(( char *s ));
+int isgroup LDAP_P(( void ));
+void format LDAP_P(( char *str, int width, int lead ));
+void format2 LDAP_P(( char *s, char *ft, char *t, int fi, int i, int w ));
+char *strip_ignore_chars LDAP_P(( char *cp ));
+char *code_to_str LDAP_P(( int i ));
+char *friendly_name LDAP_P(( char *s ));
+#ifdef UOFM
+int isauniqname LDAP_P(( char *s ));
+#endif
+int isadn LDAP_P(( char *s ));
+char *my_ldap_dn2ufn LDAP_P(( char *s ));
+int isaurl LDAP_P(( char *s ));
+int isadate LDAP_P(( char *s ));
+void *Malloc LDAP_P(( unsigned int size ));
+void Free LDAP_P(( void *ptr ));
+char *nextstr LDAP_P(( char *s ));
+void free_mod_struct LDAP_P(( LDAPMod *modp ));
+void StrFreeDup LDAP_P(( char **ptr, char *new_value ));
+int confirm_action LDAP_P(( char *msg ));
+
LDAP_END_DECL
#include "ud.h"
-#ifdef DEBUG
-extern int debug;
-#endif
-
-char * mygetpass(prompt)
-char *prompt;
+char *
+mygetpass( char *prompt )
{
#if !defined(HAVE_TERMIOS) && !defined(HAVE_SGTTY_H)
static char buf[256];
register char *p;
register int c;
FILE *fi;
- RETSIGTYPE (*sig)();
+ RETSIGTYPE (*sig)( int sig );
#ifdef DEBUG
if (debug & D_TRACE)
#endif /* DOS */
}
-void printbase(lead, s)
-char *lead, *s;
+void
+printbase( char *lead, char *s )
{
register char **cp;
char **rdns;
- char * friendly_name();
#ifdef DEBUG
if (debug & D_TRACE)
return;
}
-fetch_buffer(buffer, length, where)
-char *buffer;
-int length;
-FILE *where;
+void
+fetch_buffer( char *buffer, int length, FILE *where )
{
- extern LDAP *ld;
register int i;
char *p;
}
-fatal(s)
-char *s;
+void
+fatal( char *s )
{
if (errno != 0)
perror(s);
exit(-1);
}
-isgroup()
+int
+isgroup( void )
{
- extern struct entry Entry;
char **vp;
register int i;
int group = FALSE;
* Print out the string 's' on a field of 'width' chracters. Each line
* should be indented 'lead' characters.
*/
-format(str, width, lead)
-char *str;
-int width, lead;
+void
+format( char *str, int width, int lead )
{
char *s, *original, *leader = "";
register char *cp;
- void * Malloc();
- void Free();
#ifdef DEBUG
if (debug & D_TRACE)
* indented 'indent' spaces, then followed by 'tag', and then followed by
* subsequent lines of 's'.
*/
-format2(s, first_tag, tag, first_indent, indent, width)
-char *s, *first_tag, *tag;
-int first_indent, indent, width;
+void
+format2(
+ char *s,
+ char *first_tag,
+ char *tag,
+ int first_indent,
+ int indent,
+ int width
+)
{
char c, *fi, *i;
register char *cp;
- void * Malloc();
- void Free();
if (first_tag == NULL)
first_tag = "";
#define IN_A_QUOTE 0
#define OUT_OF_QUOTE 1
-char * strip_ignore_chars(cp)
-char *cp;
+char *
+strip_ignore_chars( char *cp )
{
int had_a_comma = FALSE;
int flag = OUT_OF_QUOTE;
register char *rcp, *cp1;
char *tmp;
- void * Malloc();
- void Free();
#ifdef DEBUG
if (debug & D_TRACE)
return(tmp);
}
-char * code_to_str(int i)
+char *
+code_to_str( int i )
{
switch(i) {
case LDAP_MOD_ADD : return("ADD");
}
}
-char * friendly_name(s)
-char *s;
+char *
+friendly_name( char *s )
{
static FriendlyMap *map = NULL;
static char *cp;
#ifdef UOFM
/* return TRUE if s has the syntax of a uniqname */
-isauniqname(s)
-char *s;
+int
+isauniqname( char *s )
{
int i = strlen(s);
#endif
/* return TRUE if this attribute should be printed as a DN */
-isadn(s)
-char *s;
+int
+isadn( char *s )
{
register int i;
- extern struct attribute attrlist[];
for (i = 0; attrlist[i].quipu_name != NULL; i++)
if (!strcasecmp(s, attrlist[i].quipu_name))
return(FALSE);
}
-char * my_ldap_dn2ufn(s)
-char *s;
+char *
+my_ldap_dn2ufn( char *s )
{
register char **cpp;
static char short_DN[BUFSIZ];
}
/* return TRUE if this attribute should be printed as a URL */
-isaurl(s)
-char *s;
+int
+isaurl( char *s )
{
register int i;
- extern struct attribute attrlist[];
for (i = 0; attrlist[i].quipu_name != NULL; i++)
if (!strcasecmp(s, attrlist[i].quipu_name))
}
/* return TRUE if this attribute should be printed as a date and time */
-isadate(s)
-char *s;
+int
+isadate( char *s )
{
register int i;
- extern struct attribute attrlist[];
for (i = 0; attrlist[i].quipu_name != NULL; i++)
if (!strcasecmp(s, attrlist[i].quipu_name))
return(FALSE);
}
-void * Malloc(size)
-unsigned int size;
+void *
+Malloc( unsigned int size )
{
void *void_ptr;
return(void_ptr);
}
-void Free(ptr)
-char *ptr;
+void
+Free( void *ptr )
{
#ifndef STDC_HEADERS
if (free(ptr) < 0) {
return;
}
-char * nextstr(s)
-char *s;
+char *
+nextstr( char *s )
{
while (isspace(*s) && (*s != '\0'))
s++;
return(s);
}
-void free_mod_struct(modp)
-LDAPMod *modp;
+void
+free_mod_struct( LDAPMod *modp )
{
- void Free();
-
if (modp->mod_values != NULL)
(void) ldap_value_free(modp->mod_values);
Free(modp->mod_type);
Free(modp);
}
-void StrFreeDup(ptr, new_value)
-char **ptr, *new_value;
+void
+StrFreeDup( char **ptr, char *new_value )
{
- void Free();
-
if (*ptr != NULL)
Free(*ptr);
if (new_value == NULL)
}
-confirm_action( msg )
- char *msg;
+int
+confirm_action( char *msg )
{
char tmp[SMALL_BUF_SIZE];
int i;
int task(arg)
int *arg;
{
+ int i;
struct timeval tv;
- tv.tv_sec=4;
+ tv.tv_sec=5;
tv.tv_usec=0;
- select(0, NULL, NULL, NULL, &tv);
- tv.tv_sec=6;
- tv.tv_usec=0;
- select(0, NULL, NULL, NULL, &tv);
+ /* we're not interested in any fds */
+ i = select(FD_SETSIZE, NULL, NULL, NULL, &tv);
+
+ if(i < 0) {
+ perror("select");
+ }
exit(1); /* if we exit here, the select blocked the whole process */
}
}
EOF
-if { (eval echo configure:3531: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3534: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
ol_pthread_preemptive=yes
else
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3572: checking for $ac_hdr" >&5
+echo "configure:3575: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3577 "configure"
+#line 3580 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3582: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3585: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
ol_with_threads=found
echo $ac_n "checking for cthread_fork""... $ac_c" 1>&6
-echo "configure:3612: checking for cthread_fork" >&5
+echo "configure:3615: checking for cthread_fork" >&5
if eval "test \"`echo '$''{'ac_cv_func_cthread_fork'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3617 "configure"
+#line 3620 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char cthread_fork(); below. */
; return 0; }
EOF
-if { (eval echo configure:3640: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3643: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_cthread_fork=yes"
else
if test $ol_link_threads = no ; then
echo $ac_n "checking for cthread_fork with -all_load""... $ac_c" 1>&6
-echo "configure:3662: checking for cthread_fork with -all_load" >&5
+echo "configure:3665: checking for cthread_fork with -all_load" >&5
if eval "test \"`echo '$''{'ol_cv_cthread_all_load'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
save_LIBS="$LIBS"
LIBS="-all_load $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 3670 "configure"
+#line 3673 "configure"
#include "confdefs.h"
#include <mach/cthreads.h>
int main() {
; return 0; }
EOF
-if { (eval echo configure:3679: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3682: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
ol_cv_cthread_all_load=yes
else
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3722: checking for $ac_hdr" >&5
+echo "configure:3725: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3727 "configure"
+#line 3730 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3732: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3735: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
if test $ac_cv_header_thread_h = yes -a $ac_cv_header_synch_h = yes ; then
echo $ac_n "checking for thr_create in -lthread""... $ac_c" 1>&6
-echo "configure:3760: checking for thr_create in -lthread" >&5
+echo "configure:3763: checking for thr_create in -lthread" >&5
ac_lib_var=`echo thread'_'thr_create | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lthread $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 3768 "configure"
+#line 3771 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
thr_create()
; return 0; }
EOF
-if { (eval echo configure:3779: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3782: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3818: checking for $ac_hdr" >&5
+echo "configure:3821: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3823 "configure"
+#line 3826 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3828: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3831: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
if test $ac_cv_header_lwp_lwp_h = yes ; then
echo $ac_n "checking for lwp_create in -llwp""... $ac_c" 1>&6
-echo "configure:3856: checking for lwp_create in -llwp" >&5
+echo "configure:3859: checking for lwp_create in -llwp" >&5
ac_lib_var=`echo lwp'_'lwp_create | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-llwp $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 3864 "configure"
+#line 3867 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
lwp_create()
; return 0; }
EOF
-if { (eval echo configure:3875: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3878: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3927: checking for $ac_hdr" >&5
+echo "configure:3930: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3932 "configure"
+#line 3935 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3937: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3940: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
for ac_func in sched_yield pthread_yield
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3966: checking for $ac_func" >&5
+echo "configure:3969: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3971 "configure"
+#line 3974 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:3994: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3997: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
echo $ac_n "checking for LinuxThreads""... $ac_c" 1>&6
-echo "configure:4020: checking for LinuxThreads" >&5
+echo "configure:4023: checking for LinuxThreads" >&5
if eval "test \"`echo '$''{'ol_cv_linux_threads'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4041: checking for $ac_hdr" >&5
+echo "configure:4044: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4046 "configure"
+#line 4049 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4051: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4054: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4081: checking for $ac_hdr" >&5
+echo "configure:4084: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4086 "configure"
+#line 4089 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4091: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4094: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4121: checking for $ac_hdr" >&5
+echo "configure:4124: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4126 "configure"
+#line 4129 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4131: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4134: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
echo $ac_n "checking for thread specific errno""... $ac_c" 1>&6
-echo "configure:4174: checking for thread specific errno" >&5
+echo "configure:4177: checking for thread specific errno" >&5
if eval "test \"`echo '$''{'ol_cv_errno_thread_specific'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4180 "configure"
+#line 4183 "configure"
#include "confdefs.h"
#include <errno.h>
; return 0; }
EOF
-if { (eval echo configure:4191: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4194: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
ol_cv_errno_thread_specific=yes
else
ol_link_ldbm=no
if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = db2 ; then
echo $ac_n "checking for DB2 library""... $ac_c" 1>&6
-echo "configure:4237: checking for DB2 library" >&5
+echo "configure:4240: checking for DB2 library" >&5
if eval "test \"`echo '$''{'ol_cv_lib_db2'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ol_LIBS="$LIBS"
echo $ac_n "checking for db_open in -ldb""... $ac_c" 1>&6
-echo "configure:4243: checking for db_open in -ldb" >&5
+echo "configure:4246: checking for db_open in -ldb" >&5
ac_lib_var=`echo db'_'db_open | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-ldb $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 4251 "configure"
+#line 4254 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
db_open()
; return 0; }
EOF
-if { (eval echo configure:4262: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4265: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4293: checking for $ac_hdr" >&5
+echo "configure:4296: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4298 "configure"
+#line 4301 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4303: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4306: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
if test $ac_cv_header_db_h = yes ; then
echo $ac_n "checking if db.h is DB2""... $ac_c" 1>&6
-echo "configure:4331: checking if db.h is DB2" >&5
+echo "configure:4334: checking if db.h is DB2" >&5
if eval "test \"`echo '$''{'ol_cv_header_db2'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4337 "configure"
+#line 4340 "configure"
#include "confdefs.h"
# include <db.h>
echo $ac_n "checking for Berkeley DB2""... $ac_c" 1>&6
-echo "configure:4369: checking for Berkeley DB2" >&5
+echo "configure:4372: checking for Berkeley DB2" >&5
if eval "test \"`echo '$''{'ol_cv_berkeley_db2'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = db ; then
echo $ac_n "checking for Berkeley DB library""... $ac_c" 1>&6
-echo "configure:4415: checking for Berkeley DB library" >&5
+echo "configure:4418: checking for Berkeley DB library" >&5
if eval "test \"`echo '$''{'ol_cv_lib_db'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ol_LIBS="$LIBS"
echo $ac_n "checking for dbopen""... $ac_c" 1>&6
-echo "configure:4421: checking for dbopen" >&5
+echo "configure:4424: checking for dbopen" >&5
if eval "test \"`echo '$''{'ac_cv_func_dbopen'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4426 "configure"
+#line 4429 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char dbopen(); below. */
; return 0; }
EOF
-if { (eval echo configure:4449: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4452: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_dbopen=yes"
else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for dbopen in -ldb""... $ac_c" 1>&6
-echo "configure:4468: checking for dbopen in -ldb" >&5
+echo "configure:4471: checking for dbopen in -ldb" >&5
ac_lib_var=`echo db'_'dbopen | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-ldb $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 4476 "configure"
+#line 4479 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
dbopen()
; return 0; }
EOF
-if { (eval echo configure:4487: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4490: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4522: checking for $ac_hdr" >&5
+echo "configure:4525: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4527 "configure"
+#line 4530 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4532: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4535: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
echo $ac_n "checking for Berkeley DB""... $ac_c" 1>&6
-echo "configure:4568: checking for Berkeley DB" >&5
+echo "configure:4571: checking for Berkeley DB" >&5
if eval "test \"`echo '$''{'ol_cv_berkeley_db'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4621: checking for $ac_hdr" >&5
+echo "configure:4624: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4626 "configure"
+#line 4629 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4631: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4634: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = gdbm ; then
echo $ac_n "checking for GDBM library""... $ac_c" 1>&6
-echo "configure:4666: checking for GDBM library" >&5
+echo "configure:4669: checking for GDBM library" >&5
if eval "test \"`echo '$''{'ol_cv_lib_gdbm'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ol_LIBS="$LIBS"
echo $ac_n "checking for gdbm_open""... $ac_c" 1>&6
-echo "configure:4672: checking for gdbm_open" >&5
+echo "configure:4675: checking for gdbm_open" >&5
if eval "test \"`echo '$''{'ac_cv_func_gdbm_open'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4677 "configure"
+#line 4680 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char gdbm_open(); below. */
; return 0; }
EOF
-if { (eval echo configure:4700: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4703: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_gdbm_open=yes"
else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for gdbm_open in -lgdbm""... $ac_c" 1>&6
-echo "configure:4719: checking for gdbm_open in -lgdbm" >&5
+echo "configure:4722: checking for gdbm_open in -lgdbm" >&5
ac_lib_var=`echo gdbm'_'gdbm_open | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lgdbm $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 4727 "configure"
+#line 4730 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
gdbm_open()
; return 0; }
EOF
-if { (eval echo configure:4738: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4741: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4773: checking for $ac_hdr" >&5
+echo "configure:4776: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4778 "configure"
+#line 4781 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4783: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4786: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
done
echo $ac_n "checking for db""... $ac_c" 1>&6
-echo "configure:4810: checking for db" >&5
+echo "configure:4813: checking for db" >&5
if eval "test \"`echo '$''{'ol_cv_gdbm'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test $ol_with_ldbm_api = auto -o $ol_with_ldbm_api = ndbm ; then
echo $ac_n "checking for NDBM library""... $ac_c" 1>&6
-echo "configure:4844: checking for NDBM library" >&5
+echo "configure:4847: checking for NDBM library" >&5
if eval "test \"`echo '$''{'ol_cv_lib_ndbm'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ol_LIBS="$LIBS"
echo $ac_n "checking for dbm_open""... $ac_c" 1>&6
-echo "configure:4850: checking for dbm_open" >&5
+echo "configure:4853: checking for dbm_open" >&5
if eval "test \"`echo '$''{'ac_cv_func_dbm_open'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4855 "configure"
+#line 4858 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char dbm_open(); below. */
; return 0; }
EOF
-if { (eval echo configure:4878: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4881: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_dbm_open=yes"
else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for dbm_open in -lndbm""... $ac_c" 1>&6
-echo "configure:4897: checking for dbm_open in -lndbm" >&5
+echo "configure:4900: checking for dbm_open in -lndbm" >&5
ac_lib_var=`echo ndbm'_'dbm_open | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lndbm $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 4905 "configure"
+#line 4908 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
dbm_open()
; return 0; }
EOF
-if { (eval echo configure:4916: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4919: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for dbm_open in -ldbm""... $ac_c" 1>&6
-echo "configure:4936: checking for dbm_open in -ldbm" >&5
+echo "configure:4939: checking for dbm_open in -ldbm" >&5
ac_lib_var=`echo dbm'_'dbm_open | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-ldbm $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 4944 "configure"
+#line 4947 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
dbm_open()
; return 0; }
EOF
-if { (eval echo configure:4955: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:4958: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4992: checking for $ac_hdr" >&5
+echo "configure:4995: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 4997 "configure"
+#line 5000 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5002: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5005: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
done
echo $ac_n "checking for db""... $ac_c" 1>&6
-echo "configure:5029: checking for db" >&5
+echo "configure:5032: checking for db" >&5
if eval "test \"`echo '$''{'ol_cv_ndbm'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test $ol_enable_wrappers = yes ; then
echo $ac_n "checking for hosts_access in -lwrap""... $ac_c" 1>&6
-echo "configure:5077: checking for hosts_access in -lwrap" >&5
+echo "configure:5080: checking for hosts_access in -lwrap" >&5
ac_lib_var=`echo wrap'_'hosts_access | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lwrap $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 5085 "configure"
+#line 5088 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
hosts_access()
; return 0; }
EOF
-if { (eval echo configure:5096: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5099: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:5142: checking for $ac_hdr" >&5
+echo "configure:5145: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5147 "configure"
+#line 5150 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5152: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5155: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
if test $ol_link_termcap = no ; then
echo $ac_n "checking for tputs in -ltermcap""... $ac_c" 1>&6
-echo "configure:5181: checking for tputs in -ltermcap" >&5
+echo "configure:5184: checking for tputs in -ltermcap" >&5
ac_lib_var=`echo termcap'_'tputs | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-ltermcap $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 5189 "configure"
+#line 5192 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
tputs()
; return 0; }
EOF
-if { (eval echo configure:5200: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5203: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
if test $ol_link_termcap = no ; then
echo $ac_n "checking for initscr in -lncurses""... $ac_c" 1>&6
-echo "configure:5233: checking for initscr in -lncurses" >&5
+echo "configure:5236: checking for initscr in -lncurses" >&5
ac_lib_var=`echo ncurses'_'initscr | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lncurses $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 5241 "configure"
+#line 5244 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
initscr()
; return 0; }
EOF
-if { (eval echo configure:5252: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5255: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
# FreeBSD (and others) have crypt(3) in -lcrypt
if test $ol_enable_crypt != no ; then
echo $ac_n "checking for crypt""... $ac_c" 1>&6
-echo "configure:5294: checking for crypt" >&5
+echo "configure:5297: checking for crypt" >&5
if eval "test \"`echo '$''{'ac_cv_func_crypt'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5299 "configure"
+#line 5302 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char crypt(); below. */
; return 0; }
EOF
-if { (eval echo configure:5322: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5325: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_crypt=yes"
else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for crypt in -lcrypt""... $ac_c" 1>&6
-echo "configure:5341: checking for crypt in -lcrypt" >&5
+echo "configure:5344: checking for crypt in -lcrypt" >&5
ac_lib_var=`echo crypt'_'crypt | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lcrypt $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 5349 "configure"
+#line 5352 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
crypt()
; return 0; }
EOF
-if { (eval echo configure:5360: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5363: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
# FreeBSD (and others) have setproctitle(3) in -lutil
if test $ol_enable_proctitle != no ; then
echo $ac_n "checking for setproctitle""... $ac_c" 1>&6
-echo "configure:5404: checking for setproctitle" >&5
+echo "configure:5407: checking for setproctitle" >&5
if eval "test \"`echo '$''{'ac_cv_func_setproctitle'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5409 "configure"
+#line 5412 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char setproctitle(); below. */
; return 0; }
EOF
-if { (eval echo configure:5432: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5435: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_setproctitle=yes"
else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for setproctitle in -lutil""... $ac_c" 1>&6
-echo "configure:5451: checking for setproctitle in -lutil" >&5
+echo "configure:5454: checking for setproctitle in -lutil" >&5
ac_lib_var=`echo util'_'setproctitle | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lutil $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 5459 "configure"
+#line 5462 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
setproctitle()
; return 0; }
EOF
-if { (eval echo configure:5470: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5473: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
fi
echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:5505: checking for ANSI C header files" >&5
+echo "configure:5508: checking for ANSI C header files" >&5
if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5510 "configure"
+#line 5513 "configure"
#include "confdefs.h"
#include <stdlib.h>
#include <stdarg.h>
#include <float.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5518: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5521: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 5535 "configure"
+#line 5538 "configure"
#include "confdefs.h"
#include <string.h>
EOF
if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 5553 "configure"
+#line 5556 "configure"
#include "confdefs.h"
#include <stdlib.h>
EOF
:
else
cat > conftest.$ac_ext <<EOF
-#line 5574 "configure"
+#line 5577 "configure"
#include "confdefs.h"
#include <ctype.h>
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
exit (0); }
EOF
-if { (eval echo configure:5585: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:5588: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
:
else
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6
-echo "configure:5618: checking for $ac_hdr that defines DIR" >&5
+echo "configure:5621: checking for $ac_hdr that defines DIR" >&5
if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5623 "configure"
+#line 5626 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <$ac_hdr>
DIR *dirp = 0;
; return 0; }
EOF
-if { (eval echo configure:5631: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5634: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
eval "ac_cv_header_dirent_$ac_safe=yes"
else
# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
if test $ac_header_dirent = dirent.h; then
echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6
-echo "configure:5656: checking for opendir in -ldir" >&5
+echo "configure:5659: checking for opendir in -ldir" >&5
ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-ldir $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 5664 "configure"
+#line 5667 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
opendir()
; return 0; }
EOF
-if { (eval echo configure:5675: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5678: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
else
echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6
-echo "configure:5697: checking for opendir in -lx" >&5
+echo "configure:5700: checking for opendir in -lx" >&5
ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lx $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 5705 "configure"
+#line 5708 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
opendir()
; return 0; }
EOF
-if { (eval echo configure:5716: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:5719: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
fi
echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6
-echo "configure:5739: checking for sys/wait.h that is POSIX.1 compatible" >&5
+echo "configure:5742: checking for sys/wait.h that is POSIX.1 compatible" >&5
if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5744 "configure"
+#line 5747 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/wait.h>
s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
; return 0; }
EOF
-if { (eval echo configure:5760: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5763: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_header_sys_wait_h=yes
else
for ac_hdr in \
stdarg.h \
stddef.h \
+ string.h \
+ strings.h \
errno.h \
fcntl.h \
filio.h \
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:5810: checking for $ac_hdr" >&5
+echo "configure:5815: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5815 "configure"
+#line 5820 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5820: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5825: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:5848: checking for uid_t in sys/types.h" >&5
+echo "configure:5853: checking for uid_t in sys/types.h" >&5
if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5853 "configure"
+#line 5858 "configure"
#include "confdefs.h"
#include <sys/types.h>
EOF
fi
echo $ac_n "checking type of array argument to getgroups""... $ac_c" 1>&6
-echo "configure:5882: checking type of array argument to getgroups" >&5
+echo "configure:5887: checking type of array argument to getgroups" >&5
if eval "test \"`echo '$''{'ac_cv_type_getgroups'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_cv_type_getgroups=cross
else
cat > conftest.$ac_ext <<EOF
-#line 5890 "configure"
+#line 5895 "configure"
#include "confdefs.h"
/* Thanks to Mike Rendell for this test. */
}
EOF
-if { (eval echo configure:5915: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:5920: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
ac_cv_type_getgroups=gid_t
else
if test $ac_cv_type_getgroups = cross; then
cat > conftest.$ac_ext <<EOF
-#line 5929 "configure"
+#line 5934 "configure"
#include "confdefs.h"
#include <unistd.h>
EOF
echo $ac_n "checking for mode_t""... $ac_c" 1>&6
-echo "configure:5953: checking for mode_t" >&5
+echo "configure:5958: checking for mode_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_mode_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5958 "configure"
+#line 5963 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
fi
echo $ac_n "checking for off_t""... $ac_c" 1>&6
-echo "configure:5986: checking for off_t" >&5
+echo "configure:5991: checking for off_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5991 "configure"
+#line 5996 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
fi
echo $ac_n "checking for pid_t""... $ac_c" 1>&6
-echo "configure:6019: checking for pid_t" >&5
+echo "configure:6024: checking for pid_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6024 "configure"
+#line 6029 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
fi
echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:6052: checking return type of signal handlers" >&5
+echo "configure:6057: checking return type of signal handlers" >&5
if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6057 "configure"
+#line 6062 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <signal.h>
int i;
; return 0; }
EOF
-if { (eval echo configure:6074: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6079: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_type_signal=void
else
echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:6093: checking for size_t" >&5
+echo "configure:6098: checking for size_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6098 "configure"
+#line 6103 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
fi
echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:6126: checking for uid_t in sys/types.h" >&5
+echo "configure:6131: checking for uid_t in sys/types.h" >&5
if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6131 "configure"
+#line 6136 "configure"
#include "confdefs.h"
#include <sys/types.h>
EOF
fi
echo $ac_n "checking for st_blksize in struct stat""... $ac_c" 1>&6
-echo "configure:6160: checking for st_blksize in struct stat" >&5
+echo "configure:6165: checking for st_blksize in struct stat" >&5
if eval "test \"`echo '$''{'ac_cv_struct_st_blksize'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6165 "configure"
+#line 6170 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/stat.h>
struct stat s; s.st_blksize;
; return 0; }
EOF
-if { (eval echo configure:6173: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6178: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_struct_st_blksize=yes
else
fi
echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:6194: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:6199: checking whether time.h and sys/time.h may both be included" >&5
if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6199 "configure"
+#line 6204 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/time.h>
struct tm *tp;
; return 0; }
EOF
-if { (eval echo configure:6208: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6213: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_header_time=yes
else
fi
echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6
-echo "configure:6229: checking whether struct tm is in sys/time.h or time.h" >&5
+echo "configure:6234: checking whether struct tm is in sys/time.h or time.h" >&5
if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6234 "configure"
+#line 6239 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <time.h>
struct tm *tp; tp->tm_sec;
; return 0; }
EOF
-if { (eval echo configure:6242: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6247: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_struct_tm=time.h
else
echo $ac_n "checking if toupper() requires islower()""... $ac_c" 1>&6
-echo "configure:6265: checking if toupper() requires islower()" >&5
+echo "configure:6270: checking if toupper() requires islower()" >&5
if eval "test \"`echo '$''{'ol_cv_c_upper_lower'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ol_cv_c_upper_lower=safe
else
cat > conftest.$ac_ext <<EOF
-#line 6274 "configure"
+#line 6279 "configure"
#include "confdefs.h"
#include <ctype.h>
exit(1);
}
EOF
-if { (eval echo configure:6286: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6291: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
ol_cv_c_upper_lower=no
else
fi
echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:6309: checking for working const" >&5
+echo "configure:6314: checking for working const" >&5
if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6314 "configure"
+#line 6319 "configure"
#include "confdefs.h"
int main() {
; return 0; }
EOF
-if { (eval echo configure:6363: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6368: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_const=yes
else
echo $ac_n "checking for 8-bit clean memcmp""... $ac_c" 1>&6
-echo "configure:6386: checking for 8-bit clean memcmp" >&5
+echo "configure:6391: checking for 8-bit clean memcmp" >&5
if eval "test \"`echo '$''{'ac_cv_func_memcmp_clean'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_cv_func_memcmp_clean=no
else
cat > conftest.$ac_ext <<EOF
-#line 6394 "configure"
+#line 6399 "configure"
#include "confdefs.h"
main()
}
EOF
-if { (eval echo configure:6404: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6409: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
ac_cv_func_memcmp_clean=yes
else
test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.o"
echo $ac_n "checking for strftime""... $ac_c" 1>&6
-echo "configure:6422: checking for strftime" >&5
+echo "configure:6427: checking for strftime" >&5
if eval "test \"`echo '$''{'ac_cv_func_strftime'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6427 "configure"
+#line 6432 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char strftime(); below. */
; return 0; }
EOF
-if { (eval echo configure:6450: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6455: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_strftime=yes"
else
echo "$ac_t""no" 1>&6
# strftime is in -lintl on SCO UNIX.
echo $ac_n "checking for strftime in -lintl""... $ac_c" 1>&6
-echo "configure:6472: checking for strftime in -lintl" >&5
+echo "configure:6477: checking for strftime in -lintl" >&5
ac_lib_var=`echo intl'_'strftime | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
ac_save_LIBS="$LIBS"
LIBS="-lintl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 6480 "configure"
+#line 6485 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
strftime()
; return 0; }
EOF
-if { (eval echo configure:6491: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6496: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
fi
echo $ac_n "checking for vprintf""... $ac_c" 1>&6
-echo "configure:6518: checking for vprintf" >&5
+echo "configure:6523: checking for vprintf" >&5
if eval "test \"`echo '$''{'ac_cv_func_vprintf'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6523 "configure"
+#line 6528 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char vprintf(); below. */
; return 0; }
EOF
-if { (eval echo configure:6546: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6551: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_vprintf=yes"
else
if test "$ac_cv_func_vprintf" != yes; then
echo $ac_n "checking for _doprnt""... $ac_c" 1>&6
-echo "configure:6570: checking for _doprnt" >&5
+echo "configure:6575: checking for _doprnt" >&5
if eval "test \"`echo '$''{'ac_cv_func__doprnt'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6575 "configure"
+#line 6580 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char _doprnt(); below. */
; return 0; }
EOF
-if { (eval echo configure:6598: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6603: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func__doprnt=yes"
else
for ac_func in vsnprintf
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:6627: checking for $ac_func" >&5
+echo "configure:6632: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6632 "configure"
+#line 6637 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:6655: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6660: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
fi
echo $ac_n "checking for wait3 that fills in rusage""... $ac_c" 1>&6
-echo "configure:6682: checking for wait3 that fills in rusage" >&5
+echo "configure:6687: checking for wait3 that fills in rusage" >&5
if eval "test \"`echo '$''{'ac_cv_func_wait3_rusage'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_cv_func_wait3_rusage=no
else
cat > conftest.$ac_ext <<EOF
-#line 6690 "configure"
+#line 6695 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/time.h>
}
}
EOF
-if { (eval echo configure:6721: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6726: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
ac_cv_func_wait3_rusage=yes
else
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:6778: checking for $ac_func" >&5
+echo "configure:6783: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6783 "configure"
+#line 6788 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:6806: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6811: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
for ac_func in getopt strdup tempnam
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:6834: checking for $ac_func" >&5
+echo "configure:6839: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6839 "configure"
+#line 6844 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:6862: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6867: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
# Check Configuration
echo $ac_n "checking declaration of sys_errlist""... $ac_c" 1>&6
-echo "configure:6892: checking declaration of sys_errlist" >&5
+echo "configure:6897: checking declaration of sys_errlist" >&5
if eval "test \"`echo '$''{'ol_cv_dcl_sys_errlist'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6898 "configure"
+#line 6903 "configure"
#include "confdefs.h"
#include <stdio.h>
char *c = (char *) *sys_errlist
; return 0; }
EOF
-if { (eval echo configure:6908: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6913: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ol_cv_dcl_sys_errlist=yes
else
EOF
echo $ac_n "checking existence of sys_errlist""... $ac_c" 1>&6
-echo "configure:6929: checking existence of sys_errlist" >&5
+echo "configure:6934: checking existence of sys_errlist" >&5
if eval "test \"`echo '$''{'ol_cv_have_sys_errlist'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6935 "configure"
+#line 6940 "configure"
#include "confdefs.h"
#include <errno.h>
int main() {
char *c = (char *) *sys_errlist
; return 0; }
EOF
-if { (eval echo configure:6942: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:6947: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
ol_cv_have_sys_errlist=yes
else
int task(arg)
int *arg;
{
+ int i;
struct timeval tv;
- tv.tv_sec=4;
+ tv.tv_sec=5;
tv.tv_usec=0;
- select(0, NULL, NULL, NULL, &tv);
- tv.tv_sec=6;
- tv.tv_usec=0;
- select(0, NULL, NULL, NULL, &tv);
+ /* we're not interested in any fds */
+ i = select(FD_SETSIZE, NULL, NULL, NULL, &tv);
+
+ if(i < 0) {
+ perror("select");
+ }
exit(1); /* if we exit here, the select blocked the whole process */
}
AC_CHECK_HEADERS( \
stdarg.h \
stddef.h \
+ string.h \
+ strings.h \
errno.h \
fcntl.h \
filio.h \
*/
#include "whois++.h"
-
-extern char *index(), *rindex();
+#include <stdlib.h>
+extern int getdtablesize (void);
#define isspecial(c) ( (c) == ',' || (c) == ';' || (c) == ':' || (c) == '=' )
static int numberOfComponents;
static int components = 10;
-static int getToken( token )
-char *token;
-
+static int
+getToken( char *token )
{
static char *buffer = NULL;
static int idx;
if ( buffer == NULL ) {
tablesize = getdtablesize();
+
+#ifdef FD_SETSIZE
+ if ( tablesize > FD_SETSIZE ) {
+ tablesize = FD_SETSIZE;
+ }
+#endif /* FD_SETSIZE */
+
timeout.tv_sec = 60;
timeout.tv_usec = 0;
FD_ZERO( &readfds );
}
}
-static int term( token, value, attribute, specifier, soundex )
-int token;
-char *value, *attribute;
-int *specifier, *soundex;
+static int
+term(
+ int token,
+ char *value,
+ char *attribute,
+ int *specifier,
+ int *soundex
+)
{
char buffer[BUFSIZ], temp[BUFSIZ];
int iterations;
return token;
}
-static int processTerm( specifier, soundex, buffer, attribute, value )
-int specifier, soundex;
-char *buffer, *attribute, *value;
-
+static int
+processTerm(
+ int specifier,
+ int soundex,
+ char *buffer,
+ char *attribute,
+ char *value
+)
{
char *s, *t;
char query[BUFSIZ];
sprintf( query, "(%s%s%s)", attribute,
(soundex)?"~=":"=", buffer );
} else {
- if ( ( s = index( buffer, ',' ) ) != NULL ) {
+ if ( ( s = strchr( buffer, ',' ) ) != NULL ) {
*s++ = '\0';
while ( *s && isspace( *s ) )
s++;
(soundex)?"~=":"=", buffer );
component[numberOfComponents++] = strdup( query );
/* let's just make sure there is no title */
- if ( ( t = rindex( s, ',' ) ) != NULL ) {
+ if ( ( t = strrchr( s, ',' ) ) != NULL ) {
*t++ = '\0';
while ( *t && isspace( *t ) )
t++;
sprintf( query, "%s *", &buffer[6] );
strcpy( buffer, query );
}
- if ( ( s = index( buffer, '@' ) ) != NULL ) {
+ if ( ( s = strchr( buffer, '@' ) ) != NULL ) {
*s++ = '\0';
if ( *buffer == '\0' ) /* no username */
sprintf( query, "(mail=*@%s)", s );
if ( soundex )
printFormatted( lineLength, TRUE, stdout,
"Fuzzy matching not supported on e-mail address queries" );
- } else if ( index( buffer, ' ' ) == NULL ) {
+ } else if ( strchr( buffer, ' ' ) == NULL ) {
sprintf( query,
"(|(sn%s%s)(userid%s%s)(l%s%s)(ou%s%s)\
(&(cn%s%s)(!(objectClass=person))))",
return SEARCH;
}
-int parseCommand( query )
-char *query;
+int
+parseCommand( char *query )
{
/*
* This procedure reads the string sent by the user and breaks it
*/
#include "whois++.h"
+#include <stdlib.h>
static struct {
char *str;
NULL, NULL
};
-static nextLine(fp)
-FILE *fp;
+static void
+nextLine( FILE *fp )
{
/*
* We probably should check that the user hasn't put anything else
/*
* Get next word, skipping blanks & comments.
*/
-static int getWord(buffer, size, fp)
-char *buffer;
-int size;
-FILE *fp;
+static int
+getWord( char *buffer, int size, FILE *fp )
{
char *cp;
int c, string;
return (cp != buffer);
}
-void readConfiguration( config )
-FILE *config;
-
+void
+readConfiguration( FILE *config )
{
char buffer[BUFSIZ];
char *s;
#include "whois++.h"
-void needHelp( reason )
-char *reason;
+void
+needHelp( char *reason )
{
char filename[MAXPATHLEN];
char buffer[BUFSIZ];
*/
#include "whois++.h"
+#include <stdlib.h>
-void showTemplate( template )
-char *template;
+void
+showTemplate( char *template )
{
char filename[MAXPATHLEN], buffer[BUFSIZ];
FILE *description;
}
}
-void listTemplates( query )
-char *query;
-
+void
+listTemplates( char *query )
{
char filename[MAXPATHLEN];
DIR *dir;
}
}
-char **specifyAttributes( objectClass )
-char *objectClass;
-
+char **
+specifyAttributes( char *objectClass )
{
FILE *description;
char filename[MAXPATHLEN], buffer[BUFSIZ];
return attributes;
}
-char *templateToObjectClass( template )
-char *template;
-
+char *
+templateToObjectClass( char *template )
{
int i;
return template;
}
-char *objectClassToTemplate( objectClass )
-char *objectClass;
-
+char *
+objectClassToTemplate( char *objectClass )
{
int i;
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
+#include "portable.h"
+
#include <stdio.h>
#include <signal.h>
#include <ctype.h>
#include <langinfo.h>
#include <locale.h>
#endif
+#include <ac/unistd.h>
-static void handler();
-
-char *lowerCase( string )
-char *string;
+static void handler(int sig);
+char *
+lowerCase( char *string )
{
char *s;
return string;
}
-char *convertTime( date, locale )
-char *date, *locale;
-
+char *
+convertTime( char *date, char *locale )
{
/*
* A quick hack to convert the time from the format Quipu uses into
static long interrupt;
-char *getPassword( prompt )
-char *prompt;
-
+char *
+getPassword( char *prompt )
{
#if defined(SYS5) || defined(XOS_2)
struct termios ttyb;
#endif
FILE *input;
struct sigvec ovec, vec;
- void handler();
unsigned long flags;
int c, idx;
static char buffer[BUFSIZ + 1];
return buffer;
}
-static void handler()
-
+static void
+handler( int sig )
{
++interrupt;
}
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
-char *version()
-
+char *version( void )
{
return "1.7";
}
EXTERN char **category;
EXTERN table *templateTranslationTable;
-extern int displayDescribe(), parseCommand();
-extern void needHelp();
-extern void showTemplate(), listTemplates();
-extern char **specifyAttributes();
-extern char *lowerCase(), *version(), *attributeLabel();
+extern int displayDescribe(), parseCommand(char *query);
+extern void needHelp(char *reason);
+extern void showTemplate(char *template), listTemplates(char *query);
+extern char **specifyAttributes(char *objectClass);
+extern char *lowerCase(char *string), *version(void), *attributeLabel();
extern char *rfc931_name();
+extern char *templateToObjectClass(char *template);
--- /dev/null
+/* Generic string.h */
+
+#ifndef _AC_STRING_H
+#define _AC_STRING_H
+
+#ifdef STDC_HEADERS
+# include <string.h>
+#else
+# ifdef HAVE_STRING_H
+# include <string.h>
+# elif HAVE_STRINGS_H
+# include <strings.h>
+# endif
+
+# ifndef HAVE_STRCHR
+# define strchr index
+# define strrchr rindex
+# endif
+
+# ifndef HAVE_MEMCPY
+# define memcpy(d, s, n) bcopy ((s), (d), (n))
+# define memmove(d, s, n) bcopy ((s), (d), (n))
+# endif
+
+# if !defined(HAVE_STRING_H) && !defined(HAVE_STRINGS_H)
+ /* define prototypes for string functions */
+ /* this could cause problems on some odd ball systems */
+ char *strchr(), *strrchr();
+ char *strcpy(), *strncpy();
+ char *strcat (), *strncat ();
+ int strcmp(), strncmp();
+ int strcasecmp(), strncasecmp();
+ char *strdup();
+ char *strtok();
+ char *strpbrk();
+ int memcmp();
+# endif
+
+#endif
+
+#ifndef SAFEMEMCPY
+# if defined( HAVE_MEMMOVE )
+# define SAFEMEMCPY( d, s, n ) memmove((d), (s), (n))
+# elif defined( HAVE_BCOPY )
+# define SAFEMEMCPY( d, s, n ) bcopy((s), (d), (n))
+# elif defined( MACOS )
+# define SAFEMEMCPY( d, s, n ) BlockMoveData((Ptr)(s), (Ptr)(d), (n))
+# else
+ /* nothing left but memcpy() */
+# define SAFEMEMCPY( d, s, n ) memcpy((d), (s), (n))
+# endif
+#endif
+
+#endif /* _AC_STRING_H */
--- /dev/null
+/* Generic unistd.h */
+
+#ifndef _AC_UNISTD_H
+#define _AC_UNISTD_H
+
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#else
+ /* we really should test for these */
+ char *crypt();
+ char *gethostname();
+ char *getenv();
+ long *random();
+ int flock();
+#endif
+
+/* getopt() defines may be in separate include file */
+#if HAVE_GETOPT_H
+# include <getopt.h>
+
+#elif !defined(HAVE_GETOPT)
+ /* no getopt, assume we need getopt-compat.h */
+# include <getopt-compat.h>
+
+#else
+ /* assume we need to declare these externs */
+ extern char *optarg;
+ extern int optind, opterr, optopt;
+#endif
+
+#ifndef HAVE_TEMPNAM
+ extern char *tempnam(const char *tmpdir, const char *prefix);
+#endif
+#ifndef HAVE_MKTEMP
+ extern char *mktemp(char *);
+#endif
+
+/* use _POSIX_VERSION for POSIX.1 code */
+
+#endif /* _AC_UNISTD_H */
avl_getfirst LDAP_P((Avlnode *));
#ifdef AVL_REENTRANT
+/* ??? avl.c does not provide this version ??? */
LDAP_F caddr_t
avl_getnext LDAP_P((Avlnode *, caddr_t ));
#else
LDAP_F int
avl_dup_error LDAP_P((void));
+LDAP_F int
+avl_dup_ok LDAP_P((void));
+
LDAP_F int
avl_apply LDAP_P((Avlnode *, IFP, caddr_t, int, int));
+LDAP_F int
+avl_prefixapply LDAP_P((Avlnode *, caddr_t, IFP, caddr_t, IFP, caddr_t, int));
+
/* apply traversal types */
#define AVL_PREORDER 1
#define AVL_INORDER 2
#define LDAP_URL_ERR_BADSCOPE 3 /* URL scope string is invalid */
#define LDAP_URL_ERR_MEM 4 /* can't allocate memory space */
-/* this typedef is never used, only exists to rid of declaration
- in function param list warning */
-typedef struct timeval LDAPtv;
+/* avoid pulling in headers */
+struct timeval;
/*
* in abandon.c:
*/
LDAP_F int ldap_sort_entries LDAP_P(( LDAP *ld,
LDAPMessage **chain, char *attr,
- int (*cmp) LDAP_P((const char *, const char *)) ));
+ int (*cmp) (const char *, const char *) ));
LDAP_F int ldap_sort_values LDAP_P(( LDAP *ld,
- char **vals, int (*cmp) LDAP_P((const void *, const void *)) ));
-LDAP_F int ldap_sort_strcasecmp LDAP_P(( char **a, char **b ));
+ char **vals, int (*cmp) (const void *, const void *) ));
+LDAP_F int ldap_sort_strcasecmp LDAP_P(( const void *a, const void *b ));
/*
LDAP_BEGIN_DECL
+stkalign_t *get_stack( int *stacknop );
+void free_stack( int *stackno );
+
typedef void *(*VFP)();
/* thread attributes and thread type */
* Include file for LDAP utility routine
*/
-/* ISC Base64 Routines */
-
LDAP_BEGIN_DECL
+/* ISC Base64 Routines */
+/* base64.c */
LDAP_F int b64_ntop LDAP_P((u_char const *, size_t, char *, size_t));
LDAP_F int b64_pton LDAP_P((char const *, u_char *, size_t));
+/* detach.c */
LDAP_F void lutil_detach LDAP_P((int debug, int do_close));
+/* passwd.c */
LDAP_F int lutil_passwd LDAP_P((const char *cred, const char *passwd));
LDAP_END_DECL
/* Define if you have the <stddef.h> header file. */
#undef HAVE_STDDEF_H
+/* Define if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
/* Define if you have the <synch.h> header file. */
#undef HAVE_SYNCH_H
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#ifndef lint
static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of Michigan.\nAll rights reserved.\n";
static char avl_version[] = "AVL library version 1.0\n";
#endif
-#include <sys/types.h>
#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+
#include "avl.h"
#define ROTATERIGHT(x) { \
Avlnode *tmp;\
- if ( *x == NULL || (*x)->avl_left == NULL ) {\
+ if ( *(x) == NULL || (*(x))->avl_left == NULL ) {\
(void) printf("RR error\n"); exit(1); \
}\
- tmp = (*x)->avl_left;\
- (*x)->avl_left = tmp->avl_right;\
- tmp->avl_right = *x;\
- *x = tmp;\
+ tmp = (*(x))->avl_left;\
+ (*(x))->avl_left = tmp->avl_right;\
+ tmp->avl_right = *(x);\
+ *(x) = tmp;\
}
#define ROTATELEFT(x) { \
Avlnode *tmp;\
- if ( *x == NULL || (*x)->avl_right == NULL ) {\
+ if ( *(x) == NULL || (*(x))->avl_right == NULL ) {\
(void) printf("RL error\n"); exit(1); \
}\
- tmp = (*x)->avl_right;\
- (*x)->avl_right = tmp->avl_left;\
+ tmp = (*(x))->avl_right;\
+ (*(x))->avl_right = tmp->avl_left;\
tmp->avl_left = *x;\
- *x = tmp;\
+ *(x) = tmp;\
}
/*
* and balance of an avl tree.
*/
-static
-ravl_insert( iroot, data, taller, fcmp, fdup, depth )
- Avlnode **iroot;
- caddr_t data;
- int *taller;
- IFP fcmp; /* comparison function */
- IFP fdup; /* function to call for duplicates */
- int depth;
+static int
+ravl_insert(
+ Avlnode **iroot,
+ caddr_t data,
+ int *taller,
+ IFP fcmp, /* comparison function */
+ IFP fdup, /* function to call for duplicates */
+ int depth
+)
{
int rc, cmp, tallersub;
Avlnode *l, *r;
* NOTE: this routine may malloc memory
*/
-avl_insert( root, data, fcmp, fdup )
- Avlnode **root;
- caddr_t data;
- IFP fcmp;
- IFP fdup;
+int
+avl_insert( Avlnode **root, caddr_t data, IFP fcmp, IFP fdup )
{
int taller;
* been shortened because of a deletion.
*/
-static
-right_balance( root )
- Avlnode **root;
+static int
+right_balance( Avlnode **root )
{
- int shorter;
+ int shorter = -1;
Avlnode *r, *l;
switch( (*root)->avl_bf ) {
* been shortened because of a deletion.
*/
-static
-left_balance( root )
- Avlnode **root;
+static int
+left_balance( Avlnode **root )
{
- int shorter;
+ int shorter = -1;
Avlnode *r, *l;
switch( (*root)->avl_bf ) {
*/
static caddr_t
-ravl_delete( root, data, fcmp, shorter )
- Avlnode **root;
- caddr_t data;
- IFP fcmp;
- int *shorter;
+ravl_delete( Avlnode **root, caddr_t data, IFP fcmp, int *shorter )
{
int shortersubtree = 0;
int cmp;
*/
caddr_t
-avl_delete( root, data, fcmp )
- Avlnode **root;
- caddr_t data;
- IFP fcmp;
+avl_delete( Avlnode **root, caddr_t data, IFP fcmp )
{
int shorter;
return( ravl_delete( root, data, fcmp, &shorter ) );
}
-static
-avl_inapply( root, fn, arg, stopflag )
- Avlnode *root;
- IFP fn;
- caddr_t arg;
- int stopflag;
+static int
+avl_inapply( Avlnode *root, IFP fn, caddr_t arg, int stopflag )
{
if ( root == 0 )
return( AVL_NOMORE );
return( avl_inapply( root->avl_right, fn, arg, stopflag ) );
}
-static
-avl_postapply( root, fn, arg, stopflag )
- Avlnode *root;
- IFP fn;
- caddr_t arg;
- int stopflag;
+static int
+avl_postapply( Avlnode *root, IFP fn, caddr_t arg, int stopflag )
{
if ( root == 0 )
return( AVL_NOMORE );
return( (*fn)( root->avl_data, arg ) );
}
-static
-avl_preapply( root, fn, arg, stopflag )
- Avlnode *root;
- IFP fn;
- caddr_t arg;
- int stopflag;
+static int
+avl_preapply( Avlnode *root, IFP fn, caddr_t arg, int stopflag )
{
if ( root == 0 )
return( AVL_NOMORE );
* of nodes.
*/
-avl_apply( root, fn, arg, stopflag, type )
- Avlnode *root;
- IFP fn;
- caddr_t arg;
- int stopflag;
- int type;
+int
+avl_apply( Avlnode *root, IFP fn, caddr_t arg, int stopflag, int type )
{
switch ( type ) {
case AVL_INORDER:
* AVL_NOMORE is returned.
*/
-avl_prefixapply( root, data, fmatch, marg, fcmp, carg, stopflag )
- Avlnode *root;
- caddr_t data;
- IFP fmatch;
- caddr_t marg;
- IFP fcmp;
- caddr_t carg;
- int stopflag;
+int
+avl_prefixapply(
+ Avlnode *root,
+ caddr_t data,
+ IFP fmatch,
+ caddr_t marg,
+ IFP fcmp,
+ caddr_t carg,
+ int stopflag
+)
{
int cmp;
* number of items actually freed is returned.
*/
-avl_free( root, dfree )
- Avlnode *root;
- IFP dfree;
+int
+avl_free( Avlnode *root, IFP dfree )
{
int nleft, nright;
*/
caddr_t
-avl_find( root, data, fcmp )
- Avlnode *root;
- caddr_t data;
- IFP fcmp;
+avl_find( Avlnode *root, caddr_t data, IFP fcmp )
{
int cmp;
*/
caddr_t
-avl_find_lin( root, data, fcmp )
- Avlnode *root;
- caddr_t data;
- IFP fcmp;
+avl_find_lin( Avlnode *root, caddr_t data, IFP fcmp )
{
caddr_t res;
#define AVL_GRABSIZE 100
/* ARGSUSED */
-static
-avl_buildlist( data, arg )
- caddr_t data;
- int arg;
+static int
+avl_buildlist( caddr_t data, int arg )
{
static int slots;
*/
caddr_t
-avl_getfirst( root )
- Avlnode *root;
+avl_getfirst( Avlnode *root )
{
if ( avl_list ) {
free( (char *) avl_list);
}
caddr_t
-avl_getnext()
+avl_getnext( void )
{
if ( avl_list == 0 )
return( 0 );
return( avl_list[ avl_nextlist++ ] );
}
-avl_dup_error()
+int
+avl_dup_error( void )
{
return( -1 );
}
-avl_dup_ok()
+int
+avl_dup_ok( void )
{
return( 0 );
}
/* testavl.c - Test Tim Howes AVL code */
-#include <sys/types.h>
-#include <stdio.h>
-#include "avl.h"
-char *strdup( s )
-char *s;
-{
- char *new;
+#include "portable.h"
- if ( (new = (char *) malloc( strlen( s ) + 1 )) == NULL )
- return( NULL );
+#include <stdio.h>
+#include <stdlib.h>
- strcpy( new, s );
+#include <ac/string.h>
+#include <sys/types.h>
- return( new );
-}
+#include "avl.h"
+
+static void ravl_print LDAP_P(( Avlnode *root, int depth ));
+static void myprint LDAP_P(( Avlnode *root ));
-main( argc, argv )
-int argc;
-char **argv;
+int
+main( int argc, char **argv )
{
Avlnode *tree = NULLAVL;
char command[ 10 ];
char name[ 80 ];
char *p;
- int free(), strcmp();
printf( "> " );
while ( fgets( command, sizeof( command ), stdin ) != NULL ) {
case 't': /* traverse with first, next */
printf( "***\n" );
for ( p = (char * ) avl_getfirst( tree );
- p != NULL; p = (char *) avl_getnext( tree, p ) )
+ p != NULL; p = (char *) avl_getnext( /* tree, p */ ) )
printf( "%s\n", p );
printf( "***\n" );
break;
exit( 0 );
name[ strlen( name ) - 1 ] = '\0';
if ( avl_insert( &tree, strdup( name ), strcmp,
- avl_dup_error ) != OK )
+ avl_dup_error ) != 0 )
printf( "\nNot inserted!\n" );
break;
case 'd': /* delete */
/* NOTREACHED */
}
-static ravl_print( root, depth )
-Avlnode *root;
-int depth;
+static void ravl_print( Avlnode *root, int depth )
{
int i;
ravl_print( root->avl_left, depth+1 );
}
-myprint( root )
-Avlnode *root;
+static void myprint( Avlnode *root )
{
printf( "********\n" );
if ( root == 0 )
printf( "\tNULL\n" );
else
- ( void ) ravl_print( root, 0 );
+ ravl_print( root, 0 );
printf( "********\n" );
}
#include "portable.h"
#include <stdio.h>
-
-#ifdef STDC_HEADERS
#include <stdlib.h>
-#endif
#include <ac/stdarg.h>
#include <ac/string.h>
#include <ac/socket.h>
+#include <ac/unistd.h>
#ifdef HAVE_CONSOLE_H
#include <console.h>
int tag;
BerElement ber;
Sockbuf sb;
- extern char *optarg;
#ifdef HAVE_CONSOLE_H
ccommand( &argv );
* All rights reserved.
*/
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#ifdef MACOS
-#include <stdlib.h>
-#include <unix.h>
-#include <fcntl.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/unistd.h>
+
+#ifdef HAVE_CONSOLE_H
#include <console.h>
-#else /* MACOS */
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif /* MACOS */
+#endif /* HAVE_CONSOLE_H */
+
#include "lber.h"
-static usage( char *name )
+static void usage( char *name )
{
fprintf( stderr, "usage: %s fmtstring\n", name );
}
main( int argc, char **argv )
{
- int i, num, len;
- char *s, *p;
+#ifdef notdef
+ int i, len;
+ char *s, *p;
+#endif
+ int num;
Seqorset *sos = NULLSEQORSET;
BerElement *ber;
Sockbuf sb;
- extern char *optarg;
if ( argc < 2 ) {
usage( argv[0] );
exit( 1 );
}
- bzero( &sb, sizeof(sb) );
+ memset( &sb, 0, sizeof(sb) );
sb.sb_sd = 1;
sb.sb_ber.ber_buf = NULL;
-#ifdef MACOS
+#ifdef HAVE_CONSOLE_H
ccommand( &argv );
cshow( stdout );
break;
default:
-#ifndef NO_USERINTERFACE
+#ifdef LDAP_LIBUI
fprintf( stderr, "unknown fmt %c\n", *fmt );
-#endif /* NO_USERINTERFACE */
+#endif /* LDAP_LIBUI */
rc = -1;
break;
}
#define EXBUFSIZ 1024
-int
+static int
ber_filbuf( Sockbuf *sb, long len )
{
short rc;
}
-long
+static long
BerRead( Sockbuf *sb, char *buf, long len )
{
int c;
}
BerElement *
-ber_alloc()
+ber_alloc( void )
{
return( ber_alloc_t( 0 ) );
}
BerElement *
-der_alloc()
+der_alloc( void )
{
return( ber_alloc_t( LBER_USE_DER ) );
}
unsigned long tag = 0, netlen, toread;
unsigned char lc;
long rc;
- int noctets, diff;
+ int noctets;
+ unsigned int diff;
#ifdef LDAP_DEBUG
if ( lber_debug )
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/time.h>
+#include <ac/unistd.h>
#include "lber.h"
#include "ldap.h"
tv.tv_usec = 0;
Debug( LDAP_DEBUG_TRACE,
- "cldap_result waiting up to %d seconds for a response\n",
- tv.tv_sec, 0, 0 );
+ "cldap_result waiting up to %ld seconds for a response\n",
+ (long) tv.tv_sec, 0, 0 );
ber_init( &ber, 0 );
ldap_set_ber_options( ld, &ber );
bv = NULL;
} else {
- Debug( LDAP_DEBUG_TRACE, "cldap_parsemsg got unknown tag %d\n",
+ Debug( LDAP_DEBUG_TRACE, "cldap_parsemsg got unknown tag %lu\n",
tag, 0, 0 );
rc = LDAP_PROTOCOL_ERROR;
break; /* return w/error */
#ifndef _LDAP_INT_H
#define _LDAP_INT_H
+LDAP_BEGIN_DECL
+
#define LDAP_URL_PREFIX "ldap://"
#define LDAP_URL_PREFIX_LEN 7
#define LDAP_URL_URLCOLON "URL:"
#endif /* LDAP_DNS */
#endif /* LDAP_REFERRALS */
-LDAP_BEGIN_DECL
/*
* in cache.c
*/
int ldap_check_cache LDAP_P(( LDAP *ld, unsigned long msgtype, BerElement *request ));
/*
- * in dparse.c
+ * in dsparse.c
*/
int next_line_tokens LDAP_P(( char **bufp, long *blenp, char ***toksp ));
void free_strarray LDAP_P(( char **sap ));
int ldap_append_referral( LDAP *ld, char **referralsp, char *s );
#endif /* LDAP_REFERRALS */
+/*
+ * in result.c:
+ */
+#ifdef LDAP_CONNECTIONLESS
+LDAP_F int cldap_getmsg ( LDAP *ld, struct timeval *timeout, BerElement *ber );
+#endif
/*
* in search.c
#endif /* LDAP_CHARSET_8859 == LDAP_DEFAULT_CHARSET */
#endif /* STR_TRANSLATION && LDAP_DEFAULT_CHARSET */
+LDAP_END_DECL
#endif /* _LDAP_INT_H */
connected = use_hp = 0;
- if ( host != NULL && ( address = inet_addr( host )) == (unsigned long) -1L ) {
+ if ( host != NULL ) {
+ address = inet_addr( host );
+ /* This was just a test for -1 until OSF1 let inet_addr return
+ unsigned int, which is narrower than 'unsigned long address' */
+ if ( address == 0xffffffff || address == (unsigned long) -1 ) {
if ( (hp = gethostbyname( host )) == NULL ) {
#ifdef HAVE_WINSOCK
errno = WSAGetLastError();
return( -1 );
}
use_hp = 1;
+ }
}
rc = -1;
void *
-ldap_new_select_info()
+ldap_new_select_info( void )
{
struct selectinfo *sip;
tblsize = sysconf( _SC_OPEN_MAX );
#elif defined( HAVE_GETDTABLESIZE )
tblsize = getdtablesize();
+#else
+ tblsize = FD_SETSIZE;
#endif /* !USE_SYSCONF */
#ifdef FD_SETSIZE
LDAPMessage *et_msg;
};
-static int (*et_cmp_fn) LDAP_P(( char *a, char *b ));
+static int (*et_cmp_fn) LDAP_P(( const char *a, const char *b ));
static int et_cmp LDAP_P(( const void *aa, const void *bb));
int
ldap_sort_strcasecmp(
- char **a,
- char **b
+ const void *a,
+ const void *b
)
{
- return( strcasecmp( *a, *b ) );
+ return( strcasecmp( *(char *const *)a, *(char *const *)b ) );
}
static int
LDAP *ld,
LDAPMessage **chain,
char *attr, /* NULL => sort by DN */
- int (*cmp) LDAP_P((const char *, const char *))
+ int (*cmp) (const char *, const char *)
)
{
int i, count;
ldap_sort_values(
LDAP *ld,
char **vals,
- int (*cmp) LDAP_P((const void *, const void *))
+ int (*cmp) (const void *, const void *)
)
{
int nel;
+#include "portable.h"
+
#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#ifdef MACOS
#include <stdlib.h>
-#ifdef THINK_C
-#include <console.h>
-#include <unix.h>
-#include <fcntl.h>
-#endif /* THINK_C */
-#include "macos.h"
-#else /* MACOS */
-#if defined( DOS ) || defined( _WIN32 )
-#include "msdos.h"
-#if defined( WINSOCK ) || defined( _WIN32 )
-#include "console.h"
-#endif /* WINSOCK */
-#else /* DOS */
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/time.h>
+
+#include <ac/ctype.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+#include <ac/unistd.h>
+
#include <sys/stat.h>
+
+#ifdef HAVE_SYS_FILE_H
#include <sys/file.h>
-#ifndef VMS
+#endif
+#ifdef HAVE_IO_H
+#include <io.h>
+#endif
+
#include <fcntl.h>
-#include <unistd.h>
-#endif /* VMS */
-#endif /* DOS */
-#endif /* MACOS */
#include "lber.h"
#include "ldap.h"
-#if !defined( PCNFS ) && !defined( WINSOCK ) && !defined( MACOS )
-#define MOD_USE_BVALS
-#endif /* !PCNFS && !WINSOCK && !MACOS */
+/* 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"
-#ifdef NEEDPROTOS
-static void handle_result( LDAP *ld, LDAPMessage *lm );
-static void print_ldap_result( LDAP *ld, LDAPMessage *lm, char *s );
-static void print_search_entry( LDAP *ld, LDAPMessage *res );
-static void free_list( char **list );
-#else
-static void handle_result();
-static void print_ldap_result();
-static void print_search_entry();
-static void free_list();
-#endif /* NEEDPROTOS */
+/* local functions */
+#ifndef HAVE_GETLINE
+static char *getline LDAP_P(( char *line, int len, FILE *fp, char *prompt ));
+#endif
+static char **get_list LDAP_P(( char *prompt ));
+static int file_read LDAP_P(( char *path, struct berval *bv ));
+static LDAPMod **get_modlist LDAP_P(( char *prompt1, char *prompt2, char *prompt3 ));
+static void handle_result LDAP_P(( LDAP *ld, LDAPMessage *lm ));
+static void print_ldap_result LDAP_P(( LDAP *ld, LDAPMessage *lm, char *s ));
+static void print_search_entry LDAP_P(( LDAP *ld, LDAPMessage *res ));
+static void free_list LDAP_P(( char **list ));
-#define NOCACHEERRMSG "don't compile with -DNO_CACHE if you desire local caching"
+#define NOCACHEERRMSG "don't compile with -DLDAP_NOCACHE if you desire local caching"
-char *dnsuffix;
+static char *dnsuffix;
-#ifndef WINSOCK
+#ifndef HAVE_GETLINE
static char *
getline( char *line, int len, FILE *fp, char *prompt )
{
return( line );
}
-#endif /* WINSOCK */
+#endif
static char **
get_list( char *prompt )
}
-#ifdef MOD_USE_BVALS
static int
file_read( char *path, struct berval *bv )
{
eof = feof( fp );
fclose( fp );
- if ( rlen != bv->bv_len ) {
+ if ( (unsigned long) rlen != bv->bv_len ) {
perror( path );
free( bv->bv_val );
return( -1 );
return( bv->bv_len );
}
-#endif /* MOD_USE_BVALS */
static LDAPMod **
int num;
LDAPMod tmp;
LDAPMod **result;
-#ifdef MOD_USE_BVALS
struct berval **bvals;
-#endif /* MOD_USE_BVALS */
num = 0;
result = NULL;
tmp.mod_type = strdup( buf );
tmp.mod_values = get_list( prompt3 );
-#ifdef MOD_USE_BVALS
+
if ( tmp.mod_values != NULL ) {
int i;
tmp.mod_bvalues = bvals;
tmp.mod_op |= LDAP_MOD_BVALUES;
}
-#endif /* MOD_USE_BVALS */
if ( result == NULL )
result = (LDAPMod **) malloc( sizeof(LDAPMod *) );
#ifdef LDAP_REFERRALS
-int
+static int
bind_prompt( LDAP *ld, char **dnp, char **passwdp, int *authmethodp,
int freeit )
{
static char dn[256], passwd[256];
if ( !freeit ) {
-#ifdef KERBEROS
+#ifdef HAVE_KERBEROS
getline( dn, sizeof(dn), stdin,
"re-bind method (0->simple, 1->krbv41, 2->krbv42, 3->krbv41&2)? " );
if (( *authmethodp = atoi( dn )) == 3 ) {
} else {
*authmethodp |= 0x80;
}
-#else /* KERBEROS */
+#else /* HAVE_KERBEROS */
*authmethodp = LDAP_AUTH_SIMPLE;
-#endif /* KERBEROS */
+#endif /* HAVE_KERBEROS */
getline( dn, sizeof(dn), stdin, "re-bind dn? " );
strcat( dn, dnsuffix );
int
-#ifdef WINSOCK
-ldapmain(
-#else /* WINSOCK */
-main(
-#endif /* WINSOCK */
- int argc, char **argv )
+main( int argc, char **argv )
{
- LDAP *ld;
+ LDAP *ld = NULL;
int i, c, port, cldapflg, errflg, method, id, msgtype;
char line[256], command1, command2, command3;
char passwd[64], dn[256], rdn[64], attr[64], value[256];
int copyoptions = 0;
LDAPURLDesc *ludp;
- extern char *optarg;
- extern int optind;
-
-#ifdef MACOS
- if (( argv = get_list( "cmd line arg?" )) == NULL ) {
- exit( 1 );
- }
- for ( argc = 0; argv[ argc ] != NULL; ++argc ) {
- ;
- }
-#endif /* MACOS */
-
host = NULL;
port = LDAP_PORT;
dnsuffix = "";
while (( c = getopt( argc, argv, "uh:d:s:p:t:T:" )) != -1 ) {
switch( c ) {
case 'u':
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
cldapflg++;
-#else /* CLDAP */
- printf( "Compile with -DCLDAP for UDP support\n" );
-#endif /* CLDAP */
+#else /* LDAP_CONNECTIONLESS */
+ printf( "Compile with -DLDAP_CONNECTIONLESS for UDP support\n" );
+#endif /* LDAP_CONNECTIONLESS */
break;
case 'd':
port = atoi( optarg );
break;
-#if !defined(MACOS) && !defined(DOS)
case 't': /* copy ber's to given file */
copyfname = strdup( optarg );
copyoptions = LBER_TO_FILE;
copyfname = strdup( optarg );
copyoptions = (LBER_TO_FILE | LBER_TO_FILE_ONLY);
break;
-#endif
default:
++errflg;
host == NULL ? "(null)" : host, port );
if ( cldapflg ) {
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
ld = cldap_open( host, port );
-#endif /* CLDAP */
+#endif /* LDAP_CONNECTIONLESS */
} else {
ld = ldap_open( host, port );
}
exit(1);
}
-#if !defined(MACOS) && !defined(DOS)
if ( copyfname != NULL ) {
if ( (ld->ld_sb.sb_fd = open( copyfname, O_WRONLY | O_CREAT,
0600 )) == -1 ) {
}
ld->ld_sb.sb_options = copyoptions;
}
-#endif
bound = 0;
timeout.tv_sec = 0;
break;
case 'b': /* asynch bind */
-#ifdef KERBEROS
+#ifdef HAVE_KERBEROS
getline( line, sizeof(line), stdin,
"method (0->simple, 1->krbv41, 2->krbv42)? " );
method = atoi( line ) | 0x80;
-#else /* KERBEROS */
+#else /* HAVE_KERBEROS */
method = LDAP_AUTH_SIMPLE;
-#endif /* KERBEROS */
+#endif /* HAVE_KERBEROS */
getline( dn, sizeof(dn), stdin, "dn? " );
strcat( dn, dnsuffix );
break;
case 'B': /* synch bind */
-#ifdef KERBEROS
+#ifdef HAVE_KERBEROS
getline( line, sizeof(line), stdin,
"method 0->simple 1->krbv41 2->krbv42 3->krb? " );
method = atoi( line );
method = LDAP_AUTH_KRBV4;
else
method = method | 0x80;
-#else /* KERBEROS */
+#else /* HAVE_KERBEROS */
method = LDAP_AUTH_SIMPLE;
-#endif /* KERBEROS */
+#endif /* HAVE_KERBEROS */
getline( dn, sizeof(dn), stdin, "dn? " );
strcat( dn, dnsuffix );
break;
case 'q': /* quit */
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
if ( cldapflg )
cldap_close( ld );
-#endif /* CLDAP */
+#endif /* LDAP_CONNECTIONLESS */
#ifdef LDAP_REFERRALS
if ( !cldapflg )
#else /* LDAP_REFERRALS */
attrsonly = atoi( line );
if ( cldapflg ) {
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
getline( line, sizeof(line), stdin,
"Requestor DN (for logging)? " );
if ( cldap_search_s( ld, dn, scope, filter, types,
handle_result( ld, res );
res = NULLMSG;
}
-#endif /* CLDAP */
+#endif /* LDAP_CONNECTIONLESS */
} else {
if (( id = ldap_search( ld, dn, scope, filter,
types, attrsonly )) == -1 ) {
break;
case 'e': /* enable cache */
-#ifdef NO_CACHE
+#ifdef LDAP_NOCACHE
printf( NOCACHEERRMSG );
-#else /* NO_CACHE */
+#else /* LDAP_NOCACHE */
getline( line, sizeof(line), stdin, "Cache timeout (secs)? " );
i = atoi( line );
getline( line, sizeof(line), stdin, "Maximum memory to use (bytes)? " );
} else {
printf( "ldap_enable_cache failed\n" );
}
-#endif /* NO_CACHE */
+#endif /* LDAP_NOCACHE */
break;
case 'x': /* uncache entry */
-#ifdef NO_CACHE
+#ifdef LDAP_NOCACHE
printf( NOCACHEERRMSG );
-#else /* NO_CACHE */
+#else /* LDAP_NOCACHE */
getline( line, sizeof(line), stdin, "DN? " );
ldap_uncache_entry( ld, line );
-#endif /* NO_CACHE */
+#endif /* LDAP_NOCACHE */
break;
case 'X': /* uncache request */
-#ifdef NO_CACHE
+#ifdef LDAP_NOCACHE
printf( NOCACHEERRMSG );
-#else /* NO_CACHE */
+#else /* LDAP_NOCACHE */
getline( line, sizeof(line), stdin, "request msgid? " );
ldap_uncache_request( ld, atoi( line ));
-#endif /* NO_CACHE */
+#endif /* LDAP_NOCACHE */
break;
case 'o': /* set ldap options */
break;
case 'O': /* set cache options */
-#ifdef NO_CACHE
+#ifdef LDAP_NOCACHE
printf( NOCACHEERRMSG );
-#else /* NO_CACHE */
+#else /* LDAP_NOCACHE */
getline( line, sizeof(line), stdin, "cache errors (0=smart, 1=never, 2=always)?" );
switch( atoi( line )) {
case 0:
default:
printf( "not a valid cache option\n" );
}
-#endif /* NO_CACHE */
+#endif /* LDAP_NOCACHE */
break;
case '?': /* help */
ufn = ldap_dn2ufn( dn );
printf( "\tUFN: %s\n", ufn );
-#ifdef WINSOCK
- ldap_memfree( dn );
- ldap_memfree( ufn );
-#else /* WINSOCK */
+
free( dn );
free( ufn );
-#endif /* WINSOCK */
for ( a = ldap_first_attribute( ld, e, &ber ); a != NULL;
a = ldap_next_attribute( ld, e, ber ) ) {
int j, nonascii;
nonascii = 0;
- for ( j = 0; j < vals[i]->bv_len; j++ )
+ for ( j = 0; (unsigned long) j < vals[i]->bv_len; j++ )
if ( !isascii( vals[i]->bv_val[j] ) ) {
nonascii = 1;
break;
|| res->lm_chain != NULLMSG )
print_ldap_result( ld, res, "search" );
}
-
-
-#ifdef WINSOCK
-void
-ldap_perror( LDAP *ld, char *s )
-{
- char *errs;
-
- if ( ld == NULL ) {
- perror( s );
- return;
- }
-
- errs = ldap_err2string( ld->ld_errno );
- printf( "%s: %s\n", s, errs == NULL ? "unknown error" : errs );
- if ( ld->ld_error != NULL && *ld->ld_error != '\0' ) {
- printf( "%s: additional info: %s\n", s, ld->ld_error );
- }
-}
-#endif /* WINSOCK */
#include <stdio.h>
#include <stdlib.h>
+#include <ac/ctype.h>
#include <ac/socket.h>
#include <ac/string.h>
-#include <ac/ctype.h>
#include <ac/time.h>
#ifdef HAVE_SYS_FILE_H
#include "ldapconfig.h"
+/* local functions */
static int do_entry2text LDAP_P((
LDAP *ld, char *buf, char *base, LDAPMessage *entry,
struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals,
-#include <stdio.h>
-#include <sys/types.h>
-#include "lber.h"
-#include "ldap.h"
-#include "disptmpl.h"
-#include "srchpref.h"
+#include "portable.h"
-#ifdef MACOS
+#include <stdio.h>
#include <stdlib.h>
+
+#include <ac/socket.h>
+#include <ac/time.h>
+
+#ifdef HAVE_CONSOLE_H
#include <console.h>
#endif /* MACOS */
-#ifdef NEEDPROTOS
-void dump_tmpl( struct ldap_disptmpl *tmpl );
-void dump_srchpref( struct ldap_searchobj *sp );
-#else /* NEEDPROTOS */
-void dump_tmpl();
-void dump_srchpref();
-#endif /* NEEDPROTOS */
+#include "lber.h"
+#include "ldap.h"
+#include "disptmpl.h"
+#include "srchpref.h"
+static void dump_tmpl ( struct ldap_disptmpl *tmpl );
+static void dump_srchpref( struct ldap_searchobj *sp );
#define NULLSTRINGIFNULL( s ) ( s == NULL ? "(null)" : s )
-
int
main( int argc, char **argv )
{
struct ldap_searchobj *so, *sop;
int err;
-#ifdef MACOS
+#ifdef HAVE_CONSOLE_H
ccommand( &argv );
for ( argc = 0; argv[ argc ] != NULL; ++argc ) {
;
typedef int (*cancelptype) LDAP_P(( void *cancelparm ));
+/* local functions */
static int ldap_ufn_search_ctx LDAP_P(( LDAP *ld, char **ufncomp, int ncomp,
char *prefix, char **attrs, int attrsonly, LDAPMessage **res,
cancelptype cancelproc, void *cancelparm, char *tag1, char *tag2,
LDAPFiltInfo *fi;
LDAPMessage *tmpcand;
LDAPMessage *candidates;
- LDAPMessage *ldap_msg_merge(), *ldap_ufn_expand();
static char *objattrs[] = { "objectClass", NULL };
/*
#include "ldap-int.h"
+/* local functions */
static int skip_url_prefix LDAP_P(( char **urlp, int *enclosedp ));
static void hex_unescape LDAP_P(( char *s ));
static int unhex( char c );
#include <stdio.h>
#include <stdlib.h>
+#include <ac/string.h>
#include <ac/errno.h>
#include "ldbm.h"
return( dup );
}
dup.dsize = data.dsize;
- if ( dup.dptr = (char *) malloc( data.dsize ) )
+ if ( (dup.dptr = (char *) malloc( data.dsize )) != NULL )
memcpy( dup.dptr, data.dptr, data.dsize );
return( dup );
/* stack.c - stack handling routines */
+#include "portable.h"
+
+#if defined( HAVE_LWP )
+
#include <stdio.h>
+
+#include <ac/time.h>
+#include <ac/socket.h>
+
#include "lber.h"
#include "ldap.h"
-#if defined( sunos4 )
-
#include <lwp/lwp.h>
#include <lwp/stackdep.h>
}
void
-pthread_yield()
+pthread_yield( void )
{
cthread_yield();
}
#endif /* ! sunos56 */
void
-pthread_yield()
+pthread_yield( void )
{
thr_yield();
}
* *
*************/
-extern stkalign_t *get_stack();
-static void lwp_create_stack();
-
int
pthread_attr_init( pthread_attr_t *attr )
{
return( 0 );
}
+static void
+lwp_create_stack( VFP func, void *arg, int stackno )
+{
+ (*func)( arg );
+
+ free_stack( stackno );
+}
+
/* ARGSUSED */
int
pthread_create(
arg, stackno ) );
}
-static void
-lwp_create_stack( VFP func, void *arg, int stackno )
-{
- (*func)( arg );
-
- free_stack( stackno );
-}
-
void
-pthread_yield()
+pthread_yield( void )
{
lwp_yield( SELF );
}
}
void
-pthread_yield()
+pthread_yield( void )
{
return;
}
--- /dev/null
+/*
+ * Modified by Kurt D. Zeilenga for inclusion into OpenLDAP
+ * I hereby disclaim copyright in any changes I have made; this
+ * code remains in the public domain.
+ */
+
+/*
+ * This code implements the MD5 message-digest algorithm.
+ * The algorithm is due to Ron Rivest. This code was
+ * written by Colin Plumb in 1993, no copyright is claimed.
+ * This code is in the public domain; do with it what you wish.
+ *
+ * Equivalent code is available from RSA Data Security, Inc.
+ * This code has been tested against that, and is equivalent,
+ * except that you don't need to include two pages of legalese
+ * with every copy.
+ *
+ * To compute the message digest of a chunk of bytes, declare an
+ * MD5Context structure, pass it to MD5Init, call MD5Update as
+ * needed on buffers full of bytes, and then call MD5Final, which
+ * will fill a supplied 16-byte array with the digest.
+ */
+
+/* This code was modified in 1997 by Jim Kingdon of Cyclic Software to
+ not require an integer type which is exactly 32 bits. This work
+ draws on the changes for the same purpose by Tatu Ylonen
+ <ylo@cs.hut.fi> as part of SSH, but since I didn't actually use
+ that code, there is no copyright issue. I hereby disclaim
+ copyright in any changes I have made; this code remains in the
+ public domain. */
+
+#include "portable.h"
+
+#include <ac/string.h>
+
+/* include socket.h to get sys/types.h and/or winsock2.h */
+#include <ac/socket.h>
+
+#include <lutil_md5.h>
+
+/* Little-endian byte-swapping routines. Note that these do not
+ depend on the size of datatypes such as uint32, nor do they require
+ us to detect the endianness of the machine we are running on. It
+ is possible they should be macros for speed, but I would be
+ surprised if they were a performance bottleneck for MD5. */
+
+static uint32
+getu32( const unsigned char *addr )
+{
+ return (((((unsigned long)addr[3] << 8) | addr[2]) << 8)
+ | addr[1]) << 8 | addr[0];
+}
+
+static void
+putu32( uint32 data, unsigned char *addr )
+{
+ addr[0] = (unsigned char)data;
+ addr[1] = (unsigned char)(data >> 8);
+ addr[2] = (unsigned char)(data >> 16);
+ addr[3] = (unsigned char)(data >> 24);
+}
+
+/*
+ * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
+ * initialization constants.
+ */
+void
+ldap_MD5Init( struct ldap_MD5Context *ctx )
+{
+ ctx->buf[0] = 0x67452301;
+ ctx->buf[1] = 0xefcdab89;
+ ctx->buf[2] = 0x98badcfe;
+ ctx->buf[3] = 0x10325476;
+
+ ctx->bits[0] = 0;
+ ctx->bits[1] = 0;
+}
+
+/*
+ * Update context to reflect the concatenation of another buffer full
+ * of bytes.
+ */
+void
+ldap_MD5Update(
+ struct ldap_MD5Context *ctx,
+ const unsigned char *buf,
+ unsigned int len
+)
+{
+ uint32 t;
+
+ /* Update bitcount */
+
+ t = ctx->bits[0];
+ if ((ctx->bits[0] = (t + ((uint32)len << 3)) & 0xffffffff) < t)
+ ctx->bits[1]++; /* Carry from low to high */
+ ctx->bits[1] += len >> 29;
+
+ t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
+
+ /* Handle any leading odd-sized chunks */
+
+ if ( t ) {
+ unsigned char *p = ctx->in + t;
+
+ t = 64-t;
+ if (len < t) {
+ memcpy(p, buf, len);
+ return;
+ }
+ memcpy(p, buf, t);
+ ldap_MD5Transform(ctx->buf, ctx->in);
+ buf += t;
+ len -= t;
+ }
+
+ /* Process data in 64-byte chunks */
+
+ while (len >= 64) {
+ memcpy(ctx->in, buf, 64);
+ ldap_MD5Transform(ctx->buf, ctx->in);
+ buf += 64;
+ len -= 64;
+ }
+
+ /* Handle any remaining bytes of data. */
+
+ memcpy(ctx->in, buf, len);
+}
+
+/*
+ * Final wrapup - pad to 64-byte boundary with the bit pattern
+ * 1 0* (64-bit count of bits processed, MSB-first)
+ */
+void
+ldap_MD5Final( unsigned char *digest, struct ldap_MD5Context *ctx )
+{
+ unsigned count;
+ unsigned char *p;
+
+ /* Compute number of bytes mod 64 */
+ count = (ctx->bits[0] >> 3) & 0x3F;
+
+ /* Set the first char of padding to 0x80. This is safe since there is
+ always at least one byte free */
+ p = ctx->in + count;
+ *p++ = 0x80;
+
+ /* Bytes of padding needed to make 64 bytes */
+ count = 64 - 1 - count;
+
+ /* Pad out to 56 mod 64 */
+ if (count < 8) {
+ /* Two lots of padding: Pad the first block to 64 bytes */
+ memset(p, 0, count);
+ ldap_MD5Transform(ctx->buf, ctx->in);
+
+ /* Now fill the next block with 56 bytes */
+ memset(ctx->in, 0, 56);
+ } else {
+ /* Pad block to 56 bytes */
+ memset(p, 0, count-8);
+ }
+
+ /* Append length in bits and transform */
+ putu32(ctx->bits[0], ctx->in + 56);
+ putu32(ctx->bits[1], ctx->in + 60);
+
+ ldap_MD5Transform(ctx->buf, ctx->in);
+ putu32(ctx->buf[0], digest);
+ putu32(ctx->buf[1], digest + 4);
+ putu32(ctx->buf[2], digest + 8);
+ putu32(ctx->buf[3], digest + 12);
+ memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
+}
+
+#ifndef ASM_MD5
+
+/* The four core functions - F1 is optimized somewhat */
+
+/* #define F1(x, y, z) (x & y | ~x & z) */
+#define F1(x, y, z) (z ^ (x & (y ^ z)))
+#define F2(x, y, z) F1(z, x, y)
+#define F3(x, y, z) (x ^ y ^ z)
+#define F4(x, y, z) (y ^ (x | ~z))
+
+/* This is the central step in the MD5 algorithm. */
+#define MD5STEP(f, w, x, y, z, data, s) \
+ ( w += f(x, y, z) + data, w &= 0xffffffff, w = w<<s | w>>(32-s), w += x )
+
+/*
+ * The core of the MD5 algorithm, this alters an existing MD5 hash to
+ * reflect the addition of 16 longwords of new data. MD5Update blocks
+ * the data and converts bytes into longwords for this routine.
+ */
+void
+ldap_MD5Transform( uint32 *buf, const unsigned char *inraw )
+{
+ register uint32 a, b, c, d;
+ uint32 in[16];
+ int i;
+
+ for (i = 0; i < 16; ++i)
+ in[i] = getu32 (inraw + 4 * i);
+
+ a = buf[0];
+ b = buf[1];
+ c = buf[2];
+ d = buf[3];
+
+ MD5STEP(F1, a, b, c, d, in[ 0]+0xd76aa478, 7);
+ MD5STEP(F1, d, a, b, c, in[ 1]+0xe8c7b756, 12);
+ MD5STEP(F1, c, d, a, b, in[ 2]+0x242070db, 17);
+ MD5STEP(F1, b, c, d, a, in[ 3]+0xc1bdceee, 22);
+ MD5STEP(F1, a, b, c, d, in[ 4]+0xf57c0faf, 7);
+ MD5STEP(F1, d, a, b, c, in[ 5]+0x4787c62a, 12);
+ MD5STEP(F1, c, d, a, b, in[ 6]+0xa8304613, 17);
+ MD5STEP(F1, b, c, d, a, in[ 7]+0xfd469501, 22);
+ MD5STEP(F1, a, b, c, d, in[ 8]+0x698098d8, 7);
+ MD5STEP(F1, d, a, b, c, in[ 9]+0x8b44f7af, 12);
+ MD5STEP(F1, c, d, a, b, in[10]+0xffff5bb1, 17);
+ MD5STEP(F1, b, c, d, a, in[11]+0x895cd7be, 22);
+ MD5STEP(F1, a, b, c, d, in[12]+0x6b901122, 7);
+ MD5STEP(F1, d, a, b, c, in[13]+0xfd987193, 12);
+ MD5STEP(F1, c, d, a, b, in[14]+0xa679438e, 17);
+ MD5STEP(F1, b, c, d, a, in[15]+0x49b40821, 22);
+
+ MD5STEP(F2, a, b, c, d, in[ 1]+0xf61e2562, 5);
+ MD5STEP(F2, d, a, b, c, in[ 6]+0xc040b340, 9);
+ MD5STEP(F2, c, d, a, b, in[11]+0x265e5a51, 14);
+ MD5STEP(F2, b, c, d, a, in[ 0]+0xe9b6c7aa, 20);
+ MD5STEP(F2, a, b, c, d, in[ 5]+0xd62f105d, 5);
+ MD5STEP(F2, d, a, b, c, in[10]+0x02441453, 9);
+ MD5STEP(F2, c, d, a, b, in[15]+0xd8a1e681, 14);
+ MD5STEP(F2, b, c, d, a, in[ 4]+0xe7d3fbc8, 20);
+ MD5STEP(F2, a, b, c, d, in[ 9]+0x21e1cde6, 5);
+ MD5STEP(F2, d, a, b, c, in[14]+0xc33707d6, 9);
+ MD5STEP(F2, c, d, a, b, in[ 3]+0xf4d50d87, 14);
+ MD5STEP(F2, b, c, d, a, in[ 8]+0x455a14ed, 20);
+ MD5STEP(F2, a, b, c, d, in[13]+0xa9e3e905, 5);
+ MD5STEP(F2, d, a, b, c, in[ 2]+0xfcefa3f8, 9);
+ MD5STEP(F2, c, d, a, b, in[ 7]+0x676f02d9, 14);
+ MD5STEP(F2, b, c, d, a, in[12]+0x8d2a4c8a, 20);
+
+ MD5STEP(F3, a, b, c, d, in[ 5]+0xfffa3942, 4);
+ MD5STEP(F3, d, a, b, c, in[ 8]+0x8771f681, 11);
+ MD5STEP(F3, c, d, a, b, in[11]+0x6d9d6122, 16);
+ MD5STEP(F3, b, c, d, a, in[14]+0xfde5380c, 23);
+ MD5STEP(F3, a, b, c, d, in[ 1]+0xa4beea44, 4);
+ MD5STEP(F3, d, a, b, c, in[ 4]+0x4bdecfa9, 11);
+ MD5STEP(F3, c, d, a, b, in[ 7]+0xf6bb4b60, 16);
+ MD5STEP(F3, b, c, d, a, in[10]+0xbebfbc70, 23);
+ MD5STEP(F3, a, b, c, d, in[13]+0x289b7ec6, 4);
+ MD5STEP(F3, d, a, b, c, in[ 0]+0xeaa127fa, 11);
+ MD5STEP(F3, c, d, a, b, in[ 3]+0xd4ef3085, 16);
+ MD5STEP(F3, b, c, d, a, in[ 6]+0x04881d05, 23);
+ MD5STEP(F3, a, b, c, d, in[ 9]+0xd9d4d039, 4);
+ MD5STEP(F3, d, a, b, c, in[12]+0xe6db99e5, 11);
+ MD5STEP(F3, c, d, a, b, in[15]+0x1fa27cf8, 16);
+ MD5STEP(F3, b, c, d, a, in[ 2]+0xc4ac5665, 23);
+
+ MD5STEP(F4, a, b, c, d, in[ 0]+0xf4292244, 6);
+ MD5STEP(F4, d, a, b, c, in[ 7]+0x432aff97, 10);
+ MD5STEP(F4, c, d, a, b, in[14]+0xab9423a7, 15);
+ MD5STEP(F4, b, c, d, a, in[ 5]+0xfc93a039, 21);
+ MD5STEP(F4, a, b, c, d, in[12]+0x655b59c3, 6);
+ MD5STEP(F4, d, a, b, c, in[ 3]+0x8f0ccc92, 10);
+ MD5STEP(F4, c, d, a, b, in[10]+0xffeff47d, 15);
+ MD5STEP(F4, b, c, d, a, in[ 1]+0x85845dd1, 21);
+ MD5STEP(F4, a, b, c, d, in[ 8]+0x6fa87e4f, 6);
+ MD5STEP(F4, d, a, b, c, in[15]+0xfe2ce6e0, 10);
+ MD5STEP(F4, c, d, a, b, in[ 6]+0xa3014314, 15);
+ MD5STEP(F4, b, c, d, a, in[13]+0x4e0811a1, 21);
+ MD5STEP(F4, a, b, c, d, in[ 4]+0xf7537e82, 6);
+ MD5STEP(F4, d, a, b, c, in[11]+0xbd3af235, 10);
+ MD5STEP(F4, c, d, a, b, in[ 2]+0x2ad7d2bb, 15);
+ MD5STEP(F4, b, c, d, a, in[ 9]+0xeb86d391, 21);
+
+ buf[0] += a;
+ buf[1] += b;
+ buf[2] += c;
+ buf[3] += d;
+}
+#endif
+
+#ifdef TEST
+/* Simple test program. Can use it to manually run the tests from
+ RFC1321 for example. */
+#include <stdio.h>
+
+int
+main (int argc, char **argv )
+{
+ struct ldap_MD5Context context;
+ unsigned char checksum[16];
+ int i;
+ int j;
+
+ if (argc < 2)
+ {
+ fprintf (stderr, "usage: %s string-to-hash\n", argv[0]);
+ exit (1);
+ }
+ for (j = 1; j < argc; ++j)
+ {
+ printf ("MD5 (\"%s\") = ", argv[j]);
+ ldap_MD5Init (&context);
+ ldap_MD5Update (&context, argv[j], strlen (argv[j]));
+ ldap_MD5Final (checksum, &context);
+ for (i = 0; i < 16; i++)
+ {
+ printf ("%02x", (unsigned int) checksum[i]);
+ }
+ printf ("\n");
+ }
+ return 0;
+}
+#endif /* TEST */
#ifndef HAVE_SETPROCTITLE
+#include <stdio.h>
#include <stdlib.h>
#include <ac/string.h>
--- /dev/null
+/* Acquired from:
+ * $OpenBSD: sha1.c,v 1.9 1997/07/23 21:12:32 kstailey Exp $ */
+
+/*
+ * SHA-1 in C
+ * By Steve Reid <steve@edmweb.com>
+ * 100% Public Domain
+ *
+ * Test Vectors (from FIPS PUB 180-1)
+ * "abc"
+ * A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
+ * "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+ * 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
+ * A million repetitions of "a"
+ * 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
+ */
+
+
+#include "portable.h"
+#include <ac/string.h>
+
+/* include socket.h to get sys/types.h and/or winsock2.h */
+#include <ac/socket.h>
+
+#if defined(HAVE_SYS_PARAM_H)
+#include <sys/param.h>
+#endif
+
+#include "lutil_sha1.h"
+
+#define SHA1HANDSOFF /* Copies data before messing with it. */
+#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
+
+/*
+ * blk0() and blk() perform the initial expand.
+ * I got the idea of expanding during the round function from SSLeay
+ */
+#if BYTE_ORDER == LITTLE_ENDIAN
+# define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
+ |(rol(block->l[i],8)&0x00FF00FF))
+#else
+# define blk0(i) block->l[i]
+#endif
+#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
+ ^block->l[(i+2)&15]^block->l[i&15],1))
+
+/*
+ * (R0+R1), R2, R3, R4 are the different operations (rounds) used in SHA1
+ */
+#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
+#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
+#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
+#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
+#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
+
+
+/*
+ * Hash a single 512-bit block. This is the core of the algorithm.
+ */
+void
+ldap_SHA1Transform( uint32 *state, const unsigned char *buffer )
+{
+ uint32 a, b, c, d, e;
+ typedef union {
+ unsigned char c[64];
+ u_int l[16];
+ } CHAR64LONG16;
+ CHAR64LONG16 *block;
+
+#ifdef SHA1HANDSOFF
+ CHAR64LONG16 workspace;
+ block = &workspace;
+ (void)memcpy(block, buffer, 64);
+#else
+ block = (CHAR64LONG16 *)buffer;
+#endif
+
+ /* Copy context->state[] to working vars */
+ a = state[0];
+ b = state[1];
+ c = state[2];
+ d = state[3];
+ e = state[4];
+
+ /* 4 rounds of 20 operations each. Loop unrolled. */
+ R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
+ R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
+ R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
+ R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
+ R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
+ R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
+ R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
+ R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
+ R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
+ R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
+ R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
+ R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
+ R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
+ R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
+ R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
+ R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
+ R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
+ R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
+ R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
+ R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
+
+ /* Add the working vars back into context.state[] */
+ state[0] += a;
+ state[1] += b;
+ state[2] += c;
+ state[3] += d;
+ state[4] += e;
+
+ /* Wipe variables */
+ a = b = c = d = e = 0;
+}
+
+
+/*
+ * ldap_SHA1Init - Initialize new context
+ */
+void
+ldap_SHA1Init( ldap_SHA1_CTX *context )
+{
+
+ /* SHA1 initialization constants */
+ context->state[0] = 0x67452301;
+ context->state[1] = 0xEFCDAB89;
+ context->state[2] = 0x98BADCFE;
+ context->state[3] = 0x10325476;
+ context->state[4] = 0xC3D2E1F0;
+ context->count[0] = context->count[1] = 0;
+}
+
+
+/*
+ * Run your data through this.
+ */
+void
+ldap_SHA1Update(
+ ldap_SHA1_CTX *context,
+ const unsigned char *data,
+ u_int len
+)
+{
+ u_int i, j;
+
+ j = context->count[0];
+ if ((context->count[0] += len << 3) < j)
+ context->count[1] += (len>>29)+1;
+ j = (j >> 3) & 63;
+ if ((j + len) > 63) {
+ (void)memcpy(&context->buffer[j], data, (i = 64-j));
+ ldap_SHA1Transform(context->state, context->buffer);
+ for ( ; i + 63 < len; i += 64)
+ ldap_SHA1Transform(context->state, &data[i]);
+ j = 0;
+ } else {
+ i = 0;
+ }
+ (void)memcpy(&context->buffer[j], &data[i], len - i);
+}
+
+
+/*
+ * Add padding and return the message digest.
+ */
+void
+ldap_SHA1Final( unsigned char *digest, ldap_SHA1_CTX *context )
+{
+ u_int i;
+ unsigned char finalcount[8];
+
+ for (i = 0; i < 8; i++) {
+ finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)]
+ >> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */
+ }
+ ldap_SHA1Update(context, (unsigned char *)"\200", 1);
+ while ((context->count[0] & 504) != 448)
+ ldap_SHA1Update(context, (unsigned char *)"\0", 1);
+ ldap_SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */
+
+ if (digest) {
+ for (i = 0; i < 20; i++)
+ digest[i] = (unsigned char)
+ ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
+ }
+}
+
+
+/* sha1hl.c
+ * ----------------------------------------------------------------------------
+ * "THE BEER-WARE LICENSE" (Revision 42):
+ * <phk@login.dkuug.dk> wrote this file. As long as you retain this notice you
+ * can do whatever you want with this stuff. If we meet some day, and you think
+ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
+ * ----------------------------------------------------------------------------
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char rcsid[] = "$OpenBSD: sha1hl.c,v 1.1 1997/07/12 20:06:03 millert Exp $";
+#endif /* LIBC_SCCS and not lint */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <ac/errno.h>
+#include <ac/unistd.h>
+
+#ifdef HAVE_SYS_FILE_H
+#include <sys/file.h>
+#endif
+#ifdef HAVE_SYS_UIO_H
+#include <sys/uio.h>
+#endif
+
+#ifdef HAVE_IO_H
+#include <io.h>
+#endif
+
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+
+
+/* ARGSUSED */
+char *
+ldap_SHA1End( ldap_SHA1_CTX *ctx, char *buf )
+{
+ int i;
+ char *p = buf;
+ unsigned char digest[20];
+ static const char hex[]="0123456789abcdef";
+
+ if (p == NULL && (p = malloc(41)) == NULL)
+ return 0;
+
+ ldap_SHA1Final(digest,ctx);
+ for (i = 0; i < 20; i++) {
+ p[i + i] = hex[digest[i] >> 4];
+ p[i + i + 1] = hex[digest[i] & 0x0f];
+ }
+ p[i + i] = '\0';
+ return(p);
+}
+
+char *
+ldap_SHA1File( char *filename, char *buf )
+{
+ unsigned char buffer[BUFSIZ];
+ ldap_SHA1_CTX ctx;
+ int fd, num, oerrno;
+
+ ldap_SHA1Init(&ctx);
+
+ if ((fd = open(filename,O_RDONLY)) < 0)
+ return(0);
+
+ while ((num = read(fd, buffer, sizeof(buffer))) > 0)
+ ldap_SHA1Update(&ctx, buffer, num);
+
+ oerrno = errno;
+ close(fd);
+ errno = oerrno;
+ return(num < 0 ? 0 : ldap_SHA1End(&ctx, buf));
+}
+
+char *
+ldap_SHA1Data( const unsigned char *data, size_t len, char *buf )
+{
+ ldap_SHA1_CTX ctx;
+
+ ldap_SHA1Init(&ctx);
+ ldap_SHA1Update(&ctx, data, len);
+ return(ldap_SHA1End(&ctx, buf));
+}
--- /dev/null
+#include "portable.h"
+
+#ifndef HAVE_STRDUP
+
+#include <stdlib.h>
+#include <ac/string.h>
+#include "lutil.h"
+
+char *strdup( const char *s )
+{
+ char *p;
+
+ if ( (p = (char *) malloc( strlen( s ) + 1 )) == NULL )
+ return( (char *)0 );
+
+ strcpy( p, s );
+
+ return( p );
+}
+
+#endif /* !strdup */
--- /dev/null
+#include "portable.h"
+
+#ifndef HAVE_TEMPNAM
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <ac/string.h>
+#include <ac/unistd.h>
+
+#include "lutil.h"
+
+char *
+tempnam( const char *dir, const char *pfx )
+{
+ char *s;
+
+ if ( dir == NULL ) {
+ dir = "/tmp";
+ }
+
+/*
+ * allocate space for dir + '/' + pfx (up to 5 chars) + 6 trailing 'X's + 0 byte
+ */
+ if (( s = (char *)malloc( strlen( dir ) + 14 )) == NULL ) {
+ return( NULL );
+ }
+
+ strcpy( s, dir );
+ strcat( s, "/" );
+ if ( pfx != NULL ) {
+ strcat( s, pfx );
+ }
+ strcat( s, "XXXXXX" );
+ mktemp( s );
+
+ if ( *s == '\0' ) {
+ free( s );
+ s = NULL;
+ }
+
+ return( s );
+}
+
+#endif /* TEMPNAM */
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#include <stdio.h>
+
+#include <ac/socket.h>
+
#include <quipu/commonarg.h>
#include <quipu/attrvalue.h>
#include <quipu/ds_error.h>
#include <quipu/add.h>
#include <quipu/dap2.h>
#include <quipu/dua.h>
-#include <sys/types.h>
-#include <sys/socket.h>
#include "lber.h"
#include "ldap.h"
#include "common.h"
-#ifdef COMPAT20
-extern int ldap_compat;
+#ifdef LDAP_COMPAT20
#define ADDTAG (ldap_compat == 20 ? OLD_LDAP_RES_ADD : LDAP_RES_ADD)
#else
#define ADDTAG LDAP_RES_ADD
unsigned long tag, len;
struct ds_addentry_arg aa;
static CommonArgs common = default_common_args;
- extern DN ldap_str2dn();
Debug( LDAP_DEBUG_TRACE, "do_add\n", 0, 0, 0 );
aa.ada_entry = NULLATTR;
for ( tag = ber_first_element( ber, &len, &last ); tag != LBER_DEFAULT;
tag = ber_next_element( ber, &len, last ) ) {
- Attr_Sequence as, get_as();
+ Attr_Sequence as;
if ( ber_scanf( ber, "{a{V}}", &type, &bvals ) == LBER_ERROR )
break;
#include <quipu/commonarg.h>
#include <quipu/ds_error.h>
-#include "lber.h"
-#include "ldap.h"
-
+#include <quipu/dap.h> /* get dap_unbind() */
#if ISODEPACKAGE == IC
#include <ll/isoaddrs.h>
#else
#include <isoaddrs.h>
#endif
+
+#include "lber.h"
+#include "ldap.h"
#include "common.h"
#ifdef HAVE_SYS_IOCTL_H
struct conn *conns;
-struct conn *conn_dup( struct conn *cn )
+struct conn *
+conn_dup( struct conn *cn )
{
struct conn *new;
- struct PSAPaddr *psap_cpy();
-
if ( (new = (struct conn *) malloc( sizeof(struct conn) )) == NULL )
return( NULL );
}
int
-conn_init()
+conn_init( void )
{
- extern char *dsa_address;
- struct PSAPaddr *addr, *psap_cpy();
+ struct PSAPaddr *addr;
if ( (conns = (struct conn *) malloc( sizeof(struct conn) )) == NULL ) {
Debug( LDAP_DEBUG_ANY, "conn_init: malloc failed\n", 0, 0, 0 );
conn_free( struct conn *conn )
{
struct timeval tv;
- extern int referral_connection_timeout;
Debug( LDAP_DEBUG_TRACE, "conn_free (%s): refcnt is %d\n",
paddr2str( conn->c_paddr, NULLNA ), conn->c_refcnt, 0 );
}
void
-conn_badfds()
+conn_badfds( void )
{
struct conn *tmp;
}
}
-struct conn *conn_getfd( fd_set *fds )
+struct conn *
+conn_getfd( fd_set *fds )
{
struct conn *tmp;
return( bcmp( (char *) a, (char *) b, sizeof(struct PSAPaddr) ) );
}
-struct conn *conn_find( struct conn *c )
+struct conn *
+conn_find( struct conn *c )
{
struct conn *tmp;
}
void
-conn_close()
+conn_close( void )
{
struct conn *tmp;
isclosed( int ad )
{
int o;
- extern int errno;
if ( ioctl( ad, FIOGETOWN, &o ) < 0 )
return( errno == EBADF ? 1 : 0 );
#include "common.h"
#ifdef LDAP_COMPAT20
-extern int ldap_compat;
#define BINDTAG (ldap_compat == 20 ? OLD_LDAP_RES_BIND : LDAP_RES_BIND)
#else
#define BINDTAG LDAP_RES_BIND
unsigned long len;
char *dn, *pw;
char *matched;
- struct PSAPaddr *addr, *psap_cpy();
- extern char *dsa_address;
- extern int version;
+ struct PSAPaddr *addr;
Debug( LDAP_DEBUG_TRACE, "do_bind\n", 0, 0, 0 );
return( 0 );
}
- Debug( LDAP_DEBUG_ARGS, "do_bind: version %d dn (%s) method %d\n",
+ Debug( LDAP_DEBUG_ARGS, "do_bind: version %d dn (%s) method %lu\n",
version, dn, method );
if ( m->m_conn->c_paddr == NULLPA ) {
#ifdef HAVE_KERBEROS
u_long nonce;
#endif
- extern DN ldap_str2dn();
-
Debug( LDAP_DEBUG_TRACE, "do_bind_real\n", 0, 0, 0 );
*matched = NULL;
#include <quipu/ds_search.h>
#include <quipu/dap2.h>
#include <quipu/dua.h>
+extern sntx_table *get_syntax_table( short int sntx );
+extern PE asn2pe( char * );
#include "lber.h"
#include "ldap.h"
#include "common.h"
-int ldap_certif_print( PS ps, struct certificate *parm, int format )
+int
+ldap_certif_print( PS ps, struct certificate *parm, int format )
{
Debug( LDAP_DEBUG_TRACE, "ldap_certif_print()\n", 0, 0, 0 );
}
}
-struct certificate *ldap_str2cert( char *str )
+struct certificate *
+ldap_str2cert( char *str )
{
struct certificate *result;
char *ptr;
void
ldap_str2alg( char *str, struct alg_id *alg )
{
-PE asn2pe();
-
if ((str == NULLCP) || (*str == '\0'))
{
alg->asn = NULLPE;
}
}
-void certif_init()
+void
+certif_init( void )
{
- extern short ldap_certif_syntax;
sntx_table *syntax_table;
- extern sntx_table *get_syntax_table( short int sntx );
if ((syntax_table = get_syntax_table(ldap_certif_syntax)) != NULL) {
syntax_table->s_print = (void *) ldap_certif_print;
* is provided ``as is'' without express or implied warranty.
*/
+#ifndef _LDAPD_COMMON_H
+#define _LDAPD_COMMON_H 1
+
/*
* This structure represents an association to a dsa. There is one of
* these for each association open (a new association is made for each
LDAPMod *m_mods; /* for modify operations only */
BerElement *m_ber; /* the unparsed ber for the op */
struct conn *m_conn; /* connection structure */
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
int m_cldap; /* connectionless transport? (CLDAP) */
struct sockaddr m_clientaddr; /* client address (if using CLDAP) */
DN m_searchbase; /* base used in search */
-#endif /* CLDAP */
+#endif /* LDAP_CONNECTIONLESS */
struct msg *m_next;
};
#define DEFAULT_TIMEOUT 3600 /* idle client connections */
#define DEFAULT_REFERRAL_TIMEOUT 900 /* DSA connections */
-#ifdef NEEDPROTOS
#include "proto-ldapd.h"
-#else
-extern struct msg *add_msg();
-extern struct msg *get_msg();
-extern struct msg *get_cldap_msg();
-extern int del_msg();
-extern struct conn *conn_getfd();
-extern struct conn *conn_find();
-extern struct conn *conn_dup();
-extern void conn_del();
+/* from ISODE */
+extern char *dsa_address;
+extern char *bound_dn, *bound_pw;
+struct PSAPaddr *psap_cpy(struct PSAPaddr *);
+
+/* in association.c */
+extern struct conn *conns;
+
+/* in main.c */
+#ifdef LDAP_DEBUG
+extern int ldap_debug;
+#endif
+extern int version;
+#ifdef LDAP_COMPAT
+extern int ldap_compat;
+#endif
+extern int dosyslog;
+extern int do_tcp;
+#ifdef LDAP_CONNECTIONLESS
+extern int do_udp;
+#endif
+extern int idletime;
+extern int referral_connection_timeout;
+extern struct timeval conn_start_tv;
+#ifdef HAVE_KERBEROS
+extern char *krb_ldap_service;
+extern char *krb_x500_service;
+extern char *krb_x500_instance;
+extern char *krb_x500_nonce;
+extern char *kerberos_keyfile;
+#endif
+
+/* syntax.c */
+extern short ldap_photo_syntax;
+extern short ldap_jpeg_syntax;
+extern short ldap_jpeg_nonfile_syntax;
+extern short ldap_audio_syntax;
+extern short ldap_dn_syntax;
+extern short ldap_postaladdress_syntax;
+extern short ldap_acl_syntax;
+extern short ldap_mtai_syntax;
+extern short ldap_rts_cred_syntax;
+extern short ldap_rtl_syntax;
+extern short ldap_mailbox_syntax;
+extern short ldap_caseignorelist_syntax;
+extern short ldap_caseexactstring_syntax;
+extern short ldap_certif_syntax;
+extern short ldap_iattr_syntax;
+extern short ldap_telex_syntax;
+extern short ldap_octetstring_syntax;
+extern short ldap_deliverymethod_syntax;
+extern short ldap_facsimileTelephoneNumber_syntax;
+extern short ldap_presentationAddress_syntax;
+extern short ldap_teletexTerminalIdentifier_syntax;
+extern short ldap_searchGuide_syntax;
+extern short ldap_dLSubmitPermission_syntax;
+
+/* Version.c */
+extern char Versionstr[];
-extern AttributeValue ldap_str2AttrV();
-extern DN ldap_str2dn();
-extern void ldap_str2alg();
-extern void ldap_print_algid();
-#endif /* don't need protos */
+#endif
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#include <stdio.h>
+
+#include <ac/socket.h>
+
#include <quipu/commonarg.h>
#include <quipu/attrvalue.h>
#include <quipu/ds_error.h>
#include <quipu/compare.h>
#include <quipu/dap2.h>
#include <quipu/dua.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
#include "lber.h"
#include "ldap.h"
#include "common.h"
-#ifdef COMPAT20
-extern int ldap_compat;
+#ifdef HAVE_COMPAT20
#define COMPTAG (ldap_compat == 20 ? OLD_LDAP_RES_COMPARE : LDAP_RES_COMPARE)
#else
#define COMPTAG LDAP_RES_COMPARE
struct ds_compare_arg ca;
AttributeType type;
static CommonArgs common = default_common_args;
- extern short ldap_dn_syntax;
Debug( LDAP_DEBUG_TRACE, "do_compare\n", 0, 0, 0 );
#include "common.h"
#ifdef HAVE_COMPAT20
-extern int ldap_compat;
#define DELTAG (ldap_compat == 20 ? OLD_LDAP_RES_DELETE : LDAP_RES_DELETE)
#else
#define DELTAG LDAP_RES_DELETE
int rc;
struct ds_removeentry_arg ra;
static CommonArgs common = default_common_args;
- extern DN ldap_str2dn();
Debug( LDAP_DEBUG_TRACE, "do_delete\n", 0, 0, 0 );
+++ /dev/null
-/*
- * Copyright (c) 1990, 1994 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-#include <stdio.h>
-#include <sys/types.h>
-#ifdef SVR4
-#include <sys/stat.h>
-#endif /* svr4 */
-#include <fcntl.h>
-#include <sys/file.h>
-#include <sys/ioctl.h>
-#include <signal.h>
-#include "portable.h"
-
-#ifdef USE_SYSCONF
-#include <unistd.h>
-#endif /* USE_SYSCONF */
-
-
-detach()
-{
- int i, sd, nbits;
-#ifdef LDAP_DEBUG
- extern int ldap_debug;
-#endif
-
-#ifdef USE_SYSCONF
- nbits = sysconf( _SC_OPEN_MAX );
-#else /* USE_SYSCONF */
- nbits = getdtablesize();
-#endif /* USE_SYSCONF */
-
-#ifdef LDAP_DEBUG
- if ( ldap_debug == 0 ) {
-#endif
- for ( i = 0; i < 5; i++ ) {
- switch ( fork() ) {
- case -1:
- sleep( 5 );
- continue;
-
- case 0:
- break;
-
- default:
- _exit( 0 );
- }
- break;
- }
-
- for ( i = 3; i < nbits; i++ )
- close( i );
-
- (void) chdir( "/" );
-
- if ( (sd = open( "/dev/null", O_RDWR )) == -1 ) {
- perror( "/dev/null" );
- exit( 1 );
- }
- if ( isatty( 0 ) )
- (void) dup2( sd, 0 );
- if ( isatty( 1 ) )
- (void) dup2( sd, 1 );
- if ( isatty(2) )
- (void) dup2( sd, 2 );
- close( sd );
-
-#ifdef USE_SETSID
- setsid();
-#else /* USE_SETSID */
- if ( (sd = open( "/dev/tty", O_RDWR )) != -1 ) {
- (void) ioctl( sd, TIOCNOTTY, NULL );
- (void) close( sd );
- }
-#endif /* USE_SETSID */
-#ifdef LDAP_DEBUG
- }
-#endif
-
- (void) signal( SIGPIPE, SIG_IGN );
-}
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#include <stdio.h>
+
+#include <ac/ctype.h>
+#include <ac/socket.h>
+
#include <quipu/ds_error.h>
#include <quipu/attrvalue.h>
#include <quipu/name.h>
#include <quipu/commonarg.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <ctype.h>
+
#include "lber.h"
#include "ldap.h"
+#include "common.h" /* get ldap_dn_print() */
+
void
print_error( struct DSError *e )
{
* is provided ``as is'' without express or implied warranty.
*/
-#ifdef KERBEROS
+#include "portable.h"
+
+#ifdef HAVE_KERBEROS
#include <stdio.h>
-#include <sys/types.h>
-#include "krb.h"
-#include <sys/socket.h>
-#include <netdb.h>
-#include <netinet/in.h>
+
+#include <ac/krb.h>
+#include <ac/socket.h>
+
#include <quipu/bind.h>
#if ISODEPACKAGE == IC
#include <quipu/DAS-types.h>
#else
#include <pepsy/DAS-types.h>
#endif
+
#include "lber.h"
#include "ldap.h"
#include "common.h"
char instance[INST_SZ];
int err;
AUTH_DAT ad;
- extern char *krb_ldap_service;
- extern char *kerberos_keyfile;
Debug( LDAP_DEBUG_TRACE, "kerberosv4_ldap_auth\n", 0, 0, 0 );
struct timeval tv;
char realm[REALM_SZ];
int err;
- extern char *krb_x500_service;
- extern char *krb_x500_instance;
Debug( LDAP_DEBUG_TRACE, "kerberosv4_bindarg\n", 0, 0, 0 );
int deny_severity = LOG_NOTICE;
#endif /* TCP_WRAPPERS */
-void log_and_exit();
-static int set_socket();
-static void do_queries();
-static RETSIGTYPE wait4child();
+static int set_socket( int port, int udp );
+static void do_queries( int clientsock, int udp );
+static RETSIGTYPE wait4child( int sig );
#ifdef LDAP_CONNECTIONLESS
-static int udp_init();
+static int udp_init( int port, int createsocket );
#endif
#ifdef LDAP_DEBUG
int dtblsize;
int RunFromInetd = 0;
-extern char Versionstr[];
-
static void
usage( char *name )
{
}
int
-main (argc, argv)
-int argc;
-char **argv;
+main( int argc, char **argv )
{
int tcps, ns;
#ifdef LDAP_CONNECTIONLESS
int len;
int dsapargc;
char **dsapargv;
- RETSIGTYPE wait4child();
#ifdef LDAP_PROCTITLE
char title[80];
#endif
- extern char *optarg;
- extern int optind;
#ifdef VMS
/* Pick up socket from inetd-type server on VMS */
lutil_detach( 0, 1 );
# endif
#endif
- (void) SIGNAL( SIGCHLD, (void *) wait4child );
- (void) SIGNAL( SIGINT, (void *) log_and_exit );
+ (void) SIGNAL( SIGCHLD, wait4child );
+ (void) SIGNAL( SIGINT, log_and_exit );
}
/*
hp->h_name );
#endif
gettimeofday( &conn_start_tv, (struct timezone *) NULL );
- (void) SIGNAL( SIGPIPE, (void *) log_and_exit );
+ (void) SIGNAL( SIGPIPE, log_and_exit );
do_queries( ns, 0 );
/* NOT REACHED */
setproctitle( title );
#endif
gettimeofday( &conn_start_tv, (struct timezone *) NULL );
- (void) SIGNAL( SIGPIPE, (void *) log_and_exit );
+ (void) SIGNAL( SIGPIPE, log_and_exit );
do_queries( ns, 0 );
break;
timeout.tv_usec = 0;
for ( ;; ) {
struct conn *dsaconn;
- extern struct conn *conns;
FD_ZERO( &readfds );
FD_SET( clientsock, &readfds );
return( s );
}
-static RETSIGTYPE wait4child()
+static RETSIGTYPE
+wait4child( int sig )
{
#ifndef HAVE_WAITPID
WAITSTATUSTYPE status;
; /* NULL */
#endif
- (void) SIGNAL( SIGCHLD, (void *) wait4child );
+ (void) SIGNAL( SIGCHLD, wait4child );
}
-void
+RETSIGTYPE
log_and_exit( int exitcode )
{
struct timeval tv;
{
int s, bound;
char *matched;
- extern char *dsa_address;
- extern struct PSAPaddr *psap_cpy();
- extern struct conn *conns;
if ( createsocket )
s = set_socket( port, 1 );
#include <quipu/modify.h>
#include <quipu/dap2.h>
#include <quipu/dua.h>
+extern IFP merge_acl;
#include "lber.h"
#include "ldap.h"
static CommonArgs common = default_common_args;
-extern short ldap_photo_syntax;
-extern short ldap_jpeg_syntax;
-extern short ldap_jpeg_nonfile_syntax;
-extern short ldap_audio_syntax;
-extern short ldap_dn_syntax;
-extern short ldap_postaladdress_syntax;
-extern short ldap_acl_syntax;
-extern short ldap_mtai_syntax;
-extern short ldap_rts_cred_syntax;
-extern short ldap_rtl_syntax;
-extern short ldap_octetstring_syntax;
-
static int replace_mod( struct entrymod *, Attr_Sequence, Attr_Sequence );
#ifdef LDAP_COMPAT20
-extern int ldap_compat;
#define MODTAG (ldap_compat == 20 ? OLD_LDAP_RES_MODIFY : LDAP_RES_MODIFY)
#else
#define MODTAG LDAP_RES_MODIFY
unsigned long tag, len;
LDAPMod *mods, *modtail;
struct ds_read_arg ra;
- extern DN ldap_str2dn();
Debug( LDAP_DEBUG_TRACE, "do_modify\n", 0, 0, 0 );
ma.mea_changes = NULLMOD;
for ( mods = m->m_mods; mods != NULL; mods = mods->mod_next ) {
struct entrymod *em;
- Attr_Sequence as, new, get_as();
+ Attr_Sequence as, new;
if ( (em = (struct entrymod *) calloc( 1,
sizeof(struct entrymod) )) == NULLMOD ) {
AttributeValue av;
int t61str, ncomp;
char *sval, *s, *news, *n;
- extern IFP merge_acl;
- extern AttributeValue bv_asn2AttrV(), ldap_strdn2AttrV();
- extern AttributeValue ldap_str_at2AttrV(), bv_octet2AttrV();
if ( syntax == ldap_jpeg_syntax ||
syntax == ldap_jpeg_nonfile_syntax ||
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#include <stdio.h>
+
+#include <ac/socket.h>
+
#include <quipu/commonarg.h>
#include <quipu/attrvalue.h>
#include <quipu/ds_error.h>
#include <quipu/modifyrdn.h>
#include <quipu/dap2.h>
#include <quipu/dua.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
#include "lber.h"
#include "ldap.h"
#include "common.h"
-#ifdef COMPAT20
-extern int ldap_compat;
+#ifdef LDAP_COMPAT20
#define MODRDNTAG (ldap_compat == 20 ? OLD_LDAP_RES_MODRDN : LDAP_RES_MODRDN)
#else
#define MODRDNTAG LDAP_RES_MODRDN
int rc, deleteoldrdn;
struct ds_modifyrdn_arg ma;
static CommonArgs common = default_common_args;
- extern DN ldap_str2dn();
- extern RDN ldap_str2rdn();
Debug( LDAP_DEBUG_TRACE, "do_modrdn\n", 0, 0, 0 );
-#ifndef _PROTO_LDAPD
-#define _PROTO_LDAPD
+#ifndef _PROTO_LDAPD_H
+#define _PROTO_LDAPD_H
+
+#include <ldap_cdefs.h>
/*
* abandon.c
*/
-int do_abandon( struct conn *dsaconn, BerElement *ber, int msgid );
+int do_abandon LDAP_P(( struct conn *dsaconn, BerElement *ber, int msgid ));
/*
* add.c
*/
-int do_add( Sockbuf *clientsb, struct msg *m, BerElement *ber );
+int do_add LDAP_P(( Sockbuf *clientsb, struct msg *m, BerElement *ber ));
+void add_result LDAP_P(( Sockbuf *sb, struct msg *m ));
/*
* association.c
*/
-struct conn *conn_dup( struct conn *cn );
-int conn_init();
-void conn_free( struct conn *conn );
-void conn_del( struct conn *conn );
-void conn_badfds();
-struct conn *conn_getfd( fd_set *fds );
-void conn_add( struct conn *new );
-struct conn *conn_find( struct conn *c );
-void conn_add( struct conn *new );
-void conn_close();
-int isclosed( int ad );
+struct conn *conn_dup LDAP_P(( struct conn *cn ));
+int conn_init LDAP_P(( void ));
+void conn_free LDAP_P(( struct conn *conn ));
+void conn_del LDAP_P(( struct conn *conn ));
+void conn_setfds LDAP_P(( fd_set *fds ));
+void conn_badfds LDAP_P(( void ));
+struct conn *conn_getfd LDAP_P(( fd_set *fds ));
+void conn_add LDAP_P(( struct conn *new ));
+struct conn *conn_find LDAP_P(( struct conn *c ));
+void conn_close LDAP_P(( void ));
+int isclosed LDAP_P(( int ad ));
/*
* bind.c
*/
-int do_bind( Sockbuf *clientsb, struct msg *m, BerElement *ber, int *bound );
-int do_bind_real( struct conn *dsaconn, int *bound, char **matched );
+int do_bind LDAP_P(( Sockbuf *clientsb, struct msg *m, BerElement *ber, int *bound ));
+int do_bind_real LDAP_P(( struct conn *dsaconn, int *bound, char **matched ));
/*
* certificate.c
*/
-int ldap_certif_print( PS ps, struct certificate *parm, int format );
-void ldap_print_algid( PS ps, struct alg_id *parm, int format );
-struct certificate *ldap_str2cert( char *str );
-void ldap_str2alg( char *str, struct alg_id *alg );
-void certif_init();
+int ldap_certif_print LDAP_P(( PS ps, struct certificate *parm, int format ));
+void ldap_print_algid LDAP_P(( PS ps, struct alg_id *parm, int format ));
+struct certificate *ldap_str2cert LDAP_P(( char *str ));
+void ldap_str2alg LDAP_P(( char *str, struct alg_id *alg ));
+void certif_init LDAP_P(( void ));
/*
* compare.c
*/
-int do_compare( Sockbuf *clientsb, struct msg *m, BerElement *ber );
+struct ds_compare_result;
+int do_compare LDAP_P(( Sockbuf *clientsb, struct msg *m, BerElement *ber ));
+void compare_result LDAP_P(( Sockbuf *sb, struct msg *m,
+ struct ds_compare_result *cr ));
/*
* delete.c
*/
-int do_delete( Sockbuf *clientsb, struct msg *m, BerElement *ber );
+int do_delete LDAP_P(( Sockbuf *clientsb, struct msg *m, BerElement *ber ));
+void delete_result LDAP_P(( Sockbuf *sb, struct msg *m ));
/*
* error.c
*/
-void print_error( struct DSError *e );
-int x500err2ldaperr( struct DSError *e, char **matched );
+void print_error LDAP_P(( struct DSError *e ));
+int x500err2ldaperr LDAP_P(( struct DSError *e, char **matched ));
/*
* kerberos.c
*/
-int kerberosv4_ldap_auth( char *cred, long len );
+struct ds_bind_arg;
+int kerberosv4_ldap_auth LDAP_P(( char *cred, long len ));
+int kerberosv4_bindarg LDAP_P(( struct ds_bind_arg *ba, DN dn, char *cred,
+ long len, u_long *nonce ));
+int kerberos_check_mutual LDAP_P(( struct ds_bind_arg *res, u_long nonce ));
/*
* main.c
*/
-void log_and_exit( int exitcode );
+RETSIGTYPE log_and_exit LDAP_P(( int exitcode ));
/*
* message.c
*/
-struct msg *add_msg( int msgid, int msgtype, BerElement *ber,
- struct conn *dsaconn, int udp, struct sockaddr *clientaddr );
-struct msg *get_msg( int uniqid );
-int del_msg( struct msg *m );
-void send_msg( struct conn *conn, Sockbuf *clientsb, int err, char *str );
-struct msg * get_cldap_msg( int msgid, int msgtype, struct sockaddr *fromaddr );
+struct msg *add_msg LDAP_P(( int msgid, int msgtype, BerElement *ber,
+ struct conn *dsaconn, int udp, struct sockaddr *clientaddr ));
+struct msg *get_msg LDAP_P(( int uniqid ));
+int del_msg LDAP_P(( struct msg *m ));
+void send_msg LDAP_P(( struct conn *conn, Sockbuf *clientsb, int err, char *str ));
+struct msg * get_cldap_msg LDAP_P(( int msgid, int msgtype, struct sockaddr *fromaddr ));
/*
* modify.c
*/
-int do_modify( Sockbuf *clientsb, struct msg *m, BerElement *ber );
-Attr_Sequence get_as( Sockbuf *clientsb, unsigned long op, struct msg *m,
- char *type, struct berval **bvals );
-void modlist_free( LDAPMod *mods );
+struct ds_read_result;
+int do_modify LDAP_P(( Sockbuf *clientsb, struct msg *m, BerElement *ber ));
+int do_modify2 LDAP_P((Sockbuf *sb, struct msg *m, struct ds_read_result *rr));
+Attr_Sequence get_as LDAP_P(( Sockbuf *clientsb, unsigned long op, struct msg *m,
+ char *type, struct berval **bvals ));
+void modify_result LDAP_P(( Sockbuf *sb, struct msg *m ));
+void modlist_free LDAP_P(( LDAPMod *mods ));
/*
* modrdn.c
*/
-int do_modrdn( Sockbuf *clientsb, struct msg *m, BerElement *ber );
+int do_modrdn LDAP_P(( Sockbuf *clientsb, struct msg *m, BerElement *ber ));
+void modrdn_result LDAP_P((Sockbuf *sb, struct msg *m));
/*
* request.c
*/
-void client_request( Sockbuf *clientsb, struct conn *dsaconn, int udp );
-int do_request( Sockbuf *clientsb, struct msg *m, BerElement *ber,
- int *bound );
-int initiate_dap_operation( int op, struct msg *m, void *arg );
+void client_request LDAP_P(( Sockbuf *clientsb, struct conn *dsaconn, int udp ));
+int do_request LDAP_P(( Sockbuf *clientsb, struct msg *m, BerElement *ber,
+ int *bound ));
+int initiate_dap_operation LDAP_P(( int op, struct msg *m, void *arg ));
+#ifdef LDAP_DEBUG
+int trace_ber LDAP_P(( int tag, int len, char *ber,
+ FILE *trace_file, int prepend, int read_pdu ));
+#endif
/*
* result.c
*/
-void dsa_response( struct conn *dsaconn, Sockbuf *clientsb );
-int send_ldap_msgresult( Sockbuf *sb, unsigned long tag, struct msg *m,
- int err, char *matched, char *text );
-int send_ldap_result( Sockbuf *sb, unsigned long tag, int msgid, int err,
- char *matched, char *text );
+void dsa_response LDAP_P(( struct conn *dsaconn, Sockbuf *clientsb ));
+int send_ldap_msgresult LDAP_P(( Sockbuf *sb, unsigned long tag, struct msg *m,
+ int err, char *matched, char *text ));
+int send_ldap_result LDAP_P(( Sockbuf *sb, unsigned long tag, int msgid, int err,
+ char *matched, char *text ));
/*
* search.c
*/
-int do_search( Sockbuf *clientsb, struct msg *m, BerElement *ber );
+struct ds_search_result;
+int do_search LDAP_P(( Sockbuf *clientsb, struct msg *m, BerElement *ber ));
+void search_result LDAP_P(( Sockbuf *sb, struct msg *m,
+ struct ds_search_result *sr ));
+
/*
* syntax.c
*/
-void get_syntaxes();
-int dn_print_real( PS ps, DN dn, int format);
-void ldap_dn_print( PS ps, DN dn, DN base, int format);
-int encode_dn( BerElement *ber, DN dn, DN base);
-int encode_attrs( BerElement *ber, Attr_Sequence as );
-AttributeValue bv_octet2AttrV( struct berval *bv );
-AttributeValue bv_asn2AttrV( struct berval *bv );
-AttributeValue ldap_strdn2AttrV( char *dnstr );
-DN ldap_str2dn( char *str );
-RDN ldap_str2rdn( char *rdnstr );
-AttributeValue ldap_str_at2AttrV( char *str, AttributeType type );
-AttributeValue ldap_str2AttrV( char *value, short syntax );
+void get_syntaxes LDAP_P(( void ));
+int dn_print_real LDAP_P(( PS ps, DN dn, int format));
+void ldap_dn_print LDAP_P(( PS ps, DN dn, DN base, int format));
+int encode_dn LDAP_P(( BerElement *ber, DN dn, DN base));
+int encode_attrs LDAP_P(( BerElement *ber, Attr_Sequence as ));
+AttributeValue bv_octet2AttrV LDAP_P(( struct berval *bv ));
+AttributeValue bv_asn2AttrV LDAP_P(( struct berval *bv ));
+AttributeValue ldap_strdn2AttrV LDAP_P(( char *dnstr ));
+DN ldap_str2dn LDAP_P(( char *str ));
+RDN ldap_str2rdn LDAP_P(( char *rdnstr ));
+AttributeValue ldap_str_at2AttrV LDAP_P(( char *str, AttributeType type ));
+AttributeValue ldap_str2AttrV LDAP_P(( char *value, short syntax ));
/*
* util.c
*/
-void bprint( char *data, int len );
-void charlist_free( char **cl );
-int get_ava( BerElement *ber, AVA *tava );
-int chase_referral( Sockbuf *clientsb, struct msg *m, struct DSError *err,
- char **matched );
+void bprint LDAP_P(( char *data, int len ));
+void charlist_free LDAP_P(( char **cl ));
+int get_ava LDAP_P(( BerElement *ber, AVA *tava ));
+int chase_referral LDAP_P(( Sockbuf *clientsb, struct msg *m, struct DSError *err,
+ char **matched ));
#endif /* _proto_ldapd */
#include "ldap.h"
#include "common.h"
-extern int dosyslog;
-
#ifdef PEPSY_DUMP
#ifndef DEBUG
#define DEBUG
BerElement ber, *copyofber;
struct msg *m;
static int bound;
- extern char *bound_dn, *bound_pw;
- struct PSAPaddr *psap_cpy();
-#ifdef LDAP_COMPAT
- extern int ldap_compat;
-#endif
Debug( LDAP_DEBUG_TRACE, "client_request%s\n",
udp ? " udp" : "", 0, 0 );
* duplicate request: toss this one
*/
Debug( LDAP_DEBUG_TRACE,
- "client_request tossing dup request id %d from %s\n",
+ "client_request tossing dup request id %ld from %s\n",
msgid, inet_ntoa( ((struct sockaddr_in *)
clientsb->sb_fromaddr)->sin_addr ), 0 );
free( ber.ber_buf );
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/syslog.h>
+
#include <quipu/dsap.h>
#include <quipu/dap2.h>
#include <quipu/dua.h>
-#ifdef __hpux
-#include <syslog.h>
-#else
-#include <sys/syslog.h>
-#endif
+
#include "lber.h"
#include "ldap.h"
#include "common.h"
-extern int dosyslog;
-#ifdef COMPAT
-extern int ldap_compat;
-#endif
-
/*
* dsa_response - called by do_queries() when there is activity on one of
* the DSA associations. It is passed the association descriptor on which
return;
}
if ( m->m_msgtype == LDAP_REQ_SEARCH
-#ifdef COMPAT20
+#ifdef LDAP_COMPAT20
|| m->m_msgtype == OLD_LDAP_REQ_SEARCH
#endif
)
int bound, rc;
switch ( m->m_msgtype ) {
-#ifdef COMPAT20
+#ifdef LDAP_COMPAT20
case OLD_LDAP_REQ_ADD:
case OLD_LDAP_REQ_MODIFY:
case OLD_LDAP_REQ_MODRDN:
case OLD_LDAP_REQ_COMPARE:
case OLD_LDAP_REQ_SEARCH:
#endif
-#ifdef COMPAT30
+#ifdef LDAP_COMPAT30
case LDAP_REQ_DELETE_30:
#endif
case LDAP_REQ_ADD:
char *text
)
{
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
if ( m->m_cldap ) {
SAFEMEMCPY( (char *)sb->sb_useaddr, &m->m_clientaddr,
sizeof( struct sockaddr ));
{
BerElement *ber;
int rc;
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
int cldap;
-#endif
- extern int version;
-
-#ifdef CLDAP
cldap = ( sb->sb_naddr > 0 );
#endif
Debug( LDAP_DEBUG_TRACE, "send_ldap_result\n", 0, 0, 0 );
if ( tag == LBER_DEFAULT )
-#ifdef COMPAT20
+#ifdef LDAP_COMPAT20
tag = ldap_compat == 20 ? OLD_LBER_SEQUENCE : LBER_SEQUENCE;
#else
tag = LBER_SEQUENCE;
}
if ( version != 1 ) {
-#ifdef COMPAT20
+#ifdef LDAP_COMPAT20
if ( ldap_compat == 20 ) {
rc = ber_printf( ber, "t{it{tess}}", OLD_LBER_SEQUENCE,
msgid, tag, LBER_INTEGER, err,
matched ? matched : "", text );
} else
#endif
-#ifdef COMPAT30
+#ifdef LDAP_COMPAT30
if ( ldap_compat == 30 ) {
rc = ber_printf( ber, "{it{{ess}}}", msgid, tag, err,
matched ? matched : "", text );
} else
#endif
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
if ( cldap ) {
rc = ber_printf( ber, "{is{t{ess}}}", msgid, "", tag,
err, matched ? matched : "", text );
#include "ldap.h"
#include "common.h"
-static int get_filter();
-static int get_filter_list();
-static int get_substring_filter();
+static int get_filter( BerElement *ber, Filter *filt );
+static int get_filter_list( BerElement *ber, Filter f );
+static int get_substring_filter( BerElement *ber, Filter f );
#ifdef LDAP_COMPAT
-extern int version;
-extern int ldap_compat;
#define SEARCHRESTAG (ldap_compat == 20 ? OLD_LDAP_RES_SEARCH_RESULT : LDAP_RES_SEARCH_RESULT)
#else
#define SEARCHRESTAG LDAP_RES_SEARCH_RESULT
char **attrs;
struct ds_search_arg sa;
static CommonArgs common = default_common_args;
- extern DN ldap_str2dn();
Debug( LDAP_DEBUG_TRACE, "do_search\n", 0, 0, 0 );
AttributeType type;
char *valstr, *last;
AttributeValue value;
- extern short ldap_dn_syntax;
Debug( LDAP_DEBUG_TRACE, "get_substring_filter\n", 0, 0, 0 );
+++ /dev/null
-#ifndef NOSETPROCTITLE
-/*
- * Copyright (c) 1990,1991 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-char **Argv; /* pointer to original (main's) argv */
-int Argc; /* original argc */
-
-/*
- * takes a printf-style format string (fmt) and up to three parameters (a,b,c)
- * this clobbers the original argv...
- */
-
-/* VARARGS */
-setproctitle( fmt, a, b, c )
-char *fmt;
-{
- static char *endargv = (char *)0;
- char *s;
- int i;
- char buf[ 1024 ];
-
- if ( endargv == (char *)0 ) {
- /* set pointer to end of original argv */
- endargv = Argv[ Argc-1 ] + strlen( Argv[ Argc-1 ] );
- }
- sprintf( buf, fmt, a, b, c );
- /* make ps print "([prog name])" */
- s = Argv[0];
- *s++ = '-';
- i = strlen( buf );
- if ( i > endargv - s - 2 ) {
- i = endargv - s - 2;
- buf[ i ] = '\0';
- }
- strcpy( s, buf );
- s += i;
- while ( s < endargv ) *s++ = ' ';
-}
-#endif /* NOSETPROCTITLE */
#include <quipu/ds_search.h>
#include <quipu/dap2.h>
#include <quipu/dua.h>
+extern oid_table_attr *name2attr( char * );
+/*extern AttributeValue str_at2AttrV( char *, IF_AttributeType * );*/
#include "lber.h"
#include "ldap.h"
static int
get_one_syntax( char *attrib, int required )
{
- oid_table_attr *p, *name2attr();
+ oid_table_attr *p;
if ( (p = name2attr( attrib )) != (oid_table_attr *) 0 )
return( p->oa_syntax );
}
void
-get_syntaxes()
+get_syntaxes( void )
{
- oid_table_attr *name2attr();
-
Debug( LDAP_DEBUG_TRACE, "get_syntaxes\n", 0, 0, 0 );
ldap_photo_syntax = get_one_syntax( "photo", 0 );
* notation. (e.g., OID.2.6.53).
*
*/
-static void attr_key_rfc1779 (
+static void
+attr_key_rfc1779(
AttributeType at,
char *key /* return key, caller allocated */
)
int firstrdn;
char *value;
PS rps;
- void ldap_dn_print();
char key[512];
if ( dn == NULLDN )
encode_attrs( BerElement *ber, Attr_Sequence as )
{
PS ps;
-#ifdef LDAP_COMPAT20
- extern int ldap_compat;
-#endif
Debug( LDAP_DEBUG_TRACE, "encode_attrs\n", 0, 0, 0 );
}
}
-DN ldap_str2dn( char *str )
+DN
+ldap_str2dn( char *str )
{
DN dn, save;
RDN rdn, newrdn, tmprdn;
#define T61 "{T.61}"
#define T61LEN 6
-static void de_t61( char *s, int t61mark )
+static void
+de_t61( char *s, int t61mark )
{
char *next = s;
int c, hex;
ldap_str_at2AttrV( char *str, AttributeType type )
{
char *s, *res, *r;
- AttributeValue str_at2AttrV();
Debug( LDAP_DEBUG_TRACE, "ldap_str_at2AttrV str (%s) type (%s)\n", str,
type->oa_ot.ot_name, 0 );
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/errno.h>
+
+#include <ac/ctype.h>
+#include <ac/errno.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+
#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
#include <quipu/commonarg.h>
#include <quipu/ds_error.h>
+
#include "lber.h"
#include "ldap.h"
#include "common.h"
out[ i ] = ' ';
out[ i+1 ] = *data;
} else {
- out[ i ] = hexdig[ ( *data & 0xf0 ) >> 4 ];
- out[ i+1 ] = hexdig[ *data & 0x0f ];
+ out[ i ] = hexdig[ ( (unsigned char)*data & 0xf0 ) >> 4 ];
+ out[ i+1 ] = hexdig[ (unsigned char)*data & 0x0f ];
}
i += 2;
len--;
}
}
-void charlist_free( char **cl )
+void
+charlist_free( char **cl )
{
int i;
get_ava( BerElement *ber, AVA *tava )
{
char *type, *value;
- extern short ldap_dn_syntax;
Debug( LDAP_DEBUG_TRACE, "get_ava\n", 0, 0, 0 );
struct access_point *ap;
int rc, bound;
struct conn *save, *dup, *found;
- struct PSAPaddr *psap_cpy();
Debug( LDAP_DEBUG_TRACE, "chase_referral\n", 0, 0, 0 );
* is provided ``as is'' without express or implied warranty.
*/
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include "slap.h"
+#include "portable.h"
-extern Backend *select_backend();
+#include <stdio.h>
+#include <ac/socket.h>
-extern char *default_referral;
+#include "slap.h"
void
do_abandon(
#include "slap.h"
-extern Attribute *attr_find();
-extern struct acl *global_acl;
-extern int global_default_access;
-extern char *access2str();
-extern char *dn_normalize_case();
-
-int acl_access_allowed();
-int access_allowed();
-struct acl *acl_get_applicable();
-
-static int regex_matches();
-
-static string_expand(char *newbuf, int bufsiz, char *pattern,
- char *match, regmatch_t *matches);
+static int regex_matches(char *pat, char *str, char *buf, regmatch_t *matches);
+static void string_expand(char *newbuf, int bufsiz, char *pattern,
+ char *match, regmatch_t *matches);
/*
return( LDAP_SUCCESS );
}
-static string_expand(
+static void
+string_expand(
char *newbuf,
int bufsiz,
char *pat,
#include "slap.h"
-extern Filter *str2filter();
-extern struct acl *global_acl;
-extern char **str2charray();
-extern char *dn_upcase();
-
-static void split();
-static void acl_append();
-static void access_append();
-static void acl_usage();
+static void split(char *line, int splitchar, char **left, char **right);
+static void acl_append(struct acl **l, struct acl *a);
+static void access_append(struct access **l, struct access *a);
+static void acl_usage(void);
#ifdef LDAP_DEBUG
-static void print_acl();
-static void print_access();
+static void print_acl(struct acl *a);
+static void print_access(struct access *b);
#endif
-int
+static int
regtest(char *fname, int lineno, char *pat) {
int e;
regex_t re;
char buf[512];
- int size;
+ unsigned size;
char *sp;
char *dp;
}
static void
-acl_usage()
+acl_usage( void )
{
fprintf( stderr, "\n<access clause> ::= access to <what> [ by <who> <access> ]+ \n" );
fprintf( stderr, "<what> ::= * | [dn=<regex>] [filter=<ldapfilter>] [attrs=<attrlist>]\n" );
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include "slap.h"
-extern Backend *select_backend();
-extern char *dn_normalize();
+#include <ac/string.h>
+#include <ac/time.h>
+#include <ac/socket.h>
-extern char *default_referral;
-extern time_t currenttime;
-extern pthread_mutex_t currenttime_mutex;
-extern int global_lastmod;
+#include "slap.h"
-static void add_created_attrs();
+static void add_created_attrs(Operation *op, Entry *e);
void
-do_add( conn, op )
- Connection *conn;
- Operation *op;
+do_add( Connection *conn, Operation *op )
{
BerElement *ber = op->o_ber;
char *dn, *last;
*/
e = (Entry *) ch_calloc( 1, sizeof(Entry) );
+ /* initialize reader/writer lock */
+ entry_rdwr_init(e);
/* get the name */
if ( ber_scanf( ber, "{a", &dn ) == LBER_ERROR ) {
*/
if ( be->be_add != NULL ) {
/* do the update here */
- if ( be->be_updatedn == NULL || strcasecmp( be->be_updatedn,
- op->o_dn ) == 0 ) {
- if ( (be->be_lastmod == ON || be->be_lastmod == 0 &&
- global_lastmod == ON) && be->be_updatedn == NULL ) {
+ if ( be->be_updatedn == NULL ||
+ strcasecmp( be->be_updatedn, op->o_dn ) == 0 ) {
+
+ if ( (be->be_lastmod == ON || (be->be_lastmod == UNDEFINED &&
+ global_lastmod == ON)) && be->be_updatedn == NULL ) {
+
add_created_attrs( op, e );
}
if ( (*be->be_add)( be, conn, op, e ) == 0 ) {
replog( be, LDAP_REQ_ADD, e->e_dn, e, 0 );
}
+
} else {
entry_free( e );
send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL,
default_referral );
}
} else {
+ Debug( LDAP_DEBUG_ARGS, " do_add: HHH\n", 0, 0, 0 );
entry_free( e );
send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
"Function not implemented" );
static void
add_created_attrs( Operation *op, Entry *e )
{
- char buf[20];
+ char buf[22];
struct berval bv;
struct berval *bvals[2];
Attribute **a, **next;
/* remove any attempts by the user to add these attrs */
for ( a = &e->e_attrs; *a != NULL; a = next ) {
- if ( strcasecmp( (*a)->a_type, "createtimestamp" ) == 0
- || strcasecmp( (*a)->a_type, "creatorsname" ) == 0 ) {
+ if ( strcasecmp( (*a)->a_type, "modifiersname" ) == 0 ||
+ strcasecmp( (*a)->a_type, "modifytimestamp" ) == 0 ||
+ strcasecmp( (*a)->a_type, "creatorsname" ) == 0 ||
+ strcasecmp( (*a)->a_type, "createtimestamp" ) == 0 ) {
tmp = *a;
*a = (*a)->a_next;
attr_free( tmp );
attr_merge( e, "creatorsname", bvals );
pthread_mutex_lock( ¤ttime_mutex );
- ltm = localtime( ¤ttime );
- strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm );
+#ifndef LDAP_LOCALTIME
+ ltm = gmtime( ¤ttime );
+ strftime( buf, sizeof(buf), "%Y%m%d%H%M%SZ", ltm );
+#else
+ ltm = localtime( ¤ttime );
+ strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm );
+#endif
pthread_mutex_unlock( ¤ttime_mutex );
bv.bv_val = buf;
#endif
#include <ac/ctype.h>
+#include <ac/errno.h>
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/time.h>
#include "slap.h"
-extern char **charray_dup();
-extern int errno;
-
void
attr_free( Attribute *a )
{
} else {
Debug( LDAP_DEBUG_ANY,
"%s: line %d: unknown syntax \"%s\" in attribute line (ignored)\n",
- fname, lineno, 0 );
+ fname, lineno, argv[lasti] );
Debug( LDAP_DEBUG_ANY,
"possible syntaxes are \"cis\", \"ces\", \"tel\", \"dn\", or \"bin\"\n",
0, 0, 0 );
#ifdef LDAP_DEBUG
-static
+static int
attr_syntax_printnode( struct asyntaxinfo *a )
{
int i;
return( 0 );
}
-static
-attr_syntax_print()
+static void
+attr_syntax_print( void )
{
(void) avl_apply( attr_syntaxes, attr_syntax_printnode, 0, -1,
AVL_INORDER );
#include "portable.h"
-int
+/*ARGSUSED*/
+void
ldbm_back_abandon()
{
}
/* add.c - ldap ldbm back-end add routine */
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+
#include "slap.h"
#include "back-ldbm.h"
-
-extern int global_schemacheck;
-extern char *dn_parent();
-extern char *dn_normalize();
-extern Entry *dn2entry();
+#include "proto-back-ldbm.h"
int
ldbm_back_add(
)
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
- char *matched;
char *dn = NULL, *pdn = NULL;
- Entry *p;
+ Entry *p = NULL;
+ int rc;
dn = dn_normalize( strdup( e->e_dn ) );
- matched = NULL;
- if ( (p = dn2entry( be, dn, &matched )) != NULL ) {
- cache_return_entry( &li->li_cache, p );
+
+ Debug(LDAP_DEBUG_ARGS, "==> ldbm_back_add: %s\n", dn, 0, 0);
+
+ if ( ( dn2id( be, dn ) ) != NOID ) {
entry_free( e );
free( dn );
send_ldap_result( conn, op, LDAP_ALREADY_EXISTS, "", "" );
return( -1 );
}
- if ( matched != NULL ) {
- free( matched );
- }
+
/* XXX race condition here til we cache_add_entry_lock below XXX */
if ( global_schemacheck && oc_schema_check( e ) != 0 ) {
- Debug( LDAP_DEBUG_TRACE, "entry failed schema check\n", 0, 0,
- 0 );
+ Debug( LDAP_DEBUG_TRACE, "entry failed schema check\n",
+ 0, 0, 0 );
+
+ /* XXX this should be ok, no other thread should have access
+ * because e hasn't been added to the cache yet
+ */
entry_free( e );
free( dn );
send_ldap_result( conn, op, LDAP_OBJECT_CLASS_VIOLATION, "",
Debug( LDAP_DEBUG_ANY, "cache_add_entry_lock failed\n", 0, 0,
0 );
next_id_return( be, e->e_id );
+
+ /* XXX this should be ok, no other thread should have access
+ * because e hasn't been added to the cache yet
+ */
entry_free( e );
free( dn );
send_ldap_result( conn, op, LDAP_ALREADY_EXISTS, "", "" );
*/
if ( (pdn = dn_parent( be, dn )) != NULL ) {
+ char *matched;
/* no parent */
matched = NULL;
- if ( (p = dn2entry( be, pdn, &matched )) == NULL ) {
+
+ /* get entry with reader lock */
+ if ( (p = dn2entry_r( be, pdn, &matched )) == NULL ) {
+ Debug( LDAP_DEBUG_TRACE, "parent does not exist\n", 0,
+ 0, 0 );
send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT,
matched, "" );
if ( matched != NULL ) {
free( matched );
}
- Debug( LDAP_DEBUG_TRACE, "parent does not exist\n", 0,
- 0, 0 );
- goto error_return;
+
+ rc = -1;
+ goto return_results;
}
if ( matched != NULL ) {
free( matched );
0, 0 );
send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
"", "" );
- goto error_return;
+
+ rc = -1;
+ goto return_results;
}
} else {
if ( ! be_isroot( be, op->o_dn ) ) {
0, 0 );
send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
"", "" );
- goto error_return;
+
+ rc = -1;
+ goto return_results;
}
- p = NULL;
}
/*
if ( id2children_add( be, p, e ) != 0 ) {
Debug( LDAP_DEBUG_TRACE, "id2children_add failed\n", 0,
0, 0 );
- send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "",
- "" );
- goto error_return;
+ send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" );
+
+ rc = -1;
+ goto return_results;
}
/*
Debug( LDAP_DEBUG_TRACE, "index_add_entry failed\n", 0,
0, 0 );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" );
- goto error_return;
+
+ rc = -1;
+ goto return_results;
}
/* dn2id index */
Debug( LDAP_DEBUG_TRACE, "dn2id_add failed\n", 0,
0, 0 );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" );
- goto error_return;
+
+ rc = -1;
+ goto return_results;
}
+ /* acquire writer lock */
+ entry_rdwr_lock(e, 1);
+
/* id2entry index */
if ( id2entry_add( be, e ) != 0 ) {
Debug( LDAP_DEBUG_TRACE, "id2entry_add failed\n", 0,
0, 0 );
(void) dn2id_delete( be, dn );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" );
- goto error_return;
+
+ rc = -1;
+ goto return_results;
}
send_ldap_result( conn, op, LDAP_SUCCESS, "", "" );
+ rc = 0;
+
+return_results:;
+
if ( dn != NULL )
free( dn );
if ( pdn != NULL )
free( pdn );
+
cache_set_state( &li->li_cache, e, 0 );
- cache_return_entry( &li->li_cache, e );
- return( 0 );
-error_return:;
- if ( dn != NULL )
- free( dn );
- if ( pdn != NULL )
- free( pdn );
- next_id_return( be, e->e_id );
- cache_delete_entry( &li->li_cache, e );
- cache_return_entry( &li->li_cache, e );
+ /* free entry and writer lock */
+ cache_return_entry_w( &li->li_cache, e );
+
+ /* free entry and reader lock */
+ if (p != NULL) {
+ cache_return_entry_r( &li->li_cache, p );
+ }
- return( -1 );
+ return( rc );
}
/* attr.c - backend routines for dealing with attributes */
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+
#include "slap.h"
#include "back-ldbm.h"
-extern char **str2charray();
-
static int
ainfo_type_cmp(
char *type,
a->ai_indexmask |= INDEX_FROMINIT;
}
- switch (avl_insert( &li->li_attrs, a, ainfo_cmp, ainfo_dup )) {
+ switch (avl_insert( &li->li_attrs, (caddr_t) a, ainfo_cmp, ainfo_dup )) {
case 1: /* duplicate - updating init version */
free( a->ai_type );
free( (char *) a );
/* bind.c - ldbm backend bind and unbind routines */
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/krb.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/unistd.h>
+
#include "slap.h"
#include "back-ldbm.h"
-#ifdef KERBEROS
-#include "krb.h"
-#endif
+#include "proto-back-ldbm.h"
+
+#ifdef SLAPD_SHA1
+#include <lutil_sha1.h>
+#endif /* SLAPD_SHA1 */
-extern Entry *dn2entry();
-extern Attribute *attr_find();
+#ifdef SLAPD_MD5
+#include <lutil_md5.h>
+#endif /* SLAPD_MD5 */
-#ifdef KERBEROS
+#include <lutil.h>
+
+#ifdef HAVE_KERBEROS
extern int krbv4_ldap_auth();
#endif
+#ifdef SLAPD_CRYPT
+pthread_mutex_t crypt_mutex;
+
+static int
+crypted_value_find(
+ struct berval **vals,
+ struct berval *v,
+ int syntax,
+ int normalize,
+ struct berval *cred
+)
+{
+ int i;
+ for ( i = 0; vals[i] != NULL; i++ ) {
+ if ( syntax != SYNTAX_BIN && strncasecmp( "{CRYPT}",
+ vals[i]->bv_val, (sizeof("{CRYPT}") - 1 ) ) == 0 ) {
+ char *userpassword = vals[i]->bv_val + sizeof("{CRYPT}") - 1;
+ pthread_mutex_lock( &crypt_mutex );
+ if (strcmp(userpassword, crypt(cred->bv_val,
+ userpassword)) == 0) {
+ pthread_mutex_unlock( &crypt_mutex );
+ return ( 0 );
+ }
+ pthread_mutex_unlock( &crypt_mutex );
+#ifdef SLAPD_MD5
+ } else if ( syntax != SYNTAX_BIN && strncasecmp( "{MD5}",
+ vals[i]->bv_val, (sizeof("{MD5}") - 1 ) ) == 0 ) {
+ ldap_MD5_CTX MD5context;
+ unsigned char MD5digest[20];
+ char base64digest[29]; /* ceiling(sizeof(input)/3) * 4 + 1 */
+
+ char *userpassword = vals[i]->bv_val + sizeof("{MD5}") - 1;
+
+ ldap_MD5Init(&MD5context);
+ ldap_MD5Update(&MD5context,
+ (unsigned char *) cred->bv_val,
+ strlen(cred->bv_val));
+ ldap_MD5Final(MD5digest, &MD5context);
+
+ if (b64_ntop(MD5digest, sizeof(MD5digest),
+ base64digest, sizeof(base64digest)) < 0)
+ {
+ return ( 1 );
+ }
+
+ if (strcmp(userpassword, base64digest) == 0) {
+ return ( 0 );
+ }
+#endif /* SLAPD_MD5 */
+#ifdef SLAPD_SHA1
+ } else if ( syntax != SYNTAX_BIN && strncasecmp( "{SHA}",
+ vals[i]->bv_val, (sizeof("{SHA}") - 1 ) ) == 0 ) {
+ ldap_SHA1_CTX SHA1context;
+ unsigned char SHA1digest[20];
+ char base64digest[29]; /* ceiling(sizeof(input)/3) * 4 + 1 */
+
+ char *userpassword = vals[i]->bv_val + sizeof("{SHA}") - 1;
+
+ ldap_SHA1Init(&SHA1context);
+ ldap_SHA1Update(&SHA1context,
+ (unsigned char *) cred->bv_val,
+ strlen(cred->bv_val));
+ ldap_SHA1Final(SHA1digest, &SHA1context);
+
+ if (b64_ntop(SHA1digest, sizeof(SHA1digest),
+ base64digest, sizeof(base64digest)) < 0)
+ {
+ return ( 1 );
+ }
+
+ if (strcmp(userpassword, base64digest) == 0) {
+ return ( 0 );
+ }
+#endif /* SLAPD_SHA1 */
+ } else {
+ if ( value_cmp( vals[i], v, syntax, normalize ) == 0 ) {
+ return( 0 );
+ }
+ }
+ }
+
+ return( 1 );
+}
+#endif /* SLAPD_CRYPT */
+
int
ldbm_back_bind(
Backend *be,
Attribute *a;
int rc;
char *matched = NULL;
-#ifdef KERBEROS
+#ifdef HAVE_KERBEROS
char krbname[MAX_K_NAME_SZ + 1];
AUTH_DAT ad;
#endif
- if ( (e = dn2entry( be, dn, &matched )) == NULL ) {
+ Debug(LDAP_DEBUG_ARGS, "==> ldbm_back_bind: dn: %s\n", dn, 0, 0);
+
+ /* get entry with reader lock */
+ if ( (e = dn2entry_r( be, dn, &matched )) == NULL ) {
/* allow noauth binds */
if ( method == LDAP_AUTH_SIMPLE && cred->bv_len == 0 ) {
/*
/* front end will send result */
rc = 0;
} else {
- send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT,
- matched, NULL );
+ send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, matched, NULL );
rc = 1;
}
if ( matched != NULL ) {
return( rc );
}
+ /* check for deleted */
+
switch ( method ) {
case LDAP_AUTH_SIMPLE:
if ( cred->bv_len == 0 ) {
send_ldap_result( conn, op, LDAP_SUCCESS, NULL, NULL );
- return( 1 );
+
+ /* stop front end from sending result */
+ rc = 1;
+ goto return_results;
} else if ( be_isroot_pw( be, dn, cred ) ) {
/* front end will send result */
- return( 0 );
+ rc = 0;
+ goto return_results;
}
if ( (a = attr_find( e->e_attrs, "userpassword" )) == NULL ) {
if ( be_isroot_pw( be, dn, cred ) ) {
/* front end will send result */
- return( 0 );
+ rc = 0;
+ goto return_results;
}
send_ldap_result( conn, op, LDAP_INAPPROPRIATE_AUTH,
NULL, NULL );
- cache_return_entry( &li->li_cache, e );
- return( 1 );
+ rc = 1;
+ goto return_results;
}
- if ( value_find( a->a_vals, cred, a->a_syntax, 0 ) != 0 ) {
+#ifdef SLAPD_CRYPT
+ if ( crypted_value_find( a->a_vals, cred, a->a_syntax, 0, cred ) != 0 )
+#else
+ if ( value_find( a->a_vals, cred, a->a_syntax, 0 ) != 0 )
+#endif
+ {
if ( be_isroot_pw( be, dn, cred ) ) {
/* front end will send result */
- return( 0 );
+ rc = 0;
+ goto return_results;
}
send_ldap_result( conn, op, LDAP_INVALID_CREDENTIALS,
- NULL, NULL );
- cache_return_entry( &li->li_cache, e );
- return( 1 );
+ NULL, NULL );
+ rc = 1;
+ goto return_results;
}
+ rc = 0;
break;
-#ifdef KERBEROS
+#ifdef HAVE_KERBEROS
case LDAP_AUTH_KRBV41:
if ( krbv4_ldap_auth( be, cred, &ad ) != LDAP_SUCCESS ) {
send_ldap_result( conn, op, LDAP_INVALID_CREDENTIALS,
NULL, NULL );
- cache_return_entry( &li->li_cache, e );
- return( 1 );
+ rc = 0;
+ goto return_results;
}
sprintf( krbname, "%s%s%s@%s", ad.pname, *ad.pinst ? "."
: "", ad.pinst, ad.prealm );
* no krbName values present: check against DN
*/
if ( strcasecmp( dn, krbname ) == 0 ) {
+ rc = 0; /* XXX wild ass guess */
break;
}
send_ldap_result( conn, op, LDAP_INAPPROPRIATE_AUTH,
NULL, NULL );
- cache_return_entry( &li->li_cache, e );
- return( 1 );
+ rc = 1;
+ goto return_results;
} else { /* look for krbName match */
struct berval krbval;
krbval.bv_val = krbname;
krbval.bv_len = strlen( krbname );
- if ( value_find( a->a_vals, &krbval, a->a_syntax, 3 )
- != 0 ) {
+ if ( value_find( a->a_vals, &krbval, a->a_syntax, 3 ) != 0 ) {
send_ldap_result( conn, op,
LDAP_INVALID_CREDENTIALS, NULL, NULL );
- cache_return_entry( &li->li_cache, e );
- return( 1 );
+ rc = 1;
+ goto return_results;
}
}
break;
case LDAP_AUTH_KRBV42:
send_ldap_result( conn, op, LDAP_SUCCESS, NULL, NULL );
- cache_return_entry( &li->li_cache, e );
- return( 1 );
+ /* stop front end from sending result */
+ rc = 1;
+ goto return_results;
#endif
default:
send_ldap_result( conn, op, LDAP_STRONG_AUTH_NOT_SUPPORTED,
NULL, "auth method not supported" );
- cache_return_entry( &li->li_cache, e );
- return( 1 );
+ rc = 1;
+ goto return_results;
}
- cache_return_entry( &li->li_cache, e );
+return_results:;
+ /* free entry and reader lock */
+ cache_return_entry_r( &li->li_cache, e );
- /* success: front end will send result */
- return( 0 );
+ /* front end with send result on success (rc==0) */
+ return( rc );
}
+
#include "portable.h"
#include <stdio.h>
+int strcasecmp( const char *, const char *);
#include <ac/socket.h>
#include "slap.h"
#include "back-ldbm.h"
-static int cache_delete_entry_internal();
+static int cache_delete_entry_internal(struct cache *cache, Entry *e);
#ifdef LDAP_DEBUG
-static void lru_print();
+static void lru_print(struct cache *cache);
#endif
/*
cache_entrydn_cmp, avl_dup_error ) != 0 )
{
Debug( LDAP_DEBUG_TRACE,
- "====> cache_add_entry lock: entry %20s id %d already in dn cache\n",
+ "====> cache_add_entry lock: entry %20s id %lu already in dn cache\n",
e->e_dn, e->e_id, 0 );
/* free cache mutex */
cache_entryid_cmp, avl_dup_error ) != 0 )
{
Debug( LDAP_DEBUG_ANY,
- "====> entry %20s id %d already in id cache\n",
+ "====> entry %20s id %lu already in id cache\n",
e->e_dn, e->e_id, 0 );
/* delete from dn tree inserted above */
fprintf( stderr, "LRU queue (head to tail):\n" );
for ( e = cache->c_lruhead; e != NULL; e = e->e_lrunext ) {
- fprintf( stderr, "\tdn %20s id %d refcnt %d\n", e->e_dn,
+ fprintf( stderr, "\tdn %20s id %lu refcnt %d\n", e->e_dn,
e->e_id, e->e_refcnt );
}
fprintf( stderr, "LRU queue (tail to head):\n" );
for ( e = cache->c_lrutail; e != NULL; e = e->e_lruprev ) {
- fprintf( stderr, "\tdn %20s id %d refcnt %d\n", e->e_dn,
+ fprintf( stderr, "\tdn %20s id %lu refcnt %d\n", e->e_dn,
e->e_id, e->e_refcnt );
}
}
/* close.c - close ldbm backend */
+#include "portable.h"
+
#include <stdio.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/socket.h>
+
#include "slap.h"
#include "back-ldbm.h"
+void
ldbm_back_close( Backend *be )
{
Debug( LDAP_DEBUG_TRACE, "ldbm backend syncing\n", 0, 0, 0 );
#include "back-ldbm.h"
#include "proto-back-ldbm.h"
-extern Attribute *attr_find();
-
int
ldbm_back_compare(
Backend *be,
#include "slap.h"
#include "back-ldbm.h"
+void
ldbm_back_config(
Backend *be,
char *fname,
/* ldbmcache.c - maintain a cache of open ldbm files */
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/param.h>
+
+#include <ac/errno.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
#include <sys/stat.h>
-#include <errno.h>
-#include "portable.h"
-#include "slap.h"
-#include "ldapconfig.h"
-#include "back-ldbm.h"
-#ifndef SYSERRLIST_IN_STDIO
-extern int sys_nerr;
-extern char *sys_errlist[];
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
#endif
-extern time_t currenttime;
-extern pthread_mutex_t currenttime_mutex;
+
+#include "ldapconfig.h"
+#include "slap.h"
+#include "back-ldbm.h"
struct dbcache *
ldbm_cache_open(
li->li_dbcache[i].dbc_maxids) + 1;
Debug( LDAP_DEBUG_ARGS,
- "ldbm_cache_open (blksize %d) (maxids %d) (maxindirect %d)\n",
+ "ldbm_cache_open (blksize %ld) (maxids %d) (maxindirect %d)\n",
li->li_dbcache[i].dbc_blksize, li->li_dbcache[i].dbc_maxids,
li->li_dbcache[i].dbc_maxindirect );
Debug( LDAP_DEBUG_TRACE, "<= ldbm_cache_open (opened %d)\n", i, 0, 0 );
)
{
Datum data;
+#ifdef HAVE_BERKELEY_DB2
+ memset( &data, 0, sizeof( data ) );
+#endif
pthread_mutex_lock( &db->dbc_mutex );
#ifdef reentrant_database
}
#endif
+#ifdef LDBM_DEBUG
+ Statslog( LDAP_DEBUG_STATS,
+ "=> ldbm_cache_store(): key.dptr=%s, key.dsize=%d\n",
+ key.dptr, key.dsize, 0, 0, 0 );
+
+ Statslog( LDAP_DEBUG_STATS,
+ "=> ldbm_cache_store(): key.dptr=0x%08x, data.dptr=0x%0 8x\n",
+ key.dptr, data.dptr, 0, 0, 0 );
+
+ Statslog( LDAP_DEBUG_STATS,
+ "=> ldbm_cache_store(): data.dptr=%s, data.dsize=%d\n",
+ data.dptr, data.dsize, 0, 0, 0 );
+
+ Statslog( LDAP_DEBUG_STATS,
+ "=> ldbm_cache_store(): flags=0x%08x\n",
+ flags, 0, 0, 0, 0 );
+#endif /* LDBM_DEBUG */
+
rc = ldbm_store( db->dbc_db, key, data, flags );
pthread_mutex_unlock( &db->dbc_mutex );
#include "back-ldbm.h"
#include "proto-back-ldbm.h"
-extern Attribute *attr_find();
-
int
ldbm_back_delete(
Backend *be,
#include "back-ldbm.h"
#include "proto-back-ldbm.h"
-extern struct dbcache *ldbm_cache_open();
-extern char *dn_parent();
-extern Datum ldbm_cache_fetch();
-
int
dn2id_add(
Backend *be,
/* first check the cache */
if ( (id = cache_find_entry_dn2id( be, &li->li_cache, dn )) != NOID ) {
free( dn );
- Debug( LDAP_DEBUG_TRACE, "<= dn2id %d (in cache)\n", id,
+ Debug( LDAP_DEBUG_TRACE, "<= dn2id %lu (in cache)\n", id,
0, 0 );
return( id );
}
ldbm_datum_free( db->dbc_db, data );
- Debug( LDAP_DEBUG_TRACE, "<= dn2id %d\n", id, 0, 0 );
+ Debug( LDAP_DEBUG_TRACE, "<= dn2id %lu\n", id, 0, 0 );
return( id );
}
/* filterindex.c - generate the list of candidate entries from a filter */
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+
#include "slap.h"
#include "back-ldbm.h"
-extern char *first_word();
-extern char *next_word();
-extern char *phonetic();
-extern IDList *index_read();
-extern IDList *idl_intersection();
-extern IDList *idl_union();
-extern IDList *idl_notin();
-extern IDList *idl_allids();
-
-static IDList *ava_candidates();
-static IDList *presence_candidates();
-static IDList *approx_candidates();
-static IDList *list_candidates();
-static IDList *substring_candidates();
-static IDList *substring_comp_candidates();
+static IDList *ava_candidates( Backend *be, Ava *ava, int type );
+static IDList *presence_candidates( Backend *be, char *type );
+static IDList *approx_candidates( Backend *be, Ava *ava );
+static IDList *list_candidates( Backend *be, Filter *flist, int ftype );
+static IDList *substring_candidates( Backend *be, Filter *f );
+static IDList *substring_comp_candidates( Backend *be, char *type, char *val, int prepost );
/*
* test_filter - test a filter against a single entry.
break;
}
- Debug( LDAP_DEBUG_TRACE, "<= filter_candidates %d\n",
+ Debug( LDAP_DEBUG_TRACE, "<= filter_candidates %lu\n",
result ? result->b_nids : 0, 0, 0 );
return( result );
}
break;
}
- Debug( LDAP_DEBUG_TRACE, "<= ava_candidates %d\n",
+ Debug( LDAP_DEBUG_TRACE, "<= ava_candidates %lu\n",
idl ? idl->b_nids : 0, 0, 0 );
return( idl );
}
idl = index_read( be, type, 0, "*" );
- Debug( LDAP_DEBUG_TRACE, "<= presence_candidates %d\n",
+ Debug( LDAP_DEBUG_TRACE, "<= presence_candidates %lu\n",
idl ? idl->b_nids : 0, 0, 0 );
return( idl );
}
}
}
- Debug( LDAP_DEBUG_TRACE, "<= approx_candidates %d\n",
+ Debug( LDAP_DEBUG_TRACE, "<= approx_candidates %lu\n",
idl ? idl->b_nids : 0, 0, 0 );
return( idl );
}
}
}
- Debug( LDAP_DEBUG_TRACE, "<= list_candidates %d\n",
+ Debug( LDAP_DEBUG_TRACE, "<= list_candidates %lu\n",
idl ? idl->b_nids : 0, 0, 0 );
return( idl );
}
}
}
- Debug( LDAP_DEBUG_TRACE, "<= substring_candidates %d\n",
+ Debug( LDAP_DEBUG_TRACE, "<= substring_candidates %lu\n",
idl ? idl->b_nids : 0, 0, 0 );
return( idl );
}
}
}
- Debug( LDAP_DEBUG_TRACE, "<= substring_comp_candidates %d\n",
+ Debug( LDAP_DEBUG_TRACE, "<= substring_comp_candidates %lu\n",
idl ? idl->b_nids : 0, 0, 0 );
return( idl );
}
#include "back-ldbm.h"
#include "proto-back-ldbm.h"
-extern Attribute *attr_find();
-
#ifdef SLAPD_ACLGROUPS
/* return 0 IFF edn is a value in member attribute
/* can we find bdn entry with reader lock */
if ((e = dn2entry_r(be, bdn, &matched )) == NULL) {
- Debug( LDAP_DEBUG_TRACE, "=> ldbm_back_group: cannot find bdn: %s matched: %x\n", bdn, matched, 0 );
+ Debug( LDAP_DEBUG_TRACE, "=> ldbm_back_group: cannot find bdn: %s matched: %s\n", bdn, (matched ? matched : ""), 0 );
if (matched != NULL)
free(matched);
return( 1 );
}
- Debug( LDAP_DEBUG_ARGS, "=> ldbm_back_group: found bdn: %s matched: %x\n", bdn, matched, 0 );
+ Debug( LDAP_DEBUG_ARGS, "=> ldbm_back_group: found bdn: %s matched: %s\n", bdn, (matched ? matched : ""), 0 );
/* check for deleted */
#include "slap.h"
#include "back-ldbm.h"
-struct dbcache *ldbm_cache_open();
-extern Datum ldbm_cache_fetch();
-IDList *idl_fetch();
-
int
id2children_add(
Backend *be,
memset( &data, 0, sizeof( data ) );
#endif
- Debug( LDAP_DEBUG_TRACE, "=> id2children_add( %d, %d )\n", p ? p->e_id
- : 0, e->e_id, 0 );
+ Debug( LDAP_DEBUG_TRACE, "=> id2children_add( %lu, %lu )\n",
+ p ? p->e_id : 0, e->e_id, 0 );
if ( (db = ldbm_cache_open( be, "id2children", LDBM_SUFFIX,
LDBM_WRCREAT )) == NULL ) {
IDList *idl;
char buf[20];
- Debug( LDAP_DEBUG_TRACE, "=> id2children_remove( %d, %d )\n", p ? p->e_id
+ Debug( LDAP_DEBUG_TRACE, "=> id2children_remove( %lu, %lu )\n", p ? p->e_id
: 0, e->e_id, 0 );
if ( (db = ldbm_cache_open( be, "id2children", LDBM_SUFFIX,
}
memset( &key, 0, sizeof(key) );
- sprintf( buf, "%c%d", EQ_PREFIX, p ? p->e_id : 0 );
+ sprintf( buf, "%c%ld", EQ_PREFIX, p ? p->e_id : 0 );
key.dptr = buf;
key.dsize = strlen( buf ) + 1;
memset( &key, 0, sizeof( key ) );
#endif
- Debug( LDAP_DEBUG_TRACE, "=> has_children( %d )\n", p->e_id , 0, 0 );
+ Debug( LDAP_DEBUG_TRACE, "=> has_children( %lu )\n", p->e_id , 0, 0 );
if ( (db = ldbm_cache_open( be, "id2children", LDBM_SUFFIX,
LDBM_WRCREAT )) == NULL ) {
#include "slap.h"
#include "back-ldbm.h"
-extern struct dbcache *ldbm_cache_open();
-extern Datum ldbm_cache_fetch();
-extern char *dn_parent();
-extern Entry *str2entry();
-extern char *entry2str();
-extern pthread_mutex_t entry2str_mutex;
-
int
id2entry_add( Backend *be, Entry *e )
{
memset( &data, 0, sizeof( data ) );
#endif
- Debug( LDAP_DEBUG_TRACE, "=> id2entry_add( %d, \"%s\" )\n", e->e_id,
+ Debug( LDAP_DEBUG_TRACE, "=> id2entry_add( %lu, \"%s\" )\n", e->e_id,
e->e_dn, 0 );
if ( (db = ldbm_cache_open( be, "id2entry", LDBM_SUFFIX, LDBM_WRCREAT ))
Datum key;
int rc;
- Debug( LDAP_DEBUG_TRACE, "=> id2entry_delete( %d, \"%s\" )\n", e->e_id,
+ Debug(LDAP_DEBUG_TRACE, "=> id2entry_delete( %lu, \"%s\" )\n", e->e_id,
e->e_dn, 0 );
/* XXX - check for writer lock - should also check no reader pending */
}
if ( cache_delete_entry( &li->li_cache, e ) != 0 ) {
- Debug( LDAP_DEBUG_ANY, "could not delete %d (%s) from cache\n",
+ Debug(LDAP_DEBUG_ANY, "could not delete %lu (%s) from cache\n",
e->e_id, e->e_dn, 0 );
}
rw ? "w" : "r", id, 0 );
if ( (e = cache_find_entry_id( &li->li_cache, id, rw )) != NULL ) {
- Debug( LDAP_DEBUG_TRACE, "<= id2entry_%s 0x%x (cache)\n",
- rw ? "w" : "r", e, 0 );
+ Debug( LDAP_DEBUG_TRACE, "<= id2entry_%s 0x%lx (cache)\n",
+ rw ? "w" : "r", (unsigned long)e, 0 );
return( e );
}
}
Entry *
-id2entry_2( Backend *be, ID id )
+id2entry_w( Backend *be, ID id )
{
return( id2entry( be, id, 1 ) );
}
#include <ac/string.h>
#include <ac/socket.h>
-#include "slap.h"
#include "ldapconfig.h"
+#include "slap.h"
#include "back-ldbm.h"
-extern Datum ldbm_cache_fetch();
-
IDList *
idl_alloc( int nids )
{
}
free( (char *) tmp );
- Debug( LDAP_DEBUG_TRACE, "<= idl_fetch %d ids (%d max)\n", idl->b_nids,
- idl->b_nmax, 0 );
+ Debug( LDAP_DEBUG_TRACE, "<= idl_fetch %lu ids (%lu max)\n",
+ idl->b_nids, idl->b_nmax, 0 );
return( idl );
}
case 0: /* id inserted */
if ( rc == 2 ) {
Debug( LDAP_DEBUG_ANY,
- "id %d already in next block\n",
+ "id %lu already in next block\n",
id, 0, 0 );
}
free( kstr );
{
Datum k2;
IDList *idl, *tmp;
- int i, j, nids;
+ unsigned i;
+ int j, nids;
char *kstr;
if ( (idl = idl_fetch_one( be, db, key ) ) == NULL )
for ( j = 0; idl->b_ids[j] != NOID; j++ )
{
memset( &k2, 0, sizeof(k2) );
- sprintf( kstr, "%c%s%d", CONT_PREFIX, key.dptr, idl->b_ids[j] );
+ sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr, idl->b_ids[j] );
k2.dptr = kstr;
k2.dsize = strlen( kstr ) + 1;
#include "slap.h"
#include "back-ldbm.h"
-extern char *first_word();
-extern char *next_word();
-extern char *phonetic();
-extern IDList *idl_fetch();
-extern IDList *idl_allids();
-extern struct dbcache *ldbm_cache_open();
-
-int index_add_values();
-
-static int add_value();
-static int index2prefix();
+static int add_value(Backend *be, struct dbcache *db, char *type, int indextype, char *val, ID id);
+static int index2prefix(int indextype);
int
index_add_entry(
if ( ! (indextype & indexmask) ) {
idl = idl_allids( be );
Debug( LDAP_DEBUG_TRACE,
- "<= index_read %d candidates (allids - not indexed)\n",
+ "<= index_read %lu candidates (allids - not indexed)\n",
idl ? idl->b_nids : 0, 0, 0 );
return( idl );
}
ldbm_cache_close( be, db );
- Debug( LDAP_DEBUG_TRACE, "<= index_read %d candidates\n",
+ Debug( LDAP_DEBUG_TRACE, "<= index_read %lu candidates\n",
idl ? idl->b_nids : 0, 0, 0 );
return( idl );
}
)
{
char *val, *p, *code, *w;
- int i, j, len;
+ unsigned i, j, len;
int indexmask, syntax;
char buf[SUBLEN + 1];
char vbuf[BUFSIZ];
#include "slap.h"
#include "back-ldbm.h"
+void
ldbm_back_init(
Backend *be
)
#include "back-ldbm.h"
#include "proto-back-ldbm.h"
-extern int global_schemacheck;
-extern Attribute *attr_find();
-
-static int add_values();
-static int delete_values();
-static int replace_values();
+static int add_values(Entry *e, LDAPMod *mod, char *dn);
+static int delete_values(Entry *e, LDAPMod *mod, char *dn);
+static int replace_values(Entry *e, LDAPMod *mod, char *dn);
int
ldbm_back_modify(
/* modrdn.c - ldbm backend modrdn routine */
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
#include "slap.h"
#include "back-ldbm.h"
-
-extern Entry *dn2entry();
-extern char *dn_parent();
+#include "proto-back-ldbm.h"
int
ldbm_back_modrdn(
char *matched;
char *pdn, *newdn, *p;
char sep[2];
- Entry *e, *e2;
+ Entry *e;
matched = NULL;
- if ( (e = dn2entry( be, dn, &matched )) == NULL ) {
+
+ /* get entry with writer lock */
+ if ( (e = dn2entry_w( be, dn, &matched )) == NULL ) {
send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, matched, "" );
if ( matched != NULL ) {
free( matched );
}
(void) dn_normalize( newdn );
- matched = NULL;
- if ( (e2 = dn2entry( be, newdn, &matched )) != NULL ) {
+ /* get entry with writer lock */
+ if ( (dn2id ( be, newdn ) ) != NOID ) {
free( newdn );
free( pdn );
send_ldap_result( conn, op, LDAP_ALREADY_EXISTS, NULL, NULL );
- cache_return_entry( &li->li_cache, e2 );
- cache_return_entry( &li->li_cache, e );
- return( -1 );
- }
- if ( matched != NULL ) {
- free( matched );
+ goto error_return;
}
/* check for abandon */
pthread_mutex_unlock( &op->o_abandonmutex );
free( newdn );
free( pdn );
- cache_return_entry( &li->li_cache, e2 );
- cache_return_entry( &li->li_cache, e );
- return( -1 );
+ goto error_return;
}
pthread_mutex_unlock( &op->o_abandonmutex );
free( newdn );
free( pdn );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL, NULL );
- cache_return_entry( &li->li_cache, e );
- return( -1 );
+ goto error_return;
}
/* delete old one */
free( newdn );
free( pdn );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL, NULL );
- cache_return_entry( &li->li_cache, e );
- return( -1 );
+ goto error_return;
}
(void) cache_delete_entry( &li->li_cache, e );
/* id2entry index */
if ( id2entry_add( be, e ) != 0 ) {
entry_free( e );
-
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" );
- return( -1 );
+ goto error_return;
}
free( pdn );
- cache_return_entry( &li->li_cache, e );
+
+ /* free entry and writer lock */
+ cache_return_entry_w( &li->li_cache, e );
send_ldap_result( conn, op, LDAP_SUCCESS, NULL, NULL );
return( 0 );
+
+error_return:
+ /* free entry and writer lock */
+ cache_return_entry_w( &li->li_cache, e );
+ return( -1 );
}
/* id.c - keep track of the next id to be given out */
+#include "portable.h"
+
#include <stdio.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/socket.h>
+
+#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
+#endif
+
#include "slap.h"
#include "back-ldbm.h"
if ( li->li_nextid == -1 ) {
if ( (fp = fopen( buf, "r" )) == NULL ) {
Debug( LDAP_DEBUG_ANY,
- "next_id %d: could not open \"%s\"\n",
+ "next_id %lu: could not open \"%s\"\n",
li->li_nextid, buf, 0 );
li->li_nextid = 1;
} else {
li->li_nextid = atol( buf2 );
} else {
Debug( LDAP_DEBUG_ANY,
- "next_id %d: could not fgets nextid from \"%s\"\n",
+ "next_id %lu: could not fgets nextid from \"%s\"\n",
li->li_nextid, buf2, 0 );
li->li_nextid = 1;
}
li->li_nextid++;
if ( (fp = fopen( buf, "w" )) == NULL ) {
- Debug( LDAP_DEBUG_ANY, "next_id %d: could not open \"%s\"\n",
+ Debug( LDAP_DEBUG_ANY, "next_id %lu: could not open \"%s\"\n",
li->li_nextid, buf, 0 );
} else {
if ( fprintf( fp, "%ld\n", li->li_nextid ) == EOF ) {
- Debug( LDAP_DEBUG_ANY, "next_id %d: cannot fprintf\n",
+ Debug( LDAP_DEBUG_ANY, "next_id %lu: cannot fprintf\n",
li->li_nextid, 0, 0 );
}
if( fclose( fp ) != 0 ) {
- Debug( LDAP_DEBUG_ANY, "next_id %d: cannot fclose\n",
+ Debug( LDAP_DEBUG_ANY, "next_id %lu: cannot fclose\n",
li->li_nextid, 0, 0 );
}
}
li->li_nextid--;
if ( (fp = fopen( buf, "w" )) == NULL ) {
Debug( LDAP_DEBUG_ANY,
- "next_id_return of %d: could not open \"%s\" next id %d\n",
+ "next_id_return of %lu: could not open \"%s\" next id %lu\n",
id, buf, li->li_nextid );
} else {
if ( fprintf( fp, "%ld\n", li->li_nextid ) == EOF ) {
Debug( LDAP_DEBUG_ANY,
- "next_id_return of %d: cannot fprintf \"%s\" next id %d\n",
+ "next_id_return of %lu: cannot fprintf \"%s\" next id %lu\n",
id, buf, li->li_nextid );
}
if( fclose( fp ) != 0 ) {
Debug( LDAP_DEBUG_ANY,
- "next_id_return of %d: cannot fclose \"%s\" next id %d\n",
+ "next_id_return of %lu: cannot fclose \"%s\" next id %lu\n",
id, buf, li->li_nextid );
}
}
if ( li->li_nextid == -1 ) {
if ( (fp = fopen( buf, "r" )) == NULL ) {
Debug( LDAP_DEBUG_ANY,
- "next_id %d: could not open \"%s\"\n",
+ "next_id %lu: could not open \"%s\"\n",
li->li_nextid, buf, 0 );
li->li_nextid = 1;
} else {
li->li_nextid = atol( buf2 );
} else {
Debug( LDAP_DEBUG_ANY,
- "next_id %d: cannot fgets nextid from \"%s\"\n",
+ "next_id %lu: cannot fgets nextid from \"%s\"\n",
li->li_nextid, buf2, 0 );
li->li_nextid = 1;
}
#ifndef _PROTO_BACK_LDBM
#define _PROTO_BACK_LDBM
+#include <ldap_cdefs.h>
+
+LDAP_BEGIN_DECL
+
+/*
+ * alias.c
+ */
+Entry *derefAlias_r LDAP_P((
+ Backend *be,
+ Connection *conn,
+ Operation *op,
+ Entry *e ));
+char *derefDN LDAP_P((
+ Backend *be,
+ Connection *conn,
+ Operation *op,
+ char *dn ));
+
/*
* attr.c
*/
-void attr_masks( struct ldbminfo *li, char *type, int *indexmask,
- int *syntaxmask );
-void attr_index_config( struct ldbminfo *li, char *fname, int lineno,
- int argc, char **argv, int init );
+void attr_masks LDAP_P(( struct ldbminfo *li, char *type, int *indexmask,
+ int *syntaxmask ));
+void attr_index_config LDAP_P(( struct ldbminfo *li, char *fname, int lineno,
+ int argc, char **argv, int init ));
/*
* cache.c
*/
-void cache_set_state( struct cache *cache, Entry *e, int state );
-void cache_return_entry( struct cache *cache, Entry *e );
-int cache_add_entry_lock( struct cache *cache, Entry *e, int state );
-Entry * cache_find_entry_dn( struct cache *cache, char *dn );
-Entry * cache_find_entry_id( struct cache *cache, ID id );
-int cache_delete_entry( struct cache *cache, Entry *e );
+void cache_set_state LDAP_P(( struct cache *cache, Entry *e, int state ));
+void cache_return_entry_r LDAP_P(( struct cache *cache, Entry *e ));
+void cache_return_entry_w LDAP_P(( struct cache *cache, Entry *e ));
+int cache_add_entry_lock LDAP_P(( struct cache *cache, Entry *e, int state ));
+ID cache_find_entry_dn2id LDAP_P(( Backend *be, struct cache *cache, char *dn ));
+Entry * cache_find_entry_id LDAP_P(( struct cache *cache, ID id, int rw ));
+int cache_delete_entry LDAP_P(( struct cache *cache, Entry *e ));
/*
* dbcache.c
*/
-struct dbcache * ldbm_cache_open( Backend *be, char *name, char *suffix,
- int flags );
-void ldbm_cache_close( Backend *be, struct dbcache *db );
-void ldbm_cache_flush_all( Backend *be );
-Datum ldbm_cache_fetch( struct dbcache *db, Datum key );
-int ldbm_cache_store( struct dbcache *db, Datum key, Datum data, int flags );
-int ldbm_cache_delete( struct dbcache *db, Datum key );
+struct dbcache * ldbm_cache_open LDAP_P(( Backend *be, char *name, char *suffix,
+ int flags ));
+void ldbm_cache_close LDAP_P(( Backend *be, struct dbcache *db ));
+void ldbm_cache_really_close LDAP_P(( Backend *be, struct dbcache *db ));
+void ldbm_cache_flush_all LDAP_P(( Backend *be ));
+Datum ldbm_cache_fetch LDAP_P(( struct dbcache *db, Datum key ));
+int ldbm_cache_store LDAP_P(( struct dbcache *db, Datum key, Datum data, int flags ));
+int ldbm_cache_delete LDAP_P(( struct dbcache *db, Datum key ));
/*
* dn2id.c
*/
-int dn2id_add( Backend *be, char *dn, ID id );
-ID dn2id( Backend *be, char *dn );
-int dn2id_delete( Backend *be, char *dn );
-Entry * dn2entry( Backend *be, char *dn, char **matched );
+int dn2id_add LDAP_P(( Backend *be, char *dn, ID id ));
+ID dn2id LDAP_P(( Backend *be, char *dn ));
+int dn2id_delete LDAP_P(( Backend *be, char *dn ));
+Entry * dn2entry_r LDAP_P(( Backend *be, char *dn, char **matched ));
+Entry * dn2entry_w LDAP_P(( Backend *be, char *dn, char **matched ));
/*
* filterindex.c
*/
-IDList * filter_candidates( Backend *be, Filter *f );
+IDList * filter_candidates LDAP_P(( Backend *be, Filter *f ));
/*
* id2children.c
*/
-int id2children_add( Backend *be, Entry *p, Entry *e );
-int has_children( Backend *be, Entry *p );
+int id2children_add LDAP_P(( Backend *be, Entry *p, Entry *e ));
+int id2children_remove LDAP_P(( Backend *be, Entry *p, Entry *e ));
+int has_children LDAP_P(( Backend *be, Entry *p ));
/*
* id2entry.c
*/
-int id2entry_add( Backend *be, Entry *e );
-int id2entry_delete( Backend *be, Entry *e );
-Entry * id2entry( Backend *be, ID id );
+int id2entry_add LDAP_P(( Backend *be, Entry *e ));
+int id2entry_delete LDAP_P(( Backend *be, Entry *e ));
+Entry * id2entry LDAP_P(( Backend *be, ID id, int rw ));
+Entry * id2entry_r LDAP_P(( Backend *be, ID id ));
+Entry * id2entry_w LDAP_P(( Backend *be, ID id ));
/*
* idl.c
*/
-IDList * idl_alloc( int nids );
-IDList * idl_allids( Backend *be );
-void idl_free( IDList *idl );
-IDList * idl_fetch( Backend *be, struct dbcache *db, Datum key );
-int idl_insert_key( Backend *be, struct dbcache *db, Datum key, ID id );
-int idl_insert( IDList **idl, ID id, int maxids );
-IDList * idl_intersection( Backend *be, IDList *a, IDList *b );
-IDList * idl_union( Backend *be, IDList *a, IDList *b );
-IDList * idl_notin( Backend *be, IDList *a, IDList *b );
-ID idl_firstid( IDList *idl );
-ID idl_nextid( IDList *idl, ID id );
+IDList * idl_alloc LDAP_P(( int nids ));
+IDList * idl_allids LDAP_P(( Backend *be ));
+void idl_free LDAP_P(( IDList *idl ));
+IDList * idl_fetch LDAP_P(( Backend *be, struct dbcache *db, Datum key ));
+int idl_insert_key LDAP_P(( Backend *be, struct dbcache *db, Datum key, ID id ));
+int idl_insert LDAP_P(( IDList **idl, ID id, int maxids ));
+int idl_delete_key LDAP_P(( Backend *be, struct dbcache *db, Datum key, ID id ));
+IDList * idl_intersection LDAP_P(( Backend *be, IDList *a, IDList *b ));
+IDList * idl_union LDAP_P(( Backend *be, IDList *a, IDList *b ));
+IDList * idl_notin LDAP_P(( Backend *be, IDList *a, IDList *b ));
+ID idl_firstid LDAP_P(( IDList *idl ));
+ID idl_nextid LDAP_P(( IDList *idl, ID id ));
/*
* index.c
*/
-int index_add_entry( Backend *be, Entry *e );
-int index_add_mods( Backend *be, LDAPMod *mods, ID id );
-IDList * index_read( Backend *be, char *type, int indextype, char *val );
-int index_add_values( Backend *be, char *type, struct berval **vals, ID id );
+int index_add_entry LDAP_P(( Backend *be, Entry *e ));
+int index_add_mods LDAP_P(( Backend *be, LDAPMod *mods, ID id ));
+IDList * index_read LDAP_P(( Backend *be, char *type, int indextype, char *val ));
+int index_add_values LDAP_P(( Backend *be, char *type, struct berval **vals, ID id ));
/*
* kerberos.c
*/
-#ifdef KERBEROS
-/* krbv4_ldap_auth( Backend *be, struct berval *cred, AUTH_DAT *ad ); */
+#ifdef HAVE_KERBEROS
+/* krbv4_ldap_auth LDAP_P(( Backend *be, struct berval *cred, AUTH_DAT *ad )); */
#endif
/*
* nextid.c
*/
-ID next_id( Backend *be );
-void next_id_return( Backend *be, ID id );
-ID next_id_get( Backend *be );
+ID next_id LDAP_P(( Backend *be ));
+void next_id_return LDAP_P(( Backend *be, ID id ));
+ID next_id_get LDAP_P(( Backend *be ));
+LDAP_END_DECL
#endif
#include "back-ldbm.h"
#include "proto-back-ldbm.h"
-extern time_t currenttime;
-extern pthread_mutex_t currenttime_mutex;
-
-extern IDList *idl_alloc();
-extern Attribute *attr_find();
-extern IDList *filter_candidates();
-extern char *dn_parent();
-
-static IDList *base_candidates();
-static IDList *onelevel_candidates();
-static IDList *subtree_candidates();
+static IDList *base_candidates(Backend *be, Connection *conn, Operation *op, char *base, Filter *filter, char **attrs, int attrsonly, char **matched, int *err);
+static IDList *onelevel_candidates(Backend *be, Connection *conn, Operation *op, char *base, Filter *filter, char **attrs, int attrsonly, char **matched, int *err);
+static IDList *subtree_candidates(Backend *be, Connection *conn, Operation *op, char *base, Filter *filter, char **attrs, int attrsonly, char **matched, Entry *e, int *err, int lookupbase);
#define GRABSIZE BUFSIZ
/* get the entry with reader lock */
if ( (e = id2entry_r( be, id )) == NULL ) {
- Debug( LDAP_DEBUG_ARGS, "candidate %d not found\n", id, 0, 0 );
+ Debug( LDAP_DEBUG_ARGS, "candidate %lu not found\n",
+ id, 0, 0 );
continue;
}
/* unbind.c - handle an ldap unbind operation */
+#include "portable.h"
+
#include <stdio.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+#include <ac/socket.h>
+
#include "slap.h"
-int
+void
ldbm_back_unbind(
Backend *be,
Connection *conn,
Operation *op
)
{
- return( 0 );
}
/* config.c - passwd backend configuration file routine */
-#include <stdio.h>
-#include <string.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
#include "slap.h"
+void
passwd_back_config(
Backend *be,
char *fname,
#include "slap.h"
-extern time_t currenttime;
-extern pthread_mutex_t currenttime_mutex;
-
-static Entry *pw2entry();
+static Entry *pw2entry(Backend *be, struct passwd *pw);
int
passwd_back_search(
/* add.c - shell backend add function */
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
#include "slap.h"
#include "shell.h"
-extern pthread_mutex_t entry2str_mutex;
-extern char *entry2str();
-
-void
+int
shell_back_add(
Backend *be,
Connection *conn,
if ( si->si_add == NULL ) {
send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
"add not implemented" );
- return;
+ return( -1 );
}
if ( (op->o_private = forkandexec( si->si_add, &rfp, &wfp )) == -1 ) {
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
"could not fork/exec" );
- return;
+ return( -1 );
}
/* write out the request to the add process */
fprintf( wfp, "ADD\n" );
- fprintf( wfp, "msgid: %d\n", op->o_msgid );
+ fprintf( wfp, "msgid: %ld\n", op->o_msgid );
print_suffixes( wfp, be );
pthread_mutex_lock( &entry2str_mutex );
fprintf( wfp, "%s", entry2str( e, &len, 0 ) );
read_and_send_results( be, conn, op, rfp, NULL, 0 );
fclose( rfp );
+ return( 0 );
}
/* bind.c - shell backend bind function */
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+
#include "slap.h"
#include "shell.h"
if ( si->si_bind == NULL ) {
send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
"bind not implemented" );
- return;
+ return( -1 );
}
if ( (op->o_private = forkandexec( si->si_bind, &rfp, &wfp ))
== -1 ) {
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
"could not fork/exec" );
- return;
+ return( -1 );
}
/* write out the request to the bind process */
fprintf( wfp, "BIND\n" );
- fprintf( wfp, "msgid: %d\n", op->o_msgid );
+ fprintf( wfp, "msgid: %ld\n", op->o_msgid );
print_suffixes( wfp, be );
fprintf( wfp, "dn: %s\n", dn );
fprintf( wfp, "method: %d\n", method );
- fprintf( wfp, "credlen: %d\n", cred->bv_len );
+ fprintf( wfp, "credlen: %lu\n", cred->bv_len );
fprintf( wfp, "cred: %s\n", cred->bv_val ); /* XXX */
fclose( wfp );
/* compare.c - shell backend compare function */
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
#include "slap.h"
#include "shell.h"
-void
+int
shell_back_compare(
Backend *be,
Connection *conn,
if ( si->si_compare == NULL ) {
send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
"compare not implemented" );
- return;
+ return( -1 );
}
if ( (op->o_private = forkandexec( si->si_compare, &rfp, &wfp ))
== -1 ) {
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
"could not fork/exec" );
- return;
+ return( -1 );
}
/* write out the request to the compare process */
fprintf( wfp, "COMPARE\n" );
- fprintf( wfp, "msgid: %d\n", op->o_msgid );
+ fprintf( wfp, "msgid: %ld\n", op->o_msgid );
print_suffixes( wfp, be );
fprintf( wfp, "dn: %s\n", dn );
fprintf( wfp, "%s: %s\n", ava->ava_type, ava->ava_value.bv_val );
read_and_send_results( be, conn, op, rfp, NULL, 0 );
fclose( rfp );
+ return( 0 );
}
/* config.c - shell backend configuration file routine */
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
#include "slap.h"
#include "shell.h"
-extern char **charray_dup();
-
+void
shell_back_config(
Backend *be,
char *fname,
/* delete.c - shell backend delete function */
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
#include "slap.h"
#include "shell.h"
-void
+int
shell_back_delete(
Backend *be,
Connection *conn,
if ( si->si_delete == NULL ) {
send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
"delete not implemented" );
- return;
+ return( -1 );
}
if ( (op->o_private = forkandexec( si->si_delete, &rfp, &wfp ))
== -1 ) {
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
"could not fork/exec" );
- return;
+ return( -1 );
}
/* write out the request to the delete process */
fprintf( wfp, "DELETE\n" );
- fprintf( wfp, "msgid: %d\n", op->o_msgid );
+ fprintf( wfp, "msgid: %ld\n", op->o_msgid );
print_suffixes( wfp, be );
fprintf( wfp, "dn: %s\n", dn );
fclose( wfp );
/* read in the results and send them along */
read_and_send_results( be, conn, op, rfp, NULL, 0 );
fclose( rfp );
+ return( 0 );
}
/* fork.c - fork and exec a process, connecting stdin/out w/pipes */
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+#include <ac/unistd.h>
+
#include "slap.h"
+#include "shell.h"
+int
forkandexec(
char **args,
FILE **rfp,
/* init.c - initialize shell backend */
+#include "portable.h"
+
#include <stdio.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/socket.h>
+
#include "slap.h"
#include "shell.h"
+void
shell_back_init(
Backend *be
)
#include "slap.h"
#include "shell.h"
-void
+int
shell_back_modify(
Backend *be,
Connection *conn,
if ( si->si_modify == NULL ) {
send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
"modify not implemented" );
- return;
+ return( -1 );
}
if ( (op->o_private = forkandexec( si->si_modify, &rfp, &wfp ))
== -1 ) {
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
"could not fork/exec" );
- return;
+ return( -1 );
}
/* write out the request to the modify process */
fprintf( wfp, "MODIFY\n" );
- fprintf( wfp, "msgid: %d\n", op->o_msgid );
+ fprintf( wfp, "msgid: %ld\n", op->o_msgid );
print_suffixes( wfp, be );
fprintf( wfp, "dn: %s\n", dn );
for ( ; mods != NULL; mods = mods->mod_next ) {
/* read in the results and send them along */
read_and_send_results( be, conn, op, rfp, NULL, 0 );
fclose( rfp );
+ return( 0 );
+
}
/* modrdn.c - shell backend modrdn function */
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+
#include "slap.h"
#include "shell.h"
-void
+int
shell_back_modrdn(
Backend *be,
Connection *conn,
if ( si->si_modrdn == NULL ) {
send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
"modrdn not implemented" );
- return;
+ return( -1 );
}
if ( (op->o_private = forkandexec( si->si_modrdn, &rfp, &wfp ))
== -1 ) {
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
"could not fork/exec" );
- return;
+ return( -1 );
}
/* write out the request to the modrdn process */
fprintf( wfp, "MODRDN\n" );
- fprintf( wfp, "msgid: %d\n", op->o_msgid );
+ fprintf( wfp, "msgid: %ld\n", op->o_msgid );
print_suffixes( wfp, be );
fprintf( wfp, "dn: %s\n", dn );
fprintf( wfp, "newrdn: %s\n", newrdn );
/* read in the results and send them along */
read_and_send_results( be, conn, op, rfp, NULL, 0 );
fclose( rfp );
+ return( 0 );
}
/* result.c - shell backend result reading function */
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+#include <ac/unistd.h>
+
#include "slap.h"
#include "shell.h"
-extern Entry *str2entry();
-
int
read_and_send_results(
Backend *be,
/* search.c - shell backend search function */
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+
#include "slap.h"
#include "shell.h"
-extern Entry *str2entry();
-
-void
+int
shell_back_search(
Backend *be,
Connection *conn,
if ( si->si_search == NULL ) {
send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
"search not implemented" );
- return;
+ return( -1 );
}
if ( (op->o_private = forkandexec( si->si_search, &rfp, &wfp ))
== -1 ) {
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
"could not fork/exec" );
- return;
+ return( -1 );
}
/* write out the request to the search process */
fprintf( wfp, "SEARCH\n" );
- fprintf( wfp, "msgid: %d\n", op->o_msgid );
+ fprintf( wfp, "msgid: %ld\n", op->o_msgid );
print_suffixes( wfp, be );
fprintf( wfp, "base: %s\n", base );
fprintf( wfp, "scope: %d\n", scope );
read_and_send_results( be, conn, op, rfp, attrs, attrsonly );
fclose( rfp );
+ return( 0 );
}
/* shell.h - shell backend header file */
+#ifndef SLAPD_SHELL_H
+#define SLAPD_SHELL_H
+
+#include <ldap_cdefs.h>
+
+LDAP_BEGIN_DECL
+
struct shellinfo {
char **si_bind; /* cmd + args to exec for bind */
char **si_unbind; /* cmd + args to exec for unbind */
char **si_delete; /* cmd + args to exec for delete */
char **si_abandon; /* cmd + args to exec for abandon */
};
+
+struct backend;
+struct conn;
+struct op;
+extern int forkandexec LDAP_P((char **args, FILE **rfp, FILE **wfp));
+extern void print_suffixes LDAP_P((FILE *fp, struct backend *be));
+extern int read_and_send_results LDAP_P((struct backend *be, struct conn *conn, struct op *op, FILE *fp, char **attrs, int attrsonly));
+
+LDAP_END_DECL
+
+#endif
/* unbind.c - shell backend unbind function */
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+
#include "slap.h"
#include "shell.h"
shell_back_unbind(
Backend *be,
Connection *conn,
- Operation *op,
- char *dn,
- int method,
- struct berval *cred
+ Operation *op
)
{
struct shellinfo *si = (struct shellinfo *) be->be_private;
/* write out the request to the unbind process */
fprintf( wfp, "UNBIND\n" );
- fprintf( wfp, "msgid: %d\n", op->o_msgid );
+ fprintf( wfp, "msgid: %ld\n", op->o_msgid );
print_suffixes( wfp, be );
- fprintf( wfp, "dn: %s\n", dn );
+ fprintf( wfp, "dn: %s\n", (conn->c_dn ? conn->c_dn : "") );
fclose( wfp );
/* no response to unbind */
#include "slap.h"
-#ifdef SLAPD_LDBM
-extern int ldbm_back_bind();
-extern int ldbm_back_unbind();
-extern int ldbm_back_search();
-extern int ldbm_back_compare();
-extern int ldbm_back_modify();
-extern int ldbm_back_modrdn();
-extern int ldbm_back_add();
-extern int ldbm_back_delete();
-extern int ldbm_back_abandon();
-extern int ldbm_back_config();
-extern int ldbm_back_init();
-extern int ldbm_back_close();
-extern int ldbm_back_group();
-#endif
-
-#ifdef SLAPD_PASSWD
-extern int passwd_back_search();
-extern int passwd_back_config();
-#endif
-
-#ifdef SLAPD_SHELL
-extern int shell_back_bind();
-extern int shell_back_unbind();
-extern int shell_back_search();
-extern int shell_back_compare();
-extern int shell_back_modify();
-extern int shell_back_modrdn();
-extern int shell_back_add();
-extern int shell_back_delete();
-extern int shell_back_abandon();
-extern int shell_back_config();
-extern int shell_back_init();
-#endif
-
-extern int defsize;
-extern int deftime;
#define BACKEND_GRAB_SIZE 10
}
void
-be_close()
+be_close( void )
{
int i;
#ifdef SLAPD_ACLGROUPS
int
-be_group(Backend *be, char *bdn, char *edn, char *objectclassValue, char *groupattrName)
+be_group(
+ Backend *be,
+ char *bdn,
+ char *edn,
+ char *objectclassValue,
+ char *groupattrName
+)
{
if (be->be_group)
return(be->be_group(be, bdn, edn, objectclassValue, groupattrName));
#include "slap.h"
-extern Backend *select_backend();
-extern char *suffixAlias();
-
-extern char *default_referral;
-
void
do_bind(
Connection *conn,
void *new;
if ( (new = (void *) malloc( size )) == NULL ) {
- Debug( LDAP_DEBUG_ANY, "malloc of %d bytes failed\n", size, 0, 0 );
+ Debug( LDAP_DEBUG_ANY, "malloc of %lu bytes failed\n", size, 0, 0 );
exit( 1 );
}
}
if ( (new = (void *) realloc( block, size )) == NULL ) {
- Debug( LDAP_DEBUG_ANY, "realloc of %d bytes failed\n", size, 0, 0 );
+ Debug( LDAP_DEBUG_ANY, "realloc of %lu bytes failed\n", size, 0, 0 );
exit( 1 );
}
void *new;
if ( (new = (void *) calloc( nelem, size )) == NULL ) {
- Debug( LDAP_DEBUG_ANY, "calloc of %d elems of %d bytes failed\n",
+ Debug( LDAP_DEBUG_ANY, "calloc of %lu elems of %lu bytes failed\n",
nelem, size, 0 );
exit( 1 );
}
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#include <stdio.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include "slap.h"
-extern Backend *select_backend();
+#include <ac/socket.h>
-extern char *default_referral;
+#include "slap.h"
void
do_compare(
/* config.c - configuration file handling routines */
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include "slap.h"
+
+#include <ac/string.h>
+#include <ac/ctype.h>
+#include <ac/socket.h>
+
#include "ldapconfig.h"
+#include "slap.h"
#define MAXARGS 100
-extern Backend *new_backend();
-extern char *default_referral;
-extern int ldap_syslog;
-extern int global_schemacheck;
-
/*
* defaults for various global variables
*/
int global_lastmod;
char *ldap_srvtab = "";
-static char *fp_getline();
-static void fp_getline_init();
-static void fp_parse_line();
+static char *fp_getline(FILE *fp, int *lineno);
+static void fp_getline_init(int *lineno);
+static void fp_parse_line(char *line, int *argcp, char **argv);
-static char *strtok_quote();
+static char *strtok_quote(char *line, char *sep);
void
read_config( char *fname, Backend **bep, FILE *pfp )
*bep = new_backend( cargv[1] );
be = *bep;
+ /* assign a default depth limit for alias deref */
+ be->be_maxDerefDepth = SLAPD_DEFAULT_MAXDEREFDEPTH;
+
/* set size limit */
} else if ( strcasecmp( cargv[0], "sizelimit" ) == 0 ) {
if ( cargc < 2 ) {
charray_add( &be->be_suffix, dn );
}
+ /* set database suffixAlias */
+ } else if ( strcasecmp( cargv[0], "suffixAlias" ) == 0 ) {
+ if ( cargc < 2 ) {
+ Debug( LDAP_DEBUG_ANY,
+ "%s: line %d: missing alias and aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
+ fname, lineno, 0 );
+ exit( 1 );
+ } else if ( cargc < 3 ) {
+ Debug( LDAP_DEBUG_ANY,
+ "%s: line %d: missing aliased_dn in \"suffixAlias <alias> <aliased_dn>\" line\n",
+ fname, lineno, 0 );
+ exit( 1 );
+ } else if ( cargc > 3 ) {
+ Debug( LDAP_DEBUG_ANY,
+ "%s: line %d: extra cruft in suffixAlias line (ignored)\n",
+ fname, lineno, 0 );
+ }
+ if ( be == NULL ) {
+ Debug( LDAP_DEBUG_ANY,
+"%s: line %d: suffixAlias line must appear inside a database definition (ignored)\n",
+ fname, lineno, 0 );
+ } else {
+ dn = strdup( cargv[1] );
+ (void) dn_normalize( dn );
+ charray_add( &be->be_suffixAlias, dn );
+
+ dn = strdup( cargv[2] );
+ (void) dn_normalize( dn );
+ charray_add( &be->be_suffixAlias, dn );
+ }
+
+ /* set max deref depth */
+ } else if ( strcasecmp( cargv[0], "maxDerefDepth" ) == 0 ) {
+ if ( cargc < 2 ) {
+ Debug( LDAP_DEBUG_ANY,
+ "%s: line %d: missing depth in \"maxDerefDepth <depth>\" line\n",
+ fname, lineno, 0 );
+ exit( 1 );
+ }
+ if ( be == NULL ) {
+ Debug( LDAP_DEBUG_ANY,
+"%s: line %d: depth line must appear inside a database definition (ignored)\n",
+ fname, lineno, 0 );
+ } else {
+ be->be_maxDerefDepth = atoi (cargv[1]);
+ }
+
+
/* set magic "root" dn for this database */
} else if ( strcasecmp( cargv[0], "rootdn" ) == 0 ) {
if ( cargc < 2 ) {
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include "slap.h"
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
#include "ldapconfig.h"
+#include "slap.h"
#if defined( SLAPD_CONFIG_DN )
-extern int nbackends;
-extern Backend *backends;
-extern char *default_referral;
-
/*
* no mutex protection in here - take our chances!
*/
vals[1] = NULL;
e = (Entry *) ch_calloc( 1, sizeof(Entry) );
+ /* initialize reader/writer lock */
+ entry_rdwr_init(e);
+
e->e_attrs = NULL;
e->e_dn = strdup( SLAPD_CONFIG_DN );
#include "slap.h"
-extern Operation *op_add();
-extern int active_threads;
-extern pthread_mutex_t active_threads_mutex;
-extern pthread_mutex_t new_conn_mutex;
-extern long ops_initiated;
-extern long ops_completed;
-extern pthread_mutex_t ops_mutex;
-extern pthread_t listener_tid;
-
struct co_arg {
Connection *co_conn;
Operation *co_op;
* calls the appropriate stub to handle it.
*/
-static void
-connection_operation( struct co_arg *arg )
+static void *
+connection_operation( void *arg_v )
{
+ struct co_arg *arg = arg_v;
unsigned long len;
pthread_mutex_lock( &arg->co_conn->c_opsmutex );
break;
default:
- Debug( LDAP_DEBUG_ANY, "unknown request 0x%x\n",
+ Debug( LDAP_DEBUG_ANY, "unknown request 0x%lx\n",
arg->co_op->o_tag, 0, 0 );
break;
}
pthread_mutex_lock( &active_threads_mutex );
active_threads--;
pthread_mutex_unlock( &active_threads_mutex );
+ return NULL;
}
void
"ber_get_next on fd %d failed errno %d (%s)\n",
conn->c_sb.sb_sd, errno, errno > -1 && errno < sys_nerr ?
sys_errlist[errno] : "unknown" );
- Debug( LDAP_DEBUG_TRACE, "*** got %d of %d so far\n",
+ Debug( LDAP_DEBUG_TRACE, "*** got %d of %lu so far\n",
conn->c_currentber->ber_rwptr - conn->c_currentber->ber_buf,
conn->c_currentber->ber_len, 0 );
if ( (tag = ber_get_int( ber, &msgid )) != LDAP_TAG_MSGID ) {
/* log, close and send error */
- Debug( LDAP_DEBUG_ANY, "ber_get_int returns 0x%x\n", tag, 0,
+ Debug( LDAP_DEBUG_ANY, "ber_get_int returns 0x%lx\n", tag, 0,
0 );
ber_free( ber, 1 );
if ( (tag = ber_peek_tag( ber, &len )) == LBER_ERROR ) {
/* log, close and send error */
- Debug( LDAP_DEBUG_ANY, "ber_peek_tag returns 0x%x\n", tag, 0,
+ Debug( LDAP_DEBUG_ANY, "ber_peek_tag returns 0x%lx\n", tag, 0,
0 );
ber_free( ber, 1 );
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <errno.h>
-#include <sys/time.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <signal.h>
-#ifdef _AIX
-#include <sys/select.h>
-#endif
-#include "slap.h"
+
+/* Revision history
+ *
+ * 5-Jun-96 hodges
+ * Added locking of new_conn_mutex when traversing the c[] array.
+ */
+
#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/ctype.h>
+#include <ac/errno.h>
+#include <ac/signal.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+#include <ac/unistd.h>
+
#include "ldapconfig.h"
-#ifdef NEED_FILIO
+#include "slap.h"
+
+#ifdef HAVE_SYS_FILIO_H
#include <sys/filio.h>
-#else /* NEED_FILIO */
+#elif HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
-#endif /* NEED_FILIO */
-#ifdef USE_SYSCONF
-#include <unistd.h>
-#endif /* USE_SYSCONF */
+#endif
-extern Operation *op_add();
+#ifdef HAVE_TCPD
+#include <tcpd.h>
-#ifndef SYSERRLIST_IN_STDIO
-extern int sys_nerr;
-extern char *sys_errlist[];
-#endif
-extern time_t currenttime;
-extern pthread_mutex_t currenttime_mutex;
-extern int active_threads;
-extern pthread_mutex_t active_threads_mutex;
-extern pthread_mutex_t new_conn_mutex;
-extern int slapd_shutdown;
-extern pthread_t listener_tid;
-extern int num_conns;
-extern pthread_mutex_t ops_mutex;
-extern int g_argc;
-extern char **g_argv;
+int allow_severity = LOG_INFO;
+int deny_severity = LOG_NOTICE;
+#endif /* TCP Wrappers */
int dtblsize;
Connection *c;
-static void set_shutdown();
-static void do_nothing();
+static void set_shutdown(int sig);
+static void do_nothing (int sig);
-void
-daemon(
- int port
+void *
+slapd_daemon(
+ void *port
)
{
Operation *o;
FILE *fp;
int on = 1;
-#ifdef USE_SYSCONF
- dtblsize = sysconf( _SC_OPEN_MAX );
-#else /* USE_SYSCONF */
- dtblsize = getdtablesize();
-#endif /* USE_SYSCONF */
+#ifdef HAVE_SYSCONF
+ dtblsize = sysconf( _SC_OPEN_MAX );
+#elif HAVE_GETDTABLESIZE
+ dtblsize = getdtablesize();
+#else
+ dtblsize = FD_SETSIZE
+#endif
+
+#ifdef FD_SETSIZE
+ if(dtblsize > FD_SETSIZE) {
+ dtblsize = FD_SETSIZE;
+ }
+#endif /* !FD_SETSIZE */
c = (Connection *) ch_calloc( 1, dtblsize * sizeof(Connection) );
(void) memset( (void *) &addr, '\0', sizeof(addr) );
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = INADDR_ANY;
- addr.sin_port = htons( port );
+ addr.sin_port = htons( (int)port );
if ( bind( tcps, (struct sockaddr *) &addr, sizeof(addr) ) == -1 ) {
Debug( LDAP_DEBUG_ANY, "bind() failed errno %d (%s)\n",
errno, errno > -1 && errno < sys_nerr ? sys_errlist[errno] :
}
(void) SIGNAL( SIGPIPE, SIG_IGN );
- (void) SIGNAL( SIGUSR1, (void *) do_nothing );
- (void) SIGNAL( SIGUSR2, (void *) set_shutdown );
- (void) SIGNAL( SIGTERM, (void *) set_shutdown );
- (void) SIGNAL( SIGHUP, (void *) set_shutdown );
+#ifdef HAVE_LINUX_THREADS
+ /*
+ * LinuxThreads are implemented using SIGUSR1/USR2,
+ * so we'll use SIGSTKFLT and SIGUNUSED
+ */
+ (void) SIGNAL( SIGSTKFLT, do_nothing );
+ (void) SIGNAL( SIGUNUSED, set_shutdown );
+#else /* !linux */
+ (void) SIGNAL( SIGUSR1, do_nothing );
+ (void) SIGNAL( SIGUSR2, set_shutdown );
+#endif /* !linux */
+ (void) SIGNAL( SIGTERM, set_shutdown );
+ (void) SIGNAL( SIGINT, set_shutdown );
+ (void) SIGNAL( SIGHUP, set_shutdown );
Debug( LDAP_DEBUG_ANY, "slapd starting\n", 0, 0, 0 );
#ifdef SLAPD_PIDFILE
if ( (fp = fopen( SLAPD_PIDFILE, "w" )) != NULL ) {
- fprintf( fp, "%d\n", getpid() );
+ fprintf( fp, "%d\n", (int) getpid() );
fclose( fp );
}
#endif
struct timeval *tvp;
int len, pid;
+ char *client_name;
+ char *client_addr;
+
FD_ZERO( &writefds );
FD_ZERO( &readfds );
FD_SET( tcps, &readfds );
+ zero.tv_sec = 0;
+ zero.tv_usec = 0;
+
pthread_mutex_lock( &active_threads_mutex );
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 );
}
}
Debug( LDAP_DEBUG_CONNS, "\n", 0, 0, 0 );
+ pthread_mutex_unlock( &new_conn_mutex );
- zero.tv_sec = 0;
- zero.tv_usec = 0;
Debug( LDAP_DEBUG_CONNS, "before select active_threads %d\n",
active_threads, 0, 0 );
-#ifdef PTHREAD_PREEMPTIVE
+#ifdef PREEMPTIVE_THREADS
tvp = NULL;
#else
tvp = active_threads ? &zero : NULL;
#endif
pthread_mutex_unlock( &active_threads_mutex );
- switch ( select( dtblsize, &readfds, &writefds, 0, tvp ) ) {
+ switch ( i = select( dtblsize, &readfds, &writefds, 0, tvp ) ) {
case -1: /* failure - try again */
Debug( LDAP_DEBUG_CONNS,
"select failed errno %d (%s)\n",
continue;
default: /* something happened - deal with it */
- Debug( LDAP_DEBUG_CONNS, "select activity\n", 0, 0, 0 );
+ Debug( LDAP_DEBUG_CONNS, "select activity on %d descriptors\n", i, 0, 0 );
; /* FALL */
}
pthread_mutex_lock( ¤ttime_mutex );
}
if ( ioctl( ns, FIONBIO, (caddr_t) &on ) == -1 ) {
Debug( LDAP_DEBUG_ANY,
- "FIONBIO ioctl on %d faled\n", ns, 0, 0 );
+ "FIONBIO ioctl on %d failed\n", ns, 0, 0 );
}
+
c[ns].c_sb.sb_sd = ns;
Debug( LDAP_DEBUG_CONNS, "new connection on %d\n", ns,
0, 0 );
pthread_mutex_lock( &ops_mutex );
c[ns].c_connid = num_conns++;
pthread_mutex_unlock( &ops_mutex );
+
len = sizeof(from);
+
if ( getpeername( ns, (struct sockaddr *) &from, &len )
== 0 ) {
- char *s;
-#ifdef REVERSE_LOOKUP
+ char *s;
+ client_addr = inet_ntoa( from.sin_addr );
+
+#if defined(SLAPD_RLOOKUPS) || defined(HAVE_TCPD)
hp = gethostbyaddr( (char *)
&(from.sin_addr.s_addr),
sizeof(from.sin_addr.s_addr), AF_INET );
-#else
- hp = NULL;
-#endif
- Statslog( LDAP_DEBUG_STATS,
- "conn=%d fd=%d connection from %s (%s)\n",
- c[ns].c_connid, ns, hp == NULL ? "unknown"
- : hp->h_name, inet_ntoa( from.sin_addr ),
- 0 );
+ if(hp) {
+ client_name = hp->h_name;
- if ( c[ns].c_addr != NULL ) {
- free( c[ns].c_addr );
- }
- c[ns].c_addr = strdup( inet_ntoa(
- from.sin_addr ) );
- if ( c[ns].c_domain != NULL ) {
- free( c[ns].c_domain );
- }
- c[ns].c_domain = strdup( hp == NULL ? "" :
- hp->h_name );
- /* normalize the domain */
- for ( s = c[ns].c_domain; *s; s++ ) {
- *s = TOLOWER( *s );
+ /* normalize the domain */
+ for ( s = client_name; *s; s++ ) {
+ *s = TOLOWER( *s );
+ }
+
+ } else {
+ client_name = NULL;
}
+#else
+ client_name = NULL;
+#endif
+
} else {
+ client_name = NULL;;
+ client_addr = NULL;
+ }
+
+#ifdef HAVE_TCPD
+ if(!hosts_ctl("slapd", client_name, client_addr,
+ STRING_UNKNOWN))
+ {
+ /* DENY ACCESS */
Statslog( LDAP_DEBUG_STATS,
- "conn=%d fd=%d connection from unknown\n",
- c[ns].c_connid, ns, 0, 0, 0 );
+ "conn=%d fd=%d connection from %s (%s) denied.\n",
+ c[ns].c_connid, ns,
+ client_name == NULL ? "unknown" : client_name,
+ client_addr == NULL ? "unknown" : client_addr,
+ 0 );
+
+ close(ns);
+ pthread_mutex_unlock( &new_conn_mutex );
+ continue;
+ }
+#endif /* HAVE_TCPD */
+
+ Statslog( LDAP_DEBUG_STATS,
+ "conn=%d fd=%d connection from %s (%s) accepted.\n",
+ c[ns].c_connid, ns,
+ client_name == NULL ? "unknown" : client_name,
+ client_addr == NULL ? "unknown" : client_addr,
+ 0 );
+
+ if ( c[ns].c_addr != NULL ) {
+ free( c[ns].c_addr );
+ }
+ c[ns].c_addr = strdup( client_addr );
+
+ if ( c[ns].c_domain != NULL ) {
+ free( c[ns].c_domain );
}
+
+ c[ns].c_domain = strdup( client_name == NULL
+ ? "" : client_name );
+
pthread_mutex_lock( &c[ns].c_dnmutex );
if ( c[ns].c_dn != NULL ) {
free( c[ns].c_dn );
0 );
be_close();
Debug( LDAP_DEBUG_ANY, "slapd stopping\n", 0, 0, 0 );
+ return NULL;
}
static void
-set_shutdown()
+set_shutdown( int sig )
{
- Debug( LDAP_DEBUG_ANY, "slapd got shutdown signal\n", 0, 0, 0 );
+ Debug( LDAP_DEBUG_ANY, "slapd got shutdown signal %d\n", sig, 0, 0 );
slapd_shutdown = 1;
+#ifdef HAVE_LINUX_THREADS
+ /*
+ * LinuxThreads are implemented using SIGUSR1/USR2,
+ * so we'll use SIGSTKFLT and SIGUNUSED
+ */
+ pthread_kill( listener_tid, SIGSTKFLT );
+ (void) SIGNAL( SIGUNUSED, set_shutdown );
+#else /* !linux */
pthread_kill( listener_tid, SIGUSR1 );
- (void) SIGNAL( SIGUSR2, (void *) set_shutdown );
- (void) SIGNAL( SIGTERM, (void *) set_shutdown );
- (void) SIGNAL( SIGHUP, (void *) set_shutdown );
+ (void) SIGNAL( SIGUSR2, set_shutdown );
+#endif /* !linux */
+ (void) SIGNAL( SIGTERM, set_shutdown );
+ (void) SIGNAL( SIGINT, set_shutdown );
+ (void) SIGNAL( SIGHUP, set_shutdown );
}
static void
-do_nothing()
+do_nothing( int sig )
{
- Debug( LDAP_DEBUG_TRACE, "slapd got SIGUSR1\n", 0, 0, 0 );
- (void) SIGNAL( SIGUSR1, (void *) do_nothing );
+ Debug( LDAP_DEBUG_TRACE, "slapd got do_nothing signal %d\n", sig, 0, 0 );
+#ifdef HAVE_LINUX_THREADS
+ /*
+ * LinuxThreads are implemented using SIGUSR1/USR2,
+ * so we'll use SIGSTKFLT and SIGUNUSED
+ */
+ (void) SIGNAL( SIGSTKFLT, do_nothing );
+#else /* !linux */
+ (void) SIGNAL( SIGUSR1, do_nothing );
+#endif /* !linux */
}
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include "slap.h"
-extern Backend *select_backend();
+#include <ac/string.h>
+#include <ac/socket.h>
-extern char *default_referral;
+#include "slap.h"
void
do_delete(
return;
}
+ /* alias suffix if approp */
+ dn = suffixAlias ( dn, op, be );
+
/*
* do the delete if 1 && (2 || 3)
* 1) there is a delete function implemented in this backend;
+++ /dev/null
-/*
- * Copyright (c) 1990, 1994 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-#include <stdio.h>
-#include <sys/types.h>
-#ifdef SVR4
-#include <sys/stat.h>
-#endif /* svr4 */
-#include <fcntl.h>
-#include <sys/file.h>
-#include <sys/ioctl.h>
-#include <signal.h>
-#include "portable.h"
-
-#ifdef USE_SYSCONF
-#include <unistd.h>
-#endif /* USE_SYSCONF */
-
-
-detach()
-{
- int i, sd, nbits;
-#ifdef LDAP_DEBUG
- extern int ldap_debug;
-#endif
-
-#ifdef USE_SYSCONF
- nbits = sysconf( _SC_OPEN_MAX );
-#else /* USE_SYSCONF */
- nbits = getdtablesize();
-#endif /* USE_SYSCONF */
-
-#ifdef LDAP_DEBUG
- if ( ldap_debug == 0 ) {
-#endif
- for ( i = 0; i < 5; i++ ) {
-#if defined( sunos5 ) && defined( THREAD_SUNOS5_LWP )
- switch ( fork1() ) {
-#else
- switch ( fork() ) {
-#endif
- case -1:
- sleep( 5 );
- continue;
-
- case 0:
- break;
-
- default:
- _exit( 0 );
- }
- break;
- }
-
-/*
- for ( i = 3; i < nbits; i++ )
- close( i );
-*/
-
- (void) chdir( "/" );
-
- if ( (sd = open( "/dev/null", O_RDWR )) == -1 ) {
- perror( "/dev/null" );
- exit( 1 );
- }
- if ( isatty( 0 ) )
- (void) dup2( sd, 0 );
- if ( isatty( 1 ) )
- (void) dup2( sd, 1 );
- if ( isatty(2) )
- (void) dup2( sd, 2 );
- close( sd );
-
-#ifdef USE_SETSID
- setsid();
-#else /* USE_SETSID */
- if ( (sd = open( "/dev/tty", O_RDWR )) != -1 ) {
- (void) ioctl( sd, TIOCNOTTY, NULL );
- (void) close( sd );
- }
-#endif /* USE_SETSID */
-#ifdef LDAP_DEBUG
- }
-#endif
-
- (void) SIGNAL( SIGPIPE, SIG_IGN );
-}
/* dn.c - routines for dealing with distinguished names */
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
#include "portable.h"
-#include "slap.h"
-static char **dn_explode();
+#include <stdio.h>
+
+#include <ac/ctype.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
+#include "slap.h"
#define DNSEPARATOR(c) (c == ',' || c == ';')
#define SEPARATOR(c) (c == ',' || c == ';' || c == '+')
}
}
- return( NULL );
+ return( strdup("") );
}
/*
#include "slap.h"
-void entry_free();
-char *entry2str();
-
static unsigned char *ebuf; /* buf returned by entry2str */
static unsigned char *ecur; /* pointer to end of currently used ebuf */
static int emaxsize;/* max size of ebuf */
if ( strcasecmp( type, "dn" ) == 0 ) {
if ( e->e_dn != NULL ) {
Debug( LDAP_DEBUG_ANY,
- "str2entry: entry %d has multiple dns \"%s\" and \"%s\" (second ignored)\n",
+ "str2entry: entry %lu has multiple dns \"%s\" and \"%s\" (second ignored)\n",
e->e_id, e->e_dn, value );
continue;
}
/* check to make sure there was a dn: line */
if ( e->e_dn == NULL ) {
- Debug( LDAP_DEBUG_ANY, "str2entry: entry %d has no dn\n",
+ Debug( LDAP_DEBUG_ANY, "str2entry: entry %lu has no dn\n",
e->e_id, 0, 0 );
entry_free( e );
return( NULL );
}
- Debug( LDAP_DEBUG_TRACE, "<= str2entry 0x%x\n", e, 0, 0 );
+ Debug(LDAP_DEBUG_TRACE, "<= str2entry 0x%lx\n", (unsigned long)e, 0,0);
return( e );
}
{
return pthread_rdwr_init_np(&e->e_rdwr, NULL);
}
-
#include "slap.h"
-static int get_filter_list();
-static int get_substring_filter();
-
-extern int get_ava();
+static int get_filter_list(Connection *conn, BerElement *ber, Filter **f, char **fstr);
+static int get_substring_filter(Connection *conn, BerElement *ber, Filter *f, char **fstr);
int
get_filter( Connection *conn, BerElement *ber, Filter **filt, char **fstr )
break;
default:
- Debug( LDAP_DEBUG_ANY, "unknown filter type %d\n", f->f_choice,
- 0, 0 );
+ Debug( LDAP_DEBUG_ANY, "unknown filter type %lu\n",
+ f->f_choice, 0, 0 );
err = LDAP_PROTOCOL_ERROR;
break;
}
break;
default:
- Debug( LDAP_DEBUG_ANY, "unknown filter type %d\n", f->f_choice,
- 0, 0 );
+ Debug( LDAP_DEBUG_ANY, "unknown filter type %lu\n",
+ f->f_choice, 0, 0 );
break;
}
free( f );
break;
default:
- fprintf( stderr, "unknown type %d", f->f_choice );
+ fprintf( stderr, "unknown type %lu", f->f_choice );
break;
}
}
#include "slap.h"
-extern Attribute *attr_find();
-extern char *first_word();
-extern char *next_word();
-extern char *phonetic();
-
-static int test_filter_list();
-static int test_substring_filter();
-static int test_ava_filter();
-static int test_approx_filter();
-static int test_presence_filter();
+static int test_filter_list(Backend *be, Connection *conn, Operation *op, Entry *e, Filter *flist, int ftype);
+static int test_substring_filter(Backend *be, Connection *conn, Operation *op, Entry *e, Filter *f);
+static int test_ava_filter(Backend *be, Connection *conn, Operation *op, Entry *e, Ava *ava, int type);
+static int test_approx_filter(Backend *be, Connection *conn, Operation *op, Entry *e, Ava *ava);
+static int test_presence_filter(Backend *be, Connection *conn, Operation *op, Entry *e, char *type);
/*
* test_filter - test a filter against a single entry.
break;
default:
- Debug( LDAP_DEBUG_ANY, " unknown filter type %d\n",
+ Debug( LDAP_DEBUG_ANY, " unknown filter type %lu\n",
f->f_choice, 0, 0 );
rc = -1;
}
/* init.c - initialize various things */
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
#include "portable.h"
#include "slap.h"
-extern pthread_mutex_t active_threads_mutex;
-extern pthread_mutex_t new_conn_mutex;
-extern pthread_mutex_t currenttime_mutex;
-extern pthread_mutex_t entry2str_mutex;
-extern pthread_mutex_t replog_mutex;
-extern pthread_mutex_t ops_mutex;
-extern pthread_mutex_t num_sent_mutex;
-#ifndef sunos5
-extern pthread_mutex_t regex_mutex;
-#endif
-
-init()
+void
+init( void )
{
pthread_mutex_init( &active_threads_mutex, pthread_mutexattr_default );
pthread_mutex_init( &new_conn_mutex, pthread_mutexattr_default );
pthread_mutex_init( &replog_mutex, pthread_mutexattr_default );
pthread_mutex_init( &ops_mutex, pthread_mutexattr_default );
pthread_mutex_init( &num_sent_mutex, pthread_mutexattr_default );
-#ifndef sunos5
- pthread_mutex_init( ®ex_mutex, pthread_mutexattr_default );
-#endif
}
#include <stdio.h>
+#include <ac/string.h>
#include <ac/socket.h>
#include <ac/time.h>
#include <ac/unistd.h>
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/time.h>
+#include <ac/unistd.h>
-#include "slap.h"
#include "ldapconfig.h"
+#include "slap.h"
#include "lutil.h" /* Get lutil_detach() */
-extern void slapd_daemon();
-extern int lber_debug;
-
-extern char Versionstr[];
-
/*
* read-only global variables or variables only written by the listener
pthread_mutex_t replog_mutex;
static void
-usage( name )
- char *name;
+usage( char *name )
{
fprintf( stderr, "usage: %s [-d ?|debuglevel] [-f configfile] [-p portnumber] [-s sysloglevel]\n", name );
}
int
-main( argc, argv )
- int argc;
- char **argv;
+main( int argc, char **argv )
{
int i;
int inetd = 0;
char *myname;
Backend *be = NULL;
FILE *fp = NULL;
- extern char *optarg;
configfile = SLAPD_DEFAULT_CONFIGFILE;
port = LDAP_PORT;
!= LDAP_TAG_MSGID ) {
/* log and send error */
Debug( LDAP_DEBUG_ANY,
- "ber_get_int returns 0x%x\n", tag, 0, 0 );
+ "ber_get_int returns 0x%lx\n", tag, 0, 0 );
return 1;
}
== LBER_ERROR ) {
/* log, close and send error */
Debug( LDAP_DEBUG_ANY,
- "ber_peek_tag returns 0x%x\n", tag, 0, 0 );
+ "ber_peek_tag returns 0x%lx\n", tag, 0, 0 );
ber_free( &ber, 1 );
close( c.c_sb.sb_sd );
c.c_sb.sb_sd = -1;
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <time.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include "slap.h"
-extern Backend *select_backend();
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+
+#include "slap.h"
-extern char *default_referral;
-extern time_t currenttime;
-extern pthread_mutex_t currenttime_mutex;
-extern int global_lastmod;
+static void modlist_free(LDAPMod *mods);
+static void add_lastmods(Operation *op, LDAPMod **mods);
-static void modlist_free();
-static void add_lastmods();
void
do_modify(
return;
}
+ /* alias suffix if approp */
+ dn = suffixAlias ( dn, op, be );
+
/*
* do the modify if 1 && (2 || 3)
* 1) there is a modify function implemented in this backend;
*/
if ( be->be_modify != NULL ) {
/* do the update here */
- if ( be->be_updatedn == NULL || strcasecmp( be->be_updatedn,
- op->o_dn ) == 0 ) {
- if ( (be->be_lastmod == ON || be->be_lastmod == 0 &&
- global_lastmod == ON) && be->be_updatedn == NULL ) {
+ if ( be->be_updatedn == NULL ||
+ strcasecmp( be->be_updatedn, op->o_dn ) == 0 ) {
+
+ if ( (be->be_lastmod == ON || ( be->be_lastmod == UNDEFINED &&
+ global_lastmod == ON ) ) && be->be_updatedn == NULL ) {
add_lastmods( op, &mods );
}
- if ( (*be->be_modify)( be, conn, op, odn, mods )
- == 0 ) {
+ if ( (*be->be_modify)( be, conn, op, odn, mods ) == 0 ) {
replog( be, LDAP_REQ_MODIFY, dn, mods, 0 );
}
static void
add_lastmods( Operation *op, LDAPMod **mods )
{
- char buf[20];
+ char buf[22];
struct berval bv;
struct berval *bvals[2];
LDAPMod **m;
/* remove any attempts by the user to modify these attrs */
for ( m = mods; *m != NULL; m = &(*m)->mod_next ) {
- if ( strcasecmp( (*m)->mod_type, "modifytimestamp" ) == 0
- || strcasecmp( (*m)->mod_type, "modifiersname" ) == 0 ) {
- tmp = *m;
- *m = (*m)->mod_next;
- free( tmp->mod_type );
- if ( tmp->mod_bvalues != NULL ) {
- ber_bvecfree( tmp->mod_bvalues );
- }
- free( tmp );
- }
- }
+ if ( strcasecmp( (*m)->mod_type, "modifytimestamp" ) == 0 ||
+ strcasecmp( (*m)->mod_type, "modifiersname" ) == 0 ||
+ strcasecmp( (*m)->mod_type, "createtimestamp" ) == 0 ||
+ strcasecmp( (*m)->mod_type, "creatorsname" ) == 0 ) {
+
+ Debug( LDAP_DEBUG_TRACE,
+ "add_lastmods: found lastmod attr: %s\n",
+ (*m)->mod_type, 0, 0 );
+ tmp = *m;
+ *m = (*m)->mod_next;
+ free( tmp->mod_type );
+ if ( tmp->mod_bvalues != NULL ) {
+ ber_bvecfree( tmp->mod_bvalues );
+ }
+ free( tmp );
+ if (!*m)
+ break;
+ }
+ }
if ( op->o_dn == NULL || op->o_dn[0] == '\0' ) {
bv.bv_val = "NULLDN";
*mods = tmp;
pthread_mutex_lock( ¤ttime_mutex );
- ltm = localtime( ¤ttime );
- strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm );
+#ifndef LDAP_LOCALTIME
+ ltm = gmtime( ¤ttime );
+ strftime( buf, sizeof(buf), "%Y%m%d%H%M%SZ", ltm );
+#else
+ ltm = localtime( ¤ttime );
+ strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm );
+#endif
pthread_mutex_unlock( ¤ttime_mutex );
bv.bv_val = buf;
bv.bv_len = strlen( bv.bv_val );
tmp = (LDAPMod *) ch_calloc( 1, sizeof(LDAPMod) );
tmp->mod_type = strdup( "modifytimestamp" );
tmp->mod_op = LDAP_MOD_REPLACE;
- tmp->mod_bvalues = (struct berval **) ch_calloc( 1,
- 2 * sizeof(struct berval *) );
+ tmp->mod_bvalues = (struct berval **) ch_calloc( 1, 2 * sizeof(struct berval *) );
tmp->mod_bvalues[0] = ber_bvdup( &bv );
tmp->mod_next = *mods;
*mods = tmp;
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include "slap.h"
-extern Backend *select_backend();
+#include <ac/socket.h>
+#include <ac/string.h>
-extern char *default_referral;
+#include "slap.h"
void
do_modrdn(
#include <ac/string.h>
#include <ac/time.h>
-#include "slap.h"
#include "ldapconfig.h"
+#include "slap.h"
#if defined( SLAPD_MONITOR_DN )
-extern int nbackends;
-extern Backend *backends;
-extern int active_threads;
-extern int dtblsize;
-extern Connection *c;
-extern long ops_initiated;
-extern long ops_completed;
-extern long num_entries_sent;
-extern long num_bytes_sent;
-extern time_t currenttime;
-extern time_t starttime;
-extern int num_conns;
-
-extern pthread_mutex_t new_conn_mutex;
-extern pthread_mutex_t currenttime_mutex;
-
-extern char Versionstr[];
-
void
monitor_info( Connection *conn, Operation *op )
{
pthread_mutex_unlock( ¤ttime_mutex );
pthread_mutex_lock( &c[i].c_dnmutex );
- sprintf( buf, "%d : %s : %ld : %ld : %s : %s%s", i,
+ sprintf( buf, "%d : %s : %d : %d : %s : %s%s", i,
buf2, c[i].c_opsinitiated, c[i].c_opscompleted,
c[i].c_dn ? c[i].c_dn : "NULLDN",
c[i].c_gettingber ? "r" : "",
/* operation.c - routines to deal with pending ldap operations */
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
#include "slap.h"
-extern time_t currenttime;
-extern pthread_mutex_t currenttime_mutex;
void
op_free( Operation *op )
; /* NULL */
if ( *tmp == NULL ) {
- Debug( LDAP_DEBUG_ANY, "op_delete: can't find op %d\n",
+ Debug( LDAP_DEBUG_ANY, "op_delete: can't find op %ld\n",
op->o_msgid, 0, 0 );
return;
}
int be_issuffix LDAP_P(( Backend *be, char *suffix ));
int be_isroot LDAP_P(( Backend *be, char *dn ));
int be_isroot_pw LDAP_P(( Backend *be, char *dn, struct berval *cred ));
-void be_close LDAP_P(());
+void be_close LDAP_P(( void ));
/*
* ch_malloc.c
*/
char *suffixAlias LDAP_P(( char *dn, Operation *op, Backend *be ));
+/*
+ * Other...
+ */
+
+extern char **g_argv;
+extern char *default_referral;
+extern char *replogfile;
+extern char Versionstr[];
+extern int active_threads;
+extern int defsize;
+extern int deftime;
+extern int g_argc;
+extern int global_default_access;
+extern int global_lastmod;
+extern int global_schemacheck;
+extern int lber_debug;
+extern int ldap_syslog;
+extern int num_conns;
+extern int slapd_shutdown;
+extern long num_bytes_sent;
+extern long num_entries_sent;
+extern long ops_completed;
+extern long ops_initiated;
+extern pthread_mutex_t active_threads_mutex;
+extern pthread_mutex_t currenttime_mutex;
+extern pthread_mutex_t entry2str_mutex;
+extern pthread_mutex_t new_conn_mutex;
+extern pthread_mutex_t num_sent_mutex;
+extern pthread_mutex_t ops_mutex;
+extern pthread_mutex_t replog_mutex;
+extern pthread_t listener_tid;
+extern struct acl *global_acl;
+extern struct objclass *global_oc;
+extern time_t currenttime;
+
+extern int be_group LDAP_P((Backend *be, char *bdn, char *edn, char *objectclassValue, char *groupattrName));
+extern void init LDAP_P((void));
+extern void be_unbind LDAP_P((Connection *conn, Operation *op));
+extern void config_info LDAP_P((Connection *conn, Operation *op));
+extern void do_abandon LDAP_P((Connection *conn, Operation *op));
+extern void do_add LDAP_P((Connection *conn, Operation *op));
+extern void do_bind LDAP_P((Connection *conn, Operation *op));
+extern void do_compare LDAP_P((Connection *conn, Operation *op));
+extern void do_delete LDAP_P((Connection *conn, Operation *op));
+extern void do_modify LDAP_P((Connection *conn, Operation *op));
+extern void do_modrdn LDAP_P((Connection *conn, Operation *op));
+extern void do_search LDAP_P((Connection *conn, Operation *op));
+extern void do_unbind LDAP_P((Connection *conn, Operation *op));
+extern void * slapd_daemon LDAP_P((void *port));
+
+extern int nbackends;
+extern Backend *backends;
+extern int send_search_entry LDAP_P((Backend *be, Connection *conn, Operation *op, Entry *e, char **attrs, int attrsonly));
+extern int str2result LDAP_P(( char *s, int *code, char **matched, char **info ));
+
+#if defined( SLAPD_MONITOR_DN )
+extern Connection *c;
+extern int dtblsize;
+extern time_t starttime;
+#endif
+
+#ifdef SLAPD_LDBM
+extern int ldbm_back_bind LDAP_P((Backend *be, Connection *c, Operation *o, char *dn, int method, struct berval *cred ));
+extern void ldbm_back_unbind LDAP_P((Backend *be, Connection *c, Operation *o ));
+extern int ldbm_back_search LDAP_P((Backend *be, Connection *c, Operation *o, char *base, int scope, int deref, int slimit, int tlimit, Filter *f, char *filterstr, char **attrs, int attrsonly));
+extern int ldbm_back_compare LDAP_P((Backend *be, Connection *c, Operation *o, char *dn, Ava *ava));
+extern int ldbm_back_modify LDAP_P((Backend *be, Connection *c, Operation *o, char *dn, LDAPMod *m));
+extern int ldbm_back_modrdn LDAP_P((Backend *be, Connection *c, Operation *o, char *dn, char *newrdn, int deleteoldrdn ));
+extern int ldbm_back_add LDAP_P((Backend *be, Connection *c, Operation *o, Entry *e));
+extern int ldbm_back_delete LDAP_P((Backend *be, Connection *c, Operation *o, char *dn));
+extern void ldbm_back_abandon LDAP_P((Backend *be, Connection *c, Operation *o, int msgid));
+extern void ldbm_back_config LDAP_P((Backend *be, char *fname, int lineno, int argc, char **argv ));
+extern void ldbm_back_init LDAP_P((Backend *be));
+extern void ldbm_back_close LDAP_P((Backend *be));
+extern int ldbm_back_group LDAP_P((Backend *be, char *bdn, char *edn, char *objectclassValue, char *groupattrName ));
+#endif
+
+#ifdef SLAPD_PASSWD
+extern int passwd_back_search LDAP_P((Backend *be, Connection *c, Operation *o, char *base, int scope, int deref, int slimit, int tlimit, Filter *f, char *filterstr, char **attrs, int attrsonly));
+extern void passwd_back_config LDAP_P((Backend *be, char *fname, int lineno, int argc, char **argv ));
+#endif
+
+#ifdef SLAPD_SHELL
+extern int shell_back_bind LDAP_P((Backend *be, Connection *c, Operation *o, char *dn, int method, struct berval *cred ));
+extern void shell_back_unbind LDAP_P((Backend *be, Connection *c, Operation *o ));
+extern int shell_back_search LDAP_P((Backend *be, Connection *c, Operation *o, char *base, int scope, int deref, int slimit, int tlimit, Filter *f, char *filterstr, char **attrs, int attrsonly));
+extern int shell_back_compare LDAP_P((Backend *be, Connection *c, Operation *o, char *dn, Ava *ava));
+extern int shell_back_modify LDAP_P((Backend *be, Connection *c, Operation *o, char *dn, LDAPMod *m));
+extern int shell_back_modrdn LDAP_P((Backend *be, Connection *c, Operation *o, char *dn, char *newrdn, int deleteoldrdn ));
+extern int shell_back_add LDAP_P((Backend *be, Connection *c, Operation *o, Entry *e));
+extern int shell_back_delete LDAP_P((Backend *be, Connection *c, Operation *o, char *dn));
+extern void shell_back_abandon LDAP_P((Backend *be, Connection *c, Operation *o, int msgid));
+extern void shell_back_config LDAP_P((Backend *be, char *fname, int lineno, int argc, char **argv ));
+extern void shell_back_init LDAP_P((Backend *be));
+#endif
+
#endif /* _proto_slap */
#include <stdio.h>
#include <ac/string.h>
+#include <ac/ctype.h>
#include <ac/socket.h>
#include <sys/file.h>
#include "slap.h"
-extern pthread_mutex_t replog_mutex;
-extern pthread_mutex_t entry2str_mutex;
-extern time_t currenttime;
-extern char *replogfile;
-
-extern FILE *lock_fopen();
-extern int lock_fclose();
-extern char *entry2str();
void
replog(
/* result.c - routines to send ldap results, errors, and referrals */
-#include <stdio.h>
-#include <string.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <errno.h>
-#include <signal.h>
#include "portable.h"
-#include "slap.h"
-#ifndef SYSERRLIST_IN_STDIO
-extern int sys_nerr;
-extern char *sys_errlist[];
-#endif
-extern int active_threads;
-extern pthread_mutex_t active_threads_mutex;
-extern pthread_mutex_t new_conn_mutex;
-extern pthread_t listener_tid;
-extern struct acl *acl_get_applicable();
-extern long num_entries_sent;
-extern long num_bytes_sent;
-extern pthread_mutex_t num_sent_mutex;
+#include <stdio.h>
+
+#include <ac/errno.h>
+#include <ac/signal.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/time.h>
+#include <ac/unistd.h> /* get close() */
+
+#include "slap.h"
-void close_connection();
static void
send_ldap_result2(
int rc, sd;
unsigned long tag, bytes;
+ if ( err == LDAP_PARTIAL_RESULTS && (text == NULL || *text == '\0') )
+ err = LDAP_NO_SUCH_OBJECT;
+
Debug( LDAP_DEBUG_TRACE, "send_ldap_result %d:%s:%s\n", err, matched ?
matched : "", text ? text : "" );
break;
}
-#ifdef COMPAT30
+#ifdef LDAP_COMPAT30
if ( (ber = ber_alloc_t( conn->c_version == 30 ? 0 : LBER_USE_DER ))
== NULLBER ) {
#else
return;
}
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
if ( op->o_cldap ) {
rc = ber_printf( ber, "{is{t{ess}}}", op->o_msgid, "", tag,
err, matched ? matched : "", text ? text : "" );
} else
#endif
-#ifdef COMPAT30
+#ifdef LDAP_COMPAT30
if ( conn->c_version == 30 ) {
rc = ber_printf( ber, "{it{{ess}}}", op->o_msgid, tag, err,
matched ? matched : "", text ? text : "" );
pthread_mutex_lock( &active_threads_mutex );
active_threads--;
conn->c_writewaiter = 1;
+
+#ifdef HAVE_LINUX_THREADS
+ pthread_kill( listener_tid, SIGSTKFLT );
+#else /* !linux */
pthread_kill( listener_tid, SIGUSR1 );
+#endif /* !linux */
+
pthread_cond_wait( &conn->c_wcv, &active_threads_mutex );
pthread_mutex_unlock( &active_threads_mutex );
char *text
)
{
-#ifdef CLDAP
+#ifdef LDAP_CONNECTIONLESS
if ( op->o_cldap ) {
SAFEMEMCPY( (char *)conn->c_sb.sb_useaddr, &op->o_clientaddr,
sizeof( struct sockaddr ));
Attribute *a;
int i, rc, bytes, sd;
struct acl *acl;
+ char *edn;
Debug( LDAP_DEBUG_TRACE, "=> send_search_entry (%s)\n", e->e_dn, 0, 0 );
return( 1 );
}
-#ifdef COMPAT30
+ edn = dn_normalize_case( strdup( e->e_dn ) );
+
+#ifdef LDAP_COMPAT30
if ( (ber = ber_alloc_t( conn->c_version == 30 ? 0 : LBER_USE_DER ))
- == NULLBER ) {
+ == NULLBER )
#else
- if ( (ber = der_alloc()) == NULLBER ) {
+ if ( (ber = der_alloc()) == NULLBER )
#endif
+ {
Debug( LDAP_DEBUG_ANY, "ber_alloc failed\n", 0, 0, 0 );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
- "ber_alloc" );
- return( 1 );
+ "ber_alloc" );
+ goto error_return;
}
-#ifdef COMPAT30
+#ifdef LDAP_COMPAT30
if ( conn->c_version == 30 ) {
rc = ber_printf( ber, "{it{{s{", op->o_msgid,
LDAP_RES_SEARCH_ENTRY, e->e_dn );
} else
#endif
+ {
rc = ber_printf( ber, "{it{s{", op->o_msgid,
- LDAP_RES_SEARCH_ENTRY, e->e_dn );
+ LDAP_RES_SEARCH_ENTRY, e->e_dn );
+ }
if ( rc == -1 ) {
Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 );
ber_free( ber, 1 );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, NULL,
"ber_printf dn" );
- return( 1 );
+ goto error_return;
}
for ( a = e->e_attrs; a != NULL; a = a->a_next ) {
+ regmatch_t matches[MAXREMATCHES];
+
if ( attrs != NULL && ! charray_inlist( attrs, a->a_type ) ) {
continue;
}
- acl = acl_get_applicable( be, op, e, a->a_type );
+ /* the lastmod attributes are ignored by ACL checking */
+ if ( strcasecmp( a->a_type, "modifiersname" ) == 0 ||
+ strcasecmp( a->a_type, "modifytimestamp" ) == 0 ||
+ strcasecmp( a->a_type, "creatorsname" ) == 0 ||
+ strcasecmp( a->a_type, "createtimestamp" ) == 0 )
+ {
+ Debug( LDAP_DEBUG_ACL, "LASTMOD attribute: %s access DEFAULT\n",
+ a->a_type, 0, 0 );
+ acl = NULL;
+ } else {
+ acl = acl_get_applicable( be, op, e, a->a_type, edn,
+ MAXREMATCHES, matches );
+ }
- if ( ! acl_access_allowed( acl, be, conn, e, NULL, op,
- ACL_READ ) ) {
+ if ( ! acl_access_allowed( acl, be, conn, e, NULL, op, ACL_READ,
+ edn, matches ) )
+ {
continue;
}
ber_free( ber, 1 );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
NULL, "ber_printf type" );
- return( 1 );
+ goto error_return;
}
if ( ! attrsonly ) {
for ( i = 0; a->a_vals[i] != NULL; i++ ) {
- if ( a->a_syntax & SYNTAX_DN &&
- ! acl_access_allowed( acl, be, conn, e,
- a->a_vals[i], op, ACL_READ ) )
+ if ( a->a_syntax & SYNTAX_DN &&
+ ! acl_access_allowed( acl, be, conn, e, a->a_vals[i], op,
+ ACL_READ, edn, matches) )
{
continue;
}
send_ldap_result( conn, op,
LDAP_OPERATIONS_ERROR, NULL,
"ber_printf value" );
- return( 1 );
+ goto error_return;
}
}
}
ber_free( ber, 1 );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
NULL, "ber_printf type end" );
- return( 1 );
+ goto error_return;
}
}
-#ifdef COMPAT30
+ free(edn);
+
+#ifdef LDAP_COMPAT30
if ( conn->c_version == 30 ) {
rc = ber_printf( ber, "}}}}" );
} else
Debug( LDAP_DEBUG_TRACE, "<= send_search_entry\n", 0, 0, 0 );
return( rc );
+
+error_return:;
+ free(edn);
+ return( 1 );
}
int
/* schema.c - routines to enforce schema definitions */
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include "slap.h"
-extern Attribute *attr_find();
-extern char **str2charray();
-extern void charray_merge();
+#include <ac/string.h>
+#include <ac/socket.h>
-extern struct objclass *global_oc;
-extern int global_schemacheck;
+#include "slap.h"
-static struct objclass *oc_find();
-static int oc_check_required();
-static int oc_check_allowed();
+static struct objclass *oc_find(char *ocname);
+static int oc_check_required(Entry *e, char *ocname);
+static int oc_check_allowed(char *type, struct berval **ocl);
/*
* oc_check - check that entry e conforms to the schema required by
return( 0 );
}
+ /* check for empty oc_required */
+ if(oc->oc_required == NULL) {
+ return( 0 );
+ }
+
/* for each required attribute */
for ( i = 0; oc->oc_required[i] != NULL; i++ ) {
/* see if it's in the entry */
/* if we know about the oc */
if ( (oc = oc_find( ocl[i]->bv_val )) != NULL ) {
/* does it require the type? */
- for ( j = 0; oc->oc_required[j] != NULL; j++ ) {
+ for ( j = 0; oc->oc_required != NULL &&
+ oc->oc_required[j] != NULL; j++ ) {
if ( strcasecmp( oc->oc_required[j], type )
== 0 ) {
return( 0 );
}
}
/* does it allow the type? */
- for ( j = 0; oc->oc_allowed[j] != NULL; j++ ) {
+ for ( j = 0; oc->oc_allowed != NULL &&
+ oc->oc_allowed[j] != NULL; j++ ) {
if ( strcasecmp( oc->oc_allowed[j], type )
== 0 || strcmp( oc->oc_allowed[j], "*" )
== 0 )
#ifdef LDAP_DEBUG
-static
+static void
oc_print( struct objclass *oc )
{
int i;
/* schemaparse.c - routines to parse config file objectclass definitions */
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include "slap.h"
-extern char **str2charray();
-extern void charray_merge();
+#include <ac/string.h>
+#include <ac/socket.h>
+
+#include "slap.h"
struct objclass *global_oc;
int global_schemacheck;
-static void oc_usage();
+static void oc_usage(void);
void
parse_oc(
}
static void
-oc_usage()
+oc_usage( void )
{
fprintf( stderr, "<oc clause> ::= objectclass <ocname>\n" );
fprintf( stderr, " [ requires <attrlist> ]\n" );
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include "slap.h"
-#include "ldapconfig.h"
-extern int get_filter();
-extern Backend *select_backend();
+#include <ac/string.h>
+#include <ac/socket.h>
+
+#include "ldapconfig.h"
+#include "slap.h"
-extern char *default_referral;
void
-do_search( conn, op )
- Connection *conn; /* where to send results */
- Operation *op; /* info about the op to which we're responding */
+do_search(
+ Connection *conn, /* where to send results */
+ Operation *op /* info about the op to which we're responding */
+)
{
int i, err;
int scope, deref, attrsonly;
return;
}
+ /* translate the base if it matches an aliased base part */
+ base = suffixAlias ( base, op, be );
+
/* actually do the search and send the result(s) */
if ( be->be_search != NULL ) {
(*be->be_search)( be, conn, op, base, scope, deref, sizelimit,
*/
-#include <sys/types.h>
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
#include <stdlib.h>
+
+#include <ac/string.h>
+#include <ac/unistd.h>
+
#include <pwd.h>
-#include <varargs.h>
+
#include <lber.h>
#include <ldap.h>
+
#include "shellutil.h"
#include "passwd-shell.h"
-#ifdef LDAP_DEBUG
-void debug_printf();
-#else /* LDAP_DEBUG */
-#define debug_printf()
-#endif /* LDAP_DEBUG */
-
-
-static void pwdfile_search( struct ldop *op, FILE *ofp );
-static struct ldentry *pw2entry( struct ldop *op, struct passwd *pw );
+static void pwdfile_search LDAP_P(( struct ldop *op, FILE *ofp ));
+static struct ldentry *pw2entry LDAP_P(( struct ldop *op, struct passwd *pw ));
static char tmpbuf[ MAXLINELEN * 2 ];
+int
main( int argc, char **argv )
{
int c, errflg;
struct ldop op;
- extern int optind;
- extern char *optarg;
if (( progname = strrchr( argv[ 0 ], '/' )) == NULL ) {
progname = estrdup( argv[ 0 ] );
*/
-#include <sys/types.h>
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
+
#include <stdlib.h>
+#include <ac/stdarg.h>
+
#include <pwd.h>
-#include <varargs.h>
+
+#include <ac/ctype.h>
+#include <ac/string.h>
+
#include <lber.h>
#include <ldap.h>
#include "shellutil.h"
/* VARARGS */
void
-debug_printf( va_alist /* char *fmt, args... */ )
+debug_printf
+#ifdef STDC_HEADERS
+ ( char *fmt, ... )
+#else
+ ( va_alist )
va_dcl
+#endif
{
- char *fmt;
va_list ap;
-
- if ( debugflg ) {
- va_start( ap );
- fmt = va_arg( ap, char * );
- fprintf( stderr, "%s: ", progname );
- vfprintf( stderr, fmt, ap );
- va_end( ap );
- }
+#ifndef STDC_HEADERS
+ char *fmt;
+#endif
+
+ if ( debugflg ) {
+#ifdef STDC_HEADERS
+ va_start( ap, fmt );
+#else
+ va_start( ap );
+ fmt = va_arg( ap, char * );
+#endif
+ fprintf( stderr, "%s: ", progname );
+ vfprintf( stderr, fmt, ap );
+ va_end( ap );
+ }
}
is provided ``as is'' without express or implied warranty.
*/
+#ifndef SHELLUTIL_H
+#define SHELLUTIL_H
+
+#include <ldap_cdefs.h>
+
+LDAP_BEGIN_DECL
#define MAXLINELEN 512
#ifdef LDAP_DEBUG
-void debug_printf();
+void debug_printf LDAP_P((char *, ...));
#else /* LDAP_DEBUG */
#define debug_printf()
#endif /* LDAP_DEBUG */
char *ecalloc( unsigned nelem, unsigned elsize );
void *erealloc( void *s, unsigned size );
char *estrdup( char *s );
+extern void dump_ldop (struct ldop *op);
+
/*
* global variables
*/
extern int debugflg;
extern char *progname;
+
+LDAP_END_DECL
+#endif
LDAP_BEGIN_DECL
+struct op;
+struct conn;
+
/*
* represents an attribute value assertion (i.e., attr=value)
*/
* represents a "database"
*/
-typedef struct backend {
+typedef struct backend Backend;
+struct backend {
char **be_suffix; /* the DN suffixes of data in this backend */
char **be_suffixAlias; /* the DN suffix aliases of data in this backend */
char *be_rootdn; /* the magic "root" dn for this db */
void *be_private; /* anything the backend needs */
- IFP be_bind; /* backend bind routine */
- IFP be_unbind; /* backend unbind routine */
- IFP be_search; /* backend search routine */
- IFP be_compare; /* backend compare routine */
- IFP be_modify; /* backend modify routine */
- IFP be_modrdn; /* backend modrdn routine */
- IFP be_add; /* backend add routine */
- IFP be_delete; /* backend delete routine */
- IFP be_abandon; /* backend abandon routine */
- IFP be_config; /* backend config routine */
- IFP be_init; /* backend init routine */
- IFP be_close; /* backend close routine */
+ /* backend routines */
+ int (*be_bind) LDAP_P((Backend *be, struct conn *c, struct op *o, char *dn, int method, struct berval *cred ));
+ void (*be_unbind) LDAP_P((Backend *be, struct conn *c, struct op *o ));
+ int (*be_search) LDAP_P((Backend *be, struct conn *c, struct op *o, char *base, int scope, int deref, int slimit, int tlimit, Filter *f, char *filterstr, char **attrs, int attrsonly));
+ int (*be_compare)LDAP_P((Backend *be, struct conn *c, struct op *o, char *dn, Ava *ava));
+ int (*be_modify) LDAP_P((Backend *be, struct conn *c, struct op *o, char *dn, LDAPMod *m));
+ int (*be_modrdn) LDAP_P((Backend *be, struct conn *c, struct op *o, char *dn, char *newrdn, int deleteoldrdn ));
+ int (*be_add) LDAP_P((Backend *be, struct conn *c, struct op *o, Entry *e));
+ int (*be_delete) LDAP_P((Backend *be, struct conn *c, struct op *o, char *dn));
+ /* Bug: be_abandon in unused! */
+ void (*be_abandon)LDAP_P((Backend *be, struct conn *c, struct op *o, int msgid));
+ void (*be_config) LDAP_P((Backend *be, char *fname, int lineno, int argc, char **argv ));
+ void (*be_init) LDAP_P((Backend *be));
+ void (*be_close) LDAP_P((Backend *be));
#ifdef SLAPD_ACLGROUPS
- IFP be_group; /* backend group member test */
+ int (*be_group) LDAP_P((Backend *be, char *bdn, char *edn, char *objectclassValue, char *groupattrName ));
#endif
-} Backend;
+};
/*
* represents an operation pending from an ldap client
/* str2filter.c - parse an rfc 1588 string filter */
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/string.h>
+#include <ac/ctype.h>
+#include <ac/socket.h>
+
#include "slap.h"
-static char *find_matching_paren();
-static Filter *str2list();
-static Filter *str2simple();
-static int str2subvals();
+static char *find_matching_paren(char *s);
+static Filter *str2list(char *str, long unsigned int ftype);
+static Filter *str2simple(char *str);
+static int str2subvals(char *val, Filter *f);
Filter *
str2filter( char *str )
{
- Filter *f;
+ Filter *f = NULL;
char *end;
Debug( LDAP_DEBUG_FILTER, "str2filter \"%s\"\n", str, 0, 0 );
* given a dn (or root part), return an aliased dn if any of the
* alias suffixes match
*/
-char *suffixAlias ( dn, op, be )
- char *dn;
- Operation *op;
- Backend *be;
+char *suffixAlias (char *dn, Operation *op, Backend *be)
{
int i, dnLength;
#include <ac/ctype.h>
#include <ac/string.h>
#include <ac/time.h>
+#include <ac/unistd.h> /* get link(), unlink() */
#include <lber.h>
#include <ldap.h>
int verbose;
int not;
-static LDAP *start_ldap_search();
-static LDAP *bind_to_destination_ldap();
-static int create_tmp_files();
-static int generate_new_centroids();
-static LDAPMod **diff_centroids();
-static LDAPMod **full_centroid();
-static char **charray_add_dup();
+static LDAP *start_ldap_search(char *ldapsrcurl, char *ldapfilter, char **attrs);
+static LDAP *bind_to_destination_ldap(char *ldapsrcurl, char *ldapdesturl);
+static int create_tmp_files(char **attrs, char ***tmpfile, LDBM **ldbm);
+static int generate_new_centroids(LDAP *ld, char **attrs, LDBM *ldbm);
+static LDAPMod **diff_centroids(char *attr, LDBM oldbm, LDBM nldbm, int nentries);
+static LDAPMod **full_centroid(char *attr, LDBM ldbm, int nentries);
+static char **charray_add_dup(char ***a, int *cur, int *max, char *s);
static void usage( char *name )
{
fprintf( stderr, "\t-c size\t\tldbm cache size\n" );
}
+int
main( int argc, char **argv )
{
char *ldapfilter;
char buf[BUFSIZ];
int i, j, k, count;
char *s;
- extern int optind;
- extern char *optarg;
ldapsrcurl = NULL;
ldapdesturl = NULL;
Datum olast, nlast;
Datum lastkey, key;
Datum data;
- int rc;
LDAPMod **mods;
char **avals, **dvals;
int amax, acur, dmax, dcur;
okey.dptr != NULL && nkey.dptr != NULL; )
#endif
{
- rc = strcmp( okey.dptr, nkey.dptr );
+ int rc = strcmp( okey.dptr, nkey.dptr );
if ( rc == 0 ) {
/* value is in both places - leave it */
#include <ac/ctype.h>
#include <ac/string.h>
+#include <ac/unistd.h>
#include <quipu/commonarg.h>
#include <quipu/attrvalue.h>
#include "ldif.h"
-static int dn2ldif();
-static void de_t61();
+static int dn2ldif(PS ps, DN dn);
+static void de_t61(char *s, int t61mark);
extern FILE *lock_fopen( char *, char *, FILE ** );
extern int lock_fclose( FILE *, FILE * );
static void
-de_t61( s, t61mark )
-char *s;
-int t61mark;
+de_t61(char *s, int t61mark)
{
char *next = s;
int c, hex;
char *
-getattr( buf, sep )
-char *buf;
-char sep;
+getattr(char *buf, char sep)
{
char *val;
#define RBSIZE 255
char *
-getattr_ldif( buf )
-char *buf;
+getattr_ldif(char *buf)
{
return( getattr( buf, ':' ));
}
char *
-getattr_edb( buf )
-char *buf;
+getattr_edb(char *buf)
{
return( getattr( buf, '=' ));
}
char *
-getval( buf, sep )
-char *buf;
-char sep;
+getval(char *buf, char sep)
{
char *val;
}
char *
-getval_ldif( buf )
-char *buf;
+getval_ldif(char *buf)
{
return( getval( buf, ':' ));
}
char *
-getval_edb( buf )
-char *buf;
+getval_edb(char *buf)
{
return( getval( buf, '=' ));
}
int
-isDNsyntax( attr )
-char *attr;
+isDNsyntax(char *attr)
{
- oid_table_attr *p, *name2attr();
+ oid_table_attr *p, *name2attr(char *);
p = name2attr( attr );
if ( p == ( oid_table_attr * ) 0 ) {
void
-print_as( as, modtype, ofp )
-Attr_Sequence as;
-int modtype;
-FILE *ofp;
+print_as(Attr_Sequence as, int modtype, FILE *ofp)
{
Attr_Sequence p;
AV_Sequence av;
* is provided ``as is'' without express or implied warranty.
*/
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <dirent.h>
#include <stdlib.h>
-#include <ctype.h>
+
+#include <ac/ctype.h>
+#include <ac/errno.h>
+#include <ac/dirent.h>
+#include <ac/string.h>
+#include <ac/unistd.h>
+
#include <sys/types.h>
#include <sys/stat.h>
static int edb2ldif( FILE *outfp, char *edbfile, char *basedn, int recurse );
static int convert_entry( FILE *fp, char *edbname, FILE *outfp,
char *basedn, char *loc_addvals, int loc_addlen, char *linebuf );
+static int add_rdn_values (Attr_Sequence entryas, RDN rdn);
static int read_edbmap( char *mapfile, struct edbmap **edbmapp );
static char *file2rdn( struct edbmap *edbmap, char *filename );
static void free_edbmap( struct edbmap *edbmap );
int ldap_syslog_level = 0;
-main( argc, argv )
- int argc;
- char **argv;
+int
+main( int argc, char **argv )
{
char *usage = "usage: %s [-d] [-o] [-r] [-v] [-b basedn] [-a addvalsfile] [-f fileattrdir] [-i ignoreattr...] [edbfile...]\n";
char edbfile[ MAXNAMLEN ], *basedn;
int c, rc, errflg, ignore_count, recurse;
- extern int optind;
- extern char *optarg;
extern char dsa_mode;
#ifdef HAVE_FILE_ATTR_DIR
extern char *file_attr_directory;
static int
-edb2ldif( outfp, edbfile, basedn, recurse )
- FILE *outfp;
- char *edbfile;
- char *basedn;
- int recurse;
+edb2ldif( FILE *outfp, char *edbfile, char *basedn, int recurse )
{
FILE *fp;
char *addvals, *p, *rdn, line[ MAX_LINE_SIZE + 1 ];
* return > 0 if entry converted, 0 if end of file, < 0 if error occurs
*/
static int
-convert_entry( fp, edbname, outfp, basedn, loc_addvals, loc_addlen, linebuf )
- FILE *fp;
- char *edbname;
- FILE *outfp;
- char *basedn;
- char *loc_addvals;
- int loc_addlen;
- char *linebuf;
+convert_entry(
+ FILE *fp,
+ char *edbname,
+ FILE *outfp,
+ char *basedn,
+ char *loc_addvals,
+ int loc_addlen,
+ char *linebuf
+)
{
Attr_Sequence as, tmpas;
AV_Sequence av;
}
-int
-add_rdn_values( entryas, rdn )
- Attr_Sequence entryas;
- RDN rdn;
+static int
+add_rdn_values( Attr_Sequence entryas, RDN rdn )
{
/*
* this routine is based on code from the real_unravel_attribute() routine
/* read the EDB.map file and return a linked list of translations */
static int
-read_edbmap( mapfile, edbmapp )
- char *mapfile;
- struct edbmap **edbmapp;
+read_edbmap( char *mapfile, struct edbmap **edbmapp )
{
FILE *fp;
char *p, *filename, *rdn, line[ MAX_LINE_SIZE + 1 ];
static char *
-file2rdn( edbmap, filename )
- struct edbmap *edbmap;
- char *filename;
+file2rdn( struct edbmap *edbmap, char *filename )
{
#ifdef LDAP_DEBUG
if ( debugflg ) {
/* free the edbmap list */
static void
-free_edbmap( edbmap )
- struct edbmap *edbmap;
+free_edbmap( struct edbmap *edbmap )
{
struct edbmap *tmp;
static void
-print_err( msg )
- char *msg;
+print_err( char *msg )
{
- extern int sys_nerr;
- extern char *sys_errlist[];
- extern int errno;
-
#ifdef LDAP_DEBUG
if ( debugflg ) {
fprintf( stderr, "print_err( \"%s\" )\n", msg );
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/ctype.h>
+#include <ac/socket.h>
+#include <ac/string.h>
+
#include "ldbm.h"
#include "../slap.h"
-usage( name )
-char *name;
+static void
+usage( char *name )
{
fprintf( stderr, "usage: %s [-n] <filename>\n", name );
exit( 1 );
}
-main( argc, argv )
- int argc;
- char **argv;
+int
+main( int argc, char **argv )
{
Datum key, last, data;
LDBM dbp;
char *file, *s;
int printid = 1;
+#ifdef HAVE_BERKELEY_DB2
+ DBC *cursorp;
+#endif
+
if ( argc < 2 || argc > 3 || ( argc == 3 && strcmp( argv[1], "-n" )
!= 0 )) {
usage( argv[0] );
}
last.dptr = NULL;
+
+#ifdef HAVE_BERKELEY_DB2
+ for ( key = ldbm_firstkey( dbp, &cursorp ); key.dptr != NULL;
+ key = ldbm_nextkey( dbp, last, cursorp ) )
+#else
for ( key = ldbm_firstkey( dbp ); key.dptr != NULL;
- key = ldbm_nextkey( dbp, last ) ) {
+ key = ldbm_nextkey( dbp, last ) )
+#endif
+ {
if ( last.dptr != NULL )
ldbm_datum_free( dbp, last );
data = ldbm_fetch( dbp, key );
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
#include <stdlib.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/time.h>
+#include <limits.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/ctype.h>
+#include <ac/time.h>
+#include <ac/unistd.h>
+#include <ac/wait.h>
+
#include <sys/resource.h>
-#include <sys/wait.h>
#include <sys/param.h>
#include <sys/stat.h>
-#include <limits.h>
-#include "portable.h"
+
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+
#include "ldapconfig.h"
#include "../slap.h"
#include "../back-ldbm/back-ldbm.h"
#define EDITOR "/usr/ucb/vi"
-extern IDList *idl_fetch();
-extern Backend *select_backend();
-extern struct dbcache *ldbm_cache_open();
-
-static struct dbcache *openchoice();
-static void print_entry();
-static void free_and_close();
-static void edit_entry();
-static void get_keydata();
+static struct dbcache *openchoice(char c, int mode, int verbose, char **fname);
+static void print_entry(FILE *fp, char c, Datum *key, char *klabel, Datum *data, char *dlabel);
+static void free_and_close(struct dbcache *dbc, Datum key, Datum data);
+static void edit_entry(char c, Datum *data);
+static void get_keydata(FILE *fp, char c, Datum *key, Datum *data);
struct dbcache *dbc;
LDBM dbp;
int ldap_syslog;
int ldap_syslog_level;
int global_schemacheck;
-int num_entries_sent;
-int num_bytes_sent;
+long num_entries_sent;
+long num_bytes_sent;
int active_threads;
char *default_referral;
struct objclass *global_oc;
pthread_mutex_t ops_mutex;
pthread_mutex_t regex_mutex;
-main( argc, argv )
- int argc;
- char **argv;
+int
+main( int argc, char **argv )
{
char buf[256];
Datum savekey, key, data, last;
IDList *idl;
Backend *tbe;
int i;
- extern char *optarg;
+
+#ifdef HAVE_BERKELEY_DB2
+ DBC *cursorp;
+#endif
tailorfile = SLAPD_DEFAULT_CONFIGFILE;
while ( (i = getopt( argc, argv, "d:f:" )) != EOF ) {
}
savekey.dptr = NULL;
+#ifdef HAVE_BERKELEY_DB2
+ for ( key = ldbm_firstkey( dbc->dbc_db, &cursorp );
+ key.dptr != NULL;
+ key = ldbm_nextkey( dbc->dbc_db, key, cursorp ) )
+#else
for ( key = ldbm_firstkey( dbc->dbc_db );
key.dptr != NULL;
- key = ldbm_nextkey( dbc->dbc_db, key ) ) {
+ key = ldbm_nextkey( dbc->dbc_db, key ) )
+#endif
+ {
if ( savekey.dptr != NULL )
ldbm_datum_free( dbc->dbc_db, savekey );
savekey = key;
if ( idl_insert_key( be, dbc, key, id )
!= 0 ) {
fprintf( stderr,
- "idl_insert_key (%s) %d failed\n",
+ "idl_insert_key (%s) %ld failed\n",
key.dptr, id );
continue;
}
}
last.dptr = NULL;
+
+#ifdef HAVE_BERKELEY_DB2
+ for ( key = ldbm_firstkey( dbp, &cursorp );
+ key.dptr != NULL;
+ key = ldbm_nextkey( dbp, last, cursorp ) )
+#else
for ( key = ldbm_firstkey( dbp ); key.dptr != NULL;
- key = ldbm_nextkey( dbp, last ) ) {
+ key = ldbm_nextkey( dbp, last ) )
+#endif
+ {
if ( last.dptr != NULL ) {
ldbm_datum_free( dbp, last );
}
}
static void
-free_and_close( dbc, key, data )
- struct dbcache *dbc;
- Datum key;
- Datum data;
+free_and_close( struct dbcache *dbc, Datum key, Datum data )
{
ldbm_cache_really_close( be, dbc );
if ( key.dptr != NULL )
}
static int
-dnid_cmp( a, b )
- long *a;
- long *b;
+dnid_cmp( const void *a, const void *b )
{
- return( *a - *b );
+ return( *(const long int *)a - *(const long int *)b );
}
static char *
-myrealloc( p, size )
- char *p;
- int size;
+myrealloc( char *p, int size )
{
if ( p == NULL )
return( (char *) malloc( size ) );
}
static void
-get_idlist( fp, data )
- FILE *fp;
- Datum *data;
+get_idlist( FILE *fp, Datum *data )
{
char buf[20];
int i, j, fd, tty;
p->b_nids = i;
}
- qsort( (void *) p->b_ids, i, sizeof(ID), (void *) dnid_cmp );
+ qsort( (void *) p->b_ids, i, sizeof(ID), dnid_cmp );
}
data->dptr = (char *) p;
}
static void
-get_entry( fp, data )
- FILE *fp;
- Datum *data;
+get_entry( FILE *fp, Datum *data )
{
char buf[BUFSIZ];
char *p;
}
static void
-edit_entry( c, data )
- char c;
- Datum *data;
+edit_entry( char c, Datum *data )
{
int fd, pid;
char tmpname[20];
FILE *fp;
+#ifndef HAVE_WAITPID
WAITSTATUSTYPE status;
+#endif
strcpy( tmpname, "/tmp/dbtestXXXXXX" );
-#ifdef ultrix
+#ifndef HAVE_MKSTEMP
if ( (fd = open( mktemp( tmpname ), O_RDWR, 0600 )) == -1 ) {
perror( tmpname );
return;
fclose( fp );
-#ifdef USE_WAITPID
- if ( waitpid( (pid_t) -1, 0, WAIT_FLAGS ) < 0 ) {
+#ifdef HAVE_WAITPID
+ if ( waitpid( (pid_t) -1, NULL, WAIT_FLAGS ) < 0 ) {
#else
if ( wait3( &status, WAIT_FLAGS, 0 ) < 0 ) {
#endif
}
static struct dbcache *
-openfile( name, namesiz, mode, verbose, c )
- char *name;
- int namesiz;
- int mode;
- int verbose;
- char c;
+openfile( char *name, int namesiz, int mode, int verbose, char c )
{
struct dbcache *dbc;
}
static struct dbcache *
-openchoice( c, mode, verbose, fname )
- char c;
- int mode;
- int verbose;
- char **fname;
+openchoice( char c, int mode, int verbose, char **fname )
{
static char name[MAXPATHLEN];
}
static void
-print_entry( fp, c, key, klabel, data, dlabel )
- FILE *fp;
- char c;
- Datum *key;
- char *klabel;
- Datum *data;
- char *dlabel;
+print_entry(
+ FILE *fp,
+ char c,
+ Datum *key,
+ char *klabel,
+ Datum *data,
+ char *dlabel
+)
{
ID id;
IDList *idl;
key->dsize );
if ( data != NULL ) {
SAFEMEMCPY( (char *) &id, data->dptr, sizeof(ID) );
- fprintf( fp, "%s%d\n", dlabel ? dlabel : "", id );
+ fprintf( fp, "%s%ld\n", dlabel ? dlabel : "", id );
}
break;
case 'e': /* id2entry - key is dnid, data is entry */
if ( key != NULL ) {
SAFEMEMCPY( (char *) &id, key->dptr, sizeof(ID) );
- fprintf( fp, "%s %d\n", klabel, id );
+ fprintf( fp, "%s %lu\n", klabel, id );
}
if ( data != NULL ) {
if ( dlabel ) {
idl = (IDList *) data->dptr;
if ( dlabel )
- fprintf( fp, "%s\tnmax=%d\n\tncur=%d\n", dlabel,
+ fprintf( fp, "%s\tnmax=%ld\n\tncur=%ld\n", dlabel,
idl->b_nmax, idl->b_nids );
if ( INDIRECT_BLOCK( idl ) ) {
for ( i = 0; idl->b_ids[i] != NOID; i++ ) {
- fprintf( fp, "\t%d\n", idl->b_ids[i] );
+ fprintf( fp, "\t%ld\n", idl->b_ids[i] );
}
} else if ( ALLIDS( idl ) ) {
- fprintf( fp, "\tALLIDS (1..%d)\n",
+ fprintf( fp, "\tALLIDS (1..%ld)\n",
idl->b_nids - 1 );
} else {
for ( i = 0; i < idl->b_nids; i++ ) {
- fprintf( fp, "\t%d\n", idl->b_ids[i] );
+ fprintf( fp, "\t%ld\n", idl->b_ids[i] );
}
}
}
}
static void
-get_keydata( fp, c, key, data )
- FILE *fp;
- char c;
- Datum *key;
- Datum *data;
+get_keydata( FILE *fp, char c, Datum *key, Datum *data )
{
static char kbuf[BUFSIZ], dbuf[BUFSIZ];
long n;
#include <ac/string.h>
#include <ac/socket.h>
+#include <ac/unistd.h> /* Get read() */
#include "lber.h"
#include "ldap.h"
int ldap_syslog_level;
-usage( name )
-char *name;
+static void
+usage( char *name )
{
fprintf( stderr, "usage: %s [-b] <attrtype>\n", name );
exit( 1 );
}
-main( argc, argv )
- int argc;
- char **argv;
+int
+main( int argc, char **argv )
{
char buf[BUFSIZ];
char *type, *out;
#include <ac/string.h>
#include <ac/socket.h>
+#include <ac/unistd.h>
+#include "ldapconfig.h"
#include "../slap.h"
#include "../back-ldbm/back-ldbm.h"
-#include "ldapconfig.h"
#include "ldif.h"
#define MAXARGS 100
-extern struct dbcache *ldbm_cache_open();
-extern void attr_index_config();
-extern char *dn_parent();
-extern char *dn_normalize_case();
-extern int nbackends;
-extern Backend *backends;
-extern int ldap_debug;
-
int lineno;
int ldap_debug;
int ldap_syslog;
int ldap_syslog_level;
int global_schemacheck;
-int num_entries_sent;
-int num_bytes_sent;
+long num_entries_sent;
+long num_bytes_sent;
int active_threads;
char *default_referral;
struct objclass *global_oc;
exit( 1 );
}
+int
main( int argc, char **argv )
{
int i, cargc, indb, stop, status;
struct berval bv;
struct berval *vals[2];
Avlnode *avltypes = NULL;
- extern char *optarg;
tailorfile = SLAPD_DEFAULT_CONFIGFILE;
dbnum = -1;
}
if ( linep == NULL ) {
- fprintf( stderr, "entry %d has no dn\n",
+ fprintf( stderr, "entry %lu has no dn\n",
id );
} else {
key.dptr = dn_normalize_case( val );
}
if ( linep == NULL ) {
- fprintf( stderr, "entry %d has no dn\n",
+ fprintf( stderr, "entry %lu has no dn\n",
id );
} else {
if ( (dn = dn_parent( be, val ))
data.dptr, sizeof(ID) );
}
- sprintf( buf2, "%c%d", EQ_PREFIX, pid );
+ sprintf( buf2, "%c%ld", EQ_PREFIX, pid );
key.dptr = buf2;
key.dsize = strlen( buf2 ) + 1;
if ( idl_insert_key( be, db2, key, id )
+#include "portable.h"
+
#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+#include <ac/unistd.h>
+
+#include "ldapconfig.h"
#include "../slap.h"
#include "../back-ldbm/back-ldbm.h"
-#define DEFAULT_CONFIGFILE "/usr/local/etc/slapd.conf"
#define MAXARGS 100
-extern struct dbcache *ldbm_cache_open();
-extern void attr_index_config();
-extern int strcasecmp();
-extern int nbackends;
-extern Backend *backends;
-extern int ldap_debug;
-
int ldap_debug;
int ldap_syslog;
int ldap_syslog_level;
int global_schemacheck;
-int num_entries_sent;
-int num_bytes_sent;
+long num_entries_sent;
+long num_bytes_sent;
int active_threads;
char *default_referral;
struct objclass *global_oc;
pthread_mutex_t ops_mutex;
pthread_mutex_t regex_mutex;
-static int make_index();
-
static char *tailorfile;
static char *inputfile;
exit( 1 );
}
+int
main( int argc, char **argv )
{
int i, cargc, indb, stop, status;
struct berval *vals[2];
Avlnode *avltypes = NULL;
FILE *fp;
- extern char *optarg;
- tailorfile = DEFAULT_CONFIGFILE;
+ tailorfile = SLAPD_DEFAULT_CONFIGFILE;
dbnum = -1;
while ( (i = getopt( argc, argv, "d:f:i:n:" )) != EOF ) {
switch ( i ) {
fprintf( stderr, "No ldbm database found in config file\n" );
exit( 1 );
}
- } else if ( dbnum < 1 || dbnum > nbackends ) {
+ } else if ( dbnum < 0 || dbnum > (nbackends-1) ) {
fprintf( stderr, "Database number selected via -n is out of range\n" );
fprintf( stderr, "Must be in the range 1 to %d (number of databases in the config file)\n", nbackends );
exit( 1 );
len = strlen( line );
if ( buf == NULL || *buf == '\0' ) {
- sprintf( idbuf, "%d\n", id + 1 );
+ sprintf( idbuf, "%lu\n", id + 1 );
idlen = strlen( idbuf );
} else {
idlen = 0;
#include <ac/string.h>
#include <ac/socket.h>
+#include <ac/unistd.h>
#include "../slap.h"
+#include "../back-ldbm/back-ldbm.h"
#include "ldapconfig.h"
#include "ldif.h"
#define MAXARGS 100
-extern void attr_index_config();
-extern char *attr_normalize();
-extern int nbackends;
-extern Backend *backends;
-extern int ldap_debug;
-
int ldap_debug;
int ldap_syslog;
int ldap_syslog_level;
int global_schemacheck;
-int num_entries_sent;
-int num_bytes_sent;
+long num_entries_sent;
+long num_bytes_sent;
int active_threads;
char *default_referral;
struct objclass *global_oc;
pthread_mutex_t ops_mutex;
pthread_mutex_t regex_mutex;
+
static void
usage( char *name )
{
exit( 1 );
}
+int
main( int argc, char **argv )
{
int i, cargc, indb, stop;
Backend *be = NULL;
struct berval bv;
struct berval *vals[2];
- extern char *optarg;
inputfile = NULL;
tailorfile = SLAPD_DEFAULT_CONFIGFILE;
#include <stdio.h>
#include <ac/string.h>
+#include <ac/ctype.h>
#include <ac/socket.h>
+#include <ac/unistd.h>
+#include <ac/wait.h>
#include <sys/param.h>
+#include "ldapconfig.h"
#include "../slap.h"
#include "../back-ldbm/back-ldbm.h"
-#include "ldapconfig.h"
#include "ldif.h"
#define INDEXCMD "ldif2index"
#define ID2CHILDRENCMD "ldif2id2children"
#define MAXARGS 100
-extern int nbackends;
-extern Backend *backends;
-extern int ldap_debug;
-
int ldap_debug;
int ldap_syslog;
int ldap_syslog_level;
int global_schemacheck;
-int num_entries_sent;
-int num_bytes_sent;
+long num_entries_sent;
+long num_bytes_sent;
int active_threads;
char *default_referral;
struct objclass *global_oc;
static char *inputfile;
static int maxkids = 1;
static int nkids;
-
+
static void
usage( char *name )
{
exit( 1 );
}
+int
main( int argc, char **argv )
{
int i, stop, status;
struct berval bv;
struct berval *vals[2];
Avlnode *avltypes = NULL;
- extern char *optarg;
sbindir = DEFAULT_SBINDIR;
tailorfile = SLAPD_DEFAULT_CONFIGFILE;
+#include "portable.h"
+
#include <stdio.h>
+#include <stdlib.h>
+#include <ac/string.h>
+#include <unistd.h> /* get unlink() */
+
#include <ldbm.h>
#include <lber.h>
#include <ldap.h>
#define DB_FLAGS (LDBM_WRCREAT|LDBM_NEWDB)
#define SUBLEN 3
-extern char *first_word();
-extern char *next_word();
-extern char *word_dup();
-extern char *phonetic();
+extern char *first_word(char *);
+extern char *next_word(char *);
+extern char *word_dup(char *);
+extern char *phonetic(char *);
extern int ldap_debug;
extern int lber_debug;
int ldap_syslog;
int ldap_syslog_level;
-static void add();
+static void add(LDBM ldbm, char *s, int *count, int *size, int freeit);
-main( argc, argv )
- int argc;
- char **argv;
+int
+main( int argc, char **argv )
{
LDAP *ld;
LDAPMessage *res, *e;
*
*/
+#include "portable.h"
+
#include <stdio.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include "slap.h"
-extern Backend *select_backend();
-extern void be_unbind();
+#include <ac/socket.h>
+
+#include "slap.h"
-extern char *default_referral;
-extern pthread_mutex_t new_conn_mutex;
void
do_unbind(
* reconfiguration of slurpd.
*/
+#include "portable.h"
#include <stdio.h>
-#include <signal.h>
+
+#include <ac/signal.h>
#include "slurp.h"
#include "globals.h"
* slurpd receives a USR2 signal, it will dump its replication
* queue to the disk file given by SLURPD_DUMPFILE.
*/
-void
-do_admin()
+RETSIGTYPE
+do_admin( int sig )
{
sglob->rq->rq_dump( sglob->rq );
- (void) SIGNAL( SIGUSR2, (void *) do_admin );
+ (void) SIGNAL( SIGUSR2, do_admin );
}
#include "portable.h"
#include <stdio.h>
+#include <stdlib.h>
#include <ac/string.h>
#include <ac/time.h>
+#include <ac/unistd.h>
#include <lber.h>
#include <ldap.h>
)
{
int i;
- extern char *optarg;
int rflag = 0;
if ( (g->myname = strrchr( argv[0], '/' )) == NULL ) {
#include "portable.h"
#include <stdio.h>
+#include <stdlib.h>
#include <ac/socket.h>
#include "portable.h"
#include <stdio.h>
+#include <stdlib.h>
#include <ac/string.h>
#include <ac/socket.h>
+++ /dev/null
-/*
- * Copyright (c) 1990, 1994 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-#include <stdio.h>
-#include <sys/types.h>
-#ifdef SVR4
-#include <sys/stat.h>
-#endif /* svr4 */
-#include <fcntl.h>
-#include <sys/file.h>
-#include <sys/ioctl.h>
-#include <signal.h>
-#include "portable.h"
-
-#ifdef USE_SYSCONF
-#include <unistd.h>
-#endif /* USE_SYSCONF */
-
-
-detach()
-{
- int i, sd, nbits;
-#ifdef LDAP_DEBUG
- extern int ldap_debug;
-#endif
-
-#ifdef USE_SYSCONF
- nbits = sysconf( _SC_OPEN_MAX );
-#else /* USE_SYSCONF */
- nbits = getdtablesize();
-#endif /* USE_SYSCONF */
-
-#ifdef LDAP_DEBUG
- if ( ldap_debug == 0 ) {
-#endif
- for ( i = 0; i < 5; i++ ) {
-#if defined( sunos5 ) && defined( THREAD_SUNOS5_LWP )
- switch ( fork1() ) {
-#else
- switch ( fork() ) {
-#endif
- case -1:
- sleep( 5 );
- continue;
-
- case 0:
- break;
-
- default:
- _exit( 0 );
- }
- break;
- }
-
-/*
- for ( i = 3; i < nbits; i++ )
- close( i );
-*/
-
- (void) chdir( "/" );
-
- if ( (sd = open( "/dev/null", O_RDWR )) == -1 ) {
- perror( "/dev/null" );
- exit( 1 );
- }
- if ( isatty( 0 ) )
- (void) dup2( sd, 0 );
- if ( isatty( 1 ) )
- (void) dup2( sd, 1 );
- if ( isatty(2) )
- (void) dup2( sd, 2 );
- close( sd );
-
-#ifdef USE_SETSID
- setsid();
-#else /* USE_SETSID */
- if ( (sd = open( "/dev/tty", O_RDWR )) != -1 ) {
- (void) ioctl( sd, TIOCNOTTY, NULL );
- (void) close( sd );
- }
-#endif /* USE_SETSID */
-#ifdef LDAP_DEBUG
- }
-#endif
-
- (void) SIGNAL( SIGPIPE, SIG_IGN );
-}
#include "portable.h"
#include <stdio.h>
+#include <stdlib.h> /* get free() */
#include <ac/string.h>
#include <ac/signal.h>
#include "globals.h"
-/*
- * Externs
- */
-extern RETSIGTYPE do_admin LDAP_P((int));
-extern int file_nonempty LDAP_P(( char * ));
-extern int acquire_lock LDAP_P((char *, FILE **, FILE ** ));
-extern int relinquish_lock LDAP_P((char *, FILE *, FILE * ));
-
/*
* Forward references
*/
static char *get_record LDAP_P(( FILE * ));
static void populate_queue LDAP_P(( char *f ));
static RETSIGTYPE set_shutdown LDAP_P((int));
-RETSIGTYPE do_nothing LDAP_P((int));
/*
* - adds items to the internal queue of replication work to do
* - signals the replication threads to let them know new work has arrived.
*/
-void
+void *
fm(
void *arg
)
sglob->rq->rq_getcount( sglob->rq, RQ_COUNT_ALL ));
printf( "%d replication records to process.\n",
sglob->rq->rq_getcount( sglob->rq, RQ_COUNT_NZRC ));
- return;
+ return NULL;
}
/*
* There may be some leftover replication records in our own
}
}
Debug( LDAP_DEBUG_ARGS, "fm: exiting\n", 0, 0, 0 );
+ return NULL;
}
}
return( buf );
}
-
#include <stdio.h>
#include <stdlib.h>
+#include <ac/string.h>
#include "slurp.h"
#include "globals.h"
/*
* Initialize the globals
*/
-Globals *init_globals()
+Globals *
+init_globals( void )
{
Globals *g;
#include "portable.h"
#include <stdio.h>
+#include <stdlib.h>
#include <ac/errno.h>
#include <ac/string.h>
#include <ac/ctype.h>
#include <ac/time.h>
+#include <ac/unistd.h> /* Get_t getpid() */
#include <ac/krb.h>
static int op_ldap_modify LDAP_P(( Ri *, Re *, char ** ));
static int op_ldap_delete LDAP_P(( Ri *, Re *, char ** ));
static int op_ldap_modrdn LDAP_P(( Ri *, Re *, char ** ));
-static LDAPMod *alloc_ldapmod LDAP_P(());
+static LDAPMod *alloc_ldapmod LDAP_P(( void ));
static void free_ldapmod LDAP_P(( LDAPMod * ));
static void free_ldmarr LDAP_P(( LDAPMod ** ));
static int getmodtype LDAP_P(( char * ));
* Allocate and initialize an ldapmod struct.
*/
static LDAPMod *
-alloc_ldapmod()
+alloc_ldapmod( void )
{
LDAPMod *ldm;
if ( rc != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_ANY,
"Error: do_unbind: ldap_unbind failed for %s:%d: %s\n",
- ldap_err2string( rc ), ri->ri_hostname, ri->ri_port );
+ ri->ri_hostname, ri->ri_port, ldap_err2string( rc ) );
}
ri->ri_ldp = NULL;
}
*/
static void
dump_ldm_array(
-LDAPMod **ldmarr )
+ LDAPMod **ldmarr
+)
{
int i, j;
LDAPMod *ldm;
for ( i = 0; ldmarr[ i ] != NULL; i++ ) {
ldm = ldmarr[ i ];
Debug( LDAP_DEBUG_TRACE,
- "Trace (%d): *** ldmarr[ %d ] contents:\n",
- getpid(), i, 0 );
+ "Trace (%ld): *** ldmarr[ %d ] contents:\n",
+ (long) getpid(), i, 0 );
Debug( LDAP_DEBUG_TRACE,
- "Trace (%d): *** ldm->mod_op: %d\n",
- getpid(), ldm->mod_op, 0 );
+ "Trace (%ld): *** ldm->mod_op: %d\n",
+ (long) getpid(), ldm->mod_op, 0 );
Debug( LDAP_DEBUG_TRACE,
- "Trace (%d): *** ldm->mod_type: %s\n",
- getpid(), ldm->mod_type, 0 );
+ "Trace (%ld): *** ldm->mod_type: %s\n",
+ (long) getpid(), ldm->mod_type, 0 );
if ( ldm->mod_bvalues != NULL ) {
for ( j = 0; ( b = ldm->mod_bvalues[ j ] ) != NULL; j++ ) {
msgbuf = ch_malloc( b->bv_len + 512 );
sprintf( msgbuf, "***** bv[ %d ] len = %ld, val = <%s>",
j, b->bv_len, b->bv_val );
Debug( LDAP_DEBUG_TRACE,
- "Trace (%d):%s\n", getpid(), msgbuf, 0 );
+ "Trace (%ld):%s\n", (long) getpid(), msgbuf, 0 );
free( msgbuf );
}
}
*/
static void
upcase(
-char *s )
+ char *s
+)
{
char *p;
#include <sys/file.h>
#include <sys/param.h>
-#include "../slapd/slap.h"
-
+#include "slurp.h"
FILE *
{
if (( *rfp = lock_fopen( file, "r+", lfp )) == NULL ) {
Debug( LDAP_DEBUG_ANY,
- "Error: acquire_lock(%d): Could not acquire lock on \"%s\"\n",
- getpid(), file, 0);
+ "Error: acquire_lock(%ld): Could not acquire lock on \"%s\"\n",
+ (long) getpid(), file, 0);
return( -1 );
}
return( 0 );
{
if ( lock_fclose( rfp, lfp ) == EOF ) {
Debug( LDAP_DEBUG_ANY,
- "Error: relinquish_lock (%d): Error closing \"%s\"\n",
- getpid(), file, 0 );
+ "Error: relinquish_lock (%ld): Error closing \"%s\"\n",
+ (long) getpid(), file, 0 );
return( -1 );
}
return( 0 );
#include "lutil.h"
-extern int doargs( int, char **, Globals * );
-extern void fm();
-extern int start_replica_thread( Ri * );
-extern Globals *init_globals();
-extern int sanity();
-
-#if defined( HAVE_LWP )
-extern void start_lwp_scheduler();
-#endif /* HAVE_LWP */
-
int
main(
int argc,
--- /dev/null
+#ifndef _PROTO_SLURP
+#define _PROTO_SLURP
+
+#include <ldap_cdefs.h>
+
+struct globals;
+
+/* admin.c */
+RETSIGTYPE do_admin LDAP_P((int sig));
+
+/* args.c */
+int doargs LDAP_P((int argc, char **argv, struct globals *g));
+
+/* ch_malloc.c */
+void *ch_malloc LDAP_P((unsigned long size));
+void *ch_realloc LDAP_P((void *block, unsigned long size));
+void *ch_calloc LDAP_P((unsigned long nelem, unsigned long size));
+void ch_free LDAP_P((void *p));
+
+/* config.c */
+int slurpd_read_config LDAP_P((char *fname));
+
+/* ch_malloc.c */
+void ch_free LDAP_P(( void *p ));
+
+/* fm.c */
+void *fm LDAP_P((void *arg));
+RETSIGTYPE do_nothing LDAP_P((int i));
+
+/* globals.c */
+extern struct globals *sglob;
+extern int ldap_syslog;
+extern int ldap_syslog_level;
+extern int ldap_debug;
+extern struct globals *init_globals LDAP_P((void));
+
+/* ldap_op.c */
+int do_ldap LDAP_P((Ri *ri, Re *re, char **errmsg));
+
+/* lock.c */
+FILE *lock_fopen LDAP_P((char *fname, char *type, FILE **lfp));
+int lock_fclose LDAP_P((FILE *fp, FILE *lfp));
+int acquire_lock LDAP_P((char *file, FILE **rfp, FILE **lfp));
+int relinquish_lock LDAP_P((char *file, FILE *rfp, FILE *lfp));
+
+/* reject.c */
+void write_reject LDAP_P((Ri *ri, Re *re, int lderr, char *errmsg));
+
+/* replica.c */
+int start_replica_thread LDAP_P((Ri *ri));
+
+/* replog.c */
+int copy_replog LDAP_P((char *src, char *dst));
+int file_nonempty LDAP_P((char *filename));
+
+/* sanity.c */
+int sanity LDAP_P((void));
+
+/* st.c */
+int St_init LDAP_P((St **st));
+
+/* tsleep.c */
+void tsleep LDAP_P((time_t interval));
+#if defined( HAVE_LWP )
+void start_lwp_scheduler LDAP_P(( void ));
+#endif
+
+#endif /* _PROTO_SLURP */
#include "slurp.h"
#include "globals.h"
-/* externs */
-extern char *str_getline LDAP_P(( char **next ));
-
/* Forward references */
static Rh *get_repl_hosts LDAP_P(( char *, int *, char ** ));
static int gettype LDAP_P(( char * ));
/*
* Free an Re
+ * ??? Something should apparently return nonzero here, but I dont know what.
*/
static int
Re_free(
free( mi );
}
free( re );
+ return 0;
}
* Just invoke the Ri's process() member function, and log the start and
* finish.
*/
-void
+static void *
replicate(
- Ri *ri
+ void *ri_arg
)
{
+ Ri *ri = (Ri *) ri_arg;
+
Debug( LDAP_DEBUG_ARGS, "begin replication thread for %s:%d\n",
- ri->ri_hostname, ri->ri_port, 0 );
+ ((Ri *)ri)->ri_hostname, ((Ri *)ri)->ri_port, 0 );
ri->ri_process( ri );
Debug( LDAP_DEBUG_ARGS, "end replication thread for %s:%d\n",
ri->ri_hostname, ri->ri_port, 0 );
- return;
+ return NULL;
}
#include "slurp.h"
#include "globals.h"
-/*
- * Externs
- */
-extern FILE *lock_fopen LDAP_P(( char *, char *, FILE ** ));
-
-/*
- * Forward declarations
- */
-int file_nonempty LDAP_P(( char * ));
-
-
-/*
- * Forward declarations
- */
-static int duplicate_replog( char *, char * );
-
-
/*
* Copy the replication log. Returns 0 on success, 1 if a temporary
* error occurs, and -1 if a fatal error occurs.
}
if ( access( buf, W_OK ) < 0 ) {
Debug( LDAP_DEBUG_ANY,
- "Error: copy_replog (%d): Directory %s is not writable\n",
- getpid(), buf, 0 );
+ "Error: copy_replog (%ld): Directory %s is not writable\n",
+ (long) getpid(), buf, 0 );
return( -1 );
}
strcpy( buf, dst );
}
if ( access( buf, W_OK ) < 0 ) {
Debug( LDAP_DEBUG_ANY,
- "Error: copy_replog (%d): Directory %s is not writable\n",
- getpid(), buf, 0 );
+ "Error: copy_replog (%ld): Directory %s is not writable\n",
+ (long) getpid(), buf, 0 );
return( -1 );
}
#include "globals.h"
-/* External references */
-extern void write_reject LDAP_P(( Ri *, Re *, int, char * ));
-extern void do_nothing LDAP_P(());
-
/* Forward references */
static int ismine LDAP_P(( Ri *, Re * ));
static int isnew LDAP_P(( Ri *, Re * ));
-void tsleep LDAP_P(( time_t ));
/*
sglob->st->st_unlock( sglob->st );
return ret;
}
-
-
#include <stdio.h>
#include <stdlib.h>
+#include <ac/unistd.h> /* get ftruncate() */
#include "slurp.h"
#include "globals.h"
-/* externs */
-extern void Re_dump LDAP_P(( Re *re ));
-
/*
* Lock the replication queue.
*/
return 0;
}
-
* feedback to the users.
*/
+#include "portable.h"
+
#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
+
+#include <ac/unistd.h>
+#include <ac/string.h>
#include "slurp.h"
#include "globals.h"
-#include "portable.h"
#define FC_DIRBAD 1
#define FC_DIRUNREAD 2
/*
* Forward declarations
*/
-#ifdef NEEDPROTOS
-static unsigned int filecheck( char * );
-#else /* NEEDPROTOS */
-static unsigned int filecheck();
-#endif /* NEEDPROTOS */
+static unsigned int filecheck LDAP_P(( char * ));
*/
int
-sanity()
+sanity( void )
{
int err = 0;
int rc;
return ret;
}
-
* Notes:
* - Private data should not be manipulated expect by Ri member functions.
*/
-typedef struct ri {
+typedef struct ri Ri;
+struct ri {
/* Private data */
char *ri_hostname; /* canonical hostname of replica */
pthread_t ri_tid; /* ID of thread for this replica */
/* Member functions */
- int (*ri_process)(); /* process the next repl entry */
- void (*ri_wake)(); /* wake up a sleeping thread */
-} Ri;
+ int (*ri_process) LDAP_P(( Ri * )); /* process the next repl entry */
+ void (*ri_wake) LDAP_P(( Ri * )); /* wake up a sleeping thread */
+};
-
/*
* Information about one particular replication entry. Only routines in
* re.c and rq.c should touch the private data. Other routines should
* only use member functions.
*/
-typedef struct re {
+typedef struct re Re;
+struct re {
/* Private data */
pthread_mutex_t
struct re *re_next; /* pointer to next element */
/* Public functions */
- int (*re_free)(); /* free an re struct */
- struct re *(*re_getnext)(); /* return next Re in linked list */
- int (*re_parse)(); /* parse a replication log entry */
- int (*re_write)(); /* write a replication log entry */
- void (*re_dump)(); /* debugging - print contents */
- int (*re_lock)(); /* lock this re */
- int (*re_unlock)(); /* unlock this re */
- int (*re_decrefcnt)(); /* decrement the refcnt */
- int (*re_getrefcnt)(); /* get the refcnt */
-} Re;
+ int (*re_free) LDAP_P(( Re * )); /* free an re struct */
+ Re *(*re_getnext) LDAP_P(( Re * )); /* return next Re in linked list */
+ int (*re_parse) LDAP_P(( Re *, char * )); /* parse replication log entry */
+ int (*re_write) LDAP_P(( Ri *, Re *, FILE * )); /* write repl. log entry */
+ void (*re_dump) LDAP_P(( Re *, FILE * )); /* debugging - print contents */
+ int (*re_lock) LDAP_P(( Re * )); /* lock this re */
+ int (*re_unlock) LDAP_P(( Re * )); /* unlock this re */
+ int (*re_decrefcnt) LDAP_P(( Re * )); /* decrement the refcnt */
+ int (*re_getrefcnt) LDAP_P(( Re * )); /* get the refcnt */
+};
* variable so routines in ri.c can use it as a mutex for the
* rq_more condition variable.
*/
-typedef struct rq {
+typedef struct rq Rq;
+struct rq {
/* Private data */
Re *rq_head; /* pointer to head */
rq_more; /* condition var - more work added */
/* Member functions */
- Re *(*rq_gethead)(); /* get the element at head */
- Re *(*rq_getnext)(); /* get the next element */
- int (*rq_delhead)(); /* delete the element at head */
- int (*rq_add)(); /* add at tail */
- void (*rq_gc)(); /* garbage-collect queue */
- int (*rq_lock)(); /* lock the queue */
- int (*rq_unlock)(); /* unlock the queue */
- int (*rq_needtrim)(); /* see if queue needs trimming */
- int (*rq_write)(); /* write Rq contents to a file */
- int (*rq_getcount)(); /* return queue counts */
- void (*rq_dump)(); /* debugging - print contents */
-} Rq;
+ Re * (*rq_gethead) LDAP_P(( Rq * )); /* get the element at head */
+ Re * (*rq_getnext) LDAP_P(( Re * )); /* get the next element */
+ int (*rq_delhead) LDAP_P(( Rq * )); /* delete the element at head */
+ int (*rq_add) LDAP_P(( Rq *, char * )); /* add at tail */
+ void (*rq_gc) LDAP_P(( Rq * )); /* garbage-collect queue */
+ int (*rq_lock) LDAP_P(( Rq * )); /* lock the queue */
+ int (*rq_unlock) LDAP_P(( Rq * )); /* unlock the queue */
+ int (*rq_needtrim) LDAP_P(( Rq * )); /* see if queue needs trimming */
+ int (*rq_write) LDAP_P(( Rq *, FILE * )); /*write Rq contents to file*/
+ int (*rq_getcount) LDAP_P(( Rq *, int )); /* return queue counts */
+ void (*rq_dump) LDAP_P(( Rq * )); /* debugging - print contents */
+};
* if present, uses the timestamps to avoid "replaying" replications
* which have already been sent to a given replica.
*/
-typedef struct st {
-
+typedef struct st St;
+struct st {
/* Private data */
pthread_mutex_t
st_mutex; /* mutex to serialize access */
FILE *st_lfp; /* lockfile fp */
/* Public member functions */
- int (*st_update)(); /* update the entry for a host */
- Stel *(*st_add)(); /* add a new repl host */
- int (*st_write)(); /* write status to disk */
- int (*st_read)(); /* read status info from disk */
- int (*st_lock)(); /* read status info from disk */
- int (*st_unlock)(); /* read status info from disk */
-} St;
+ int (*st_update) LDAP_P(( St *, Stel*, Re* ));/*update entry for a host*/
+ Stel*(*st_add) LDAP_P(( St *, Ri * )); /*add a new repl host*/
+ int (*st_write) LDAP_P(( St * )); /* write status to disk */
+ int (*st_read) LDAP_P(( St * )); /* read status info from disk */
+ int (*st_lock) LDAP_P(( St * )); /* read status info from disk */
+ int (*st_unlock) LDAP_P(( St * )); /* read status info from disk */
+};
#if defined( HAVE_LWP )
typedef struct tl {
} tsl_t;
#endif /* HAVE_LWP */
-/* Public functions */
-
-/* In ch_malloc.c */
-void * ch_malloc LDAP_P(( unsigned long size ));
-void * ch_realloc LDAP_P(( void *block, unsigned long size ));
-void * ch_calloc LDAP_P(( unsigned long nelem, unsigned long size ));
-void ch_free LDAP_P(( void *p ));
-
-
/*
* Public functions used to instantiate and initialize queue objects.
*/
extern int Rq_init LDAP_P(( Rq **rq ));
extern int Re_init LDAP_P(( Re **re ));
+#include "proto-slurp.h"
+
LDAP_END_DECL
#endif /* _SLURPD_H_ */
* is so much simpler...
*/
+#include "portable.h"
+
#include <stdio.h>
+#include <stdlib.h>
+#include <ac/unistd.h> /* get sleep() */
#include "slurp.h"
#include "globals.h"
-#if defined( THREAD_SUNOS4_LWP )
-
-extern stkalign_t *get_stack( int * );
-extern void free_stack( int );
+#if defined( HAVE_LWP )
int
tsleep(
- int interval
+ time_t interval
)
{
thread_t mylwp;
for ( t = sglob->tsl_list; t != NULL; t = t->tl_next ) {
if ( SAMETHREAD( t->tl_tid, mylwp )) {
/* We're already sleeping? */
- t->tl_wake = now + (time_t) interval;
+ t->tl_wake = now + interval;
mon_exit( &sglob->tsl_mon );
lwp_suspend( mylwp );
return 0;
nt = (tl_t *) malloc( sizeof( tl_t ));
nt->tl_next = sglob->tsl_list;
- nt->tl_wake = now + (time_t) interval;
+ nt->tl_wake = now + interval;
nt->tl_tid = mylwp;
sglob->tsl_list = nt;
mon_exit( &sglob->tsl_mon );
* Create the lwp_scheduler thread.
*/
void
-start_lwp_scheduler()
+start_lwp_scheduler( void )
{
thread_t tid;
stkalign_t *stack;
}
-#else /* THREAD_SUNOS4_LWP */
+#else /* !HAVE_LWP */
/*
* Here we assume we have fully preemptive threads, and that sleep()
{
sleep( interval );
}
-#endif /* THREAD_SUNOS4_LWP */
-
-
-
+#endif /* !HAVE_LWP */