From: Stefan Berger Subject: [PATCH] [Xend/ACM] Embed the policy schema in the python file Date: Mon, 28 Apr 2008 15:56:50 -0400 Message-ID: <1209412610.859.5.camel@gsal-3.watson.ibm.com> Reply-To: stefanb@us.ibm.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-/JyLwde+3g5ftdrj1taE" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel Cc: Keir Fraser List-Id: xen-devel@lists.xenproject.org --=-/JyLwde+3g5ftdrj1taE Content-Type: text/plain Content-Transfer-Encoding: 7bit This patch embeds the ACM policy's schema in the python file where the schema is being accessed for verifying the policy XML. This way also programs that cannot access a protected directory where the schema may be located in can use this class. Signed-off-by: Stefan Berger --=-/JyLwde+3g5ftdrj1taE Content-Disposition: attachment; filename=acmpolicy_embed_schema.diff Content-Type: text/x-patch; name=acmpolicy_embed_schema.diff; charset=UTF-8 Content-Transfer-Encoding: 7bit Index: root/xen-unstable.hg/tools/python/xen/util/acmpolicy.py =================================================================== --- root.orig/xen-unstable.hg/tools/python/xen/util/acmpolicy.py +++ root/xen-unstable.hg/tools/python/xen/util/acmpolicy.py @@ -49,8 +49,6 @@ ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY = 2 ACM_POLICY_UNDEFINED = 15 -ACM_SCHEMA_FILE = ACM_POLICIES_DIR + "security_policy.xsd" - ACM_LABEL_UNLABELED = "__UNLABELED__" ACM_LABEL_UNLABELED_DISPLAY = "unlabeled" @@ -118,6 +116,153 @@ DEFAULT_policy = \ " \n" +\ "\n" +ACM_SCHEMA=""" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +""" + def get_DEFAULT_policy(dom0label=""): fromnode = "" @@ -133,18 +278,7 @@ def initialize(): instdir = security.install_policy_dir_prefix DEF_policy_file = "DEFAULT-security_policy.xml" - xsd_file = "security_policy.xsd" - - files = [ xsd_file ] - for file in files: - if not os.path.isfile(policiesdir + "/" + file ): - try: - shutil.copyfile(instdir + "/" + file, - policiesdir + "/" + file) - except Exception, e: - log.info("could not copy '%s': %s" % - (file, str(e))) #Install default policy. f = open(policiesdir + "/" + DEF_policy_file, 'w') if f: @@ -219,7 +353,8 @@ class ACMPolicy(XSPolicy): log.warn("Libxml2 python-wrapper is not installed on the system.") return xsconstants.XSERR_SUCCESS try: - parserctxt = libxml2.schemaNewParserCtxt(ACM_SCHEMA_FILE) + parserctxt = libxml2.schemaNewMemParserCtxt(ACM_SCHEMA, + len(ACM_SCHEMA)) schemaparser = parserctxt.schemaParse() valid = schemaparser.schemaNewValidCtxt() doc = libxml2.parseDoc(self.toxml()) --=-/JyLwde+3g5ftdrj1taE Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=-/JyLwde+3g5ftdrj1taE--