From d8a7e5b36b9fb46488f7e0d6859dbd10fa318ead Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Mon, 9 Nov 2020 09:03:58 +0200 Subject: Only do early name services initialization if we actually chroot There's no point or need to do all this fluff on library initialization, we can just as well do it when we're told to use a chroot by calling rpmChrootSet(), at which time we're still on familiar ground. Eliminating unused cruft from initialization can't hurt our start-up times either. (cherry picked from commit f9c7b53f50adc129baee809692d4c80b3bd15432) --- lib/rpmchroot.c | 5 +++++ lib/rpmrc.c | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/rpmchroot.c b/lib/rpmchroot.c index 4f2ca77cd..400e285b5 100644 --- a/lib/rpmchroot.c +++ b/lib/rpmchroot.c @@ -5,6 +5,7 @@ #include #include #include "lib/rpmchroot.h" +#include "lib/rpmug.h" #include "debug.h" int _rpm_nouserns = 0; @@ -101,6 +102,10 @@ int rpmChrootSet(const char *rootDir) rpmlog(RPMLOG_ERR, _("Unable to open current directory: %m\n")); rc = -1; } + + /* Force preloading of dlopen()'ed libraries before chroot */ + if (rpmugInit()) + rc = -1; } return rc; diff --git a/lib/rpmrc.c b/lib/rpmrc.c index 77a8708fb..e707ab238 100644 --- a/lib/rpmrc.c +++ b/lib/rpmrc.c @@ -35,7 +35,6 @@ #include "rpmio/rpmlua.h" #include "rpmio/rpmio_internal.h" /* XXX for rpmioSlurp */ #include "lib/misc.h" -#include "lib/rpmug.h" #include "debug.h" @@ -1632,10 +1631,6 @@ int rpmReadConfigFiles(const char * file, const char * target) pthread_once(&atexit_registered, register_atexit); - /* Force preloading of dlopen()'ed libraries in case we go chrooting */ - if (rpmugInit()) - goto exit; - if (rpmInitCrypto()) goto exit; -- cgit v1.2.1