LDFLAGS += -Wl,-z,now -Wl,-z,relro -pie -Wl,-z,noexecstack
-SRCS = nsjail.c cmdline.c contain.c log.c mount.c net.c pid.c sandbox.c subproc.c user.c util.c uts.c seccomp/bpf-helper.c
+SRCS = nsjail.c cmdline.c contain.c log.c cgroup.c mount.c net.c pid.c sandbox.c subproc.c user.c util.c uts.c seccomp/bpf-helper.c
OBJS = $(SRCS:.c=.o)
BIN = nsjail
nsjail.o: nsjail.h common.h cmdline.h log.h net.h subproc.h
cmdline.o: cmdline.h common.h log.h util.h
-contain.o: contain.h common.h log.h mount.h net.h pid.h util.h uts.h
+contain.o: contain.h common.h cgroup.h log.h mount.h net.h pid.h util.h uts.h
log.o: log.h common.h
+cgroup.o: cgroup.h common.h
mount.o: mount.h common.h log.h
net.o: net.h common.h log.h
pid.o: pid.h common.h log.h
--- /dev/null
+/*
+
+ nsjail - cgroup namespacing
+ -----------------------------------------
+
+ Copyright 2014 Google Inc. All Rights Reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+#include "cgroup.h"
+
+bool cgroupInitNs(struct nsjconf_t *nsjconf)
+{
+ if (nsjconf == NULL) {
+ return false;
+ }
+ return true;
+}
--- /dev/null
+/*
+
+ nsjail - cgroup namespacing
+ -----------------------------------------
+
+ Copyright 2014 Google Inc. All Rights Reserved.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+#ifndef NS_CGROUP_H
+#define NS_CGROUP_H
+
+#include <stdbool.h>
+#include <stddef.h>
+
+#include "common.h"
+
+bool cgroupInitNs(struct nsjconf_t * nsjconf);
+
+#endif /* _CGROUP_H */
#include <sys/time.h>
#include <unistd.h>
+#include "cgroup.h"
#include "log.h"
#include "mount.h"
#include "net.h"
return utsInitNs(nsjconf);
}
+static bool containInitCgroupNs(struct nsjconf_t *nsjconf)
+{
+ return cgroupInitNs(nsjconf);
+}
+
static bool containDropPrivs(struct nsjconf_t *nsjconf)
{
/*
if (containInitUtsNs(nsjconf) == false) {
return false;
}
+ if (containInitCgroupNs(nsjconf) == false) {
+ return false;
+ }
if (containDropPrivs(nsjconf) == false) {
return false;
}