mirror of
https://git.openldap.org/openldap/openldap.git
synced 2026-02-18 18:18:06 -05:00
zap finger from release
This commit is contained in:
parent
72e111301b
commit
f5618f4ebe
4 changed files with 907 additions and 1133 deletions
244
build/top.mk
Normal file
244
build/top.mk
Normal file
|
|
@ -0,0 +1,244 @@
|
|||
# $OpenLDAP$
|
||||
## Copyright 1998-2002 The OpenLDAP Foundation, Redwood City, California, USA
|
||||
## All rights reserved.
|
||||
##
|
||||
## Redistribution and use in source and binary forms, with or without
|
||||
## modification, are permitted only as authorized by the OpenLDAP
|
||||
## Public License. A copy of this license is available at
|
||||
## http://www.OpenLDAP.org/license.html or in file LICENSE in the
|
||||
## top-level directory of the distribution.
|
||||
##
|
||||
PACKAGE= @PACKAGE@
|
||||
VERSION= @VERSION@
|
||||
|
||||
@SET_MAKE@
|
||||
SHELL = /bin/sh
|
||||
|
||||
top_builddir = @top_builddir@
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
ldap_subdir = @ldap_subdir@
|
||||
|
||||
bindir = @bindir@
|
||||
datadir = @datadir@$(ldap_subdir)
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
moduledir = @libexecdir@$(ldap_subdir)
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
sysconfdir = @sysconfdir@$(ldap_subdir)
|
||||
schemadir = $(sysconfdir)/schema
|
||||
|
||||
PLAT = @PLAT@
|
||||
EXEEXT = @EXEEXT@
|
||||
OBJEXT = @OBJEXT@
|
||||
|
||||
BUILD_LIBS_DYNAMIC = @BUILD_LIBS_DYNAMIC@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
|
||||
LINT = lint
|
||||
5LINT = 5lint
|
||||
|
||||
MKDEP = $(top_srcdir)/build/mkdep $(MKDEPFLAG) \
|
||||
-d "$(srcdir)" -c "$(MKDEP_CC)" -m "$(MKDEP_CFLAGS)"
|
||||
MKDEP_CC = @OL_MKDEP@
|
||||
MKDEP_CFLAGS = @OL_MKDEP_FLAGS@
|
||||
|
||||
MKVERSION = $(top_srcdir)/build/mkversion -v "$(VERSION)"
|
||||
|
||||
SHTOOL = $(top_srcdir)/build/shtool
|
||||
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LIBVERSION = @OPENLDAP_LIBVERSION@
|
||||
LTVERSION = -version-info $(LIBVERSION)
|
||||
|
||||
# libtool --only flag for libraries: platform specific
|
||||
NT_LTONLY_LIB = --only-$(BUILD_LIBS_DYNAMIC)
|
||||
LTONLY_LIB = $(@PLAT@_LTONLY_LIB)
|
||||
|
||||
# libtool --only flag for modules: depends on linkage of module
|
||||
# The BUILD_MOD_DYNAMIC macro is defined in each backend Makefile.in file
|
||||
LTONLY_MOD = # --only-$(BUILD_MOD_DYNAMIC)
|
||||
|
||||
# platform-specific libtool flags
|
||||
NT_LTFLAGS_LIB = -no-undefined -avoid-version -rpath $(libdir)
|
||||
NT_LTFLAGS_MOD = -no-undefined -avoid-version -rpath $(moduledir)
|
||||
UNIX_LTFLAGS_LIB = $(LTVERSION) -rpath $(libdir)
|
||||
UNIX_LTFLAGS_MOD = $(LTVERSION) -rpath $(moduledir)
|
||||
|
||||
# libtool flags
|
||||
LTFLAGS = $(@PLAT@_LTFLAGS)
|
||||
LTFLAGS_LIB = $(@PLAT@_LTFLAGS_LIB)
|
||||
LTFLAGS_MOD = $(@PLAT@_LTFLAGS_MOD)
|
||||
|
||||
# LIB_DEFS defined in liblber and libldap Makefile.in files.
|
||||
# MOD_DEFS defined in backend Makefile.in files.
|
||||
|
||||
# platform-specific LINK_LIBS defined in various Makefile.in files.
|
||||
# LINK_LIBS referenced in library and module link commands.
|
||||
LINK_LIBS = $(@PLAT@_LINK_LIBS)
|
||||
|
||||
LTLINK = $(LIBTOOL) --mode=link \
|
||||
$(CC) -static $(LT_CFLAGS) $(LDFLAGS) $(LTFLAGS)
|
||||
|
||||
LTCOMPILE_LIB = $(LIBTOOL) $(LTONLY_LIB) --mode=compile \
|
||||
$(CC) $(LT_CFLAGS) $(LT_CPPFLAGS) $(LIB_DEFS) -c
|
||||
|
||||
LTLINK_LIB = $(LIBTOOL) $(LTONLY_LIB) --mode=link \
|
||||
$(CC) $(LT_CFLAGS) $(LDFLAGS) $(LTFLAGS_LIB)
|
||||
|
||||
LTCOMPILE_MOD = $(LIBTOOL) $(LTONLY_MOD) --mode=compile \
|
||||
$(CC) $(LT_CFLAGS) $(LT_CPPFLAGS) $(MOD_DEFS) -c
|
||||
|
||||
LTLINK_MOD = $(LIBTOOL) $(LTONLY_MOD) --mode=link \
|
||||
$(CC) $(LT_CFLAGS) $(LDFLAGS) $(LTFLAGS_MOD)
|
||||
|
||||
LTINSTALL = $(LIBTOOL) --mode=install $(INSTALL)
|
||||
LTFINISH = $(LIBTOOL) --mode=finish
|
||||
|
||||
# Misc UNIX commands used in build environment
|
||||
AR = @AR@
|
||||
AWK = @AWK@
|
||||
BASENAME = basename
|
||||
CAT = cat
|
||||
CHMOD = chmod
|
||||
DATE = date
|
||||
HOSTNAME = $(SHTOOL) echo -e "%h%d"
|
||||
LN = ln
|
||||
LN_H = @LN_H@
|
||||
LN_S = @LN_S@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MKDIR = $(SHTOOL) mkdir -p
|
||||
MV = mv
|
||||
PWD = pwd
|
||||
RANLIB = @RANLIB@
|
||||
RM = rm -f
|
||||
SED = sed
|
||||
|
||||
# Misc UNIX commands used in programs
|
||||
EDITOR = @EDITOR@
|
||||
SENDMAIL = @SENDMAIL@
|
||||
|
||||
# For manual pages
|
||||
# MANCOMPRESS=@MANCOMPRESS@
|
||||
# MANCOMPRESSSUFFIX=@MANCOMPRESSSUFFIX@
|
||||
MANCOMPRESS=$(CAT)
|
||||
MANCOMPRESSSUFFIX=
|
||||
|
||||
INCLUDEDIR= $(top_srcdir)/include
|
||||
LDAP_INCPATH= -I$(LDAP_INCDIR) -I$(INCLUDEDIR)
|
||||
LDAP_LIBDIR= $(top_builddir)/libraries
|
||||
|
||||
LUTIL_LIBS = @LUTIL_LIBS@
|
||||
LDIF_LIBS = @LDIF_LIBS@
|
||||
LDBM_LIBS = @LDBM_LIBS@
|
||||
LTHREAD_LIBS = @LTHREAD_LIBS@
|
||||
|
||||
LDAP_LIBLBER_LA = $(LDAP_LIBDIR)/liblber/liblber.la
|
||||
LDAP_LIBLDAP_LA = $(LDAP_LIBDIR)/libldap/libldap.la
|
||||
LDAP_LIBLDAP_R_LA = $(LDAP_LIBDIR)/libldap_r/libldap_r.la
|
||||
|
||||
LDAP_LIBAVL_A = $(LDAP_LIBDIR)/libavl/libavl.a
|
||||
LDAP_LIBLDBM_A = $(LDAP_LIBDIR)/libldbm/libldbm.a
|
||||
LDAP_LIBLDIF_A = $(LDAP_LIBDIR)/libldif/libldif.a
|
||||
LDAP_LIBREWRITE_A = $(LDAP_LIBDIR)/librewrite/librewrite.a
|
||||
LDAP_LIBLUNICODE_A = $(LDAP_LIBDIR)/liblunicode/liblunicode.a
|
||||
LDAP_LIBLUTIL_A = $(LDAP_LIBDIR)/liblutil/liblutil.a
|
||||
|
||||
LDAP_L = $(LDAP_LIBLUTIL_A) $(LDAP_LIBLDIF_A) \
|
||||
$(LDAP_LIBLDAP_LA) $(LDAP_LIBLBER_LA)
|
||||
SLURPD_L = $(LDAP_LIBLDIF_A) $(LDAP_LIBLUTIL_A) \
|
||||
$(LDAP_LIBLDAP_R_LA) $(LDAP_LIBLBER_LA)
|
||||
SLAPD_L = $(LDAP_LIBAVL_A) $(LDAP_LIBLDBM_A) \
|
||||
$(LDAP_LIBLUNICODE_A) $(LDAP_LIBREWRITE_A) \
|
||||
$(SLURPD_L)
|
||||
|
||||
WRAP_LIBS = @WRAP_LIBS@
|
||||
# AutoConfig generated
|
||||
AC_CC = @CC@
|
||||
AC_CFLAGS = @CFLAGS@
|
||||
AC_DEFS = @CPPFLAGS@ # @DEFS@
|
||||
AC_LDFLAGS = @LDFLAGS@
|
||||
AC_LIBS = @LIBS@
|
||||
|
||||
KRB4_LIBS = @KRB4_LIBS@
|
||||
KRB5_LIBS = @KRB5_LIBS@
|
||||
KRB_LIBS = @KRB4_LIBS@ @KRB5_LIBS@
|
||||
SASL_LIBS = @SASL_LIBS@
|
||||
TLS_LIBS = @TLS_LIBS@
|
||||
AUTH_LIBS = @AUTH_LIBS@
|
||||
SECURITY_LIBS = $(SASL_LIBS) $(KRB_LIBS) $(TLS_LIBS) $(AUTH_LIBS)
|
||||
|
||||
MODULES_CPPFLAGS = @SLAPD_MODULES_CPPFLAGS@
|
||||
MODULES_LDFLAGS = @SLAPD_MODULES_LDFLAGS@
|
||||
MODULES_LIBS = @MODULES_LIBS@
|
||||
TERMCAP_LIBS = @TERMCAP_LIBS@
|
||||
SLAPD_PERL_LDFLAGS = @SLAPD_PERL_LDFLAGS@
|
||||
|
||||
SLAPD_SQL_LDFLAGS = @SLAPD_SQL_LDFLAGS@
|
||||
SLAPD_SQL_INCLUDES = @SLAPD_SQL_INCLUDES@
|
||||
SLAPD_SQL_LIBS = @SLAPD_SQL_LIBS@
|
||||
|
||||
SLAPD_LIBS = @SLAPD_LIBS@ @SLAPD_PERL_LDFLAGS@ @SLAPD_SQL_LDFLAGS@ @SLAPD_SQL_LIBS@ @SLAPD_SLP_LIBS@
|
||||
SLURPD_LIBS = @SLURPD_LIBS@
|
||||
|
||||
# Our Defaults
|
||||
CC = $(AC_CC)
|
||||
DEFS = $(LDAP_INCPATH) $(XINCPATH) $(XDEFS) $(AC_DEFS) $(DEFINES)
|
||||
CFLAGS = $(AC_CFLAGS) $(DEFS)
|
||||
LDFLAGS = $(LDAP_LIBPATH) $(AC_LDFLAGS) $(XLDFLAGS)
|
||||
LIBS = $(XLIBS) $(XXLIBS) $(AC_LIBS) $(XXXLIBS)
|
||||
|
||||
LT_CFLAGS = $(AC_CFLAGS)
|
||||
LT_CPPFLAGS = $(DEFS)
|
||||
|
||||
all: all-common all-local FORCE
|
||||
install: install-common install-local FORCE
|
||||
clean: clean-common clean-local FORCE
|
||||
veryclean: veryclean-common veryclean-local FORCE
|
||||
depend: depend-common depend-local FORCE
|
||||
|
||||
# empty common rules
|
||||
all-common:
|
||||
install-common:
|
||||
clean-common:
|
||||
veryclean-common: clean-common FORCE
|
||||
depend-common:
|
||||
lint-common:
|
||||
lint5-common:
|
||||
|
||||
# empty local rules
|
||||
all-local:
|
||||
install-local:
|
||||
clean-local:
|
||||
veryclean-local: clean-local FORCE
|
||||
depend-local:
|
||||
lint-local:
|
||||
lint5-local:
|
||||
|
||||
veryclean: FORCE
|
||||
$(RM) Makefile
|
||||
$(RM) -r .libs
|
||||
|
||||
Makefile: Makefile.in $(top_srcdir)/build/top.mk
|
||||
|
||||
pathtest:
|
||||
$(SHTOOL) --version
|
||||
|
||||
# empty rule for forcing rules
|
||||
FORCE:
|
||||
|
||||
##---------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -1,429 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 1990,1994 Regents of the University of Michigan.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that this notice is preserved and that due credit is given
|
||||
* to the University of Michigan at Ann Arbor. The name of the University
|
||||
* may not be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission. This software
|
||||
* is provided ``as is'' without express or implied warranty.
|
||||
*/
|
||||
|
||||
#include "lber.h"
|
||||
#include "ldap.h"
|
||||
#include "disptmpl.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <syslog.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/wait.h>
|
||||
#ifdef aix
|
||||
#include <sys/select.h>
|
||||
#endif /* aix */
|
||||
#include <signal.h>
|
||||
#include "portable.h"
|
||||
#include "ldapconfig.h"
|
||||
|
||||
#ifdef USE_SYSCONF
|
||||
#include <unistd.h>
|
||||
#endif /* USE_SYSCONF */
|
||||
|
||||
int dosyslog = 1;
|
||||
char *ldaphost = LDAPHOST;
|
||||
int ldapport = LDAP_PORT;
|
||||
char *base = FINGER_BASE;
|
||||
int deref;
|
||||
char *filterfile = FILTERFILE;
|
||||
char *templatefile = TEMPLATEFILE;
|
||||
int rdncount = FINGER_RDNCOUNT;
|
||||
|
||||
static do_query();
|
||||
static do_search();
|
||||
static do_read();
|
||||
static print_attr();
|
||||
|
||||
static usage( name )
|
||||
char *name;
|
||||
{
|
||||
fprintf( stderr, "usage: %s [-l] [-x ldaphost] [-p ldapport] [-f filterfile] [-t templatefile] [-c rdncount]\r\n", name );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
int i;
|
||||
char *myname;
|
||||
unsigned long mypeer = -1;
|
||||
struct hostent *hp;
|
||||
struct sockaddr_in peername;
|
||||
int peernamelen;
|
||||
int interactive = 0;
|
||||
extern char *optarg;
|
||||
|
||||
deref = FINGER_DEREF;
|
||||
while ( (i = getopt( argc, argv, "f:ilp:t:x:p:c:" )) != EOF ) {
|
||||
switch( i ) {
|
||||
case 'f': /* ldap filter file */
|
||||
filterfile = strdup( optarg );
|
||||
break;
|
||||
|
||||
case 'i': /* interactive */
|
||||
interactive = 1;
|
||||
break;
|
||||
|
||||
case 'l': /* don't do syslogging */
|
||||
dosyslog = 0;
|
||||
break;
|
||||
|
||||
case 't': /* ldap template file */
|
||||
templatefile = strdup( optarg );
|
||||
break;
|
||||
|
||||
case 'x': /* specify ldap host */
|
||||
ldaphost = strdup( optarg );
|
||||
break;
|
||||
|
||||
case 'p': /* specify ldap port */
|
||||
ldapport = atoi( optarg );
|
||||
break;
|
||||
|
||||
case 'c': /* specify number of DN components to show */
|
||||
rdncount = atoi( optarg );
|
||||
break;
|
||||
|
||||
default:
|
||||
usage( argv[0] );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !interactive ) {
|
||||
peernamelen = sizeof(peername);
|
||||
if ( getpeername( 0, (struct sockaddr *)&peername,
|
||||
&peernamelen ) != 0 ) {
|
||||
perror( "getpeername" );
|
||||
exit( 1 );
|
||||
}
|
||||
mypeer = (unsigned long) peername.sin_addr.s_addr;
|
||||
}
|
||||
|
||||
#ifdef FINGER_BANNER
|
||||
if ( FINGER_BANNER != NULL && strcmp( FINGER_BANNER, "" ) != 0 ) {
|
||||
printf( FINGER_BANNER );
|
||||
fflush( stdout );
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( (myname = strrchr( argv[0], '/' )) == NULL )
|
||||
myname = strdup( argv[0] );
|
||||
else
|
||||
myname = strdup( myname + 1 );
|
||||
|
||||
if ( dosyslog ) {
|
||||
#ifdef LOG_LOCAL4
|
||||
openlog( myname, OPENLOG_OPTIONS, LOG_LOCAL4 );
|
||||
#else
|
||||
openlog( myname, OPENLOG_OPTIONS );
|
||||
#endif
|
||||
}
|
||||
|
||||
if ( dosyslog && mypeer != -1 ) {
|
||||
struct in_addr addr;
|
||||
|
||||
hp = gethostbyaddr( (char *) &mypeer, sizeof(mypeer), AF_INET );
|
||||
addr.s_addr = mypeer;
|
||||
syslog( LOG_INFO, "connection from %s (%s)", (hp == NULL) ?
|
||||
"unknown" : hp->h_name, inet_ntoa( addr ) );
|
||||
}
|
||||
|
||||
do_query();
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
static do_query()
|
||||
{
|
||||
char buf[256];
|
||||
int len, rc, tblsize;
|
||||
struct timeval timeout;
|
||||
fd_set readfds;
|
||||
LDAP *ld;
|
||||
|
||||
if ( (ld = ldap_open( ldaphost, ldapport )) == NULL ) {
|
||||
fprintf( stderr, FINGER_UNAVAILABLE );
|
||||
perror( "ldap_open" );
|
||||
exit( 1 );
|
||||
}
|
||||
ld->ld_sizelimit = FINGER_SIZELIMIT;
|
||||
ld->ld_deref = deref;
|
||||
|
||||
if ( ldap_simple_bind_s( ld, FINGER_BINDDN, NULL ) != LDAP_SUCCESS ) {
|
||||
fprintf( stderr, FINGER_UNAVAILABLE );
|
||||
ldap_perror( ld, "ldap_simple_bind_s" );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
#ifdef USE_SYSCONF
|
||||
tblsize = sysconf( _SC_OPEN_MAX );
|
||||
#else /* USE_SYSCONF */
|
||||
tblsize = getdtablesize();
|
||||
#endif /* USE_SYSCONF */
|
||||
|
||||
timeout.tv_sec = FINGER_TIMEOUT;
|
||||
timeout.tv_usec = 0;
|
||||
FD_ZERO( &readfds );
|
||||
FD_SET( fileno( stdin ), &readfds );
|
||||
|
||||
if ( (rc = select( tblsize, &readfds, 0, 0, &timeout )) <= 0 ) {
|
||||
if ( rc < 0 )
|
||||
perror( "select" );
|
||||
else
|
||||
fprintf( stderr, "connection timed out on input\r\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
if ( fgets( buf, sizeof(buf), stdin ) == NULL )
|
||||
exit( 1 );
|
||||
|
||||
len = strlen( buf );
|
||||
|
||||
/* strip off \r \n */
|
||||
if ( buf[len - 1] == '\n' ) {
|
||||
buf[len - 1] = '\0';
|
||||
len--;
|
||||
}
|
||||
if ( buf[len - 1] == '\r' ) {
|
||||
buf[len - 1] = '\0';
|
||||
len--;
|
||||
}
|
||||
|
||||
if ( len == 0 ) {
|
||||
printf( "No campus-wide login information available. Info for this machine only:\r\n" );
|
||||
fflush( stdout );
|
||||
execl( FINGER_CMD, FINGER_CMD, NULL );
|
||||
} else {
|
||||
char *p;
|
||||
|
||||
/* skip and ignore stinking /w */
|
||||
if ( strncmp( buf, "/W ", 2 ) == 0 ) {
|
||||
p = buf + 2;
|
||||
} else {
|
||||
p = buf;
|
||||
}
|
||||
|
||||
for ( ; *p && isspace( *p ); p++ )
|
||||
; /* NULL */
|
||||
|
||||
do_search( ld, p );
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
spaces2dots( s )
|
||||
char *s;
|
||||
{
|
||||
for ( ; *s; s++ ) {
|
||||
if ( *s == ' ' ) {
|
||||
*s = '.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static do_search( ld, buf )
|
||||
LDAP *ld;
|
||||
char *buf;
|
||||
{
|
||||
char *dn, *rdn;
|
||||
char **title;
|
||||
int rc, matches, i, ufn;
|
||||
struct timeval tv;
|
||||
LDAPFiltInfo *fi;
|
||||
LDAPMessage *result, *e;
|
||||
static char *attrs[] = { "cn", "title", "objectClass", "joinable",
|
||||
#ifdef FINGER_SORT_ATTR
|
||||
FINGER_SORT_ATTR,
|
||||
#endif
|
||||
0 };
|
||||
extern int strcasecmp();
|
||||
|
||||
ufn = 0;
|
||||
#ifdef FINGER_UFN
|
||||
if ( strchr( buf, ',' ) != NULL ) {
|
||||
ldap_ufn_setprefix( ld, base );
|
||||
tv.tv_sec = FINGER_TIMEOUT;
|
||||
tv.tv_usec = 0;
|
||||
ldap_ufn_timeout( (void *) &tv );
|
||||
|
||||
if ( (rc = ldap_ufn_search_s( ld, buf, attrs, 0, &result ))
|
||||
!= LDAP_SUCCESS && rc != LDAP_SIZELIMIT_EXCEEDED ) {
|
||||
fprintf( stderr, FINGER_UNAVAILABLE );
|
||||
ldap_perror( ld, "ldap_search_st" );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
matches = ldap_count_entries( ld, result );
|
||||
ufn = 1;
|
||||
} else {
|
||||
#endif
|
||||
if ( (ld->ld_filtd = ldap_init_getfilter( filterfile ))
|
||||
== NULL ) {
|
||||
fprintf( stderr, "Cannot open filter file (%s)\n",
|
||||
filterfile );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
for ( fi = ldap_getfirstfilter( ld->ld_filtd, "finger", buf );
|
||||
fi != NULL;
|
||||
fi = ldap_getnextfilter( ld->ld_filtd ) )
|
||||
{
|
||||
tv.tv_sec = FINGER_TIMEOUT;
|
||||
tv.tv_usec = 0;
|
||||
if ( (rc = ldap_search_st( ld, base, LDAP_SCOPE_SUBTREE,
|
||||
fi->lfi_filter, attrs, 0, &tv, &result ))
|
||||
!= LDAP_SUCCESS && rc != LDAP_SIZELIMIT_EXCEEDED
|
||||
&& rc != LDAP_TIMELIMIT_EXCEEDED )
|
||||
{
|
||||
fprintf( stderr, FINGER_UNAVAILABLE );
|
||||
ldap_perror( ld, "ldap_search_st" );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
if ( (matches = ldap_count_entries( ld, result )) != 0 )
|
||||
break;
|
||||
|
||||
ldap_msgfree( result );
|
||||
result = NULL;
|
||||
}
|
||||
#ifdef FINGER_UFN
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( rc == LDAP_SIZELIMIT_EXCEEDED ) {
|
||||
printf( "(Partial results - a size limit was exceeded)\r\n" );
|
||||
} else if ( rc == LDAP_TIMELIMIT_EXCEEDED ) {
|
||||
printf( "(Partial results - a time limit was exceeded)\r\n" );
|
||||
}
|
||||
|
||||
if ( matches == 0 ) {
|
||||
printf( FINGER_NOMATCH );
|
||||
fflush( stdout );
|
||||
} else if ( matches < 0 ) {
|
||||
fprintf( stderr, "error return from ldap_count_entries\r\n" );
|
||||
exit( 1 );
|
||||
} else if ( matches <= FINGER_LISTLIMIT ) {
|
||||
printf( "%d %s match%s found for \"%s\":\r\n", matches,
|
||||
ufn ? "UFN" : fi->lfi_desc, matches > 1 ? "es" : "", buf );
|
||||
fflush( stdout );
|
||||
|
||||
for ( e = ldap_first_entry( ld, result ); e != NULL; ) {
|
||||
do_read( ld, e );
|
||||
e = ldap_next_entry( ld, e );
|
||||
if ( e != NULL ) {
|
||||
printf( "--------------------\r\n" );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
printf( "%d %s matches for \"%s\":\r\n", matches,
|
||||
ufn ? "UFN" : fi->lfi_desc, buf );
|
||||
fflush( stdout );
|
||||
|
||||
#ifdef FINGER_SORT_ATTR
|
||||
ldap_sort_entries( ld, &result, FINGER_SORT_ATTR, strcasecmp );
|
||||
#endif
|
||||
|
||||
for ( e = ldap_first_entry( ld, result ); e != NULL;
|
||||
e = ldap_next_entry( ld, e ) ) {
|
||||
char *p;
|
||||
|
||||
dn = ldap_get_dn( ld, e );
|
||||
rdn = dn;
|
||||
if ( (p = strchr( dn, ',' )) != NULL )
|
||||
*p = '\0';
|
||||
while ( *rdn && *rdn != '=' )
|
||||
rdn++;
|
||||
if ( *rdn )
|
||||
rdn++;
|
||||
|
||||
/* hack attack */
|
||||
for ( i = 0; buf[i] != '\0'; i++ ) {
|
||||
if ( buf[i] == '.' || buf[i] == '_' )
|
||||
buf[i] = ' ';
|
||||
}
|
||||
if ( strcasecmp( rdn, buf ) == 0 ) {
|
||||
char **cn;
|
||||
int i, last;
|
||||
|
||||
cn = ldap_get_values( ld, e, "cn" );
|
||||
for ( i = 0; cn[i] != NULL; i++ ) {
|
||||
last = strlen( cn[i] ) - 1;
|
||||
if ( isdigit( cn[i][last] ) ) {
|
||||
rdn = strdup( cn[i] );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
title = ldap_get_values( ld, e, "title" );
|
||||
|
||||
spaces2dots( rdn );
|
||||
printf( " %-20s %s\r\n", rdn,
|
||||
title ? title[0] : "" );
|
||||
if ( title != NULL ) {
|
||||
for ( i = 1; title[i] != NULL; i++ )
|
||||
printf( " %-20s %s\r\n", "",
|
||||
title[i] );
|
||||
}
|
||||
fflush( stdout );
|
||||
|
||||
if ( title != NULL )
|
||||
ldap_value_free( title );
|
||||
|
||||
free( dn );
|
||||
}
|
||||
}
|
||||
|
||||
if ( result != NULL ) {
|
||||
ldap_msgfree( result );
|
||||
}
|
||||
ldap_unbind( ld );
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
entry2textwrite( void *fp, char *buf, int len )
|
||||
{
|
||||
return( fwrite( buf, len, 1, (FILE *)fp ) == 0 ? -1 : len );
|
||||
}
|
||||
|
||||
|
||||
static do_read( ld, e )
|
||||
LDAP *ld;
|
||||
LDAPMessage *e;
|
||||
{
|
||||
static struct ldap_disptmpl *tmpllist;
|
||||
static char *defattrs[] = { "mail", NULL };
|
||||
static char *mailvals[] = FINGER_NOEMAIL;
|
||||
static char **defvals[] = { mailvals, NULL };
|
||||
|
||||
ldap_init_templates( templatefile, &tmpllist );
|
||||
|
||||
if ( ldap_entry2text_search( ld, NULL, base, e, tmpllist, defattrs,
|
||||
defvals, entry2textwrite, (void *)stdout, "\r\n", rdncount,
|
||||
LDAP_DISP_OPT_DOSEARCHACTIONS ) != LDAP_SUCCESS ) {
|
||||
ldap_perror( ld, "ldap_entry2text_search" );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
if ( tmpllist != NULL ) {
|
||||
ldap_free_templates( tmpllist );
|
||||
}
|
||||
}
|
||||
|
|
@ -624,7 +624,6 @@ AC_PROG_LN_S
|
|||
AC_PATH_PROG(SENDMAIL, sendmail, /usr/lib/sendmail,
|
||||
$PATH:/usr/libexec:/usr/lib:/usr/sbin:/usr/etc:/etc)
|
||||
AC_PATH_PROG(EDITOR, vi, /usr/ucb/vi, $PATH:/usr/ucb)
|
||||
AC_PATH_PROG(FINGER, finger, /usr/ucb/finger, $PATH:/usr/ucb)
|
||||
|
||||
dnl ----------------------------------------------------------------
|
||||
dnl Perl
|
||||
|
|
@ -2762,7 +2761,6 @@ doc/man/man3/Makefile:build/top.mk:doc/man/man3/Makefile.in:build/man.mk \
|
|||
doc/man/man5/Makefile:build/top.mk:doc/man/man5/Makefile.in:build/man.mk \
|
||||
doc/man/man8/Makefile:build/top.mk:doc/man/man8/Makefile.in:build/man.mk \
|
||||
clients/Makefile:build/top.mk:clients/Makefile.in:build/dir.mk \
|
||||
clients/finger/Makefile:build/top.mk:clients/finger/Makefile.in:build/rules.mk \
|
||||
clients/mail500/Makefile:build/top.mk:clients/mail500/Makefile.in:build/rules.mk \
|
||||
clients/ud/Makefile:build/top.mk:clients/ud/Makefile.in:build/rules.mk \
|
||||
clients/maildap/Makefile:build/top.mk:clients/maildap/Makefile.in:build/rules.mk \
|
||||
|
|
|
|||
Loading…
Reference in a new issue