aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/libpq/fe-auth.c
Commit message (Collapse)AuthorAge
* Avoid possibly-unsafe use of Windows' FormatMessage() function.Tom Lane2016-03-29
| | | | | | | | | | | | Whenever this function is used with the FORMAT_MESSAGE_FROM_SYSTEM flag, it's good practice to include FORMAT_MESSAGE_IGNORE_INSERTS as well. Otherwise, if the message contains any %n insertion markers, the function will try to fetch argument strings to substitute --- which we are not passing, possibly leading to a crash. This is exactly analogous to the rule about not giving printf() a format string you're not in control of. Noted and patched by Christian Ullrich. Back-patch to all supported branches.
* Update copyright for 2016Bruce Momjian2016-01-02
| | | | Backpatch certain files through 9.1
* Fix more typos in comments.Heikki Linnakangas2015-05-20
| | | | Patch by CharSyam, plus a few more I spotted with grep.
* libpq: add newlines to SSPI error messagesBruce Momjian2015-04-08
| | | | Report by Tom Lane
* Fix libpq's behavior when /etc/passwd isn't readable.Tom Lane2015-01-11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some users run their applications in chroot environments that lack an /etc/passwd file. This means that the current UID's user name and home directory are not obtainable. libpq used to be all right with that, so long as the database role name to use was specified explicitly. But commit a4c8f14364c27508233f8a31ac4b10a4c90235a9 broke such cases by causing any failure of pg_fe_getauthname() to be treated as a hard error. In any case it did little to advance its nominal goal of causing errors in pg_fe_getauthname() to be reported better. So revert that and instead put some real error-reporting code in place. This requires changes to the APIs of pg_fe_getauthname() and pqGetpwuid(), since the latter had departed from the POSIX-specified API of getpwuid_r() in a way that made it impossible to distinguish actual lookup errors from "no such user". To allow such failures to be reported, while not failing if the caller supplies a role name, add a second call of pg_fe_getauthname() in connectOptions2(). This is a tad ugly, and could perhaps be avoided with some refactoring of PQsetdbLogin(), but I'll leave that idea for later. (Note that the complained-of misbehavior only occurs in PQsetdbLogin, not when using the PQconnect functions, because in the latter we will never bother to call pg_fe_getauthname() if the user gives a role name.) In passing also clean up the Windows-side usage of GetUserName(): the recommended buffer size is 257 bytes, the passed buffer length should be the buffer size not buffer size less 1, and any error is reported by GetLastError() not errno. Per report from Christoph Berg. Back-patch to 9.4 where the chroot failure case was introduced. The generally poor reporting of errors here is of very long standing, of course, but given the lack of field complaints about it we won't risk changing these APIs further back (even though they're theoretically internal to libpq).
* Update copyright for 2015Bruce Momjian2015-01-06
| | | | Backpatch certain files through 9.0
* pgindent run for 9.4Bruce Momjian2014-05-06
| | | | | This includes removing tabs after periods in C comments, which was applied to back branches, so this change should not effect backpatching.
* libpq: pass a memory allocation failure error up to PQconndefaults()Bruce Momjian2014-03-20
| | | | | Previously user name memory allocation failures were ignored and the default user name set to NULL.
* Remove support for native krb5 authenticationMagnus Hagander2014-01-19
| | | | | | | | | | | krb5 has been deprecated since 8.3, and the recommended way to do Kerberos authentication is using the GSSAPI authentication method (which is still fully supported). libpq retains the ability to identify krb5 authentication, but only gives an error message about it being unsupported. Since all authentication is initiated from the backend, there is no need to keep it at all in the backend.
* Update copyright for 2014Bruce Momjian2014-01-07
| | | | | Update all files in head, and files COPYRIGHT and legal.sgml in all back branches.
* C comment: again update comment for pg_fe_sendauth for error casesBruce Momjian2013-12-03
|
* Update C comment for pg_fe_getauthnameBruce Momjian2013-12-03
| | | | This function no longer takes an argument.
* libpq: change PQconndefaults() to ignore invalid service filesBruce Momjian2013-12-03
| | | | | | | | Previously missing or invalid service files returned NULL. Also fix pg_upgrade to report "out of memory" for a null return from PQconndefaults(). Patch by Steve Singer, rewritten by me
* Get rid of use of asprintf() in favor of a more portable implementation.Tom Lane2013-10-22
| | | | | | | | | | | | | | | | asprintf(), aside from not being particularly portable, has a fundamentally badly-designed API; the psprintf() function that was added in passing in the previous patch has a much better API choice. Moreover, the NetBSD implementation that was borrowed for the previous patch doesn't work with non-C99-compliant vsnprintf, which is something we still have to cope with on some platforms; and it depends on va_copy which isn't all that portable either. Get rid of that code in favor of an implementation similar to what we've used for many years in stringinfo.c. Also, move it into libpgcommon since it's not really libpgport material. I think this patch will be enough to turn the buildfarm green again, but there's still cosmetic work left to do, namely get rid of pg_asprintf() in favor of using psprintf(). That will come in a followon patch.
* Add use of asprintf()Peter Eisentraut2013-10-13
| | | | | | | | | Add asprintf(), pg_asprintf(), and psprintf() to simplify string allocation and composition. Replacement implementations taken from NetBSD. Reviewed-by: Álvaro Herrera <alvherre@2ndquadrant.com> Reviewed-by: Asif Naeem <anaeem.it@gmail.com>
* pgindent run for release 9.3Bruce Momjian2013-05-29
| | | | | This is the first run of the Perl-based pgindent script. Also update pgindent instructions.
* Standardize spelling of "nonblocking"Peter Eisentraut2013-04-18
| | | | | Only adjusted the user-exposed messages and documentation, not all source code comments.
* Update copyrights for 2013Bruce Momjian2013-01-01
| | | | | Fully update git head, and update back branches in ./COPYRIGHT and legal.sgml files.
* libpq: Small code clarification, and avoid casting away constPeter Eisentraut2012-03-06
|
* Update copyright notices for year 2012.Bruce Momjian2012-01-01
|
* Pgindent run before 9.1 beta2.Bruce Momjian2011-06-09
|
* Replace use of credential control messages with getsockopt(LOCAL_PEERCRED).Tom Lane2011-05-31
| | | | | | | | | | | | | | | | | | | | | | | | It turns out the reason we hadn't found out about the portability issues with our credential-control-message code is that almost no modern platforms use that code at all; the ones that used to need it now offer getpeereid(), which we choose first. The last holdout was NetBSD, and they added getpeereid() as of 5.0. So far as I can tell, the only live platform on which that code was being exercised was Debian/kFreeBSD, ie, FreeBSD kernel with Linux userland --- since glibc doesn't provide getpeereid(), we fell back to the control message code. However, the FreeBSD kernel provides a LOCAL_PEERCRED socket parameter that's functionally equivalent to Linux's SO_PEERCRED. That is both much simpler to use than control messages, and superior because it doesn't require receiving a message from the other end at just the right time. Therefore, add code to use LOCAL_PEERCRED when necessary, and rip out all the credential-control-message code in the backend. (libpq still has such code so that it can still talk to pre-9.1 servers ... but eventually we can get rid of it there too.) Clean up related autoconf probes, too. This means that libpq's requirepeer parameter now works on exactly the same platforms where the backend supports peer authentication, so adjust the documentation accordingly.
* Fix portability bugs in use of credentials control messages for peer auth.Tom Lane2011-05-30
| | | | | | | | | | | | | | | | | Even though our existing code for handling credentials control messages has been basically unchanged since 2001, it was fundamentally wrong: it did not ensure proper alignment of the supplied buffer, and it was calculating buffer sizes and message sizes incorrectly. This led to failures on platforms where alignment padding is relevant, for instance FreeBSD on 64-bit platforms, as seen in a recent Debian bug report passed on by Martin Pitt (http://bugs.debian.org//cgi-bin/bugreport.cgi?bug=612888). Rewrite to do the message-whacking using the macros specified in RFC 2292, following a suggestion from Theo de Raadt in that thread. Tested by me on Debian/kFreeBSD-amd64; since OpenBSD and NetBSD document the identical CMSG API, it should work there too. Back-patch to all supported branches.
* Clean up most -Wunused-but-set-variable warnings from gcc 4.6Peter Eisentraut2011-04-11
| | | | | | This warning is new in gcc 4.6 and part of -Wall. This patch cleans up most of the noise, but there are some still warnings that are trickier to remove.
* pgindent run before PG 9.1 beta 1.Bruce Momjian2011-04-10
|
* Use GSSAPI library for SSPI auth, when native SSPI is not availableMagnus Hagander2011-01-29
| | | | | | | This allows non-Windows clients to connect to a Windows server with SSPI authentication. Christian Ullrich, largely modified by me
* Stamp copyrights for year 2011.Bruce Momjian2011-01-01
|
* Remove cvs keywords from all files.Magnus Hagander2010-09-20
|
* Allow full SSL certificate verification (wherein libpq checks its host nameTom Lane2010-07-14
| | | | | | | | | | | | | | | parameter against server cert's CN field) to succeed in the case where both host and hostaddr are specified. As with the existing precedents for Kerberos, GSSAPI, SSPI, it is the calling application's responsibility that host and hostaddr match up --- we just use the host name as given. Per bug #5559 from Christopher Head. In passing, make the error handling and messages for the no-host-name-given failure more consistent among these four cases, and correct a lie in the documentation: we don't attempt to reverse-lookup host from hostaddr if host is missing. Back-patch to 8.4 where SSL cert verification was introduced.
* Require hostname to be set when using GSSAPI authentication. Without it,Magnus Hagander2010-03-08
| | | | | | the GSSAPI libraries crash. Noted by Zdenek Kotala
* Update copyright for the year 2010.Bruce Momjian2010-01-02
|
* 8.4 pgindent run, with new combined Linux/FreeBSD/MinGW typedef listBruce Momjian2009-06-11
| | | | provided by Andrew.
* Clean up pg_SSPI_error() coding a little bit: make the messages moreTom Lane2009-03-22
| | | | | consistent, translate where intended, const-ify declarations. Resolves a gripe from Alvaro as well as some stuff I didn't like.
* Remove special-handling of usernames with Kerberos authentication. We willMagnus Hagander2009-01-13
| | | | | | | | | now always use the system username as the default, and not try to pick it up from the kerberos ticket. This fixes the spurious error messages that show up on kerberos-enabled builds when not actually using kerberos, and puts it in line with how other authentication methods work.
* Update copyright for 2009.Bruce Momjian2009-01-01
|
* Remove support for (insecure) crypt authentication.Magnus Hagander2008-10-28
| | | | This breaks compatibility with pre-7.2 versions.
* Fix pg_GSS_error to use conn->errorMessage more sanely, ie, actuallyTom Lane2008-01-31
| | | | | | work with the PQExpBuffer code instead of fighting it. This avoids an unnecessary limit on message length and fixes the latent bug that errorMessage.len wasn't getting set.
* Update copyrights in source tree to 2008.Bruce Momjian2008-01-01
|
* Fix up the PQconnectionUsedPassword mess: create a separateTom Lane2007-12-09
| | | | | | | | PQconnectionNeedsPassword function that tells the right thing for whether to prompt for a password, and improve PQconnectionUsedPassword so that it checks whether the password used by the connection was actually supplied as a connection argument, instead of coming from environment or a password file. Per bug report from Mark Cave-Ayland and subsequent discussion.
* Don't send an empty SSPI negotiation packet at the end of the negotiation.Magnus Hagander2007-12-04
| | | | Fixes bug #3750
* pgindent run for 8.3.Bruce Momjian2007-11-15
|
* Small string tweaksPeter Eisentraut2007-09-25
|
* Make it possible, and default, for MingW to build with SSPI supportMagnus Hagander2007-07-24
| | | | | by dynamically loading the function that's missing from the MingW headers and library.
* Use PQExpBuffer for error message in fe-auth.c.Magnus Hagander2007-07-23
| | | | | In passing, change functions that passedin both PGconn and parts of it to just pass in the PGconn.
* Stupid typo.Magnus Hagander2007-07-23
|
* SSPI authentication on Windows. GSSAPI compatible client when doing KerberosMagnus Hagander2007-07-23
| | | | | | | against a Unix server, and Windows-specific server-side authentication using SSPI "negotiate" method (Kerberos or NTLM). Only builds properly with MSVC for now.
* Enable GSSAPI to build using MSVC. Always build GSSAPI when Kerberos isMagnus Hagander2007-07-12
| | | | enabled, because the only Kerberos library supported always contains it.
* Support GSSAPI builds where the header is <gssapi.h> and not <gssapi/gssapi.h>,Magnus Hagander2007-07-12
| | | | | | such as OpenBSD (possibly all Heimdal). Stefan Kaltenbrunner
* Fix freenig of names in Kerberos when using MIT - need to use theMagnus Hagander2007-07-12
| | | | | | free function provided in the Kerberos library. This fixes a very hard to track down heap corruption on windows when using debug runtimes.
* Add support for GSSAPI authentication.Magnus Hagander2007-07-10
| | | | | | Documentation still being written, will be committed later. Henry B. Hotz and Magnus Hagander