pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Re: Postmaster startup
4+ messages / 4 participants
[nested] [flat]

* Re: Postmaster startup
@ 2001-10-05 16:56  Brett W. McCoy <bmccoy@chapelperilous.net>
  parent: Oleg Lebedev <olebedev@waterford.org>
  2 siblings, 0 replies; 4+ messages in thread

From: Brett W. McCoy @ 2001-10-05 16:56 UTC (permalink / raw)
  To: Oleg Lebedev <olebedev@waterford.org>; +Cc: pgsql-admin

On Fri, 5 Oct 2001, Oleg Lebedev wrote:

> I decided to tighten up security on the server and start postmaster as
> postgres user on startup.
> I have a script my_script that is run on startup, which has root
> permissions. From this script I want to start postgres script, which is
> owned by postgres (postgerSQL superuser) and has 's' bit set so that it
> executes with postgres priviledges. When I try to run my_script, I get
> an error:
> postmaster: real and effective userids must match
> what am I doing wrong?

You should start postmaster with something like:

su - postgres -c 'postmaster' &

in your startup scripts.  Setting the sticky bit will not accomplish what
you are trying to do.

-- Brett
                                          http://www.chapelperilous.net/
------------------------------------------------------------------------
To thine own self be true.  (If not that, at least make some money.)




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Postmaster startup
@ 2001-10-05 18:25  Oleg Lebedev <olebedev@waterford.org>
  0 siblings, 3 replies; 4+ messages in thread

From: Oleg Lebedev @ 2001-10-05 18:25 UTC (permalink / raw)
  To: pgsql-admin

Hi,
I decided to tighten up security on the server and start postmaster as
postgres user on startup.
I have a script my_script that is run on startup, which has root
permissions. From this script I want to start postgres script, which is
owned by postgres (postgerSQL superuser) and has 's' bit set so that it
executes with postgres priviledges. When I try to run my_script, I get
an error:
postmaster: real and effective userids must match
what am I doing wrong?
Thanks for your help in advance,

Oleg





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Postmaster startup
@ 2001-10-05 18:33  Peter Eisentraut <peter_e@gmx.net>
  parent: Oleg Lebedev <olebedev@waterford.org>
  2 siblings, 0 replies; 4+ messages in thread

From: Peter Eisentraut @ 2001-10-05 18:33 UTC (permalink / raw)
  To: Oleg Lebedev <olebedev@waterford.org>; +Cc: pgsql-admin

Oleg Lebedev writes:

> I have a script my_script that is run on startup, which has root
> permissions. From this script I want to start postgres script, which is
> owned by postgres (postgerSQL superuser) and has 's' bit set so that it
> executes with postgres priviledges. When I try to run my_script, I get
> an error:
> postmaster: real and effective userids must match

You should start the postmaster like this:

su -c 'postmaster -D ...' postgres

Setuid is not allowed because it introduces a security hole (on some
platforms anyway), coming from user-defined C functions.

-- 
Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Postmaster startup
@ 2001-10-07 18:23  Chad R. Larson <chad@eldocomp.com>
  parent: Oleg Lebedev <olebedev@waterford.org>
  2 siblings, 0 replies; 4+ messages in thread

From: Chad R. Larson @ 2001-10-07 18:23 UTC (permalink / raw)
  To: Oleg Lebedev <olebedev@waterford.org>; pgsql-admin

At 12:25 PM 10/5/01 -0600, Oleg Lebedev wrote:
>I have a script my_script that is run on startup, which has root 
>permissions. From this script I want to start postgres script, which is 
>owned by postgres (postgerSQL superuser) and has 's' bit set so that it 
>executes with postgres priviledges. When I try to run my_script, I get an 
>error: postmaster: real and effective userids must match what am I doing wrong?

On many systems, SUID scripts are considered a security hole.  On 
SysVr4-derived systems, the SUID bit on a script is silently ignored for 
that reason.  If you're half-interested, go look at all the hoops PERL 
jumps through to run SUID PERL scripts.

Anyway, attached is the script I use to start/stop Postgres on a Solaris 
2.6 system.  Hope it helps.  The magic is the "su posgtres -c ..." part.
         -crl
--
Chad R. Larson (CRL22)    chad@eldocomp.com
   Eldorado Computing, Inc.   602-604-3100
      5353 North 16th Street, Suite 400
        Phoenix, Arizona   85016-3228

Attachments:

postgres (text/plain, 2.6K) download #!/sbin/sh # $Id: postgres,v 1.3 2001/08/29 15:55:11 toor Exp $ LINKS='../rc3.d/S05postgres ../rc0.d/K30postgres' # The version of PostgreSQL this is for PGVERSION=7.1.2 PGBASE=/pgsql PGHOME=$PGBASE/$PGVERSION BINDIR=$PGHOME/bin POSTGRES=$BINDIR/postgres INITDB=$BINDIR/initdb PGCTL=$BINDIR/pg_ctl PGUSER=postgres PGLOGFILE=/var/log/pgsql/pgsql.log PATH=$BINDIR:$PATH LD_LIBRARY_PATH=$PGHOME/lib:$LD_LIBRARY_PATH PGLIB=$PGHOME/lib PGDATA=$PGBASE/data export PATH LD_LIBRARY_PATH PGLIB PGDATA ERRMSG1="ERROR: PostgreSQL not installed in $PGHOME!" ERRMSG2="ERROR: 'postgres' program not found in $BINDIR!" ERRMSG3="ERROR: PostgreSQL already running!" ERRMSG4="ERROR: PostgreSQL not started!" ERRMSG5="ERROR: Could not create PostgreSQL data directory for initdb!" OKMSG1="PostgreSQL $PGDATA Initalized." OKMSG2="PostgreSQL $PGVERSION has started." if [ ! -d "$PGHOME" ]; then /usr/bin/logger -p daemon.err $ERRMSG1 exit 1 fi case "$1" in 'start') # If not found if [ ! -f "$POSTGRES" ]; then /usr/bin/logger -p daemon.err $ERRMSG2 exit 1 fi # check to see if PostgreSQL is already running $PGCTL status > /dev/null 2>&1 rtn=$? if [ $rtn -eq 0 ]; then /usr/bin/logger -p daemon.err $ERRMSG3 exit 2 fi # No existing PGDATA, initdb it. if [ ! -d "$PGDATA" ]; then /usr/bin/mkdir -p $PGDATA rtn=$? if [ $rtn -ne 0 ]; then /usr/bin/logger -p daemon.err $ERRMSG5 exit 5 fi /usr/bin/chown postgres:postgres $PGDATA /usr/bin/su $PGUSER -c \ "$INITDB --pgdata=$PGDATA >& /dev/null < /dev/null" rtn=$? if [ $rtn ]; then /usr/bin/logger -p daemon.info $OKMSG1 else /usr/bin/logger -p daemon.err $ERRMSG4 exit 3 fi fi /usr/bin/su $PGUSER -c \ "$PGCTL -w -D $PGDATA -o '-i' -l $PGLOGFILE start" $PGCTL status > /dev/null 2>&1 rtn=$? if [ $rtn -eq 0 ]; then /usr/bin/logger -p daemon.info $OKMSG2 else /usr/bin/logger -p daemon.err $ERRMSG4 exit 4 fi ;; 'stop') /usr/bin/su $PGUSER -c "$PGCTL stop -m smart" /usr/bin/sleep 1 ;; 'links') for LINK in ${LINKS} ; do ln -f ${0} ${LINK} done ;; *) echo "Usage: $0 { start | stop | links}" exit 1 ;; esac exit 0
^ permalink raw reply [nested|flat] 4+ messages in thread


end of thread, other threads:[~2001-10-07 18:23 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-10-05 18:25 Postmaster startup Oleg Lebedev <olebedev@waterford.org>
2001-10-05 16:56 ` Brett W. McCoy <bmccoy@chapelperilous.net>
2001-10-05 18:33 ` Peter Eisentraut <peter_e@gmx.net>
2001-10-07 18:23 ` Chad R. Larson <chad@eldocomp.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox