drcmg28484 2013-03-01 21:45
浏览 59

使用PHP(Apache)以某些命令的root权限启动linux应用程序

I am running several instance of Node and all of them run on different ports.

I need a way to be able to kill a particular instance of Node based on the port it is running (kill node instance binded to port n).

From my terminal I can easily do a "fuser -k xxxx/tcp" xxxx being the port.

The thing is, that is because I have the authorisation to do so. My question is: I want to be able to have a PHP file that closes the node instance running on port n and it can be opened by anyone. How to do this without opening huge security holes?

Thank you!

  • 写回答

2条回答 默认 最新

  • douren6874 2013-03-01 21:57
    关注

    The best way to do this would be to have php write the port number to a file, then have a cron script run as root (or whatever user it needs to be) and read the port number(s) from that file. The cron script should have some sort of safety measures in there as well, such as not stopping whatever is running on port 80 or not a node process at all.

    edit: for a bit more security, you could require the port number to be prefixed by a "password" that would require you to input. Then the cron script would verify it's prefixed by that password (or hash it and compare the hash would be even better)

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!