Commit Graph

720 Commits

Author SHA1 Message Date
Magnus Hagander d7d7157109 Change hba load failure message to LOG instead of WARNING.
Per comment from Tom.
2009-03-04 18:43:38 +00:00
Magnus Hagander a2e9de79a6 Log a warning instead of shutting down the system if we can't load
pg_hba.conf on reload (for example due to a permission error).

Selena Deckelmann
2009-03-04 08:43:15 +00:00
Tom Lane fd9e2accef When we are in error recursion trouble, arrange to suppress translation and
encoding conversion of any elog/ereport message being sent to the frontend.
This generalizes a patch that I put in last October, which suppressed
translation of only specific messages known to be associated with recursive
can't-translate-the-message behavior.  As shown in bug #4680, we need a more
general answer in order to have some hope of coping with broken encoding
conversion setups.  This approach seems a good deal less klugy anyway.

Patch in all supported branches.
2009-03-02 21:18:43 +00:00
Magnus Hagander 16c46d5d7a Go over all OpenSSL return values and make sure we compare them
to the documented API value. The previous code got it right as
it's implemented, but accepted too much/too little compared to
the API documentation.

Per comment from Zdenek Kotala.
2009-01-28 15:06:47 +00:00
Tom Lane 006b9e7a92 Tweak the existing special case for AIX in pg_getaddrinfo_all() to handle
yet another failure case in AIX's getaddrinfo().  Per report and patch
by Andrew Chernow.
2009-01-23 19:58:06 +00:00
Magnus Hagander 1b4e729eaa Make krb_realm and krb_server_hostname be pg_hba options only, and remove
their GUCs.

In passing, noted that the pg_hba options for krb5 authentication weren't
listed at all - so add this.
2009-01-09 10:13:19 +00:00
Magnus Hagander b09f930d2e Add hba parameter include_realm to krb5, gss and sspi authentication, used
to pass the full username@realm string to the authentication instead of
just the username. This makes it possible to use pg_ident.conf to authenticate
users from multiple realms as different database users.
2009-01-07 13:09:21 +00:00
Magnus Hagander 32c469d7b1 Allow krb_realm (krb5, gssapi and sspi) and krb_server_hostname (krb5 only)
authentication options to be set in pg_hba.conf on a per-line basis, to
override the defaults set in postgresql.conf.
2009-01-07 12:38:11 +00:00
Magnus Hagander 67b94f5fb4 Fix cut/paste error that caused all errors from REQUIRE_AUTH_OPTION to say
it was the ldaptls parameter that was wrong...
2009-01-02 11:34:03 +00:00
Bruce Momjian 511db38ace Update copyright for 2009. 2009-01-01 17:24:05 +00:00
Magnus Hagander b8753e5955 Replace both send and receive BIO routines in the SSL code with our own,
calling recv() and send(). This makes the calls go through the socket
emulation code on Win32, making them for example properly interruptible.
2008-12-14 19:39:37 +00:00
Magnus Hagander 4e81628653 Properly unregister OpenSSL callbacks when libpq is done with
it's connection. This is required for applications that unload
the libpq library (such as PHP) in which case we'd otherwise
have pointers to these functions when they no longer exist.

This needs a bit more testing before we can consider a backpatch,
so not doing that yet.

In passing, remove unused functions in backend/libpq.

Bruce Momjian and Magnus Hagander, per report and analysis
by Russell Smith.
2008-12-03 20:04:26 +00:00
Magnus Hagander 5d2a1a41d0 Support regular expressions in pg_ident.conf. 2008-11-28 14:26:58 +00:00
Bruce Momjian 170b66a0c5 Issue a proper error message when MD5 is attempted when
db_user_namespace is enabled.

Also document this limitation.
2008-11-20 20:45:30 +00:00
Magnus Hagander f179d5ea99 Add support for using SSL client certificates to authenticate to the
database (only for SSL connections, obviously).
2008-11-20 11:48:26 +00:00
Magnus Hagander 3c486fbd1c Control client certificate requesting with the pg_hba option "clientcert"
instead of just relying on the root certificate file to be present.
2008-11-20 09:29:36 +00:00
Peter Eisentraut f426fbf746 Ident authentication over Unix-domain sockets on Solaris, using
getpeerucred() function.

Author: Garick Hamlin <ghamlin@isc.upenn.edu>
2008-11-18 13:10:20 +00:00
Magnus Hagander 53a5026b5c Remove support for (insecure) crypt authentication.
This breaks compatibility with pre-7.2 versions.
2008-10-28 12:10:44 +00:00
Magnus Hagander e98ca4d383 Make hba parsing error messages more specific. 2008-10-27 20:04:45 +00:00
Magnus Hagander 3ca5aa6cbc Replace now unnecessary goto statements by using return directly. 2008-10-24 12:48:31 +00:00
Magnus Hagander 81f3e109b7 Remove a "TODO-list" structure at the top of the file, referring back
to the old set of SSL patches. Hasn't been updated since, and we keep
the TODOs in the "real" TODO list, really...
2008-10-24 12:24:35 +00:00
Magnus Hagander f5020684db Remove large parts of the old SSL readme, that consisted of a couple
of copy/paste:d emails. Much of the contents had already been migrated
into the main documentation, some was out of date and some just plain
wrong.

Keep the "protocol-flowchart" which can still be useful.
2008-10-24 11:48:29 +00:00
Magnus Hagander 7356381ef5 * make pg_hba authoption be a set of 0 or more name=value pairs
* make LDAP use this instead of the hacky previous method to specify
  the DN to bind as
* make all auth options behave the same when they are not compiled
  into the server
* rename "ident maps" to "user name maps", and support them for all
  auth methods that provide an external username

This makes a backwards incompatible change in the format of pg_hba.conf
for the ident, PAM and LDAP authentication methods.
2008-10-23 13:31:10 +00:00
Magnus Hagander 448950b37b Fix error messages from recent pg_hba parsing patch to use errcontext()
to indicate where the error occurred.
2008-09-15 20:55:04 +00:00
Magnus Hagander 9872381090 Parse pg_hba.conf in postmaster, instead of once in each backend for
each connection. This makes it possible to catch errors in the pg_hba
file when it's being reloaded, instead of silently reloading a broken
file and failing only when a user tries to connect.

This patch also makes the "sameuser" argument to ident authentication
optional.
2008-09-15 12:32:57 +00:00
Magnus Hagander 26e6991a2d Rearrange the code in auth.c so that all functions for a single authentication
method is grouped together in a reasonably similar way, keeping the "global
shared functions" together in their own section as well. Makes it a lot easier
to find your way around the code.
2008-08-01 11:41:12 +00:00
Magnus Hagander c30c1b8786 Move ident authentication code into auth.c along with the other authenciation
routines, leaving hba.c to deal only with processing the HBA specific files.
2008-08-01 09:09:49 +00:00
Tom Lane 94be06af76 Fix parsing of LDAP URLs so it doesn't reject spaces in the "suffix" part.
Per report from César Miguel Oliveira Alves.
2008-07-24 17:51:55 +00:00
Tom Lane e76ef8d581 Remove some redundant tests and improve comments in next_token().
Cosmetic, but it might make this a bit less confusing to the next reader.
2008-07-24 17:43:45 +00:00
Tom Lane 3405f2b925 Use error message wordings for permissions checks on .pgpass and SSL private
key files that are similar to the one for the postmaster's data directory
permissions check.  (I chose to standardize on that one since it's the most
heavily used and presumably best-wordsmithed by now.)  Also eliminate explicit
tests on file ownership in these places, since the ensuing read attempt must
fail anyway if it's wrong, and there seems no value in issuing the same error
message for distinct problems.  (But I left in the explicit ownership test in
postmaster.c, since it had its own error message anyway.)  Also be more
specific in the documentation's descriptions of these checks.  Per a gripe
from Kevin Hunter.
2008-03-31 02:43:14 +00:00
Tom Lane 220db7ccd8 Simplify and standardize conversions between TEXT datums and ordinary C
strings.  This patch introduces four support functions cstring_to_text,
cstring_to_text_with_len, text_to_cstring, and text_to_cstring_buffer, and
two macros CStringGetTextDatum and TextDatumGetCString.  A number of
existing macros that provided variants on these themes were removed.

