Re: pkg check -B tcpdump: libcap_dns.so.2 not found

From: Tatsuki Makino <tatsuki_makino_at_hotmail.com>
Date: Sat, 11 Nov 2023 05:51:40 UTC
John W. O'Brien wrote on 2023/11/11 11:25:
> On 11/10/23 16:26, Tatsuki Makino wrote:
>> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=261550
>
> I can reproduce the example you cite in comment 8, and yet "-d" and "-B" output cover disjoint packages on this system.

> That is, it seems like bug 261550 is about shlibs that are provided by base ending up being recorded in the local package database as if they are provided by packages. Something about how the llvm15 package is produced and/or how its metadata is ingested into the local package database results in required/provided data that is invalid.

> That is, it seems like the tcpdump anomaly is fundamentally different than the llvm15 example from bug 261550.

I checked.
This is a different problem than bug 261550.
And it is presumed that this does not occur at 15?-CURRENT.
My 12.x-STABLE still has the cause of this problem.

Here is how I looked into it.

cd /tmp/
echo 'int main() { return 0; }' > /tmp/test.c
clang -shared -Wl,--soname,libaaaaa.so -o /tmp/libaaaaa.so /tmp/test.c
clang /tmp/test.c -L/tmp -laaaaa
truss -o /tmp/truss.log ./a.out
grep -e ^openat.\*libaaaaa /tmp/truss.log

The result of the last grep is the following.

openat(AT_FDCWD,"/lib/libaaaaa.so",O_RDONLY|O_CLOEXEC|O_VERIFY,00) ERR#2 'No such file or directory'
openat(AT_FDCWD,"/usr/lib/libaaaaa.so",O_RDONLY|O_CLOEXEC|O_VERIFY,00) ERR#2 'No such file or directory'
openat(AT_FDCWD,"/usr/lib/compat/libaaaaa.so",O_RDONLY|O_CLOEXEC|O_VERIFY,00) ERR#2 'No such file or directory'
openat(AT_FDCWD,"/usr/local/lib/libaaaaa.so",O_RDONLY|O_CLOEXEC|O_VERIFY,00) ERR#2 'No such file or directory'
openat(AT_FDCWD,"/usr/local/lib/compat/pkg/libaaaaa.so",O_RDONLY|O_CLOEXEC|O_VERIFY,00) ERR#2 'No such file or directory'
openat(AT_FDCWD,"/lib/casper/libaaaaa.so",O_RDONLY|O_CLOEXEC|O_VERIFY,00) ERR#2 'No such file or directory'
openat(AT_FDCWD,"/lib/libaaaaa.so",O_RDONLY|O_CLOEXEC|O_VERIFY,00) ERR#2 'No such file or directory'
openat(AT_FDCWD,"/usr/lib/libaaaaa.so",O_RDONLY|O_CLOEXEC|O_VERIFY,00) ERR#2 'No such file or directory'

I can understand it because it is related to ldconfig up to /usr/local/lib/compat/pkg, but then it jumps to /lib/casper.
This is due to the following.

https://cgit.freebsd.org/src/tree/libexec/rtld-elf/paths.h?h=stable/12#n59

This allows tcpdump to load libcap_dns.so.2.
However, pkg does not seem to treat that directory as a base library directory.

It is presumed that the main branch will not have this problem because it has already been moved from /lib/casper to /lib.

> Would freebsd-pkg@ be a better forum for this discussion?

I do not subscribe, so please take this :)

Regards.