diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2000-09-06 14:15:31 +0000 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2000-09-06 14:15:31 +0000 |
commit | 6dc249610a87aa8b9dcc8baf4e64d2e14d02f548 (patch) | |
tree | 6ca1b864625ecf91a2887c8031a9fa91b5f9c5c5 /src/backend/main/main.c | |
parent | daf1e3a7026e367d630be3ac34ac0a9e7cf1340f (diff) | |
download | postgresql-6dc249610a87aa8b9dcc8baf4e64d2e14d02f548.tar.gz postgresql-6dc249610a87aa8b9dcc8baf4e64d2e14d02f548.zip |
Code cleanup of user name and user id handling in the backend. The current
user is now defined in terms of the user id, the user name is only computed
upon request (for display purposes). This is kind of the opposite of the
previous state, which would maintain the user name and compute the user id
for permission checks.
Besides perhaps saving a few cycles (integer vs string), this now creates a
single point of attack for changing the user id during a connection, for
purposes of "setuid" functions, etc.
Diffstat (limited to 'src/backend/main/main.c')
-rw-r--r-- | src/backend/main/main.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/backend/main/main.c b/src/backend/main/main.c index ec36b602f45..a20b39886d5 100644 --- a/src/backend/main/main.c +++ b/src/backend/main/main.c @@ -8,10 +8,13 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.29 2000/01/26 05:56:30 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.30 2000/09/06 14:15:19 petere Exp $ * *------------------------------------------------------------------------- */ +#include "postgres.h" + +#include <pwd.h> #include <unistd.h> #if defined(__alpha__) && !defined(linux) @@ -22,7 +25,6 @@ #undef ASSEMBLER #endif -#include "postgres.h" #ifdef USE_LOCALE #include <locale.h> #endif @@ -100,5 +102,15 @@ main(int argc, char *argv[]) exit(BootstrapMain(argc - 1, argv + 1)); /* remove the -boot arg * from the command line */ else - exit(PostgresMain(argc, argv, argc, argv)); + { + struct passwd *pw; + + pw = getpwuid(geteuid()); + if (!pw) + { + fprintf(stderr, "%s: invalid current euid", argv[0]); + exit(1); + } + exit(PostgresMain(argc, argv, argc, argv, pw->pw_name)); + } } |