Shells/bash.go: set permissions before dir/file deletion
What does this MR do?
Modifies shells/bash.go
. Before any attempt to delete a file/directory with rm
, ensure that the current process has write permission to the file/directory by running chmod u+w
.
Why was this MR needed?
Some software build systems create read-only files in the CI project directory, e.g. software build with Autoconf/Automake creates a read-only source tree when running make distcheck
. If the job fails or is cancelled, the read-only files are left behind in the CI project directory. If a subsequent CI job then tries to remove the CI project directory from the previous job, rm
will fail with Permission denied
errors. See https://git.ligo.org/lscsoft/lalsuite/-/jobs/2361173 for an example of this failure in action.
What's the best way to test this MR?
The changes introduced by this MR are pretty simple -- 7 lines -- so it's probably sufficient to check that the chmod
syntax is correct. The b.IsFile()
and b.IsDirectory()
are needed because (unlike rm -f
) chmod
fails if a file is nonexistent.
A full test of the failure mode seen in https://git.ligo.org/lscsoft/lalsuite/-/jobs/2361173 might be difficult to set up. One would need to run a CI job which creates read-only files, manually cancel the job, then run a 2nd CI job on the same system which tries to remove the project directory of the previous CI job. At https://git.ligo.org/ we only see this failure on macOS runners, not Linux, so it could depend on how the runners are configured.
What are the relevant issue numbers?
None