Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1exH4j-0004kV-Iu for pgsql-bugs@arkaria.postgresql.org; Sat, 17 Mar 2018 19:01:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1exH4i-0001ip-MU for pgsql-bugs@arkaria.postgresql.org; Sat, 17 Mar 2018 19:01:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1exH4i-0001ig-GX for pgsql-bugs@lists.postgresql.org; Sat, 17 Mar 2018 19:01:04 +0000 Received: from crane.smokva.net ([85.10.196.166]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1exH4f-0007EU-25 for pgsql-bugs@lists.postgresql.org; Sat, 17 Mar 2018 19:01:04 +0000 Received: from pintail.NGC068 (212-51-138-61.fiber7.init7.net [212.51.138.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by crane.smokva.net (Postfix) with ESMTPSA id 978991CAEE56; Sat, 17 Mar 2018 20:00:59 +0100 (CET) Date: Sat, 17 Mar 2018 20:00:58 +0100 From: Petar Bogdanovic To: Tom Lane Cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15120: use of getcwd(3)/chdir(2) during path resolution (exec.c) Message-ID: <20180317190058.GA2414@pintail.NGC068> References: <152130268473.1317.3689189784729884454@wrigleys.postgresql.org> <18476.1521304133@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <18476.1521304133@sss.pgh.pa.us> User-Agent: Mutt/1.9.3 (2018-01-21) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sat, Mar 17, 2018 at 12:28:53PM -0400, Tom Lane wrote: > PG Bug reporting form 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.