Package: proot Version: 3.0.2-1 Severity: normal Tags: patch Hi,
when giving the -q option, proot currently automatically bind-mounts the host rootfs into /host-rootfs. This functionality only exists for the convenience of being able to also execute binaries of the host system at the same time. But it is otherwise completely unnecessary for qemu-user mode operation to have the host rootfs bind-mounted into /host-rootfs. Attached, find a patch which moves this functionality from the -q option into the -t option and which lets the -Q option be an alias for -t as well. cheers, josch -- System Information: Debian Release: jessie/sid APT prefers testing APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable'), (1, 'experimental') Architecture: amd64 (x86_64) Foreign Architectures: i386 armel powerpc sparc mips Kernel: Linux 3.4-trunk-amd64 (SMP w/4 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages proot depends on: ii libc6 2.17-92+b1 ii libtalloc2 2.0.8-0.1 proot recommends no packages. proot suggests no packages. -- debconf-show failed
--- a/src/cli.c +++ b/src/cli.c @@ -130,12 +130,20 @@ static int handle_option_q(Tracee *trace } assert(i == nb_args); - new_binding(tracee, "/", HOST_ROOTFS, true); new_binding(tracee, "/dev/null", "/etc/ld.so.preload", false); return 0; } +static int handle_option_t(Tracee *tracee, char *value) +{ + Binding *binding = new_binding(tracee, "/", HOST_ROOTFS, true); + if (binding == NULL) + return -1; + + return 0; +} + static int handle_option_w(Tracee *tracee, char *value) { tracee->fs->cwd = talloc_strdup(tracee->fs, value); @@ -218,6 +226,10 @@ static int handle_option_Q(Tracee *trace { int status; + status = handle_option_t(tracee, NULL); + if (status < 0) + return status; + status = handle_option_q(tracee, value); if (status < 0) return status; --- a/doc/proot.1 +++ b/doc/proot.1 @@ -112,9 +112,14 @@ Execute guest programs through QEMU as s Each time a guest program is going to be executed, PRoot inserts the QEMU user\-mode \fIcommand\fP in front of the initial request. That way, guest programs actually run on a virtual guest CPU -emulated by QEMU user\-mode. The native execution of host programs -is still effective and the whole host rootfs is bound to -\fB/host\-rootfs\fP in the guest environment. +emulated by QEMU user\-mode. +.sp +This option is automatically enabled by the \fB\-Q\fP option. +.TP +.BI \-t, \-\-host +The host rootfs will be bound to \fB/host\-rootfs\fP in the guest +environment. This allows the native execution of host programs +during QEMU user\-mode. .sp This option is automatically enabled by the \fB\-Q\fP option. .TP @@ -217,7 +222,7 @@ $HOME .UNINDENT .TP .BI \-Q \ command -Alias: \fB\-q *command* \-B\fP +Alias: \fB\-t \-q *command* \-B\fP .sp This option is highly recommended when using QEMU user\-mode; it enables all the recommended bindings. --- a/src/cli.h +++ b/src/cli.h @@ -55,6 +55,7 @@ static char *recommended_bindings[] = { static int handle_option_r(Tracee *tracee, char *value); static int handle_option_b(Tracee *tracee, char *value); static int handle_option_q(Tracee *tracee, char *value); +static int handle_option_t(Tracee *tracee, char *value); static int handle_option_w(Tracee *tracee, char *value); static int handle_option_v(Tracee *tracee, char *value); static int handle_option_V(Tracee *tracee, char *value); @@ -109,8 +110,20 @@ static Option options[] = { .detail = "\tEach time a guest program is going to be executed, PRoot inserts\n\ \tthe QEMU user-mode command in front of the initial request.\n\ \tThat way, guest programs actually run on a virtual guest CPU\n\ -\temulated by QEMU user-mode. The native execution of host programs\n\ -\tis still effective and the whole host rootfs is bound to\n\ +\temulated by QEMU user-mode.\n\ +\t\n\ +\tThis option is automatically enabled by the -Q option.", + }, + { .class = "Regular options", + .arguments = { + { .name = "-t", .separator = '\0', .value = NULL }, + { .name = "--host", .separator = '\0', .value = NULL }, + { .name = NULL, .separator = '\0', .value = NULL } }, + .handler = handle_option_t, + .description = "Bind mount the host rootfs to /host-rootfs", + .detail = "\tWhen this option is activated, it is possible to natively.\n\ +\texecute host programs from within an emulated QEMU user-mode\n\ +\tenvironment. This is achieved by binding the host rootfs into\n\ \t/host-rootfs in the guest environment.\n\ \t\n\ \tThis option is automatically enabled by the -Q option.",