Page MenuHomeFreeBSD

ldconfig(8): check for no-args command line after options are parsed
ClosedPublic

Authored by kib on Nov 19 2021, 4:20 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Mar 22, 3:31 PM
Unknown Object (File)
Fri, Mar 22, 3:31 PM
Unknown Object (File)
Fri, Mar 22, 12:47 PM
Unknown Object (File)
Fri, Mar 22, 12:07 PM
Unknown Object (File)
Fri, Mar 22, 10:32 AM
Unknown Object (File)
Mar 8 2024, 3:47 AM
Unknown Object (File)
Feb 7 2024, 8:48 PM
Unknown Object (File)
Dec 20 2023, 1:29 AM
Subscribers

Details

Summary
Default action for ldconfig is specified as -R AKA 'append', and for
no-args (without options changing default actions), ldconfig should
append empty list of directories to current list.  But because the check
was done before options were parsed out, presence of any option turned
off default rescan.

As result, innocently-looked commands like `ldconfig -v' were interpreted
as setting directory hints list to one specified on the command line,
i.e. empty.

Reported by:    https://github.com/mesonbuild/meson/issues/9592

Other changes

ldconfig: use libexec/rtld-elf/rtld_paths.h

instead of duplicating definitions using slighly different macro names.
rtld_paths.h: Provide _PATH_ELF32_HINTS string, unconditionally
ldconfig: start of cleanup

Use bool.
Use local variables instead of static.
Remove non-functional debugging override of hints file path.
Use explicit exit() instead of return from main.
Minor style tweaks.
ldconfig(8): nostd/-s does nothing

Remove the option from man page and summary.  Silently ignore it when
parsing command line for backward compatibility.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib requested review of this revision.Nov 19 2021, 4:20 AM
kib edited the summary of this revision. (Show Details)

Remove -s

I confirm, this neutralizes ldconfig -v (no paths) in meson-0.60.1. Tested inside 13.0 amd64 jail after applying a19e14ca2d36 and 33dba3bb0ec2 to fix merge conflicts.

Steps to reproduce:

$ pkg install meson git
$ git clone https://gitlab.freedesktop.org/xorg/lib/libxcvt.git
$ meson setup libxcvt_build libxcvt
$ meson compile -C libxcvt_build
$ su root -c 'meson install -C libxcvt_build'

Previously it failed with

$ meson
ld-elf.so.1: Shared object "libpython3.8.so.1.0" not found, required by "python3.8"
$ git
ld-elf.so.1: Shared object "libpcre2-8.so.0" not found, required by "git"

but now works fine with

$ meson

ERROR: Must specify at least one directory name.
$ git
usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           [--super-prefix=<path>] [--config-env=<name>=<envvar>]
           <command> [<args>]
[...]
emaste added inline comments.
sbin/ldconfig/ldconfig.c
105

We could probably just delete this comment now

146

argc == optind is maybe a tiny bit confusing, we could perhaps do if (argc == optind) rescan = true; along with a comment to make it explicit? But I'm fine with this if you think that's too much.

This revision is now accepted and ready to land.Nov 24 2021, 8:28 PM

Remove a.out comment.
Set rescan to true explicitly.

This revision now requires review to proceed.Nov 24 2021, 8:49 PM
kib marked 2 inline comments as done.Nov 24 2021, 8:50 PM
This revision is now accepted and ready to land.Nov 24 2021, 8:52 PM