diff options
author | Frank Ch. Eigler <fche@redhat.com> | 2019-11-06 18:53:31 -0500 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2019-11-22 23:56:25 +0100 |
commit | 0587c28365ccb119f860c1b3ca115a6105baadc8 (patch) | |
tree | 6acb3eeb8b8f1fc7fbc9d9782db58921cd83cabf | |
parent | 3d7a08d5d37c3e96151d1be6e6e6eb0556c079c9 (diff) |
debuginfod 4: symbolic link traversal mode
In order to support file/rpm archives that are organized via symlink
trees, add an "-L" option to debuginfod, meaning about the same as for
find(1) or ls(1): to traverse rather than ignore symlinks.
-rw-r--r-- | debuginfod/ChangeLog | 5 | ||||
-rw-r--r-- | debuginfod/debuginfod.cxx | 15 | ||||
-rw-r--r-- | doc/debuginfod.8 | 9 | ||||
-rw-r--r-- | tests/ChangeLog | 5 | ||||
-rwxr-xr-x | tests/run-debuginfod-find.sh | 28 |
5 files changed, 50 insertions, 12 deletions
diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog index 34713746..2870b6df 100644 --- a/debuginfod/ChangeLog +++ b/debuginfod/ChangeLog @@ -1,3 +1,8 @@ +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 diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx index 359f9a24..8c8f2658 100644 --- a/debuginfod/debuginfod.cxx +++ b/debuginfod/debuginfod.cxx @@ -326,6 +326,7 @@ static const struct argp_option options[] = // "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 }, @@ -374,6 +375,7 @@ static vector<string> extra_ddl; 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. */ @@ -391,6 +393,9 @@ parse_opt (int key, char *arg, 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); @@ -1463,8 +1468,7 @@ scan_source_file_path (const string& dir) 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) @@ -1660,7 +1664,7 @@ scan_source_file_path (const string& dir) 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; } @@ -1931,8 +1935,7 @@ scan_source_rpm_path (const string& dir) 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) @@ -2062,7 +2065,7 @@ scan_source_rpm_path (const string& dir) 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; } diff --git a/doc/debuginfod.8 b/doc/debuginfod.8 index eb1d8910..8783df58 100644 --- a/doc/debuginfod.8 +++ b/doc/debuginfod.8 @@ -159,6 +159,15 @@ 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. May be repeated to increase details. The default verbosity is 0. diff --git a/tests/ChangeLog b/tests/ChangeLog index 42dee5c2..3ce7f01a 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,8 @@ +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. diff --git a/tests/run-debuginfod-find.sh b/tests/run-debuginfod-find.sh index eb32def6..4b31af10 100755 --- a/tests/run-debuginfod-find.sh +++ b/tests/run-debuginfod-find.sh @@ -20,10 +20,11 @@ set -x . $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 @@ -40,10 +41,11 @@ done # 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 / @@ -193,14 +195,28 @@ done 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 |