Skip to content

Commit

Permalink
config: don't throw exception if there's problem with config file rea…
Browse files Browse the repository at this point in the history
…ding
  • Loading branch information
robertswiecki committed Jun 25, 2024
1 parent f6f63bd commit 4f5ff26
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

#include <fstream>
#include <list>
#include <sstream>
#include <string>
#include <vector>

Expand Down Expand Up @@ -327,7 +328,14 @@ bool parseFile(nsjconf_t* nsjconf, const char* file) {
return false;
}

std::string conf((std::istreambuf_iterator<char>(ifs)), (std::istreambuf_iterator<char>()));
std::stringstream buffer;
buffer << ifs.rdbuf();
std::string conf = buffer.str();

if (ifs.good()) {
PLOG_W("Couldn't read config file '%s'", file);
return false;
}

/* Use static so we can get c_str() pointers, and copy them into the nsjconf struct */
static nsjail::NsJailConfig json_nsc;
Expand Down

0 comments on commit 4f5ff26

Please sign in to comment.