static Bool PerformAuthenticationTight(void) { rfbAuthenticationCapsMsg caps; CARD32 authScheme; int i; /* In the protocol version 3.7t, the server informs us about supported authentication schemes. Here we read this information. */ if (!ReadFromRFBServer((char *)&caps, sz_rfbAuthenticationCapsMsg)) return False; caps.nAuthTypes = Swap32IfLE(caps.nAuthTypes); if (!caps.nAuthTypes) { fprintf(stderr, "No authentication needed\n"); return True; } if (!ReadCapabilityList(authCaps, caps.nAuthTypes)) return False; /* Prefer Unix login authentication if a user name was given. */ if (appData.userLogin && CapsIsEnabled(authCaps, rfbAuthUnixLogin)) { authScheme = Swap32IfLE(rfbAuthUnixLogin); if (!WriteExact(rfbsock, (char *)&authScheme, sizeof(authScheme))) return False; return AuthenticateUnixLogin(); } /* Otherwise, try server's preferred authentication scheme. */ for (i = 0; i < CapsNumEnabled(authCaps); i++) { authScheme = CapsGetByOrder(authCaps, i); if (authScheme != rfbAuthUnixLogin && authScheme != rfbAuthVNC) continue; /* unknown scheme - cannot use it */ authScheme = Swap32IfLE(authScheme); if (!WriteExact(rfbsock, (char *)&authScheme, sizeof(authScheme))) return False; authScheme = Swap32IfLE(authScheme); /* convert it back */ if (authScheme == rfbAuthUnixLogin) { return AuthenticateUnixLogin(); } else if (authScheme == rfbAuthVNC) { return AuthenticateVNC(); } else { /* Should never happen. */ fprintf(stderr, "Assertion failed: unknown authentication scheme\n"); return False; } } fprintf(stderr, "No suitable authentication schemes offered by server\n"); return False; }
static Bool PerformAuthenticationTight(void) { rfbAuthenticationCapsMsg caps; CARD32 authScheme; int i; /* In protocols 3.7t/3.8t, the server informs us about supported authentication schemes. Here we read this information. */ if (!ReadFromRFBServer((char *)&caps, sz_rfbAuthenticationCapsMsg)) return False; caps.nAuthTypes = Swap32IfLE(caps.nAuthTypes); /* Special case - empty capability list stands for no authentication. */ if (!caps.nAuthTypes) return AuthenticateNone(); if (!ReadCapabilityList(authCaps, caps.nAuthTypes)) return False; /* Try server's preferred authentication scheme. */ for (i = 0; i < CapsNumEnabled(authCaps); i++) { authScheme = CapsGetByOrder(authCaps, i); if (authScheme != rfbAuthVNC && authScheme != rfbAuthNone) continue; /* unknown scheme - cannot use it */ authScheme = Swap32IfLE(authScheme); if (!WriteExact(rfbsock, (char *)&authScheme, sizeof(authScheme))) return False; authScheme = Swap32IfLE(authScheme); /* convert it back */ switch (authScheme) { case rfbAuthNone: return AuthenticateNone(); case rfbAuthVNC: return AuthenticateVNC(); default: /* should never happen */ fprintf(stderr, "Internal error: Invalid authentication type\n"); return False; } } fprintf(stderr, "No suitable authentication schemes offered by server\n"); return False; }