mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 10:11:27 +01:00
integrate into Xen Management and which support the new access control labels (labels replace the ssidref numbers at the management user interface). Signed-off by: Reiner Sailer <sailer@us.ibm.com>
49 lines
1.4 KiB
Python
49 lines
1.4 KiB
Python
#!/usr/bin/env python
|
|
# -*- mode: python; -*-
|
|
import sys
|
|
import traceback
|
|
import getopt
|
|
|
|
# add fallback path for non-native python path installs if needed
|
|
sys.path.insert(-1, '/usr/lib/python')
|
|
sys.path.insert(-1, '/usr/lib64/python')
|
|
|
|
from xen.util.security import ACMError, err, get_ssid
|
|
|
|
# getopt.gnu_getopt is better, but only exists in Python 2.3+. Use
|
|
# getopt.getopt if gnu_getopt is not available. This will mean that options
|
|
# may only be specified before positional arguments.
|
|
if not hasattr(getopt, 'gnu_getopt'):
|
|
getopt.gnu_getopt = getopt.getopt
|
|
|
|
def usage():
|
|
print "Usage: acm_getlabel -i domainid"
|
|
print " Test program illustrating the retrieval of"
|
|
print " label information (for domains) from Xen."
|
|
print " Argument is one paramter describing the domain"
|
|
print " for which the label is retrieved."
|
|
print "\t -i domain_id or --domid=domain_id"
|
|
print " Return value:"
|
|
print "\t none -- Error (e.g., unknown ssidref, label, or domain id)"
|
|
print "\t (labelname, policyname, ssidref)"
|
|
err("Usage")
|
|
|
|
try:
|
|
domid = None
|
|
(options, params) = getopt.gnu_getopt(sys.argv[1:], ':i:', ['domid='])
|
|
for (k, v) in options:
|
|
if k in ['-i', '--domid']:
|
|
if not domid:
|
|
domid = v
|
|
else:
|
|
usage()
|
|
if not domid:
|
|
usage()
|
|
|
|
print get_ssid(domid)
|
|
|
|
except ACMError:
|
|
pass
|
|
except:
|
|
traceback.print_exc(limit=1)
|