Full_Name: Mark Adamson Version: DEV Beta OS: Solaris 2.7 URL: http://nil.andrew.cmu.edu/ldap/sasl_setip.gdiff Submission from: (NULL) (128.2.122.223) I'm running the BETA version of OpenLDAP, downloaded July 7th. I was testing the SASL authentication implementation, using the KERBEROS_V4 mechanism. I was getting the following message from client programs: ldap_negotiated_sasl_bind_s: Unknown error additional info: couldn't get local IP address I found that the server was returning this message to the client because the sasl_bind() call was not setting the IP address properties using sasl_setprop(). Appended to this message is a patch to servers/slapd/sasl.c that will set the properties SASL_IP_LOCAL and SASL_IP_REMOTE when the new bind connection context is being initialized. -Mark Adamson Carnegie Mellon *** .old/sasl.c Thu Jul 6 11:13:01 2000 --- sasl.c Mon Jul 10 14:07:48 2000 *************** *** 93,100 **** --- 93,103 ---- int sasl_init( void ) { + char hebuf[256]; int rc; char *mechs; + struct hostent he; + struct sockaddr_in sin; sasl_conn_t *server = NULL; sasl_set_alloc( ch_malloc, ch_calloc, ch_realloc, ch_free ); *************** *** 244,249 **** --- 247,257 ---- } else { unsigned reslen; + char hebuf[256], namebuf[MAXHOSTNAMELEN]; + int rc, fd; + struct hostent he; + struct sockaddr_in sin; + conn->c_authmech = ch_strdup( mech ); sc = sasl_server_start( conn->c_sasl_bind_context, *************** *** 257,262 **** --- 265,287 ---- send_ldap_result( conn, op, rc = slap_sasl_err2ldap( sc ), NULL, errstr, NULL, NULL ); } + + gethostname( namebuf, sizeof(namebuf) ); + namebuf[ sizeof( namebuf ) - 1 ] = '\0'; + gethostbyname_r( namebuf, &he, hebuf, sizeof(hebuf), &rc ); + if (rc == 0) { + sin.sin_family = AF_INET; + memcpy( &sin.sin_addr.s_addr, he.h_addr_list[0], 4 ); + sasl_setprop( conn->c_sasl_bind_context, SASL_IP_LOCAL, &sin ); + } + + ber_sockbuf_ctrl( conn->c_sb, LBER_SB_OPT_GET_FD, &fd ); + rc = sizeof( sin ); + rc = getpeername( fd, (struct sockaddr *)&sin, &rc ); + if (rc == 0) { + sasl_setprop( conn->c_sasl_bind_context, SASL_IP_REMOTE, &sin ); + } + } } else {
changed notes changed state Open to Feedback moved from Incoming to Development
changed notes changed state Feedback to Closed
under discussion in -devel not to be applied for now.