修改linux的shell限制,Nginx下解决WebShell访问限制问题

直入主题公布修改方法

wget http://www.php.net/get/php-5.2.10.tar.gz/from/this/mirror

wget http://php-fpm.org/downloads/php-5.2.10-fpm-0.5.13.diff.gz

tar zxvf php-5.2.10.tar.gz

gzip -cd php-5.2.10-fpm-0.5.13.diff.gz | patch -d php-5.2.10 -p1 //如果你用补丁的话先打补丁再改比较妥当,我没检查过补丁有没动这个文件

cd php-5.2.10/

./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –with-mysql=/usr/local/mysql –with-mysqli=/usr/local/mysql/bin/mysql_config –with-iconv-dir –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir=/usr –enable-xml –disable-rpath –enable-discard-path –enable-magic-quotes –enable-safe-mode –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curl –with-curlwrappers –enable-mbregex –enable-fastcgi –enable-fpm –enable-force-cgi-redirect –enable-mbstring –with-mcrypt –enable-ftp –with-gd –enable-gd-native-ttf –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-xmlrpc –enable-zip –enable-soap –without-pear –with-gettext –with-mime-magic –enable-suhosin

vi main/fopen_wrappers.c

找到/* {{{ php_check_open_basedir

*/

PHPAPI int php_check_open_basedir_ex(const char *path, int warn TSRMLS_DC)

{

/* Only check when open_basedir is available */

if (PG(open_basedir) && *PG(open_basedir)) {

char *pathbuf;

char *ptr;

char *end;

// add by anxsoft.com

char *env_doc_root;

if(PG(doc_root)){

env_doc_root = estrdup(PG(doc_root));

}else{

env_doc_root = sapi_getenv("DOCUMENT_ROOT", sizeof("DOCUMENT_ROOT")-1 TSRMLS_CC);

}

if(env_doc_root){

intres_root = php_check_specific_open_basedir(env_doc_root, path TSRMLS_CC);

efree(env_doc_root);

if (res_root == 0) {

return 0;

}

if (res_root == -2) {

errno = EPERM;

return -1;

}

}

// add by anxsoft.com

pathbuf = estrdup(PG(open_basedir));

ptr = pathbuf;

while (ptr && *ptr) {

end = strchr(ptr, DEFAULT_DIR_SEPARATOR);

if (end != NULL) {

*end = '\0';

end++;

}

if (php_check_specific_open_basedir(ptr, path TSRMLS_CC) == 0) {

efree(pathbuf);

return 0;

}

ptr = end;

}

if (warn) {

php_error_docref(NULL TSRMLS_CC, E_WARNING, "open_basedir restriction in effect. File(%s) is not within the allowed path(s): (%s)", path, PG(open_basedir));

}

efree(pathbuf);

errno = EPERM; /* we deny permission to open it */

return -1;

}

/* Nothing to check... */

return 0;

}

/* }}} */

两个 add by anxsoft.com 中间的是修改加上去的

然后保存,退出。

make ZEND_EXTRA_LIBS=’-liconv’

make install

php.in的open_basedir配置

open_basedir = “/tmp/:/var/tmp/”0b1331709591d260c1c78e86d0c51c18.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值