pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Petar Bogdanovic <petar@smokva.net>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15120: use of getcwd(3)/chdir(2) during path resolution (exec.c)
Date: Sat, 17 Mar 2018 20:00:58 +0100
Message-ID: <20180317190058.GA2414@pintail.NGC068> (raw)
In-Reply-To: <18476.1521304133@sss.pgh.pa.us>
References: <152130268473.1317.3689189784729884454@wrigleys.postgresql.org>
	<18476.1521304133@sss.pgh.pa.us>

On Sat, Mar 17, 2018 at 12:28:53PM -0400, Tom Lane wrote:
> PG Bug reporting form <noreply@postgresql.org> writes:
> > In the patch below, path resolution is skipped if getcwd returns EACCES.
> 
> ... I find that quite an unacceptable answer.

The patch was just a POC, yes.  I was out of better ideas and not really
qualified to rewrite find_my_exec/resolve_symlinks without breaking path
resolution for some other supported platform.


> The idea of pre-checking to see if the initial path is already absolute
> seems safe enough, but I'm not sure how much of the use-case it'd cover.
> I think your example of "sudo /usr/bin/pg_ctl" is pretty artificial;
> who'd bother spelling that out?

rc-scripts on some BSDs spell it out:

    $ uname
    NetBSD

    $ egrep 'command=|doit=' /etc/rc.d/pgsql
    command="/usr/pkg/bin/pg_ctl"
       doit="/usr/bin/su -m ${pgsql_user} -c '${command} init ${command_args}'"
       doit="/usr/bin/su -m ${pgsql_user} -c '${command} start ${command_args}'"
       doit="/usr/bin/su -m ${pgsql_user} -c '${command} restart ${command_args}'"
       doit="/usr/bin/su -m ${pgsql_user} -c '${command} stop ${command_args}'"
       doit="/usr/bin/su -m ${pgsql_user} -c '${command} reload ${command_args}'"

But you are right, testing for an absolute path is not a complete
solution either.  Running "sudo pg_ctl" will still fail.




view thread (9+ messages)  latest in thread

Message-ID: <20180317190058.GA2414@pintail.NGC068>
Permalink:  ../20180317190058.GA2414@pintail.NGC068/
Also on:    postgresql.org/message-id/20180317190058.GA2414@pintail.NGC068

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: petar@smokva.net, tgl@sss.pgh.pa.us
  Subject: Re: BUG #15120: use of getcwd(3)/chdir(2) during path resolution (exec.c)
  In-Reply-To: <20180317190058.GA2414@pintail.NGC068>
  References: <152130268473.1317.3689189784729884454@wrigleys.postgresql.org> <18476.1521304133@sss.pgh.pa.us> <20180317190058.GA2414@pintail.NGC068>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox