Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Aug 2020 16:37:46 +0100
From:      Jessica Clarke <jrtc27@freebsd.org>
To:        Ian Lepore <ian@freebsd.org>
Cc:        rgrimes@freebsd.org, Alex Richardson <arichardson@freebsd.org>, src-committers <src-committers@freebsd.org>, svn-src-all <svn-src-all@freebsd.org>, svn-src-head@freebsd.org
Subject:   Re: svn commit: r364166 - head/usr.sbin/crunch/crunchgen
Message-ID:  <7DF33D5E-A867-4C33-957D-74A6B8D72ED2@freebsd.org>
In-Reply-To: <1f724b1b9e0c230f793a49c948c778d3def045b9.camel@freebsd.org>
References:  <202008121624.07CGOTnt038878@gndrsh.dnsmgr.net> <1f724b1b9e0c230f793a49c948c778d3def045b9.camel@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 13 Aug 2020, at 16:33, Ian Lepore <ian@freebsd.org> wrote:
> On Wed, 2020-08-12 at 09:24 -0700, Rodney W. Grimes wrote:
>>> On 12 Aug 2020, at 17:10, Rodney W. Grimes <
>>> freebsd@gndrsh.dnsmgr.net> wrote:
>>>> 
>>>>> Author: arichardson
>>>>> Date: Wed Aug 12 15:49:06 2020
>>>>> New Revision: 364166
>>>>> URL: https://svnweb.freebsd.org/changeset/base/364166
>>>>> 
>>>>> Log:
>>>>> Fix crunchgen usage of mkstemp()
>>>>> 
>>>>> On Glibc systems mkstemp can only be used once with the same
>>>>> template
>>>>> string since it will be modified in-place and no longer
>>>>> contain any 'X' chars.
>>>>> It is fine to reuse the same file here but we need to be
>>>>> explicit and use
>>>>> open() instead of mkstemp() on the second use.
>>>>> 
>>>>> While touching this file also avoid a hardcoded /bin/pwd since
>>>>> that may not
>>>>> work when building on non-FreeBSD systems.
>>>> 
>>>> This may cause some grief, as now pwd may use a shell builtin
>>>> and often shell builtin's return a cwd that is not a true
>>>> full path, ie it may contain symlink compontents in the
>>>> path.
>>>> 
>>>> /bin/sh:
>>>> 
>>>> # cd /tmp/b
>>>> # /bin/pwd
>>>> /tmp/a
>>>> # pwd
>>>> /tmp/b
>>>> # ls -lag /tmp/?
>>>> lrwxr-xr-x  1 root  wheel  1 Aug 12 16:06 /tmp/b -> a
>>>> 
>>>> /tmp/a:
>>>> total 17
>>>> drwxr-xr-x   2 root  wheel    2 Aug 12 16:06 .
>>>> drwxrwxrwt  18 root  wheel  248 Aug 12 16:06 ..
>>> 
>>> There's the question of whether that really matters; both values
>>> are in
>>> some sense correct. But if you want to restore the old behaviour, I
>>> believe `env pwd` is the portable way to do so?
>> 
>> You have cut the context, but the code has a comment that
>> states it is doing this to remove symbolic links, so this
>> change infact undoes something that was being done intentionally.
>> 
>> I do believe also that a "env pwd" would do the right thing
>> as well.
>> 
> 
> Or just use "pwd -P" and avoid invoking multiple programs when the
> shell can do all the work.

Indeed, my suggestion was solving the wrong problem. r364174 added the
-P but also needlessly added env too; -P is part of POSIX so any
conforming pwd will support it, builtin or not.

Jess




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7DF33D5E-A867-4C33-957D-74A6B8D72ED2>