]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/plugins/radius/radrealms.c
pppd.8: Document netmask option
[ppp.git] / pppd / plugins / radius / radrealms.c
index cd006fd0894cae2cae87ec303daf1256839cbe87..ab923cc114a7114cb79928454719c04431e31e2f 100644 (file)
 static char const RCSID[] =
     "$Id: radrealms.c,v 1.2 2004/11/14 07:26:26 paulus Exp $";
 
-#include "pppd.h"
-#include "radiusclient.h"
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#include <sys/param.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdarg.h>
+#include <sys/types.h>
+
+#include <pppd/pppd.h>
+
+#include "radiusclient.h"
 
-char pppd_version[] = VERSION;
+char pppd_version[] = PPPD_VERSION;
 
 char radrealms_config[MAXPATHLEN] = "/etc/radiusclient/realms";
 
@@ -67,7 +74,7 @@ lookup_realm(char const *user,
     }
     
     if ((fd = fopen(radrealms_config, "r")) == NULL) {
-       option_error("cannot open %s", radrealms_config);
+       ppp_option_error("cannot open %s", radrealms_config);
        free(auths);
        free(accts);
        return;
@@ -87,7 +94,7 @@ lookup_realm(char const *user,
        if (p == NULL || (strcmp(p, "authserver") !=0
            && strcmp(p, "acctserver"))) {
            fclose(fd);
-           option_error("%s: invalid line %d: %s", radrealms_config,
+           ppp_option_error("%s: invalid line %d: %s", radrealms_config,
                         line, buffer);
            free(auths);
            free(accts);
@@ -103,7 +110,7 @@ lookup_realm(char const *user,
 
        if ((p = strtok(NULL, "\t ")) == NULL) {
            fclose(fd);
-           option_error("%s: realm name missing on line %d: %s",
+           ppp_option_error("%s: realm name missing on line %d: %s",
                         radrealms_config, line, buffer);
            free(auths);
            free(accts);
@@ -115,7 +122,7 @@ lookup_realm(char const *user,
            info(" - Matched realm %s", p);
            if ((p = strtok(NULL, ":")) == NULL) {
                fclose(fd);
-               option_error("%s: server address missing on line %d: %s",
+               ppp_option_error("%s: server address missing on line %d: %s",
                             radrealms_config, line, buffer);
                free(auths);
                free(accts);
@@ -125,7 +132,7 @@ lookup_realm(char const *user,
            info(" - Address is '%s'",p);
            if ((p = strtok(NULL, "\t ")) == NULL) {
                fclose(fd);
-               option_error("%s: server port missing on line %d:  %s",
+               ppp_option_error("%s: server port missing on line %d:  %s",
                             radrealms_config, line, buffer);
                free(auths);
                free(accts);
@@ -141,9 +148,13 @@ lookup_realm(char const *user,
 
     if (accts->max)
        *acctserver = accts;
+    else
+       free(accts);
 
     if (auths->max)
        *authserver = auths;
+    else
+       free(auths);
 
     return;
 }
@@ -153,6 +164,6 @@ plugin_init(void)
 {
     radius_pre_auth_hook = lookup_realm;
 
-    add_options(Options);
+    ppp_add_options(Options);
     info("RADIUS Realms plugin initialized.");
 }