Skip to content

Commit

Permalink
Fix cleanup when kpatch is installed in read-only location
Browse files Browse the repository at this point in the history
On NixOS files are installed with mode 444 (read-only). This causes
directories in $TEMPDIR to be read-only as well, because they are
created by:

cp -LR "$DATADIR/patch" "$TEMPDIR" || die

which preserves the mode of the directory. We could do
--no-preserve=mode, but this will make people with non-coreutils cp
unhappy. Instead just chmod the files after copying.

If this patch is not applied, cleanup complains like this:

rm: cannot remove '/home/julian/.kpatch/tmp/patch/kpatch.h': Permission denied
rm: cannot remove '/home/julian/.kpatch/tmp/patch/Makefile': Permission denied
rm: cannot remove '/home/julian/.kpatch/tmp/patch/kpatch-macros.h': Permission denied
...

Signed-off-by: Julian Stecklina <[email protected]>
  • Loading branch information
blitz committed Jul 29, 2024
1 parent 6115a1a commit 828b557
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions kpatch-build/kpatch-build
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,10 @@ verify_patch_files
apply_patches
remove_patches

# cp preserves mode and the files might have been read-only. This would
# interfere with cleanup later, so ensure the $TEMPDIR is read/write.
cp -LR "$DATADIR/patch" "$TEMPDIR" || die
chmod -R u+rw "$TEMPDIR" || die

if [[ "$ARCH" = "ppc64le" ]]; then
ARCH_KCFLAGS="-mcmodel=large -fplugin=$PLUGINDIR/ppc64le-plugin.so"
Expand Down

0 comments on commit 828b557

Please sign in to comment.