diff --git a/contrib/mSQL-interface/mpgsql.c b/contrib/mSQL-interface/mpgsql.c index 3957c11dd25b94a07ae29164d8cd7ce90179c741..cd3daba337dfe8ef4a1085c5874dc7c93cebd8a9 100644 --- a/contrib/mSQL-interface/mpgsql.c +++ b/contrib/mSQL-interface/mpgsql.c @@ -1,6 +1,7 @@ #include <time.h> #include <string.h> #include <stdlib.h> +#include <unistd.h> #include "msql.h" #include "libpq-fe.h" @@ -264,7 +265,7 @@ msqlListTables(int a) snprintf(tbuf, BUFSIZ, "select relname from pg_class where relkind='r' and relowner=%d", - getuid()); + geteuid()); if (msqlQuery(a, tbuf) > 0) { m = msqlStoreResult(); @@ -288,7 +289,7 @@ msqlListIndex(int a, char *b, char *c) snprintf(tbuf, BUFSIZ, "select relname from pg_class where relkind='i' and relowner=%d", - getuid()); + geteuid()); if (msqlQuery(a, tbuf) > 0) { m = msqlStoreResult(); diff --git a/src/backend/libpq/be-secure.c b/src/backend/libpq/be-secure.c index 8ab152d4c2d26e8e6c2ccbec22487667ab0d5d40..f5657efae5155061e179c38740e34bae6c9fc93d 100644 --- a/src/backend/libpq/be-secure.c +++ b/src/backend/libpq/be-secure.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/libpq/be-secure.c,v 1.55 2004/12/31 21:59:50 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/libpq/be-secure.c,v 1.56 2005/01/08 22:51:12 tgl Exp $ * * Since the server static private key ($DataDir/server.key) * will normally be stored unencrypted so that the database @@ -676,7 +676,7 @@ initialize_SSL(void) */ #if !defined(WIN32) && !defined(__CYGWIN__) if (!S_ISREG(buf.st_mode) || (buf.st_mode & (S_IRWXG | S_IRWXO)) || - buf.st_uid != getuid()) + buf.st_uid != geteuid()) ereport(FATAL, (errcode(ERRCODE_CONFIG_FILE_ERROR), errmsg("unsafe permissions on private key file \"%s\"", diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index d85944ebfc0afef781bdcdd2954be1c6163196af..2d3958b5a1ca61bf8e576028ba6044057b08ea1f 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -39,7 +39,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * Portions taken from FreeBSD. * - * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.72 2004/12/31 22:02:59 pgsql Exp $ + * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.73 2005/01/08 22:51:12 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -628,11 +628,11 @@ get_id(void) struct passwd *pw; - pw = getpwuid(getuid()); + pw = getpwuid(geteuid()); #ifndef __BEOS__ /* no root check on BEOS */ - if (!geteuid()) /* 0 is root's uid */ + if (geteuid() == 0) /* 0 is root's uid */ { fprintf(stderr, _("%s: cannot be run as root\n" diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c index 2033a4bd86b502ff51ae9349b532448a734e6e9b..1012de57d3fcb6d0542493267bd75c54df875112 100644 --- a/src/bin/psql/help.c +++ b/src/bin/psql/help.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2005, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.99 2005/01/01 05:43:08 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.100 2005/01/08 22:51:13 tgl Exp $ */ #include "postgres_fe.h" #include "common.h" @@ -19,7 +19,7 @@ #include <pwd.h> /* for getpwuid() */ #endif #include <sys/types.h> /* (ditto) */ -#include <unistd.h> /* for getuid() */ +#include <unistd.h> /* for geteuid() */ #else #include <win32.h> #endif diff --git a/src/bin/scripts/common.c b/src/bin/scripts/common.c index d11ebfd644f4e7861cb15f74ad813d3c39164419..c84617b3edf7f65bdd0e96d52a97db129292db77 100644 --- a/src/bin/scripts/common.c +++ b/src/bin/scripts/common.c @@ -5,7 +5,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.15 2004/12/31 22:03:17 pgsql Exp $ + * $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.16 2005/01/08 22:51:14 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -27,7 +27,7 @@ get_user_name(const char *progname) #ifndef WIN32 struct passwd *pw; - pw = getpwuid(getuid()); + pw = getpwuid(geteuid()); if (!pw) { fprintf(stderr, _("%s: could not obtain information about current user: %s\n"), diff --git a/src/interfaces/libpq/fe-secure.c b/src/interfaces/libpq/fe-secure.c index b4c24754aabe8090a7d56b01b6dc30ab1e453028..0f9a8fec60024ce4af67c809b93bbd5bb54b4c7b 100644 --- a/src/interfaces/libpq/fe-secure.c +++ b/src/interfaces/libpq/fe-secure.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.65 2005/01/06 21:41:44 tgl Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.66 2005/01/08 22:51:15 tgl Exp $ * * NOTES * [ Most of these notes are wrong/obsolete, but perhaps not all ] @@ -79,12 +79,9 @@ #include "postgres_fe.h" -#include <sys/types.h> #include <signal.h> #include <fcntl.h> -#include <errno.h> #include <ctype.h> -#include <string.h> #include "libpq-fe.h" #include "libpq-int.h" @@ -819,7 +816,7 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey) } #ifndef WIN32 if (!S_ISREG(buf.st_mode) || (buf.st_mode & 0077) || - buf.st_uid != getuid()) + buf.st_uid != geteuid()) { printfPQExpBuffer(&conn->errorMessage, libpq_gettext("private key file \"%s\" has wrong permissions\n"),