# --- T2-COPYRIGHT-NOTE-BEGIN --- # T2 SDE: package/*/glibc/ldconfig-glob.patch # Copyright (C) 2004 - 2022 The T2 SDE Project # # This Copyright note is generated by scripts/Create-CopyPatch, # more information can be found in the files COPYING and README. # # This patch file is dual-licensed. It is available under the license the # patched project is licensed under, as long as it is an OpenSource license # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms # of the GNU General Public License version 2 as used by the T2 SDE. # --- T2-COPYRIGHT-NOTE-END --- This is an alternative ldconfig wildcard expansion (glob) patch for recent glibc's. - Valentin Ziegler --- glibc-2.35/elf/ldconfig.c.vanilla 2022-02-02 13:02:34.684800081 +0100 +++ glibc-2.35/elf/ldconfig.c 2022-02-02 13:25:04.253869704 +0100 @@ -508,23 +508,56 @@ if (opt_chroot) path = chroot_canon (opt_chroot, path); - struct stat stat_buf; - if (path == NULL || stat (path, &stat_buf)) - { - if (opt_verbose) - error (0, errno, _("Can't stat %s"), entry->path); - free (entry->path); - free (entry); - } - else - { - entry->ino = stat_buf.st_ino; - entry->dev = stat_buf.st_dev; + /* assume path is a pattern */ + glob_t result; + if (glob(path, GLOB_ONLYDIR, NULL, &result) == 0) { + for (int j = 0; j < result.gl_pathc; j++) + { + /* create a copy entry with expanded path */ + struct dir_entry *real_entry = xmalloc (sizeof (struct dir_entry)); + memcpy (real_entry, entry, sizeof (struct dir_entry)); + real_entry->path = xstrdup (result.gl_pathv[j]); - if (add_single_dir (entry, 1)) - /* Add glibc-hwcaps subdirectories if present. */ - add_glibc_hwcaps_subdirectories (entry, path); - } + struct stat stat_buf; + if (real_entry->path == NULL || stat (real_entry->path, &stat_buf)) + { + if (opt_verbose) + error (0, errno, _("Can't stat %s"), real_entry->path); + free (real_entry->path); + free (real_entry); + } + else + { + real_entry->ino = stat_buf.st_ino; + real_entry->dev = stat_buf.st_dev; + + if (add_single_dir (real_entry, 1)) + /* Add glibc-hwcaps subdirectories if present. */ + add_glibc_hwcaps_subdirectories (real_entry, real_entry->path); + } + } + } else { + /* fallback to code from glibc with orig. error handling */ + struct stat stat_buf; + if (path == NULL || stat (path, &stat_buf)) + { + if (opt_verbose) + error (0, errno, _("Can't stat %s"), entry->path); + free (entry->path); + free (entry); + } + else + { + entry->ino = stat_buf.st_ino; + entry->dev = stat_buf.st_dev; + + if (add_single_dir (entry, 1)) + /* Add glibc-hwcaps subdirectories if present. */ + add_glibc_hwcaps_subdirectories (entry, path); + } + } + + globfree (&result); if (opt_chroot) free (path);