};
int nameToVal(const char* name) {
- for (size_t i = 0; i < ARR_SZ(capNames); i++) {
- if (strcmp(name, capNames[i].name) == 0) {
- return capNames[i].val;
+ for (const auto& cap : capNames) {
+ if (strcmp(name, cap.name) == 0) {
+ return cap.val;
}
}
LOG_W("Uknown capability: '%s'", name);
}
static const std::string capToStr(int val) {
- std::string res;
- for (size_t i = 0; i < ARR_SZ(capNames); i++) {
- if (val == capNames[i].val) {
- return capNames[i].name;
+ for (const auto& cap : capNames) {
+ if (val == cap.val) {
+ return cap.name;
}
}
+ std::string res;
res.append("CAP_UNKNOWN(");
res.append(std::to_string(val));
res.append(")");
};
uintptr_t knownFlagMask = CSIGNAL;
- for (size_t i = 0; i < ARR_SZ(cloneFlags); i++) {
- if (flags & cloneFlags[i].flag) {
- res.append(cloneFlags[i].name);
+ for (const auto& f : cloneFlags) {
+ if (flags & f.flag) {
+ res.append(f.name);
res.append("|");
}
- knownFlagMask |= cloneFlags[i].flag;
+ knownFlagMask |= f.flag;
}
if (flags & ~(knownFlagMask)) {
/* 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 < ARR_SZ(nssigs); i++) {
- if (signal(nssigs[i], SIG_DFL) == SIG_ERR) {
- PLOG_W("signal(%s, SIG_DFL)", util::sigName(nssigs[i]).c_str());
+ for (const auto& sig : nssigs) {
+ if (signal(sig, SIG_DFL) == SIG_ERR) {
+ PLOG_W("signal(%s, SIG_DFL)", util::sigName(sig).c_str());
return false;
}
}
p->remote_txt.c_str(), util::timeToStr(p->start).c_str());
close(p->pid_syscall_fd);
nsjconf->pids.erase(p);
+
return;
}
}