Consistently use geteuid() not getuid(); there were a few places deviating
authorTom Lane <[email protected]>
Sat, 8 Jan 2005 22:51:15 +0000 (22:51 +0000)
committerTom Lane <[email protected]>
Sat, 8 Jan 2005 22:51:15 +0000 (22:51 +0000)
from our long-established standard.

contrib/mSQL-interface/mpgsql.c
src/backend/libpq/be-secure.c
src/bin/initdb/initdb.c
src/bin/psql/help.c
src/bin/scripts/common.c
src/interfaces/libpq/fe-secure.c

index 3957c11dd25b94a07ae29164d8cd7ce90179c741..cd3daba337dfe8ef4a1085c5874dc7c93cebd8a9 100644 (file)
@@ -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();
index f9190b8f1d52cd51c32f2ceceadae50e4ee54bc2..53d26adc776979957343880224a7ed2116d77e99 100644 (file)
@@ -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\"",
index af99cfff5cc74ef1007fa0c841e7d91d9f847bd7..7cd51659deccaf51e8abbd38b3876c199400944f 100644 (file)
@@ -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"
index 4f99274e6a4b90a1ab68480e3c8b077e7f873a85..b62a937f594d00687bb859b569fe8916913c04dc 100644 (file)
@@ -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
index 045409658db5e7cebfc8ee99ce4455b8fcd7da62..59b3c9b91ad8d402f7b412c803bbcc3bc62c378d 100644 (file)
@@ -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"),
index 07be56e782f99a6a991bff5924648f07a2911566..0e3e5e2a3efaf231ccd688f55334a41882b8c142 100644 (file)
 
 #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"),