mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-15 03:01:09 +08:00
Use ldap_cdefs.h more. Use bridge.h less.
This commit is contained in:
parent
84864e55e1
commit
6949ab31ac
@ -9,6 +9,7 @@ install-local: FORCE
|
||||
-$(MKDIR) -p $(includedir)
|
||||
$(INSTALL) $(INSTALLFLAGS) -m 644 ldap.h $(includedir)
|
||||
$(INSTALL) $(INSTALLFLAGS) -m 644 lber.h $(includedir)
|
||||
$(INSTALL) $(INSTALLFLAGS) -m 644 ldap_cdefs.h $(includedir)
|
||||
$(INSTALL) $(INSTALLFLAGS) -m 644 proto-lber.h $(includedir)
|
||||
$(INSTALL) $(INSTALLFLAGS) -m 644 proto-ldap.h $(includedir)
|
||||
$(INSTALL) $(INSTALLFLAGS) -m 644 disptmpl.h $(includedir)
|
||||
|
@ -12,8 +12,8 @@
|
||||
|
||||
/* This file SHOULD go away !!! */
|
||||
|
||||
#ifndef LDAP_BRIDGE
|
||||
#define LDAP_BRIDGE
|
||||
#ifndef _LDAP_BRIDGE_H
|
||||
#define _LDAP_BRIDGE_H
|
||||
|
||||
/*
|
||||
* portable.h for LDAP -- this is where we define common stuff to make
|
||||
@ -122,6 +122,7 @@
|
||||
#endif
|
||||
#endif NOTDEF
|
||||
|
||||
#ifndef DISABLE_BRIDGE
|
||||
/*
|
||||
* Are sys_errlist and sys_nerr declared in stdio.h?
|
||||
*/
|
||||
@ -142,6 +143,7 @@
|
||||
#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
|
||||
#define FD_ZERO(p) bzero((char *)(p), sizeof(*(p)))
|
||||
#endif /* FD_SET */
|
||||
#endif
|
||||
|
||||
#if defined( hpux ) && defined( __STDC__ )
|
||||
/*
|
||||
@ -209,4 +211,4 @@
|
||||
extern char *strdup();
|
||||
#endif /* ultrix || nextstep */
|
||||
|
||||
#endif /* LDAP_BRIDGE */
|
||||
#endif /* _LDAP_BRIDGE_H */
|
||||
|
@ -16,10 +16,9 @@
|
||||
#ifndef _DISPTMPL_H
|
||||
#define _DISPTMPL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <ldap_cdefs.h>
|
||||
|
||||
LDAP_BEGIN_DECL
|
||||
|
||||
#define LDAP_TEMPLATE_VERSION 1
|
||||
|
||||
@ -221,110 +220,95 @@ struct ldap_disptmpl {
|
||||
#define LDAP_DTMPL_BUFSIZ 8192
|
||||
|
||||
|
||||
#ifndef NEEDPROTOS
|
||||
typedef int (*writeptype) LDAP_P(( void *writeparm, char *p, int len ));
|
||||
|
||||
typedef int (*writeptype)();
|
||||
LDAP_F int
|
||||
ldap_init_templates LDAP_P(( char *file, struct ldap_disptmpl **tmpllistp ));
|
||||
|
||||
int ldap_init_templates();
|
||||
int ldap_init_templates_buf();
|
||||
void ldap_free_templates();
|
||||
struct ldap_disptmpl *ldap_first_disptmpl();
|
||||
struct ldap_disptmpl *ldap_next_disptmpl();
|
||||
struct ldap_disptmpl *ldap_name2template();
|
||||
struct ldap_disptmpl *ldap_oc2template();
|
||||
char **ldap_tmplattrs();
|
||||
struct ldap_tmplitem *ldap_first_tmplrow();
|
||||
struct ldap_tmplitem *ldap_next_tmplrow();
|
||||
struct ldap_tmplitem *ldap_first_tmplcol();
|
||||
struct ldap_tmplitem *ldap_next_tmplcol();
|
||||
int ldap_entry2text_search();
|
||||
int ldap_entry2text();
|
||||
int ldap_vals2text();
|
||||
int ldap_entry2html_search();
|
||||
int ldap_entry2html();
|
||||
int ldap_vals2html();
|
||||
LDAP_F int
|
||||
ldap_init_templates_buf LDAP_P(( char *buf,
|
||||
long buflen,
|
||||
struct ldap_disptmpl **tmpllistp ));
|
||||
|
||||
#else /* !NEEDPROTOS */
|
||||
LDAP_F void
|
||||
ldap_free_templates LDAP_P(( struct ldap_disptmpl *tmpllist ));
|
||||
|
||||
typedef int (*writeptype)( void *writeparm, char *p, int len );
|
||||
LDAP_F struct ldap_disptmpl *
|
||||
ldap_first_disptmpl LDAP_P(( struct ldap_disptmpl *tmpllist ));
|
||||
|
||||
LDAPFUNCDECL int
|
||||
ldap_init_templates( char *file, struct ldap_disptmpl **tmpllistp );
|
||||
LDAP_F struct ldap_disptmpl *
|
||||
ldap_next_disptmpl LDAP_P(( struct ldap_disptmpl *tmpllist,
|
||||
struct ldap_disptmpl *tmpl ));
|
||||
|
||||
LDAPFUNCDECL int
|
||||
ldap_init_templates_buf( char *buf, long buflen,
|
||||
struct ldap_disptmpl **tmpllistp );
|
||||
LDAP_F struct ldap_disptmpl *
|
||||
ldap_name2template LDAP_P(( char *name,
|
||||
struct ldap_disptmpl *tmpllist ));
|
||||
|
||||
LDAPFUNCDECL void
|
||||
ldap_free_templates( struct ldap_disptmpl *tmpllist );
|
||||
LDAP_F struct ldap_disptmpl *
|
||||
ldap_oc2template LDAP_P(( char **oclist,
|
||||
struct ldap_disptmpl *tmpllist ));
|
||||
|
||||
LDAPFUNCDECL struct ldap_disptmpl *
|
||||
ldap_first_disptmpl( struct ldap_disptmpl *tmpllist );
|
||||
LDAP_F char **
|
||||
ldap_tmplattrs LDAP_P(( struct ldap_disptmpl *tmpl,
|
||||
char **includeattrs,
|
||||
int exclude,
|
||||
unsigned long syntaxmask ));
|
||||
|
||||
LDAPFUNCDECL struct ldap_disptmpl *
|
||||
ldap_next_disptmpl( struct ldap_disptmpl *tmpllist,
|
||||
struct ldap_disptmpl *tmpl );
|
||||
LDAP_F struct ldap_tmplitem *
|
||||
ldap_first_tmplrow LDAP_P(( struct ldap_disptmpl *tmpl ));
|
||||
|
||||
LDAPFUNCDECL struct ldap_disptmpl *
|
||||
ldap_name2template( char *name, struct ldap_disptmpl *tmpllist );
|
||||
LDAP_F struct ldap_tmplitem *
|
||||
ldap_next_tmplrow LDAP_P(( struct ldap_disptmpl *tmpl,
|
||||
struct ldap_tmplitem *row ));
|
||||
|
||||
LDAPFUNCDECL struct ldap_disptmpl *
|
||||
ldap_oc2template( char **oclist, struct ldap_disptmpl *tmpllist );
|
||||
LDAP_F struct ldap_tmplitem *
|
||||
ldap_first_tmplcol LDAP_P(( struct ldap_disptmpl *tmpl,
|
||||
struct ldap_tmplitem *row ));
|
||||
|
||||
LDAPFUNCDECL char **
|
||||
ldap_tmplattrs( struct ldap_disptmpl *tmpl, char **includeattrs, int exclude,
|
||||
unsigned long syntaxmask );
|
||||
LDAP_F struct ldap_tmplitem *
|
||||
ldap_next_tmplcol LDAP_P(( struct ldap_disptmpl *tmpl,
|
||||
struct ldap_tmplitem *row,
|
||||
struct ldap_tmplitem *col ));
|
||||
|
||||
LDAPFUNCDECL struct ldap_tmplitem *
|
||||
ldap_first_tmplrow( struct ldap_disptmpl *tmpl );
|
||||
|
||||
LDAPFUNCDECL struct ldap_tmplitem *
|
||||
ldap_next_tmplrow( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row );
|
||||
|
||||
LDAPFUNCDECL struct ldap_tmplitem *
|
||||
ldap_first_tmplcol( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row );
|
||||
|
||||
LDAPFUNCDECL struct ldap_tmplitem *
|
||||
ldap_next_tmplcol( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row,
|
||||
struct ldap_tmplitem *col );
|
||||
|
||||
LDAPFUNCDECL int
|
||||
ldap_entry2text( LDAP *ld, char *buf, LDAPMessage *entry,
|
||||
LDAP_F int
|
||||
ldap_entry2text LDAP_P(( LDAP *ld,
|
||||
char *buf, LDAPMessage *entry,
|
||||
struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals,
|
||||
writeptype writeproc, void *writeparm, char *eol, int rdncount,
|
||||
unsigned long opts );
|
||||
unsigned long opts ));
|
||||
|
||||
LDAPFUNCDECL int
|
||||
ldap_vals2text( LDAP *ld, char *buf, char **vals, char *label, int labelwidth,
|
||||
LDAP_F int
|
||||
ldap_vals2text LDAP_P(( LDAP *ld,
|
||||
char *buf, char **vals, char *label, int labelwidth,
|
||||
unsigned long syntaxid, writeptype writeproc, void *writeparm,
|
||||
char *eol, int rdncount );
|
||||
char *eol, int rdncount ));
|
||||
|
||||
LDAPFUNCDECL int
|
||||
ldap_entry2text_search( LDAP *ld, char *dn, char *base, LDAPMessage *entry,
|
||||
LDAP_F int
|
||||
ldap_entry2text_search LDAP_P(( LDAP *ld,
|
||||
char *dn, char *base, LDAPMessage *entry,
|
||||
struct ldap_disptmpl *tmpllist, char **defattrs, char ***defvals,
|
||||
writeptype writeproc, void *writeparm, char *eol, int rdncount,
|
||||
unsigned long opts );
|
||||
unsigned long opts ));
|
||||
|
||||
LDAPFUNCDECL int
|
||||
ldap_entry2html( LDAP *ld, char *buf, LDAPMessage *entry,
|
||||
LDAP_F int
|
||||
ldap_entry2html LDAP_P(( LDAP *ld,
|
||||
char *buf, LDAPMessage *entry,
|
||||
struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals,
|
||||
writeptype writeproc, void *writeparm, char *eol, int rdncount,
|
||||
unsigned long opts, char *urlprefix, char *base );
|
||||
unsigned long opts, char *urlprefix, char *base ));
|
||||
|
||||
LDAPFUNCDECL int
|
||||
ldap_vals2html( LDAP *ld, char *buf, char **vals, char *label, int labelwidth,
|
||||
LDAP_F int
|
||||
ldap_vals2html LDAP_P(( LDAP *ld,
|
||||
char *buf, char **vals, char *label, int labelwidth,
|
||||
unsigned long syntaxid, writeptype writeproc, void *writeparm,
|
||||
char *eol, int rdncount, char *urlprefix );
|
||||
char *eol, int rdncount, char *urlprefix ));
|
||||
|
||||
LDAPFUNCDECL int
|
||||
ldap_entry2html_search( LDAP *ld, char *dn, char *base, LDAPMessage *entry,
|
||||
LDAP_F int
|
||||
ldap_entry2html_search LDAP_P(( LDAP
|
||||
*ld, char *dn, char *base, LDAPMessage *entry,
|
||||
struct ldap_disptmpl *tmpllist, char **defattrs, char ***defvals,
|
||||
writeptype writeproc, void *writeparm, char *eol, int rdncount,
|
||||
unsigned long opts, char *urlprefix );
|
||||
#endif /* !NEEDPROTOS */
|
||||
unsigned long opts, char *urlprefix ));
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
LDAP_END_DECL
|
||||
#endif /* _DISPTMPL_H */
|
||||
|
@ -17,10 +17,9 @@
|
||||
#ifndef _SRCHPREF_H
|
||||
#define _SRCHPREF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <ldap_cdefs.h>
|
||||
|
||||
LDAP_BEGIN_DECL
|
||||
|
||||
struct ldap_searchattr {
|
||||
char *sa_attrlabel;
|
||||
@ -60,7 +59,7 @@ struct ldap_searchobj {
|
||||
#define LDAP_SEARCHOBJ_OPT_INTERNAL 0x00000001
|
||||
|
||||
#define LDAP_IS_SEARCHOBJ_OPTION_SET( so, option ) \
|
||||
(((so)->so_options & option ) != 0 )
|
||||
(((so)->so_options & (option) ) != 0 )
|
||||
|
||||
#define LDAP_SEARCHPREF_VERSION_ZERO 0
|
||||
#define LDAP_SEARCHPREF_VERSION 1
|
||||
@ -71,36 +70,26 @@ struct ldap_searchobj {
|
||||
#define LDAP_SEARCHPREF_ERR_FILE 4
|
||||
|
||||
|
||||
#ifndef NEEDPROTOS
|
||||
int ldap_init_searchprefs();
|
||||
int ldap_init_searchprefs_buf();
|
||||
void ldap_free_searchprefs();
|
||||
struct ldap_searchobj *ldap_first_searchobj();
|
||||
struct ldap_searchobj *ldap_next_searchobj();
|
||||
LDAP_F int
|
||||
ldap_init_searchprefs LDAP_P(( char *file,
|
||||
struct ldap_searchobj **solistp ));
|
||||
|
||||
#else /* !NEEDPROTOS */
|
||||
LDAP_F int
|
||||
ldap_init_searchprefs_buf LDAP_P(( char *buf,
|
||||
long buflen,
|
||||
struct ldap_searchobj **solistp ));
|
||||
|
||||
LDAPFUNCDECL int
|
||||
ldap_init_searchprefs( char *file, struct ldap_searchobj **solistp );
|
||||
LDAP_F void
|
||||
ldap_free_searchprefs LDAP_P(( struct ldap_searchobj *solist ));
|
||||
|
||||
LDAPFUNCDECL int
|
||||
ldap_init_searchprefs_buf( char *buf, long buflen,
|
||||
struct ldap_searchobj **solistp );
|
||||
LDAP_F struct ldap_searchobj *
|
||||
ldap_first_searchobj LDAP_P(( struct ldap_searchobj *solist ));
|
||||
|
||||
LDAPFUNCDECL void
|
||||
ldap_free_searchprefs( struct ldap_searchobj *solist );
|
||||
|
||||
LDAPFUNCDECL struct ldap_searchobj *
|
||||
ldap_first_searchobj( struct ldap_searchobj *solist );
|
||||
|
||||
LDAPFUNCDECL struct ldap_searchobj *
|
||||
ldap_next_searchobj( struct ldap_searchobj *sollist,
|
||||
struct ldap_searchobj *so );
|
||||
|
||||
#endif /* !NEEDPROTOS */
|
||||
LDAP_F struct ldap_searchobj *
|
||||
ldap_next_searchobj LDAP_P(( struct ldap_searchobj *sollist,
|
||||
struct ldap_searchobj *so ));
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
LDAP_END_DECL
|
||||
|
||||
#endif /* _SRCHPREF_H */
|
||||
|
@ -11,7 +11,7 @@
|
||||
* is provided ``as is'' without express or implied warranty.
|
||||
*/
|
||||
|
||||
#define LDAP_BRIDGE /* disable LDAP_BRIDGE code */
|
||||
#define DISABLE_BRIDGE /* disable LDAP_BRIDGE code */
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -15,9 +15,8 @@
|
||||
* 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
|
||||
*/
|
||||
|
||||
#define SHA1HANDSOFF /* Copies data before messing with it. */
|
||||
|
||||
#define LDAP_BRIDGE
|
||||
#define DISABLE_BRIDGE
|
||||
#include "portable.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -25,6 +24,7 @@
|
||||
|
||||
#include "lutil_sha1.h"
|
||||
|
||||
#define SHA1HANDSOFF /* Copies data before messing with it. */
|
||||
#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
|
||||
|
||||
/*
|
||||
|
@ -1,22 +1,27 @@
|
||||
/* ldbmcache.c - maintain a cache of open ldbm files */
|
||||
|
||||
#define DISABLE_BRIDGE /* disable LDAP_BRIDGE code */
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <ac/string.h>
|
||||
#include <ac/time.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/param.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
|
||||
#include "slap.h"
|
||||
#include "back-ldbm.h"
|
||||
#include "ldapconfig.h"
|
||||
|
||||
#ifndef DECL_SYS_ERRLIST
|
||||
extern int sys_nerr;
|
||||
extern char *sys_errlist[];
|
||||
#endif
|
||||
|
||||
extern time_t currenttime;
|
||||
extern pthread_mutex_t currenttime_mutex;
|
||||
|
||||
@ -176,6 +181,9 @@ ldbm_cache_fetch(
|
||||
)
|
||||
{
|
||||
Datum data;
|
||||
#ifdef LDBM_USE_DB2
|
||||
memset( &data, 0, sizeof( data ) );
|
||||
#endif
|
||||
|
||||
pthread_mutex_lock( &db->dbc_mutex );
|
||||
#ifdef reentrant_database
|
||||
@ -216,6 +224,24 @@ ldbm_cache_store(
|
||||
}
|
||||
#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 );
|
||||
|
@ -1,11 +1,13 @@
|
||||
#define DISABLE_BRIDGE
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <ac/string.h>
|
||||
#include <ac/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include "portable.h"
|
||||
#include "slap.h"
|
||||
|
||||
extern Operation *op_add();
|
||||
@ -16,7 +18,8 @@ extern long ops_initiated;
|
||||
extern long ops_completed;
|
||||
extern pthread_mutex_t ops_mutex;
|
||||
extern pthread_t listener_tid;
|
||||
#ifndef SYSERRLIST_IN_STDIO
|
||||
|
||||
#ifndef DECL_SYS_ERRLIST
|
||||
extern int sys_nerr;
|
||||
extern char *sys_errlist[];
|
||||
#endif
|
||||
@ -203,6 +206,22 @@ connection_activity(
|
||||
|
||||
pthread_attr_init( &attr );
|
||||
pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED );
|
||||
#ifndef THREAD_MIT_PTHREADS
|
||||
/* POSIX_THREADS or compatible
|
||||
* This is a draft 10 or standard pthreads implementation
|
||||
*/
|
||||
if ( pthread_create( &arg->co_op->o_tid, &attr,
|
||||
(void *) connection_operation, (void *) arg ) != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY, "pthread_create failed\n", 0, 0, 0 );
|
||||
} else {
|
||||
pthread_mutex_lock( &active_threads_mutex );
|
||||
active_threads++;
|
||||
pthread_mutex_unlock( &active_threads_mutex );
|
||||
}
|
||||
#else /* !THREAD_MIT_PTHREAD */
|
||||
/*
|
||||
* This is a draft 4 or earlier pthreads implementation
|
||||
*/
|
||||
if ( pthread_create( &arg->co_op->o_tid, attr,
|
||||
(void *) connection_operation, (void *) arg ) != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY, "pthread_create failed\n", 0, 0, 0 );
|
||||
@ -211,5 +230,6 @@ connection_activity(
|
||||
active_threads++;
|
||||
pthread_mutex_unlock( &active_threads_mutex );
|
||||
}
|
||||
#endif /* !THREAD_MIT_PTHREAD */
|
||||
pthread_attr_destroy( &attr );
|
||||
}
|
||||
|
@ -1,9 +1,19 @@
|
||||
|
||||
/* Revision history
|
||||
*
|
||||
* 5-Jun-96 hodges
|
||||
* Added locking of new_conn_mutex when traversing the c[] array.
|
||||
*/
|
||||
|
||||
#define DISABLE_BRIDGE /* disable bridge code */
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ac/string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <errno.h>
|
||||
#include <sys/time.h>
|
||||
#include <ac/time.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
@ -12,7 +22,6 @@
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
#include "slap.h"
|
||||
#include "portable.h"
|
||||
#include "ldapconfig.h"
|
||||
#ifdef NEED_FILIO
|
||||
#include <sys/filio.h>
|
||||
@ -23,12 +32,20 @@
|
||||
#include <unistd.h>
|
||||
#endif /* USE_SYSCONF */
|
||||
|
||||
#ifdef TCP_WRAPPERS
|
||||
#include <tcpd.h>
|
||||
|
||||
int allow_severity = LOG_INFO;
|
||||
int deny_severity = LOG_NOTICE;
|
||||
#endif /* TCP_WRAPPERS */
|
||||
|
||||
extern Operation *op_add();
|
||||
|
||||
#ifndef SYSERRLIST_IN_STDIO
|
||||
#ifndef DECL_SYS_ERRLIST
|
||||
extern int sys_nerr;
|
||||
extern char *sys_errlist[];
|
||||
#endif
|
||||
|
||||
extern time_t currenttime;
|
||||
extern pthread_mutex_t currenttime_mutex;
|
||||
extern int active_threads;
|
||||
@ -48,7 +65,7 @@ static void set_shutdown();
|
||||
static void do_nothing();
|
||||
|
||||
void
|
||||
daemon(
|
||||
slapd_daemon(
|
||||
int port
|
||||
)
|
||||
{
|
||||
@ -64,10 +81,18 @@ daemon(
|
||||
int on = 1;
|
||||
|
||||
#ifdef USE_SYSCONF
|
||||
dtblsize = sysconf( _SC_OPEN_MAX );
|
||||
dtblsize = sysconf( _SC_OPEN_MAX );
|
||||
#else /* USE_SYSCONF */
|
||||
dtblsize = getdtablesize();
|
||||
dtblsize = getdtablesize();
|
||||
#endif /* USE_SYSCONF */
|
||||
/*
|
||||
* Add greg@greg.rim.or.jp
|
||||
*/
|
||||
#ifdef FD_SETSIZE
|
||||
if(dtblsize > FD_SETSIZE) {
|
||||
dtblsize = FD_SETSIZE;
|
||||
}
|
||||
#endif /* !FD_SETSIZE */
|
||||
|
||||
c = (Connection *) ch_calloc( 1, dtblsize * sizeof(Connection) );
|
||||
|
||||
@ -127,9 +152,19 @@ daemon(
|
||||
}
|
||||
|
||||
(void) SIGNAL( SIGPIPE, SIG_IGN );
|
||||
#ifdef linux
|
||||
/*
|
||||
* LinuxThreads are implemented using SIGUSR1/USR2,
|
||||
* so we'll use SIGSTKFLT and SIGUNUSED
|
||||
*/
|
||||
(void) SIGNAL( SIGSTKFLT, (void *) do_nothing );
|
||||
(void) SIGNAL( SIGUNUSED, (void *) set_shutdown );
|
||||
#else /* !linux */
|
||||
(void) SIGNAL( SIGUSR1, (void *) do_nothing );
|
||||
(void) SIGNAL( SIGUSR2, (void *) set_shutdown );
|
||||
#endif /* !linux */
|
||||
(void) SIGNAL( SIGTERM, (void *) set_shutdown );
|
||||
(void) SIGNAL( SIGINT, (void *) set_shutdown );
|
||||
(void) SIGNAL( SIGHUP, (void *) set_shutdown );
|
||||
|
||||
Debug( LDAP_DEBUG_ANY, "slapd starting\n", 0, 0, 0 );
|
||||
@ -156,6 +191,9 @@ daemon(
|
||||
struct timeval *tvp;
|
||||
int len, pid;
|
||||
|
||||
char *client_name;
|
||||
char *client_addr;
|
||||
|
||||
FD_ZERO( &writefds );
|
||||
FD_ZERO( &readfds );
|
||||
FD_SET( tcps, &readfds );
|
||||
@ -164,6 +202,8 @@ daemon(
|
||||
Debug( LDAP_DEBUG_CONNS,
|
||||
"listening for connections on %d, activity on:",
|
||||
tcps, 0, 0 );
|
||||
|
||||
pthread_mutex_lock( &new_conn_mutex );
|
||||
for ( i = 0; i < dtblsize; i++ ) {
|
||||
if ( c[i].c_sb.sb_sd != -1 ) {
|
||||
FD_SET( c[i].c_sb.sb_sd, &readfds );
|
||||
@ -176,19 +216,20 @@ daemon(
|
||||
}
|
||||
}
|
||||
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
|
||||
#if defined(PTHREAD_PREEMPTIVE) || defined(NO_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",
|
||||
@ -203,7 +244,7 @@ daemon(
|
||||
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 );
|
||||
@ -225,8 +266,9 @@ daemon(
|
||||
}
|
||||
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 );
|
||||
@ -234,43 +276,76 @@ daemon(
|
||||
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(REVERSE_LOOKUP) || defined(TCP_WRAPPERS)
|
||||
hp = gethostbyaddr( (char *)
|
||||
&(from.sin_addr.s_addr),
|
||||
sizeof(from.sin_addr.s_addr), AF_INET );
|
||||
|
||||
if(hp) {
|
||||
client_name = hp->h_name;
|
||||
|
||||
/* normalize the domain */
|
||||
for ( s = client_name; *s; s++ ) {
|
||||
*s = TOLOWER( *s );
|
||||
}
|
||||
|
||||
} else {
|
||||
client_name = NULL;
|
||||
}
|
||||
#else
|
||||
hp = NULL;
|
||||
client_name = 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 ( 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 );
|
||||
}
|
||||
} else {
|
||||
Statslog( LDAP_DEBUG_STATS,
|
||||
"conn=%d fd=%d connection from unknown\n",
|
||||
c[ns].c_connid, ns, 0, 0, 0 );
|
||||
client_name = NULL;;
|
||||
client_addr = NULL;
|
||||
}
|
||||
|
||||
#ifdef TCP_WRAPPERS
|
||||
if(!hosts_ctl("slapd", client_name, client_addr,
|
||||
STRING_UNKNOWN))
|
||||
{
|
||||
/* DENY ACCESS */
|
||||
Statslog( LDAP_DEBUG_STATS,
|
||||
"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 /* TCP_WRAPPERS */
|
||||
|
||||
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 );
|
||||
@ -349,15 +424,33 @@ set_shutdown()
|
||||
{
|
||||
Debug( LDAP_DEBUG_ANY, "slapd got shutdown signal\n", 0, 0, 0 );
|
||||
slapd_shutdown = 1;
|
||||
#ifdef linux
|
||||
/*
|
||||
* LinuxThreads are implemented using SIGUSR1/USR2,
|
||||
* so we'll use SIGSTKFLT and SIGUNUSED
|
||||
*/
|
||||
pthread_kill( listener_tid, SIGSTKFLT );
|
||||
(void) SIGNAL( SIGUNUSED, (void *) set_shutdown );
|
||||
#else /* !linux */
|
||||
pthread_kill( listener_tid, SIGUSR1 );
|
||||
(void) SIGNAL( SIGUSR2, (void *) set_shutdown );
|
||||
#endif /* !linux */
|
||||
(void) SIGNAL( SIGTERM, (void *) set_shutdown );
|
||||
(void) SIGNAL( SIGINT, (void *) set_shutdown );
|
||||
(void) SIGNAL( SIGHUP, (void *) set_shutdown );
|
||||
}
|
||||
|
||||
static void
|
||||
do_nothing()
|
||||
{
|
||||
Debug( LDAP_DEBUG_TRACE, "slapd got SIGUSR1\n", 0, 0, 0 );
|
||||
Debug( LDAP_DEBUG_TRACE, "slapd got do_nothing signal\n", 0, 0, 0 );
|
||||
#ifdef linux
|
||||
/*
|
||||
* LinuxThreads are implemented using SIGUSR1/USR2,
|
||||
* so we'll use SIGSTKFLT and SIGUNUSED
|
||||
*/
|
||||
(void) SIGNAL( SIGSTKFLT, (void *) do_nothing );
|
||||
#else /* !linux */
|
||||
(void) SIGNAL( SIGUSR1, (void *) do_nothing );
|
||||
#endif /* !linux */
|
||||
}
|
||||
|
@ -1,20 +1,23 @@
|
||||
/* result.c - routines to send ldap results, errors, and referrals */
|
||||
|
||||
#define DISABLE_BRIDGE
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <ac/string.h>
|
||||
#include <ac/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
|
||||
#ifndef DECL_SYS_ERRLIST
|
||||
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;
|
||||
@ -121,7 +124,13 @@ send_ldap_result2(
|
||||
pthread_mutex_lock( &active_threads_mutex );
|
||||
active_threads--;
|
||||
conn->c_writewaiter = 1;
|
||||
|
||||
#ifdef linux
|
||||
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 );
|
||||
|
||||
@ -192,6 +201,7 @@ send_search_entry(
|
||||
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 );
|
||||
|
||||
@ -202,15 +212,19 @@ send_search_entry(
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
edn = dn_normalize_case( strdup( e->e_dn ) );
|
||||
|
||||
#ifdef 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" );
|
||||
"ber_alloc" );
|
||||
free(edn);
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
@ -220,26 +234,44 @@ send_search_entry(
|
||||
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" );
|
||||
free(edn);
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -248,14 +280,15 @@ send_search_entry(
|
||||
ber_free( ber, 1 );
|
||||
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
|
||||
NULL, "ber_printf type" );
|
||||
free(edn);
|
||||
return( 1 );
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@ -270,6 +303,7 @@ send_search_entry(
|
||||
send_ldap_result( conn, op,
|
||||
LDAP_OPERATIONS_ERROR, NULL,
|
||||
"ber_printf value" );
|
||||
free(edn);
|
||||
return( 1 );
|
||||
}
|
||||
}
|
||||
@ -280,10 +314,13 @@ send_search_entry(
|
||||
ber_free( ber, 1 );
|
||||
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
|
||||
NULL, "ber_printf type end" );
|
||||
free(edn);
|
||||
return( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
free(edn);
|
||||
|
||||
#ifdef COMPAT30
|
||||
if ( conn->c_version == 30 ) {
|
||||
rc = ber_printf( ber, "}}}}" );
|
||||
|
@ -14,49 +14,36 @@
|
||||
* fm.c - file management routines.
|
||||
*/
|
||||
|
||||
#define DISABLE_BRIDGE
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <ac/string.h>
|
||||
#include <sys/signal.h>
|
||||
|
||||
#include "slurp.h"
|
||||
#include "globals.h"
|
||||
|
||||
extern void do_admin();
|
||||
|
||||
static void set_shutdown();
|
||||
void do_nothing();
|
||||
|
||||
/*
|
||||
* Externs
|
||||
*/
|
||||
#ifdef NEEDPROTOS
|
||||
extern int file_nonempty( char * );
|
||||
extern int acquire_lock(char *, FILE **, FILE ** );
|
||||
extern int relinquish_lock(char *, FILE *, FILE * );
|
||||
#else /* NEEDPROTOS */
|
||||
extern int file_nonempty();
|
||||
extern int acquire_lock();
|
||||
extern int relinquish_lock();
|
||||
#endif /* NEEDPROTOS */
|
||||
extern void do_admin LDAP_P((void));
|
||||
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
|
||||
*/
|
||||
#ifdef NEEDPROTOS
|
||||
static char *get_record( FILE * );
|
||||
static void populate_queue( char *f );
|
||||
static void set_shutdown();
|
||||
void do_nothing();
|
||||
#else /* NEEDPROTOS */
|
||||
static char *get_record();
|
||||
static void populate_queue();
|
||||
static void set_shutdown();
|
||||
void do_nothing();
|
||||
#endif /* NEEDPROTOS */
|
||||
static char *get_record LDAP_P(( FILE * ));
|
||||
static void populate_queue LDAP_P(( char *f ));
|
||||
static void set_shutdown LDAP_P((void));
|
||||
void do_nothing LDAP_P((void));
|
||||
|
||||
#ifndef SYSERRLIST_IN_STDIO
|
||||
#ifndef DECL_SYS_ERRLIST
|
||||
extern char *sys_errlist[];
|
||||
#endif /* SYSERRLIST_IN_STDIO */
|
||||
#endif /* DECL_SYS_ERRLIST */
|
||||
|
||||
|
||||
|
||||
@ -77,12 +64,20 @@ fm(
|
||||
|
||||
/* Set up our signal handlers:
|
||||
* SIG{TERM,INT,HUP} causes a shutdown
|
||||
* SIGUSR1 - does nothing, used to wake up sleeping threads.
|
||||
* SIGUSR2 - causes slurpd to read its administrative interface file.
|
||||
* SIG(STKFLT|USR1) - does nothing, used to wake up sleeping threads.
|
||||
* SIG(UNUSED|USR2) - causes slurpd to read its administrative interface file.
|
||||
* (not yet implemented).
|
||||
*/
|
||||
#ifdef SIGSTKFLT
|
||||
(void) SIGNAL( SIGSTKFLT, (void *) do_nothing );
|
||||
#else
|
||||
(void) SIGNAL( SIGUSR1, (void *) do_nothing );
|
||||
#endif
|
||||
#ifdef SIGUNUSED
|
||||
(void) SIGNAL( SIGUNUSED, (void *) do_admin );
|
||||
#else
|
||||
(void) SIGNAL( SIGUSR2, (void *) do_admin );
|
||||
#endif
|
||||
(void) SIGNAL( SIGTERM, (void *) set_shutdown );
|
||||
(void) SIGNAL( SIGINT, (void *) set_shutdown );
|
||||
(void) SIGNAL( SIGHUP, (void *) set_shutdown );
|
||||
@ -160,7 +155,11 @@ set_shutdown()
|
||||
int i;
|
||||
|
||||
sglob->slurpd_shutdown = 1; /* set flag */
|
||||
#ifdef SIGSTKFLT
|
||||
pthread_kill( sglob->fm_tid, SIGSTKFLT ); /* wake up file mgr */
|
||||
#else
|
||||
pthread_kill( sglob->fm_tid, SIGUSR1 ); /* wake up file mgr */
|
||||
#endif
|
||||
sglob->rq->rq_lock( sglob->rq ); /* lock queue */
|
||||
pthread_cond_broadcast( &(sglob->rq->rq_more) ); /* wake repl threads */
|
||||
for ( i = 0; i < sglob->num_replicas; i++ ) {
|
||||
@ -181,7 +180,11 @@ set_shutdown()
|
||||
void
|
||||
do_nothing()
|
||||
{
|
||||
#ifdef SIGSTKFLT
|
||||
(void) SIGNAL( SIGSTKFLT, (void *) do_nothing );
|
||||
#else
|
||||
(void) SIGNAL( SIGUSR1, (void *) do_nothing );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -14,43 +14,49 @@
|
||||
* ldap_op.c - routines to perform LDAP operations
|
||||
*/
|
||||
|
||||
#define DISABLE_BRIDGE
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ac/string.h>
|
||||
#include <ac/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#ifdef KERBEROS
|
||||
#ifdef KERBEROS_V
|
||||
#include <kerberosIV/krb.h>
|
||||
#else
|
||||
#include <krb.h>
|
||||
#endif /* KERBEROS_V */
|
||||
#endif /* KERBEROS */
|
||||
|
||||
#include <lber.h>
|
||||
#include <ldap.h>
|
||||
|
||||
#include "portable.h"
|
||||
#include "slurp.h"
|
||||
|
||||
/* Forward references */
|
||||
static int get_changetype( char * );
|
||||
static struct berval **make_singlevalued_berval( char *, int );
|
||||
static int op_ldap_add( Ri *, Re *, char ** );
|
||||
static int op_ldap_modify( Ri *, Re *, char ** );
|
||||
static int op_ldap_delete( Ri *, Re *, char ** );
|
||||
static int op_ldap_modrdn( Ri *, Re *, char ** );
|
||||
static LDAPMod *alloc_ldapmod();
|
||||
static void free_ldapmod( LDAPMod * );
|
||||
static void free_ldmarr( LDAPMod ** );
|
||||
static int getmodtype( char * );
|
||||
static void dump_ldm_array( LDAPMod ** );
|
||||
static char **read_krbnames( Ri * );
|
||||
static void upcase( char * );
|
||||
static int do_bind( Ri *, int * );
|
||||
static int do_unbind( Ri * );
|
||||
static int get_changetype LDAP_P(( char * ));
|
||||
static struct berval **make_singlevalued_berval LDAP_P(( char *, int ));
|
||||
static int op_ldap_add LDAP_P(( Ri *, Re *, char ** ));
|
||||
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 void free_ldapmod LDAP_P(( LDAPMod * ));
|
||||
static void free_ldmarr LDAP_P(( LDAPMod ** ));
|
||||
static int getmodtype LDAP_P(( char * ));
|
||||
static void dump_ldm_array LDAP_P(( LDAPMod ** ));
|
||||
static char **read_krbnames LDAP_P(( Ri * ));
|
||||
static void upcase LDAP_P(( char * ));
|
||||
static int do_bind LDAP_P(( Ri *, int * ));
|
||||
static int do_unbind LDAP_P(( Ri * ));
|
||||
|
||||
|
||||
/* External references */
|
||||
#ifndef SYSERRLIST_IN_STDIO
|
||||
#ifndef DECL_SYS_ERRLIST
|
||||
extern char *sys_errlist[];
|
||||
#endif /* SYSERRLIST_IN_STDIO */
|
||||
#endif /* DECL_SYS_ERRLIST */
|
||||
|
||||
extern char *ch_malloc( unsigned long );
|
||||
|
||||
|
@ -18,8 +18,11 @@
|
||||
*/
|
||||
|
||||
|
||||
#define DISABLE_BRIDGE
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ac/string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
@ -28,18 +31,20 @@
|
||||
#include "globals.h"
|
||||
|
||||
/* externs */
|
||||
extern char *str_getline( char **next );
|
||||
extern void ch_free( char *p );
|
||||
extern char *str_getline LDAP_P(( char **next ));
|
||||
extern void ch_free LDAP_P(( char *p ));
|
||||
|
||||
#ifndef DECL_SYS_ERRLIST
|
||||
extern char *sys_errlist[];
|
||||
#endif /* DECL_SYS_ERRLIST */
|
||||
|
||||
/* Forward references */
|
||||
static Rh *get_repl_hosts( char *, int *, char ** );
|
||||
static int gettype( char * );
|
||||
static int getchangetype( char *);
|
||||
static int Re_parse( Re *re, char *replbuf );
|
||||
static void Re_dump( Re *re, FILE *fp );
|
||||
static void warn_unknown_replica( char *, int port );
|
||||
static Rh *get_repl_hosts LDAP_P(( char *, int *, char ** ));
|
||||
static int gettype LDAP_P(( char * ));
|
||||
static int getchangetype LDAP_P(( char * ));
|
||||
static int Re_parse LDAP_P(( Re *re, char *replbuf ));
|
||||
static void Re_dump LDAP_P(( Re *re, FILE *fp ));
|
||||
static void warn_unknown_replica LDAP_P(( char *, int port ));
|
||||
|
||||
/* Globals, scoped within this file */
|
||||
static int nur = 0; /* Number of unknown replicas */
|
||||
@ -182,7 +187,9 @@ Re_parse(
|
||||
state |= GOT_TIME;
|
||||
break;
|
||||
case T_DN:
|
||||
re->re_dn = strdup( value );
|
||||
re->re_dn = ch_malloc( len + 1 );
|
||||
memcpy( re->re_dn, value, len );
|
||||
re->re_dn[ len ]='\0';
|
||||
state |= GOT_DN;
|
||||
break;
|
||||
default:
|
||||
@ -222,7 +229,9 @@ Re_parse(
|
||||
sizeof( Mi ) * ( nml + 2 ));
|
||||
re->re_mods[ nml ].mi_type = strdup( type );
|
||||
if ( value != NULL ) {
|
||||
re->re_mods[ nml ].mi_val = strdup( value );
|
||||
re->re_mods[ nml ].mi_val = ch_malloc( len + 1 );
|
||||
memcpy( re->re_mods[ nml ].mi_val, value, len );
|
||||
re->re_mods[ nml ].mi_val[ len ] = '\0';
|
||||
re->re_mods[ nml ].mi_len = len;
|
||||
} else {
|
||||
re->re_mods[ nml ].mi_val = NULL;
|
||||
|
@ -17,6 +17,8 @@
|
||||
* to a replica LDAP server.
|
||||
*/
|
||||
|
||||
#define DISABLE_BRIDGE
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
@ -27,9 +29,9 @@
|
||||
#include "slurp.h"
|
||||
#include "globals.h"
|
||||
|
||||
#ifndef SYSERRLIST_IN_STDIO
|
||||
#ifndef DECL_SYS_ERRLIST
|
||||
extern char *sys_errlist[];
|
||||
#endif /* SYSERRLIST_IN_STDIO */
|
||||
#endif /* DECL_SYS_ERRLIST */
|
||||
|
||||
|
||||
/*
|
||||
|
@ -15,44 +15,37 @@
|
||||
* replog.c - routines which read and write replication log files.
|
||||
*/
|
||||
|
||||
#define DISABLE_BRIDGE
|
||||
#include "portable.h"
|
||||
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <syslog.h>
|
||||
#include <sys/time.h>
|
||||
#include <ac/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/param.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <ac/string.h>
|
||||
|
||||
#include "portable.h"
|
||||
#include "slurp.h"
|
||||
#include "globals.h"
|
||||
|
||||
/*
|
||||
* Externs
|
||||
*/
|
||||
#ifdef NEEDPROTOS
|
||||
extern FILE *lock_fopen( char *, char *, FILE ** );
|
||||
extern char *ch_malloc( unsigned long );
|
||||
#else /* NEEDPROTOS */
|
||||
extern FILE *lock_fopen();
|
||||
extern char *ch_malloc();
|
||||
#endif /* NEEDPROTOS */
|
||||
extern FILE *lock_fopen LDAP_P(( char *, char *, FILE ** ));
|
||||
extern char *ch_malloc LDAP_P(( unsigned long ));
|
||||
|
||||
/*
|
||||
* Forward declarations
|
||||
*/
|
||||
#ifdef NEEDPROTOS
|
||||
int file_nonempty( char * );
|
||||
#else /* NEEDPROTOS */
|
||||
int file_nonempty();
|
||||
#endif /* NEEDPROTOS */
|
||||
int file_nonempty LDAP_P(( char * ));
|
||||
|
||||
|
||||
#ifndef SYSERRLIST_IN_STDIO
|
||||
#ifndef DECL_SYS_ERRLIST
|
||||
extern char *sys_errlist[];
|
||||
#endif
|
||||
|
||||
@ -62,8 +55,6 @@ extern char *sys_errlist[];
|
||||
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.
|
||||
|
@ -31,6 +31,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#define DISABLE_BRIDGE
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "slurp.h"
|
||||
@ -38,15 +41,11 @@
|
||||
|
||||
|
||||
/* externs */
|
||||
#ifdef NEEDPROTOS
|
||||
extern void Re_dump( Re *re );
|
||||
#else /* NEEDPROTOS */
|
||||
extern void Re_dump();
|
||||
#endif /* NEEDPROTOS */
|
||||
|
||||
extern void Re_dump LDAP_P(( Re *re ));
|
||||
|
||||
#ifndef DECL_SYS_ERRLIST
|
||||
extern char *sys_errlist[];
|
||||
|
||||
#endif /* DECL_SYS_ERRLIST */
|
||||
|
||||
/*
|
||||
* Lock the replication queue.
|
||||
@ -60,9 +59,6 @@ Rq_lock(
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Unlock the replication queue.
|
||||
*/
|
||||
@ -89,8 +85,6 @@ Rq_gethead(
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Return the next item in the queue. Callers should lock the queue before
|
||||
* calling this routine.
|
||||
@ -108,8 +102,6 @@ Rq_getnext(
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Delete the item at the head of the list. The queue should be locked
|
||||
* by the caller before calling this routine.
|
||||
@ -144,8 +136,6 @@ Rq_delhead(
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Add an entry to the tail of the replication queue. Locking is handled
|
||||
* internally. When items are added to the queue, this routine wakes
|
||||
@ -209,8 +199,6 @@ Rq_add(
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Garbage-collect the replication queue. Locking is handled internally.
|
||||
*/
|
||||
@ -234,7 +222,6 @@ Rq_gc(
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* For debugging: dump the contents of the replication queue to a file.
|
||||
* Locking is handled internally.
|
||||
@ -268,7 +255,6 @@ Rq_dump(
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Write the contents of a replication queue to a file. Returns zero if
|
||||
* successful, -1 if not. Handles queue locking internally. Callers should
|
||||
@ -317,8 +303,6 @@ Rq_write(
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Check to see if the private slurpd replication log needs trimming.
|
||||
* The current criteria are:
|
||||
@ -391,8 +375,6 @@ Rq_getcount(
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Allocate and initialize an Rq object.
|
||||
*/
|
||||
|
@ -16,18 +16,19 @@
|
||||
* writing status information to disk.
|
||||
*/
|
||||
|
||||
|
||||
#define DISABLE_BRIDGE
|
||||
#include "portable.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ac/string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "slurp.h"
|
||||
#include "globals.h"
|
||||
|
||||
#ifndef SYSERRLIST_IN_STDIO
|
||||
#ifndef DECL_SYS_ERRLIST
|
||||
extern char *sys_errlist[];
|
||||
#endif /* SYSERRLIST_IN_STDIO */
|
||||
#endif /* DECL_SYS_ERRLIST */
|
||||
|
||||
/*
|
||||
* Add information about replica host specified by Ri to list
|
||||
@ -56,8 +57,7 @@ St_add(
|
||||
pthread_mutex_unlock( &(st->st_mutex ));
|
||||
return NULL;
|
||||
}
|
||||
st->st_data[ ind ] = ( Stel * ) ch_malloc( st->st_data,
|
||||
sizeof( Stel ));
|
||||
st->st_data[ ind ] = ( Stel * ) ch_malloc( sizeof( Stel ) );
|
||||
if ( st->st_data[ ind ] == NULL ) {
|
||||
pthread_mutex_unlock( &(st->st_mutex ));
|
||||
return NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user