Update for Alpha3 from -devel as of OPENLDAP_DEVEL_981116.

Includes everything but ldapext & ldap.conf changes.
This commit is contained in:
Kurt Zeilenga 1998-11-17 00:24:13 +00:00
parent cea69246d6
commit 3952bc8e95
198 changed files with 4280 additions and 3708 deletions

View file

@ -1,14 +1,15 @@
OpenLDAP Change Log
Changes included in OpenLDAP 1.1-Alpha (from -devel)
CVS Tag: OPENLDAP_REL_ENG_1_1
CVS Tag: OPENLDAP_REL_ENG_1_1_ALPHA3
Changed LDBM default to sync on writes
Added mail500 BOUNCEFROM patch
Added dbcachenowsync option
Fixed slapd/ldbm id2children bug
Fixed slapd/shell newline bug
Fixed whois++ get_dn leak
Fixed DEC OSF1 (alpha) support
Fixed pointer truncation to int bugs
Fixed DEC OSF/1 support bugs
Fixed r/w lock initialization on non-final Pthreads
Fixed slapd/slurpd file unlock bugs
Fixed slurpd string translation bug
@ -24,6 +25,8 @@ Changes included in OpenLDAP 1.1-Alpha (from -devel)
Added pwd.h & getpwuid() tests
Added sys/resource.h test
Updated NT support (now builds ud)
Added function prototypes
Removed library externs
Removed lint

10
clients/fax500/fax500.h Normal file
View file

@ -0,0 +1,10 @@
#ifndef FAX500_H
#define FAX500_H 1
/* in faxtotpc.c */
void strip_nonnum ( char *str );
char *remove_parens( char *ibuf, char *obuf );
char *munge_phone ( char *ibuf, char *obuf );
char *faxtotpc ( char *phone, char *userinfo );
#endif

View file

