Commit Graph

355 Commits

Author SHA1 Message Date
Tom Lane b05d3ae1ed Error message editing in backend/libpq, backend/postmaster, backend/tcop.
Along the way, fix some logic problems in pgstat_initstats, notably the
bogus assumption that malloc returns zeroed memory.
2003-07-22 19:00:12 +00:00
Tom Lane da78e3e2eb index() -> strchr(). 2003-06-15 16:21:39 +00:00
Bruce Momjian b4cea00a1f IPv6 cleanups.
Kurt Roeckx
Andrew Dunstan
2003-06-12 07:36:51 +00:00
Bruce Momjian e5549a272d Back out this patch because it is patched inside a later patch.
---------------------------------------------------------------------------

here is a patch that allows CIDR netmasks in pg_hba.conf. It allows two
address/mask forms:

. address/maskbits, or
. address netmask (as now)

If the patch is accepted I will submit a documentation patch to cover
it.

This is submitted by agreement with Kurt Roeckx, who has worked on a
patch that covers this and other IPv6 issues.
2003-06-12 07:00:57 +00:00
Bruce Momjian b78961b0da Here is a patch that allows CIDR netmasks in pg_hba.conf. It allows two
address/mask forms:

. address/maskbits, or
. address netmask (as now)

If the patch is accepted I will submit a documentation patch to cover
it.

This is submitted by agreement with Kurt Roeckx, who has worked on a
patch that covers this and other IPv6 issues.

Andrew Dunstan
2003-06-12 02:12:58 +00:00
Bruce Momjian db7e46a76d Use closesocket() for all socket/pipe closing, because Win32 requires
it, and map that to close() on Unix.
2003-04-25 01:24:00 +00:00
Tom Lane cb7fb3ca95 First phase of FE/BE protocol modifications: new StartupPacket layout
with variable-width fields.  No more truncation of long user names.
Also, libpq can now send its environment-variable-driven SET commands
as part of the startup packet, saving round trips to server.
2003-04-17 22:26:02 +00:00
Tom Lane 3fd5faed5b Second try at avoiding conflicts with system isblank(). 2003-04-13 04:07:17 +00:00
Tom Lane ae02cf3c44 Guard against macro versions of isblank(). 2003-04-12 22:28:33 +00:00
Tom Lane 61c9ea0f3c Fix load_user/load_group to not leave dangling pointers around if the
config files are present on one pass and not present on a later pass.
2003-04-03 21:25:02 +00:00
Bruce Momjian a18331004a Add start time to pg_stat_activity
Neil Conway
2003-03-20 03:34:57 +00:00
Bruce Momjian 35911088ff A typo in src/backend/libpq/hba.c breaks local ident authentication
in the SO_PEERCRED case. elif is misspelled as elsif for the test.
A patch is attached.

Bruno Wolff III
2003-03-15 16:18:25 +00:00
Bruce Momjian c3e9699f21 Enable IPv6 connections to the server, and add pg_hba.conf IPv6 entries
if the OS supports it.  Code will still compile on non-IPv6-aware
machines (feature added by Bruce).

Nigel Kukard
2003-01-06 03:18:27 +00:00
Bruce Momjian c78701697c The actual segfault was caused by a double pfree(), but ISTM that
failing to find pg_hba.conf should be a fatal error anyway, so I
increased the priority of the elog() from LOG to FATAL and refactored
the code a little bit.

Neil Conway
2002-12-14 18:49:37 +00:00
Bruce Momjian 92d77c69e5 Fix line count error reporting in config files, like pg_hba.conf, per
report from Oliver Elphick.

Backpatch to 7.3.
2002-12-11 22:17:11 +00:00
Bruce Momjian 38ffbb95d5 Back out V6 code, caused postmaster startup failure. 2002-12-06 04:37:05 +00:00
Bruce Momjian 8fc86dd593 We have just finished porting the old KAME IPv6 patch over to
postgresql version 7.3, but yea... this patch adds full IPv6
support to postgres. I've tested it out on 7.2.3 and has
been running perfectly stable.

