return false;
}
+ inline bool parse_path_option(const std::string& opt_name,
+ std::istringstream& stream)
+ {
+ std::string val;
+
+ if (stream >> val)
+ {
+ std::size_t prev_pos = 0;
+ while (true)
+ {
+ auto env_start = val.find('$', prev_pos);
+ if (env_start == std::string::npos)
+ {
+ if (prev_pos)
+ val.push_back('\'');
+ break;
+ }
+
+ if (env_start)
+ {
+ if (!prev_pos)
+ {
+ val.insert(prev_pos, "$\'");
+ env_start += 2;
+ }
+ val.replace(env_start, 1, "\' .. ");
+ }
+
+ auto env_end = val.find('/', env_start + 1);
+ if (env_end == std::string::npos)
+ break;
+
+ val.replace(env_end, 1, " .. \'/");
+ prev_pos = env_end + 5;
+ }
+
+ table_api.add_option(opt_name, val);
+ return true;
+ }
+
+ table_api.add_comment("snort.conf missing argument for: " + opt_name + " <string>");
+ return false;
+ }
+
inline bool parse_int_option(const std::string& opt_name,
std::istringstream& stream, bool append)
{
else if (keyword == "blacklist")
{
- std::string file_name;
- if( arg_stream >> file_name)
- {
- tmpval = table_api.add_option("blacklist", file_name);
- }
- else
- {
- data_api.failed_conversion(arg_stream, "reputation: blacklist <missing_arg>");
- tmpval = false;
- }
+ tmpval = parse_path_option("blacklist", arg_stream);
}
else if (keyword == "memcap")
{
}
else if (keyword == "whitelist")
{
- std::string file_name;
- if( arg_stream >> file_name)
- {
- tmpval = table_api.add_option("whitelist", file_name);
- }
- else
- {
- data_api.failed_conversion(arg_stream, "reputation: whitelist <missing_arg>");
- tmpval = false;
- }
+ tmpval = parse_path_option("whitelist", arg_stream);
}
else
{