Commit Graph

180 Commits

Author SHA1 Message Date
Bruce Momjian a16a031411 Make libpq thread-safe with configure --with-threads option.
Lee Kindness
2003-06-14 17:49:54 +00:00
Tom Lane 6bdb7aa4db libpq can now talk to either 3.0 or 2.0 protocol servers. It first tries
protocol 3, then falls back to 2 if postmaster rejects the startup packet
with an old-format error message.  A side benefit of the rewrite is that
SSL-encrypted connections can now be made without blocking.  (I think,
anyway, but do not have a good way to test.)
2003-06-08 17:43:00 +00:00
Tom Lane 32be7207aa Revert kerberos code breakage. 2003-05-16 04:58:03 +00:00
Bruce Momjian 12c9423832 Allow Win32 to compile under MinGW. Major changes are:
Win32 port is now called 'win32' rather than 'win'
        add -lwsock32 on Win32
        make gethostname() be only used when kerberos4 is enabled
        use /port/getopt.c
        new /port/opendir.c routines
        disable GUC unix_socket_group on Win32
        convert some keywords.c symbols to KEYWORD_P to prevent conflict
        create new FCNTL_NONBLOCK macro to turn off socket blocking
        create new /include/port.h file that has /port prototypes, move
          out of c.h
        new /include/port/win32_include dir to hold missing include files
        work around ERROR being defined in Win32 includes
2003-05-15 16:35:30 +00:00
Tom Lane bd8d441775 Second round of FE/BE protocol changes. Frontend->backend messages now
have length counts, and COPY IN data is packetized into messages.
2003-04-19 00:02:30 +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 e4704001ea This patch fixes a bunch of spelling mistakes in comments throughout the
PostgreSQL source code.

Neil Conway
2003-03-10 22:28:22 +00:00
Tom Lane 3cb282f3e6 Guard against array overrun, per report from Yichen Xie. This case
can only occur if the constant DEFAULT_CLIENT_AUTHSVC is given a bogus
value, so it doesn't seem worth back-patching, but I'll fix it in HEAD.
2003-01-29 01:18:21 +00:00
Bruce Momjian 6f0ebe3fba Deal with cases where getpeereid _and_ another creditial method is
supported.
2002-12-03 22:09:20 +00:00
Bruce Momjian e50f52a074 pgindent run. 2002-09-04 20:31:48 +00:00
Bruce Momjian a12b4e279b I checked all the previous string handling errors and most of them were
already fixed by You. However there were a few left and attached patch
should fix the rest of them.

I used StringInfo only in 2 places and both of them are inside debug
ifdefs. Only performance penalty will come from using strlen() like all
the other code does.

