emulator: fail if object_id of requirement starts with slash

Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
Steven Armstrong 2011-10-14 11:39:55 +02:00
parent d346364544
commit f285d9e64e

View file

@ -106,8 +106,19 @@ def run(argv):
# Record requirements
if "require" in os.environ:
requirements = os.environ['require']
log.debug("%s:Writing requirements: %s" % (cdist_object.path, requirements))
cdist_object.requirements.extend(requirements.split(" "))
for requirement in requirements.split(" "):
requirement_parts = requirement.split(os.sep, 1)
requirement_parts.reverse()
requirement_type_name = requirement_parts.pop()
try:
requirement_object_id = requirement_parts.pop()
except IndexError:
# no object id, must be singleton
requirement_object_id = 'singleton'
if requirement_object_id.startswith('/'):
raise core.IllegalObjectIdError(requirement_object_id, 'object_id may not start with /')
log.debug("Recording requirement: %s -> %s" % (cdist_object.path, requirement))
cdist_object.requirements.append(rement_object_id)
# Record / Append source
cdist_object.source.append(object_source)