Skip to content
Snippets Groups Projects
  1. Apr 20, 2017
  2. Apr 14, 2017
  3. Apr 13, 2017
    • Heikki Linnakangas's avatar
      Improve the SASL authentication protocol. · 4f3b87ab
      Heikki Linnakangas authored
      This contains some protocol changes to SASL authentiation (which is new
      in v10):
      
      * For future-proofing, in the AuthenticationSASL message that begins SASL
        authentication, provide a list of SASL mechanisms that the server
        supports, for the client to choose from. Currently, it's always just
        SCRAM-SHA-256.
      
      * Add a separate authentication message type for the final server->client
        SASL message, which the client doesn't need to respond to. This makes
        it unambiguous whether the client is supposed to send a response or not.
        The SASL mechanism should know that anyway, but better to be explicit.
      
      Also, in the server, support clients that don't send an Initial Client
      response in the first SASLInitialResponse message. The server is supposed
      to first send an empty request in that case, to which the client will
      respond with the data that usually comes in the Initial Client Response.
      libpq uses the Initial Client Response field and doesn't need this, and I
      would assume any other sensible implementation to use Initial Client
      Response, too, but let's follow the SASL spec.
      
      Improve the documentation on SASL authentication in protocol. Add a
      section describing the SASL message flow, and some details on our
      SCRAM-SHA-256 implementation.
      
      Document the different kinds of PasswordMessages that the frontend sends
      in different phases of SASL authentication, as well as GSS/SSPI
      authentication as separate message formats. Even though they're all 'p'
      messages, and the exact format depends on the context, describing them as
      separate message formats makes the documentation more clear.
      
      Reviewed by Michael Paquier and Álvaro Hernández Tortosa.
      
      Discussion: https://www.postgresql.org/message-id/CAB7nPqS-aFg0iM3AQOJwKDv_0WkAedRjs1W2X8EixSz+sKBXCQ@mail.gmail.com
      4f3b87ab
    • Heikki Linnakangas's avatar
      Refactor libpq authentication request processing. · 61bf96ca
      Heikki Linnakangas authored
      Move the responsibility of reading the data from the authentication request
      message from PQconnectPoll() to pg_fe_sendauth(). This way, PQconnectPoll()
      doesn't need to know about all the different authentication request types,
      and we don't need the extra fields in the pg_conn struct to pass the data
      from PQconnectPoll() to pg_fe_sendauth() anymore.
      
      Reviewed by Michael Paquier.
      
      Discussion: https://www.postgresql.org/message-id/6490b975-5ee1-6280-ac1d-af975b19fb9a%40iki.fi
      61bf96ca
  4. Apr 11, 2017
    • Magnus Hagander's avatar
      Remove symbol WIN32_ONLY_COMPILER · a4777f35
      Magnus Hagander authored
      This used to mean "Visual C++ except in those parts where Borland C++
      was supported where it meant one of those". Now that we don't support
      Borland C++ anymore, simplify by using _MSC_VER which is the normal way
      to detect Visual C++.
      a4777f35
    • Magnus Hagander's avatar
      Remove support for bcc and msvc standalone libpq builds · 6da56f3f
      Magnus Hagander authored
      This removes the support for building just libpq using Borland C++ or
      Visual C++. This has not worked properly for years, and given the number
      of complaints it's clearly not worth the maintenance burden.
      
      Building libpq using the standard MSVC build system is of course still
      supported, along with mingw.
      6da56f3f
  5. Apr 08, 2017
  6. Apr 07, 2017
    • Heikki Linnakangas's avatar
      Use SASLprep to normalize passwords for SCRAM authentication. · 60f11b87
      Heikki Linnakangas authored
      An important step of SASLprep normalization, is to convert the string to
      Unicode normalization form NFKC. Unicode normalization requires a fairly
      large table of character decompositions, which is generated from data
      published by the Unicode consortium. The script to generate the table is
      put in src/common/unicode, as well test code for the normalization.
      A pre-generated version of the tables is included in src/include/common,
      so you don't need the code in src/common/unicode to build PostgreSQL, only
      if you wish to modify the normalization tables.
      
      The SASLprep implementation depends on the UTF-8 functions from
      src/backend/utils/mb/wchar.c. So to use it, you must also compile and link
      that. That doesn't change anything for the current users of these
      functions, the backend and libpq, as they both already link with wchar.o.
      It would be good to move those functions into a separate file in
      src/commmon, but I'll leave that for another day.
      
      No documentation changes included, because there is no details on the
      SCRAM mechanism in the docs anyway. An overview on that in the protocol
      specification would probably be good, even though SCRAM is documented in
      detail in RFC5802. I'll write that as a separate patch. An important thing
      to mention there is that we apply SASLprep even on invalid UTF-8 strings,
      to support other encodings.
      
      Patch by Michael Paquier and me.
      
      Discussion: https://www.postgresql.org/message-id/CAB7nPqSByyEmAVLtEf1KxTRh=PWNKiWKEKQR=e1yGehz=wbymQ@mail.gmail.com
      60f11b87
  7. Apr 06, 2017
  8. Mar 31, 2017
  9. Mar 27, 2017
  10. Mar 20, 2017
  11. Mar 18, 2017
  12. Mar 14, 2017
  13. Mar 13, 2017
  14. Mar 10, 2017
  15. Mar 09, 2017
  16. Mar 07, 2017
    • Heikki Linnakangas's avatar
      A collection of small fixes for the SCRAM patch. · 95c1dbcd
      Heikki Linnakangas authored
      * Add required #includes for htonl. Per buildfarm members pademelon/gaur.
      
      * Remove unnecessary "#include <utils/memutils>".
      
      * Fix checking for empty string in pg_SASL_init. (Reported by Peter
        Eisentraut and his compiler)
      
      * Move code in pg_SASL_init to match the recent changes (commit ba005f19)
        to pg_fe_sendauth() function, where it's copied from.
      
      * Return value of malloc() was not checked for NULL in
        scram_SaltedPassword(). Fix by avoiding the malloc().
      95c1dbcd
    • Heikki Linnakangas's avatar
      Fix comments in SCRAM-SHA-256 patch. · 55acfcbf
      Heikki Linnakangas authored
      Amit Kapila.
      55acfcbf
    • Heikki Linnakangas's avatar
      Support SCRAM-SHA-256 authentication (RFC 5802 and 7677). · 818fd4a6
      Heikki Linnakangas authored
      This introduces a new generic SASL authentication method, similar to the
      GSS and SSPI methods. The server first tells the client which SASL
      authentication mechanism to use, and then the mechanism-specific SASL
      messages are exchanged in AuthenticationSASLcontinue and PasswordMessage
      messages. Only SCRAM-SHA-256 is supported at the moment, but this allows
      adding more SASL mechanisms in the future, without changing the overall
      protocol.
      
      Support for channel binding, aka SCRAM-SHA-256-PLUS is left for later.
      
      The SASLPrep algorithm, for pre-processing the password, is not yet
      implemented. That could cause trouble, if you use a password with
      non-ASCII characters, and a client library that does implement SASLprep.
      That will hopefully be added later.
      
      Authorization identities, as specified in the SCRAM-SHA-256 specification,
      are ignored. SET SESSION AUTHORIZATION provides more or less the same
      functionality, anyway.
      
      If a user doesn't exist, perform a "mock" authentication, by constructing
      an authentic-looking challenge on the fly. The challenge is derived from
      a new system-wide random value, "mock authentication nonce", which is
      created at initdb, and stored in the control file. We go through these
      motions, in order to not give away the information on whether the user
      exists, to unauthenticated users.
      
      Bumps PG_CONTROL_VERSION, because of the new field in control file.
      
      Patch by Michael Paquier and Heikki Linnakangas, reviewed at different
      stages by Robert Haas, Stephen Frost, David Steele, Aleksander Alekseev,
      and many others.
      
      Discussion: https://www.postgresql.org/message-id/CAB7nPqRbR3GmFYdedCAhzukfKrgBLTLtMvENOmPrVWREsZkF8g%40mail.gmail.com
      Discussion: https://www.postgresql.org/message-id/CAB7nPqSMXU35g%3DW9X74HVeQp0uvgJxvYOuA4A-A3M%2B0wfEBv-w%40mail.gmail.com
      Discussion: https://www.postgresql.org/message-id/55192AFE.6080106@iki.fi
      818fd4a6
  17. Feb 25, 2017
    • Tom Lane's avatar
      Remove useless duplicate inclusions of system header files. · 9e3755ec
      Tom Lane authored
      c.h #includes a number of core libc header files, such as <stdio.h>.
      There's no point in re-including these after having read postgres.h,
      postgres_fe.h, or c.h; so remove code that did so.
      
      While at it, also fix some places that were ignoring our standard pattern
      of "include postgres[_fe].h, then system header files, then other Postgres
      header files".  While there's not any great magic in doing it that way
      rather than system headers last, it's silly to have just a few files
      deviating from the general pattern.  (But I didn't attempt to enforce this
      globally, only in files I was touching anyway.)
      
      I'd be the first to say that this is mostly compulsive neatnik-ism,
      but over time it might save enough compile cycles to be useful.
      9e3755ec
  18. Feb 24, 2017
    • Tom Lane's avatar
      Suppress compiler warnings in ecpg test on newer Windows toolchains. · c5658a07
      Tom Lane authored
      nan_test.pgc supposed that it could unconditionally #define isnan()
      and isinf() on WIN32.  This was evidently copied at some point from
      src/include/port/win32.h, but nowadays there's a test on _MSC_VER
      there.  Make nan_test.pgc look the same.
      
      Per buildfarm warnings.  There's no evidence this produces anything
      worse than a warning, and besides it's only a test case, so I don't
      feel a need to back-patch.
      c5658a07
  19. Feb 23, 2017
    • Tom Lane's avatar
      Remove now-dead code for !HAVE_INT64_TIMESTAMP. · b9d092c9
      Tom Lane authored
      This is a basically mechanical removal of #ifdef HAVE_INT64_TIMESTAMP
      tests and the negative-case controlled code.
      
      Discussion: https://postgr.es/m/26788.1487455319@sss.pgh.pa.us
      b9d092c9
    • Tom Lane's avatar
      De-support floating-point timestamps. · b6aa17e0
      Tom Lane authored
      Per discussion, the time has come to do this.  The handwriting has been
      on the wall at least since 9.0 that this would happen someday, whenever
      it got to be too much of a burden to support the float-timestamp option.
      The triggering factor now is the discovery that there are multiple bugs
      in the code that attempts to implement use of integer timestamps in the
      replication protocol even when the server is built for float timestamps.
      The internal float timestamps leak into the protocol fields in places.
      While we could fix the identified bugs, there's a very high risk of
      introducing more.  Trying to build a wall that would positively prevent
      mixing integer and float timestamps is more complexity than we want to
      undertake to maintain a long-deprecated option.  The fact that these
      bugs weren't found through testing also indicates a lack of interest
      in float timestamps.
      
      This commit disables configure's --disable-integer-datetimes switch
      (it'll still accept --enable-integer-datetimes, though), removes direct
      references to USE_INTEGER_DATETIMES, and removes discussion of float
      timestamps from the user documentation.  A considerable amount of code is
      rendered dead by this, but removing that will occur as separate mop-up.
      
      Discussion: https://postgr.es/m/26788.1487455319@sss.pgh.pa.us
      b6aa17e0
  20. Feb 19, 2017
  21. Feb 15, 2017
  22. Feb 06, 2017
  23. Feb 03, 2017
    • Tom Lane's avatar
      Avoid improbable null pointer dereference in pgpassfileWarning(). · 8ac0365c
      Tom Lane authored
      Coverity complained that we might pass a null pointer to strcmp()
      if PQresultErrorField were to return NULL.  That shouldn't be possible,
      since the server is supposed to always provide some SQLSTATE or other
      in an error message.  But we usually defend against such hazards, and
      it only takes a little more code to do so here.
      
      There's no good reason to think this is a live bug, so no back-patch.
      8ac0365c
  24. Jan 24, 2017
  25. Jan 03, 2017
  26. Dec 22, 2016
  27. Dec 11, 2016
    • Tom Lane's avatar
      Use "%option prefix" to set API names in ecpg's lexer. · 92fb6498
      Tom Lane authored
      Clean up some technical debt left behind by commit 72b1e3a2: instead of
      quickly hacking the name of base_yylex() with a #define, set it properly
      with "%option prefix".  This causes the names of pgc.l's other exported
      symbols to change as well, so run around and modify the outside references
      to them as needed.  Similarly, make pgc.l's external references to
      base_yylval use that variable's true name instead of a macro.
      
      The reason for doing this now is that the quick-hack solution will fail
      with future versions of flex, as reported by Дилян Палаузов.
      Hence, back-patch into 9.6 where the previous commit appeared, since
      it's likely people will build 9.6 with newer flex versions during
      its lifetime.
      
      Discussion: https://postgr.es/m/d845c1af-e18d-6651-178f-9f08cdf37e10@aegee.org
      92fb6498
  28. Dec 07, 2016
    • Tom Lane's avatar
      Handle empty or all-blank PAGER setting more sanely in psql. · 18f8f784
      Tom Lane authored
      If the PAGER environment variable is set but contains an empty string,
      psql would pass it to "sh" which would silently exit, causing whatever
      query output we were printing to vanish entirely.  This is quite
      mystifying; it took a long time for us to figure out that this was the
      cause of Joseph Brenner's trouble report.  Rather than allowing that
      to happen, we should treat this as another way to specify "no pager".
      (We could alternatively treat it as selecting the default pager, but
      it seems more likely that the former is what the user meant to achieve
      by setting PAGER this way.)
      
      Nonempty, but all-white-space, PAGER values have the same behavior, and
      it's pretty easy to test for that, so let's handle that case the same way.
      
      Most other cases of faulty PAGER values will result in the shell printing
      some kind of complaint to stderr, which should be enough to diagnose the
      problem, so we don't need to work harder than this.  (Note that there's
      been an intentional decision not to be very chatty about apparent failure
      returns from the pager process, since that may happen if, eg, the user
      quits the pager with control-C or some such.  I'd just as soon not start
      splitting hairs about which exit codes might merit making our own report.)
      
      libpq's old PQprint() function was already on board with ignoring empty
      PAGER values, but for consistency, make it ignore all-white-space values
      as well.
      
      It's been like this a long time, so back-patch to all supported branches.
      
      Discussion: https://postgr.es/m/CAFfgvXWLOE2novHzYjmQK8-J6TmHz42G8f3X0SORM44+stUGmw@mail.gmail.com
      18f8f784
  29. Dec 05, 2016
    • Robert Haas's avatar
      libpq: Fix another bug in 721f7bd3. · a0ae54df
      Robert Haas authored
      If we failed to connect to one or more hosts, and then afterwards we
      find one that fails to be read-write, the latter error message was
      clobbering any earlier ones.  Repair.
      
      Mithun Cy, slightly revised by me.
      a0ae54df
Loading