diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2010-04-21 00:51:57 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2010-04-21 00:51:57 +0000 |
commit | a3c6d105752c28dbd19d0558733a2157e6ab55e0 (patch) | |
tree | 52faf827f4f761ba8fbd311c262e06cfa552e7d6 | |
parent | ea46000a40cf583401504e095ca1a49f57fa0227 (diff) | |
download | postgresql-a3c6d105752c28dbd19d0558733a2157e6ab55e0.tar.gz postgresql-a3c6d105752c28dbd19d0558733a2157e6ab55e0.zip |
Move the check for whether walreceiver has authenticated as a superuser
from walsender.c, where it didn't really belong, to postinit.c where it does
belong (and is essentially free, too).
-rw-r--r-- | src/backend/replication/walsender.c | 9 | ||||
-rw-r--r-- | src/backend/utils/init/postinit.c | 7 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c index 26fddba10b6..1c1e9f17d2d 100644 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -30,7 +30,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/replication/walsender.c,v 1.16 2010/04/12 10:18:50 heikki Exp $ + * $PostgreSQL: pgsql/src/backend/replication/walsender.c,v 1.17 2010/04/21 00:51:56 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -47,13 +47,13 @@ #include "replication/walsender.h" #include "storage/fd.h" #include "storage/ipc.h" -#include "storage/lock.h" #include "storage/pmsignal.h" #include "tcop/tcopprot.h" #include "utils/guc.h" #include "utils/memutils.h" #include "utils/ps_status.h" + /* Array of WalSnds in shared memory */ WalSndCtlData *WalSndCtl = NULL; @@ -114,11 +114,6 @@ WalSenderMain(void) { MemoryContext walsnd_context; - if (!superuser()) - ereport(FATAL, - (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("must be superuser to start walsender"))); - if (RecoveryInProgress()) ereport(FATAL, (errcode(ERRCODE_CANNOT_CONNECT_NOW), diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index 1fc41cce676..b812c40ac0e 100644 --- a/src/backend/utils/init/postinit.c +++ b/src/backend/utils/init/postinit.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.210 2010/04/20 23:48:47 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.211 2010/04/21 00:51:57 tgl Exp $ * * *------------------------------------------------------------------------- @@ -624,6 +624,11 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username, if (am_walsender) { Assert(!bootstrap); + /* must have authenticated as a superuser */ + if (!am_superuser) + ereport(FATAL, + (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), + errmsg("must be superuser to start walsender"))); /* report this backend in the PgBackendStatus array */ pgstat_bestart(); /* close the transaction we started above */ |