CREDITS:
 The KAME Project  (Initial patch)
 Nigel Kukard  <nkukard@lbsd.net>
 Johan Jordaan  <johanj@lando.co.za>
2002-12-06 03:46:37 +00:00
Bruce Momjian f988edb4e1 Add OpenBSD local indent credentials, from William Ahern. 2002-12-03 21:50:44 +00:00
Bruce Momjian e50f52a074 pgindent run. 2002-09-04 20:31:48 +00:00
Bruce Momjian 97ac103289 Remove sys/types.h in files that include postgres.h, and hence c.h,
because c.h has sys/types.h.
2002-09-02 02:47:07 +00:00
Tom Lane 893fe4919d Treat \r as white space when parsing pg_hba and related files.
Should make life easier for DBAs who insist on editing files with
Windoze tools.
2002-06-26 14:52:08 +00:00
Bruce Momjian d84fe82230 Update copyright to 2002. 2002-06-20 20:29:54 +00:00
Bruce Momjian ea43fec258 Fix problem with new pg_hba.conf code where the same comparison function
was incorrectly used for both qsort and bsearch.
2002-04-28 22:49:07 +00:00
Bruce Momjian 6cdba03d38 Fix password code to deal with new quoting code. 2002-04-25 00:56:36 +00:00
Bruce Momjian 43a3543a4e Authentication improvements:
A new pg_hba.conf column, USER
Allow specifiction of lists of users separated by commas
Allow group names specified by +
Allow include files containing lists of users specified by @
Allow lists of databases, and database files
Allow samegroup in database column to match group name matching dbname
Removal of secondary password files
Remove pg_passwd utility
Lots of code cleanup in user.c and hba.c
New data/global/pg_pwd format
New data/global/pg_group file
2002-04-04 04:25:54 +00:00
Tom Lane 36f693ec69 Further work on elog cleanup: fix some bogosities in elog's logic about
when to send what to which, prevent recursion by introducing new COMMERROR
elog level for client-communication problems, get rid of direct writes
to stderr in backend/libpq files, prevent non-error elogs from going to
client during the authentication cycle.
2002-03-04 01:46:04 +00:00
Tom Lane 9facc585ad Fix use of 'char' to hold result of getc, per bug report forwarded by
Oliver Elphick.  A few other minor cleanups while at it.
2002-01-09 19:13:41 +00:00
Tom Lane 1131ba3135 send() attempt for IDENT communication should retry on EINTR. 2001-11-12 04:29:23 +00:00
Bruce Momjian ea08e6cd55 New pgindent run with fixes suggested by Tom. Patch manually reviewed,
initdb/regression tests pass.
2001-11-05 17:46:40 +00:00
Bruce Momjian 6783b2372e Another pgindent run. Fixes enum indenting, and improves #endif
spacing.  Also adds space for one-line comments.
2001-10-28 06:26:15 +00:00
Bruce Momjian b81844b173 pgindent run on all C files. Java run to follow. initdb/regression
tests pass.
2001-10-25 05:50:21 +00:00
Bruce Momjian 3e9014d02c Add ALIGN() for cred packet, for OpenBSD. 2001-09-26 19:57:01 +00:00
Bruce Momjian be83aac6d2 Disable local creds on OpenBSD because it doesn't support it. Document
supported platforms in pg_hba.conf.
2001-09-26 19:54:12 +00:00
Tom Lane c1c888a9de Code review for MD5 authorization patch. Clean up some breakage
(salts were always zero!?), add much missing documentation.
2001-09-21 20:31:49 +00:00
Bruce Momjian 8c55728295 Add CRED alignment for NetBSD. 2001-09-07 19:59:04 +00:00
Bruce Momjian a7621c92ae Update SCM_CREDS for Net/Free/BSD-OS. Add configure checks. 2001-09-07 19:52:54 +00:00
Bruce Momjian 04c1f72920 PAM authentication:
> pam_strerror() should be used a few more times, rather than just saying
> "Error!".  Also, the configure.in snippet seems wrong.  You add
> -I$pam_prefix/include/security to $INCLUDES and then you #include
> <security/pam_appl.h>.  This whole thing is probably unnecessary, since
> PAM is a system library on the systems where it exists, so the headers
> and libraries are found automatically, unlike OpenSSL and
> Kerberos.

