summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2014-02-25 01:48:14 -0500
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2014-02-25 01:48:14 -0500
commit139cc36c4f24dbc8c759f6bc3fba536698db6e03 (patch)
treede7a4d2627c3980036a2634c973e8ec81b99df4c
parent4473d16e7cdad08eccad95f5920e1aa171d5512d (diff)
Fix fakeroot and remap parsing corner cases
Fix case when $PWD contains spaces. Pass directly arguments to command, to directly avoid escaping issues. Based on suggestion by Ivan Shmakov <oneingray@gmail.com> * utils/fakeroot.sh (TARGET): Do not define. (sh): Rather pass PWD and commandline as parameters. * utils/remap.sh: Likewise.
-rw-r--r--utils/fakeroot.sh10
-rw-r--r--utils/remap.sh9
2 files changed, 5 insertions, 14 deletions
diff --git a/utils/fakeroot.sh b/utils/fakeroot.sh
index a64e9631..6993365d 100644
--- a/utils/fakeroot.sh
+++ b/utils/fakeroot.sh
@@ -54,16 +54,12 @@ if [ $# -eq 0 ]; then
set -- ${SHELL:-/bin/sh}
fi
-TARGET=
-until [ $# -eq 0 ]; do
- TARGET="${TARGET} '$(echo "$1" | sed -e "s/'/'\\\\''/g")'"
- shift
-done
-
# 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 `pwd`; exec ${TARGET}" \
+ /bin/fakeauth \
+ /bin/sh -c 'cd "$1" || exit ; shift ; exec "$@"' \
+ "$1" "$PWD" "$@" \
-- / /hurd/fakeroot
diff --git a/utils/remap.sh b/utils/remap.sh
index 064f0f5f..f24ed0e7 100644
--- a/utils/remap.sh
+++ b/utils/remap.sh
@@ -57,16 +57,11 @@ if [ $# -eq 0 ]; then
set -- ${SHELL:-/bin/sh}
fi
-TARGET=
-until [ $# -eq 0 ]; do
- TARGET="${TARGET} '$(echo "$1" | sed -e "s/'/'\\\\''/g")'"
- shift
-done
-
# 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 `pwd`; exec ${TARGET}" \
+ /bin/sh -c 'cd "$1" || exit ; shift ; exec "$@"' \
+ "$1" "$PWD" "$@" \
-- / /hurd/remap $MAPPED