Mysql源码学习——用户认证原理与实现(4)

来源:未知 责任编辑:责任编辑 发表时间:2014-01-06 18:17 点击:

             ("New connection received on %s", vio_description(net->vio)));

#ifdef SIGNAL_WITH_VIO_CLOSE

  thd->set_active_vio(net->vio);

#endif

 

  if (!thd->main_security_ctx.host)         // If TCP/IP connection

  {

    char ip[30];

 

    if (vio_peer_addr(net->vio, ip, &thd->peer_port))

    {

      my_error(ER_BAD_HOST_ERROR, MYF(0), thd->main_security_ctx.host_or_ip);

      return 1;

    }

    if (!(thd->main_security_ctx.ip= my_strdup(ip,MYF(MY_WME))))

      return 1; /* The error is set by my_strdup(). */

    thd->main_security_ctx.host_or_ip= thd->main_security_ctx.ip;

    vio_in_addr(net->vio,&thd->remote.sin_addr);

    if (!(specialflag & SPECIAL_NO_RESOLVE))

    {

      vio_in_addr(net->vio,&thd->remote.sin_addr);

      thd->main_security_ctx.host=

        ip_to_hostname(&thd->remote.sin_addr, &connect_errors);

      /* Cut very long hostnames to avoid possible overflows */

      if (thd->main_security_ctx.host)

      {

        if (thd->main_security_ctx.host != my_localhost)

          thd->main_security_ctx.host[min(strlen(thd->main_security_ctx.host),

                                          HOSTNAME_LENGTH)]= 0;

        thd->main_security_ctx.host_or_ip= thd->main_security_ctx.host;

      }

      if (connect_errors > max_connect_errors)

      {

        my_error(ER_HOST_IS_BLOCKED, MYF(0), thd->main_security_ctx.host_or_ip);

        return 1;

      }

    }

    ...

   

if (acl_check_host(thd->main_security_ctx.host, thd->main_security_ctx.ip))//此处验证主机名或IP是否存在

 

    {

      my_error(ER_HOST_NOT_PRIVILEGED, MYF(0),

发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
用户名: 验证码:点击我更换图片
最新评论 更多>>

推荐热点

  • mysql-mmm
  • mysqldump命令——MySQL数据库备份还原
  • Oracle数据导入MySQL的快捷工具:MySQL Migration Toolkit
  • 简简单单储存过程——循环一个select结果集
  • MySQL数据库十大优化技巧
  • Mysql主主复制架构配置
  • Mysql安装笔记
  • Mysql的Procedure 参数为NULL问题分析
  • MySQL Stmt预处理提高效率问题的小研究
网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
Copyright © 2008-2015 计算机技术学习交流网. 版权所有

豫ICP备11007008号-1