Re: BUG #15265: The program "initdb" is needed by pg_ctl but was not found in the same directory as "pg_ctl".

Lists: Postg토토 베이SQL : Postg토토 베이SQL 메일 링리스트 : 2018-07-09 이후 PGSQL-BUGS 08:54
From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: mohammedshahid(dot)r(at)gmail(dot)com
Subject: BUG #15265: The program "initdb" is needed by pg_ctl but was not found in the same directory as "pg_ctl".
Date: 2018-07-06 18:10:47
Message-ID: 153090064731.1408.9248514053747358145@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 15265
Logged by: Mohammed Shahid Nawaz
Email address: mohammedshahid(dot)r(at)gmail(dot)com
PostgreSQL version: 10.4
Operating system: CentOS7
Description:

Hello,
I am new to this forum, i am facing this issue, where i get the below
error.

sudo -u shahid ./pg_ctl -D /root/pgsql10x/data/ initdb invalid binary
"/root/pgsql10x/bin/pg_ctl" invalid binary "/root/pgsql10x/bin/pg_ctl"
invalid binary "/root/pgsql10x/bin/pg_ctl" The program "initdb" is needed by
pg_ctl but was not found in the same directory as "pg_ctl". Check your
installation.

FYI , I am trying to run this from root. I have built from the source. I am
trying version 10. on CentOS7. I downloaded direct from postgres site. I am
not facing this problem when i run as non-root user.

I have all the files in the bin directory, as shared below , bin directory
files

-rwxrwxrwx. 1 shahid shahid 7604946 Jul 6 17:19 postgres
lrwxrwxrwx. 1 shahid shahid 8 Jul 6 17:19 postmaster -> postgres
-rwxr-xr-x. 1 shahid shahid 908965 Jul 6 17:19 ecpg
-rwxr-xr-x. 1 shahid shahid 128690 Jul 6 17:19 initdb
-rwxr-xr-x. 1 shahid shahid 30548 Jul 6 17:19 pg_archivecleanup
-rwxr-xr-x. 1 shahid shahid 112608 Jul 6 17:19 pg_basebackup
-rwxr-xr-x. 1 shahid shahid 71241 Jul 6 17:19 pg_receivewal
-rwxr-xr-x. 1 shahid shahid 72771 Jul 6 17:19 pg_recvlogical
-rwxr-xr-x. 1 shahid shahid 30009 Jul 6 17:19 pg_config
-rwxr-xr-x. 1 shahid shahid 39920 Jul 6 17:19 pg_controldata
-rwxr-xr-x. 1 shahid shahid 58438 Jul 6 17:19 pg_ctl
-rwxr-xr-x. 1 shahid shahid 400623 Jul 6 17:19 pg_dump
-rwxr-xr-x. 1 shahid shahid 164991 Jul 6 17:19 pg_restore
-rwxr-xr-x. 1 shahid shahid 97686 Jul 6 17:19 pg_dumpall
-rwxr-xr-x. 1 shahid shahid 49138 Jul 6 17:19 pg_resetwal
-rwxr-xr-x. 1 shahid shahid 88205 Jul 6 17:19 pg_rewind
-rwxr-xr-x. 1 shahid shahid 31798 Jul 6 17:19 pg_test_fsync
-rwxr-xr-x. 1 shahid shahid 26337 Jul 6 17:19 pg_test_timing
-rwxr-xr-x. 1 shahid shahid 130515 Jul 6 17:19 pg_upgrade
-rwxr-xr-x. 1 shahid shahid 86270 Jul 6 17:19 pg_waldump
-rwxr-xr-x. 1 shahid shahid 141273 Jul 6 17:19 pgbench
-rwxr-xr-x. 1 shahid shahid 454216 Jul 6 17:19 psql
-rwxr-xr-x. 1 shahid shahid 60635 Jul 6 17:19 createdb
-rwxr-xr-x. 1 shahid shahid 56335 Jul 6 17:19 dropdb
-rwxr-xr-x. 1 shahid shahid 64416 Jul 6 17:19 createuser
-rwxr-xr-x. 1 shahid shahid 56305 Jul 6 17:19 dropuser
-rwxr-xr-x. 1 shahid shahid 61135 Jul 6 17:19 clusterdb
-rwxr-xr-x. 1 shahid shahid 68735 Jul 6 17:19 vacuumdb
-rwxr-xr-x. 1 shahid shahid 64047 Jul 6 17:19 reindexdb
-rwxr-xr-x. 1 shahid shahid 59104 Jul 6 17:19 pg_isready

