Example #1
0
File: auth.c Project: djyos/djyos
/*
 * Tell the client what security type will be used (protocol 3.3).
 */
static void
rfbSendSecurityType(rfbClientPtr cl, int32_t securityType)
{
    uint32_t value32;

    /* Send the value. */
    value32 = Swap32IfLE(securityType);
    if (rfbWriteExact(cl, (char *)&value32, 4) < 0) {
	rfbLogPerror("rfbSendSecurityType: write");
	rfbCloseClient(cl);
	return;
    }

    /* Decide what to do next. */
    switch (securityType) {
    case rfbSecTypeNone:
	/* Dispatch client input to rfbProcessClientInitMessage. */
	cl->state = RFB_INITIALISATION;
	break;
    case rfbSecTypeVncAuth:
	/* Begin the standard VNC authentication procedure. */
	rfbVncAuthSendChallenge(cl);
	break;
    default:
	/* Impossible case (hopefully). */
	rfbLogPerror("rfbSendSecurityType: assertion failed");
	rfbCloseClient(cl);
    }
}
Example #2
0
void
rfbProcessClientAuthType(rfbClientPtr cl)
{
    uint32_t auth_type;
    int n, i;
    rfbTightClientPtr rtcp = rfbGetTightClientData(cl);

    rfbLog("tightvnc-filetransfer/rfbProcessClientAuthType\n");

    if(rtcp == NULL)
	return;

    /* Read authentication type selected by the client. */
    n = rfbReadExact(cl, (char *)&auth_type, sizeof(auth_type));
    if (n <= 0) {
	if (n == 0)
	    rfbLog("rfbProcessClientAuthType: client gone\n");
	else
	    rfbLogPerror("rfbProcessClientAuthType: read");
	rfbCloseClient(cl);
	return;
    }
    auth_type = Swap32IfLE(auth_type);

    /* Make sure it was present in the list sent by the server. */
    for (i = 0; i < rtcp->nAuthCaps; i++) {
	if (auth_type == rtcp->authCaps[i])
	    break;
    }
    if (i >= rtcp->nAuthCaps) {
	rfbLog("rfbProcessClientAuthType: "
	       "wrong authentication type requested\n");
	rfbCloseClient(cl);
	return;
    }

    switch (auth_type) {
    case rfbAuthNone:
	/* Dispatch client input to rfbProcessClientInitMessage. */
#ifdef USE_SECTYPE_TIGHT_FOR_RFB_3_8
	SECTYPE_TIGHT_FOR_RFB_3_8
#endif
	cl->state = RFB_INITIALISATION;
	break;
    case rfbAuthVNC:
	rfbVncAuthSendChallenge(cl);
	break;
    default:
	rfbLog("rfbProcessClientAuthType: unknown authentication scheme\n");
	rfbCloseClient(cl);
    }
}
Example #3
0
// =========================================================================
// 函数功能:处理客户端的安全类型信息
// 输入参数:待交流的客户端cl
// 输出参数:
// 返回值    :
// 说明         : 只有3.7及其以上版本的server才会让cl选择安全类型
// =========================================================================void
void rfbProcessClientSecurityType(rfbClientPtr cl)
{
    int n;
    u8 chosenType;
    u32 authResult;
        /* Read the security type. */
    n = ReadExact(cl, (char *)&chosenType, 1);
    if (n <= 0) {
    if (n == 0)
        debug_printf("rfbProcessClientSecurityType: client gone\n");
    else
        debug_printf("rfbProcessClientSecurityType: read");
    rfbCloseClient(cl);
    return;
    }

    /* Make sure it was present in the list sent by the server. */
    switch (chosenType)
    {
        case rfbConnFailed:
            debug_printf("The client %s connfailed!\n",cl->host);
            cl->state = RFB_INITIALISATION;
            break;

        case rfbNoAuth:
            debug_printf("The client %s need no auth!\n",cl->host);
            //对于3.8版本仍然需要把结果返还回去
            if((cl->protocolMajorVersion==3)&&(cl->protocolMinorVersion>7))
            {
                authResult = Swap32IfLE(rfbVncAuthOK);
                if (WriteExact(cl, (char *)&authResult, 4) < 0) {
                    debug_printf("rfbAuthProcessClientMessage: write");
                    rfbCloseClient(cl);
                    break;
                }
            }
            cl->state = RFB_INITIALISATION;
            break;
        case rfbVncAuth:
            debug_printf("The client %s need vncauth!\n",cl->host);
            rfbVncAuthSendChallenge(cl);//发送挑战信息
            break;

        default:
            debug_printf("No supported security method--%d\n",chosenType);
            rfbCloseClient(cl);
            break;
    }

    return;
}