+2019-11-06 Frank Ch. Eigler <fche@redhat.com>
+
+ * debuginfod.cxx: Add new -L (symlink-following) mode.
+ * debuginfod.8: Document it.
+
2019-11-04 Frank Ch. Eigler <fche@redhat.com>
* debuginfo-client.c (debuginfod_set_progressfn): New function
// "source-oci-imageregistry" ...
{ NULL, 0, NULL, 0, "Options:", 2 },
+ { "logical", 'L', NULL, 0, "Follow symlinks, default=ignore.", 0 },
{ "rescan-time", 't', "SECONDS", 0, "Number of seconds to wait between rescans, 0=disable.", 0 },
{ "groom-time", 'g', "SECONDS", 0, "Number of seconds to wait between database grooming, 0=disable.", 0 },
{ "maxigroom", 'G', NULL, 0, "Run a complete database groom/shrink pass at startup.", 0 },
static regex_t file_include_regex;
static regex_t file_exclude_regex;
static int test_webapi_sleep; /* testing only */
+static bool traverse_logical;
/* Handle program arguments. */
break;
case 'F': scan_files = true; break;
case 'R': scan_rpms = true; break;
+ case 'L':
+ traverse_logical = true;
+ break;
case 'D': extra_ddl.push_back(string(arg)); break;
case 't':
rescan_s = (unsigned) atoi(arg);
unsigned fts_scanned=0, fts_regex=0, fts_cached=0, fts_debuginfo=0, fts_executable=0, fts_sourcefiles=0;
FTS *fts = fts_open (dirs,
- FTS_PHYSICAL /* don't follow symlinks */
- | FTS_XDEV /* don't cross devices/mountpoints */
+ (traverse_logical ? FTS_LOGICAL : FTS_PHYSICAL|FTS_XDEV)
| FTS_NOCHDIR /* multithreaded */,
NULL);
if (fts == NULL)
throw libc_exception(f->fts_errno, string("fts/file traversal ") + string(f->fts_path));
default:
- case FTS_SL: /* NB: don't enter symbolic links into the database */
+ case FTS_SL: /* ignore symlinks; seen in non-L mode only */
break;
}
unsigned fts_executable=0, fts_rpm = 0, fts_sref=0, fts_sdef=0;
FTS *fts = fts_open (dirs,
- FTS_PHYSICAL /* don't follow symlinks */
- | FTS_XDEV /* don't cross devices/mountpoints */
+ (traverse_logical ? FTS_LOGICAL : FTS_PHYSICAL|FTS_XDEV)
| FTS_NOCHDIR /* multithreaded */,
NULL);
if (fts == NULL)
throw libc_exception(f->fts_errno, string("fts/rpm traversal ") + string(f->fts_path));
default:
- case FTS_SL: /* NB: don't enter symbolic links into the database */
+ case FTS_SL: /* ignore symlinks; seen in non-L mode only */
break;
}
or an RPM. The default is the number of processors on the system;
the minimum is 1.
+.TP
+.B "\-L"
+Traverse symbolic links encountered during traversal of the PATHs,
+including across devices - as in \fIfind\ -L\fP. The default is to
+traverse the physical directory structure only, stay on the same
+device, and ignore symlinks - as in \fIfind\ -P\ -xdev\fP. Caution: a
+loops in the symbolic directory tree might lead to \fIinfinite
+traversal\fP.
+
.TP
.B "\-v"
Increase verbosity of logging to the standard error file descriptor.
+2019-11-06 Frank Ch. Eigler <fche@redhat.com>
+
+ * run-debuginfod-find.sh: Test debuginfod -L mode. Drop
+ plain debuginfo-find help-output-comparison.
+
2019-11-04 Frank Ch. Eigler <fche@redhat.com>
* run-debuginfod-find.sh: Test debuginfod-find -v progress mode.
. $srcdir/test-subr.sh # includes set -e
DB=${PWD}/.debuginfod_tmp.sqlite
+tempfiles $DB
export DEBUGINFOD_CACHE_PATH=${PWD}/.client_cache
# clean up trash if we were aborted early
-trap 'kill $PID1 $PID2 || true; sleep 5; rm -rf F R ${PWD}/.client_cache*; exit_cleanup' 0 1 2 3 5 9 15
+trap 'kill $PID1 $PID2 || true; sleep 5; rm -rf F R L ${PWD}/.client_cache*; exit_cleanup' 0 1 2 3 5 9 15
# find an unused port number
while true; do
# So we gather the LD_LIBRARY_PATH with this cunning trick:
ldpath=`testrun sh -c 'echo $LD_LIBRARY_PATH'`
-mkdir F R
-# not tempfiles F R - they are directories which we clean up manually
-env DEBUGINFOD_TEST_WEBAPI_SLEEP=3 LD_LIBRARY_PATH=$ldpath DEBUGINFOD_URLS= ${abs_builddir}/../debuginfod/debuginfod -F -R -vvvv -d $DB \
--p $PORT1 -t0 -g0 R F &
+mkdir F R L
+# not tempfiles F R L - they are directories which we clean up manually
+ln -s ${abs_builddir}/dwfllines L/foo # any program not used elsewhere in this test
+
+env DEBUGINFOD_TEST_WEBAPI_SLEEP=3 LD_LIBRARY_PATH=$ldpath DEBUGINFOD_URLS= ${abs_builddir}/../debuginfod/debuginfod -F -R -vvvv -d $DB -p $PORT1 -t0 -g0 R F L &
PID1=$!
sleep 3
export DEBUGINFOD_URLS=http://localhost:$PORT1/ # or without trailing /
export DEBUGINFOD_CACHE_PATH=${PWD}/.client_cache2
mkdir -p $DEBUGINFOD_CACHE_PATH
# NB: inherits the DEBUGINFOD_URLS to the first server
-env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../debuginfod/debuginfod -F -vvvv -d ${DB}_2 -p $PORT2 &
+# NB: run in -L symlink-following mode for the L subdir
+env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../debuginfod/debuginfod -F -vvvv -d ${DB}_2 -p $PORT2 -L L &
PID2=$!
+tempfiles ${DB}_2
sleep 3
# have clients contact the new server
export DEBUGINFOD_URLS=http://localhost:$PORT2
testrun ${abs_builddir}/debuginfod_build_id_find -e F/prog 1
+# confirm that first server can't resolve symlinked info in L/ but second can
+BUILDID=`env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../src/readelf \
+ -a L/foo | grep 'Build ID' | cut -d ' ' -f 7`
+file L/foo
+file -L L/foo
+export DEBUGINFOD_URLS=http://localhost:$PORT1
+rm -rf $DEBUGINFOD_CACHE_PATH
+testrun ${abs_top_builddir}/debuginfod/debuginfod-find debuginfo $BUILDID && false || true
+export DEBUGINFOD_URLS=http://localhost:$PORT2
+testrun ${abs_top_builddir}/debuginfod/debuginfod-find debuginfo $BUILDID
+
+
# test parallel queries in client
export DEBUGINFOD_CACHE_PATH=${PWD}/.client_cache3
mkdir -p $DEBUGINFOD_CACHE_PATH