hi im使用gpg在linux中解密文件,im使用
shell_exec("gpg --batch --passphrase-file $passphrase_file -d $encrypted_file");
解密文件,但我得到以下错误。
gpg: gpg-agent is not available in this session
gpg: can't query passphrase in batch mode
gpg: Invalid passphrase; please try again ...
gpg: can't query passphrase in batch mode
gpg: Invalid passphrase; please try again ...
gpg: can't query passphrase in batch mode
最佳答案
此错误使comma和不喜欢使用shell_exec运行(类似于sudo/ssh在使用shell_exec运行时警告需要tyy的方式):
gpg: gpg-agent is not available in this session
如果直接从shell提示符运行它会怎么样?
另外,请确保您没有处于安全模式:
shell_exec()(与backticks函数等价)
当php在安全模式下运行时,此函数被禁用。
查看phpinfo()
检查功能是否未禁用:
$ grep 'disable_functions' /etc/php.ini
编辑:
另外,尝试使用putenv将gnupghome指向您的.gnupg文件夹。
可能是php脚本作为httpd用户运行,而gpg希望您的站点使用“user”用户。