Add qubes.{Backup,Restore} services, include them in rpm package

This commit is contained in:
Marek Marczykowski-Górecki 2013-11-09 19:01:57 +01:00
parent 6eaa30a96a
commit 639cb51414
4 changed files with 60 additions and 0 deletions

View File

@ -120,6 +120,7 @@ install-vm:
install qubes-rpc/qvm-copy-to-vm.kde $(DESTDIR)/usr/lib/qubes
install qubes-rpc/qvm-copy-to-vm.gnome $(DESTDIR)/usr/lib/qubes
install qubes-rpc/{vm-file-editor,qfile-agent,qopen-in-vm} $(DESTDIR)/usr/lib/qubes
install qubes-rpc/tar2qfile $(DESTDIR)/usr/lib/qubes
# Install qfile-unpacker as SUID - because it will fail to receive files from other vm
install -m 4555 qubes-rpc/qfile-unpacker $(DESTDIR)/usr/lib/qubes
install qubes-rpc/qrun-in-vm $(DESTDIR)/usr/lib/qubes
@ -132,6 +133,7 @@ install-vm:
install -m 0644 qubes-rpc/{qubes.SuspendPre,qubes.SuspendPost,qubes.GetAppmenus} $(DESTDIR)/etc/qubes-rpc
install -m 0644 qubes-rpc/qubes.WaitForSession $(DESTDIR)/etc/qubes-rpc
install -m 0644 qubes-rpc/qubes.DetachPciDevice $(DESTDIR)/etc/qubes-rpc
install -m 0644 qubes-rpc/qubes.{Backup,Restore} $(DESTDIR)/etc/qubes-rpc
install -d $(DESTDIR)/usr/share/file-manager/actions
install -m 0644 qubes-rpc/*-gnome.desktop $(DESTDIR)/usr/share/file-manager/actions

23
qubes-rpc/qubes.Backup Normal file
View File

@ -0,0 +1,23 @@
echo Starting Backupcopy
read args
echo Arguments: $args
if [ -d "$args" ] ; then
echo "Performing backup to directory $args"
TARGET="$args/qubes-backup-`date +'%Y-%d-%d-%H%M%S'`"
echo "Copying STDIN data to $TARGET"
cat > $TARGET
else
echo "Checking if arguments is matching a command"
COMMAND=`echo $args | cut -d ' ' -f 1`
TYPE=`type -t $COMMAND`
if [ "$TYPE" == "file" ] ; then
echo "Redirecting STDIN to $args"
# Parsing args to handle quotes correctly
# Dangerous method if args are uncontrolled
eval "set -- $args"
$@
else
echo "Invalid command $COMMAND"
exit 1
fi
fi

32
qubes-rpc/qubes.Restore Normal file
View File

@ -0,0 +1,32 @@
echo Starting Restorecopy >2
read args
echo Arguments: $args >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
else
echo "Checking if arguments is matching a command" >2
COMMAND=`echo $args | cut -d ' ' -f 1`
TYPE=`type -t $COMMAND`
if [ "$TYPE" == "file" ] ; 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
wait
rm $tmpdir/backup-data
rmdir $tmpdir
exit $retcode
else
echo "Invalid command $COMMAND" >2
exit 1
fi
fi

View File

@ -277,6 +277,8 @@ rm -f %{name}-%{version}
/etc/qubes-rpc/qubes.SuspendPost
/etc/qubes-rpc/qubes.WaitForSession
/etc/qubes-rpc/qubes.DetachPciDevice
/etc/qubes-rpc/qubes.Backup
/etc/qubes-rpc/qubes.Restore
/etc/sudoers.d/qubes
%config(noreplace) /etc/sysconfig/iptables
%config(noreplace) /etc/sysconfig/ip6tables
@ -322,6 +324,7 @@ rm -f %{name}-%{version}
/usr/lib/qubes/qvm-copy-to-vm.kde
/usr/lib/qubes/serial.conf
/usr/lib/qubes/setup-ip
/usr/lib/qubes/tar2qfile
/usr/lib/qubes/vm-file-editor
/usr/lib/qubes/wrap-in-html-if-url.sh
/usr/lib/qubes/iptables-yum-proxy