Граф коммитов

399 Коммитов

Автор SHA1 Сообщение Дата
Simon Tatham 7d394fc9e9 Stop sending release events for mouse wheel 'buttons' in X mouse mode.
On Windows (X mouse reporting of the mouse wheel isn't currently done
by the Unix front end, though I'm shortly about to fix that too) a
mouse wheel event is translated into a virtual button, and we send
both a press and a release of that button to terminal.c, which encodes
both in X mouse reporting escape sequences and passes them on to the
server. This isn't consistent with what xterm does - scroll-wheel
events are encoded _like_ button presses, but differ semantically in
that they don't have matching releases. So we're updating to match
xterm.

[originally from svn r10138]
2014-02-16 16:40:45 +00:00
Simon Tatham 5a5ef64a30 Support explicit IPv6 source addresses in Windows port forwarding.
There's been a long-standing FIXME in Windows's sk_newlistener which
says that in IPv6 mode, an explicit source address (e.g. from a
command-line option of the form -L srcaddr:12345:dest:22) is ignored.
Now it's honoured if possible.

[originally from svn r10122]
2014-01-25 15:58:59 +00:00
Simon Tatham 2b70f39061 Avoid misidentifying unbracketed IPv6 literals as host:port.
Both GUI PuTTY front ends have a piece of logic whereby a string is
interpreted as host:port if there's _one_ colon in it, but if there's
more than one colon then it's assumed to be an IPv6 literal with no
trailing port number. This permits the PuTTY command line to take
strings such as 'host', 'host:22' or '[::1]:22', but also cope with a
bare v6 literal such as '::1'.

This logic is also required in the two Plink front ends and in the
processing of CONF_loghost for host key indexing in ssh.c, but was
missing in all those places. Add it.

[originally from svn r10121]
2014-01-25 15:58:57 +00:00
Simon Tatham 8da4fa5063 Use the new host_str* functions to improve IPv6 literal support.
I've gone through everywhere we handle host names / addresses (on
command lines, in PuTTY config, in port forwarding, in X display
names, in host key storage...) and tried to make them handle IPv6
literals sensibly, by using the host_str* functions I introduced in my
previous commit. Generally it's now OK to use a bracketed IPv6 literal
anywhere a hostname might have been valid; in a few cases where no
ambiguity exists (e.g. no :port suffix is permitted anyway)
unbracketed IPv6 literals are also acceptable.

[originally from svn r10120]
2014-01-25 15:58:54 +00:00
Jacob Nevins bd119b1fba It's a new year.
[originally from svn r10114]
2014-01-15 23:57:54 +00:00
Simon Tatham c0f7178f63 Rename the handle-type enumeration values.
Mike Edenfield points out that modern versions of the Windows SDK have
decided that 'INPUT' is a sensible name for an OS data structure
(sigh), and provided a patch to add a disambiguating prefix to
winhandl.c's enum values INPUT, OUTPUT and FOREIGN.

