def prepare_unshared_proccess(): for cmd in setup_user_map: try: with catch_and_die([CalledProcessError], debug='forked child'): check_call(cmd) except FileNotFoundError as exc: utils.die( 'newuidmap/newgidmap not found in PATH, please install it (package typically called `uidmap` or `shadow-utils`)' )
def get_subs(query_user, subfile): 'get subuids or subgids for a user' try: with open(subfile) as f: read = f.readline() user, start, count = read.split(':') if user == query_user: return int(start), int(count) except FileNotFoundError: pass die('please configure a subgid/uid range for the user {} in /etc/subuid and /etc/subgid' .format(repr(query_user)))
def die_with_errno(calling, extra=''): myerrno = ctypes.get_errno() errno_str = errno.errorcode.get(myerrno, myerrno) die('calling {} returned {} {}'.format(calling, errno_str, extra))