diff --git a/Makefile b/Makefile index 36c561e..ac0d382 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/qubes-rpc/qubes.Backup b/qubes-rpc/qubes.Backup new file mode 100644 index 0000000..6e3f1d4 --- /dev/null +++ b/qubes-rpc/qubes.Backup @@ -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 diff --git a/qubes-rpc/qubes.Restore b/qubes-rpc/qubes.Restore new file mode 100644 index 0000000..8480ea4 --- /dev/null +++ b/qubes-rpc/qubes.Restore @@ -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 diff --git a/rpm_spec/core-vm.spec b/rpm_spec/core-vm.spec index 9d5f2fa..1834f66 100644 --- a/rpm_spec/core-vm.spec +++ b/rpm_spec/core-vm.spec @@ -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