Perl CGI PHP 会话权限被拒绝
我正在尝试将 PHP 会话变量放入 Perl CGI 脚本中。我有下面的 perl 代码,它似乎可以让我获取 PHPSESSID,然后将其与存储会话文件的目录一起传递给 PHP::Session。
my $cookie_name='PHPSESSID';
my $sess_query = new CGI;
my $session_name = $sess_query->cookie($cookie_name);
my $session = PHP::Session->new($session_name,{save_path =>'/var/lib/php/session/'});
当我收到权限被拒绝错误时,就会出现问题
[Fri Dec 2 16:52:44 2011] upload.cgi: /var/lib/php/session/sess_417ar7qsh4sh853gqs3bj454i5: 权限在 /var/www/html/xxx/upload.cgi 第 22 行被拒绝,引荐来源:。 ..
...第 22 行是上面的 PHP::Session->new
行 代码。
我的 httpd 服务器以用户 apache 身份运行,cgi 脚本由 apache 拥有,/var/lib/php/session/
中的所有会话文件也是如此,所以我想知道为什么 CGI 不这样做脚本能够读取会话文件。
我在网上读到有人使用 LWP 作为一种解决方法,但这不是我的偏好,因为我觉得这对我所缺少的权限来说是愚蠢的。
更新:添加信息 - 这是会话文件 - 正如您所看到的,会话文件存在并且属于 apache,但 CGI perl 脚本无法读取这些文件:
-rw-------. 1 apache apache 0 Dec 2 16:58 /var/lib/php/session/sess_417ar7qsh4sh853gqs3bj454i5
-rw-------. 1 apache apache 126 Dec 2 16:58 /var/lib/php/session/sess_f39ot5ul3bu55uu7d1rg3aqq02
I'm trying to get PHP session variables into a Perl CGI script. I've got the following perl code below which seems to work in getting me the PHPSESSID which I then pass to the PHP::Session along with the directory where the session files are stored.
my $cookie_name='PHPSESSID';
my $sess_query = new CGI;
my $session_name = $sess_query->cookie($cookie_name);
my $session = PHP::Session->new($session_name,{save_path =>'/var/lib/php/session/'});
My problem is occuring when I get a permission denied error
[Fri Dec 2 16:52:44 2011] upload.cgi: /var/lib/php/session/sess_417ar7qsh4sh853gqs3bj454i5: Permission denied at /var/www/html/xxx/upload.cgi line 22, referer:...
The line 22 is the PHP::Session->new
line in the above code.
My httpd server is running as user apache and the cgi scripts are owned by apache as are all the sesssion files in /var/lib/php/session/
so I'm wondering why wouldn't the CGI script be able to read the session files.
I read online where one person use LWP as a workaround, but that's not my preference as I feel this is something silly on permissions that I'm missing.
UPDATE: Added info - here are the session files - as you can see the session file exists and is owned by apache, but the CGI perl script can't read these:
-rw-------. 1 apache apache 0 Dec 2 16:58 /var/lib/php/session/sess_417ar7qsh4sh853gqs3bj454i5
-rw-------. 1 apache apache 126 Dec 2 16:58 /var/lib/php/session/sess_f39ot5ul3bu55uu7d1rg3aqq02
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题确实是 SELinux...在这种情况下,不是 1 个 AVC 警报,而是 5 个警报 - 与读取目录中的文件所需的每个文件 I/O 操作相对应的一个警报。它们按顺序触发,但可以使用下面的 {} 语法来允许。
这可以通过以下方法解决:
谈论使用腰带和背带!
感谢您的帮助!
右
The problem was indeed SELinux...and in this case, not 1 AVC alert, but 5 - one alert corresponding to each file I/O action needed to read a file in the directory. they fire sequentially, but can be allowed using {} syntax below.
this can be solved by:
Talk about using a belt and suspenders!
Thanks for the help!
R
在 文档 中,它说:
我不认为您和这个模块正在考虑相同的会话文件。
In the documentation it says:
I don't think you and this module are thinking of the same session files.