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 <stdlib.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#ifdef __OpenBSD__
|
||||||
|
#include <glob.h>
|
||||||
|
#else
|
||||||
#include <wordexp.h>
|
#include <wordexp.h>
|
||||||
|
#endif
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
@ -17,7 +17,11 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#ifdef __OpenBSD__
|
||||||
|
#include <glob.h>
|
||||||
|
#else
|
||||||
#include <wordexp.h>
|
#include <wordexp.h>
|
||||||
|
#endif
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <inttypes.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> expandEnv(const std::string& var, int flags) {
|
||||||
std::list<std::string> vars;
|
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;
|
wordexp_t p;
|
||||||
if (wordexp(var.c_str(), &p, flags) == false) {
|
if (wordexp(var.c_str(), &p, flags) == false) {
|
||||||
if (p.we_wordc) {
|
if (p.we_wordc) {
|
||||||
for (char** exp = p.we_wordv; *exp; ++exp) {
|
for (char** exp = p.we_wordv; *exp; ++exp) {
|
||||||
|
#endif
|
||||||
std::ifstream *iss = new std::ifstream(exp[0], std::ios::in);
|
std::ifstream *iss = new std::ifstream(exp[0], std::ios::in);
|
||||||
if (iss->is_open()) {
|
if (iss->is_open()) {
|
||||||
iss->close();
|
iss->close();
|
||||||
@ -131,12 +142,15 @@ std::list<std::string> expandEnv(const std::string& var, int flags) {
|
|||||||
delete iss;
|
delete iss;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef __OpenBSD__
|
||||||
|
globfree(&p);
|
||||||
|
#else
|
||||||
wordfree(&p);
|
wordfree(&p);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
return vars;
|
return vars;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool createDir(std::string dir, int mode, std::string *error) {
|
bool createDir(std::string dir, int mode, std::string *error) {
|
||||||
int ret = mkdir(dir.data(), mode);
|
int ret = mkdir(dir.data(), mode);
|
||||||
if (ret != 0 && errno != EEXIST) {
|
if (ret != 0 && errno != EEXIST) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user