0
0
mirror of https://github.com/OpenVPN/openvpn3.git synced 2024-09-20 04:02:15 +02:00

Support "setenv opt" prefix before directives, where

its presence indicates that the directive is optional,
i.e. if a client doesn't understand the directive, it
should simply ignore it.
This commit is contained in:
James Yonan 2013-06-08 16:10:35 +00:00
parent 7d9921972e
commit 906584ba3b
3 changed files with 27 additions and 1 deletions

View File

@ -27,6 +27,7 @@
// debug settings (production setting in parentheses)
#define OPENVPN_INSTRUMENTATION // include debug instrumentation for classes (define)
//#define OPENVPN_DUMP_CONFIG // dump parsed configuration (comment out)
//#define OPENVPN_DEBUG_CLIPROTO // shows packets in/out (comment out)
#define OPENVPN_DEBUG_PROTO 1 // increases low-level protocol verbosity (1)
//#define OPENVPN_DEBUG_VERBOSE_ERRORS // verbosely log Error::Type errors (comment out)
@ -333,6 +334,12 @@ namespace openvpn {
kvl.push_back(new OptionList::KeyValue(kv.key, kv.value));
}
const ParseClientConfig cc = ParseClientConfig::parse(config.content, &kvl, options);
#ifdef OPENVPN_DUMP_CONFIG
std::cout << "---------- ARGS ----------" << std::endl;
std::cout << options.render() << std::endl;
std::cout << "---------- MAP ----------" << std::endl;
std::cout << options.render_map() << std::endl;
#endif
eval.error = cc.error();
eval.message = cc.message();
eval.userlockedUsername = cc.userlockedUsername();

View File

@ -225,6 +225,7 @@ namespace openvpn {
content_list->preprocess();
options.parse_from_key_value_list(*content_list, &limits);
}
process_setenv_opt(options);
options.update_map();
// add in missing options
@ -315,6 +316,16 @@ namespace openvpn {
}
private:
static void process_setenv_opt(OptionList& options)
{
for (OptionList::iterator i = options.begin(); i != options.end(); ++i)
{
Option& o = *i;
if (o.size() >= 3 && o.ref(0) == "setenv" && o.ref(1) == "opt")
o.remove_first(2);
}
}
static bool is_autologin(const OptionList& options)
{
const Option* autologin = options.get_ptr("AUTOLOGIN");

View File

@ -36,7 +36,7 @@
#include <string>
#include <sstream>
#include <vector>
#include <algorithm> // for std::sort
#include <algorithm> // for std::sort, std::min
#include <boost/cstdint.hpp> // for boost::uint64_t
#include <boost/algorithm/string.hpp> // for boost::algorithm::starts_with, ends_with
@ -185,6 +185,14 @@ namespace openvpn {
bool operator==(const Option& other) const { return data == other.data; }
bool operator!=(const Option& other) const { return data != other.data; }
// remove first n elements
void remove_first(const size_t n_elements)
{
const size_t n = std::min(data.size(), n_elements);
if (n)
data.erase(data.begin(), data.begin() + n);
}
private:
std::string err_ref() const
{