donglu8779 2016-07-14 12:23
浏览 62

通过PHP命令'at now'

I'm trying to run at command via PHP

<?php
shell_exec("echo \"php /tmp/skript.php `whoami`\" | at now");
echo shell_exec("atq 2>&1");

output:

247 2016-07-14 11:30 = apache

But the command at is not executed and after this, and the time disappear from the queue.


I'm running Cent OS on my production server. (SELinux is disabled)

When I'm running this on my personal computer with Debian, everything works well. (SELinux disabled here too)


The permissions are OK:

bash-4.1$ ls -l /tmp/skript.php 

-rwxrwxrwx 1 admin admin 741 13. čec 08.16 /tmp/skript.php


When I execute the shell as apache

me@PC:~$ sudo -u apache /bin/bash
bash-4.1$ echo "php /tmp/skript.php `whoami`" | at now 

script will be executed as apache


When I do this:

me@PC:~$ sudo usermod -s /bin/bash tom 

everything works, but this is BAD and not the way I would like to do. This is not an answer/solution for me.

My Debian has apache as shell /bin/nologin too and it's working. Also at.deny is empty and at.allow doesn't exist.

Can somebody answer this tricky question?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!
    • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
    • ¥15 求daily translation(DT)偏差订正方法的代码
    • ¥15 js调用html页面需要隐藏某个按钮
    • ¥15 ads仿真结果在圆图上是怎么读数的