[yocto] [prelink-cross][PATCH] Support config dropfiles

Matt Hoosier matt.hoosier at garmin.com
Fri Jan 4 07:21:30 PST 2019


When packages provide executables or libraries in nonstandard
locations, these have to be declared in prelink.conf in order for
the tool to find them during its crawl through the filesystem.

But arranging for each package to individually edit the centralized
prelink.conf file is error-prone. Dropfiles are a good solution to
this sort of problem (e.g., systemd's unit files and central
configuration each use this mechanism).

Add support in prelink for a similar paradigm. Whatever the config
file is, search also for *.conf in <configfile>.d. In practice, this
works out to <sysrootdir>/etc/prelink.conf.d/*.conf.

Signed-off-by: Matt Hoosier <matt.hoosier at garmin.com>
---
 doc/prelink.8   | 18 +++++++++++++-----
 doc/prelink.tex |  2 +-
 src/gather.c    | 26 ++++++++++++++++++++++++++
 3 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/doc/prelink.8 b/doc/prelink.8
index 215445e..9bdd247 100644
--- a/doc/prelink.8
+++ b/doc/prelink.8
@@ -58,7 +58,9 @@ print what would be prelinked.
 .B \-a \-\-all
 Prelink all binaries and dependent libraries found in directory hierarchies
 specified in
-.IR /etc/prelink.conf .
+.IR /etc/prelink.conf
+and
+.IR /etc/prelink.conf.d/*.conf .
 Normally, only binaries specified on the command line and their dependent
 libraries are prelinked.
 .TP
@@ -101,7 +103,9 @@ option).
 .TP
 .B \-c \-\-config\-file=CONFIG
 Specify an alternate config file instead of default
-.IR /etc/prelink.conf .
+.IR /etc/prelink.conf
+and
+.IR /etc/prelink.conf.d/*.conf .
 .TP
 .B \-C \-\-cache\-file=CACHE
 Specify an alternate cache file instead of default
@@ -257,6 +261,8 @@ the libraries they depend on are prelinked with them.
 .RE
 prelinks all binaries found in directories specified in
 .I /etc/prelink.conf
+and
+.I /etc/prelink.conf.d/*.conf
 and all their dependent libraries, assigning libraries unique virtual
 address space slots only if they ever appear together, and starts
 assigning libraries at a random address.
@@ -284,10 +290,10 @@ You can run
 .I /usr/sbin/prelink -p
 to see what is stored in there.
 .TP 20
-.B /etc/prelink.conf
-Configuration file containing a list of directory hierarchies that
+.B /etc/prelink.conf /etc/prelink.conf.d/*.conf
+Configuration files containing a list of directory hierarchies that
 contain ELF shared libraries or binaries which should be prelinked.
-This configuration file is used in
+These configuration files are used in
 .B \-a
 mode to find binaries which should be prelinked and also, no matter whether
 .B \-a
@@ -297,6 +303,8 @@ prelinked. If
 finds a dependent library of some binary or other library which is not
 present in any of the directories specified either in
 .B /etc/prelink.conf
+and
+.B /etc/prelink.conf.d/*.conf
 or on the command line, then it cannot be prelinked.
 Each line of the config file should be either a comment starting with
 .BR # ,
diff --git a/doc/prelink.tex b/doc/prelink.tex
index 5075030..a931166 100644
--- a/doc/prelink.tex
+++ b/doc/prelink.tex
@@ -625,7 +625,7 @@ The second mode is {\sl full prelinking}, where the \tts{-a} option is
 given on the command line.  This in addition to incremental prelinking
 queues all executables found in directory trees specified in \tts{prelink.conf}
 (which typically includes all or most directories where system executables
-are found).  For each directory subtree in the config file the user
+are found) or \tts{prelink.conf.d/*.conf}.  For each directory subtree in the config file the user
 can specify whether symbolic links to places outside of the tree are to be followed
 or not and whether searching should continue even across filesystem
 boundaries.
diff --git a/src/gather.c b/src/gather.c
index 751822c..130ecd5 100644
--- a/src/gather.c
+++ b/src/gather.c
@@ -1190,6 +1190,32 @@ read_config (const char *config)
 
   free (line);
   fclose (file);
+
+  /* read all dropfiles recursively */
+  if (!ret)
+    {
+      char *p;
+      glob_t g;
+
+      asprintf (&p, "%s.d/*.conf", config);
+
+      if (!wrap_glob(p, 0, NULL, &g))
+	{
+	  size_t n;
+
+	  for (n = 0; n < g.gl_pathc; ++n)
+	    if (read_config (g.gl_pathv[n]))
+	      {
+		ret = 1;
+		break;
+	      }
+
+	  globfree(&g);
+	}
+
+	free (p);
+    }
+
   return ret;
 }
 
-- 
2.17.2



More information about the yocto mailing list