summaryrefslogtreecommitdiff
path: root/src/port/Makefile
Commit message (Collapse)AuthorAgeFilesLines
* Revert error-throwing wrappers for the printf family of functions.Tom Lane2015-05-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 16304a013432931e61e623c8d85e9fe24709d9ba, except for its changes in src/port/snprintf.c; as well as commit cac18a76bb6b08f1ecc2a85e46c9d2ab82dd9d23 which is no longer needed. Fujii Masao reported that the previous commit caused failures in psql on OS X, since if one exits the pager program early while viewing a query result, psql sees an EPIPE error from fprintf --- and the wrapper function thought that was reason to panic. (It's a bit surprising that the same does not happen on Linux.) Further discussion among the security list concluded that the risk of other such failures was far too great, and that the one-size-fits-all approach to error handling embodied in the previous patch is unlikely to be workable. This leaves us again exposed to the possibility of the type of failure envisioned in CVE-2015-3166. However, that failure mode is strictly hypothetical at this point: there is no concrete reason to believe that an attacker could trigger information disclosure through the supposed mechanism. In the first place, the attack surface is fairly limited, since so much of what the backend does with format strings goes through stringinfo.c or psprintf(), and those already had adequate defenses. In the second place, even granting that an unprivileged attacker could control the occurrence of ENOMEM with some precision, it's a stretch to believe that he could induce it just where the target buffer contains some valuable information. So we concluded that the risk of non-hypothetical problems induced by the patch greatly outweighs the security risks. We will therefore revert, and instead undertake closer analysis to identify specific calls that may need hardening, rather than attempt a universal solution. We have kept the portion of the previous patch that improved snprintf.c's handling of errors when it calls the platform's sprintf(). That seems to be an unalloyed improvement. Security: CVE-2015-3166
* Add error-throwing wrappers for the printf family of functions.Noah Misch2015-05-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | All known standard library implementations of these functions can fail with ENOMEM. A caller neglecting to check for failure would experience missing output, information exposure, or a crash. Check return values within wrappers and code, currently just snprintf.c, that bypasses the wrappers. The wrappers do not return after an error, so their callers need not check. Back-patch to 9.0 (all supported versions). Popular free software standard library implementations do take pains to bypass malloc() in simple cases, but they risk ENOMEM for floating point numbers, positional arguments, large field widths, and large precisions. No specification demands such caution, so this commit regards every call to a printf family function as a potential threat. Injecting the wrappers implicitly is a compromise between patch scope and design goals. I would prefer to edit each call site to name a wrapper explicitly. libpq and the ECPG libraries would, ideally, convey errors to the caller rather than abort(). All that would be painfully invasive for a back-patched security fix, hence this compromise. Security: CVE-2015-3166
* Use Intel SSE 4.2 CRC instructions where available.Heikki Linnakangas2015-04-141-2/+6
| | | | | | | | | | | | | | | | | | Modern x86 and x86-64 processors with SSE 4.2 support have special instructions, crc32b and crc32q, for calculating CRC-32C. They greatly speed up CRC calculation. Whether the instructions can be used or not depends on the compiler and the target architecture. If generation of SSE 4.2 instructions is allowed for the target (-msse4.2 flag on gcc and clang), use them. If they are not allowed by default, but the compiler supports the -msse4.2 flag to enable them, compile just the CRC-32C function with -msse4.2 flag, and check at runtime whether the processor we're running on supports it. If it doesn't, fall back to the slicing-by-8 algorithm. (With the common defaults on current operating systems, the runtime-check variant is what you get in practice.) Abhijit Menon-Sen, heavily modified by me, reviewed by Andres Freund.
* Reorganize our CRC source files again.Heikki Linnakangas2015-04-141-1/+1
| | | | | | | | | | Now that we use CRC-32C in WAL and the control file, the "traditional" and "legacy" CRC-32 variants are not used in any frontend programs anymore. Move the code for those back from src/common to src/backend/utils/hash. Also move the slicing-by-8 implementation (back) to src/port. This is in preparation for next patch that will add another implementation that uses Intel SSE 4.2 instructions to calculate CRC-32C, where available.
* Build src/port/dirmod.c only on Windows.Tom Lane2015-03-141-1/+1
| | | | | | | | | | | Since commit ba7c5975adea74c6f17bdb0e0427ad85962092a2, port/dirmod.c has contained only Windows-specific functions. Most platforms don't seem to mind uselessly building an empty file, but OS X for one issues warnings. Hence, treat dirmod.c as a Windows-specific file selected by configure rather than one that's always built. We can revert this change if dirmod.c ever gains any non-Windows functionality again. Back-patch to 9.4 where the mentioned commit appeared.
* Build fls.o only when AC_REPLACE_FUNCS so dictates via $(LIBOBJS).Noah Misch2015-03-071-1/+1
| | | | | | By building it unconditionally, libpgport inadvertently replaced any libc version of the function. This is essentially a code cleanup; any effect on performance is almost surely too small to notice.
* Unlink static libraries before rebuilding them.Noah Misch2015-03-011-0/+2
| | | | | | | | When the library already exists in the build directory, "ar" preserves members not named on its command line. This mattered when, for example, a "configure" rerun dropped a file from $(LIBOBJS). libpgport carried the obsolete member until "make clean". Back-patch to 9.0 (all supported versions).
* Move pg_crc.c to src/common, and remove pg_crc_tables.hHeikki Linnakangas2015-02-091-1/+1
| | | | | | | | | | | | | | | | | To get CRC functionality in a client program, you now need to link with libpgcommon instead of libpgport. The CRC code has nothing to do with portability, so libpgcommon is a better home. (libpgcommon didn't exist when pg_crc.c was originally moved to src/port.) Remove the possibility to get CRC functionality by just #including pg_crc_tables.h. I'm not aware of any extensions that actually did that and couldn't simply link with libpgcommon. This also moves the pg_crc.h header file from src/include/utils to src/include/common, which will require changes to any external programs that currently does #include "utils/pg_crc.h". That seems acceptable, as include/common is clearly the right home for it now, and the change needed to any such programs is trivial.
* Move username lookup functions from /port to /commonBruce Momjian2014-01-101-1/+1
| | | | Per suggestion from Peter E and Alvaro
* Fix incorrect error message reported for non-existent usersBruce Momjian2013-12-181-1/+1
| | | | | | | | Previously, lookups of non-existent user names could return "Success"; it will now return "User does not exist" by resetting errno. This also centralizes the user name lookup code in libpgport. Report and analysis by Nicolas Marchildon; patch by me
* Switch dependency order of libpgcommon and libpgportPeter Eisentraut2013-10-171-3/+2
| | | | | | | | | | | Continuing 63f32f3416a8b4f8e057dc184e8e8eae734ccc8a, libpgcommon should depend on libpgport, but not vice versa. But wait_result_to_str() in wait_error.c depends on pstrdup() in libpgcommon. So move exec.c and wait_error.c from libpgport to libpgcommon. Also switch the link order in the place that's actually used by the failing ecpg builds. The function declarations have been left in port.h for now. That should perhaps be separated sometime.
* Move pqsignal() to libpgport.Tom Lane2013-03-171-1/+2
| | | | | | | | | We had two copies of this function in the backend and libpq, which was already pretty bogus, but it turns out that we need it in some other programs that don't use libpq (such as pg_test_fsync). So put it where it probably should have been all along. The signal-mask-initialization support in src/backend/libpq/pqsignal.c stays where it is, though, since we only need that in the backend.
* Add support for piping COPY to/from an external program.Heikki Linnakangas2013-02-271-1/+2
| | | | | | | | | | | | | | | | | | This includes backend "COPY TO/FROM PROGRAM '...'" syntax, and corresponding psql \copy syntax. Like with reading/writing files, the backend version is superuser-only, and in the psql version, the program is run in the client. In the passing, the psql \copy STDIN/STDOUT syntax is subtly changed: if you the stdin/stdout is quoted, it's now interpreted as a filename. For example, "\copy foo from 'stdin'" now reads from a file called 'stdin', not from standard input. Before this, there was no way to specify a filename called stdin, stdout, pstdin or pstdout. This creates a new function in pgport, wait_result_to_str(), which can be used to convert the exit status of a process, as returned by wait(3), to a human-readable string. Etsuro Fujita, reviewed by Amit Kapila.
* Centralize single quote escaping in src/port/quotes.cMagnus Hagander2013-01-051-1/+1
| | | | | | For code-reuse in upcoming functionality in pg_basebackup. Zoltan Boszormenyi
* Unify some tar functionality across different partsMagnus Hagander2013-01-011-1/+1
| | | | | | | | | | Move some of the tar functionality that existed mostly duplicated in both pg_dump and the walsender basebackup functionality into port/tar.c instead, so it can be used from both. It will also be used by pg_basebackup in the future, which would've caused a third copy of it around. Zoltan Boszormenyi and Magnus Hagander
* Fix dependency tracking for src/port/%_srv.o filesPeter Eisentraut2012-05-081-1/+8
| | | | | | | | | | Because they use their own compilation rule, they don't use the dependency tracking logic from Makefile.global. To make sure that dependency tracking works anyway for the *_srv.o files, depend on their *.o siblings as well, which do have proper dependencies. It's a hack that might fail someday if there is a *_srv.o without a corresponding *.o, but it works for now (and those would probably go into src/backend/port/ anyway).
* Simplify makefile rulePeter Eisentraut2012-04-291-2/+1
| | | | | Instead of writing out the .c -> .o rule, use the default one, so that dependency tracking can be used.
* Move CRC tables to libpgport, and provide them in a separate include file.Tom Lane2012-02-281-2/+2
| | | | | | | | | | | | | | | | | | This makes it much more convenient to build tools for Postgres that are separately compiled and require a matching CRC implementation. To prevent multiple copies of the CRC polynomial tables being introduced into the postgres binaries, they are now included in the static library libpgport that is mainly meant for replacement system functions. That seems like a bit of a kludge, but there's no better place. This cleans up building of the tools pg_controldata and pg_resetxlog, which previously had to build their own copies of pg_crc.o. In the future, external programs that need access to the CRC tables can include the tables directly from the new header file pg_crc_tables.h. Daniel Farina, reviewed by Abhijit Menon-Sen and Tom Lane
* Attempt to fix MSVC builds and other fls-related breakage.Robert Haas2012-02-091-1/+1
| | | | Thanks to Andrew Dunstan for bringing this to my attention.
* Make pgbench use erand48() rather than random().Robert Haas2011-08-031-2/+2
| | | | | | | | | | | | | | | | | | glibc renders random() thread-safe by wrapping a futex lock around it; testing reveals that this limits the performance of pgbench on machines with many CPU cores. Rather than switching to random_r(), which is only available on GNU systems and crashes unless you use undocumented alchemy to initialize the random state properly, switch to our built-in implementation of erand48(), which is both thread-safe and concurrent. Since the list of reasons not to use the operating system's erand48() is getting rather long, rename ours to pg_erand48() (and similarly for our implementations of lrand48() and srand48()) and just always use those. We were already doing this on Cygwin anyway, and the glibc implementation is not quite thread-safe, so pgbench wouldn't be able to use that either. Per discussion with Tom Lane.
* Move pipe.c into the backend.Robert Haas2011-02-041-4/+0
| | | | | It's full of backend-specific error reporting, so it's neither possible nor necessary for this to be used from frontend code.
* Use $(MAKE) rather than make.Robert Haas2011-02-041-1/+1
| | | | Per buildfarm.
* Make handling of errcodes.h more consistent with other generated headers.Robert Haas2011-02-041-0/+7
| | | | | | | | | | This fixes make distprep, and seems more robust in other ways as well. Some special handling is required because errcodes.txt is needed by some stuff in src/port, but just by src/backend as is the case for the other generated headers. While I'm at it, fix a few other things that were overlooked in the original patch.
* Move a couple of initdb's subroutines into src/port/.Tom Lane2010-12-101-4/+6
| | | | | | | | | | mkdir_p and check_data_dir will be useful in CREATE TABLESPACE, since we have agreed that that command should handle subdirectory creation just like initdb creates the PGDATA directory. Push them into src/port/ so that they are available to both initdb and the backend. Rename to pg_mkdir_p and pg_check_dir, just to be on the safe side. Add FreeBSD's copyright notice to pgmkdirp.c, since that's where the code came from originally (this really should have been in initdb.c). Very marginal code/comment cleanup.
* When reporting the server as not responding, if the hostname wasBruce Momjian2010-11-241-1/+1
| | | | | | | | | supplied, also print the IP address. This allows IPv4 and IPv6 failures to be distinguished. Also useful when a hostname resolves to multiple IP addresses. Also, remove use of inet_ntoa() and use our own inet_net_ntop() in all places, including in libpq, because it is thread-safe.
* Remove cvs keywords from all files.Magnus Hagander2010-09-201-1/+1
|
* Move copydir.c from src/port to src/backend/storage/fileRobert Haas2010-07-021-2/+2
| | | | | | | | | | | | | The previous commit to make copydir() interruptible prevented postgres.exe from linking on MinGW and Cygwin, because on those platforms libpgport_srv.a can't freely reference symbols defined by the backend. Since that code is already backend-specific anyway, just move the whole file into the backend rather than adding further kludges to deal with the symbols needed by CHECK_FOR_INTERRUPTS(). This probably needs some further cleanup, but this commit just moves the file as-is, which should hopefully be enough to turn the buildfarm green again.
* Update of install-sh, mkinstalldirs, and associated configuryPeter Eisentraut2009-08-261-2/+2
| | | | | | | | | | | | | | Update install-sh to that from Autoconf 2.63, plus our Darwin-specific changes (which I simplified a bit). install-sh is now able to install multiple files in one run, so we could simplify our makefiles sometime. install-sh also now has a -d option to create directories, so we don't need mkinstalldirs anymore. Use AC_PROG_MKDIR_P in configure.in, so we can use mkdir -p when available instead of install-sh -d. For consistency with the rest of the world, the corresponding make variable has been renamed from $(mkinstalldirs) to $(MKDIR_P).
* Omit src/port/pipe.c on non-Windows platforms. It's useless and drawsTom Lane2008-11-251-3/+7
| | | | complaints about empty object files on some platforms, eg Darwin.
* Added --htmldir option to pg_config, equivalent to the new configure option.Peter Eisentraut2008-02-181-1/+2
|
* Change initdb and CREATE DATABASE to actively reject attempts to createTom Lane2007-09-281-15/+18
| | | | | | | | | | | | databases with encodings that are incompatible with the server's LC_CTYPE locale, when we can determine that (which we can on most modern platforms, I believe). C/POSIX locale is compatible with all encodings, of course, so there is still some usefulness to CREATE DATABASE's ENCODING option, but this will insulate us against all sorts of recurring complaints caused by mismatched settings. I moved initdb's existing LC_CTYPE-to-encoding mapping knowledge into a new src/port/ file so it could be shared by CREATE DATABASE.
* Replace useless uses of := by = in makefiles.Peter Eisentraut2007-02-091-2/+2
|
* Add dependency to fix parallel-make race condition. Alexander DupuyTom Lane2006-07-141-1/+3
|
* Add comment about the use of pg_config_paths.h.Bruce Momjian2006-06-261-1/+5
|
* Build server libpgport with all non-FRONTEND object files. This is toBruce Momjian2006-05-081-14/+4
| | | | | fix a Win32 bug where pipe.c included a file that used FRONTEND, but it wasn't on the server-build list.
* Allow installation into directories containing spaces in the name.Peter Eisentraut2005-12-091-4/+7
|
* Fix problems with PGXS builds against an installation tree that wasTom Lane2005-09-271-1/+3
| | | | | | | relocated after installation. We can't trust the installation paths inserted into Makefile.global by configure, so instead we must get the paths from pg_config. This requires extending pg_config to support all the separately-configurable path names, but that was on TODO anyway.
* No server version of snprintf needed, so remove Makefile rule.Bruce Momjian2005-08-121-4/+1
|
* Reverse out changes to canonicalize_path(), per suggestion from Tom.Bruce Momjian2005-08-121-3/+2
|
* Modify canonicalize_path() so if we would return a trailing "..", throwBruce Momjian2005-08-121-2/+3
| | | | an error instead.
* Department of second thoughts. Remove FRONTEND from snprintf.c becauseBruce Momjian2005-03-201-2/+1
| | | | | snprintf is called before the memory system is started. We have to just malloc/free. There are no elogs in the code so we should be fine.
* Fix typo in Makefile.Bruce Momjian2005-03-201-2/+2
|
* Another change for FRONTEND snprintf.c.Bruce Momjian2005-03-201-1/+4
|
* Mark snprintf.c as a file that uses FRONTEND and needs to a version inBruce Momjian2005-03-201-1/+2
| | | | | the server-side port library. Somehow I missed that change when I added memory allocation to snprintf.c.
* Add a missing dependency: the "install" target requires "all" to haveNeil Conway2004-10-271-2/+2
| | | | been built before it. Per report from Kris Jurka.
* please find attached an alternate submission which addresses open itemBruce Momjian2004-10-061-2/+2
| | | | | | | | | | | | | "make pgxs install by default". It is up to the committers to chose. (1) there is only one "install" target. no more "install-all-headers". it simplifies/changes several makefiles. (2) the documentation reflects the change. (3) a minor fix on pgxs to use a nicer patch without a double slash. Fabien Coelho
* Make libpgport be front-end only and make libpgport_srv be a backendBruce Momjian2004-10-041-7/+42
| | | | | library that uses palloc, ereport, etc. This simplifies the makefiles for client applications.
* > Am Dienstag, 17. August 2004 14:26 schrieb Fabien COELHO:Bruce Momjian2004-08-281-3/+3
| | | | | | | | | | | | > > The patch adds missing the "libpgport.a" file to the installation under > > "install-all-headers". It is needed by some contribs. I install the > > library in "pkglibdir", but I was wondering whether it should be "libdir"? Please find attached a small patch against current CVS head that fixes pgport library installation so that it goes to libdir instead of pkglibdir. It works for me. Fabien Coelho
* > Please find enclose a submission to fix these problems.Bruce Momjian2004-08-201-1/+8
| | | | | | | | | | | | | | | | | | | | | | > > The patch adds missing the "libpgport.a" file to the installation under > "install-all-headers". It is needed by some contribs. I install the > library in "pkglibdir", but I was wondering whether it should be "libdir"? > I was wondering also whether it would make sense to have a "libpgport.so"? > > It fixes various macros which are used by contrib makefiles, especially > libpq_*dir and LDFLAGS when used under PGXS. It seems to me that they are > needed to > > It adds the ability to test and use PGXS with contribs, with "make > USE_PGXS=1". Without the macro, this is exactly as before, there should be > no difference, esp. wrt the vpath feature that seemed broken by previous > submission. So it should not harm anybody, and it is useful at least to me. > > It fixes some inconsistencies in various contrib makefiles > (useless override, ":=" instead of "="). Fabien COELHO
* Create a C version of pg_config.Bruce Momjian2004-08-011-1/+3
| | | | Andrew Dunstan