diff options
author | Tom Lane | 2005-01-08 22:51:15 +0000 |
---|---|---|
committer | Tom Lane | 2005-01-08 22:51:15 +0000 |
commit | 0796f6b4a1f615385082f4542ef32525fc6b5d07 (patch) | |
tree | 65fdd4affd57b6020cde499e3576477f2bcebe65 | |
parent | d0027eb7baecfd13b49623c9079900cdcb48b8b8 (diff) |
Consistently use geteuid() not getuid(); there were a few places deviating
from our long-established standard.
-rw-r--r-- | contrib/mSQL-interface/mpgsql.c | 5 | ||||
-rw-r--r-- | src/backend/libpq/be-secure.c | 2 | ||||
-rw-r--r-- | src/bin/initdb/initdb.c | 4 | ||||
-rw-r--r-- | src/bin/psql/help.c | 2 | ||||
-rw-r--r-- | src/bin/scripts/common.c | 2 | ||||
-rw-r--r-- | src/interfaces/libpq/fe-secure.c | 5 |
6 files changed, 9 insertions, 11 deletions
diff --git a/contrib/mSQL-interface/mpgsql.c b/contrib/mSQL-interface/mpgsql.c index 3957c11dd2..cd3daba337 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 f9190b8f1d..53d26adc77 100644 --- a/src/backend/libpq/be-secure.c +++ b/src/backend/libpq/be-secure.c @@ -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 af99cfff5c..7cd51659de 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -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 4f99274e6a..b62a937f59 100644 --- a/src/bin/psql/help.c +++ b/src/bin/psql/help.c @@ -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 045409658d..59b3c9b91a 100644 --- a/src/bin/scripts/common.c +++ b/src/bin/scripts/common.c @@ -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 07be56e782..0e3e5e2a3e 100644 --- a/src/interfaces/libpq/fe-secure.c +++ b/src/interfaces/libpq/fe-secure.c @@ -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"), |