Fix a build failure on OpenBSD

The wordexp function doesn't exist in OpenBSD.  Skipping this
functionality only affects users who have bro installed in a directory
in the PATH and the directory name as it appears in PATH starts with
a tilde (e.g. "~/bin").  A simple workaround for affected users
would be to change the PATH environment variable to not contain any
tildes.
This commit is contained in:
Daniel Thayer 2016-12-02 13:17:30 -06:00
parent de1c13e3a3
commit 31e46d37f0

View file

@ -6,7 +6,9 @@
#include <utility>
#include <cstdlib>
#if !defined(__OpenBSD__)
#include <wordexp.h>
#endif
using namespace broxygen;
using namespace std;
@ -66,9 +68,11 @@ Manager::Manager(const string& arg_config, const string& bro_command)
const char* env_path = getenv("PATH");
string path = env_path ? string(env_path) + ":." : ".";
string path_to_bro;
#if !defined(__OpenBSD__)
wordexp_t expanded_path;
wordexp(path.c_str(), &expanded_path, WRDE_NOCMD);
string path_to_bro;
if ( expanded_path.we_wordc == 1 )
path_to_bro = find_file(bro_command, expanded_path.we_wordv[0]);
@ -77,6 +81,9 @@ Manager::Manager(const string& arg_config, const string& bro_command)
reporter->InternalWarning("odd expansion of path: %s\n", path.c_str());
path_to_bro = find_file(bro_command, path);
}
#else
path_to_bro = find_file(bro_command, path);
#endif
struct stat s;