Commit 77896d1f authored by Tom Lane's avatar Tom Lane

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).
parent 0889bd00
This diff is collapsed.
......@@ -37,7 +37,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.232 2001/07/30 14:50:22 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.233 2001/07/31 22:55:45 tgl Exp $
*
* NOTES
*
......@@ -805,12 +805,12 @@ ServerLoop(void)
later;
struct timezone tz;
load_hba_and_ident();
gettimeofday(&now, &tz);
nSockets = initMasks(&readmask, &writemask);
load_hba_and_ident();
for (;;)
{
Port *port;
......@@ -876,8 +876,8 @@ ServerLoop(void)
if (got_SIGHUP)
{
got_SIGHUP = false;
load_hba_and_ident();
ProcessConfigFile(PGC_SIGHUP);
load_hba_and_ident();
}
/*
......@@ -1902,20 +1902,25 @@ DoBackend(Port *port)
/* Close the postmaster's other sockets */
ClosePostmasterPorts();
SetProcessingMode(InitProcessing);
/* Save port etc. for ps status */
MyProcPort = port;
/* Reset MyProcPid to new backend's pid */
MyProcPid = getpid();
whereToSendOutput = Remote;
whereToSendOutput = Remote; /* XXX probably doesn't belong here */
/*
* Receive the startup packet (which might turn out to be a cancel
* request packet); then perform client authentication.
*/
status = ProcessStartupPacket(port, false);
if (status == 127)
return 0; /* cancel request processed */
ClientAuthentication(MyProcPort); /* might not return, if failure */
/*
* Don't want backend to be able to see the postmaster random number
* generator state. We have to clobber the static random_seed *and*
......@@ -1990,8 +1995,19 @@ DoBackend(Port *port)
av[ac++] = "-o";
av[ac++] = ttybuf;
}
av[ac] = (char *) NULL;
/*
* Release postmaster's working memory context so that backend can
* recycle the space. Note this does not trash *MyProcPort, because
* ConnCreate() allocated that space with malloc() ... else we'd need
* to copy the Port data here.
*/
MemoryContextSwitchTo(TopMemoryContext);
MemoryContextDelete(PostmasterContext);
PostmasterContext = NULL;
/*
* Debug: print arguments being passed to backend
*/
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.228 2001/07/30 14:50:24 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.229 2001/07/31 22:55:45 tgl Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
......@@ -45,7 +45,6 @@
#include "libpq/pqformat.h"
#include "libpq/pqsignal.h"
#include "miscadmin.h"
#include "libpq/auth.h"
#include "nodes/print.h"
#include "optimizer/cost.h"
#include "optimizer/planner.h"
......@@ -1144,27 +1143,14 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
*
* If we are running under the postmaster, this is done already.
*/
if (IsUnderPostmaster)
{
MemoryContextSwitchTo(TopMemoryContext);
ClientAuthentication(MyProcPort); /* might not return */
/*
* Release postmaster's working memory context so that backend can
* recycle the space. Note this does not trash *MyProcPort, because
* ConnCreate() allocated that space with malloc() ... else we'd need
* to copy the Port data here. We delete it here because the
* authorization file tokens are stored in this context.
*/
MemoryContextDelete(PostmasterContext);
PostmasterContext = NULL;
}
else
if (!IsUnderPostmaster)
{
SetProcessingMode(InitProcessing);
EnableExceptionHandling(true);
MemoryContextInit();
}
SetProcessingMode(InitProcessing);
/*
* Set default values for command-line options.
*/
......@@ -1725,7 +1711,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
if (!IsUnderPostmaster)
{
puts("\nPOSTGRES backend interactive interface ");
puts("$Revision: 1.228 $ $Date: 2001/07/30 14:50:24 $\n");
puts("$Revision: 1.229 $ $Date: 2001/07/31 22:55:45 $\n");
}
/*
......
......@@ -4,7 +4,7 @@
* Interface to hba.c
*
*
* $Id: hba.h,v 1.20 2001/07/30 14:50:24 momjian Exp $
* $Id: hba.h,v 1.21 2001/07/31 22:55:45 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -40,9 +40,9 @@ typedef enum UserAuth
typedef struct Port hbaPort;
int hba_getauthmethod(hbaPort *port);
int authident(struct sockaddr_in * raddr, struct sockaddr_in * laddr,
const char *postgres_username, const char *auth_arg);
void load_hba_and_ident(void);
extern int hba_getauthmethod(hbaPort *port);
extern int authident(struct sockaddr_in *raddr, struct sockaddr_in *laddr,
const char *postgres_username, const char *auth_arg);
extern void load_hba_and_ident(void);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment