Adds possibility to use include with wildcards and env vars

This commit is contained in:
Felipe Zimmerle
2015-09-29 14:06:13 -07:00
parent cb9524ffd7
commit 900af2cd48
3 changed files with 42 additions and 17 deletions

View File

@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <wordexp.h>
#include <stdint.h>
@@ -1022,5 +1023,22 @@ std::string toHexIfNeeded(const std::string &str) {
}
std::vector<std::string> expandEnv(const std::string& var, int flags)
{
std::vector<std::string> vars;
wordexp_t p;
if (wordexp(var.c_str(), &p, flags) == false) {
if (p.we_wordc) {
for (char** exp = p.we_wordv; *exp; ++exp) {
vars.push_back(exp[0]);
}
}
wordfree(&p);
}
return vars;
}
} // namespace ModSecurity