Skip to content

Commit 52e1245

Browse files
author
ralfluebben
committed
*** empty log message ***
1 parent 9065c5c commit 52e1245

9 files changed

+98
-109
lines changed

AcctScheduler.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ void AcctScheduler::parseStatusFile(PluginContext *context, uint64_t *bytesin, u
195195

196196
//open the status file to read
197197
ifstream file(context->conf.getStatusFile().c_str(), ios::in);
198-
199198
if (file.is_open())
200199
{
201200
if (DEBUG (context->getVerbosity()))

AuthenticationProcess.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ void AuthenticationProcess::Authentication(PluginContext * context)
7474
user->setUsername(context->authsocketforegr.recvStr());
7575
user->setPassword(context->authsocketforegr.recvStr());
7676
user->setPortnumber(context->authsocketforegr.recvInt());
77+
user->setSessionId(context->authsocketforegr.recvStr());
7778
user->setCallingStationId(context->authsocketforegr.recvStr());
7879
user->setCommonname(context->authsocketforegr.recvStr());
7980
// framed-ip is an @IP if we're renegotiating, "" otherwise

ChangeLog

+6-3
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ radiusplugin_2.0b:
6666
- update example config file
6767
- use string for config parsing
6868
- correct bug in Config.cpp: parameter status was detected wrong if parameter status-version parameter is used in OpenVPN config
69-
- don't delete client config file at CLIENT-DISCONNECT it could already a new file from a new AUTH-USER-PASS-VERIFY
69+
- don't delete client config file at CLIENT-DISCONNECT it could be already a new file from a new AUTH-USER-PASS-VERIFY
7070
- Fix segmentation fault in radiusplugin.cpp. The error occurs if an accounting request fails after a successful authentication.
7171

7272
radiusplugin_2.0c:
@@ -75,7 +75,7 @@ radiusplugin_2.0c:
7575
- delete NAS port if authentication fails
7676

7777
radiusplugin_2.0d_beta:
78-
- add some some headerfiles to avoid compiling errors on Fedora with gcc4
78+
- add some headerfiles to avoid compiling errors on Fedora with gcc4
7979
- close socket in radiuspacket.cpp on retries
8080
- add parenthesize to avoid compiler warnings
8181

@@ -93,4 +93,7 @@ radiusplugin_2.1:
9393
- Rewrite ACF file when the user is authenticated.
9494
- Include nested configfiles from main configfile.
9595
- Add "\r" in the configfile parser, before the carriage return was ignored.
96-
- Add support for RADIUS reply message, the output is sent to stderr
96+
- Add support for RADIUS reply message, the output is sent to stderr
97+
- Only create the client-config file, if one of attributes for it is defined.
98+
- Add NAS port number to the session id, it's definitely unique
99+
- Acct-Session-Id added to Access-Request packet (RFC2866)

Config.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,14 @@ int Config::parseConfigFile(const char * configfile)
215215
// trim leading whitespace again
216216
pos = line.find_first_not_of(" \t");
217217
if (pos != string::npos) line.erase(0,pos);
218-
219218
//delete the trailing version of status if there
220219
pos = line.find_first_of(delims);
221220
if (pos != string::npos) line.erase(pos);
222221
this->deletechars(&line);
223-
224222
if(!line.empty())
225223
{
226-
this->statusfile=line;
224+
225+
this->statusfile=line;
227226
}
228227
}
229228
}

RadiusClass/RadiusAttribute.cpp

+26-21
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,19 @@ char * RadiusAttribute::makePasswordHash(const char *password,char * hpassword,
162162

163163
//build the hash
164164
if (!gcry_control (GCRYCTL_ANY_INITIALIZATION_P))
165-
// { /* No other library has already initialized libgcrypt. */
166-
//
167-
// gcry_control(GCRYCTL_SET_THREAD_CBS,&gcry_threads_pthread);
168-
//
169-
// if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) )
170-
// {
171-
// cerr << "libgcrypt is too old (need " << NEED_LIBGCRYPT_VERSION << ", have " << gcry_check_version (NULL) << ")\n";
172-
// }
173-
// gcry_control (GCRYCTL_INITIALIZATION_FINISHED);
174-
// }
165+
{ /* No other library has already initialized libgcrypt. */
166+
167+
gcry_control(GCRYCTL_SET_THREAD_CBS,&gcry_threads_pthread);
168+
169+
if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) )
170+
{
171+
cerr << "libgcrypt is too old (need " << NEED_LIBGCRYPT_VERSION << ", have " << gcry_check_version (NULL) << ")\n";
172+
}
173+
/* Disable secure memory. */
174+
gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
175+
176+
gcry_control (GCRYCTL_INITIALIZATION_FINISHED);
177+
}
175178

