diff options
Diffstat (limited to 'debian')
-rw-r--r-- | debian/patches/gpg0001-utils-settrans-improve-chroot-functionality.patch | 122 | ||||
-rw-r--r-- | debian/patches/series | 1 |
2 files changed, 123 insertions, 0 deletions
diff --git a/debian/patches/gpg0001-utils-settrans-improve-chroot-functionality.patch b/debian/patches/gpg0001-utils-settrans-improve-chroot-functionality.patch new file mode 100644 index 00000000..8ed04132 --- /dev/null +++ b/debian/patches/gpg0001-utils-settrans-improve-chroot-functionality.patch @@ -0,0 +1,122 @@ +From 2e4fecd33b97db7e028f69e78f80e85e953250b4 Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Fri, 15 Jan 2016 18:56:25 +0100 +Subject: [PATCH hurd] utils/settrans: improve --chroot functionality + +Add an option '--chroot-chdir' to settrans and make it chdir to this +directory before executing the target program. + +* utils/fakeroot.sh: Simplify using the new option. +* utils/remap.sh: Likewise. +* utils/settrans.c (OPT_CHROOT_CHDIR): New constant. +(options): New option 'chroot-chdir'. +(main): Handle new option. +--- + utils/fakeroot.sh | 15 ++++++--------- + utils/remap.sh | 14 ++++++-------- + utils/settrans.c | 16 +++++++++++++++- + 3 files changed, 27 insertions(+), 18 deletions(-) + +diff --git a/utils/fakeroot.sh b/utils/fakeroot.sh +index 6993365..90b436c 100644 +--- a/utils/fakeroot.sh ++++ b/utils/fakeroot.sh +@@ -54,12 +54,9 @@ if [ $# -eq 0 ]; then + set -- ${SHELL:-/bin/sh} + fi + +-# We exec settrans, which execs the "fakeauth" command in the chroot context. +-# The `pwd` is evaluated here and now, and that result interpreted inside +-# the shell running under fakeauth to chdir there inside the chroot world. +-# That shell then execs our arguments as a command line. +-exec /bin/settrans --chroot \ +- /bin/fakeauth \ +- /bin/sh -c 'cd "$1" || exit ; shift ; exec "$@"' \ +- "$1" "$PWD" "$@" \ +- -- / /hurd/fakeroot ++# We exec settrans, which execs the "fakeauth" command in the chroot ++# context provided by /hurd/fakeroot. ++exec /bin/settrans \ ++ --chroot /bin/fakeauth "$@" -- \ ++ --chroot-chdir "$PWD" \ ++ / /hurd/fakeroot +diff --git a/utils/remap.sh b/utils/remap.sh +index f24ed0e..3bc6680 100644 +--- a/utils/remap.sh ++++ b/utils/remap.sh +@@ -57,11 +57,9 @@ if [ $# -eq 0 ]; then + set -- ${SHELL:-/bin/sh} + fi + +-# We exec settrans, which execs the "fakeauth" command in the chroot context. +-# The `pwd` is evaluated here and now, and that result interpreted inside +-# the shell running under fakeauth to chdir there inside the chroot world. +-# That shell then execs our arguments as a command line. +-exec /bin/settrans --chroot \ +- /bin/sh -c 'cd "$1" || exit ; shift ; exec "$@"' \ +- "$1" "$PWD" "$@" \ +- -- / /hurd/remap $MAPPED ++# We exec settrans, which execs the target command in the chroot ++# context provided by /hurd/remap. ++exec /bin/settrans \ ++ --chroot "$@" -- \ ++ --chroot-chdir "$PWD" \ ++ / /hurd/remap $MAPPED +diff --git a/utils/settrans.c b/utils/settrans.c +index cd40c56..7e7db0b 100644 +--- a/utils/settrans.c ++++ b/utils/settrans.c +@@ -45,6 +45,8 @@ const char *argp_program_version = STANDARD_HURD_VERSION (settrans); + #define _STRINGIFY(arg) #arg + #define STRINGIFY(arg) _STRINGIFY (arg) + ++#define OPT_CHROOT_CHDIR -1 ++ + static struct argp_option options[] = + { + {"active", 'a', 0, 0, "Start TRANSLATOR and set it as NODE's active translator" }, +@@ -65,6 +67,9 @@ static struct argp_option options[] = + {"chroot", 'C', 0, 0, + "Instead of setting the node's translator, take following arguments up to" + " `--' and run that command chroot'd to the translated node."}, ++ {"chroot-chdir", OPT_CHROOT_CHDIR, "DIR", 0, ++ "Change to DIR before running the chrooted command. " ++ "DIR must be an absolute path."}, + + {0,0,0,0, "When setting the passive translator, if there's an active translator:"}, + {"goaway", 'g', 0, 0, "Ask the active translator to go away"}, +@@ -114,6 +119,7 @@ main(int argc, char *argv[]) + int excl = 0; + int timeout = DEFAULT_TIMEOUT * 1000; /* ms */ + char **chroot_command = 0; ++ char *chroot_chdir = "/"; + + /* Parse our options... */ + error_t parse_opt (int key, char *arg, struct argp_state *state) +@@ -183,6 +189,14 @@ main(int argc, char *argv[]) + argp_error (state, "--chroot command must be terminated with `--'"); + return EINVAL; + ++ case OPT_CHROOT_CHDIR: ++ if (strcmp (chroot_chdir, "/") != 0) ++ argp_error (state, "--chroot-chdir given twice"); ++ if (arg[0] != '/') ++ argp_error (state, "--chroot-chdir must be absolute"); ++ chroot_chdir = arg; ++ break; ++ + case 'c': lookup_flags |= O_CREAT; break; + case 'L': lookup_flags &= ~O_NOTRANS; break; + +@@ -341,7 +355,7 @@ main(int argc, char *argv[]) + if (setcrdir (root)) + error (7, errno, "cannot install root port"); + mach_port_deallocate (mach_task_self (), root); +- if (chdir ("/")) ++ if (chdir (chroot_chdir)) + error (8, errno, "cannot chdir to new root"); + + execvp (chroot_command[0], chroot_command); +-- +2.1.4 + diff --git a/debian/patches/series b/debian/patches/series index 711b6eb9..2485f3d2 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -38,3 +38,4 @@ translators-list0003-libfshelp-improve-translator-list.patch translators-list0004-add-iteration.patch nodeihash0001-xxx-fix-node-iteration.patch fix-devnode0001-devnode-fix-falling-back-to-the-kernel-driver.patch +gpg0001-utils-settrans-improve-chroot-functionality.patch |