Index: linux-user/main.c =================================================================== --- linux-user/main.c (revision 5527) +++ linux-user/main.c (working copy) @@ -2186,6 +2186,10 @@ "-cpu model select CPU (-cpu ? for list)\n" "-drop-ld-preload drop LD_PRELOAD for target process\n" "\n" + "Root options:\n" + "-chroot dir chroot to dir\n" + "-su uid:gid set numeric user and group IDs\n" + "\n" "Debug options:\n" "-d options activate log (logfile=%s)\n" "-p pagesize set the host page size to 'pagesize'\n" @@ -2301,6 +2305,28 @@ drop_ld_preload = 1; } else if (!strcmp(r, "strace")) { do_strace = 1; + } else if (!strcmp(r, "chroot")) { + if (chdir(argv[optind++]) || chroot(".")) { + fprintf(stderr, "Can't chroot to '%s' (are you root?)\n", + argv[--optind]); + _exit(1); + } + } else if (!strcmp(r, "su")) { + int temp; + char *gid = strchr(argv[optind], ':'); + if (gid) { + temp = atoi(++gid); + if (setresgid(temp, temp, temp)) { + fprintf(stderr, "Can't set gid to %d (are you root?)\n", + temp); + _exit(1); + } + } + temp = atoi(argv[optind++]); + if (setresuid(temp, temp, temp)) { + fprintf(stderr, "Can't set uid to %d (are you root?)\n", temp); + _exit(1); + } } else { usage();