1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

Add db-local user names, per discussion on hackers.

This commit is contained in:
Bruce Momjian
2002-08-18 03:03:26 +00:00
parent 4b26e7d24b
commit 2c6b34d959
7 changed files with 62 additions and 14 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.82 2002/06/20 20:29:28 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.83 2002/08/18 03:03:25 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -117,7 +117,7 @@ pg_krb4_recvauth(Port *port)
version, PG_KRB4_VERSION);
return STATUS_ERROR;
}
if (strncmp(port->user, auth_data.pname, SM_USER) != 0)
if (strncmp(port->user, auth_data.pname, SM_DATABASE_USER) != 0)
{
elog(LOG, "pg_krb4_recvauth: name \"%s\" != \"%s\"",
port->user, auth_data.pname);
@@ -290,7 +290,7 @@ pg_krb5_recvauth(Port *port)
}
kusername = pg_an_to_ln(kusername);
if (strncmp(port->user, kusername, SM_USER))
if (strncmp(port->user, kusername, SM_DATABASE_USER))
{
elog(LOG, "pg_krb5_recvauth: user name \"%s\" != krb5 name \"%s\"",
port->user, kusername);

View File

@@ -37,7 +37,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.284 2002/08/17 15:12:06 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.285 2002/08/18 03:03:25 momjian Exp $
*
* NOTES
*
@@ -116,7 +116,6 @@
sigset_t UnBlockSig,
BlockSig,
AuthBlockSig;
#else
int UnBlockSig,
BlockSig,
@@ -191,6 +190,8 @@ int CheckPointTimeout = 300;
bool HostnameLookup; /* for ps display */
bool ShowPortNumber;
bool Log_connections = false;
bool Db_user_namespace = false;
/* Startup/shutdown state */
static pid_t StartupPID = 0,
@@ -1155,6 +1156,26 @@ ProcessStartupPacket(Port *port, bool SSLdone)
if (port->user[0] == '\0')
elog(FATAL, "no PostgreSQL user name specified in startup packet");
if (Db_user_namespace)
{
/*
* If user@, it is a global user, remove '@'.
* We only want to do this if there is an '@' at the end and no
* earlier in the user string or they may fake as a local user
* of another database attaching to this database.
*/
if (strchr(port->user, '@') == port->user + strlen(port->user)-1)
*strchr(port->user, '@') = '\0';
else
{
/* Append '@' and dbname */
char hold_user[SM_DATABASE_USER+1];
snprintf(hold_user, SM_DATABASE_USER+1, "%s@%s", port->user,
port->database);
strcpy(port->user, hold_user);
}
}
/*
* If we're going to reject the connection due to database state, say
* so now instead of wasting cycles on an authentication exchange.
@@ -2581,11 +2602,10 @@ CreateOptsFile(int argc, char *argv[])
if (FindExec(fullprogname, argv[0], "postmaster") < 0)
return false;
filename = palloc(strlen(DataDir) + 20);
filename = palloc(strlen(DataDir) + 17);
sprintf(filename, "%s/postmaster.opts", DataDir);
fp = fopen(filename, "w");
if (fp == NULL)
if ((fp = fopen(filename, "w")) == NULL)
{
postmaster_error("cannot create file %s: %s",
filename, strerror(errno));

View File

@@ -5,7 +5,7 @@
* command, configuration file, and command line options.
* See src/backend/utils/misc/README for more information.
*
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.82 2002/08/15 02:51:26 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.83 2002/08/18 03:03:25 momjian Exp $
*
* Copyright 2000 by PostgreSQL Global Development Group
* Written by Peter Eisentraut <peter_e@gmx.net>.
@@ -483,6 +483,10 @@ static struct config_bool
{ "transform_null_equals", PGC_USERSET }, &Transform_null_equals,
false, NULL, NULL
},
{
{ "db_user_namespace", PGC_SIGHUP }, &Db_user_namespace,
false, NULL, NULL
},
{
{ NULL, 0 }, NULL, false, NULL, NULL

View File

@@ -113,7 +113,6 @@
#
# Message display
#
#server_min_messages = notice # Values, in order of decreasing detail:
# debug5, debug4, debug3, debug2, debug1,
# info, notice, warning, error, log, fatal,
@@ -201,3 +200,4 @@
#sql_inheritance = true
#transform_null_equals = false
#statement_timeout = 0 # 0 is disabled
#db_user_namespace = false