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

676 Коммитов

Автор SHA1 Сообщение Дата
Simon Tatham e4c4bd2092 Fix an annoying warning from GTK on Ubuntu 14.04.
Timer objects evaporate when our timer_trigger callback is called, and
therefore we should not remember their ids beyond that time and
attempt to cancel them later. Previous versions of GTK silently
ignored us doing that, but upgrading to Ubuntu Trusty has given me a
version of GTK that complains about it, so let's stop doing it.

[originally from svn r10181]
2014-04-20 16:48:18 +00:00
Simon Tatham a947c49bec Move the Unix configure script up to the top level.
Previously, 'configure' and its assorted machinery lived in the 'unix'
subdir, because that seemed like a clean place to keep it given that
all the other per-platform Makefiles live in their platform
directories. However, this never sat all that happily with autotools,
and even less so now that it likes to have object file pathnames
parallel source file pathnames: if you have Makefile.am refer to
source files outside its subdir as "../terminal.c" and enable
subdir-objects then any out-of-tree build calls the corresponding
object file "../terminal.o" and so your build products mostly end up
at the directory above your build dir! And as of autotools 1.14 my
previous compensatory bodge of prefixing every source file path in
Makefile.am with "$(srcdir)" has stopped working too.

So I'm giving in to necessity, and changing policy by moving the
configure machinery up to the top level of the source tree where
autotools will be less confused by it. This should not be taken as any
indication of the primacy of the Unix port, only of the recalcitrance
of autotools.

Whereas before we had a trivial script called 'configure' at the top
level that invoked unix/configure to effectively do an 'out-of-tree
build' (for make purposes) at the top level of the source tree, we now
have a similar script in unix/configure. So this _should_ make very
little difference: people who were previously running configure from
the top level should still be able to, and likewise people who were
running it from the unix subdir.

[originally from svn r10141]
2014-02-22 18:01:32 +00:00
Simon Tatham f272ea88db Enable xterm mouse reporting of wheel actions in GTK.
I had somehow missed this completely out of the GTK mouse-button
handling and never noticed until now!

Of course, like any other mouse action, if you want it to be handled
locally rather than passed through then you can hold down Shift.

[originally from svn r10139]
2014-02-16 16:40:46 +00:00
Simon Tatham 0f04cab151 Revert half of r10135, and re-fix properly.
One of my changes in uxnet.c was outside the NO_IPV6 ifdef, and broke
compilation in the normal mode. Revert all changes in that file and
replace with a reference to the 'step' parameter in the no-IPv6
version of the SOCKADDR_FAMILY macro, so that those warnings are
squelched anyway.

[originally from svn r10136]
[r10135 == e00a004e64]
2014-02-05 21:51:25 +00:00
Simon Tatham e00a004e64 Fix warnings when compiling with -DNO_IPV6.
A user pointed out that 'family' was uninitialised in config.c, and
when I tried test-building with -DNO_IPV6 (and the usual -Werror, of
course) some unused variables showed up in uxnet.c too.

[originally from svn r10135]
2014-02-04 22:37:53 +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 df1eee6027 Make GTK idle and quit function setup idempotent.
I found last week that when a local proxy process terminated
unexpectedly, Unix PuTTY went into a tight loop calling quit
functions, because if idle_toplevel_callback_func is called from
inside a subsidiary gtk_main then it will schedule a quit function and
_not_ disable itself, so that that quit function keeps being
rescheduled on subsequent calls.

To fix, I've tried to make the whole handling of idle and quit
functions more sensibly robust: we keep our own boolean flag
indicating whether each of our functions has already been scheduled
with GTK, and if so, we don't schedule the same one again. Also, when
idle_toplevel_callback_func schedules a quit function, it should
unschedule itself since it's now done everything it can until a
gtk_main instance quits.

[originally from svn r10100]
2013-11-30 18:04:57 +00:00
Simon Tatham b12fbeffd6 Restore compatibility with older autoconfs.
The one in Ubuntu 10.04 doesn't know what AM_PROG_AR means, so
configure.ac was broken in r10053 when fixing compatibility with later
versions; you can't win...

