mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-01 10:06:57 +03:00
Enhance --enable-tunables to select tunables frontend at build time
At the GNU Tools Cauldron 2016, the state of the current tunables patchset was considered OK with the addition of a way to select the frontend to be used for the tunables. That is, to avoid being locked in to one type of frontend initially, it should be possible to build tunables with a different frontend with something as simple as a configure switch. To that effect, this patch enhances the --enable-tunables option to accept more values than just 'yes' or 'no'. The current frontend (and default when enable-tunables is 'yes') is called 'valstring', to select the frontend where a single environment variable is set to a colon-separated value string. More such frontends can be added in future. * Makeconfig (have-tunables): Check for non-negative instead of positive. * configure.ac: Add 'valstring' as a valid value for --enable-tunables. * configure: Regenerate. * elf/Makefile (have-tunables): Check for non-negative instead of positive. (CPPFLAGS-dl-tunables.c): Define TUNABLES_FRONTEND for dl-tunables.c. * elf/dl-tunables.c (GLIBC_TUNABLES): Define only when TUNABLES_FRONTEND == TUNABLES_FRONTEND_valstring. (tunables_strdup): Likewise. (disable_tunables): Likewise. (parse_tunables): Likewise. (__tunables_init): Process GLIBC_TUNABLES envvar only when. TUNABLES_FRONTEND == TUNABLES_FRONTEND_valstring. * elf/dl-tunables.h (TUNABLES_FRONTEND_valstring): New macro. (TUNABLES_FRONTEND_yes): New macro, define as TUNABLES_FRONTEND_valstring by default. * manual/install.texi: Document new acceptable values for --enable-tunables. * INSTALL: Regenerate.
This commit is contained in:
@ -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++)
|
||||
{
|
||||
|
Reference in New Issue
Block a user