- struct vc_ctx_caps caps;
- struct vc_ctx_flags flags;
-
- caps.ccaps = ~vc_get_insecureccaps();
- caps.cmask = ~0ull;
- caps.bcaps = ~vc_get_insecurebcaps();
- caps.bmask = ~0ull;
-
- flags.flagword = VC_VXF_INFO_LOCK;
- flags.mask = VC_VXF_STATE_SETUP | VC_VXF_INFO_LOCK;
-
- if ((vc_ctx_create(xid) == VC_NOCTX) && (errno != EEXIST)) {
- PERROR("vc_ctx_create(%d)", xid);
- exit(1);
- }
-
- if (vc_set_ccaps(xid, &caps) == -1) {
- PERROR("vc_set_ccaps(%d, 0x%16ullx/0x%16ullx, 0x%16ullx/0x%16ullx)\n",
- xid, caps.ccaps, caps.cmask, caps.bcaps, caps.bmask);
- exit(1);
- }
-
- if (vc_set_cflags(xid, &flags) == -1) {
- PERROR("vc_set_cflags(%d, 0x%16llx/0x%16llx)\n",
- xid, flags.flagword, flags.mask);
- exit(1);
- }
+ int ctx_is_new;
+ struct sliver_resources slr;
+ char hostname[HOST_NAME_MAX+1];
+ pl_get_limits(context,&slr);
+
+ if (gethostname(hostname, sizeof hostname) == -1)
+ {
+ PERROR("gethostname(...)");
+ exit(1);
+ }
+
+ /* check whether the slice has been suspended */
+ if (slr.vs_cpu==0)
+ {
+ fprintf(stderr, "*** %s: %s has zero cpu resources and presumably it has been disabled/suspended ***\n", hostname, context);
+ exit(0);
+ }
+
+ (void) (sandbox_chroot(ctx));
+
+ if ((ctx_is_new = pl_chcontext(ctx, ~vc_get_insecurebcaps(),&slr)) < 0)
+ {
+ PERROR("pl_chcontext(%u)", ctx);
+ exit(1);
+ }
+ if (ctx_is_new)
+ {
+ pl_set_limits(ctx,&slr);
+ pl_setup_done(ctx);
+ }