]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/init.c
ITS#6254
[openldap] / libraries / libldap / init.c
index 2aa88936e06ed8d19e93e0df51be2ed1fe2d431b..d21f44bb795cac84edff8368d70897e7dc74ac67 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2007 The OpenLDAP Foundation.
+ * Copyright 1998-2009 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 #include <stdio.h>
 #include <ac/stdlib.h>
 
+#ifdef HAVE_GETEUID
+#include <ac/unistd.h>
+#endif
+
 #include <ac/socket.h>
 #include <ac/string.h>
 #include <ac/ctype.h>
@@ -47,6 +51,8 @@ struct ldapoptions ldap_int_global_options =
 #define ATTR_OPT_TV    8
 #define ATTR_OPT_INT   9
 
+#define ATTR_GSSAPI    10
+
 struct ol_keyvalue {
        const char *            key;
        int                     value;
@@ -100,6 +106,13 @@ static const struct ol_attribute {
        {1, ATTR_STRING,        "SASL_AUTHZID",         NULL,
                offsetof(struct ldapoptions, ldo_def_sasl_authzid)},
        {0, ATTR_SASL,          "SASL_SECPROPS",        NULL,   LDAP_OPT_X_SASL_SECPROPS},
+       {0, ATTR_BOOL,          "SASL_NOCANON", NULL,   LDAP_BOOL_SASL_NOCANON},
+#endif
+
+#ifdef HAVE_GSSAPI
+       {0, ATTR_GSSAPI,"GSSAPI_SIGN",                  NULL,   LDAP_OPT_SIGN},
+       {0, ATTR_GSSAPI,"GSSAPI_ENCRYPT",               NULL,   LDAP_OPT_ENCRYPT},
+       {0, ATTR_GSSAPI,"GSSAPI_ALLOW_REMOTE_PRINCIPAL",NULL,   LDAP_OPT_X_GSSAPI_ALLOW_REMOTE_PRINCIPAL},
 #endif
 
 #ifdef HAVE_TLS
@@ -110,17 +123,21 @@ static const struct ol_attribute {
        {0, ATTR_TLS,   "TLS_REQCERT",          NULL,   LDAP_OPT_X_TLS_REQUIRE_CERT},
        {0, ATTR_TLS,   "TLS_RANDFILE",         NULL,   LDAP_OPT_X_TLS_RANDOM_FILE},
        {0, ATTR_TLS,   "TLS_CIPHER_SUITE",     NULL,   LDAP_OPT_X_TLS_CIPHER_SUITE},
+       {0, ATTR_TLS,   "TLS_PROTOCOL_MIN",     NULL,   LDAP_OPT_X_TLS_PROTOCOL_MIN},
 
 #ifdef HAVE_OPENSSL_CRL
        {0, ATTR_TLS,   "TLS_CRLCHECK",         NULL,   LDAP_OPT_X_TLS_CRLCHECK},
 #endif
+#ifdef HAVE_GNUTLS
+       {0, ATTR_TLS,   "TLS_CRLFILE",                  NULL,   LDAP_OPT_X_TLS_CRLFILE},
+#endif
         
 #endif
 
        {0, ATTR_NONE,          NULL,           NULL,   0}
 };
 
-#define MAX_LDAP_ATTR_LEN  sizeof("TLS_CIPHER_SUITE")
+#define MAX_LDAP_ATTR_LEN  sizeof("GSSAPI_ALLOW_REMOTE_PRINCIPAL")
 #define MAX_LDAP_ENV_PREFIX_LEN 8
 
 static void openldap_ldap_init_w_conf(
@@ -249,6 +266,11 @@ static void openldap_ldap_init_w_conf(
                        case ATTR_SASL:
 #ifdef HAVE_CYRUS_SASL
                                ldap_int_sasl_config( gopts, attrs[i].offset, opt );
+#endif
+                               break;
+                       case ATTR_GSSAPI:
+#ifdef HAVE_GSSAPI
+                               ldap_int_gssapi_config( gopts, attrs[i].offset, opt );
 #endif
                                break;
                        case ATTR_TLS:
@@ -259,7 +281,6 @@ static void openldap_ldap_init_w_conf(
                        case ATTR_OPT_TV: {
                                struct timeval tv;
                                char *next;
-                               tv.tv_sec = -1;
                                tv.tv_usec = 0;
                                tv.tv_sec = strtol( opt, &next, 10 );
                                if ( next != opt && next[ 0 ] == '\0' && tv.tv_sec > 0 ) {
@@ -476,8 +497,8 @@ void ldap_int_initialize_global_options( struct ldapoptions *gopts, int *dbglvl
        gopts->ldo_timelimit = LDAP_NO_LIMIT;
        gopts->ldo_sizelimit = LDAP_NO_LIMIT;
 
-       gopts->ldo_tm_api = (struct timeval *)NULL;
-       gopts->ldo_tm_net = (struct timeval *)NULL;
+       gopts->ldo_tm_api.tv_sec = -1;
+       gopts->ldo_tm_net.tv_sec = -1;
 
        /* ldo_defludp will be freed by the termination handler
         */
@@ -522,7 +543,11 @@ void ldap_int_initialize_global_options( struct ldapoptions *gopts, int *dbglvl
 #ifdef HAVE_TLS
        gopts->ldo_tls_connect_cb = NULL;
        gopts->ldo_tls_connect_arg = NULL;
+       gopts->ldo_tls_require_cert = LDAP_OPT_X_TLS_DEMAND;
 #endif
+       gopts->ldo_keepalive_probes = 0;
+       gopts->ldo_keepalive_interval = 0;
+       gopts->ldo_keepalive_idle = 0;
 
        gopts->ldo_valid = LDAP_INITIALIZED;
        return;
@@ -613,6 +638,12 @@ void ldap_int_initialize( struct ldapoptions *gopts, int *dbglvl )
 #endif
 
        openldap_ldap_init_w_sysconf(LDAP_CONF_FILE);
+
+#ifdef HAVE_GETEUID
+       if ( geteuid() != getuid() )
+               return;
+#endif
+
        openldap_ldap_init_w_userconf(LDAP_USERRC_FILE);
 
        {