Re: [HACKERS] Re: initdb.sh fixed - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [HACKERS] Re: initdb.sh fixed
Date
Msg-id 17865.945660371@sss.pgh.pa.us
Whole thread Raw
In response to Re: initdb.sh fixed  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: [HACKERS] Re: initdb.sh fixed
List pgsql-hackers
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Seems either $USER or $LOGNAME should be set in all cases.

One or both is probably set in most shell environments ... but
it's not necessarily *right*.  If you've su'd to postgres from
your login account, these env vars may still reflect your login.

> I am now using:
>    POSTGRES_SUPERUSERID="`id -u 2>/dev/null || echo 0`"
> Let's see how portable that is?

Some quick experimentation shows that id -u isn't too trustworthy,
which is a shame because it's the POSIX standard.  But I find that
the SunOS implementation ignores -u:

$ id -u
uid=6902(tgl) gid=50(users0) groups=50(users0)

And no doubt there will be platforms that haven't got "id" at all.

It might be best to provide a little bitty C program that calls
geteuid() and prints the result...
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [HACKERS] Re: [PATCHES] Lock
Next
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] Re: initdb.sh fixed