Log In
Log In
Places
All Projects
Status Monitor
Collapse sidebar
obs:server:fedora:2.9
build
_service:gitpkg:0002-Make-enter_target-shell-qu...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:gitpkg:0002-Make-enter_target-shell-quote-safe.patch of Package build
From c1297e97100a94974d9c72ca2025fdd96736a22c Mon Sep 17 00:00:00 2001 From: Carsten Munk <carsten.munk@gmail.com> Date: Sat, 11 Feb 2012 10:15:33 +0100 Subject: [PATCH] Make enter_target shell quote safe Signed-off-by: Carsten Munk <carsten.munk@gmail.com> --- common_functions | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/common_functions b/common_functions index ef01085..3026365 100755 --- a/common_functions +++ b/common_functions @@ -160,6 +160,18 @@ cleanup_sb2() { fi } +shellquote() +{ + for arg; do + arg=${arg/\\/\\\\} + arg=${arg/\$/\\\$} + arg=${arg/\"/\\\"} + arg=${arg/\`/\\\`} + echo -n " \"$arg\"" + done +} + + # chroot-like wrapper, enter_target <mode: needroot|user> $TARGET commands # needroot - operations that need to be done as root, like unpacking into file system, etc # needuser - operations that will be done as non-root user @@ -168,15 +180,16 @@ enter_target() { if [ -z "$BUILD_SB2FLAGS" ]; then if [ x$1 == xneeduser ]; then shift - chroot $BUILD_TARGET su -c "${*}" - $BUILD_USER + PARAMS=`shellquote "$@"` + chroot $BUILD_TARGET su -c "$PARAMS" - $BUILD_USER elif [ x$1 == xneedscript ]; then shift SCRIPT=$1 shift - chroot $BUILD_TARGET su -s $SCRIPT $BUILD_USER -- ${*} + chroot $BUILD_TARGET su -s $SCRIPT $BUILD_USER -- "$@" else shift - chroot $BUILD_TARGET ${*} + chroot $BUILD_TARGET "$@" fi else if [ -z "$VM_TYPE" ]; then @@ -212,7 +225,8 @@ enter_target() { fi su -c "cd $PWD; /usr/bin/sb2-config -t oscbuild setenv HOME /root" - abuild su -c "cd $PWD; /usr/bin/sb2-config -t oscbuild setenv USER root" - abuild - su -c "cd $PWD; /usr/bin/sb2 $SESSION $SB2_DEBUG -m $SB2_INSTALLMODE -R ${*}" - abuild + PARAMS=`shellquote "$@"` + su -c "cd $PWD; /usr/bin/sb2 $SESSION $SB2_DEBUG -m $SB2_INSTALLMODE -R $PARAMS" - abuild RET=$? cd $ORIG return $RET @@ -227,9 +241,11 @@ enter_target() { else SESSION="-J /home/abuild/sb2-session-needuser" fi + PARAMS=`shellquote "$@"` + su -c "cd $PWD; /usr/bin/sb2-config -t oscbuild setenv HOME /home/abuild" - abuild su -c "cd $PWD; /usr/bin/sb2-config -t oscbuild setenv USER abuild" - abuild - su -c "cd $PWD; /usr/bin/sb2 $SESSION $SB2_DEBUG -m $SB2_DEFAULTMODE ${*}" - abuild + su -c "cd $PWD; /usr/bin/sb2 $SESSION $SB2_DEBUG -m $SB2_DEFAULTMODE $PARAMS" - abuild RET=$? cd $ORIG return $RET -- 2.26.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Contact
Support
@OBShq
The Open Build Service is an
openSUSE project
.
Log In
Places
Places
All Projects
Status Monitor