import glibc-2.28-166.el8

This commit is contained in:
CentOS Sources 2021-10-15 16:30:28 +00:00 committed by Stepan Oksanichenko
parent 6823d1e6f5
commit 40615243ef
16 changed files with 5678 additions and 26 deletions

View File

@ -0,0 +1,102 @@
commit 0c78b0bb78d87a7de18726a033d88904f158f0fe
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date: Mon Jun 7 14:22:17 2021 +0530
iconvconfig: Make file handling more general purpose
Split out configuration file handling code from handle_dir into its
own function so that it can be reused for multiple configuration
files.
Reviewed-by: DJ Delorie <dj@redhat.com>
diff --git a/iconv/iconvconfig.c b/iconv/iconvconfig.c
index b6fef1553cbbdd3d..2b3c587bc77cfdcd 100644
--- a/iconv/iconvconfig.c
+++ b/iconv/iconvconfig.c
@@ -644,37 +644,17 @@ add_module (char *rp, const char *directory)
cost, need_ext);
}
-
-/* Read the config file and add the data for this directory to that. */
-static int
-handle_dir (const char *dir)
+/* Read a gconv-modules configuration file. */
+static bool
+handle_file (const char *dir, const char *infile)
{
- char *cp;
FILE *fp;
char *line = NULL;
size_t linelen = 0;
- size_t dirlen = strlen (dir);
-
- if (dir[dirlen - 1] != '/')
- {
- char *newp = (char *) xmalloc (dirlen + 2);
- dir = memcpy (newp, dir, dirlen);
- newp[dirlen++] = '/';
- newp[dirlen] = '\0';
- }
-
- char infile[prefix_len + dirlen + sizeof "gconv-modules"];
- cp = infile;
- if (dir[0] == '/')
- cp = mempcpy (cp, prefix, prefix_len);
- strcpy (mempcpy (cp, dir, dirlen), "gconv-modules");
fp = fopen (infile, "r");
if (fp == NULL)
- {
- error (0, errno, "cannot open `%s'", infile);
- return 1;
- }
+ return false;
/* No threads present. */
__fsetlocking (fp, FSETLOCKING_BYCALLER);
@@ -723,7 +703,42 @@ handle_dir (const char *dir)
fclose (fp);
- return 0;
+ return true;
+}
+
+/* Read config files and add the data for this directory to cache. */
+static int
+handle_dir (const char *dir)
+{
+ char *cp;
+ size_t dirlen = strlen (dir);
+ bool found = false;
+
+ if (dir[dirlen - 1] != '/')
+ {
+ char *newp = (char *) xmalloc (dirlen + 2);
+ dir = memcpy (newp, dir, dirlen);
+ newp[dirlen++] = '/';
+ newp[dirlen] = '\0';
+ }
+
+ char infile[prefix_len + dirlen + sizeof "gconv-modules"];
+ cp = infile;
+ if (dir[0] == '/')
+ cp = mempcpy (cp, prefix, prefix_len);
+ strcpy (mempcpy (cp, dir, dirlen), "gconv-modules");
+
+ found |= handle_file (dir, infile);
+
+ if (!found)
+ {
+ error (0, errno, "failed to open gconv configuration file in `%s'",
+ dir);
+ error (0, 0,
+ "ensure that the directory contains a valid gconv-modules file.");
+ }
+
+ return found ? 0 : 1;
}

View File