@ -21,18 +21,20 @@
#include "portable.h"
#include <stdio.h>
#include <ctype.h>
#include <sys/types.h>
#include <ac/ctype.h>
#include <ac/string.h>
#include "fax500.h"
#define TPCDOMAIN "tpc.int"
/*
* Remove everything from 'str' which is not a digit
*/
void strip_nonnum(str)
char *str;
void
strip_nonnum( char *str )
{
char *p, *q;
p = q = str;
@ -58,9 +60,8 @@ char *str;
* Remove anything of the form (blah) where
* "blah" contains a non-numeric character.
*/
char *remove_parens(ibuf, obuf)
char *ibuf;
char *obuf;
char *
remove_parens( char *ibuf, char *obuf )
{
char *p = ibuf;
char *q = obuf;
@ -129,9 +130,8 @@ char *obuf;
* 6 93
* 8 99
*/
char *munge_phone(ibuf, obuf)
char *ibuf;
char *obuf;
char *
munge_phone( char *ibuf, char *obuf )
{
#define UMAREACODE "1313"
@ -173,17 +173,11 @@ char *obuf;
/*
* Convert string to "tpc.int" domain name.
*/
char *faxtotpc(phone, userinfo)
char *phone;
char *userinfo;
char *
faxtotpc( char *phone, char *userinfo )
{
char *p;
char *q;
@ -241,5 +235,4 @@ char *userinfo;
strcat(obuf, TPCDOMAIN); /* tack on domain name */
p = strdup(obuf);
return(p);
}

View file

@ -14,23 +14,29 @@
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/syslog.h>
#include <ac/time.h>
#include <ac/wait.h>
#include <ac/unistd.h>
#include <ac/errno.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
#include <sysexits.h>
#include "lber.h"
#include "ldap.h"
#include "fax500.h"
#include <ldapconfig.h>
#define USER 0
@ -47,7 +53,6 @@ char *errorsfrom = NULL;
char *mailfrom = NULL;
char *host = NULL;
int hostlen = 0;
char *faxtotpc();
int identity;
#define MAIL500 1
@ -103,27 +108,33 @@ static char *attrs[] = { "objectClass", "title", "postaladdress",
"rfc822RequestsTo", "joinable", "cn", "member",
"facsimileTelephoneNumber", NULL };
static do_address();
static do_group();
static do_group_members();
static send_message();
static send_errors();
static do_noemailorfax();
static do_ambiguous();
static add_to();
static isgroup();
static add_error();
static add_group();
static unbind_and_exit();
static group_loop();
static send_group();
static has_attributes();
static char **get_attributes_mail_dn();
static char *canonical();
main (argc, argv)
int argc;
char **argv;
static void do_address(char *name, char ***to, int *nto, Group **togroups, int *ngroups, Error **err, int *nerr, int type);
static int do_group(LDAPMessage *e, char *dn, char ***to, int *nto, Group **togroups, int *ngroups, Error **err, int *nerr);
static void do_group_members(LDAPMessage *e, char *dn, char ***to, int *nto, Group **togroups, int *ngroups, Error **err, int *nerr);
static void send_message(char **to);
static void send_errors(Error *err, int nerr);
static void do_noemailorfax(FILE *fp, Error *err, int namelen, int errtype);
static void do_ambiguous(FILE *fp, Error *err, int namelen);
static int count_values(char **list);
static void add_to(char ***list, int *nlist, char **new);
static int isgroup(LDAPMessage *e);
static void add_error(Error **err, int *nerr, int code, char *addr, LDAPMessage *msg);
static void add_group(char *dn, Group **list, int *nlist);
static void unbind_and_exit(int rc);
static int group_loop(char *dn);
static void send_group(Group *group, int ngroup);
static int has_attributes(LDAPMessage *e, char *attr1, char *attr2);
static char **get_attributes_mail_dn(LDAPMessage *e, char *attr1, char *attr2);
static char *canonical(char *s);
static int connect_to_x500 (void);
static void do_group_errors (LDAPMessage *e, char *dn, char ***to, int *nto, Error **err, int *nerr);
static void do_group_request (LDAPMessage *e, char *dn, char ***to, int *nto, Error **err, int *nerr);
static void add_member (char *gdn, char *dn, char ***to, int *nto, Group **togroups, int *ngroups, Error **err, int *nerr);
int
main ( int argc, char **argv )
{
char *myname;
char **tolist;
@ -131,9 +142,6 @@ char **argv;
Group *togroups;
int numto, ngroups, numerr, nargs;
int i, j;
FILE *fp;
extern int optind, errno;
extern char *optarg;
while ( (i = getopt( argc, argv, "f:h:m:" )) != EOF ) {
switch( i ) {
@ -255,7 +263,7 @@ char **argv;
*/
if ( numerr > 0 && numto > nargs || ngroups > 0 ) {
int fd;
FILE *fp;
char buf[BUFSIZ];
umask( 077 );
@ -303,7 +311,8 @@ char **argv;
return( EX_OK );
}
connect_to_x500()
static int
connect_to_x500( void )
{
if ( (ld = ldap_open( LDAPHOST, LDAP_PORT )) == NULL ) {
syslog( LOG_ALERT, "ldap_open failed" );
@ -321,16 +330,17 @@ connect_to_x500()
}
static
do_address( name, to, nto, togroups, ngroups, err, nerr, type )
char *name;
char ***to;
int *nto;
Group **togroups;
int *ngroups;
Error **err;
int *nerr;
int type;
static void
do_address(
char *name,
char ***to,
int *nto,
Group **togroups,
int *ngroups,
Error **err,
int *nerr,
int type
)
{
int rc, b, f, match;
LDAPMessage *e, *res;
@ -572,16 +582,17 @@ do_address( name, to, nto, togroups, ngroups, err, nerr, type )
return;
}
static
do_group( e, dn, to, nto, togroups, ngroups, err, nerr )
LDAPMessage *e;
char *dn;
char ***to;
int *nto;
Group **togroups;
int *ngroups;
Error **err;
int *nerr;
static int
do_group(
LDAPMessage *e,
char *dn,
char ***to,
int *nto,
Group **togroups,
int *ngroups,
Error **err,
int *nerr
)
{
/*
* If this group has an rfc822ErrorsTo attribute, we need to
@ -610,16 +621,17 @@ do_group( e, dn, to, nto, togroups, ngroups, err, nerr )
}
/* ARGSUSED */
static
do_group_members( e, dn, to, nto, togroups, ngroups, err, nerr )
LDAPMessage *e;
char *dn;
char ***to;
int *nto;
Group **togroups;
int *ngroups;
Error **err;
int *nerr;
static void
do_group_members(
LDAPMessage *e,
char *dn,
char ***to,
int *nto,
Group **togroups,
int *ngroups,
Error **err,
int *nerr
)
{
int i, rc;
char *ndn;
@ -785,15 +797,17 @@ do_group_members( e, dn, to, nto, togroups, ngroups, err, nerr )
return;
}
add_member( gdn, dn, to, nto, togroups, ngroups, err, nerr )
char *gdn;
char *dn;
char ***to;
int *nto;
Group **togroups;
int *ngroups;
Error **err;
int *nerr;
static void
add_member(
char *gdn,
char *dn,
char ***to,
int *nto,
Group **togroups,
int *ngroups,
Error **err,
int *nerr
)
{
char *ndn;
char **mail;
@ -876,13 +890,15 @@ add_member( gdn, dn, to, nto, togroups, ngroups, err, nerr )
return;
}
do_group_request( e, dn, to, nto, err, nerr )
LDAPMessage *e;
char *dn;
char ***to;
int *nto;
Error **err;
int *nerr;
static void
do_group_request(
LDAPMessage *e,
char *dn,
char ***to,
int *nto,
Error **err,
int *nerr
)
{
char **requeststo;
@ -894,17 +910,17 @@ do_group_request( e, dn, to, nto, err, nerr )
} else {
add_error( err, nerr, E_NOREQUEST, dn, NULLMSG );
}
return;
}
do_group_errors( e, dn, to, nto, err, nerr )
LDAPMessage *e;
char *dn;
char ***to;
int *nto;
Error **err;
int *nerr;
static void
do_group_errors(
LDAPMessage *e,
char *dn,
char ***to,
int *nto,
Error **err,
int *nerr
)
{
char **errorsto;
@ -916,13 +932,10 @@ do_group_errors( e, dn, to, nto, err, nerr )
} else {
add_error( err, nerr, E_NOERRORS, dn, NULLMSG );
}
return;
}
static
send_message( to )
char **to;
static void
send_message( char **to )
{
int pid;
#ifndef HAVE_WAITPID
@ -931,7 +944,7 @@ send_message( to )
/* parent */
if ( pid = fork() ) {
if ( (pid = fork()) != 0 ) {
#ifdef HAVE_WAITPID
waitpid( pid, (int *) NULL, 0 );
#else
@ -948,10 +961,8 @@ send_message( to )
}
}
static
send_group( group, ngroup )
Group *group;
int ngroup;
static void
send_group( Group *group, int ngroup )
{
int i, pid;
char **argv;
@ -979,7 +990,7 @@ send_group( group, ngroup )
/* parent */
if ( pid = fork() ) {
if ( (pid = fork()) != 0 ) {
#ifdef HAVE_WAITPID
waitpid( pid, (int *) NULL, 0 );
#else
@ -998,10 +1009,8 @@ send_group( group, ngroup )
return;
}
static
send_errors( err, nerr )
Error *err;
int nerr;
static void
send_errors( Error *err, int nerr )
{
int i, namelen;
FILE *fp;
@ -1097,12 +1106,8 @@ send_errors( err, nerr )
}
static
do_noemailorfax( fp, err, namelen, errtype )
FILE *fp;
Error *err;
int namelen;
int errtype;
static void
do_noemailorfax( FILE *fp, Error *err, int namelen, int errtype )
{
int i, last;
char *dn, *rdn;
@ -1191,11 +1196,8 @@ do_noemailorfax( fp, err, namelen, errtype )
}
/* ARGSUSED */
static
do_ambiguous( fp, err, namelen )
FILE *fp;
Error *err;
int namelen;
static void
do_ambiguous( FILE *fp, Error *err, int namelen )
{
int i, last;
char *dn, *rdn;
@ -1246,9 +1248,8 @@ do_ambiguous( fp, err, namelen )
}
}
static
count_values( list )
char **list;
static int
count_values( char **list )
{
int i;
@ -1258,11 +1259,8 @@ count_values( list )
return( i );
}
static
add_to( list, nlist, new )
char ***list;
int *nlist;
char **new;
static void
add_to( char ***list, int *nlist, char **new )
{
int i, nnew, oldnlist;
@ -1286,9 +1284,8 @@ add_to( list, nlist, new )
return;
}
static
isgroup( e )
LDAPMessage *e;
static int
isgroup( LDAPMessage *e )
{
int i;
char **oclist;
@ -1306,13 +1303,8 @@ isgroup( e )
return( 0 );
}
static
add_error( err, nerr, code, addr, msg )
Error **err;
int *nerr;
int code;
char *addr;
LDAPMessage *msg;
static void
add_error( Error **err, int *nerr, int code, char *addr, LDAPMessage *msg )
{
if ( *nerr == 0 ) {
*err = (Error *) malloc( sizeof(Error) );
@ -1328,11 +1320,8 @@ add_error( err, nerr, code, addr, msg )
return;
}
static
add_group( dn, list, nlist )
char *dn;
Group **list;
int *nlist;
static void
add_group( char *dn, Group **list, int *nlist )
{
int i, namelen;
char **ufn;
@ -1379,9 +1368,8 @@ add_group( dn, list, nlist )
return;
}
static
unbind_and_exit( rc )
int rc;
static void
unbind_and_exit( int rc )
{
int i;
@ -1392,8 +1380,7 @@ unbind_and_exit( rc )
}
static char *
canonical( s )
char *s;
canonical( char *s )
{
char *saves = s;
@ -1405,9 +1392,8 @@ canonical( s )
return( saves );
}
static
group_loop( dn )
char *dn;
static int
group_loop( char *dn )
{
int i;
static char **groups;
@ -1429,11 +1415,8 @@ group_loop( dn )
return( 0 );
}
static
has_attributes( e, attr1, attr2 )
LDAPMessage *e;
char *attr1;
char *attr2;
static int
has_attributes( LDAPMessage *e, char *attr1, char *attr2 )
{
char **attr;
@ -1451,10 +1434,7 @@ has_attributes( e, attr1, attr2 )
}
static char **
get_attributes_mail_dn( e, attr1, attr2 )
LDAPMessage *e;
char *attr1;
char *attr2; /* this one is dn-valued */
get_attributes_mail_dn( LDAPMessage *e, char *attr1, char *attr2 )
{
LDAPMessage *ee, *res;
char **vals, **dnlist, **mail;

View file

@ -12,20 +12,25 @@
#include "portable.h"
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <ac/signal.h>
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/syslog.h>
#include <ac/time.h>
#include <ac/unistd.h>
#include <ac/wait.h>
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
#include <lber.h>
#include <ldap.h>
#include "fax500.h"
#include <ldapconfig.h>
#define DEFAULT_PORT 79
@ -38,23 +43,20 @@ int deref;
int sizelimit;
LDAPFiltDesc *filtd;
static print_entry();
static void print_entry(LDAP *ld, LDAPMessage *e);
static
usage( name )
char *name;
static void
usage( char *name )
{
fprintf( stderr, "usage: %s [-d debuglevel] [-x ldaphost] [-b searchbase] [-a] [-z sizelimit] [-f filterfile] searchstring\r\n", name );
exit( -1 );
}
main (argc, argv)
int argc;
char **argv;
int
main( int argc, char **argv )
{
int i, rc, matches;
char *filterfile = FILTERFILE;
struct timeval timeout;
char buf[10];
char *key;
LDAP *ld;
@ -64,8 +66,6 @@ main (argc, argv)
static char *attrs[] = { "title", "o", "ou", "postalAddress",
"telephoneNumber", "mail",
"facsimileTelephoneNumber", NULL };
extern char *optarg;
extern int optind;
deref = LDAP_DEREF_ALWAYS;
while ( (i = getopt( argc, argv, "ab:d:f:x:z:" )) != EOF ) {
@ -176,7 +176,6 @@ main (argc, argv)
rdn++;
if ( strcasecmp( rdn, buf ) == 0 ) {
char **cn;
char *s;
int i, last;
cn = ldap_get_values( ld, e, "cn" );
@ -237,16 +236,14 @@ main (argc, argv)
return( 0 );
}
static
print_entry( ld, e )
LDAP *ld;
LDAPMessage *e;
static void
print_entry( LDAP *ld, LDAPMessage *e )
{
int i;
char *dn, *rdn;
char **ufn;
char **title, **dept, **addr, **phone, **fax, **mail;
char *faxmail, *org, *faxtotpc();
char *faxmail, *org;
dn = ldap_get_dn( ld, e );
ufn = ldap_explode_dn( dn, 0 );

View file

@ -10,31 +10,30 @@
* is provided ``as is'' without express or implied warranty.
*/
#include "portable.h"
#include <stdio.h>
#include <stdlib.h>
#include <ac/ctype.h>
#include <ac/signal.h>
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/syslog.h>
#include <ac/time.h>
#include <ac/unistd.h>
#include <ac/wait.h>
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
#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;
@ -45,21 +44,19 @@ char *filterfile = FILTERFILE;
char *templatefile = TEMPLATEFILE;
int rdncount = FINGER_RDNCOUNT;
static do_query();
static do_search();
static do_read();
static print_attr();
static void do_query(void);
static void do_search(LDAP *ld, char *buf);
static void do_read(LDAP *ld, LDAPMessage *e);
static usage( name )
char *name;
static void
usage( 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
main( int argc, char **argv )
{
int i;
char *myname;
@ -68,7 +65,6 @@ char **argv;
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 ) {
@ -136,7 +132,7 @@ char **argv;
#endif
}
if ( dosyslog && mypeer != -1 ) {
if ( dosyslog && mypeer != (unsigned long) -1 ) {
struct in_addr addr;
hp = gethostbyaddr( (char *) &mypeer, sizeof(mypeer), AF_INET );
@ -150,7 +146,8 @@ char **argv;
return( 0 );
}
static do_query()
static void
do_query( void )
{
char buf[256];
int len, rc, tblsize;
@ -166,17 +163,27 @@ static do_query()
ld->ld_sizelimit = FINGER_SIZELIMIT;
ld->ld_deref = deref;
if ( ldap_simple_bind_s( ld, FINGER_BINDDN, NULL ) != LDAP_SUCCESS ) {
if ( ldap_simple_bind_s( ld, FINGER_BINDDN, FINGER_BIND_CRED )
!= LDAP_SUCCESS )
{
fprintf( stderr, FINGER_UNAVAILABLE );
ldap_perror( ld, "ldap_simple_bind_s" );
exit( 1 );
}
#ifdef USE_SYSCONF
#ifdef HAVE_SYSCONF
tblsize = sysconf( _SC_OPEN_MAX );
#else /* USE_SYSCONF */
#elif HAVE_GETDTABLESIZE
tblsize = getdtablesize();
#endif /* USE_SYSCONF */
#else
tblsize = FD_SETSIZE;
#endif
#ifdef FD_SETSIZE
if (tblsize > FD_SETSIZE) {
tblsize = FD_SETSIZE;
}
#endif /* FD_SETSIZE*/
timeout.tv_sec = FINGER_TIMEOUT;
timeout.tv_usec = 0;
@ -228,8 +235,7 @@ static do_query()
}
static void
spaces2dots( s )
char *s;
spaces2dots( char *s )
{
for ( ; *s; s++ ) {
if ( *s == ' ' ) {
@ -238,9 +244,8 @@ spaces2dots( s )
}
}
static do_search( ld, buf )
LDAP *ld;
char *buf;
static void
do_search( LDAP *ld, char *buf )
{
char *dn, *rdn;
char **title;
@ -253,7 +258,6 @@ char *buf;
FINGER_SORT_ATTR,
#endif
0 };
extern int strcasecmp();
ufn = 0;
#ifdef FINGER_UFN
@ -405,9 +409,8 @@ entry2textwrite( void *fp, char *buf, int len )
}
static do_read( ld, e )
LDAP *ld;
LDAPMessage *e;
static void
do_read( LDAP *ld, LDAPMessage *e )
{
static struct ldap_disptmpl *tmpllist;
static char *defattrs[] = { "mail", NULL };

View file

@ -1,80 +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 <stdio.h>
#include <sys/types.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <signal.h>
#include "portable.h"
#ifdef USE_SYSCONF
#include <unistd.h>
#endif /* USE_SYSCONF */
detach( debug )
int debug;
{
int i, sd, nbits;
#ifdef USE_SYSCONF
nbits = sysconf( _SC_OPEN_MAX );
#else /* USE_SYSCONF */
nbits = getdtablesize();
#endif /* USE_SYSCONF */
if ( debug == 0 || !(isatty( 1 )) ) {
for ( i = 0; i < 5; i++ ) {
switch ( fork() ) {
case -1:
sleep( 5 );
continue;
case 0:
break;
default:
_exit( 0 );
}
break;
}
for ( i = 3; i < nbits; i++ )
close( i );
(void) chdir( "/" );
if ( (sd = open( "/dev/null", O_RDWR )) == -1 ) {
if ( debug ) perror( "/dev/null" );
exit( 1 );
}
if ( isatty( 0 ) )
(void) dup2( sd, 0 );
if ( isatty( 1 ) )
(void) dup2( sd, 1 );
if ( isatty(2) )
(void) dup2( sd, 2 );
close( sd );
#ifdef USE_SETSID
(void) setsid();
#else /* USE_SETSID */
if ( (sd = open( "/dev/tty", O_RDWR )) != -1 ) {
(void) ioctl( sd, TIOCNOTTY, NULL );
(void) close( sd );
}
#endif /* USE_SETSID */
}
(void) signal( SIGPIPE, SIG_IGN );
}

View file

@ -13,6 +13,7 @@
#include "portable.h"
#include <stdio.h>
#include <stdlib.h>
#include <ac/ctype.h>
#include <ac/signal.h>
@ -29,7 +30,9 @@
#include <sys/param.h>
#endif
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
#include "ldapconfig.h"
#include "lber.h"
@ -52,24 +55,23 @@ char *templatefile = TEMPLATEFILE;
char myhost[MAXHOSTNAMELEN];
int myport;
static set_socket();
static RETSIGTYPE wait4child();
static do_queries();
static do_error();
static do_search();
static do_read();
extern int strcasecmp();
static void usage ( char *name );
static int set_socket (int port);
static RETSIGTYPE wait4child(int sig);
static void do_queries (int s);
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);
static usage( name )
char *name;
static void
usage( char *name )
{
fprintf( stderr, "usage: %s [-d debuglevel] [-f filterfile] [-t templatefile]\r\n\t[-a] [-l] [-p port] [-x ldaphost] [-b searchbase] [-c rdncount]\r\n", name );
exit( 1 );
}
main (argc, argv)
int argc;
char **argv;
int
main( int argc, char **argv )
{
int s, ns, rc;
int port = -1;
@ -79,8 +81,6 @@ char **argv;
struct hostent *hp;
struct sockaddr_in from;
int fromlen;
RETSIGTYPE wait4child();
extern char *optarg;
#if defined( LDAP_PROCTITLE ) && !defined( HAVE_SETPROCTITLE )
/* for setproctitle */
@ -260,9 +260,8 @@ char **argv;
/* NOT REACHED */
}
static
set_socket( port )
int port;
static int
set_socket( int port )
{
int s, one;
struct sockaddr_in addr;
@ -305,7 +304,7 @@ int port;
}
static RETSIGTYPE
wait4child()
wait4child( int sig )
{
#ifndef HAVE_WAITPID
WAITSTATUSTYPE status;
@ -324,9 +323,8 @@ wait4child()
(void) SIGNAL( SIGCHLD, wait4child );
}
static
do_queries( s )
int s;
static void
do_queries( int s )
{
char buf[1024], *query;
int len;
@ -426,7 +424,7 @@ int s;
fprintf( fp, ".\r\n" );
rewind(fp);
if( ld == NULL ) {
if ( ld != NULL) {
ldap_unbind( ld );
}
@ -434,10 +432,8 @@ int s;
/* NOT REACHED */
}
static
do_error( fp, s )
FILE *fp;
char *s;
static void
do_error( FILE *fp, char *s )
{
int code;
@ -449,11 +445,8 @@ char *s;
fprintf( fp, ".\r\n" );
}
static
do_search( ld, fp, buf )
LDAP *ld;
FILE *fp;
char *buf;
static void
do_search( LDAP *ld, FILE *fp, char *buf )
{
char *dn, *rdn;
char **title;
@ -563,14 +556,11 @@ char *buf;
static int
entry2textwrite( void *fp, char *buf, int len )
{
return( fwrite( buf, len, 1, (FILE *)fp ) == 0 ? -1 : len );
return( fwrite( buf, len, 1, (FILE *)fp ) == 0 ? -1 : len );
}
static
do_read( ld, fp, dn )
LDAP *ld;
FILE *fp;
char *dn;
static void
do_read( LDAP *ld, FILE *fp, char *dn )
{
static struct ldap_disptmpl *tmpllist;

View file

@ -13,6 +13,7 @@
#include "portable.h"
#include <stdio.h>
#include <stdlib.h>
#include <ac/ctype.h>
#include <ac/signal.h>
@ -25,12 +26,15 @@
#include <ac/setproctitle.h>
#include <sys/resource.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
#include "lber.h"
#include "ldap.h"
#include "lutil.h"
@ -53,31 +57,35 @@ char *templatefile = TEMPLATEFILE;
char *friendlyfile = FRIENDLYFILE;
int rdncount = GO500GW_RDNCOUNT;
static set_socket();
static RETSIGTYPE wait4child();
static do_queries();
static do_menu();
static do_list();
static do_search();
static do_read();
static do_help();
static do_sizelimit();
static do_error();
extern int strcasecmp();
static void usage ( char *name );
static int set_socket (int port);
static RETSIGTYPE wait4child(int sig);
static void do_queries (int s);
static char *pick_oc ( char **oclist );
static int isnonleaf ( LDAP *ld, char **oclist, char *dn );
static void do_menu (LDAP *ld, FILE *fp, char *dn);
static void do_list (LDAP *ld, FILE *fp, char *dn);
static int isoc ( char **ocl, char *oc );
static int make_scope ( LDAP *ld, char *dn );
static void do_search (LDAP *ld, FILE *fp, char *query);
static int entry2textwrite( void *fp, char *buf, int len );
static void do_read (LDAP *ld, FILE *fp, char *dn);
static void do_help (FILE *op);
static void do_sizelimit(FILE *fp, char type);
static void do_error (FILE *fp, char *s);
char myhost[MAXHOSTNAMELEN];
int myport = GO500GW_PORT;
static usage( name )
char *name;
static void
usage( char *name )
{
fprintf( stderr, "usage: %s [-d debuglevel] [-I] [-p port] [-P ldapport] [-l]\r\n\t[-x ldaphost] [-a] [-h helpfile] [-f filterfile] [-t templatefile] [-c rdncount]\r\n", name );
exit( 1 );
}
main (argc, argv)
int argc;
char **argv;
int
main (int argc, char **argv )
{
int s, ns, rc;
int port = -1;
@ -87,8 +95,6 @@ char **argv;
struct hostent *hp;
struct sockaddr_in from;
int fromlen;
RETSIGTYPE wait4child();
extern char *optarg;
#if defined( LDAP_PROCTITLE ) && !defined( HAVE_SETPROCTITLE )
/* for setproctitle */
@ -284,8 +290,8 @@ char **argv;
/* NOT REACHED */
}
static set_socket( port )
int port;
static int
set_socket( int port )
{
int s, one;
struct sockaddr_in addr;
@ -329,7 +335,7 @@ int port;
}
static RETSIGTYPE
wait4child()
wait4child( int sig )
{
#ifndef HAVE_WAITPID
WAITSTATUSTYPE status;
@ -348,8 +354,8 @@ wait4child()
(void) SIGNAL( SIGCHLD, wait4child );
}
static do_queries( s )
int s;
static void
do_queries( int s )
{
char buf[1024], *query;
int len;
@ -452,7 +458,7 @@ int s;
break;
case 'S': /* search */
do_search( ld, fp, query, 1 );
do_search( ld, fp, query );
break;
case 'M': /* X.500 menu */
@ -471,8 +477,8 @@ int s;
/* NOT REACHED */
}
static char *pick_oc( oclist )
char **oclist;
static char *
pick_oc( char **oclist )
{
int i;
@ -489,10 +495,8 @@ char **oclist;
return( "unknown" );
}
static isnonleaf( ld, oclist, dn )
LDAP *ld;
char **oclist;
char *dn;
static int
isnonleaf( LDAP *ld, char **oclist, char *dn )
{
int i, quipuobject = 0;
@ -543,10 +547,8 @@ char *dn;
#endif
}
static do_menu( ld, fp, dn )
LDAP *ld;
FILE *fp;
char *dn;
static void
do_menu( LDAP *ld, FILE *fp, char *dn )
{
char **s;
char *rdn = NULL;
@ -576,10 +578,8 @@ char *dn;
ldap_free_friendlymap( &fm );
}
static do_list( ld, fp, dn )
LDAP *ld;
FILE *fp;
char *dn;
static void
do_list( LDAP *ld, FILE *fp, char *dn )
{
int rc;
LDAPMessage *e, *res;
@ -651,9 +651,8 @@ char *dn;
}
}
static isoc( ocl, oc )
char **ocl;
char *oc;
static int
isoc( char **ocl, char *oc )
{
int i;
@ -665,9 +664,8 @@ char *oc;
return( 0 );
}
static int make_scope( ld, dn )
LDAP *ld;
char *dn;
static int
make_scope( LDAP *ld, char *dn )
{
int scope;
char **oc;
@ -698,10 +696,8 @@ char *dn;
return( scope );
}
static do_search( ld, fp, query )
LDAP *ld;
FILE *fp;
char *query;
static void
do_search( LDAP *ld, FILE *fp, char *query )
{
int scope;
char *base, *filter;
@ -768,7 +764,7 @@ char *query;
!= LDAP_SUCCESS && rc != LDAP_SIZELIMIT_EXCEEDED ) {
fprintf(fp, "0An error occurred (explanation)\tE%d\t%s\t%d\r\n",
rc, myhost, myport );
return( 1 );
return;
}
if ( (count = ldap_count_entries( ld, res )) != 0 )
break;
@ -780,7 +776,7 @@ char *query;
#endif
if ( count == 0 ) {
return( 0 );
return;
}
if ( count == 1 ) {
@ -792,10 +788,10 @@ char *query;
dn = ldap_get_dn( ld, e );
if ( isnonleaf( ld, oc, dn ) ) {
rc = do_menu( ld, fp, dn );
do_menu( ld, fp, dn );
free( dn );
return( rc );
return;
}
free( dn );
@ -840,10 +836,8 @@ entry2textwrite( void *fp, char *buf, int len )
return( fwrite( buf, len, 1, (FILE *)fp ) == 0 ? -1 : len );
}
static do_read( ld, fp, dn )
LDAP *ld;
FILE *fp;
char *dn;
static void
do_read( LDAP *ld, FILE *fp, char *dn )
{
static struct ldap_disptmpl *tmpllist;
@ -863,8 +857,8 @@ char *dn;
}
}
static do_help( op )
FILE *op;
static void
do_help( FILE *op )
{
FILE *fp;
char line[BUFSIZ];
@ -883,9 +877,8 @@ FILE *op;
fclose( fp );
}
static do_sizelimit( fp, type )
FILE *fp;
char type;
static void
do_sizelimit( FILE *fp, char type )
{
if ( type == 'S' ) {
fprintf( fp, "The query you specified was not specific enough, causing a size limit\r\n" );
@ -901,9 +894,8 @@ char type;
fprintf( fp, ".\r\n" );
}
static do_error( fp, s )
FILE *fp;
char *s;
static void
do_error( FILE *fp, char *s )
{
int code;

View file

@ -1,46 +0,0 @@
/*
* Copyright (c) 1990,1991 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.
*/
char **Argv; /* pointer to original (main's) argv */
int Argc; /* original argc */
/*
* takes a printf-style format string (fmt) and up to three parameters (a,b,c)
* this clobbers the original argv...
*/
/* VARARGS */
setproctitle( fmt, a, b, c )
char *fmt;
{
static char *endargv = (char *)0;
char *s;
int i;
char buf[ 1024 ];
if ( endargv == (char *)0 ) {
/* set pointer to end of original argv */
endargv = Argv[ Argc-1 ] + strlen( Argv[ Argc-1 ] );
}
sprintf( buf, fmt, a, b, c );
/* make ps print "([prog name])" */
s = Argv[0];
*s++ = '-';
i = strlen( buf );
if ( i > endargv - s - 2 ) {
i = endargv - s - 2;
buf[ i ] = '\0';
}
strcpy( s, buf );
s += i;
while ( s < endargv ) *s++ = ' ';
}

View file

@ -14,18 +14,21 @@
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <ac/ctype.h>
#include <ac/string.h>
#include <ac/syslog.h>
#include <ac/time.h>
#include <ac/wait.h>
#include <ac/unistd.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
#include <sysexits.h>
@ -121,27 +124,32 @@ static char *attrs[] = { "objectClass", "title", "postaladdress",
"moderator", "onVacation", "uid",
"suppressNoEmailError", NULL };
static do_address();
static do_group();
static do_group_members();
static send_message();
static send_errors();
static do_noemail();
static do_ambiguous();
static add_to();
static isgroup();
static add_error();
static add_group();
static unbind_and_exit();
static group_loop();
static send_group();
static has_attributes();
static char **get_attributes_mail_dn();
static char *canonical();
static void do_address( char *name, char ***to, int *nto, Group **togroups, int *ngroups, Error **err, int *nerr, int type );
static int do_group( LDAPMessage *e, char *dn, char ***to, int *nto, Group **togroups, int *ngroups, Error **err, int *nerr );
static void do_group_members( LDAPMessage *e, char *dn, char ***to, int *nto, Group **togroups, int *ngroups, Error **err, int *nerr );
static void send_message( char **to );
static void send_errors( Error *err, int nerr );
static void do_noemail( FILE *fp, Error *err, int namelen );
static void do_ambiguous( FILE *fp, Error *err, int namelen );
static void add_to( char ***list, int *nlist, char **new );
static int isgroup( LDAPMessage *e );
static void add_error( Error **err, int *nerr, int code, char *addr, LDAPMessage *msg );
static void add_group( char *dn, Group **list, int *nlist );
static void unbind_and_exit( int rc );
static int group_loop( char *dn );
static void send_group( Group *group, int ngroup );
static int has_attributes( LDAPMessage *e, char *attr1, char *attr2 );
static char **get_attributes_mail_dn( LDAPMessage *e, char *attr1, char *attr2 );
static char *canonical( char *s );
static int connect_to_x500( void );
main (argc, argv)
int argc;
char **argv;
static void do_group_errors( LDAPMessage *e, char *dn, char ***to, int *nto, Error **err, int *nerr );
static void do_group_request( LDAPMessage *e, char *dn, char ***to, int *nto, Error **err, int *nerr );
static void do_group_owner( LDAPMessage *e, char *dn, char ***to, int *nto, Error **err, int *nerr );
static void add_member( char *gdn, char *dn, char ***to, int *nto, Group **togroups, int *ngroups, Error **err, int *nerr, char **suppress );
int
main ( int argc, char **argv )
{
char *myname;
char **tolist;
@ -149,9 +157,6 @@ char **argv;
Group *togroups;
int numto, ngroups, numerr, nargs;
int i, j;
FILE *fp;
extern int optind, errno;
extern char *optarg;
if ( (myname = strrchr( argv[0], '/' )) == NULL )
myname = strdup( argv[0] );
@ -285,7 +290,7 @@ char **argv;
*/
if ( numerr > 0 && numto > nargs || ngroups > 0 ) {
int fd;
FILE *fp;
char buf[BUFSIZ];
umask( 077 );
@ -342,7 +347,8 @@ char **argv;
return( EX_OK );
}
connect_to_x500()
static int
connect_to_x500( void )
{
if ( (ld = ldap_open( ldaphost, LDAP_PORT )) == NULL ) {
syslog( LOG_ALERT, "ldap_open failed" );
@ -359,10 +365,8 @@ connect_to_x500()
return( 0 );
}
static
mailcmp( a, b )
char *a;
char *b;
static int
mailcmp( char *a, char *b )
{
int i;
@ -385,16 +389,17 @@ mailcmp( a, b )
return( 0 );
}
static
do_address( name, to, nto, togroups, ngroups, err, nerr, type )
char *name;
char ***to;
int *nto;
Group **togroups;
int *ngroups;
Error **err;
int *nerr;
int type;
static void
do_address(
char *name,
char ***to,
int *nto,
Group **togroups,
int *ngroups,
Error **err,
int *nerr,
int type
)
{
int rc, b, f, match;
LDAPMessage *e, *res;
@ -686,20 +691,19 @@ do_address( name, to, nto, togroups, ngroups, err, nerr, type )
ldap_value_free( uid );
}
free( dn );
return;
}
static
do_group( e, dn, to, nto, togroups, ngroups, err, nerr )
LDAPMessage *e;
char *dn;
char ***to;
int *nto;
Group **togroups;
int *ngroups;
Error **err;
int *nerr;
static int
do_group(
LDAPMessage *e,
char *dn,
char ***to,
int *nto,
Group **togroups,
int *ngroups,
Error **err,
int *nerr
)
{
int i;
char **moderator;
@ -757,16 +761,17 @@ do_group( e, dn, to, nto, togroups, ngroups, err, nerr )
}
/* ARGSUSED */
static
do_group_members( e, dn, to, nto, togroups, ngroups, err, nerr )
LDAPMessage *e;
char *dn;
char ***to;
int *nto;
Group **togroups;
int *ngroups;
Error **err;
int *nerr;
static void
do_group_members(
LDAPMessage *e,
char *dn,
char ***to,
int *nto,
Group **togroups,
int *ngroups,
Error **err,
int *nerr
)
{
int i, rc, anymembers;
char *ndn;
@ -898,20 +903,20 @@ do_group_members( e, dn, to, nto, togroups, ngroups, err, nerr )
if ( ! anymembers ) {
add_error( err, nerr, E_NOMEMBERS, dn, NULLMSG );
}
return;
}
add_member( gdn, dn, to, nto, togroups, ngroups, err, nerr, suppress )
char *gdn;
char *dn;
char ***to;
int *nto;
Group **togroups;
int *ngroups;
Error **err;
int *nerr;
char **suppress;
static void
add_member(
char *gdn,
char *dn,
char ***to,
int *nto,
Group **togroups,
int *ngroups,
Error **err,
int *nerr,
char **suppress
)
{
char *ndn;
char **mail;
@ -968,17 +973,17 @@ add_member( gdn, dn, to, nto, togroups, ngroups, err, nerr, suppress )
}
free( ndn );
return;
}
do_group_request( e, dn, to, nto, err, nerr )
LDAPMessage *e;
char *dn;
char ***to;
int *nto;
Error **err;
int *nerr;
static void
do_group_request(
LDAPMessage *e,
char *dn,
char ***to,
int *nto,
Error **err,
int *nerr
)
{
char **requeststo;
@ -990,17 +995,17 @@ do_group_request( e, dn, to, nto, err, nerr )
} else {
add_error( err, nerr, E_NOREQUEST, dn, NULLMSG );
}
return;
}
do_group_errors( e, dn, to, nto, err, nerr )
LDAPMessage *e;
char *dn;
char ***to;
int *nto;
Error **err;
int *nerr;
static void
do_group_errors(
LDAPMessage *e,
char *dn,
char ***to,
int *nto,
Error **err,
int *nerr
)
{
char **errorsto;
@ -1012,17 +1017,17 @@ do_group_errors( e, dn, to, nto, err, nerr )
} else {
add_error( err, nerr, E_NOERRORS, dn, NULLMSG );
}
return;
}
do_group_owner( e, dn, to, nto, err, nerr )
LDAPMessage *e;
char *dn;
char ***to;
int *nto;
Error **err;
int *nerr;
static void
do_group_owner(
LDAPMessage *e,
char *dn,
char ***to,
int *nto,
Error **err,
int *nerr
)
{
char **owner;
@ -1032,12 +1037,10 @@ do_group_owner( e, dn, to, nto, err, nerr )
} else {
add_error( err, nerr, E_NOOWNER, dn, NULLMSG );
}
return;
}
static
send_message( to )
char **to;
static void
send_message( char **to )
{
int pid;
#ifndef HAVE_WAITPID
@ -1058,7 +1061,7 @@ send_message( to )
}
/* parent */
if ( pid = fork() ) {
if ( (pid = fork()) != 0 ) {
#ifdef HAVE_WAITPID
waitpid( pid, (int *) NULL, 0 );
#else
@ -1075,10 +1078,8 @@ send_message( to )
}
}
static
send_group( group, ngroup )
Group *group;
int ngroup;
static void
send_group( Group *group, int ngroup )
{
int i, pid;
char **argv;
@ -1118,7 +1119,7 @@ send_group( group, ngroup )
}
/* parent */
if ( pid = fork() ) {
if ( (pid = fork()) != 0 ) {
#ifdef HAVE_WAITPID
waitpid( pid, (int *) NULL, 0 );
#else
@ -1133,14 +1134,10 @@ send_group( group, ngroup )
exit( EX_TEMPFAIL );
}
}
return;
}
static
send_errors( err, nerr )
Error *err;
int nerr;
static void
send_errors( Error *err, int nerr )
{
int pid, i, namelen;
FILE *fp;
@ -1181,7 +1178,7 @@ send_errors( err, nerr )
exit( EX_TEMPFAIL );
}
if ( pid = fork() ) {
if ( (pid = fork()) != 0 ) {
if ( (fp = fdopen( fd[1], "w" )) == NULL ) {
syslog( LOG_ALERT, "cannot fdopen pipe" );
exit( EX_TEMPFAIL );
@ -1284,15 +1281,10 @@ send_errors( err, nerr )
exit( EX_TEMPFAIL );
}
return;
}
static
do_noemail( fp, err, namelen )
FILE *fp;
Error *err;
int namelen;
static void
do_noemail( FILE *fp, Error *err, int namelen )
{
int i, last;
char *dn, *rdn;
@ -1376,11 +1368,8 @@ do_noemail( fp, err, namelen )
}
/* ARGSUSED */
static
do_ambiguous( fp, err, namelen )
FILE *fp;
Error *err;
int namelen;
static void
do_ambiguous( FILE *fp, Error *err, int namelen )
{
int i, last;
char *dn, *rdn;
@ -1431,9 +1420,8 @@ do_ambiguous( fp, err, namelen )
}
}
static
count_values( list )
char **list;
static int
count_values( char **list )
{
int i;
@ -1443,11 +1431,8 @@ count_values( list )
return( i );
}
static
add_to( list, nlist, new )
char ***list;
int *nlist;
char **new;
static void
add_to( char ***list, int *nlist, char **new )
{
int i, nnew, oldnlist;
@ -1466,13 +1451,10 @@ add_to( list, nlist, new )
for ( i = 0; i < nnew; i++ )
(*list)[i + oldnlist] = strdup( new[i] );
(*list)[*nlist] = NULL;
return;
}
static
isgroup( e )
LDAPMessage *e;
static int
isgroup( LDAPMessage *e )
{
int i;
char **oclist;
@ -1490,13 +1472,8 @@ isgroup( e )
return( 0 );
}
static
add_error( err, nerr, code, addr, msg )
Error **err;
int *nerr;
int code;
char *addr;
LDAPMessage *msg;
static void
add_error( Error **err, int *nerr, int code, char *addr, LDAPMessage *msg )
{
if ( *nerr == 0 ) {
*err = (Error *) malloc( sizeof(Error) );
@ -1508,15 +1485,10 @@ add_error( err, nerr, code, addr, msg )
(*err)[*nerr].e_addr = strdup( addr );
(*err)[*nerr].e_msg = msg;
(*nerr)++;
return;
}
static
add_group( dn, list, nlist )
char *dn;
Group **list;
int *nlist;
static void
add_group( char *dn, Group **list, int *nlist )
{
int i, namelen;
char **ufn;
@ -1559,13 +1531,10 @@ add_group( dn, list, nlist )
(*nlist)++;
ldap_value_free( ufn );
return;
}
static
unbind_and_exit( rc )
int rc;
static void
unbind_and_exit( int rc )
{
int i;
@ -1576,8 +1545,7 @@ unbind_and_exit( rc )
}
static char *
canonical( s )
char *s;
canonical( char *s )
{
char *saves = s;
@ -1589,9 +1557,8 @@ canonical( s )
return( saves );
}
static
group_loop( dn )
char *dn;
static int
group_loop( char *dn )
{
int i;
static char **groups;
@ -1613,11 +1580,8 @@ group_loop( dn )
return( 0 );
}
static
has_attributes( e, attr1, attr2 )
LDAPMessage *e;
char *attr1;
char *attr2;
static int
has_attributes( LDAPMessage *e, char *attr1, char *attr2 )
{
char **attr;
@ -1635,10 +1599,11 @@ has_attributes( e, attr1, attr2 )
}
static char **
get_attributes_mail_dn( e, attr1, attr2 )
LDAPMessage *e;
char *attr1;
char *attr2; /* this one is dn-valued */
get_attributes_mail_dn(
LDAPMessage *e,
char *attr1,
char *attr2 /* this one is dn-valued */
)
{
LDAPMessage *ee, *res;
char **vals, **dnlist, **mail, **grname, **graddr;

View file

@ -6,22 +6,24 @@
* All Rights Reserved
*/
#include <stdio.h>
#include <syslog.h>
#include <string.h>
#include <fcntl.h>
#include "portable.h"
#include <stdio.h>
#include <ac/syslog.h>
#include <ac/string.h>
#include <ac/unistd.h>
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#include "ldapconfig.h"
#include "rcpt500.h"
extern int dosyslog;
int
help_cmd( msgp, reply )
struct msginfo *msgp;
char *reply;
help_cmd(struct msginfo *msgp, char *reply)
{
int fd, len;

View file

@ -14,6 +14,7 @@
#include <ac/ctype.h>
#include <ac/string.h>
#include <ac/syslog.h>
#include <ac/unistd.h>
#include "ldapconfig.h"
#include "rcpt500.h"
@ -32,33 +33,29 @@ char *searchbase = RCPT500_BASE;
char *dapuser = RCPT500_BINDDN;
char *filterfile = FILTERFILE;
char *templatefile = TEMPLATEFILE;
char reply[ MAXSIZE * RCPT500_LISTLIMIT ];
static char reply[ MAXSIZE * RCPT500_LISTLIMIT ];
/*
* functions
*/
int read_msg();
char *read_hdr();
int send_reply();
static int read_msg(FILE *fp, struct msginfo *msgp);
static char *read_hdr(FILE *fp, int off, char *buf, int MAXSIZEe, char **ln_p);
static int send_reply(struct msginfo *msgp, char *body);
static int find_command(char *text, char **argp);
/*
* main is invoked by sendmail via the alias file
* the entire incoming message gets piped to our standard input
*/
main( argc, argv )
int argc;
char **argv;
int
main( int argc, char **argv )
{
char *prog, *usage = "%s [-l] [-U] [-h ldaphost] [-p ldapport] [-b searchbase] [-a] [-z sizelimit] [-u dapuser] [-f filterfile] [-t templatefile] [-c rdncount]\n";
struct msginfo msg;
int c, errflg;
char *replytext;
extern int optind;
extern char *optarg;
*reply = '\0';
if (( prog = strrchr( argv[ 0 ], '/' )) == NULL ) {
@ -168,10 +165,8 @@ main( argc, argv )
}
int
read_msg( fp, msgp )
FILE *fp;
struct msginfo *msgp;
static int
read_msg( FILE *fp, struct msginfo *msgp )
{
char buf[ MAXSIZE ], *line;
int command = -1;
@ -231,13 +226,8 @@ read_msg( fp, msgp )
}
char *
read_hdr( fp, offset, buf, MAXSIZEe, linep )
FILE *fp;
int offset;
char *buf;
int MAXSIZEe;
char **linep;
static char *
read_hdr( FILE *fp, int offset, char *buf, int MAXSIZEe, char **linep )
{
char *hdr;
@ -272,10 +262,8 @@ read_hdr( fp, offset, buf, MAXSIZEe, linep )
}
int
send_reply( msgp, body )
struct msginfo *msgp;
char *body;
static int
send_reply( struct msginfo *msgp, char *body )
{
char buf[ MAXSIZE ];
FILE *cmdpipe;
@ -353,10 +341,8 @@ send_reply( msgp, body )
}
int
find_command( text, argp )
char *text;
char **argp;
static int
find_command( char *text, char **argp )
{
int i;
char *s, *p;

View file

@ -6,43 +6,38 @@
* All Rights Reserved
*/
#include "portable.h"
#include <stdio.h>
#include <syslog.h>
#include <string.h>
#include <ctype.h>
#include <sys/time.h>
#include <stdlib.h>
#include <ac/ctype.h>
#include <ac/string.h>
#include <ac/syslog.h>
#include <ac/time.h>
#include "lber.h"
#include "ldap.h"
#include "portable.h"
#include "ldapconfig.h"
#include "disptmpl.h"
#include "rcpt500.h"
extern int dosyslog;
extern int do_cldap;
extern int rdncount;
extern int derefaliases;
extern int sizelimit;
extern int ldapport;
extern char *ldaphost;
extern char *searchbase;
extern char *dapuser;
extern char *filterfile;
extern char *templatefile;
#include "rcpt500.h"
#include "ldapconfig.h"
static char buf[ MAXSIZE ];
static char *errpreface = "Your query failed: ";
extern int strcasecmp();
static void close_ldap(LDAP *ld);
static void append_entry_list(char *rep, char *qu, LDAP *ld, LDAPMessage *msg);
static int append_text(void *reply, char *text, int len);
static int do_read (LDAP *ld, char *dn, char *rep, struct ldap_disptmpl *tmp);
static void report_ldap_err (LDAP *ldp, char *reply);
static void remove_trailing_space (char *s);
void close_ldap();
int
query_cmd( msgp, reply )
struct msginfo *msgp;
char *reply;
query_cmd( struct msginfo *msgp, char *reply )
{
LDAP *ldp;
LDAPMessage *ldmsgp, *entry;
@ -77,11 +72,11 @@ query_cmd( msgp, reply )
/*
* open connection to LDAP server and bind as dapuser
*/
#ifdef CLDAP
#ifdef LDAP_CONNECTIONLESS
if ( do_cldap )
ldp = cldap_open( ldaphost, ldapport );
else
#endif /* CLDAP */
#endif /* LDAP_CONNECTIONLESS */
ldp = ldap_open( ldaphost, ldapport );
if ( ldp == NULL ) {
@ -91,9 +86,9 @@ query_cmd( msgp, reply )
return( 0 );
}
#ifdef CLDAP
#ifdef LDAP_CONNECTIONLESS
if ( !do_cldap )
#endif /* CLDAP */
#endif /* LDAP_CONNECTIONLESS */
if ( ldap_simple_bind_s( ldp, dapuser, NULL ) != LDAP_SUCCESS ) {
report_ldap_err( ldp, reply );
close_ldap( ldp );
@ -110,11 +105,11 @@ query_cmd( msgp, reply )
matches = 0;
#ifdef RCPT500_UFN
#ifdef CLDAP
#ifdef LDAP_CONNECTIONLESS
if ( !do_cldap && strchr( msgp->msg_arg, ',' ) != NULL ) {
#else /* CLDAP */
#else /* LDAP_CONNECTIONLESS */
if ( strchr( msgp->msg_arg, ',' ) != NULL ) {
#endif /* CLDAP */
#endif /* LDAP_CONNECTIONLESS */
struct timeval tv;
ldap_ufn_setprefix( ldp, searchbase );
@ -133,12 +128,12 @@ query_cmd( msgp, reply )
for ( lfi = ldap_getfirstfilter( lfdp, "rcpt500", msgp->msg_arg );
lfi != NULL; lfi = ldap_getnextfilter( lfdp )) {
#ifdef CLDAP
#ifdef LDAP_CONNECTIONLESS
if ( do_cldap )
rc = cldap_search_s( ldp, searchbase, LDAP_SCOPE_SUBTREE,
lfi->lfi_filter, attrs, 0, &ldmsgp, dapuser );
else
#endif /* CLDAP */
#endif /* LDAP_CONNECTIONLESS */
rc = ldap_search_s( ldp, searchbase, LDAP_SCOPE_SUBTREE,
lfi->lfi_filter, attrs, 0, &ldmsgp );
@ -217,23 +212,20 @@ query_cmd( msgp, reply )
}
void
static void
close_ldap( LDAP *ld )
{
#ifdef CLDAP
#ifdef LDAP_CONNECTIONLESS
if ( do_cldap )
cldap_close( ld );
else
#endif /* CLDAP */
#endif /* LDAP_CONNECTIONLESS */
ldap_unbind( ld );
}
append_entry_list( reply, query, ldp, ldmsgp )
char *reply;
char *query;
LDAP *ldp;
LDAPMessage *ldmsgp;
static void
append_entry_list( char *reply, char *query, LDAP *ldp, LDAPMessage *ldmsgp )
{
LDAPMessage *e;
char *dn, *rdn, *s, **title;
@ -294,23 +286,16 @@ append_entry_list( reply, query, ldp, ldmsgp )
}
int
append_text( reply, text, len )
char *reply;
char *text;
int len;
static int
append_text( void *reply, char *text, int len )
{
strcat( reply, text );
strcat( (char *) reply, text );
return( len );
}
int
do_read( ldp, dn, reply, tmpll )
LDAP *ldp;
char *dn;
char *reply;
struct ldap_disptmpl *tmpll;
static int
do_read( LDAP *ldp, char *dn, char *reply, struct ldap_disptmpl *tmpll )
{
int rc;
static char *maildefvals[] = { "None registered in this service", NULL };
@ -319,16 +304,15 @@ do_read( ldp, dn, reply, tmpll )
rc = ldap_entry2text_search( ldp, dn, searchbase, NULLMSG, tmpll,
defattrs, defvals, (void *)append_text, (void *)reply, "\n",
defattrs, defvals, append_text, (void *)reply, "\n",
rdncount, LDAP_DISP_OPT_DOSEARCHACTIONS );
return( rc );
}
report_ldap_err( ldp, reply )
LDAP *ldp;
char *reply;
static void
report_ldap_err( LDAP *ldp, char *reply )
{
strcat( reply, errpreface );
strcat( reply, ldap_err2string( ldp->ld_errno ));
@ -336,8 +320,8 @@ report_ldap_err( ldp, reply )
}
remove_trailing_space( s )
char *s;
static void
remove_trailing_space( char *s )
{
char *p = s + strlen( s ) - 1;

View file

@ -6,6 +6,10 @@
* All Rights Reserved
*/
#include <ldap_cdefs.h>
LDAP_BEGIN_DECL
struct msginfo {
char *msg_subject;
char *msg_replyto; /* actually could be from From: line */
@ -16,8 +20,9 @@ struct msginfo {
};
struct command {
char *cmd_text; /* text for command, e.g. "HELP" */
int (*cmd_handler)(); /* pointer to handler function */
char *cmd_text; /* text for command, e.g. "HELP" */
/* pointer to handler function */
int (*cmd_handler) LDAP_P((struct msginfo *msgp, char *reply));
};
@ -27,10 +32,28 @@ struct command {
/*
* functions
*/
int help_cmd();
int query_cmd();
int help_cmd LDAP_P((struct msginfo *msgp, char *reply));
int query_cmd LDAP_P((struct msginfo *msgp, char *reply));
/*
* externs
*/
/* cmds.c */
extern struct command cmds[];
/* main.c */
extern int dosyslog;
#ifdef LDAP_CONNECTIONLESS
extern int do_cldap;
#endif
extern int derefaliases;
extern int sizelimit;
extern int rdncount;
extern int ldapport;
extern char *ldaphost;
extern char *searchbase;
extern char *dapuser;
extern char *filterfile;
extern char *templatefile;
LDAP_END_DECL

View file

@ -23,10 +23,6 @@ static int ldapport = LDAP_PORT;
static int not, verbose, contoper;
static LDAP *ld;
#ifdef LDAP_DEBUG
extern int ldap_debug, lber_debug;
#endif /* LDAP_DEBUG */
#define safe_realloc( ptr, size ) ( ptr == NULL ? malloc( size ) : \
realloc( ptr, size ))
@ -35,18 +31,13 @@ static int dodelete LDAP_P((
char *dn));
int
main( argc, argv )
int argc;
char **argv;
main( int argc, char **argv )
{
char *usage = "usage: %s [-n] [-v] [-k] [-d debug-level] [-f file] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [dn]...\n";
char buf[ 4096 ];
FILE *fp;
int i, rc, kerberos, authmethod;
extern char *optarg;
extern int optind;
kerberos = not = verbose = contoper = 0;
fp = NULL;

View file

@ -33,10 +33,6 @@ static int ldapport = LDAP_PORT;
static int new, replace, not, verbose, contoper, force, valsfromfiles;
static LDAP *ld;
#ifdef LDAP_DEBUG
extern int ldap_debug, lber_debug;
#endif /* LDAP_DEBUG */
#define safe_realloc( ptr, size ) ( ptr == NULL ? malloc( size ) : \
realloc( ptr, size ))
@ -78,9 +74,6 @@ main( int argc, char **argv )
int rc, i, kerberos, use_ldif, authmethod;
char *usage = "usage: %s [-abcknrvF] [-d debug-level] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [ -f file | < entryfile ]\n";
extern char *optarg;
extern int optind;
if (( prog = strrchr( argv[ 0 ], '/' )) == NULL ) {
prog = argv[ 0 ];
} else {

View file

@ -23,10 +23,6 @@ static int ldapport = LDAP_PORT;
static int not, verbose, contoper;
static LDAP *ld;
#ifdef LDAP_DEBUG
extern int ldap_debug, lber_debug;
#endif /* LDAP_DEBUG */
#define safe_realloc( ptr, size ) ( ptr == NULL ? malloc( size ) : \
realloc( ptr, size ))
@ -37,18 +33,13 @@ static int domodrdn LDAP_P((
int remove)); /* flag: remove old RDN */
int
main( argc, argv )
int argc;
char **argv;
main(int argc, char **argv)
{
char *usage = "usage: %s [-nvkc] [-d debug-level] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [ -f file | < entryfile | dn newrdn ]\n";
char *myname,*infile, *entrydn, *rdn, buf[ 4096 ];
FILE *fp;
int rc, i, kerberos, remove, havedn, authmethod;
extern char *optarg;
extern int optind;
infile = NULL;
kerberos = not = contoper = verbose = remove = 0;

View file

@ -17,13 +17,9 @@
#define DEFSEP "="
#ifdef LDAP_DEBUG
extern int ldap_debug, lber_debug;
#endif /* LDAP_DEBUG */
static void usage( s )
char *s;
static void
usage( char *s )
{
fprintf( stderr, "usage: %s [options] filter [attributes...]\nwhere:\n", s );
fprintf( stderr, " filter\tRFC-1558 compliant LDAP search filter\n" );
@ -89,17 +85,13 @@ static int skipsortattr = 0;
static int verbose, not, includeufn, allow_binary, vals2tmp, ldif;
int
main( argc, argv )
int argc;
char **argv;
main( int argc, char **argv )
{
char *infile, *filtpattern, **attrs, line[ BUFSIZ ];
FILE *fp;
int rc, i, first, scope, kerberos, deref, attrsonly;
int ldap_options, timelimit, sizelimit, authmethod;
LDAP *ld;
extern char *optarg;
extern int optind;
infile = NULL;
deref = verbose = allow_binary = not = kerberos = vals2tmp =
@ -375,8 +367,6 @@ static int dosearch(
ldap_perror( ld, "ldap_search" );
}
if ( sortattr != NULL ) {
extern int strcasecmp();
(void) ldap_sort_entries( ld, &res,
( *sortattr == '\0' ) ? NULL : sortattr, strcasecmp );
matches = 0;
@ -412,7 +402,6 @@ void print_entry(
BerElement *ber;
struct berval **bvals;
FILE *tmpfp;
extern char *mktemp();
dn = ldap_get_dn( ld, entry );
if ( ldif ) {

View file

@ -19,6 +19,7 @@
#include <ac/krb.h>
#include <ac/string.h>
#include <ac/time.h>
#include <ac/unistd.h>
#ifdef HAVE_PWD_H
#include <pwd.h>
@ -30,25 +31,17 @@
#include "ud.h"
extern LDAP *ld; /* our LDAP descriptor */
extern int verbose; /* verbosity indicator */
extern char *mygetpass(); /* getpass() passwds are too short */
#ifdef DEBUG
extern int debug; /* debug flag */
#endif
#ifdef HAVE_KERBEROS
static char tktpath[20]; /* ticket file path */
static int kinit();
static int valid_tgt();
#endif
static void set_bound_dn();
static void set_bound_dn(char *s);
auth(who, implicit)
char *who;
int implicit;
int
auth( char *who, int implicit )
{
int rc; /* return code from ldap_bind() */
char *passwd = NULL; /* returned by mygetpass() */
@ -71,13 +64,6 @@ int implicit;
static char prompt[MED_BUF_SIZE]; /* place for us to sprintf the prompt */
static char name[MED_BUF_SIZE]; /* place to store the user's name */
static char password[MED_BUF_SIZE]; /* password entered by user */
extern struct entry Entry; /* look here for a name if needed */
extern LDAPMessage *find(); /* for looking up 'name' */
extern char *search_base; /* for printing later */
extern char *default_bind_object; /* bind as this on failure */
extern void printbase(); /* used to pretty-print a base */
extern int bind_status;
extern void Free();
#ifdef DEBUG
if (debug & D_TRACE)
@ -306,8 +292,8 @@ int implicit;
#define FIVEMINS ( 5 * 60 )
#define TGT "krbtgt"
static void str2upper( s )
char *s;
static void
str2upper( char *s )
{
char *p;
@ -317,8 +303,8 @@ static void str2upper( s )
}
static valid_tgt( names )
char **names;
static int
valid_tgt( char **names )
{
int i;
char name[ ANAME_SZ ], inst[ INST_SZ ], realm[ REALM_SZ ];
@ -358,9 +344,7 @@ static char *kauth_name;
/*ARGSUSED*/
int
krbgetpass( user, inst, realm, pw, key )
char *user, *inst, *realm, *pw;
C_Block key;
krbgetpass( char *user, char *inst, char *realm, char *pw, C_Block key )
{
char *p, lcrealm[ REALM_SZ ], prompt[256], *passwd;
@ -390,8 +374,8 @@ krbgetpass( user, inst, realm, pw, key )
return( 0 );
}
static kinit( kname )
char *kname;
static int
kinit( char *kname )
{
int rc;
char name[ ANAME_SZ ], inst[ INST_SZ ], realm[ REALM_SZ ];
@ -430,7 +414,8 @@ static kinit( kname )
return( 0 );
}
void destroy_tickets(void)
void
destroy_tickets( void )
{
if ( *tktpath != '\0' ) {
unlink( tktpath );
@ -438,11 +423,9 @@ void destroy_tickets(void)
}
#endif
static void set_bound_dn(char *s)
static void
set_bound_dn( char *s )
{
extern void Free();
extern char *bound_dn;
if (bound_dn != NULL)
Free(bound_dn);
bound_dn = (s == NULL) ? NULL : strdup(s);

View file

@ -17,8 +17,10 @@
#include <ac/signal.h>
#include <ac/string.h>
#include <ac/ctype.h>
#include <ac/time.h>
#include <ac/wait.h>
#include <ac/unistd.h>
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
@ -31,33 +33,22 @@
#include <ldap.h>
#include <ldapconfig.h>
#include "ud.h"
extern void *Malloc();
extern struct entry Entry;
extern int verbose;
extern LDAP *ld;
extern LDAPMessage *find();
static int load_editor();
static int modifiable();
static int print_attrs_and_values();
static int ovalues();
static int write_entry();
static int load_editor( void );
static int modifiable( char *s, short flag );
static int print_attrs_and_values( FILE *fp, struct attribute *attrs, short flag );
static int ovalues( char *attr );
static void write_entry( void );
static char *entry_temp_file;
#ifdef DEBUG
extern int debug;
#endif
edit(who)
char *who;
void
edit( char *who )
{
LDAPMessage *mp; /* returned from find() */
char *dn, **rdns; /* distinguished name */
char name[MED_BUF_SIZE]; /* entry to modify */
extern int bind_status;
#ifdef DEBUG
if (debug & D_TRACE)
@ -111,19 +102,18 @@ char *who;
(void) ldap_value_free(rdns);
if (load_editor() < 0)
return;
(void) write_entry();
write_entry();
(void) unlink(entry_temp_file);
ldap_uncache_entry(ld, Entry.DN);
return;
}
static load_editor()
static int
load_editor( void )
{
FILE *fp;
char *cp, *editor = UD_DEFAULT_EDITOR;
static char template[MED_BUF_SIZE];
extern char * mktemp();
extern int isgroup(), fatal();
int pid;
int status;
int rc;
@ -208,10 +198,8 @@ static load_editor()
return(0);
}
static int print_attrs_and_values(fp, attrs, flag)
FILE *fp;
struct attribute attrs[];
short flag;
static int
print_attrs_and_values( FILE *fp, struct attribute *attrs, short int flag )
{
register int i, j;
@ -231,12 +219,10 @@ short flag;
return( 0 );
}
static modifiable(s, flag)
char *s;
short flag;
static int
modifiable( char *s, short int flag )
{
register int i;
extern struct attribute attrlist[];
for (i = 0; attrlist[i].quipu_name != NULL; i++) {
if (strcasecmp(s, attrlist[i].quipu_name))
@ -249,7 +235,8 @@ short flag;
return(FALSE);
}
static write_entry()
static void
write_entry( void )
{
int i = 0, j, number_of_values = -1;
@ -259,9 +246,6 @@ static write_entry()
LDAPMod *mods[MAX_ATTRS + 1];
LDAPMod *modp = NULL;
extern char * code_to_str();
extern void free_mod_struct();
/* parse the file and write the values to the Directory */
if ((fp = fopen(entry_temp_file, "r")) == NULL) {
perror("fopen");
@ -455,8 +439,8 @@ static write_entry()
return;
}
static ovalues(attr)
char *attr;
static int
ovalues( char *attr )
{
struct attribute *ap;

View file

@ -13,6 +13,7 @@
#include "portable.h"
#include <stdio.h>
#include <stdlib.h>
#include <ac/ctype.h>
#include <ac/string.h>
@ -23,18 +24,11 @@
#include "ud.h"
extern char *search_base; /* search base */
extern int verbose; /* verbose mode flag */
extern LDAP *ld; /* our ldap descriptor */
static int num_picked = 0; /* used when user picks entry at More prompt */
#ifdef DEBUG
extern int debug; /* debug flag */
#endif
vrfy(dn)
char *dn;
int
vrfy( char *dn )
{
LDAPMessage *results;
static char *attrs[2] = { "objectClass", NULL };
@ -57,11 +51,8 @@ char *dn;
}
static LDAPMessage * disambiguate( result, matches, read_attrs, who )
LDAPMessage *result;
int matches;
char **read_attrs;
char *who;
static LDAPMessage *
disambiguate( LDAPMessage *result, int matches, char **read_attrs, char *who )
{
int choice; /* entry that user chooses */
int i;
@ -69,7 +60,6 @@ char *who;
char response[SMALL_BUF_SIZE]; /* results from user */
char *name = NULL; /* DN to lookup */
LDAPMessage *mp;
extern void Free();
#ifdef DEBUG
if (debug & D_TRACE)
@ -153,9 +143,8 @@ char *who;
}
}
LDAPMessage * find(who, quiet)
char *who;
int quiet;
LDAPMessage *
find( char *who, int quiet )
{
register int i, j, k; /* general ints */
int matches; /* from ldap_count_entries() */
@ -169,9 +158,6 @@ int quiet;
char response[SMALL_BUF_SIZE];
char *cp, *dn, **rdns;
LDAPFiltInfo *fi;
extern LDAPFiltDesc *lfdp; /* LDAP filter descriptor */
extern struct attribute attrlist[]; /* complete list of attrs */
extern void Free();
#ifdef DEBUG
if (debug & D_TRACE)
@ -330,8 +316,8 @@ int quiet;
return(NULL);
}
pick_one(i)
int i;
int
pick_one( int i )
{
int n;
char user_pick[SMALL_BUF_SIZE];
@ -356,13 +342,10 @@ int i;
/* NOTREACHED */
}
print_list(list, names, matches)
LDAPMessage *list;
char *names[];
int *matches;
void
print_list( LDAPMessage *list, char **names, int *matches )
{
char **rdns, **cpp;
extern int lpp;
char resp[SMALL_BUF_SIZE];
register LDAPMessage *ep;
register int i = 1;
@ -406,9 +389,8 @@ again:
return;
}
find_all_subscribers(sub, group)
char *sub[];
char *group;
int
find_all_subscribers( char **sub, char *group )
{
int count;
LDAPMessage *result;
@ -451,9 +433,8 @@ char *group;
return(count);
}
char * fetch_boolean_value(who, attr)
char *who;
struct attribute attr;
char *
fetch_boolean_value( char *who, struct attribute attr )
{
LDAPMessage *result; /* from the search below */
register LDAPMessage *ep; /* entry pointer */

View file

@ -10,15 +10,13 @@
* is provided ``as is'' without express or implied warranty.
*/
#include <stdio.h>
#include "ud.h"
#include "portable.h"
extern void set_boolean(),
change_field(),
#ifdef UOFM
set_updates(),
#endif
mod_addrDN();
#include <stdio.h>
#include <ac/time.h> /* portable.h+ldap.h needs time_t */
#include <lber.h>
#include <ldap.h>
#include "ud.h"
struct attribute attrlist[] = {
@ -28,8 +26,8 @@ struct attribute attrlist[] = {
* Field 3 = function used to modify this field (if any)
* Field 4 = Flags specifying how this field is displayed
*/
{ "memberOfGroup", "Subscriptions", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_IS_A_DN },
{ "acl", "Access Control", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ },
{ "memberOfGroup", "Subscriptions", 0, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_IS_A_DN },
{ "acl", "Access Control", 0, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ },
{ "cn", "Aliases", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ | ATTR_FLAG_SEARCH | ATTR_FLAG_GROUP_MOD },
{ "title", "Title", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_SEARCH | ATTR_FLAG_PERSON_MOD },
{ "postalAddress", "Business address", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD | ATTR_FLAG_GROUP_MOD | ATTR_FLAG_IS_MULTILINE },
@ -38,18 +36,18 @@ struct attribute attrlist[] = {
{ "member", "Members", mod_addrDN, ATTR_FLAG_GROUP | ATTR_FLAG_READ | ATTR_FLAG_IS_A_DN | ATTR_FLAG_GROUP_MOD },
{ "homePhone", "Home phone", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD },
{ "homePostalAddress", "Home address", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD | ATTR_FLAG_IS_MULTILINE },
{ "objectClass", "Object class", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ | ATTR_FLAG_SEARCH },
{ "objectClass", "Object class", 0, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ | ATTR_FLAG_SEARCH },
#ifdef UOFM
{ "multiLineDescription", "Description", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD | ATTR_FLAG_GROUP_MOD | ATTR_FLAG_IS_MULTILINE },
#endif
#ifdef KERBEROS
{ "krbName", "Kerberos name", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_READ },
#ifdef HAVE_KERBEROS
{ "krbName", "Kerberos name", 0, ATTR_FLAG_PERSON | ATTR_FLAG_READ },
#endif
{ "description", "Brief description", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ },
{ "description", "Brief description", 0, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ },
{ "facsimileTelephoneNumber", "Fax number", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD | ATTR_FLAG_GROUP_MOD },
{ "pager", "Pager number", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD },
{ "uid", "Uniqname", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ },
{ "userPassword", "Password", NULL, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ },
{ "uid", "Uniqname", 0, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ },
{ "userPassword", "Password", 0, ATTR_FLAG_PERSON | ATTR_FLAG_GROUP | ATTR_FLAG_READ },
#ifdef UOFM
{ "noBatchUpdates", "No batch updates", set_updates, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD },
#endif
@ -65,7 +63,7 @@ struct attribute attrlist[] = {
{ "onVacation", "On Vacation", set_boolean, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD | ATTR_FLAG_IS_A_BOOL },
{ "vacationMessage", "Vacation Message", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD | ATTR_FLAG_IS_MULTILINE },
{ "drink", "Favorite Beverage", change_field, ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_PERSON_MOD },
{ "lastModifiedBy", "Last modified by", NULL, ATTR_FLAG_GROUP | ATTR_FLAG_PERSON | ATTR_FLAG_IS_A_DN | ATTR_FLAG_READ },
{ "lastModifiedTime", "Last modified at", NULL, ATTR_FLAG_GROUP | ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_IS_A_DATE },
{ NULL, NULL, NULL, ATTR_FLAG_NONE }
{ "lastModifiedBy", "Last modified by", 0, ATTR_FLAG_GROUP | ATTR_FLAG_PERSON | ATTR_FLAG_IS_A_DN | ATTR_FLAG_READ },
{ "lastModifiedTime", "Last modified at", 0, ATTR_FLAG_GROUP | ATTR_FLAG_PERSON | ATTR_FLAG_READ | ATTR_FLAG_IS_A_DATE },
{ NULL, NULL, 0, ATTR_FLAG_NONE }
};

View file

@ -11,28 +11,25 @@
*
*/
#include "portable.h"
#include <stdio.h>
#include <string.h>
#include <ac/string.h>
#include <ac/ctype.h>
#include <ac/time.h>
#include <ac/unistd.h>
#include <lber.h>
#include <ldap.h>
#include <ldapconfig.h>
#include "ud.h"
extern LDAPMessage * find();
static char * bind_and_fetch(char *name);
#ifdef DEBUG
extern int debug;
#endif
extern char *bound_dn, *group_base;
extern int verbose, bind_status;
extern struct entry Entry;
extern LDAP *ld;
extern void Free();
void add_group(name)
char *name;
void
add_group( char *name )
{
register int i, idx = 0, prompt = 0;
char tmp[BUFSIZ], dn[BUFSIZ];
@ -42,8 +39,6 @@ char *name;
char *init_rdn_value[2], *init_owner_value[2], *init_domain_value[2],
*init_errors_value[MAX_VALUES], *init_joinable_value[2],
*init_request_value[MAX_VALUES];
extern void ldap_flush_cache();
extern char * strip_ignore_chars();
#ifdef DEBUG
if (debug & D_TRACE) {
@ -160,7 +155,6 @@ char *name;
register LDAPMod **lpp;
register char **cpp;
register int j;
extern char * code_to_str();
printf(" About to call ldap_add()\n");
printf(" ld = 0x%x\n", ld);
printf(" dn = [%s]\n", dn);
@ -175,7 +169,7 @@ char *name;
#endif
/*
* Now add this to the X.500 Directory.
* Now add this to the LDAP Directory.
*/
if (ldap_add_s(ld, dn, attrs) != 0) {
ldap_perror(ld, " ldap_add_s");
@ -199,11 +193,10 @@ char *name;
return;
}
void remove_group(name)
char *name;
void
remove_group( char *name )
{
char *dn, tmp[BUFSIZ];
static char * bind_and_fetch();
#ifdef DEBUG
if (debug & D_TRACE) {
@ -225,7 +218,7 @@ char *name;
return;
/*
* Now remove this from the X.500 Directory.
* Now remove this from the LDAP Directory.
*/
if (ldap_delete_s(ld, dn) != 0) {
if (ld->ld_errno == LDAP_INSUFFICIENT_ACCESS)
@ -246,15 +239,13 @@ char *name;
return;
}
void x_group(action, name)
int action;
char *name;
void
x_group( int action, char *name )
{
char **vp;
char *values[2], *group_name;
LDAPMod mod, *mods[2];
static char *actions[] = { "join", "resign from", NULL };
static char * bind_and_fetch();
#ifdef DEBUG
if (debug & D_TRACE) {
@ -344,8 +335,8 @@ char *name;
return;
}
void bulk_load(group)
char *group;
void
bulk_load( char *group )
{
register int idx_mail, idx_x500;
register int count_mail, count_x500;
@ -452,7 +443,7 @@ char *group;
}
/*
* Add the X.500 style names.
* Add the LDAP style names.
*/
if (count_x500 > 0) {
mods[0] = &mod;
@ -500,15 +491,13 @@ char *group;
return;
}
void purge_group(group)
char *group;
void
purge_group( char *group )
{
int isclean = TRUE;
LDAPMessage *lm;
LDAPMod mod, *mods[2];
char dn[BUFSIZ], tmp[BUFSIZ], *values[2], **vp, **rdns;
extern char * my_ldap_dn2ufn();
extern int col_size;
#ifdef DEBUG
if (debug & D_TRACE) {
@ -562,7 +551,7 @@ char *group;
vp = Entry.attrs[attr_to_index("member")].values;
if (vp == NULL) {
if (verbose)
printf(" \"%s\" has no X.500 members. There is nothing to purge.\n", group);
printf(" \"%s\" has no LDAP members. There is nothing to purge.\n", group);
return;
}
for (; *vp != NULL; vp++) {
@ -654,7 +643,8 @@ ask:
return;
}
void tidy_up()
void
tidy_up( void )
{
register int i = 0;
int found_one = 0;
@ -729,11 +719,9 @@ void tidy_up()
* Names or e-mail addresses. This includes things like group members,
* the errors-to field in groups, and so on.
*/
void mod_addrDN(group, offset)
char *group;
int offset;
void
mod_addrDN( char *group, int offset )
{
extern struct attribute attrlist[];
char s[BUFSIZ], *new_value /* was member */, *values[2];
char attrtype[ 64 ];
int i;
@ -805,7 +793,7 @@ int offset;
}
if (verbose) {
printf("\n");
format("Values may be specified as a name (which is then looked up in the X.500 Directory) or as a domain-style (i.e., user@domain) e-mail address. Simply hit the RETURN key at the prompt when finished.\n", 75, 2);
format("Values may be specified as a name (which is then looked up in the LDAP Directory) or as a domain-style (i.e., user@domain) e-mail address. Simply hit the RETURN key at the prompt when finished.\n", 75, 2);
printf("\n");
}
@ -998,10 +986,8 @@ int offset;
}
}
my_ldap_modify_s(ldap, group, mods)
LDAP *ldap;
char *group;
LDAPMod *mods[];
int
my_ldap_modify_s( LDAP *ldap, char *group, LDAPMod **mods )
{
int was_rfc822member, rc;
@ -1020,8 +1006,8 @@ LDAPMod *mods[];
return(rc);
}
void list_groups(who)
char *who;
void
list_groups( char *who )
{
LDAPMessage *mp;
char name[BUFSIZ], filter[BUFSIZ], *search_attrs[2];
@ -1099,12 +1085,11 @@ char *who;
return;
}
static char * bind_and_fetch(name)
char *name;
static char *
bind_and_fetch( char *name )
{
LDAPMessage *lm;
char tmp[MED_BUF_SIZE];
extern char * strip_ignore_chars();
#ifdef DEBUG
if (debug & D_TRACE) {
@ -1154,8 +1139,8 @@ char *name;
return(strdup(Entry.DN));
}
void list_memberships(who)
char *who;
void
list_memberships( char *who )
{
LDAPMessage *mp;
char name[BUFSIZ], filter[BUFSIZ], *search_attrs[2];

View file

@ -10,19 +10,22 @@
* is provided ``as is'' without express or implied warranty.
*/
#include "portable.h"
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <ac/ctype.h>
#include <ac/string.h>
#include <ac/time.h>
#include <lber.h>
#include <ldap.h>
#include "ud.h"
#ifdef DEBUG
extern int debug;
#endif
print_help(s)
char *s;
void
print_help( char *s )
{
int len; /* command length */
@ -88,7 +91,7 @@ char *s;
format("should be specified as a ordinary name (e.g., 'Friends of maX500').", 75, 15);
printf("\n");
printf(" [where] A place in the Directory needs to be specified. This name\n");
format("should be specified as an X.500-style name (e.g., 'ou=people, o=University of Michigan, c=United States of America'). In most cases, it is easier to omit the [where] and allow the program to guide you.", 75, 15);
format("should be specified as an LDAP-style name (e.g., 'ou=people, o=University of Michigan, c=United States of America'). In most cases, it is easier to omit the [where] and allow the program to guide you.", 75, 15);
printf("\n");
printf(" [who] A person in the Directory needs to be specified. This name\n");
format("can be specified as either a ordinary name (e.g., 'Jane Doe'), or as some other identifying characteristic (e.g., 'uid=babs').", 75, 15);
@ -111,7 +114,7 @@ char *s;
}
else if (!strncasecmp("groupbase", s, len)) {
printf(" groupbase [where]\n\n");
format("The syntax and use of this command is identical to the more commonly used 'cb' command. This command sets the base which is used to create groups in the X.500 Directory. Setting the base to a certain value does not necessarily grant the person write-access to that part of the Directory in order to successfully create a group.", 75, 2);
format("The syntax and use of this command is identical to the more commonly used 'cb' command. This command sets the base which is used to create groups in the LDAP Directory. Setting the base to a certain value does not necessarily grant the person write-access to that part of the Directory in order to successfully create a group.", 75, 2);
}
else if (!strncasecmp("cd", s, len) || !strncasecmp("cb", s,len)) {
printf(" cb [where]\n");
@ -125,7 +128,7 @@ char *s;
printf("\n * cb default\n\n");
format("sets the search base to its original default value.", 75, 2);
printf("\n * cb o=Merit Computer Network, c=US\n\n");
format("sets the search base to organization given, the Merit Computer Network in this case. This comamnd checks the validity of the specified search base, and rejects it if it is not a valid Distinguished Name (DN). A DN uniquely identifies a portion of the global X.500 namespace.", 75, 2);
format("sets the search base to organization given, the Merit Computer Network in this case. This comamnd checks the validity of the specified search base, and rejects it if it is not a valid Distinguished Name (DN). A DN uniquely identifies a portion of the global LDAP namespace.", 75, 2);
}
else if (!strncasecmp("quit", s, len) || !strncasecmp("stop",s, len)) {
printf(" quit\n");
@ -145,7 +148,7 @@ char *s;
else if (!strncasecmp("modify", s, len) || !strncasecmp("change", s, len)) {
printf(" modify [entry]\n");
printf(" change [entry]\n\n");
format("Changes information associated with an entry in the X.500 Directory. 'change' is an alias for 'modify'.", 75, 2);
format("Changes information associated with an entry in the LDAP Directory. 'change' is an alias for 'modify'.", 75, 2);
}
else if (!strncasecmp("verbose", s, len)) {
printf(" verbose\n\n");
@ -182,7 +185,7 @@ char *s;
}
else if (!strncasecmp("tidy", s, len)) {
printf(" tidy\n\n");
format("Unsubscribes you from non-existent groups. Useful when you cannot resign from a group because, while your X.500 entry still contains a pointer to it, someone has removed a group of which you were a subscriber.", 75, 2);
format("Unsubscribes you from non-existent groups. Useful when you cannot resign from a group because, while your LDAP entry still contains a pointer to it, someone has removed a group of which you were a subscriber.", 75, 2);
}
else if (*s == '?') {
format("Prints out a brief description of each command. Same as typing 'help help'.", 75, 2);

View file

@ -28,6 +28,7 @@
#include <ac/signal.h>
#include <ac/string.h>
#include <ac/ctype.h>
#include <ac/termios.h>
#include <ac/time.h>
#include <ac/unistd.h>
@ -80,15 +81,10 @@ LDAPFiltDesc *lfdp; /* LDAP filter descriptor */
int debug; /* debug flag */
#endif
extern void initialize_client();
extern void initialize_attribute_strings();
main(argc, argv)
int argc;
char *argv[];
int
main( int argc, char **argv )
{
extern char Version[]; /* version number */
extern char *optarg; /* for parsing argv */
register int c; /* for parsing argv */
register char *cp; /* for parsing Version */
@ -163,7 +159,8 @@ char *argv[];
/* NOTREACHED */
}
do_commands()
void
do_commands( void )
{
LDAPMessage *mp; /* returned by find() */
register char *cp; /* misc char pointer */
@ -171,10 +168,6 @@ do_commands()
static char buf[MED_BUF_SIZE]; /* for prompting */
static char cmd[MED_BUF_SIZE]; /* holds the command */
static char input[MED_BUF_SIZE]; /* buffer for input */
extern LDAPMessage *find();
extern void purge_group(), add_group(), remove_group(), x_group(),
tidy_up(), list_groups(), list_memberships(), edit();
extern char *nextstr();
#ifdef DEBUG
if (debug & D_TRACE)
@ -282,9 +275,9 @@ do_commands()
/* NOTREACHED */
}
status()
void
status( void )
{
void printbase();
register char **rdns;
#ifdef DEBUG
@ -311,9 +304,8 @@ status()
}
}
change_base(type, base, s)
int type;
char **base, *s;
void
change_base( int type, char **base, char *s )
{
register char *cp; /* utility pointers */
char **rdns; /* for parsing */
@ -327,13 +319,9 @@ char **base, *s;
static char *choices[MED_BUF_SIZE]; /* bases from which to choose */
static char resp[SMALL_BUF_SIZE]; /* for prompting user */
static char buf[MED_BUF_SIZE];
void printbase();
static char *attrs[] = { "objectClass", NULL };
LDAPMessage *mp; /* results from a search */
LDAPMessage *ep; /* for going thru bases */
extern char * friendly_name();
extern void StrFreeDup();
extern void Free();
#ifdef DEBUG
if (debug & D_TRACE)
@ -528,7 +516,8 @@ char **base, *s;
}
}
void initialize_client()
void
initialize_client( void )
{
FILE *fp; /* for config file */
static char buffer[MED_BUF_SIZE]; /* for input */
@ -537,9 +526,6 @@ void initialize_client()
char *term; /* for tty set-up */
char *config; /* config file to use */
static char bp[1024]; /* for tty set-up */
extern RETSIGTYPE attn(); /* ^C signal handler */
extern char *getenv();
extern void Free();
#ifdef DEBUG
if (debug & D_TRACE)
@ -665,7 +651,6 @@ void initialize_client()
#ifndef NO_TERMCAP
{
struct winsize win; /* for tty set-up */
extern RETSIGTYPE chwinsz(); /* WINSZ signal handler */
if (((term = getenv("TERM")) == NULL) || (tgetent(bp, term) <= 0))
return;
@ -693,7 +678,8 @@ void initialize_client()
#endif
}
RETSIGTYPE attn()
RETSIGTYPE
attn( int sig )
{
fflush(stderr);
fflush(stdout);
@ -704,8 +690,9 @@ RETSIGTYPE attn()
longjmp(env, 1);
}
#ifndef NO_TERMCAP
RETSIGTYPE chwinsz()
#if !defined(NO_TERMCAP) && defined(TIOCGWINSZ)
RETSIGTYPE
chwinsz( int sig )
{
struct winsize win;

View file

@ -13,6 +13,7 @@
#include "portable.h"
#include <stdio.h>
#include <stdlib.h>
#include <ac/ctype.h>
#include <ac/string.h>
@ -21,28 +22,14 @@
#include <lber.h>
#include <ldap.h>
#include "ud.h"
extern void Free();
extern struct entry Entry;
extern int verbose;
extern LDAP *ld;
static char *get_URL( void );
static int check_URL( char *url );
extern LDAPMessage *find();
extern void * Malloc();
static char * get_URL();
static int check_URL();
#ifdef DEBUG
extern int debug;
#endif
modify(who)
char *who;
void
modify( char *who )
{
#ifdef UOFM
void set_updates(); /* routine to modify noBatchUpdates */
#endif
LDAPMessage *mp; /* returned from find() */
char *dn; /* distinguished name */
char **rdns; /* for fiddling with the DN */
@ -52,11 +39,8 @@ char *who;
#ifdef UOFM
static char printed_warning = 0; /* for use with the */
struct attribute no_batch_update_attr;
extern char * fetch_boolean_value();
#endif
int is_a_group; /* TRUE if it is; FALSE otherwise */
extern void Free();
extern int bind_status;
#ifdef DEBUG
if (debug & D_TRACE)
@ -165,14 +149,16 @@ char *who;
}
/* generic routine for changing any field */
void change_field(who, attr)
char *who; /* DN of entry we are changing */
struct attribute attr; /* attribute to change */
void
change_field(
char *who, /* DN of entry we are changing */
int attr_idx /* attribute to change */
)
{
struct attribute attr = Entry.attrs[attr_to_index(attrlist[attr_idx].quipu_name)];
#define IS_MOD(x) (!strncasecmp(resp, (x), strlen(resp)))
char *get_value(); /* routine to extract values */
static char buf[MED_BUF_SIZE]; /* for printing things */
static char resp[SMALL_BUF_SIZE]; /* for user input */
char *prompt, *prompt2, *more;
@ -180,7 +166,6 @@ struct attribute attr; /* attribute to change */
static LDAPMod mod;
static LDAPMod *mods[2] = { &mod }; /* passed to ldap_modify */
static char *values[MAX_VALUES]; /* passed to ldap_modify */
extern void Free();
#ifdef DEBUG
if (debug & D_TRACE)
@ -378,8 +363,8 @@ struct attribute attr; /* attribute to change */
#define MAX_DESC_LINES 24
#define INTL_ADDR_LIMIT 30
char *get_value(id, prompt)
char *id, *prompt;
char *
get_value( char *id, char *prompt )
{
char *cp; /* for the Malloc() */
int count; /* line # of new value -- if multiline */
@ -541,12 +526,15 @@ mail_is_good:
return(cp);
}
void set_boolean(who, attr)
char *who; /* DN of entry we are changing */
struct attribute attr; /* boolean attribute to change */
void
set_boolean(
char *who, /* DN of entry we are changing */
int attr_idx /* boolean attribute to change */
)
{
struct attribute attr = Entry.attrs[attr_to_index(attrlist[attr_idx].quipu_name)];
char *cp, *s;
extern char * fetch_boolean_value();
static char response[16];
static char *newsetting[2] = { NULL, NULL };
LDAPMod mod, *mods[2];
@ -600,11 +588,10 @@ struct attribute attr; /* boolean attribute to change */
#ifdef UOFM
void set_updates(who)
char *who;
void
set_updates( char *who, int dummy )
{
char *cp, *s;
extern char * fetch_boolean_value();
static char response[16];
static char value[6];
static char *newsetting[2] = { value, NULL };
@ -670,11 +657,10 @@ char *who;
#endif
print_mod_list(group)
int group;
void
print_mod_list( int group )
{
register int i, j = 1;
extern struct attribute attrlist[];
if (group == TRUE) {
for (i = 0; attrlist[i].quipu_name != NULL; i++) {
@ -699,15 +685,11 @@ int group;
#endif
}
perform_action(choice, dn, group)
char choice[];
char *dn;
int group;
int
perform_action( char *choice, char *dn, int group )
{
int selection;
register int i, j = 1;
extern struct attribute attrlist[];
extern void mod_addrDN(), change_field(), set_boolean();
selection = atoi(choice);
if (selection < 1) {
@ -743,18 +725,12 @@ int group;
return(1);
/* NOTREACHED */
}
if (attrlist[i].mod_func == change_field)
(*attrlist[i].mod_func)(dn, Entry.attrs[attr_to_index(attrlist[i].quipu_name)]);
else if (attrlist[i].mod_func == mod_addrDN)
(*attrlist[i].mod_func)(dn, i);
else if (attrlist[i].mod_func == set_boolean)
(*attrlist[i].mod_func)(dn, Entry.attrs[attr_to_index(attrlist[i].quipu_name)]);
else
(*attrlist[i].mod_func)(dn);
(*attrlist[i].mod_func)(dn, i);
return(0);
}
static char * get_URL()
static char *
get_URL( void )
{
char *rvalue, label[MED_BUF_SIZE], url[MED_BUF_SIZE];
@ -784,8 +760,8 @@ static char * get_URL()
return((char *) rvalue);
}
static check_URL(url)
char *url;
static int
check_URL( char *url )
{
register char *cp;
@ -799,6 +775,7 @@ char *url;
}
void
mod_perror( LDAP *ld )
{
if ( ld == NULL || ( ld->ld_errno != LDAP_UNAVAILABLE &&

View file

@ -10,27 +10,23 @@
* is provided ``as is'' without express or implied warranty.
*/
#include "portable.h"
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#ifndef __STDC__
#include <memory.h>
#endif
#include <time.h>
#include <ac/ctype.h>
#include <ac/string.h>
#include <ac/time.h>
#include <lber.h>
#include <ldap.h>
#include "ud.h"
#ifdef DEBUG
extern int debug;
#endif
struct entry Entry;
extern LDAP *ld;
extern void * Malloc();
extern void Free();
extern char * my_ldap_dn2ufn();
static char *time2text(char *ldtimestr, int dateonly);
static long gtime(struct tm *tm);
/*
* When displaying entries, display only these attributes, and in this
@ -80,15 +76,15 @@ static char *group_attr_print_order[] = {
NULL
};
parse_answer(s)
LDAPMessage *s;
void
parse_answer( LDAPMessage *s )
{
int idx;
char **rdns;
BerElement *cookie;
register LDAPMessage *ep;
register char *ap;
void clear_entry();
#ifdef DEBUG
if (debug & D_TRACE)
@ -137,10 +133,8 @@ LDAPMessage *s;
#endif
}
add_value(attr, ep, ap)
struct attribute *attr;
LDAPMessage *ep;
char *ap;
void
add_value( struct attribute *attr, LDAPMessage *ep, char *ap )
{
register int i = 0;
char **vp, **tp, **avp;
@ -185,13 +179,12 @@ char *ap;
ldap_value_free(vp);
}
print_an_entry()
void
print_an_entry( void )
{
int n = 0, i, idx;
char is_a_group, **order;
char *sub_list[MAX_VALUES], buf[SMALL_BUF_SIZE];
extern int col_size, isaurl(), isadn();
static char *time2text();
#ifdef DEBUG
if (debug & D_TRACE)
@ -277,8 +270,8 @@ print_an_entry()
#define OUT_LABEL_LEN 20
/* prints the values associated with an attribute */
print_values(A)
struct attribute A;
void
print_values( struct attribute A )
{
register int i, k;
register char *cp, **vp;
@ -370,13 +363,12 @@ struct attribute A;
}
/* prints the DN's associated with an attribute */
print_DN(A)
struct attribute A;
void
print_DN( struct attribute A )
{
int i, lead;
register char **vp;
char out_buf[MED_BUF_SIZE], *padding = NULL;
extern int col_size;
#ifdef DEBUG
if (debug & D_TRACE)
@ -407,10 +399,10 @@ struct attribute A;
return;
}
void clear_entry()
void
clear_entry( void )
{
register int i;
extern struct attribute attrlist[];
#ifdef DEBUG
if (debug & D_TRACE)
@ -456,11 +448,10 @@ void clear_entry()
}
}
attr_to_index(s)
char *s;
int
attr_to_index( char *s )
{
register int i;
extern struct attribute attrlist[];
for (i = 0; attrlist[i].quipu_name != NULL; i++)
if (!strcasecmp(s, attrlist[i].quipu_name))
@ -468,11 +459,10 @@ char *s;
return(-1);
}
void initialize_attribute_strings()
void
initialize_attribute_strings( void )
{
register int i;
extern struct entry Entry;
extern struct attribute attrlist[];
for (i = 0; attrlist[i].quipu_name != NULL; i++)
Entry.attrs[i].quipu_name = attrlist[i].quipu_name;
@ -481,8 +471,8 @@ void initialize_attribute_strings()
}
/* prints the URL/label pairs associated with an attribute */
print_URL(A)
struct attribute A;
void
print_URL( struct attribute A )
{
int i, lead;
register char **vp;
@ -516,16 +506,11 @@ struct attribute A;
return;
}
print_one_URL(s, label_lead, tag, url_lead)
char *s;
int label_lead;
char *tag;
int url_lead;
void
print_one_URL( char *s, int label_lead, char *tag, int url_lead )
{
register int i;
char c, *cp, *url;
extern int col_size;
extern void Free();
for (cp = s; !isspace(*cp) && (*cp != '\0'); cp++)
;
@ -555,7 +540,6 @@ time2text( char *ldtimestr, int dateonly )
struct tm t;
char *p, *timestr, zone, *fmterr = "badly formatted time";
time_t gmttime;
static long gtime();
memset( (char *)&t, 0, sizeof( struct tm ));
if ( strlen( ldtimestr ) < 13 ) {
@ -595,9 +579,7 @@ time2text( char *ldtimestr, int dateonly )
/* gtime.c - inverse gmtime */
#if !defined( MACOS ) && !defined( _WIN32 ) && !defined( DOS )
#include <sys/time.h>
#endif /* !MACOS */
#include <ac/time.h>
/* gtime(): the inverse of localtime().
This routine was supplied by Mike Accetta at CMU many years ago.
@ -614,7 +596,8 @@ int dmsize[] = {
/* */
static long gtime ( struct tm *tm )
static long
gtime( struct tm *tm )
{
register int i,
sec,

View file

@ -1,7 +1,9 @@
#ifdef KERBEROS
#include "portable.h"
#if defined(HAVE_KERBEROS) && !defined(openbsd)
/*
* $Source: /usr/local/src/ldap/clients/ud/RCS/string_to_key.c,v $
* $Author: lsloan $
* $Source: /repo/OpenLDAP/pkg/ldap/clients/ud/string_to_key.c,v $
* $Author: hallvard $
*
* Copyright 1985, 1986, 1987, 1988, 1989 by the Massachusetts Institute
* of Technology.
@ -24,35 +26,24 @@
* spm 8/85 MIT project athena
*/
#ifndef lint
static char rcsid_string_to_key_c[] =
"$Id: string_to_key.c,v 1.5 1995/11/09 20:29:55 lsloan Exp $";
#endif
#include <mit-copyright.h>
#include <stdio.h>
#include <des.h>
/* #include "des_internal.h" */
#if 1
#include <krb.h>
#endif
#include <ac/krb.h>
extern int des_debug;
extern int des_debug_print();
extern void des_fixup_key_parity();
#ifndef AFSKERBEROS
#ifndef HAVE_AFS_KERBEROS
#define WORLDPEACEINOURTIME
#endif
#if defined(WORLDPEACEINOURTIME) /* Use original, not ifs version */
#ifndef HAVE_KERBEROS_V
/*
* convert an arbitrary length string to a DES key
*/
int
des_string_to_key(str,key)
char *str;
register des_cblock *key;
des_string_to_key( char *str, register des_cblock *key )
{
register char *in_str;
register unsigned temp,i;
@ -132,6 +123,7 @@ des_string_to_key(str,key)
*((unsigned long *) key+1));
}
#endif /* HAVE_KERBEROS_V */
#else /* Use ifs version */
#if 0
@ -151,10 +143,12 @@ des_string_to_key(str,key)
encryption key. It is compatible with the original Andrew authentication
service password database. */
static void Andrew_StringToKey (str, cell, key)
char *str;
char *cell; /* cell for password */
des_cblock *key;
static void
Andrew_StringToKey(
char *str,
char *cell, /* cell for password */
des_cblock *key
)
{ char password[8+1]; /* crypt is limited to 8 chars anyway */
int i;
int passlen;
@ -190,10 +184,12 @@ static void Andrew_StringToKey (str, cell, key)
des_fixup_key_parity (key);
}
static void StringToKey (str, cell, key)
char *str;
char *cell; /* cell for password */
des_cblock *key;
static void
StringToKey(
char *str,
char *cell, /* cell for password */
des_cblock *key
)
{ des_key_schedule schedule;
char temp_key[8];
char ivec[8];
@ -219,16 +215,19 @@ static void StringToKey (str, cell, key)
des_fixup_key_parity (key);
}
/* static */ void
ka_StringToKey (str, cell, key)
char *str;
char *cell; /* cell for password */
des_cblock *key;
void
ka_StringToKey (
char *str,
char *cell, /* cell for password */
des_cblock *key
)
{ char realm[REALM_SZ];
#if NOWAYOUTTODAY
long code;
/* code = ka_CellToRealm (cell, realm, 0/*local*/); */
#if 0
code = ka_CellToRealm (cell, realm, 0/*local*/);
#endif
if (code) strcpy (realm, "");
else lcstring (realm, realm, sizeof(realm)); /* for backward compatibility */
#else
@ -243,9 +242,7 @@ ka_StringToKey (str, cell, key)
* convert an arbitrary length string to a DES key
*/
int
des_string_to_key(str,key)
char *str;
register des_cblock *key;
des_string_to_key( char *str, register des_cblock *key )
{
/* NB: i should probably call routine to get local cell here */
ka_StringToKey(str, "umich.edu", key);

View file

@ -138,7 +138,7 @@ LDAP_BEGIN_DECL
struct attribute {
char *quipu_name;
char *output_string;
void (*mod_func)();
void (*mod_func) LDAP_P(( char *who, int attr_idx ));
unsigned short flags;
int number_of_values;
char **values;
@ -152,4 +152,145 @@ struct entry {
struct attribute attrs[MAX_ATTRS];
};
/*
* Variables
*/
/* in globals.c: */
extern struct attribute attrlist[];/* complete list of attrs */
/* in main.c: */
extern char copyright[];
extern char *default_bind_object;
extern char *bound_dn;
extern char *group_base;
extern char *search_base; /* search base */
extern int lpp;
extern int verbose; /* verbose mode flag */
extern int col_size;
extern int bind_status;
extern LDAP *ld; /* our ldap descriptor */
extern LDAPFiltDesc *lfdp; /* LDAP filter descriptor */
#ifdef DEBUG
extern int debug; /* debug flag */
#endif
/* in print.c: */
extern struct entry Entry;
extern int dmsize[];
/* in version.c: */
extern char Version[];
/*
* Functions
*/
/* in auth.c: */
int auth LDAP_P(( char *who, int implicit ));
#if defined(HAVE_KERBEROS) && defined(_AC_KRB_H)
int krbgetpass LDAP_P(( char *u, char *in, char *re, char *pw, C_Block key ));
void destroy_tickets LDAP_P(( void ));
#endif
/* in edit.c: */
void edit LDAP_P(( char *who ));
/* in find.c: */
int vrfy LDAP_P(( char *dn ));
LDAPMessage *find LDAP_P(( char *who, int quiet ));
int pick_one LDAP_P(( int i ));
void print_list LDAP_P(( LDAPMessage *list, char **names, int *matches ));
int find_all_subscribers LDAP_P(( char **sub, char *group ));
char *fetch_boolean_value LDAP_P(( char *who, struct attribute attr ));
/* in globals.c: */
/* in group.c: */
void add_group LDAP_P(( char *name ));
void remove_group LDAP_P(( char *name ));
void x_group LDAP_P(( int action, char *name ));
void bulk_load LDAP_P(( char *group ));
void purge_group LDAP_P(( char *group ));
void tidy_up LDAP_P(( void ));
void mod_addrDN LDAP_P(( char *group, int offset ));
int my_ldap_modify_s LDAP_P(( LDAP *ldap, char *group, LDAPMod **mods ));
void list_groups LDAP_P(( char *who ));
void list_memberships LDAP_P(( char *who ));
/* in help.c: */
void print_help LDAP_P(( char *s ));
/* in main.c: */
#ifdef DEBUG
#endif
void do_commands LDAP_P(( void ));
void status LDAP_P(( void ));
void change_base LDAP_P(( int type, char **base, char *s ));
void initialize_client LDAP_P(( void ));
RETSIGTYPE attn LDAP_P(( int sig ));
#ifndef NO_TERMCAP
RETSIGTYPE chwinsz LDAP_P(( int sig ));
#endif
/* in mod.c: */
void modify LDAP_P(( char *who ));
void change_field LDAP_P(( char *who, int attr_idx ));
char *get_value LDAP_P(( char *id, char *prompt ));
void set_boolean LDAP_P(( char *who, int attr_idx ));
#ifdef UOFM
void set_updates LDAP_P(( char *who, int dummy ));
#endif
void print_mod_list LDAP_P(( int group ));
int perform_action LDAP_P(( char *choice, char *dn, int group ));
void mod_perror LDAP_P(( LDAP *ld ));
/* in print.c: */
void parse_answer LDAP_P(( LDAPMessage *s ));
void add_value LDAP_P(( struct attribute *attr, LDAPMessage *ep, char *ap ));
void print_an_entry LDAP_P(( void ));
void print_values LDAP_P(( struct attribute A ));
void print_DN LDAP_P(( struct attribute A ));
void clear_entry LDAP_P(( void ));
int attr_to_index LDAP_P(( char *s ));
void initialize_attribute_strings LDAP_P(( void ));
void print_URL LDAP_P(( struct attribute A ));
void print_one_URL LDAP_P(( char *s, int l_lead, char *tag, int u_lead ));
/* in string_to_key.c: */
#if defined(HAVE_KERBEROS) && !defined(openbsd) && defined(_AC_KRB_H)
#if defined(HAVE_AFS_KERBEROS) || !defined(HAVE_KERBEROS_V)
int des_string_to_key LDAP_P(( char *str, des_cblock *key ));
#endif
#if defined(HAVE_AFS_KERBEROS)
void ka_StringToKey LDAP_P(( char *str, char *cell, des_cblock *key ));
#endif
#endif
/* in util.c: */
char *mygetpass LDAP_P(( char *prompt ));
void printbase LDAP_P(( char *lead, char *s ));
void fetch_buffer LDAP_P(( char *buffer, int length, FILE *where ));
void fatal LDAP_P(( char *s ));
int isgroup LDAP_P(( void ));
void format LDAP_P(( char *str, int width, int lead ));
void format2 LDAP_P(( char *s, char *ft, char *t, int fi, int i, int w ));
char *strip_ignore_chars LDAP_P(( char *cp ));
char *code_to_str LDAP_P(( int i ));
char *friendly_name LDAP_P(( char *s ));
#ifdef UOFM
int isauniqname LDAP_P(( char *s ));
#endif
int isadn LDAP_P(( char *s ));
char *my_ldap_dn2ufn LDAP_P(( char *s ));
int isaurl LDAP_P(( char *s ));
int isadate LDAP_P(( char *s ));
void *Malloc LDAP_P(( unsigned int size ));
void Free LDAP_P(( void *ptr ));
char *nextstr LDAP_P(( char *s ));
void free_mod_struct LDAP_P(( LDAPMod *modp ));
void StrFreeDup LDAP_P(( char **ptr, char *new_value ));
int confirm_action LDAP_P(( char *msg ));
LDAP_END_DECL

View file

@ -29,12 +29,8 @@
#include "ud.h"
#ifdef DEBUG
extern int debug;
#endif
char * mygetpass(prompt)
char *prompt;
char *
mygetpass( char *prompt )
{
#if !defined(HAVE_TERMIOS) && !defined(HAVE_SGTTY_H)
static char buf[256];
@ -61,7 +57,7 @@ char *prompt;
register char *p;
register int c;
FILE *fi;
RETSIGTYPE (*sig)();
RETSIGTYPE (*sig)( int sig );
#ifdef DEBUG
if (debug & D_TRACE)
@ -145,12 +141,11 @@ char *prompt;
#endif /* DOS */
}
void printbase(lead, s)
char *lead, *s;
void
printbase( char *lead, char *s )
{
register char **cp;
char **rdns;
char * friendly_name();
#ifdef DEBUG
if (debug & D_TRACE)
@ -176,12 +171,9 @@ char *lead, *s;
return;
}
fetch_buffer(buffer, length, where)
char *buffer;
int length;
FILE *where;
void
fetch_buffer( char *buffer, int length, FILE *where )
{
extern LDAP *ld;
register int i;
char *p;
@ -212,8 +204,8 @@ FILE *where;
}
fatal(s)
char *s;
void
fatal( char *s )
{
if (errno != 0)
perror(s);
@ -223,9 +215,9 @@ char *s;
exit(-1);
}
isgroup()
int
isgroup( void )
{
extern struct entry Entry;
char **vp;
register int i;
int group = FALSE;
@ -253,14 +245,11 @@ isgroup()
* Print out the string 's' on a field of 'width' chracters. Each line
* should be indented 'lead' characters.
*/
format(str, width, lead)
char *str;
int width, lead;
void
format( char *str, int width, int lead )
{
char *s, *original, *leader = "";
register char *cp;
void * Malloc();
void Free();
#ifdef DEBUG
if (debug & D_TRACE)
@ -309,14 +298,18 @@ int width, lead;
* indented 'indent' spaces, then followed by 'tag', and then followed by
* subsequent lines of 's'.
*/
format2(s, first_tag, tag, first_indent, indent, width)
char *s, *first_tag, *tag;
int first_indent, indent, width;
void
format2(
char *s,
char *first_tag,
char *tag,
int first_indent,
int indent,
int width
)
{
char c, *fi, *i;
register char *cp;
void * Malloc();
void Free();
if (first_tag == NULL)
first_tag = "";
@ -411,15 +404,13 @@ int first_indent, indent, width;
#define IN_A_QUOTE 0
#define OUT_OF_QUOTE 1
char * strip_ignore_chars(cp)
char *cp;
char *
strip_ignore_chars( char *cp )
{
int had_a_comma = FALSE;
int flag = OUT_OF_QUOTE;
register char *rcp, *cp1;
char *tmp;
void * Malloc();
void Free();
#ifdef DEBUG
if (debug & D_TRACE)
@ -464,7 +455,8 @@ char *cp;
return(tmp);
}
char * code_to_str(int i)
char *
code_to_str( int i )
{
switch(i) {
case LDAP_MOD_ADD : return("ADD");
@ -474,8 +466,8 @@ char * code_to_str(int i)
}
}
char * friendly_name(s)
char *s;
char *
friendly_name( char *s )
{
static FriendlyMap *map = NULL;
static char *cp;
@ -489,8 +481,8 @@ char *s;
#ifdef UOFM
/* return TRUE if s has the syntax of a uniqname */
isauniqname(s)
char *s;
int
isauniqname( char *s )
{
int i = strlen(s);
@ -506,11 +498,10 @@ char *s;
#endif
/* return TRUE if this attribute should be printed as a DN */
isadn(s)
char *s;
int
isadn( char *s )
{
register int i;
extern struct attribute attrlist[];
for (i = 0; attrlist[i].quipu_name != NULL; i++)
if (!strcasecmp(s, attrlist[i].quipu_name))
@ -520,8 +511,8 @@ char *s;
return(FALSE);
}
char * my_ldap_dn2ufn(s)
char *s;
char *
my_ldap_dn2ufn( char *s )
{
register char **cpp;
static char short_DN[BUFSIZ];
@ -535,11 +526,10 @@ char *s;
}
/* return TRUE if this attribute should be printed as a URL */
isaurl(s)
char *s;
int
isaurl( char *s )
{
register int i;
extern struct attribute attrlist[];
for (i = 0; attrlist[i].quipu_name != NULL; i++)
if (!strcasecmp(s, attrlist[i].quipu_name))
@ -550,11 +540,10 @@ char *s;
}
/* return TRUE if this attribute should be printed as a date and time */
isadate(s)
char *s;
int
isadate( char *s )
{
register int i;
extern struct attribute attrlist[];
for (i = 0; attrlist[i].quipu_name != NULL; i++)
if (!strcasecmp(s, attrlist[i].quipu_name))
@ -564,8 +553,8 @@ char *s;
return(FALSE);
}
void * Malloc(size)
unsigned int size;
void *
Malloc( unsigned int size )
{
void *void_ptr;
@ -578,8 +567,8 @@ unsigned int size;
return(void_ptr);
}
void Free(ptr)
char *ptr;
void
Free( void *ptr )
{
#ifndef STDC_HEADERS
if (free(ptr) < 0) {
@ -593,8 +582,8 @@ char *ptr;
return;
}
char * nextstr(s)
char *s;
char *
nextstr( char *s )
{
while (isspace(*s) && (*s != '\0'))
s++;
@ -605,22 +594,18 @@ char *s;
return(s);
}
void free_mod_struct(modp)
LDAPMod *modp;
void
free_mod_struct( LDAPMod *modp )
{
void Free();
if (modp->mod_values != NULL)
(void) ldap_value_free(modp->mod_values);
Free(modp->mod_type);
Free(modp);
}
void StrFreeDup(ptr, new_value)
char **ptr, *new_value;
void
StrFreeDup( char **ptr, char *new_value )
{
void Free();
if (*ptr != NULL)
Free(*ptr);
if (new_value == NULL)
@ -630,8 +615,8 @@ char **ptr, *new_value;
}
confirm_action( msg )
char *msg;
int
confirm_action( char *msg )
{
char tmp[SMALL_BUF_SIZE];
int i;

421
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -502,15 +502,18 @@ if test $ol_with_threads = auto -o $ol_with_threads = posix ; then
int task(arg)
int *arg;
{
int i;
struct timeval tv;
tv.tv_sec=4;
tv.tv_sec=5;
tv.tv_usec=0;
select(0, NULL, NULL, NULL, &tv);
tv.tv_sec=6;
tv.tv_usec=0;
select(0, NULL, NULL, NULL, &tv);
/* we're not interested in any fds */
i = select(FD_SETSIZE, NULL, NULL, NULL, &tv);
if(i < 0) {
perror("select");
}
exit(1); /* if we exit here, the select blocked the whole process */
}
@ -902,6 +905,8 @@ AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS( \
stdarg.h \
stddef.h \
string.h \
strings.h \
errno.h \
fcntl.h \
filio.h \

View file

@ -29,8 +29,8 @@ static char copyright[] = "Copyright 1992 The University of Adelaide";
*/
#include "whois++.h"
extern char *index(), *rindex();
#include <stdlib.h>
extern int getdtablesize (void);
#define isspecial(c) ( (c) == ',' || (c) == ';' || (c) == ':' || (c) == '=' )
@ -38,9 +38,8 @@ static char **component = NULL;
static int numberOfComponents;
static int components = 10;
static int getToken( token )
char *token;
static int
getToken( char *token )
{
static char *buffer = NULL;
static int idx;
@ -51,6 +50,13 @@ char *token;
if ( buffer == NULL ) {
tablesize = getdtablesize();
#ifdef FD_SETSIZE
if ( tablesize > FD_SETSIZE ) {
tablesize = FD_SETSIZE;
}
#endif /* FD_SETSIZE */
timeout.tv_sec = 60;
timeout.tv_usec = 0;
FD_ZERO( &readfds );
@ -201,10 +207,14 @@ char *token;
}
}
static int term( token, value, attribute, specifier, soundex )
int token;
char *value, *attribute;
int *specifier, *soundex;
static int
term(
int token,
char *value,
char *attribute,
int *specifier,
int *soundex
)
{
char buffer[BUFSIZ], temp[BUFSIZ];
int iterations;
@ -334,10 +344,14 @@ int *specifier, *soundex;
return token;
}
static int processTerm( specifier, soundex, buffer, attribute, value )
int specifier, soundex;
char *buffer, *attribute, *value;
static int
processTerm(
int specifier,
int soundex,
char *buffer,
char *attribute,
char *value
)
{
char *s, *t;
char query[BUFSIZ];
@ -360,7 +374,7 @@ char *buffer, *attribute, *value;
sprintf( query, "(%s%s%s)", attribute,
(soundex)?"~=":"=", buffer );
} else {
if ( ( s = index( buffer, ',' ) ) != NULL ) {
if ( ( s = strchr( buffer, ',' ) ) != NULL ) {
*s++ = '\0';
while ( *s && isspace( *s ) )
s++;
@ -368,7 +382,7 @@ char *buffer, *attribute, *value;
(soundex)?"~=":"=", buffer );
component[numberOfComponents++] = strdup( query );
/* let's just make sure there is no title */
if ( ( t = rindex( s, ',' ) ) != NULL ) {
if ( ( t = strrchr( s, ',' ) ) != NULL ) {
*t++ = '\0';
while ( *t && isspace( *t ) )
t++;
@ -382,7 +396,7 @@ char *buffer, *attribute, *value;
sprintf( query, "%s *", &buffer[6] );
strcpy( buffer, query );
}
if ( ( s = index( buffer, '@' ) ) != NULL ) {
if ( ( s = strchr( buffer, '@' ) ) != NULL ) {
*s++ = '\0';
if ( *buffer == '\0' ) /* no username */
sprintf( query, "(mail=*@%s)", s );
@ -395,7 +409,7 @@ char *buffer, *attribute, *value;
if ( soundex )
printFormatted( lineLength, TRUE, stdout,
"Fuzzy matching not supported on e-mail address queries" );
} else if ( index( buffer, ' ' ) == NULL ) {
} else if ( strchr( buffer, ' ' ) == NULL ) {
sprintf( query,
"(|(sn%s%s)(userid%s%s)(l%s%s)(ou%s%s)\
(&(cn%s%s)(!(objectClass=person))))",
@ -522,8 +536,8 @@ char *buffer, *attribute, *value;
return SEARCH;
}
int parseCommand( query )
char *query;
int
parseCommand( char *query )
{
/*
* This procedure reads the string sent by the user and breaks it

View file

@ -29,6 +29,7 @@ static char copyright[] = "Copyright 1992 The University of Adelaide";
*/
#include "whois++.h"
#include <stdlib.h>
static struct {
char *str;
@ -59,8 +60,8 @@ static struct {
NULL, NULL
};
static nextLine(fp)
FILE *fp;
static void
nextLine( FILE *fp )
{
/*
* We probably should check that the user hasn't put anything else
@ -75,10 +76,8 @@ FILE *fp;
/*
* Get next word, skipping blanks & comments.
*/
static int getWord(buffer, size, fp)
char *buffer;
int size;
FILE *fp;
static int
getWord( char *buffer, int size, FILE *fp )
{
char *cp;
int c, string;
@ -119,9 +118,8 @@ FILE *fp;
return (cp != buffer);
}
void readConfiguration( config )
FILE *config;
void
readConfiguration( FILE *config )
{
char buffer[BUFSIZ];
char *s;

View file

@ -30,8 +30,8 @@ static char copyright[] = "Copyright 1992 The University of Adelaide";
#include "whois++.h"
void needHelp( reason )
char *reason;
void
needHelp( char *reason )
{
char filename[MAXPATHLEN];
char buffer[BUFSIZ];

View file

@ -29,10 +29,11 @@ static char copyright[] = "Copyright 1992 The University of Adelaide";
*/
#include "whois++.h"
#include <stdlib.h>
void showTemplate( template )
char *template;
void
showTemplate( char *template )
{
char filename[MAXPATHLEN], buffer[BUFSIZ];
FILE *description;
@ -57,9 +58,8 @@ char *template;
}
}
void listTemplates( query )
char *query;
void
listTemplates( char *query )
{
char filename[MAXPATHLEN];
DIR *dir;
@ -89,9 +89,8 @@ char *query;
}
}
char **specifyAttributes( objectClass )
char *objectClass;
char **
specifyAttributes( char *objectClass )
{
FILE *description;
char filename[MAXPATHLEN], buffer[BUFSIZ];
@ -131,9 +130,8 @@ char *objectClass;
return attributes;
}
char *templateToObjectClass( template )
char *template;
char *
templateToObjectClass( char *template )
{
int i;
@ -151,9 +149,8 @@ char *template;
return template;
}
char *objectClassToTemplate( objectClass )
char *objectClass;
char *
objectClassToTemplate( char *objectClass )
{
int i;

View file

@ -28,6 +28,8 @@ static char copyright[] = "Copyright 1992 The University of Adelaide";
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#include "portable.h"
#include <stdio.h>
#include <signal.h>
#include <ctype.h>
@ -41,12 +43,12 @@ static char copyright[] = "Copyright 1992 The University of Adelaide";
#include <langinfo.h>
#include <locale.h>
#endif
#include <ac/unistd.h>
static void handler();
char *lowerCase( string )
char *string;
static void handler(int sig);
char *
lowerCase( char *string )
{
char *s;
@ -56,9 +58,8 @@ char *string;
return string;
}
char *convertTime( date, locale )
char *date, *locale;
char *
convertTime( char *date, char *locale )
{
/*
* A quick hack to convert the time from the format Quipu uses into
@ -96,9 +97,8 @@ char *date, *locale;
static long interrupt;
char *getPassword( prompt )
char *prompt;
char *
getPassword( char *prompt )
{
#if defined(SYS5) || defined(XOS_2)
struct termios ttyb;
@ -107,7 +107,6 @@ char *prompt;
#endif
FILE *input;
struct sigvec ovec, vec;
void handler();
unsigned long flags;
int c, idx;
static char buffer[BUFSIZ + 1];
@ -160,8 +159,8 @@ char *prompt;
return buffer;
}
static void handler()
static void
handler( int sig )
{
++interrupt;
}

View file

@ -28,8 +28,7 @@ static char copyright[] = "Copyright 1992 The University of Adelaide";
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
char *version()
char *version( void )
{
return "1.7";
}

View file

@ -139,9 +139,10 @@ EXTERN char *banner;
EXTERN char **category;
EXTERN table *templateTranslationTable;
extern int displayDescribe(), parseCommand();
extern void needHelp();
extern void showTemplate(), listTemplates();
extern char **specifyAttributes();
extern char *lowerCase(), *version(), *attributeLabel();
extern int displayDescribe(), parseCommand(char *query);
extern void needHelp(char *reason);
extern void showTemplate(char *template), listTemplates(char *query);
extern char **specifyAttributes(char *objectClass);
extern char *lowerCase(char *string), *version(void), *attributeLabel();
extern char *rfc931_name();
extern char *templateToObjectClass(char *template);

54
include/ac/string.h Normal file
View file

@ -0,0 +1,54 @@
/* Generic string.h */
#ifndef _AC_STRING_H
#define _AC_STRING_H
#ifdef STDC_HEADERS
# include <string.h>
#else
# ifdef HAVE_STRING_H
# include <string.h>
# elif HAVE_STRINGS_H
# include <strings.h>
# endif
# ifndef HAVE_STRCHR
# define strchr index
# define strrchr rindex
# endif
# ifndef HAVE_MEMCPY
# define memcpy(d, s, n) bcopy ((s), (d), (n))
# define memmove(d, s, n) bcopy ((s), (d), (n))
# endif
# if !defined(HAVE_STRING_H) && !defined(HAVE_STRINGS_H)
/* define prototypes for string functions */
/* this could cause problems on some odd ball systems */
char *strchr(), *strrchr();
char *strcpy(), *strncpy();
char *strcat (), *strncat ();
int strcmp(), strncmp();
int strcasecmp(), strncasecmp();
char *strdup();
char *strtok();
char *strpbrk();
int memcmp();
# endif
#endif
#ifndef SAFEMEMCPY
# if defined( HAVE_MEMMOVE )
# define SAFEMEMCPY( d, s, n ) memmove((d), (s), (n))
# elif defined( HAVE_BCOPY )
# define SAFEMEMCPY( d, s, n ) bcopy((s), (d), (n))
# elif defined( MACOS )
# define SAFEMEMCPY( d, s, n ) BlockMoveData((Ptr)(s), (Ptr)(d), (n))
# else
/* nothing left but memcpy() */
# define SAFEMEMCPY( d, s, n ) memcpy((d), (s), (n))
# endif
#endif
#endif /* _AC_STRING_H */

44
include/ac/unistd.h Normal file
View file

@ -0,0 +1,44 @@
/* Generic unistd.h */
#ifndef _AC_UNISTD_H
#define _AC_UNISTD_H
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#if HAVE_UNISTD_H
# include <unistd.h>
#else
/* we really should test for these */
char *crypt();
char *gethostname();
char *getenv();
long *random();
int flock();
#endif
/* getopt() defines may be in separate include file */
#if HAVE_GETOPT_H
# include <getopt.h>
#elif !defined(HAVE_GETOPT)
/* no getopt, assume we need getopt-compat.h */
# include <getopt-compat.h>
#else
/* assume we need to declare these externs */
extern char *optarg;
extern int optind, opterr, optopt;
#endif
#ifndef HAVE_TEMPNAM
extern char *tempnam(const char *tmpdir, const char *prefix);
#endif
#ifndef HAVE_MKTEMP
extern char *mktemp(char *);
#endif
/* use _POSIX_VERSION for POSIX.1 code */
#endif /* _AC_UNISTD_H */

View file

@ -64,6 +64,7 @@ LDAP_F caddr_t
avl_getfirst LDAP_P((Avlnode *));
#ifdef AVL_REENTRANT
/* ??? avl.c does not provide this version ??? */
LDAP_F caddr_t
avl_getnext LDAP_P((Avlnode *, caddr_t ));
#else
@ -74,9 +75,15 @@ avl_getnext LDAP_P((void));
LDAP_F int
avl_dup_error LDAP_P((void));
LDAP_F int
avl_dup_ok LDAP_P((void));
LDAP_F int
avl_apply LDAP_P((Avlnode *, IFP, caddr_t, int, int));
LDAP_F int
avl_prefixapply LDAP_P((Avlnode *, caddr_t, IFP, caddr_t, IFP, caddr_t, int));
/* apply traversal types */
#define AVL_PREORDER 1
#define AVL_INORDER 2

View file

@ -501,9 +501,8 @@ typedef struct ldap_url_desc {
#define LDAP_URL_ERR_BADSCOPE 3 /* URL scope string is invalid */
#define LDAP_URL_ERR_MEM 4 /* can't allocate memory space */
/* this typedef is never used, only exists to rid of declaration
in function param list warning */
typedef struct timeval LDAPtv;
/* avoid pulling in headers */
struct timeval;
/*
* in abandon.c:
@ -718,10 +717,10 @@ LDAP_F void cldap_setretryinfo LDAP_P(( LDAP *ld, int tries, int timeout ));
*/
LDAP_F int ldap_sort_entries LDAP_P(( LDAP *ld,
LDAPMessage **chain, char *attr,
int (*cmp) LDAP_P((const char *, const char *)) ));
int (*cmp) (const char *, const char *) ));
LDAP_F int ldap_sort_values LDAP_P(( LDAP *ld,
char **vals, int (*cmp) LDAP_P((const void *, const void *)) ));
LDAP_F int ldap_sort_strcasecmp LDAP_P(( char **a, char **b ));
char **vals, int (*cmp) (const void *, const void *) ));
LDAP_F int ldap_sort_strcasecmp LDAP_P(( const void *a, const void *b ));
/*

View file

@ -148,6 +148,9 @@ LDAP_END_DECL
LDAP_BEGIN_DECL
stkalign_t *get_stack( int *stacknop );
void free_stack( int *stackno );
typedef void *(*VFP)();
/* thread attributes and thread type */

View file

@ -6,13 +6,15 @@
* Include file for LDAP utility routine
*/
/* ISC Base64 Routines */
LDAP_BEGIN_DECL
/* ISC Base64 Routines */
/* base64.c */
LDAP_F int b64_ntop LDAP_P((u_char const *, size_t, char *, size_t));
LDAP_F int b64_pton LDAP_P((char const *, u_char *, size_t));
/* detach.c */
LDAP_F void lutil_detach LDAP_P((int debug, int do_close));
/* passwd.c */
LDAP_F int lutil_passwd LDAP_P((const char *cred, const char *passwd));
LDAP_END_DECL

View file

@ -466,6 +466,12 @@ is provided ``as is'' without express or implied warranty.
/* Define if you have the <stddef.h> header file. */
#undef HAVE_STDDEF_H
/* Define if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define if you have the <synch.h> header file. */
#undef HAVE_SYNCH_H

View file

@ -11,34 +11,38 @@
* is provided ``as is'' without express or implied warranty.
*/
#include "portable.h"
#ifndef lint
static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of Michigan.\nAll rights reserved.\n";
static char avl_version[] = "AVL library version 1.0\n";
#endif
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include "avl.h"
#define ROTATERIGHT(x) { \
Avlnode *tmp;\
if ( *x == NULL || (*x)->avl_left == NULL ) {\
if ( *(x) == NULL || (*(x))->avl_left == NULL ) {\
(void) printf("RR error\n"); exit(1); \
}\
tmp = (*x)->avl_left;\
(*x)->avl_left = tmp->avl_right;\
tmp->avl_right = *x;\
*x = tmp;\
tmp = (*(x))->avl_left;\
(*(x))->avl_left = tmp->avl_right;\
tmp->avl_right = *(x);\
*(x) = tmp;\
}
#define ROTATELEFT(x) { \
Avlnode *tmp;\
if ( *x == NULL || (*x)->avl_right == NULL ) {\
if ( *(x) == NULL || (*(x))->avl_right == NULL ) {\
(void) printf("RL error\n"); exit(1); \
}\
tmp = (*x)->avl_right;\
(*x)->avl_right = tmp->avl_left;\
tmp = (*(x))->avl_right;\
(*(x))->avl_right = tmp->avl_left;\
tmp->avl_left = *x;\
*x = tmp;\
*(x) = tmp;\
}
/*
@ -46,14 +50,15 @@ static char avl_version[] = "AVL library version 1.0\n";
* and balance of an avl tree.
*/
static
ravl_insert( iroot, data, taller, fcmp, fdup, depth )
Avlnode **iroot;
caddr_t data;
int *taller;
IFP fcmp; /* comparison function */
IFP fdup; /* function to call for duplicates */
int depth;
static int
ravl_insert(
Avlnode **iroot,
caddr_t data,
int *taller,
IFP fcmp, /* comparison function */
IFP fdup, /* function to call for duplicates */
int depth
)
{
int rc, cmp, tallersub;
Avlnode *l, *r;
@ -200,11 +205,8 @@ ravl_insert( iroot, data, taller, fcmp, fdup, depth )
* NOTE: this routine may malloc memory
*/
avl_insert( root, data, fcmp, fdup )
Avlnode **root;
caddr_t data;
IFP fcmp;
IFP fdup;
int
avl_insert( Avlnode **root, caddr_t data, IFP fcmp, IFP fdup )
{
int taller;
@ -216,11 +218,10 @@ avl_insert( root, data, fcmp, fdup )
* been shortened because of a deletion.
*/
static
right_balance( root )
Avlnode **root;
static int
right_balance( Avlnode **root )
{
int shorter;
int shorter = -1;
Avlnode *r, *l;
switch( (*root)->avl_bf ) {
@ -281,11 +282,10 @@ right_balance( root )
* been shortened because of a deletion.
*/
static
left_balance( root )
Avlnode **root;
static int
left_balance( Avlnode **root )
{
int shorter;
int shorter = -1;
Avlnode *r, *l;
switch( (*root)->avl_bf ) {
@ -349,11 +349,7 @@ left_balance( root )
*/
static caddr_t
ravl_delete( root, data, fcmp, shorter )
Avlnode **root;
caddr_t data;
IFP fcmp;
int *shorter;
ravl_delete( Avlnode **root, caddr_t data, IFP fcmp, int *shorter )
{
int shortersubtree = 0;
int cmp;
@ -442,22 +438,15 @@ ravl_delete( root, data, fcmp, shorter )
*/
caddr_t
avl_delete( root, data, fcmp )
Avlnode **root;
caddr_t data;
IFP fcmp;
avl_delete( Avlnode **root, caddr_t data, IFP fcmp )
{
int shorter;
return( ravl_delete( root, data, fcmp, &shorter ) );
}
static
avl_inapply( root, fn, arg, stopflag )
Avlnode *root;
IFP fn;
caddr_t arg;
int stopflag;
static int
avl_inapply( Avlnode *root, IFP fn, caddr_t arg, int stopflag )
{
if ( root == 0 )
return( AVL_NOMORE );
@ -476,12 +465,8 @@ avl_inapply( root, fn, arg, stopflag )
return( avl_inapply( root->avl_right, fn, arg, stopflag ) );
}
static
avl_postapply( root, fn, arg, stopflag )
Avlnode *root;
IFP fn;
caddr_t arg;
int stopflag;
static int
avl_postapply( Avlnode *root, IFP fn, caddr_t arg, int stopflag )
{
if ( root == 0 )
return( AVL_NOMORE );
@ -499,12 +484,8 @@ avl_postapply( root, fn, arg, stopflag )
return( (*fn)( root->avl_data, arg ) );
}
static
avl_preapply( root, fn, arg, stopflag )
Avlnode *root;
IFP fn;
caddr_t arg;
int stopflag;
static int
avl_preapply( Avlnode *root, IFP fn, caddr_t arg, int stopflag )
{
if ( root == 0 )
return( AVL_NOMORE );
@ -531,12 +512,8 @@ avl_preapply( root, fn, arg, stopflag )
* of nodes.
*/
avl_apply( root, fn, arg, stopflag, type )
Avlnode *root;
IFP fn;
caddr_t arg;
int stopflag;
int type;
int
avl_apply( Avlnode *root, IFP fn, caddr_t arg, int stopflag, int type )
{
switch ( type ) {
case AVL_INORDER:
@ -564,14 +541,16 @@ avl_apply( root, fn, arg, stopflag, type )
* AVL_NOMORE is returned.
*/
avl_prefixapply( root, data, fmatch, marg, fcmp, carg, stopflag )
Avlnode *root;
caddr_t data;
IFP fmatch;
caddr_t marg;
IFP fcmp;
caddr_t carg;
int stopflag;
int
avl_prefixapply(
Avlnode *root,
caddr_t data,
IFP fmatch,
caddr_t marg,
IFP fcmp,
caddr_t carg,
int stopflag
)
{
int cmp;
@ -613,9 +592,8 @@ avl_prefixapply( root, data, fmatch, marg, fcmp, carg, stopflag )
* number of items actually freed is returned.
*/
avl_free( root, dfree )
Avlnode *root;
IFP dfree;
int
avl_free( Avlnode *root, IFP dfree )
{
int nleft, nright;
@ -643,10 +621,7 @@ avl_free( root, dfree )
*/
caddr_t
avl_find( root, data, fcmp )
Avlnode *root;
caddr_t data;
IFP fcmp;
avl_find( Avlnode *root, caddr_t data, IFP fcmp )
{
int cmp;
@ -668,10 +643,7 @@ avl_find( root, data, fcmp )
*/
caddr_t
avl_find_lin( root, data, fcmp )
Avlnode *root;
caddr_t data;
IFP fcmp;
avl_find_lin( Avlnode *root, caddr_t data, IFP fcmp )
{
caddr_t res;
@ -699,10 +671,8 @@ static int avl_nextlist;
#define AVL_GRABSIZE 100
/* ARGSUSED */
static
avl_buildlist( data, arg )
caddr_t data;
int arg;
static int
avl_buildlist( caddr_t data, int arg )
{
static int slots;
@ -734,8 +704,7 @@ avl_buildlist( data, arg )
*/
caddr_t
avl_getfirst( root )
Avlnode *root;
avl_getfirst( Avlnode *root )
{
if ( avl_list ) {
free( (char *) avl_list);
@ -753,7 +722,7 @@ avl_getfirst( root )
}
caddr_t
avl_getnext()
avl_getnext( void )
{
if ( avl_list == 0 )
return( 0 );
@ -767,12 +736,14 @@ avl_getnext()
return( avl_list[ avl_nextlist++ ] );
}
avl_dup_error()
int
avl_dup_error( void )
{
return( -1 );
}
avl_dup_ok()
int
avl_dup_ok( void )
{
return( 0 );
}

View file

@ -1,30 +1,25 @@
/* testavl.c - Test Tim Howes AVL code */
#include <sys/types.h>
#include "portable.h"
#include <stdio.h>
#include <stdlib.h>
#include <ac/string.h>
#include <sys/types.h>
#include "avl.h"
char *strdup( s )
char *s;
{
char *new;
static void ravl_print LDAP_P(( Avlnode *root, int depth ));
static void myprint LDAP_P(( Avlnode *root ));
if ( (new = (char *) malloc( strlen( s ) + 1 )) == NULL )
return( NULL );
strcpy( new, s );
return( new );
}
main( argc, argv )
int argc;
char **argv;
int
main( int argc, char **argv )
{
Avlnode *tree = NULLAVL;
char command[ 10 ];
char name[ 80 ];
char *p;
int free(), strcmp();
printf( "> " );
while ( fgets( command, sizeof( command ), stdin ) != NULL ) {
@ -39,7 +34,7 @@ char **argv;
case 't': /* traverse with first, next */
printf( "***\n" );
for ( p = (char * ) avl_getfirst( tree );
p != NULL; p = (char *) avl_getnext( tree, p ) )
p != NULL; p = (char *) avl_getnext( /* tree, p */ ) )
printf( "%s\n", p );
printf( "***\n" );
break;
@ -60,7 +55,7 @@ char **argv;
exit( 0 );
name[ strlen( name ) - 1 ] = '\0';
if ( avl_insert( &tree, strdup( name ), strcmp,
avl_dup_error ) != OK )
avl_dup_error ) != 0 )
printf( "\nNot inserted!\n" );
break;
case 'd': /* delete */
@ -85,9 +80,7 @@ char **argv;
/* NOTREACHED */
}
static ravl_print( root, depth )
Avlnode *root;
int depth;
static void ravl_print( Avlnode *root, int depth )
{
int i;
@ -103,15 +96,14 @@ int depth;
ravl_print( root->avl_left, depth+1 );
}
myprint( root )
Avlnode *root;
static void myprint( Avlnode *root )
{
printf( "********\n" );
if ( root == 0 )
printf( "\tNULL\n" );
else
( void ) ravl_print( root, 0 );
ravl_print( root, 0 );
printf( "********\n" );
}

View file

@ -14,10 +14,7 @@
#include "portable.h"
#include <stdio.h>
#ifdef STDC_HEADERS
#include <stdlib.h>
#endif
#include <ac/stdarg.h>

View file

@ -18,6 +18,7 @@
#include <ac/string.h>
#include <ac/socket.h>
#include <ac/unistd.h>
#ifdef HAVE_CONSOLE_H
#include <console.h>
@ -38,7 +39,6 @@ main( int argc, char **argv )
int tag;
BerElement ber;
Sockbuf sb;
extern char *optarg;
#ifdef HAVE_CONSOLE_H
ccommand( &argv );

View file

@ -4,43 +4,46 @@
* All rights reserved.
*/
#include "portable.h"
#include <stdio.h>
#include <string.h>
#ifdef MACOS
#include <stdlib.h>
#include <unix.h>
#include <fcntl.h>
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/unistd.h>
#ifdef HAVE_CONSOLE_H
#include <console.h>
#else /* MACOS */
#include <sys/types.h>
#include <sys/socket.h>
#endif /* MACOS */
#endif /* HAVE_CONSOLE_H */
#include "lber.h"
static usage( char *name )
static void usage( char *name )
{
fprintf( stderr, "usage: %s fmtstring\n", name );
}
main( int argc, char **argv )
{
int i, num, len;
char *s, *p;
#ifdef notdef
int i, len;
char *s, *p;
#endif
int num;
Seqorset *sos = NULLSEQORSET;
BerElement *ber;
Sockbuf sb;
extern char *optarg;
if ( argc < 2 ) {
usage( argv[0] );
exit( 1 );
}
bzero( &sb, sizeof(sb) );
memset( &sb, 0, sizeof(sb) );
sb.sb_sd = 1;
sb.sb_ber.ber_buf = NULL;
#ifdef MACOS
#ifdef HAVE_CONSOLE_H
ccommand( &argv );
cshow( stdout );
@ -151,9 +154,9 @@ main( int argc, char **argv )
break;
default:
#ifndef NO_USERINTERFACE
#ifdef LDAP_LIBUI
fprintf( stderr, "unknown fmt %c\n", *fmt );
#endif /* NO_USERINTERFACE */
#endif /* LDAP_LIBUI */
rc = -1;
break;
}

View file

@ -105,7 +105,7 @@ static int BerWrite LDAP_P(( Sockbuf *sb, char *buf, long len ));
#define EXBUFSIZ 1024
int
static int
ber_filbuf( Sockbuf *sb, long len )
{
short rc;
@ -151,7 +151,7 @@ ber_filbuf( Sockbuf *sb, long len )
}
long
static long
BerRead( Sockbuf *sb, char *buf, long len )
{
int c;
@ -340,13 +340,13 @@ ber_alloc_t( int options )
}
BerElement *
ber_alloc()
ber_alloc( void )
{
return( ber_alloc_t( 0 ) );
}
BerElement *
der_alloc()
der_alloc( void )
{
return( ber_alloc_t( LBER_USE_DER ) );
}
@ -467,7 +467,8 @@ ber_get_next( Sockbuf *sb, unsigned long *len, BerElement *ber )
unsigned long tag = 0, netlen, toread;
unsigned char lc;
long rc;
int noctets, diff;
int noctets;
unsigned int diff;
#ifdef LDAP_DEBUG
if ( lber_debug )

View file

@ -20,6 +20,7 @@ static char copyright[] = "@(#) Copyright (c) 1990, 1994 Regents of the Universi
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/time.h>
#include <ac/unistd.h>
#include "lber.h"
#include "ldap.h"
@ -300,8 +301,8 @@ cldap_result( LDAP *ld, int msgid, LDAPMessage **res,
tv.tv_usec = 0;
Debug( LDAP_DEBUG_TRACE,
"cldap_result waiting up to %d seconds for a response\n",
tv.tv_sec, 0, 0 );
"cldap_result waiting up to %ld seconds for a response\n",
(long) tv.tv_sec, 0, 0 );
ber_init( &ber, 0 );
ldap_set_ber_options( ld, &ber );
@ -473,7 +474,7 @@ cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber,
bv = NULL;
} else {
Debug( LDAP_DEBUG_TRACE, "cldap_parsemsg got unknown tag %d\n",
Debug( LDAP_DEBUG_TRACE, "cldap_parsemsg got unknown tag %lu\n",
tag, 0, 0 );
rc = LDAP_PROTOCOL_ERROR;
break; /* return w/error */

View file

@ -8,6 +8,8 @@
#ifndef _LDAP_INT_H
#define _LDAP_INT_H
LDAP_BEGIN_DECL
#define LDAP_URL_PREFIX "ldap://"
#define LDAP_URL_PREFIX_LEN 7
#define LDAP_URL_URLCOLON "URL:"
@ -24,7 +26,6 @@
#endif /* LDAP_DNS */
#endif /* LDAP_REFERRALS */
LDAP_BEGIN_DECL
/*
* in cache.c
*/
@ -34,7 +35,7 @@ void ldap_add_result_to_cache LDAP_P(( LDAP *ld, LDAPMessage *result ));
int ldap_check_cache LDAP_P(( LDAP *ld, unsigned long msgtype, BerElement *request ));
/*
* in dparse.c
* in dsparse.c
*/
int next_line_tokens LDAP_P(( char **bufp, long *blenp, char ***toksp ));
void free_strarray LDAP_P(( char **sap ));
@ -105,6 +106,12 @@ int ldap_chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadref
int ldap_append_referral( LDAP *ld, char **referralsp, char *s );
#endif /* LDAP_REFERRALS */
/*
* in result.c:
*/
#ifdef LDAP_CONNECTIONLESS
LDAP_F int cldap_getmsg ( LDAP *ld, struct timeval *timeout, BerElement *ber );
#endif
/*
* in search.c
@ -142,4 +149,5 @@ int ldap_8859_to_t61( char **bufp, unsigned long *buflenp, int free_input );
#endif /* LDAP_CHARSET_8859 == LDAP_DEFAULT_CHARSET */
#endif /* STR_TRANSLATION && LDAP_DEFAULT_CHARSET */
LDAP_END_DECL
#endif /* _LDAP_INT_H */

View file

@ -56,7 +56,11 @@ ldap_connect_to_host( Sockbuf *sb, char *host, unsigned long address,
connected = use_hp = 0;
if ( host != NULL && ( address = inet_addr( host )) == (unsigned long) -1L ) {
if ( host != NULL ) {
address = inet_addr( host );
/* This was just a test for -1 until OSF1 let inet_addr return
unsigned int, which is narrower than 'unsigned long address' */
if ( address == 0xffffffff || address == (unsigned long) -1 ) {
if ( (hp = gethostbyname( host )) == NULL ) {
#ifdef HAVE_WINSOCK
errno = WSAGetLastError();
@ -66,6 +70,7 @@ ldap_connect_to_host( Sockbuf *sb, char *host, unsigned long address,
return( -1 );
}
use_hp = 1;
}
}
rc = -1;
@ -256,7 +261,7 @@ ldap_is_read_ready( LDAP *ld, Sockbuf *sb )
void *
ldap_new_select_info()
ldap_new_select_info( void )
{
struct selectinfo *sip;
@ -290,6 +295,8 @@ do_ldap_select( LDAP *ld, struct timeval *timeout )
tblsize = sysconf( _SC_OPEN_MAX );
#elif defined( HAVE_GETDTABLESIZE )
tblsize = getdtablesize();
#else
tblsize = FD_SETSIZE;
#endif /* !USE_SYSCONF */
#ifdef FD_SETSIZE

View file

@ -30,17 +30,17 @@ struct entrything {
LDAPMessage *et_msg;
};
static int (*et_cmp_fn) LDAP_P(( char *a, char *b ));
static int (*et_cmp_fn) LDAP_P(( const char *a, const char *b ));
static int et_cmp LDAP_P(( const void *aa, const void *bb));
int
ldap_sort_strcasecmp(
char **a,
char **b
const void *a,
const void *b
)
{
return( strcasecmp( *a, *b ) );
return( strcasecmp( *(char *const *)a, *(char *const *)b ) );
}
static int
@ -79,7 +79,7 @@ ldap_sort_entries(
LDAP *ld,
LDAPMessage **chain,
char *attr, /* NULL => sort by DN */
int (*cmp) LDAP_P((const char *, const char *))
int (*cmp) (const char *, const char *)
)
{
int i, count;
@ -132,7 +132,7 @@ int
ldap_sort_values(
LDAP *ld,
char **vals,
int (*cmp) LDAP_P((const void *, const void *))
int (*cmp) (const void *, const void *)
)
{
int nel;

View file

@ -1,57 +1,51 @@
#include "portable.h"
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#ifdef MACOS
#include <stdlib.h>
#ifdef THINK_C
#include <console.h>
#include <unix.h>
#include <fcntl.h>
#endif /* THINK_C */
#include "macos.h"
#else /* MACOS */
#if defined( DOS ) || defined( _WIN32 )
#include "msdos.h"
#if defined( WINSOCK ) || defined( _WIN32 )
#include "console.h"
#endif /* WINSOCK */
#else /* DOS */
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <ac/ctype.h>
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/time.h>
#include <ac/unistd.h>
#include <sys/stat.h>
#ifdef HAVE_SYS_FILE_H
#include <sys/file.h>
#ifndef VMS
#endif
#ifdef HAVE_IO_H
#include <io.h>
#endif
#include <fcntl.h>
#include <unistd.h>
#endif /* VMS */
#endif /* DOS */
#endif /* MACOS */
#include "lber.h"
#include "ldap.h"
#if !defined( PCNFS ) && !defined( WINSOCK ) && !defined( MACOS )
#define MOD_USE_BVALS
#endif /* !PCNFS && !WINSOCK && !MACOS */
/* including the "internal" defs is legit and nec. since this test routine has
* a-priori knowledge of libldap internal workings.
* hodges@stanford.edu 5-Feb-96
*/
#include "ldap-int.h"
#ifdef NEEDPROTOS
static void handle_result( LDAP *ld, LDAPMessage *lm );
static void print_ldap_result( LDAP *ld, LDAPMessage *lm, char *s );
static void print_search_entry( LDAP *ld, LDAPMessage *res );
static void free_list( char **list );
#else
static void handle_result();
static void print_ldap_result();
static void print_search_entry();
static void free_list();
#endif /* NEEDPROTOS */
/* local functions */
#ifndef HAVE_GETLINE
static char *getline LDAP_P(( char *line, int len, FILE *fp, char *prompt ));
#endif
static char **get_list LDAP_P(( char *prompt ));
static int file_read LDAP_P(( char *path, struct berval *bv ));
static LDAPMod **get_modlist LDAP_P(( char *prompt1, char *prompt2, char *prompt3 ));
static void handle_result LDAP_P(( LDAP *ld, LDAPMessage *lm ));
static void print_ldap_result LDAP_P(( LDAP *ld, LDAPMessage *lm, char *s ));
static void print_search_entry LDAP_P(( LDAP *ld, LDAPMessage *res ));
static void free_list LDAP_P(( char **list ));
#define NOCACHEERRMSG "don't compile with -DNO_CACHE if you desire local caching"
#define NOCACHEERRMSG "don't compile with -DLDAP_NOCACHE if you desire local caching"
char *dnsuffix;
static char *dnsuffix;
#ifndef WINSOCK
#ifndef HAVE_GETLINE
static char *
getline( char *line, int len, FILE *fp, char *prompt )
{
@ -64,7 +58,7 @@ getline( char *line, int len, FILE *fp, char *prompt )
return( line );
}
#endif /* WINSOCK */
#endif
static char **
get_list( char *prompt )
@ -112,7 +106,6 @@ free_list( char **list )
}
#ifdef MOD_USE_BVALS
static int
file_read( char *path, struct berval *bv )
{
@ -149,7 +142,7 @@ file_read( char *path, struct berval *bv )
eof = feof( fp );
fclose( fp );
if ( rlen != bv->bv_len ) {
if ( (unsigned long) rlen != bv->bv_len ) {
perror( path );
free( bv->bv_val );
return( -1 );
@ -157,7 +150,6 @@ file_read( char *path, struct berval *bv )
return( bv->bv_len );
}
#endif /* MOD_USE_BVALS */
static LDAPMod **
@ -167,9 +159,7 @@ get_modlist( char *prompt1, char *prompt2, char *prompt3 )
int num;
LDAPMod tmp;
LDAPMod **result;
#ifdef MOD_USE_BVALS
struct berval **bvals;
#endif /* MOD_USE_BVALS */
num = 0;
result = NULL;
@ -188,7 +178,7 @@ get_modlist( char *prompt1, char *prompt2, char *prompt3 )
tmp.mod_type = strdup( buf );
tmp.mod_values = get_list( prompt3 );
#ifdef MOD_USE_BVALS
if ( tmp.mod_values != NULL ) {
int i;
@ -214,7 +204,6 @@ get_modlist( char *prompt1, char *prompt2, char *prompt3 )
tmp.mod_bvalues = bvals;
tmp.mod_op |= LDAP_MOD_BVALUES;
}
#endif /* MOD_USE_BVALS */
if ( result == NULL )
result = (LDAPMod **) malloc( sizeof(LDAPMod *) );
@ -236,14 +225,14 @@ get_modlist( char *prompt1, char *prompt2, char *prompt3 )
#ifdef LDAP_REFERRALS
int
static int
bind_prompt( LDAP *ld, char **dnp, char **passwdp, int *authmethodp,
int freeit )
{
static char dn[256], passwd[256];
if ( !freeit ) {
#ifdef KERBEROS
#ifdef HAVE_KERBEROS
getline( dn, sizeof(dn), stdin,
"re-bind method (0->simple, 1->krbv41, 2->krbv42, 3->krbv41&2)? " );
if (( *authmethodp = atoi( dn )) == 3 ) {
@ -251,9 +240,9 @@ bind_prompt( LDAP *ld, char **dnp, char **passwdp, int *authmethodp,
} else {
*authmethodp |= 0x80;
}
#else /* KERBEROS */
#else /* HAVE_KERBEROS */
*authmethodp = LDAP_AUTH_SIMPLE;
#endif /* KERBEROS */
#endif /* HAVE_KERBEROS */
getline( dn, sizeof(dn), stdin, "re-bind dn? " );
strcat( dn, dnsuffix );
@ -274,14 +263,9 @@ bind_prompt( LDAP *ld, char **dnp, char **passwdp, int *authmethodp,
int
#ifdef WINSOCK
ldapmain(
#else /* WINSOCK */
main(
#endif /* WINSOCK */
int argc, char **argv )
main( int argc, char **argv )
{
LDAP *ld;
LDAP *ld = NULL;
int i, c, port, cldapflg, errflg, method, id, msgtype;
char line[256], command1, command2, command3;
char passwd[64], dn[256], rdn[64], attr[64], value[256];
@ -296,18 +280,6 @@ main(
int copyoptions = 0;
LDAPURLDesc *ludp;
extern char *optarg;
extern int optind;
#ifdef MACOS
if (( argv = get_list( "cmd line arg?" )) == NULL ) {
exit( 1 );
}
for ( argc = 0; argv[ argc ] != NULL; ++argc ) {
;
}
#endif /* MACOS */
host = NULL;
port = LDAP_PORT;
dnsuffix = "";
@ -316,11 +288,11 @@ main(
while (( c = getopt( argc, argv, "uh:d:s:p:t:T:" )) != -1 ) {
switch( c ) {
case 'u':
#ifdef CLDAP
#ifdef LDAP_CONNECTIONLESS
cldapflg++;
#else /* CLDAP */
printf( "Compile with -DCLDAP for UDP support\n" );
#endif /* CLDAP */
#else /* LDAP_CONNECTIONLESS */
printf( "Compile with -DLDAP_CONNECTIONLESS for UDP support\n" );
#endif /* LDAP_CONNECTIONLESS */
break;
case 'd':
@ -346,7 +318,6 @@ main(
port = atoi( optarg );
break;
#if !defined(MACOS) && !defined(DOS)
case 't': /* copy ber's to given file */
copyfname = strdup( optarg );
copyoptions = LBER_TO_FILE;
@ -356,7 +327,6 @@ main(
copyfname = strdup( optarg );
copyoptions = (LBER_TO_FILE | LBER_TO_FILE_ONLY);
break;
#endif
default:
++errflg;
@ -377,9 +347,9 @@ main(
host == NULL ? "(null)" : host, port );
if ( cldapflg ) {
#ifdef CLDAP
#ifdef LDAP_CONNECTIONLESS
ld = cldap_open( host, port );
#endif /* CLDAP */
#endif /* LDAP_CONNECTIONLESS */
} else {
ld = ldap_open( host, port );
}
@ -389,7 +359,6 @@ main(
exit(1);
}
#if !defined(MACOS) && !defined(DOS)
if ( copyfname != NULL ) {
if ( (ld->ld_sb.sb_fd = open( copyfname, O_WRONLY | O_CREAT,
0600 )) == -1 ) {
@ -398,7 +367,6 @@ main(
}
ld->ld_sb.sb_options = copyoptions;
}
#endif
bound = 0;
timeout.tv_sec = 0;
@ -440,13 +408,13 @@ main(
break;
case 'b': /* asynch bind */
#ifdef KERBEROS
#ifdef HAVE_KERBEROS
getline( line, sizeof(line), stdin,
"method (0->simple, 1->krbv41, 2->krbv42)? " );
method = atoi( line ) | 0x80;
#else /* KERBEROS */
#else /* HAVE_KERBEROS */
method = LDAP_AUTH_SIMPLE;
#endif /* KERBEROS */
#endif /* HAVE_KERBEROS */
getline( dn, sizeof(dn), stdin, "dn? " );
strcat( dn, dnsuffix );
@ -466,7 +434,7 @@ main(
break;
case 'B': /* synch bind */
#ifdef KERBEROS
#ifdef HAVE_KERBEROS
getline( line, sizeof(line), stdin,
"method 0->simple 1->krbv41 2->krbv42 3->krb? " );
method = atoi( line );
@ -474,9 +442,9 @@ main(
method = LDAP_AUTH_KRBV4;
else
method = method | 0x80;
#else /* KERBEROS */
#else /* HAVE_KERBEROS */
method = LDAP_AUTH_SIMPLE;
#endif /* KERBEROS */
#endif /* HAVE_KERBEROS */
getline( dn, sizeof(dn), stdin, "dn? " );
strcat( dn, dnsuffix );
@ -567,10 +535,10 @@ main(
break;
case 'q': /* quit */
#ifdef CLDAP
#ifdef LDAP_CONNECTIONLESS
if ( cldapflg )
cldap_close( ld );
#endif /* CLDAP */
#endif /* LDAP_CONNECTIONLESS */
#ifdef LDAP_REFERRALS
if ( !cldapflg )
#else /* LDAP_REFERRALS */
@ -636,7 +604,7 @@ main(
attrsonly = atoi( line );
if ( cldapflg ) {
#ifdef CLDAP
#ifdef LDAP_CONNECTIONLESS
getline( line, sizeof(line), stdin,
"Requestor DN (for logging)? " );
if ( cldap_search_s( ld, dn, scope, filter, types,
@ -648,7 +616,7 @@ main(
handle_result( ld, res );
res = NULLMSG;
}
#endif /* CLDAP */
#endif /* LDAP_CONNECTIONLESS */
} else {
if (( id = ldap_search( ld, dn, scope, filter,
types, attrsonly )) == -1 ) {
@ -749,9 +717,9 @@ main(
break;
case 'e': /* enable cache */
#ifdef NO_CACHE
#ifdef LDAP_NOCACHE
printf( NOCACHEERRMSG );
#else /* NO_CACHE */
#else /* LDAP_NOCACHE */
getline( line, sizeof(line), stdin, "Cache timeout (secs)? " );
i = atoi( line );
getline( line, sizeof(line), stdin, "Maximum memory to use (bytes)? " );
@ -760,25 +728,25 @@ main(
} else {
printf( "ldap_enable_cache failed\n" );
}
#endif /* NO_CACHE */
#endif /* LDAP_NOCACHE */
break;
case 'x': /* uncache entry */
#ifdef NO_CACHE
#ifdef LDAP_NOCACHE
printf( NOCACHEERRMSG );
#else /* NO_CACHE */
#else /* LDAP_NOCACHE */
getline( line, sizeof(line), stdin, "DN? " );
ldap_uncache_entry( ld, line );
#endif /* NO_CACHE */
#endif /* LDAP_NOCACHE */
break;
case 'X': /* uncache request */
#ifdef NO_CACHE
#ifdef LDAP_NOCACHE
printf( NOCACHEERRMSG );
#else /* NO_CACHE */
#else /* LDAP_NOCACHE */
getline( line, sizeof(line), stdin, "request msgid? " );
ldap_uncache_request( ld, atoi( line ));
#endif /* NO_CACHE */
#endif /* LDAP_NOCACHE */
break;
case 'o': /* set ldap options */
@ -833,9 +801,9 @@ main(
break;
case 'O': /* set cache options */
#ifdef NO_CACHE
#ifdef LDAP_NOCACHE
printf( NOCACHEERRMSG );
#else /* NO_CACHE */
#else /* LDAP_NOCACHE */
getline( line, sizeof(line), stdin, "cache errors (0=smart, 1=never, 2=always)?" );
switch( atoi( line )) {
case 0:
@ -852,7 +820,7 @@ main(
default:
printf( "not a valid cache option\n" );
}
#endif /* NO_CACHE */
#endif /* LDAP_NOCACHE */
break;
case '?': /* help */
@ -956,13 +924,9 @@ print_search_entry( LDAP *ld, LDAPMessage *res )
ufn = ldap_dn2ufn( dn );
printf( "\tUFN: %s\n", ufn );
#ifdef WINSOCK
ldap_memfree( dn );
ldap_memfree( ufn );
#else /* WINSOCK */
free( dn );
free( ufn );
#endif /* WINSOCK */
for ( a = ldap_first_attribute( ld, e, &ber ); a != NULL;
a = ldap_next_attribute( ld, e, ber ) ) {
@ -975,7 +939,7 @@ print_search_entry( LDAP *ld, LDAPMessage *res )
int j, nonascii;
nonascii = 0;
for ( j = 0; j < vals[i]->bv_len; j++ )
for ( j = 0; (unsigned long) j < vals[i]->bv_len; j++ )
if ( !isascii( vals[i]->bv_val[j] ) ) {
nonascii = 1;
break;
@ -1001,23 +965,3 @@ print_search_entry( LDAP *ld, LDAPMessage *res )
|| res->lm_chain != NULLMSG )
print_ldap_result( ld, res, "search" );
}
#ifdef WINSOCK
void
ldap_perror( LDAP *ld, char *s )
{
char *errs;
if ( ld == NULL ) {
perror( s );
return;
}
errs = ldap_err2string( ld->ld_errno );
printf( "%s: %s\n", s, errs == NULL ? "unknown error" : errs );
if ( ld->ld_error != NULL && *ld->ld_error != '\0' ) {
printf( "%s: additional info: %s\n", s, ld->ld_error );
}
}
#endif /* WINSOCK */

View file

@ -8,9 +8,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <ac/ctype.h>
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/ctype.h>
#include <ac/time.h>
#ifdef HAVE_SYS_FILE_H
@ -23,6 +23,7 @@
#include "ldapconfig.h"
/* local functions */
static int do_entry2text LDAP_P((
LDAP *ld, char *buf, char *base, LDAPMessage *entry,
struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals,

View file

@ -1,27 +1,25 @@
#include "portable.h"
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
#include <ac/socket.h>
#include <ac/time.h>
#ifdef HAVE_CONSOLE_H
#include <console.h>
#endif /* MACOS */
#include "lber.h"
#include "ldap.h"
#include "disptmpl.h"
#include "srchpref.h"
#ifdef MACOS
#include <stdlib.h>
#include <console.h>
#endif /* MACOS */
#ifdef NEEDPROTOS
void dump_tmpl( struct ldap_disptmpl *tmpl );
void dump_srchpref( struct ldap_searchobj *sp );
#else /* NEEDPROTOS */
void dump_tmpl();
void dump_srchpref();
#endif /* NEEDPROTOS */
static void dump_tmpl ( struct ldap_disptmpl *tmpl );
static void dump_srchpref( struct ldap_searchobj *sp );
#define NULLSTRINGIFNULL( s ) ( s == NULL ? "(null)" : s )
int
main( int argc, char **argv )
{
@ -29,7 +27,7 @@ main( int argc, char **argv )
struct ldap_searchobj *so, *sop;
int err;
#ifdef MACOS
#ifdef HAVE_CONSOLE_H
ccommand( &argv );
for ( argc = 0; argv[ argc ] != NULL; ++argc ) {
;

View file

@ -26,6 +26,7 @@ static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of
typedef int (*cancelptype) LDAP_P(( void *cancelparm ));
/* local functions */
static int ldap_ufn_search_ctx LDAP_P(( LDAP *ld, char **ufncomp, int ncomp,
char *prefix, char **attrs, int attrsonly, LDAPMessage **res,
cancelptype cancelproc, void *cancelparm, char *tag1, char *tag2,
@ -73,7 +74,6 @@ ldap_ufn_search_ctx( LDAP *ld, char **ufncomp, int ncomp, char *prefix,
LDAPFiltInfo *fi;
LDAPMessage *tmpcand;
LDAPMessage *candidates;
LDAPMessage *ldap_msg_merge(), *ldap_ufn_expand();
static char *objattrs[] = { "objectClass", NULL };
/*

View file

@ -36,6 +36,7 @@ static char copyright[] = "@(#) Copyright (c) 1996 Regents of the University of
#include "ldap-int.h"
/* local functions */
static int skip_url_prefix LDAP_P(( char **urlp, int *enclosedp ));
static void hex_unescape LDAP_P(( char *s ));
static int unhex( char c );

View file

@ -12,6 +12,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <ac/string.h>
#include <ac/errno.h>
#include "ldbm.h"
@ -317,7 +318,7 @@ ldbm_datum_dup( LDBM ldbm, Datum data )
return( dup );
}
dup.dsize = data.dsize;
if ( dup.dptr = (char *) malloc( data.dsize ) )
if ( (dup.dptr = (char *) malloc( data.dsize )) != NULL )
memcpy( dup.dptr, data.dptr, data.dsize );
return( dup );

View file

@ -1,11 +1,17 @@
/* stack.c - stack handling routines */
#include "portable.h"
#if defined( HAVE_LWP )
#include <stdio.h>
#include <ac/time.h>
#include <ac/socket.h>
#include "lber.h"
#include "ldap.h"
#if defined( sunos4 )
#include <lwp/lwp.h>
#include <lwp/stackdep.h>

View file

@ -72,7 +72,7 @@ pthread_create(
}
void
pthread_yield()
pthread_yield( void )
{
cthread_yield();
}
@ -223,7 +223,7 @@ pthread_create(
#endif /* ! sunos56 */
void
pthread_yield()
pthread_yield( void )
{
thr_yield();
}
@ -317,9 +317,6 @@ pthread_cond_broadcast( pthread_cond_t *cv )
* *
*************/
extern stkalign_t *get_stack();
static void lwp_create_stack();
int
pthread_attr_init( pthread_attr_t *attr )
{
@ -347,6 +344,14 @@ pthread_attr_setdetachstate( pthread_attr_t *attr, int detachstate )
return( 0 );
}
static void
lwp_create_stack( VFP func, void *arg, int stackno )
{
(*func)( arg );
free_stack( stackno );
}
/* ARGSUSED */
int
pthread_create(
@ -366,16 +371,8 @@ pthread_create(
arg, stackno ) );
}
static void
lwp_create_stack( VFP func, void *arg, int stackno )
{
(*func)( arg );
free_stack( stackno );
}
void
pthread_yield()
pthread_yield( void )
{
lwp_yield( SELF );
}
@ -528,7 +525,7 @@ pthread_create(
}
void
pthread_yield()
pthread_yield( void )
{
return;
}

318
libraries/liblutil/md5.c Normal file
View file

@ -0,0 +1,318 @@
/*
* Modified by Kurt D. Zeilenga for inclusion into OpenLDAP
* I hereby disclaim copyright in any changes I have made; this
* code remains in the public domain.
*/
/*
* This code implements the MD5 message-digest algorithm.
* The algorithm is due to Ron Rivest. This code was
* written by Colin Plumb in 1993, no copyright is claimed.
* This code is in the public domain; do with it what you wish.
*
* Equivalent code is available from RSA Data Security, Inc.
* This code has been tested against that, and is equivalent,
* except that you don't need to include two pages of legalese
* with every copy.
*
* To compute the message digest of a chunk of bytes, declare an
* MD5Context structure, pass it to MD5Init, call MD5Update as
* needed on buffers full of bytes, and then call MD5Final, which
* will fill a supplied 16-byte array with the digest.
*/
/* This code was modified in 1997 by Jim Kingdon of Cyclic Software to
not require an integer type which is exactly 32 bits. This work
draws on the changes for the same purpose by Tatu Ylonen
<ylo@cs.hut.fi> as part of SSH, but since I didn't actually use
that code, there is no copyright issue. I hereby disclaim
copyright in any changes I have made; this code remains in the
public domain. */
#include "portable.h"
#include <ac/string.h>
/* include socket.h to get sys/types.h and/or winsock2.h */
#include <ac/socket.h>
#include <lutil_md5.h>
/* Little-endian byte-swapping routines. Note that these do not
depend on the size of datatypes such as uint32, nor do they require
us to detect the endianness of the machine we are running on. It
is possible they should be macros for speed, but I would be
surprised if they were a performance bottleneck for MD5. */
static uint32
getu32( const unsigned char *addr )
{
return (((((unsigned long)addr[3] << 8) | addr[2]) << 8)
| addr[1]) << 8 | addr[0];
}
static void
putu32( uint32 data, unsigned char *addr )
{
addr[0] = (unsigned char)data;
addr[1] = (unsigned char)(data >> 8);
addr[2] = (unsigned char)(data >> 16);
addr[3] = (unsigned char)(data >> 24);
}
/*
* Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
* initialization constants.
*/
void
ldap_MD5Init( struct ldap_MD5Context *ctx )
{
ctx->buf[0] = 0x67452301;
ctx->buf[1] = 0xefcdab89;
ctx->buf[2] = 0x98badcfe;
ctx->buf[3] = 0x10325476;
ctx->bits[0] = 0;
ctx->bits[1] = 0;
}
/*
* Update context to reflect the concatenation of another buffer full
* of bytes.
*/
void
ldap_MD5Update(
struct ldap_MD5Context *ctx,
const unsigned char *buf,
unsigned int len
)
{
uint32 t;
/* Update bitcount */
t = ctx->bits[0];
if ((ctx->bits[0] = (t + ((uint32)len << 3)) & 0xffffffff) < t)
ctx->bits[1]++; /* Carry from low to high */
ctx->bits[1] += len >> 29;
t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
/* Handle any leading odd-sized chunks */
if ( t ) {
unsigned char *p = ctx->in + t;
t = 64-t;
if (len < t) {
memcpy(p, buf, len);
return;
}
memcpy(p, buf, t);
ldap_MD5Transform(ctx->buf, ctx->in);
buf += t;
len -= t;
}
/* Process data in 64-byte chunks */
while (len >= 64) {
memcpy(ctx->in, buf, 64);
ldap_MD5Transform(ctx->buf, ctx->in);
buf += 64;
len -= 64;
}
/* Handle any remaining bytes of data. */
memcpy(ctx->in, buf, len);
}
/*
* Final wrapup - pad to 64-byte boundary with the bit pattern
* 1 0* (64-bit count of bits processed, MSB-first)
*/
void
ldap_MD5Final( unsigned char *digest, struct ldap_MD5Context *ctx )
{
unsigned count;
unsigned char *p;
/* Compute number of bytes mod 64 */
count = (ctx->bits[0] >> 3) & 0x3F;
/* Set the first char of padding to 0x80. This is safe since there is
always at least one byte free */
p = ctx->in + count;
*p++ = 0x80;
/* Bytes of padding needed to make 64 bytes */
count = 64 - 1 - count;
/* Pad out to 56 mod 64 */
if (count < 8) {
/* Two lots of padding: Pad the first block to 64 bytes */
memset(p, 0, count);
ldap_MD5Transform(ctx->buf, ctx->in);
/* Now fill the next block with 56 bytes */
memset(ctx->in, 0, 56);
} else {
/* Pad block to 56 bytes */
memset(p, 0, count-8);
}
/* Append length in bits and transform */
putu32(ctx->bits[0], ctx->in + 56);
putu32(ctx->bits[1], ctx->in + 60);
ldap_MD5Transform(ctx->buf, ctx->in);
putu32(ctx->buf[0], digest);
putu32(ctx->buf[1], digest + 4);
putu32(ctx->buf[2], digest + 8);
putu32(ctx->buf[3], digest + 12);
memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
}
#ifndef ASM_MD5
/* The four core functions - F1 is optimized somewhat */
/* #define F1(x, y, z) (x & y | ~x & z) */
#define F1(x, y, z) (z ^ (x & (y ^ z)))
#define F2(x, y, z) F1(z, x, y)
#define F3(x, y, z) (x ^ y ^ z)
#define F4(x, y, z) (y ^ (x | ~z))
/* This is the central step in the MD5 algorithm. */
#define MD5STEP(f, w, x, y, z, data, s) \
( w += f(x, y, z) + data, w &= 0xffffffff, w = w<<s | w>>(32-s), w += x )
/*
* The core of the MD5 algorithm, this alters an existing MD5 hash to
* reflect the addition of 16 longwords of new data. MD5Update blocks
* the data and converts bytes into longwords for this routine.
*/
void
ldap_MD5Transform( uint32 *buf, const unsigned char *inraw )
{
register uint32 a, b, c, d;
uint32 in[16];
int i;
for (i = 0; i < 16; ++i)
in[i] = getu32 (inraw + 4 * i);
a = buf[0];
b = buf[1];
c = buf[2];
d = buf[3];
MD5STEP(F1, a, b, c, d, in[ 0]+0xd76aa478, 7);
MD5STEP(F1, d, a, b, c, in[ 1]+0xe8c7b756, 12);
MD5STEP(F1, c, d, a, b, in[ 2]+0x242070db, 17);
MD5STEP(F1, b, c, d, a, in[ 3]+0xc1bdceee, 22);
MD5STEP(F1, a, b, c, d, in[ 4]+0xf57c0faf, 7);
MD5STEP(F1, d, a, b, c, in[ 5]+0x4787c62a, 12);
MD5STEP(F1, c, d, a, b, in[ 6]+0xa8304613, 17);
MD5STEP(F1, b, c, d, a, in[ 7]+0xfd469501, 22);
MD5STEP(F1, a, b, c, d, in[ 8]+0x698098d8, 7);
MD5STEP(F1, d, a, b, c, in[ 9]+0x8b44f7af, 12);
MD5STEP(F1, c, d, a, b, in[10]+0xffff5bb1, 17);
MD5STEP(F1, b, c, d, a, in[11]+0x895cd7be, 22);
MD5STEP(F1, a, b, c, d, in[12]+0x6b901122, 7);
MD5STEP(F1, d, a, b, c, in[13]+0xfd987193, 12);
MD5STEP(F1, c, d, a, b, in[14]+0xa679438e, 17);
MD5STEP(F1, b, c, d, a, in[15]+0x49b40821, 22);
MD5STEP(F2, a, b, c, d, in[ 1]+0xf61e2562, 5);
MD5STEP(F2, d, a, b, c, in[ 6]+0xc040b340, 9);
MD5STEP(F2, c, d, a, b, in[11]+0x265e5a51, 14);
MD5STEP(F2, b, c, d, a, in[ 0]+0xe9b6c7aa, 20);
MD5STEP(F2, a, b, c, d, in[ 5]+0xd62f105d, 5);
MD5STEP(F2, d, a, b, c, in[10]+0x02441453, 9);
MD5STEP(F2, c, d, a, b, in[15]+0xd8a1e681, 14);
MD5STEP(F2, b, c, d, a, in[ 4]+0xe7d3fbc8, 20);
MD5STEP(F2, a, b, c, d, in[ 9]+0x21e1cde6, 5);
MD5STEP(F2, d, a, b, c, in[14]+0xc33707d6, 9);
MD5STEP(F2, c, d, a, b, in[ 3]+0xf4d50d87, 14);
MD5STEP(F2, b, c, d, a, in[ 8]+0x455a14ed, 20);
MD5STEP(F2, a, b, c, d, in[13]+0xa9e3e905, 5);
MD5STEP(F2, d, a, b, c, in[ 2]+0xfcefa3f8, 9);
MD5STEP(F2, c, d, a, b, in[ 7]+0x676f02d9, 14);
MD5STEP(F2, b, c, d, a, in[12]+0x8d2a4c8a, 20);
MD5STEP(F3, a, b, c, d, in[ 5]+0xfffa3942, 4);
MD5STEP(F3, d, a, b, c, in[ 8]+0x8771f681, 11);
MD5STEP(F3, c, d, a, b, in[11]+0x6d9d6122, 16);
MD5STEP(F3, b, c, d, a, in[14]+0xfde5380c, 23);
MD5STEP(F3, a, b, c, d, in[ 1]+0xa4beea44, 4);
MD5STEP(F3, d, a, b, c, in[ 4]+0x4bdecfa9, 11);
MD5STEP(F3, c, d, a, b, in[ 7]+0xf6bb4b60, 16);
MD5STEP(F3, b, c, d, a, in[10]+0xbebfbc70, 23);
MD5STEP(F3, a, b, c, d, in[13]+0x289b7ec6, 4);
MD5STEP(F3, d, a, b, c, in[ 0]+0xeaa127fa, 11);
MD5STEP(F3, c, d, a, b, in[ 3]+0xd4ef3085, 16);
MD5STEP(F3, b, c, d, a, in[ 6]+0x04881d05, 23);
MD5STEP(F3, a, b, c, d, in[ 9]+0xd9d4d039, 4);
MD5STEP(F3, d, a, b, c, in[12]+0xe6db99e5, 11);
MD5STEP(F3, c, d, a, b, in[15]+0x1fa27cf8, 16);
MD5STEP(F3, b, c, d, a, in[ 2]+0xc4ac5665, 23);
MD5STEP(F4, a, b, c, d, in[ 0]+0xf4292244, 6);
MD5STEP(F4, d, a, b, c, in[ 7]+0x432aff97, 10);
MD5STEP(F4, c, d, a, b, in[14]+0xab9423a7, 15);
MD5STEP(F4, b, c, d, a, in[ 5]+0xfc93a039, 21);
MD5STEP(F4, a, b, c, d, in[12]+0x655b59c3, 6);
MD5STEP(F4, d, a, b, c, in[ 3]+0x8f0ccc92, 10);
MD5STEP(F4, c, d, a, b, in[10]+0xffeff47d, 15);
MD5STEP(F4, b, c, d, a, in[ 1]+0x85845dd1, 21);
MD5STEP(F4, a, b, c, d, in[ 8]+0x6fa87e4f, 6);
MD5STEP(F4, d, a, b, c, in[15]+0xfe2ce6e0, 10);
MD5STEP(F4, c, d, a, b, in[ 6]+0xa3014314, 15);
MD5STEP(F4, b, c, d, a, in[13]+0x4e0811a1, 21);
MD5STEP(F4, a, b, c, d, in[ 4]+0xf7537e82, 6);
MD5STEP(F4, d, a, b, c, in[11]+0xbd3af235, 10);
MD5STEP(F4, c, d, a, b, in[ 2]+0x2ad7d2bb, 15);
MD5STEP(F4, b, c, d, a, in[ 9]+0xeb86d391, 21);
buf[0] += a;
buf[1] += b;
buf[2] += c;
buf[3] += d;
}
#endif
#ifdef TEST
/* Simple test program. Can use it to manually run the tests from
RFC1321 for example. */
#include <stdio.h>
int
main (int argc, char **argv )
{
struct ldap_MD5Context context;
unsigned char checksum[16];
int i;
int j;
if (argc < 2)
{
fprintf (stderr, "usage: %s string-to-hash\n", argv[0]);
exit (1);
}
for (j = 1; j < argc; ++j)
{
printf ("MD5 (\"%s\") = ", argv[j]);
ldap_MD5Init (&context);
ldap_MD5Update (&context, argv[j], strlen (argv[j]));
ldap_MD5Final (checksum, &context);
for (i = 0; i < 16; i++)
{
printf ("%02x", (unsigned int) checksum[i]);
}
printf ("\n");
}
return 0;
}
#endif /* TEST */

View file

@ -2,6 +2,7 @@
#ifndef HAVE_SETPROCTITLE
#include <stdio.h>
#include <stdlib.h>
#include <ac/string.h>

276
libraries/liblutil/sha1.c Normal file
View file

@ -0,0 +1,276 @@
/* Acquired from:
* $OpenBSD: sha1.c,v 1.9 1997/07/23 21:12:32 kstailey Exp $ */
/*
* SHA-1 in C
* By Steve Reid <steve@edmweb.com>
* 100% Public Domain
*
* Test Vectors (from FIPS PUB 180-1)
* "abc"
* A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
* "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
* 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
* A million repetitions of "a"
* 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
*/
#include "portable.h"
#include <ac/string.h>
/* include socket.h to get sys/types.h and/or winsock2.h */
#include <ac/socket.h>
#if defined(HAVE_SYS_PARAM_H)
#include <sys/param.h>
#endif
#include "lutil_sha1.h"
#define SHA1HANDSOFF /* Copies data before messing with it. */
#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
/*
* blk0() and blk() perform the initial expand.
* I got the idea of expanding during the round function from SSLeay
*/
#if BYTE_ORDER == LITTLE_ENDIAN
# define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
|(rol(block->l[i],8)&0x00FF00FF))
#else
# define blk0(i) block->l[i]
#endif
#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
^block->l[(i+2)&15]^block->l[i&15],1))
/*
* (R0+R1), R2, R3, R4 are the different operations (rounds) used in SHA1
*/
#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
/*
* Hash a single 512-bit block. This is the core of the algorithm.
*/
void
ldap_SHA1Transform( uint32 *state, const unsigned char *buffer )
{
uint32 a, b, c, d, e;
typedef union {
unsigned char c[64];
u_int l[16];
} CHAR64LONG16;
CHAR64LONG16 *block;
#ifdef SHA1HANDSOFF
CHAR64LONG16 workspace;
block = &workspace;
(void)memcpy(block, buffer, 64);
#else
block = (CHAR64LONG16 *)buffer;
#endif
/* Copy context->state[] to working vars */
a = state[0];
b = state[1];
c = state[2];
d = state[3];
e = state[4];
/* 4 rounds of 20 operations each. Loop unrolled. */
R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
/* Add the working vars back into context.state[] */
state[0] += a;
state[1] += b;
state[2] += c;
state[3] += d;
state[4] += e;
/* Wipe variables */
a = b = c = d = e = 0;
}
/*
* ldap_SHA1Init - Initialize new context
*/
void
ldap_SHA1Init( ldap_SHA1_CTX *context )
{
/* SHA1 initialization constants */
context->state[0] = 0x67452301;
context->state[1] = 0xEFCDAB89;
context->state[2] = 0x98BADCFE;
context->state[3] = 0x10325476;
context->state[4] = 0xC3D2E1F0;
context->count[0] = context->count[1] = 0;
}
/*
* Run your data through this.
*/
void
ldap_SHA1Update(
ldap_SHA1_CTX *context,
const unsigned char *data,
u_int len
)
{
u_int i, j;
j = context->count[0];
if ((context->count[0] += len << 3) < j)
context->count[1] += (len>>29)+1;
j = (j >> 3) & 63;
if ((j + len) > 63) {
(void)memcpy(&context->buffer[j], data, (i = 64-j));
ldap_SHA1Transform(context->state, context->buffer);
for ( ; i + 63 < len; i += 64)
ldap_SHA1Transform(context->state, &data[i]);
j = 0;
} else {
i = 0;
}
(void)memcpy(&context->buffer[j], &data[i], len - i);
}
/*
* Add padding and return the message digest.
*/
void
ldap_SHA1Final( unsigned char *digest, ldap_SHA1_CTX *context )
{
u_int i;
unsigned char finalcount[8];
for (i = 0; i < 8; i++) {
finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)]
>> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */
}
ldap_SHA1Update(context, (unsigned char *)"\200", 1);
while ((context->count[0] & 504) != 448)
ldap_SHA1Update(context, (unsigned char *)"\0", 1);
ldap_SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */
if (digest) {
for (i = 0; i < 20; i++)
digest[i] = (unsigned char)
((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
}
}
/* sha1hl.c
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <phk@login.dkuug.dk> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
* ----------------------------------------------------------------------------
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char rcsid[] = "$OpenBSD: sha1hl.c,v 1.1 1997/07/12 20:06:03 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <stdio.h>
#include <stdlib.h>
#include <ac/errno.h>
#include <ac/unistd.h>
#ifdef HAVE_SYS_FILE_H
#include <sys/file.h>
#endif
#ifdef HAVE_SYS_UIO_H
#include <sys/uio.h>
#endif
#ifdef HAVE_IO_H
#include <io.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
/* ARGSUSED */
char *
ldap_SHA1End( ldap_SHA1_CTX *ctx, char *buf )
{
int i;
char *p = buf;
unsigned char digest[20];
static const char hex[]="0123456789abcdef";
if (p == NULL && (p = malloc(41)) == NULL)
return 0;
ldap_SHA1Final(digest,ctx);
for (i = 0; i < 20; i++) {
p[i + i] = hex[digest[i] >> 4];
p[i + i + 1] = hex[digest[i] & 0x0f];
}
p[i + i] = '\0';
return(p);
}
char *
ldap_SHA1File( char *filename, char *buf )
{
unsigned char buffer[BUFSIZ];
ldap_SHA1_CTX ctx;
int fd, num, oerrno;
ldap_SHA1Init(&ctx);
if ((fd = open(filename,O_RDONLY)) < 0)
return(0);
while ((num = read(fd, buffer, sizeof(buffer))) > 0)
ldap_SHA1Update(&ctx, buffer, num);
oerrno = errno;
close(fd);
errno = oerrno;
return(num < 0 ? 0 : ldap_SHA1End(&ctx, buf));
}
char *
ldap_SHA1Data( const unsigned char *data, size_t len, char *buf )
{
ldap_SHA1_CTX ctx;
ldap_SHA1Init(&ctx);
ldap_SHA1Update(&ctx, data, len);
return(ldap_SHA1End(&ctx, buf));
}

View file

@ -0,0 +1,21 @@
#include "portable.h"
#ifndef HAVE_STRDUP
#include <stdlib.h>
#include <ac/string.h>
#include "lutil.h"
char *strdup( const char *s )
{
char *p;
if ( (p = (char *) malloc( strlen( s ) + 1 )) == NULL )
return( (char *)0 );
strcpy( p, s );
return( p );
}
#endif /* !strdup */

View file

@ -0,0 +1,44 @@
#include "portable.h"
#ifndef HAVE_TEMPNAM
#include <stdio.h>
#include <stdlib.h>
#include <ac/string.h>
#include <ac/unistd.h>
#include "lutil.h"
char *
tempnam( const char *dir, const char *pfx )
{
char *s;
if ( dir == NULL ) {
dir = "/tmp";
}
/*
* allocate space for dir + '/' + pfx (up to 5 chars) + 6 trailing 'X's + 0 byte
*/
if (( s = (char *)malloc( strlen( dir ) + 14 )) == NULL ) {
return( NULL );
}
strcpy( s, dir );
strcat( s, "/" );
if ( pfx != NULL ) {
strcat( s, pfx );
}
strcat( s, "XXXXXX" );
mktemp( s );
if ( *s == '\0' ) {
free( s );
s = NULL;
}
return( s );
}
#endif /* TEMPNAM */

View file

@ -10,21 +10,23 @@
* is provided ``as is'' without express or implied warranty.
*/
#include "portable.h"
#include <stdio.h>
#include <ac/socket.h>
#include <quipu/commonarg.h>
#include <quipu/attrvalue.h>
#include <quipu/ds_error.h>
#include <quipu/add.h>
#include <quipu/dap2.h>
#include <quipu/dua.h>
#include <sys/types.h>
#include <sys/socket.h>
#include "lber.h"
#include "ldap.h"
#include "common.h"
#ifdef COMPAT20
extern int ldap_compat;
#ifdef LDAP_COMPAT20
#define ADDTAG (ldap_compat == 20 ? OLD_LDAP_RES_ADD : LDAP_RES_ADD)
#else
#define ADDTAG LDAP_RES_ADD
@ -44,7 +46,6 @@ do_add(
unsigned long tag, len;
struct ds_addentry_arg aa;
static CommonArgs common = default_common_args;
extern DN ldap_str2dn();
Debug( LDAP_DEBUG_TRACE, "do_add\n", 0, 0, 0 );
@ -87,7 +88,7 @@ do_add(
aa.ada_entry = NULLATTR;
for ( tag = ber_first_element( ber, &len, &last ); tag != LBER_DEFAULT;
tag = ber_next_element( ber, &len, last ) ) {
Attr_Sequence as, get_as();
Attr_Sequence as;
if ( ber_scanf( ber, "{a{V}}", &type, &bvals ) == LBER_ERROR )
break;

View file

@ -21,14 +21,15 @@
#include <quipu/commonarg.h>
#include <quipu/ds_error.h>
#include "lber.h"
#include "ldap.h"
#include <quipu/dap.h> /* get dap_unbind() */
#if ISODEPACKAGE == IC
#include <ll/isoaddrs.h>
#else
#include <isoaddrs.h>
#endif
#include "lber.h"
#include "ldap.h"
#include "common.h"
#ifdef HAVE_SYS_IOCTL_H
@ -44,11 +45,10 @@
struct conn *conns;
struct conn *conn_dup( struct conn *cn )
struct conn *
conn_dup( struct conn *cn )
{
struct conn *new;
struct PSAPaddr *psap_cpy();
if ( (new = (struct conn *) malloc( sizeof(struct conn) )) == NULL )
return( NULL );
@ -70,10 +70,9 @@ struct conn *conn_dup( struct conn *cn )
}
int
conn_init()
conn_init( void )
{
extern char *dsa_address;
struct PSAPaddr *addr, *psap_cpy();
struct PSAPaddr *addr;
if ( (conns = (struct conn *) malloc( sizeof(struct conn) )) == NULL ) {
Debug( LDAP_DEBUG_ANY, "conn_init: malloc failed\n", 0, 0, 0 );
@ -104,7 +103,6 @@ void
conn_free( struct conn *conn )
{
struct timeval tv;
extern int referral_connection_timeout;
Debug( LDAP_DEBUG_TRACE, "conn_free (%s): refcnt is %d\n",
paddr2str( conn->c_paddr, NULLNA ), conn->c_refcnt, 0 );
@ -173,7 +171,7 @@ conn_setfds( fd_set *fds )
}
void
conn_badfds()
conn_badfds( void )
{
struct conn *tmp;
@ -186,7 +184,8 @@ conn_badfds()
}
}
struct conn *conn_getfd( fd_set *fds )
struct conn *
conn_getfd( fd_set *fds )
{
struct conn *tmp;
@ -226,7 +225,8 @@ psap_cmp( struct PSAPaddr *a, struct PSAPaddr *b )
return( bcmp( (char *) a, (char *) b, sizeof(struct PSAPaddr) ) );
}
struct conn *conn_find( struct conn *c )
struct conn *
conn_find( struct conn *c )
{
struct conn *tmp;
@ -263,7 +263,7 @@ struct conn *conn_find( struct conn *c )
}
void
conn_close()
conn_close( void )
{
struct conn *tmp;
@ -277,7 +277,6 @@ int
isclosed( int ad )
{
int o;
extern int errno;
if ( ioctl( ad, FIOGETOWN, &o ) < 0 )
return( errno == EBADF ? 1 : 0 );

View file

@ -28,7 +28,6 @@
#include "common.h"
#ifdef LDAP_COMPAT20
extern int ldap_compat;
#define BINDTAG (ldap_compat == 20 ? OLD_LDAP_RES_BIND : LDAP_RES_BIND)
#else
#define BINDTAG LDAP_RES_BIND
@ -53,9 +52,7 @@ do_bind(
unsigned long len;
char *dn, *pw;
char *matched;
struct PSAPaddr *addr, *psap_cpy();
extern char *dsa_address;
extern int version;
struct PSAPaddr *addr;
Debug( LDAP_DEBUG_TRACE, "do_bind\n", 0, 0, 0 );
@ -99,7 +96,7 @@ do_bind(
return( 0 );
}
Debug( LDAP_DEBUG_ARGS, "do_bind: version %d dn (%s) method %d\n",
Debug( LDAP_DEBUG_ARGS, "do_bind: version %d dn (%s) method %lu\n",
version, dn, method );
if ( m->m_conn->c_paddr == NULLPA ) {
@ -147,8 +144,6 @@ do_bind_real(
#ifdef HAVE_KERBEROS
u_long nonce;
#endif
extern DN ldap_str2dn();
Debug( LDAP_DEBUG_TRACE, "do_bind_real\n", 0, 0, 0 );
*matched = NULL;

View file

@ -17,12 +17,15 @@
#include <quipu/ds_search.h>
#include <quipu/dap2.h>
#include <quipu/dua.h>
extern sntx_table *get_syntax_table( short int sntx );
extern PE asn2pe( char * );
#include "lber.h"
#include "ldap.h"
#include "common.h"
int ldap_certif_print( PS ps, struct certificate *parm, int format )
int
ldap_certif_print( PS ps, struct certificate *parm, int format )
{
Debug( LDAP_DEBUG_TRACE, "ldap_certif_print()\n", 0, 0, 0 );
@ -114,7 +117,8 @@ ldap_print_algid( PS ps, struct alg_id *parm, int format )
}
}
struct certificate *ldap_str2cert( char *str )
struct certificate *
ldap_str2cert( char *str )
{
struct certificate *result;
char *ptr;
@ -280,8 +284,6 @@ OID oid;
void
ldap_str2alg( char *str, struct alg_id *alg )
{
PE asn2pe();
if ((str == NULLCP) || (*str == '\0'))
{
alg->asn = NULLPE;
@ -305,11 +307,10 @@ PE asn2pe();
}
}
void certif_init()
void
certif_init( void )
{
extern short ldap_certif_syntax;
sntx_table *syntax_table;
extern sntx_table *get_syntax_table( short int sntx );
if ((syntax_table = get_syntax_table(ldap_certif_syntax)) != NULL) {
syntax_table->s_print = (void *) ldap_certif_print;

View file

@ -10,6 +10,9 @@
* is provided ``as is'' without express or implied warranty.
*/
#ifndef _LDAPD_COMMON_H
#define _LDAPD_COMMON_H 1
/*
* This structure represents an association to a dsa. There is one of
* these for each association open (a new association is made for each
@ -41,32 +44,77 @@ struct msg {
LDAPMod *m_mods; /* for modify operations only */
BerElement *m_ber; /* the unparsed ber for the op */
struct conn *m_conn; /* connection structure */
#ifdef CLDAP
#ifdef LDAP_CONNECTIONLESS
int m_cldap; /* connectionless transport? (CLDAP) */
struct sockaddr m_clientaddr; /* client address (if using CLDAP) */
DN m_searchbase; /* base used in search */
#endif /* CLDAP */
#endif /* LDAP_CONNECTIONLESS */
struct msg *m_next;
};
#define DEFAULT_TIMEOUT 3600 /* idle client connections */
#define DEFAULT_REFERRAL_TIMEOUT 900 /* DSA connections */
#ifdef NEEDPROTOS
#include "proto-ldapd.h"
#else
extern struct msg *add_msg();
extern struct msg *get_msg();
extern struct msg *get_cldap_msg();
extern int del_msg();
extern struct conn *conn_getfd();
extern struct conn *conn_find();
extern struct conn *conn_dup();
extern void conn_del();
/* from ISODE */
extern char *dsa_address;
extern char *bound_dn, *bound_pw;
struct PSAPaddr *psap_cpy(struct PSAPaddr *);
extern AttributeValue ldap_str2AttrV();
extern DN ldap_str2dn();
extern void ldap_str2alg();
extern void ldap_print_algid();
#endif /* don't need protos */
/* in association.c */
extern struct conn *conns;
/* in main.c */
#ifdef LDAP_DEBUG
extern int ldap_debug;
#endif
extern int version;
#ifdef LDAP_COMPAT
extern int ldap_compat;
#endif
extern int dosyslog;
extern int do_tcp;
#ifdef LDAP_CONNECTIONLESS
extern int do_udp;
#endif
extern int idletime;
extern int referral_connection_timeout;
extern struct timeval conn_start_tv;
#ifdef HAVE_KERBEROS
extern char *krb_ldap_service;
extern char *krb_x500_service;
extern char *krb_x500_instance;
extern char *krb_x500_nonce;
extern char *kerberos_keyfile;
#endif
/* syntax.c */
extern short ldap_photo_syntax;
extern short ldap_jpeg_syntax;
extern short ldap_jpeg_nonfile_syntax;
extern short ldap_audio_syntax;
extern short ldap_dn_syntax;
extern short ldap_postaladdress_syntax;
extern short ldap_acl_syntax;
extern short ldap_mtai_syntax;
extern short ldap_rts_cred_syntax;
extern short ldap_rtl_syntax;
extern short ldap_mailbox_syntax;
extern short ldap_caseignorelist_syntax;
extern short ldap_caseexactstring_syntax;
extern short ldap_certif_syntax;
extern short ldap_iattr_syntax;
extern short ldap_telex_syntax;
extern short ldap_octetstring_syntax;
extern short ldap_deliverymethod_syntax;
extern short ldap_facsimileTelephoneNumber_syntax;
extern short ldap_presentationAddress_syntax;
extern short ldap_teletexTerminalIdentifier_syntax;
extern short ldap_searchGuide_syntax;
extern short ldap_dLSubmitPermission_syntax;
/* Version.c */
extern char Versionstr[];
#endif

View file

@ -10,21 +10,24 @@
* is provided ``as is'' without express or implied warranty.
*/
#include "portable.h"
#include <stdio.h>
#include <ac/socket.h>
#include <quipu/commonarg.h>
#include <quipu/attrvalue.h>
#include <quipu/ds_error.h>
#include <quipu/compare.h>
#include <quipu/dap2.h>
#include <quipu/dua.h>
#include <sys/types.h>
#include <sys/socket.h>
#include "lber.h"
#include "ldap.h"
#include "common.h"
#ifdef COMPAT20
extern int ldap_compat;
#ifdef HAVE_COMPAT20
#define COMPTAG (ldap_compat == 20 ? OLD_LDAP_RES_COMPARE : LDAP_RES_COMPARE)
#else
#define COMPTAG LDAP_RES_COMPARE
@ -42,7 +45,6 @@ do_compare(
struct ds_compare_arg ca;
AttributeType type;
static CommonArgs common = default_common_args;
extern short ldap_dn_syntax;
Debug( LDAP_DEBUG_TRACE, "do_compare\n", 0, 0, 0 );

View file

@ -30,7 +30,6 @@
#include "common.h"
#ifdef HAVE_COMPAT20
extern int ldap_compat;
#define DELTAG (ldap_compat == 20 ? OLD_LDAP_RES_DELETE : LDAP_RES_DELETE)
#else
#define DELTAG LDAP_RES_DELETE
@ -54,7 +53,6 @@ do_delete(
int rc;
struct ds_removeentry_arg ra;
static CommonArgs common = default_common_args;
extern DN ldap_str2dn();
Debug( LDAP_DEBUG_TRACE, "do_delete\n", 0, 0, 0 );

View file

@ -1,90 +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 <stdio.h>
#include <sys/types.h>
#ifdef SVR4
#include <sys/stat.h>
#endif /* svr4 */
#include <fcntl.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <signal.h>
#include "portable.h"
#ifdef USE_SYSCONF
#include <unistd.h>
#endif /* USE_SYSCONF */
detach()
{
int i, sd, nbits;
#ifdef LDAP_DEBUG
extern int ldap_debug;
#endif
#ifdef USE_SYSCONF
nbits = sysconf( _SC_OPEN_MAX );
#else /* USE_SYSCONF */
nbits = getdtablesize();
#endif /* USE_SYSCONF */
#ifdef LDAP_DEBUG
if ( ldap_debug == 0 ) {
#endif
for ( i = 0; i < 5; i++ ) {
switch ( fork() ) {
case -1:
sleep( 5 );
continue;
case 0:
break;
default:
_exit( 0 );
}
break;
}
for ( i = 3; i < nbits; i++ )
close( i );
(void) chdir( "/" );
if ( (sd = open( "/dev/null", O_RDWR )) == -1 ) {
perror( "/dev/null" );
exit( 1 );
}
if ( isatty( 0 ) )
(void) dup2( sd, 0 );
if ( isatty( 1 ) )
(void) dup2( sd, 1 );
if ( isatty(2) )
(void) dup2( sd, 2 );
close( sd );
#ifdef USE_SETSID
setsid();
#else /* USE_SETSID */
if ( (sd = open( "/dev/tty", O_RDWR )) != -1 ) {
(void) ioctl( sd, TIOCNOTTY, NULL );
(void) close( sd );
}
#endif /* USE_SETSID */
#ifdef LDAP_DEBUG
}
#endif
(void) signal( SIGPIPE, SIG_IGN );
}

View file

@ -10,17 +10,23 @@
* is provided ``as is'' without express or implied warranty.
*/
#include "portable.h"
#include <stdio.h>
#include <ac/ctype.h>
#include <ac/socket.h>
#include <quipu/ds_error.h>
#include <quipu/attrvalue.h>
#include <quipu/name.h>
#include <quipu/commonarg.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <ctype.h>
#include "lber.h"
#include "ldap.h"
#include "common.h" /* get ldap_dn_print() */
void
print_error( struct DSError *e )
{

View file

@ -10,20 +10,22 @@
* is provided ``as is'' without express or implied warranty.
*/
#ifdef KERBEROS
#include "portable.h"
#ifdef HAVE_KERBEROS
#include <stdio.h>
#include <sys/types.h>
#include "krb.h"
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include <ac/krb.h>
#include <ac/socket.h>
#include <quipu/bind.h>
#if ISODEPACKAGE == IC
#include <quipu/DAS-types.h>
#else
#include <pepsy/DAS-types.h>
#endif
#include "lber.h"
#include "ldap.h"
#include "common.h"
@ -36,8 +38,6 @@ kerberosv4_ldap_auth( char *cred, long len )
char instance[INST_SZ];
int err;
AUTH_DAT ad;
extern char *krb_ldap_service;
extern char *kerberos_keyfile;
Debug( LDAP_DEBUG_TRACE, "kerberosv4_ldap_auth\n", 0, 0, 0 );
@ -70,8 +70,6 @@ kerberosv4_bindarg(
struct timeval tv;
char realm[REALM_SZ];
int err;
extern char *krb_x500_service;
extern char *krb_x500_instance;
Debug( LDAP_DEBUG_TRACE, "kerberosv4_bindarg\n", 0, 0, 0 );

View file

@ -48,12 +48,11 @@ int allow_severity = LOG_INFO;
int deny_severity = LOG_NOTICE;
#endif /* TCP_WRAPPERS */
void log_and_exit();
static int set_socket();
static void do_queries();
static RETSIGTYPE wait4child();
static int set_socket( int port, int udp );
static void do_queries( int clientsock, int udp );
static RETSIGTYPE wait4child( int sig );
#ifdef LDAP_CONNECTIONLESS
static int udp_init();
static int udp_init( int port, int createsocket );
#endif
#ifdef LDAP_DEBUG
@ -82,8 +81,6 @@ char *kerberos_keyfile;
int dtblsize;
int RunFromInetd = 0;
extern char Versionstr[];
static void
usage( char *name )
{
@ -101,9 +98,7 @@ usage( char *name )
}
int
main (argc, argv)
int argc;
char **argv;
main( int argc, char **argv )
{
int tcps, ns;
#ifdef LDAP_CONNECTIONLESS
@ -118,12 +113,9 @@ char **argv;
int len;
int dsapargc;
char **dsapargv;
RETSIGTYPE wait4child();
#ifdef LDAP_PROCTITLE
char title[80];
#endif
extern char *optarg;
extern int optind;
#ifdef VMS
/* Pick up socket from inetd-type server on VMS */
@ -274,8 +266,8 @@ char **argv;
lutil_detach( 0, 1 );
# endif
#endif
(void) SIGNAL( SIGCHLD, (void *) wait4child );
(void) SIGNAL( SIGINT, (void *) log_and_exit );
(void) SIGNAL( SIGCHLD, wait4child );
(void) SIGNAL( SIGINT, log_and_exit );
}
/*
@ -449,7 +441,7 @@ char **argv;
hp->h_name );
#endif
gettimeofday( &conn_start_tv, (struct timezone *) NULL );
(void) SIGNAL( SIGPIPE, (void *) log_and_exit );
(void) SIGNAL( SIGPIPE, log_and_exit );
do_queries( ns, 0 );
/* NOT REACHED */
@ -465,7 +457,7 @@ char **argv;
setproctitle( title );
#endif
gettimeofday( &conn_start_tv, (struct timezone *) NULL );
(void) SIGNAL( SIGPIPE, (void *) log_and_exit );
(void) SIGNAL( SIGPIPE, log_and_exit );
do_queries( ns, 0 );
break;
@ -538,7 +530,6 @@ do_queries(
timeout.tv_usec = 0;
for ( ;; ) {
struct conn *dsaconn;
extern struct conn *conns;
FD_ZERO( &readfds );
FD_SET( clientsock, &readfds );
@ -651,7 +642,8 @@ set_socket(
return( s );
}
static RETSIGTYPE wait4child()
static RETSIGTYPE
wait4child( int sig )
{
#ifndef HAVE_WAITPID
WAITSTATUSTYPE status;
@ -667,11 +659,11 @@ static RETSIGTYPE wait4child()
; /* NULL */
#endif
(void) SIGNAL( SIGCHLD, (void *) wait4child );
(void) SIGNAL( SIGCHLD, wait4child );
}
void
RETSIGTYPE
log_and_exit( int exitcode )
{
struct timeval tv;
@ -699,9 +691,6 @@ udp_init(
{
int s, bound;
char *matched;
extern char *dsa_address;
extern struct PSAPaddr *psap_cpy();
extern struct conn *conns;
if ( createsocket )
s = set_socket( port, 1 );

View file

@ -24,6 +24,7 @@
#include <quipu/modify.h>
#include <quipu/dap2.h>
#include <quipu/dua.h>
extern IFP merge_acl;
#include "lber.h"
#include "ldap.h"
@ -31,22 +32,9 @@
static CommonArgs common = default_common_args;
extern short ldap_photo_syntax;
extern short ldap_jpeg_syntax;
extern short ldap_jpeg_nonfile_syntax;
extern short ldap_audio_syntax;
extern short ldap_dn_syntax;
extern short ldap_postaladdress_syntax;
extern short ldap_acl_syntax;
extern short ldap_mtai_syntax;
extern short ldap_rts_cred_syntax;
extern short ldap_rtl_syntax;
extern short ldap_octetstring_syntax;
static int replace_mod( struct entrymod *, Attr_Sequence, Attr_Sequence );
#ifdef LDAP_COMPAT20
extern int ldap_compat;
#define MODTAG (ldap_compat == 20 ? OLD_LDAP_RES_MODIFY : LDAP_RES_MODIFY)
#else
#define MODTAG LDAP_RES_MODIFY
@ -65,7 +53,6 @@ do_modify(
unsigned long tag, len;
LDAPMod *mods, *modtail;
struct ds_read_arg ra;
extern DN ldap_str2dn();
Debug( LDAP_DEBUG_TRACE, "do_modify\n", 0, 0, 0 );
@ -183,7 +170,7 @@ do_modify2(
ma.mea_changes = NULLMOD;
for ( mods = m->m_mods; mods != NULL; mods = mods->mod_next ) {
struct entrymod *em;
Attr_Sequence as, new, get_as();
Attr_Sequence as, new;
if ( (em = (struct entrymod *) calloc( 1,
sizeof(struct entrymod) )) == NULLMOD ) {
@ -401,9 +388,6 @@ get_as(
AttributeValue av;
int t61str, ncomp;
char *sval, *s, *news, *n;
extern IFP merge_acl;
extern AttributeValue bv_asn2AttrV(), ldap_strdn2AttrV();
extern AttributeValue ldap_str_at2AttrV(), bv_octet2AttrV();
if ( syntax == ldap_jpeg_syntax ||
syntax == ldap_jpeg_nonfile_syntax ||

View file

@ -10,21 +10,24 @@
* is provided ``as is'' without express or implied warranty.
*/
#include "portable.h"
#include <stdio.h>
#include <ac/socket.h>
#include <quipu/commonarg.h>
#include <quipu/attrvalue.h>
#include <quipu/ds_error.h>
#include <quipu/modifyrdn.h>
#include <quipu/dap2.h>
#include <quipu/dua.h>
#include <sys/types.h>
#include <sys/socket.h>
#include "lber.h"
#include "ldap.h"
#include "common.h"
#ifdef COMPAT20
extern int ldap_compat;
#ifdef LDAP_COMPAT20
#define MODRDNTAG (ldap_compat == 20 ? OLD_LDAP_RES_MODRDN : LDAP_RES_MODRDN)
#else
#define MODRDNTAG LDAP_RES_MODRDN
@ -41,8 +44,6 @@ do_modrdn(
int rc, deleteoldrdn;
struct ds_modifyrdn_arg ma;
static CommonArgs common = default_common_args;
extern DN ldap_str2dn();
extern RDN ldap_str2rdn();
Debug( LDAP_DEBUG_TRACE, "do_modrdn\n", 0, 0, 0 );

View file

@ -1,158 +1,181 @@
#ifndef _PROTO_LDAPD
#define _PROTO_LDAPD
#ifndef _PROTO_LDAPD_H
#define _PROTO_LDAPD_H
#include <ldap_cdefs.h>
/*
* abandon.c
*/
int do_abandon( struct conn *dsaconn, BerElement *ber, int msgid );
int do_abandon LDAP_P(( struct conn *dsaconn, BerElement *ber, int msgid ));
/*
* add.c
*/
int do_add( Sockbuf *clientsb, struct msg *m, BerElement *ber );
int do_add LDAP_P(( Sockbuf *clientsb, struct msg *m, BerElement *ber ));
void add_result LDAP_P(( Sockbuf *sb, struct msg *m ));
/*
* association.c
*/
struct conn *conn_dup( struct conn *cn );
int conn_init();
void conn_free( struct conn *conn );
void conn_del( struct conn *conn );
void conn_badfds();
struct conn *conn_getfd( fd_set *fds );
void conn_add( struct conn *new );
struct conn *conn_find( struct conn *c );
void conn_add( struct conn *new );
void conn_close();
int isclosed( int ad );
struct conn *conn_dup LDAP_P(( struct conn *cn ));
int conn_init LDAP_P(( void ));
void conn_free LDAP_P(( struct conn *conn ));
void conn_del LDAP_P(( struct conn *conn ));
void conn_setfds LDAP_P(( fd_set *fds ));
void conn_badfds LDAP_P(( void ));
struct conn *conn_getfd LDAP_P(( fd_set *fds ));
void conn_add LDAP_P(( struct conn *new ));
struct conn *conn_find LDAP_P(( struct conn *c ));
void conn_close LDAP_P(( void ));
int isclosed LDAP_P(( int ad ));
/*
* bind.c
*/
int do_bind( Sockbuf *clientsb, struct msg *m, BerElement *ber, int *bound );
int do_bind_real( struct conn *dsaconn, int *bound, char **matched );
int do_bind LDAP_P(( Sockbuf *clientsb, struct msg *m, BerElement *ber, int *bound ));
int do_bind_real LDAP_P(( struct conn *dsaconn, int *bound, char **matched ));
/*
* certificate.c
*/
int ldap_certif_print( PS ps, struct certificate *parm, int format );
void ldap_print_algid( PS ps, struct alg_id *parm, int format );
struct certificate *ldap_str2cert( char *str );
void ldap_str2alg( char *str, struct alg_id *alg );
void certif_init();
int ldap_certif_print LDAP_P(( PS ps, struct certificate *parm, int format ));
void ldap_print_algid LDAP_P(( PS ps, struct alg_id *parm, int format ));
struct certificate *ldap_str2cert LDAP_P(( char *str ));
void ldap_str2alg LDAP_P(( char *str, struct alg_id *alg ));
void certif_init LDAP_P(( void ));
/*
* compare.c
*/
int do_compare( Sockbuf *clientsb, struct msg *m, BerElement *ber );
struct ds_compare_result;
int do_compare LDAP_P(( Sockbuf *clientsb, struct msg *m, BerElement *ber ));
void compare_result LDAP_P(( Sockbuf *sb, struct msg *m,
struct ds_compare_result *cr ));
/*
* delete.c
*/
int do_delete( Sockbuf *clientsb, struct msg *m, BerElement *ber );
int do_delete LDAP_P(( Sockbuf *clientsb, struct msg *m, BerElement *ber ));
void delete_result LDAP_P(( Sockbuf *sb, struct msg *m ));
/*
* error.c
*/
void print_error( struct DSError *e );
int x500err2ldaperr( struct DSError *e, char **matched );
void print_error LDAP_P(( struct DSError *e ));
int x500err2ldaperr LDAP_P(( struct DSError *e, char **matched ));
/*
* kerberos.c
*/
int kerberosv4_ldap_auth( char *cred, long len );
struct ds_bind_arg;
int kerberosv4_ldap_auth LDAP_P(( char *cred, long len ));
int kerberosv4_bindarg LDAP_P(( struct ds_bind_arg *ba, DN dn, char *cred,
long len, u_long *nonce ));
int kerberos_check_mutual LDAP_P(( struct ds_bind_arg *res, u_long nonce ));
/*
* main.c
*/
void log_and_exit( int exitcode );
RETSIGTYPE log_and_exit LDAP_P(( int exitcode ));
/*
* message.c
*/
struct msg *add_msg( int msgid, int msgtype, BerElement *ber,
struct conn *dsaconn, int udp, struct sockaddr *clientaddr );
struct msg *get_msg( int uniqid );
int del_msg( struct msg *m );
void send_msg( struct conn *conn, Sockbuf *clientsb, int err, char *str );
struct msg * get_cldap_msg( int msgid, int msgtype, struct sockaddr *fromaddr );
struct msg *add_msg LDAP_P(( int msgid, int msgtype, BerElement *ber,
struct conn *dsaconn, int udp, struct sockaddr *clientaddr ));
struct msg *get_msg LDAP_P(( int uniqid ));
int del_msg LDAP_P(( struct msg *m ));
void send_msg LDAP_P(( struct conn *conn, Sockbuf *clientsb, int err, char *str ));
struct msg * get_cldap_msg LDAP_P(( int msgid, int msgtype, struct sockaddr *fromaddr ));
/*
* modify.c
*/
int do_modify( Sockbuf *clientsb, struct msg *m, BerElement *ber );
Attr_Sequence get_as( Sockbuf *clientsb, unsigned long op, struct msg *m,
char *type, struct berval **bvals );
void modlist_free( LDAPMod *mods );
struct ds_read_result;
int do_modify LDAP_P(( Sockbuf *clientsb, struct msg *m, BerElement *ber ));
int do_modify2 LDAP_P((Sockbuf *sb, struct msg *m, struct ds_read_result *rr));
Attr_Sequence get_as LDAP_P(( Sockbuf *clientsb, unsigned long op, struct msg *m,
char *type, struct berval **bvals ));
void modify_result LDAP_P(( Sockbuf *sb, struct msg *m ));
void modlist_free LDAP_P(( LDAPMod *mods ));
/*
* modrdn.c
*/
int do_modrdn( Sockbuf *clientsb, struct msg *m, BerElement *ber );
int do_modrdn LDAP_P(( Sockbuf *clientsb, struct msg *m, BerElement *ber ));
void modrdn_result LDAP_P((Sockbuf *sb, struct msg *m));
/*
* request.c
*/
void client_request( Sockbuf *clientsb, struct conn *dsaconn, int udp );
int do_request( Sockbuf *clientsb, struct msg *m, BerElement *ber,
int *bound );
int initiate_dap_operation( int op, struct msg *m, void *arg );
void client_request LDAP_P(( Sockbuf *clientsb, struct conn *dsaconn, int udp ));
int do_request LDAP_P(( Sockbuf *clientsb, struct msg *m, BerElement *ber,
int *bound ));
int initiate_dap_operation LDAP_P(( int op, struct msg *m, void *arg ));
#ifdef LDAP_DEBUG
int trace_ber LDAP_P(( int tag, int len, char *ber,
FILE *trace_file, int prepend, int read_pdu ));
#endif
/*
* result.c
*/
void dsa_response( struct conn *dsaconn, Sockbuf *clientsb );
int send_ldap_msgresult( Sockbuf *sb, unsigned long tag, struct msg *m,
int err, char *matched, char *text );
int send_ldap_result( Sockbuf *sb, unsigned long tag, int msgid, int err,
char *matched, char *text );
void dsa_response LDAP_P(( struct conn *dsaconn, Sockbuf *clientsb ));
int send_ldap_msgresult LDAP_P(( Sockbuf *sb, unsigned long tag, struct msg *m,
int err, char *matched, char *text ));
int send_ldap_result LDAP_P(( Sockbuf *sb, unsigned long tag, int msgid, int err,
char *matched, char *text ));
/*
* search.c
*/
int do_search( Sockbuf *clientsb, struct msg *m, BerElement *ber );
struct ds_search_result;
int do_search LDAP_P(( Sockbuf *clientsb, struct msg *m, BerElement *ber ));
void search_result LDAP_P(( Sockbuf *sb, struct msg *m,
struct ds_search_result *sr ));
/*
* syntax.c
*/
void get_syntaxes();
int dn_print_real( PS ps, DN dn, int format);
void ldap_dn_print( PS ps, DN dn, DN base, int format);
int encode_dn( BerElement *ber, DN dn, DN base);
int encode_attrs( BerElement *ber, Attr_Sequence as );
AttributeValue bv_octet2AttrV( struct berval *bv );
AttributeValue bv_asn2AttrV( struct berval *bv );
AttributeValue ldap_strdn2AttrV( char *dnstr );
DN ldap_str2dn( char *str );
RDN ldap_str2rdn( char *rdnstr );
AttributeValue ldap_str_at2AttrV( char *str, AttributeType type );
AttributeValue ldap_str2AttrV( char *value, short syntax );
void get_syntaxes LDAP_P(( void ));
int dn_print_real LDAP_P(( PS ps, DN dn, int format));
void ldap_dn_print LDAP_P(( PS ps, DN dn, DN base, int format));
int encode_dn LDAP_P(( BerElement *ber, DN dn, DN base));
int encode_attrs LDAP_P(( BerElement *ber, Attr_Sequence as ));
AttributeValue bv_octet2AttrV LDAP_P(( struct berval *bv ));
AttributeValue bv_asn2AttrV LDAP_P(( struct berval *bv ));
AttributeValue ldap_strdn2AttrV LDAP_P(( char *dnstr ));
DN ldap_str2dn LDAP_P(( char *str ));
RDN ldap_str2rdn LDAP_P(( char *rdnstr ));
AttributeValue ldap_str_at2AttrV LDAP_P(( char *str, AttributeType type ));
AttributeValue ldap_str2AttrV LDAP_P(( char *value, short syntax ));
/*
* util.c
*/
void bprint( char *data, int len );
void charlist_free( char **cl );
int get_ava( BerElement *ber, AVA *tava );
int chase_referral( Sockbuf *clientsb, struct msg *m, struct DSError *err,
char **matched );
void bprint LDAP_P(( char *data, int len ));
void charlist_free LDAP_P(( char **cl ));
int get_ava LDAP_P(( BerElement *ber, AVA *tava ));
int chase_referral LDAP_P(( Sockbuf *clientsb, struct msg *m, struct DSError *err,
char **matched ));
#endif /* _proto_ldapd */

View file

@ -30,8 +30,6 @@
#include "ldap.h"
#include "common.h"
extern int dosyslog;
#ifdef PEPSY_DUMP
#ifndef DEBUG
#define DEBUG
@ -69,11 +67,6 @@ client_request(
BerElement ber, *copyofber;
struct msg *m;
static int bound;
extern char *bound_dn, *bound_pw;
struct PSAPaddr *psap_cpy();
#ifdef LDAP_COMPAT
extern int ldap_compat;
#endif
Debug( LDAP_DEBUG_TRACE, "client_request%s\n",
udp ? " udp" : "", 0, 0 );
@ -202,7 +195,7 @@ client_request(
* duplicate request: toss this one
*/
Debug( LDAP_DEBUG_TRACE,
"client_request tossing dup request id %d from %s\n",
"client_request tossing dup request id %ld from %s\n",
msgid, inet_ntoa( ((struct sockaddr_in *)
clientsb->sb_fromaddr)->sin_addr ), 0 );
free( ber.ber_buf );

View file

@ -10,28 +10,22 @@
* is provided ``as is'' without express or implied warranty.
*/
#include "portable.h"
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/syslog.h>
#include <quipu/dsap.h>
#include <quipu/dap2.h>
#include <quipu/dua.h>
#ifdef __hpux
#include <syslog.h>
#else
#include <sys/syslog.h>
#endif
#include "lber.h"
#include "ldap.h"
#include "common.h"
extern int dosyslog;
#ifdef COMPAT
extern int ldap_compat;
#endif
/*
* dsa_response - called by do_queries() when there is activity on one of
* the DSA associations. It is passed the association descriptor on which
@ -131,7 +125,7 @@ dsa_response(
return;
}
if ( m->m_msgtype == LDAP_REQ_SEARCH
#ifdef COMPAT20
#ifdef LDAP_COMPAT20
|| m->m_msgtype == OLD_LDAP_REQ_SEARCH
#endif
)
@ -154,7 +148,7 @@ dsa_response(
int bound, rc;
switch ( m->m_msgtype ) {
#ifdef COMPAT20
#ifdef LDAP_COMPAT20
case OLD_LDAP_REQ_ADD:
case OLD_LDAP_REQ_MODIFY:
case OLD_LDAP_REQ_MODRDN:
@ -162,7 +156,7 @@ dsa_response(
case OLD_LDAP_REQ_COMPARE:
case OLD_LDAP_REQ_SEARCH:
#endif
#ifdef COMPAT30
#ifdef LDAP_COMPAT30
case LDAP_REQ_DELETE_30:
#endif
case LDAP_REQ_ADD:
@ -283,7 +277,7 @@ send_ldap_msgresult(
char *text
)
{
#ifdef CLDAP
#ifdef LDAP_CONNECTIONLESS
if ( m->m_cldap ) {
SAFEMEMCPY( (char *)sb->sb_useaddr, &m->m_clientaddr,
sizeof( struct sockaddr ));
@ -308,19 +302,15 @@ send_ldap_result(
{
BerElement *ber;
int rc;
#ifdef CLDAP
#ifdef LDAP_CONNECTIONLESS
int cldap;
#endif
extern int version;
#ifdef CLDAP
cldap = ( sb->sb_naddr > 0 );
#endif
Debug( LDAP_DEBUG_TRACE, "send_ldap_result\n", 0, 0, 0 );
if ( tag == LBER_DEFAULT )
#ifdef COMPAT20
#ifdef LDAP_COMPAT20
tag = ldap_compat == 20 ? OLD_LBER_SEQUENCE : LBER_SEQUENCE;
#else
tag = LBER_SEQUENCE;
@ -332,20 +322,20 @@ send_ldap_result(
}
if ( version != 1 ) {
#ifdef COMPAT20
#ifdef LDAP_COMPAT20
if ( ldap_compat == 20 ) {
rc = ber_printf( ber, "t{it{tess}}", OLD_LBER_SEQUENCE,
msgid, tag, LBER_INTEGER, err,
matched ? matched : "", text );
} else
#endif
#ifdef COMPAT30
#ifdef LDAP_COMPAT30
if ( ldap_compat == 30 ) {
rc = ber_printf( ber, "{it{{ess}}}", msgid, tag, err,
matched ? matched : "", text );
} else
#endif
#ifdef CLDAP
#ifdef LDAP_CONNECTIONLESS
if ( cldap ) {
rc = ber_printf( ber, "{is{t{ess}}}", msgid, "", tag,
err, matched ? matched : "", text );

View file

@ -28,13 +28,11 @@
#include "ldap.h"
#include "common.h"
static int get_filter();
static int get_filter_list();
static int get_substring_filter();
static int get_filter( BerElement *ber, Filter *filt );
static int get_filter_list( BerElement *ber, Filter f );
static int get_substring_filter( BerElement *ber, Filter f );
#ifdef LDAP_COMPAT
extern int version;
extern int ldap_compat;
#define SEARCHRESTAG (ldap_compat == 20 ? OLD_LDAP_RES_SEARCH_RESULT : LDAP_RES_SEARCH_RESULT)
#else
#define SEARCHRESTAG LDAP_RES_SEARCH_RESULT
@ -54,7 +52,6 @@ do_search(
char **attrs;
struct ds_search_arg sa;
static CommonArgs common = default_common_args;
extern DN ldap_str2dn();
Debug( LDAP_DEBUG_TRACE, "do_search\n", 0, 0, 0 );
@ -425,7 +422,6 @@ get_substring_filter( BerElement *ber, Filter f )
AttributeType type;
char *valstr, *last;
AttributeValue value;
extern short ldap_dn_syntax;
Debug( LDAP_DEBUG_TRACE, "get_substring_filter\n", 0, 0, 0 );

View file

@ -1,48 +0,0 @@
#ifndef NOSETPROCTITLE
/*
* Copyright (c) 1990,1991 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.
*/
char **Argv; /* pointer to original (main's) argv */
int Argc; /* original argc */
/*
* takes a printf-style format string (fmt) and up to three parameters (a,b,c)
* this clobbers the original argv...
*/
/* VARARGS */
setproctitle( fmt, a, b, c )
char *fmt;
{
static char *endargv = (char *)0;
char *s;
int i;
char buf[ 1024 ];
if ( endargv == (char *)0 ) {
/* set pointer to end of original argv */
endargv = Argv[ Argc-1 ] + strlen( Argv[ Argc-1 ] );
}
sprintf( buf, fmt, a, b, c );
/* make ps print "([prog name])" */
s = Argv[0];
*s++ = '-';
i = strlen( buf );
if ( i > endargv - s - 2 ) {
i = endargv - s - 2;
buf[ i ] = '\0';
}
strcpy( s, buf );
s += i;
while ( s < endargv ) *s++ = ' ';
}
#endif /* NOSETPROCTITLE */

View file

@ -24,6 +24,8 @@
#include <quipu/ds_search.h>
#include <quipu/dap2.h>
#include <quipu/dua.h>
extern oid_table_attr *name2attr( char * );
/*extern AttributeValue str_at2AttrV( char *, IF_AttributeType * );*/
#include "lber.h"
#include "ldap.h"
@ -59,7 +61,7 @@ static int syntax_is_string( short syntax );
static int
get_one_syntax( char *attrib, int required )
{
oid_table_attr *p, *name2attr();
oid_table_attr *p;
if ( (p = name2attr( attrib )) != (oid_table_attr *) 0 )
return( p->oa_syntax );
@ -74,10 +76,8 @@ get_one_syntax( char *attrib, int required )
}
void
get_syntaxes()
get_syntaxes( void )
{
oid_table_attr *name2attr();
Debug( LDAP_DEBUG_TRACE, "get_syntaxes\n", 0, 0, 0 );
ldap_photo_syntax = get_one_syntax( "photo", 0 );
@ -134,7 +134,8 @@ get_syntaxes()
* notation. (e.g., OID.2.6.53).
*
*/
static void attr_key_rfc1779 (
static void
attr_key_rfc1779(
AttributeType at,
char *key /* return key, caller allocated */
)
@ -181,7 +182,6 @@ dn_print_real(
int firstrdn;
char *value;
PS rps;
void ldap_dn_print();
char key[512];
if ( dn == NULLDN )
@ -553,9 +553,6 @@ int
encode_attrs( BerElement *ber, Attr_Sequence as )
{
PS ps;
#ifdef LDAP_COMPAT20
extern int ldap_compat;
#endif
Debug( LDAP_DEBUG_TRACE, "encode_attrs\n", 0, 0, 0 );
@ -622,7 +619,8 @@ trim_trailing_spaces( char *s )
}
}
DN ldap_str2dn( char *str )
DN
ldap_str2dn( char *str )
{
DN dn, save;
RDN rdn, newrdn, tmprdn;
@ -785,7 +783,8 @@ DN ldap_str2dn( char *str )
#define T61 "{T.61}"
#define T61LEN 6
static void de_t61( char *s, int t61mark )
static void
de_t61( char *s, int t61mark )
{
char *next = s;
int c, hex;
@ -965,7 +964,6 @@ AttributeValue
ldap_str_at2AttrV( char *str, AttributeType type )
{
char *s, *res, *r;
AttributeValue str_at2AttrV();
Debug( LDAP_DEBUG_TRACE, "ldap_str_at2AttrV str (%s) type (%s)\n", str,
type->oa_ot.ot_name, 0 );

View file

@ -10,15 +10,20 @@
* is provided ``as is'' without express or implied warranty.
*/
#include "portable.h"
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <sys/errno.h>
#include <ac/ctype.h>
#include <ac/errno.h>
#include <ac/socket.h>
#include <ac/string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <quipu/commonarg.h>
#include <quipu/ds_error.h>
#include "lber.h"
#include "ldap.h"
#include "common.h"
@ -48,8 +53,8 @@ bprint( char *data, int len )
out[ i ] = ' ';
out[ i+1 ] = *data;
} else {
out[ i ] = hexdig[ ( *data & 0xf0 ) >> 4 ];
out[ i+1 ] = hexdig[ *data & 0x0f ];
out[ i ] = hexdig[ ( (unsigned char)*data & 0xf0 ) >> 4 ];
out[ i+1 ] = hexdig[ (unsigned char)*data & 0x0f ];
}
i += 2;
len--;
@ -65,7 +70,8 @@ bprint( char *data, int len )
}
}
void charlist_free( char **cl )
void
charlist_free( char **cl )
{
int i;
@ -81,7 +87,6 @@ int
get_ava( BerElement *ber, AVA *tava )
{
char *type, *value;
extern short ldap_dn_syntax;
Debug( LDAP_DEBUG_TRACE, "get_ava\n", 0, 0, 0 );
@ -127,7 +132,6 @@ chase_referral(
struct access_point *ap;
int rc, bound;
struct conn *save, *dup, *found;
struct PSAPaddr *psap_cpy();
Debug( LDAP_DEBUG_TRACE, "chase_referral\n", 0, 0, 0 );

View file

@ -12,15 +12,13 @@
* is provided ``as is'' without express or implied warranty.
*/
#include "portable.h"
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <ac/socket.h>
#include "slap.h"
extern Backend *select_backend();
extern char *default_referral;
void
do_abandon(
Connection *conn,

View file

@ -10,20 +10,9 @@
#include "slap.h"
extern Attribute *attr_find();
extern struct acl *global_acl;
extern int global_default_access;
extern char *access2str();
extern char *dn_normalize_case();
int acl_access_allowed();
int access_allowed();
struct acl *acl_get_applicable();
static int regex_matches();
static string_expand(char *newbuf, int bufsiz, char *pattern,
char *match, regmatch_t *matches);
static int regex_matches(char *pat, char *str, char *buf, regmatch_t *matches);
static void string_expand(char *newbuf, int bufsiz, char *pattern,
char *match, regmatch_t *matches);
/*
@ -472,7 +461,8 @@ acl_check_mods(
return( LDAP_SUCCESS );
}
static string_expand(
static void
string_expand(
char *newbuf,
int bufsiz,
char *pat,

View file

@ -12,27 +12,22 @@
#include "slap.h"
extern Filter *str2filter();
extern struct acl *global_acl;
extern char **str2charray();
extern char *dn_upcase();
static void split();
static void acl_append();
static void access_append();
static void acl_usage();
static void split(char *line, int splitchar, char **left, char **right);
static void acl_append(struct acl **l, struct acl *a);
static void access_append(struct access **l, struct access *a);
static void acl_usage(void);
#ifdef LDAP_DEBUG
static void print_acl();
static void print_access();
static void print_acl(struct acl *a);
static void print_access(struct access *b);
#endif
int
static int
regtest(char *fname, int lineno, char *pat) {
int e;
regex_t re;
char buf[512];
int size;
unsigned size;
char *sp;
char *dp;
@ -369,7 +364,7 @@ str2access( char *str )
}
static void
acl_usage()
acl_usage( void )
{
fprintf( stderr, "\n<access clause> ::= access to <what> [ by <who> <access> ]+ \n" );
fprintf( stderr, "<what> ::= * | [dn=<regex>] [filter=<ldapfilter>] [attrs=<attrlist>]\n" );

View file

@ -10,27 +10,20 @@
* is provided ``as is'' without express or implied warranty.
*/
#include "portable.h"
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <ac/string.h>
#include <ac/time.h>
#include <ac/socket.h>
#include "slap.h"
extern Backend *select_backend();
extern char *dn_normalize();
extern char *default_referral;
extern time_t currenttime;
extern pthread_mutex_t currenttime_mutex;
extern int global_lastmod;
static void add_created_attrs();
static void add_created_attrs(Operation *op, Entry *e);
void
do_add( conn, op )
Connection *conn;
Operation *op;
do_add( Connection *conn, Operation *op )
{
BerElement *ber = op->o_ber;
char *dn, *last;
@ -53,6 +46,8 @@ do_add( conn, op )
*/
e = (Entry *) ch_calloc( 1, sizeof(Entry) );
/* initialize reader/writer lock */
entry_rdwr_init(e);
/* get the name */
if ( ber_scanf( ber, "{a", &dn ) == LBER_ERROR ) {
@ -117,21 +112,25 @@ do_add( conn, op )
*/
if ( be->be_add != NULL ) {
/* do the update here */
if ( be->be_updatedn == NULL || strcasecmp( be->be_updatedn,
op->o_dn ) == 0 ) {
if ( (be->be_lastmod == ON || be->be_lastmod == 0 &&
global_lastmod == ON) && be->be_updatedn == NULL ) {
if ( be->be_updatedn == NULL ||
strcasecmp( be->be_updatedn, op->o_dn ) == 0 ) {
if ( (be->be_lastmod == ON || (be->be_lastmod == UNDEFINED &&
global_lastmod == ON)) && be->be_updatedn == NULL ) {
add_created_attrs( op, e );
}
if ( (*be->be_add)( be, conn, op, e ) == 0 ) {
replog( be, LDAP_REQ_ADD, e->e_dn, e, 0 );
}
} else {
entry_free( e );
send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL,
default_referral );
}
} else {
Debug( LDAP_DEBUG_ARGS, " do_add: HHH\n", 0, 0, 0 );
entry_free( e );
send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
"Function not implemented" );
@ -141,7 +140,7 @@ do_add( conn, op )
static void
add_created_attrs( Operation *op, Entry *e )
{
char buf[20];
char buf[22];
struct berval bv;
struct berval *bvals[2];
Attribute **a, **next;
@ -155,8 +154,10 @@ add_created_attrs( Operation *op, Entry *e )
/* remove any attempts by the user to add these attrs */
for ( a = &e->e_attrs; *a != NULL; a = next ) {
if ( strcasecmp( (*a)->a_type, "createtimestamp" ) == 0
|| strcasecmp( (*a)->a_type, "creatorsname" ) == 0 ) {
if ( strcasecmp( (*a)->a_type, "modifiersname" ) == 0 ||
strcasecmp( (*a)->a_type, "modifytimestamp" ) == 0 ||
strcasecmp( (*a)->a_type, "creatorsname" ) == 0 ||
strcasecmp( (*a)->a_type, "createtimestamp" ) == 0 ) {
tmp = *a;
*a = (*a)->a_next;
attr_free( tmp );
@ -176,8 +177,13 @@ add_created_attrs( Operation *op, Entry *e )
attr_merge( e, "creatorsname", bvals );
pthread_mutex_lock( &currenttime_mutex );
ltm = localtime( &currenttime );
strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm );
#ifndef LDAP_LOCALTIME
ltm = gmtime( &currenttime );
strftime( buf, sizeof(buf), "%Y%m%d%H%M%SZ", ltm );
#else
ltm = localtime( &currenttime );
strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm );
#endif
pthread_mutex_unlock( &currenttime_mutex );
bv.bv_val = buf;

View file

@ -9,6 +9,7 @@
#endif
#include <ac/ctype.h>
#include <ac/errno.h>
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/time.h>
@ -21,9 +22,6 @@
#include "slap.h"
extern char **charray_dup();
extern int errno;
void
attr_free( Attribute *a )
{
@ -294,7 +292,7 @@ attr_syntax_config(
} else {
Debug( LDAP_DEBUG_ANY,
"%s: line %d: unknown syntax \"%s\" in attribute line (ignored)\n",
fname, lineno, 0 );
fname, lineno, argv[lasti] );
Debug( LDAP_DEBUG_ANY,
"possible syntaxes are \"cis\", \"ces\", \"tel\", \"dn\", or \"bin\"\n",
0, 0, 0 );
@ -325,7 +323,7 @@ attr_syntax_config(
#ifdef LDAP_DEBUG
static
static int
attr_syntax_printnode( struct asyntaxinfo *a )
{
int i;
@ -337,8 +335,8 @@ attr_syntax_printnode( struct asyntaxinfo *a )
return( 0 );
}
static
attr_syntax_print()
static void
attr_syntax_print( void )
{
(void) avl_apply( attr_syntaxes, attr_syntax_printnode, 0, -1,
AVL_INORDER );

View file

@ -2,7 +2,8 @@
#include "portable.h"
int
/*ARGSUSED*/
void
ldbm_back_abandon()
{
}

View file

@ -1,16 +1,15 @@
/* add.c - ldap ldbm back-end add routine */
#include "portable.h"
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <ac/socket.h>
#include <ac/string.h>
#include "slap.h"
#include "back-ldbm.h"
extern int global_schemacheck;
extern char *dn_parent();
extern char *dn_normalize();
extern Entry *dn2entry();
#include "proto-back-ldbm.h"
int
ldbm_back_add(
@ -21,27 +20,30 @@ ldbm_back_add(
)
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
char *matched;
char *dn = NULL, *pdn = NULL;
Entry *p;
Entry *p = NULL;
int rc;
dn = dn_normalize( strdup( e->e_dn ) );
matched = NULL;
if ( (p = dn2entry( be, dn, &matched )) != NULL ) {
cache_return_entry( &li->li_cache, p );
Debug(LDAP_DEBUG_ARGS, "==> ldbm_back_add: %s\n", dn, 0, 0);
if ( ( dn2id( be, dn ) ) != NOID ) {
entry_free( e );
free( dn );
send_ldap_result( conn, op, LDAP_ALREADY_EXISTS, "", "" );
return( -1 );
}
if ( matched != NULL ) {
free( matched );
}
/* XXX race condition here til we cache_add_entry_lock below XXX */
if ( global_schemacheck && oc_schema_check( e ) != 0 ) {
Debug( LDAP_DEBUG_TRACE, "entry failed schema check\n", 0, 0,
0 );
Debug( LDAP_DEBUG_TRACE, "entry failed schema check\n",
0, 0, 0 );
/* XXX this should be ok, no other thread should have access
* because e hasn't been added to the cache yet
*/
entry_free( e );
free( dn );
send_ldap_result( conn, op, LDAP_OBJECT_CLASS_VIOLATION, "",
@ -61,6 +63,10 @@ ldbm_back_add(
Debug( LDAP_DEBUG_ANY, "cache_add_entry_lock failed\n", 0, 0,
0 );
next_id_return( be, e->e_id );
/* XXX this should be ok, no other thread should have access
* because e hasn't been added to the cache yet
*/
entry_free( e );
free( dn );
send_ldap_result( conn, op, LDAP_ALREADY_EXISTS, "", "" );
@ -74,17 +80,22 @@ ldbm_back_add(
*/
if ( (pdn = dn_parent( be, dn )) != NULL ) {
char *matched;
/* no parent */
matched = NULL;
if ( (p = dn2entry( be, pdn, &matched )) == NULL ) {
/* get entry with reader lock */
if ( (p = dn2entry_r( be, pdn, &matched )) == NULL ) {
Debug( LDAP_DEBUG_TRACE, "parent does not exist\n", 0,
0, 0 );
send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT,
matched, "" );
if ( matched != NULL ) {
free( matched );
}
Debug( LDAP_DEBUG_TRACE, "parent does not exist\n", 0,
0, 0 );
goto error_return;
rc = -1;
goto return_results;
}
if ( matched != NULL ) {
free( matched );
@ -96,7 +107,9 @@ ldbm_back_add(
0, 0 );
send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
"", "" );
goto error_return;
rc = -1;
goto return_results;
}
} else {
if ( ! be_isroot( be, op->o_dn ) ) {
@ -104,9 +117,10 @@ ldbm_back_add(
0, 0 );
send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
"", "" );
goto error_return;
rc = -1;
goto return_results;
}
p = NULL;
}
/*
@ -116,9 +130,10 @@ ldbm_back_add(
if ( id2children_add( be, p, e ) != 0 ) {
Debug( LDAP_DEBUG_TRACE, "id2children_add failed\n", 0,
0, 0 );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "",
"" );
goto error_return;
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" );
rc = -1;
goto return_results;
}
/*
@ -131,7 +146,9 @@ ldbm_back_add(
Debug( LDAP_DEBUG_TRACE, "index_add_entry failed\n", 0,
0, 0 );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" );
goto error_return;
rc = -1;
goto return_results;
}
/* dn2id index */
@ -139,35 +156,44 @@ ldbm_back_add(
Debug( LDAP_DEBUG_TRACE, "dn2id_add failed\n", 0,
0, 0 );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" );
goto error_return;
rc = -1;
goto return_results;
}
/* acquire writer lock */
entry_rdwr_lock(e, 1);
/* id2entry index */
if ( id2entry_add( be, e ) != 0 ) {
Debug( LDAP_DEBUG_TRACE, "id2entry_add failed\n", 0,
0, 0 );
(void) dn2id_delete( be, dn );
send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, "", "" );
goto error_return;
rc = -1;
goto return_results;
}
send_ldap_result( conn, op, LDAP_SUCCESS, "", "" );
rc = 0;
return_results:;
if ( dn != NULL )
free( dn );
if ( pdn != NULL )
free( pdn );
cache_set_state( &li->li_cache, e, 0 );
cache_return_entry( &li->li_cache, e );
return( 0 );
error_return:;
if ( dn != NULL )
free( dn );
if ( pdn != NULL )
free( pdn );
next_id_return( be, e->e_id );
cache_delete_entry( &li->li_cache, e );
cache_return_entry( &li->li_cache, e );
/* free entry and writer lock */
cache_return_entry_w( &li->li_cache, e );
return( -1 );
/* free entry and reader lock */
if (p != NULL) {
cache_return_entry_r( &li->li_cache, p );
}
return( rc );
}

View file

@ -1,14 +1,15 @@
/* attr.c - backend routines for dealing with attributes */
#include "portable.h"
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <ac/socket.h>
#include <ac/string.h>
#include "slap.h"
#include "back-ldbm.h"
extern char **str2charray();
static int
ainfo_type_cmp(
char *type,
@ -141,7 +142,7 @@ attr_index_config(
a->ai_indexmask |= INDEX_FROMINIT;
}
switch (avl_insert( &li->li_attrs, a, ainfo_cmp, ainfo_dup )) {
switch (avl_insert( &li->li_attrs, (caddr_t) a, ainfo_cmp, ainfo_dup )) {
case 1: /* duplicate - updating init version */
free( a->ai_type );
free( (char *) a );

View file

@ -1,22 +1,117 @@
/* bind.c - ldbm backend bind and unbind routines */
#include "portable.h"
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <ac/krb.h>
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/unistd.h>
#include "slap.h"
#include "back-ldbm.h"
#ifdef KERBEROS
#include "krb.h"
#endif
#include "proto-back-ldbm.h"
extern Entry *dn2entry();
extern Attribute *attr_find();
#ifdef SLAPD_SHA1
#include <lutil_sha1.h>
#endif /* SLAPD_SHA1 */
#ifdef KERBEROS
#ifdef SLAPD_MD5
#include <lutil_md5.h>
#endif /* SLAPD_MD5 */
#include <lutil.h>
#ifdef HAVE_KERBEROS
extern int krbv4_ldap_auth();
#endif
#ifdef SLAPD_CRYPT
pthread_mutex_t crypt_mutex;
static int
crypted_value_find(
struct berval **vals,
struct berval *v,
int syntax,
int normalize,
struct berval *cred
)
{
int i;
for ( i = 0; vals[i] != NULL; i++ ) {
if ( syntax != SYNTAX_BIN && strncasecmp( "{CRYPT}",
vals[i]->bv_val, (sizeof("{CRYPT}") - 1 ) ) == 0 ) {
char *userpassword = vals[i]->bv_val + sizeof("{CRYPT}") - 1;
pthread_mutex_lock( &crypt_mutex );
if (strcmp(userpassword, crypt(cred->bv_val,
userpassword)) == 0) {
pthread_mutex_unlock( &crypt_mutex );
return ( 0 );
}
pthread_mutex_unlock( &crypt_mutex );
#ifdef SLAPD_MD5
} else if ( syntax != SYNTAX_BIN && strncasecmp( "{MD5}",
vals[i]->bv_val, (sizeof("{MD5}") - 1 ) ) == 0 ) {
ldap_MD5_CTX MD5context;
unsigned char MD5digest[20];
char base64digest[29]; /* ceiling(sizeof(input)/3) * 4 + 1 */
char *userpassword = vals[i]->bv_val + sizeof("{MD5}") - 1;
ldap_MD5Init(&MD5context);
ldap_MD5Update(&MD5context,
(unsigned char *) cred->bv_val,
strlen(cred->bv_val));
ldap_MD5Final(MD5digest, &MD5context);
if (b64_ntop(MD5digest, sizeof(MD5digest),
base64digest, sizeof(base64digest)) < 0)
{
return ( 1 );
}
if (strcmp(userpassword, base64digest) == 0) {
return ( 0 );
}
#endif /* SLAPD_MD5 */
#ifdef SLAPD_SHA1
} else if ( syntax != SYNTAX_BIN && strncasecmp( "{SHA}",
vals[i]->bv_val, (sizeof("{SHA}") - 1 ) ) == 0 ) {
ldap_SHA1_CTX SHA1context;
unsigned char SHA1digest[20];
char base64digest[29]; /* ceiling(sizeof(input)/3) * 4 + 1 */
char *userpassword = vals[i]->bv_val + sizeof("{SHA}") - 1;
ldap_SHA1Init(&SHA1context);
ldap_SHA1Update(&SHA1context,
(unsigned char *) cred->bv_val,
strlen(cred->bv_val));
ldap_SHA1Final(SHA1digest, &SHA1context);
if (b64_ntop(SHA1digest, sizeof(SHA1digest),
base64digest, sizeof(base64digest)) < 0)
{
return ( 1 );
}
if (strcmp(userpassword, base64digest) == 0) {
return ( 0 );
}
#endif /* SLAPD_SHA1 */
} else {
if ( value_cmp( vals[i], v, syntax, normalize ) == 0 ) {
return( 0 );
}
}
}
return( 1 );
}
#endif /* SLAPD_CRYPT */
int
ldbm_back_bind(
Backend *be,
@ -32,12 +127,15 @@ ldbm_back_bind(
Attribute *a;
int rc;
char *matched = NULL;
#ifdef KERBEROS
#ifdef HAVE_KERBEROS
char krbname[MAX_K_NAME_SZ + 1];
AUTH_DAT ad;
#endif
if ( (e = dn2entry( be, dn, &matched )) == NULL ) {
Debug(LDAP_DEBUG_ARGS, "==> ldbm_back_bind: dn: %s\n", dn, 0, 0);
/* get entry with reader lock */
if ( (e = dn2entry_r( be, dn, &matched )) == NULL ) {
/* allow noauth binds */
if ( method == LDAP_AUTH_SIMPLE && cred->bv_len == 0 ) {
/*
@ -50,8 +148,7 @@ ldbm_back_bind(
/* front end will send result */
rc = 0;
} else {
send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT,
matched, NULL );
send_ldap_result( conn, op, LDAP_NO_SUCH_OBJECT, matched, NULL );
rc = 1;
}
if ( matched != NULL ) {
@ -60,46 +157,60 @@ ldbm_back_bind(
return( rc );
}
/* check for deleted */
switch ( method ) {
case LDAP_AUTH_SIMPLE:
if ( cred->bv_len == 0 ) {
send_ldap_result( conn, op, LDAP_SUCCESS, NULL, NULL );
return( 1 );
/* stop front end from sending result */
rc = 1;
goto return_results;
} else if ( be_isroot_pw( be, dn, cred ) ) {
/* front end will send result */
return( 0 );
rc = 0;
goto return_results;
}
if ( (a = attr_find( e->e_attrs, "userpassword" )) == NULL ) {
if ( be_isroot_pw( be, dn, cred ) ) {
/* front end will send result */
return( 0 );
rc = 0;
goto return_results;
}
send_ldap_result( conn, op, LDAP_INAPPROPRIATE_AUTH,
NULL, NULL );
cache_return_entry( &li->li_cache, e );
return( 1 );
rc = 1;
goto return_results;
}
if ( value_find( a->a_vals, cred, a->a_syntax, 0 ) != 0 ) {
#ifdef SLAPD_CRYPT
if ( crypted_value_find( a->a_vals, cred, a->a_syntax, 0, cred ) != 0 )
#else
if ( value_find( a->a_vals, cred, a->a_syntax, 0 ) != 0 )
#endif
{
if ( be_isroot_pw( be, dn, cred ) ) {
/* front end will send result */
return( 0 );
rc = 0;
goto return_results;
}
send_ldap_result( conn, op, LDAP_INVALID_CREDENTIALS,
NULL, NULL );
cache_return_entry( &li->li_cache, e );
return( 1 );
NULL, NULL );
rc = 1;
goto return_results;
}
rc = 0;
break;
#ifdef KERBEROS
#ifdef HAVE_KERBEROS
case LDAP_AUTH_KRBV41:
if ( krbv4_ldap_auth( be, cred, &ad ) != LDAP_SUCCESS ) {
send_ldap_result( conn, op, LDAP_INVALID_CREDENTIALS,
NULL, NULL );
cache_return_entry( &li->li_cache, e );
return( 1 );
rc = 0;
goto return_results;
}
sprintf( krbname, "%s%s%s@%s", ad.pname, *ad.pinst ? "."
: "", ad.pinst, ad.prealm );
@ -108,43 +219,47 @@ ldbm_back_bind(
* no krbName values present: check against DN
*/
if ( strcasecmp( dn, krbname ) == 0 ) {
rc = 0; /* XXX wild ass guess */
break;
}
send_ldap_result( conn, op, LDAP_INAPPROPRIATE_AUTH,
NULL, NULL );
cache_return_entry( &li->li_cache, e );
return( 1 );
rc = 1;
goto return_results;
} else { /* look for krbName match */
struct berval krbval;
krbval.bv_val = krbname;
krbval.bv_len = strlen( krbname );
if ( value_find( a->a_vals, &krbval, a->a_syntax, 3 )
!= 0 ) {
if ( value_find( a->a_vals, &krbval, a->a_syntax, 3 ) != 0 ) {
send_ldap_result( conn, op,
LDAP_INVALID_CREDENTIALS, NULL, NULL );
cache_return_entry( &li->li_cache, e );
return( 1 );
rc = 1;
goto return_results;
}
}
break;
case LDAP_AUTH_KRBV42:
send_ldap_result( conn, op, LDAP_SUCCESS, NULL, NULL );
cache_return_entry( &li->li_cache, e );
return( 1 );
/* stop front end from sending result */
rc = 1;
goto return_results;
#endif
default:
send_ldap_result( conn, op, LDAP_STRONG_AUTH_NOT_SUPPORTED,
NULL, "auth method not supported" );
cache_return_entry( &li->li_cache, e );
return( 1 );
rc = 1;
goto return_results;
}
cache_return_entry( &li->li_cache, e );
return_results:;
/* free entry and reader lock */
cache_return_entry_r( &li->li_cache, e );
/* success: front end will send result */
return( 0 );
/* front end with send result on success (rc==0) */
return( rc );
}

View file

@ -3,15 +3,16 @@
#include "portable.h"
#include <stdio.h>
int strcasecmp( const char *, const char *);
#include <ac/socket.h>
#include "slap.h"
#include "back-ldbm.h"
static int cache_delete_entry_internal();
static int cache_delete_entry_internal(struct cache *cache, Entry *e);
#ifdef LDAP_DEBUG
static void lru_print();
static void lru_print(struct cache *cache);
#endif
/*
@ -139,7 +140,7 @@ cache_add_entry_lock(
cache_entrydn_cmp, avl_dup_error ) != 0 )
{
Debug( LDAP_DEBUG_TRACE,
"====> cache_add_entry lock: entry %20s id %d already in dn cache\n",
"====> cache_add_entry lock: entry %20s id %lu already in dn cache\n",
e->e_dn, e->e_id, 0 );
/* free cache mutex */
@ -152,7 +153,7 @@ cache_add_entry_lock(
cache_entryid_cmp, avl_dup_error ) != 0 )
{
Debug( LDAP_DEBUG_ANY,
"====> entry %20s id %d already in id cache\n",
"====> entry %20s id %lu already in id cache\n",
e->e_dn, e->e_id, 0 );
/* delete from dn tree inserted above */
@ -451,12 +452,12 @@ lru_print( struct cache *cache )
fprintf( stderr, "LRU queue (head to tail):\n" );
for ( e = cache->c_lruhead; e != NULL; e = e->e_lrunext ) {
fprintf( stderr, "\tdn %20s id %d refcnt %d\n", e->e_dn,
fprintf( stderr, "\tdn %20s id %lu refcnt %d\n", e->e_dn,
e->e_id, e->e_refcnt );
}
fprintf( stderr, "LRU queue (tail to head):\n" );
for ( e = cache->c_lrutail; e != NULL; e = e->e_lruprev ) {
fprintf( stderr, "\tdn %20s id %d refcnt %d\n", e->e_dn,
fprintf( stderr, "\tdn %20s id %lu refcnt %d\n", e->e_dn,
e->e_id, e->e_refcnt );
}
}

Some files were not shown because too many files have changed in this diff Show more