From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f42.google.com ([209.85.128.42]) by ewsd; Tue Sep 22 14:25:39 EDT 2020 Received: by mail-wm1-f42.google.com with SMTP id a9so4365427wmm.2 for <9front@9front.org>; Tue, 22 Sep 2020 11:25:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-transfer-encoding; bh=Ic0abkbfrVny793IsJ2fnjUE3RTj4m1ehWMwt9k9I1E=; b=iPe1YfBjOWFG8/g6N1wGiCkB8Oq4JvSGG9+6bwak7YyHVT4Zba99pblVvHQ3eSZW73 hFHZgqfs0B+jayVRrksCOCt/yfCYo47C34MUdtqiY79NhOWMY0N0gr1kvxiBp6I5RkuC AInmDKE40G6T5kUgH2qtoMW4D8l2Hfe8qUmcddoVC8tOkzLdTc89iN+HPaBbQCsZqCMk KHR9GGfxFZNo3oBWwIK3eGgR/nz3SaoQSxFlfT5d4URcbKLSBi1inYprvEhf7HAU+Wzo Fi8xJo2v/Erh+u0f+F350SB9r25rGBtNBMP0K731Oca3FLKc+H6G0uLJu5gz8gfCkWzK 4yYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-transfer-encoding; bh=Ic0abkbfrVny793IsJ2fnjUE3RTj4m1ehWMwt9k9I1E=; b=hYpF9Vn1hEHVlkznrnSgirJQoxAsfN5iylIXF6DtJkcXtqKN8ZWizFtVnTUkpfXHN9 Z2zoP2XudXJ9JpB9yorzVBijD7mbCsO0No9n+Y391yHKvoJxnF+GSFmOfu1S0Nl/9H/h QRu5ifDSpGDL1apduqu4EyrvTabBUQA50n/KI576D5m9tHRah79BGo5T5J1E+2n6YbCt AdjkiYORiWtDYFl6FIZFqQiRZGGL4AebH5Xuk13JtHuBPX7cHF28uZNzibEyUwMpTTTO j/GnqXFeNX/itquoDu512DwbF38564GPrz6f/chlyEsD/2BSpLJnL1BcavLjwIYHcPSG CE8A== X-Gm-Message-State: AOAM532emVHCUKg8gnkK1EiKcvwpHtOEzbQOWLP8xKsX0i0Ljk3DPBUw puQ+GvBCIvbG5TeP8Re7Q8f7NSAO7CpDh+5CCeAwichrvuE= X-Google-Smtp-Source: ABdhPJwItSnd7HT6z4xHz7Qqr7A0qZOg0SEyOs+lPKUZYhs8U6rED7OAcf60HWr+TSTUEC9ONqCyRT39KOVSz5Hyu1g= X-Received: by 2002:a1c:2042:: with SMTP id g63mr2339062wmg.174.1600799134768; Tue, 22 Sep 2020 11:25:34 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: =?UTF-8?Q?Iruat=C3=A3_Souza?= Date: Tue, 22 Sep 2020 20:25:23 +0200 Message-ID: Subject: Re: vncv(1): support for RFB 3.8 To: 9front@9front.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: optimized patented pipelining software-oriented scripting layer Hi, Did anyone try this? kvik? On Mon, Jun 22, 2020 at 7:37 PM Iruat=C3=A3 Souza wro= te: > > Hi, > > The following patch adds support for RFB 3.8 in vncv(1). > It has been tested by connecting to a screen shared by gnome3 on > linux. Please let me know if it introduces any regressions. > > diff -r 19baa5600a90 sys/man/1/vnc > --- a/sys/man/1/vnc Mon Apr 06 01:31:35 2020 +0200 > +++ b/sys/man/1/vnc Mon Jun 22 19:25:55 2020 +0200 > @@ -204,6 +204,3 @@ > .I Vncv > does no verification of the TLS certificate presented > by the server. > -.PP > -.I Vncv > -supports only version 3.3 of the RFB protocol. > diff -r 19baa5600a90 sys/src/cmd/vnc/auth.c > --- a/sys/src/cmd/vnc/auth.c Mon Apr 06 01:31:35 2020 +0200 > +++ b/sys/src/cmd/vnc/auth.c Mon Jun 22 19:25:55 2020 +0200 > @@ -9,14 +9,16 @@ > VerLen =3D 12 > }; > > -static char version[VerLen+1] =3D "RFB 003.003\n"; > +static char version33[VerLen+1] =3D "RFB 003.003\n"; > +static char version38[VerLen+1] =3D "RFB 003.008\n"; > +static int srvversion; > > int > vncsrvhandshake(Vnc *v) > { > char msg[VerLen+1]; > > - strecpy(msg, msg+sizeof msg, version); > + strecpy(msg, msg+sizeof msg, version33); > if(verbose) > fprint(2, "server version: %s\n", msg); > vncwrbytes(v, msg, VerLen); > @@ -35,18 +37,51 @@ > > msg[VerLen] =3D 0; > vncrdbytes(v, msg, VerLen); > - if(strncmp(msg, "RFB ", 4) !=3D 0){ > + if(strncmp(msg, "RFB 003.", 8) !=3D 0) { > werrstr("bad rfb version \"%s\"", msg); > return -1; > } > + if(strncmp(msg, "RFB 003.008\n", VerLen) =3D=3D 0) > + srvversion =3D 38; > + else > + srvversion =3D 33; > + > if(verbose) > fprint(2, "server version: %s\n", msg); > - strcpy(msg, version); > + strcpy(msg, version38); > vncwrbytes(v, msg, VerLen); > vncflush(v); > return 0; > } > > +ulong > +sectype38(Vnc *v) > +{ > + ulong auth, type; > + int i, ntypes; > + > + ntypes =3D vncrdchar(v); > + if (ntypes =3D=3D 0) { > + werrstr("no security types from server"); > + return AFailed; > + } > + > + /* choose the "most secure" security type */ > + auth =3D AFailed; > + for (i =3D 0; i < ntypes; i++) { > + type =3D vncrdchar(v); > + if(verbose){ > + fprint(2, "auth type %s\n", > + type =3D=3D AFailed ? "Invalid" : > + type =3D=3D ANoAuth ? "None" : > + type =3D=3D AVncAuth ? "VNC" : "Unknown"); > + } > + if(type > auth) > + auth =3D type; > + } > + return auth; > +} > + > int > vncauth(Vnc *v, char *keypattern) > { > @@ -56,7 +91,9 @@ > > if(keypattern =3D=3D nil) > keypattern =3D ""; > - auth =3D vncrdlong(v); > + > + auth =3D srvversion =3D=3D 38 ? sectype38(v) : vncrdlong(v); > + > switch(auth){ > default: > werrstr("unknown auth type 0x%lux", auth); > @@ -65,6 +102,7 @@ > return -1; > > case AFailed: > + failed: > reason =3D vncrdstring(v); > werrstr("%s", reason); > if(verbose) > @@ -72,11 +110,20 @@ > return -1; > > case ANoAuth: > + if(srvversion =3D=3D 38){ > + vncwrchar(v, auth); > + vncflush(v); > + } > if(verbose) > fprint(2, "no auth needed\n"); > break; > > case AVncAuth: > + if(srvversion =3D=3D 38){ > + vncwrchar(v, auth); > + vncflush(v); > + } > + > vncrdbytes(v, chal, VncChalLen); > if(auth_respond(chal, VncChalLen, nil, 0, chal, VncChalLen, > auth_getkey, > "proto=3Dvnc role=3Dclient server=3D%s %s", serveraddr, > keypattern) !=3D VncChalLen){ > @@ -84,13 +131,20 @@ > } > vncwrbytes(v, chal, VncChalLen); > vncflush(v); > + break; > + } > > - auth =3D vncrdlong(v); > + /* in version 3.8 the auth status is always sent, in 3.3 only in > AVncAuth */ > + if(srvversion =3D=3D 38 || auth =3D=3D AVncAuth){ > + auth =3D vncrdlong(v); /* auth status */ > switch(auth){ > default: > werrstr("unknown server response 0x%lux", auth); > return -1; > case VncAuthFailed: > + if (srvversion =3D=3D 38) > + goto failed; > + > werrstr("server says authentication failed"); > return -1; > case VncAuthTooMany: > @@ -99,7 +153,6 @@ > case VncAuthOK: > break; > } > - break; > } > return 0; > }