Skip to content

Commit

Permalink
chroot_scan: create result directory with appropriate permissions
Browse files Browse the repository at this point in the history
To make the fix possible, we needed to make the result directory
creation method public.

Fixes: rpm-software-management#1467
  • Loading branch information
praiskup committed Sep 26, 2024
1 parent 1505bcf commit 48217f1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
9 changes: 6 additions & 3 deletions mock/py/mockbuild/buildroot.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,10 @@ def _setup_basedir(self):
os.chmod(self.basedir, 0o775)

@traceLog()
def _setup_result_dir(self):
def create_resultdir(self):
"""
(re)create self.resultdir directory with appropriate permissions
"""
self._setup_basedir()
with self.uid_manager:
try:
Expand Down Expand Up @@ -300,7 +303,7 @@ def _init(self, prebuild):
# intentionally we do not call bootstrap hook here - it does not have sense
self._setup_nosync()
self.chroot_was_initialized = self.chroot_is_initialized()
self._setup_result_dir()
self.create_resultdir()
getLog().info("calling preinit hooks")
self.plugins.call_hooks('preinit')
# intentionally we do not call bootstrap hook here - it does not have sense
Expand Down Expand Up @@ -629,7 +632,7 @@ def resetLogging(self, force=False):
return
self.logging_initialized = True

self._setup_result_dir()
self.create_resultdir()

with self.uid_manager:
# attach logs to log files.
Expand Down
2 changes: 1 addition & 1 deletion mock/py/mockbuild/plugins/chroot_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __scanChroot(self):
regexstr = "|".join(self.scan_opts['regexes'])
regex = re.compile(regexstr)
chroot = self.buildroot.make_chroot_path()
file_util.mkdirIfAbsent(self.resultdir)
self.buildroot.create_resultdir()
count = 0
logger = getLog()
logger.debug("chroot_scan: Starting scan of %s", chroot)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Several internal code locations attempt to ensure that the result directory
exists, creating it if necessary. However, these locations handled it
inconsistently, sometimes neglecting to [change the ownership][issue#1467] of
the result directory. Now, all locations use a single method dedicated to
result directory preparation.

0 comments on commit 48217f1

Please sign in to comment.