Skip to content

Commit b716b5a

Browse files
committed
Fix local sources of git repositories
This is I2cbf1f539880d512aa223c3ef3a4b19ee18854ac extended to fix the case when a git repository is used with a git repo. This is probably a rarer use case but, still, we use it in CI for in-review changes testing. Change-Id: I77b0dcd2e9dfd8ea8390a471b80c8954b67ef91b (cherry picked from commit b888f68)
1 parent 3548fa6 commit b716b5a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

kolla/image/build.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,15 @@ def followups(self):
405405
def process_source(self, image, source):
406406
dest_archive = os.path.join(image.path, source['name'] + '-archive')
407407

408+
# NOTE(mgoddard): Change ownership of files to root:root. This
409+
# avoids an issue introduced by the fix for git CVE-2022-24765,
410+
# which breaks PBR when the source checkout is not owned by the
411+
# user installing it. LP#1969096
412+
def reset_userinfo(tarinfo):
413+
tarinfo.uid = tarinfo.gid = 0
414+
tarinfo.uname = tarinfo.gname = "root"
415+
return tarinfo
416+
408417
if source.get('type') == 'url':
409418
self.logger.debug("Getting archive from %s", source['source'])
410419
try:
@@ -458,7 +467,8 @@ def process_source(self, image, source):
458467
if os.path.isdir(source['source']):
459468
with tarfile.open(dest_archive, 'w') as tar:
460469
tar.add(source['source'],
461-
arcname=os.path.basename(source['source']))
470+
arcname=os.path.basename(source['source']),
471+
filter=reset_userinfo)
462472
else:
463473
shutil.copyfile(source['source'], dest_archive)
464474

0 commit comments

Comments
 (0)