]> git.sur5r.net Git - openldap/blobdiff - servers/slurpd/slurp.h
lots of cleanup; few improvements; fix RDN selection bug when creating connection...
[openldap] / servers / slurpd / slurp.h
index f107793230a44bc16eaa1fa1d25c89237db357b8..96ca977127e7dcd867a58ea21a9a212d1bed2488 100644 (file)
@@ -1,5 +1,18 @@
-/*
- * Copyright (c) 1996 Regents of the University of Michigan.
+/* $OpenLDAP$ */
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 1998-2004 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
+ */
+/* Portions Copyright (c) 1996 Regents of the University of Michigan.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms are permitted
  * software without specific prior written permission. This software
  * is provided ``as is'' without express or implied warranty.
  */
+/* ACKNOWLEDGEMENTS:
+ * This work was originally developed by the University of Michigan
+ * (as part of U-MICH LDAP).
+ */
 
 /* slurp.h - Standalone Ldap Update Replication Daemon (slurpd) */
 
 #ifndef _SLURPD_H_
 #define _SLURPD_H_
 
-#ifndef LDAP_SYSLOG
+#if !defined(HAVE_WINSOCK) && !defined(LDAP_SYSLOG)
 #define LDAP_SYSLOG 1
 #endif
 
 #include <ac/errno.h>
+#include <ac/param.h>
 #include <ac/signal.h>
 #include <ac/syslog.h>
+#include <ac/time.h>
 
-#include <sys/param.h>
+#include <sys/types.h>
 
-#include "lber.h"
-#include "ldap.h"
+#include <ldap.h>
 
+#undef  ldap_debug
 #define ldap_debug slurp_debug
 #include "ldap_log.h"
 
-#include "lthread.h"
-#include "ldapconfig.h"
+#include "ldap_pvt_thread.h"
+#include "ldap_defaults.h"
 #include "ldif.h"
 
+#ifdef HAVE_WINSOCK
+       /* should be moved to portable.h.nt */
+#define ftruncate(a,b) _chsize(a,b)
+#define truncate(a,b) _lclose( _lcreat(a, 0))
+#define S_IRGRP 0
+#define S_IWGRP 0
+#endif
+
+#undef SERVICE_NAME
+#define SERVICE_NAME   OPENLDAP_PACKAGE "-slurpd"
 
 /* Default directory for slurpd's private copy of replication logs */
-#define        DEFAULT_SLURPD_REPLICA_DIR      "/usr/tmp"
+#define        DEFAULT_SLURPD_REPLICA_DIR      LDAP_RUNDIR LDAP_DIRSEP "openldap-slurp"
 
 /* Default name for slurpd's private copy of the replication log */
 #define        DEFAULT_SLURPD_REPLOGFILE       "slurpd.replog"
 #define        DEFAULT_SLURPD_STATUS_FILE      "slurpd.status"
 
 /* slurpd dump file - contents of rq struct are written here (debugging) */
-#define        SLURPD_DUMPFILE                 "/tmp/slurpd.dump"
-
-/* default srvtab file.  Can be overridden */
-#define        SRVTAB                          "/etc/srvtab"
+#define        SLURPD_DUMPFILE                 LDAP_TMPDIR LDAP_DIRSEP "slurpd.dump"
 
 /* Amount of time to sleep if no more work to do */
 #define        DEFAULT_NO_WORK_INTERVAL        3
 /* Maximum line length we can read from replication log */
 #define        REPLBUFLEN                      256
 
-/* We support simple (plaintext password) and kerberos authentication */
-#define        AUTH_SIMPLE     1
-#define        AUTH_KERBEROS   2
+/* TLS flags */
+#define TLS_OFF                        0
+#define TLS_ON                 1
+#define TLS_CRITICAL   2
 
 /* Rejection records are prefaced with this string */
 #define        ERROR_STR       "ERROR"
 #define        T_DELETECTSTR           "delete"
 #define        T_DELETECT              6
 #define        T_MODRDNCTSTR           "modrdn"
+#define        T_MODDNCTSTR            "moddn"
+#define        T_RENAMECTSTR           "rename"
 #define        T_MODRDNCT              7
 
 #define        T_MODOPADDSTR           "add"
 #define        T_MODOPREPLACE          9
 #define        T_MODOPDELETESTR        "delete"
 #define        T_MODOPDELETE           10
+#define        T_MODOPINCREMENTSTR     "increment"
+#define        T_MODOPINCREMENT        11
 #define        T_MODSEPSTR             "-"
-#define        T_MODSEP                11
+#define        T_MODSEP                12
 
 #define        T_NEWRDNSTR             "newrdn"
-#define        T_DRDNFLAGSTR           "deleteoldrdn"
+#define        T_DELOLDRDNSTR  "deleteoldrdn"
+#define T_NEWSUPSTR            "newsuperior"
 
 #define        T_ERR                   -1
 
 /* Config file keywords */
 #define        HOSTSTR                 "host"
+#define        URISTR                  "uri"
+#define        ATTRSTR                 "attr"
+#define        SUFFIXSTR               "suffix"
 #define        BINDDNSTR               "binddn"
 #define        BINDMETHSTR             "bindmethod"
 #define        KERBEROSSTR             "kerberos"
 #define        SIMPLESTR               "simple"
+#define        SASLSTR                 "sasl"
 #define        CREDSTR                 "credentials"
-#define BINDPSTR               "bindprincipal"
+#define        OLDAUTHCSTR             "bindprincipal"
+#define        AUTHCSTR                "authcID"
+#define        AUTHZSTR                "authzID"
 #define        SRVTABSTR               "srvtab"
