Note that
configuration files can be nested to a reasonable depth.
-Double quotation characters ("") can be used
-to enclose single parameters containing whitespace,
+Double quotation or single quotation characters ("", '')
+can be used to enclose single parameters containing whitespace,
and "#" or ";" characters in the first column
can be used to denote comments.
Note that OpenVPN 2.0 and higher performs backslash-based shell
-escaping, so the following mappings should be observed:
+escaping for characters not in single quotations,
+so the following mappings should be observed:
.RS
.ft 3
const int STATE_READING_QUOTED_PARM = 1;
const int STATE_READING_UNQUOTED_PARM = 2;
const int STATE_DONE = 3;
+ const int STATE_READING_SQUOTED_PARM = 4;
const char *error_prefix = "";
in = *c;
out = 0;
- if (!backslash && in == '\\')
+ if (!backslash && in == '\\' && state != STATE_READING_SQUOTED_PARM)
{
backslash = true;
}
break;
if (!backslash && in == '\"')
state = STATE_READING_QUOTED_PARM;
+ else if (!backslash && in == '\'')
+ state = STATE_READING_SQUOTED_PARM;
else
{
out = in;
else
out = in;
}
+ else if (state == STATE_READING_SQUOTED_PARM)
+ {
+ if (in == '\'')
+ state = STATE_DONE;
+ else
+ out = in;
+ }
if (state == STATE_DONE)
{
/* ASSERT (parm_len > 0); */
msg (msglevel, "%sOptions error: No closing quotation (\") in %s:%d", error_prefix, file, line_num);
return 0;
}
+ if (state == STATE_READING_SQUOTED_PARM)
+ {
+ msg (msglevel, "%sOptions error: No closing single quotation (\') in %s:%d", error_prefix, file, line_num);
+ return 0;
+ }
if (state != STATE_INITIAL)
{
msg (msglevel, "%sOptions error: Residual parse state (%d) in %s:%d", error_prefix, state, file, line_num);