cgroup.o: cgroup.h nsjail.h logs.h util.h
cmdline.o: cmdline.h nsjail.h logs.h caps.h config.h macros.h mnt.h user.h
cmdline.o: util.h
-config.o: caps.h nsjail.h logs.h cmdline.h config.h macros.h mnt.h user.h
-config.o: util.h
+config.o: caps.h nsjail.h logs.h cmdline.h config.h config.pb.h macros.h
+config.o: mnt.h user.h util.h
contain.o: contain.h nsjail.h logs.h caps.h cgroup.h cpu.h mnt.h net.h pid.h
contain.o: user.h uts.h
cpu.o: cpu.h nsjail.h logs.h util.h
uts.o: uts.h nsjail.h logs.h
user.o: user.h nsjail.h logs.h macros.h subproc.h util.h
util.o: util.h nsjail.h logs.h macros.h
+config.pb.o: config.pb.h
};
int nameToVal(const char* name) {
- for (size_t i = 0; i < ARRAYSIZE(capNames); i++) {
+ for (size_t i = 0; i < ARR_SZ(capNames); i++) {
if (strcmp(name, capNames[i].name) == 0) {
return capNames[i].val;
}
static const std::string capToStr(int val) {
std::string res;
- for (size_t i = 0; i < ARRAYSIZE(capNames); i++) {
+ for (size_t i = 0; i < ARR_SZ(capNames); i++) {
if (val == capNames[i].val) {
return capNames[i].name;
}
/* Copy all permitted caps to the inheritable set */
dbgmsg[0] = '\0';
- for (size_t i = 0; i < ARRAYSIZE(capNames); i++) {
+ for (size_t i = 0; i < ARR_SZ(capNames); i++) {
if (getPermitted(cap_data, capNames[i].val)) {
util::sSnPrintf(dbgmsg, sizeof(dbgmsg), " %s", capNames[i].name);
setInheritable(cap_data, capNames[i].val);
/* Make sure the inheritable set is preserved across execve via the ambient set */
dbgmsg[0] = '\0';
- for (size_t i = 0; i < ARRAYSIZE(capNames); i++) {
+ for (size_t i = 0; i < ARR_SZ(capNames); i++) {
if (!getPermitted(cap_data, capNames[i].val)) {
continue;
}
*/
if (getEffective(cap_data, CAP_SETPCAP)) {
dbgmsg[0] = '\0';
- for (size_t i = 0; i < ARRAYSIZE(capNames); i++) {
+ for (size_t i = 0; i < ARR_SZ(capNames); i++) {
if (getInheritable(cap_data, capNames[i].val)) {
continue;
}
static void cmdlineUsage(const char* pname) {
LOG_HELP_BOLD("Usage: %s [options] -- path_to_command [args]", pname);
LOG_HELP_BOLD("Options:");
- for (size_t i = 0; i < ARRAYSIZE(custom_opts); i++) {
+ for (size_t i = 0; i < ARR_SZ(custom_opts); i++) {
cmdlineOptUsage(&custom_opts[i]);
}
LOG_HELP_BOLD("\nDeprecated options:");
- for (size_t i = 0; i < ARRAYSIZE(deprecated_opts); i++) {
+ for (size_t i = 0; i < ARR_SZ(deprecated_opts); i++) {
cmdlineOptUsage(&deprecated_opts[i]);
// Find replacement flag.
- for (size_t j = 0; j < ARRAYSIZE(custom_opts); j++) {
+ for (size_t j = 0; j < ARR_SZ(custom_opts); j++) {
if (custom_opts[j].opt.val == deprecated_opts[i].opt.val) {
LOG_HELP_BOLD(
"\tDEPRECATED: Use %s instead.", custom_opts[j].opt.name);
static char cmdlineTmpfsSz[PATH_MAX] = "size=4194304";
// Generate options array for getopt_long.
- size_t options_length = ARRAYSIZE(custom_opts) + ARRAYSIZE(deprecated_opts) + 1;
+ size_t options_length = ARR_SZ(custom_opts) + ARR_SZ(deprecated_opts) + 1;
struct option opts[options_length];
- for (unsigned i = 0; i < ARRAYSIZE(custom_opts); i++) {
+ for (unsigned i = 0; i < ARR_SZ(custom_opts); i++) {
opts[i] = custom_opts[i].opt;
}
- for (unsigned i = 0; i < ARRAYSIZE(deprecated_opts); i++) {
- opts[ARRAYSIZE(custom_opts) + i] = deprecated_opts[i].opt;
+ for (unsigned i = 0; i < ARR_SZ(deprecated_opts); i++) {
+ opts[ARR_SZ(custom_opts) + i] = deprecated_opts[i].opt;
}
// Last, NULL option as a terminator.
struct option terminator = {NULL, 0, NULL, 0};
}))
#endif /* !defined(TEMP_FAILURE_RETRY) */
-#if !defined(ARRAYSIZE)
-#define ARRAYSIZE(array) (sizeof(array) / sizeof(*array))
-#endif /* !defined(ARRAYSIZE) */
+#if !defined(ARR_SZ)
+#define ARR_SZ(array) (sizeof(array) / sizeof(*array))
+#endif /* !defined(ARR_SZ) */
#define UNUSED __attribute__((unused))
#if 0 /* Works, but needs -fblocks and libBlocksRuntime with clang */
};
uintptr_t knownFlagMask = 0U;
- for (size_t i = 0; i < ARRAYSIZE(mountFlags); i++) {
+ for (size_t i = 0; i < ARR_SZ(mountFlags); i++) {
if (flags & mountFlags[i].flag) {
res.append(mountFlags[i].name);
res.append("|");
};
unsigned long new_flags = MS_REMOUNT | MS_RDONLY | MS_BIND;
- for (size_t i = 0; i < ARRAYSIZE(mountPairs); i++) {
+ for (size_t i = 0; i < ARR_SZ(mountPairs); i++) {
if (vfs.f_flag & mountPairs[i].vfs_flag) {
new_flags |= mountPairs[i].mount_flag;
}
}
static bool nsjailSetSigHandlers(void) {
- for (size_t i = 0; i < ARRAYSIZE(nssigs); i++) {
+ for (size_t i = 0; i < ARR_SZ(nssigs); i++) {
if (!nsjailSetSigHandler(nssigs[i])) {
return false;
}
};
uintptr_t knownFlagMask = CSIGNAL;
- for (size_t i = 0; i < ARRAYSIZE(cloneFlags); i++) {
+ for (size_t i = 0; i < ARR_SZ(cloneFlags); i++) {
if (flags & cloneFlags[i].flag) {
res.append(cloneFlags[i].name);
res.append("|");
/* Reset the execution environment for the new process */
static bool resetEnv(void) {
/* Set all previously changed signals to their default behavior */
- for (size_t i = 0; i < ARRAYSIZE(nssigs); i++) {
+ for (size_t i = 0; i < ARR_SZ(nssigs); i++) {
if (signal(nssigs[i], SIG_DFL) == SIG_ERR) {
PLOG_W("signal(%s, SIG_DFL)", util::sigName(nssigs[i]).c_str());
return false;
NS_VALSTR_STRUCT(SIGWINCH),
};
- for (size_t i = 0; i < ARRAYSIZE(sigNames); i++) {
+ for (size_t i = 0; i < ARR_SZ(sigNames); i++) {
if (signo == sigNames[i].signo) {
res.append(sigNames[i].name);
return res;