Most of the places that need to make such conversions now require just one
function or macro call, in place of the multiple notational layers that used
to be needed.  There are no longer any direct calls of textout or textin,
and we got most of the places that were using handmade conversions via
memcpy (there may be a few still lurking, though).

This commit doesn't make any serious effort to eliminate transient memory
leaks caused by detoasting toasted text objects before they reach
text_to_cstring.  We changed PG_GETARG_TEXT_P to PG_GETARG_TEXT_PP in a few
places where it was easy, but much more could be done.

Brendan Jurd and Tom Lane
2008-03-25 22:42:46 +00:00
Tatsuo Ishii 325c0a39e4 Add server side lo_import(filename, oid) function. 2008-03-22 01:55:14 +00:00
Bruce Momjian fca9fff41b More README src cleanups. 2008-03-21 13:23:29 +00:00
Peter Eisentraut 0474dcb608 Refactor backend makefiles to remove lots of duplicate code 2008-02-19 10:30:09 +00:00
Tom Lane 81e770857d Since GSSAPI and SSPI authentication don't work in protocol version 2,
issue a helpful error message instead of sending unparsable garbage.
(It is clearly a design error that this doesn't work, but fixing it
is not worth the trouble at this point.)  Per discussion.
2008-02-08 17:58:46 +00:00
Tom Lane b58d8c9a53 Don't putenv() a string that is allocated in a context that will go away
soon.  I suspect this explains bug #3902, though I'm still not able to
reproduce that.
2008-01-30 04:11:19 +00:00
Bruce Momjian 9098ab9e32 Update copyrights in source tree to 2008. 2008-01-01 19:46:01 +00:00
Peter Eisentraut 178c78c79f Fix typo 2007-11-28 13:30:16 +00:00
Peter Eisentraut 542d04e179 correct capitalization 2007-11-27 12:17:27 +00:00
Bruce Momjian fdf5a5efb7 pgindent run for 8.3. 2007-11-15 21:14:46 +00:00
Peter Eisentraut 166f67cebe Message improvements 2007-11-15 20:04:38 +00:00
Magnus Hagander 4b606ee444 Add parameter krb_realm used by GSSAPI, SSPI and Kerberos
to validate the realm of the connecting user. By default
it's empty meaning no verification, which is the way
Kerberos authentication has traditionally worked in
PostgreSQL.
2007-11-09 17:31:07 +00:00
Peter Eisentraut 5f9869d0ee Use "alternative" instead of "alternate" where it is clearer. 2007-11-07 12:24:24 +00:00
Bruce Momjian 7f9de5407a Fix GSS API pointer checking.
Kris Jurka
2007-09-14 15:58:02 +00:00
Magnus Hagander f903278e2d Silence compiler warning on mingw 2007-07-24 11:16:36 +00:00
Magnus Hagander d602592494 Make it possible, and default, for MingW to build with SSPI support
by dynamically loading the function that's missing from the MingW
headers and library.
2007-07-24 09:00:27 +00:00
Magnus Hagander f70866fb23 SSPI authentication on Windows. GSSAPI compatible client when doing Kerberos
against a Unix server, and Windows-specific server-side authentication
using SSPI "negotiate" method (Kerberos or NTLM).

Only builds properly with MSVC for now.
2007-07-23 10:16:54 +00:00
Tom Lane 72c7badbab Fix some warnings (probably actual bugs) generated by new GSSAPI code
when built on a 64-bit machine.  Per buildfarm results extracted by Stefan.
2007-07-12 20:36:11 +00:00
Magnus Hagander 784fd04940 Enable GSSAPI to build using MSVC. Always build GSSAPI when Kerberos is
enabled, because the only Kerberos library supported always contains it.
2007-07-12 14:43:21 +00:00
Magnus Hagander 65a513c249 Support GSSAPI builds where the header is <gssapi.h> and not <gssapi/gssapi.h>,
such as OpenBSD (possibly all Heimdal).

Stefan Kaltenbrunner
2007-07-12 14:36:52 +00:00