Commit bf2a1e11 authored by Quanah Gibson-Mount's avatar Quanah Gibson-Mount
Browse files

Merge remote-tracking branch 'origin/master' into OPENLDAP_REL_ENG_2_5

parents 2be22ecd 56860fc4
......@@ -530,29 +530,32 @@ dnl Check for declaration of sys_errlist in one of stdio.h and errno.h.
dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration.
dnl Reported by Keith Bostic.
AC_DEFUN([OL_SYS_ERRLIST],
[AC_CACHE_CHECK([declaration of sys_errlist],ol_cv_dcl_sys_errlist,[
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
[AC_CACHE_CHECK([existence of sys_errlist],ol_cv_have_sys_errlist,[
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <errno.h>]], [[char *c = (char *) *sys_errlist]])],[ol_cv_have_sys_errlist=yes],[ol_cv_have_sys_errlist=no])])
if test $ol_cv_have_sys_errlist = yes ; then
AC_DEFINE(HAVE_SYS_ERRLIST,1,
[define if you actually have sys_errlist in your libs])
AC_CACHE_CHECK([declaration of sys_errlist],ol_cv_dcl_sys_errlist,[
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <stdio.h>
#include <sys/types.h>
#include <errno.h>
#ifdef _WIN32
#include <stdlib.h>
#endif ]], [[char *c = (char *) *sys_errlist]])],[ol_cv_dcl_sys_errlist=yes
ol_cv_have_sys_errlist=yes],[ol_cv_dcl_sys_errlist=no])])
#endif ]], [[char *c = (char *) *sys_errlist]])],[ol_cv_dcl_sys_errlist=yes],
[ol_cv_dcl_sys_errlist=no])])
#
# It's possible (for near-UNIX clones) that sys_errlist doesn't exist
if test $ol_cv_dcl_sys_errlist = no ; then
AC_DEFINE(DECL_SYS_ERRLIST,1,
[define if sys_errlist is not declared in stdio.h or errno.h])
AC_CACHE_CHECK([existence of sys_errlist],ol_cv_have_sys_errlist,[
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <errno.h>]], [[char *c = (char *) *sys_errlist]])],[ol_cv_have_sys_errlist=yes],[ol_cv_have_sys_errlist=no])])
fi
if test $ol_cv_have_sys_errlist = yes ; then
AC_DEFINE(HAVE_SYS_ERRLIST,1,
[define if you actually have sys_errlist in your libs])
# It's possible (for near-UNIX clones) that sys_errlist doesn't exist
if test $ol_cv_dcl_sys_errlist = no ; then
AC_DEFINE(DECL_SYS_ERRLIST,1,
[define if sys_errlist is not declared in stdio.h or errno.h])
fi
fi
])dnl
dnl
dnl ====================================================================
dnl glibc supplies a non-standard strerror_r if _GNU_SOURCE is defined.
dnl It's actually preferable to the POSIX version, if available.
AC_DEFUN([OL_NONPOSIX_STRERROR_R],
[AC_CACHE_CHECK([non-posix strerror_r],ol_cv_nonposix_strerror_r,[
AC_EGREP_CPP(strerror_r,[#include <string.h>],
......@@ -572,7 +575,7 @@ AC_DEFUN([OL_NONPOSIX_STRERROR_R],
strerror_r( 1, buf, sizeof buf );
exit( buf[0] == 0 );
}
]])],[ol_cv_nonposix_strerror_r=yes],[ol_cv_nonposix_strerror=no],[ol_cv_nonposix_strerror=no])
]])],[ol_cv_nonposix_strerror_r=yes],[ol_cv_nonposix_strerror_r=no],[ol_cv_nonposix_strerror_r=no])
fi
])
if test $ol_cv_nonposix_strerror_r = yes ; then
......@@ -582,8 +585,7 @@ fi
])dnl
dnl
AC_DEFUN([OL_STRERROR],
[OL_SYS_ERRLIST dnl TEMPORARY
AC_CHECK_FUNCS(strerror strerror_r)
[AC_CHECK_FUNCS(strerror strerror_r)
ol_cv_func_strerror_r=no
if test "${ac_cv_func_strerror_r}" = yes ; then
OL_NONPOSIX_STRERROR_R
......
......@@ -16112,80 +16112,7 @@ fi
 
fi
 
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking declaration of sys_errlist" >&5
$as_echo_n "checking declaration of sys_errlist... " >&6; }
if ${ol_cv_dcl_sys_errlist+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <stdio.h>
#include <sys/types.h>
#include <errno.h>
#ifdef _WIN32
#include <stdlib.h>
#endif
int
main ()
{
char *c = (char *) *sys_errlist
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ol_cv_dcl_sys_errlist=yes
ol_cv_have_sys_errlist=yes
else
ol_cv_dcl_sys_errlist=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_dcl_sys_errlist" >&5
$as_echo "$ol_cv_dcl_sys_errlist" >&6; }
#
# It's possible (for near-UNIX clones) that sys_errlist doesn't exist
if test $ol_cv_dcl_sys_errlist = no ; then
$as_echo "#define DECL_SYS_ERRLIST 1" >>confdefs.h
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking existence of sys_errlist" >&5
$as_echo_n "checking existence of sys_errlist... " >&6; }
if ${ol_cv_have_sys_errlist+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <errno.h>
int
main ()
{
char *c = (char *) *sys_errlist
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ol_cv_have_sys_errlist=yes
else
ol_cv_have_sys_errlist=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_have_sys_errlist" >&5
$as_echo "$ol_cv_have_sys_errlist" >&6; }
fi
if test $ol_cv_have_sys_errlist = yes ; then
$as_echo "#define HAVE_SYS_ERRLIST 1" >>confdefs.h
fi
for ac_func in strerror strerror_r
for ac_func in strerror strerror_r
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
......@@ -16241,7 +16168,7 @@ fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
else
if test "$cross_compiling" = yes; then :
ol_cv_nonposix_strerror=no
ol_cv_nonposix_strerror_r=no
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
......@@ -16257,7 +16184,7 @@ _ACEOF
if ac_fn_c_try_run "$LINENO"; then :
ol_cv_nonposix_strerror_r=yes
else
ol_cv_nonposix_strerror=no
ol_cv_nonposix_strerror_r=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
......@@ -16275,21 +16202,15 @@ $as_echo "#define HAVE_NONPOSIX_STRERROR_R 1" >>confdefs.h
fi
 
elif test "${ac_cv_func_strerror}" = no ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking declaration of sys_errlist" >&5
$as_echo_n "checking declaration of sys_errlist... " >&6; }
if ${ol_cv_dcl_sys_errlist+:} false; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking existence of sys_errlist" >&5
$as_echo_n "checking existence of sys_errlist... " >&6; }
if ${ol_cv_have_sys_errlist+:} false; then :
$as_echo_n "(cached) " >&6
else
 
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <stdio.h>
#include <sys/types.h>
#include <errno.h>
#ifdef _WIN32
#include <stdlib.h>
#endif
int
main ()
{
......@@ -16298,32 +16219,35 @@ char *c = (char *) *sys_errlist
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ol_cv_dcl_sys_errlist=yes
ol_cv_have_sys_errlist=yes
if ac_fn_c_try_link "$LINENO"; then :
ol_cv_have_sys_errlist=yes
else
ol_cv_dcl_sys_errlist=no
ol_cv_have_sys_errlist=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_dcl_sys_errlist" >&5
$as_echo "$ol_cv_dcl_sys_errlist" >&6; }
#
# It's possible (for near-UNIX clones) that sys_errlist doesn't exist
if test $ol_cv_dcl_sys_errlist = no ; then
$as_echo "#define DECL_SYS_ERRLIST 1" >>confdefs.h
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_have_sys_errlist" >&5
$as_echo "$ol_cv_have_sys_errlist" >&6; }
if test $ol_cv_have_sys_errlist = yes ; then
 
