From: Stefan Berger Subject: [PATCH] [Xend] Reworked initialization of XSPolicy administration class Date: Wed, 24 Oct 2007 19:04:16 -0400 Message-ID: <1193267056.19870.8.camel@gsal-3.watson.ibm.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-xZbwWbH9d4Lw9dkO4fXK" 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 --=-xZbwWbH9d4Lw9dkO4fXK Content-Type: text/plain Content-Transfer-Encoding: 7bit I reworked the initialization of the XSPolicy administration class. Rather than picking up the current policy from the managed policies file the hypervisor is asked for the name of the current policy. Signed-off-by: Stefan Berger --=-xZbwWbH9d4Lw9dkO4fXK Content-Disposition: attachment; filename=xend_policy_init_rework.diff Content-Type: text/x-patch; name=xend_policy_init_rework.diff; charset=UTF-8 Content-Transfer-Encoding: 7bit --- xen-unstable.hg/tools/python/xen/xend/XendXSPolicyAdmin.py | 37 +++---------- 1 file changed, 11 insertions(+), 26 deletions(-) Index: root/xen-unstable.hg/tools/python/xen/xend/XendXSPolicyAdmin.py =================================================================== --- root.orig/xen-unstable.hg/tools/python/xen/xend/XendXSPolicyAdmin.py +++ root/xen-unstable.hg/tools/python/xen/xend/XendXSPolicyAdmin.py @@ -27,7 +27,6 @@ from xen.util.xspolicy import XSPolicy from xen.util.acmpolicy import ACMPolicy from xen.xend.XendError import SecurityError -XS_MANAGED_POLICIES_FILE = "/etc/xen/acm-security/policies/managed_policies" class XSPolicyAdmin: """ The class that handles the managed policies in the system. @@ -44,28 +43,19 @@ class XSPolicyAdmin: on the system (currently '1') """ self.maxpolicies = maxpolicies + self.policies = {} + self.xsobjs = {} + + act_pol_name = self.get_hv_loaded_policy_name() + + ref = uuid.createString() try: - self.policies = dictio.dict_read("managed_policies", - XS_MANAGED_POLICIES_FILE) + self.xsobjs[ref] = ACMPolicy(name=act_pol_name, ref=ref) + self.policies[ref] = (act_pol_name, xsconstants.ACM_POLICY_ID) except Exception, e: - self.policies = {} + log.error("Could not find XML representation of policy '%s': " + "%s" % (act_pol_name,e)) - self.xsobjs = {} - for ref, data in self.policies.items(): - name = data[0] - typ = data[1] - try: - if typ == xsconstants.ACM_POLICY_ID: - try: - self.xsobjs[ref] = ACMPolicy(name=name, ref=ref) - except Exception, e: - del self.policies[ref] - else: - del self.policies[ref] - except Exception, e: - log.error("XSPolicyAdmin: Could not find policy '%s': %s" % - (name, str(e))) - del self.policies[ref] log.debug("XSPolicyAdmin: Known policies: %s" % self.policies) def isXSEnabled(self): @@ -112,6 +102,7 @@ class XSPolicyAdmin: if rc == 0: self.rm_bootpolicy() irc = self.activate_xspolicy(loadedpol, flags) + # policy is loaded; if setting the boot flag fails it's ok. return (loadedpol, rc, errors) try: @@ -165,9 +156,6 @@ class XSPolicyAdmin: xsconstants.ACM_POLICY_ID]) } self.policies.update(new_entry) self.xsobjs[ref] = acmpol - dictio.dict_write(self.policies, - "managed_policies", - XS_MANAGED_POLICIES_FILE) return (acmpol, xsconstants.XSERR_SUCCESS, errors) def make_boot_policy(self, acmpol): @@ -216,9 +204,6 @@ class XSPolicyAdmin: if rc == xsconstants.XSERR_SUCCESS or force: del self.policies[ref] del self.xsobjs[ref] - dictio.dict_write(self.policies, - "managed_policies", - XS_MANAGED_POLICIES_FILE) rc = xsconstants.XSERR_SUCCESS return rc --=-xZbwWbH9d4Lw9dkO4fXK 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 --=-xZbwWbH9d4Lw9dkO4fXK--