appmenus: fallback hardcoded appmenus for HVM with qrexec installed
If VM didn't returned any appmenus data, the service is most likely not available there. Actually it hasn't been written yet.
This commit is contained in:
parent
190d52b6fb
commit
c000f24def
8
appmenus-files/hvm/cmd.desktop
Normal file
8
appmenus-files/hvm/cmd.desktop
Normal file
@ -0,0 +1,8 @@
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Type=Application
|
||||
Terminal=false
|
||||
Name=Command Prompt
|
||||
Comment=Use the command line
|
||||
Categories=GNOME;GTK;Utility;TerminalEmulator;System;
|
||||
Exec=cmd /c start cmd
|
8
appmenus-files/hvm/explorer.desktop
Normal file
8
appmenus-files/hvm/explorer.desktop
Normal file
@ -0,0 +1,8 @@
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Type=Application
|
||||
Terminal=false
|
||||
Name=Libraries
|
||||
Comment=Browse files
|
||||
Categories=Utility;Core;
|
||||
Exec=explorer
|
8
appmenus-files/hvm/internet-explorer.desktop
Normal file
8
appmenus-files/hvm/internet-explorer.desktop
Normal file
@ -0,0 +1,8 @@
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Type=Application
|
||||
Terminal=false
|
||||
Name=Internet Explorer
|
||||
Comment=Browse the Web
|
||||
Categories=Network;WebBrowser;
|
||||
Exec=C:\Program Files\Internet Explorer\iexplore.exe
|
@ -27,7 +27,8 @@ import sys
|
||||
import fnmatch
|
||||
import shutil
|
||||
from optparse import OptionParser
|
||||
from qubes.qubes import QubesVmCollection,QubesException
|
||||
from qubes.qubes import QubesVmCollection,QubesException,system_path
|
||||
from qubes.qubes import QubesHVm
|
||||
|
||||
# fields required to be present (and verified) in retrieved desktop file
|
||||
required_fields = [ "Name", "Exec" ]
|
||||
@ -43,9 +44,15 @@ fields_regexp = {
|
||||
"GenericName": std_re,
|
||||
"Comment": std_re,
|
||||
"Categories": re.compile(r"^[a-zA-Z0-9/.; -]*$"),
|
||||
"Exec": re.compile(r"^[a-zA-Z0-9%>/:.= -]*$"),
|
||||
"Exec": re.compile(r"^[a-zA-Z0-9%>/\\:.= -]*$"),
|
||||
}
|
||||
|
||||
def fallback_hvm_appmenulist():
|
||||
p = subprocess.Popen(["grep", "-rH", "=", "/usr/share/qubes-appmenus/hvm"],
|
||||
stdout=subprocess.PIPE)
|
||||
(stdout, stderr) = p.communicate()
|
||||
return stdout.splitlines()
|
||||
|
||||
def get_appmenus(vm):
|
||||
global appmenus_line_count
|
||||
global appmenus_line_size
|
||||
@ -69,7 +76,10 @@ def get_appmenus(vm):
|
||||
appmenus_line_count -= 1
|
||||
p.wait()
|
||||
if p.returncode != 0:
|
||||
raise QubesException("Error getting application list")
|
||||
if isinstance(vm, QubesHVm):
|
||||
untrusted_appmenulist = fallback_hvm_appmenulist()
|
||||
else:
|
||||
raise QubesException("Error getting application list")
|
||||
if appmenus_line_count == 0:
|
||||
raise QubesException("Line count limit exceeded")
|
||||
|
||||
@ -144,6 +154,8 @@ def main():
|
||||
parser.add_option ("-v", "--verbose", action="store_true", dest="verbose", default=False)
|
||||
parser.add_option ("--force-root", action="store_true", dest="force_root", default=False,
|
||||
help="Force to run, even with root privileges")
|
||||
parser.add_option ("--force-rpc", action="store_true", dest="force_rpc", default=False,
|
||||
help="Force to start a new RPC call, even if called from existing one")
|
||||
|
||||
(options, args) = parser.parse_args ()
|
||||
if (len (args) != 1) and env_vmname is None:
|
||||
@ -181,7 +193,7 @@ def main():
|
||||
exit(1)
|
||||
|
||||
new_appmenus = {}
|
||||
if env_vmname is None:
|
||||
if env_vmname is None or options.force_rpc:
|
||||
new_appmenus = get_appmenus(vm)
|
||||
else:
|
||||
options.verbose = False
|
||||
@ -205,7 +217,7 @@ def main():
|
||||
print >> sys.stderr, "---> Creating {0}".format(appmenu_file)
|
||||
create_template(vm.appmenus_templates_dir + '/' + appmenu_file, new_appmenus[appmenu_file])
|
||||
|
||||
# Delete appmenus of remove applications
|
||||
# Delete appmenus of removed applications
|
||||
if options.verbose:
|
||||
print >> sys.stderr, "--> Cleaning old files"
|
||||
for appmenu_file in os.listdir(vm.appmenus_templates_dir):
|
||||
@ -217,4 +229,9 @@ def main():
|
||||
print >> sys.stderr, "---> Removing {0}".format(appmenu_file)
|
||||
os.unlink(vm.appmenus_templates_dir + '/' + appmenu_file)
|
||||
|
||||
if isinstance(vm, QubesHVm):
|
||||
if not os.path.exists(os.path.join(vm.appmenus_templates_dir,
|
||||
os.path.basename(system_path['appmenu_start_hvm_template']))):
|
||||
shutil.copy(system_path['appmenu_start_hvm_template'], vm.appmenus_templates_dir)
|
||||
|
||||
main()
|
||||
|
@ -88,7 +88,7 @@ cp appmenus-scripts/qubes.SyncAppMenus $RPM_BUILD_ROOT/etc/qubes-rpc/
|
||||
cp appmenus-scripts/qubes.SyncAppMenus.policy $RPM_BUILD_ROOT/etc/qubes-rpc/policy/qubes.SyncAppMenus
|
||||
|
||||
mkdir -p $RPM_BUILD_ROOT/usr/share/qubes-appmenus/
|
||||
cp appmenus-files/* $RPM_BUILD_ROOT/usr/share/qubes-appmenus/
|
||||
cp -r appmenus-files/* $RPM_BUILD_ROOT/usr/share/qubes-appmenus/
|
||||
|
||||
### Dom0 updates
|
||||
install -D dom0-updates/qubes-dom0-updates.cron $RPM_BUILD_ROOT/etc/cron.daily/qubes-dom0-updates.cron
|
||||
@ -208,6 +208,7 @@ mv -f /lib/udev/rules.d/69-xorg-vmmouse.rules /var/lib/qubes/removed-udev-script
|
||||
/usr/share/qubes-appmenus/qubes-start.desktop
|
||||
/usr/share/qubes-appmenus/qubes-templatevm.directory.template
|
||||
/usr/share/qubes-appmenus/qubes-vm.directory.template
|
||||
/usr/share/qubes-appmenus/hvm
|
||||
/usr/share/qubes/icons/*.png
|
||||
/usr/bin/qvm-sync-appmenus
|
||||
# Dom0 updates
|
||||
|
Loading…
Reference in New Issue
Block a user