aboutsummaryrefslogtreecommitdiff
path: root/src/backend/tcop
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/tcop')
-rw-r--r--src/backend/tcop/postgres.c39
-rw-r--r--src/backend/tcop/utility.c26
2 files changed, 27 insertions, 38 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index 3369e22825e..373d6831df6 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.174 2000/08/30 20:30:06 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.175 2000/09/06 14:15:21 petere Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
@@ -817,28 +817,27 @@ usage(char *progname)
}
/* ----------------------------------------------------------------
- * PostgresMain
- * postgres main loop
- * all backends, interactive or otherwise start here
+ * PostgresMain
+ * postgres main loop -- all backends, interactive or otherwise start here
*
- * argc/argv are the command line arguments to be used. When being forked
- * by the postmaster, these are not the original argv array of the process.
- * real_argc/real_argv point to the original argv array, which is needed by
- * PS_INIT_STATUS on some platforms.
+ * argc/argv are the command line arguments to be used. When being forked
+ * by the postmaster, these are not the original argv array of the process.
+ * real_argc/real_argv point to the original argv array, which is needed by
+ * `ps' display on some platforms. username is the (possibly authenticated)
+ * PostgreSQL user name to be used for the session.
* ----------------------------------------------------------------
*/
int
-PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
+PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const char * username)
{
int flag;
- char *DBName = NULL;
+ const char *DBName = NULL;
bool secure = true;
int errs = 0;
int firstchar;
StringInfo parser_input;
- char *userName;
char *remote_host;
unsigned short remote_port;
@@ -1244,12 +1243,6 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
pqsignal(SIGTTOU, SIG_DFL);
pqsignal(SIGCONT, SIG_DFL);
- /*
- * Get user name (needed now in case it is the default database name)
- * and check command line validity
- */
- SetPgUserName();
- userName = GetPgUserName();
if (IsUnderPostmaster)
{
@@ -1274,9 +1267,9 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
}
else if (argc - optind == 1)
DBName = argv[optind];
- else if ((DBName = userName) == NULL)
+ else if ((DBName = username) == NULL)
{
- fprintf(stderr, "%s: USER undefined and no database specified\n",
+ fprintf(stderr, "%s: user name undefined and no database specified\n",
argv[0]);
proc_exit(0);
}
@@ -1361,20 +1354,20 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
* references to optarg or getenv() from above will be invalid
* after this call. Better use strdup or something similar.
*/
- init_ps_display(real_argc, real_argv, userName, DBName, remote_host);
+ init_ps_display(real_argc, real_argv, username, DBName, remote_host);
set_ps_display("startup");
}
if (Log_connections)
elog(DEBUG, "connection: host=%s user=%s database=%s",
- remote_host, userName, DBName);
+ remote_host, username, DBName);
/*
* general initialization
*/
if (DebugLvl > 1)
elog(DEBUG, "InitPostgres");
- InitPostgres(DBName);
+ InitPostgres(DBName, username);
#ifdef MULTIBYTE
/* set default client encoding */
@@ -1404,7 +1397,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
if (!IsUnderPostmaster)
{
puts("\nPOSTGRES backend interactive interface ");
- puts("$Revision: 1.174 $ $Date: 2000/08/30 20:30:06 $\n");
+ puts("$Revision: 1.175 $ $Date: 2000/09/06 14:15:21 $\n");
}
/*
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c
index 409aca70ada..558f678430f 100644
--- a/src/backend/tcop/utility.c
+++ b/src/backend/tcop/utility.c
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.91 2000/07/05 12:45:26 wieck Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.92 2000/09/06 14:15:21 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -74,9 +74,6 @@ ProcessUtility(Node *parsetree,
char *commandTag = NULL;
char *relname;
char *relationName;
- char *userName;
-
- userName = GetPgUserName();
switch (nodeTag(parsetree))
{
@@ -200,7 +197,7 @@ ProcessUtility(Node *parsetree,
/* close rel, but keep lock until end of xact */
heap_close(rel, NoLock);
#ifndef NO_SECURITY
- if (!pg_ownercheck(userName, relname, RELNAME))
+ if (!pg_ownercheck(GetUserId(), relname, RELNAME))
elog(ERROR, "you do not own class \"%s\"",
relname);
#endif
@@ -234,7 +231,7 @@ ProcessUtility(Node *parsetree,
heap_close(rel, NoLock);
#ifndef NO_SECURITY
- if (!pg_ownercheck(userName, relname, RELNAME))
+ if (!pg_ownercheck(GetUserId(), relname, RELNAME))
elog(ERROR, "you do not own class \"%s\"", relname);
#endif
TruncateRelation(relname);
@@ -299,7 +296,7 @@ ProcessUtility(Node *parsetree,
elog(ERROR, "ALTER TABLE: relation \"%s\" is a system catalog",
relname);
#ifndef NO_SECURITY
- if (!pg_ownercheck(userName, relname, RELNAME))
+ if (!pg_ownercheck(GetUserId(), relname, RELNAME))
elog(ERROR, "permission denied");
#endif
@@ -333,7 +330,6 @@ ProcessUtility(Node *parsetree,
renameatt(relname, /* relname */
stmt->column, /* old att name */
stmt->newname, /* new att name */
- userName,
stmt->inh); /* recursive? */
}
}
@@ -405,7 +401,7 @@ ProcessUtility(Node *parsetree,
/* close rel, but keep lock until end of xact */
heap_close(rel, NoLock);
#ifndef NO_SECURITY
- if (!pg_ownercheck(userName, relname, RELNAME))
+ if (!pg_ownercheck(GetUserId(), relname, RELNAME))
elog(ERROR, "you do not own class \"%s\"",
relname);
#endif
@@ -484,7 +480,7 @@ ProcessUtility(Node *parsetree,
#ifndef NO_SECURITY
relname = stmt->object->relname;
- aclcheck_result = pg_aclcheck(relname, userName, ACL_RU);
+ aclcheck_result = pg_aclcheck(relname, GetUserId(), ACL_RU);
if (aclcheck_result != ACLCHECK_OK)
elog(ERROR, "%s: %s", relname, aclcheck_error_strings[aclcheck_result]);
#endif
@@ -529,7 +525,7 @@ ProcessUtility(Node *parsetree,
elog(ERROR, "class \"%s\" is a system catalog index",
relname);
#ifndef NO_SECURITY
- if (!pg_ownercheck(userName, relname, RELNAME))
+ if (!pg_ownercheck(GetUserId(), relname, RELNAME))
elog(ERROR, "%s: %s", relname, aclcheck_error_strings[ACLCHECK_NOT_OWNER]);
#endif
RemoveIndex(relname);
@@ -542,7 +538,7 @@ ProcessUtility(Node *parsetree,
#ifndef NO_SECURITY
relationName = RewriteGetRuleEventRel(rulename);
- aclcheck_result = pg_aclcheck(relationName, userName, ACL_RU);
+ aclcheck_result = pg_aclcheck(relationName, GetUserId(), ACL_RU);
if (aclcheck_result != ACLCHECK_OK)
elog(ERROR, "%s: %s", relationName, aclcheck_error_strings[aclcheck_result]);
#endif
@@ -564,7 +560,7 @@ ProcessUtility(Node *parsetree,
ruleName = MakeRetrieveViewRuleName(viewName);
relationName = RewriteGetRuleEventRel(ruleName);
- if (!pg_ownercheck(userName, relationName, RELNAME))
+ if (!pg_ownercheck(GetUserId(), relationName, RELNAME))
elog(ERROR, "%s: %s", relationName, aclcheck_error_strings[ACLCHECK_NOT_OWNER]);
pfree(ruleName);
#endif
@@ -881,7 +877,7 @@ ProcessUtility(Node *parsetree,
relname);
}
#ifndef NO_SECURITY
- if (!pg_ownercheck(userName, relname, RELNAME))
+ if (!pg_ownercheck(GetUserId(), relname, RELNAME))
elog(ERROR, "%s: %s", relname, aclcheck_error_strings[ACLCHECK_NOT_OWNER]);
#endif
ReindexIndex(relname, stmt->force);
@@ -899,7 +895,7 @@ ProcessUtility(Node *parsetree,
relname);
}
#ifndef NO_SECURITY
- if (!pg_ownercheck(userName, relname, RELNAME))
+ if (!pg_ownercheck(GetUserId(), relname, RELNAME))
elog(ERROR, "%s: %s", relname, aclcheck_error_strings[ACLCHECK_NOT_OWNER]);
#endif
ReindexTable(relname, stmt->force);