@ -0,0 +1,188 @@
commit eeac390eecf7de24a110dc84e77e1190f42c5305
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date: Thu Jun 10 14:31:57 2021 +0530
iconvconfig: Use common gconv module parsing function
Drop local copy of gconv file parsing and use the one in
gconv_parseconfdir.h instead. Now there is a single implementation of
configuration file parsing.
Reviewed-by: DJ Delorie <dj@redhat.com>
diff --git a/iconv/iconvconfig.c b/iconv/iconvconfig.c
index 2f9d5f45ad3a8159..01ecf6f67d55dbbf 100644
--- a/iconv/iconvconfig.c
+++ b/iconv/iconvconfig.c
@@ -18,7 +18,6 @@
#include <argp.h>
#include <assert.h>
-#include <dirent.h>
#include <error.h>
#include <errno.h>
#include <fcntl.h>
@@ -34,10 +33,10 @@
#include <string.h>
#include <unistd.h>
#include <sys/cdefs.h>
-#include <sys/types.h>
#include <sys/uio.h>
#include "iconvconfig.h"
+#include <gconv_parseconfdir.h>
/* Get libc version number. */
#include "../version.h"
@@ -568,7 +567,9 @@ new_module (const char *fromname, size_t fromlen, const char *toname,
/* Add new module. */
static void
-add_module (char *rp, const char *directory)
+add_module (char *rp, const char *directory,
+ size_t dirlen __attribute__ ((__unused__)),
+ int modcount __attribute__ ((__unused__)))
{
/* We expect now
1. `from' name
@@ -646,131 +647,28 @@ add_module (char *rp, const char *directory)
cost, need_ext);
}
-/* Read a gconv-modules configuration file. */
-static bool
-handle_file (const char *dir, const char *infile)
-{
- FILE *fp;
- char *line = NULL;
- size_t linelen = 0;
-
- fp = fopen (infile, "r");
- if (fp == NULL)
- return false;
-
- /* No threads present. */
- __fsetlocking (fp, FSETLOCKING_BYCALLER);
-
- while (!feof_unlocked (fp))
- {
- char *rp, *endp, *word;
- ssize_t n = __getdelim (&line, &linelen, '\n', fp);
-
- if (n < 0)
- /* An error occurred. */
- break;
-
- rp = line;
- /* Terminate the line (excluding comments or newline) with a NUL
- byte to simplify the following code. */
- endp = strchr (rp, '#');
- if (endp != NULL)
- *endp = '\0';
- else
- if (rp[n - 1] == '\n')
- rp[n - 1] = '\0';
-
- while (isspace (*rp))
- ++rp;
-
- /* If this is an empty line go on with the next one. */
- if (rp == endp)
- continue;
-
- word = rp;
- while (*rp != '\0' && !isspace (*rp))
- ++rp;
-
- if (rp - word == sizeof ("alias") - 1
- && memcmp (word, "alias", sizeof ("alias") - 1) == 0)
- add_alias (rp);
- else if (rp - word == sizeof ("module") - 1
- && memcmp (word, "module", sizeof ("module") - 1) == 0)
- add_module (rp, dir);
- /* else */
- /* Otherwise ignore the line. */
- }
-
- free (line);
-
- fclose (fp);
-
- return true;
-}
-
/* Read config files and add the data for this directory to cache. */
static int
handle_dir (const char *dir)
{
- char *cp;
size_t dirlen = strlen (dir);
bool found = false;
+ /* Add the prefix before sending it off to the parser. */
+ char *fulldir = xmalloc (prefix_len + dirlen + 2);
+ char *cp = mempcpy (mempcpy (fulldir, prefix, prefix_len), dir, dirlen);
+
if (dir[dirlen - 1] != '/')
{
- char *newp = (char *) xmalloc (dirlen + 2);
- dir = memcpy (newp, dir, dirlen);
- newp[dirlen++] = '/';
- newp[dirlen] = '\0';
+ *cp++ = '/';
+ *cp = '\0';
+ dirlen++;
}
- /* First, look for a gconv-modules file. */
- char *buf = malloc (prefix_len + dirlen + sizeof "gconv-modules.d");
- if (buf == NULL)
- goto out;
-
- cp = buf;
- if (dir[0] == '/')
- cp = mempcpy (cp, prefix, prefix_len);
- cp = mempcpy (cp, dir, dirlen);
- cp = stpcpy (cp, "gconv-modules");
-
- found |= handle_file (dir, buf);
-
- /* Next, see if there is a gconv-modules.d directory containing configuration
- files and if it is non-empty. */
- cp[0] = '.';
- cp[1] = 'd';
- cp[2] = '\0';
-
- DIR *confdir = opendir (buf);
- if (confdir != NULL)
- {
- struct dirent *ent;
- while ((ent = readdir (confdir)) != NULL)
- {
- if (ent->d_type != DT_REG)
- continue;
-
- size_t len = strlen (ent->d_name);
- const char *suffix = ".conf";
-
- if (len > strlen (suffix)
- && strcmp (ent->d_name + len - strlen (suffix), suffix) == 0)
- {
- char *conf;
- if (asprintf (&conf, "%s/%s", buf, ent->d_name) < 0)
- continue;
- found |= handle_file (dir, conf);
- free (conf);
- }
- }
- closedir (confdir);
- }
+ found = gconv_parseconfdir (fulldir, dirlen + prefix_len);
- free (buf);
+ free (fulldir);
-out:
if (!found)
{
error (0, errno, "failed to open gconv configuration files in `%s'",

View File

@ -0,0 +1,53 @@
Changes specific to RHEL-8:
- lstat64 is a macro, so undefine it first
commit f3629a4be82a393ff56646c388da2fda0101f557
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date: Thu Jun 10 14:56:37 2021 +0530
Handle DT_UNKNOWN in gconv-modules.d
On filesystems that do not support dt_type, a regular file shows up as
DT_UNKNOWN. Fall back to using lstat64 to read file properties in
such cases.
Reviewed-by: DJ Delorie <dj@redhat.com>
diff --git a/iconv/gconv_parseconfdir.h b/iconv/gconv_parseconfdir.h
index 3d4d58d4be10a250..ba9b3fd36d9e30f9 100644
--- a/iconv/gconv_parseconfdir.h
+++ b/iconv/gconv_parseconfdir.h
@@ -32,6 +32,8 @@
# define readdir __readdir
# define closedir __closedir
# define mempcpy __mempcpy
+# undef lstat64
+# define lstat64 __lstat64
#endif
/* Name of the file containing the module information in the directories
@@ -138,7 +140,7 @@ gconv_parseconfdir (const char *dir, size_t dir_len)
struct dirent *ent;
while ((ent = readdir (confdir)) != NULL)
{
- if (ent->d_type != DT_REG)
+ if (ent->d_type != DT_REG && ent->d_type != DT_UNKNOWN)
continue;
size_t len = strlen (ent->d_name);
@@ -148,8 +150,14 @@ gconv_parseconfdir (const char *dir, size_t dir_len)
&& strcmp (ent->d_name + len - strlen (suffix), suffix) == 0)
{
char *conf;
+ struct stat64 st;
if (asprintf (&conf, "%s/%s", buf, ent->d_name) < 0)
continue;
+ if (ent->d_type == DT_UNKNOWN
+ && (lstat64 (conf, &st) == -1
+ || !S_ISREG (st.st_mode)))
+ continue;
+
found |= read_conf_file (conf, dir, dir_len);
free (conf);
}

View File

@ -0,0 +1,98 @@
commit 9429049c178b3af3d6afeb3717ff1f2214dc9572
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date: Mon Jun 28 09:15:55 2021 +0530
iconvconfig: Fix multiple issues
It was noticed on big-endian systems that msgfmt would fail with the
following error:
msgfmt: gconv_builtin.c:70: __gconv_get_builtin_trans: Assertion `cnt < sizeof (map) / sizeof (map[0])' failed.
Aborted (core dumped)
This is only seen on installed systems because it was due to a
corrupted gconv-modules.cache. iconvconfig had the following issues
(it was specifically freeing fulldir that caused this issue, but other
cleanups are also needed) that this patch fixes.
- Add prefix only if dir starts with '/'
- Use asprintf instead of mempcpy so that the directory string is NULL
terminated
- Make a copy of the directory reference in new_module so that fulldir
can be freed within the same scope in handle_dir.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
diff --git a/iconv/Makefile b/iconv/Makefile
index d09b8ac842731780..6df9862e748ae588 100644
--- a/iconv/Makefile
+++ b/iconv/Makefile
@@ -33,7 +33,7 @@ vpath %.c ../locale/programs ../intl
iconv_prog-modules = iconv_charmap charmap charmap-dir linereader \
dummy-repertoire simple-hash xstrdup xmalloc \
record-status
-iconvconfig-modules = strtab xmalloc hash-string
+iconvconfig-modules = strtab xmalloc xasprintf xstrdup hash-string
extra-objs = $(iconv_prog-modules:=.o) $(iconvconfig-modules:=.o)
CFLAGS-iconv_prog.c += -I../locale/programs
CFLAGS-iconv_charmap.c += -I../locale/programs
diff --git a/iconv/iconvconfig.c b/iconv/iconvconfig.c
index 01ecf6f67d55dbbf..777da870d2f8e99a 100644
--- a/iconv/iconvconfig.c
+++ b/iconv/iconvconfig.c
@@ -250,6 +250,7 @@ static const char gconv_module_ext[] = MODULE_EXT;
#include <programs/xmalloc.h>
+#include <programs/xasprintf.h>
/* C string table handling. */
@@ -519,11 +520,12 @@ module_compare (const void *p1, const void *p2)
/* Create new module record. */
static void
new_module (const char *fromname, size_t fromlen, const char *toname,
- size_t tolen, const char *directory,
+ size_t tolen, const char *dir_in,
const char *filename, size_t filelen, int cost, size_t need_ext)
{
struct module *new_module;
- size_t dirlen = strlen (directory) + 1;
+ size_t dirlen = strlen (dir_in) + 1;
+ const char *directory = xstrdup (dir_in);
char *tmp;
void **inserted;
@@ -654,20 +656,10 @@ handle_dir (const char *dir)
size_t dirlen = strlen (dir);
bool found = false;
- /* Add the prefix before sending it off to the parser. */
- char *fulldir = xmalloc (prefix_len + dirlen + 2);
- char *cp = mempcpy (mempcpy (fulldir, prefix, prefix_len), dir, dirlen);
+ char *fulldir = xasprintf ("%s%s%s", dir[0] == '/' ? prefix : "",
+ dir, dir[dirlen - 1] != '/' ? "/" : "");
- if (dir[dirlen - 1] != '/')
- {
- *cp++ = '/';
- *cp = '\0';
- dirlen++;
- }
-
- found = gconv_parseconfdir (fulldir, dirlen + prefix_len);
-
- free (fulldir);
+ found = gconv_parseconfdir (fulldir, strlen (fulldir));
if (!found)
{
@@ -679,6 +671,8 @@ handle_dir (const char *dir)
"configuration files with names ending in .conf.");
}
+ free (fulldir);
+
return found ? 0 : 1;
}

View File

@ -0,0 +1,34 @@
commit 7f784fabcb186ffaa082ed0aeed52a56b7d96cee
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date: Fri Jul 2 16:53:25 2021 +0530
iconvconfig: Use the public feof_unlocked
Build of iconvconfig failed with CFLAGS=-Os since __feof_unlocked is
not a public symbol. Replace with feof_unlocked (defined to
__feof_unlocked when IS_IN (libc)) to fix this.
Reported-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
diff --git a/iconv/gconv_parseconfdir.h b/iconv/gconv_parseconfdir.h
index ba9b3fd36d9e30f9..234b85a586f1d79a 100644
--- a/iconv/gconv_parseconfdir.h
+++ b/iconv/gconv_parseconfdir.h
@@ -34,6 +34,7 @@
# define mempcpy __mempcpy
# undef lstat64
# define lstat64 __lstat64
+# define feof_unlocked __feof_unlocked
#endif
/* Name of the file containing the module information in the directories
@@ -65,7 +66,7 @@ read_conf_file (const char *filename, const char *directory, size_t dir_len)
/* Process the known entries of the file. Comments start with `#' and
end with the end of the line. Empty lines are ignored. */
- while (!__feof_unlocked (fp))
+ while (!feof_unlocked (fp))
{
char *rp, *endp, *word;
ssize_t n = __getdelim (&line, &line_len, '\n', fp);

View File

@ -0,0 +1,32 @@
commit 5f9b78fe35d08739b6da1e5b356786d41116c108
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date: Tue Aug 3 21:10:20 2021 +0530
gconv_parseconfdir: Fix memory leak
The allocated `conf` would leak if we have to skip over the file due
to the underlying filesystem not supporting dt_type.
Reviewed-by: Arjun Shankar <arjun@redhat.com>
diff --git a/iconv/gconv_parseconfdir.h b/iconv/gconv_parseconfdir.h
index 915b60845ca11c03..e4c3c16d1f96ce0c 100644
--- a/iconv/gconv_parseconfdir.h
+++ b/iconv/gconv_parseconfdir.h
@@ -153,12 +153,11 @@ gconv_parseconfdir (const char *dir, size_t dir_len)
struct stat64 st;
if (asprintf (&conf, "%s/%s", buf, ent->d_name) < 0)
continue;
- if (ent->d_type == DT_UNKNOWN
- && (lstat64 (conf, &st) == -1
- || !S_ISREG (st.st_mode)))
- continue;
- found |= read_conf_file (conf, dir, dir_len);
+ if (ent->d_type != DT_UNKNOWN
+ || (lstat64 (conf, &st) != -1 && S_ISREG (st.st_mode)))
+ found |= read_conf_file (conf, dir, dir_len);
+
free (conf);
}
}

View File

@ -0,0 +1,116 @@
commit 43cea6d5652b6b9e61ac6ecc69419c909b504f47
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date: Mon Sep 13 20:48:35 2021 +0530
iconvconfig: Fix behaviour with --prefix [BZ #28199]
The consolidation of configuration parsing broke behaviour with
--prefix, where the prefix bled into the modules cache. Accept a
prefix which, when non-NULL, is prepended to the path when looking for
configuration files but only the original directory is added to the
modules cache.
This has no effect on the codegen of gconv_conf since it passes NULL.
Reported-by: Patrick McCarty <patrick.mccarty@intel.com>
Reported-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
Reviewed-by: Andreas Schwab <schwab@linux-m68k.org>
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index ce64faa928dc1c52..3f5a692f1510157c 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -476,7 +476,7 @@ __gconv_read_conf (void)
__gconv_get_path ();
for (cnt = 0; __gconv_path_elem[cnt].name != NULL; ++cnt)
- gconv_parseconfdir (__gconv_path_elem[cnt].name,
+ gconv_parseconfdir (NULL, __gconv_path_elem[cnt].name,
__gconv_path_elem[cnt].len);
#endif
diff --git a/iconv/gconv_parseconfdir.h b/iconv/gconv_parseconfdir.h
index e4c3c16d1f96ce0c..433aa18bab5083b0 100644
--- a/iconv/gconv_parseconfdir.h
+++ b/iconv/gconv_parseconfdir.h
@@ -39,7 +39,6 @@
/* Name of the file containing the module information in the directories
along the path. */
static const char gconv_conf_filename[] = "gconv-modules";
-static const char gconv_conf_dirname[] = "gconv-modules.d";
static void add_alias (char *);
static void add_module (char *, const char *, size_t, int);
@@ -110,19 +109,28 @@ read_conf_file (const char *filename, const char *directory, size_t dir_len)
return true;
}
+/* Prefix DIR (with length DIR_LEN) with PREFIX if the latter is non-NULL and
+ parse configuration in it. */
+
static __always_inline bool
-gconv_parseconfdir (const char *dir, size_t dir_len)
+gconv_parseconfdir (const char *prefix, const char *dir, size_t dir_len)
{
- /* No slash needs to be inserted between dir and gconv_conf_filename;
- dir already ends in a slash. */
- char *buf = malloc (dir_len + sizeof (gconv_conf_dirname));
+ /* No slash needs to be inserted between dir and gconv_conf_filename; dir
+ already ends in a slash. The additional 2 is to accommodate the ".d"
+ when looking for configuration files in gconv-modules.d. */
+ size_t buflen = dir_len + sizeof (gconv_conf_filename) + 2;
+ char *buf = malloc (buflen + (prefix != NULL ? strlen (prefix) : 0));
+ char *cp = buf;
bool found = false;
if (buf == NULL)
return false;
- char *cp = mempcpy (mempcpy (buf, dir, dir_len), gconv_conf_filename,
- sizeof (gconv_conf_filename));
+ if (prefix != NULL)
+ cp = stpcpy (cp, prefix);
+
+ cp = mempcpy (mempcpy (cp, dir, dir_len), gconv_conf_filename,
+ sizeof (gconv_conf_filename));
/* Read the gconv-modules configuration file first. */
found = read_conf_file (buf, dir, dir_len);
diff --git a/iconv/iconvconfig.c b/iconv/iconvconfig.c
index 777da870d2f8e99a..b1fd4100b5cbc9d2 100644
--- a/iconv/iconvconfig.c
+++ b/iconv/iconvconfig.c
@@ -653,13 +653,21 @@ add_module (char *rp, const char *directory,
static int
handle_dir (const char *dir)
{
+ char *newp = NULL;
size_t dirlen = strlen (dir);
bool found = false;
- char *fulldir = xasprintf ("%s%s%s", dir[0] == '/' ? prefix : "",
- dir, dir[dirlen - 1] != '/' ? "/" : "");
+ /* End directory path with a '/' if it doesn't already. */
+ if (dir[dirlen - 1] != '/')
+ {
+ newp = xmalloc (dirlen + 2);
+ memcpy (newp, dir, dirlen);
+ newp[dirlen++] = '/';
+ newp[dirlen] = '\0';
+ dir = newp;
+ }
- found = gconv_parseconfdir (fulldir, strlen (fulldir));
+ found = gconv_parseconfdir (dir[0] == '/' ? prefix : NULL, dir, dirlen);
if (!found)
{
@@ -671,7 +679,7 @@ handle_dir (const char *dir)
"configuration files with names ending in .conf.");
}
- free (fulldir);
+ free (newp);
return found ? 0 : 1;
}

View File

@ -0,0 +1,109 @@
commit 3979c3e1bae20459d9b6d424bdb49927d9cd6fec
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date: Mon Jun 7 14:22:18 2021 +0530
iconvconfig: Read configuration from gconv-modules.d subdirectory
In addition to GCONV_PATH/gconv-modules, also read module
configuration from *.conf files in GCONV_PATH/gconv-modules.d. This
allows a single gconv directory to have multiple sets of gconv modules
but at the same time, a single modules cache.
With this feature, one could separate the glibc supported gconv
modules into a minimal essential set (ISO-8859-*, UTF, etc.) from the
remaining modules. In future, these could be further segregated into
langpack-associated sets with their own
gconv-modules.d/someconfig.conf.
Reviewed-by: DJ Delorie <dj@redhat.com>
diff --git a/iconv/iconvconfig.c b/iconv/iconvconfig.c
index 2b3c587bc77cfdcd..fafc686ae25fb5c1 100644
--- a/iconv/iconvconfig.c
+++ b/iconv/iconvconfig.c
@@ -18,6 +18,7 @@
#include <argp.h>
#include <assert.h>
+#include <dirent.h>
#include <error.h>
#include <errno.h>
#include <fcntl.h>
@@ -33,6 +34,7 @@
#include <string.h>
#include <unistd.h>
#include <sys/cdefs.h>
+#include <sys/types.h>
#include <sys/uio.h>
#include "iconvconfig.h"
@@ -710,6 +712,7 @@ handle_file (const char *dir, const char *infile)
static int
handle_dir (const char *dir)
{
+#define BUF_LEN prefix_len + dirlen + sizeof "gconv-modules.d"
char *cp;
size_t dirlen = strlen (dir);
bool found = false;
@@ -722,20 +725,55 @@ handle_dir (const char *dir)
newp[dirlen] = '\0';
}
- char infile[prefix_len + dirlen + sizeof "gconv-modules"];
- cp = infile;
+ /* First, look for a gconv-modules file. */
+ char buf[BUF_LEN];
+ cp = buf;
if (dir[0] == '/')
cp = mempcpy (cp, prefix, prefix_len);
- strcpy (mempcpy (cp, dir, dirlen), "gconv-modules");
+ cp = mempcpy (cp, dir, dirlen);
+ cp = stpcpy (cp, "gconv-modules");
- found |= handle_file (dir, infile);
+ found |= handle_file (dir, buf);
+
+ /* Next, see if there is a gconv-modules.d directory containing configuration
+ files and if it is non-empty. */
+ cp[0] = '.';
+ cp[1] = 'd';
+ cp[2] = '\0';
+
+ DIR *confdir = opendir (buf);
+ if (confdir != NULL)
+ {
+ struct dirent *ent;
+ while ((ent = readdir (confdir)) != NULL)
+ {
+ if (ent->d_type != DT_REG)
+ continue;
+
+ size_t len = strlen (ent->d_name);
+ const char *suffix = ".conf";
+
+ if (len > strlen (suffix)
+ && strcmp (ent->d_name + len - strlen (suffix), suffix) == 0)
+ {
+ /* LEN <= PATH_MAX so this alloca is not unbounded. */
+ char *conf = alloca (BUF_LEN + len + 1);
+ cp = stpcpy (conf, buf);
+ sprintf (cp, "/%s", ent->d_name);
+ found |= handle_file (dir, conf);
+ }
+ }
+ closedir (confdir);
+ }
if (!found)
{
- error (0, errno, "failed to open gconv configuration file in `%s'",
+ error (0, errno, "failed to open gconv configuration files in `%s'",
dir);
error (0, 0,
- "ensure that the directory contains a valid gconv-modules file.");
+ "ensure that the directory contains either a valid "
+ "gconv-modules file or a gconv-modules.d directory with "
+ "configuration files with names ending in .conf.");
}
return found ? 0 : 1;

View File

@ -0,0 +1,99 @@
commit b17d29b390154df9dfad9d21f1e6605422521fd2
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date: Mon Jun 7 14:22:19 2021 +0530
gconv_conf: Read configuration files in gconv-modules.d
Read configuration files with names ending in .conf in
GCONV_PATH/gconv-modules.d to mirror configuration flexibility in
iconvconfig into the iconv program and function.
Reviewed-by: DJ Delorie <dj@redhat.com>
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index f173cde71b2a61d7..8eb981fca7cee36a 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -19,6 +19,7 @@
#include <assert.h>
#include <ctype.h>
+#include <dirent.h>
#include <errno.h>
#include <limits.h>
#include <locale.h>
@@ -30,6 +31,7 @@
#include <string.h>
#include <unistd.h>
#include <sys/param.h>
+#include <sys/types.h>
#include <libc-lock.h>
#include <gconv_int.h>
@@ -50,6 +52,7 @@ static const struct path_elem empty_path_elem = { NULL, 0 };
/* Name of the file containing the module information in the directories
along the path. */
static const char gconv_conf_filename[] = "gconv-modules";
+static const char gconv_conf_dirname[] = "gconv-modules.d";
/* Filename extension for the modules. */
#ifndef MODULE_EXT
@@ -554,18 +557,52 @@ __gconv_read_conf (void)
for (cnt = 0; __gconv_path_elem[cnt].name != NULL; ++cnt)
{
+#define BUF_LEN elem_len + sizeof (gconv_conf_dirname)
+
const char *elem = __gconv_path_elem[cnt].name;
size_t elem_len = __gconv_path_elem[cnt].len;
- char *filename;
+ char *buf;
/* No slash needs to be inserted between elem and gconv_conf_filename;
elem already ends in a slash. */
- filename = alloca (elem_len + sizeof (gconv_conf_filename));
- __mempcpy (__mempcpy (filename, elem, elem_len),
- gconv_conf_filename, sizeof (gconv_conf_filename));
+ buf = alloca (BUF_LEN);
+ char *cp = __mempcpy (__mempcpy (buf, elem, elem_len),
+ gconv_conf_filename, sizeof (gconv_conf_filename));
+
+ /* Read the gconv-modules configuration file first. */
+ read_conf_file (buf, elem, elem_len, &modules, &nmodules);
+
+ /* Next, see if there is a gconv-modules.d directory containing
+ configuration files and if it is non-empty. */
+ cp--;
+ cp[0] = '.';
+ cp[1] = 'd';
+ cp[2] = '\0';
+
+ DIR *confdir = __opendir (buf);
+ if (confdir != NULL)
+ {
+ struct dirent *ent;
+ while ((ent = __readdir (confdir)) != NULL)
+ {
+ if (ent->d_type != DT_REG)
+ continue;
+
+ size_t len = strlen (ent->d_name);
+ const char *suffix = ".conf";
- /* Read the next configuration file. */
- read_conf_file (filename, elem, elem_len, &modules, &nmodules);
+ if (len > strlen (suffix)
+ && strcmp (ent->d_name + len - strlen (suffix), suffix) == 0)
+ {
+ /* LEN <= PATH_MAX so this alloca is not unbounded. */
+ char *conf = alloca (BUF_LEN + len + 1);
+ cp = stpcpy (conf, buf);
+ sprintf (cp, "/%s", ent->d_name);
+ read_conf_file (conf, elem, elem_len, &modules, &nmodules);
+ }
+ }
+ __closedir (confdir);
+ }
}
#endif

View File

@ -0,0 +1,179 @@
commit fc5bfade69ca12d034967dc6b929dbe3dd715172
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date: Mon Jun 7 14:22:20 2021 +0530
iconvdata: Move gconv-modules configuration to gconv-modules.conf
Move all gconv-modules configuration files to gconv-modules.conf.
That is, the S390 extensions now become gconv-modules-s390.conf. Move
both configuration files into gconv-modules.d.
Now GCONV_PATH/gconv-modules is read only for backward compatibility
for third-party gconv modules directories.
Reviewed-by: DJ Delorie <dj@redhat.com>
# Conflicts:
# iconvdata/Makefile
diff --git a/iconvdata/Makefile b/iconvdata/Makefile
index 32656ad31d9b434b..fc403e8abe3cc11f 100644
--- a/iconvdata/Makefile
+++ b/iconvdata/Makefile
@@ -136,10 +136,13 @@ charmaps = ../localedata/charmaps
extra-modules-left := $(modules)
include extra-module.mk
+gconv-modules = gconv-modules.conf
+modpfx = $(objpfx)gconv-modules.d/
extra-objs += $(modules.so)
install-others = $(addprefix $(inst_gconvdir)/, $(modules.so)) \
- $(inst_gconvdir)/gconv-modules
+ $(addprefix $(inst_gconvdir)/gconv-modules.d/, \
+ $(gconv-modules))
# We can build the conversion tables for numerous charsets automatically.
@@ -181,7 +184,7 @@ generated += $(generated-modules:=.h) $(generated-modules:=.stmp) \
iconv-test.out iconv-rules tst-loading.mtrace \
mtrace-tst-loading.out tst-tables.out iconv-test.xxx
ifdef objpfx
-generated += gconv-modules
+generated += $(addprefix gconv-modules.d/,$(gconv-modules))
endif
# Rules to generate the headers.
@@ -249,7 +252,8 @@ headers: $(addprefix $(objpfx), $(generated-modules:=.h))
$(addprefix $(inst_gconvdir)/, $(modules.so)): \
$(inst_gconvdir)/%: $(objpfx)% $(+force)
$(do-install-program)
-$(inst_gconvdir)/gconv-modules: $(objpfx)gconv-modules $(+force)
+$(addprefix $(inst_gconvdir)/gconv-modules.d/, $(gconv-modules)): \
+ $(inst_gconvdir)/gconv-modules.d/%: $(modpfx)% $(+force)
$(do-install)
ifeq (no,$(cross-compiling))
# Update the $(prefix)/lib/gconv/gconv-modules.cache file. This is necessary
@@ -297,29 +301,30 @@ $(objpfx)mtrace-tst-loading.out: $(objpfx)tst-loading.out
$(common-objpfx)malloc/mtrace $(objpfx)tst-loading.mtrace > $@; \
$(evaluate-test)
-$(objpfx)bug-iconv1.out: $(objpfx)gconv-modules \
+$(objpfx)bug-iconv1.out: $(addprefix $(modpfx), $(gconv-modules)) \
$(addprefix $(objpfx),$(modules.so))
-$(objpfx)bug-iconv2.out: $(objpfx)gconv-modules \
+$(objpfx)bug-iconv2.out: $(addprefix $(modpfx), $(gconv-modules)) \
$(addprefix $(objpfx),$(modules.so))
$(objpfx)bug-iconv3: $(libdl)
-$(objpfx)bug-iconv3.out: $(objpfx)gconv-modules \
+$(objpfx)bug-iconv3.out: $(addprefix $(modpfx), $(gconv-modules)) \
$(addprefix $(objpfx),$(modules.so))
-$(objpfx)bug-iconv5.out: $(objpfx)gconv-modules \
+$(objpfx)bug-iconv5.out: $(addprefix $(modpfx), $(gconv-modules)) \
$(addprefix $(objpfx),$(modules.so))
-$(objpfx)tst-loading.out: $(objpfx)gconv-modules \
+$(objpfx)tst-loading.out: $(addprefix $(modpfx), $(gconv-modules)) \
$(addprefix $(objpfx),$(modules.so))
-$(objpfx)tst-iconv4.out: $(objpfx)gconv-modules \
+$(objpfx)tst-iconv4.out: $(addprefix $(modpfx), $(gconv-modules)) \
$(addprefix $(objpfx),$(modules.so))
-$(objpfx)tst-iconv7.out: $(objpfx)gconv-modules \
+$(objpfx)tst-iconv7.out: $(addprefix $(modpfx), $(gconv-modules)) \
$(addprefix $(objpfx),$(modules.so))
-$(objpfx)bug-iconv10.out: $(objpfx)gconv-modules \
+$(objpfx)bug-iconv10.out: $(addprefix $(modpfx), $(gconv-modules)) \
$(addprefix $(objpfx),$(modules.so))
-$(objpfx)bug-iconv12.out: $(objpfx)gconv-modules \
+$(objpfx)bug-iconv12.out: $(addprefix $(modpfx), $(gconv-modules)) \
$(addprefix $(objpfx),$(modules.so))
-$(objpfx)bug-iconv14.out: $(objpfx)gconv-modules \
+$(objpfx)bug-iconv14.out: $(addprefix $(modpfx), $(gconv-modules)) \
$(addprefix $(objpfx),$(modules.so))
-$(objpfx)iconv-test.out: run-iconv-test.sh $(objpfx)gconv-modules \
+$(objpfx)iconv-test.out: run-iconv-test.sh \
+ $(addprefix $(modpfx), $(gconv-modules)) \
$(addprefix $(objpfx),$(modules.so)) \
$(common-objdir)/iconv/iconv_prog TESTS
iconv_modules="$(modules)" \
@@ -327,7 +332,8 @@ $(objpfx)iconv-test.out: run-iconv-test.sh $(objpfx)gconv-modules \
'$(run-program-env)' > $@; \
$(evaluate-test)
-$(objpfx)tst-tables.out: tst-tables.sh $(objpfx)gconv-modules \
+$(objpfx)tst-tables.out: tst-tables.sh \
+ $(addprefix $(modpfx), $(gconv-modules)) \
$(addprefix $(objpfx),$(modules.so)) \
$(objpfx)tst-table-from $(objpfx)tst-table-to
$(SHELL) $< $(common-objpfx) $(common-objpfx)iconvdata/ \
@@ -340,5 +346,8 @@ do-tests-clean common-mostlyclean: tst-tables-clean
tst-tables-clean:
-rm -f $(objpfx)tst-*.table $(objpfx)tst-EUC-TW.irreversible
-$(objpfx)gconv-modules: gconv-modules
- cat $(sysdeps-gconv-modules) $^ > $@
+$(modpfx):
+ mkdir -p $@
+
+$(modpfx)%: % $(modpfx)
+ cp $< $@
diff --git a/iconvdata/gconv-modules b/iconvdata/gconv-modules.conf
similarity index 100%
rename from iconvdata/gconv-modules
rename to iconvdata/gconv-modules.conf
diff --git a/localedata/Makefile b/localedata/Makefile
index 14fcc37fed21e740..a5ca7a31f43d50c3 100644
--- a/localedata/Makefile
+++ b/localedata/Makefile
@@ -179,7 +179,7 @@ install-others := $(addprefix $(inst_i18ndir)/, \
$(locales))
endif
-tests: $(objdir)/iconvdata/gconv-modules
+tests: $(objdir)/iconvdata/gconv-modules.d/gconv-modules.conf
tests-static += tst-langinfo-newlocale-static tst-langinfo-setlocale-static
@@ -442,5 +442,5 @@ $(objpfx)mtrace-tst-leaks.out: $(objpfx)tst-leaks.out
bug-setlocale1-ENV-only = LOCPATH=$(objpfx) LC_CTYPE=de_DE.UTF-8
bug-setlocale1-static-ENV-only = $(bug-setlocale1-ENV-only)
-$(objdir)/iconvdata/gconv-modules:
+$(objdir)/iconvdata/gconv-modules.d/gconv-modules.conf:
$(MAKE) -C ../iconvdata subdir=iconvdata $@
diff --git a/sysdeps/s390/Makefile b/sysdeps/s390/Makefile
index 8bc82e523f9049db..5c8e1170b4d799ba 100644
--- a/sysdeps/s390/Makefile
+++ b/sysdeps/s390/Makefile
@@ -21,13 +21,25 @@ lib := iconvdata
include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))
extra-objs += $(addsuffix .so, $(s390x-iconv-modules))
-install-others += $(patsubst %, $(inst_gconvdir)/%.so, $(s390x-iconv-modules))
+install-others += $(patsubst %, $(inst_gconvdir)/%.so, \
+ $(s390x-iconv-modules)) \
+ $(inst_gconvdir)/gconv-modules.d/gconv-modules-s390.conf
$(patsubst %, $(inst_gconvdir)/%.so, $(s390x-iconv-modules)) : \
$(inst_gconvdir)/%.so: $(objpfx)%.so $(+force)
$(do-install-program)
-sysdeps-gconv-modules = ../sysdeps/s390/gconv-modules
+ifdef objpfx
+generated += gconv-modules.d/gconv-modules-s390.conf
+endif
+
+$(inst_gconvdir)/gconv-modules.d/gconv-modules-s390.conf: \
+ $(modpfx)gconv-modules-s390.conf $(+force)
+ $(do-install)
+
+$(modpfx)gconv-modules-s390.conf: ../sysdeps/s390/gconv-modules-s390.conf \
+ $(modpfx)
+ cp $< $@
endif
ifeq ($(subdir),string)
diff --git a/sysdeps/s390/gconv-modules b/sysdeps/s390/gconv-modules-s390.conf
similarity index 100%
rename from sysdeps/s390/gconv-modules
rename to sysdeps/s390/gconv-modules-s390.conf

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,137 @@
commit 06a1b794073c4d6adbfb2e4b11339985a14d7a00
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date: Mon Jun 14 11:09:56 2021 +0530
Reinstate gconv-modules as the default configuration file
Reinstate gconv-modules as the main file so that the configuration
files in gconv-modules.d/ become add-on configuration. With this, the
effective user visible change is that GCONV_PATH can now have
supplementary configuration in GCONV_PATH/gconv-modules.d/ in addition
to the main GCONV_PATH/gconv-modules file.
# Conflicts:
# iconvdata/Makefile
diff --git a/iconvdata/Makefile b/iconvdata/Makefile
index d682a98b5c4a8003..95e5fb8f722a513b 100644
--- a/iconvdata/Makefile
+++ b/iconvdata/Makefile
@@ -136,13 +136,12 @@ charmaps = ../localedata/charmaps
extra-modules-left := $(modules)
include extra-module.mk
-gconv-modules = gconv-modules.conf gconv-modules-extra.conf
+gconv-modules = gconv-modules gconv-modules.d/gconv-modules-extra.conf
modpfx = $(objpfx)gconv-modules.d/
extra-objs += $(modules.so)
install-others = $(addprefix $(inst_gconvdir)/, $(modules.so)) \
- $(addprefix $(inst_gconvdir)/gconv-modules.d/, \
- $(gconv-modules))
+ $(addprefix $(inst_gconvdir)/, $(gconv-modules))
# We can build the conversion tables for numerous charsets automatically.
@@ -184,7 +183,7 @@ generated += $(generated-modules:=.h) $(generated-modules:=.stmp) \
iconv-test.out iconv-rules tst-loading.mtrace \
mtrace-tst-loading.out tst-tables.out iconv-test.xxx
ifdef objpfx
-generated += $(addprefix gconv-modules.d/,$(gconv-modules))
+generated += $(gconv-modules)
endif
# Rules to generate the headers.
@@ -252,8 +251,8 @@ headers: $(addprefix $(objpfx), $(generated-modules:=.h))
$(addprefix $(inst_gconvdir)/, $(modules.so)): \
$(inst_gconvdir)/%: $(objpfx)% $(+force)
$(do-install-program)
-$(addprefix $(inst_gconvdir)/gconv-modules.d/, $(gconv-modules)): \
- $(inst_gconvdir)/gconv-modules.d/%: $(modpfx)% $(+force)
+$(addprefix $(inst_gconvdir)/, $(gconv-modules)): \
+ $(inst_gconvdir)/%: $(objpfx)% $(+force)
$(do-install)
ifeq (no,$(cross-compiling))
# Update the $(prefix)/lib/gconv/gconv-modules.cache file. This is necessary
@@ -301,30 +300,30 @@ $(objpfx)mtrace-tst-loading.out: $(objpfx)tst-loading.out
$(common-objpfx)malloc/mtrace $(objpfx)tst-loading.mtrace > $@; \
$(evaluate-test)
-$(objpfx)bug-iconv1.out: $(addprefix $(modpfx), $(gconv-modules)) \
+$(objpfx)bug-iconv1.out: $(addprefix $(objpfx), $(gconv-modules)) \
$(addprefix $(objpfx),$(modules.so))
-$(objpfx)bug-iconv2.out: $(addprefix $(modpfx), $(gconv-modules)) \
+$(objpfx)bug-iconv2.out: $(addprefix $(objpfx), $(gconv-modules)) \
$(addprefix $(objpfx),$(modules.so))
$(objpfx)bug-iconv3: $(libdl)
-$(objpfx)bug-iconv3.out: $(addprefix $(modpfx), $(gconv-modules)) \
+$(objpfx)bug-iconv3.out: $(addprefix $(objpfx), $(gconv-modules)) \
$(addprefix $(objpfx),$(modules.so))
-$(objpfx)bug-iconv5.out: $(addprefix $(modpfx), $(gconv-modules)) \
+$(objpfx)bug-iconv5.out: $(addprefix $(objpfx), $(gconv-modules)) \
$(addprefix $(objpfx),$(modules.so))
-$(objpfx)tst-loading.out: $(addprefix $(modpfx), $(gconv-modules)) \
+$(objpfx)tst-loading.out: $(addprefix $(objpfx), $(gconv-modules)) \
$(addprefix $(objpfx),$(modules.so))
-$(objpfx)tst-iconv4.out: $(addprefix $(modpfx), $(gconv-modules)) \
+$(objpfx)tst-iconv4.out: $(addprefix $(objpfx), $(gconv-modules)) \
$(addprefix $(objpfx),$(modules.so))
-$(objpfx)tst-iconv7.out: $(addprefix $(modpfx), $(gconv-modules)) \
+$(objpfx)tst-iconv7.out: $(addprefix $(objpfx), $(gconv-modules)) \
$(addprefix $(objpfx),$(modules.so))
-$(objpfx)bug-iconv10.out: $(addprefix $(modpfx), $(gconv-modules)) \
+$(objpfx)bug-iconv10.out: $(addprefix $(objpfx), $(gconv-modules)) \
$(addprefix $(objpfx),$(modules.so))
-$(objpfx)bug-iconv12.out: $(addprefix $(modpfx), $(gconv-modules)) \
+$(objpfx)bug-iconv12.out: $(addprefix $(objpfx), $(gconv-modules)) \
$(addprefix $(objpfx),$(modules.so))
-$(objpfx)bug-iconv14.out: $(addprefix $(modpfx), $(gconv-modules)) \
+$(objpfx)bug-iconv14.out: $(addprefix $(objpfx), $(gconv-modules)) \
$(addprefix $(objpfx),$(modules.so))
$(objpfx)iconv-test.out: run-iconv-test.sh \
- $(addprefix $(modpfx), $(gconv-modules)) \
+ $(addprefix $(objpfx), $(gconv-modules)) \
$(addprefix $(objpfx),$(modules.so)) \
$(common-objdir)/iconv/iconv_prog TESTS
iconv_modules="$(modules)" \
@@ -333,7 +332,7 @@ $(objpfx)iconv-test.out: run-iconv-test.sh \
$(evaluate-test)
$(objpfx)tst-tables.out: tst-tables.sh \
- $(addprefix $(modpfx), $(gconv-modules)) \
+ $(addprefix $(objpfx), $(gconv-modules)) \
$(addprefix $(objpfx),$(modules.so)) \
$(objpfx)tst-table-from $(objpfx)tst-table-to
$(SHELL) $< $(common-objpfx) $(common-objpfx)iconvdata/ \
@@ -351,3 +350,6 @@ $(modpfx):
$(modpfx)%: % $(modpfx)
cp $< $@
+
+$(objpfx)gconv-modules: gconv-modules
+ cp $^ $@
diff --git a/iconvdata/gconv-modules.conf b/iconvdata/gconv-modules
similarity index 100%
rename from iconvdata/gconv-modules.conf
rename to iconvdata/gconv-modules
diff --git a/localedata/Makefile b/localedata/Makefile
index a5ca7a31f43d50c3..14fcc37fed21e740 100644
--- a/localedata/Makefile
+++ b/localedata/Makefile
@@ -179,7 +179,7 @@ install-others := $(addprefix $(inst_i18ndir)/, \
$(locales))
endif
-tests: $(objdir)/iconvdata/gconv-modules.d/gconv-modules.conf
+tests: $(objdir)/iconvdata/gconv-modules
tests-static += tst-langinfo-newlocale-static tst-langinfo-setlocale-static
@@ -442,5 +442,5 @@ $(objpfx)mtrace-tst-leaks.out: $(objpfx)tst-leaks.out
bug-setlocale1-ENV-only = LOCPATH=$(objpfx) LC_CTYPE=de_DE.UTF-8
bug-setlocale1-static-ENV-only = $(bug-setlocale1-ENV-only)
-$(objdir)/iconvdata/gconv-modules.d/gconv-modules.conf:
+$(objdir)/iconvdata/gconv-modules:
$(MAKE) -C ../iconvdata subdir=iconvdata $@

View File

@ -0,0 +1,107 @@
commit e3217c7fd9e67aa2d53700bb1da9a966e73b9684
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date: Thu Jun 10 00:41:35 2021 +0530
iconv: Remove alloca use in gconv-modules configuration parsing
The alloca sizes ought to be constrained to PATH_MAX, but replace them
with dynamic allocation to be safe. A static PATH_MAX array would
have worked too but Hurd does not have PATH_MAX and the code path is
not hot enough to micro-optimise this allocation. Revisit if any of
those realities change.
Reviewed-by: DJ Delorie <dj@redhat.com>
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index 8eb981fca7cee36a..3099bf192adce711 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -557,15 +557,15 @@ __gconv_read_conf (void)
for (cnt = 0; __gconv_path_elem[cnt].name != NULL; ++cnt)
{
-#define BUF_LEN elem_len + sizeof (gconv_conf_dirname)
-
const char *elem = __gconv_path_elem[cnt].name;
size_t elem_len = __gconv_path_elem[cnt].len;
- char *buf;
/* No slash needs to be inserted between elem and gconv_conf_filename;
elem already ends in a slash. */
- buf = alloca (BUF_LEN);
+ char *buf = malloc (elem_len + sizeof (gconv_conf_dirname));
+ if (buf == NULL)
+ continue;
+
char *cp = __mempcpy (__mempcpy (buf, elem, elem_len),
gconv_conf_filename, sizeof (gconv_conf_filename));
@@ -594,15 +594,16 @@ __gconv_read_conf (void)
if (len > strlen (suffix)
&& strcmp (ent->d_name + len - strlen (suffix), suffix) == 0)
{
- /* LEN <= PATH_MAX so this alloca is not unbounded. */
- char *conf = alloca (BUF_LEN + len + 1);
- cp = stpcpy (conf, buf);
- sprintf (cp, "/%s", ent->d_name);
+ char *conf;
+ if (__asprintf (&conf, "%s/%s", buf, ent->d_name) < 0)
+ continue;
read_conf_file (conf, elem, elem_len, &modules, &nmodules);
+ free (conf);
}
}
__closedir (confdir);
}
+ free (buf);
}
#endif
diff --git a/iconv/iconvconfig.c b/iconv/iconvconfig.c
index fafc686ae25fb5c1..2f9d5f45ad3a8159 100644
--- a/iconv/iconvconfig.c
+++ b/iconv/iconvconfig.c
@@ -712,7 +712,6 @@ handle_file (const char *dir, const char *infile)
static int
handle_dir (const char *dir)
{
-#define BUF_LEN prefix_len + dirlen + sizeof "gconv-modules.d"
char *cp;
size_t dirlen = strlen (dir);
bool found = false;
@@ -726,7 +725,10 @@ handle_dir (const char *dir)
}
/* First, look for a gconv-modules file. */
- char buf[BUF_LEN];
+ char *buf = malloc (prefix_len + dirlen + sizeof "gconv-modules.d");
+ if (buf == NULL)
+ goto out;
+
cp = buf;
if (dir[0] == '/')
cp = mempcpy (cp, prefix, prefix_len);
@@ -756,16 +758,19 @@ handle_dir (const char *dir)
if (len > strlen (suffix)
&& strcmp (ent->d_name + len - strlen (suffix), suffix) == 0)
{
- /* LEN <= PATH_MAX so this alloca is not unbounded. */
- char *conf = alloca (BUF_LEN + len + 1);
- cp = stpcpy (conf, buf);
- sprintf (cp, "/%s", ent->d_name);
+ char *conf;
+ if (asprintf (&conf, "%s/%s", buf, ent->d_name) < 0)
+ continue;
found |= handle_file (dir, conf);
+ free (conf);
}
}
closedir (confdir);
}
+ free (buf);
+
+out:
if (!found)
{
error (0, errno, "failed to open gconv configuration files in `%s'",

View File

@ -0,0 +1,113 @@
commit 23e15ea1ae80ec2120afdf643691359644cf2873
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date: Thu Jun 10 09:51:50 2021 +0530
gconv_conf: Remove unused variables
The modules and nmodules parameters passed to add_modules, add_alias,
etc. are not used and are hence unnecessary. Remove them so that
their signatures match the functions in iconvconfig.
Reviewed-by: DJ Delorie <dj@redhat.com>
Reviewed-by: Andreas Schwab <schwab@linux-m68k.org>
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index 3099bf192adce711..dc12ce24844474cc 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -125,7 +125,7 @@ detect_conflict (const char *alias)
/* The actual code to add aliases. */
static void
-add_alias2 (const char *from, const char *to, const char *wp, void *modules)
+add_alias2 (const char *from, const char *to, const char *wp)
{
/* Test whether this alias conflicts with any available module. */
if (detect_conflict (from))
@@ -154,7 +154,7 @@ add_alias2 (const char *from, const char *to, const char *wp, void *modules)
/* Add new alias. */
static void
-add_alias (char *rp, void *modules)
+add_alias (char *rp)
{
/* We now expect two more string. The strings are normalized
(converted to UPPER case) and strored in the alias database. */
@@ -179,7 +179,7 @@ add_alias (char *rp, void *modules)
return;
*wp++ = '\0';
- add_alias2 (from, to, wp, modules);
+ add_alias2 (from, to, wp);
}
@@ -243,8 +243,7 @@ insert_module (struct gconv_module *newp, int tobefreed)
/* Add new module. */
static void
-add_module (char *rp, const char *directory, size_t dir_len, void **modules,
- size_t *nmodules, int modcounter)
+add_module (char *rp, const char *directory, size_t dir_len, int modcounter)
{
/* We expect now
1. `from' name
@@ -357,8 +356,7 @@ add_module (char *rp, const char *directory, size_t dir_len, void **modules,
/* Read the next configuration file. */
static void
-read_conf_file (const char *filename, const char *directory, size_t dir_len,
- void **modules, size_t *nmodules)
+read_conf_file (const char *filename, const char *directory, size_t dir_len)
{
/* Note the file is opened with cancellation in the I/O functions
disabled. */
@@ -408,10 +406,10 @@ read_conf_file (const char *filename, const char *directory, size_t dir_len,
if (rp - word == sizeof ("alias") - 1
&& memcmp (word, "alias", sizeof ("alias") - 1) == 0)
- add_alias (rp, *modules);
+ add_alias (rp);
else if (rp - word == sizeof ("module") - 1
&& memcmp (word, "module", sizeof ("module") - 1) == 0)
- add_module (rp, directory, dir_len, modules, nmodules, modcounter++);
+ add_module (rp, directory, dir_len, modcounter++);
/* else */
/* Otherwise ignore the line. */
}
@@ -537,8 +535,6 @@ void
attribute_hidden
__gconv_read_conf (void)
{
- void *modules = NULL;
- size_t nmodules = 0;
int save_errno = errno;
size_t cnt;
@@ -570,7 +566,7 @@ __gconv_read_conf (void)
gconv_conf_filename, sizeof (gconv_conf_filename));
/* Read the gconv-modules configuration file first. */
- read_conf_file (buf, elem, elem_len, &modules, &nmodules);
+ read_conf_file (buf, elem, elem_len);
/* Next, see if there is a gconv-modules.d directory containing
configuration files and if it is non-empty. */
@@ -597,7 +593,7 @@ __gconv_read_conf (void)
char *conf;
if (__asprintf (&conf, "%s/%s", buf, ent->d_name) < 0)
continue;
- read_conf_file (conf, elem, elem_len, &modules, &nmodules);
+ read_conf_file (conf, elem, elem_len);
free (conf);
}
}
@@ -631,7 +627,7 @@ __gconv_read_conf (void)
const char *to = __rawmemchr (from, '\0') + 1;
cp = __rawmemchr (to, '\0') + 1;
- add_alias2 (from, to, cp, modules);
+ add_alias2 (from, to, cp);
}
while (*cp != '\0');

View File

@ -0,0 +1,360 @@
commit d8e8097f3be5b3c49fc741fa19e1da0b0431384c
Author: Siddhesh Poyarekar <siddhesh@sourceware.org>
Date: Thu Jun 10 14:07:27 2021 +0530
gconv_conf: Split out configuration file processing
Split configuration file processing into a separate header file and
include it. Macroize all calls that need to go through internal
interfaces so that iconvconfig can also use them.
Reviewed-by: DJ Delorie <dj@redhat.com>
# Conflicts:
# iconv/gconv_conf.c
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index dc12ce24844474cc..ce64faa928dc1c52 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -19,7 +19,6 @@
#include <assert.h>
#include <ctype.h>
-#include <dirent.h>
#include <errno.h>
#include <limits.h>
#include <locale.h>
@@ -31,11 +30,10 @@
#include <string.h>
#include <unistd.h>
#include <sys/param.h>
-#include <sys/types.h>
#include <libc-lock.h>
#include <gconv_int.h>
-
+#include <gconv_parseconfdir.h>
/* This is the default path where we look for module lists. */
static const char default_gconv_path[] = GCONV_PATH;
@@ -49,11 +47,6 @@ size_t __gconv_max_path_elem_len;
/* We use the following struct if we couldn't allocate memory. */
static const struct path_elem empty_path_elem = { NULL, 0 };
-/* Name of the file containing the module information in the directories
- along the path. */
-static const char gconv_conf_filename[] = "gconv-modules";
-static const char gconv_conf_dirname[] = "gconv-modules.d";
-
/* Filename extension for the modules. */
#ifndef MODULE_EXT
# define MODULE_EXT ".so"
@@ -92,9 +85,6 @@ static const char builtin_aliases[] =
#undef BUILTIN_ALIAS
};
-#include <libio/libioP.h>
-#define __getdelim(line, len, c, fp) _IO_getdelim (line, len, c, fp)
-
/* Value of the GCONV_PATH environment variable. */
const char *__gconv_path_envvar;
@@ -354,72 +344,6 @@ add_module (char *rp, const char *directory, size_t dir_len, int modcounter)
}
-/* Read the next configuration file. */
-static void
-read_conf_file (const char *filename, const char *directory, size_t dir_len)
-{
- /* Note the file is opened with cancellation in the I/O functions
- disabled. */
- FILE *fp = fopen (filename, "rce");
- char *line = NULL;
- size_t line_len = 0;
- static int modcounter;
-
- /* Don't complain if a file is not present or readable, simply silently
- ignore it. */
- if (fp == NULL)
- return;
-
- /* No threads reading from this stream. */
- __fsetlocking (fp, FSETLOCKING_BYCALLER);
-
- /* Process the known entries of the file. Comments start with `#' and
- end with the end of the line. Empty lines are ignored. */
- while (!__feof_unlocked (fp))
- {
- char *rp, *endp, *word;
- ssize_t n = __getdelim (&line, &line_len, '\n', fp);
- if (n < 0)
- /* An error occurred. */
- break;
-
- rp = line;
- /* Terminate the line (excluding comments or newline) by an NUL byte
- to simplify the following code. */
- endp = strchr (rp, '#');
- if (endp != NULL)
- *endp = '\0';
- else
- if (rp[n - 1] == '\n')
- rp[n - 1] = '\0';
-
- while (__isspace_l (*rp, _nl_C_locobj_ptr))
- ++rp;
-
- /* If this is an empty line go on with the next one. */
- if (rp == endp)
- continue;
-
- word = rp;
- while (*rp != '\0' && !__isspace_l (*rp, _nl_C_locobj_ptr))
- ++rp;
-
- if (rp - word == sizeof ("alias") - 1
- && memcmp (word, "alias", sizeof ("alias") - 1) == 0)
- add_alias (rp);
- else if (rp - word == sizeof ("module") - 1
- && memcmp (word, "module", sizeof ("module") - 1) == 0)
- add_module (rp, directory, dir_len, modcounter++);
- /* else */
- /* Otherwise ignore the line. */
- }
-
- free (line);
-
- fclose (fp);
-}
-
-
/* Determine the directories we are looking for data in. */
void
__gconv_get_path (void)
@@ -552,55 +476,8 @@ __gconv_read_conf (void)
__gconv_get_path ();
for (cnt = 0; __gconv_path_elem[cnt].name != NULL; ++cnt)
- {
- const char *elem = __gconv_path_elem[cnt].name;
- size_t elem_len = __gconv_path_elem[cnt].len;
-
- /* No slash needs to be inserted between elem and gconv_conf_filename;
- elem already ends in a slash. */
- char *buf = malloc (elem_len + sizeof (gconv_conf_dirname));
- if (buf == NULL)
- continue;
-
- char *cp = __mempcpy (__mempcpy (buf, elem, elem_len),
- gconv_conf_filename, sizeof (gconv_conf_filename));
-
- /* Read the gconv-modules configuration file first. */
- read_conf_file (buf, elem, elem_len);
-
- /* Next, see if there is a gconv-modules.d directory containing
- configuration files and if it is non-empty. */
- cp--;
- cp[0] = '.';
- cp[1] = 'd';
- cp[2] = '\0';
-
- DIR *confdir = __opendir (buf);
- if (confdir != NULL)
- {
- struct dirent *ent;
- while ((ent = __readdir (confdir)) != NULL)
- {
- if (ent->d_type != DT_REG)
- continue;
-
- size_t len = strlen (ent->d_name);
- const char *suffix = ".conf";
-
- if (len > strlen (suffix)
- && strcmp (ent->d_name + len - strlen (suffix), suffix) == 0)
- {
- char *conf;
- if (__asprintf (&conf, "%s/%s", buf, ent->d_name) < 0)
- continue;
- read_conf_file (conf, elem, elem_len);
- free (conf);
- }
- }
- __closedir (confdir);
- }
- free (buf);
- }
+ gconv_parseconfdir (__gconv_path_elem[cnt].name,
+ __gconv_path_elem[cnt].len);
#endif
/* Add the internal modules. */
diff --git a/iconv/gconv_parseconfdir.h b/iconv/gconv_parseconfdir.h
new file mode 100644
index 0000000000000000..3d4d58d4be10a250
--- /dev/null
+++ b/iconv/gconv_parseconfdir.h
@@ -0,0 +1,161 @@
+/* Handle configuration data.
+ Copyright (C) 2021 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <dirent.h>
+#include <libc-symbols.h>
+#include <locale.h>
+#include <sys/types.h>
+
+#if IS_IN (libc)
+# include <libio/libioP.h>
+# define __getdelim(line, len, c, fp) _IO_getdelim (line, len, c, fp)
+
+# undef isspace
+# define isspace(__c) __isspace_l ((__c), _nl_C_locobj_ptr)
+# define asprintf __asprintf
+# define opendir __opendir
+# define readdir __readdir
+# define closedir __closedir
+# define mempcpy __mempcpy
+#endif
+
+/* Name of the file containing the module information in the directories
+ along the path. */
+static const char gconv_conf_filename[] = "gconv-modules";
+static const char gconv_conf_dirname[] = "gconv-modules.d";
+
+static void add_alias (char *);
+static void add_module (char *, const char *, size_t, int);
+
+/* Read the next configuration file. */
+static bool
+read_conf_file (const char *filename, const char *directory, size_t dir_len)
+{
+ /* Note the file is opened with cancellation in the I/O functions
+ disabled. */
+ FILE *fp = fopen (filename, "rce");
+ char *line = NULL;
+ size_t line_len = 0;
+ static int modcounter;
+
+ /* Don't complain if a file is not present or readable, simply silently
+ ignore it. */
+ if (fp == NULL)
+ return false;
+
+ /* No threads reading from this stream. */
+ __fsetlocking (fp, FSETLOCKING_BYCALLER);
+
+ /* Process the known entries of the file. Comments start with `#' and
+ end with the end of the line. Empty lines are ignored. */
+ while (!__feof_unlocked (fp))
+ {
+ char *rp, *endp, *word;
+ ssize_t n = __getdelim (&line, &line_len, '\n', fp);
+ if (n < 0)
+ /* An error occurred. */
+ break;
+
+ rp = line;
+ /* Terminate the line (excluding comments or newline) by an NUL byte
+ to simplify the following code. */
+ endp = strchr (rp, '#');
+ if (endp != NULL)
+ *endp = '\0';
+ else
+ if (rp[n - 1] == '\n')
+ rp[n - 1] = '\0';
+
+ while (isspace (*rp))
+ ++rp;
+
+ /* If this is an empty line go on with the next one. */
+ if (rp == endp)
+ continue;
+
+ word = rp;
+ while (*rp != '\0' && !isspace (*rp))
+ ++rp;
+
+ if (rp - word == sizeof ("alias") - 1
+ && memcmp (word, "alias", sizeof ("alias") - 1) == 0)
+ add_alias (rp);
+ else if (rp - word == sizeof ("module") - 1
+ && memcmp (word, "module", sizeof ("module") - 1) == 0)
+ add_module (rp, directory, dir_len, modcounter++);
+ /* else */
+ /* Otherwise ignore the line. */
+ }
+
+ free (line);
+
+ fclose (fp);
+ return true;
+}
+
+static __always_inline bool
+gconv_parseconfdir (const char *dir, size_t dir_len)
+{
+ /* No slash needs to be inserted between dir and gconv_conf_filename;
+ dir already ends in a slash. */
+ char *buf = malloc (dir_len + sizeof (gconv_conf_dirname));
+ bool found = false;
+
+ if (buf == NULL)
+ return false;
+
+ char *cp = mempcpy (mempcpy (buf, dir, dir_len), gconv_conf_filename,
+ sizeof (gconv_conf_filename));
+
+ /* Read the gconv-modules configuration file first. */
+ found = read_conf_file (buf, dir, dir_len);
+
+ /* Next, see if there is a gconv-modules.d directory containing
+ configuration files and if it is non-empty. */
+ cp--;
+ cp[0] = '.';
+ cp[1] = 'd';
+ cp[2] = '\0';
+
+ DIR *confdir = opendir (buf);
+ if (confdir != NULL)
+ {
+ struct dirent *ent;
+ while ((ent = readdir (confdir)) != NULL)
+ {
+ if (ent->d_type != DT_REG)
+ continue;
+
+ size_t len = strlen (ent->d_name);
+ const char *suffix = ".conf";
+
+ if (len > strlen (suffix)
+ && strcmp (ent->d_name + len - strlen (suffix), suffix) == 0)
+ {
+ char *conf;
+ if (asprintf (&conf, "%s/%s", buf, ent->d_name) < 0)
+ continue;
+ found |= read_conf_file (conf, dir, dir_len);
+ free (conf);
+ }
+ }
+ closedir (confdir);
+ }
+ free (buf);
+ return found;
+}

