我想应用这个生成的补丁,但该patch
命令要求我提供文件路径名:
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
您需要剥离第一个组件 ,/
并从根目录开始:
cd /
sudo patch -p1 < ~/php8.1-fpm-www.conf.patch
GNUpatch
认为文件名在从当前目录(或由 给出的目录)开始的树之外的补丁内容-d
是不安全的(请参阅CVE-2010-4651)。最好使用相对路径,我建议尽可能最小化路径,因为它允许补丁在不同的上下文中使用 - 在你的情况下,我实际上会完全跳过目录:
(
cd /etc/php/8.1/fpm/pool.d &&
diff -u www.conf www.NEW.conf
) > ~/php8.1-fpm-www.conf.patch