nsjail: make njsconf::cgroup_pids_max unsigned int
This commit is contained in:
parent
a1260e49f3
commit
61727949ca
12
cgroup.c
12
cgroup.c
@ -85,7 +85,7 @@ static bool cgroupInitNsFromParentMem(struct nsjconf_t* nsjconf, pid_t pid)
|
||||
|
||||
static bool cgroupInitNsFromParentPids(struct nsjconf_t* nsjconf, pid_t pid)
|
||||
{
|
||||
if (nsjconf->cgroup_pids_max == (size_t)0) {
|
||||
if (nsjconf->cgroup_pids_max == 0U) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -99,9 +99,9 @@ static bool cgroupInitNsFromParentPids(struct nsjconf_t* nsjconf, pid_t pid)
|
||||
}
|
||||
|
||||
char fname[PATH_MAX];
|
||||
if (nsjconf->cgroup_pids_max != (size_t)0) {
|
||||
if (nsjconf->cgroup_pids_max != 0U) {
|
||||
char pids_max_str[512];
|
||||
snprintf(pids_max_str, sizeof(pids_max_str), "%zu", nsjconf->cgroup_pids_max);
|
||||
snprintf(pids_max_str, sizeof(pids_max_str), "%u", nsjconf->cgroup_pids_max);
|
||||
snprintf(fname, sizeof(fname), "%s/pids.max", pids_cgroup_path);
|
||||
LOG_D("Setting '%s' to '%s'", fname, pids_max_str);
|
||||
if (!utilWriteBufToFile(
|
||||
@ -125,7 +125,7 @@ static bool cgroupInitNsFromParentPids(struct nsjconf_t* nsjconf, pid_t pid)
|
||||
|
||||
static bool cgroupInitNsFromParentNetCls(struct nsjconf_t* nsjconf, pid_t pid)
|
||||
{
|
||||
if (nsjconf->cgroup_net_cls_classid == (unsigned int)0) {
|
||||
if (nsjconf->cgroup_net_cls_classid == 0U) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -139,7 +139,7 @@ static bool cgroupInitNsFromParentNetCls(struct nsjconf_t* nsjconf, pid_t pid)
|
||||
}
|
||||
|
||||
char fname[PATH_MAX];
|
||||
if (nsjconf->cgroup_net_cls_classid != (unsigned int)0) {
|
||||
if (nsjconf->cgroup_net_cls_classid != 0U) {
|
||||
char net_cls_classid_str[512];
|
||||
snprintf(net_cls_classid_str, sizeof(net_cls_classid_str), "0x%x",
|
||||
nsjconf->cgroup_net_cls_classid);
|
||||
@ -195,7 +195,7 @@ void cgroupFinishFromParentMem(struct nsjconf_t* nsjconf, pid_t pid)
|
||||
|
||||
void cgroupFinishFromParentPids(struct nsjconf_t* nsjconf, pid_t pid)
|
||||
{
|
||||
if (nsjconf->cgroup_pids_max == (size_t)0) {
|
||||
if (nsjconf->cgroup_pids_max == 0) {
|
||||
return;
|
||||
}
|
||||
char pids_cgroup_path[PATH_MAX];
|
||||
|
@ -363,7 +363,7 @@ bool cmdlineParse(int argc, char* argv[], struct nsjconf_t* nsjconf)
|
||||
.cgroup_mem_max = (size_t)0,
|
||||
.cgroup_pids_mount = "/sys/fs/cgroup/pids",
|
||||
.cgroup_pids_parent = "NSJAIL",
|
||||
.cgroup_pids_max = (size_t)0,
|
||||
.cgroup_pids_max = (unsigned int)0,
|
||||
.cgroup_net_cls_mount = "/sys/fs/cgroup/net_cls",
|
||||
.cgroup_net_cls_parent = "NSJAIL",
|
||||
.cgroup_net_cls_classid = (unsigned int)0,
|
||||
@ -730,7 +730,7 @@ bool cmdlineParse(int argc, char* argv[], struct nsjconf_t* nsjconf)
|
||||
nsjconf->cgroup_mem_parent = optarg;
|
||||
break;
|
||||
case 0x811:
|
||||
nsjconf->cgroup_pids_max = (size_t)strtoull(optarg, NULL, 0);
|
||||
nsjconf->cgroup_pids_max = (unsigned int)strtoul(optarg, NULL, 0);
|
||||
break;
|
||||
case 0x812:
|
||||
nsjconf->cgroup_pids_mount = optarg;
|
||||
|
2
nsjail.h
2
nsjail.h
@ -157,7 +157,7 @@ struct nsjconf_t {
|
||||
size_t cgroup_mem_max;
|
||||
const char* cgroup_pids_mount;
|
||||
const char* cgroup_pids_parent;
|
||||
size_t cgroup_pids_max;
|
||||
unsigned int cgroup_pids_max;
|
||||
const char* cgroup_net_cls_mount;
|
||||
const char* cgroup_net_cls_parent;
|
||||
unsigned int cgroup_net_cls_classid;
|
||||
|
Loading…
Reference in New Issue
Block a user