]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
RAGE: add support for reading ldap host/base from files
authorKurt Zeilenga <kurt@openldap.org>
Sun, 9 Aug 1998 08:37:09 +0000 (08:37 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Sun, 9 Aug 1998 08:37:09 +0000 (08:37 +0000)
13 files changed:
clients/fax500/main.c
clients/fax500/rp500.c
clients/finger/main.c
clients/gopher/go500.c
clients/gopher/go500gw.c
clients/mail500/main.c
clients/rcpt500/main.c
clients/tools/ldapdelete.c
clients/tools/ldapmodify.c
clients/tools/ldapmodrdn.c
clients/tools/ldapsearch.c
clients/ud/main.c
servers/slapd/tools/centipede.c

index 7481d4980e860ec07b4756c89e0ff54d0f04ebef..7e3025123b251d5abcc79c06403d5b0008764226 100644 (file)
@@ -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;
 
index 25eece609dacd4d8217d6296ede3e47a5caa3965..dcc71b1e588adaf0f0cca6d5634323f4e4fc6cf7 100644 (file)
@@ -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 ) {
index 38c8dfc7696b0a4e8e7c3dd4c08f888f8e12b8f3..2af793f7881eaffe9e098af4ea8ed7acaca5ed49 100644 (file)
@@ -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 ) {
index 333787677a14ef869a5b8c13120d16681f44eec7..555752b31fa63f1fff0d19b3eea0d569fb6f2f79 100644 (file)
@@ -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 ) {
index 7f74fbf57c562e78dca41c33a5e9f4ac11a5c798..b9419ac9450dd10e1230ec27031b657c6ad2d6b0 100644 (file)
@@ -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;
index 5fdea962011536a366ef54fb7b72c77565e2acdc..6cf65b451ead16763bf244d65fc350e07c7a9123 100644 (file)
@@ -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] );
index 3e65ac233b6467731c569e486c1a6d2f8c901098..25a04dd78de495841d9ed3b8c2088f554b15a1f3 100644 (file)
@@ -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';
 
index 3054cfb54fe52aacc397d621398c0fb2f6187a86..57bd322890ae738bb5c6248b6599f79c7637e93c 100644 (file)
@@ -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;
index d09b9ad8398b4ece77746f25347a9f5b25db4f40..362dd84629ce37976b681cc51aa288c55c549044 100644 (file)
@@ -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 ];
index 69d99e7f5a469a9f58a2b34ee677427a86148b3c..797cd80444f7f810df4f8f3fd003697ae8878bba 100644 (file)
@@ -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;
index d96aff131711ea7bc85bde1ed6194a246c2d7afc..55da4847c60ec344e5f5f7d5ee4030760333a21f 100644 (file)
@@ -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 =
index cb2030c2833505a62e163df2509bae5d9f2fa734..91e37634fbc001eb74e89a7fe7af906ae41c481d 100644 (file)
@@ -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);
 
        /*
index 9919232b7aa31fd9b5fcc039e5125d8ba13ea7ef..11ab916f29afa45806d3bfb651c6f8a68668b250 100644 (file)
@@ -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;