From owner-p4-projects@FreeBSD.ORG Mon Aug 7 19:07:19 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id C632216A4E5; Mon, 7 Aug 2006 19:07:19 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A432C16A4E1 for ; Mon, 7 Aug 2006 19:07:19 +0000 (UTC) (envelope-from bushman@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2E9BA43D5E for ; Mon, 7 Aug 2006 19:07:06 +0000 (GMT) (envelope-from bushman@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k77J74SZ054755 for ; Mon, 7 Aug 2006 19:07:04 GMT (envelope-from bushman@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k77J74Lg054752 for perforce@freebsd.org; Mon, 7 Aug 2006 19:07:04 GMT (envelope-from bushman@freebsd.org) Date: Mon, 7 Aug 2006 19:07:04 GMT Message-Id: <200608071907.k77J74Lg054752@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bushman@freebsd.org using -f From: Michael Bushkov To: Perforce Change Reviews Cc: Subject: PERFORCE change 103391 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2006 19:07:20 -0000 http://perforce.freebsd.org/chv.cgi?CH=103391 Change 103391 by bushman@bushman_nss_ldap_cached on 2006/08/07 19:06:44 Pretty everything is done. This is the just-in-case commit before the major sources cleanup (gotta remove all the weird debugging printfs). Affected files ... .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/Makefile#9 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldap_group.c#8 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldap_group.h#8 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldap_passwd.c#9 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldap_passwd.h#9 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldap_serv.c#5 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldap_serv.h#5 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldapconf.c#9 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldapconf.h#9 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldapconn.c#9 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldapconn.h#9 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldapschema.c#9 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldapschema.h#9 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldapsearch.c#8 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldapsearch.h#8 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldaptls.c#7 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldaptls.h#7 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldaputil.c#9 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldaputil.h#9 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/nss_ldap.c#9 edit .. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/nss_ldap.h#9 edit Differences ... ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/Makefile#9 (text+ko) ==== ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldap_group.c#8 (text+ko) ==== ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldap_group.h#8 (text+ko) ==== ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldap_passwd.c#9 (text+ko) ==== ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldap_passwd.h#9 (text+ko) ==== ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldap_serv.c#5 (text+ko) ==== @@ -187,7 +187,7 @@ nss_ldap_destroy_servent(struct nss_ldap_parse_context *pctx) { - printf("here - %s %d\n", __FILE__, __LINE__); + printf("SAFDASPIFO UASFIOOASUIFIOAS FUOAISFUI OAUSFIOASUF!!!!!!!!!here - %s %d\n", __FILE__, __LINE__); assert(pctx != NULL); free(pctx->mdata_ext); } ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldap_serv.h#5 (text+ko) ==== ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldapconf.c#9 (text+ko) ==== @@ -590,7 +590,14 @@ } continue; } - } + } else if (strcmp(fields[0], "use_sasl") == 0) { + if ((field_count == 2) && + (get_yesno(fields[1], &value) == + NSS_LDAP_SUCCESS)) { + conf->use_sasl = value; + continue; + } + } break; default: break; @@ -622,7 +629,7 @@ printf("BBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCc %p\n", (void *)conf->sasl_authid); #ifdef NSS_LDAP_SASL_AUTH_ENABLED - if (conf->sasl_authid == NULL) { + if (conf->use_sasl == 0) { #endif switch (conf->ssl_mode) { case NSS_LDAP_SSL_OFF: ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldapconf.h#9 (text+ko) ==== @@ -105,7 +105,8 @@ char *root_sasl_authid; char *sasl_secprops; char *krb5_ccname; - int root_use_sasl; + int root_use_sasl; + int use_sasl; char *tls_cacert; char *tls_cacertdir; ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldapconn.c#9 (text+ko) ==== @@ -348,6 +348,7 @@ if (ldapuri == NULL) { snprintf(err->description, NSS_LDAP_MAX_ERR_DESC_SIZE, "cannot format the ldap URI"); + printf("911 %s\n", err->description); free(conn); return (NULL); } @@ -521,8 +522,11 @@ } /* Check to see if the bind operation completed. */ + memset(&zerotime, 0, sizeof(zerotime)); while ( !finished ) { - rc = ldap_result( conn->ld, msgid, 0, &zerotime, &res ); + printf("FIININISHED %d %d %d %p\n", finished, rc, msgid, (void *)conn->ld); + res = NULL; + rc = ldap_result( conn->ld, msgid, 1, &zerotime, &res ); switch ( rc ) { /* If ldap_result() returns -1, error occurred. */ case -1: @@ -881,7 +885,7 @@ int rv; /* Falling back to simple authentication if the config says so */ - if (conf->root_use_sasl != NSS_LDAP_OPTION_YES) + if ((geteuid() == 0) && (conf->root_use_sasl != NSS_LDAP_OPTION_YES)) return (__nss_ldap_simple_auth(conn, conf, err)); dn = geteuid() == 0 ? conf->root_bind_dn : conf->bind_dn; ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldapconn.h#9 (text+ko) ==== ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldapschema.c#9 (text+ko) ==== ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldapschema.h#9 (text+ko) ==== ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldapsearch.c#8 (text+ko) ==== @@ -121,6 +121,7 @@ printf("%s %d\n", __FILE__, __LINE__); if (ctx->msgid == -1) { + ldap_msgfree(ctx->msg); ctx->msg = NULL; return (NSS_LDAP_SUCCESS); } @@ -128,6 +129,10 @@ finished = 0; memset(&zerotime, 0, sizeof(struct timeval)); while (!finished) { + if (ctx->msg != NULL) { + ldap_msgfree(ctx->msg); + ctx->msg = NULL; + } rv = ldap_result( ctx->conn->ld, ctx->msgid, LDAP_MSG_ONE, &zerotime, &ctx->msg); @@ -161,10 +166,14 @@ assert(ctx != NULL); - if (ctx->msg != NULL) + if (ctx->msg != NULL) { ldap_msgfree(ctx->msg); + ctx->msg = NULL; + } destroy_request(&ctx->search_request); free(ctx); + + printf("ENDING SEEEEEEEEEEEEEARCHING\n"); } static void @@ -175,7 +184,7 @@ if (pctx->parse_destroy_fn != NULL) pctx->parse_destroy_fn(pctx); - free(pctx); + free(pctx); } struct nss_ldap_search_context * @@ -256,6 +265,7 @@ assert(pctx != NULL); + printf("ENDING PAAAAAAAAAAAARSING\n"); if (pctx->parse_destroy_fn != NULL) pctx->parse_destroy_fn(pctx); free(pctx); ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldapsearch.h#8 (text+ko) ==== ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldaptls.c#7 (text+ko) ==== @@ -109,17 +109,21 @@ int rv; rv = nss_ldap_connection_getstate(&st); - if (rv != NSS_LDAP_SUCCESS) + if (rv != NSS_LDAP_SUCCESS) { + printf("ABBCBCBCBBCBC %d %s\n", __LINE__, __FILE__); return (rv); + } st->instance = conn; st->destroy_fn = destroy_fn; + printf("ABBCBCBCBBCBC %d %s\n", __LINE__, __FILE__); return (NSS_LDAP_SUCCESS); } void tls_return_connection_def(struct nss_ldap_connection *conn) { + printf("ABBCBCBCBBCBC %d %s\n", __LINE__, __FILE__); /* DO NOTHING */ } @@ -223,6 +227,7 @@ assert(method != NULL); + printf("GET_CONNECTION %d %s\n", __LINE__, __FILE__); return (method->get_connection_fn(res)); } @@ -233,7 +238,7 @@ { assert(method != NULL); - + printf("SET_CONNECTION %d %s\n", __LINE__, __FILE__); return (method->set_connection_fn(conn, destroy_fn)); } @@ -243,7 +248,7 @@ { assert(method != NULL); - + printf("RETURN_CONNECTION %d %s\n", __LINE__, __FILE__); return (method->return_connection_fn(conn)); } ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldaptls.h#7 (text+ko) ==== ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldaputil.c#9 (text+ko) ==== ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldaputil.h#9 (text+ko) ==== ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/nss_ldap.c#9 (text+ko) ==== @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include "ldapschema.h" @@ -139,15 +140,20 @@ isthreaded = __isthreaded; path = NSS_LDAP_CONF_PATH; printf("conf- %s %d\n", __FILE__, __LINE__); - if ((__nss_ldap_conf != NULL) && (stat(path, &statbuf) != 0)) + memset(&statbuf, 0, sizeof(statbuf)); + result = stat(path, &statbuf); + printf("RV %d\n", result); + if ((__nss_ldap_conf != NULL) && (result != 0)) return (0); printf("conf- %s %d\n", __FILE__, __LINE__); if ((__nss_ldap_conf != NULL) && (statbuf.st_mtime <= confmod)) return (0); + printf("-=-=-=-= %s %ld %ld %p\n",path, statbuf.st_mtime, confmod, (void *)__nss_ldap_conf); if (isthreaded) { - result = pthread_mutex_trylock(&conf_lock); + result = pthread_mutex_lock(&conf_lock); if (result != 0) - return (0); + return (NSS_LDAP_GENERIC_ERROR); + result = pthread_rwlock_wrlock(&nss_ldap_lock); if (result != 0) goto fin2; @@ -158,17 +164,23 @@ printf("conf %s %d\n", __FILE__, __LINE__); atexit(nss_ldap_atexit); } + + printf("-=-=-=-=1 %s %ld %ld %p\n",path, statbuf.st_mtime, confmod, (void *)__nss_ldap_conf); confmod = statbuf.st_mtime; + printf("-=-=-=-=2 %s %ld %ld %p\n",path, statbuf.st_mtime, confmod, (void *)__nss_ldap_conf); memset(&config_file_error, 0, sizeof(struct nss_ldap_config_file_error)); __nss_ldap_init_default_config(&nss_ldap_conf); result = __nss_ldap_load_config_from_file(&nss_ldap_conf, path, &config_file_error); + result = __nss_ldap_load_config_from_file(&nss_ldap_conf, path, + &config_file_error); if (result == NSS_LDAP_SUCCESS) __nss_ldap_conf = &nss_ldap_conf; else { /* TODO: proper error handling */ + printf("I HATE THIS WORLD!\n"); } printf("conf %s %d\n", __FILE__, __LINE__); @@ -313,6 +325,7 @@ rv = __nss_ldap_auth(connection_method, *conn, __nss_ldap_conf, conn_error); if (rv != NSS_LDAP_SUCCESS) { + printf(">>>>>>>>>>>> %s %d\n", __FILE__, __LINE__); rv = __nss_ldap_disconnect(connection_method, *conn, __nss_ldap_conf, conn_error); if (rv != NSS_LDAP_SUCCESS) { @@ -536,6 +549,7 @@ if (tls_method == NULL) { if (pctx != NULL) { sctx = pctx->sctx; + printf("PARSECONTEXTDOOOOOOOOOOOOOONe %p %p\n", (void *)tls_method, (void *)pctx); __nss_ldap_end_parsing(pctx); if (sctx != NULL) @@ -546,10 +560,35 @@ } static int +nss_ldap_set_sigpipe_mask(sigset_t *oset) +{ + sigset_t new; + + sigemptyset(oset); + sigemptyset(&new); + + sigaddset(&new, SIGPIPE); + if (__isthreaded != 0) + return (pthread_sigmask(SIG_BLOCK, &new, oset)); + else + return (sigprocmask(SIG_BLOCK, &new, oset)); +} + +static int +nss_ldap_unset_sigpipe_mask(sigset_t *oset) +{ + if (__isthreaded != 0) + return (pthread_sigmask(SIG_SETMASK, oset, NULL)); + else + return (sigprocmask(SIG_SETMASK, oset, NULL)); +} + +static int nss_ldap_get_common(int map_id, char const *filter, void *mdata, char *buffer, size_t bufsize, nss_ldap_parse_next_fn parse_next_fn, nss_ldap_parse_destroy_fn parse_destroy_fn, int parse_tls) { + sigset_t signal_mask; struct nss_ldap_connection_method *connection_method; struct nss_ldap_search_method *search_method; struct nss_ldap_tls_method *tls_method; @@ -557,7 +596,7 @@ struct nss_ldap_connection_error conn_error; struct nss_ldap_connection *conn; struct nss_ldap_parse_context *pctx, pctx_model; - int rv, conn_flag; + int rv, conn_flag, signals_rv; assert(map_id < NSS_LDAP_MAP_MAX); assert(filter != NULL); @@ -568,6 +607,12 @@ search_method = &__nss_ldap_conf->search_method; tls_method = &__nss_ldap_conf->tls_method; + signals_rv = nss_ldap_set_sigpipe_mask(&signal_mask); + if (signals_rv != 0) { + printf("OMG! can't set signal mask!\n"); + /* TODO: do something really weird */ + } + pctx = NULL; conn = NULL; conn_flag = 0; @@ -642,6 +687,14 @@ parse_tls != 0 ? tls_method : NULL, pctx, map_id); if (conn != NULL) nss_ldap_connection_done(tls_method, conn); + + if (signals_rv == 0) { + signals_rv = nss_ldap_unset_sigpipe_mask(&signal_mask); + if (signals_rv != 0) { + printf("OMG!\n"); + /* TODO: do something */ + } + } // else // nss_ldap_connection_reset(tls_method, conn); @@ -687,6 +740,8 @@ { int rv, isthreaded; + printf("saasas\n"); + rv = nss_ldap_configure(); if (rv != NSS_LDAP_SUCCESS) return (NS_UNAVAIL); @@ -710,10 +765,11 @@ void __nss_ldap_setent(int map_id) { + sigset_t signal_mask; struct nss_ldap_search_method *search_method; struct nss_ldap_tls_method *tls_method; struct nss_ldap_parse_context *pctx; - int rv, isthreaded; + int rv, isthreaded, signals_rv; assert(map_id < NSS_LDAP_MAP_MAX); @@ -738,6 +794,12 @@ return; } + signals_rv = nss_ldap_set_sigpipe_mask(&signal_mask); + if (signals_rv != 0) { + printf("OMG! can't set signal mask!\n"); + /* TODO: do something really weird */ + } + if (pctx != NULL) parse_context_destroy_func(pctx); @@ -749,6 +811,14 @@ __nss_ldap_tls_return_parse_context(tls_method, map_id, NULL); + if (signals_rv == 0) { + signals_rv = nss_ldap_unset_sigpipe_mask(&signal_mask); + if (signals_rv != 0) { + printf("OMG!\n"); + /* TODO: do something */ + } + } + if (isthreaded) pthread_rwlock_unlock(&nss_ldap_lock); } ==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/nss_ldap.h#9 (text+ko) ====