Hi, Since 7.4 patch(1) does not work if an explicit patchfile is given on command line.
https://marc.info/?l=openbsd-cvs&m=168941770509379&w=2 root@ot14:.../~# patch /usr/src/usr.bin/patch/patch.c patch-unveil.diff Hmm... Looks like a unified diff to me... The text leading up to this was: -------------------------- |Index: patch.c |=================================================================== |RCS file: /data/mirror/openbsd/cvs/src/usr.bin/patch/patch.c,v |diff -u -p -r1.74 patch.c |--- patch.c 19 Jul 2023 13:26:20 -0000 1.74 |+++ patch.c 24 Oct 2023 17:13:28 -0000 -------------------------- Patching file /usr/src/usr.bin/patch/patch.c using Plan A... Hunk #1 succeeded at 32. Hunk #2 succeeded at 214. Hunk #3 succeeded at 245. Can't backup /usr/src/usr.bin/patch/patch.c, output is in /tmp/patchoorjYymLKcM: No such file or directory done A backup file should be created in the directory of the original file, but only the current directory is unveiled. Then the patched file is created in /tmp and does not replace the original patchfile in place. Diff below fixes it. ok? bluhm Index: patch.c =================================================================== RCS file: /data/mirror/openbsd/cvs/src/usr.bin/patch/patch.c,v diff -u -p -r1.74 patch.c --- patch.c 19 Jul 2023 13:26:20 -0000 1.74 +++ patch.c 24 Oct 2023 17:13:28 -0000 @@ -32,6 +32,7 @@ #include <ctype.h> #include <getopt.h> +#include <libgen.h> #include <limits.h> #include <paths.h> #include <stdio.h> @@ -213,11 +214,27 @@ main(int argc, char *argv[]) perror("unveil"); my_exit(2); } - if (filearg[0] != NULL) + if (filearg[0] != NULL) { + char *origdir; + if (unveil(filearg[0], "rwc") == -1) { perror("unveil"); my_exit(2); } + if ((origdir = dirname(filearg[0])) == NULL) { + perror("dirname"); + my_exit(2); + } + if (unveil(origdir, "rwc") == -1) { + perror("unveil"); + my_exit(2); + } + } else { + if (unveil(".", "rwc") == -1) { + perror("unveil"); + my_exit(2); + } + } if (filearg[1] != NULL) if (unveil(filearg[1], "r") == -1) { perror("unveil"); @@ -228,10 +245,6 @@ main(int argc, char *argv[]) perror("unveil"); my_exit(2); } - if (unveil(".", "rwc") == -1) { - perror("unveil"); - my_exit(2); - } if (*rejname != '\0') if (unveil(rejname, "rwc") == -1) { perror("unveil");