@@ -120,7 +120,7 @@ int Config::parseConfigFile(const char * configfile)
120
120
this ->getValue (line.c_str (), tmp);
121
121
this ->openvpnconfig =tmp;
122
122
}
123
- if (strncmp (line.c_str ()," overwriteccfiles=" ,14 )==0 )
123
+ if (strncmp (line.c_str ()," overwriteccfiles=" ,17 )==0 )
124
124
{
125
125
this ->getValue (line.c_str (), tmp);
126
126
string stmp=tmp;
@@ -142,34 +142,52 @@ int Config::parseConfigFile(const char * configfile)
142
142
while (file2.eof ()==false )
143
143
{
144
144
getline (file2,line);
145
- this ->deletechars (&line);
146
145
if (line.empty ()==false )
147
146
{
148
- if (line == " client-cert-not-required" )
147
+ if (line. find ( " client-cert-not-required" ) != string::npos )
149
148
{
150
- this ->clientcertnotrequired =true ;
149
+ this ->deletechars (&line);
150
+ if (line == " client-cert-not-required" )
151
+ {
152
+ this ->clientcertnotrequired =true ;
153
+ }
151
154
}
152
- if (line == " username-as-common-name" )
155
+ if (line. find ( " username-as-common-name" ) != string::npos )
153
156
{
154
- this ->usernameascommonname =true ;
157
+ this ->deletechars (&line);
158
+ if (line == " username-as-common-name" )
159
+ {
160
+ this ->usernameascommonname =true ;
161
+ }
155
162
}
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)
161
164
{
162
- line.erase (0 , pos + 17 );
163
165
this ->deletechars (&line);
166
+ line.erase (0 , 17 );
164
167
this ->setCcdPath (line);
165
168
}
166
169
if (string::size_type pos = line.find (" status" ) != string::npos)
167
170
{
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 (" " );
171
184
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
+ }
173
191
}
174
192
}
175
193
}
@@ -200,17 +218,15 @@ void Config::deletechars(string * line)
200
218
// trim leading whitespace
201
219
string::size_type pos = line->find_first_not_of (delims);
202
220
if (pos != string::npos) line->erase (0 ,pos );
203
-
204
221
// trim trailing whitespace
205
222
pos = line->find_last_not_of (delims);
206
223
if (pos != string::npos) line->erase (pos+1 );
207
-
208
-
224
+
209
225
// trim whitespaces in line
210
226
pos = line->find_first_of (delims);
211
227
while (pos != string::npos)
212
228
{
213
- line->erase (pos);
229
+ line->erase (pos, 1 );
214
230
pos = line->find_first_of (delims);
215
231
}
216
232
@@ -220,6 +236,7 @@ void Config::deletechars(string * line)
220
236
{
221
237
line->erase (pos);
222
238
}
239
+
223
240
}
224
241
225
242
0 commit comments