I also modified some of the already patched parts by changing
snprintf(buf, 2 * BUFSIZE, ... style lines to
snprintf(buf, sizeof(buf), ... where buf is an array.

Jukka Holappa
2002-09-02 06:11:43 +00:00
Tom Lane 5241a6259f Remove support for version-0 FE/BE protocol, per pghackers discussion.
This breaks support for 6.2 or older client libraries.
2002-08-29 03:22:01 +00:00
Bruce Momjian b6d2faaf24 Hello, i noticed that win32 native stopped working/compiling after the SSL merge
.
So i took the opportunity to fix some stuff:

1. Made the thing compile (typos & needed definitions) with the new pqsecure_* s
tuff, and added fe-secure.c to the win32.mak makefile.
2. Fixed some MULTIBYTE compile errors (when building without MB support).
3. Made it do that you can build with debug info: "nmake -f win32.mak DEBUG=1".
4. Misc small compiler speedup changes.

The resulting .dll has been tested in production, and everything seems ok.
I CC:ed -hackers because i'm not sure about two things:

1. In libpq-int.h I typedef ssize_t as an int because Visual C (v6.0)
doesn't de fine ssize_t. Is that ok, or is there any standard about what
type should be use d for ssize_t?

2. To keep the .dll api consistent regarding MULTIBYTE I just return -1
in fe-connect.c:PQsetClientEncoding() instead of taking away the whole
function. I wonder if i should do any compares with the
conn->client_encoding and return 0 if not hing would have changed (if so
how do i check that?).

Regards

Magnus Naeslund
2002-07-20 05:43:31 +00:00
Bruce Momjian d84fe82230 Update copyright to 2002. 2002-06-20 20:29:54 +00:00
Jan Wieck 469cb65aca Katherine Ward wrote:
> Changes to avoid collisions with WIN32 & MFC names...
> 1.  Renamed:
>       a.  PROC => PGPROC
>       b.  GetUserName() => GetUserNameFromId()
>       c.  GetCurrentTime() => GetCurrentDateTime()
>       d.  IGNORE => IGNORE_DTF in include/utils/datetime.h & utils/adt/datetim
>
> 2.  Added _P to some lex/yacc tokens:
>       CONST, CHAR, DELETE, FLOAT, GROUP, IN, OUT

Jan
2002-06-11 13:40:53 +00:00
Peter Eisentraut 39e77dd365 Remove reference to NAMEDATALEN, which wasn't necessary anyway. 2002-04-24 23:00:40 +00:00
Peter Eisentraut 42c3381fc7 Heimdal support (Kerberos V implementation from KTH) 2002-02-23 04:17:47 +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 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 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 a7621c92ae Update SCM_CREDS for Net/Free/BSD-OS. Add configure checks. 2001-09-07 19:52:54 +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 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 0a3094b6f3 Reorder MD5/crypt so MD5 comes first in the code. 2001-08-17 15:40:07 +00:00
Bruce Momjian 2637f887e7 Remove some unneeded dashes from libpq comments. 2001-08-17 15:11:15 +00:00
Bruce Momjian 27c272917a Add \n to libpq print output where needed. 2001-08-17 15:02:18 +00:00
Bruce Momjian b5453fae74 Force crypt() salt to be null-terminated. 2001-08-17 03:09:31 +00:00
Bruce Momjian da45a0bdb7 Add 4-byte MD5 salt. 2001-08-17 02:59:20 +00:00
Bruce Momjian d4fb1b2388 Move md5.h contents to crypt.h. 2001-08-15 21:08:21 +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
Peter Eisentraut 1a17447be1 NLS for libpq. Clean up the message formats and change the documentation
accordingly.
2001-07-15 13:45:04 +00:00
Bruce Momjian 9e1552607a pgindent run. Make it all clean. 2001-03-22 04:01:46 +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
Bruce Momjian 623bf843d2 Change Copyright from PostgreSQL, Inc to PostgreSQL Global Development Group. 2001-01-24 19:43:33 +00:00
Peter Eisentraut 996832caee Make the location of the Kerberos server key file run time configurable
(rather than compile time). For libpq, even when Kerberos support is
compiled in, the default user name should still fall back to geteuid()
if it can't be determined via the Kerberos system.

A couple of fixes for string type configuration parameters, now that there
is one.
2000-08-25 10:00:35 +00:00
Peter Eisentraut 1652d43358 Remove fmgrstamp-h business -- not needed and confusing
Add options to configure to automatically build for Kerberos
support; no more editing of make files.
2000-06-17 00:10:40 +00:00
Bruce Momjian d45f7dfdca Update kerberos patch 2000-05-27 04:13:05 +00:00
Bruce Momjian 632a7ed759 Back out kerberos changes. Causes compile problems. 2000-05-27 03:58:20 +00:00
Bruce Momjian 9500b35f17 Patch for Kerberos V.
Most (nearly all) of the work was done by David Wragg <dpw@doc.ic.ac.uk>

He patched 6.5.3. I've updated it for 7.0RC5.

It works for MIT kerberos 1.1.1 (and previously for 1.0.6 as well).

I've got the patch against 6.5.3, plus kerberized RPMS.

Mike Wyer <mw@doc.ic.ac.uk>     ||         "Woof?"
2000-05-27 03:39:33 +00:00
Bruce Momjian 52f77df613 Ye-old pgindent run. Same 4-space tabs. 2000-04-12 17:17:23 +00:00
Tom Lane a71daab4b4 Change PQconndefaults() to return a malloc'd array, instead of a static
array.  This allows processing of conninfo strings to be made thread-safe,
at the cost of a small memory leak in applications that use
PQconndefaults() and are not updated to free the returned array via
the new PQconninfoFree() function.  But PQconndefaults() is probably not
used very much, so this seems like a good compromise.
2000-03-11 03:08:37 +00:00
Peter Eisentraut 9ceb5d8a7b Fixed psql double quoting of SQL ids
Fixed libpq printing functions
2000-02-07 23:10:11 +00:00
Bruce Momjian 5c25d60244 Add:
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc

to all files copyright Regents of Berkeley.  Man, that's a lot of files.
2000-01-26 05:58:53 +00:00
Bruce Momjian 0cb6bc70ce Hi!
Here is a patch to bring both libpq and psql to a state where it compiles on
win32 (native) again. A lot of things have changed, and I have not been able
to keep up with them all, so it has been broken for quite a while.
After this patch, at least it compiles. It also talks "basic talk" to the
server, but I have not yet tested all things. Sending queries, and using
e.g. \d or \dt works fine. The rest will have to be tested further.
It also bumps the version on libpq.dll to 7.0.

Everything should be enclosed in #ifdef WIN32, unless I have missed
something. Except for one or maybe two places where I have moved a #include
that should not be used on win32 from the "global area" into a "#ifndef
WIN32 area".


//Magnus
2000-01-18 19:05:31 +00:00
Tom Lane 51f62d505e Standardize on MAXPGPATH as the size of a file pathname buffer,
eliminating some wildly inconsistent coding in various parts of the
system.  I set MAXPGPATH = 1024 in config.h.in.  If anyone is really
convinced that there ought to be a configure-time test to set the
value, go right ahead ... but I think it's a waste of time.
1999-10-25 03:08:03 +00:00
Tom Lane ab5cafa5d3 Update frontend libpq to remove limits on query lengths,
error/notice message lengths, and number of fields per tuple.  Add
pqexpbuffer.c/.h, a frontend version of backend's stringinfo module.
This is first step in applying Mike Ansley's long-query patches,
even though he didn't do any of these particular changes...
1999-08-31 01:37:37 +00:00
Bruce Momjian e259780b13 Enable WIN32 compilation of libpq. 1999-07-19 06:25:40 +00:00
Bruce Momjian e44c931801 Re-add getopt.h check, remove NT-specific tests for it. 1999-07-19 02:27: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 07842084fe pgindent run over code. 1999-05-25 16:15:34 +00:00
Bruce Momjian 4853495e03 Change error messages to oids come out as %u and not %d. Change has no
real affect now.
1999-05-10 00:46:32 +00:00
Bruce Momjian 9cab13c42e I've been having also sorts of fun trying to get kerberos 4
authentifica
tion
working with postgresql-6.4.2 and  KTH-KRB Ebones
(http://www.pdc.kth.se/kth-kr
b) on a dec alpha running DU 4.0D using the native compiler. The
following
patch does the trick.

The rationale behind this is as follows. The KTH-KRB code header files
defines
lots of lengths like INST_SZ,REALM_SZ and KRB_SENDAUTH_VLEN. It also has
a
habit of doing things like

        chararray[LENGTH] = '\0'

to ensure null terminated strings. In my instance this just happens to
blat
the kerberos principal instance string leading to error like

        pg_krb4_recvauth: kerberos error: Can't decode authenticator
(krb_rd_req
)

The application code that comes with KTH-KRB uses "KRB_SENDAUTH_VLEN +
1" and
sometimes uses "INST_SZ + 1" so it seems safest to put that 1 char
buffer in
the appropriate place.


Rodney McDuff
1999-03-14 16:06:43 +00:00
Bruce Momjian 6724a50787 Change my-function-name-- to my_function_name, and optimizer renames. 1999-02-13 23:22:53 +00:00
Marc G. Fournier 8135140a3e |From: "D'Arcy" "J.M." Cain <darcy@druid.net>
|
|The following patch just prevents a warning from being generated because
|the data type isn't specified.
1999-01-22 13:28:50 +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
Marc G. Fournier 9312033071 Date: Sun, 16 Aug 1998 14:56:48 -0400
From: Tom Lane <tgl@sss.pgh.pa.us>
Attached is a patch for this weekend's work on libpq.  I've dealt
with several issues:

        <for details: see message, in pgsql-patches archive for above data>
1998-08-17 03:50:43 +00:00
Bruce Momjian e6311b4ad0 The attached patch implements some changes that were discussed a
couple weeks ago on the hackers and interfaces lists:

1. When the backend sends a NOTICE message and closes the connection
   (typically, because it was told to by the postmaster after
   another backend coredumped), libpq will now print the notice
   and close the connection cleanly.  Formerly, the frontend app
   would usually terminate ungracefully due to a SIGPIPE.  (I am
   not sure if 6.3.2 behaved that way, but the current cvs sources
   do...)

2. libpq's various printouts to stderr are now fed through a single
   "notice processor" routine, which can be overridden by the
   application to direct notices someplace else.  This should ease
   porting libpq to Windows.

I also noticed and fixed a problem in PQprint: when sending output
to a pager subprocess, it would disable SIGPIPE in case the pager
terminates early (this is good) --- but afterwards it reset SIGPIPE
to SIG_DFL, rather than restoring the application's prior setting
(bad).

			regards, tom lane
1998-08-09 02:59:33 +00:00
Bruce Momjian 0da6358f37 Cleanup use of 16 that should be NAMEDATALEN. 1998-07-20 16:57:18 +00:00
Marc G. Fournier bd029bcb4a From: Tom Lane <tgl@sss.pgh.pa.us>
The attached patches respond to discussion that was on pgsql-hackers
around the beginning of June (see thread "libpgtcl bug (and symptomatic
treatment)").  The changes are:

1. Remove code in connectDB that throws away the password after making
a connection.  This doesn't really add much security IMHO --- a bad guy
with access to your client's address space can likely extract the
password anyway, to say nothing of what he might do directly.  And
there's the serious shortcoming that it prevents PQreset() from working
if the database requires a password.

2. Fix coredump problem: fe_sendauth did not guard against being handed
a NULL password pointer.  (This is the proximate cause of the coredump-
during-PQreset problem that Magosanyi Arpad complained of last month.)

3. Remove highly questionable "error recovery" logic in libpgtcl's
pg_exec statement.

I believe the consensus of the discussion last month was in favor of
#1 and #3, but I'm just now getting around to making the change.
I realized that #2 was a bug in process of looking at the change.
1998-07-09 03:32:10 +00:00
Bruce Momjian c765b4b052 Hello!
Through some minor changes, I have been able to compile the libpq
client libraries on the Win32 platform. Since the libpq communications
part has been rewritten, this has become much easier. Enclosed is
a patch that will allow at least Microsoft Visual C++ to compile
libpq into both a static and a dynamic library.  I will take a look
at porting the psql frontend as well, but I figured it was a good
idea to send in these patches first - so no major changes are done
to the files before it gets applied (if it does).

Regards,
  Magnus Hagander
1998-07-03 04:24:16 +00:00
Bruce Momjian 6bd323c6b3 Remove un-needed braces around single statements. 1998-06-15 19:30:31 +00:00
Marc G. Fournier 8d53465ed5 Moved sys/types.h to before netdb.h
From: Vince Vielhaber <vev@michvhf.com>
1998-03-22 04:18:17 +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 8e789e8ef1 From: Phil Thompson <phil@river-bank.demon.co.uk>
Attached is the patch to fix the warning messages from my code.  I also
fixed one which wasn't my code.  Apart from the usual warnings about the
bison/yacc generated code I only have one other warning message.  This
is in gramm.y around line 2234.  I wasn't sure of the fix.

I've also replaced all the calls to free() in gramm.y to calls to
pfree().  Without these I was getting backend crashes with GRANT.  This
might already have been fixed.
1998-01-29 03:24:36 +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 4c04f7724e From: todd brandys <brandys@eng3.hep.uiuc.edu>
An extension to the code to allow for a pg_password authentication database
that is *seperate* from the system password file
1997-12-04 00:28: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 edb58721b8 Fix pgproc names over 15 chars in output. Add strNcpy() function. remove some (void) casts that are unnecessary. 1997-08-12 20:16: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
Marc G. Fournier 4bdf308bdf shared build fails, but the rest compiles...formatting error in the
cc -shared, I believe...
1996-11-03 07:14:32 +00:00
Bruce Momjian 86be8677a9 Added consistent include file handling for MAXHOSTNAMELEN.
If I have introduced any syntax errors with this, I will patch them in
the morning, and Marc will have a good laugh.
1996-10-13 04:50:27 +00:00
Marc G. Fournier c4e53a1411 Fixes for:
Here are a few minor fixes to Postgres95.  Mostly I have added const
to some of the char pointers.  There was also a missing header file
and a place where it looks like "==" was used when "=" was meant.
I also changed some variables from Pfin and Pfout tp pfin and pfout
because the latter shadow global variables and that just seems like
an unsafe practice which I like to avoid.

Submitted by:  "D'Arcy J.M. Cain" <darcy@druid.druid.com>
1996-08-06 16:16:50 +00:00
Marc G. Fournier c13ef1afed My patch to fe-connect.c introduced a new bug which is triggered only, if
Kerberos is being used (attempt to free static memory).
The error was caused by a confusing doublespeak of fe_getauthname():
Returns a pointer to static memory, if you authenticate via Kerberos,
a pointer to dynamic memory otherwise.

Submitted by: Erich Stamberger <eberger@gewi.kfunigraz.ac.at>
1996-07-27 02:27:55 +00:00
Marc G. Fournier 2206b5819d Alot of "changes" from Dr. George's source tree...
Most of the changes in here look to b epurely cosmetic, and don't
affect anything...

...and some stuff is completely questionable...in that I may have reversed
some of the stuf fwe already had :(
1996-07-23 03:35:14 +00:00
Marc G. Fournier d31084e9d1 Postgres95 1.01 Distribution - Virgin Sources 1996-07-09 06:22:35 +00:00