Skip to content

Commit

Permalink
qubes: admin extension
Browse files Browse the repository at this point in the history
for managing tags
  • Loading branch information
woju committed Jun 21, 2017
1 parent 8196b2d commit 2942f8b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
34 changes: 34 additions & 0 deletions qubes/ext/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- encoding: utf8 -*-
#
# The Qubes OS Project, http://www.qubes-os.org
#
# Copyright (C) 2017 Wojtek Porczyk <[email protected]>
#
# 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.api
import qubes.ext

class AdminExtension(qubes.ext.Extension):
# pylint: disable=too-few-public-methods
@qubes.ext.handler(
'mgmt-permission:admin.vm.tag.Set',
'mgmt-permission:admin.vm.tag.Remove')
def on_tag_set_or_remove(self, vm, event, arg, **kwargs):
'''Forbid changing specific tags'''
# pylint: disable=no-self-use,unused-argument
if arg.startswith('created-by-'):
raise qubes.api.PermissionDenied()

# TODO create that extension in the first place
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def get_console_scripts():
'DispVM = qubes.vm.dispvm:DispVM',
],
'qubes.ext': [
'qubes.ext.admin = qubes.ext.admin:AdminExtension',
'qubes.ext.core_features = qubes.ext.core_features:CoreFeatures',
'qubes.ext.qubesmanager = qubes.ext.qubesmanager:QubesManager',
'qubes.ext.gui = qubes.ext.gui:GUI',
Expand Down

0 comments on commit 2942f8b

Please sign in to comment.