/* Set all requested caps in the inheritable set if these are present in the permitted set
*/
dbgmsg[0] = '\0';
- TAILQ_FOREACH(p, &nsjconf->caps, pointers) {
- if (getPermitted(cap_data, p->val) == false) {
- LOG_W("Capability %s is not permitted in the namespace", valToStr(p->val));
+ for (const auto& cap : nsjconf->caps) {
+ if (getPermitted(cap_data, cap) == false) {
+ LOG_W("Capability %s is not permitted in the namespace", valToStr(cap));
return false;
}
- util::sSnPrintf(dbgmsg, sizeof(dbgmsg), " %s", valToStr(p->val));
- setInheritable(cap_data, p->val);
+ util::sSnPrintf(dbgmsg, sizeof(dbgmsg), " %s", valToStr(cap));
+ setInheritable(cap_data, cap);
}
LOG_D("Adding the following capabilities to the inheritable set:%s", dbgmsg);
/* Make sure inheritable set is preserved across execve via the modified ambient set */
dbgmsg[0] = '\0';
- TAILQ_FOREACH(p, &nsjconf->caps, pointers) {
- if (prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_RAISE, (unsigned long)p->val, 0UL, 0UL) ==
+ for (const auto& cap : nsjconf->caps) {
+ if (prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_RAISE, (unsigned long)cap, 0UL, 0UL) ==
-1) {
- PLOG_W("prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_RAISE, %s)", valToStr(p->val));
+ PLOG_W("prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_RAISE, %s)", valToStr(cap));
} else {
- util::sSnPrintf(dbgmsg, sizeof(dbgmsg), " %s", valToStr(p->val));
+ util::sSnPrintf(dbgmsg, sizeof(dbgmsg), " %s", valToStr(cap));
}
}
LOG_D("Added the following capabilities to the ambient set:%s", dbgmsg);
TAILQ_INIT(&nsjconf->envs);
TAILQ_INIT(&nsjconf->uids);
TAILQ_INIT(&nsjconf->gids);
- TAILQ_INIT(&nsjconf->caps);
static char cmdlineTmpfsSz[PATH_MAX] = "size=4194304";
nsjconf->max_cpus = strtoul(optarg, NULL, 0);
break;
case 0x0509: {
- struct ints_t* f =
- reinterpret_cast<struct ints_t*>(util::memAlloc(sizeof(struct ints_t)));
- f->val = caps::nameToVal(optarg);
- if (f->val == -1) {
+ int cap = caps::nameToVal(optarg);
+ if (cap == -1) {
return nullptr;
}
- TAILQ_INSERT_HEAD(&nsjconf->caps, f, pointers);
+ nsjconf->caps.push_back(cap);
} break;
case 0x0601:
nsjconf->is_root_rw = true;
for (ssize_t i = 0; i < njc.cap_size(); i++) {
struct ints_t* f =
reinterpret_cast<struct ints_t*>(util::memAlloc(sizeof(struct ints_t)));
- f->val = caps::nameToVal(njc.cap(i).c_str());
- if (f->val == -1) {
+ int cap = caps::nameToVal(njc.cap(i).c_str());
+ if (cap == -1) {
return false;
}
- TAILQ_INSERT_HEAD(&nsjconf->caps, f, pointers);
+ nsjconf->caps.push_back(cap);
}
nsjconf->is_silent = njc.silent();