dom0: appmenu to start Firefox in new DispVM (#594)
This commit is contained in:
parent
55ad480a14
commit
0008e71784
10
dom0/misc/qubes-dispvm-firefox.desktop
Normal file
10
dom0/misc/qubes-dispvm-firefox.desktop
Normal file
@ -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;
|
5
dom0/misc/qubes-dispvm.directory
Normal file
5
dom0/misc/qubes-dispvm.directory
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Encoding=UTF-8
|
||||||
|
Type=Directory
|
||||||
|
Name=DisposableVM
|
||||||
|
Icon=/usr/share/qubes/icons/dispvm-red.png
|
@ -29,6 +29,7 @@ import shutil
|
|||||||
from qubes.qubes import QubesVmCollection
|
from qubes.qubes import QubesVmCollection
|
||||||
from qubes.qubes import QubesException
|
from qubes.qubes import QubesException
|
||||||
from qubes.qubes import QubesDaemonPidfile
|
from qubes.qubes import QubesDaemonPidfile
|
||||||
|
from qubes.qubes import QubesDispVmLabels
|
||||||
from qubes.qmemman_client import QMemmanClient
|
from qubes.qmemman_client import QMemmanClient
|
||||||
|
|
||||||
current_savefile = '/var/run/qubes/current_savefile'
|
current_savefile = '/var/run/qubes/current_savefile'
|
||||||
@ -58,12 +59,16 @@ class QfileDaemonDvm:
|
|||||||
qvm_collection.unlock_db()
|
qvm_collection.unlock_db()
|
||||||
qmemman_client.close()
|
qmemman_client.close()
|
||||||
return None
|
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',
|
retcode = subprocess.call(['/usr/lib/qubes/qubes_restore',
|
||||||
current_savefile,
|
current_savefile,
|
||||||
current_dvm_conf,
|
current_dvm_conf,
|
||||||
'-c', vm.label.color,
|
'-c', label.color,
|
||||||
'-i', vm.label.icon,
|
'-i', label.icon,
|
||||||
'-l', str(vm.label.index)])
|
'-l', str(label.index)])
|
||||||
qmemman_client.close()
|
qmemman_client.close()
|
||||||
if retcode != 0:
|
if retcode != 0:
|
||||||
subprocess.call(['/usr/bin/kdialog', '--sorry', 'DisposableVM creation failed, see qubes_restore.log'])
|
subprocess.call(['/usr/bin/kdialog', '--sorry', 'DisposableVM creation failed, see qubes_restore.log'])
|
||||||
@ -80,12 +85,15 @@ class QfileDaemonDvm:
|
|||||||
qvm_collection.unlock_db()
|
qvm_collection.unlock_db()
|
||||||
return None
|
return None
|
||||||
dispid=int(disp_name[4:])
|
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
|
# By default inherit firewall rules from calling VM
|
||||||
if os.path.exists(vm.firewall_conf):
|
if os.path.exists(vm.firewall_conf):
|
||||||
disp_firewall_conf = '/var/run/qubes/%s-firewall.xml' % disp_name
|
disp_firewall_conf = '/var/run/qubes/%s-firewall.xml' % disp_name
|
||||||
shutil.copy(vm.firewall_conf, disp_firewall_conf)
|
shutil.copy(vm.firewall_conf, disp_firewall_conf)
|
||||||
dispvm.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.save()
|
||||||
qvm_collection.unlock_db()
|
qvm_collection.unlock_db()
|
||||||
# Reload firewall rules
|
# Reload firewall rules
|
||||||
@ -137,6 +145,9 @@ def main():
|
|||||||
exec_index = sys.argv[1]
|
exec_index = sys.argv[1]
|
||||||
src_vmname = sys.argv[2]
|
src_vmname = sys.argv[2]
|
||||||
user = sys.argv[3]
|
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")
|
notify_object = dbus.SessionBus().get_object("org.freedesktop.Notifications", "/org/freedesktop/Notifications")
|
||||||
qfile = QfileDaemonDvm(src_vmname)
|
qfile = QfileDaemonDvm(src_vmname)
|
||||||
|
@ -157,6 +157,8 @@ mkdir -p $RPM_BUILD_ROOT/usr/share/qubes/icons
|
|||||||
cp icons/*.png $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-vm.directory.template $RPM_BUILD_ROOT/usr/share/qubes/
|
||||||
cp misc/qubes-templatevm.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/qubes-appmenu-select.desktop $RPM_BUILD_ROOT/usr/share/qubes/
|
||||||
cp misc/qubes-start.desktop $RPM_BUILD_ROOT/usr/share/qubes/
|
cp misc/qubes-start.desktop $RPM_BUILD_ROOT/usr/share/qubes/
|
||||||
cp misc/vm-template.conf $RPM_BUILD_ROOT/usr/share/qubes/
|
cp misc/vm-template.conf $RPM_BUILD_ROOT/usr/share/qubes/
|
||||||
@ -256,6 +258,8 @@ for i in /usr/share/qubes/icons/*.png ; do
|
|||||||
xdg-icon-resource install --novendor --size 48 $i
|
xdg-icon-resource install --novendor --size 48 $i
|
||||||
done
|
done
|
||||||
|
|
||||||
|
xdg-desktop-menu install /usr/share/qubes/qubes-dispvm.directory /usr/share/qubes/qubes-dispvm-firefox.desktop
|
||||||
|
|
||||||
# Because we now have an installer
|
# Because we now have an installer
|
||||||
# this script is always executed during upgrade
|
# this script is always executed during upgrade
|
||||||
# and we decided not to restart core during upgrade
|
# and we decided not to restart core during upgrade
|
||||||
@ -297,6 +301,8 @@ if [ "$1" = 0 ] ; then
|
|||||||
for i in /usr/share/qubes/icons/*.png ; do
|
for i in /usr/share/qubes/icons/*.png ; do
|
||||||
xdg-icon-resource uninstall --novendor --size 48 $i
|
xdg-icon-resource uninstall --novendor --size 48 $i
|
||||||
done
|
done
|
||||||
|
|
||||||
|
xdg-desktop-menu uninstall /usr/share/qubes/qubes-dispvm.directory /usr/share/qubes/qubes-dispvm-firefox.desktop
|
||||||
fi
|
fi
|
||||||
|
|
||||||
%postun
|
%postun
|
||||||
@ -358,6 +364,8 @@ fi
|
|||||||
/usr/share/qubes/icons/*.png
|
/usr/share/qubes/icons/*.png
|
||||||
/usr/share/qubes/qubes-vm.directory.template
|
/usr/share/qubes/qubes-vm.directory.template
|
||||||
/usr/share/qubes/qubes-templatevm.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/qubes-appmenu-select.desktop
|
||||||
/usr/share/qubes/qubes-start.desktop
|
/usr/share/qubes/qubes-start.desktop
|
||||||
/usr/share/qubes/vm-template.conf
|
/usr/share/qubes/vm-template.conf
|
||||||
|
Loading…
Reference in New Issue
Block a user