See attached revised patch. (I'm sure the configure.in stuff can be done
right/better, I'm just not enough of a autoconf guru to know what to
change it to.)

Dominic J. Eidson
2001-09-06 03:23:38 +00:00
Bruce Momjian 8dbaca424f Fix SCM_CREDS for FreeBSD, from Teodor Sigaev. 2001-08-21 15:49:17 +00:00
Bruce Momjian 9bee8a1fd9 Add missing include for SCM_CREDS. 2001-08-21 15:21:25 +00:00
Bruce Momjian ca66b2370a Fix SO_PEERCRED printf bug added with SCM_CREDS cleanup. 2001-08-21 14:48:19 +00:00
Bruce Momjian bca9d0cdf4 Add SCM_CREDS to get owner of unix-domain socket on BSD-like systems. 2001-08-21 00:33:28 +00:00
Bruce Momjian bcb0ccf5be Add new MD5 pg_hba.conf keyword. Prevent fallback to crypt. 2001-08-16 16:24:16 +00:00
Bruce Momjian cd6868176e Remove protocol version change. Try MD5 first, then crypt() on all clients. 2001-08-16 04:27:18 +00:00
Bruce Momjian 38bb1abcda Use MD5 for wire protocol encryption for >= 7.2 client/server.
Allow pg_shadow to be MD5 encrypted.
Add ENCRYPTED/UNENCRYPTED option to CREATE/ALTER user.
Add password_encryption postgresql.conf option.
Update wire protocol version to 2.1.
2001-08-15 18:42:16 +00:00
Tom Lane d00b272299 Even though SO_PEERCRED is probably totally unportable, might as well
declare the getsockopt parameter as ACCEPT_TYPE_ARG3 to be consistent
with our other uses of getsockopt.
2001-08-02 14:39:35 +00:00
Tom Lane 49435fb98f Remove SO_PASSCRED step in ident_unix --- according to Helge Bahmann,
that call is not needed to prepare for SO_PEERCRED.  Also, simplify code
so that #ifdef SO_PEERCRED appears in only one place, to make it easier
to support other platforms with variants of this capability.
2001-08-02 14:27:40 +00:00
Tom Lane cb90b2dacb Digging through previous discussion of this patch, I note where Peter E.
points out how silly it is to use Autoconf to test for a preprocessor
symbol, when one can equally easily #ifdef on the symbol itself.
Accordingly, revert configure to prior state and do it that way.
2001-08-01 23:52:50 +00:00
Tom Lane bc042e0a77 Support ident authentication on local (Unix) socket connections, if the
system supports SO_PEERCRED requests for Unix sockets.  This is an
amalgamation of patches submitted by Helge Bahmann and Oliver Elphick,
with some editorializing by yours truly.
2001-08-01 23:25:39 +00:00
Tom Lane 77896d1fc9 Cleanup code for preparsing pg_hba.conf and pg_ident.conf. Store line
number in the data structure so that we can give at least a minimally
useful idea of where the mistake is when we issue syntax error messages.
Move the ClientAuthentication() call to where it should have been in
the first place, so that postmaster memory releasing can happen in a
reasonable place also.  Update obsolete comments, correct one real bug
(auth_argument was not picked up correctly).
2001-07-31 22:55:45 +00:00
Bruce Momjian 462b7d46d1 Load pg_hba.conf and pg_ident.conf on startup and SIGHUP into List of
Lists, and use that for user validation.

