aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/libpq/fe-misc.c
Commit message (Collapse)AuthorAge
...
* Save and restore errno across bindtextdomain call, per discussion.Tom Lane2005-07-06
|
* libpq was not consistently checking for memory allocation failures. ThisNeil Conway2005-06-12
| | | | | | | patch adds missing checks to the call sites of malloc(), strdup(), PQmakeEmptyPGresult(), pqResultAlloc(), and pqResultStrdup(), and updates the documentation. Per original report from Volkan Yazici about PQmakeEmptyPGresult() not checking for malloc() failure.
* Use _() macro consistently rather than gettext(). Add translationBruce Momjian2005-02-22
| | | | macros around strings that were missing them.
* Tag appropriate files for rc3PostgreSQL Daemon2004-12-31
| | | | | | | | Also performed an initial run through of upgrading our Copyright date to extend to 2005 ... first run here was very simple ... change everything where: grep 1996-2004 && the word 'Copyright' ... scanned through the generated list with 'less' first, and after, to make sure that I only picked up the right entries ...
* Add new macro as shorthand for MS VC and Borland C++:Bruce Momjian2004-09-27
| | | | | | + #if defined(_MSC_VER) || defined(__BORLANDC__) + #define WIN32_CLIENT_ONLY + #endif
* Pgindent run for 8.0.Bruce Momjian2004-08-29
|
* Update copyright to 2004.Bruce Momjian2004-08-29
|
* Change PGETC to PGSYSCONFDIR and PGLOCALE to PGLOCALEDIR, per Peter.Bruce Momjian2004-06-08
|
* Add PGETC (for pg_service.conf) and PGLOCALE (for locale dir)Bruce Momjian2004-06-03
| | | | | | | | | environment variable processing to libpq. The patch also adds code to our client apps so we set the environment variable directly based on our binary location, unless it is already set. This will allow our applications to emit proper locale messages that are generated in libpq.
* Make the locale location relocatable.Bruce Momjian2004-05-25
| | | | Adjust get_*_path functions to be limited to MAXPGPATH.
* Add PQmbdsplen() which returns the "display length" of a character.Tatsuo Ishii2004-03-15
| | | | | Still some works needed: - UTF-8, MULE_INTERNAL always returns 1
* $Header: -> $PostgreSQL Changes ...PostgreSQL Daemon2003-11-29
|
* Adjust libpq to avoid deadlock when both client and server want to sendTom Lane2003-10-19
| | | | | | data, and both have filled the transmission buffers. One scenario where this can happen was illustrated here: http://archives.postgresql.org/pgsql-hackers/2003-04/msg00979.php
* Another pgindent run with updated typedefs.Bruce Momjian2003-08-08
|
* Fix some more problems with testing error returns from SSL.Tom Lane2003-08-04
|
* Update copyrights to 2003.Bruce Momjian2003-08-04
|
* pgindent run.Bruce Momjian2003-08-04
|
* Change pqInternalNotice to accept a format string and args instead ofTom Lane2003-06-23
| | | | just a preformatted message; per suggestion by Sean Chittenden.
* Update libpq to make new features of FE/BE protocol available toTom Lane2003-06-21
| | | | client applications. Some editorial work on libpq.sgml, too.
* Make libpq thread-safe with configure --with-threads option.Bruce Momjian2003-06-14
| | | | Lee Kindness
* Attached is the complete diff against current CVS.Bruce Momjian2003-06-12
| | | | | | Compiles on BCC 5.5 and VC++ 6.0 (with warnings). Karl Waclawek
* Back out patch that got bundled into another patch.Bruce Momjian2003-06-12
|
* New patch with corrected README attached.Bruce Momjian2003-06-12
| | | | | | Also quickly added mention that it may be a qualified schema name. Rod Taylor
* libpq can now talk to either 3.0 or 2.0 protocol servers. It first triesTom Lane2003-06-08
| | | | | | | 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.)
* Use closesocket() for all socket/pipe closing, because Win32 requiresBruce Momjian2003-04-25
| | | | it, and map that to close() on Unix.
* Another round of protocol changes. Backend-to-frontend messages now allTom Lane2003-04-22
| | | | | | | | | | have length words. COPY OUT reimplemented per new protocol: it doesn't need \. anymore, thank goodness. COPY BINARY to/from frontend works, at least as far as the backend is concerned --- libpq's PQgetline API is not up to snuff, and will have to be replaced with something that is null-safe. libpq uses message length words for performance improvement (no cycles wasted rescanning long messages), but not yet for error recovery.
* Second round of FE/BE protocol changes. Frontend->backend messages nowTom Lane2003-04-19
| | | | have length counts, and COPY IN data is packetized into messages.
* Whack getaddrinfo() patch around until it works, more or less, onTom Lane2003-04-02
| | | | machines without IPv6. Or at least it works on HPUX 10.20 ...
* Use poll(2) in preference to select(2), if available. This solvesTom Lane2003-03-06
| | | | | | problems in applications that may have a large number of files open, such that libpq's socket number exceeds the range supported by fd_set. From Chris Brown.
* Fix various places where global s/NOTICE/WARNING/ was applied with tooTom Lane2003-01-07
| | | | much enthusiasm.
* Code review for connection timeout patch. Avoid unportable assumptionTom Lane2002-10-24
| | | | | | that tv_sec is signed; return a useful error message on timeout failure; honor PGCONNECT_TIMEOUT environment variable in PQsetdbLogin; make code obey documentation statement that timeout=0 means no timeout.
* Fix connection_timeout to use time() and handle timeout == 1.Bruce Momjian2002-10-16
| | | | Code cleanup.
* Mention that resetting the timeout may be wrong on select retry.Bruce Momjian2002-10-14
|
* Restore ptmp_timeout for cases where no timeout is passed.Bruce Momjian2002-10-14
|
* libpq connection_timeout doesn't do subsecond timing, so make the codeBruce Momjian2002-10-14
| | | | clear on that point.
* The attached patch fixes a number of issues related to compiling theBruce Momjian2002-10-03
| | | | | | | | | | | | | | | | | | client utilities (libpq.dll and psql.exe) for win32 (missing defines, adjustments to includes, pedantic casting, non-existent functions) per: http://developer.postgresql.org/docs/postgres/install-win32.html. It compiles cleanly under Windows 2000 using Visual Studio .net. Also compiles clean and passes all regression tests (regular and contrib) under Linux. In addition to a review by the usual suspects, it would be very desirable for someone well versed in the peculiarities of win32 to take a look. Joe Conway
* pgindent run.Bruce Momjian2002-09-04
|
* Remove #ifdef MULTIBYTE per hackers list discussion.Tatsuo Ishii2002-08-29
|
* Add libpq connection timeout parameter.Bruce Momjian2002-08-17
| | | | Denis A Ustimenko
* Update copyright to 2002.Bruce Momjian2002-06-20
|
* Clean up gcc warnings. Avoid the bad habit of putting externs in .cTom Lane2002-06-15
| | | | | | files rather than a header file where they belong. Pay some modicum of attention to picking global routine names that aren't likely to conflict with surrounding applications.
* PATCH SSL_pending() checks in libpq/fe-misc.c:Bruce Momjian2002-06-15
| | | | | | | | | | I am no longer pursuing a total non-blocking implementation. I haven't found a good way to test it with the type of work that I do with PostgreSQL. I do use blocking SSL sockets with this mod and have had no problem whatsoever. The bug that I fixed in this patch is exceptionally hard to reproduce reliably. Jack Bates
* UPDATED PATCH:Bruce Momjian2002-06-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Attached are a revised set of SSL patches. Many of these patches are motivated by security concerns, it's not just bug fixes. The key differences (from stock 7.2.1) are: *) almost all code that directly uses the OpenSSL library is in two new files, src/interfaces/libpq/fe-ssl.c src/backend/postmaster/be-ssl.c in the long run, it would be nice to merge these two files. *) the legacy code to read and write network data have been encapsulated into read_SSL() and write_SSL(). These functions should probably be renamed - they handle both SSL and non-SSL cases. the remaining code should eliminate the problems identified earlier, albeit not very cleanly. *) both front- and back-ends will send a SSL shutdown via the new close_SSL() function. This is necessary for sessions to work properly. (Sessions are not yet fully supported, but by cleanly closing the SSL connection instead of just sending a TCP FIN packet other SSL tools will be much happier.) *) The client certificate and key are now expected in a subdirectory of the user's home directory. Specifically, - the directory .postgresql must be owned by the user, and allow no access by 'group' or 'other.' - the file .postgresql/postgresql.crt must be a regular file owned by the user. - the file .postgresql/postgresql.key must be a regular file owned by the user, and allow no access by 'group' or 'other'. At the current time encrypted private keys are not supported. There should also be a way to support multiple client certs/keys. *) the front-end performs minimal validation of the back-end cert. Self-signed certs are permitted, but the common name *must* match the hostname used by the front-end. (The cert itself should always use a fully qualified domain name (FDQN) in its common name field.) This means that psql -h eris db will fail, but psql -h eris.example.com db will succeed. At the current time this must be an exact match; future patches may support any FQDN that resolves to the address returned by getpeername(2). Another common "problem" is expiring certs. For now, it may be a good idea to use a very-long-lived self-signed cert. As a compile-time option, the front-end can specify a file containing valid root certificates, but it is not yet required. *) the back-end performs minimal validation of the client cert. It allows self-signed certs. It checks for expiration. It supports a compile-time option specifying a file containing valid root certificates. *) both front- and back-ends default to TLSv1, not SSLv3/SSLv2. *) both front- and back-ends support DSA keys. DSA keys are moderately more expensive on startup, but many people consider them preferable than RSA keys. (E.g., SSH2 prefers DSA keys.) *) if /dev/urandom exists, both client and server will read 16k of randomization data from it. *) the server can read empheral DH parameters from the files $DataDir/dh512.pem $DataDir/dh1024.pem $DataDir/dh2048.pem $DataDir/dh4096.pem if none are provided, the server will default to hardcoded parameter files provided by the OpenSSL project. Remaining tasks: *) the select() clauses need to be revisited - the SSL abstraction layer may need to absorb more of the current code to avoid rare deadlock conditions. This also touches on a true solution to the pg_eof() problem. *) the SIGPIPE signal handler may need to be revisited. *) support encrypted private keys. *) sessions are not yet fully supported. (SSL sessions can span multiple "connections," and allow the client and server to avoid costly renegotiations.) *) makecert - a script that creates back-end certs. *) pgkeygen - a tool that creates front-end certs. *) the whole protocol issue, SASL, etc. *) certs are fully validated - valid root certs must be available. This is a hassle, but it means that you *can* trust the identity of the server. *) the client library can handle hardcoded root certificates, to avoid the need to copy these files. *) host name of server cert must resolve to IP address, or be a recognized alias. This is more liberal than the previous iteration. *) the number of bytes transferred is tracked, and the session key is periodically renegotiated. *) basic cert generation scripts (mkcert.sh, pgkeygen.sh). The configuration files have reasonable defaults for each type of use. Bear Giles
* Back out SSL changes. Newer patch available.Bruce Momjian2002-06-14
|
* Attached are a revised set of SSL patches. Many of these patchesBruce Momjian2002-06-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | are motivated by security concerns, it's not just bug fixes. The key differences (from stock 7.2.1) are: *) almost all code that directly uses the OpenSSL library is in two new files, src/interfaces/libpq/fe-ssl.c src/backend/postmaster/be-ssl.c in the long run, it would be nice to merge these two files. *) the legacy code to read and write network data have been encapsulated into read_SSL() and write_SSL(). These functions should probably be renamed - they handle both SSL and non-SSL cases. the remaining code should eliminate the problems identified earlier, albeit not very cleanly. *) both front- and back-ends will send a SSL shutdown via the new close_SSL() function. This is necessary for sessions to work properly. (Sessions are not yet fully supported, but by cleanly closing the SSL connection instead of just sending a TCP FIN packet other SSL tools will be much happier.) *) The client certificate and key are now expected in a subdirectory of the user's home directory. Specifically, - the directory .postgresql must be owned by the user, and allow no access by 'group' or 'other.' - the file .postgresql/postgresql.crt must be a regular file owned by the user. - the file .postgresql/postgresql.key must be a regular file owned by the user, and allow no access by 'group' or 'other'. At the current time encrypted private keys are not supported. There should also be a way to support multiple client certs/keys. *) the front-end performs minimal validation of the back-end cert. Self-signed certs are permitted, but the common name *must* match the hostname used by the front-end. (The cert itself should always use a fully qualified domain name (FDQN) in its common name field.) This means that psql -h eris db will fail, but psql -h eris.example.com db will succeed. At the current time this must be an exact match; future patches may support any FQDN that resolves to the address returned by getpeername(2). Another common "problem" is expiring certs. For now, it may be a good idea to use a very-long-lived self-signed cert. As a compile-time option, the front-end can specify a file containing valid root certificates, but it is not yet required. *) the back-end performs minimal validation of the client cert. It allows self-signed certs. It checks for expiration. It supports a compile-time option specifying a file containing valid root certificates. *) both front- and back-ends default to TLSv1, not SSLv3/SSLv2. *) both front- and back-ends support DSA keys. DSA keys are moderately more expensive on startup, but many people consider them preferable than RSA keys. (E.g., SSH2 prefers DSA keys.) *) if /dev/urandom exists, both client and server will read 16k of randomization data from it. *) the server can read empheral DH parameters from the files $DataDir/dh512.pem $DataDir/dh1024.pem $DataDir/dh2048.pem $DataDir/dh4096.pem if none are provided, the server will default to hardcoded parameter files provided by the OpenSSL project. Remaining tasks: *) the select() clauses need to be revisited - the SSL abstraction layer may need to absorb more of the current code to avoid rare deadlock conditions. This also touches on a true solution to the pg_eof() problem. *) the SIGPIPE signal handler may need to be revisited. *) support encrypted private keys. *) sessions are not yet fully supported. (SSL sessions can span multiple "connections," and allow the client and server to avoid costly renegotiations.) *) makecert - a script that creates back-end certs. *) pgkeygen - a tool that creates front-end certs. *) the whole protocol issue, SASL, etc. *) certs are fully validated - valid root certs must be available. This is a hassle, but it means that you *can* trust the identity of the server. *) the client library can handle hardcoded root certificates, to avoid the need to copy these files. *) host name of server cert must resolve to IP address, or be a recognized alias. This is more liberal than the previous iteration. *) the number of bytes transferred is tracked, and the session key is periodically renegotiated. *) basic cert generation scripts (mkcert.sh, pgkeygen.sh). The configuration files have reasonable defaults for each type of use. Bear Giles
* I'm at the win32 error messages once more. The DLL load thingy doesn'tBruce Momjian2002-04-24
| | | | | | | | | | | | | | | | work on all win9x machines, so i made it go thru a l ookup table instead, using the DLL as last resort. I also moved this out of the fe-misc.c file because of the size of the lookup ta ble. Who knows, we might add more other win32 specific code there in the future. I also fixed a small typo in the pg_config.h.win32 that made the compiler compla in about the gnu snprintf declaration. I tried to make this patch with psql coding style. I've successfully tested this on win2k and win98 and it works fine (i.e. the mes sage shows on win98 too, it didn't with the old implementation). Magnus Naeslund
* Fix for EINTR returns from Win9X socket operations:Bruce Momjian2002-04-15
| | | | | | | | | | | | | | In summary, if a software writer implements timer events or other events which generate a signal with a timing fast enough to occur while libpq is inside connect(), then connect returns -EINTR. The code following the connect call does not handle this and generates an error message. The sum result is that the pg_connect() fails. If the timer or other event is right on the window of the connect() completion time, the pg_connect() may appear to work sporadically. If the event is too slow, pg_connect() will appear to always work and if the event is too fast, pg_connect() will always fail. David Ford
* Change made to elog:Bruce Momjian2002-03-06
| | | | | | | | | | | | | | | | | | | o Change all current CVS messages of NOTICE to WARNING. We were going to do this just before 7.3 beta but it has to be done now, as you will see below. o Change current INFO messages that should be controlled by client_min_messages to NOTICE. o Force remaining INFO messages, like from EXPLAIN, VACUUM VERBOSE, etc. to always go to the client. o Remove INFO from the client_min_messages options and add NOTICE. Seems we do need three non-ERROR elog levels to handle the various behaviors we need for these messages. Regression passed.
* Back out old version and update with newer patch of:Bruce Momjian2002-03-05
| | | | | | Fix for non-blocking connections in libpq Bernhard Herzog
* Here's a patch against 7.1.3 that fixes a problem with sending largerBruce Momjian2002-03-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | queries over non-blocking connections with libpq. "Larger" here basically means that it doesn't fit into the output buffer. The basic strategy is to fix pqFlush and pqPutBytes. The problem with pqFlush as it stands now is that it returns EOF when an error occurs or when not all data could be sent. The latter case is clearly not an error for a non-blocking connection but the caller can't distringuish it from an error very well. The first part of the fix is therefore to fix pqFlush. This is done by to renaming it to pqSendSome which only differs from pqFlush in its return values to allow the caller to make the above distinction and a new pqFlush which is implemented in terms of pqSendSome and behaves exactly like the old pqFlush. The second part of the fix modifies pqPutBytes to use pqSendSome instead of pqFlush and to either send all the data or if not all data can be sent on a non-blocking connection to at least put all data into the output buffer, enlarging it if necessary. The callers of pqPutBytes don't have to be changed because from their point of view pqPutBytes behaves like before. It either succeeds in queueing all output data or fails with an error. I've also added a new API function PQsendSome which analogously to PQflush just calls pqSendSome. Programs using non-blocking queries should use this new function. The main difference is that this function will have to be called repeatedly (calling select() properly in between) until all data has been written. AFAICT, the code in CVS HEAD hasn't changed with respect to non-blocking queries and this fix should work there, too, but I haven't tested that yet. Bernhard Herzog