ia64/xen-unstable

view tools/python/xen/util/dictio.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)
parents c77b066f864a
children
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
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
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 #============================================================================
20 def dict_read(dictname, filename):
21 """Loads <filename> and returns the dictionary named <dictname> from
22 the file.
23 """
24 dict = {}
26 # read in the config file
27 globs = {}
28 locs = {}
29 execfile(filename, globs, locs)
31 for (k, v) in locs.items():
32 if k == dictname:
33 dict = v
34 break
36 return dict
38 def dict_write(dict, dictname, filename):
39 """Writes <dict> to <filename> using the name <dictname>. If the file
40 contains any other data, it will be overwritten.
41 """
42 prefix = dictname + " = {\n"
43 suffix = "}\n"
44 fd = open(filename, "wb")
45 fd.write(prefix)
46 for key in dict:
47 line = " '" + str(key) + "': " + str(dict[key]) + ",\n"
48 fd.write(line)
49 fd.write(suffix)
50 fd.close()