cgroup.o: cgroup.h nsjail.h logs.h util.h
cmdline.o: cmdline.h nsjail.h caps.h config.h logs.h macros.h mnt.h user.h
cmdline.o: util.h
-config.o: caps.h nsjail.h cmdline.h config.h config.pb.h logs.h macros.h
+config.o: config.h nsjail.h caps.h cmdline.h config.pb.h logs.h macros.h
config.o: mnt.h user.h util.h
contain.o: contain.h nsjail.h caps.h cgroup.h cpu.h logs.h macros.h mnt.h
contain.o: net.h pid.h user.h util.h uts.h
*/
+#include "config.h"
+
#include <fcntl.h>
+#include <google/protobuf/io/zero_copy_stream_impl.h>
+#include <google/protobuf/text_format.h>
#include <stdio.h>
#include <sys/mount.h>
#include <sys/personality.h>
#include <sys/stat.h>
#include <sys/types.h>
-#include <google/protobuf/io/zero_copy_stream_impl.h>
-#include <google/protobuf/text_format.h>
#include <fstream>
#include <string>
#include <vector>
#include "caps.h"
#include "cmdline.h"
-#include "config.h"
#include "config.pb.h"
#include "logs.h"
#include "macros.h"
enum Mode {
LISTEN = 0; /* Listening on a TCP port */
- ONCE = 1; /* Running the command once only */
- RERUN = 2; /* Re-executing the command (forever) */
+ ONCE = 1; /* Running the command once only */
+ RERUN = 2; /* Re-executing the command (forever) */
EXECVE = 3; /* Executing command w/o the supervisor */
}
/* Should be self explanatory */
enum LogLevel {
- DEBUG = 0; /* Equivalent to the '-v' cmd-line option */
- INFO = 1; /* Default level */
+ DEBUG = 0; /* Equivalent to the '-v' cmd-line option */
+ INFO = 1; /* Default level */
WARNING = 2; /* Equivalent to the '-q' cmd-line option */
ERROR = 3;
FATAL = 4;
#include "macros.h"
#include "util.h"
-#include <string.h>
-
namespace logs {
static int _log_fd = STDERR_FILENO;
for (auto it = nsjconf->gids.begin() + 1; it != nsjconf->gids.end(); it++) {
groups.push_back(it->inside_id);
groupsString += std::to_string(it->inside_id);
- if (it < nsjconf->gids.end() - 1)
- groupsString += ", ";
+ if (it < nsjconf->gids.end() - 1) groupsString += ", ";
}
}
groupsString += "]";
LOG_D("setgroups(%lu, %s)", groups.size(), groupsString.c_str());
if (setgroups(groups.size(), groups.data()) == -1) {
+ /* Indicate errror if specific groups were requested */
+ if (groups.size() > 0) {
+ PLOG_E("setgroups(%lu, %s) failed", groups.size(), groupsString.c_str());
+ return false;
+ }
PLOG_D("setgroups(%lu, %s) failed", groups.size(), groupsString.c_str());
- return false;
}
if (!setResUid(nsjconf->uids[0].inside_id)) {