Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 5 Oct 2020 20:33:45 -0500
From:      Kyle Evans <kevans@freebsd.org>
To:        Alexey Dokuchaev <danfe@freebsd.org>
Cc:        src-committers <src-committers@freebsd.org>, svn-src-all <svn-src-all@freebsd.org>,  svn-src-head <svn-src-head@freebsd.org>, Alex Richardson <arichardson@freebsd.org>
Subject:   Re: svn commit: r366466 - head/usr.sbin/crunch/crunchgen
Message-ID:  <CACNAnaHcuYDpD_zkqP3pLc45=4wXOyaRuExg34MT6yCD%2BomhpA@mail.gmail.com>
In-Reply-To: <20201005213914.GA28182@FreeBSD.org>
References:  <202010052057.095Kvi7e098469@repo.freebsd.org> <20201005213914.GA28182@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Oct 5, 2020 at 4:39 PM Alexey Dokuchaev <danfe@freebsd.org> wrote:
>
> On Mon, Oct 05, 2020 at 08:57:44PM +0000, Kyle Evans wrote:
> > New Revision: 366466
> > URL: https://svnweb.freebsd.org/changeset/base/366466
> >
> > Log:
> >   crunchgen: fix MK_AUTO_OBJ logic after r364166
> >
> >   r364166 converted echo -n `/bin/pwd` to a raw pwd invocation, leaving a
> >   trailing newline at the end of path.  This caused a later stat() of it to
> >   erroneously fail and the fallback to MK_AUTO_OBJ=no logic proceeded as
> >   unexpected.
>
> [...]
> @@ -648,8 +653,7 @@
>
>         /* Determine the actual srcdir (maybe symlinked). */
>         if (p->srcdir) {
> -               snprintf(line, MAXLINELEN, "cd %s && echo -n `/bin/pwd`",
> -                   p->srcdir);
> +               snprintf(line, MAXLINELEN, "cd %s && pwd", p->srcdir);
>                 f = popen(line,"r");
>
> Calling popen("cd somedir && pwd") in a C program to resolve symlinks,
> seriously?  Why not simply call realpath(3) instead? :-/
>

Excellent question. :-) CC'ing Alex, because he might have looked at
this more in-depth. I don't see any real reason for the status quo vs.
realpath(3) off the top of my head, but I'm not familiar with the
history and don't quite have the time to track down the ramifications
of the change.

Thanks,

Kyle Evans



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CACNAnaHcuYDpD_zkqP3pLc45=4wXOyaRuExg34MT6yCD%2BomhpA>