diff --git a/appvm/Makefile b/appvm/Makefile index d1e1040f..42bb6369 100644 --- a/appvm/Makefile +++ b/appvm/Makefile @@ -1,9 +1,9 @@ CC=gcc CFLAGS=-g -Wall -I../common -fPIC -pie -all: dvm_file_editor qfile-agent-dvm qfile-agent qfile-unpacker -dvm_file_editor: dvm_file_editor.o ../common/ioall.o +all: vm-file-editor qopen-in-vm qfile-agent qfile-unpacker +vm-file-editor: vm-file-editor.o ../common/ioall.o $(CC) -pie -g -o $@ $^ -qfile-agent-dvm: qfile-agent-dvm.o ../common/ioall.o ../common/gui-fatal.o +qopen-in-vm: qopen-in-vm.o ../common/ioall.o ../common/gui-fatal.o $(CC) -pie -g -o $@ $^ qfile-agent: qfile-agent.o ../common/ioall.o ../common/gui-fatal.o ../common/copy_file.o ../common/crc32.o $(CC) -pie -g -o $@ $^ @@ -11,4 +11,4 @@ qfile-unpacker: qfile-unpacker.o ../common/ioall.o ../common/gui-fatal.o ../comm $(CC) -pie -g -o $@ $^ clean: - rm -f qfile-agent-dvm qfile-agent qfile-unpacker dvm_file_editor *.o *~ + rm -f qopen-in-vm qfile-agent qfile-unpacker vm-file-editor *.o *~ diff --git a/appvm/qfile-agent-dvm.c b/appvm/qopen-in-vm.c similarity index 68% rename from appvm/qfile-agent-dvm.c rename to appvm/qopen-in-vm.c index 5db430cc..80f99c31 100644 --- a/appvm/qfile-agent-dvm.c +++ b/appvm/qopen-in-vm.c @@ -93,47 +93,11 @@ void talk_to_daemon(char *fname) recv_file(fname); } -void process_spoolentry(char *entry_name) -{ - char *abs_spool_entry_name; - int entry_fd; - struct stat st; - char *filename; - int entry_size; - asprintf(&abs_spool_entry_name, "%s/%s", DVM_SPOOL, entry_name); - entry_fd = open(abs_spool_entry_name, O_RDONLY); - unlink(abs_spool_entry_name); - if (entry_fd < 0 || fstat(entry_fd, &st)) - gui_fatal("bad dvm_entry"); - entry_size = st.st_size; - filename = calloc(1, entry_size + DVM_FILENAME_SIZE); - if (!filename) - gui_fatal("malloc"); - if (!read_all(entry_fd, filename, entry_size)) - gui_fatal("read dvm entry %s", abs_spool_entry_name); - close(entry_fd); - talk_to_daemon(filename); -} - -void scan_spool(char *name) -{ - struct dirent *ent; - DIR *dir = opendir(name); - if (!dir) - gui_fatal("opendir %s", name); - while ((ent = readdir(dir))) { - char *fname = ent->d_name; - if (!strcmp(fname, ".") || !strcmp(fname, "..")) - continue; - process_spoolentry(fname); - break; - } - closedir(dir); -} - -int main() +int main(int argc, char ** argv) { signal(SIGPIPE, SIG_IGN); - scan_spool(DVM_SPOOL); + if (argc!=2) + gui_fatal("OpenInVM - no file given?"); + talk_to_daemon(argv[1]); return 0; -} +} diff --git a/appvm/qubes.OpenInVM b/appvm/qubes.OpenInVM new file mode 100644 index 00000000..48db9065 --- /dev/null +++ b/appvm/qubes.OpenInVM @@ -0,0 +1 @@ +/usr/lib/qubes/vm-file-editor diff --git a/appvm/qubes.OpenInVM.policy b/appvm/qubes.OpenInVM.policy new file mode 100644 index 00000000..e103d394 --- /dev/null +++ b/appvm/qubes.OpenInVM.policy @@ -0,0 +1,2 @@ +anyvm dispvm allow +anyvm anyvm ask diff --git a/appvm/qvm-open-in-dvm2 b/appvm/qvm-open-in-dvm2 index eb0d4e2e..365c5640 100755 --- a/appvm/qvm-open-in-dvm2 +++ b/appvm/qvm-open-in-dvm2 @@ -25,16 +25,4 @@ if ! [ $# = 1 ] ; then exit 1 fi -FILE="$1" -if ! [ "X""${FILE:0:1}" = X/ ] ; then - FILE="$PWD"/"$1" -fi - -DVMSPOOL=/home/user/.dvmspool -if ! [ -e $DVMSPOOL ] ; then - mkdir $DVMSPOOL || exit 1 -fi - -echo -n "$FILE" > $DVMSPOOL/req.$$ -echo -n DVMR > /var/run/qubes/qrexec_agent - +exec /usr/lib/qubes/qrexec_client_vm "/usr/lib/qubes/qopen-in-vm" dispvm qubes.OpenInVM "$1" diff --git a/appvm/qvm-open-in-vm b/appvm/qvm-open-in-vm new file mode 100755 index 00000000..dc77ffe9 --- /dev/null +++ b/appvm/qvm-open-in-vm @@ -0,0 +1,28 @@ +#!/bin/bash +# +# The Qubes OS Project, http://www.qubes-os.org +# +# Copyright (C) 2010 Rafal Wojtczuk +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# + +if ! [ $# = 2 ] ; then + echo "Usage: $0 vmname filename" + exit 1 +fi + +exec /usr/lib/qubes/qrexec_client_vm "/usr/lib/qubes/qopen-in-vm" "$1" qubes.OpenInVM "$2" diff --git a/appvm/dvm_file_editor.c b/appvm/vm-file-editor.c similarity index 100% rename from appvm/dvm_file_editor.c rename to appvm/vm-file-editor.c diff --git a/dom0/restore/qfile-daemon-dvm b/dom0/restore/qfile-daemon-dvm index 024c7eef..4ac2271b 100755 --- a/dom0/restore/qfile-daemon-dvm +++ b/dom0/restore/qfile-daemon-dvm @@ -124,15 +124,18 @@ class QfileDaemonDvm: def main(): global notify_object + exec_index = sys.argv[1] + src_vmname = sys.argv[2] notify_object = dbus.SessionBus().get_object("org.freedesktop.Notifications", "/org/freedesktop/Notifications") - qfile = QfileDaemonDvm(os.getenv("QREXEC_REMOTE_DOMAIN")) + qfile = QfileDaemonDvm(src_vmname) lockf = open("/var/run/qubes/qfile-daemon-dvm.lock", 'a') fcntl.fcntl(lockf, fcntl.F_SETFD, fcntl.FD_CLOEXEC) fcntl.flock(lockf, fcntl.LOCK_EX) dispname = qfile.get_dvm() lockf.close() if dispname is not None: - subprocess.call(['/usr/lib/qubes/qrexec_client', '-d', dispname, 'directly:user:/usr/lib/qubes/dvm_file_editor']) + subprocess.call(['/usr/lib/qubes/qrexec_client', '-d', dispname, + 'user:exec /usr/lib/qubes/qubes_rpc_multiplexer ' + exec_index + " " + src_vmname]) subprocess.call(['/usr/sbin/xl', 'destroy', dispname]) qfile.remove_disposable_from_qdb(dispname) diff --git a/qrexec/qrexec_policy b/qrexec/qrexec_policy index ba87f7cf..cf4e02d4 100755 --- a/qrexec/qrexec_policy +++ b/qrexec/qrexec_policy @@ -33,8 +33,11 @@ def apply_policy(policy, domain, target): return (None, None) def do_execute(domain, target, exec_index, process_ident): - cmd= "qvm-run -uroot -q -a --pass_io "+target - cmd+=" '/usr/lib/qubes/qubes_rpc_multiplexer "+exec_index + " " + domain + "'" + if target == "dispvm": + cmd = "/usr/lib/qubes/qfile-daemon-dvm " + exec_index + " " + domain + else: + cmd= "qvm-run -uroot -q -a --pass_io "+target + cmd+=" '/usr/lib/qubes/qubes_rpc_multiplexer "+exec_index + " " + domain + "'" os.execl(QREXEC_CLIENT, "qrexec_client", "-d", domain, "-l", cmd, "-c", process_ident) def confirm_execution(domain, target, exec_index): diff --git a/rpm_spec/core-appvm.spec b/rpm_spec/core-appvm.spec index 77862597..ce783b2c 100644 --- a/rpm_spec/core-appvm.spec +++ b/rpm_spec/core-appvm.spec @@ -75,6 +75,7 @@ cp qubes_core_appvm $RPM_BUILD_ROOT/etc/init.d/ mkdir -p $RPM_BUILD_ROOT/var/lib/qubes mkdir -p $RPM_BUILD_ROOT/usr/bin cp qubes_timestamp qvm-open-in-dvm2 $RPM_BUILD_ROOT/usr/bin +cp qvm-open-in-vm $RPM_BUILD_ROOT/usr/bin cp qvm-copy-to-vm $RPM_BUILD_ROOT/usr/bin mkdir -p $RPM_BUILD_ROOT/usr/lib/qubes cp qvm-copy-to-vm2.kde $RPM_BUILD_ROOT/usr/lib/qubes @@ -82,14 +83,14 @@ cp qvm-copy-to-vm2.gnome $RPM_BUILD_ROOT/usr/lib/qubes cp ../qrexec/qrexec_agent $RPM_BUILD_ROOT/usr/lib/qubes cp ../qrexec/qrexec_client_vm $RPM_BUILD_ROOT/usr/lib/qubes cp ../qrexec/qubes_rpc_multiplexer $RPM_BUILD_ROOT/usr/lib/qubes -cp dvm_file_editor qfile-agent qfile-agent-dvm qfile-unpacker $RPM_BUILD_ROOT/usr/lib/qubes +cp vm-file-editor qfile-agent qopen-in-vm qfile-unpacker $RPM_BUILD_ROOT/usr/lib/qubes cp ../common/meminfo-writer $RPM_BUILD_ROOT/usr/lib/qubes mkdir -p $RPM_BUILD_ROOT/%{kde_service_dir} cp qvm-copy.desktop qvm-dvm.desktop $RPM_BUILD_ROOT/%{kde_service_dir} mkdir -p $RPM_BUILD_ROOT/mnt/removable mkdir -p $RPM_BUILD_ROOT/etc/qubes_rpc cp qubes.Filecopy $RPM_BUILD_ROOT/etc/qubes_rpc - +cp qubes.OpenInVM $RPM_BUILD_ROOT/etc/qubes_rpc mkdir -p $RPM_BUILD_ROOT/etc/X11 cp xorg-preload-apps.conf $RPM_BUILD_ROOT/etc/X11 @@ -140,19 +141,21 @@ rm -rf $RPM_BUILD_ROOT /usr/lib/qubes/qvm-copy-to-vm2.kde /usr/lib/qubes/qvm-copy-to-vm2.gnome /usr/bin/qvm-open-in-dvm2 +/usr/bin/qvm-open-in-vm /usr/lib/qubes/meminfo-writer -/usr/lib/qubes/dvm_file_editor +/usr/lib/qubes/vm-file-editor %{kde_service_dir}/qvm-copy.desktop %{kde_service_dir}/qvm-dvm.desktop /usr/lib/qubes/qrexec_agent /usr/lib/qubes/qrexec_client_vm /usr/lib/qubes/qubes_rpc_multiplexer /usr/lib/qubes/qfile-agent -/usr/lib/qubes/qfile-agent-dvm +/usr/lib/qubes/qopen-in-vm /usr/lib/qubes/qfile-unpacker %dir /mnt/removable %dir /etc/qubes_rpc /etc/qubes_rpc/qubes.Filecopy +/etc/qubes_rpc/qubes.OpenInVM /usr/bin/qubes_timestamp %dir /home_volatile %attr(700,user,user) /home_volatile/user diff --git a/rpm_spec/core-dom0.spec b/rpm_spec/core-dom0.spec index 0a806547..6058fc3b 100644 --- a/rpm_spec/core-dom0.spec +++ b/rpm_spec/core-dom0.spec @@ -101,6 +101,7 @@ cp aux-tools/qfile-dom0-unpacker $RPM_BUILD_ROOT/usr/lib/qubes/ mkdir -p $RPM_BUILD_ROOT/etc/qubes_rpc/policy cp ../appvm/qubes.Filecopy.policy $RPM_BUILD_ROOT/etc/qubes_rpc/policy/qubes.Filecopy +cp ../appvm/qubes.OpenInVM.policy $RPM_BUILD_ROOT/etc/qubes_rpc/policy/qubes.OpenInVM cp restore/qvm-create-default-dvm $RPM_BUILD_ROOT/usr/bin cp restore/xenstore-watch $RPM_BUILD_ROOT/usr/bin/xenstore-watch-qubes @@ -326,6 +327,7 @@ fi /usr/lib/qubes/qrexec_policy %dir /etc/qubes_rpc/policy /etc/qubes_rpc/policy/qubes.Filecopy +/etc/qubes_rpc/policy/qubes.OpenInVM %attr(4750,root,qubes) /usr/lib/qubes/qrexec_daemon %attr(4750,root,qubes) /usr/lib/qubes/xenfreepages %attr(2770,root,qubes) %dir /var/log/qubes