[tac_plus] plugin-loading: 1/3: updating configuration parser

Steve Kemp steve at steve.org.uk
Wed Aug 22 08:43:54 UTC 2012


--- a/parse.c
+++ b/parse.c
@@ -96,6 +96,7 @@
     declare("ipx", S_ipx);
     declare("key", S_key);
     declare("lcp", S_lcp);
+    declare("load_plugin", S_load_plugin);
 #ifdef MAXSESS
     declare("maxsess", S_maxsess);
 #endif
@@ -106,6 +107,7 @@
     declare("login", S_login);
     declare("permit", S_permit);
     declare("pap", S_pap);
+    declare("plugin", S_plugin);
     declare("opap", S_opap);
     declare("ppp", S_ppp);
     declare("protocol", S_protocol);
@@ -164,6 +166,8 @@
 #endif
     case S_key:
 	return("key");
+    case S_load_plugin:
+    return("load_plugin");
     case S_user:
 	return("user");
     case S_group:
@@ -210,6 +214,8 @@
 #endif /* MSCHAP */
     case S_pap:
 	return("pap");
+    case S_plugin:
+    return("plugin");
     case S_opap:
 	return("opap");
     case S_cleartext:
--- a/parse.h
+++ b/parse.h
@@ -91,3 +91,5 @@
 #endif
 #define	S_syslog	50
 #define S_aceclnt	51
+#define S_load_plugin 52
+#define S_plugin      53
--- a/tac_plus.h
+++ b/tac_plus.h
@@ -199,6 +199,7 @@
     char *cfgfile;                 /* config file name */
     char *acctfile;                /* name of accounting file */
     char port[NAS_PORT_MAX_LEN+1]; /* For error reporting */
+    char *auth_plugin;             /* External authentication plugin library */
     u_char version;                /* version of last packet read */
 };
 
--- a/config.c
+++ b/config.c
@@ -746,7 +746,7 @@
 static int
 parse_decls()
 {
-
+    struct stat sb;   /* for stat()ing the auth plugin(s) */
     sym_code = 0;
     rch();
 
@@ -786,6 +786,24 @@
 	    sym_get();
 	    continue;
 
+    case S_load_plugin:
+           sym_get();
+           parse(S_separator);
+
+        if (session.auth_plugin != NULL)
+            free(session.auth_plugin);
+
+        session.auth_plugin = tac_strdup(sym_buf);
+        sym_get();
+
+        if ( stat( session.auth_plugin, &sb ) != 0 )
+        {
+             parse_error("plugin library %s doesn't exist lines %d and %d",
+                         session.auth_plugin, session.keyline, sym_line);
+             return(1);
+         }
+         continue;
+
 	case S_default:
 	    sym_get();
 	    switch (sym_code) {
@@ -1121,6 +1139,7 @@
 	    case S_file:
 	    case S_cleartext:
 	    case S_des:
+        case S_plugin:
 		sprintf(buf, "%s ", sym_buf);
 		sym_get();
 		strcat(buf, sym_buf);
@@ -1138,7 +1157,7 @@
 #ifdef HAVE_PAM
 			    "'PAM', "
 #endif
-			    "or 'des' keyword after 'login =' on line %d",
+			    "'plugin', or 'des' keyword after 'login =' on line %d",
 			    sym_line);
 	    }
 	    sym_get();
@@ -1164,6 +1183,7 @@
 	    case S_file:
 	    case S_cleartext:
 	    case S_des:
+        case S_plugin:
 		sprintf(buf, "%s ", sym_buf);
 		sym_get();
 		strcat(buf, sym_buf);


More information about the tac_plus mailing list