$as_echo "#define HAVE_SYS_ERRLIST 1" >>confdefs.h
 
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking existence of sys_errlist" >&5
$as_echo_n "checking existence of sys_errlist... " >&6; }
if ${ol_cv_have_sys_errlist+:} false; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking declaration of sys_errlist" >&5
$as_echo_n "checking declaration of sys_errlist... " >&6; }
if ${ol_cv_dcl_sys_errlist+:} false; then :
$as_echo_n "(cached) " >&6
else
 
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <stdio.h>
#include <sys/types.h>
#include <errno.h>
#ifdef _WIN32
#include <stdlib.h>
#endif
int
main ()
{
......@@ -16332,21 +16256,22 @@ char *c = (char *) *sys_errlist
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ol_cv_have_sys_errlist=yes
if ac_fn_c_try_compile "$LINENO"; then :
ol_cv_dcl_sys_errlist=yes
else
ol_cv_have_sys_errlist=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
ol_cv_dcl_sys_errlist=no
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_have_sys_errlist" >&5
$as_echo "$ol_cv_have_sys_errlist" >&6; }
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
if test $ol_cv_have_sys_errlist = yes ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_dcl_sys_errlist" >&5
$as_echo "$ol_cv_dcl_sys_errlist" >&6; }
#
# It's possible (for near-UNIX clones) that sys_errlist doesn't exist
if test $ol_cv_dcl_sys_errlist = no ; then
 
