diff --git a/dom0/misc/qubes-dispvm-firefox.desktop b/dom0/misc/qubes-dispvm-firefox.desktop new file mode 100644 index 00000000..021bda61 --- /dev/null +++ b/dom0/misc/qubes-dispvm-firefox.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Version=1.0 +Type=Application +Exec=sh -c 'echo firefox | /usr/lib/qubes/qfile-daemon-dvm qubes.VMShell dom0 user red' +Icon=/usr/share/qubes/icons/dispvm-red.png +Terminal=false +Name=DispVM: Firefox web browser +GenericName=DispVM: Web browser +StartupNotify=false +Categories=Network; diff --git a/dom0/misc/qubes-dispvm.directory b/dom0/misc/qubes-dispvm.directory new file mode 100644 index 00000000..9b5544d6 --- /dev/null +++ b/dom0/misc/qubes-dispvm.directory @@ -0,0 +1,5 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=Directory +Name=DisposableVM +Icon=/usr/share/qubes/icons/dispvm-red.png diff --git a/dom0/restore/qfile-daemon-dvm b/dom0/restore/qfile-daemon-dvm index db779c65..a2fb8c72 100755 --- a/dom0/restore/qfile-daemon-dvm +++ b/dom0/restore/qfile-daemon-dvm @@ -29,6 +29,7 @@ import shutil from qubes.qubes import QubesVmCollection from qubes.qubes import QubesException from qubes.qubes import QubesDaemonPidfile +from qubes.qubes import QubesDispVmLabels from qubes.qmemman_client import QMemmanClient current_savefile = '/var/run/qubes/current_savefile' @@ -58,12 +59,16 @@ class QfileDaemonDvm: qvm_collection.unlock_db() qmemman_client.close() return None + label = vm.label + if len(sys.argv) > 4 and len(sys.argv[4]) > 0: + assert sys.argv[4] in QubesDispVmLabels.keys(), "Invalid label" + label = QubesDispVmLabels[sys.argv[4]] retcode = subprocess.call(['/usr/lib/qubes/qubes_restore', current_savefile, current_dvm_conf, - '-c', vm.label.color, - '-i', vm.label.icon, - '-l', str(vm.label.index)]) + '-c', label.color, + '-i', label.icon, + '-l', str(label.index)]) qmemman_client.close() if retcode != 0: subprocess.call(['/usr/bin/kdialog', '--sorry', 'DisposableVM creation failed, see qubes_restore.log']) @@ -80,12 +85,15 @@ class QfileDaemonDvm: qvm_collection.unlock_db() return None dispid=int(disp_name[4:]) - dispvm=qvm_collection.add_new_disposablevm(disp_name, vm_disptempl.template, label=vm.label, dispid=dispid) + dispvm=qvm_collection.add_new_disposablevm(disp_name, vm_disptempl.template, label=label, dispid=dispid) # By default inherit firewall rules from calling VM if os.path.exists(vm.firewall_conf): disp_firewall_conf = '/var/run/qubes/%s-firewall.xml' % disp_name shutil.copy(vm.firewall_conf, disp_firewall_conf) dispvm.firewall_conf = disp_firewall_conf + if len(sys.argv) > 5 and len(sys.argv[5]) > 0: + assert os.path.exists(sys.argv[5]), "Invalid firewall.conf location" + dispvm.firewall_conf = sys.argv[5] qvm_collection.save() qvm_collection.unlock_db() # Reload firewall rules @@ -137,6 +145,9 @@ def main(): exec_index = sys.argv[1] src_vmname = sys.argv[2] user = sys.argv[3] + #accessed directly by get_dvm() + # sys.argv[4] - override label + # sys.argv[5] - override firewall notify_object = dbus.SessionBus().get_object("org.freedesktop.Notifications", "/org/freedesktop/Notifications") qfile = QfileDaemonDvm(src_vmname) diff --git a/rpm_spec/core-dom0.spec b/rpm_spec/core-dom0.spec index e9c3cd67..918164f9 100644 --- a/rpm_spec/core-dom0.spec +++ b/rpm_spec/core-dom0.spec @@ -155,6 +155,8 @@ mkdir -p $RPM_BUILD_ROOT/usr/share/qubes/icons cp icons/*.png $RPM_BUILD_ROOT/usr/share/qubes/icons cp misc/qubes-vm.directory.template $RPM_BUILD_ROOT/usr/share/qubes/ cp misc/qubes-templatevm.directory.template $RPM_BUILD_ROOT/usr/share/qubes/ +cp misc/qubes-dispvm.directory $RPM_BUILD_ROOT/usr/share/qubes/ +cp misc/qubes-dispvm-firefox.desktop $RPM_BUILD_ROOT/usr/share/qubes/ cp misc/qubes-appmenu-select.desktop $RPM_BUILD_ROOT/usr/share/qubes/ cp misc/vm-template.conf $RPM_BUILD_ROOT/usr/share/qubes/ @@ -252,6 +254,8 @@ for i in /usr/share/qubes/icons/*.png ; do xdg-icon-resource install --novendor --size 48 $i done +xdg-desktop-menu install /usr/share/qubes/qubes-dispvm.directory /usr/share/qubes/qubes-dispvm-firefox.desktop + # Because we now have an installer # this script is always executed during upgrade # and we decided not to restart core during upgrade @@ -293,6 +297,8 @@ if [ "$1" = 0 ] ; then for i in /usr/share/qubes/icons/*.png ; do xdg-icon-resource uninstall --novendor --size 48 $i done + + xdg-desktop-menu uninstall /usr/share/qubes/qubes-dispvm.directory /usr/share/qubes/qubes-dispvm-firefox.desktop fi %postun @@ -353,6 +359,8 @@ fi /usr/share/qubes/icons/*.png /usr/share/qubes/qubes-vm.directory.template /usr/share/qubes/qubes-templatevm.directory.template +/usr/share/qubes/qubes-dispvm.directory +/usr/share/qubes/qubes-dispvm-firefox.desktop /usr/share/qubes/qubes-appmenu-select.desktop /usr/share/qubes/vm-template.conf /usr/lib/qubes/qubes_setup_dnat_to_ns