af7d54d388
Handle 'os' feature - if it's Windows, then set rpc-clipboard feature. Handle 'gui-emulated' feature - request for specifically stubdomain GUI. With 'gui' feature it is only possible to enable gui-agent based on, or disable GUI completely. Handle 'default-user' - verify it for weird characters and set 'default_user' property (if wasn't already set). QubesOS/qubes-issues#3585
65 lines
2.4 KiB
Python
65 lines
2.4 KiB
Python
# -*- encoding: utf-8 -*-
|
|
#
|
|
# The Qubes OS Project, http://www.qubes-os.org
|
|
#
|
|
# Copyright (C) 2017 Marek Marczykowski-Górecki
|
|
# <marmarek@invisiblethingslab.com>
|
|
#
|
|
# 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
import qubes.ext
|
|
|
|
class WindowsFeatures(qubes.ext.Extension):
|
|
# pylint: disable=too-few-public-methods
|
|
@qubes.ext.handler('features-request')
|
|
def qubes_features_request(self, vm, event, untrusted_features):
|
|
'''Handle features provided requested by Qubes Windows Tools'''
|
|
# pylint: disable=no-self-use,unused-argument
|
|
if getattr(vm, 'template', None):
|
|
vm.log.warning(
|
|
'Ignoring qubes.NotifyTools for template-based VM')
|
|
return
|
|
|
|
guest_os = None
|
|
if 'os' in untrusted_features:
|
|
if untrusted_features['os'] in ['Windows']:
|
|
guest_os = untrusted_features['os']
|
|
|
|
qrexec = None
|
|
if 'qrexec' in untrusted_features:
|
|
if untrusted_features['qrexec'] == '1':
|
|
# qrexec feature is set by CoreFeatures extension
|
|
qrexec = True
|
|
|
|
del untrusted_features
|
|
|
|
if guest_os:
|
|
vm.features['os'] = guest_os
|
|
if guest_os == 'Windows' and qrexec:
|
|
vm.features['rpc-clipboard'] = True
|
|
|
|
@qubes.ext.handler('domain-add', system=True)
|
|
def on_domain_add(self, app, _event, vm, **kwargs):
|
|
# pylint: disable=no-self-use,unused-argument
|
|
if getattr(vm, 'template', None) is None:
|
|
# handle only template-based vms
|
|
return
|
|
|
|
template = vm.template
|
|
if template.features.check_with_template('os', None) != 'Windows':
|
|
# ignore non-windows templates
|
|
return
|
|
|
|
# TODO: consider copying template's root volume here
|