dongxia527680 2014-12-22 20:51
浏览 49

www-data用户无法写入fifo,chmodded 777

I wrote a little PHP script that I'd like to call from Apache. I'm intending to use this to control pianobar.

If I execute the script directly from a root terminal, it works just fine, but if I try to run the script through the web server, nothing.

The fifo I created is at /home/dave/.config/pianobar/piano and the relevant lines in the PHP script look like this...

<?php
system("echo -n 'p' > /home/dave/.config/pianobar/piano"); //'p' pauses pianobar.

echo system('whoami');
?>

If I execute this script in a browser through Apache, it echoes 'www-data www-data' which tells me that safe mode is disabled and the system() command is working, but pianobar keeps playing. If I run this from a root terminal, it echoes back 'root' and pianobar pauses. If I execute this from a terminal under my own username, it echoes back 'dave' and pianobar still pauses.

The fifo I created /home/dave/.config/pianobar/piano was chmodded to 777. What gives? Is this a permissions issue somehow? Is PHP not allowing me to do anything useful with the system() command?

  • 写回答

1条回答 默认 最新

  • dongliushui2001 2014-12-22 21:14
    关注

    Check folder permissions:

    stat --format '%a' /home/dave/.config/pianobar/piano
    

    Set folder permissions for all files inside of folder:

    sudo chmod -R 755 /home/dave/.config/pianobar/piano
    

    Try, should work.

    评论

报告相同问题?

悬赏问题

  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能