Bruce Momjian
2001-07-30 14:50:24 +00:00
Tom Lane d08741eab5 Restructure the key include files per recent pghackers discussion: there
are now separate files "postgres.h" and "postgres_fe.h", which are meant
to be the primary include files for backend .c files and frontend .c files
respectively.  By default, only include files meant for frontend use are
installed into the installation include directory.  There is a new make
target 'make install-all-headers' that adds the whole content of the
src/include tree to the installed fileset, for use by people who want to
develop server-side code without keeping the complete source tree on hand.
Cleaned up a whole lot of crufty and inconsistent header inclusions.
2001-02-10 02:31:31 +00:00
Tom Lane 4c8d2f7f7b Clean up callers of AllocateFile and BasicOpenFile to ensure that
a reasonable error message (including the kernel errno message)
is reported on any file open failure.
2000-08-27 21:50:18 +00:00
Tom Lane ba62fe32c3 Remove long-dead support for invoking queries from dynamically loaded
backend functions via backend PQexec().  The SPI interface has long
been our only documented way to do this, and the backend pqexec/portal
code is unused and suffering bit-rot.  I'm putting it out of its misery.
2000-07-08 03:04:41 +00:00
Bruce Momjian cc2b5e5815 Remove NT-specific file open defines by defining our own open macros for
"rb" and "wb".
2000-06-02 15:57:44 +00:00
Bruce Momjian 52f77df613 Ye-old pgindent run. Same 4-space tabs. 2000-04-12 17:17:23 +00:00
Tom Lane 341b328b18 Fix a bunch of minor portability problems and maybe-bugs revealed by
running gcc and HP's cc with warnings cranked way up.  Signed vs unsigned
comparisons, routines declared static and then defined not-static,
that kind of thing.  Tedious, but perhaps useful...
2000-03-17 02:36:41 +00:00
Tom Lane ecd0bfa81a Look Ma, no MAX_PARSE_BUFFER! (At least not in the backend.
pg_dump and interfaces/odbc still need some work.)
1999-10-23 03:13:33 +00:00
Bruce Momjian e0e7daef6d Lots of patches coming in from me today :-)
When drawing up a very simple "text-drawing" of how the negotiation is done,
I realised I had done this last part (fallback) in a very stupid way. Patch
#4 fixes this, and does it in a much better way.

Included is also the simple text-drawing of how the negotiation is done.

//Magnus
1999-09-27 03:13:16 +00:00
Bruce Momjian 3406901a29 Move some system includes into c.h, and remove duplicates. 1999-07-17 20:18:55 +00:00
Bruce Momjian a71802e12e Final cleanup. 1999-07-16 05:00:38 +00:00
Bruce Momjian a9591ce66a Change #include's to use <> and "" as appropriate. 1999-07-15 23:04:24 +00:00
Bruce Momjian 2e6b1e63a3 Remove unused #includes in *.c files. 1999-07-15 22:40:16 +00:00
Bruce Momjian 07842084fe pgindent run over code. 1999-05-25 16:15:34 +00:00
Bruce Momjian d6e33c8b07 Rename MAP_FILE to USERMAP_FILE for Digital Unix. 1999-05-10 15:17:17 +00:00
Tom Lane b5bcef683b Fix some miscellaneous places that were using raw open() or
fopen(), instead of going through fd.c ... naughty naughty.
1999-05-09 00:54:30 +00:00
Tom Lane 26139bb4a0 Improve error messages when a connection is rejected. 1999-04-16 04:59:03 +00:00
Bruce Momjian 6724a50787 Change my-function-name-- to my_function_name, and optimizer renames. 1999-02-13 23:22:53 +00:00
Bruce Momjian 7a6b562fdf Apply Win32 patch from Horak Daniel. 1999-01-17 06:20:06 +00:00
Marc G. Fournier df1468e251 Many more cleanups... 1998-12-14 06:50:32 +00:00
Bruce Momjian 772a596ed2 Summary
The ident() function in src/backend/libpq/hba.c doesn't cope when
postmaster is contacted on an IP alias. This patch fixes it.

 Malcolm Beattie
