Skip to content

Commit

Permalink
Avoid making builddir read-only
Browse files Browse the repository at this point in the history
When using e.g. `--stop=patch` the log directory will be inside the build directory. When `--read-only-installdir` is set the log directory and the build directory itself will be read-only which is not what the option intended:
The `ensure_writable_log_dir` function changes the permissions of the folder containing the log directory to writeable without checking if this is required. When supposedly reverting it any write permissions will be removed even if they have been there before.

Similar the write permissions of the log directory are removed even when the installation was stopped.

This adds the neccessary checks.
  • Loading branch information
Flamefire authored Jan 3, 2025
1 parent d2e37b5 commit ca6be53
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions easybuild/framework/easyblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -4324,7 +4324,7 @@ def ensure_writable_log_dir(log_dir):
adjust_permissions(log_dir, stat.S_IWUSR, add=True, recursive=True)
else:
parent_dir = os.path.dirname(log_dir)
if os.path.exists(parent_dir):
if os.path.exists(parent_dir) and not (os.stat(parent_dir).st_mode & stat.S_IWUSR):
adjust_permissions(parent_dir, stat.S_IWUSR, add=True, recursive=False)
mkdir(log_dir, parents=True)
adjust_permissions(parent_dir, stat.S_IWUSR, add=False, recursive=False)
Expand Down Expand Up @@ -4405,7 +4405,7 @@ def ensure_writable_log_dir(log_dir):
copy_file(patch['path'], target)
_log.debug("Copied patch %s to %s", patch['path'], target)

if build_option('read_only_installdir'):
if build_option('read_only_installdir') and not app.cfg['stop']:
# take away user write permissions (again)
perms = stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH
adjust_permissions(new_log_dir, perms, add=False, recursive=True)
Expand Down

0 comments on commit ca6be53

Please # to comment.