return security_label
def set_security_label(policy, label):
- policytype = xsconstants.ACM_POLICY_ID
if label != "" and policy != "":
- return "%s:%s:%s" % (policytype, policy, label)
+ return "%s:%s:%s" % (xsconstants.ACM_POLICY_ID, policy, label)
else:
return ""
def ssidref2security_label(ssidref):
from xen.xend.XendXSPolicyAdmin import XSPolicyAdminInstance
return XSPolicyAdminInstance().ssidref_to_vmlabel(ssidref)
+
+def get_security_label(self, xspol=None):
+ """
+ Get the security label of a domain
+ @param xspol The policy to use when converting the ssid into
+ a label; only to be passed during the updating
+ of the policy
+ """
+ domid = self.getDomid()
+
+ if not xspol:
+ from xen.xend.XendXSPolicyAdmin import XSPolicyAdminInstance
+ xspol = XSPolicyAdminInstance().get_loaded_policy()
+
+ if domid == 0:
+ if xspol:
+ label = xspol.policy_get_domain_label_formatted(domid)
+ else:
+ label = ""
+ else:
+ label = self.info.get('security_label', '')
+ return label
def has_authorization(ssidref):
return True
+
+def get_security_label(self, xspol=None):
+ return ""
def ssidref2security_label(ssidref):
return ssidref2label(ssidref)
+
+def get_security_label(self, xspol=None):
+ label = self.info.get('security_label', '')
+ return label
def get_security_label(self, xspol=None):
- """
- Get the security label of a domain
- @param xspol The policy to use when converting the ssid into
- a label; only to be passed during the updating
- of the policy
- """
- domid = self.getDomid()
-
- if not xspol:
- from xen.xend.XendXSPolicyAdmin import XSPolicyAdminInstance
- xspol = XSPolicyAdminInstance().get_loaded_policy()
-
- if domid == 0:
- if xspol:
- label = xspol.policy_get_domain_label_formatted(domid)
- else:
- label = ""
- else:
- label = self.info.get('security_label', '')
+ import xen.util.xsm.xsm as security
+ label = security.get_security_label(self, xspol)
return label
def set_security_label(self, seclab, old_seclab, xspol=None,
XEN_API_ON_CRASH_BEHAVIOUR
from xen.xm.opts import OptionError
from xen.util import xsconstants
+import xen.util.xsm.xsm as security
import sys
import os
if sec_data:
try :
vm.attributes['security_label'] = \
- "%s:%s:%s" % (xsconstants.ACM_POLICY_ID, sec_data[0][1][1],sec_data[0][2][1])
+ security.set_security_label(sec_data[0][1][1],sec_data[0][2][1])
except Exception, e:
raise "Invalid security data format: %s" % str(sec_data)
policy = get_child_by_name(vif_sxp, "policy")
label = get_child_by_name(vif_sxp, "label")
- if label and policy:
- vif.attributes["security_label"] \
- = "%s:%s:%s" % (xsconstants.ACM_POLICY_ID, policy, label)
- else:
- vif.attributes["security_label"] = ""
+ vif.attributes["security_label"] = security.set_security_label(policy, label)
if get_child_by_name(vif_sxp, "bridge") is not None:
vif.attributes["network"] \