On Thu, Nov 11, 2021 at 12:42:47AM +0300, Dmitry V. Levin wrote: > Hi Frank, > > On Sun, Oct 03, 2021 at 05:33:33PM -0400, Frank Ch. Eigler via Elfutils-devel > wrote: > > commit 0c634f243d266ce8841fd311433d5d79555fabf9 > > Author: Frank Ch. Eigler <f...@redhat.com> > > Date: Sun Oct 3 17:04:24 2021 -0400 > > > > PR27783: switch default debuginfod-urls to drop-in style files > > > > Rewrote and commented the /etc/profile.d csh and sh script fragments > > to take the default $DEBUGINFOD_URLS from the union of drop-in files: > > /etc/debuginfod/*.urls. Hand-tested with csh and bash, with > > conditions including no prior $DEBUGINFOD_URLS, nonexistent .urls > > files, multiple entries in .urls files. > [...] > > diff --git a/config/profile.csh.in b/config/profile.csh.in > > index 0a2d6d162019..29e59a709450 100644 > > --- a/config/profile.csh.in > > +++ b/config/profile.csh.in > > @@ -1,11 +1,16 @@ > > -if ("@DEBUGINFOD_URLS@" != "") then > > - if ($?DEBUGINFOD_URLS) then > > - if ($%DEBUGINFOD_URLS) then > > - setenv DEBUGINFOD_URLS "$DEBUGINFOD_URLS > > @DEBUGINFOD_URLS@" > > - else > > - setenv DEBUGINFOD_URLS "@DEBUGINFOD_URLS@" > > - endif > > - else > > - setenv DEBUGINFOD_URLS "@DEBUGINFOD_URLS@" > > - endif > > + > > +# $HOME/.login* or similar files may first set $DEBUGINFOD_URLS. > > +# If $DEBUGINFOD_URLS is not set there, we set it from system *.url files. > > +# $HOME/.*rc or similar files may then amend $DEBUGINFOD_URLS. > > +# See also [man debuginfod-client-config] for other environment variables > > +# such as $DEBUGINFOD_MAXSIZE, $DEBUGINFOD_MAXTIME, $DEBUGINFOD_PROGRESS. > > + > > +if (! $?DEBUGINFOD_URLS) then > > + set prefix="@prefix@" > > + set debuginfod_urls=`find "@sysconfdir@/debuginfod/" -name '*.urls' | > > xargs cat | tr '\n' ' '` > > + if ( "$debuginfod_urls" != "" ) then > > + setenv DEBUGINFOD_URLS "$debuginfod_urls" > > + endif > > + unset debuginfod_urls > > + unset prefix > > endif > > diff --git a/config/profile.sh.in b/config/profile.sh.in > > index aa228a0dcd16..94b2983b9f90 100644 > > --- a/config/profile.sh.in > > +++ b/config/profile.sh.in > > @@ -1,4 +1,17 @@ > > -if [ -n "@DEBUGINFOD_URLS@" ]; then > > - DEBUGINFOD_URLS="${DEBUGINFOD_URLS-}${DEBUGINFOD_URLS:+ > > }@DEBUGINFOD_URLS@" > > - export DEBUGINFOD_URLS > > + > > +# $HOME/.profile* or similar files may first set $DEBUGINFOD_URLS. > > +# If $DEBUGINFOD_URLS is not set there, we set it from system *.url files. > > +# $HOME/.*rc or similar files may then amend $DEBUGINFOD_URLS. > > +# See also [man debuginfod-client-config] for other environment variables > > +# such as $DEBUGINFOD_MAXSIZE, $DEBUGINFOD_MAXTIME, $DEBUGINFOD_PROGRESS. > > + > > +if [ -z "$DEBUGINFOD_URLS" ]; then
By the way, this test has undesired consequences in "set -eu" mode: $ sh -c 'set -eu; if [ -z "$DEBUGINFOD_URLS" ]; then echo bingo; fi; echo ok' sh: DEBUGINFOD_URLS: unbound variable It has to be "${DEBUGINFOD_URLS-}" to avoid this side effect. Also, this method cannot distinguish an empty DEBUGINFOD_URLS from unset DEBUGINFOD_URLS. As result, there is no easy way for the user to turn this feature off. Consider a test like [ -z "${DEBUGINFOD_URLS+1}" ] that would enable /etc/debuginfod/*.urls scanning only if DEBUGINFOD_URLS is unset. -- ldv