1998-10-02 16:18:20 +00:00
Bruce Momjian fa1a8d6a97 OK, folks, here is the pgindent output. 1998-09-01 04:40:42 +00:00
Bruce Momjian af74855a60 Renaming cleanup, no pgindent yet. 1998-09-01 03:29:17 +00:00
Bruce Momjian 6bd323c6b3 Remove un-needed braces around single statements. 1998-06-15 19:30:31 +00:00
Bruce Momjian d3d541996b Cleanup of 'sameuser' patch. 1998-06-13 05:14:56 +00:00
Bruce Momjian 3f372ee6b3 > I needed to do that for the web database that I'm setting up. We
have > 20000 users and each (potentially) needs a separate database
which is > only accessible to them. Rather than having 20000 lines
in pg_hba.conf, > I've patched Postgres so that the special token
"sameuser" in the > database field of pg_hba.conf allows access
only to the username which > is connecting.
1998-06-13 04:27:18 +00:00
Marc G. Fournier 22bd99e462 From: hankin <hankin@consultco.com>
a while back I posted a patch for pg_ident, the patch worked but I didn't
diagnose the problem properly.
on my compiler(gcc2.7.2) this compiles with no errors...

char buf[1000]; if(buf != '\0') {

...but it doesn't compare '\0' with the first char of buf.
1998-03-15 08:18:03 +00:00
Bruce Momjian a32450a585 pgindent run before 6.3 release, with Thomas' requested changes. 1998-02-26 04:46:47 +00:00
Marc G. Fournier 0227a4e114 From: "Denis V. Dmitrienko" <denis@null.net>
What it does:
It solves stupid problem with cyrillic charsets IP-based on-fly recoding.
take a look at /data/charset.conf for details.
You can use any tables for any charset.
Tables are from Russian Apache project.
Tables in this patch contains also Ukrainian characters.

Then run ./configure --enable-recode
1998-02-24 15:27:04 +00:00
Marc G. Fournier c4213aede1 From: Phil Thompson <phil@river-bank.demon.co.uk>
Cleanup patches for previous protocol changes patch
1998-01-27 03:25:14 +00:00
Marc G. Fournier d5bbe2aca5 From: Phil Thompson <phil@river-bank.demon.co.uk>
I've completed the patch to fix the protocol and authentication issues I
was discussing a couple of weeks ago.  The particular changes are:

- the protocol has a version number
- network byte order is used throughout
- the pg_hba.conf file is used to specify what method is used to
  authenticate a frontend (either password, ident, trust, reject, krb4
  or krb5)
- support for multiplexed backends is removed
- appropriate changes to man pages
- the -a switch to many programs to specify an authentication service
  no longer has any effect
- the libpq.so version number has changed to 1.1

The new backend still supports the old protocol so old interfaces won't
break.
1998-01-26 01:42:53 +00:00
Marc G. Fournier da72b903ff Major code cleanup following the pg_password insertion...
...malloc/free -> palloc/pfree
	...fopen/fclose -> AllocateFile/FreeFile
1997-12-09 03:11:25 +00:00
Bruce Momjian 725bbde05c Clean up indenting. 1997-11-10 05:16:00 +00:00
Bruce Momjian c17fa36d3c Add Unix domain socket support, from Goran Thyni, goran@bildbasen.se 1997-11-07 20:52:15 +00:00
Bruce Momjian 59f6a57e59 Used modified version of indent that understands over 100 typedefs. 1997-09-08 21:56:23 +00:00
Bruce Momjian 319dbfa736 Another PGINDENT run that changes variable indenting and case label indenting. Also static variable indenting. 1997-09-08 02:41:22 +00:00
Bruce Momjian 1ccd423235 Massive commit to run PGINDENT on all *.c and *.h files. 1997-09-07 05:04:48 +00:00
Bruce Momjian ed7a17dca0 Remove unneeded stat calls. 1997-08-27 03:48:50 +00:00
Bruce Momjian 022903f22e Reduce open() calls. Replace fopen() calls with calls to fd.c functions. 1997-08-18 02:15:04 +00:00
Bruce Momjian ea5b5357cd Remove more (void) and fix -Wall warnings. 1997-08-12 22:55:25 +00:00
Marc G. Fournier 3a7c93e7f3 From: Dan McGuirk <mcguirk@indirect.com>
Subject: [HACKERS] password authentication

This patch adds support for plaintext password authentication.  To use
it, you add a line like

host         all         0.0.0.0       0.0.0.0           password  pg_pwd.conf


to your pg_hba.conf, where 'pg_pwd.conf' is the name of a file containing
the usernames and password hashes in the format of the first two fields
of a Unix /etc/passwd file.  (Of course, you can use a specific database
name or IP instead.)

Then, to connect with a password through libpq, you use the PQconnectdb()
function, specifying the "password=" tag in the connect string and also
adding the tag "authtype=password".

I also added a command-line switch '-u' to psql that tells it to prompt
for a username and password and use password authentication.
1997-03-12 21:23:16 +00:00
Bruce Momjian 42efa28cf7 There are two prototypes for inet_aton, one in include/inet_aton.h, and
another one in Solaris' port-protos.h.

The following patch will bring inet_aton's prototype into scope for
Ultrix to silence a compilation warning.

If the intention is to have inet_aton's prototype in its own header
filer, the declaration in Solaris' port-protos.h should be removed.
If the declaration in port-protos.h is deemed to be the correct
place, a declaration should be added in Ultrix' port-protos.h

regards
Erik Bertelsen
1997-01-14 01:56:44 +00:00
Bruce Momjian 90ff767d14 I found the following bugs in the version 6.0 (dated 961229).
At least the first two should be fixed before the final release of 6.0.

1)      There is a mismatch between the type declared in the catalog for
        the input/output attributes of pg_type and the actual type of
        values stored in the table.  The type of typinput, typoutput,
        typsend and typreceive are declared oid (26) while the values are
        regproc (24).  The error was there also in previous versions but
        nobody noticed it until an Assert has been added in ExecEvalVar.
        The effect is that it is now impossible to replace the typoutput
        of existing data types with new procs.