[originally from svn r10086]
[r10053 == 2d9cc79d53]
2013-11-18 19:07:11 +00:00
Simon Tatham 85d1e7608e Fix an assortment of dupprintf() format string bugs.
I've enabled gcc's format-string checking on dupprintf, by declaring
it in misc.h to have the appropriate GNU-specific attribute. This
pointed out a selection of warnings, which I've fixed.

[originally from svn r10084]
2013-11-17 14:05:44 +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 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 489590cbd4 Reliably initialise uxnet's socket fd fields to -1.
This prevents embarrassing mess-ups involving getting back a Socket
which has mostly been memset to 0 but contains an error message,
sk_close()ing it to free the memory, and finding that standard input
has been closed as a side effect.

[originally from svn r10073]
2013-11-17 14:04:33 +00:00
Simon Tatham 6f6e9db932 Add support in uxnet.c for Unix-domain listening sockets.
There are two new functions: one to construct a SockAddr wrapping a
Unix socket pathname (which can also be used as the destination for
new_connection), and one to establish a new listening Unix-domain
socket.

[originally from svn r10072]
2013-11-17 14:04:29 +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 2d9cc79d53 Fix build failures on Ubuntu 13.10.
Automake now insists that we run AM_PROG_AR if we're going to build a
library, and AM_PROG_CC_C_O if we're going to build anything with
extra compile options. Those extra macros seem harmless in previous
versions of automake.

[originally from svn r10053]
2013-10-26 14:00:10 +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 6805bdcd6a Don't run toplevel callbacks in modal dialogs.
Because some of them can call gtk_main_quit(), which completely
confuses the dialog box system.

[originally from svn r10029]
2013-08-18 10:56:20 +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 a44366585f Revamp GTK's session close handling using toplevel callbacks.
Instead of having a special GTK idle function for dealing with session
closing, I now use the new top-level callback mechanism which is
slightly simpler for calling a one-off function.

Also in this commit, I've arranged for connection_fatal to queue a
call to the same session close function after displaying the message
box, with the effect that now all the same processing takes place no
matter whether the session closes cleanly or uncleanly - e.g. the SSH
specials submenu is cleaned out, as it should be.

[originally from svn r10022]
2013-08-17 16:06:22 +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
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 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 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 7426b8f215 Completely remove the 'frozen_readable' mechanism from uxnet.c. It
parallels a similar mechanism in winnet.c and came over by copy and
paste, but is pointless in the Unix networking API.

On Windows, if you're using a mechanism such as WSAAsyncSelect which
delivers readability notifications as messages rather than return
values from a system call, you only get notified that a socket is
readable once - it remembers that it's told you, and doesn't tell you
again until after you've done a read. So in the case where we
intentionally stop reading from a socket because our local buffer is
full, and later want to start reading again, we do a read from the
socket with MSG_PEEK set, and that clears Windows's flag and tells it
to start sending us readability notifications again.

On Unix, select() and friends didn't do anything so strange in the
first place, so the whole mechanism is unnecessary.

[originally from svn r9951]
2013-07-21 07:40:36 +00:00
Simon Tatham 77791de4e1 Fix error checking in uxstore.c: add a missing check, and fix a
mis-cut-and-pasted one.

[originally from svn r9950]
2013-07-21 07:40:30 +00:00
Simon Tatham f1d6fa4712 When I turned fcntls into noncloexecs in r9940, I missed one.
[originally from svn r9949]
[r9940 == b426872219]
2013-07-21 07:40:28 +00:00
Simon Tatham 08d46fca51 Two more memory leak fixes, on error paths I didn't spot in r9919.
[originally from svn r9948]
[r9919 == ea301bdd9b]
2013-07-21 07:40:26 +00:00
Simon Tatham adf8b3222f Fix leak of 'fname' introduced by the rewrite of write_random_seed in
r9933.

[originally from svn r9945]
[r9933 == 2854ae1f33]
2013-07-20 13:15:16 +00:00
Simon Tatham 3af26af19e Redo a mis-fix of a memory leak in r9919: I added sfree(data)
immediately after conf_deserialise in the Duplicate Session receiver,
whereas I should have put it after the subsequent loop that extracts
the pty argv if any.

[originally from svn r9943]
[r9919 == ea301bdd9b]
2013-07-20 13:15:10 +00:00
Simon Tatham b426872219 Centralise calls to fcntl into functions that carefully check the
error returns.

