1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-13 16:22:44 +03:00

Another round of those unportable config/build changes :-/

* Add option to build with OpenSSL out of the box. Fix thusly exposed
  bit rot. Although it compiles now, getting this to do something
  useful is left as an exercise.

* Fix Kerberos options to defer checking for required libraries until
  all the other libraries are checked for.

* Change default odbcinst.ini and krb5.srvtab path to PREFIX/etc.

* Install work around for Autoconf's install-sh relative path anomaly.
  Get rid of old INSTL_*_OPTS variables, now that we don't need them
  anymore.

* Use `gunzip -c' instead of g?zcat. Reportedly broke on AIX.

* Look for only one of readline.h or readline/readline.h, not both.

* Make check for PS_STRINGS cacheable. Don't test for the header files
  separately.

* Disable fcntl(F_SETLK) test on Linux.

* Substitute the standard GCC warnings set into CFLAGS in configure,
  don't add it on in Makefile.global.

* Sweep through contrib tree to teach makefiles standard semantics.

... and in completely unrelated news:

* Make postmaster.opts arbitrary options-aware. I still think we need to
  save the environment as well.
This commit is contained in:
Peter Eisentraut
2000-07-09 13:14:19 +00:00
parent b59c03f842
commit 74618e2b82
37 changed files with 1796 additions and 1975 deletions

View File

@@ -4,11 +4,12 @@
# Makefile for libpq subsystem (backend half of libpq interface)
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/backend/libpq/Makefile,v 1.21 2000/07/08 03:04:39 tgl Exp $
# $Header: /cvsroot/pgsql/src/backend/libpq/Makefile,v 1.22 2000/07/09 13:14:05 petere Exp $
#
#-------------------------------------------------------------------------
SRCDIR = ../..
subdir = src/backend/libpq
top_builddir = ../..
include ../../Makefile.global
# be-fsstubs is here for historical reasons, probably belongs elsewhere
@@ -17,6 +18,12 @@ OBJS = be-fsstubs.o \
auth.o crypt.o hba.o password.o \
pqcomm.o pqformat.o pqpacket.o pqsignal.o util.o
# This location might depend on the installation directories. Therefore
# we can't subsitute it into config.h.
ifdef krb_srvtab
CPPFLAGS += -DPG_KRB_SRVTAB='"$(krb_srvtab)"'
endif
all: SUBSYS.o

View File

@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.153 2000/07/08 03:04:13 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.154 2000/07/09 13:14:05 petere Exp $
*
* NOTES
*
@@ -86,11 +86,6 @@
#include "utils/exc.h"
#include "utils/guc.h"
/*
* "postmaster.opts" is a file containing options for postmaser.
* pg_ctl will use it to restart postmaster.
*/
#define OPTSFNAME "postmaster.opts"
#if !defined(MAXINT)
#define MAXINT INT_MAX
@@ -246,7 +241,7 @@ extern int optind,
/*
* postmaster.c - function prototypes
*/
static void pmdaemonize(char *extraoptions);
static void pmdaemonize(int argc, char *argv[]);
static Port *ConnCreate(int serverFd);
static void ConnFree(Port *port);
static void reset_shared(int port);
@@ -267,15 +262,7 @@ static long PostmasterRandom(void);
static void RandomSalt(char *salt);
static void SignalChildren(SIGNAL_ARGS);
static int CountChildren(void);
static int
SetOptsFile(char *progname, int port, char *datadir,
int assert, int nbuf,
int debuglvl, int netserver,
#ifdef USE_SSL
int securenetserver,
#endif
int maxbackends, int reinit,
int silent, int sendstop, char *extraoptions);
static bool CreateOptsFile(int argc, char *argv[]);
extern int BootstrapMain(int argc, char *argv[]);
static pid_t SSDataBase(bool startup);
@@ -564,8 +551,8 @@ PostmasterMain(int argc, char *argv[])
#ifdef USE_SSL
if (!NetServer && SecureNetServer)
{
fprintf(stderr, "For SSL, you must enable TCP/IP connections.\n",
argv[0]);
fprintf(stderr, "%s: For SSL, you must enable TCP/IP connections.\n",
progname);
exit(1);
}
InitSSL();
@@ -602,7 +589,7 @@ PostmasterMain(int argc, char *argv[])
PortList = DLNewList();
if (silentflag)
pmdaemonize(original_extraoptions);
pmdaemonize(argc, argv);
else
{
@@ -612,26 +599,7 @@ PostmasterMain(int argc, char *argv[])
SetPidFname(DataDir);
if (SetPidFile(getpid()) == 0)
{
if (SetOptsFile(
progname, /* postmaster executable file */
PostPortName, /* port number */
DataDir, /* PGDATA */
assert_enabled, /* whether -A is specified
* or not */
NBuffers, /* -B: number of shared buffers */
DebugLvl, /* -d: debug level */
NetServer, /* -i: accept connection from INET */
#ifdef USE_SSL
SecureNetServer, /* -l: use SSL */
#endif
MaxBackends, /* -N: max number of
* backends */
Reinit, /* -n: reinit shared mem after
* failure */
silentflag, /* -S: detach tty */
SendStop, /* -s: send SIGSTOP */
original_extraoptions /* options for backend */
) != 0)
if (!CreateOptsFile(argc, argv))
{
UnlinkPidFile();
ExitPostmaster(1);
@@ -678,7 +646,7 @@ PostmasterMain(int argc, char *argv[])
}
static void
pmdaemonize(char *extraoptions)
pmdaemonize(int argc, char *argv[])
{
int i;
pid_t pid;
@@ -700,26 +668,7 @@ pmdaemonize(char *extraoptions)
*/
if (SetPidFile(pid) == 0)
{
if (SetOptsFile(
progname, /* postmaster executable file */
PostPortName, /* port number */
DataDir, /* PGDATA */
assert_enabled, /* whether -A is specified
* or not */
NBuffers, /* -B: number of shared buffers */
DebugLvl, /* -d: debug level */
NetServer, /* -i: accept connection from INET */
#ifdef USE_SSL
SecureNetServer, /* -l: use SSL */
#endif
MaxBackends, /* -N: max number of
* backends */
Reinit, /* -n: reinit shared mem after
* failure */
1, /* -S: detach tty */
SendStop, /* -s: send SIGSTOP */
extraoptions /* options for backend */
) != 0)
if (!CreateOptsFile(argc, argv))
{
/*
@@ -2202,84 +2151,44 @@ SSDataBase(bool startup)
return (pid);
}
/*
* Create the opts file
*/
static int
SetOptsFile(char *progname, int port, char *datadir,
int assert, int nbuf,
int debuglvl, int netserver,
#ifdef USE_SSL
int securenetserver,
#endif
int maxbackends, int reinit,
int silent, int sendstop, char *extraoptions)
static bool
CreateOptsFile(int argc, char *argv[])
{
int fd;
char optsfile[MAXPGPATH];
char opts[1024];
char buf[1024];
char fullprogname[MAXPGPATH];
char *filename;
FILE *fp;
unsigned i;
/*
* Creating opts file
*/
snprintf(optsfile, sizeof(optsfile), "%s/%s", datadir, OPTSFNAME);
fd = open(optsfile, O_RDWR | O_TRUNC | O_CREAT, 0600);
if (fd < 0)
if (FindExec(fullprogname, argv[0], "postmaster") == -1)
return false;
filename = palloc(strlen(DataDir) + 20);
sprintf(filename, "%s/postmaster.opts", DataDir);
fp = fopen(filename, "w");
if (fp == NULL)
{
fprintf(stderr, "Can't create optsfile:%s", optsfile);
return (-1);
}
snprintf(opts, sizeof(opts), "%s\n-p %d\n-D %s\n", progname, port, datadir);
if (assert)
{
sprintf(buf, "-A %d\n", assert);
strcat(opts, buf);
fprintf(stderr, "%s: cannot create file %s: %s\n", progname,
filename, strerror(errno));
return false;
}
snprintf(buf, sizeof(buf), "-B %d\n", nbuf);
strcat(opts, buf);
fprintf(fp, "%s", fullprogname);
for (i = 1; i < argc; i++)
fprintf(fp, " '%s'", argv[i]);
fputs("\n", fp);
if (debuglvl)
if (ferror(fp))
{
sprintf(buf, "-d %d\n", debuglvl);
strcat(opts, buf);
fprintf(stderr, "%s: writing file %s failed\n", progname, filename);
fclose(fp);
return false;
}
if (netserver)
strcat(opts, "-i\n");
#ifdef USE_SSL
if (securenetserver)
strcat(opts, "-l\n");
#endif
snprintf(buf, sizeof(buf), "-N %d\n", maxbackends);
strcat(opts, buf);
if (!reinit)
strcat(opts, "-n\n");
if (silent)
strcat(opts, "-S\n");
if (sendstop)
strcat(opts, "-s\n");
if (strlen(extraoptions) > 0)
{
strcat(opts, "-o '");
strcat(opts, extraoptions);
strcat(opts, "'");
}
if (write(fd, opts, strlen(opts)) != strlen(opts))
{
perror("Writing to opts file failed");
close(fd);
return (-1);
}
close(fd);
return (0);
fclose(fp);
return true;
}

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.18 2000/06/08 22:37:33 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.19 2000/07/09 13:14:08 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -151,7 +151,7 @@ ValidateBinary(char *path)
* we change directories to the /data directory.
*/
int
FindExec(char *full_path, char *argv0, char *binary_name)
FindExec(char *full_path, const char *argv0, const char *binary_name)
{
char buf[MAXPGPATH + 2];
char *p;

View File

@@ -5,7 +5,7 @@
* to contain some useful information. Differs wildly across
* platforms.
*
* $Header: /cvsroot/pgsql/src/backend/utils/misc/ps_status.c,v 1.1 2000/06/04 01:44:34 petere Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/misc/ps_status.c,v 1.2 2000/07/09 13:14:11 petere Exp $
*
* Copyright 2000 by PostgreSQL Global Development Group
* various details abducted from various places
@@ -20,11 +20,9 @@
#ifdef HAVE_SYS_PSTAT_H
# include <sys/pstat.h> /* for HP-UX */
#endif
#ifdef HAVE_MACHINE_VMPARAM_H
#ifdef HAVE_PS_STRINGS
# include <machine/vmparam.h> /* for old BSD */
#endif
#ifdef HAVE_SYS_EXEC_H
# include <sys/exec.h> /* for old BSD */
# include <sys/exec.h>
#endif
#include "miscadmin.h"