parent
417cb6e912
commit
93153da893
@ -19,6 +19,7 @@ manpages and API documentation. For primary user documentation, see
|
|||||||
qubes-exc
|
qubes-exc
|
||||||
qubes-ext
|
qubes-ext
|
||||||
qubes-log
|
qubes-log
|
||||||
|
qubes-mgmt
|
||||||
qubes-tools/index
|
qubes-tools/index
|
||||||
qubes-tests
|
qubes-tests
|
||||||
qubes-dochelpers
|
qubes-dochelpers
|
||||||
|
@ -385,7 +385,10 @@ def check_man_args(app, doctree, docname):
|
|||||||
''' Checks the manpage for undocumented or obsolete sub-commands and
|
''' Checks the manpage for undocumented or obsolete sub-commands and
|
||||||
options.
|
options.
|
||||||
'''
|
'''
|
||||||
command = os.path.split(docname)[1]
|
dirname, command = os.path.split(docname)
|
||||||
|
if os.path.basename(dirname) != 'manpages':
|
||||||
|
return
|
||||||
|
|
||||||
app.info('Checking arguments for {!r}'.format(command))
|
app.info('Checking arguments for {!r}'.format(command))
|
||||||
doctree.walk(ManpageCheckVisitor(app, command, doctree))
|
doctree.walk(ManpageCheckVisitor(app, command, doctree))
|
||||||
|
|
||||||
|
@ -58,19 +58,36 @@ class PermissionDenied(Exception):
|
|||||||
|
|
||||||
|
|
||||||
def not_in_api(func):
|
def not_in_api(func):
|
||||||
|
'''Decorator for methods not intended to appear in API.
|
||||||
|
|
||||||
|
The decorated method cannot be called from public API using
|
||||||
|
:py:class:`QubesMgmt` class. The method becomes "private", and can be
|
||||||
|
called only as a helper for other methods.
|
||||||
|
'''
|
||||||
func.not_in_api = True
|
func.not_in_api = True
|
||||||
return func
|
return func
|
||||||
|
|
||||||
class QubesMgmt(object):
|
class QubesMgmt(object):
|
||||||
|
'''Implementation of Qubes Management API calls
|
||||||
|
|
||||||
|
This class contains all the methods available in the API.
|
||||||
|
'''
|
||||||
def __init__(self, app, src, method, dest, arg):
|
def __init__(self, app, src, method, dest, arg):
|
||||||
|
#: :py:class:`qubes.Qubes` object
|
||||||
self.app = app
|
self.app = app
|
||||||
|
|
||||||
|
#: source qube
|
||||||
self.src = self.app.domains[src.decode('ascii')]
|
self.src = self.app.domains[src.decode('ascii')]
|
||||||
|
|
||||||
|
#: destination qube
|
||||||
self.dest = self.app.domains[dest.decode('ascii')]
|
self.dest = self.app.domains[dest.decode('ascii')]
|
||||||
|
|
||||||
|
#: argument
|
||||||
self.arg = arg.decode('ascii')
|
self.arg = arg.decode('ascii')
|
||||||
|
|
||||||
self.prepr = ProtocolRepr()
|
self.prepr = ProtocolRepr()
|
||||||
|
|
||||||
|
#: name of the method
|
||||||
self.method = method.decode('ascii')
|
self.method = method.decode('ascii')
|
||||||
|
|
||||||
untrusted_func_name = self.method
|
untrusted_func_name = self.method
|
||||||
@ -111,11 +128,13 @@ class QubesMgmt(object):
|
|||||||
|
|
||||||
@not_in_api
|
@not_in_api
|
||||||
def fire_event_for_permission(self, **kwargs):
|
def fire_event_for_permission(self, **kwargs):
|
||||||
|
'''Fire an event on the source qube to check for permission'''
|
||||||
return self.src.fire_event_pre('mgmt-permission:{}'.format(self.method),
|
return self.src.fire_event_pre('mgmt-permission:{}'.format(self.method),
|
||||||
dest=self.dest, arg=self.arg, **kwargs)
|
dest=self.dest, arg=self.arg, **kwargs)
|
||||||
|
|
||||||
@not_in_api
|
@not_in_api
|
||||||
def fire_event_for_filter(self, iterable, **kwargs):
|
def fire_event_for_filter(self, iterable, **kwargs):
|
||||||
|
'''Fire an event on the source qube to filter for permission'''
|
||||||
for selector in self.fire_event_for_permission(**kwargs):
|
for selector in self.fire_event_for_permission(**kwargs):
|
||||||
iterable = filter(selector, iterable)
|
iterable = filter(selector, iterable)
|
||||||
return iterable
|
return iterable
|
||||||
@ -130,6 +149,7 @@ class QubesMgmt(object):
|
|||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def vm_list(self, untrusted_payload):
|
def vm_list(self, untrusted_payload):
|
||||||
|
'''List all the domains'''
|
||||||
assert self.dest.name == 'dom0'
|
assert self.dest.name == 'dom0'
|
||||||
assert not self.arg
|
assert not self.arg
|
||||||
assert not untrusted_payload
|
assert not untrusted_payload
|
||||||
@ -145,6 +165,7 @@ class QubesMgmt(object):
|
|||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def vm_property_list(self, untrusted_payload):
|
def vm_property_list(self, untrusted_payload):
|
||||||
|
'''List all properties on a qube'''
|
||||||
assert not self.arg
|
assert not self.arg
|
||||||
assert not untrusted_payload
|
assert not untrusted_payload
|
||||||
del untrusted_payload
|
del untrusted_payload
|
||||||
@ -155,6 +176,7 @@ class QubesMgmt(object):
|
|||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def vm_property_get(self, untrusted_payload):
|
def vm_property_get(self, untrusted_payload):
|
||||||
|
'''Get a value of one property'''
|
||||||
assert self.arg in self.dest.property_list()
|
assert self.arg in self.dest.property_list()
|
||||||
assert not untrusted_payload
|
assert not untrusted_payload
|
||||||
del untrusted_payload
|
del untrusted_payload
|
||||||
@ -172,6 +194,7 @@ class QubesMgmt(object):
|
|||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def vm_property_help(self, untrusted_payload):
|
def vm_property_help(self, untrusted_payload):
|
||||||
|
'''Get help for one property'''
|
||||||
assert self.arg in self.dest.property_list()
|
assert self.arg in self.dest.property_list()
|
||||||
assert not untrusted_payload
|
assert not untrusted_payload
|
||||||
del untrusted_payload
|
del untrusted_payload
|
||||||
@ -187,6 +210,7 @@ class QubesMgmt(object):
|
|||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def vm_property_reset(self, untrusted_payload):
|
def vm_property_reset(self, untrusted_payload):
|
||||||
|
'''Reset a property to a default value'''
|
||||||
assert self.arg in self.dest.property_list()
|
assert self.arg in self.dest.property_list()
|
||||||
assert not untrusted_payload
|
assert not untrusted_payload
|
||||||
del untrusted_payload
|
del untrusted_payload
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# The Qubes OS Project, https://www.qubes-os.org/
|
# The Qubes OS Project, https://www.qubes-os.org/
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user