b560596f1b
Do not send 'which' command output to stdout, as it will mess real
backup data.
This fixes regression introduced by this commit:
commit dad5bfbd18
Author: HW42 <hw42@ipsumj.de>
Date: Thu Feb 5 03:14:41 2015 +0100
remove 'bashisms' or explicit use bash
34 lines
944 B
Plaintext
34 lines
944 B
Plaintext
echo Starting Restorecopy >&2
|
|
read args
|
|
read paths
|
|
echo Arguments: $args >&2
|
|
echo Paths: $paths >&2
|
|
if [ -f "$args" ] ; then
|
|
echo "Performing restore from backup file $args" >&2
|
|
TARGET="$args"
|
|
echo "Copying $TARGET to STDOUT" >&2
|
|
/usr/lib/qubes/tar2qfile $TARGET $paths
|
|
else
|
|
echo "Checking if arguments is matching a command" >&2
|
|
COMMAND=`echo $args | cut -d ' ' -f 1`
|
|
if which "$COMMAND" 2>/dev/null; then
|
|
tmpdir=`mktemp -d`
|
|
mkfifo $tmpdir/backup-data
|
|
echo "Redirecting $args to STDOUT" >&2
|
|
# Parsing args to handle quotes correctly
|
|
# Dangerous method if args are uncontrolled
|
|
eval "set -- $args"
|
|
# Use named pipe to pass original stdin to tar2file
|
|
$@ > $tmpdir/backup-data < /dev/null &
|
|
retcode=$?
|
|
/usr/lib/qubes/tar2qfile $tmpdir/backup-data $paths
|
|
wait
|
|
rm $tmpdir/backup-data
|
|
rmdir $tmpdir
|
|
exit $retcode
|
|
else
|
|
echo "Invalid command $COMMAND" >&2
|
|
exit 2
|
|
fi
|
|
fi
|