+open('/proc/pidsu','w').write(pid)
+
+# cgroups is not yet LXC-safe, so we need to use the course grained access control
+# strategy of unmounting the filesystem
+
+umount_result = True
+for subsystem in ['cpuset','cpu,cpuacct','memory','devices','freezer','net_cls','blkio','perf_event']:
+ fs_path = '/sys/fs/cgroup/%s'%subsystem
+ if (not umount(fs_path)):
+ print "Error disabling cgroup access"
+ exit(1)
+
+if (not umount('/sys/fs/cgroup')):
+ print "Error disabling cgroup access"
+ exit(1)
+
+pid = os.fork()
+
+if (pid == 0):
+ cap_arg = '--drop='+drop_capabilities
+ exec_args = ['/usr/sbin/capsh',cap_arg,'--','--login']+args[1:]
+
+ os.environ['SHELL'] = '/bin/sh'
+ os.execv('/usr/sbin/capsh',exec_args)
+else:
+ (r_pid,combined)=os.waitpid(pid,0)
+ retcod=combined/256
+ sys.exit(retcod)
+