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 1exHzS-0007XV-6t for pgsql-bugs@arkaria.postgresql.org; Sat, 17 Mar 2018 19:59:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1exHzQ-0004y5-Jp for pgsql-bugs@arkaria.postgresql.org; Sat, 17 Mar 2018 19:59:40 +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 1exHzQ-0004xw-DD for pgsql-bugs@lists.postgresql.org; Sat, 17 Mar 2018 19:59:40 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1exHzK-0008WE-0E for pgsql-bugs@lists.postgresql.org; Sat, 17 Mar 2018 19:59:39 +0000 Received: from [192.168.127.1] (port=25639 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.88 (FreeBSD)) (envelope-from ) id 1exHzH-000Ni3-71; Sat, 17 Mar 2018 19:59:31 +0000 Received: from [127.0.0.1] (port=44575 helo=caithnard.riddles.org.uk) by caithnard.riddles.org.uk with esmtp (Exim 4.89 (FreeBSD)) (envelope-from ) id 1exHzG-000F55-GO; Sat, 17 Mar 2018 19:59:30 +0000 From: Andrew Gierth To: Tom Lane Cc: petar@smokva.net, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15120: use of getcwd(3)/chdir(2) during path resolution (exec.c) In-Reply-To: <7607.1521309974@sss.pgh.pa.us> (Tom Lane's message of "Sat, 17 Mar 2018 14:06:14 -0400") Message-ID: <87efkih4gi.fsf@news-spur.riddles.org.uk> References: <152130268473.1317.3689189784729884454@wrigleys.postgresql.org> <18476.1521304133@sss.pgh.pa.us> <87in9uhbco.fsf@news-spur.riddles.org.uk> <7607.1521309974@sss.pgh.pa.us> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (berkeley-unix) Date: Sat, 17 Mar 2018 19:59:30 +0000 MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk >>>>> "Tom" == Tom Lane writes: >> On systems with openat(), would it not be possible to resolve >> symlinks without ever needing chdir? Tom> Um ... AFAICS, openat() just opens a file, it doesn't give back a Tom> resolved path. Did you mean readlinkat()? No, what I meant was that if you have openat() (and fstatat() and fdopendir()), you can do what getcwd does except starting with some arbitrary directory other than the current one. So the current logic of "chdir through all symlinks, then do getcwd to find where we landed" would not be necessary. -- Andrew (irc:RhodiumToad)