diff options
author | james <james@e7ae566f-a301-0410-adde-c780ea21d3b5> | 2007-10-22 19:19:21 +0000 |
---|---|---|
committer | james <james@e7ae566f-a301-0410-adde-c780ea21d3b5> | 2007-10-22 19:19:21 +0000 |
commit | 7256e6b4d6439695fc1221b00ae0b876006ffe75 (patch) | |
tree | bd2d99212b5015433fbecd0a97f64f5fb2dca3f6 | |
parent | Added --management-signal option to signal SIGUSR1 when the management (diff) | |
download | openvpn-7256e6b4d6439695fc1221b00ae0b876006ffe75.tar.xz |
Modified command line and config file parser to allow
quoted strings using single quotes ('') (Alon Bar-Lev).
git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@2414 e7ae566f-a301-0410-adde-c780ea21d3b5
-rw-r--r-- | openvpn.8 | 7 | ||||
-rw-r--r-- | options.c | 17 |
2 files changed, 20 insertions, 4 deletions
@@ -380,13 +380,14 @@ can be removed, and the command can be given as 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 @@ -2577,6 +2577,7 @@ parse_line (const char *line, 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 = ""; @@ -2599,7 +2600,7 @@ parse_line (const char *line, in = *c; out = 0; - if (!backslash && in == '\\') + if (!backslash && in == '\\' && state != STATE_READING_SQUOTED_PARM) { backslash = true; } @@ -2613,6 +2614,8 @@ parse_line (const char *line, break; if (!backslash && in == '\"') state = STATE_READING_QUOTED_PARM; + else if (!backslash && in == '\'') + state = STATE_READING_SQUOTED_PARM; else { out = in; @@ -2634,6 +2637,13 @@ parse_line (const char *line, 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); */ @@ -2681,6 +2691,11 @@ parse_line (const char *line, 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); |