如何以root身份从apache(centOS)运行cmd? [英] how to run cmd as root from apache (centOS)?

查看:586
本文介绍了如何以root身份从apache(centOS)运行cmd?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在CENTOS中运行useradd命令,但是我不能,因为我需要root权限。

I'm trying to run the "useradd" command in CENTOS but I can't because I need root permissions.

在我的 php_info(); 我有'--disable-posix'。我尝试重新安装我的PHP,并尝试启用posix与yum和更多的选择,但没有运气。

In my php_info(); I have '--disable-posix'. I have tried to re-install my PHP, and tried to enable the posix with yum and more options, but no luck.

有人可以帮助我使posix使能或一些其他解决方案?我注意到 posix_getuid(); 正在工作,但 posix_setuid(); 不是。

Can someone help me to make the posix enable or some other solutions? I notice that posix_getuid(); is working, but posix_setuid(); is not.

任何解决方案?

所有我需要在passwd中插入 useradd )命令。

All I need to insert useradd into passwd(root) command by "user click". What is the best and most secure way to do this?

非常感谢!

Koren或

推荐答案

Sudo可能是一个快速实现这个快速的黑客,但它很难保证,有陷阱,即使是有经验的unix guru 。

Sudo could be a quick hack to implement this quickly, but it is hard to secure and there are pitfalls even for the experienced unix guru.

另一种方法是编写自己的服务器守护程序,以root身份运行,监听本地unix域套接字或命名管道,或者只是查找文件在某个受保护的目录中。然后从您的php脚本消息这个守护程序与要添加的用户名。在这个守护进程中只实现最低限度的应用程序功能,而在php中实现其他一切。但是在你的守护进程中进行强大的输入检查,清理你的环境等等,以确保它是php应用程序调用,而不是其他人。

A different way is to write your own server daemon, running as root, listening to a local unix domain socket, or a named pipe, or simply to look for files in a certain protected directory. Then message this daemon from your php script with the user name to add. Implement only the bare minimum application functionality in this daemon, and everything else in php. But do strong input checks in your daemon, sanitize your environment, etc, to be really sure it is the php app calling, not someone else.

这篇关于如何以root身份从apache(centOS)运行cmd?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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