Skip to content

Commit 2b222ce

Browse files
yavimmalchuk
authored andcommitted
Fix plugin builds with sources using type=git
A recent change to git [1] introduced a new behaviour to work around a CVE [2] that disallows any git operations in directories not owned by the current user. A fix was introduced for general checkouts, but it was not applied to the plugins archive, resulting in PBR still not working as intended. Fixed conflict added in I093620679016b37e1664c9fe4cf7559433e744b7. [1] git/git@8959555 [2] https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-24765. Closes-Bug: #1969096 Related-Bug: #1968877 Co-Authored-By: Mark Goddard <[email protected]> Co-Authored-By: Marcin Juszkiewicz <[email protected]> Signed-off-by: Jakub Neumann <[email protected]> Change-Id: Ib3a37eebb29d975fc51a117cecdff74baafd8941 (cherry picked from commit 6be0068)
1 parent f3edd4d commit 2b222ce

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
@@ -496,8 +496,18 @@ def make_an_archive(items, arcname, item_child_path=None):
496496
image.status = Status.CONNECTION_ERROR
497497
raise ArchivingError
498498
arc_path = os.path.join(image.path, '%s-archive' % arcname)
499+
500+
# NOTE(jneumann): Change ownership of files to root:root. This
501+
# avoids an issue introduced by the fix for git CVE-2022-24765,
502+
# which breaks PBR when the source checkout is not owned by the
503+
# user installing it. LP#1969096
504+
def reset_userinfo(tarinfo):
505+
tarinfo.uid = tarinfo.gid = 0
506+
tarinfo.uname = tarinfo.gname = "root"
507+
return tarinfo
508+
499509
with tarfile.open(arc_path, 'w') as tar:
500-
tar.add(items_path, arcname=arcname)
510+
tar.add(items_path, arcname=arcname, filter=reset_userinfo)
501511
return len(os.listdir(items_path))
502512

503513
self.logger.debug('Processing')

0 commit comments

Comments
 (0)