$as_echo "#define HAVE_SYS_ERRLIST 1" >>confdefs.h
$as_echo "#define DECL_SYS_ERRLIST 1" >>confdefs.h
 
fi
fi
 
fi
......
......@@ -168,8 +168,10 @@ static int dsaschema_read_config(const char *fname, int depth)
fp = fopen(fname, "r");
if (fp == NULL) {
char ebuf[128];
int saved_errno = errno;
fprintf(stderr, "could not open config file \"%s\": %s (%d)\n",
fname, strerror(errno), errno);
fname, AC_STRERROR_R(saved_errno, ebuf, sizeof(ebuf)), saved_errno);
return 1;
}
fp_getline_init(&lineno);
......
......@@ -86,8 +86,10 @@ static void debug_dump(const void *ptr, size_t size)
DEBUG_DUMP(ptr, size); \
if (tio_write(fp, ptr, (size_t)size)) \
{ \
char ebuf[128]; \
int saved_errno = errno; \
DEBUG_PRINT("WRITE : var="__STRING(ptr)" error: %s", \
strerror(errno)); \
AC_STRERROR_R(saved_errno, ebuf, sizeof(ebuf))); \
ERROR_OUT_WRITEERROR(fp); \
}
......@@ -161,8 +163,10 @@ static void debug_dump(const void *ptr, size_t size)
#define READ(fp, ptr, size) \
if (tio_read(fp, ptr, (size_t)size)) \
{ \
char ebuf[128]; \
int saved_errno = errno; \
DEBUG_PRINT("READ : var="__STRING(ptr)" error: %s", \
strerror(errno)); \
AC_STRERROR_R(saved_errno, ebuf, sizeof(ebuf))); \
ERROR_OUT_READERROR(fp); \
} \
DEBUG_PRINT("READ : var="__STRING(ptr)" size=%d", (int)(size)); \
......@@ -301,7 +305,10 @@ static void debug_dump(const void *ptr, size_t size)
/* read (skip) the specified number of bytes */ \
if (tio_skip(fp, sz)) \
{ \
DEBUG_PRINT("READ : skip error: %s", strerror(errno)); \
char ebuf[128]; \
int saved_errno = errno; \
DEBUG_PRINT("READ : skip error: %s", \
AC_STRERROR_R(saved_errno, ebuf, sizeof(ebuf))); \
ERROR_OUT_READERROR(fp); \
}
......@@ -350,7 +357,10 @@ TFILE *nslcd_client_open(void)
/* flush the stream */ \
if (tio_flush(fp) < 0) \
{ \
DEBUG_PRINT("WRITE_FLUSH : error: %s", strerror(errno)); \
char ebuf[128]; \
int saved_errno = errno; \
DEBUG_PRINT("WRITE_FLUSH : error: %s", \
AC_STRERROR_R(saved_errno, ebuf, sizeof(ebuf))); \
ERROR_OUT_WRITEERROR(fp); \
} \
/* read and check response version number */ \
......
......@@ -298,11 +298,15 @@ static void handleconnection(nssov_info *ni,int sock,Operation *op)
struct berval peerbv = { sizeof(peerbuf), peerbuf };
/* log connection */
if (LUTIL_GETPEEREID(sock,&uid,&gid,&peerbv))
Debug( LDAP_DEBUG_TRACE,"nssov: connection from unknown client: %s\n",strerror(errno) );
else
if (LUTIL_GETPEEREID(sock,&uid,&gid,&peerbv)) {
char ebuf[128];
int saved_errno = errno;
Debug( LDAP_DEBUG_TRACE,"nssov: connection from unknown client: %s\n",
AC_STRERROR_R(saved_errno, ebuf, sizeof(ebuf)) );
} else {
Debug( LDAP_DEBUG_TRACE,"nssov: connection from uid=%d gid=%d\n",
(int)uid,(int)gid );
}
/* Should do authid mapping too */
op->o_dn.bv_len = sprintf(authid,"gidNumber=%d+uidNumber=%d,cn=peercred,cn=external,cn=auth",
......@@ -322,7 +326,10 @@ static void handleconnection(nssov_info *ni,int sock,Operation *op)
READBUFFER_MINSIZE,READBUFFER_MAXSIZE,
WRITEBUFFER_MINSIZE,WRITEBUFFER_MAXSIZE))==NULL)
{
Debug( LDAP_DEBUG_ANY,"nssov: cannot create stream for writing: %s",strerror(errno) );
char ebuf[128];
int saved_errno = errno;
Debug( LDAP_DEBUG_ANY,"nssov: cannot create stream for writing: %s",
AC_STRERROR_R(saved_errno, ebuf, sizeof(ebuf)) );
(void)close(sock);
return;
}
......@@ -403,27 +410,43 @@ static void *acceptconn(void *ctx, void *arg)
connection_client_enable(ni->ni_conn);
if (csock<0)
{
char ebuf[128];
int saved_errno = errno;
if ((errno==EINTR)||(errno==EAGAIN)||(errno==EWOULDBLOCK))
{
Debug( LDAP_DEBUG_TRACE,"nssov: accept() failed (ignored): %s",strerror(errno) );
Debug( LDAP_DEBUG_TRACE,"nssov: accept() failed (ignored): %s",
AC_STRERROR_R(saved_errno, ebuf, sizeof(ebuf)) );
return NULL;
}
Debug( LDAP_DEBUG_ANY,"nssov: accept() failed: %s",strerror(errno) );
Debug( LDAP_DEBUG_ANY,"nssov: accept() failed: %s",
AC_STRERROR_R(saved_errno, ebuf, sizeof(ebuf)) );
return NULL;
}
/* make sure O_NONBLOCK is not inherited */
if ((j=fcntl(csock,F_GETFL,0))<0)
{
Debug( LDAP_DEBUG_ANY,"nssov: fcntl(F_GETFL) failed: %s",strerror(errno) );
if (close(csock))
Debug( LDAP_DEBUG_ANY,"nssov: problem closing socket: %s",strerror(errno) );
char ebuf[128];
int saved_errno = errno;
Debug( LDAP_DEBUG_ANY,"nssov: fcntl(F_GETFL) failed: %s",
AC_STRERROR_R(saved_errno, ebuf, sizeof(ebuf)) );
if (close(csock)) {
saved_errno = errno;
Debug( LDAP_DEBUG_ANY,"nssov: problem closing socket: %s",
AC_STRERROR_R(saved_errno, ebuf, sizeof(ebuf)) );
}
return NULL;
}
if (fcntl(csock,F_SETFL,j&~O_NONBLOCK)<0)
{
Debug( LDAP_DEBUG_ANY,"nssov: fcntl(F_SETFL,~O_NONBLOCK) failed: %s",strerror(errno) );
if (close(csock))
Debug( LDAP_DEBUG_ANY,"nssov: problem closing socket: %s",strerror(errno) );
char ebuf[128];
int saved_errno = errno;
Debug( LDAP_DEBUG_ANY,"nssov: fcntl(F_SETFL,~O_NONBLOCK) failed: %s",
AC_STRERROR_R(saved_errno, ebuf, sizeof(ebuf)) );
if (close(csock)) {
saved_errno = errno;
Debug( LDAP_DEBUG_ANY,"nssov: problem closing socket: %s",
AC_STRERROR_R(saved_errno, ebuf, sizeof(ebuf)) );
}
return NULL;
}
}
......@@ -868,10 +891,12 @@ nssov_db_open(
}
}
if ( slapMode & SLAP_SERVER_MODE ) {
char ebuf[128];
/* make sure /var/run/nslcd exists */
if (mkdir(NSLCD_PATH, (mode_t) 0555)) {
int saved_errno = errno;
Debug(LDAP_DEBUG_TRACE,"nssov: mkdir(%s) failed (ignored): %s\n",
NSLCD_PATH,strerror(errno) );
NSLCD_PATH, AC_STRERROR_R(saved_errno, ebuf, sizeof(ebuf)) );
} else {
Debug(LDAP_DEBUG_TRACE,"nssov: created %s\n",NSLCD_PATH );
}
......@@ -879,14 +904,17 @@ nssov_db_open(
/* create a socket */
if ( (sock=socket(PF_UNIX,SOCK_STREAM,0))<0 )
{
Debug(LDAP_DEBUG_ANY,"nssov: cannot create socket: %s\n",strerror(errno) );
int saved_errno = errno;
Debug(LDAP_DEBUG_ANY,"nssov: cannot create socket: %s\n",
AC_STRERROR_R(saved_errno, ebuf, sizeof(ebuf)) );
return -1;
}
/* remove existing named socket */
if (unlink(NSLCD_SOCKET)<0)
{
int saved_errno = errno;
Debug( LDAP_DEBUG_TRACE,"nssov: unlink() of "NSLCD_SOCKET" failed (ignored): %s\n",
strerror(errno) );
AC_STRERROR_R(saved_errno, ebuf, sizeof(ebuf)) );
}
/* create socket address structure */
memset(&addr,0,sizeof(struct sockaddr_un));
......@@ -896,18 +924,27 @@ nssov_db_open(
/* bind to the named socket */
if (bind(sock,(struct sockaddr *)&addr,sizeof(struct sockaddr_un)))
{
int saved_errno = errno;
Debug( LDAP_DEBUG_ANY,"nssov: bind() to "NSLCD_SOCKET" failed: %s",
strerror(errno) );
if (close(sock))
Debug( LDAP_DEBUG_ANY,"nssov: problem closing socket: %s",strerror(errno) );
AC_STRERROR_R(saved_errno, ebuf, sizeof(ebuf)) );
if (close(sock)) {
saved_errno = errno
Debug( LDAP_DEBUG_ANY,"nssov: problem closing socket: %s",
AC_STRERROR_R(saved_errno, ebuf, sizeof(ebuf)) );
}
return -1;
}
/* close the file descriptor on exit */
if (fcntl(sock,F_SETFD,FD_CLOEXEC)<0)
{
Debug( LDAP_DEBUG_ANY,"nssov: fcntl(F_SETFL,O_NONBLOCK) failed: %s",strerror(errno) );
if (close(sock))
Debug( LDAP_DEBUG_ANY,"nssov: problem closing socket: %s",strerror(errno) );
int saved_errno = errno;
Debug( LDAP_DEBUG_ANY,"nssov: fcntl(F_SETFL,O_NONBLOCK) failed: %s",
AC_STRERROR_R(saved_errno, ebuf, sizeof(ebuf)) );
if (close(sock)) {
saved_errno = errno
Debug( LDAP_DEBUG_ANY,"nssov: problem closing socket: %s",
AC_STRERROR_R(saved_errno, ebuf, sizeof(ebuf)) );
}
return -1;
}
/* set permissions of socket so anybody can do requests */
......@@ -917,17 +954,27 @@ nssov_db_open(
http://lkml.org/lkml/2005/5/16/11 */
if (chmod(NSLCD_SOCKET,(mode_t)0666))
{
Debug( LDAP_DEBUG_ANY,"nssov: chmod(0666) failed: %s",strerror(errno) );
if (close(sock))
Debug( LDAP_DEBUG_ANY,"nssov: problem closing socket: %s",strerror(errno) );
int saved_errno = errno;
Debug( LDAP_DEBUG_ANY,"nssov: chmod(0666) failed: %s",
AC_STRERROR_R(saved_errno, ebuf, sizeof(ebuf)) );
if (close(sock)) {
saved_errno = errno
Debug( LDAP_DEBUG_ANY,"nssov: problem closing socket: %s",
AC_STRERROR_R(saved_errno, ebuf, sizeof(ebuf)) );
}
return -1;
}
/* start listening for connections */
if (listen(sock,SOMAXCONN)<0)
{
Debug( LDAP_DEBUG_ANY,"nssov: listen() failed: %s",strerror(errno) );
if (close(sock))
Debug( LDAP_DEBUG_ANY,"nssov: problem closing socket: %s",strerror(errno) );
int saved_errno = errno;
Debug( LDAP_DEBUG_ANY,"nssov: listen() failed: %s",
AC_STRERROR_R(saved_errno, ebuf, sizeof(ebuf)) );
if (close(sock)) {
saved_errno = errno
Debug( LDAP_DEBUG_ANY,"nssov: problem closing socket: %s",
AC_STRERROR_R(saved_errno, ebuf, sizeof(ebuf)) );
}
return -1;
}
ni->ni_socket = sock;
......@@ -946,18 +993,23 @@ nssov_db_close(
nssov_info *ni = on->on_bi.bi_private;
if ( slapMode & SLAP_SERVER_MODE ) {
char ebuf[128];
/* close socket if it's still in use */
if (ni->ni_socket >= 0)
{
if (close(ni->ni_socket))
Debug( LDAP_DEBUG_ANY,"problem closing server socket (ignored): %s",strerror(errno) );
if (close(ni->ni_socket)) {
int saved_errno = errno;
Debug( LDAP_DEBUG_ANY,"problem closing server socket (ignored): %s",
AC_STRERROR_R(saved_errno, ebuf, sizeof(ebuf)) );
}
ni->ni_socket = -1;
}
/* remove existing named socket */
if (unlink(NSLCD_SOCKET)<0)
{
int saved_errno = errno;
Debug( LDAP_DEBUG_TRACE,"unlink() of "NSLCD_SOCKET" failed (ignored): %s",
strerror(errno) );
AC_STRERROR_R(saved_errno, ebuf, sizeof(ebuf)) );
}
}
return 0;
......
......@@ -29,23 +29,4 @@
LDAP_LIBC_V(char) *sys_errlist[];
#endif
#undef _AC_ERRNO_UNKNOWN
#define _AC_ERRNO_UNKNOWN "unknown error"
#ifdef HAVE_SYS_ERRLIST
/* this is thread safe */
# define STRERROR(e) ( (e) > -1 && (e) < sys_nerr \
? sys_errlist[(e)] : _AC_ERRNO_UNKNOWN )
#elif defined( HAVE_STRERROR )
/* this may not be thread safe */
/* and, yes, some implementations of strerror may return NULL */
# define STRERROR(e) ( strerror(e) \
? strerror(e) : _AC_ERRNO_UNKNOWN )
#else
/* this is thread safe */
# define STRERROR(e) ( _AC_ERRNO_UNKNOWN )
#endif
#endif /* _AC_ERRNO_H */
......@@ -82,7 +82,7 @@
#undef sock_errno
#undef sock_errstr
#define sock_errno() errno
#define sock_errstr(e) STRERROR(e)
#define sock_errstr(e, b, l) AC_STRERROR_R(e, b, l)
#define sock_errset(e) ((void) (errno = (e)))
#ifdef HAVE_WINSOCK
......@@ -106,7 +106,7 @@
#undef sock_errstr
#undef sock_errset
#define sock_errno() WSAGetLastError()
#define sock_errstr(e) ber_pvt_wsa_err2string(e)
#define sock_errstr(e, b, l) ber_pvt_wsa_err2string(e)
#define sock_errset(e) WSASetLastError(e)
LBER_F( char * ) ber_pvt_wsa_err2string LDAP_P((int));
......
......@@ -200,10 +200,12 @@ ldap_int_prepare_socket(LDAP *ld, int s, int proto )
#undef TRACE
#define TRACE do { \
char ebuf[128]; \
int saved_errno = errno; \
Debug3(LDAP_DEBUG_TRACE, "ldap_is_socket_ready: error on socket %d: errno: %d (%s)\n", \
s, \
errno, \
sock_errstr(errno) ); \
saved_errno, \
sock_errstr(saved_errno, ebuf, sizeof(ebuf)) ); \
} while( 0 )
/*
......@@ -371,7 +373,7 @@ ldap_int_poll(
ldap_pvt_set_errno( so_errno );
Debug3(LDAP_DEBUG_TRACE,
"ldap_int_poll: error on socket %d: "
"errno: %d (%s)\n", s, errno, sock_errstr( errno ));
"errno: %d (%s)\n", s, so_errno, sock_errstr( so_errno, dummy, dummy ));
return -1;
}
#endif
......
......@@ -95,10 +95,11 @@ ldap_pvt_close_socket(LDAP *ld, int s)
#undef TRACE
#define TRACE do { \
char ebuf[128]; \
int saved_errno = errno; \
Debug3(LDAP_DEBUG_TRACE, "ldap_is_socket_ready: error on socket %d: errno: %d (%s)\n", \
s, \
errno, \
AC_STRERROR_R(errno, ebuf, sizeof ebuf)); \
saved_errno, \
AC_STRERROR_R(saved_errno, ebuf, sizeof ebuf)); \
} while( 0 )
/*
......