RE: [HACKERS] Linux MANDRAKE startup startup script is broken ?

From: Dmitry Samersoff <dms(at)wplus(dot)net>
To: Oleg Bartunov <oleg(at)sai(dot)msu(dot)su>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: RE: [HACKERS] Linux MANDRAKE startup startup script is broken ?
Date: 2000-02-05 21:01:09
Message-ID: XFMail.20000206000109.dms@wplus.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 05-Feb-2000 Oleg Bartunov wrote:
> Hi,
>
> I had a request from bulgarian user of postgres. He complained
> about non-working locale. His system is MANDRAKE 7.0 which comes
> with postgres 6.5.3 I believe. After several messages we found
> that problem was in startup script /etc/init.d/rc3.d
> su -l postgres -c 'postmaster .......'
> The problem was '-l', after removing it all problems were solved !
> I'm not an expert in su, at least I don't know what '-l' is supposed
> for, but it's worth to describe the problem and let people from
> MANDRAKE to know.

Switch -l cause su to emulate login procedure,
i.e rewrite all environment.
I use simple program to avoid such kind of collision,
and apropriate startup script

(see below sign)

--
Dmitry Samersoff, dms(at)wplus(dot)net, ICQ:3161705
http://devnull.wplus.net
* There will come soft rains ...

==================== cat ===========================
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <pwd.h>

int main(int argc, char *argv[])
{
struct passwd *pw;
uid_t u;

if (!argv[1])
{ fprintf(stderr,"usage: su_postgres command\n");
exit(0);
}

pw = getpwnam("postgres");
if (!pw)
{ fprintf(stderr, "user postgres doesn't exist\n");
exit(0);
}
setuid(pw->pw_uid);
seteuid(pw->pw_uid);

u = geteuid();
if( u != pw->pw_uid)
{ fprintf(stderr,"Can\'t change uid to %d\n", pw->pw_uid);
exit(0);
}
system(argv[1]);

}

=================================================================
# $Id: S81pgsql.in,v 1.2 1999/08/31 14:21:19 dms Exp $

PG_HOME="/usr/local/pgsql"
PG_DATA="$PG_HOME/data"
UDS="/tmp/.s.PGSQL.5432"

PS="@PS@"
GREP="@GREP@"

case "$1" in
'start')
# If no postgres run, remove UDS and start postgres.
pid=
set -- `$PS | $GREP postmaster | $GREP -v grep`
[ $? -eq 0 ] && pid=$1

if [ -z "$pid" ]; then
rm -f "$UDS"
$PG_HOME/bin/su_postgres "$PG_HOME/bin/postmaster -D $PG_DATA -b
$PG_HOME/bin/postgres -i -S -o -F &"
echo "Postgres started"
else
echo "Postmaster already run with pid $pid"
fi
;;
'stop')
pid=
set -- `$PS | $GREP postmaster | $GREP -v grep`
[ $? -eq 0 ] && pid=$1

if [ -z "$pid" ]; then
echo "Postgres not run"
else
echo "Stoping postmaster with pid $pid"
kill $pid
fi

;;
*)
echo "USAGE: $0 {start | stop}"
;;
esac

=================================================================

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2000-02-05 21:29:26 Proposal for new SET variables for optimizer costs
Previous Message Oleg Bartunov 2000-02-05 20:54:27 Re: [HACKERS] Linux MANDRAKE startup startup script is broken ? (fwd)