View File

@ -1,6 +1,6 @@
%define glibcsrcdir glibc-2.28 %define glibcsrcdir glibc-2.28
%define glibcversion 2.28 %define glibcversion 2.28
%define glibcrelease 164%{?dist} %define glibcrelease 166%{?dist}
# Pre-release tarballs are pulled in from git using a command that is # Pre-release tarballs are pulled in from git using a command that is
# effectively: # effectively:
# #
@ -85,6 +85,47 @@
# here. If the arch is not listed here then a single core debuginfo package # here. If the arch is not listed here then a single core debuginfo package
# will be created for the architecture. # will be created for the architecture.
%define debuginfocommonarches %{biarcharches} alpha alphaev6 %define debuginfocommonarches %{biarcharches} alpha alphaev6
##############################################################################
# Utility functions for pre/post scripts. Stick them at the beginning of
# any lua %pre, %post, %postun, etc. sections to have them expand into
# those scripts. It only works in lua sections and not anywhere else.
%define glibc_post_funcs() \
-- We use lua posix.exec because there may be no shell that we can \
-- run during glibc upgrade. We used to implement much of %%post as a \
-- C program, but from an overall maintenance perspective the lua in \
-- the spec file was simpler and safer given the operations required. \
-- All lua code will be ignored by rpm-ostree; see: \
-- https://github.com/projectatomic/rpm-ostree/pull/1869 \
-- If we add new lua actions to the %%post code we should coordinate \
-- with rpm-ostree and ensure that their glibc install is functional. \
function post_exec (program, ...) \
local pid = posix.fork () \
if pid == 0 then \
posix.exec (program, ...) \
assert (nil) \
elseif pid > 0 then \
posix.wait (pid) \
end \
end \
\
function update_gconv_modules_cache () \
local iconv_dir = "%{_libdir}/gconv" \
local iconv_cache = iconv_dir .. "/gconv-modules.cache" \
local iconv_modules = iconv_dir .. "/gconv-modules" \
if (posix.utime (iconv_modules) == 0) then \
if (posix.utime (iconv_cache) == 0) then \
post_exec ("%{_prefix}/sbin/iconvconfig", \
"-o", iconv_cache, \
"--nostdlib", \
iconv_dir) \
else \
io.stdout:write ("Error: Missing " .. iconv_cache .. " file.\n") \
end \
end \
end \
%{nil}
############################################################################## ##############################################################################
# %%package glibc - The GNU C Library (glibc) core package. # %%package glibc - The GNU C Library (glibc) core package.
############################################################################## ##############################################################################
@ -719,6 +760,21 @@ Patch582: glibc-rh1966472-1.patch
Patch583: glibc-rh1966472-2.patch Patch583: glibc-rh1966472-2.patch
Patch584: glibc-rh1966472-3.patch Patch584: glibc-rh1966472-3.patch
Patch585: glibc-rh1966472-4.patch Patch585: glibc-rh1966472-4.patch
Patch586: glibc-rh1971664-1.patch
Patch587: glibc-rh1971664-2.patch
Patch588: glibc-rh1971664-3.patch
Patch589: glibc-rh1971664-4.patch
Patch590: glibc-rh1971664-5.patch
Patch591: glibc-rh1971664-6.patch
Patch592: glibc-rh1971664-7.patch
Patch593: glibc-rh1971664-8.patch
Patch594: glibc-rh1971664-9.patch
Patch595: glibc-rh1971664-10.patch
Patch596: glibc-rh1971664-11.patch
Patch597: glibc-rh1971664-12.patch
Patch598: glibc-rh1971664-13.patch
Patch599: glibc-rh1971664-14.patch
Patch600: glibc-rh1971664-15.patch
############################################################################## ##############################################################################
# Continued list of core "glibc" package information: # Continued list of core "glibc" package information:
@ -849,6 +905,10 @@ BuildRequires: libidn2
Requires: glibc-langpack = %{version}-%{release} Requires: glibc-langpack = %{version}-%{release}
Suggests: glibc-all-langpacks = %{version}-%{release} Suggests: glibc-all-langpacks = %{version}-%{release}
# Suggest extra gconv modules so that they are installed by default but can be
# removed if needed to build a minimal OS image.
Requires: glibc-gconv-extra%{_isa} = %{version}-%{release}
%description %description
The glibc package contains standard libraries which are used by The glibc package contains standard libraries which are used by
multiple programs on the system. In order to save disk space and multiple programs on the system. In order to save disk space and
@ -1098,6 +1158,15 @@ nothing else. It is designed for assembling a minimal system.
%files minimal-langpack %files minimal-langpack
%endif %endif
# Infrequently used iconv converter modules.
%package gconv-extra
Summary: All iconv converter modules for %{name}.
Requires: %{name}%{_isa} = %{version}-%{release}
Requires: %{name}-common = %{version}-%{release}
%description gconv-extra
This package contains all iconv converter modules built in %{name}.
############################################################################## ##############################################################################
# glibc "nscd" sub-package # glibc "nscd" sub-package
############################################################################## ##############################################################################
@ -1875,6 +1944,7 @@ touch master.filelist
touch glibc.filelist touch glibc.filelist
touch common.filelist touch common.filelist
touch utils.filelist touch utils.filelist
touch gconv.filelist
touch nscd.filelist touch nscd.filelist
touch devel.filelist touch devel.filelist
touch headers.filelist touch headers.filelist
@ -1897,10 +1967,10 @@ touch debuginfocommon.filelist
find %{glibc_sysroot} \( -type f -o -type l \) \ find %{glibc_sysroot} \( -type f -o -type l \) \
\( \ \( \
-name etc -printf "%%%%config " -o \ -name etc -printf "%%%%config " -o \
-name gconv-modules \
-printf "%%%%verify(not md5 size mtime) %%%%config(noreplace) " -o \
-name gconv-modules.cache \ -name gconv-modules.cache \
-printf "%%%%verify(not md5 size mtime) " \ -printf "%%%%verify(not md5 size mtime) " -o \
-name gconv-modules* \
-printf "%%%%verify(not md5 size mtime) %%%%config(noreplace) " \
, \ , \
! -path "*/lib/debug/*" -printf "/%%P\n" \) ! -path "*/lib/debug/*" -printf "/%%P\n" \)
# List all directories with a %%dir prefix. We omit the info directory and # List all directories with a %%dir prefix. We omit the info directory and
@ -1952,6 +2022,7 @@ chmod 0444 master.filelist
# - All bench test binaries. # - All bench test binaries.
# - The aux-cache, since it's handled specially in the files section. # - The aux-cache, since it's handled specially in the files section.
# - The build-locale-archive binary since it's in the common package. # - The build-locale-archive binary since it's in the common package.
# - Extra gconv modules. We add the required modules later.
cat master.filelist \ cat master.filelist \
| grep -v \ | grep -v \
-e '%{_infodir}' \ -e '%{_infodir}' \
@ -1960,6 +2031,8 @@ cat master.filelist \
-e '%{_libdir}/lib.*\.a' \ -e '%{_libdir}/lib.*\.a' \
-e '%{_libdir}/.*\.o' \ -e '%{_libdir}/.*\.o' \
-e '%{_libdir}/lib.*\.so' \ -e '%{_libdir}/lib.*\.so' \
-e '%{_libdir}/gconv/.*\.so$' \
-e '%{_libdir}/gconv/gconv-modules.d/gconv-modules-extra\.conf$' \
-e 'nscd' \ -e 'nscd' \
-e '%{_prefix}/bin' \ -e '%{_prefix}/bin' \
-e '%{_prefix}/lib/locale' \ -e '%{_prefix}/lib/locale' \
@ -1984,6 +2057,34 @@ for module in compat files dns; do
done done
grep -e "libmemusage.so" -e "libpcprofile.so" master.filelist >> glibc.filelist grep -e "libmemusage.so" -e "libpcprofile.so" master.filelist >> glibc.filelist
###############################################################################
# glibc-gconv-extra
###############################################################################
grep -e "gconv-modules-extra.conf" master.filelist > gconv.filelist
# Put the essential gconv modules into the main package.
GconvBaseModules="ANSI_X3.110 ISO8859-15 ISO8859-1 CP1252"
GconvBaseModules="$GconvBaseModules UNICODE UTF-16 UTF-32 UTF-7"
%ifarch s390 s390x
GconvBaseModules="$GconvBaseModules ISO-8859-1_CP037_Z900 UTF8_UTF16_Z9"
GconvBaseModules="$GconvBaseModules UTF16_UTF32_Z9 UTF8_UTF32_Z9"
%endif
GconvAllModules=$(cat master.filelist |
sed -n 's|%{_libdir}/gconv/\(.*\)\.so|\1|p')
# Put the base modules into glibc and the rest into glibc-gconv-extra
for conv in $GconvAllModules; do
if echo $GconvBaseModules | grep -q $conv; then
grep -E -e "%{_libdir}/gconv/$conv.so$" \
master.filelist >> glibc.filelist
else
grep -E -e "%{_libdir}/gconv/$conv.so$" \
master.filelist >> gconv.filelist
fi
done
############################################################################### ###############################################################################
# glibc-devel # glibc-devel
############################################################################### ###############################################################################
@ -2148,6 +2249,7 @@ find_debuginfo_args="$find_debuginfo_args \
-l nscd.filelist \ -l nscd.filelist \
-p '.*/(sbin|libexec)/.*' \ -p '.*/(sbin|libexec)/.*' \
-o debuginfocommon.filelist \ -o debuginfocommon.filelist \
-l gconv.filelist \
-l nss_db.filelist -l nss_hesiod.filelist \ -l nss_db.filelist -l nss_hesiod.filelist \
-l libnsl.filelist -l glibc.filelist \ -l libnsl.filelist -l glibc.filelist \
%if %{with benchtests} %if %{with benchtests}
@ -2350,17 +2452,7 @@ if rpm.vercmp(rel, required) < 0 then
end end
%post -p <lua> %post -p <lua>
-- We use lua's posix.exec because there may be no shell that we can %glibc_post_funcs
-- run during glibc upgrade.
function post_exec (program, ...)
local pid = posix.fork ()
if pid == 0 then
assert (posix.exec (program, ...))
elseif pid > 0 then
posix.wait (pid)
end
end
-- (1) Remove multilib libraries from previous installs. -- (1) Remove multilib libraries from previous installs.
-- In order to support in-place upgrades, we must immediately remove -- In order to support in-place upgrades, we must immediately remove
-- obsolete platform directories after installing a new glibc -- obsolete platform directories after installing a new glibc
@ -2469,16 +2561,7 @@ post_exec ("%{_prefix}/sbin/ldconfig")
-- We assume that the cache is in _libdir/gconv and called -- We assume that the cache is in _libdir/gconv and called
-- "gconv-modules.cache". -- "gconv-modules.cache".
local iconv_dir = "%{_libdir}/gconv" update_gconv_modules_cache()
local iconv_cache = iconv_dir .. "/gconv-modules.cache"
if (posix.utime (iconv_cache) == 0) then
post_exec ("%{_prefix}/sbin/iconvconfig",
"-o", iconv_cache,
"--nostdlib",
iconv_dir)
else
io.stdout:write ("Error: Missing " .. iconv_cache .. " file.\n")
end
%posttrans all-langpacks -e -p <lua> %posttrans all-langpacks -e -p <lua>
-- If at the end of the transaction we are still installed -- If at the end of the transaction we are still installed
@ -2519,6 +2602,14 @@ if [ "$1" = 0 ]; then
fi fi
%endif %endif
%post gconv-extra -p <lua>
%glibc_post_funcs
update_gconv_modules_cache ()
%postun gconv-extra -p <lua>
%glibc_post_funcs
update_gconv_modules_cache ()
%pre -n nscd %pre -n nscd
getent group nscd >/dev/null || /usr/sbin/groupadd -g 28 -r nscd getent group nscd >/dev/null || /usr/sbin/groupadd -g 28 -r nscd
getent passwd nscd >/dev/null || getent passwd nscd >/dev/null ||
@ -2551,6 +2642,7 @@ fi
%dir /etc/ld.so.conf.d %dir /etc/ld.so.conf.d
%dir %{_prefix}/libexec/getconf %dir %{_prefix}/libexec/getconf
%dir %{_libdir}/gconv %dir %{_libdir}/gconv
%dir %{_libdir}/gconv/gconv-modules.d
%dir %attr(0700,root,root) /var/cache/ldconfig %dir %attr(0700,root,root) /var/cache/ldconfig
%attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/cache/ldconfig/aux-cache %attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/cache/ldconfig/aux-cache
%attr(0644,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /etc/ld.so.cache %attr(0644,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /etc/ld.so.cache
@ -2586,6 +2678,8 @@ fi
%files -f utils.filelist utils %files -f utils.filelist utils
%files -f gconv.filelist gconv-extra
%files -f nscd.filelist -n nscd %files -f nscd.filelist -n nscd
%config(noreplace) /etc/nscd.conf %config(noreplace) /etc/nscd.conf
%dir %attr(0755,root,root) /var/run/nscd %dir %attr(0755,root,root) /var/run/nscd
@ -2631,6 +2725,12 @@ fi
%files -f compat-libpthread-nonshared.filelist -n compat-libpthread-nonshared %files -f compat-libpthread-nonshared.filelist -n compat-libpthread-nonshared
%changelog %changelog
* Wed Oct 13 2021 Siddhesh Poyarekar <siddhesh@redhat.com> - 2.28-166
- Fix debuginfo location for gconv-extra and make glibc Require it (#1971664).
* Wed Oct 6 2021 Siddhesh Poyarekar <siddhesh@redhat.com> - 2.28-165
- Split extra gconv modules into a separate package (#1971664).
* Mon Aug 9 2021 Siddhesh Poyarekar <siddhesh@redhat.com> - 2.28-164 * Mon Aug 9 2021 Siddhesh Poyarekar <siddhesh@redhat.com> - 2.28-164
- librt: fix NULL pointer dereference (#1966472). - librt: fix NULL pointer dereference (#1966472).