view tools/python/xen/xm/resources.py @ 10720:8922c1fbe684

[XM][ACM] Add xm subcommands to work with security resource labels.

This patch adds new xm subcommands to support working with resource
labels. The new subcommands are 'xm resources', 'xm rmlabel', 'xm
getlabel' and 'xm dry-run'. In addition, the 'xm addlabel' subcommand
now uses an updated syntax to support labeling both domains and
resources. See the xm man page for details on each subcommand.

Beyond the new subcommands, this patch allows users to immediately see
when security checks will fail by pushing some basic security checking
into the beginning of 'xm create' and 'xm block-attach'. ACM security
attributes for block devices are added to XenStore in order to support
the final security enforcement, which will be performed in the kernel
and included in a separate patch.

Signed-off-by: Bryan D. Payne <bdpayne@us.ibm.com>
Signed-off-by: Reiner Sailer <sailer@us.ibm.com>
author kfraser@localhost.localdomain
date Mon Jul 10 17:18:07 2006 +0100 (2006-07-10)
children 956e9aaf88c9
line source
1 #============================================================================
2 # This library is free software; you can redistribute it and/or
3 # modify it under the terms of version 2.1 of the GNU Lesser General Public
4 # License as published by the Free Software Foundation.
5 #
6 # This library is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # Lesser General Public License for more details.
10 #
11 # You should have received a copy of the GNU Lesser General Public
12 # License along with this library; if not, write to the Free Software
13 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14 #============================================================================
15 # Copyright (C) 2006 International Business Machines Corp.
16 # Author: Bryan D. Payne <bdpayne@us.ibm.com>
17 #============================================================================
19 """List the resource label information from the global resource label file
20 """
21 import sys, os
22 import string
23 from xen.util import dictio
24 from xen.util import security
26 def usage():
27 print "\nUsage: xm resource\n"
28 print " This program lists information for each resource in the"
29 print " global resource label file\n"
32 def print_resource_data(access_control):
33 """Prints out a resource dictionary to stdout
34 """
35 for resource in access_control:
36 (policy, label) = access_control[resource]
37 print resource
38 print " policy: "+policy
39 print " label: "+label
42 def main (argv):
43 try:
44 file = security.res_label_filename
45 access_control = dictio.dict_read("resources", file)
46 except:
47 print "Resource file not found."
48 return
50 print_resource_data(access_control)
53 if __name__ == '__main__':
54 main(sys.argv)