mirror of
https://github.com/postgres/postgres.git
synced 2025-04-25 21:42:33 +03:00
Many more cleanups...
This commit is contained in:
parent
7c3b7d2744
commit
df1468e251
@ -5,9 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
*
|
* $Id: xid.c,v 1.20 1998/12/14 06:50:17 scrappy Exp $
|
||||||
* IDENTIFICATION
|
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/Attic/xid.c,v 1.19 1998/12/14 05:18:33 scrappy Exp $
|
|
||||||
*
|
*
|
||||||
* OLD COMMENTS
|
* OLD COMMENTS
|
||||||
* XXX WARNING
|
* XXX WARNING
|
||||||
@ -41,13 +39,10 @@ xidin(char *representation)
|
|||||||
char *
|
char *
|
||||||
xidout(TransactionId transactionId)
|
xidout(TransactionId transactionId)
|
||||||
{
|
{
|
||||||
/* return(TransactionIdFormString(transactionId)); */
|
|
||||||
char *representation;
|
|
||||||
|
|
||||||
/* maximum 32 bit unsigned integer representation takes 10 chars */
|
/* maximum 32 bit unsigned integer representation takes 10 chars */
|
||||||
representation = palloc(11);
|
char *representation = palloc(11);
|
||||||
|
|
||||||
sprintf(representation, "%u", transactionId);
|
snprintf(representation, 11, "%u", transactionId);
|
||||||
|
|
||||||
return representation;
|
return representation;
|
||||||
|
|
||||||
|
@ -5,19 +5,18 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* The version stuff has not been tested under postgres95 and probably doesn't
|
* The version stuff has not been tested under postgres95 and probably
|
||||||
* work! - jolly 8/19/95
|
* doesn't work! - jolly 8/19/95
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* $Id: version.c,v 1.17 1998/12/14 06:50:19 scrappy Exp $
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/version.c,v 1.16 1998/12/14 05:18:44 scrappy Exp $
|
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* At the point the version is defined, 2 physical relations are created
|
* At the point the version is defined, 2 physical relations are created
|
||||||
* <vname>_added and <vname>_deleted.
|
* <vname>_added and <vname>_deleted.
|
||||||
*
|
*
|
||||||
* In addition, 4 rules are defined which govern the semantics of versions
|
* In addition, 4 rules are defined which govern the semantics of
|
||||||
* w.r.t retrieves, appends, replaces and deletes.
|
* versions w.r.t retrieves, appends, replaces and deletes.
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
*
|
* $Id: user.c,v 1.21 1998/12/14 06:50:18 scrappy Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -35,6 +35,8 @@
|
|||||||
|
|
||||||
static void CheckPgUserAclNotNull(void);
|
static void CheckPgUserAclNotNull(void);
|
||||||
|
|
||||||
|
#define SQL_LENGTH 512
|
||||||
|
|
||||||
/*---------------------------------------------------------------------
|
/*---------------------------------------------------------------------
|
||||||
* UpdatePgPwdFile
|
* UpdatePgPwdFile
|
||||||
*
|
*
|
||||||
@ -47,8 +49,9 @@ void
|
|||||||
UpdatePgPwdFile(char *sql)
|
UpdatePgPwdFile(char *sql)
|
||||||
{
|
{
|
||||||
|
|
||||||
char *filename;
|
char *filename,
|
||||||
char *tempname;
|
*tempname;
|
||||||
|
int bufsize;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a temporary filename to be renamed later. This prevents the
|
* Create a temporary filename to be renamed later. This prevents the
|
||||||
@ -56,18 +59,21 @@ UpdatePgPwdFile(char *sql)
|
|||||||
* be reading from it.
|
* be reading from it.
|
||||||
*/
|
*/
|
||||||
filename = crypt_getpwdfilename();
|
filename = crypt_getpwdfilename();
|
||||||
tempname = (char *) malloc(strlen(filename) + 12);
|
bufsize = strlen(filename) + 12;
|
||||||
sprintf(tempname, "%s.%d", filename, MyProcPid);
|
tempname = (char *) palloc(bufsize);
|
||||||
|
snprintf(tempname, bufsize, "%s.%d", filename, MyProcPid);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copy the contents of pg_shadow to the pg_pwd ASCII file using a the
|
* Copy the contents of pg_shadow to the pg_pwd ASCII file using a the
|
||||||
* SEPCHAR character as the delimiter between fields. Then rename the
|
* SEPCHAR character as the delimiter between fields. Then rename the
|
||||||
* file to its final name.
|
* file to its final name.
|
||||||
*/
|
*/
|
||||||
sprintf(sql, "copy %s to '%s' using delimiters %s", ShadowRelationName, tempname, CRYPT_PWD_FILE_SEPCHAR);
|
snprintf(sql, QRY_LENGTH,
|
||||||
|
"copy %s to '%s' using delimiters %s",
|
||||||
|
ShadowRelationName, tempname, CRYPT_PWD_FILE_SEPCHAR);
|
||||||
pg_exec_query(sql);
|
pg_exec_query(sql);
|
||||||
rename(tempname, filename);
|
rename(tempname, filename);
|
||||||
free((void *) tempname);
|
pfree((void *) tempname);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a flag file the postmaster will detect the next time it
|
* Create a flag file the postmaster will detect the next time it
|
||||||
@ -89,18 +95,17 @@ void
|
|||||||
DefineUser(CreateUserStmt *stmt)
|
DefineUser(CreateUserStmt *stmt)
|
||||||
{
|
{
|
||||||
|
|
||||||
char *pg_shadow;
|
char *pg_shadow,
|
||||||
Relation pg_shadow_rel;
|
sql[SQL_LENGTH];
|
||||||
TupleDesc pg_shadow_dsc;
|
Relation pg_shadow_rel;
|
||||||
HeapScanDesc scan;
|
TupleDesc pg_shadow_dsc;
|
||||||
HeapTuple tuple;
|
HeapScanDesc scan;
|
||||||
Datum datum;
|
HeapTuple tuple;
|
||||||
char sql[512];
|
Datum datum;
|
||||||
char *sql_end;
|
bool exists = false,
|
||||||
bool exists = false,
|
n,
|
||||||
n,
|
inblock;
|
||||||
inblock;
|
int max_id = -1;
|
||||||
int max_id = -1;
|
|
||||||
|
|
||||||
if (stmt->password)
|
if (stmt->password)
|
||||||
CheckPgUserAclNotNull();
|
CheckPgUserAclNotNull();
|
||||||
@ -152,46 +157,23 @@ DefineUser(CreateUserStmt *stmt)
|
|||||||
RelationUnsetLockForWrite(pg_shadow_rel);
|
RelationUnsetLockForWrite(pg_shadow_rel);
|
||||||
heap_close(pg_shadow_rel);
|
heap_close(pg_shadow_rel);
|
||||||
UserAbortTransactionBlock();
|
UserAbortTransactionBlock();
|
||||||
elog(ERROR, "defineUser: user \"%s\" has already been created", stmt->user);
|
elog(ERROR,
|
||||||
|
"defineUser: user \"%s\" has already been created", stmt->user);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Build the insert statment to be executed.
|
* Build the insert statment to be executed.
|
||||||
*/
|
*/
|
||||||
sprintf(sql, "insert into %s(usename,usesysid,usecreatedb,usetrace,usesuper,usecatupd,passwd", ShadowRelationName);
|
snprintf(sql, SQL_LENGTH,
|
||||||
/* if (stmt->password)
|
"insert into %s(usename,usesysid,usecreatedb,usetrace,usesuper,"
|
||||||
strcat(sql, ",passwd"); -- removed so that insert empty string when no password */
|
"usecatupd,passwd,valuntil) values('%s',%d%s%s,'%s','%s')",
|
||||||
if (stmt->validUntil)
|
ShadowRelationName,
|
||||||
strcat(sql, ",valuntil");
|
stmt->user, max_id + 1,
|
||||||
|
(stmt->createdb && *stmt->createdb) ? ",'t','t'" : ",'f','t'",
|
||||||
sql_end = sql + strlen(sql);
|
(stmt->createuser && *stmt->createuser) ? ",'t','t'" : ",'f','t'",
|
||||||
sprintf(sql_end, ") values('%s',%d", stmt->user, max_id + 1);
|
stmt->password ? stmt->password : "''",
|
||||||
if (stmt->createdb && *stmt->createdb)
|
stmt->validUntil ? stmt->valudUntil : "");
|
||||||
strcat(sql_end, ",'t','t'");
|
|
||||||
else
|
|
||||||
strcat(sql_end, ",'f','t'");
|
|
||||||
if (stmt->createuser && *stmt->createuser)
|
|
||||||
strcat(sql_end, ",'t','t'");
|
|
||||||
else
|
|
||||||
strcat(sql_end, ",'f','t'");
|
|
||||||
sql_end += strlen(sql_end);
|
|
||||||
if (stmt->password)
|
|
||||||
{
|
|
||||||
sprintf(sql_end, ",'%s'", stmt->password);
|
|
||||||
sql_end += strlen(sql_end);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strcpy(sql_end, ",''");
|
|
||||||
sql_end += strlen(sql_end);
|
|
||||||
}
|
|
||||||
if (stmt->validUntil)
|
|
||||||
{
|
|
||||||
sprintf(sql_end, ",'%s'", stmt->validUntil);
|
|
||||||
sql_end += strlen(sql_end);
|
|
||||||
}
|
|
||||||
strcat(sql_end, ")");
|
|
||||||
|
|
||||||
pg_exec_query(sql);
|
pg_exec_query(sql);
|
||||||
|
|
||||||
@ -217,13 +199,12 @@ extern void
|
|||||||
AlterUser(AlterUserStmt *stmt)
|
AlterUser(AlterUserStmt *stmt)
|
||||||
{
|
{
|
||||||
|
|
||||||
char *pg_shadow;
|
char *pg_shadow,
|
||||||
|
sql[SQL_LENGTH];
|
||||||
Relation pg_shadow_rel;
|
Relation pg_shadow_rel;
|
||||||
TupleDesc pg_shadow_dsc;
|
TupleDesc pg_shadow_dsc;
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
char sql[512];
|
bool inblock;
|
||||||
char *sql_end;
|
|
||||||
bool inblock;
|
|
||||||
|
|
||||||
if (stmt->password)
|
if (stmt->password)
|
||||||
CheckPgUserAclNotNull();
|
CheckPgUserAclNotNull();
|
||||||
@ -271,47 +252,38 @@ AlterUser(AlterUserStmt *stmt)
|
|||||||
/*
|
/*
|
||||||
* Create the update statement to modify the user.
|
* Create the update statement to modify the user.
|
||||||
*/
|
*/
|
||||||
sprintf(sql, "update %s set", ShadowRelationName);
|
snprintf(sql, SQL_LENGTH, "update %s set", ShadowRelationName);
|
||||||
sql_end = sql;
|
|
||||||
if (stmt->password)
|
if (stmt->password)
|
||||||
{
|
{
|
||||||
sql_end += strlen(sql_end);
|
snprintf(sql, SQL_LENGTH, "%s passwd = '%s'", sql, stmt->password);
|
||||||
sprintf(sql_end, " passwd = '%s'", stmt->password);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stmt->createdb)
|
if (stmt->createdb)
|
||||||
{
|
{
|
||||||
if (sql_end != sql)
|
snprintf(sql, SQL_LENGTH, "%s %susecreatedb='%s'",
|
||||||
strcat(sql_end, ",");
|
stmt->password ? "," : "",
|
||||||
sql_end += strlen(sql_end);
|
*stmt->createdb ? "t" : "f");
|
||||||
if (*stmt->createdb)
|
|
||||||
strcat(sql_end, " usecreatedb = 't'");
|
|
||||||
else
|
|
||||||
strcat(sql_end, " usecreatedb = 'f'");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stmt->createuser)
|
if (stmt->createuser)
|
||||||
{
|
{
|
||||||
if (sql_end != sql)
|
snprintf(sql, SQL_LENGTH, "%s %susesuper='%s'",
|
||||||
strcat(sql_end, ",");
|
(stmt->password || stmt->createdb) ? "," : "",
|
||||||
sql_end += strlen(sql_end);
|
*stmt->createuser ? "t" : "f");
|
||||||
if (*stmt->createuser)
|
|
||||||
strcat(sql_end, " usesuper = 't'");
|
|
||||||
else
|
|
||||||
strcat(sql_end, " usesuper = 'f'");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stmt->validUntil)
|
if (stmt->validUntil)
|
||||||
{
|
{
|
||||||
if (sql_end != sql)
|
snprintf(sql, SQL_LENGTH, "%s %svaluntil='%s'",
|
||||||
strcat(sql_end, ",");
|
(stmt->password || stmt->createdb || stmt->createuser) ? "," : "",
|
||||||
sql_end += strlen(sql_end);
|
stmt->validUntil);
|
||||||
sprintf(sql_end, " valuntil = '%s'", stmt->validUntil);
|
|
||||||
}
|
|
||||||
if (sql_end != sql)
|
|
||||||
{
|
|
||||||
sql_end += strlen(sql_end);
|
|
||||||
sprintf(sql_end, " where usename = '%s'", stmt->user);
|
|
||||||
pg_exec_query(sql);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snprintf(sql, SQL_LENGTH, "%s where usename = '%s'", sql, stmt->user);
|
||||||
|
|
||||||
|
pg_exec_query(sql);
|
||||||
|
|
||||||
/* do the pg_group stuff here */
|
/* do the pg_group stuff here */
|
||||||
|
|
||||||
UpdatePgPwdFile(sql);
|
UpdatePgPwdFile(sql);
|
||||||
@ -402,8 +374,9 @@ RemoveUser(char *user)
|
|||||||
datum = heap_getattr(tuple, Anum_pg_database_datname, pg_dsc, &n);
|
datum = heap_getattr(tuple, Anum_pg_database_datname, pg_dsc, &n);
|
||||||
if (memcmp((void *) datum, "template1", 9))
|
if (memcmp((void *) datum, "template1", 9))
|
||||||
{
|
{
|
||||||
dbase = (char **) realloc((void *) dbase, sizeof(char *) * (ndbase + 1));
|
dbase =
|
||||||
dbase[ndbase] = (char *) malloc(NAMEDATALEN + 1);
|
(char **) repalloc((void *) dbase, sizeof(char *) * (ndbase + 1));
|
||||||
|
dbase[ndbase] = (char *) palloc(NAMEDATALEN + 1);
|
||||||
memcpy((void *) dbase[ndbase], (void *) datum, NAMEDATALEN);
|
memcpy((void *) dbase[ndbase], (void *) datum, NAMEDATALEN);
|
||||||
dbase[ndbase++][NAMEDATALEN] = '\0';
|
dbase[ndbase++][NAMEDATALEN] = '\0';
|
||||||
}
|
}
|
||||||
@ -415,12 +388,12 @@ RemoveUser(char *user)
|
|||||||
while (ndbase--)
|
while (ndbase--)
|
||||||
{
|
{
|
||||||
elog(NOTICE, "Dropping database %s", dbase[ndbase]);
|
elog(NOTICE, "Dropping database %s", dbase[ndbase]);
|
||||||
sprintf(sql, "drop database %s", dbase[ndbase]);
|
snprintf(sql, SQL_LENGTH, "drop database %s", dbase[ndbase]);
|
||||||
free((void *) dbase[ndbase]);
|
pfree((void *) dbase[ndbase]);
|
||||||
pg_exec_query(sql);
|
pg_exec_query(sql);
|
||||||
}
|
}
|
||||||
if (dbase)
|
if (dbase)
|
||||||
free((void *) dbase);
|
pfree((void *) dbase);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Since pg_shadow is global over all databases, one of two things
|
* Since pg_shadow is global over all databases, one of two things
|
||||||
@ -443,7 +416,8 @@ RemoveUser(char *user)
|
|||||||
/*
|
/*
|
||||||
* Remove the user from the pg_shadow table
|
* Remove the user from the pg_shadow table
|
||||||
*/
|
*/
|
||||||
sprintf(sql, "delete from %s where usename = '%s'", ShadowRelationName, user);
|
snprintf(sql, SQL_LENGTH,
|
||||||
|
"delete from %s where usename = '%s'", ShadowRelationName, user);
|
||||||
pg_exec_query(sql);
|
pg_exec_query(sql);
|
||||||
|
|
||||||
UpdatePgPwdFile(sql);
|
UpdatePgPwdFile(sql);
|
||||||
|
@ -5,9 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
*
|
* $Id: view.c,v 1.28 1998/12/14 06:50:18 scrappy Exp $
|
||||||
* IDENTIFICATION
|
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/view.c,v 1.27 1998/12/14 05:18:44 scrappy Exp $
|
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -5,9 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
*
|
* $Id: execAmi.c,v 1.27 1998/12/14 06:50:20 scrappy Exp $
|
||||||
* IDENTIFICATION
|
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/execAmi.c,v 1.26 1998/12/14 05:18:49 scrappy Exp $
|
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -6,8 +6,7 @@
|
|||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* $Id: nodeHash.c,v 1.26 1998/12/14 06:50:21 scrappy Exp $
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeHash.c,v 1.25 1998/12/14 05:18:50 scrappy Exp $
|
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -6,16 +6,15 @@
|
|||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* DESCRIPTION
|
* DESCRIPTION
|
||||||
* This code provides support for a tee node, which allows multiple
|
* This code provides support for a tee node, which allows
|
||||||
* parent in a megaplan.
|
* multiple parent in a megaplan.
|
||||||
*
|
*
|
||||||
* INTERFACE ROUTINES
|
* INTERFACE ROUTINES
|
||||||
* ExecTee
|
* ExecTee
|
||||||
* ExecInitTee
|
* ExecInitTee
|
||||||
* ExecEndTee
|
* ExecEndTee
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* $Id: nodeTee.c,v 1.27 1998/12/14 06:50:22 scrappy Exp $
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/Attic/nodeTee.c,v 1.26 1998/12/14 05:18:51 scrappy Exp $
|
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -6,9 +6,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
*
|
* $Id: be-dumpdata.c,v 1.19 1998/12/14 06:50:23 scrappy Exp $
|
||||||
* IDENTIFICATION
|
|
||||||
* $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-dumpdata.c,v 1.18 1998/11/27 19:52:05 vadim Exp $
|
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -132,8 +130,8 @@ static u_int be_portalcnt = 0;
|
|||||||
PortalEntry *
|
PortalEntry *
|
||||||
be_newportal(void)
|
be_newportal(void)
|
||||||
{
|
{
|
||||||
PortalEntry *entry;
|
PortalEntry *entry;
|
||||||
char buf[PortalNameLength];
|
char buf[PortalNameLength];
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* generate a new name
|
* generate a new name
|
||||||
@ -142,7 +140,7 @@ be_newportal(void)
|
|||||||
if (be_portalcnt == 0)
|
if (be_portalcnt == 0)
|
||||||
be_portaloid = newoid();
|
be_portaloid = newoid();
|
||||||
be_portalcnt++;
|
be_portalcnt++;
|
||||||
sprintf(buf, "be_%d_%d", be_portaloid, be_portalcnt);
|
snprintf(buf, PortalNameLength, "be_%d_%d", be_portaloid, be_portalcnt);
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* initialize the new portal entry and keep track
|
* initialize the new portal entry and keep track
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
/*-------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* crypt.c--
|
* crypt.c--
|
||||||
* Look into pg_shadow and check the encrypted password with the one
|
* Look into pg_shadow and check the encrypted password with
|
||||||
* passed in from the frontend.
|
* the one passed in from the frontend.
|
||||||
*
|
*
|
||||||
* Modification History
|
* Modification History
|
||||||
*
|
*
|
||||||
* Dec 17, 1997 - Todd A. Brandys
|
* Dec 17, 1997 - Todd A. Brandys
|
||||||
* Orignal Version Completed.
|
* Orignal Version Completed.
|
||||||
*
|
*
|
||||||
|
* $Id: crypt.c,v 1.13 1998/12/14 06:50:24 scrappy Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -37,13 +38,12 @@ char *
|
|||||||
crypt_getpwdfilename()
|
crypt_getpwdfilename()
|
||||||
{
|
{
|
||||||
|
|
||||||
static char *pfnam = NULL;
|
static char *pfnam = NULL;
|
||||||
|
int bufsize;
|
||||||
|
|
||||||
if (!pfnam)
|
bufsize = strlen(DataDir) + strlen(CRYPT_PWD_FILE) + 2;
|
||||||
{
|
pfnam = (char *) palloc(bufsize);
|
||||||
pfnam = (char *) malloc(strlen(DataDir) + strlen(CRYPT_PWD_FILE) + 2);
|
snprintf(pfnam, bufsize, "%s/%s", DataDir, CRYPT_PWD_FILE);
|
||||||
sprintf(pfnam, "%s/%s", DataDir, CRYPT_PWD_FILE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return pfnam;
|
return pfnam;
|
||||||
}
|
}
|
||||||
@ -54,16 +54,14 @@ char *
|
|||||||
crypt_getpwdreloadfilename()
|
crypt_getpwdreloadfilename()
|
||||||
{
|
{
|
||||||
|
|
||||||
static char *rpfnam = NULL;
|
static char *rpfnam = NULL;
|
||||||
|
char *pwdfilename;
|
||||||
|
int bufsize;
|
||||||
|
|
||||||
if (!rpfnam)
|
pwdfilename = crypt_getpwdfilename();
|
||||||
{
|
bufsize = strlen(pwdfilename) + strlen(CRYPT_PWD_RELOAD_SUFX) + 1;
|
||||||
char *pwdfilename;
|
rpfnam = (char *) palloc(bufsize);
|
||||||
|
snprintf(rpfnam, bufsize, "%s%s", pwdfilename, CRYPT_PWD_RELOAD_SUFX);
|
||||||
pwdfilename = crypt_getpwdfilename();
|
|
||||||
rpfnam = (char *) malloc(strlen(pwdfilename) + strlen(CRYPT_PWD_RELOAD_SUFX) + 1);
|
|
||||||
sprintf(rpfnam, "%s%s", pwdfilename, CRYPT_PWD_RELOAD_SUFX);
|
|
||||||
}
|
|
||||||
|
|
||||||
return rpfnam;
|
return rpfnam;
|
||||||
}
|
}
|
||||||
@ -145,8 +143,10 @@ crypt_loadpwdfile()
|
|||||||
{ /* free the old data only if this is a
|
{ /* free the old data only if this is a
|
||||||
* reload */
|
* reload */
|
||||||
while (pwd_cache_count--)
|
while (pwd_cache_count--)
|
||||||
free((void *) pwd_cache[pwd_cache_count]);
|
{
|
||||||
free((void *) pwd_cache);
|
pfree((void *) pwd_cache[pwd_cache_count]);
|
||||||
|
}
|
||||||
|
pfree((void *) pwd_cache);
|
||||||
pwd_cache = NULL;
|
pwd_cache = NULL;
|
||||||
pwd_cache_count = 0;
|
pwd_cache_count = 0;
|
||||||
}
|
}
|
||||||
@ -168,7 +168,7 @@ crypt_loadpwdfile()
|
|||||||
buffer[result] = '\0';
|
buffer[result] = '\0';
|
||||||
|
|
||||||
pwd_cache = (char **) realloc((void *) pwd_cache, sizeof(char *) * (pwd_cache_count + 1));
|
pwd_cache = (char **) realloc((void *) pwd_cache, sizeof(char *) * (pwd_cache_count + 1));
|
||||||
pwd_cache[pwd_cache_count++] = strdup(buffer);
|
pwd_cache[pwd_cache_count++] = pstrdup(buffer);
|
||||||
}
|
}
|
||||||
fclose(pwd_file);
|
fclose(pwd_file);
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ crypt_parsepwdentry(char *buffer, char **pwd, char **valdate)
|
|||||||
* store a copy of user password to return
|
* store a copy of user password to return
|
||||||
*/
|
*/
|
||||||
count = strcspn(parse, CRYPT_PWD_FILE_SEPSTR);
|
count = strcspn(parse, CRYPT_PWD_FILE_SEPSTR);
|
||||||
*pwd = (char *) malloc(count + 1);
|
*pwd = (char *) palloc(count + 1);
|
||||||
strncpy(*pwd, parse, count);
|
strncpy(*pwd, parse, count);
|
||||||
(*pwd)[count] = '\0';
|
(*pwd)[count] = '\0';
|
||||||
parse += (count + 1);
|
parse += (count + 1);
|
||||||
@ -209,7 +209,7 @@ crypt_parsepwdentry(char *buffer, char **pwd, char **valdate)
|
|||||||
* store a copy of date login becomes invalid
|
* store a copy of date login becomes invalid
|
||||||
*/
|
*/
|
||||||
count = strcspn(parse, CRYPT_PWD_FILE_SEPSTR);
|
count = strcspn(parse, CRYPT_PWD_FILE_SEPSTR);
|
||||||
*valdate = (char *) malloc(count + 1);
|
*valdate = (char *) palloc(count + 1);
|
||||||
strncpy(*valdate, parse, count);
|
strncpy(*valdate, parse, count);
|
||||||
(*valdate)[count] = '\0';
|
(*valdate)[count] = '\0';
|
||||||
parse += (count + 1);
|
parse += (count + 1);
|
||||||
@ -222,9 +222,9 @@ int
|
|||||||
crypt_getloginfo(const char *user, char **passwd, char **valuntil)
|
crypt_getloginfo(const char *user, char **passwd, char **valuntil)
|
||||||
{
|
{
|
||||||
|
|
||||||
char *pwd;
|
char *pwd,
|
||||||
char *valdate;
|
*valdate;
|
||||||
void *fakeout;
|
void *fakeout;
|
||||||
|
|
||||||
*passwd = NULL;
|
*passwd = NULL;
|
||||||
*valuntil = NULL;
|
*valuntil = NULL;
|
||||||
@ -232,10 +232,10 @@ crypt_getloginfo(const char *user, char **passwd, char **valuntil)
|
|||||||
|
|
||||||
if (pwd_cache)
|
if (pwd_cache)
|
||||||
{
|
{
|
||||||
char **pwd_entry;
|
char **pwd_entry;
|
||||||
char user_search[NAMEDATALEN + 2];
|
char user_search[NAMEDATALEN + 2];
|
||||||
|
|
||||||
sprintf(user_search, "%s\t", user);
|
snprintf(user_search, NAMEDATALEN + 2, "%s\t", user);
|
||||||
fakeout = (void *) &user_search;
|
fakeout = (void *) &user_search;
|
||||||
if ((pwd_entry = (char **) bsearch((void *) &fakeout, (void *) pwd_cache, pwd_cache_count, sizeof(char *), compar_user)))
|
if ((pwd_entry = (char **) bsearch((void *) &fakeout, (void *) pwd_cache, pwd_cache_count, sizeof(char *), compar_user)))
|
||||||
{
|
{
|
||||||
@ -253,56 +253,32 @@ crypt_getloginfo(const char *user, char **passwd, char **valuntil)
|
|||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#if 0
|
|
||||||
MsgType
|
|
||||||
crypt_salt(const char *user)
|
|
||||||
{
|
|
||||||
|
|
||||||
char *passwd;
|
|
||||||
char *valuntil;
|
|
||||||
|
|
||||||
if (crypt_getloginfo(user, &passwd, &valuntil) == STATUS_ERROR)
|
|
||||||
return STARTUP_UNSALT_MSG;
|
|
||||||
|
|
||||||
if (passwd == NULL || *passwd == '\0' || !strcmp(passwd, "\\N"))
|
|
||||||
{
|
|
||||||
if (passwd)
|
|
||||||
free((void *) passwd);
|
|
||||||
if (valuntil)
|
|
||||||
free((void *) valuntil);
|
|
||||||
return STARTUP_UNSALT_MSG;
|
|
||||||
}
|
|
||||||
|
|
||||||
free((void *) passwd);
|
|
||||||
if (valuntil)
|
|
||||||
free((void *) valuntil);
|
|
||||||
return STARTUP_SALT_MSG;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
int
|
int
|
||||||
crypt_verify(Port *port, const char *user, const char *pgpass)
|
crypt_verify(Port *port, const char *user, const char *pgpass)
|
||||||
{
|
{
|
||||||
|
|
||||||
char *passwd;
|
char *passwd,
|
||||||
char *valuntil;
|
*valuntil,
|
||||||
char *crypt_pwd;
|
*crypt_pwd;
|
||||||
int retval = STATUS_ERROR;
|
int retval = STATUS_ERROR;
|
||||||
AbsoluteTime vuntil,
|
AbsoluteTime vuntil,
|
||||||
current;
|
current;
|
||||||
|
|
||||||
if (crypt_getloginfo(user, &passwd, &valuntil) == STATUS_ERROR)
|
if (crypt_getloginfo(user, &passwd, &valuntil) == STATUS_ERROR)
|
||||||
|
{
|
||||||
return STATUS_ERROR;
|
return STATUS_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if (passwd == NULL || *passwd == '\0')
|
if (passwd == NULL || *passwd == '\0')
|
||||||
{
|
{
|
||||||
if (passwd)
|
if (passwd)
|
||||||
free((void *) passwd);
|
{
|
||||||
|
pfree((void *) passwd);
|
||||||
|
}
|
||||||
if (valuntil)
|
if (valuntil)
|
||||||
free((void *) valuntil);
|
{
|
||||||
|
pfree((void *) valuntil);
|
||||||
|
}
|
||||||
return STATUS_ERROR;
|
return STATUS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,28 +287,38 @@ crypt_verify(Port *port, const char *user, const char *pgpass)
|
|||||||
* authentication method being used for this connection.
|
* authentication method being used for this connection.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
crypt_pwd = (port->auth_method == uaCrypt ? crypt(passwd, port->salt) : passwd);
|
crypt_pwd =
|
||||||
|
(port->auth_method == uaCrypt ? crypt(passwd, port->salt) : passwd);
|
||||||
|
|
||||||
if (!strcmp(pgpass, crypt_pwd))
|
if (!strcmp(pgpass, crypt_pwd))
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* check here to be sure we are not past valuntil
|
* check here to be sure we are not past valuntil
|
||||||
*/
|
*/
|
||||||
if (!valuntil || strcmp(valuntil, "\\N") == 0)
|
if (!valuntil || strcmp(valuntil, "\\N") == 0)
|
||||||
|
{
|
||||||
vuntil = INVALID_ABSTIME;
|
vuntil = INVALID_ABSTIME;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
vuntil = nabstimein(valuntil);
|
vuntil = nabstimein(valuntil);
|
||||||
|
}
|
||||||
current = GetCurrentAbsoluteTime();
|
current = GetCurrentAbsoluteTime();
|
||||||
if (vuntil != INVALID_ABSTIME && vuntil < current)
|
if (vuntil != INVALID_ABSTIME && vuntil < current)
|
||||||
|
{
|
||||||
retval = STATUS_ERROR;
|
retval = STATUS_ERROR;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
retval = STATUS_OK;
|
retval = STATUS_OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free((void *) passwd);
|
pfree((void *) passwd);
|
||||||
if (valuntil)
|
if (valuntil)
|
||||||
free((void *) valuntil);
|
{
|
||||||
|
pfree((void *) valuntil);
|
||||||
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,7 @@
|
|||||||
* wherein you authenticate a user by seeing what IP address the system
|
* wherein you authenticate a user by seeing what IP address the system
|
||||||
* says he comes from and possibly using ident).
|
* says he comes from and possibly using ident).
|
||||||
*
|
*
|
||||||
*
|
* $Id: hba.c,v 1.37 1998/12/14 06:50:25 scrappy Exp $
|
||||||
* IDENTIFICATION
|
|
||||||
* $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.36 1998/10/02 16:18:20 momjian Exp $
|
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -287,7 +285,7 @@ process_hba_record(FILE *file, SockAddr *raddr, const char *user,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
syntax:
|
syntax:
|
||||||
sprintf(PQerrormsg,
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH,
|
||||||
"process_hba_record: invalid syntax in pg_hba.conf file\n");
|
"process_hba_record: invalid syntax in pg_hba.conf file\n");
|
||||||
|
|
||||||
fputs(PQerrormsg, stderr);
|
fputs(PQerrormsg, stderr);
|
||||||
@ -358,29 +356,29 @@ static void
|
|||||||
find_hba_entry(SockAddr *raddr, const char *user, const char *database,
|
find_hba_entry(SockAddr *raddr, const char *user, const char *database,
|
||||||
bool *host_ok_p, UserAuth *userauth_p, char *auth_arg)
|
bool *host_ok_p, UserAuth *userauth_p, char *auth_arg)
|
||||||
{
|
{
|
||||||
/*--------------------------------------------------------------------------
|
/*
|
||||||
Read the config file and find an entry that allows connection from
|
* Read the config file and find an entry that allows connection from
|
||||||
host "*raddr" to database "database". If found, return *host_ok_p == true
|
* host "*raddr" to database "database". If found, return *host_ok_p == true
|
||||||
and *userauth_p and *auth_arg representing the contents of that entry.
|
* and *userauth_p and *auth_arg representing the contents of that entry.
|
||||||
|
*
|
||||||
|
* When a record has invalid syntax, we either ignore it or reject the
|
||||||
|
* connection (depending on where it's invalid). No message or anything.
|
||||||
|
* We need to fix that some day.
|
||||||
|
*
|
||||||
|
* If we don't find or can't access the config file, we issue an error
|
||||||
|
* message and deny the connection.
|
||||||
|
*
|
||||||
|
* If we find a file by the old name of the config file (pg_hba), we issue
|
||||||
|
* an error message because it probably needs to be converted. He didn't
|
||||||
|
* follow directions and just installed his old hba file in the new database
|
||||||
|
* system.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
When a record has invalid syntax, we either ignore it or reject the
|
int fd,
|
||||||
connection (depending on where it's invalid). No message or anything.
|
bufsize;
|
||||||
We need to fix that some day.
|
FILE *file; /* The config file we have to read */
|
||||||
|
char *old_conf_file;
|
||||||
If we don't find or can't access the config file, we issue an error
|
|
||||||
message and deny the connection.
|
|
||||||
|
|
||||||
If we find a file by the old name of the config file (pg_hba), we issue
|
|
||||||
an error message because it probably needs to be converted. He didn't
|
|
||||||
follow directions and just installed his old hba file in the new database
|
|
||||||
system.
|
|
||||||
|
|
||||||
---------------------------------------------------------------------------*/
|
|
||||||
int fd;
|
|
||||||
|
|
||||||
FILE *file; /* The config file we have to read */
|
|
||||||
|
|
||||||
char *old_conf_file;
|
|
||||||
|
|
||||||
/* The name of old config file that better not exist. */
|
/* The name of old config file that better not exist. */
|
||||||
|
|
||||||
@ -388,15 +386,15 @@ find_hba_entry(SockAddr *raddr, const char *user, const char *database,
|
|||||||
|
|
||||||
|
|
||||||
/* put together the full pathname to the old config file */
|
/* put together the full pathname to the old config file */
|
||||||
old_conf_file = (char *) palloc((strlen(DataDir) +
|
bufsize = (strlen(DataDir) + strlen(OLD_CONF_FILE) + 2) * sizeof(char);
|
||||||
strlen(OLD_CONF_FILE) + 2) * sizeof(char));
|
old_conf_file = (char *) palloc(bufsize);
|
||||||
sprintf(old_conf_file, "%s/%s", DataDir, OLD_CONF_FILE);
|
snprintf(old_conf_file, bufsize, "%s/%s", DataDir, OLD_CONF_FILE);
|
||||||
|
|
||||||
if ((fd = open(old_conf_file, O_RDONLY, 0)) != -1)
|
if ((fd = open(old_conf_file, O_RDONLY, 0)) != -1)
|
||||||
{
|
{
|
||||||
/* Old config file exists. Tell this guy he needs to upgrade. */
|
/* Old config file exists. Tell this guy he needs to upgrade. */
|
||||||
close(fd);
|
close(fd);
|
||||||
sprintf(PQerrormsg,
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH,
|
||||||
"A file exists by the name used for host-based authentication "
|
"A file exists by the name used for host-based authentication "
|
||||||
"in prior releases of Postgres (%s). The name and format of "
|
"in prior releases of Postgres (%s). The name and format of "
|
||||||
"the configuration file have changed, so this file should be "
|
"the configuration file have changed, so this file should be "
|
||||||
@ -407,22 +405,21 @@ find_hba_entry(SockAddr *raddr, const char *user, const char *database,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *conf_file; /* The name of the config file we have to
|
char *conf_file; /* The name of the config file we have to read */
|
||||||
* read */
|
|
||||||
|
|
||||||
/* put together the full pathname to the config file */
|
/* put together the full pathname to the config file */
|
||||||
conf_file = (char *) palloc((strlen(DataDir) +
|
bufsize = (strlen(DataDir) + strlen(CONF_FILE) + 2) * sizeof(char);
|
||||||
strlen(CONF_FILE) + 2) * sizeof(char));
|
conf_file = (char *) palloc(bufsize);
|
||||||
sprintf(conf_file, "%s/%s", DataDir, CONF_FILE);
|
snprintf(conf_file, bufsize, "%s/%s", DataDir, CONF_FILE);
|
||||||
|
|
||||||
file = AllocateFile(conf_file, "r");
|
file = AllocateFile(conf_file, "r");
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
{
|
{
|
||||||
/* The open of the config file failed. */
|
/* The open of the config file failed. */
|
||||||
|
|
||||||
sprintf(PQerrormsg,
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH,
|
||||||
"find_hba_entry: Host-based authentication config file "
|
"find_hba_entry: Host-based authentication config file "
|
||||||
"does not exist or permissions are not setup correctly! "
|
"does not exist or permissions are not setup correctly! "
|
||||||
"Unable to open file \"%s\".\n",
|
"Unable to open file \"%s\".\n",
|
||||||
conf_file);
|
conf_file);
|
||||||
fputs(PQerrormsg, stderr);
|
fputs(PQerrormsg, stderr);
|
||||||
@ -430,8 +427,8 @@ find_hba_entry(SockAddr *raddr, const char *user, const char *database,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
process_open_config_file(file, raddr, user, database, host_ok_p, userauth_p,
|
process_open_config_file(file, raddr, user, database, host_ok_p,
|
||||||
auth_arg);
|
userauth_p, auth_arg);
|
||||||
FreeFile(file);
|
FreeFile(file);
|
||||||
}
|
}
|
||||||
pfree(conf_file);
|
pfree(conf_file);
|
||||||
@ -545,18 +542,15 @@ ident(const struct in_addr remote_ip_addr, const struct in_addr local_ip_addr,
|
|||||||
*ident_failed == true (and *ident_username undefined).
|
*ident_failed == true (and *ident_username undefined).
|
||||||
----------------------------------------------------------------------------*/
|
----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
int sock_fd;
|
|
||||||
|
|
||||||
/* File descriptor for socket on which we talk to Ident */
|
int sock_fd, /* File descriptor for socket on which we talk to Ident */
|
||||||
|
rc; /* Return code from a locally called function */
|
||||||
int rc; /* Return code from a locally called
|
|
||||||
* function */
|
|
||||||
|
|
||||||
sock_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
|
sock_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
|
||||||
if (sock_fd == -1)
|
if (sock_fd == -1)
|
||||||
{
|
{
|
||||||
sprintf(PQerrormsg,
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH,
|
||||||
"Failed to create socket on which to talk to Ident server. "
|
"Failed to create socket on which to talk to Ident server. "
|
||||||
"socket() returned errno = %s (%d)\n",
|
"socket() returned errno = %s (%d)\n",
|
||||||
strerror(errno), errno);
|
strerror(errno), errno);
|
||||||
fputs(PQerrormsg, stderr);
|
fputs(PQerrormsg, stderr);
|
||||||
@ -592,8 +586,8 @@ ident(const struct in_addr remote_ip_addr, const struct in_addr local_ip_addr,
|
|||||||
}
|
}
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
{
|
{
|
||||||
sprintf(PQerrormsg,
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH,
|
||||||
"Unable to connect to Ident server on the host which is "
|
"Unable to connect to Ident server on the host which is "
|
||||||
"trying to connect to Postgres "
|
"trying to connect to Postgres "
|
||||||
"(IP address %s, Port %d). "
|
"(IP address %s, Port %d). "
|
||||||
"errno = %s (%d)\n",
|
"errno = %s (%d)\n",
|
||||||
@ -604,15 +598,15 @@ ident(const struct in_addr remote_ip_addr, const struct in_addr local_ip_addr,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char ident_query[80];
|
char ident_query[80];
|
||||||
|
|
||||||
/* The query we send to the Ident server */
|
/* The query we send to the Ident server */
|
||||||
sprintf(ident_query, "%d,%d\n",
|
snprintf(ident_query, 80, "%d,%d\n",
|
||||||
ntohs(remote_port), ntohs(local_port));
|
ntohs(remote_port), ntohs(local_port));
|
||||||
rc = send(sock_fd, ident_query, strlen(ident_query), 0);
|
rc = send(sock_fd, ident_query, strlen(ident_query), 0);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
{
|
{
|
||||||
sprintf(PQerrormsg,
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH,
|
||||||
"Unable to send query to Ident server on the host which is "
|
"Unable to send query to Ident server on the host which is "
|
||||||
"trying to connect to Postgres (Host %s, Port %d),"
|
"trying to connect to Postgres (Host %s, Port %d),"
|
||||||
"even though we successfully connected to it. "
|
"even though we successfully connected to it. "
|
||||||
@ -624,16 +618,16 @@ ident(const struct in_addr remote_ip_addr, const struct in_addr local_ip_addr,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char ident_response[80 + IDENT_USERNAME_MAX];
|
char ident_response[80 + IDENT_USERNAME_MAX];
|
||||||
|
|
||||||
rc = recv(sock_fd, ident_response, sizeof(ident_response) - 1, 0);
|
rc = recv(sock_fd, ident_response, sizeof(ident_response) - 1, 0);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
{
|
{
|
||||||
sprintf(PQerrormsg,
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH,
|
||||||
"Unable to receive response from Ident server "
|
"Unable to receive response from Ident server "
|
||||||
"on the host which is "
|
"on the host which is "
|
||||||
"trying to connect to Postgres (Host %s, Port %d),"
|
"trying to connect to Postgres (Host %s, Port %d),"
|
||||||
"even though we successfully sent our query to it. "
|
"even though we successfully sent our query to it. "
|
||||||
"errno = %s (%d)\n",
|
"errno = %s (%d)\n",
|
||||||
inet_ntoa(remote_ip_addr), IDENT_PORT,
|
inet_ntoa(remote_ip_addr), IDENT_PORT,
|
||||||
strerror(errno), errno);
|
strerror(errno), errno);
|
||||||
@ -694,7 +688,8 @@ parse_map_record(FILE *file,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sprintf(PQerrormsg, "Incomplete line in pg_ident: %s", file_map);
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH,
|
||||||
|
"Incomplete line in pg_ident: %s", file_map);
|
||||||
fputs(PQerrormsg, stderr);
|
fputs(PQerrormsg, stderr);
|
||||||
pqdebug("%s", PQerrormsg);
|
pqdebug("%s", PQerrormsg);
|
||||||
}
|
}
|
||||||
@ -776,10 +771,10 @@ verify_against_usermap(const char *pguser,
|
|||||||
if (usermap_name[0] == '\0')
|
if (usermap_name[0] == '\0')
|
||||||
{
|
{
|
||||||
*checks_out_p = false;
|
*checks_out_p = false;
|
||||||
sprintf(PQerrormsg,
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH,
|
||||||
"verify_against_usermap: hba configuration file does not "
|
"verify_against_usermap: hba configuration file does not "
|
||||||
"have the usermap field filled in in the entry that pertains "
|
"have the usermap field filled in in the entry that pertains "
|
||||||
"to this connection. That field is essential for Ident-based "
|
"to this connection. That field is essential for Ident-based "
|
||||||
"authentication.\n");
|
"authentication.\n");
|
||||||
fputs(PQerrormsg, stderr);
|
fputs(PQerrormsg, stderr);
|
||||||
pqdebug("%s", PQerrormsg);
|
pqdebug("%s", PQerrormsg);
|
||||||
@ -787,21 +782,24 @@ verify_against_usermap(const char *pguser,
|
|||||||
else if (strcmp(usermap_name, "sameuser") == 0)
|
else if (strcmp(usermap_name, "sameuser") == 0)
|
||||||
{
|
{
|
||||||
if (strcmp(ident_username, pguser) == 0)
|
if (strcmp(ident_username, pguser) == 0)
|
||||||
|
{
|
||||||
*checks_out_p = true;
|
*checks_out_p = true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
*checks_out_p = false;
|
*checks_out_p = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FILE *file; /* The map file we have to read */
|
FILE *file; /* The map file we have to read */
|
||||||
|
char *map_file; /* The name of the map file we have to read */
|
||||||
char *map_file; /* The name of the map file we have to
|
int bufsize;
|
||||||
* read */
|
|
||||||
|
|
||||||
/* put together the full pathname to the map file */
|
/* put together the full pathname to the map file */
|
||||||
map_file = (char *) palloc((strlen(DataDir) +
|
bufsize = (strlen(DataDir) + strlen(MAP_FILE) + 2) * sizeof(char);
|
||||||
strlen(MAP_FILE) + 2) * sizeof(char));
|
map_file = (char *) palloc(bufsize);
|
||||||
sprintf(map_file, "%s/%s", DataDir, MAP_FILE);
|
snprintf(map_file, bufsize, "%s/%s", DataDir, MAP_FILE);
|
||||||
|
|
||||||
file = AllocateFile(map_file, "r");
|
file = AllocateFile(map_file, "r");
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
@ -810,10 +808,10 @@ verify_against_usermap(const char *pguser,
|
|||||||
|
|
||||||
*checks_out_p = false;
|
*checks_out_p = false;
|
||||||
|
|
||||||
sprintf(PQerrormsg,
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH,
|
||||||
"verify_against_usermap: usermap file for Ident-based "
|
"verify_against_usermap: usermap file for Ident-based "
|
||||||
"authentication "
|
"authentication "
|
||||||
"does not exist or permissions are not setup correctly! "
|
"does not exist or permissions are not setup correctly! "
|
||||||
"Unable to open file \"%s\".\n",
|
"Unable to open file \"%s\".\n",
|
||||||
map_file);
|
map_file);
|
||||||
fputs(PQerrormsg, stderr);
|
fputs(PQerrormsg, stderr);
|
||||||
@ -955,27 +953,31 @@ InRange(char *buf, int host)
|
|||||||
void
|
void
|
||||||
GetCharSetByHost(char *TableName, int host, const char *DataDir)
|
GetCharSetByHost(char *TableName, int host, const char *DataDir)
|
||||||
{
|
{
|
||||||
FILE *file;
|
FILE *file;
|
||||||
char buf[MAX_TOKEN],
|
char buf[MAX_TOKEN],
|
||||||
BaseCharset[MAX_TOKEN],
|
BaseCharset[MAX_TOKEN],
|
||||||
OrigCharset[MAX_TOKEN],
|
OrigCharset[MAX_TOKEN],
|
||||||
DestCharset[MAX_TOKEN],
|
DestCharset[MAX_TOKEN],
|
||||||
HostCharset[MAX_TOKEN];
|
HostCharset[MAX_TOKEN],
|
||||||
char c,
|
c,
|
||||||
eof = false;
|
eof = false,
|
||||||
char *map_file;
|
*map_file;
|
||||||
int key = 0,
|
int key = 0,
|
||||||
i;
|
ChIndex = 0,
|
||||||
struct CharsetItem *ChArray[MAX_CHARSETS];
|
i,
|
||||||
int ChIndex = 0;
|
bufsize;
|
||||||
|
|
||||||
|
struct CharsetItem *ChArray[MAX_CHARSETS];
|
||||||
|
|
||||||
*TableName = '\0';
|
*TableName = '\0';
|
||||||
map_file = (char *) malloc((strlen(DataDir) +
|
bufsize = (strlen(DataDir) + strlen(CHARSET_FILE) + 2) * sizeof(char);
|
||||||
strlen(CHARSET_FILE) + 2) * sizeof(char));
|
map_file = (char *) palloc(bufsize);
|
||||||
sprintf(map_file, "%s/%s", DataDir, CHARSET_FILE);
|
snprintf(map_file, bufsize, "%s/%s", DataDir, CHARSET_FILE);
|
||||||
file = fopen(map_file, "r");
|
file = fopen(map_file, "r");
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
while (!eof)
|
while (!eof)
|
||||||
{
|
{
|
||||||
c = getc(file);
|
c = getc(file);
|
||||||
@ -1035,7 +1037,8 @@ GetCharSetByHost(char *TableName, int host, const char *DataDir)
|
|||||||
next_token(file, buf, sizeof(buf));
|
next_token(file, buf, sizeof(buf));
|
||||||
if (buf[0] != '\0')
|
if (buf[0] != '\0')
|
||||||
{
|
{
|
||||||
ChArray[ChIndex] = (struct CharsetItem *) malloc(sizeof(struct CharsetItem));
|
ChArray[ChIndex] =
|
||||||
|
(struct CharsetItem *) palloc(sizeof(struct CharsetItem));
|
||||||
strcpy(ChArray[ChIndex]->Orig, OrigCharset);
|
strcpy(ChArray[ChIndex]->Orig, OrigCharset);
|
||||||
strcpy(ChArray[ChIndex]->Dest, DestCharset);
|
strcpy(ChArray[ChIndex]->Dest, DestCharset);
|
||||||
strcpy(ChArray[ChIndex]->Table, buf);
|
strcpy(ChArray[ChIndex]->Table, buf);
|
||||||
@ -1051,14 +1054,14 @@ GetCharSetByHost(char *TableName, int host, const char *DataDir)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(file);
|
fclose(file);
|
||||||
free(map_file);
|
pfree(map_file);
|
||||||
|
|
||||||
for (i = 0; i < ChIndex; i++)
|
for (i = 0; i < ChIndex; i++)
|
||||||
{
|
{
|
||||||
if (!strcasecmp(BaseCharset, ChArray[i]->Orig) &&
|
if (!strcasecmp(BaseCharset, ChArray[i]->Orig) &&
|
||||||
!strcasecmp(HostCharset, ChArray[i]->Dest))
|
!strcasecmp(HostCharset, ChArray[i]->Dest))
|
||||||
strncpy(TableName, ChArray[i]->Table, 79);
|
strncpy(TableName, ChArray[i]->Table, 79);
|
||||||
free((struct CharsetItem *) ChArray[i]);
|
pfree((struct CharsetItem *) ChArray[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
|
*
|
||||||
|
* $Id: password.c,v 1.19 1998/12/14 06:50:26 scrappy Exp $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
#include <postgres.h>
|
#include <postgres.h>
|
||||||
#include <miscadmin.h>
|
#include <miscadmin.h>
|
||||||
#include <libpq/password.h>
|
#include <libpq/password.h>
|
||||||
@ -23,7 +30,7 @@ verify_password(char *auth_arg, char *user, char *password)
|
|||||||
pw_file = AllocateFile(pw_file_fullname, "r");
|
pw_file = AllocateFile(pw_file_fullname, "r");
|
||||||
if (!pw_file)
|
if (!pw_file)
|
||||||
{
|
{
|
||||||
sprintf(PQerrormsg,
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH,
|
||||||
"verify_password: couldn't open password file '%s'\n",
|
"verify_password: couldn't open password file '%s'\n",
|
||||||
pw_file_fullname);
|
pw_file_fullname);
|
||||||
fputs(PQerrormsg, stderr);
|
fputs(PQerrormsg, stderr);
|
||||||
@ -68,7 +75,7 @@ verify_password(char *auth_arg, char *user, char *password)
|
|||||||
return STATUS_OK;
|
return STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(PQerrormsg,
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH,
|
||||||
"verify_password: password mismatch for '%s'.\n",
|
"verify_password: password mismatch for '%s'.\n",
|
||||||
user);
|
user);
|
||||||
fputs(PQerrormsg, stderr);
|
fputs(PQerrormsg, stderr);
|
||||||
@ -80,7 +87,7 @@ verify_password(char *auth_arg, char *user, char *password)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(PQerrormsg,
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH,
|
||||||
"verify_password: user '%s' not found in password file.\n",
|
"verify_password: user '%s' not found in password file.\n",
|
||||||
user);
|
user);
|
||||||
fputs(PQerrormsg, stderr);
|
fputs(PQerrormsg, stderr);
|
||||||
|
@ -5,9 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
*
|
* $Id: portal.c,v 1.18 1998/12/14 06:50:26 scrappy Exp $
|
||||||
* IDENTIFICATION
|
|
||||||
* $Header: /cvsroot/pgsql/src/backend/libpq/Attic/portal.c,v 1.17 1998/09/01 04:28:50 momjian Exp $
|
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -75,8 +73,8 @@ in_range(char *msg, int value, int min, int max)
|
|||||||
{
|
{
|
||||||
if (value < min || value >= max)
|
if (value < min || value >= max)
|
||||||
{
|
{
|
||||||
sprintf(PQerrormsg, "FATAL: %s, %d is not in range [%d,%d)\n",
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH,
|
||||||
msg, value, min, max);
|
"FATAL: %s, %d is not in range [%d,%d)\n", msg, value, min, max);
|
||||||
pqdebug("%s", PQerrormsg);
|
pqdebug("%s", PQerrormsg);
|
||||||
fputs(PQerrormsg, stderr);
|
fputs(PQerrormsg, stderr);
|
||||||
return 0;
|
return 0;
|
||||||
@ -89,7 +87,7 @@ valid_pointer(char *msg, void *ptr)
|
|||||||
{
|
{
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
{
|
{
|
||||||
sprintf(PQerrormsg, "FATAL: %s\n", msg);
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH, "FATAL: %s\n", msg);
|
||||||
pqdebug("%s", PQerrormsg);
|
pqdebug("%s", PQerrormsg);
|
||||||
fputs(PQerrormsg, stderr);
|
fputs(PQerrormsg, stderr);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -5,9 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
*
|
* $Id: pqcomm.c,v 1.59 1998/12/14 06:50:27 scrappy Exp $
|
||||||
* IDENTIFICATION
|
|
||||||
* $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.58 1998/11/29 01:47:42 tgl Exp $
|
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -77,9 +75,9 @@
|
|||||||
* declarations
|
* declarations
|
||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
FILE *Pfout,
|
FILE *Pfout,
|
||||||
*Pfin;
|
*Pfin,
|
||||||
FILE *Pfdebug; /* debugging libpq */
|
*Pfdebug; /* debugging libpq */
|
||||||
|
|
||||||
/* --------------------------------
|
/* --------------------------------
|
||||||
* pq_init - open portal file descriptors
|
* pq_init - open portal file descriptors
|
||||||
@ -315,7 +313,7 @@ pq_getint(int b)
|
|||||||
|
|
||||||
if (status)
|
if (status)
|
||||||
{
|
{
|
||||||
sprintf(PQerrormsg,
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH,
|
||||||
"FATAL: pq_getint failed: errno=%d\n", errno);
|
"FATAL: pq_getint failed: errno=%d\n", errno);
|
||||||
fputs(PQerrormsg, stderr);
|
fputs(PQerrormsg, stderr);
|
||||||
pqdebug("%s", PQerrormsg);
|
pqdebug("%s", PQerrormsg);
|
||||||
@ -341,7 +339,7 @@ pq_putstr(char *s)
|
|||||||
if (pqPutString(s, Pfout))
|
if (pqPutString(s, Pfout))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
sprintf(PQerrormsg,
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH,
|
||||||
"FATAL: pq_putstr: fputs() failed: errno=%d\n", errno);
|
"FATAL: pq_putstr: fputs() failed: errno=%d\n", errno);
|
||||||
fputs(PQerrormsg, stderr);
|
fputs(PQerrormsg, stderr);
|
||||||
pqdebug("%s", PQerrormsg);
|
pqdebug("%s", PQerrormsg);
|
||||||
@ -357,7 +355,7 @@ pq_putnchar(char *s, int n)
|
|||||||
{
|
{
|
||||||
if (pqPutNBytes(s, n, Pfout))
|
if (pqPutNBytes(s, n, Pfout))
|
||||||
{
|
{
|
||||||
sprintf(PQerrormsg,
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH,
|
||||||
"FATAL: pq_putnchar: fputc() failed: errno=%d\n",
|
"FATAL: pq_putnchar: fputc() failed: errno=%d\n",
|
||||||
errno);
|
errno);
|
||||||
fputs(PQerrormsg, stderr);
|
fputs(PQerrormsg, stderr);
|
||||||
@ -398,7 +396,7 @@ pq_putint(int i, int b)
|
|||||||
|
|
||||||
if (status)
|
if (status)
|
||||||
{
|
{
|
||||||
sprintf(PQerrormsg,
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH,
|
||||||
"FATAL: pq_putint failed: errno=%d\n", errno);
|
"FATAL: pq_putint failed: errno=%d\n", errno);
|
||||||
fputs(PQerrormsg, stderr);
|
fputs(PQerrormsg, stderr);
|
||||||
pqdebug("%s", PQerrormsg);
|
pqdebug("%s", PQerrormsg);
|
||||||
@ -431,7 +429,7 @@ pq_getinaddr(struct sockaddr_in * sin,
|
|||||||
}
|
}
|
||||||
if (hs->h_addrtype != AF_INET)
|
if (hs->h_addrtype != AF_INET)
|
||||||
{
|
{
|
||||||
sprintf(PQerrormsg,
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH,
|
||||||
"FATAL: pq_getinaddr: %s not on Internet\n",
|
"FATAL: pq_getinaddr: %s not on Internet\n",
|
||||||
host);
|
host);
|
||||||
fputs(PQerrormsg, stderr);
|
fputs(PQerrormsg, stderr);
|
||||||
@ -461,7 +459,7 @@ pq_getinserv(struct sockaddr_in * sin, char *host, char *serv)
|
|||||||
return pq_getinaddr(sin, host, atoi(serv));
|
return pq_getinaddr(sin, host, atoi(serv));
|
||||||
if (!(ss = getservbyname(serv, NULL)))
|
if (!(ss = getservbyname(serv, NULL)))
|
||||||
{
|
{
|
||||||
sprintf(PQerrormsg,
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH,
|
||||||
"FATAL: pq_getinserv: unknown service: %s\n",
|
"FATAL: pq_getinserv: unknown service: %s\n",
|
||||||
serv);
|
serv);
|
||||||
fputs(PQerrormsg, stderr);
|
fputs(PQerrormsg, stderr);
|
||||||
@ -521,7 +519,7 @@ StreamServerPort(char *hostName, short portName, int *fdP)
|
|||||||
|
|
||||||
if ((fd = socket(family, SOCK_STREAM, 0)) < 0)
|
if ((fd = socket(family, SOCK_STREAM, 0)) < 0)
|
||||||
{
|
{
|
||||||
sprintf(PQerrormsg,
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH,
|
||||||
"FATAL: StreamServerPort: socket() failed: errno=%d\n",
|
"FATAL: StreamServerPort: socket() failed: errno=%d\n",
|
||||||
errno);
|
errno);
|
||||||
fputs(PQerrormsg, stderr);
|
fputs(PQerrormsg, stderr);
|
||||||
@ -531,7 +529,7 @@ StreamServerPort(char *hostName, short portName, int *fdP)
|
|||||||
if ((setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &one,
|
if ((setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &one,
|
||||||
sizeof(one))) == -1)
|
sizeof(one))) == -1)
|
||||||
{
|
{
|
||||||
sprintf(PQerrormsg,
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH,
|
||||||
"FATAL: StreamServerPort: setsockopt (SO_REUSEADDR) failed: errno=%d\n",
|
"FATAL: StreamServerPort: setsockopt (SO_REUSEADDR) failed: errno=%d\n",
|
||||||
errno);
|
errno);
|
||||||
fputs(PQerrormsg, stderr);
|
fputs(PQerrormsg, stderr);
|
||||||
@ -576,18 +574,20 @@ StreamServerPort(char *hostName, short portName, int *fdP)
|
|||||||
err = bind(fd, &saddr.sa, len);
|
err = bind(fd, &saddr.sa, len);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
{
|
{
|
||||||
sprintf(PQerrormsg,
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH,
|
||||||
"FATAL: StreamServerPort: bind() failed: errno=%d\n",
|
"FATAL: StreamServerPort: bind() failed: errno=%d\n", errno);
|
||||||
errno);
|
|
||||||
pqdebug("%s", PQerrormsg);
|
pqdebug("%s", PQerrormsg);
|
||||||
strcat(PQerrormsg,
|
strcat(PQerrormsg,
|
||||||
"\tIs another postmaster already running on that port?\n");
|
"\tIs another postmaster already running on that port?\n");
|
||||||
if (family == AF_UNIX)
|
if (family == AF_UNIX)
|
||||||
sprintf(PQerrormsg + strlen(PQerrormsg),
|
{
|
||||||
"\tIf not, remove socket node (%s) and retry.\n",
|
snprintf(PQerrormsg + strlen(PQerrormsg), ERROR_MSG_LENGTH,
|
||||||
sock_path);
|
"\tIf not, remove socket node (%s) and retry.\n", sock_path);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
strcat(PQerrormsg, "\tIf not, wait a few seconds and retry.\n");
|
strcat(PQerrormsg, "\tIf not, wait a few seconds and retry.\n");
|
||||||
|
}
|
||||||
fputs(PQerrormsg, stderr);
|
fputs(PQerrormsg, stderr);
|
||||||
return STATUS_ERROR;
|
return STATUS_ERROR;
|
||||||
}
|
}
|
||||||
@ -723,9 +723,8 @@ StreamOpen(char *hostName, short portName, Port *port)
|
|||||||
{
|
{
|
||||||
if (!(hp = gethostbyname(hostName)) || hp->h_addrtype != AF_INET)
|
if (!(hp = gethostbyname(hostName)) || hp->h_addrtype != AF_INET)
|
||||||
{
|
{
|
||||||
sprintf(PQerrormsg,
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH,
|
||||||
"FATAL: StreamOpen: unknown hostname: %s\n",
|
"FATAL: StreamOpen: unknown hostname: %s\n", hostName);
|
||||||
hostName);
|
|
||||||
fputs(PQerrormsg, stderr);
|
fputs(PQerrormsg, stderr);
|
||||||
pqdebug("%s", PQerrormsg);
|
pqdebug("%s", PQerrormsg);
|
||||||
return STATUS_ERROR;
|
return STATUS_ERROR;
|
||||||
@ -745,9 +744,8 @@ StreamOpen(char *hostName, short portName, Port *port)
|
|||||||
/* connect to the server */
|
/* connect to the server */
|
||||||
if ((port->sock = socket(port->raddr.sa.sa_family, SOCK_STREAM, 0)) < 0)
|
if ((port->sock = socket(port->raddr.sa.sa_family, SOCK_STREAM, 0)) < 0)
|
||||||
{
|
{
|
||||||
sprintf(PQerrormsg,
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH,
|
||||||
"FATAL: StreamOpen: socket() failed: errno=%d\n",
|
"FATAL: StreamOpen: socket() failed: errno=%d\n", errno);
|
||||||
errno);
|
|
||||||
fputs(PQerrormsg, stderr);
|
fputs(PQerrormsg, stderr);
|
||||||
pqdebug("%s", PQerrormsg);
|
pqdebug("%s", PQerrormsg);
|
||||||
return STATUS_ERROR;
|
return STATUS_ERROR;
|
||||||
@ -755,9 +753,8 @@ StreamOpen(char *hostName, short portName, Port *port)
|
|||||||
err = connect(port->sock, &port->raddr.sa, len);
|
err = connect(port->sock, &port->raddr.sa, len);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
{
|
{
|
||||||
sprintf(PQerrormsg,
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH,
|
||||||
"FATAL: StreamOpen: connect() failed: errno=%d\n",
|
"FATAL: StreamOpen: connect() failed: errno=%d\n", errno);
|
||||||
errno);
|
|
||||||
fputs(PQerrormsg, stderr);
|
fputs(PQerrormsg, stderr);
|
||||||
pqdebug("%s", PQerrormsg);
|
pqdebug("%s", PQerrormsg);
|
||||||
return STATUS_ERROR;
|
return STATUS_ERROR;
|
||||||
@ -766,9 +763,8 @@ StreamOpen(char *hostName, short portName, Port *port)
|
|||||||
/* fill in the client address */
|
/* fill in the client address */
|
||||||
if (getsockname(port->sock, &port->laddr.sa, &len) < 0)
|
if (getsockname(port->sock, &port->laddr.sa, &len) < 0)
|
||||||
{
|
{
|
||||||
sprintf(PQerrormsg,
|
snprintf(PQerrormsg, ERROR_MSG_LENGTH,
|
||||||
"FATAL: StreamOpen: getsockname() failed: errno=%d\n",
|
"FATAL: StreamOpen: getsockname() failed: errno=%d\n", errno);
|
||||||
errno);
|
|
||||||
fputs(PQerrormsg, stderr);
|
fputs(PQerrormsg, stderr);
|
||||||
pqdebug("%s", PQerrormsg);
|
pqdebug("%s", PQerrormsg);
|
||||||
return STATUS_ERROR;
|
return STATUS_ERROR;
|
||||||
|
@ -5,9 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
*
|
* $Id: util.c,v 1.6 1998/12/14 06:50:27 scrappy Exp $
|
||||||
* IDENTIFICATION
|
|
||||||
* $Header: /cvsroot/pgsql/src/backend/libpq/Attic/util.c,v 1.5 1997/09/08 02:23:21 momjian Exp $
|
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -5,9 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
*
|
* $Id: outfuncs.c,v 1.51 1998/12/14 06:50:28 scrappy Exp $
|
||||||
* IDENTIFICATION
|
|
||||||
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.50 1998/12/14 00:01:47 thomas Exp $
|
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* Every (plan) node in POSTGRES has an associated "out" routine which
|
* Every (plan) node in POSTGRES has an associated "out" routine which
|
||||||
|
@ -5,9 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
*
|
* $Id: analyze.c,v 1.91 1998/12/14 06:50:32 scrappy Exp $
|
||||||
* IDENTIFICATION
|
|
||||||
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.90 1998/12/04 15:34:28 thomas Exp $
|
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user