Skip to content

Commit 8afe005

Browse files
committed
Consistently use geteuid() not getuid(); there were a few places deviating
from our long-established standard.
1 parent b5adf46 commit 8afe005

File tree

6 files changed

+14
-16
lines changed

6 files changed

+14
-16
lines changed

contrib/mSQL-interface/mpgsql.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <time.h>
22
#include <string.h>
33
#include <stdlib.h>
4+
#include <unistd.h>
45
#include "msql.h"
56
#include "libpq-fe.h"
67

@@ -264,7 +265,7 @@ msqlListTables(int a)
264265

265266
snprintf(tbuf, BUFSIZ,
266267
"select relname from pg_class where relkind='r' and relowner=%d",
267-
getuid());
268+
geteuid());
268269
if (msqlQuery(a, tbuf) > 0)
269270
{
270271
m = msqlStoreResult();
@@ -288,7 +289,7 @@ msqlListIndex(int a, char *b, char *c)
288289

289290
snprintf(tbuf, BUFSIZ,
290291
"select relname from pg_class where relkind='i' and relowner=%d",
291-
getuid());
292+
geteuid());
292293
if (msqlQuery(a, tbuf) > 0)
293294
{
294295
m = msqlStoreResult();

src/backend/libpq/be-secure.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/backend/libpq/be-secure.c,v 1.55 2004/12/31 21:59:50 pgsql Exp $
14+
* $PostgreSQL: pgsql/src/backend/libpq/be-secure.c,v 1.56 2005/01/08 22:51:12 tgl Exp $
1515
*
1616
* Since the server static private key ($DataDir/server.key)
1717
* will normally be stored unencrypted so that the database
@@ -676,7 +676,7 @@ initialize_SSL(void)
676676
*/
677677
#if !defined(WIN32) && !defined(__CYGWIN__)
678678
if (!S_ISREG(buf.st_mode) || (buf.st_mode & (S_IRWXG | S_IRWXO)) ||
679-
buf.st_uid != getuid())
679+
buf.st_uid != geteuid())
680680
ereport(FATAL,
681681
(errcode(ERRCODE_CONFIG_FILE_ERROR),
682682
errmsg("unsafe permissions on private key file \"%s\"",

src/bin/initdb/initdb.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
* Portions Copyright (c) 1994, Regents of the University of California
4040
* Portions taken from FreeBSD.
4141
*
42-
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.72 2004/12/31 22:02:59 pgsql Exp $
42+
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.73 2005/01/08 22:51:12 tgl Exp $
4343
*
4444
*-------------------------------------------------------------------------
4545
*/
@@ -628,11 +628,11 @@ get_id(void)
628628

629629
struct passwd *pw;
630630

631-
pw = getpwuid(getuid());
631+
pw = getpwuid(geteuid());
632632

633633
#ifndef __BEOS__ /* no root check on BEOS */
634634

635-
if (!geteuid()) /* 0 is root's uid */
635+
if (geteuid() == 0) /* 0 is root's uid */
636636
{
637637
fprintf(stderr,
638638
_("%s: cannot be run as root\n"

src/bin/psql/help.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.99 2005/01/01 05:43:08 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/help.c,v 1.100 2005/01/08 22:51:13 tgl Exp $
77
*/
88
#include "postgres_fe.h"
99
#include "common.h"
@@ -19,7 +19,7 @@
1919
#include <pwd.h> /* for getpwuid() */
2020
#endif
2121
#include <sys/types.h> /* (ditto) */
22-
#include <unistd.h> /* for getuid() */
22+
#include <unistd.h> /* for geteuid() */
2323
#else
2424
#include <win32.h>
2525
#endif

src/bin/scripts/common.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
8-
* $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.15 2004/12/31 22:03:17 pgsql Exp $
8+
* $PostgreSQL: pgsql/src/bin/scripts/common.c,v 1.16 2005/01/08 22:51:14 tgl Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -27,7 +27,7 @@ get_user_name(const char *progname)
2727
#ifndef WIN32
2828
struct passwd *pw;
2929

30-
pw = getpwuid(getuid());
30+
pw = getpwuid(geteuid());
3131
if (!pw)
3232
{
3333
fprintf(stderr, _("%s: could not obtain information about current user: %s\n"),

src/interfaces/libpq/fe-secure.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.65 2005/01/06 21:41:44 tgl Exp $
14+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-secure.c,v 1.66 2005/01/08 22:51:15 tgl Exp $
1515
*
1616
* NOTES
1717
* [ Most of these notes are wrong/obsolete, but perhaps not all ]
@@ -79,12 +79,9 @@
7979

8080
#include "postgres_fe.h"
8181

82-
#include <sys/types.h>
8382
#include <signal.h>
8483
#include <fcntl.h>
85-
#include <errno.h>
8684
#include <ctype.h>
87-
#include <string.h>
8885

8986
#include "libpq-fe.h"
9087
#include "libpq-int.h"
@@ -819,7 +816,7 @@ client_cert_cb(SSL *ssl, X509 **x509, EVP_PKEY **pkey)
819816
}
820817
#ifndef WIN32
821818
if (!S_ISREG(buf.st_mode) || (buf.st_mode & 0077) ||
822-
buf.st_uid != getuid())
819+
buf.st_uid != geteuid())
823820
{
824821
printfPQExpBuffer(&conn->errorMessage,
825822
libpq_gettext("private key file \"%s\" has wrong permissions\n"),

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy