Add new code, compiles with NO warnings. Untested but SHOULD work.
authormmachado <mmachado>
Fri, 17 Mar 2000 00:28:13 +0000 (00:28 +0000)
committermmachado <mmachado>
Fri, 17 Mar 2000 00:28:13 +0000 (00:28 +0000)
src/modules/rlm_sql/README
src/modules/rlm_sql/conf.h
src/modules/rlm_sql/db_mysql.sql
src/modules/rlm_sql/rlm_sql.c
src/modules/rlm_sql/rlm_sql.conf [new file with mode: 0644]
src/modules/rlm_sql/rlm_sql.h
src/modules/rlm_sql/sql.c
src/modules/rlm_sql/sql_module.c
src/modules/rlm_sql/sql_module.h
src/modules/rlm_sql/sql_mysql.c
src/modules/rlm_sql/sql_mysql.h

index a50d2e3..9002181 100644 (file)
@@ -10,4 +10,4 @@ FreeRADIUS SQL Module
 Mike Machado
 mike@innercite.com
 InnerCite Inc.
-Engineering Manager
+Engineering Team Leader
index 12cc8f4..4ba7a6d 100644 (file)
@@ -1,3 +1,10 @@
+/***************************************************************************
+*  conf.h                             rlm_sql - FreeRADIUS SQL Module      *
+*                                                                          *
+*      Configuration options for the SQL module                            *
+*                                                                          *
+*                                     Mike Machado <mike@innercite.com>    *
+***************************************************************************/
 #define CHECKRAD1              "/usr/sbin/checkrad"
 #define CHECKRAD2              "/usr/local/sbin/checkrad"
 
index cf80a40..a16d62d 100644 (file)
@@ -1,3 +1,13 @@
+###########################################################################
+#  db_mysql.sql                     rlm_sql - FreeRADIUS SQL Module       #
+#                                                                         #
+#     Database schema for MySQL rlm_sql module                            #
+#                                                                         #
+#     To load:                                                            #
+#         mysql -uroot -prootpass radius < db_mysql.sql                   #
+#                                                                         #
+#                                   Mike Machado <mike@innercite.com>     #
+###########################################################################
 # MySQL dump 4.0
 #
 # Host: localhost    Database: radius
index 860bc60..037b554 100644 (file)
@@ -1,3 +1,10 @@
+/***************************************************************************
+*  rlm_sql.c                          rlm_sql - FreeRADIUS SQL Module      *
+*                                                                          *
+*      Main SQL module file. Most ICRADIUS code is located in sql.c        *
+*                                                                          *
+*                                     Mike Machado <mike@innercite.com>    *
+***************************************************************************/
 #include "autoconf.h"
 
 #include <stdio.h>
@@ -106,7 +113,7 @@ static int rlm_sql_authorize(REQUEST *request, VALUE_PAIR **check_pairs, VALUE_P
                 return RLM_AUTZ_NOTFOUND;
         }
 
