AC_MEMCPY( buf, sbiod->sbiod_sb->sb_ungetbuf, blen );
buf += blen;
len -= blen;
- if ( blen < sbiod->sbiod_sb->sb_ungetlen ) {
- sbiod->sbiod_sb->sb_ungetlen -= blen;
+ sbiod->sbiod_sb->sb_ungetlen -= blen;
+ if ( sbiod->sbiod_sb->sb_ungetlen ) {
AC_MEMCPY( sbiod->sbiod_sb->sb_ungetbuf,
sbiod->sbiod_sb->sb_ungetbuf+blen,
sbiod->sbiod_sb->sb_ungetlen );
#include <sys/types.h>
#include <ac/unistd.h>
+#include <ac/socket.h>
+#include <ac/errno.h>
+
+#ifdef HAVE_GETPEERUCRED
+#include <ucred.h>
+#endif
+
#ifdef LDAP_PF_LOCAL_SENDMSG
#include <lber.h>
#ifdef HAVE_SYS_UIO_H
#include <sys/stat.h>
#endif
-#include <ac/socket.h>
-#include <ac/errno.h>
-
-#ifdef HAVE_GETPEERUCRED
-#include <ucred.h>
-#endif
-
#ifdef HAVE_SYS_UCRED_H
#ifdef HAVE_GRP_H
#include <grp.h> /* for NGROUPS on Tru64 5.1 */
*egid = st.st_gid;
return 0;
}
- } else if ( peer->bv_len < 0 ) {
- peer->bv_len = 0;
+ } else if ( peerbv->bv_len < 0 ) {
+ peerbv->bv_len = 0;
}
#elif defined(SOCKCREDSIZE)
struct msghdr msg;
const char* peername,
int flags,
slap_ssf_t ssf,
- struct berval *authid )
+ struct berval *authid
+#ifdef LDAP_PF_LOCAL_SENDMSG
+ , struct berval *peerbv
+#endif
+)
{
unsigned long id;
Connection *c;
assert( peername != NULL );
#ifndef HAVE_TLS
- assert( flags != CONN_IS_TLS );
+ assert( !( flags & CONN_IS_TLS ));
#endif
if( s == AC_SOCKET_INVALID ) {
c->c_listener = listener;
- if ( flags == CONN_IS_CLIENT ) {
+ if ( flags & CONN_IS_CLIENT ) {
c->c_connid = 0;
c->c_conn_state = SLAP_C_CLIENT;
c->c_struct_state = SLAP_C_USED;
#ifdef LDAP_CONNECTIONLESS
c->c_is_udp = 0;
- if( flags == CONN_IS_UDP ) {
+ if( flags & CONN_IS_UDP ) {
c->c_is_udp = 1;
#ifdef LDAP_DEBUG
ber_sockbuf_add_io( c->c_sb, &ber_sockbuf_io_debug,
ber_sockbuf_add_io( c->c_sb, &ber_sockbuf_io_readahead,
LBER_SBIOD_LEVEL_PROVIDER, NULL );
} else
+#endif /* LDAP_CONNECTIONLESS */
+#ifdef LDAP_PF_LOCAL
+ if ( flags & CONN_IS_IPC ) {
+#ifdef LDAP_DEBUG
+ ber_sockbuf_add_io( c->c_sb, &ber_sockbuf_io_debug,
+ LBER_SBIOD_LEVEL_PROVIDER, (void*)"ipc_" );
#endif
+ ber_sockbuf_add_io( c->c_sb, &ber_sockbuf_io_fd,
+ LBER_SBIOD_LEVEL_PROVIDER, (void *)&s );
+#ifdef LDAP_PF_LOCAL_SENDMSG
+ if ( !BER_BVISEMPTY( peerbv ))
+ ber_sockbuf_ctrl( c->c_sb, LBER_SB_OPT_UNGET_BUF, peerbv );
+#endif
+ } else
+#endif /* LDAP_PF_LOCAL */
{
#ifdef LDAP_DEBUG
ber_sockbuf_add_io( c->c_sb, &ber_sockbuf_io_debug,
c->c_tls_ssf = 0;
#ifdef HAVE_TLS
- if ( flags == CONN_IS_TLS ) {
+ if ( flags & CONN_IS_TLS ) {
c->c_is_tls = 1;
c->c_needs_tls_accept = 1;
} else {
Connection *c;
c = connection_init( s, (Listener *)&dummy_list, "", "",
- CONN_IS_CLIENT, 0, NULL );
+ CONN_IS_CLIENT, 0, NULL
+#ifdef LDAP_PF_LOCAL_SENDMSG
+ , NULL
+#endif
+ );
if ( !c ) return -1;
c->c_clientfunc = func;
#else /* ! LDAP_PF_LOCAL && ! LDAP_PF_INET6 */
char peername[sizeof("IP=255.255.255.255:65336")];
#endif /* LDAP_PF_LOCAL */
+ int cflag;
Debug( LDAP_DEBUG_TRACE,
">>> slap_listener(%s)\n",
"daemon: listen=%ld, new connection on %ld\n",
(long) sl->sl_sd, (long) s, 0 );
+ cflag = 0;
switch ( from.sa_addr.sa_family ) {
# ifdef LDAP_PF_LOCAL
case AF_LOCAL:
+ cflag |= CONN_IS_IPC;
+
/* FIXME: apparently accept doesn't fill
* the sun_path sun_path member */
if ( from.sa_un_addr.sun_path[0] == '\0' ) {
#endif /* HAVE_TCPD */
}
+#ifdef HAVE_TLS
+ if ( sl->sl_is_tls ) cflag |= CONN_IS_TLS;
+#endif
c = connection_init(s, sl,
dnsname != NULL ? dnsname : SLAP_STRING_UNKNOWN,
- peername,
-#ifdef HAVE_TLS
- sl->sl_is_tls ? CONN_IS_TLS : 0,
-#else /* ! HAVE_TLS */
- 0,
-#endif /* ! HAVE_TLS */
- ssf,
- authid.bv_val ? &authid : NULL );
+ peername, cflag, ssf,
+ authid.bv_val ? &authid : NULL
+#ifdef LDAP_PF_LOCAL_SENDMSG
+ , &peerbv
+#endif
+ );
if( authid.bv_val ) ch_free(authid.bv_val);
return 0;
}
-#ifdef LDAP_PF_LOCAL_SENDMSG
- if ( !BER_BVISEMPTY( &peerbv ))
- ber_sockbuf_ctrl( c->c_sb, LBER_SB_OPT_UNGET_BUF, &peerbv );
-#endif
-
Statslog( LDAP_DEBUG_STATS,
"conn=%ld fd=%ld ACCEPT from %s (%s)\n",
c->c_connid, (long) s, peername, sl->sl_name.bv_val,
}
c = connection_init( lr->sl_sd, lr, "", "",
- CONN_IS_UDP, (slap_ssf_t) 0, NULL );
+ CONN_IS_UDP, (slap_ssf_t) 0, NULL
+#ifdef LDAP_PF_LOCAL_SENDMSG
+ , NULL
+#endif
+ );
if ( !c ) {
Debug( LDAP_DEBUG_TRACE,
const char* peername,
int use_tls,
slap_ssf_t ssf,
- struct berval *id ));
+ struct berval *id
+#ifdef LDAP_PF_LOCAL_SENDMSG
+ , struct berval *peerbv
+#endif
+ ));
LDAP_SLAPD_F (void) connection_closing LDAP_P((
Connection *c, const char *why ));
#define CONN_IS_TLS 1
#define CONN_IS_UDP 2
-#define CONN_IS_CLIENT 3
+#define CONN_IS_CLIENT 4
+#define CONN_IS_IPC 8
#ifdef LDAP_CONNECTIONLESS
int c_is_udp; /* true if this is (C)LDAP over UDP */