+#define        SASLMECHSTR             "saslmech"
+#define        REALMSTR                "realm"
+#define        SECPROPSSTR             "secprops"
+#define STARTTLSSTR            "starttls"
+#define TLSSTR                 "tls"
+#define CRITICALSTR            "critical"
 
 #define        REPLICA_SLEEP_TIME      ( 10 )
 
 /* Enumeration of various types of bind failures */
-#define BIND_OK                        0
-#define BIND_ERR_BADLDP                        1
-#define        BIND_ERR_OPEN                   2
-#define        BIND_ERR_BAD_ATYPE              3
+#define BIND_OK                                        0
+#define BIND_ERR_BADLDP                                1
+#define        BIND_ERR_OPEN                           2
+#define        BIND_ERR_BAD_ATYPE                      3
 #define        BIND_ERR_SIMPLE_FAILED          4
 #define        BIND_ERR_KERBEROS_FAILED        5
-#define        BIND_ERR_BADRI                  6
+#define        BIND_ERR_BADRI                          6
+#define        BIND_ERR_VERSION                        7
+#define        BIND_ERR_REFERRALS                      8
+#define        BIND_ERR_MANAGEDSAIT            9
+#define        BIND_ERR_SASL_FAILED            10
+#define        BIND_ERR_TLS_FAILED                     11
 
 /* Return codes for do_ldap() */
 #define        DO_LDAP_OK                      0
@@ -170,27 +219,31 @@ typedef struct rh {
  */
 typedef struct ri Ri;
 struct ri {
-
     /* Private data */
     char       *ri_hostname;           /* canonical hostname of replica */
     int                ri_port;                /* port where slave slapd running */
+    char       *ri_uri;                /* e.g. "ldaps://ldap-1.example.com:636" */
     LDAP       *ri_ldp;                /* LDAP struct for this replica */
+    int                ri_tls;                 /* TLS: 0=no, 1=yes, 2=critical */
     int                ri_bind_method;         /* AUTH_SIMPLE or AUTH_KERBEROS */
     char       *ri_bind_dn;            /* DN to bind as when replicating */
-    char       *ri_password;           /* Password for AUTH_SIMPLE */
-    char       *ri_principal;          /* principal for kerberos bind */
+    char       *ri_password;           /* Password for any method */
+    char       *ri_secprops;           /* SASL security properties */
+    char       *ri_realm;                      /* realm for any mechanism */
+    char       *ri_authcId;            /* authentication ID for any mechanism */
+    char       *ri_authzId;            /* authorization ID for any mechanism */
     char       *ri_srvtab;             /* srvtab file for kerberos bind */
+    char       *ri_saslmech;           /* SASL mechanism to use */
     struct re  *ri_curr;               /* current repl entry being processed */
     struct stel        *ri_stel;               /* pointer to Stel for this replica */
     unsigned long
                ri_seq;                 /* seq number of last repl */
-    pthread_t  ri_tid;                 /* ID of thread for this replica */
+    ldap_pvt_thread_t  ri_tid;                 /* ID of thread for this replica */
 
     /* Member functions */
     int (*ri_process) LDAP_P(( Ri * ));        /* process the next repl entry */
     void (*ri_wake)   LDAP_P(( Ri * ));        /* wake up a sleeping thread */
 };
-    
 
 
 
@@ -199,12 +252,10 @@ struct ri {
  * be considered private to routines in re.c, and to routines in ri.c.
  */
 typedef struct mi {
-    
     /* Private data */
     char       *mi_type;               /* attr or type */
     char       *mi_val;                /* value */
     int                mi_len;                 /* length of mi_val */
-
 } Mi;
 
 
@@ -216,12 +267,11 @@ typedef struct mi {
  */
 typedef struct re Re;
 struct re {
-
     /* Private data */
-    pthread_mutex_t
+    ldap_pvt_thread_mutex_t
                re_mutex;               /* mutex for this Re */
     int                re_refcnt;              /* ref count, 0 = done */
-    char       *re_timestamp;          /* timestamp of this re */
+    time_t     re_timestamp;           /* timestamp of this re */
     int                re_seq;                 /* sequence number */
     Rh         *re_replicas;           /* array of replica info */
     char       *re_dn;                 /* dn of entry being modified */
@@ -263,9 +313,9 @@ struct rq {
     time_t     rq_lasttrim;            /* Last time we trimmed file */
     
     /* Public data */
-    pthread_mutex_t
+    ldap_pvt_thread_mutex_t
                rq_mutex;               /* mutex for whole queue */
-    pthread_cond_t
+    ldap_pvt_thread_cond_t
                rq_more;                /* condition var - more work added */
 
     /* Member functions */
@@ -291,7 +341,7 @@ struct rq {
 typedef struct stel {
     char       *hostname;              /* host name of replica */
     int                port;                   /* port number of replica */
-    char       last[ 64 ];             /* timestamp of last successful repl */
+    time_t     last;                   /* timestamp of last successful repl */
     int                seq;                    /* Sequence number of last repl */
 } Stel;
 
@@ -309,7 +359,7 @@ typedef struct stel {
 typedef struct st St;
 struct st {
     /* Private data */
-    pthread_mutex_t
+    ldap_pvt_thread_mutex_t
                st_mutex;               /* mutex to serialize access */
     Stel       **st_data;              /* array of pointers to Stel structs */
     int                st_nreplicas;           /* number of repl hosts */