Mike Machado
mike@innercite.com
InnerCite Inc.
-Engineering Manager
+Engineering Team Leader
+/***************************************************************************
+* 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"
+###########################################################################
+# 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
+/***************************************************************************
+* 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>
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;
}
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;
--- /dev/null
+# 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
-/* 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
+/***************************************************************************
+* 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>
/*
* 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;
}
-/*
- * 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>
*
* 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
*
*************************************************************************/
-/*
- * 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"
-/*
- * 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>
*
* 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
*
*************************************************************************/
-/*
- * 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"