Requesting help at the earliest.

Thanks in advance,
Shahid


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: mohammedshahid(dot)r(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org, PG Bug reporting form <noreply(at)postgresql(dot)org>
Subject: Re: BUG #15265: The program "initdb" is needed by pg_ctl but was not found in the same directory as "pg_ctl".
Date: 2018-07-06 20:02:30
Message-ID: 69527.1530907350@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

=?utf-8?q?PG_Bug_reporting_form?= <noreply(at)postgresql(dot)org> writes:
> sudo -u shahid ./pg_ctl -D /root/pgsql10x/data/ initdb
> invalid binary "/root/pgsql10x/bin/pg_ctl"

I think you would get that error if pg_ctl is unable to stat itself,
which might be due to a permissions problem. Are you sure the shahid
user can read/exec all the directories in that path (particularly /root)?

regards, tom lane


From: Mohammed Shahid Nawaz <mohammedshahid(dot)r(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org, PG Bug reporting form <noreply(at)postgresql(dot)org>
Subject: Re: BUG #15265: The program "initdb" is needed by pg_ctl but was not found in the same directory as "pg_ctl".
Date: 2018-07-07 06:00:57
Message-ID: CAG5wiRznpn99x_AmymU9x+E6jh1zBB+QOkOXMRuW+fCz4JMfqA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Hi Tom,
Thanks for the quick response.
The same build and, the same command works fine on a non-root user.
Since, this time i am running from a root login, the command i use is as
follows.
su - shahid -c '/root/pgsql10x/bin/pg_ctl -D /root/pgsql10x/data/ initdb'

The bin folder has 777 permission with the owner being shahid here.
If you see my post I have shared the ls-lrt output for reference.

I have been using the same command for my earlier 9.6.3 version of build,
and it worked without any trouble.

Thanks again,
Mohammed Shahid Nawaz

On Sat 7 Jul, 2018, 1:32 AM Tom Lane, <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> =?utf-8?q?PG_Bug_reporting_form?= <noreply(at)postgresql(dot)org> writes:
> > sudo -u shahid ./pg_ctl -D /root/pgsql10x/data/ initdb
> > invalid binary "/root/pgsql10x/bin/pg_ctl"
>
> I think you would get that error if pg_ctl is unable to stat itself,
> which might be due to a permissions problem. Are you sure the shahid
> user can read/exec all the directories in that path (particularly /root)?
>
> regards, tom lane
>


From: Mohammed Shahid Nawaz <mohammedshahid(dot)r(at)gmail(dot)com>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: PG Bug reporting form <noreply(at)postgresql(dot)org>
Subject: Re: BUG #15265: The program "initdb" is needed by pg_ctl but was not found in the same directory as "pg_ctl".
Date: 2018-07-09 08:54:14
Message-ID: CAG5wiRyLDtVtu=61rgVLndU+gxvgL+B3m+uwEdRP4x+Sg4hFkg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: Postg토토 베이SQL : Postg토토 베이SQL 메일 링리스트 : 2018-07-09 이후 PGSQL-BUGS 08:54

Hello Everyone,
Can anyone help me with this issue? As this is being a road block for me,
where I am able to run the commands in non-root login, but not from root
with sudo or su command.
Requesting help at the earliest.
Thanks in Advance. I

Shahid

On Sat 7 Jul, 2018, 11:30 AM Mohammed Shahid Nawaz, <
mohammedshahid(dot)r(at)gmail(dot)com> wrote:

> Hi Tom,
> Thanks for the quick response.
> The same build and, the same command works fine on a non-root user.
> Since, this time i am running from a root login, the command i use is as
> follows.
> su - shahid -c '/root/pgsql10x/bin/pg_ctl -D /root/pgsql10x/data/ initdb'
>
> The bin folder has 777 permission with the owner being shahid here.
> If you see my post I have shared the ls-lrt output for reference.
>
> I have been using the same command for my earlier 9.6.3 version of build,
> and it worked without any trouble.
>
> Thanks again,
> Mohammed Shahid Nawaz
>
>
>
> On Sat 7 Jul, 2018, 1:32 AM Tom Lane, <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
>> =?utf-8?q?PG_Bug_reporting_form?= <noreply(at)postgresql(dot)org> writes:
>> > sudo -u shahid ./pg_ctl -D /root/pgsql10x/data/ initdb
>> > invalid binary "/root/pgsql10x/bin/pg_ctl"
>>
>> I think you would get that error if pg_ctl is unable to stat itself,
>> which might be due to a permissions problem. Are you sure the shahid
>> user can read/exec all the directories in that path (particularly /root)?
>>
>> regards, tom lane
>>
>


From: "Aaron W(dot) Swenson" <titanofold(at)gentoo(dot)org>
To: Mohammed Shahid Nawaz <mohammedshahid(dot)r(at)gmail(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org, PG Bug reporting form <noreply(at)postgresql(dot)org>
Subject: Re: BUG #15265: The program "initdb" is needed by pg_ctl but was not found in the same directory as "pg_ctl".
Date: 2018-07-09 09:54:22
Message-ID: 20180709095422.GB11978@martineau.grandmasfridge.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On 2018-07-09 14:24, Mohammed Shahid Nawaz wrote:
> Hello Everyone,
> Can anyone help me with this issue? As this is being a road block for me,
> where I am able to run the commands in non-root login, but not from root
> with sudo or su command.
> Requesting help at the earliest.
> Thanks in Advance. I
>
> Shahid

It’s probably because /root has its access restricted to just the root
user, so the shahid user can’t get past that first part of the path.

Further, it’s atypical to allow users to do anything inside /root. You should
probably work under /usr/local or in /home/shahid/.


From: Mohammed Shahid Nawaz <mohammedshahid(dot)r(at)gmail(dot)com>
To: "Aaron W(dot) Swenson" <titanofold(at)gentoo(dot)org>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org, PG Bug reporting form <noreply(at)postgresql(dot)org>
Subject: Re: BUG #15265: The program "initdb" is needed by pg_ctl but was not found in the same directory as "pg_ctl".
Date: 2018-07-09 09:59:50
Message-ID: CAG5wiRzgpgxbKDQQsN57ErKPe9ekzWPpZ3_xvUNhWv_k80fY0g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Hello Aaron,
Talking about the restrictions, I have given permissions to user Shahid, as
equivalent to root by editing the sudoers file.

I did not face this issue in earlier versions and the same setup and
command steps worked flawlessly.

I have even given su permission for user shahid to run su commands.

This was never the case with 9.6.3.

I have been running for past 1yr from root by using su / sudo commands to
initdb and start the database.

Thanks
Shahid

On Mon 9 Jul, 2018, 3:24 PM Aaron W. Swenson, <titanofold(at)gentoo(dot)org> wrote:

> On 2018-07-09 14:24, Mohammed Shahid Nawaz wrote:
> > Hello Everyone,
> > Can anyone help me with this issue? As this is being a road block for
> me,
> > where I am able to run the commands in non-root login, but not from root
> > with sudo or su command.
> > Requesting help at the earliest.
> > Thanks in Advance. I
> >
> > Shahid
>
> It’s probably because /root has its access restricted to just the root
> user, so the shahid user can’t get past that first part of the path.
>
> Further, it’s atypical to allow users to do anything inside /root. You
> should
> probably work under /usr/local or in /home/shahid/.
>