Skip to content
Snippets Groups Projects
  1. Sep 19, 2021
  2. Jun 23, 2021
    • Simon Tatham's avatar
      New option to reject 'trivial' success of userauth. · 1dc5659a
      Simon Tatham authored
      Suggested by Manfred Kaiser, who also wrote most of this patch
      (although outlying parts, like documentation and SSH-1 support, are by
      me).
      
      This is a second line of defence against the kind of spoofing attacks
      in which a malicious or compromised SSH server rushes the client
      through the userauth phase of SSH without actually requiring any auth
      inputs (passwords or signatures or whatever), and then at the start of
      the connection phase it presents something like a spoof prompt,
      intended to be taken for part of userauth by the user but in fact with
      some more sinister purpose.
      
      Our existing line of defence against this is the trust sigil system,
      and as far as I know, that's still working. This option allows a bit of
      extra defence in depth: if you don't expect your SSH server to
      trivially accept authentication in the first place, then enabling this
      option will cause PuTTY to disconnect if it unexpectedly does so,
      without the user having to spot the presence or absence of a fiddly
      little sigil anywhere.
      
      Several types of authentication count as 'trivial'. The obvious one is
      the SSH-2 "none" method, which clients always try first so that the
      failure message will tell them what else they can try, and which a
      server can instead accept in order to authenticate you unconditionally.
      But there are two other ways to do it that we know of: one is to run
      keyboard-interactive authentication and send an empty INFO_REQUEST
      packet containing no actual prompts for the user, and another even
      weirder one is to send USERAUTH_SUCCESS in response to the user's
      preliminary *offer* of a public key (instead of sending the usual PK_OK
      to request an actual signature from the key).
      
      This new option detects all of those, by clearing the 'is_trivial_auth'
      flag only when we send some kind of substantive authentication response
      (be it a password, a k-i prompt response, a signature, or a GSSAPI
      token). So even if there's a further path through the userauth maze we
      haven't spotted, that somehow avoids sending anything substantive, this
      strategy should still pick it up.
      
      (cherry picked from commit 5f5c710c)
      1dc5659a
  3. Feb 21, 2021
  4. Nov 22, 2020
    • Simon Tatham's avatar
      Support -logoverwrite and -logappend command-line flags. · ca73159c
      Simon Tatham authored
      If it's worth having command-line options to _specify_ a log file,
      it's also worth having options to avoid having to answer an
      interactive prompt _about_ that log file every time.
      
      (Particularly useful when debugging, in which I often want to run a
      zillion instances of the same quite temporary command line that
      involves writing a log file.)
      ca73159c
  5. Feb 22, 2020
    • Simon Tatham's avatar
      Permit protocol selection in file transfer tools. · 91c2e6b4
      Simon Tatham authored
      PSCP and PSFTP can only work over a protocol enough like SSH to be
      able to run subsystems (or at the very least a remote command, for
      old-style PSCP). Historically we've implemented this restriction by
      having them not support any protocol-selection command-line options at
      all, and hardwiring them to instantiating ssh_backend.
      
      This commit regularises them to be more like the rest of the tools.
      You can select a protocol using the appropriate command-line option,
      provided it's a protocol in those tools' backends[] array. And the
      setup code will find the BackendVtable to instantiate by the usual
      method of calling backend_vt_from_proto.
      
      Currently, this makes essentially no difference: those tools link in
      be_ssh.c, which means the only supported backend is SSH. So the effect
      is that now -ssh is an accepted option with no effect, instead of
      being rejected. But it opens the way to add other protocols that are
      SSH-like enough to run file transfer over.
      91c2e6b4
    • Simon Tatham's avatar
      cmdline.c: loop over backends list for '-protocol' options. · bd16a0e1
      Simon Tatham authored
      I'm reusing the 'id' string from each BackendVtable as the name of its
      command-line option, which means I don't need to manually implement an
      option for each new protocol.
      bd16a0e1
  6. Feb 02, 2020
    • Simon Tatham's avatar
      Move the restricted_acl flag into winsecur.c. · 3cb86d9f
      Simon Tatham authored
      It's silly to set it at each call site of restrict_process_acl() if
      that function returns success! More sensible to have it be a flag in
      the same source file as restrict_process_acl(), set as an automatic
      _side effect_ of success.
      
      I've renamed the variable itself, and the global name 'restricted_acl'
      is now a query function that asks winsecur.c whether that operation
      has been (successfully) performed.
      3cb86d9f
    • Simon Tatham's avatar
      Move default_protocol and default_port into settings.c. · 46fc31c0
      Simon Tatham authored
      These global variables are only ever used by load_settings, which uses
      them to vary the default protocol and port number in the absence of
      any specification elsewhere. So there's no real need for them to be
      universally accessible via the awkward GLOBAL mechanism: they can be
      statics inside settings.c, with accessor functions that can set them.
      
      That was the last GLOBAL in putty.h, so I've removed the definition of
      the macro GLOBAL itself as well. There are still some GLOBALs in the
      Windows subdirectory, though.
      46fc31c0
  7. Jan 30, 2020
    • Simon Tatham's avatar
      Move 'loaded_session' into cmdline.c. · 22deebfc
      Simon Tatham authored
      I haven't managed to make this one _not_ be a mutable variable, but at
      least it's not global across all tools any more: it lives in cmdline.c
      along with the code that decides what to set it to, and cmdline.c
      exports a query method to ask for its value.
      22deebfc
    • Simon Tatham's avatar
      Remove cmdline_session_name. · 492e6b11
      Simon Tatham authored
      This mutable global was never actually used at all, _even_ in history!
      Commit 1a03fa92 introduced it, as part of the jump list support, but
      even that commit never _read_ from the variable - it only assigned to
      it. I have to guess that it was part of an earlier draft of the jump
      lists patch and ended up orphaned in the final version.
      492e6b11
    • Simon Tatham's avatar
      Make cmdline_tooltype a const int. · 575ee4f8
      Simon Tatham authored
      Another ugly mutable global variable gone: now, instead of this
      variable being defined in cmdline.c and written to by everyone's
      main(), it's defined _alongside_ everyone's main() as a constant, and
      cmdline.c just refers to it.
      
      A bonus is that now nocmdline.c doesn't have to define it anyway for
      tools that don't use cmdline.c. But mostly, it didn't need to be
      mutable, so better for it not to be.
      
      While I'm at it, I've also fiddled with the bit flags that go in it,
      to define their values automatically using a list macro instead of
      manually specifying each one to be a different power of 2.
      575ee4f8
    • Simon Tatham's avatar
      Remove FLAG_VERBOSE. · d20d3b20
      Simon Tatham authored
      The global 'int flags' has always been an ugly feature of this code
      base, and I suddenly thought that perhaps it's time to start throwing
      it out, one flag at a time, until it's totally unused.
      
      My first target is FLAG_VERBOSE. This was usually set by cmdline.c
      when it saw a -v option on the program's command line, except that GUI
      PuTTY itself sets it unconditionally on startup. And then various bits
      of the code would check it in order to decide whether to print a given
      message.
      
      In the current system of front-end abstraction traits, there's no
      _one_ place that I can move it to. But there are two: every place that
      checked FLAG_VERBOSE has access to either a Seat or a LogPolicy. So
      now each of those traits has a query method for 'do I want verbose
      messages?'.
      
      A good effect of this is that subsidiary Seats, like the ones used in
      Uppity for the main SSH server module itself and the server end of
      shell channels, now get to have their own verbosity setting instead of
      inheriting the one global one. In fact I don't expect any code using
      those Seats to be generating any messages at all, but if that changes
      later, we'll have a way to control it. (Who knows, perhaps logging in
      Uppity might become a thing.)
      
      As part of this cleanup, I've added a new flag to cmdline_tooltype,
      called TOOLTYPE_NO_VERBOSE_OPTION. The unconditionally-verbose tools
      now set that, and it has the effect of making cmdline.c disallow -v
      completely. So where 'putty -v' would previously have been silently
      ignored ("I was already verbose"), it's now an error, reminding you
      that that option doesn't actually do anything.
      
      Finally, the 'default_logpolicy' provided by uxcons.c and wincons.c
      (with identical definitions) has had to move into a new file of its
      own, because now it has to ask cmdline.c for the verbosity setting as
      well as asking console.c for the rest of its methods. So there's a new
      file clicons.c which can only be included by programs that link
      against both cmdline.c _and_ one of the *cons.c, and I've renamed the
      logpolicy to reflect that.
      d20d3b20
  8. Jan 29, 2020
    • Simon Tatham's avatar
      Assorted benign warning fixes. · 76430f82
      Simon Tatham authored
      These were just too footling for even me to bother splitting up into
      multiple commits:
      
       - a couple of int -> size_t changes left out of the big-bang commit
         0cda34c6
      
       - a few 'const' added to pointer-type casts that are only going to be
         read from (leaving out the const provokes a warning if the pointer
         was const _before_ the cast)
      
       - a couple of 'return' statements trying to pass the void return of
         one function through to another.
      
       - another missing (void) in a declaration in putty.h (but this one
         didn't cause any knock-on confusion).
      
       - a few tweaks to macros, to arrange that they eat a semicolon after
         the macro call (extra do ... while (0) wrappers, mostly, and one
         case where I had to do it another way because the macro included a
         variable declaration intended to remain in scope)
      
       - reworked key_type_to_str to stop putting an unreachable 'break'
         statement after every 'return'
      
       - removed yet another type-check of a function loaded from a Windows
         system DLL
      
       - and finally, a totally spurious semicolon right after an open brace
         in mainchan.c.
      76430f82
  9. Sep 08, 2019
    • Simon Tatham's avatar
      Whitespace rationalisation of entire code base. · 5d718ef6
      Simon Tatham authored
      The number of people has been steadily increasing who read our source
      code with an editor that thinks tab stops are 4 spaces apart, as
      opposed to the traditional tty-derived 8 that the PuTTY code expects.
      
      So I've been wondering for ages about just fixing it, and switching to
      a spaces-only policy throughout the code. And I recently found out
      about 'git blame -w', which should make this change not too disruptive
      for the purposes of source-control archaeology; so perhaps now is the
      time.
      
      While I'm at it, I've also taken the opportunity to remove all the
      trailing spaces from source lines (on the basis that git dislikes
      them, and is the only thing that seems to have a strong opinion one
      way or the other).
          
      Apologies to anyone downstream of this code who has complicated patch
      sets to rebase past this change. I don't intend it to be needed again.
      5d718ef6
  10. Mar 16, 2019
    • Simon Tatham's avatar
      Switch to using poll(2) in place of select(2). · 5c926d9e
      Simon Tatham authored
      I've always thought poll was more hassle to set up, because if you
      want to reuse part of your pollfds list between calls then you have to
      index every fd by its position in the list as well as the fd number
      itself, which gives you twice as many indices to keep track of than if
      the fd is always its own key.
      
      But the problem is that select is fundamentally limited to the range
      of fds that can fit in an fd_set, which is not the range of fds that
      can _exist_, so I've had a change of heart and now have to go with
      poll.
      
      For the moment, I've surrounded it with a 'pollwrapper' structure that
      lets me treat it more or less like select, containing a tree234 that
      maps each fd to its location in the list, and also translating between
      the simple select r/w/x classification and the richer poll flags.
      That's let me do the migration with minimal disruption to the call
      sites.
      
      In future perhaps I can start using poll more directly, and/or using
      the richer flag system (though the latter might be fiddly because of
      sometimes being constrained to use the glib event loop). But this will
      do for now.
      5c926d9e
  11. Feb 28, 2019
    • Simon Tatham's avatar
      New array-growing macros: sgrowarray and sgrowarrayn. · e0a76971
      Simon Tatham authored
      The idea of these is that they centralise the common idiom along the
      lines of
      
         if (logical_array_len >= physical_array_size) {
             physical_array_size = logical_array_len * 5 / 4 + 256;
             array = sresize(array, physical_array_size, ElementType);
         }
      
      which happens at a zillion call sites throughout this code base, with
      different random choices of the geometric factor and additive
      constant, sometimes forgetting them completely, and generally doing a
      lot of repeated work.
      
      The new macro sgrowarray(array,size,n) has the semantics: here are the
      array pointer and its physical size for you to modify, now please
      ensure that the nth element exists, so I can write into it. And
      sgrowarrayn(array,size,n,m) is the same except that it ensures that
      the array has size at least n+m (so sgrowarray is just the special
      case where m=1).
      
      Now that this is a single centralised implementation that will be used
      everywhere, I've also gone to more effort in the implementation, with
      careful overflow checks that would have been painful to put at all the
      previous call sites.
      
      This commit also switches over every use of sresize(), apart from a
      few where I really didn't think it would gain anything. A consequence
      of that is that a lot of array-size variables have to have their types
      changed to size_t, because the macros require that (they address-take
      the size to pass to the underlying function).
      e0a76971
    • Simon Tatham's avatar
      Replace more ad-hoc growing char buffers with strbuf. · d07d7d66
      Simon Tatham authored
      I've fixed a handful of these where I found them in passing, but when
      I went systematically looking, there were a lot more that I hadn't
      found!
      
      A particular highlight of this collection is the code that formats
      Windows clipboard data in RTF, which was absolutely crying out for
      strbuf_catf, and now it's got it.
      d07d7d66
  12. Feb 27, 2019
    • Simon Tatham's avatar
      Plink: fix mishandling of launchable Default Settings. · d147f764
      Simon Tatham authored
      Plink's hostname argument can refer to a saved session instead of a
      hostname. We test this by trying to load it as a session, and seeing
      if the resulting Conf is launchable. But if Default Settings itself is
      launchable (e.g. if it has the protocol set to Serial) then that can
      happen even if there is no saved session with that name - in which
      case we'll _never_ fall back to treating the argument as a host name.
      
      Fixed by also checking the new success flag returned from do_defaults.
      d147f764
  13. Nov 03, 2018
    • Simon Tatham's avatar
      Convert a lot of 'int' variables to 'bool'. · 3214563d
      Simon Tatham authored
      My normal habit these days, in new code, is to treat int and bool as
      _almost_ completely separate types. I'm still willing to use C's
      implicit test for zero on an integer (e.g. 'if (!blob.len)' is fine,
      no need to spell it out as blob.len != 0), but generally, if a
      variable is going to be conceptually a boolean, I like to declare it
      bool and assign to it using 'true' or 'false' rather than 0 or 1.
      
      PuTTY is an exception, because it predates the C99 bool, and I've
      stuck to its existing coding style even when adding new code to it.
      But it's been annoying me more and more, so now that I've decided C99
      bool is an acceptable thing to require from our toolchain in the first
      place, here's a quite thorough trawl through the source doing
      'boolification'. Many variables and function parameters are now typed
      as bool rather than int; many assignments of 0 or 1 to those variables
      are now spelled 'true' or 'false'.
      
      I managed this thorough conversion with the help of a custom clang
      plugin that I wrote to trawl the AST and apply heuristics to point out
      where things might want changing. So I've even managed to do a decent
      job on parts of the code I haven't looked at in years!
      
      To make the plugin's work easier, I pushed platform front ends
      generally in the direction of using standard 'bool' in preference to
      platform-specific boolean types like Windows BOOL or GTK's gboolean;
      I've left the platform booleans in places they _have_ to be for the
      platform APIs to work right, but variables only used by my own code
      have been converted wherever I found them.
      
      In a few places there are int values that look very like booleans in
      _most_ of the places they're used, but have a rarely-used third value,
      or a distinction between different nonzero values that most users
      don't care about. In these cases, I've _removed_ uses of 'true' and
      'false' for the return values, to emphasise that there's something
      more subtle going on than a simple boolean answer:
       - the 'multisel' field in dialog.h's list box structure, for which
         the GTK front end in particular recognises a difference between 1
         and 2 but nearly everything else treats as boolean
       - the 'urgent' parameter to plug_receive, where 1 vs 2 tells you
         something about the specific location of the urgent pointer, but
         most clients only care about 0 vs 'something nonzero'
       - the return value of wc_match, where -1 indicates a syntax error in
         the wildcard.
       - the return values from SSH-1 RSA-key loading functions, which use
         -1 for 'wrong passphrase' and 0 for all other failures (so any
         caller which already knows it's not loading an _encrypted private_
         key can treat them as boolean)
       - term->esc_query, and the 'query' parameter in toggle_mode in
         terminal.c, which _usually_ hold 0 for ESC[123h or 1 for ESC[?123h,
         but can also hold -1 for some other intervening character that we
         don't support.
      
      In a few places there's an integer that I haven't turned into a bool
      even though it really _can_ only take values 0 or 1 (and, as above,
      tried to make the call sites consistent in not calling those values
      true and false), on the grounds that I thought it would make it more
      confusing to imply that the 0 value was in some sense 'negative' or
      bad and the 1 positive or good:
       - the return value of plug_accepting uses the POSIXish convention of
         0=success and nonzero=error; I think if I made it bool then I'd
         also want to reverse its sense, and that's a job for a separate
         piece of work.
       - the 'screen' parameter to lineptr() in terminal.c, where 0 and 1
         represent the default and alternate screens. There's no obvious
         reason why one of those should be considered 'true' or 'positive'
         or 'success' - they're just indices - so I've left it as int.
      
      ssh_scp_recv had particularly confusing semantics for its previous int
      return value: its call sites used '<= 0' to check for error, but it
      never actually returned a negative number, just 0 or 1. Now the
      function and its call sites agree that it's a bool.
      
      In a couple of places I've renamed variables called 'ret', because I
      don't like that name any more - it's unclear whether it means the
      return value (in preparation) for the _containing_ function or the
      return value received from a subroutine call, and occasionally I've
      accidentally used the same variable for both and introduced a bug. So
      where one of those got in my way, I've renamed it to 'toret' or 'retd'
      (the latter short for 'returned') in line with my usual modern
      practice, but I haven't done a thorough job of finding all of them.
      
      Finally, one amusing side effect of doing this is that I've had to
      separate quite a few chained assignments. It used to be perfectly fine
      to write 'a = b = c = TRUE' when a,b,c were int and TRUE was just a
      the 'true' defined by stdbool.h, that idiom provokes a warning from
      gcc: 'suggest parentheses around assignment used as truth value'!
      3214563d
    • Simon Tatham's avatar
      Switch some Conf settings over to being bool. · 1378bb04
      Simon Tatham authored
      I think this is the full set of things that ought logically to be
      boolean.
      
      One annoyance is that quite a few radio-button controls in config.c
      address Conf fields that are now bool rather than int, which means
      that the shared handler function can't just access them all with
      conf_{get,set}_int. Rather than back out the rigorous separation of
      int and bool in conf.c itself, I've just added a similar alternative
      handler function for the bool-typed ones.
      1378bb04
    • Simon Tatham's avatar
      Adopt C99 <stdbool.h>'s true/false. · a6f1709c
      Simon Tatham authored
      This commit includes <stdbool.h> from defs.h and deletes my
      traditional definitions of TRUE and FALSE, but other than that, it's a
      100% mechanical search-and-replace transforming all uses of TRUE and
      FALSE into the C99-standardised lowercase spellings.
      
      No actual types are changed in this commit; that will come next. This
      is just getting the noise out of the way, so that subsequent commits
      can have a higher proportion of signal.
      a6f1709c
  14. Oct 11, 2018
    • Simon Tatham's avatar
      New abstraction 'Seat', to pass to backends. · b4c8fd9d
      Simon Tatham authored
      This is a new vtable-based abstraction which is passed to a backend in
      place of Frontend, and it implements only the subset of the Frontend
      functions needed by a backend. (Many other Frontend functions still
      exist, notably the wide range of things called by terminal.c providing
      platform-independent operations on the GUI terminal window.)
      
      The purpose of making it a vtable is that this opens up the
      possibility of creating a backend as an internal implementation detail
      of some other activity, by providing just that one backend with a
      custom Seat that implements the methods differently.
      
      For example, this refactoring should make it feasible to directly
      implement an SSH proxy type, aka the 'jump host' feature supported by
      OpenSSH, aka 'open a secondary SSH session in MAINCHAN_DIRECT_TCP
      mode, and then expose the main channel of that as the Socket for the
      primary connection'. (Which of course you can already do by spawning
      'plink -nc' as a separate proxy process, but this would permit it in
      the _same_ process without anything getting confused.)
      
      I've centralised a full set of stub methods in misc.c for the new
      abstraction, which allows me to get rid of several annoying stubs in
      the previous code. Also, while I'm here, I've moved a lot of
      duplicated modalfatalbox() type functions from application main
      program files into wincons.c / uxcons.c, which I think saves
      duplication overall. (A minor visible effect is that the prefixes on
      those console-based fatal error messages will now be more consistent
      between applications.)
      b4c8fd9d
  15. Oct 06, 2018
  16. Sep 19, 2018
    • Simon Tatham's avatar
      Turn Backend into a sensible classoid. · eefebaaa
      Simon Tatham authored
      Nearly every part of the code that ever handles a full backend
      structure has historically done it using a pair of pointer variables,
      one pointing at a constant struct full of function pointers, and the
      other pointing to a 'void *' state object that's passed to each of
      those.
      
      While I'm modernising the rest of the code, this seems like a good
      time to turn that into the same more or less type-safe and less
      cumbersome system as I'm using for other parts of the code, such as
      Socket, Plug, BinaryPacketProtocol and so forth: the Backend structure
      contains a vtable pointer, and a system of macro wrappers handles
      dispatching through that vtable.
      eefebaaa
  17. May 18, 2018
  18. Dec 07, 2017
    • Simon Tatham's avatar
      Centralise PuTTY and Plink's non-option argument handling. · b9a25510
      Simon Tatham authored
      This is another piece of long-overdue refactoring similar to the
      recent commit e3796cb7. But where that one dealt with normalisation
      of stuff already stored _in_ a Conf by whatever means (including, in
      particular, handling a user typing 'username@host.name' into the
      Hostname box of the GUI session dialog box), this one deals with
      handling argv entries and putting them into the Conf.
      
      This isn't exactly a pure no-functional-change-at-all refactoring. On
      the other hand, it isn't a full-on cleanup that completely
      rationalises all the user-visible behaviour as well as the code
      structure. It's somewhere in between: I've preserved all the behaviour
      quirks that I could imagine a reason for having intended, but taken
      the opportunity to _not_ faithfully replicate anything I thought was
      clearly just a bug.
      
      So, for example, the following inconsistency is carefully preserved:
      the command 'plink -load session nextword' treats 'nextword' as a host
      name if the loaded session hasn't provided a hostname already, and
      otherwise treats 'nextword' as the remote command to execute on the
      already-specified remote host, but the same combination of arguments
      to GUI PuTTY will _always_ treat 'nextword' as a hostname, overriding
      a hostname (if any) in the saved session. That makes some sense to me
      because of the different shapes of the overall command lines.
      
      On the other hand, there are two behaviour changes I know of as a
      result of this commit: a third argument to GUI PuTTY (after a hostname
      and port) now provokes an error message instead of being silently
      ignored, and in Plink, if you combine a -P option (specifying a port
      number) with the historical comma-separated protocol selection prefix
      on the hostname argument (which I'd completely forgotten even existed
      until this piece of work), then the -P will now override the selected
      protocol's default port number, whereas previously the default port
      would win. For example, 'plink -P 12345 telnet,hostname' will now
      connect via Telnet to port 12345 instead of to port 23.
      
      There may be scope for removing or rethinking some of the command-
      line syntax quirks in the wake of this change. If we do decide to do
      anything like that, then hopefully having it all in one place will
      make it easier to remove or change things consistently across the
      tools.
      b9a25510
  19. Jul 08, 2017
  20. Feb 04, 2017
    • Simon Tatham's avatar
      Pass -restrict-acl, if given, through to sub-PuTTYs. · f0496904
      Simon Tatham authored
      This change applies to every situation when GUI PuTTY knowingly spawns
      another GUI PuTTY, to wit, the System menu options 'New Session',
      'Duplicate Session' and the 'Saved Sessions' submenu.
      
      (Literally speaking, what we actually pass through to the sub-PuTTY's
      command line is not the "-restrict-acl" option itself, but a special
      prefix "&R", which has the same meaning but which lives in the special
      pre-argv-splitting command-line namespace like the magic options used
      for Duplicate Session and the old '@sessionname' prefix which the
      Saved Sessions submenu still uses. Otherwise, by the time we split up
      argv and recognised -restrict-acl, it would be too late to parse those
      other options.)
      
      One case in which PuTTY spawns a subprocess and this change _doesn't_
      apply is when the subprocess is a proxy command which happens to be a
      Plink. Recognising Plink commands in that situation would be fragile
      and unreliable, and in any case if the user wants a proxy Plink to be
      ACL-restricted, they are in control of its exact command line so they
      can add -restrict-acl themselves.
      f0496904
  21. Jan 30, 2017
    • Simon Tatham's avatar
      Turn off Windows process ACL restriction by default. · e22120fe
      Simon Tatham authored
      As documented in bug 'win-process-acl-finesse', we've had enough
      assorted complaints about it breaking various non-malicious pieces of
      Windows process interaction (ranging from git->plink integration to
      screen readers for the vision-impaired) that I think it's more
      sensible to set the process back to its default level of protection.
      
      This precaution was never a fully effective protection anyway, due to
      the race condition at process startup; the only properly effective
      defence would have been to prevent malware running under the same user
      ID as PuTTY in the first place, so in that sense, nothing has changed.
      But people who want the arguable defence-in-depth advantage of the ACL
      restriction can now turn it on with the '-restrict-acl' command-line
      option, and it's up to them whether they can live with the assorted
      inconveniences that come with it.
      
      In the course of this change, I've centralised a bit more of the
      restriction code into winsecur.c, to avoid repeating the error
      handling in multiple places.
      e22120fe
  22. May 03, 2016
    • Simon Tatham's avatar
      Add a '-proxycmd' command-line option. · e65e5d16
      Simon Tatham authored
      This is equivalent to selecting 'Local' as the proxy type and entering
      the argument string in the proxy command box, in the GUI.
      
      I've pulled this out of all the other proxy options to promote to a
      named command-line option, partly because it's the proxy option with
      the most natural command-line expression in the first place (any shell
      command you might want to use is already in the form of a single
      string), and also because it has uses beyond end-user proxying
      applications: in particular, replacing the network connection with a
      local process is a convenient way to do testing in the style of
      contrib/samplekex.py, avoiding the need to run a separate command to
      make the test 'server' listen on a port.
      e65e5d16
  23. Feb 29, 2016
    • Jacob Nevins's avatar
      Rationalise and document log options somewhat. · ac9862ec
      Jacob Nevins authored
      TOOLTYPE_NONNETWORK (i.e. pterm) already has "-log" (as does Unix
      PuTTY), so there's no sense suppressing the synonym "-sessionlog".
      
      Undocumented lacunae that remain:
      
      plink accepts -sessionlog, but does nothing with it. Arguably it should.
      
      puttytel accepts -sshlog/-sshrawlog (and happily logs e.g. Telnet
      negotiation, as does PuTTY proper).
      
      (cherry picked from commit a454399e)
      
      Conflicts:
      	unix/uxplink.c
      	windows/winplink.c
      
      (cherry-picker's notes: the conflict was only contextual, in the Plink
      help output)
      ac9862ec
  24. Nov 08, 2015
    • Jacob Nevins's avatar
      Rationalise and document log options somewhat. · a454399e
      Jacob Nevins authored
      TOOLTYPE_NONNETWORK (i.e. pterm) already has "-log" (as does Unix
      PuTTY), so there's no sense suppressing the synonym "-sessionlog".
      
      Undocumented lacunae that remain:
      
      plink accepts -sessionlog, but does nothing with it. Arguably it should.
      
      puttytel accepts -sshlog/-sshrawlog (and happily logs e.g. Telnet
      negotiation, as does PuTTY proper).
      a454399e
  25. Oct 17, 2015
    • Simon Tatham's avatar
      Command-line options to log sessions. · 31c5784d
      Simon Tatham authored
      Log files, especially SSH packet logs, are often things you want to
      generate in unusual circumstances, so it's good to have lots of ways
      to ask for them. Particularly, it's especially painful to have to set
      up a custom saved session to get diagnostics out of the command-line
      tools.
      
      I've added options '-sessionlog', '-sshlog' and '-sshrawlog', each of
      which takes a filename argument. I think the fourth option (session
      output but filtered down to the printable subset) is not really a
      _debugging_ log in the same sense, so it's not as critical to have an
      option for it.
      
      (cherry picked from commit 13edf90e)
      31c5784d
  26. Sep 24, 2015
    • Simon Tatham's avatar
      Command-line options to log sessions. · 13edf90e
      Simon Tatham authored
      Log files, especially SSH packet logs, are often things you want to
      generate in unusual circumstances, so it's good to have lots of ways
      to ask for them. Particularly, it's especially painful to have to set
      up a custom saved session to get diagnostics out of the command-line
      tools.
      
      I've added options '-sessionlog', '-sshlog' and '-sshrawlog', each of
      which takes a filename argument. I think the fourth option (session
      output but filtered down to the printable subset) is not really a
      _debugging_ log in the same sense, so it's not as critical to have an
      option for it.
      13edf90e
  27. May 15, 2015
    • Simon Tatham's avatar
      Giant const-correctness patch of doom! · 89da2ddf
      Simon Tatham authored
      Having found a lot of unfixed constness issues in recent development,
      I thought perhaps it was time to get proactive, so I compiled the
      whole codebase with -Wwrite-strings. That turned up a huge load of
      const problems, which I've fixed in this commit: the Unix build now
      goes cleanly through with -Wwrite-strings, and the Windows build is as
      close as I could get it (there are some lingering issues due to
      occasional Windows API functions like AcquireCredentialsHandle not
      having the right constness).
      
      Notable fallout beyond the purely mechanical changing of types:
       - the stuff saved by cmdline_save_param() is now explicitly
         dupstr()ed, and freed in cmdline_run_saved.
       - I couldn't make both string arguments to cmdline_process_param()
         const, because it intentionally writes to one of them in the case
         where it's the argument to -pw (in the vain hope of being at least
         slightly friendly to 'ps'), so elsewhere I had to temporarily
         dupstr() something for the sake of passing it to that function
       - I had to invent a silly parallel version of const_cmp() so I could
         pass const string literals in to lookup functions.
       - stripslashes() in pscp.c and psftp.c has the annoying strchr nature
      89da2ddf
  28. Sep 09, 2014
    • Simon Tatham's avatar
      New option to manually configure the expected host key(s). · 70ab076d
      Simon Tatham authored
      This option is available from the command line as '-hostkey', and is
      also configurable through the GUI. When enabled, it completely
      replaces all of the automated host key management: the server's host
      key will be checked against the manually configured list, and the
      connection will be allowed or disconnected on that basis, and the host
      key store in the registry will not be either consulted or updated.
      
      The main aim is to provide a means of automatically running Plink,
      PSCP or PSFTP deep inside Windows services where HKEY_CURRENT_USER
      isn't available to have stored the right host key in. But it also
      permits you to specify a list of multiple host keys, which means a
      second use case for the same mechanism will probably be round-robin
      DNS names that select one of several servers with different host keys.
      
      Host keys can be specified as the standard MD5 fingerprint or as an
      SSH-2 base64 blob, and are canonicalised on input. (The base64 blob is
      more unwieldy, especially with Windows command-line length limits, but
      provides a means of specifying the _whole_ public key in case you
      don't trust MD5. I haven't bothered to provide an analogous mechanism
      for SSH-1, on the basis that anyone worrying about MD5 should have
      stopped using SSH-1 already!)
      
      [originally from svn r10220]
      70ab076d
  29. Jan 25, 2014
    • Simon Tatham's avatar
      Use the new host_str* functions to improve IPv6 literal support. · 8da4fa50
      Simon Tatham authored
      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]
      8da4fa50
  30. Nov 17, 2013
    • Simon Tatham's avatar
      Fix an assortment of dupprintf() format string bugs. · 85d1e760
      Simon Tatham authored
      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]
      85d1e760
  31. Jul 22, 2012
    • Simon Tatham's avatar
      Introduce a new utility function smemclr(), which memsets things to · aa5bae89
      Simon Tatham authored
      zero but does it in such a way that over-clever compilers hopefully
      won't helpfully optimise the call away if you do it just before
      freeing something or letting it go out of scope. Use this for
      (hopefully) every memset whose job is to destroy sensitive data that
      might otherwise be left lying around in the process's memory.
      
      [originally from svn r9586]
      aa5bae89
  32. Oct 02, 2011
Loading