2)      The identd hba fails after the first time because the data read
        from the identd socket is not zero-terminated and strlen reports
        an incorrect length if the stack contains garbage, which usually
        happens after the first connection has been made.

3)      The new initdb wants to create itself the data directory. This
        implies that the parent directory must be writable by postgres and
        this may not always be desirable.  A better solution would be to
        allow the directory to be created by root and then filled by initdb.
        It would also nice to have some reasonable default for PGLIB and
        PGDATA like the previous version did.  This applies also to the
        postmaster executable.
1997-01-10 17:40:07 +00:00
Bryan Henderson 9c0afeabb7 More stuff to make it compile on various ports. 1996-11-27 08:16:44 +00:00
Bryan Henderson 7bf3bae1a4 Add #include <sys/types.h> so it works with Ultrix's in.h 1996-11-16 08:09:16 +00:00
Bruce Momjian aaeef4d17d All external function definitions now have prototypes that are checked. 1996-11-10 03:06:38 +00:00
Marc G. Fournier a472a29bb4 I'm getting there, slowly :) 1996-11-06 08:48:33 +00:00
Marc G. Fournier ce4c0ce1de Some compile failure fixes from Keith Parks <emkxp01@mtcc.demon.co.uk> 1996-11-06 06:52:23 +00:00
Bryan Henderson 8ac872b26d Fix bogus format in two error messages. 1996-11-03 09:24:04 +00:00
Marc G. Fournier aed384f12d Quiet a compiler warning (see line 729+, retvalue) 1996-11-03 07:00:57 +00:00
Marc G. Fournier dd5b78f1c1 Remove 'unused variable `open_errno'' 1996-11-03 06:56:52 +00:00
Marc G. Fournier c9002ecb21 Produce a clean compile of backend... 1996-11-03 06:54:38 +00:00
Marc G. Fournier bdd07411b4 remove use of PORTNAME_* 1996-10-31 10:17:09 +00:00
Bryan Henderson aa1eac7979 Make a local isblank() function, since not all standard C libraries have it.
For sparc_solaris, add inet_aton prototype, since it isn't in the header
files included for the standard C library functions.
1996-10-28 09:03:50 +00:00
Bruce Momjian e6cacf9211 Added include needed for recent addition. 1996-10-13 18:37:19 +00:00
Bryan Henderson 4b5c977782 New host-based authentication with ident 1996-10-12 07:47:12 +00:00