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 | #============================================================================ |
---|
18 | |
---|
19 | """List the resource label information from the global resource label file |
---|
20 | """ |
---|
21 | import sys |
---|
22 | from xen.util import dictio |
---|
23 | from xen.util import security |
---|
24 | from xen.xm.opts import OptionError |
---|
25 | |
---|
26 | def help(): |
---|
27 | return """ |
---|
28 | This program lists information for each resource in the |
---|
29 | global resource label file.""" |
---|
30 | |
---|
31 | def print_resource_data(access_control): |
---|
32 | """Prints out a resource dictionary to stdout |
---|
33 | """ |
---|
34 | for resource in access_control: |
---|
35 | (policy, label) = access_control[resource] |
---|
36 | print resource |
---|
37 | print " policy: "+policy |
---|
38 | print " label: "+label |
---|
39 | |
---|
40 | def main (argv): |
---|
41 | if len(argv) > 1: |
---|
42 | raise OptionError("No arguments required") |
---|
43 | |
---|
44 | try: |
---|
45 | filename = security.res_label_filename |
---|
46 | access_control = dictio.dict_read("resources", filename) |
---|
47 | except: |
---|
48 | raise OptionError("Resource file not found") |
---|
49 | |
---|
50 | print_resource_data(access_control) |
---|
51 | |
---|
52 | if __name__ == '__main__': |
---|
53 | try: |
---|
54 | main(sys.argv) |
---|
55 | except Exception, e: |
---|
56 | sys.stderr.write('Error: %s\n' % str(e)) |
---|
57 | sys.exit(-1) |
---|