Mysql源码学习——用户认证原理与实现(3)_MySQL, Oracle及数据库讨论区_Weblogic技术|Tuxedo技术|中间件技术|Oracle论坛|JAVA论坛|Linux/Unix技术|hadoop论坛_联动北方技术论坛  
网站首页 | 关于我们 | 服务中心 | 经验交流 | 公司荣誉 | 成功案例 | 合作伙伴 | 联系我们 |
联动北方-国内领先的云技术服务提供商
»  游客             当前位置:  论坛首页 »  自由讨论区 »  MySQL, Oracle及数据库讨论区 »
总帖数
1
每页帖数
101/1页1
返回列表
0
发起投票  发起投票 发新帖子
查看: 1966 | 回复: 0   主题: Mysql源码学习——用户认证原理与实现(3)        下一篇 
snisn
注册用户
等级:新兵
经验:51
发帖:84
精华:0
注册:2011-10-23
状态:离线
发送短消息息给snisn 加好友    发送短消息息给snisn 发消息
发表于: IP:您无权察看 2014-12-25 16:30:33 | [全部帖] [楼主帖] 楼主

 my_sleep(1000);                /* must wait after eof() */

#endif

statistic_increment(aborted_connects,&LOCK_status);

DBUG_RETURN(1);

}

/* Connect completed, set read/write timeouts back to default */

my_net_set_read_timeout(net, thd->variables.net_read_timeout);

my_net_set_write_timeout(net, thd->variables.net_write_timeout);

DBUG_RETURN(0);

}

此函数主要是功能是调用函数check_connection进行用户认证,由于函数check_connection过长,对其进行简化,如下所示:

static int check_connection(THD *thd)

{

    uint connect_errors= 0;

    NET *net= &thd->net;

    ulong pkt_len= 0;

    char *end;

    DBUG_PRINT("info",

    ("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是否存在

--转自 北京联动北方科技有限公司




赞(0)    操作        顶端 
总帖数
1
每页帖数
101/1页1
返回列表
发新帖子
请输入验证码: 点击刷新验证码
您需要登录后才可以回帖 登录 | 注册
技术讨论