-        if (paircmp(request->packet->vps, check_tmp, reply_tmp) != 0) {
+        if (paircmp(request->packet->vps, check_tmp, &reply_tmp) != 0) {
                DEBUG2("Pairs do not match [%s]", name);
                return RLM_AUTZ_NOTFOUND;
        }
@@ -150,6 +157,7 @@ static int rlm_sql_authenticate(REQUEST *request) {
        char            query[] = "SELECT Value FROM %s WHERE UserName = '%s' AND Attribute = 'Password'";
 
        user = request->username->strvalue;
+       password = request->password->strvalue;
 
        if ((auth_pair = pairfind(request->packet->vps, PW_AUTHTYPE)) == NULL)
           return RLM_AUTH_REJECT;
diff --git a/src/modules/rlm_sql/rlm_sql.conf b/src/modules/rlm_sql/rlm_sql.conf
new file mode 100644 (file)
index 0000000..267c675
--- /dev/null
@@ -0,0 +1,24 @@
+# This file belongs to /etc/raddb/rlm_sql.conf
+# And should contain all the things to connect to your SQL server
+server localhost
+login root
+password rootpass
+
+radius_db radius
+acct_table radacct
+
+authcheck_table radcheck
+authreply_table radreply
+
+groupcheck_table radgroupcheck
+groupreply_table radgroupreply
+
+usergroup_table usergroup
+
+realms_table realms
+realmgroup_table realmgroup
+
+sensitiveusername off
+deletestalesessions on
+
+sqltrace off
index 84af7d5..bd3764c 100644 (file)
@@ -1,9 +1,10 @@
-/* freeradius sql module
-*          Mike Machado
-*          InnerCite
-*          mike@innercite.com
-*/
-
+/***************************************************************************
+*  rlm_sql.h                          rlm_sql - FreeRADIUS SQL Module      *
+*                                                                          *
+*      Header for main SQL module file                                     *
+*                                                                          *
+*                                     Mike Machado <mike@innercite.com>    *
+***************************************************************************/
 #include "sql_module.h"
 
 #define PW_VP_USERDATA         1
index 96217e9..2712473 100644 (file)
@@ -1,7 +1,15 @@
+/***************************************************************************
+*  sql.c                              rlm_sql - FreeRADIUS SQL Module      *
+*                                                                          *
+*      Main code directly taken from ICRADIUS                              *
+*                                                                          *
+*                                     Mike Machado <mike@innercite.com>    *
+***************************************************************************/
 #include       <sys/types.h>
 #include       <sys/socket.h>
 #include       <sys/time.h>
 #include       <sys/file.h>
+#include       <string.h>
 #include       <sys/stat.h>
 #include       <netinet/in.h>
 
@@ -654,7 +662,7 @@ static int sql_check_ts(SQL_ROW row) {
        /*
         *      Find NAS type.
         */
-       if ((nas = nas_find(ipstr2long(row[4]))) == NULL) {
+       if ((nas = nas_find(ip_addr(row[4]))) == NULL) {
                 log(L_ERR, "Accounting: unknown NAS [%s]", row[4]);
                 return -1;
         }
index 3f1b820..deab98d 100644 (file)
@@ -1,9 +1,10 @@
-/*
- * sql_module.c        - MySQL routines for FreeRADIUS SQL module 
- *
- * Mike Machado <mike@innercite.com>
- */
-
+/***************************************************************************
+*  sql_mysql.c                        rlm_sql - FreeRADIUS SQL Module      *
+*                                                                          *
+*      MySQL routines for rlm_sql                                          *
+*                                                                          *
+*                                     Mike Machado <mike@innercite.com>    *
+***************************************************************************/
 #include <stdio.h>
 #include <sys/stat.h>
 #include <stdlib.h>
@@ -144,7 +145,7 @@ int sql_num_rows(SQLSOCK *socket) {
  *
  *     Function: sql_fetch_row
  *
- *     Purpose: database specific fetch_row. Returns a SQL_RES struct
+ *     Purpose: database specific fetch_row. Returns a SQL_ROW struct
  *               with all the data for the query
  *
  *************************************************************************/
index 580c53f..c4bf98a 100644 (file)
@@ -1,9 +1,10 @@
-/*
- * sql_module.h - MySQL header for FreeRADIUS SQL module
- *
- * Mike Machado <mike@innercite.com>
- */
-
+/***************************************************************************
+*  sql_module.h                       rlm_sql - FreeRADIUS SQL Module      *
+*                                                                          *
+*      MySQL headers for rlm_sql                                           *
+*                                                                          *
+*                                     Mike Machado <mike@innercite.com>    *
+***************************************************************************/
 #include       <mysql/mysql.h>
 #include       "conf.h"
 
index 3f1b820..deab98d 100644 (file)
@@ -1,9 +1,10 @@
-/*
- * sql_module.c        - MySQL routines for FreeRADIUS SQL module 
- *
- * Mike Machado <mike@innercite.com>
- */
-
+/***************************************************************************
+*  sql_mysql.c                        rlm_sql - FreeRADIUS SQL Module      *
+*                                                                          *
+*      MySQL routines for rlm_sql                                          *
+*                                                                          *
+*                                     Mike Machado <mike@innercite.com>    *
+***************************************************************************/
 #include <stdio.h>
 #include <sys/stat.h>
 #include <stdlib.h>
@@ -144,7 +145,7 @@ int sql_num_rows(SQLSOCK *socket) {
  *
  *     Function: sql_fetch_row
  *
- *     Purpose: database specific fetch_row. Returns a SQL_RES struct
+ *     Purpose: database specific fetch_row. Returns a SQL_ROW struct
  *               with all the data for the query
  *
  *************************************************************************/
index 580c53f..c4bf98a 100644 (file)
@@ -1,9 +1,10 @@
-/*
- * sql_module.h - MySQL header for FreeRADIUS SQL module
- *
- * Mike Machado <mike@innercite.com>
- */
-
+/***************************************************************************
+*  sql_module.h                       rlm_sql - FreeRADIUS SQL Module      *
+*                                                                          *
+*      MySQL headers for rlm_sql                                           *
+*                                                                          *
+*                                     Mike Machado <mike@innercite.com>    *
+***************************************************************************/
 #include       <mysql/mysql.h>
 #include       "conf.h"