Commit c2047d5e authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

RAGE: add support for reading ldap host/base from files

parent 59a66633
......@@ -301,10 +301,23 @@ char **argv;
connect_to_x500()
{
if ( (ld = ldap_open( LDAPHOST, LDAP_PORT )) == NULL ) {
char *ldaphost;
FILE *getbase;
if((getbase = fopen("/etc/ldapserver","r"))) {
ldaphost = malloc(1024);
fgets(ldaphost, 1024, getbase);
if(ldaphost[strlen(ldaphost) - 1] == '\n')
ldaphost[strlen(ldaphost) - 1] = '\0';
fclose(getbase);
}
if(!ldaphost)
ldaphost = LDAPHOST;
if ( (ld = ldap_open( ldaphost, LDAP_PORT )) == NULL ) {
syslog( LOG_ALERT, "ldap_open failed" );
return( -1 );
}
free(ldaphost);
ld->ld_sizelimit = FAX_MAXAMBIGUOUS;
ld->ld_deref = LDAP_DEREF_ALWAYS;
......
......@@ -30,8 +30,8 @@
#define DEFAULT_SIZELIMIT 50
int debug;
char *ldaphost = LDAPHOST;
char *base = DEFAULT_BASE;
char *ldaphost = NULL;
char *base = NULL;
int deref;
int sizelimit;
LDAPFiltDesc *filtd;
......@@ -64,6 +64,25 @@ main (argc, argv)
"facsimileTelephoneNumber", NULL };
extern char *optarg;
extern int optind;
FILE *getvar;
if((getvar = fopen("/etc/defaultbase.ldap","r"))) {
base = malloc(1024);
fgets(base, 1024, getvar);
if(base[strlen(base) - 1] == '\n')
base[strlen(base) - 1] = '\0';
fclose(getvar);
}
if(!base)
base = DEFAULT_BASE;
if((getvar = fopen("/etc/ldapserver","r"))) {
ldaphost = malloc(1024);
fgets(ldaphost, 1024, getvar);
if(ldaphost[strlen(ldaphost) - 1] == '\n')
ldaphost[strlen(ldaphost) - 1] = '\0';
fclose(getvar);
}
if(!ldaphost)
ldaphost = LDAPHOST;
deref = LDAP_DEREF_ALWAYS;
while ( (i = getopt( argc, argv, "ab:d:f:x:z:" )) != EOF ) {
......
......@@ -37,7 +37,7 @@
#endif /* USE_SYSCONF */
int dosyslog = 1;
char *ldaphost = LDAPHOST;
char *ldaphost = NULL;
int ldapport = LDAP_PORT;
char *base = FINGER_BASE;
int deref;
......@@ -69,6 +69,16 @@ char **argv;
int peernamelen;
int interactive = 0;
extern char *optarg;
FILE *getbase;
if((getbase = fopen("/etc/ldapserver","r"))) {
ldaphost = malloc(1024);
fgets(ldaphost, 1024, getbase);
if(ldaphost[strlen(ldaphost) - 1] == '\n')
ldaphost[strlen(ldaphost) - 1] = '\0';
fclose(getbase);
}
if(!ldaphost)
ldaphost = LDAPHOST;
deref = FINGER_DEREF;
while ( (i = getopt( argc, argv, "f:ilp:t:x:p:c:" )) != EOF ) {
......
......@@ -42,7 +42,7 @@ int dosyslog;
int inetd;
int dtblsize;
char *ldaphost = LDAPHOST;
char *ldaphost = NULL;
char *base = GO500_BASE;
int rdncount = GO500_RDNCOUNT;
char *filterfile = FILTERFILE;
......@@ -82,10 +82,20 @@ char **argv;
extern char *optarg;
extern char **Argv;
extern int Argc;
FILE *getbase;
/* for setproctitle */
Argv = argv;
Argc = argc;
if((getbase = fopen("/etc/ldapserver","r"))) {
ldaphost = malloc(1024);
fgets(ldaphost, 1024, getbase);
if(ldaphost[strlen(ldaphost) - 1] == '\n')
ldaphost[strlen(ldaphost) - 1] = '\0';
fclose(getbase);
}
if(!ldaphost)
ldaphost = LDAPHOST;
while ( (i = getopt( argc, argv, "b:d:f:lp:c:t:x:I" )) != EOF ) {
switch( i ) {
......
......@@ -42,7 +42,7 @@ int dosyslog;
int inetd;
int dtblsize;
char *ldaphost = LDAPHOST;
char *ldaphost = NULL;
int ldapport = LDAP_PORT;
int searchaliases = 1;
char *helpfile = GO500GW_HELPFILE;
......@@ -89,6 +89,17 @@ char **argv;
extern char *optarg;
extern char **Argv;
extern int Argc;
FILE *getbase;
if((getbase = fopen("/etc/ldapserver","r"))) {
ldaphost = malloc(1024);
fgets(ldaphost, 1024, getbase);
if(ldaphost[strlen(ldaphost) - 1] == '\n')
ldaphost[strlen(ldaphost) - 1] = '\0';
fclose(getbase);
}
if(!ldaphost)
ldaphost = LDAPHOST;
/* for setproctitle */
Argv = argv;
......
......@@ -46,7 +46,7 @@ char *vacationhost = NULL;
char *errorsfrom = NULL;
char *mailfrom = NULL;
char *host = NULL;
char *ldaphost = LDAPHOST;
char *ldaphost = NULL;
int hostlen = 0;
int debug;
......@@ -142,6 +142,16 @@ char **argv;
FILE *fp;
extern int optind, errno;
extern char *optarg;
FILE *getbase;
if((getbase = fopen("/etc/ldapserver","r"))) {
ldaphost = malloc(1024);
fgets(ldaphost, 1024, getbase);
if(ldaphost[strlen(ldaphost) - 1] == '\n')
ldaphost[strlen(ldaphost) - 1] = '\0';
fclose(getbase);
}
if(!ldaphost)
ldaphost = LDAPHOST;
if ( (myname = strrchr( argv[0], '/' )) == NULL )
myname = strdup( argv[0] );
......
......@@ -28,7 +28,7 @@ int derefaliases = 1;
int sizelimit = RCPT500_SIZELIMIT;
int rdncount = RCPT500_RDNCOUNT;
int ldapport = 0;
char *ldaphost = LDAPHOST;
char *ldaphost = NULL;
char *searchbase = RCPT500_BASE;
char *dapuser = RCPT500_BINDDN;
char *filterfile = FILTERFILE;
......@@ -59,6 +59,16 @@ main( argc, argv )
extern int optind;
extern char *optarg;
FILE *getbase;
if((getbase = fopen("/etc/ldapserver","r"))) {
ldaphost = malloc(1024);
fgets(ldaphost, 1024, getbase);
if(ldaphost[strlen(ldaphost) - 1] == '\n')
ldaphost[strlen(ldaphost) - 1] = '\0';
fclose(getbase);
}
if(!ldaphost)
ldaphost = LDAPHOST;
*reply = '\0';
......
......@@ -10,9 +10,9 @@
#include "ldapconfig.h"
static char *binddn = LDAPDELETE_BINDDN;
static char *base = LDAPDELETE_BASE;
static char *base = NULL;
static char *passwd = NULL;
static char *ldaphost = LDAPHOST;
static char *ldaphost = NULL;
static int ldapport = LDAP_PORT;
static int not, verbose, contoper;
static LDAP *ld;
......@@ -36,6 +36,25 @@ main( argc, argv )
extern char *optarg;
extern int optind;
FILE *getbase;
if((getbase = fopen("/etc/ldapserver","r"))) {
ldaphost = malloc(1024);
fgets(ldaphost, 1024, getbase);
if(ldaphost[strlen(ldaphost) - 1] == '\n')
ldaphost[strlen(ldaphost) - 1] = '\0';
fclose(getbase);
}
if(!ldaphost)
ldaphost = LDAPHOST;
if((getbase = fopen("/etc/defaultbase.ldap","r"))) {
base = malloc(1024);
fgets(base, 1024, getbase);
if(base[strlen(base) - 1] == '\n')
base[strlen(base) - 1] = '\0';
fclose(getbase);
}
if(!base)
base = LDAPDELETE_BASE;
kerberos = not = verbose = contoper = 0;
fp = NULL;
......
......@@ -20,7 +20,7 @@
static char *prog;
static char *binddn = LDAPMODIFY_BINDDN;
static char *passwd = NULL;
static char *ldaphost = LDAPHOST;
static char *ldaphost = NULL;
static int ldapport = LDAP_PORT;
static int new, replace, not, verbose, contoper, force, valsfromfiles;
static LDAP *ld;
......@@ -85,6 +85,16 @@ main( argc, argv )
extern char *optarg;
extern int optind;
FILE *getbase;
if((getbase = fopen("/etc/ldapserver","r"))) {
ldaphost = malloc(1024);
fgets(ldaphost, 1024, getbase);
if(ldaphost[strlen(ldaphost) - 1] == '\n')
ldaphost[strlen(ldaphost) - 1] = '\0';
fclose(getbase);
}
if(!ldaphost)
ldaphost = LDAPHOST;
if (( prog = strrchr( argv[ 0 ], '/' )) == NULL ) {
prog = argv[ 0 ];
......
......@@ -10,9 +10,9 @@
#include "ldapconfig.h"
static char *binddn = LDAPMODRDN_BINDDN;
static char *base = LDAPMODRDN_BASE;
static char *base = NULL;
static char *passwd = NULL;
static char *ldaphost = LDAPHOST;
static char *ldaphost = NULL;
static int ldapport = LDAP_PORT;
static int not, verbose, contoper;
static LDAP *ld;
......@@ -37,6 +37,26 @@ main( argc, argv )
extern char *optarg;
extern int optind;
FILE *getbase;
if((getbase = fopen("/etc/ldapserver","r"))) {
ldaphost = malloc(1024);
fgets(ldaphost, 1024, getbase);
if(ldaphost[strlen(ldaphost) - 1] == '\n')
ldaphost[strlen(ldaphost) - 1] = '\0';
fclose(getbase);
}
if(!ldaphost)
ldaphost = LDAPHOST;
if((getbase = fopen("/etc/defaultbase.ldap","r"))) {
base = malloc(1024);
fgets(base, 1024, getbase);
if(base[strlen(base) - 1] == '\n')
base[strlen(base) - 1] = '\0';
fclose(getbase);
}
if(!base)
base = LDAPMODRDN_BASE;
infile = NULL;
kerberos = not = contoper = verbose = remove = 0;
......
......@@ -53,8 +53,8 @@ char *s;
static char *binddn = LDAPSEARCH_BINDDN;
static char *passwd = NULL;
static char *base = LDAPSEARCH_BASE;
static char *ldaphost = LDAPHOST;
static char *base = NULL;
static char *ldaphost = NULL;
static int ldapport = LDAP_PORT;
static char *sep = DEFSEP;
static char *sortattr = NULL;
......@@ -72,6 +72,25 @@ char **argv;
LDAP *ld;
extern char *optarg;
extern int optind;
FILE *getbase;
if((getbase = fopen("/etc/ldapserver","r"))) {
ldaphost = malloc(1024);
fgets(ldaphost, 1024, getbase);
if(ldaphost[strlen(ldaphost) - 1] == '\n')
ldaphost[strlen(ldaphost) - 1] = '\0';
fclose(getbase);
}
if(!ldaphost)
ldaphost = LDAPHOST;
if((getbase = fopen("/etc/defaultbase.ldap","r"))) {
base = malloc(1024);
fgets(base, 1024, getbase);
if(base[strlen(base) - 1] == '\n')
base[strlen(base) - 1] = '\0';
fclose(getbase);
}
if(!base)
base = LDAPSEARCH_BASE;
infile = NULL;
deref = verbose = allow_binary = not = kerberos = vals2tmp =
......
......@@ -543,6 +543,7 @@ initialize_client()
extern SIG_FN attn(); /* ^C signal handler */
extern char *getenv();
extern void Free();
FILE *getbase;
#ifdef DEBUG
if (debug & D_TRACE)
......@@ -618,7 +619,15 @@ initialize_client()
group_base = strdup(UD_WHERE_GROUPS_ARE_CREATED);
if (search_base == NULL)
search_base = strdup(UD_BASE);
if (server == NULL)
if((getbase = fopen("/etc/ldapserver","r"))) {
server = malloc(1024);
fgets(server, 1024, getbase);
if(server[strlen(server) - 1] == '\n')
server[strlen(server) - 1] = '\0';
fclose(getbase);
}
if(!server)
server = strdup(LDAPHOST);
/*
......
......@@ -29,7 +29,7 @@ char *srcldapbinddn;
char *srcldappasswd;
char *destldapbinddn;
char *destldappasswd;
char *ldapbase;
char *ldapbase = NULL;
int srcldapauthmethod;
int destldapauthmethod;
int verbose;
......@@ -81,11 +81,29 @@ main( int argc, char **argv )
char *s;
extern int optind;
extern char *optarg;
FILE *getbase;
ldapsrcurl = NULL;
ldapdesturl = NULL;
if((getbase = fopen("/etc/ldapserver","r"))) {
ldaphost = malloc(1024);
fgets(ldaphost, 1024, getbase);
if(ldaphost[strlen(ldaphost) - 1] == '\n')
ldaphost[strlen(ldaphost) - 1] = '\0';
fclose(getbase);
}
if(!ldaphost)
ldaphost = LDAPHOST;
if((getbase = fopen("/etc/defaultbase.ldap","r"))) {
ldapbase = malloc(1024);
fgets(ldapbase, 1024, getbase);
if(ldapbase[strlen(ldapbase) - 1] == '\n')
ldapbase[strlen(ldapbase) - 1] = '\0';
fclose(getbase);
}
if(!ldapbase)
ldapbase = DEFAULT_BASE;
srcldapauthmethod = LDAP_AUTH_SIMPLE;
destldapauthmethod = LDAP_AUTH_SIMPLE;
srcldapbinddn = NULL;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment