Correctly delegate paths via add_paths() in repository_tool.py

Signed-off-by: Vladimir Diaz <vladimir.v.diaz@gmail.com>
This commit is contained in:
Vladimir Diaz 2018-02-12 17:31:17 -05:00
parent 6edad831c5
commit b3cc7dfeb6
No known key found for this signature in database
GPG key ID: 5DEE9B97B0E2289A

View file

@ -1814,6 +1814,10 @@ def add_paths(self, paths, child_rolename):
securesystemslib.formats.PATHS_SCHEMA.check_match(paths)
tuf.formats.ROLENAME_SCHEMA.check_match(child_rolename)
# A list of relative and verified paths or glob patterns to be added to the
# child role's entry in the parent's delegations field.
relative_paths = []
# Ensure that 'child_rolename' exists, otherwise it will not have an entry
# in the parent role's delegations field.
if not tuf.roledb.role_exists(child_rolename, self._repository_name):
@ -1831,6 +1835,8 @@ def add_paths(self, paths, child_rolename):
' repository\'s targets'
' directory: ' + repr(self._targets_directory))
relative_paths.append(path)
# Get the current role's roleinfo, so that its delegations field can be
# updated.
roleinfo = tuf.roledb.get_roleinfo(self._rolename, self._repository_name)