Skip to content

Commit 5dbdc94

Browse files
author
ralfluebben
committed
*** empty log message ***
1 parent 6f15905 commit 5dbdc94

6 files changed

+24
-19
lines changed

AcctScheduler.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ void AcctScheduler::parseStatusFile(PluginContext *context, uint64_t *bytesin, u
208208
do
209209
{
210210
file.getline(line, 512);
211-
cerr << getTime() << "TEST: RADIUS-PLUGIN: BACKGROUND ACCT: " << line << endl;
212211

213212
}
214213
while (line!=NULL && strncmp(line,key.c_str(),key.length())!=0 && strcmp(line,"ROUTING TABLE")!=0 && file.eof()==false);

AuthenticationProcess.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ void AuthenticationProcess::Authentication(PluginContext * context)
7979
// framed-ip is an @IP if we're renegotiating, "" otherwise
8080
user->setFramedIp(context->authsocketforegr.recvStr());
8181

82-
if (DEBUG (context->getVerbosity()) && (user->getFramedIp().compare("") == 0))
83-
cerr << getTime() << "RADIUS-PLUGIN: BACKGROUND AUTH: New user auth: username: " << user->getUsername() << ", password: *****, calling station: " << user->getCallingStationId() << ", commonname: " << user->getCommonname() << ".\n";
82+
if (DEBUG (context->getVerbosity()) && (user->getFramedIp().compare("") == 0))
83+
cerr << getTime() << "RADIUS-PLUGIN: BACKGROUND AUTH: New user auth: username: " << user->getUsername() << ", password: *****, calling station: " << user->getCallingStationId() << ", commonname: " << user->getCommonname() << ".\n";
8484

85-
if (DEBUG (context->getVerbosity()) && (user->getFramedIp().compare("") !=0 ))
86-
cerr << getTime() << "RADIUS-PLUGIN: BACKGROUND AUTH: Old user ReAuth: username: " << user->getUsername() << ", password: *****, calling station: " << user->getCallingStationId() << ", commonname: " << user->getCommonname() << ".\n";
87-
88-
//send the AcceptRequestPacket
89-
if (user->sendAcceptRequestPacket(context)==0) /* Succeeded */
85+
if (DEBUG (context->getVerbosity()) && (user->getFramedIp().compare("") !=0 ))
86+
cerr << getTime() << "RADIUS-PLUGIN: BACKGROUND AUTH: Old user ReAuth: username: " << user->getUsername() << ", password: *****, calling station: " << user->getCallingStationId() << ", commonname: " << user->getCommonname() << ".\n";
87+
88+
//send the AcceptRequestPacket
89+
if (user->sendAcceptRequestPacket(context)==0) /* Succeeded */
9090
{
9191
//if the authentication succeeded
9292
//create the user configuration file

RadiusClass/RadiusPacket.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -496,13 +496,12 @@ int RadiusPacket::radiusReceive(list<RadiusServer> *serverlist)
496496
while (retries<=server->getRetry())
497497
{
498498
// wait for the specified time for a response
499-
tv.tv_sec = server->getWait();
499+
tv.tv_sec = server->getWait();
500500
tv.tv_usec = 0;
501501
FD_ZERO(&set); // clear out the set
502502
FD_SET(this->sock, &set); // wait only for the RADIUS UDP socket
503503
result = select(FD_SETSIZE, &set, NULL, NULL, &tv);
504-
505-
504+
506505
if (result>0)
507506
{
508507

UserAuth.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ int UserAuth::sendAcceptRequestPacket(PluginContext * context)
158158
cerr << getTime() << "RADIUS-PLUGIN: Packet was not sent.\n";
159159
}
160160
//receive the packet
161-
if (packet.radiusReceive(serverlist)==0)
161+
int rc=packet.radiusReceive(serverlist);
162+
if (rc==0)
162163
{
163164
//is it a accept?
164165
if(packet.getCode()==ACCESS_ACCEPT)
@@ -190,7 +191,7 @@ int UserAuth::sendAcceptRequestPacket(PluginContext * context)
190191
}
191192
else
192193
{
193-
cerr << getTime() << "RADIUS-PLUGIN: Got no response from radius server.\n";
194+
cerr << getTime() << "RADIUS-PLUGIN: Got no response from radius server, return code:" << rc << endl;
194195
}
195196

196197
return 1;

radiusplugin.cnf

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ subnet=255.255.255.0
3636
overwriteccfiles=true
3737

3838
# Allows the plugin to use auth control files if OpenVPN (>= 2.1 rc8) provides them.
39+
# The plugin needs write permission to the folder, by default it is the OpenVPN directory (e.g. /etc/openvpm)
40+
# The OpenVPN option tmp-dir changes the directory.
3941
# default is false
4042
# useauthcontrolfile=false
4143

radiusplugin.cpp

+10-6
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,6 @@ void * auth_user_pass_verify(void * c)
10541054
context->setResult(OPENVPN_PLUGIN_FUNC_ERROR);
10551055
pthread_cond_signal( context->getCondRecv( ));
10561056
pthread_mutex_unlock (context->getMutexRecv());
1057-
10581057
}
10591058
delete newuser;
10601059
}
@@ -1172,16 +1171,18 @@ void get_user_env(PluginContext * context,const int type,const char * envp[], Us
11721171
user->setUsername ( get_env ( "common_name", envp ) );
11731172
if ( get_env ( "password", envp ) !=NULL )
11741173
user->setPassword ( get_env ( "password", envp ) );
1175-
//rewrite the username if OpenVPN use the option username-as-comon-name
1174+
1175+
if ( get_env ( "common_name", envp ) !=NULL )
1176+
{
1177+
user->setCommonname ( get_env ( "common_name", envp ) );
1178+
}
1179+
1180+
//rewrite the commonname if OpenVPN use the option username-as-comon-name
11761181
if ( context->conf.getUsernameAsCommonname() == true )
11771182
{
11781183
if ( DEBUG ( context->getVerbosity() ) ) cerr << getTime() << "RADIUS-PLUGIN: FOREGROUND: Commonname set to Username\n";
11791184
user->setCommonname ( get_env ( "username", envp ) );
11801185
}
1181-
if ( get_env ( "common_name", envp ) !=NULL )
1182-
{
1183-
user->setCommonname ( get_env ( "common_name", envp ) );
1184-
}
11851186

11861187
string untrusted_ip;
11871188
// it's ipv4
@@ -1198,7 +1199,10 @@ void get_user_env(PluginContext * context,const int type,const char * envp[], Us
11981199
//for OpenVPN option client cert not required, common_name is "UNDEF", see status.log
11991200

12001201
user->setUntrustedPort ( get_env ( "untrusted_port", envp ) );
1202+
1203+
12011204
user->setStatusFileKey(user->getCommonname() + string ( "," ) + untrusted_ip + string ( ":" ) + get_env ( "untrusted_port", envp ) );
1205+
if ( DEBUG ( context->getVerbosity() ) ) cerr << getTime() << "RADIUS-PLUGIN: FOREGROUND: StatusFileKey: " << user->getStatusFileKey() << endl;
12021206
user->setKey(untrusted_ip + string ( ":" ) + get_env ( "untrusted_port", envp ) );
12031207
if ( DEBUG ( context->getVerbosity() ) ) cerr << getTime() << "RADIUS-PLUGIN: FOREGROUND: Key: " << user->getKey() << ".\n";
12041208
}

0 commit comments

Comments
 (0)