[originally from svn r10109]
2014-01-07 23:26:10 +00:00
Simon Tatham 163b899df2 Switch to using SIDs in make_private_security_descriptor().
Daniel Meidlinger reports that at least one Windows machine which is
not obviously otherwise misconfigured will respond to our
SetEntriesInAcl call with odd errors like ERROR_NONE_MAPPED or
ERROR_TRUSTED_RELATIONSHIP_FAILURE. This is apparently to do with
failure to convert the names "EVERYONE" and "CURRENT_USER" used in the
ACL specification to SIDs. (Or perhaps only one of them is the problem
- I didn't investigate in that direction.)

If we instead construct a fully SID-based ACL, using the well-known
world SID in place of EVERYONE and calling our existing get_user_sid
routine in place of CURRENT_USER, he reports that the problem goes
away, so let's do that instead.

While I'm here, I've slightly simplified the function prototype of
make_private_security_descriptor(), by turning 'networksid' into an
internal static that we can reuse in subsequent calls once we've set
it up. (Mostly because I didn't fancy adding another two pointless
parameters at every call site for the two new SIDs.)

[originally from svn r10096]
2013-11-25 18:35:14 +00:00
Simon Tatham b7a703d38c Remove an unused variable orphaned by r10092.
[originally from svn r10095]
[r10092 == d1e4f9c8fb]
2013-11-23 16:54:51 +00:00
Simon Tatham 9803b6acb0 SetEntriesInAcl returns its error code directly.
According to the MSDN documentation, that is. Why oh why? Everything
_else_ leaves it in GetLastError().

[originally from svn r10094]
2013-11-22 19:41:49 +00:00
Simon Tatham df328536a9 Pass the right number of entries to SetEntriesInAcl!
[originally from svn r10093]
2013-11-22 19:41:45 +00:00
Simon Tatham d1e4f9c8fb Include the numeric error code in win_strerror's output.
This will be useful if someone gets a mysterious Windows error on a
system configured into a language we don't speak - if they cut and
paste the error message to send to us, then we won't have to try to
translate it.

[originally from svn r10092]
2013-11-22 19:41:43 +00:00
Jacob Nevins 98eb785c9b Fix up the Windows help context stuff for the new connection sharing controls.
[originally from svn r10088]
2013-11-18 22:34:57 +00:00
Simon Tatham e43b6203ec Gracefully degrade in the absence of CryptProtectMemory.
XP doesn't have it, and I think having connection sharing work without
its privacy enhancement is better than having it not work at all.

[originally from svn r10087]
2013-11-18 19:07:58 +00:00
Simon Tatham bb78583ad2 Implement connection sharing between instances of PuTTY.
The basic strategy is described at the top of the new source file
sshshare.c. In very brief: an 'upstream' PuTTY opens a Unix-domain
socket or Windows named pipe, and listens for connections from other
PuTTYs wanting to run sessions on the same server. The protocol spoken
down that socket/pipe is essentially the bare ssh-connection protocol,
using a trivial binary packet protocol with no encryption, and the
upstream has to do some fiddly transformations that I've been
referring to as 'channel-number NAT' to avoid resource clashes between
the sessions it's managing.

This is quite different from OpenSSH's approach of using the Unix-
domain socket as a means of passing file descriptors around; the main
reason for that is that fd-passing is Unix-specific but this system
has to work on Windows too. However, there are additional advantages,
such as making it easy for each downstream PuTTY to run its own
independent set of port and X11 forwardings (though the method for
making the latter work is quite painful).

Sharing is off by default, but configuration is intended to be very
easy in the normal case - just tick one box in the SSH config panel
and everything else happens automatically.

[originally from svn r10083]
2013-11-17 14:05:41 +00:00
Simon Tatham f6f78f8355 Move the dynamic loading of advapi into its own module.
There's now a winsecur.[ch], which centralises helper functions using
the Windows security stuff in advapi.h (currently just get_user_sid),
and also centralises the run-time loading of those functions and
checking they're all there.

[originally from svn r10082]
2013-11-17 14:05:29 +00:00
Simon Tatham 8be6fbaa09 Remove sk_{get,set}_private_ptr completely!
It was only actually used in X11 and port forwarding, to find internal
state structures given only the Socket that ssh.c held. So now that
that lookup has been reworked to be the sensible way round,
private_ptr is no longer used for anything and can be removed.

[originally from svn r10075]
2013-11-17 14:04:48 +00:00
Simon Tatham 1b3edafcff Add support for Windows named pipes.
This commit adds two new support modules, winnpc.c and winnps.c, which
deal respectively with being a client and server of a Windows named
pipe (which, in spite of what Unix programmers will infer from that
name, is actually closer to Windows's analogue of a Unix-domain
socket). Each one provides a fully featured Socket wrapper around the
hairy Windows named pipe API, so that the rest of the code base should
be able to use these interchangeably with ordinary sockets and hardly
notice the difference.

As part of this work, I've introduced a mechanism in winhandl.c to
permit it to store handles of event objects on behalf of other Windows
support modules and deal with passing them to applications' main event
loops as necessary. (Perhaps it would have been cleaner to split
winhandl.c into an event-object tracking layer analogous to uxsel, and
the handle management which is winhandl.c's proper job, but this is
less disruptive for the present.)

[originally from svn r10069]
2013-11-17 14:04:01 +00:00
Simon Tatham 19fba3fe55 Replace the hacky 'OSSocket' type with a closure.
The mechanism for constructing a new connection-type Socket when a
listening one receives an incoming connection previously worked by
passing a platform-specific 'OSSocket' type to the plug_accepting
function, which would then call sk_register to wrap it with a proper
Socket instance. This is less flexible than ideal, because it presumes
that only one kind of OS object might ever need to be turned into a
Socket. So I've replaced OSSocket throughout the code base with a pair
of parameters consisting of a function pointer and a context such that
passing the latter to the former returns the appropriate Socket; this
will permit different classes of listening Socket to pass different
function pointers.

In deference to the reality that OSSockets tend to be small integers
or pointer-sized OS handles, I've made the context parameter an
int/pointer union that can hold either of those directly, rather than
the usual approach of making it a plain 'void *' and requiring a
context structure to be dynamically allocated every time.

[originally from svn r10068]
2013-11-17 14:03:55 +00:00
Simon Tatham 9093071faa Implement freezing on Windows handle sockets.
That's been a FIXME in the code for ages, because it's difficult to
get winhandl.c to stop an already-started read from a handle (since
the read is a blocking system call running in a separate thread). But
I now realise it isn't absolutely necessary to do so - you can just
buffer one lot of data from winhandl and _then_ tell it to stop.

[originally from svn r10067]
2013-11-17 14:03:48 +00:00
Simon Tatham 98a6a3553c Factor out the HANDLE-to-Socket adapter from winproxy.c.
It's now kept in a separate module, where it can be reused
conveniently for other kinds of Windows HANDLE that I want to wrap in
the PuTTY Socket abstraction - for example, the named pipes that I
shortly plan to use for the Windows side of connection-sharing IPC.

[originally from svn r10066]
2013-11-17 14:03:44 +00:00
Simon Tatham c4833bae5a Find ToUnicodeEx() at run time, not load time.
This restores PuTTY's backward compatibility to versions of Windows
too old to have ToUnicodeEx in their system libraries, which was
accidentally broken in 0.63.

[originally from svn r10061]
2013-11-17 14:03:20 +00:00
Simon Tatham 94fd7bbf94 Replace GetQueueStatus with PeekMessage(PM_NOREMOVE).
A couple of users report that my recent reworking of the Windows
top-level message loop has led to messages occasionally being lost,
and MsgWaitForMultipleObjects blocking when it ought to have been
called with a zero timeout. I haven't been able to reproduce this
myself, but according to one reporter, PeekMessage(PM_NOREMOVE) is
effective at checking for a non-empty message queue in a way that
GetQueueStatus is not. Switch to using that instead. Thanks to Eric
Flumerfelt for debugging and testing help.

[originally from svn r10057]
2013-11-11 23:01:47 +00:00
Simon Tatham 0e233b0d87 Avoid leaving unread Windows messages in the queue.
Jochen Erwied points out that once you've used PeekMessage to remove
_one_ message from the message queue, MsgWaitForMultipleObjects will
consider the whole queue to have been 'read', or at least looked at
and deemed uninteresting, and so it will block until a further message
comes in. Hence, my change in r10040 which stops us from looping on
PeekMessage until the queue is empty has the effect of causing the
rest of the message queue not to be acted on until a new message comes
in to unblock it. Fix by checking if the queue is nonempty in advance
of calling MsgWaitForMultipleObjects, and if so, giving it a zero
timeout just as we do if there's a pending toplevel callback.

[originally from svn r10052]
[r10040 == 5c4ce2fadf]
2013-10-25 17:44:02 +00:00
Simon Tatham 2ca13fa995 Don't pass WinSock error codes to strerror.
Martin Prikryl helpfully points out that when I revamped the socket
error mechanism using toplevel callbacks, I also accidentally passed
the error code to the wrong function. Use winsock_error_string instead.

[originally from svn r10048]
2013-10-09 18:36:56 +00:00
Simon Tatham 7223973988 Fix cut-and-paste errors in nonfatal() implementations.
Unix GUI programs should not say 'Fatal Error' in the message box
title, and Plink should not destroy its logging context as a side
effect of printing a non-fatal error. Both appear to have been due to
inattentive cut and paste from the pre-existing fatal error functions.

[originally from svn r10044]
2013-09-23 14:35:08 +00:00
Simon Tatham 5c4ce2fadf Only run one toplevel callback per event loop iteration.
This change attempts to reinstate as a universal property something
which was sporadically true of the ad-hockery that came before
toplevel callbacks: that if there's a _very long_ queue of things to
be done through the callback mechanism, the doing of them will be
interleaved with re-checks of other event sources, which might (e.g.)
cause a flag to be set which makes the next callback decide not to do
anything after all.

[originally from svn r10040]
2013-09-15 14:05:31 +00:00
Simon Tatham 4db5c2899f Make calling term_nopaste() a cross-platform feature.
It was one of those things that went in ages ago on Windows and never
got replicated in the Unix front end. And it needn't be: ldisc.c is a
perfect place to put it, since it knows which of the data it's sending
is based on a keystroke and which is automatically generated, and it
also has access to the terminal context. So now a keypress can
interrupt a runaway paste on all platforms.

[originally from svn r10025]
2013-08-17 16:06:40 +00:00
Simon Tatham 9d5903b163 Revamp Windows pending_netevent using toplevel callbacks.
This greatly simplifies the process of calling select_result() from
the top level after receiving WM_NETEVENT.

[originally from svn r10024]
2013-08-17 16:06:35 +00:00
Simon Tatham d35a41f6ba Revamp net_pending_errors using toplevel callbacks.
Again, I've removed the special-purpose ad-hockery from the assorted
front end message loops that dealt with deferred handling of socket
errors, and instead uxnet.c and winnet.c arrange that for themselves
by calling the new general top-level callback mechanism.

[originally from svn r10023]
2013-08-17 16:06:27 +00:00
Simon Tatham 43c9748ac9 Revamp Windows's close_session() using toplevel callbacks.
Instead of setting a must_close_session flag and having special code
in the message loop to check it, we'll schedule the call to
close_session using the new top-level callback system.

[originally from svn r10021]
2013-08-17 16:06:18 +00:00
Simon Tatham 7be9af74ec Revamp the terminal paste mechanism using toplevel callbacks.
I've removed the ad-hoc front-end bodgery in the Windows and GTK ports
to arrange for term_paste to be called at the right moments, and
instead, terminal.c itself deals with knowing when to send the next
chunk of pasted data using a combination of timers and the new
top-level callback mechanism.

As a happy side effect, it's now all in one place so I can actually
understand what it's doing! It turns out that what all that confusing
code was up to is: send a line of pasted data, and delay sending the
next line until either a CR or LF is returned from the server
(typically indicating that the pasted text has been received and
echoed) or 450ms elapse, whichever comes first.

[originally from svn r10020]
2013-08-17 16:06:12 +00:00
Simon Tatham 75c79e318f Add a general way to request an immediate top-level callback.
This is a little like schedule_timer, in that the callback you provide
will be run from the top-level message loop of whatever application
you're in; but unlike the timer mechanism, it will happen
_immediately_.

The aim is to provide a general way to avoid re-entrance of code, in
cases where just _doing_ the thing you want done is liable to trigger
a confusing recursive call to the function in which you came to the
decision to do it; instead, you just request a top-level callback at
the message loop's earliest convenience, and do it then.

[originally from svn r10019]
2013-08-17 16:06:08 +00:00
Simon Tatham 95f581339d Bump version number prior to tagging 0.63.
[originally from svn r9998]
2013-08-06 17:09:07 +00:00
Jacob Nevins 0cc6fb8bfe Belatedly update the copyright year to 2013.
[originally from svn r9993]
[this svn revision also touched putty-website]
2013-08-05 15:15:17 +00:00
Simon Tatham ba49faec3d Reinstate a piece of code accidentally removed in r9214, where Windows
PuTTY does not trim a colon suffix off the hostname if it contains
_more than one_ colon. This allows IPv6 literals to be entered.

(Really we need to do a much bigger revamp of all uses of hostnames to
arrange that square-bracketed IPv6 literals work consistently, but
this at least removes a regression over 0.62.)

[originally from svn r9983]
[r9214 == a1f3b7a358]
2013-08-04 19:32:10 +00:00
Simon Tatham 808df44e54 Add an assortment of missing consts I've just noticed.
[originally from svn r9972]
2013-07-27 18:35:48 +00:00
Simon Tatham a5fd6ad272 Get rid of the variable 'advapi' in Pageant's WinMain, which was never
actually used for anything sensible and could have been freed while
containing nonsense at program end.

[originally from svn r9971]
2013-07-24 19:18:06 +00:00
Simon Tatham 6ede5c473a Back out r9964. I wasn't paying attention: every control is in the
byid tree but not all of them are in the byctrl tree.

[originally from svn r9970]
[r9964 == b3afa10aa7]
2013-07-22 19:56:04 +00:00
Simon Tatham eb19a35a3d Fix a few more memory and resource leaks.
[originally from svn r9968]
2013-07-22 19:55:55 +00:00
Simon Tatham e5d3a353cc Remove the variable 'bufused', which came over from winnet.c in
mistaken cut and paste and is just a bug.

[originally from svn r9967]
2013-07-22 19:55:53 +00:00
Simon Tatham 5e2c794424 Increase FONT_MAXNO from 0x2f to 0x40, to ensure the fonts[] array
includes every possible combination of the font bitfields, in
particular ATTR_OEM|ATTR_NARROW.

[originally from svn r9966]
2013-07-22 07:12:31 +00:00
Simon Tatham 81a11efdaf Correct an inequality sign causing the bounds check in Windows
palette_set() to be bogus. Fortunately, this isn't exploitable through
the terminal emulator, because the palette escape sequence parser
contains its own bounds check before even calling palette_set().

While I'm at it, fix the same goof in the OS X version! That port is
more or less abandoned, but that's no excuse for leaving obviously
wrong code lying around.

[originally from svn r9965]
2013-07-22 07:12:26 +00:00
Simon Tatham b3afa10aa7 Missing assert.
[originally from svn r9964]
2013-07-22 07:12:21 +00:00
Simon Tatham 0a26bd74e1 Replace the type-checking COMPTR macro with my current idea of best
practice in type-check macros.

[originally from svn r9963]
2013-07-22 07:12:15 +00:00
Simon Tatham 353b85be67 Add missing casts in arguments to ctype functions.
[originally from svn r9962]
2013-07-22 07:12:10 +00:00
Simon Tatham 61e555ec79 Rationalise null pointer checks in both decode_codepage functions, so
that decode_codepage(NULL) and decode_codepage("") both return the
default character set.

[originally from svn r9961]
2013-07-22 07:12:05 +00:00
Simon Tatham f9f93584c2 Fix a double error handling goof in the winstore side of the jump list
support: transform_jumplist_registry should give its caller
dynamically allocated data if and only if it returns JUMPLISTREG_OK,
and get_jumplist_registry_entries should test the return value against
JUMPLISTREG_OK rather than a value from a totally different enum.

[originally from svn r9960]
2013-07-22 07:11:58 +00:00
Simon Tatham b99bec3b02 Another big batch of memory leak fixes, again mostly on error paths.
The most interesting one is printer_add_enum, which I've modified to
take a char ** rather than a char * so that it can both realloc its
input buffer _and_ return NULL to indicate error.

[originally from svn r9959]
2013-07-22 07:11:54 +00:00
Simon Tatham 4c61cb20a1 Add a missing null pointer check in one of the dialog box functions.
[originally from svn r9958]
2013-07-22 07:11:48 +00:00
Simon Tatham 888804eef7 Report an error if deleting a random seed file fails.
(This has also required me to add a currently unused nonfatal() to
PuTTYgen, since although PuTTYgen won't actually try to delete
putty.rnd, it does link in winstore.c as a whole.)

[originally from svn r9957]
2013-07-22 07:11:44 +00:00