[originally from svn r9940]
2013-07-19 18:10:02 +00:00
Simon Tatham 96f3589e16 Add an error check to every setsockopt call in uxnet.c.
[originally from svn r9939]
2013-07-19 17:45:01 +00:00
Simon Tatham 407fd7b9ab Better error reporting when failing to save a session.
[originally from svn r9937]
2013-07-19 17:44:53 +00:00
Simon Tatham 13bac5ed69 Add some missing calls to cleanup_exit.
[originally from svn r9936]
2013-07-19 17:44:47 +00:00
Simon Tatham b4adf61bc7 Report errors in store_host_key too.
[originally from svn r9934]
2013-07-19 17:44:38 +00:00
Simon Tatham 2854ae1f33 Add proper error reports in write_random_seed, via the new 'nonfatal'
error reporting function.

[originally from svn r9933]
2013-07-19 17:44:33 +00:00
Simon Tatham acf38797eb Add a nonfatal() function everywhere, to be used for reporting things
that the user really ought to know but that are not actually fatal to
continued operation of PuTTY or a single network connection.

[originally from svn r9932]
2013-07-19 17:44:28 +00:00
Simon Tatham 1d21346d4c Add a missing error check in pterm's child-process setup. Shouldn't
really fail, but might as well be careful.

[originally from svn r9931]
2013-07-19 17:44:22 +00:00
Simon Tatham ea301bdd9b Fix another giant batch of resource leaks. (Mostly memory, but there's
one missing fclose too.)

[originally from svn r9919]
2013-07-14 10:46:07 +00:00
Simon Tatham 896bb7c74d Tighten up a lot of casts from unsigned to int which are read by one
of the GET_32BIT macros and then used as length fields. Missing bounds
checks against zero have been added, and also I've introduced a helper
function toint() which casts from unsigned to int in such a way as to
avoid C undefined behaviour, since I'm not sure I trust compilers any
more to do the obviously sensible thing.

[originally from svn r9918]
2013-07-14 10:45:54 +00:00
Simon Tatham 1662a2f6cf Fix an always-false if statement which was causing the window border
not to be redrawn when the user reconfigured the background colour.

[originally from svn r9917]
2013-07-14 10:45:48 +00:00
Simon Tatham 3d69dd2071 Add missing checks in update_for_intended_size() in the font selector
code, which would have coped badly if ever asked to select the first
font in the list at a size smaller than it supported. Luckily the
first font tended to be one of the X numeric aliases (e.g. 10x20)
which was stored with size zero, so this probably didn't actually come
up for anyone, but better safe than sorry.

[originally from svn r9910]
2013-07-11 17:24:28 +00:00
Simon Tatham 5a04ae3420 Fix a pty-freeing error which caused a segfault if you attempted to
use Restart Session in a post-not-close-on-exit pterm.

[originally from svn r9909]
2013-07-11 17:24:23 +00:00
Simon Tatham 1f3901a3a2 Add some missing null checks for inst->ldisc, which were causing
segfaults if a PuTTY or pterm did not close on exit and then you
either typed something via input_method_commit_event or changed the
line editing or echo settings.

[originally from svn r9908]
2013-07-11 17:24:20 +00:00
Simon Tatham 916cd3f0cd Remove another pointless null check, this time of inst->back in the
function which has just dereferenced it to get the exit code.

[originally from svn r9907]
2013-07-11 17:24:14 +00:00
Simon Tatham bbc9709b48 A collection of small bug fixes from Chris West, apparently spotted by
Coverity: assorted language-use goofs like freeing the wrong thing or
forgetting to initialise a string on all code paths.

[originally from svn r9889]
2013-07-01 17:56:33 +00:00
Simon Tatham c5876a8ba2 Fallback for manual setup of GTK 1, if autoconf is run on a system
where the GTK1 detection function AM_PATH_GTK hasn't been provided by
/usr/share/aclocal/gtk.m4 or equivalent.

(Systems without gtk.m4 are becoming more common, but on the other
hand I know at least one person is still using GTK 1 PuTTY since the
0.62 release.)

[originally from svn r9868]
2013-06-15 19:58:10 +00:00