Re: How to change the pgsql source code and build it?? - Mailing list pgsql-hackers

From Kyotaro HORIGUCHI
Subject Re: How to change the pgsql source code and build it??
Date
Msg-id 20140623.161421.62267203.horiguchi.kyotaro@lab.ntt.co.jp
Whole thread Raw
In response to Re: How to change the pgsql source code and build it??  (Shreesha <shreesha1988@gmail.com>)
List pgsql-hackers
Hello, I don't know you environment so I don't see how many
additional changes are needed, but still I think the message
should not be seen there.

> @Fabrizio de Royes Mello, Even upon making changes as per your suggestion,
> I could see that initdb is failing for the same reason:
> ********************************************************************
> /mswitch/pgsql/bin # ./initdb -D ../data/
...
> creating template1 database in ../data/base/1 ... "root" execution of the
> PostgreSQL server is not permitted.
> The server must be started under an unprivileged user ID to prevent
..
> Please let me know if I need to make changes in any other place. Appreciate
> your help!

The complaint looks to be made at the first one among the four
points I have shown, as far as I can see.  Are you sure that the
'postgres' binary invoked at the time has been built after
modification? 'which postgres' will show you the file to be
checked and replaced.

| postgresql $ find . -type f -print | xargs grep -nH 'geteuid() == 0'
| ./src/backend/main/main.c:377:  if (geteuid() == 0)
| ./src/bin/pg_ctl/pg_ctl.c:2121: if (geteuid() == 0)
| ./src/bin/initdb/initdb.c:778:  if (geteuid() == 0)                      /* 0 is root's uid */
| ./src/bin/pg_resetxlog/pg_resetxlog.c:250:      if (geteuid() == 0)


> On Fri, Jun 13, 2014 at 9:43 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> > Fabrízio de Royes Mello <fabriziomello@gmail.com> writes:
> > > On Thu, Jun 12, 2014 at 10:59 PM, Kyotaro HORIGUCHI <
> > > horiguchi.kyotaro@lab.ntt.co.jp> wrote:
> > >> Try replacing these conditions with "(0 && geteuid() == 0)" and
> > >> you would see it run as root.
> >
> > > Maybe a compile option like '--enable-run-as-root' could be added to
> > allow
> > > it without the need of change the source code.
> >
> > If we wanted it to be easy to run PG as root, those tests wouldn't be
> > there in the first place.  We don't want that, so there will never be
> > anything to override that policy as easily as setting a configure option.
> >
> > In the case at hand, the OP wants to run on some weird system that
> > apparently doesn't have multiple users at all.  It's a pretty safe bet
> > that hacking out those geteuid tests is just the tip of the iceberg of
> > what he's going to have to change to make it work, because it probably
> > deviates from typical-Unix-environment in a lot of other ways too.
> > So I can't get too concerned about how easy this one aspect is for him.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center



pgsql-hackers by date:

Previous
From: Kyotaro HORIGUCHI
Date:
Subject: Re: pg_resetxlog to clear backup start/end locations.
Next
From: Fujii Masao
Date:
Subject: Re: [Fwd: Re: proposal: new long psql parameter --on-error-stop]