ns_connect.c revision 47789246278f5a31cca77e9dff187c916ada68ac
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A#include <nsswitch.h>
2N/A#include <nss_dbdefs.h>
2N/A#include "solaris-priv.h"
2N/A#include "ns_sldap.h"
2N/A#include "ns_internal.h"
2N/A#include "ns_cache_door.h"
2N/A int, ns_ldap_error_t **, int, int);
2N/Astatic int sessionPoolSize = 0;
2N/Astatic int nscdChecked = 0;
2N/A return (NS_LDAP_OP_FAILED);
2N/A return (NS_LDAP_CONFIG);
2N/A return (NS_LDAP_MEMORY);
2N/A return (NS_LDAP_SUCCESS);
2N/A return (NS_LDAP_OP_FAILED);
2N/A return (NS_LDAP_OP_FAILED);
2N/A return (NS_LDAP_MEMORY);
2N/A _SASLMECHANISM_LEN) == 0) {
2N/A return (NS_LDAP_MEMORY);
2N/A return (NS_LDAP_MEMORY);
2N/A _SUPPORTEDCONTROL_LEN) == 0) {
2N/A return (NS_LDAP_MEMORY);
2N/A return (NS_LDAP_MEMORY);
return (NS_LDAP_SUCCESS);
#ifdef DEBUG
if (!con)
#ifdef DEBUG
sizeof (struct connection **));
if (!sessionPool) {
#ifdef DEBUG
if (i == sessionPoolSize) {
sizeof (Connection *));
if (!cl) {
#ifdef DEBUG
#ifdef DEBUG
return (i + CONID_OFFSET);
int id;
return (cID);
#ifdef DEBUG
for (i = 0; i < sessionPoolSize; ++i) {
#ifdef DEBUG
#ifdef DEBUG
return (i + CONID_OFFSET);
int nopasswd_acct_mgmt)
int passwd_mgmt = 0;
return (NS_LDAP_INVALID_PARAM);
#ifdef DEBUG
return (NS_LDAP_SUCCESS);
if (serverAddr) {
return (NS_LDAP_OP_FAILED);
goto create_con;
return (rc);
if (*errorp) {
if (host)
return (NS_LDAP_OP_FAILED);
if (host)
return (NS_LDAP_MEMORY);
if (nopasswd_acct_mgmt &&
host);
return (NS_LDAP_OP_FAILED);
host);
if (*errorp) {
return (rc);
if (host)
if (*errorp) {
return (NS_LDAP_MEMORY);
if (*errorp) {
return (NS_LDAP_MEMORY);
if (*errorp) {
return (NS_LDAP_MEMORY);
#ifdef DEBUG
return (exit_rc);
int id;
#ifdef DEBUG
if (use_mutex)
if (use_mutex)
if (!fini &&
if (use_mutex)
if (use_mutex)
* bind_type: "simple" or "sasl/DIGEST-MD5"
int fail_if_new_pwd_reqd,
int passwd_mgmt)
int exit_rc;
int sec_until_exp = 0;
if (errmsg &&
if (errmsg) {
if (passwd_mgmt)
NULL);
if (controls)
return (NS_LDAP_INTERNAL);
* in the ldap.h header file) is the
* defined in the ldap.h header file)
LDAP_CONTROL_PWEXPIRED) == 0) {
if (fail_if_new_pwd_reqd) {
sizeof (errstr),
NULL);
NULL,
NULL);
exit_rc =
LDAP_CONTROL_PWEXPIRING) == 0) {
if ((*ctrl)->
(*ctrl)->
NULL,
NULL);
exit_rc =
if (controls)
return (exit_rc);
const char *name;
int found = 0;
return (found);
char *digest_md5_name;
int zero = 0;
int rc;
int errnum = 0;
int msgId;
int useSSL = 0;
char *sslServerAddr;
char *s1;
char *errmsg;
int pwd_rc;
case NS_LDAP_AUTH_NONE:
case NS_LDAP_AUTH_SIMPLE:
case NS_LDAP_AUTH_SASL:
case NS_LDAP_AUTH_TLS:
case NS_LDAP_TLS_NONE:
case NS_LDAP_TLS_SIMPLE:
case NS_LDAP_TLS_SASL:
return (NS_LDAP_INTERNAL);
NULL);
return (NS_LDAP_INTERNAL);
if (useSSL) {
const char *hostcertpath;
#ifdef DEBUG
return (NS_LDAP_MEMORY);
if (alloc_hcp)
return (NS_LDAP_INTERNAL);
if (alloc_hcp)
if (s == NULL)
s = serverAddr;
if (s != NULL) {
return (NS_LDAP_MEMORY);
return (NS_LDAP_INTERNAL);
#ifdef DEBUG
return (NS_LDAP_INTERNAL);
if (ldap_in_hosts_switch() > 0 &&
"in /etc/nsswitch.conf"));
return (NS_LDAP_INTERNAL);
switch (bindType) {
case NS_LDAP_AUTH_NONE:
#ifdef DEBUG
case NS_LDAP_AUTH_SIMPLE:
return (NS_LDAP_INTERNAL);
#ifdef DEBUG
(void *)&errnum);
NULL);
return (NS_LDAP_INTERNAL);
(void *)&errnum);
NULL);
return (NS_LDAP_INTERNAL);
return (NS_LDAP_INTERNAL);
return (pwd_rc);
return (pwd_rc);
case NS_LDAP_AUTH_SASL:
return (NS_LDAP_INTERNAL);
return (NS_LDAP_INTERNAL);
case NS_LDAP_SASL_CRAM_MD5:
return (NS_LDAP_INTERNAL);
case NS_LDAP_SASL_DIGEST_MD5:
return (NS_LDAP_MEMORY);
return (NS_LDAP_INTERNAL);
return (NS_LDAP_INTERNAL);
return (pwd_rc);
return (pwd_rc);
NULL);
return (NS_LDAP_INTERNAL);
return (NS_LDAP_SUCCESS);
int *cLevel,
int getUid = 0;
int getPasswd = 0;
int getCertpath = 0;
int rc = 0;
#ifdef DEBUG
return (NS_LDAP_INVALID_PARAM);
return (NS_LDAP_INVALID_PARAM);
return (NS_LDAP_MEMORY);
case NS_LDAP_AUTH_NONE:
return (NS_LDAP_SUCCESS);
case NS_LDAP_AUTH_SIMPLE:
getUid++;
getPasswd++;
case NS_LDAP_AUTH_SASL:
getUid++;
getPasswd++;
return (NS_LDAP_INVALID_PARAM);
case NS_LDAP_AUTH_TLS:
getUid++;
getPasswd++;
getCertpath++;
getCertpath++;
return (NS_LDAP_INVALID_PARAM);
if (getUid) {
return (rc);
return (NS_LDAP_INVALID_PARAM);
return (NS_LDAP_MEMORY);
if (getPasswd) {
return (rc);
return (NS_LDAP_INVALID_PARAM);
return (NS_LDAP_INVALID_PARAM);
if (getCertpath) {
return (rc);
return (NS_LDAP_INVALID_PARAM);
return (NS_LDAP_MEMORY);
return (NS_LDAP_SUCCESS);
const char *server,
const int flags,
int fail_if_new_pwd_reqd,
int nopasswd_acct_mgmt)
int rc;
return (NS_LDAP_INVALID_PARAM);
if (*sessionId > 0) {
return (NS_LDAP_SUCCESS);
*sessionId = 0;
return (rc);
return (NS_LDAP_CONFIG);
if (*errorp)
return (rc);
return (NS_LDAP_MEMORY);
return (NS_LDAP_MEMORY);
return (rc);
return (NS_LDAP_MEMORY);
return (NS_LDAP_MEMORY);
rc ==
goto done;
rc ==
goto done;
done:
return (rc);
int id;
sessionPoolSize = 0;