Merge branch 'master' into hvm
Conflicts: dom0/qvm-tools/qvm-create version_dom0
This commit is contained in:
commit
c0455ac641
@ -214,12 +214,14 @@ class SystemState:
|
|||||||
print 'dom %s didnt react to memory request (holds %d, requested balloon down to %d)' % (dom2, self.domdict[dom2].memory_actual, mem2)
|
print 'dom %s didnt react to memory request (holds %d, requested balloon down to %d)' % (dom2, self.domdict[dom2].memory_actual, mem2)
|
||||||
self.domdict[dom2].no_progress = True
|
self.domdict[dom2].no_progress = True
|
||||||
dom_name = self.xs.read('', '/local/domain/%s/name' % str(dom2))
|
dom_name = self.xs.read('', '/local/domain/%s/name' % str(dom2))
|
||||||
notify_error_qubes_manager(dom_name, no_progress_msg)
|
if dom_name is not None:
|
||||||
|
notify_error_qubes_manager(str(dom_name), no_progress_msg)
|
||||||
else:
|
else:
|
||||||
print 'dom %s still hold more memory than have assigned (%d > %d)' % (dom2, self.domdict[dom2].memory_actual, mem2)
|
print 'dom %s still hold more memory than have assigned (%d > %d)' % (dom2, self.domdict[dom2].memory_actual, mem2)
|
||||||
self.domdict[dom2].slow_memset_react = True
|
self.domdict[dom2].slow_memset_react = True
|
||||||
dom_name = self.xs.read('', '/local/domain/%s/name' % str(dom2))
|
dom_name = self.xs.read('', '/local/domain/%s/name' % str(dom2))
|
||||||
notify_error_qubes_manager(dom_name, slow_memset_react_msg)
|
if dom_name is not None:
|
||||||
|
notify_error_qubes_manager(str(dom_name), slow_memset_react_msg)
|
||||||
self.mem_set(dom, self.get_free_xen_memory() + self.domdict[dom].memory_actual - self.XEN_FREE_MEM_LEFT)
|
self.mem_set(dom, self.get_free_xen_memory() + self.domdict[dom].memory_actual - self.XEN_FREE_MEM_LEFT)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -1 +0,0 @@
|
|||||||
/usr/bin/qvm-sync-appmenus
|
|
@ -50,10 +50,12 @@ def main():
|
|||||||
os.umask(0002)
|
os.umask(0002)
|
||||||
qubes_gid = grp.getgrnam('qubes').gr_gid
|
qubes_gid = grp.getgrnam('qubes').gr_gid
|
||||||
|
|
||||||
update_count = sys.stdin.readline(128).strip()
|
untrusted_update_count = sys.stdin.readline(128).strip()
|
||||||
if not update_count.isdigit():
|
if not untrusted_update_count.isdigit():
|
||||||
print >> sys.stderr, 'Domain ' + source + ' sent invalid number of updates: ' + update_count
|
print >> sys.stderr, 'Domain ' + source + ' sent invalid number of updates: %s' % untrusted_update_count
|
||||||
exit(1)
|
exit(1)
|
||||||
|
# now sanitized
|
||||||
|
update_count = untrusted_update_count
|
||||||
if source_vm.updateable:
|
if source_vm.updateable:
|
||||||
# Just trust information from VM itself
|
# Just trust information from VM itself
|
||||||
update_f = open(source_vm.dir_path + '/' + updates_stat_file, "w")
|
update_f = open(source_vm.dir_path + '/' + updates_stat_file, "w")
|
226
dom0/qubes_rpc/qubes-receive-appmenus
Executable file
226
dom0/qubes_rpc/qubes-receive-appmenus
Executable file
@ -0,0 +1,226 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
#
|
||||||
|
# The Qubes OS Project, http://www.qubes-os.org
|
||||||
|
#
|
||||||
|
# Copyright (C) 2011 Marek Marczykowski <marmarek@mimuw.edu.pl>
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
import subprocess
|
||||||
|
import re
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import fnmatch
|
||||||
|
import shutil
|
||||||
|
from optparse import OptionParser
|
||||||
|
from qubes.qubes import QubesVmCollection,QubesException
|
||||||
|
from qubes.qubes import qrexec_client_path
|
||||||
|
|
||||||
|
# fields required to be present (and verified) in retrieved desktop file
|
||||||
|
required_fields = [ "Name", "Exec" ]
|
||||||
|
|
||||||
|
#limits
|
||||||
|
appmenus_line_size = 1024
|
||||||
|
appmenus_line_count = 100000
|
||||||
|
|
||||||
|
# regexps for sanitization of retrieved values
|
||||||
|
std_re = re.compile(r"^[/a-zA-Z0-9.,&() -]*$")
|
||||||
|
fields_regexp = {
|
||||||
|
"Name": std_re,
|
||||||
|
"GenericName": std_re,
|
||||||
|
"Comment": std_re,
|
||||||
|
"Categories": re.compile(r"^[a-zA-Z0-9/.; -]*$"),
|
||||||
|
"Exec": re.compile(r"^[a-zA-Z0-9%>/:.= -]*$"),
|
||||||
|
}
|
||||||
|
|
||||||
|
def get_appmenus(xid):
|
||||||
|
global appmenus_line_count
|
||||||
|
global appmenus_line_size
|
||||||
|
untrusted_appmenulist = []
|
||||||
|
if xid == -1:
|
||||||
|
while appmenus_line_count > 0:
|
||||||
|
untrusted_line = sys.stdin.readline(appmenus_line_size)
|
||||||
|
if untrusted_line == "":
|
||||||
|
break;
|
||||||
|
untrusted_appmenulist.append(untrusted_line.strip())
|
||||||
|
appmenus_line_count -= 1
|
||||||
|
if appmenus_line_count == 0:
|
||||||
|
raise QubesException("Line count limit exceeded")
|
||||||
|
else:
|
||||||
|
p = subprocess.Popen ([qrexec_client_path, '-d', str(xid),
|
||||||
|
'user:QUBESRPC qubes.GetAppmenus dom0'], stdout=subprocess.PIPE)
|
||||||
|
while appmenus_line_count > 0:
|
||||||
|
untrusted_line = p.stdout.readline(appmenus_line_size)
|
||||||
|
if untrusted_line == "":
|
||||||
|
break;
|
||||||
|
untrusted_appmenulist.append(untrusted_line.strip())
|
||||||
|
appmenus_line_count -= 1
|
||||||
|
p.wait()
|
||||||
|
if p.returncode != 0:
|
||||||
|
raise QubesException("Error getting application list")
|
||||||
|
if appmenus_line_count == 0:
|
||||||
|
raise QubesException("Line count limit exceeded")
|
||||||
|
|
||||||
|
row_no = 0
|
||||||
|
appmenus = {}
|
||||||
|
line_rx = re.compile(r"([a-zA-Z0-9-.]+.desktop):([a-zA-Z0-9-]+(?:\[[a-zA-Z@_]+\])?)=(.*)")
|
||||||
|
ignore_rx = re.compile(r".*([a-zA-Z0-9-.]+.desktop):(#.*|\s+)$")
|
||||||
|
for untrusted_line in untrusted_appmenulist:
|
||||||
|
# Ignore blank lines and comments
|
||||||
|
if len(untrusted_line) == 0 or ignore_rx.match(untrusted_line):
|
||||||
|
continue
|
||||||
|
# use search instead of match to skip file path
|
||||||
|
untrusted_m = line_rx.search(untrusted_line)
|
||||||
|
if untrusted_m:
|
||||||
|
untrusted_key = untrusted_m.group(2)
|
||||||
|
untrusted_value = untrusted_m.group(3)
|
||||||
|
# Look only at predefined keys
|
||||||
|
if fields_regexp.has_key(untrusted_key):
|
||||||
|
if fields_regexp[untrusted_key].match(untrusted_value):
|
||||||
|
# now values are sanitized
|
||||||
|
key = untrusted_key
|
||||||
|
value = untrusted_value
|
||||||
|
filename = untrusted_m.group(1)
|
||||||
|
|
||||||
|
if not appmenus.has_key(filename):
|
||||||
|
appmenus[filename] = {}
|
||||||
|
|
||||||
|
appmenus[filename][key]=value
|
||||||
|
else:
|
||||||
|
print >>sys.stderr, "Warning: ignoring key %s: %s" % (untrusted_key, untrusted_value)
|
||||||
|
# else: ignore this key
|
||||||
|
else:
|
||||||
|
print >>sys.stderr, "Warning: ignoring line: %s" % (untrusted_line);
|
||||||
|
|
||||||
|
return appmenus
|
||||||
|
|
||||||
|
|
||||||
|
def create_template(path, values):
|
||||||
|
|
||||||
|
# check if all required fields are present
|
||||||
|
for key in required_fields:
|
||||||
|
if not values.has_key(key):
|
||||||
|
print >>sys.stderr, "Warning: not creating/updating '%s' because of missing '%s' key" % (path, key)
|
||||||
|
return
|
||||||
|
|
||||||
|
desktop_file = open(path, "w")
|
||||||
|
desktop_file.write("[Desktop Entry]\n")
|
||||||
|
desktop_file.write("Version=1.0\n")
|
||||||
|
desktop_file.write("Type=Application\n")
|
||||||
|
desktop_file.write("Terminal=false\n")
|
||||||
|
desktop_file.write("X-Qubes-VmName=%VMNAME%\n")
|
||||||
|
desktop_file.write("Icon=%VMDIR%/icon.png\n")
|
||||||
|
for key in ["Name", "GenericName" ]:
|
||||||
|
if values.has_key(key):
|
||||||
|
desktop_file.write("{0}=%VMNAME%: {1}\n".format(key, values[key]))
|
||||||
|
|
||||||
|
for key in [ "Comment", "Categories" ]:
|
||||||
|
if values.has_key(key):
|
||||||
|
desktop_file.write("{0}={1}\n".format(key, values[key]))
|
||||||
|
|
||||||
|
desktop_file.write("Exec=qvm-run -q --tray -a %VMNAME% '{0}'\n".format(values['Exec']))
|
||||||
|
desktop_file.close()
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
|
||||||
|
env_vmname = os.environ.get("QREXEC_REMOTE_DOMAIN")
|
||||||
|
usage = "usage: %prog [options] <vm-name>\n"\
|
||||||
|
"Updates desktop file templates for given StandaloneVM or TemplateVM"
|
||||||
|
|
||||||
|
parser = OptionParser (usage)
|
||||||
|
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")
|
||||||
|
|
||||||
|
(options, args) = parser.parse_args ()
|
||||||
|
if (len (args) != 1) and env_vmname is None:
|
||||||
|
parser.error ("You must specify at least the VM name!")
|
||||||
|
|
||||||
|
if env_vmname:
|
||||||
|
vmname=env_vmname
|
||||||
|
else:
|
||||||
|
vmname=args[0]
|
||||||
|
|
||||||
|
if os.geteuid() == 0:
|
||||||
|
if not options.force_root:
|
||||||
|
print >> sys.stderr, "*** Running this tool as root is strongly discouraged, this will lead you in permissions problems."
|
||||||
|
print >> sys.stderr, "Retry as unprivileged user."
|
||||||
|
print >> sys.stderr, "... or use --force-root to continue anyway."
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
qvm_collection = QubesVmCollection()
|
||||||
|
qvm_collection.lock_db_for_reading()
|
||||||
|
qvm_collection.load()
|
||||||
|
qvm_collection.unlock_db()
|
||||||
|
|
||||||
|
vm = qvm_collection.get_vm_by_name(vmname)
|
||||||
|
|
||||||
|
if vm is None:
|
||||||
|
print >>sys.stderr, "ERROR: A VM with the name '{0}' does not exist in the system.".format(vmname)
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
if vm.template is not None:
|
||||||
|
print >>sys.stderr, "ERROR: To sync appmenus for template based VM, do it on template instead"
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
if not vm.is_running():
|
||||||
|
print >>sys.stderr, "ERROR: Appmenus can be retrieved only from running VM - start it first"
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
new_appmenus = {}
|
||||||
|
if env_vmname is None:
|
||||||
|
# Get appmenus from VM
|
||||||
|
xid = vm.get_xid()
|
||||||
|
assert xid > 0
|
||||||
|
|
||||||
|
new_appmenus = get_appmenus(xid)
|
||||||
|
else:
|
||||||
|
options.verbose = False
|
||||||
|
new_appmenus = get_appmenus(-1)
|
||||||
|
|
||||||
|
if len(new_appmenus) == 0:
|
||||||
|
print >>sys.stderr, "ERROR: No appmenus received, terminating"
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
if not os.path.exists(vm.appmenus_templates_dir):
|
||||||
|
os.mkdir(vm.appmenus_templates_dir)
|
||||||
|
|
||||||
|
# Create new/update existing templates
|
||||||
|
if options.verbose:
|
||||||
|
print >> sys.stderr, "--> Got {0} appmenus, storing to disk".format(str(len(new_appmenus)))
|
||||||
|
for appmenu_file in new_appmenus.keys():
|
||||||
|
if options.verbose:
|
||||||
|
if os.path.exists(vm.appmenus_templates_dir + '/' + appmenu_file):
|
||||||
|
print >> sys.stderr, "---> Updating {0}".format(appmenu_file)
|
||||||
|
else:
|
||||||
|
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
|
||||||
|
if options.verbose:
|
||||||
|
print >> sys.stderr, "--> Cleaning old files"
|
||||||
|
for appmenu_file in os.listdir(vm.appmenus_templates_dir):
|
||||||
|
if not fnmatch.fnmatch(appmenu_file, '*.desktop'):
|
||||||
|
continue
|
||||||
|
|
||||||
|
if not new_appmenus.has_key(appmenu_file):
|
||||||
|
if options.verbose:
|
||||||
|
print >> sys.stderr, "---> Removing {0}".format(appmenu_file)
|
||||||
|
os.unlink(vm.appmenus_templates_dir + '/' + appmenu_file)
|
||||||
|
|
||||||
|
main()
|
@ -66,9 +66,12 @@ def handle_dom0updates(updatevm):
|
|||||||
os.chmod(updates_rpm_dir, 0775)
|
os.chmod(updates_rpm_dir, 0775)
|
||||||
subprocess.check_call(["/usr/lib/qubes/qfile-dom0-unpacker", str(os.getuid()), updates_rpm_dir])
|
subprocess.check_call(["/usr/lib/qubes/qfile-dom0-unpacker", str(os.getuid()), updates_rpm_dir])
|
||||||
# Verify received files
|
# Verify received files
|
||||||
for f in os.listdir(updates_rpm_dir):
|
for untrusted_f in os.listdir(updates_rpm_dir):
|
||||||
full_path = updates_rpm_dir + "/" + f
|
if not package_regex.match(untrusted_f):
|
||||||
if package_regex.match(f):
|
dom0updates_fatal(untrusted_f, 'Domain ' + source + ' sent unexpected file: ' + untrusted_f)
|
||||||
|
else:
|
||||||
|
f = untrusted_f
|
||||||
|
full_path = updates_rpm_dir + "/" + f
|
||||||
if os.path.islink(full_path) or not os.path.isfile(full_path):
|
if os.path.islink(full_path) or not os.path.isfile(full_path):
|
||||||
dom0updates_fatal(f, 'Domain ' + source + ' sent not regular file')
|
dom0updates_fatal(f, 'Domain ' + source + ' sent not regular file')
|
||||||
p = subprocess.Popen (["/bin/rpm", "-K", full_path],
|
p = subprocess.Popen (["/bin/rpm", "-K", full_path],
|
||||||
@ -78,8 +81,6 @@ def handle_dom0updates(updatevm):
|
|||||||
dom0updates_fatal(f, 'Error while verifing %s signature: %s' % (f, output))
|
dom0updates_fatal(f, 'Error while verifing %s signature: %s' % (f, output))
|
||||||
if not gpg_ok_regex.search(output.strip()):
|
if not gpg_ok_regex.search(output.strip()):
|
||||||
dom0updates_fatal(f, 'Domain ' + source + ' sent not signed rpm: ' + f)
|
dom0updates_fatal(f, 'Domain ' + source + ' sent not signed rpm: ' + f)
|
||||||
else:
|
|
||||||
dom0updates_fatal(f, 'Domain ' + source + ' sent unexpected file: ' + f)
|
|
||||||
if updates_error_file_handle is not None:
|
if updates_error_file_handle is not None:
|
||||||
updates_error_file_handle.close()
|
updates_error_file_handle.close()
|
||||||
# After updates received - create repo metadata
|
# After updates received - create repo metadata
|
1
dom0/qubes_rpc/qubes.SyncAppMenus
Normal file
1
dom0/qubes_rpc/qubes.SyncAppMenus
Normal file
@ -0,0 +1 @@
|
|||||||
|
/usr/lib/qubes/qubes-receive-appmenus
|
@ -1,225 +1,2 @@
|
|||||||
#!/usr/bin/python
|
#!/bin/sh
|
||||||
#
|
exec /usr/lib/qubes/qubes-receive-appmenus $@
|
||||||
# The Qubes OS Project, http://www.qubes-os.org
|
|
||||||
#
|
|
||||||
# Copyright (C) 2011 Marek Marczykowski <marmarek@mimuw.edu.pl>
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
#
|
|
||||||
#
|
|
||||||
|
|
||||||
import subprocess
|
|
||||||
import re
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import fnmatch
|
|
||||||
import shutil
|
|
||||||
from optparse import OptionParser
|
|
||||||
from qubes.qubes import QubesVmCollection,QubesException
|
|
||||||
from qubes.qubes import qrexec_client_path
|
|
||||||
|
|
||||||
# fields required to be present (and verified) in retrieved desktop file
|
|
||||||
required_fields = [ "Name", "Exec" ]
|
|
||||||
|
|
||||||
#limits
|
|
||||||
appmenus_line_size = 1024
|
|
||||||
appmenus_line_count = 100000
|
|
||||||
|
|
||||||
# regexps for sanitization of retrieved values
|
|
||||||
std_re = re.compile(r"^[/a-zA-Z0-9.,&() -]*$")
|
|
||||||
fields_regexp = {
|
|
||||||
"Name": std_re,
|
|
||||||
"GenericName": std_re,
|
|
||||||
"Comment": std_re,
|
|
||||||
"Categories": re.compile(r"^[a-zA-Z0-9/.; -]*$"),
|
|
||||||
"Exec": re.compile(r"^[a-zA-Z0-9%>/:.= -]*$"),
|
|
||||||
}
|
|
||||||
|
|
||||||
def get_appmenus(xid):
|
|
||||||
global appmenus_line_count
|
|
||||||
global appmenus_line_size
|
|
||||||
untrusted_appmenulist = []
|
|
||||||
if xid == -1:
|
|
||||||
while appmenus_line_count > 0:
|
|
||||||
line = sys.stdin.readline(appmenus_line_size)
|
|
||||||
if line == "":
|
|
||||||
break;
|
|
||||||
untrusted_appmenulist.append(line.strip())
|
|
||||||
appmenus_line_count -= 1
|
|
||||||
if appmenus_line_count == 0:
|
|
||||||
raise QubesException("Line count limit exceeded")
|
|
||||||
else:
|
|
||||||
p = subprocess.Popen ([qrexec_client_path, '-d', str(xid),
|
|
||||||
'user:QUBESRPC qubes.GetAppmenus dom0'], stdout=subprocess.PIPE)
|
|
||||||
while appmenus_line_count > 0:
|
|
||||||
line = p.stdout.readline(appmenus_line_size)
|
|
||||||
if line == "":
|
|
||||||
break;
|
|
||||||
untrusted_appmenulist.append(line.strip())
|
|
||||||
appmenus_line_count -= 1
|
|
||||||
p.wait()
|
|
||||||
if p.returncode != 0:
|
|
||||||
raise QubesException("Error getting application list")
|
|
||||||
if appmenus_line_count == 0:
|
|
||||||
raise QubesException("Line count limit exceeded")
|
|
||||||
|
|
||||||
row_no = 0
|
|
||||||
appmenus = {}
|
|
||||||
line_rx = re.compile(r"([a-zA-Z0-9-.]+.desktop):([a-zA-Z0-9-]+(?:\[[a-zA-Z@_]+\])?)=(.*)")
|
|
||||||
ignore_rx = re.compile(r".*([a-zA-Z0-9-.]+.desktop):(#.*|\s+)$")
|
|
||||||
for untrusted_line in untrusted_appmenulist:
|
|
||||||
# Ignore blank lines and comments
|
|
||||||
if len(untrusted_line) == 0 or ignore_rx.match(untrusted_line):
|
|
||||||
continue
|
|
||||||
# use search instead of match to skip file path
|
|
||||||
untrusted_m = line_rx.search(untrusted_line)
|
|
||||||
if untrusted_m:
|
|
||||||
untrusted_key = untrusted_m.group(2)
|
|
||||||
untrusted_value = untrusted_m.group(3)
|
|
||||||
if fields_regexp.has_key(untrusted_key):
|
|
||||||
if fields_regexp[untrusted_key].match(untrusted_value):
|
|
||||||
# now values are sanitized
|
|
||||||
key = untrusted_key
|
|
||||||
value = untrusted_value
|
|
||||||
filename = untrusted_m.group(1)
|
|
||||||
|
|
||||||
if not appmenus.has_key(filename):
|
|
||||||
appmenus[filename] = {}
|
|
||||||
|
|
||||||
appmenus[filename][key]=value
|
|
||||||
else:
|
|
||||||
print >>sys.stderr, "Warning: ignoring key %s: %s" % (untrusted_key, untrusted_value)
|
|
||||||
# else: ignore this key
|
|
||||||
else:
|
|
||||||
print >>sys.stderr, "Warning: ignoring line: %s" % (untrusted_line);
|
|
||||||
|
|
||||||
return appmenus
|
|
||||||
|
|
||||||
|
|
||||||
def create_template(path, values):
|
|
||||||
|
|
||||||
# check if all required fields are present
|
|
||||||
for key in required_fields:
|
|
||||||
if not values.has_key(key):
|
|
||||||
print >>sys.stderr, "Warning: not creating/updating '%s' because of missing '%s' key" % (path, key)
|
|
||||||
return
|
|
||||||
|
|
||||||
desktop_file = open(path, "w")
|
|
||||||
desktop_file.write("[Desktop Entry]\n")
|
|
||||||
desktop_file.write("Version=1.0\n")
|
|
||||||
desktop_file.write("Type=Application\n")
|
|
||||||
desktop_file.write("Terminal=false\n")
|
|
||||||
desktop_file.write("X-Qubes-VmName=%VMNAME%\n")
|
|
||||||
desktop_file.write("Icon=%VMDIR%/icon.png\n")
|
|
||||||
for key in ["Name", "GenericName" ]:
|
|
||||||
if values.has_key(key):
|
|
||||||
desktop_file.write("{0}=%VMNAME%: {1}\n".format(key, values[key]))
|
|
||||||
|
|
||||||
for key in [ "Comment", "Categories" ]:
|
|
||||||
if values.has_key(key):
|
|
||||||
desktop_file.write("{0}={1}\n".format(key, values[key]))
|
|
||||||
|
|
||||||
desktop_file.write("Exec=qvm-run -q --tray -a %VMNAME% '{0}'\n".format(values['Exec']))
|
|
||||||
desktop_file.close()
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
|
|
||||||
env_vmname = os.environ.get("QREXEC_REMOTE_DOMAIN")
|
|
||||||
usage = "usage: %prog [options] <vm-name>\n"\
|
|
||||||
"Updates desktop file templates for given StandaloneVM or TemplateVM"
|
|
||||||
|
|
||||||
parser = OptionParser (usage)
|
|
||||||
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")
|
|
||||||
|
|
||||||
(options, args) = parser.parse_args ()
|
|
||||||
if (len (args) != 1) and env_vmname is None:
|
|
||||||
parser.error ("You must specify at least the VM name!")
|
|
||||||
|
|
||||||
if env_vmname:
|
|
||||||
vmname=env_vmname
|
|
||||||
else:
|
|
||||||
vmname=args[0]
|
|
||||||
|
|
||||||
if os.geteuid() == 0:
|
|
||||||
if not options.force_root:
|
|
||||||
print >> sys.stderr, "*** Running this tool as root is strongly discouraged, this will lead you in permissions problems."
|
|
||||||
print >> sys.stderr, "Retry as unprivileged user."
|
|
||||||
print >> sys.stderr, "... or use --force-root to continue anyway."
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
qvm_collection = QubesVmCollection()
|
|
||||||
qvm_collection.lock_db_for_reading()
|
|
||||||
qvm_collection.load()
|
|
||||||
qvm_collection.unlock_db()
|
|
||||||
|
|
||||||
vm = qvm_collection.get_vm_by_name(vmname)
|
|
||||||
|
|
||||||
if vm is None:
|
|
||||||
print >>sys.stderr, "ERROR: A VM with the name '{0}' does not exist in the system.".format(vmname)
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
if vm.template is not None:
|
|
||||||
print >>sys.stderr, "ERROR: To sync appmenus for template based VM, do it on template instead"
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
if not vm.is_running():
|
|
||||||
print >>sys.stderr, "ERROR: Appmenus can be retrieved only from running VM - start it first"
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
new_appmenus = {}
|
|
||||||
if env_vmname is None:
|
|
||||||
# Get appmenus from VM
|
|
||||||
xid = vm.get_xid()
|
|
||||||
assert xid > 0
|
|
||||||
|
|
||||||
new_appmenus = get_appmenus(xid)
|
|
||||||
else:
|
|
||||||
options.verbose = False
|
|
||||||
new_appmenus = get_appmenus(-1)
|
|
||||||
|
|
||||||
if len(new_appmenus) == 0:
|
|
||||||
print >>sys.stderr, "ERROR: No appmenus received, terminating"
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
if not os.path.exists(vm.appmenus_templates_dir):
|
|
||||||
os.mkdir(vm.appmenus_templates_dir)
|
|
||||||
|
|
||||||
# Create new/update existing templates
|
|
||||||
if options.verbose:
|
|
||||||
print >> sys.stderr, "--> Got {0} appmenus, storing to disk".format(str(len(new_appmenus)))
|
|
||||||
for appmenu_file in new_appmenus.keys():
|
|
||||||
if options.verbose:
|
|
||||||
if os.path.exists(vm.appmenus_templates_dir + '/' + appmenu_file):
|
|
||||||
print >> sys.stderr, "---> Updating {0}".format(appmenu_file)
|
|
||||||
else:
|
|
||||||
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
|
|
||||||
if options.verbose:
|
|
||||||
print >> sys.stderr, "--> Cleaning old files"
|
|
||||||
for appmenu_file in os.listdir(vm.appmenus_templates_dir):
|
|
||||||
if not fnmatch.fnmatch(appmenu_file, '*.desktop'):
|
|
||||||
continue
|
|
||||||
|
|
||||||
if not new_appmenus.has_key(appmenu_file):
|
|
||||||
if options.verbose:
|
|
||||||
print >> sys.stderr, "---> Removing {0}".format(appmenu_file)
|
|
||||||
os.unlink(vm.appmenus_templates_dir + '/' + appmenu_file)
|
|
||||||
|
|
||||||
main()
|
|
||||||
|
@ -53,7 +53,7 @@ The Qubes core files for installation on Dom0.
|
|||||||
python -m compileall qvm-core qmemman
|
python -m compileall qvm-core qmemman
|
||||||
python -O -m compileall qvm-core qmemman
|
python -O -m compileall qvm-core qmemman
|
||||||
make -C restore
|
make -C restore
|
||||||
make -C aux-tools
|
make -C qubes_rpc
|
||||||
make -C ../qubes_rpc
|
make -C ../qubes_rpc
|
||||||
make -C ../vchan -f Makefile.linux
|
make -C ../vchan -f Makefile.linux
|
||||||
make -C ../u2mfn
|
make -C ../u2mfn
|
||||||
@ -109,9 +109,10 @@ cp ../misc/meminfo-writer $RPM_BUILD_ROOT/usr/lib/qubes/
|
|||||||
cp ../qrexec/qrexec_daemon $RPM_BUILD_ROOT/usr/lib/qubes/
|
cp ../qrexec/qrexec_daemon $RPM_BUILD_ROOT/usr/lib/qubes/
|
||||||
cp ../qrexec/qrexec_client $RPM_BUILD_ROOT/usr/lib/qubes/
|
cp ../qrexec/qrexec_client $RPM_BUILD_ROOT/usr/lib/qubes/
|
||||||
cp ../qrexec/qrexec_policy $RPM_BUILD_ROOT/usr/lib/qubes/
|
cp ../qrexec/qrexec_policy $RPM_BUILD_ROOT/usr/lib/qubes/
|
||||||
cp aux-tools/qfile-dom0-unpacker $RPM_BUILD_ROOT/usr/lib/qubes/
|
cp qubes_rpc/qfile-dom0-unpacker $RPM_BUILD_ROOT/usr/lib/qubes/
|
||||||
cp aux-tools/qubes-notify-updates $RPM_BUILD_ROOT/usr/lib/qubes/
|
cp qubes_rpc/qubes-notify-updates $RPM_BUILD_ROOT/usr/lib/qubes/
|
||||||
cp aux-tools/qubes-receive-updates $RPM_BUILD_ROOT/usr/lib/qubes/
|
cp qubes_rpc/qubes-receive-appmenus $RPM_BUILD_ROOT/usr/lib/qubes/
|
||||||
|
cp qubes_rpc/qubes-receive-updates $RPM_BUILD_ROOT/usr/lib/qubes/
|
||||||
cp ../misc/block_add_change $RPM_BUILD_ROOT/usr/lib/qubes/
|
cp ../misc/block_add_change $RPM_BUILD_ROOT/usr/lib/qubes/
|
||||||
cp ../misc/block_remove $RPM_BUILD_ROOT/usr/lib/qubes/
|
cp ../misc/block_remove $RPM_BUILD_ROOT/usr/lib/qubes/
|
||||||
cp ../misc/block_cleanup $RPM_BUILD_ROOT/usr/lib/qubes/
|
cp ../misc/block_cleanup $RPM_BUILD_ROOT/usr/lib/qubes/
|
||||||
@ -122,13 +123,13 @@ mkdir -p $RPM_BUILD_ROOT/etc/qubes_rpc/policy
|
|||||||
cp ../qubes_rpc/qubes.Filecopy.policy $RPM_BUILD_ROOT/etc/qubes_rpc/policy/qubes.Filecopy
|
cp ../qubes_rpc/qubes.Filecopy.policy $RPM_BUILD_ROOT/etc/qubes_rpc/policy/qubes.Filecopy
|
||||||
cp ../qubes_rpc/qubes.OpenInVM.policy $RPM_BUILD_ROOT/etc/qubes_rpc/policy/qubes.OpenInVM
|
cp ../qubes_rpc/qubes.OpenInVM.policy $RPM_BUILD_ROOT/etc/qubes_rpc/policy/qubes.OpenInVM
|
||||||
cp ../qubes_rpc/qubes.VMShell.policy $RPM_BUILD_ROOT/etc/qubes_rpc/policy/qubes.VMShell
|
cp ../qubes_rpc/qubes.VMShell.policy $RPM_BUILD_ROOT/etc/qubes_rpc/policy/qubes.VMShell
|
||||||
cp qubes.SyncAppMenus.policy $RPM_BUILD_ROOT/etc/qubes_rpc/policy/qubes.SyncAppMenus
|
cp qubes_rpc/qubes.SyncAppMenus.policy $RPM_BUILD_ROOT/etc/qubes_rpc/policy/qubes.SyncAppMenus
|
||||||
cp qubes.SyncAppMenus $RPM_BUILD_ROOT/etc/qubes_rpc/
|
cp qubes_rpc/qubes.SyncAppMenus $RPM_BUILD_ROOT/etc/qubes_rpc/
|
||||||
cp ../qrexec/qubes_rpc_multiplexer $RPM_BUILD_ROOT/usr/lib/qubes
|
cp ../qrexec/qubes_rpc_multiplexer $RPM_BUILD_ROOT/usr/lib/qubes
|
||||||
cp aux-tools/qubes.NotifyUpdates.policy $RPM_BUILD_ROOT/etc/qubes_rpc/policy/qubes.NotifyUpdates
|
cp qubes_rpc/qubes.NotifyUpdates.policy $RPM_BUILD_ROOT/etc/qubes_rpc/policy/qubes.NotifyUpdates
|
||||||
cp aux-tools/qubes.NotifyUpdates $RPM_BUILD_ROOT/etc/qubes_rpc/
|
cp qubes_rpc/qubes.NotifyUpdates $RPM_BUILD_ROOT/etc/qubes_rpc/
|
||||||
cp aux-tools/qubes.ReceiveUpdates.policy $RPM_BUILD_ROOT/etc/qubes_rpc/policy/qubes.ReceiveUpdates
|
cp qubes_rpc/qubes.ReceiveUpdates.policy $RPM_BUILD_ROOT/etc/qubes_rpc/policy/qubes.ReceiveUpdates
|
||||||
cp aux-tools/qubes.ReceiveUpdates $RPM_BUILD_ROOT/etc/qubes_rpc/
|
cp qubes_rpc/qubes.ReceiveUpdates $RPM_BUILD_ROOT/etc/qubes_rpc/
|
||||||
install -D aux-tools/qubes-dom0.modules $RPM_BUILD_ROOT/etc/sysconfig/modules/qubes-dom0.modules
|
install -D aux-tools/qubes-dom0.modules $RPM_BUILD_ROOT/etc/sysconfig/modules/qubes-dom0.modules
|
||||||
install -D aux-tools/cpufreq-xen.modules $RPM_BUILD_ROOT/etc/sysconfig/modules/cpufreq-xen.modules
|
install -D aux-tools/cpufreq-xen.modules $RPM_BUILD_ROOT/etc/sysconfig/modules/cpufreq-xen.modules
|
||||||
install -D aux-tools/qubes-dom0-updates.cron $RPM_BUILD_ROOT/etc/cron.daily/qubes-dom0-updates.cron
|
install -D aux-tools/qubes-dom0-updates.cron $RPM_BUILD_ROOT/etc/cron.daily/qubes-dom0-updates.cron
|
||||||
@ -358,6 +359,7 @@ fi
|
|||||||
/usr/lib/qubes/meminfo-writer
|
/usr/lib/qubes/meminfo-writer
|
||||||
/usr/lib/qubes/qfile-daemon-dvm*
|
/usr/lib/qubes/qfile-daemon-dvm*
|
||||||
/usr/lib/qubes/qubes-notify-updates
|
/usr/lib/qubes/qubes-notify-updates
|
||||||
|
/usr/lib/qubes/qubes-receive-appmenus
|
||||||
/usr/lib/qubes/qubes-receive-updates
|
/usr/lib/qubes/qubes-receive-updates
|
||||||
/usr/lib/qubes/block_add_change
|
/usr/lib/qubes/block_add_change
|
||||||
/usr/lib/qubes/block_remove
|
/usr/lib/qubes/block_remove
|
||||||
|
@ -1 +1 @@
|
|||||||
1.7.42
|
1.7.43
|
||||||
|
Loading…
Reference in New Issue
Block a user