176179
gcry_md_open(&context, GCRY_MD_MD5, 0);
177180
gcry_md_write(context, sharedSecret, strlen(sharedSecret));
@@ -202,17 +205,19 @@ char * RadiusAttribute::makePasswordHash(const char *password,char * hpassword,
202205

203206
//put the hash of the last XOR in the digest
204207
//build the hash
205-
// if (!gcry_control (GCRYCTL_ANY_INITIALIZATION_P))
206-
// { /* No other library has already initialized libgcrypt. */
207-
//
208-
// gcry_control(GCRYCTL_SET_THREAD_CBS,&gcry_threads_pthread);
209-
//
210-
// if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) )
211-
// {
212-
// cerr << "libgcrypt is too old (need " << NEED_LIBGCRYPT_VERSION << ", have " << gcry_check_version (NULL) << ")\n";
213-
// }
214-
// gcry_control (GCRYCTL_INITIALIZATION_FINISHED);
215-
// }
208+
if (!gcry_control (GCRYCTL_ANY_INITIALIZATION_P))
209+
{ /* No other library has already initialized libgcrypt. */
210+
211+
gcry_control(GCRYCTL_SET_THREAD_CBS,&gcry_threads_pthread);
212+
213+
if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) )
214+
{
215+
cerr << "libgcrypt is too old (need " << NEED_LIBGCRYPT_VERSION << ", have " << gcry_check_version (NULL) << ")\n";
216+
}
217+
/* Disable secure memory. */
218+
gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
219+
gcry_control (GCRYCTL_INITIALIZATION_FINISHED);
220+
}
216221
gcry_md_open (&context, GCRY_MD_MD5, 0);
217222
gcry_md_write(context, sharedSecret, strlen(sharedSecret));
218223
gcry_md_write(context, hpassword+(k*MD5_DIGEST_LENGTH), MD5_DIGEST_LENGTH);

RadiusClass/RadiusPacket.cpp

+26-22
Original file line numberDiff line numberDiff line change
@@ -578,17 +578,19 @@ void RadiusPacket::calcacctdigest(const char *secret)
578578

579579
memset((this->sendbuffer+4), 0, 16);
580580
//build the hash
581-
// if (!gcry_control (GCRYCTL_ANY_INITIALIZATION_P))
582-
// { /* No other library has already initialized libgcrypt. */
583-
//
584-
// gcry_control(GCRYCTL_SET_THREAD_CBS,&gcry_threads_pthread);
585-
//
586-
// if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) )
587-
// {
588-
// cerr << "libgcrypt is too old (need " << NEED_LIBGCRYPT_VERSION << ", have " << gcry_check_version (NULL) << ")\n";
589-
// }
590-
// gcry_control (GCRYCTL_INITIALIZATION_FINISHED);
591-
// }
581+
if (!gcry_control (GCRYCTL_ANY_INITIALIZATION_P))
582+
{ /* No other library has already initialized libgcrypt. */
583+
584+
gcry_control(GCRYCTL_SET_THREAD_CBS,&gcry_threads_pthread);
585+
586+
if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) )
587+
{
588+
cerr << "libgcrypt is too old (need " << NEED_LIBGCRYPT_VERSION << ", have " << gcry_check_version (NULL) << ")\n";
589+
}
590+
/* Disable secure memory. */
591+
gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
592+
gcry_control (GCRYCTL_INITIALIZATION_FINISHED);
593+
}
592594
gcry_md_open (&context, GCRY_MD_MD5, 0);
593595
gcry_md_write(context, this->sendbuffer, this->length);
594596
gcry_md_write(context, secret, strlen(secret));
@@ -667,17 +669,19 @@ int RadiusPacket::authenticateReceivedPacket(const char *secret)
667669

668670
//bulid the hash of the copy
669671
//build the hash
670-
// if (!gcry_control (GCRYCTL_ANY_INITIALIZATION_P))
671-
// { /* No other library has already initialized libgcrypt. */
672-
//
673-
// gcry_control(GCRYCTL_SET_THREAD_CBS,&gcry_threads_pthread);
674-
//
675-
// if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) )
676-
// {
677-
// cerr << "libgcrypt is too old (need " << NEED_LIBGCRYPT_VERSION << ", have " << gcry_check_version (NULL) << ")\n";
678-
// }
679-
// gcry_control (GCRYCTL_INITIALIZATION_FINISHED);
680-
// }
672+
if (!gcry_control (GCRYCTL_ANY_INITIALIZATION_P))
673+
{ /* No other library has already initialized libgcrypt. */
674+
675+
gcry_control(GCRYCTL_SET_THREAD_CBS,&gcry_threads_pthread);
676+
677+
if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) )
678+
{
679+
cerr << "libgcrypt is too old (need " << NEED_LIBGCRYPT_VERSION << ", have " << gcry_check_version (NULL) << ")\n";
680+
}
681+
/* Disable secure memory. */
682+
gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
683+
gcry_control (GCRYCTL_INITIALIZATION_FINISHED);
684+
}
681685
gcry_md_open (&context, GCRY_MD_MD5, 0);
682686
gcry_md_write(context, cpy_recvpacket, this->recvbufferlen);
683687
gcry_md_write(context, secret, strlen(secret));

UserAcct.cpp

