Re: How to change the pgsql source code and build it??

From: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
To: shreesha1988(at)gmail(dot)com
Cc: tgl(at)sss(dot)pgh(dot)pa(dot)us, fabriziomello(at)gmail(dot)com, ams(at)2ndquadrant(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: How to change the pgsql source code and build it??
Date: 2014-06-23 07:14:21
Message-ID: 20140623.161421.62267203.horiguchi.kyotaro@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > =?UTF-8?Q?Fabr=C3=ADzio_de_Royes_Mello?= <fabriziomello(at)gmail(dot)com> writes:
> > > On Thu, Jun 12, 2014 at 10:59 PM, Kyotaro HORIGUCHI <
> > > horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2014-06-23 07:36:16 Re: BUG #10728: json_to_recordset with nested json objects NULLs columns
Previous Message Kyotaro HORIGUCHI 2014-06-23 06:49:00 Re: pg_resetxlog to clear backup start/end locations.