你的php要是有root用户的权限就可以.

解决方案 »

  1.   

    感谢 myblessu(寒飞) 的回复
    不过 我怎么知道我的PHP是root用户权限呢?PS: 你指是会不会是apache执行的身份呢?愿闻其详
      

  2.   

    因为你的PHP执行用户是nobody用户,而nobody用户是有限权限用户,而不是超级用户,你要用ROOT权限给该用户赋于更大的权限,但是,也一样,若是你的php配置安全性不高的话,最好还不要这样,否则,会有hk使用你的现成漏洞增加用户,很危险!
      

  3.   

    PHP的执行身份在httpd.conf中定义:
    ----------------------------------------------
    User apache
    Group apache
    ----------------------------------------------
    改为root是可以的,不过不安全.另一种方法是直接修改/etc/passwd文件(取消shadow套再修改).无论怎样,以root身份运行apache服务都是不安全的.如果对实时性要求不高的话,
    可以用apache将要添加的用户信息写入数据库,  编写一后台程序(shell脚本也可)定时扫描该数据库,并添加相应用户.
      

  4.   

    我把
    User apache
    Group apache
    都改为root之后 重启apache  出现提示Error:  Apache has not been designed to serve pages while
            running as root.  There are known race conditions that
            will allow any local user to read any file on the system.
            If you still desire to serve pages as root then
            add -DBIG_SECURITY_HOLE to the EXTRA_CFLAGS line in your
            src/Configuration file and rebuild the server.  It is
            strongly suggested that you instead modify the User
            directive in your httpd.conf file to list a non-root
            user.---------
    to netvt
    你说提到的"另一种方法是直接修改/etc/passwd文件(取消shadow套再修改)."
                                                  ~~~~~~~~~~~~~~~~~~~请问这什么意思?
                                                                     如果去实现?
    谢谢
      

  5.   

    要用root运行apache需重新编译, 
    add -DBIG_SECURITY_HOLE to the EXTRA_CFLAGS line in your
    src/Configuration file and rebuild the server. 
    -----------------
    passwd是帐户及密码记录文件.一般情况下/etc/passwd是shadow过的,也就是平时看到的passwd并不是真正的passwd文件.
    即一般情况下看到的passwd文件是不显示密码的.(以x 代替),
    取消shadow用 pwunconv  (激活用pwconv)
    ===passwd文件格式如下:
    帐户名:密码:UID:GID:用户全称:主目录:shell
    ======
    passwd的默认权限为 只有root有权修改,
    -rw-r--r--    1 root     root         1631 10月  7 14:40 /etc/passwd
    --
    #chmod 666 /etc/passwd (设定为其他人可写,存在安全隐患)
      

  6.   

    我所使用的平台是Solaris 8 
    没有你所说的
    pwunconv 命令
    ....
      

  7.   

    先看看passwd是否shadow过了.(即密码部分用x代替了).
    如果没有shadow过,不必pwunconv