def main():
args = get_options()
if args.show_id:
show_current_users_and_groups()
sys.exit(0)
mamaji_data = fetch_mamaji_data(args)
filter_options(mamaji_data)
target_cmd = None
if args.cmd:
target_cmd = args.cmd
if not args.do_fork:
change_users_and_groups(mamaji_data)
# if target_cmd is None, do nothing
if target_cmd:
os.execlp(target_cmd[0], *target_cmd)
sys.exit(0)
if args.do_fork and not args.cmd:
target_cmd = [find_shell()]
pid = os.fork()
if pid == -1:
warn('failed to do fork')
sys.exit(1)
elif pid == 0:
change_users_and_groups(mamaji_data)
os.execlp(target_cmd[0], *target_cmd)
else:
status = os.wait4(pid, 0)[1] >> 8
sys.exit(status)
评论列表
文章目录