Skip to content

Commit e8c92df

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 d67bf58 commit e8c92df

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
@@ -518,8 +518,18 @@ def make_an_archive(items, arcname, item_child_path=None):
518518
image.status = Status.CONNECTION_ERROR
519519
raise ArchivingError
520520
arc_path = os.path.join(image.path, '%s-archive' % arcname)
521+
522+
# NOTE(jneumann): Change ownership of files to root:root. This
523+
# avoids an issue introduced by the fix for git CVE-2022-24765,
524+
# which breaks PBR when the source checkout is not owned by the
525+
# user installing it. LP#1969096
526+
def reset_userinfo(tarinfo):
527+
tarinfo.uid = tarinfo.gid = 0
528+
tarinfo.uname = tarinfo.gname = "root"
529+
return tarinfo
530+
521531
with tarfile.open(arc_path, 'w') as tar:
522-
tar.add(items_path, arcname=arcname)
532+
tar.add(items_path, arcname=arcname, filter=reset_userinfo)
523533
return len(os.listdir(items_path))
524534

525535
self.logger.debug('Processing')

0 commit comments

Comments
 (0)