Skip to content

Commit bd9f5cf

Browse files
author
ralfluebben
committed
Implement overwriteccfiles config file parameter
1 parent 6bb34bc commit bd9f5cf

File tree

4 files changed

+41
-21
lines changed

4 files changed

+41
-21
lines changed

Diff for: Config.cpp

+37-20
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ int Config::parseConfigFile(const char * configfile)
120120
this->getValue(line.c_str(), tmp);
121121
this->openvpnconfig=tmp;
122122
}
123-
if (strncmp(line.c_str(),"overwriteccfiles=",14)==0)
123+
if (strncmp(line.c_str(),"overwriteccfiles=",17)==0)
124124
{
125125
this->getValue(line.c_str(), tmp);
126126
string stmp=tmp;
@@ -142,34 +142,52 @@ int Config::parseConfigFile(const char * configfile)
142142
while(file2.eof()==false)
143143
{
144144
getline(file2,line);
145-
this->deletechars(&line);
146145
if(line.empty()==false)
147146
{
148-
if (line == "client-cert-not-required")
147+
if (line.find("client-cert-not-required") != string::npos)
149148
{
150-
this->clientcertnotrequired=true;
149+
this->deletechars(&line);
150+
if (line == "client-cert-not-required")
151+
{
152+
this->clientcertnotrequired=true;
153+
}
151154
}
152-
if (line == "username-as-common-name")
155+
if (line.find("username-as-common-name") != string::npos)
153156
{
154-
this->usernameascommonname=true;
157+
this->deletechars(&line);
158+
if (line == "username-as-common-name")
159+
{
160+
this->usernameascommonname=true;
161+
}
155162
}
156-
if (line == "username-as-common-name")
157-
{
158-
this->usernameascommonname=true;
159-
}
160-
if (string::size_type pos = line.find("client-config-dir") != string::npos)
163+
if (line.find("client-config-dir") != string::npos)
161164
{
162-
line.erase(0, pos + 17);
163165
this->deletechars(&line);
166+
line.erase(0, 17);
164167
this->setCcdPath(line);
165168
}
166169
if (string::size_type pos = line.find("status") != string::npos)
167170
{
168-
line.erase(0, pos + 6);
169-
this->deletechars(&line);
170-
pos = line.find(" ");
171+
172+
pos = line.find_first_of("#");
173+
if (pos != string::npos)
174+
{
175+
line.erase(pos);
176+
}
177+
// trim leading whitespace
178+
char const* delims = " \t\r\n\0";
179+
pos = line.find_first_not_of(delims);
180+
if (pos != string::npos) line.erase(0,pos );
181+
line.erase(0, 6);
182+
//delete the trailing version of status if there
183+
pos = line.find_last_of(" ");
171184
if (pos != string::npos) line.erase(pos);
172-
this->statusfile=line;
185+
this->deletechars(&line);
186+
187+
if(!line.empty())
188+
{
189+
this->statusfile=line;
190+
}
173191
}
174192
}
175193
}
@@ -200,17 +218,15 @@ void Config::deletechars(string * line)
200218
// trim leading whitespace
201219
string::size_type pos = line->find_first_not_of(delims);
202220
if (pos != string::npos) line->erase(0,pos );
203-
204221
// trim trailing whitespace
205222
pos = line->find_last_not_of(delims);
206223
if (pos != string::npos) line->erase(pos+1);
207-
208-
224+
209225
//trim whitespaces in line
210226
pos = line->find_first_of(delims);
211227
while (pos != string::npos)
212228
{
213-
line->erase(pos);
229+
line->erase(pos,1);
214230
pos = line->find_first_of(delims);
215231
}
216232

@@ -220,6 +236,7 @@ void Config::deletechars(string * line)
220236
{
221237
line->erase(pos);
222238
}
239+
223240
}
224241

225242

Diff for: RadiusClass/Changelog

+1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ RadiusClass_v2.0:
2222
RadiusClass_v2.0b:
2323
21.07.07: Support for gigawords
2424
Improve parsing of config file..
25+
Correct parsing of IPADDRESS in RadiusAttribute.cpp in setValue() for data type IPADDRESS
2526

Diff for: UserAuth.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -1472,6 +1472,7 @@ int UserAuth::createCcdFile(PluginContext *context)
14721472
int j=0,k=0;
14731473
int len=0;
14741474

1475+
14751476
if(context->conf.getOverWriteCCFiles()==true)
14761477
{
14771478
memset(ipstring,0,100);
@@ -1481,6 +1482,7 @@ int UserAuth::createCcdFile(PluginContext *context)
14811482
//create the filename, ccd-path + commonname
14821483
filename=context->conf.getCcdPath()+this->getCommonname();
14831484

1485+
14841486
if (DEBUG (context->getVerbosity()))
14851487
fprintf (stderr, "RADIUS-PLUGIN: BACKGROUND AUTH: Try to open ccd file.\n");
14861488

Diff for: radiusplugin.cnf

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ OpenVPNConfig=/etc/openvpn/server.conf
3333

3434
# Allows the plugin to overwrite the client config in client config file directory,
3535
# default is true
36-
overwriteccfiles=true
36+
overwriteccfiles=false
3737

3838
# Path to a script for vendor specific attributes.
3939
# Leave it out if you don't use an own script.

0 commit comments

Comments
 (0)