static int vncstart(Vnc *v, int shared) { vncwrchar(v, shared); vncflush(v); v->dim = vncrdpoint(v); v->Pixfmt = vncrdpixfmt(v); v->name = vncrdstring(v); return 0; }
int vncauth(Vnc *v, char *keypattern) { char pw[128], *reason; uint8_t chal[VncChalLen]; uint32_t auth; char *p, *server; if(keypattern == nil) keypattern = ""; auth = vncrdlong(v); switch(auth){ default: werrstr("unknown auth type 0x%lux", auth); if(verbose) fprint(2, "unknown auth type 0x%lux", auth); return -1; case AFailed: reason = vncrdstring(v); werrstr("%s", reason); if(verbose) fprint(2, "auth failed: %s\n", reason); return -1; case ANoAuth: if(verbose) fprint(2, "no auth needed"); break; case AVncAuth: vncrdbytes(v, chal, VncChalLen); server = strdup(serveraddr); p = strrchr(server, ':'); if(p) *p = 0; if(auth_respond(chal, VncChalLen, nil, 0, chal, VncChalLen, auth_getkey, "proto=vnc role=client server=%s %s", server, keypattern) != VncChalLen){ /* BUG This is for drawterm users who don't start their own factotums */ readln("password: "******"unknown server response 0x%lux", auth); return -1; case VncAuthFailed: werrstr("server says authentication failed"); return -1; case VncAuthTooMany: werrstr("server says too many tries"); return -1; case VncAuthOK: break; } break; } return 0; }