1 /**************************************************
2 OpengateM - MAC address authentication system
3 module for Authentication by RADIUS
5 Copyright (C) 2002 Opengate Project Team
6 Written by Yoshiaki Watanabe
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 Email: watanaby@is.saga-u.ac.jp
23 **************************************************/
25 Thanks to programs and documentations refered.
26 The experimental implementation by Fuyuta Sato.
27 Manual files about RADIUS.
31 #include "opengatemmng.h"
33 /*****************************************/
34 /* Authenticate by RADIUS */
35 /*****************************************/
36 int authRadius(char *userid, char *passwd)
40 struct rad_handle *radh;
41 char hostname[ADDRMAXLN];
43 /* get radius config file path */
44 confFile=GetConfValue("AuthServer/ConfFile");
46 /* If not set, set default conf file path */
51 if( !(radh=rad_auth_open()) ){
52 err_msg("ERR at %s#%d: rad_auth_open",__FILE__,__LINE__);
56 if(gethostname(hostname,ADDRMAXLN) < 0){
57 err_msg("ERR at %s#%d: gethostname",__FILE__,__LINE__);
62 if(rad_config(radh,confFile) < 0){
63 err_msg("ERR at %s#%d: rad_config: %s",__FILE__,__LINE__,
69 if(rad_create_request(radh, RAD_ACCESS_REQUEST) < 0){
70 err_msg("ERR at %s#%d: rad_ceate_request: %s",__FILE__,__LINE__,
76 if(rad_put_string(radh,RAD_USER_NAME,userid)<0){
77 err_msg("ERR at %s#%d: rad_put_string: %s",__FILE__,__LINE__,
82 if(rad_put_string(radh,RAD_USER_PASSWORD,passwd)<0){
83 err_msg("ERR at %s#%d: rad_put_string: %s",__FILE__,__LINE__,
88 if(rad_put_string(radh,RAD_NAS_IDENTIFIER,hostname)<0){
89 err_msg("ERR at %s#%d: rad_put_string: %s",__FILE__,__LINE__,
94 if(rad_put_int(radh,RAD_SERVICE_TYPE,RAD_LOGIN)<0){
95 err_msg("ERR at %s#%d: rad_put_int: %s",__FILE__,__LINE__,
101 switch(rad_send_request(radh)){
102 case RAD_ACCESS_ACCEPT:
106 err_msg("ERR at %s#%d: rad_send_request: %s",__FILE__,__LINE__,
110 case RAD_ACCESS_REJECT:
111 case RAD_ACCESS_CHALLENGE:
112 case RAD_ACCOUNTING_RESPONSE:
121 int AuthRadius(char *userid, char *passwd)
125 if(debug>1) err_msg("DEBUG:=>authRadius(%s,passwd)",userid);
126 ret=authRadius(userid,passwd);
127 if(debug>1) err_msg("DEBUG:(%d)<=authRadius( )",ret);