ia64/xen-unstable
changeset 10600:c157418212d8
Merge
author | ack@localhost.localdomain |
---|---|
date | Thu Jun 29 14:49:41 2006 +0100 (2006-06-29) |
parents | 18f8dde91fbd 266573a53949 |
children | 8242c0c24db7 |
files |
line diff
1.1 --- a/tools/python/xen/util/security.py Thu Jun 29 14:39:07 2006 +0100 1.2 +++ b/tools/python/xen/util/security.py Thu Jun 29 14:49:41 2006 +0100 1.3 @@ -22,10 +22,10 @@ import logging 1.4 import sys, os, string, re 1.5 import traceback 1.6 import shutil 1.7 +#from xml.marshal import generic 1.8 from xen.lowlevel import acm 1.9 from xen.xend import sxp 1.10 from xen.xend.XendLogging import log 1.11 -from xen.util import dictio 1.12 1.13 #global directories and tools for security management 1.14 policy_dir_prefix = "/etc/xen/acm-security/policies" 1.15 @@ -551,16 +551,20 @@ def get_res_label(resource): 1.16 (label, policy) = default_res_label() 1.17 1.18 # load the resource label file 1.19 - res_label_cache = {} 1.20 - try: 1.21 - res_label_cache = dictio.dict_read("resources", res_label_filename) 1.22 - except: 1.23 + configfile = res_label_filename 1.24 + if not os.path.isfile(configfile): 1.25 log.info("Resource label file not found.") 1.26 return default_res_label() 1.27 +# 1.28 +# Commented out pending replacement for xml.marshal.generic 1.29 +# 1.30 +# fd = open(configfile, "rb") 1.31 +# res_label_cache = generic.load(fd) 1.32 +# fd.close() 1.33 1.34 - # find the resource information 1.35 - if res_label_cache.has_key(resource): 1.36 - (policy, label) = res_label_cache[resource] 1.37 +# # find the resource information 1.38 +# if res_label_cache.has_key(resource): 1.39 +# (policy, label) = res_label_cache[resource] 1.40 1.41 return (label, policy) 1.42
2.1 --- a/tools/python/xen/xm/addlabel.py Thu Jun 29 14:39:07 2006 +0100 2.2 +++ b/tools/python/xen/xm/addlabel.py Thu Jun 29 14:49:41 2006 +0100 2.3 @@ -22,7 +22,7 @@ 2.4 import sys, os 2.5 import string 2.6 import traceback 2.7 -from xen.util import dictio 2.8 +#from xml.marshal import generic 2.9 from xen.util import security 2.10 2.11 def usage(): 2.12 @@ -79,13 +79,17 @@ def add_resource_label(label, resource, 2.13 return 2.14 2.15 # see if this resource is already in the file 2.16 - access_control = {} 2.17 file = security.res_label_filename 2.18 - try: 2.19 - access_control = dictio.dict_read("resources", file) 2.20 - except: 2.21 + if not os.path.isfile(file): 2.22 print "Resource file not found, creating new file at:" 2.23 print "%s" % (file) 2.24 + fd = open(file, "w") 2.25 + fd.close(); 2.26 + access_control = {} 2.27 + else: 2.28 + fd = open(file, "rb") 2.29 +# access_control = generic.load(fd) 2.30 + fd.close() 2.31 2.32 if access_control.has_key(resource): 2.33 security.err("This resource is already labeled.") 2.34 @@ -93,7 +97,9 @@ def add_resource_label(label, resource, 2.35 # write the data to file 2.36 new_entry = { resource : tuple([policyref, label]) } 2.37 access_control.update(new_entry) 2.38 - dictio.dict_write(access_control, "resources", file) 2.39 + fd = open(file, "wb") 2.40 +# generic.dump(access_control, fd) 2.41 + fd.close() 2.42 2.43 except security.ACMError: 2.44 pass
3.1 --- a/tools/python/xen/xm/getlabel.py Thu Jun 29 14:39:07 2006 +0100 3.2 +++ b/tools/python/xen/xm/getlabel.py Thu Jun 29 14:49:41 2006 +0100 3.3 @@ -21,7 +21,7 @@ 3.4 import sys, os, re 3.5 import string 3.6 import traceback 3.7 -from xen.util import dictio 3.8 +#from xml.marshal import generic 3.9 from xen.util import security 3.10 3.11 def usage(): 3.12 @@ -33,15 +33,17 @@ def usage(): 3.13 def get_resource_label(resource): 3.14 """Gets the resource label 3.15 """ 3.16 - # read in the resource file 3.17 - file = security.res_label_filename 3.18 try: 3.19 - access_control = dictio.dict_read("resources", file) 3.20 - except: 3.21 - print "Resource label file not found" 3.22 - return 3.23 + # read in the resource file 3.24 + file = security.res_label_filename 3.25 + if os.path.isfile(file): 3.26 + fd = open(file, "rb") 3.27 +# access_control = generic.load(fd) 3.28 + fd.close() 3.29 + else: 3.30 + print "Resource label file not found" 3.31 + return 3.32 3.33 - try: 3.34 # get the entry and print label 3.35 if access_control.has_key(resource): 3.36 policy = access_control[resource][0] 3.37 @@ -98,6 +100,7 @@ def get_domain_label(configfile): 3.38 data = data.strip() 3.39 data = data.lstrip("[\'") 3.40 data = data.rstrip("\']") 3.41 + (p, l) = data.split(",") 3.42 print data 3.43 3.44 except security.ACMError:
4.1 --- a/tools/python/xen/xm/resources.py Thu Jun 29 14:39:07 2006 +0100 4.2 +++ b/tools/python/xen/xm/resources.py Thu Jun 29 14:49:41 2006 +0100 4.3 @@ -21,7 +21,7 @@ 4.4 import sys, os 4.5 import string 4.6 import traceback 4.7 -from xen.util import dictio 4.8 +#from xml.marshal import generic 4.9 from xen.util import security 4.10 4.11 def usage(): 4.12 @@ -40,15 +40,24 @@ def print_resource_data(access_control): 4.13 print " label: "+label 4.14 4.15 4.16 +def get_resource_data(): 4.17 + """Returns the resource dictionary. 4.18 + """ 4.19 + file = security.res_label_filename 4.20 + if not os.path.isfile(file): 4.21 + security.err("Resource file not found.") 4.22 + 4.23 + fd = open(file, "rb") 4.24 +# access_control = generic.load(fd) 4.25 + fd.close() 4.26 + return access_control 4.27 + 4.28 + 4.29 def main (argv): 4.30 try: 4.31 - file = security.res_label_filename 4.32 - access_control = dictio.dict_read("resources", file) 4.33 - except: 4.34 - security.err("Resource file not found.") 4.35 + access_control = get_resource_data() 4.36 + print_resource_data(access_control) 4.37 4.38 - try: 4.39 - print_resource_data(access_control) 4.40 except security.ACMError: 4.41 pass 4.42 except:
5.1 --- a/tools/python/xen/xm/rmlabel.py Thu Jun 29 14:39:07 2006 +0100 5.2 +++ b/tools/python/xen/xm/rmlabel.py Thu Jun 29 14:49:41 2006 +0100 5.3 @@ -21,7 +21,7 @@ 5.4 import sys, os, re 5.5 import string 5.6 import traceback 5.7 -from xen.util import dictio 5.8 +#from xml.marshal import generic 5.9 from xen.util import security 5.10 5.11 def usage(): 5.12 @@ -36,18 +36,22 @@ def usage(): 5.13 def rm_resource_label(resource): 5.14 """Removes a resource label from the global resource label file. 5.15 """ 5.16 - # read in the resource file 5.17 - file = security.res_label_filename 5.18 try: 5.19 - access_control = dictio.dict_read("resources", file) 5.20 - except: 5.21 - security.err("Resource file not found, cannot remove label!") 5.22 + # read in the resource file 5.23 + file = security.res_label_filename 5.24 + if os.path.isfile(file): 5.25 + fd = open(file, "rb") 5.26 +# access_control = generic.load(fd) 5.27 + fd.close() 5.28 + else: 5.29 + security.err("Resource file not found, cannot remove label!") 5.30 5.31 - try: 5.32 # remove the entry and update file 5.33 if access_control.has_key(resource): 5.34 del access_control[resource] 5.35 - dictio.dict_write(access_control, "resources", file) 5.36 + fd = open(file, "wb") 5.37 +# generic.dump(access_control, fd) 5.38 + fd.close() 5.39 else: 5.40 security.err("Label does not exist in resource label file.") 5.41
6.1 --- a/xen/include/public/arch-ia64.h Thu Jun 29 14:39:07 2006 +0100 6.2 +++ b/xen/include/public/arch-ia64.h Thu Jun 29 14:49:41 2006 +0100 6.3 @@ -40,6 +40,8 @@ DEFINE_XEN_GUEST_HANDLE(xen_pfn_t); 6.4 6.5 #ifndef __ASSEMBLY__ 6.6 6.7 +typedef unsigned long xen_ulong_t; 6.8 + 6.9 #define MAX_NR_SECTION 32 /* at most 32 memory holes */ 6.10 struct mm_section { 6.11 unsigned long start; /* start of memory hole */
7.1 --- a/xen/include/public/arch-x86_32.h Thu Jun 29 14:39:07 2006 +0100 7.2 +++ b/xen/include/public/arch-x86_32.h Thu Jun 29 14:49:41 2006 +0100 7.3 @@ -98,6 +98,8 @@ DEFINE_XEN_GUEST_HANDLE(xen_pfn_t); 7.4 7.5 #ifndef __ASSEMBLY__ 7.6 7.7 +typedef unsigned long xen_ulong_t; 7.8 + 7.9 /* 7.10 * Send an array of these to HYPERVISOR_set_trap_table() 7.11 */
8.1 --- a/xen/include/public/arch-x86_64.h Thu Jun 29 14:39:07 2006 +0100 8.2 +++ b/xen/include/public/arch-x86_64.h Thu Jun 29 14:49:41 2006 +0100 8.3 @@ -105,6 +105,8 @@ DEFINE_XEN_GUEST_HANDLE(xen_pfn_t); 8.4 8.5 #ifndef __ASSEMBLY__ 8.6 8.7 +typedef unsigned long xen_ulong_t; 8.8 + 8.9 /* 8.10 * int HYPERVISOR_set_segment_base(unsigned int which, unsigned long base) 8.11 * @which == SEGBASE_* ; @base == 64-bit base address
9.1 --- a/xen/include/public/memory.h Thu Jun 29 14:39:07 2006 +0100 9.2 +++ b/xen/include/public/memory.h Thu Jun 29 14:49:41 2006 +0100 9.3 @@ -32,7 +32,7 @@ struct xen_memory_reservation { 9.4 XEN_GUEST_HANDLE(xen_pfn_t) extent_start; 9.5 9.6 /* Number of extents, and size/alignment of each (2^extent_order pages). */ 9.7 - unsigned long nr_extents; 9.8 + xen_ulong_t nr_extents; 9.9 unsigned int extent_order; 9.10 9.11 /* 9.12 @@ -90,7 +90,7 @@ struct xen_memory_exchange { 9.13 * command will be non-zero. 9.14 * 5. THIS FIELD MUST BE INITIALISED TO ZERO BY THE CALLER! 9.15 */ 9.16 - unsigned long nr_exchanged; 9.17 + xen_ulong_t nr_exchanged; 9.18 }; 9.19 typedef struct xen_memory_exchange xen_memory_exchange_t; 9.20 DEFINE_XEN_GUEST_HANDLE(xen_memory_exchange_t); 9.21 @@ -148,8 +148,8 @@ DEFINE_XEN_GUEST_HANDLE(xen_machphys_mfn 9.22 */ 9.23 #define XENMEM_machphys_mapping 12 9.24 struct xen_machphys_mapping { 9.25 - unsigned long v_start, v_end; /* Start and end virtual addresses. */ 9.26 - unsigned long max_mfn; /* Maximum MFN that can be looked up. */ 9.27 + xen_ulong_t v_start, v_end; /* Start and end virtual addresses. */ 9.28 + xen_ulong_t max_mfn; /* Maximum MFN that can be looked up. */ 9.29 }; 9.30 typedef struct xen_machphys_mapping xen_machphys_mapping_t; 9.31 DEFINE_XEN_GUEST_HANDLE(xen_machphys_mapping_t); 9.32 @@ -170,7 +170,7 @@ struct xen_add_to_physmap { 9.33 unsigned int space; 9.34 9.35 /* Index into source mapping space. */ 9.36 - unsigned long idx; 9.37 + xen_ulong_t idx; 9.38 9.39 /* GPFN where the source mapping page should appear. */ 9.40 xen_pfn_t gpfn; 9.41 @@ -188,7 +188,7 @@ struct xen_translate_gpfn_list { 9.42 domid_t domid; 9.43 9.44 /* Length of list. */ 9.45 - unsigned long nr_gpfns; 9.46 + xen_ulong_t nr_gpfns; 9.47 9.48 /* List of GPFNs to translate. */ 9.49 XEN_GUEST_HANDLE(xen_pfn_t) gpfn_list;