mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Use glob.h when using OpenBSD
This commit is contained in:
parent
d97688804e
commit
0c0b09ec52
@ -17,7 +17,11 @@
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#ifdef __OpenBSD__
|
||||
#include <glob.h>
|
||||
#else
|
||||
#include <wordexp.h>
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
|
@ -17,7 +17,11 @@
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#ifdef __OpenBSD__
|
||||
#include <glob.h>
|
||||
#else
|
||||
#include <wordexp.h>
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
@ -119,10 +123,17 @@ std::string get_path(const std::string& file) {
|
||||
std::list<std::string> expandEnv(const std::string& var, int flags) {
|
||||
std::list<std::string> vars;
|
||||
|
||||
#ifdef __OpenBSD__
|
||||
glob_t p;
|
||||
if (glob(var.c_str(), flags, NULL, &p) == false) {
|
||||
if (p.gl_pathc) {
|
||||
for (char** exp = p.gl_pathv; *exp; ++exp) {
|
||||
#else
|
||||
wordexp_t p;
|
||||
if (wordexp(var.c_str(), &p, flags) == false) {
|
||||
if (p.we_wordc) {
|
||||
for (char** exp = p.we_wordv; *exp; ++exp) {
|
||||
#endif
|
||||
std::ifstream *iss = new std::ifstream(exp[0], std::ios::in);
|
||||
if (iss->is_open()) {
|
||||
iss->close();
|
||||
@ -131,12 +142,15 @@ std::list<std::string> expandEnv(const std::string& var, int flags) {
|
||||
delete iss;
|
||||
}
|
||||
}
|
||||
#ifdef __OpenBSD__
|
||||
globfree(&p);
|
||||
#else
|
||||
wordfree(&p);
|
||||
#endif
|
||||
}
|
||||
return vars;
|
||||
}
|
||||
|
||||
|
||||
bool createDir(std::string dir, int mode, std::string *error) {
|
||||
int ret = mkdir(dir.data(), mode);
|
||||
if (ret != 0 && errno != EEXIST) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user