+36-53
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,48 @@ UserAcct::UserAcct():User()
3232
bytesout=0;
3333
nextupdate=0;
3434
starttime=0;
35-
3635
}
3736

3837
/** The destructor. Nothing happens here.*/
3938
UserAcct::~UserAcct()
4039
{
4140
}
4241

42+
/** The assignment-operator.
43+
* @param u A refernece to a UserAcct.*/
44+
UserAcct & UserAcct::operator=(const UserAcct &u)
45+
{
46+
47+
if (this!=&u)
48+
{
49+
this->User::operator=(u);
50+
this->gigain=u.gigain;
51+
this->gigaout=u.gigaout;
52+
this->bytesin=u.bytesin;
53+
this->bytesout=u.bytesout;
54+
this->nextupdate=u.nextupdate;
55+
this->starttime=u.starttime;
56+
}
57+
return *this;
58+
}
59+
60+
61+
62+
63+
/**The copy constructor, it calls first the copy constructor
64+
* of the User class.
65+
* @param UserAcct u : A reference to an UserAcct object.*/
66+
UserAcct::UserAcct(const UserAcct &u):User(u)
67+
{
68+
this->gigain=u.gigain;
69+
this->gigaout=u.gigaout;
70+
this->bytesin=u.bytesin;
71+
this->bytesout=u.bytesout;
72+
this->nextupdate=u.nextupdate;
73+
this->starttime=u.starttime;
74+
75+
}
76+
4377
/** The method sends an accounting update packet for the user to the radius server.
4478
* The accounting information are read from the OpenVpn
4579
* status file. The following attributes are sent to the radius server:
@@ -859,58 +893,7 @@ void UserAcct::addSystemRoutes(PluginContext * context)
859893

860894
}
861895

862-
/** The assignment-operator.
863-
* @param u A refernece to a UserAcct.*/
864-
UserAcct & UserAcct::operator=(const UserAcct &u)
865-
{
866-
867-
if (this!=&u)
868-
{
869-
this->sessionid=u.sessionid;
870-
//this->servicetype=u.servicetype;
871-
872-
this->gigain=u.gigain;
873-
this->gigaout=u.gigaout;
874-
this->bytesin=u.bytesin;
875-
this->bytesout=u.bytesout;
876-
this->nextupdate=u.nextupdate;
877-
this->starttime=u.starttime;
878-
}
879-
return *this;
880-
}
881-
882-
883896

884-
/**The copy constructor, it calls first the copy constructor
885-
* of the User class.
886-
* @param UserAcct u : A reference to an UserAcct object.*/
887-
UserAcct::UserAcct(const UserAcct &u):User(u)
888-
{
889-
890-
this->sessionid=u.sessionid;
891-
//this->servicetype=u.servicetype;
892-
893-
this->gigain=u.gigain;
894-
this->gigaout=u.gigaout;
895-
this->bytesin=u.bytesin;
896-
this->bytesout=u.bytesout;
897-
this->nextupdate=u.nextupdate;
898-
this->starttime=u.starttime;
899-
900-
}
901-
902-
/** The getter method for the sessionid.
903-
* @return An integer of the sessionid.*/
904-
string UserAcct::getSessionId(void)
905-
{
906-
return this->sessionid;
907-
}
908-
/**The setter method for the sessionid.
909-
* @param id The session id.*/
910-
void UserAcct::setSessionId(string id)
911-
{
912-
this->sessionid=id;
913-
}
914897

915898

916899
/** The getter method for the gigain variable.
@@ -995,7 +978,7 @@ int UserAcct::deleteCcdFile(PluginContext * context)
995978
{
996979
string filename;
997980
filename = context->conf.getCcdPath()+ this->getCommonname();
998-
if(context->conf.getOverWriteCCFiles())
981+
if(context->conf.getOverWriteCCFiles()==true && (this->getFramedIp().length() > 0 || this->getFramedRoutes().length() > 0))
999982
{
1000983
remove(filename.c_str());
1001984
}

UserAcct.h

-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
class UserAcct : public User
3939
{
4040
private:
41-
string sessionid; /**< The sessionid of the user.*/
4241
uint32_t gigain; /**< The received bytes.*/
4342
uint32_t gigaout; /**< The sent bytes.*/
4443
uint32_t bytesin; /**< The received bytes.*/
@@ -53,9 +52,6 @@ class UserAcct : public User
5352
UserAcct();
5453
~UserAcct();
5554

56-
string getSessionId(void);
57-
void setSessionId(string);
58-
5955
int getServiceType(void);
6056
void setServiceType(int);
6157

UserPlugin.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ class UserPlugin : public User
3636
{
3737
private:
3838
string password; /**<The user password.*/
39-
string sessionid; /**<The user sessionid.*/
4039
string authcontrolfile; /**<The auth control file of the user.*/
41-
bool authenticated; /**<Indicates if a user is authenticated.*/
40+
bool authenticated; /**<Indicates if a user is authenticated.*/
4241
bool accounted; /**<Indicates if a user is accounted.*/
4342

4443

0 commit comments

Comments
 (0)