]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/plugins/radius/radrealms.c
Use autoconf/automake to configure and make ppp
[ppp.git] / pppd / plugins / radius / radrealms.c
index 169004248ba6f2b19b615bdd431d96d5bb8dfc96..a3b9a513bb53ab93a59e25e7d01e4b4930d3cf99 100644 (file)
 */
 
 static char const RCSID[] =
-    "$Id: radrealms.c,v 1.1 2002/10/05 04:35:24 fcusack Exp $";
+    "$Id: radrealms.c,v 1.2 2004/11/14 07:26:26 paulus Exp $";
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include "pppd.h"
 #include "radiusclient.h"
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
 
 char pppd_version[] = VERSION;
 
 char radrealms_config[MAXPATHLEN] = "/etc/radiusclient/realms";
 
 static option_t Options[] = {
-    { "realms-config-file", o_string, &radrealms_config },
+    { "realms-config-file", o_string, &radrealms_config,
+      "Configuration file for RADIUS realms", OPT_STATIC, NULL, MAXPATHLEN },
     { NULL }
 };
 
@@ -44,7 +50,7 @@ lookup_realm(char const *user,
     FILE *fd;
     SERVER *accts, *auths, *s;
     char buffer[512], *p;
-    int line, pos;
+    int line = 0;
     
     auths = (SERVER *) malloc(sizeof(SERVER));
     auths->max = 0;
@@ -66,10 +72,12 @@ lookup_realm(char const *user,
     
     if ((fd = fopen(radrealms_config, "r")) == NULL) {
        option_error("cannot open %s", radrealms_config);
+       free(auths);
+       free(accts);
        return;
-    } 
+    }
     info("Reading %s", radrealms_config);
-    
+
     while ((fgets(buffer, sizeof(buffer), fd) != NULL)) {
        line++;
 
@@ -85,6 +93,8 @@ lookup_realm(char const *user,
            fclose(fd);
            option_error("%s: invalid line %d: %s", radrealms_config,
                         line, buffer);
+           free(auths);
+           free(accts);
            return;
        }
        info("Parsing '%s' entry:", p);
@@ -99,6 +109,8 @@ lookup_realm(char const *user,
            fclose(fd);
            option_error("%s: realm name missing on line %d: %s",
                         radrealms_config, line, buffer);
+           free(auths);
+           free(accts);
            return;
        }
 
@@ -109,6 +121,8 @@ lookup_realm(char const *user,
                fclose(fd);
                option_error("%s: server address missing on line %d: %s",
                             radrealms_config, line, buffer);
+               free(auths);
+               free(accts);
                return;
            }
            s->name[s->max] = strdup(p);
@@ -117,6 +131,8 @@ lookup_realm(char const *user,
                fclose(fd);
                option_error("%s: server port missing on line %d:  %s",
                             radrealms_config, line, buffer);
+               free(auths);
+               free(accts);
                return;
            }
            s->port[s->max] = atoi(p);