PHP exec pgp 命令 [英] PHP exec pgp command

查看:40
本文介绍了PHP exec pgp 命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 PHP 来执行"一个 pgp 加密命令.无论命令行如何,我都会收到 err 64(解析器错误)或 162(编码期间完全失败).所以我将 PHP 程序中的命令行简化为这个简单的指纹显示,它仍然会出错:

I am want to use PHP to 'exec' a pgp encryption command. Regardless of the command line I get either a err 64 (parser error) or 162 (complete failure during an encode). So I have reduced the command line within the PHP program to this simple fingerprint display which stills errs out:

exec("/opt/pgp/bin/pgp --fingerprint", $results);

如果我在命令行上运行/opt/pgp/bin/pgp --fingerprint",我会得到找到 2 个键"和预期的显示.但是 PHP 下的同一个 exec 给了我解析器错误 64.我试过\n"到字符串命令,这没有什么区别.用户在浏览器中以nobody"身份运行,该浏览器对 pgp 具有执行权限.(如果 pgp 至少没有启动,我什至不会从中看到解析器错误".)

If I run "/opt/pgp/bin/pgp --fingerprint" on a command line I get "2 keys found" and the expected display. But the same exec under PHP gives me the parser error 64. I have tried "\n" to the string command and that does not make a difference. The user runs as 'nobody' in the browser which does have execute permission on pgp. (If pgp was not at least starting up I would not even see the 'parser error' from it.)

为了在 PHP 下运行 pgp,我需要做什么特别的事情吗?

Is there something special I need to do in order to run pgp under PHP?

我已经回去尝试实际加密数据文件.这是 pgp 创建的状态文件"输出.它清楚地显示了我试图加密test.txt"文件的最后一行权限被拒绝"的错误.那是假的.我已授予该文件全世界的 r/w 权限,并且它可以清楚地访问它,因为状态表明它已对内容进行了加密.那么,真正的问题是许可被拒绝是什么?

I have gone back to trying to actually encrypt a data file. Here is the 'status-file' output that pgp creates. It clearly shows an error on the last line of 'permission denied' on the file I am trying to encrypt 'test.txt'. That is bogus. I have granted all the world r/w to that file and it clearly accesses it becuase the status says it has encrypted the contents. So, really the question is what is permission being denied to?

一些其他信息:如果我从命令行针对调用 pgp 的这个 PHP 脚本运行 PHP,它工作正常 - 文件被加密.此外,当从浏览器调用时,PERL 运行相同的命令(使用 SYSTEM()).但是,当浏览器用于调用此 PHP 脚本时,它会失败.显然,以nobody"身份运行存在一些权限问题.

Some other info: if I run PHP from the command line against this PHP script which calls pgp it works fine - the file gets encrypted. ALso, PERL runs the same commands (using SYSTEM()) when called from the browser. BUT, when the browser is used to call this PHP script it fails. Clearly, there is some permission problem running as 'nobody'.

/export/home/pgphome/.pgp/pubring.pkr:open keyrings (1006:public keyring)/export/home/pgphome/.pgp/secring.skr:open keyrings (1007:private keyring)0x221DC947:encrypt (1030:key 添加到收件人列表)/export/home/eckankar/dev/www/info/test.txt:encrypt(3048:用密码AES-128加密的数据)/export/home/eckankar/dev/www/info/test.txt:encrypt (3124:permission denied)

/export/home/pgphome/.pgp/pubring.pkr:open keyrings (1006:public keyring) /export/home/pgphome/.pgp/secring.skr:open keyrings (1007:private keyring) 0x221DC947:encrypt (1030:key added to recipient list) /export/home/eckankar/dev/www/info/test.txt:encrypt (3048:data encrypted with cipher AES-128) /export/home/eckankar/dev/www/info/test.txt:encrypt (3124:permission denied)

这里的背景是 PHP exec() 命令的参数:/opt/pgp/bin/pgp --encrypt/export/home/eckankar/dev/inc/test.txt --output/export/home/eckankar/dev/www/info/test.xxx -r 会员资格 --overwrite删除 --home-dir/export/home/pgphome/.pgp -v --status-file/export/home/eckankar/dev/inc/test.txt.err

As background here is the argument of the PHP exec() command: /opt/pgp/bin/pgp --encrypt /export/home/eckankar/dev/inc/test.txt --output /export/home/eckankar/dev/www/info/test.xxx -r membership --overwrite remove --home-dir /export/home/pgphome/.pgp -v --status-file /export/home/eckankar/dev/inc/test.txt.err

此命令中的所有文件夹/目录都已将 'rwx' 授予世界.

ALl the folder/directories in this command have granted 'rwx' to the world.

以下是加密成功时的状态输出文件的样子,就像从命令行 (/opt/csw/php5/bin/php test.php) 而不是通过浏览器运行一样:

Here is what the status output file looks like when the encrypt succeeds as it does if run from a command line (/opt/csw/php5/bin/php test.php) rather than through the browser:

pgp:encrypt (3157: 当前本地时间 2009-06-30T11:51:17-05:00)/export/home/pgphome/.pgp/pubring.pkr:open keyrings (1006:public keyring)/export/home/pgphome/.pgp/secring.skr:open keyrings (1007:private keyring)0x221DC947:encrypt (1030:key 添加到收件人列表)/export/home/eckankar/dev/inc/test.txt:encrypt (3048: 用密码 AES-128 加密的数据)/export/home/eckankar/dev/inc/test.txt:encrypt (0:输出文件/export/home/eckankar/dev/inc/test.txt.pgp)

pgp:encrypt (3157:current local time 2009-06-30T11:51:17-05:00) /export/home/pgphome/.pgp/pubring.pkr:open keyrings (1006:public keyring) /export/home/pgphome/.pgp/secring.skr:open keyrings (1007:private keyring) 0x221DC947:encrypt (1030:key added to recipient list) /export/home/eckankar/dev/inc/test.txt:encrypt (3048:data encrypted with cipher AES-128) /export/home/eckankar/dev/inc/test.txt:encrypt (0:output file /export/home/eckankar/dev/inc/test.txt.pgp)

推荐答案

答案是:需要在命令行中指定一个--temp-dir.

Answer is: need to specify a --temp-dir in the command line.

这篇关于PHP exec pgp 命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