More of RETURN_ON_FAILURE
This commit is contained in:
parent
6a4f5c110b
commit
6a4315f318
2
Makefile
2
Makefile
@ -109,7 +109,7 @@ cmdline.o: util.h
|
||||
config.o: caps.h nsjail.h cmdline.h config.h config.pb.h logs.h macros.h
|
||||
config.o: mnt.h user.h util.h
|
||||
contain.o: contain.h nsjail.h caps.h cgroup.h cpu.h logs.h macros.h mnt.h
|
||||
contain.o: net.h pid.h user.h uts.h
|
||||
contain.o: net.h pid.h user.h util.h uts.h
|
||||
cpu.o: cpu.h nsjail.h logs.h util.h
|
||||
logs.o: logs.h macros.h util.h nsjail.h
|
||||
mnt.o: mnt.h nsjail.h logs.h macros.h subproc.h util.h
|
||||
|
47
contain.cc
47
contain.cc
@ -48,6 +48,7 @@
|
||||
#include "net.h"
|
||||
#include "pid.h"
|
||||
#include "user.h"
|
||||
#include "util.h"
|
||||
#include "uts.h"
|
||||
|
||||
namespace contain {
|
||||
@ -294,41 +295,21 @@ bool setupFD(nsjconf_t* nsjconf, int fd_in, int fd_out, int fd_err) {
|
||||
}
|
||||
|
||||
bool containProc(nsjconf_t* nsjconf) {
|
||||
if (!containUserNs(nsjconf)) {
|
||||
return false;
|
||||
}
|
||||
if (!containInitPidNs(nsjconf)) {
|
||||
return false;
|
||||
}
|
||||
if (!containInitMountNs(nsjconf)) {
|
||||
return false;
|
||||
}
|
||||
if (!containInitNetNs(nsjconf)) {
|
||||
return false;
|
||||
}
|
||||
if (!containInitUtsNs(nsjconf)) {
|
||||
return false;
|
||||
}
|
||||
if (!containInitCgroupNs()) {
|
||||
return false;
|
||||
}
|
||||
if (!containDropPrivs(nsjconf)) {
|
||||
return false;
|
||||
}
|
||||
RETURN_ON_FAILURE(containUserNs(nsjconf));
|
||||
RETURN_ON_FAILURE(containInitPidNs(nsjconf));
|
||||
RETURN_ON_FAILURE(containInitMountNs(nsjconf));
|
||||
RETURN_ON_FAILURE(containInitNetNs(nsjconf));
|
||||
RETURN_ON_FAILURE(containInitUtsNs(nsjconf));
|
||||
RETURN_ON_FAILURE(containInitCgroupNs());
|
||||
RETURN_ON_FAILURE(containDropPrivs(nsjconf));
|
||||
;
|
||||
/* */
|
||||
/* As non-root */
|
||||
if (!containCPU(nsjconf)) {
|
||||
return false;
|
||||
}
|
||||
if (!containSetLimits(nsjconf)) {
|
||||
return false;
|
||||
}
|
||||
if (!containPrepareEnv(nsjconf)) {
|
||||
return false;
|
||||
}
|
||||
if (!containMakeFdsCOE(nsjconf)) {
|
||||
return false;
|
||||
}
|
||||
RETURN_ON_FAILURE(containCPU(nsjconf));
|
||||
RETURN_ON_FAILURE(containSetLimits(nsjconf));
|
||||
RETURN_ON_FAILURE(containPrepareEnv(nsjconf));
|
||||
RETURN_ON_FAILURE(containMakeFdsCOE(nsjconf));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
17
user.cc
17
user.cc
@ -205,18 +205,11 @@ static bool uidMapExternal(nsjconf_t* nsjconf, pid_t pid UNUSED) {
|
||||
}
|
||||
|
||||
static bool uidGidMap(nsjconf_t* nsjconf, pid_t pid) {
|
||||
if (!gidMapSelf(nsjconf, pid)) {
|
||||
return false;
|
||||
}
|
||||
if (!gidMapExternal(nsjconf, pid)) {
|
||||
return false;
|
||||
}
|
||||
if (!uidMapSelf(nsjconf, pid)) {
|
||||
return false;
|
||||
}
|
||||
if (!uidMapExternal(nsjconf, pid)) {
|
||||
return false;
|
||||
}
|
||||
RETURN_ON_FAILURE(gidMapSelf(nsjconf, pid));
|
||||
RETURN_ON_FAILURE(gidMapExternal(nsjconf, pid));
|
||||
RETURN_ON_FAILURE(uidMapSelf(nsjconf, pid));
|
||||
RETURN_ON_FAILURE(uidMapExternal(nsjconf, pid));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user