+/* $OpenLDAP$ */
/*
* Copyright (c) 1990 Regents of the University of Michigan.
* All rights reserved.
#include <ac/unistd.h>
#include <ac/wait.h>
+#include <ac/param.h>
#include <ac/setproctitle.h>
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
char myhost[MAXHOSTNAMELEN];
int myport;
-static void usage ( char *name );
+static void usage ( char *name ) LDAP_GCCATTR((noreturn));
static int set_socket (int port);
static RETSIGTYPE wait4child(int sig);
-static void do_queries (int s);
+static void do_queries (int s) LDAP_GCCATTR((noreturn));
static void do_error (FILE *fp, char *s);
static void do_search (LDAP *ld, FILE *fp, char *buf);
static void do_read (LDAP *ld, FILE *fp, char *dn);
#ifdef GO500_HOSTNAME
strcpy( myhost, GO500_HOSTNAME );
#else
- if ( myhost[0] == '\0' && gethostname( myhost, sizeof(myhost) )
+ if ( myhost[0] == '\0' && gethostname( myhost, sizeof(myhost)-1 )
== -1 ) {
perror( "gethostname" );
exit( EXIT_FAILURE );
}
+ myhost[sizeof(myhost)-1] = '\0';
#endif
#ifdef HAVE_SYSCONF
if ( dosyslog ) {
#ifdef LOG_LOCAL3
openlog( myname, OPENLOG_OPTIONS, LOG_LOCAL3 );
-#else
+#elif LOG_DEBUG
openlog( myname, OPENLOG_OPTIONS );
#endif
}
fromlen = sizeof(from);
if ( getpeername( 0, (struct sockaddr *) &from, &fromlen )
== 0 ) {
- hp = gethostbyaddr( (char *) &(from.sin_addr.s_addr),
- sizeof(from.sin_addr.s_addr), AF_INET );
+ hp = gethostbyaddr( (char *) &(from.sin_addr),
+ sizeof(from.sin_addr), AF_INET );
Debug( LDAP_DEBUG_ARGS, "connection from %s (%s)\n",
(hp == NULL) ? "unknown" : hp->h_name,
inet_ntoa( from.sin_addr ), 0 );
}
#ifdef LDAP_PROCTITLE
- setproctitle( hp == NULL ? inet_ntoa( from.sin_addr ) :
+ setproctitle( "%s", hp == NULL ? inet_ntoa( from.sin_addr ) :
hp->h_name );
#endif
}
exit( EXIT_FAILURE );
}
- hp = gethostbyaddr( (char *) &(from.sin_addr.s_addr),
- sizeof(from.sin_addr.s_addr), AF_INET );
+ hp = gethostbyaddr( (char *) &(from.sin_addr),
+ sizeof(from.sin_addr), AF_INET );
if ( dosyslog ) {
syslog( LOG_INFO, "TCP connection from %s (%s)",
; /* NULL */
#endif
- (void) SIGNAL( SIGCHLD, wait4child );
+ (void) SIGNAL_REINSTALL ( SIGCHLD, wait4child );
}
static void