summaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
Diffstat (limited to 'elf')
-rw-r--r--elf/Makefile4
-rw-r--r--elf/dl-tunables.c12
-rw-r--r--elf/dl-tunables.h4
3 files changed, 18 insertions, 2 deletions
diff --git a/elf/Makefile b/elf/Makefile
index 3cda2c9db8..c3636a64d2 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -36,8 +36,10 @@ ifeq (yes,$(use-ldconfig))
dl-routines += dl-cache
endif
-ifeq (yes,$(have-tunables))
+ifneq (no,$(have-tunables))
dl-routines += dl-tunables
+tunables-type = $(addprefix TUNABLES_FRONTEND_,$(have-tunables))
+CPPFLAGS-dl-tunables.c = -DTUNABLES_FRONTEND=$(tunables-type)
# Make sure that the compiler does not insert any library calls in tunables
# code paths.
diff --git a/elf/dl-tunables.c b/elf/dl-tunables.c
index 8d6914020d..39feecde16 100644
--- a/elf/dl-tunables.c
+++ b/elf/dl-tunables.c
@@ -30,7 +30,9 @@
#define TUNABLES_INTERNAL 1
#include "dl-tunables.h"
-#define GLIBC_TUNABLES "GLIBC_TUNABLES"
+#if TUNABLES_FRONTEND == TUNABLES_FRONTEND_valstring
+# define GLIBC_TUNABLES "GLIBC_TUNABLES"
+#endif
/* Compare environment or tunable names, bounded by the name hardcoded in
glibc. */
@@ -48,6 +50,7 @@ is_name (const char *orig, const char *envname)
return false;
}
+#if TUNABLES_FRONTEND == TUNABLES_FRONTEND_valstring
static char *
tunables_strdup (const char *in)
{
@@ -70,6 +73,7 @@ tunables_strdup (const char *in)
return out;
}
+#endif
static char **
get_next_env (char **envp, char **name, size_t *namelen, char **val)
@@ -244,6 +248,7 @@ tunable_initialize (tunable_t *cur, const char *strval)
}
}
+#if TUNABLES_FRONTEND == TUNABLES_FRONTEND_valstring
static void
parse_tunables (char *tunestr)
{
@@ -309,6 +314,7 @@ parse_tunables (char *tunestr)
return;
}
}
+#endif
static size_t
min_strlen (const char *s)
@@ -329,6 +335,7 @@ disable_tunable (tunable_id_t id, char **envp)
if (env_alias != NULL)
tunables_unsetenv (envp, tunable_list[id].env_alias);
+#if TUNABLES_FRONTEND == TUNABLES_FRONTEND_valstring
char *tunable = getenv (GLIBC_TUNABLES);
const char *cmp = tunable_list[id].name;
const size_t len = min_strlen (cmp);
@@ -345,6 +352,7 @@ disable_tunable (tunable_id_t id, char **envp)
}
tunable++;
}
+#endif
}
/* Disable the glibc.malloc.check tunable in SETUID/SETGID programs unless
@@ -375,6 +383,7 @@ __tunables_init (char **envp)
while ((envp = get_next_env (envp, &envname, &len, &envval)) != NULL)
{
+#if TUNABLES_FRONTEND == TUNABLES_FRONTEND_valstring
if (is_name (GLIBC_TUNABLES, envname))
{
char *val = tunables_strdup (envval);
@@ -382,6 +391,7 @@ __tunables_init (char **envp)
parse_tunables (val);
continue;
}
+#endif
for (int i = 0; i < sizeof (tunable_list) / sizeof (tunable_t); i++)
{
diff --git a/elf/dl-tunables.h b/elf/dl-tunables.h
index a3f5472b45..033781856a 100644
--- a/elf/dl-tunables.h
+++ b/elf/dl-tunables.h
@@ -84,5 +84,9 @@ extern void __tunable_set_val (tunable_id_t, void *, tunable_callback_t);
/* Namespace sanity for callback functions. Use this macro to keep the
namespace of the modules clean. */
# define DL_TUNABLE_CALLBACK(__name) _dl_tunable_ ## __name
+
+# define TUNABLES_FRONTEND_valstring 1
+/* The default value for TUNABLES_FRONTEND. */
+# define TUNABLES_FRONTEND_yes TUNABLES_FRONTEND_valstring
#endif
#endif