0

I'd like to apply this generated patch but the patch command is asking me for a file path name :

administrator@server:~$ diff -Nau /etc/php/8.1/fpm/pool.d/www.conf /etc/php/8.1/fpm/pool.d/www.NEW.conf > ~/php8.1-fpm-www.conf.patch
administrator@server:~$ sudo patch -p0 < ~/php8.1-fpm-www.conf.patch
Ignoring potentially dangerous file name /etc/php/8.1/fpm/pool.d/www.conf
Ignoring potentially dangerous file name /etc/php/8.1/fpm/pool.d/www.NEW.conf
cant find file to patch at input line 3
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|--- /etc/php/8.1/fpm/pool.d/www.conf   2022-09-15 13:30:49.000000000 +0200
|+++ /etc/php/8.1/fpm/pool.d/www.NEW.conf       2022-11-07 16:40:35.555078608 +0100
--------------------------
File to patch: ^C
administrator@server:~$

1 Answer 1

1

You need to strip the first component, /, and start from the root directory:

cd /
sudo patch -p1 < ~/php8.1-fpm-www.conf.patch

GNU patch considers patch contents with file names outside the tree starting in the current directory (or the directory given by -d) to be unsafe (see CVE-2010-4651). It’s best to use relative paths, and I recommend minimising the path as far as makes sense since it allows the patch to be used in different contexts — in your case, I would in fact skip the directories entirely:

(
  cd /etc/php/8.1/fpm/pool.d &&
    diff -u www.conf www.NEW.conf
) > ~/php8.1-fpm-www.conf.patch
1
  • Ah, yes, that’s equivalent but clearer. Commented Nov 8, 2022 at 8:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .