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

Lists: pgsql-hackers
From: Oleg Bartunov <oleg(at)sai(dot)msu(dot)su>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: Linux MANDRAKE startup startup script is broken ?
Date: 2000-02-05 18:15:35
Message-ID: Pine.GSO.3.96.SK.1000205210347.22044F-100000@ra
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

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.

Regards,

Oleg

_____________________________________________________________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg(at)sai(dot)msu(dot)su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83


From: Lamar Owen <lamar(dot)owen(at)wgcr(dot)org>
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 20:37:00
Message-ID: 389C89EC.1CEA2D16@wgcr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

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 !

?!?!?!? Do something for me: add a couple of lines in
/etc/rc.d/init.d/postgresql after the postmaster start:
su -l postgres -c 'set >/var/lib/pgsql/envvars-l.lst'
su postgres -c 'set >/var/lib/pgsql/envvaqrs-no-l.lst'

And e-mail me the two '*.lst' files out of /var/lib/pgsql.

> I'm not an expert in su, at least I don't know what '-l' is supposed

>From man su:
SU(1) FSF SU(1)

NAME
su - run a shell with substitute user and group IDs

SYNOPSIS
su [OPTION]... [-] [USER [ARG]...]

DESCRIPTION
Change the effective user id and group id to that of USER.

-, -l, --login
make the shell a login shell
......

> for, but it's worth to describe the problem and let people from
> MANDRAKE to know.

The same problem should manifest itself in RedHat, which is what I build
the RPM's for. Mandrake has been taking the RedHat RPM's and using
them, with modifications, up till now, so, if I fix this in the RedHat
RPM's, the Mandrake RPM's will follow from Mandrake shortly.

--
Lamar Owen
WGCR Internet Radio
1 Peter 4:11


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
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

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