simon-git: putty (main): Simon Tatham
Commits to Tartarus hosted VCS
tartarus-commits at lists.tartarus.org
Fri Nov 19 15:42:30 GMT 2021
TL;DR:
efee4e0e Add some more bufchain_try_* functions.
be8d3974 Generalise strbuf_catf() into put_fmt().
cc6d3591 Marshalling macros put_dataz and put_datalit.
30148eee marshal.[ch]: remove redundant declaration.
05b5aa0b proxy.c: name the 'ProxySocket' pointer consistently.
1bf93289 Pull out SOCKS protocol constants into a header.
23c64fa0 Remove PROXY_CHANGE_{SENT,CLOSING,ACCEPTING}.
b7bf2aec Reorganise proxy system into coroutines.
02aa5610 Make ProxySocket an Interactor.
6354dba6 Support interactive password prompts in SOCKS 5.
d8ecba71 get_userpass_input: remove an obsolete FIXME.
Repository: https://git.tartarus.org/simon/putty.git
On the web: https://git.tartarus.org/?p=simon/putty.git
Branch updated: main
Committer: Simon Tatham <anakin at pobox.com>
Date: 2021-11-19 15:42:30
commit efee4e0eae8cc15fdb8614c022e67b9568d8a0cb
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=efee4e0eae8cc15fdb8614c022e67b9568d8a0cb;hp=4e93a2c1b89289f35894a61c158a29a69b033b17
Author: Simon Tatham <anakin at pobox.com>
Date: Fri Nov 19 10:21:40 2021 +0000
Add some more bufchain_try_* functions.
We already had bufchain_try_fetch_consume; now we also have
bufchain_try_fetch (for when you want to wait until that much data is
available but then not commit to removing it), and
bufchain_try_consume (so you can conveniently ignore a certain amount
of incoming data).
misc.h | 2 ++
utils/bufchain.c | 20 ++++++++++++++++++++
2 files changed, 22 insertions(+)
commit be8d3974ff7ccf3864d134722ff5b9ba611c1ed4
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=be8d3974ff7ccf3864d134722ff5b9ba611c1ed4;hp=efee4e0eae8cc15fdb8614c022e67b9568d8a0cb
Author: Simon Tatham <anakin at pobox.com>
Date: Fri Nov 19 10:23:32 2021 +0000
Generalise strbuf_catf() into put_fmt().
marshal.h now provides a macro put_fmt() which allows you to write
arbitrary printf-formatted data to an arbitrary BinarySink.
We already had this facility for strbufs in particular, in the form of
strbuf_catf(). That was able to take advantage of knowing the inner
structure of a strbuf to minimise memory allocation (it would snprintf
directly into the strbuf's existing buffer if possible). For a general
black-box BinarySink we can't do that, so instead we dupvprintf into a
temporary buffer.
For consistency, I've removed strbuf_catf, and converted all uses of
it into the new put_fmt - and I've also added an extra vtable method
in the BinarySink API, so that put_fmt can still use strbuf_catf's
more efficient memory management when talking to a strbuf, and fall
back to the simpler strategy when that's not available.
crypto/ecc-ssh.c | 4 +-
crypto/hmac.c | 12 +++---
crypto/rsa.c | 6 +--
keygen/pockle.c | 24 +++++------
marshal.h | 11 +++++
misc.h | 2 -
otherbackends/supdup.c | 26 +++++------
proxy/proxy.c | 4 +-
ssh/scpserver.c | 10 ++---
sshpubk.c | 44 +++++++++----------
testcrypt.c | 46 ++++++++++----------
unix/dialog.c | 14 +++---
unix/network.c | 8 ++--
unix/procnet.c | 4 +-
unix/storage.c | 2 +-
unix/unifont.c | 12 +++---
utils/antispoof.c | 2 +-
utils/buildinfo.c | 95 ++++++++++++++++++++---------------------
utils/marshal.c | 20 +++++++++
utils/strbuf.c | 26 +++++------
windows/pageant.c | 8 ++--
windows/storage.c | 2 +-
windows/utils/split_into_argv.c | 2 +-
windows/window.c | 26 +++++------
24 files changed, 217 insertions(+), 193 deletions(-)
commit cc6d3591adeb08bc03f579df168ca3f8efd5fe64
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=cc6d3591adeb08bc03f579df168ca3f8efd5fe64;hp=be8d3974ff7ccf3864d134722ff5b9ba611c1ed4
Author: Simon Tatham <anakin at pobox.com>
Date: Fri Nov 19 14:33:23 2021 +0000
Marshalling macros put_dataz and put_datalit.
When I wanted to append an ordinary C string to a BinarySink, without
any prefix length field or suffix terminator, I was using the idiom
put_datapl(bs, ptrlen_from_asciz(string));
but I've finally decided that's too cumbersome, and it deserves a
shorter name. put_dataz(bs, string) now does the same thing - in fact
it's a macro expanding to exactly the above.
While I'm at it, I've also added put_datalit(), which is the same
except that it expects a C string literal (and will enforce that at
compile time, via PTRLEN_LITERAL which it calls in turn). You can use
that where possible to avoid the run-time cost of the strlen.
marshal.h | 4 ++++
unix/plink.c | 2 +-
unix/storage.c | 4 ++--
utils/antispoof.c | 2 +-
utils/prompts.c | 2 +-
windows/dialog.c | 2 +-
windows/plink.c | 2 +-
7 files changed, 11 insertions(+), 7 deletions(-)
commit 30148eee6a5f6cdaa27a54e5376587c6a4693fd4
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=30148eee6a5f6cdaa27a54e5376587c6a4693fd4;hp=cc6d3591adeb08bc03f579df168ca3f8efd5fe64
Author: Simon Tatham <anakin at pobox.com>
Date: Fri Nov 19 13:13:23 2021 +0000
marshal.[ch]: remove redundant declaration.
Spotted this in passing while I was adding new functions in the same
area. That 'struct strbuf;' must have been there since before I
introduced defs.h to predeclare all the structure tag names and their
typedefs. But marshal.h includes defs.h itself, so it has no reason to
worry about the possibility that the typedef 'strbuf' might not
already exist.
marshal.h | 3 +--
utils/marshal.c | 2 +-
2 files changed, 2 insertions(+), 3 deletions(-)
commit 05b5aa0bb982bf6b4a36ef8585e415ebfa04ea0e
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=05b5aa0bb982bf6b4a36ef8585e415ebfa04ea0e;hp=30148eee6a5f6cdaa27a54e5376587c6a4693fd4
Author: Simon Tatham <anakin at pobox.com>
Date: Fri Nov 19 10:14:43 2021 +0000
proxy.c: name the 'ProxySocket' pointer consistently.
It's variously 'ps' and 'p' in functions that already receive one, and
it's 'ret' in the main function that initially constructs one. Let's
call it 'ps' consistently, so that the code idioms are the same
everywhere.
proxy/cproxy.c | 90 +++++++--------
proxy/proxy.c | 346 ++++++++++++++++++++++++++++-----------------------------
2 files changed, 218 insertions(+), 218 deletions(-)
commit 1bf93289c933e5f59f35d0c65a296750b4596ae5
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=1bf93289c933e5f59f35d0c65a296750b4596ae5;hp=05b5aa0bb982bf6b4a36ef8585e415ebfa04ea0e
Author: Simon Tatham <anakin at pobox.com>
Date: Fri Nov 19 10:33:57 2021 +0000
Pull out SOCKS protocol constants into a header.
This seemed like a worthwhile cleanup to do while I was working on
this code anyway. Now all the magic numbers are defined in a header
file by macro names indicating their meaning, and used by both the
SOCKS client code in the proxy subdirectory and the SOCKS server code
in portfwd.c.
proxy/cproxy.c | 25 ++++++++++----------
proxy/proxy.c | 75 +++++++++++++++++++++++++++++-----------------------------
proxy/socks.h | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
ssh/portfwd.c | 68 ++++++++++++++++++++++++++++------------------------
4 files changed, 160 insertions(+), 80 deletions(-)
commit 23c64fa00e1189be6e251d075e7f3a8cd68795b5
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=23c64fa00e1189be6e251d075e7f3a8cd68795b5;hp=1bf93289c933e5f59f35d0c65a296750b4596ae5
Author: Simon Tatham <anakin at pobox.com>
Date: Fri Nov 19 10:42:20 2021 +0000
Remove PROXY_CHANGE_{SENT,CLOSING,ACCEPTING}.
These were just boilerplate in all the proxy negotiation functions:
every negotiator had to contain a handler for each of these events,
and they all handled them in exactly the same way. Remove them and
centralise the handling in the shared code.
A long time ago, some of these event codes were added with purpose in
mind. PROXY_CHANGE_CLOSING was there to anticipate the possibility
that you might need to make multiple TCP connections to the proxy
server (e.g. retrying with different authentication) before
successfully getting a connection you could use to talk to the
ultimate destination. And PROXY_CHANGE_ACCEPTING was there so that we
could use the listening side of SOCKS (where you ask the proxy to open
a listening socket on your behalf). But neither of them has ever been
used, and now that the code has evolved, I think probably if we do
ever need to do either of those things then they'll want to be done
differently.
proxy/proxy.c | 142 ++--------------------------------------------------------
proxy/proxy.h | 11 -----
2 files changed, 4 insertions(+), 149 deletions(-)
commit b7bf2aec745a0b7c07c79ab48b28e20f0621206f
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=b7bf2aec745a0b7c07c79ab48b28e20f0621206f;hp=23c64fa00e1189be6e251d075e7f3a8cd68795b5
Author: Simon Tatham <anakin at pobox.com>
Date: Fri Nov 19 10:26:41 2021 +0000
Reorganise proxy system into coroutines.
Previously, the proxy negotiation functions were written as explicit
state machines, with ps->state being manually set to a sequence of
positive integer values which would be tested by if statements in the
next call to the same negotiation function.
That's not how this code base likes to do things! We have a coroutine
system to allow those state machines to be implicit rather than
explicit, so that we can use ordinary control flow statements like
while loops. Reorganised each proxy negotiation function into a
coroutine-based system like that.
While I'm at it, I've also moved each proxy negotiator out into its
own source file, to make proxy.c less overcrowded and monolithic. And
_that_ gave me the opportunity to define each negotiator as an
implementation of a trait rather than as a single function - which
means now each one can define its own local variables and have its own
cleanup function, instead of all of them having to share the variables
inside the main ProxySocket struct.
In the new coroutine system, negotiators don't have to worry about the
mechanics of actually sending data down the underlying Socket any
more. The negotiator coroutine just appends to a bufchain (via a
provided bufchain_sink), and after every call to the coroutine,
central code in proxy.c transfers the data to the Socket itself. This
avoids a lot of intermediate allocations within the negotiators, which
previously kept having to make temporary strbufs or arrays in order to
have something to point an sk_write() at; now they can just put
formatted data directly into the output bufchain via the marshal.h
interface.
In this version of the code, I've also moved most of the SOCKS5 CHAP
implementation from cproxy.c into socks5.c, so that it can sit in the
same coroutine as the rest of the proxy negotiation control flow.
That's because calling a sub-coroutine (co-subroutine?) is awkward to
set up (though it is _possible_ - we do SSH-2 kex that way), and
there's no real need to bother in this case, since the only thing that
really needs to go in cproxy.c is the actual cryptography plus a flag
to tell socks5.c whether to offer CHAP authentication in the first
place.
CMakeLists.txt | 7 +-
proxy/cproxy.c | 161 +---------
proxy/http.c | 158 +++++++++
proxy/nocproxy.c | 18 +-
proxy/proxy.c | 956 ++++---------------------------------------------------
proxy/proxy.h | 82 ++---
proxy/socks4.c | 136 ++++++++
proxy/socks5.c | 434 +++++++++++++++++++++++++
proxy/telnet.c | 246 ++++++++++++++
9 files changed, 1091 insertions(+), 1107 deletions(-)
commit 02aa5610dd16bbf688e0eb626e744bde061093a4
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=02aa5610dd16bbf688e0eb626e744bde061093a4;hp=b7bf2aec745a0b7c07c79ab48b28e20f0621206f
Author: Simon Tatham <anakin at pobox.com>
Date: Fri Nov 19 11:05:14 2021 +0000
Make ProxySocket an Interactor.
This lays all the groundwork for ProxyNegotiators to be able to issue
username and password prompts: ProxySocket now implements the
Interactor trait, it will borrow and return a Seat if one is
available, and it will present an Interactor of its own to the
ProxyNegotiator which can use it (via interactor_announce as usual) to
get a Seat to send prompts to. Also, proxy.c provides a centralised
system for making a prompts_t with an appropriate callback in it, and
dealing with the results of that callback.
No actual ProxyNegotiator implementation uses it yet, though.
proxy/proxy.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
proxy/proxy.h | 16 +++++++++++
2 files changed, 99 insertions(+), 7 deletions(-)
commit 6354dba6316e02add9d359e1bd1b12c93492a5b7
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=6354dba6316e02add9d359e1bd1b12c93492a5b7;hp=02aa5610dd16bbf688e0eb626e744bde061093a4
Author: Simon Tatham <anakin at pobox.com>
Date: Fri Nov 19 14:33:47 2021 +0000
Support interactive password prompts in SOCKS 5.
This is the first of the ProxyNegotiator implementations to use the
new interaction system. The other two both need more work than just
inserting a prompt and using the result.
proxy/socks5.c | 116 ++++++++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 90 insertions(+), 26 deletions(-)
commit d8ecba71b7b4186ab68bd1b5a9622a03d94a3d7b
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=d8ecba71b7b4186ab68bd1b5a9622a03d94a3d7b;hp=6354dba6316e02add9d359e1bd1b12c93492a5b7
Author: Simon Tatham <anakin at pobox.com>
Date: Fri Nov 19 15:23:34 2021 +0000
get_userpass_input: remove an obsolete FIXME.
I just spotted this in passing, and it's out of date! The prompts_t
system no longer works by consuming user input that had already been
handed to a backend, and it now has a callback that it can use to
proactively notify a backend (or other Interactor) that its prompts
have been answered. So if we did ever want to use a separate GUI
dialog box for prompts (as the comment suggested), then we do now have
the means.
putty.h | 10 ----------
1 file changed, 10 deletions(-)
More information about the tartarus-commits
mailing list