/* $OpenLDAP$ */
/*
- * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
if( strcmp( slapd_srvurls[i], "ldap:///" ) == 0) {
char *host = ldap_pvt_get_fqdn( NULL );
if ( host != NULL ) {
- slapd_srvurls[i] = (char *) realloc( slapd_srvurls[i],
+ slapd_srvurls[i] = (char *) ch_realloc( slapd_srvurls[i],
strlen( host ) +
sizeof( LDAP_SRVTYPE_PREFIX ) );
strcpy( lutil_strcopy(slapd_srvurls[i],
} else if ( strcmp( slapd_srvurls[i], "ldaps:///" ) == 0) {
char *host = ldap_pvt_get_fqdn( NULL );
if ( host != NULL ) {
- slapd_srvurls[i] = (char *) realloc( slapd_srvurls[i],
+ slapd_srvurls[i] = (char *) ch_realloc( slapd_srvurls[i],
strlen( host ) +
sizeof( LDAPS_SRVTYPE_PREFIX ) );
strcpy( lutil_strcopy(slapd_srvurls[i],
return -1;
#endif
} else {
-#ifdef LDAP_CONNECTIONLESS
- l.sl_is_udp = ( tmp == LDAP_PROTO_UDP );
-#endif
if( lud->lud_host == NULL || lud->lud_host[0] == '\0'
|| strcmp(lud->lud_host, "*") == 0 )
{
err = slap_get_listener_addresses(lud->lud_host, port, &sal);
}
}
+#ifdef LDAP_CONNECTIONLESS
+ l.sl_is_udp = ( tmp == LDAP_PROTO_UDP );
+#endif
#if defined(LDAP_PF_LOCAL) || defined(SLAP_X_LISTENER_MOD)
if ( lud->lud_exts ) {
fd_set writefds;
Sockaddr from;
-#if defined(SLAPD_RLOOKUPS)
- struct hostent *hp;
-#endif
struct timeval zero;
struct timeval *tvp;
long id;
slap_ssf_t ssf = 0;
char *authid = NULL;
+#ifdef SLAPD_RLOOKUPS
+ char hbuf[NI_MAXHOST];
+#endif
char *dnsname = NULL;
char *peeraddr = NULL;
case AF_LOCAL:
sprintf( peername, "PATH=%s", from.sa_un_addr.sun_path );
ssf = LDAP_PVT_SASL_LOCAL_SSF;
+ {
+ uid_t uid;
+ gid_t gid;
+
+ if( getpeereid( s, &uid, &gid ) == 0 ) {
+ authid = ch_malloc(
+ sizeof("uidnumber=4294967295+gidnumber=4294967295,"
+ "cn=peercred,cn=external,cn=auth"));
+ sprintf(authid, "uidnumber=%d+gidnumber=%d,"
+ "cn=peercred,cn=external,cn=auth",
+ (int) uid, (int) gid);
+ }
+ }
dnsname = "local";
break;
#endif /* LDAP_PF_LOCAL */
) {
#ifdef SLAPD_RLOOKUPS
if ( use_reverse_lookup ) {
-# ifdef LDAP_PF_INET6
- if ( from.sa_addr.sa_family == AF_INET6 )
- hp = gethostbyaddr(
- (char *)&(from.sa_in6_addr.sin6_addr),
- sizeof(from.sa_in6_addr.sin6_addr),
- AF_INET6 );
- else
-# endif /* LDAP_PF_INET6 */
- hp = gethostbyaddr(
- (char *) &(from.sa_in_addr.sin_addr),
- sizeof(from.sa_in_addr.sin_addr),
- AF_INET );
- dnsname = hp ? ldap_pvt_str2lower( hp->h_name ) : NULL;
+ char *herr;
+ if (ldap_pvt_get_hname( &from, len, hbuf,
+ sizeof(hbuf), &herr ) == 0) {
+ ldap_pvt_str2lower( hbuf );
+ dnsname = hbuf;
+ }
}
#else
dnsname = NULL;
SLAP_STRING_UNKNOWN ))
{
/* DENY ACCESS */
- Statslog( LDAP_DEBUG_ANY,
- "fd=%ld host access from %s (%s) denied.\n",
+ Statslog( LDAP_DEBUG_STATS,
+ "fd=%ld DENIED from %s (%s)",
(long) s,
dnsname != NULL ? dnsname : SLAP_STRING_UNKNOWN,
peeraddr != NULL ? peeraddr : SLAP_STRING_UNKNOWN,
}
Statslog( LDAP_DEBUG_STATS,
- "daemon: conn=%ld fd=%ld connection from %s "
- "(%s) accepted.\n",
+ "conn=%ld fd=%ld ACCEPT from %s (%s)\n",
id, (long) s,
peername,
slap_listeners[l]->sl_name.bv_val,
#endif
}
- if( slapd_gentle_shutdown != 2 )
+ if( slapd_gentle_shutdown != 2 ) {
close_listeners ( 0 );
+ }
+
free ( slap_listeners );
slap_listeners = NULL;
+ if( !slapd_gentle_shutdown ) {
+ connections_shutdown();
+ }
+
#ifdef NEW_LOGGING
LDAP_LOG( CONNECTION, CRIT,
"slapd_daemon_task: shutdown waiting for %d threads to terminate.\n",