nsjail: make njsconf::cgroup_pids_max unsigned int

This commit is contained in:
Robert Swiecki 2017-10-25 15:50:24 +02:00
parent a1260e49f3
commit 61727949ca
3 changed files with 9 additions and 9 deletions

View File

@ -85,7 +85,7 @@ static bool cgroupInitNsFromParentMem(struct nsjconf_t* nsjconf, pid_t pid)
static bool cgroupInitNsFromParentPids(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; return true;
} }
@ -99,9 +99,9 @@ static bool cgroupInitNsFromParentPids(struct nsjconf_t* nsjconf, pid_t pid)
} }
char fname[PATH_MAX]; char fname[PATH_MAX];
if (nsjconf->cgroup_pids_max != (size_t)0) { if (nsjconf->cgroup_pids_max != 0U) {
char pids_max_str[512]; 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); snprintf(fname, sizeof(fname), "%s/pids.max", pids_cgroup_path);
LOG_D("Setting '%s' to '%s'", fname, pids_max_str); LOG_D("Setting '%s' to '%s'", fname, pids_max_str);
if (!utilWriteBufToFile( 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) 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; return true;
} }
@ -139,7 +139,7 @@ static bool cgroupInitNsFromParentNetCls(struct nsjconf_t* nsjconf, pid_t pid)
} }
char fname[PATH_MAX]; 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]; char net_cls_classid_str[512];
snprintf(net_cls_classid_str, sizeof(net_cls_classid_str), "0x%x", snprintf(net_cls_classid_str, sizeof(net_cls_classid_str), "0x%x",
nsjconf->cgroup_net_cls_classid); 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) void cgroupFinishFromParentPids(struct nsjconf_t* nsjconf, pid_t pid)
{ {
if (nsjconf->cgroup_pids_max == (size_t)0) { if (nsjconf->cgroup_pids_max == 0) {
return; return;
} }
char pids_cgroup_path[PATH_MAX]; char pids_cgroup_path[PATH_MAX];

View File

@ -363,7 +363,7 @@ bool cmdlineParse(int argc, char* argv[], struct nsjconf_t* nsjconf)
.cgroup_mem_max = (size_t)0, .cgroup_mem_max = (size_t)0,
.cgroup_pids_mount = "/sys/fs/cgroup/pids", .cgroup_pids_mount = "/sys/fs/cgroup/pids",
.cgroup_pids_parent = "NSJAIL", .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_mount = "/sys/fs/cgroup/net_cls",
.cgroup_net_cls_parent = "NSJAIL", .cgroup_net_cls_parent = "NSJAIL",
.cgroup_net_cls_classid = (unsigned int)0, .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; nsjconf->cgroup_mem_parent = optarg;
break; break;
case 0x811: case 0x811:
nsjconf->cgroup_pids_max = (size_t)strtoull(optarg, NULL, 0); nsjconf->cgroup_pids_max = (unsigned int)strtoul(optarg, NULL, 0);
break; break;
case 0x812: case 0x812:
nsjconf->cgroup_pids_mount = optarg; nsjconf->cgroup_pids_mount = optarg;

View File

@ -157,7 +157,7 @@ struct nsjconf_t {
size_t cgroup_mem_max; size_t cgroup_mem_max;
const char* cgroup_pids_mount; const char* cgroup_pids_mount;
const char* cgroup_pids_parent; 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_mount;
const char* cgroup_net_cls_parent; const char* cgroup_net_cls_parent;
unsigned int cgroup_net_cls_classid; unsigned int cgroup_net_cls_classid;