From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-3.1 required=3.0 tests=AWL,BAYES_00,BODY_8BITS, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 192501F8C6 for ; Mon, 23 Aug 2021 03:14:29 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E7EFE3853C05 for ; Mon, 23 Aug 2021 03:14:27 +0000 (GMT) Received: from buffalo.birch.relay.mailchannels.net (buffalo.birch.relay.mailchannels.net [23.83.209.24]) by sourceware.org (Postfix) with ESMTPS id A8B98385C413 for ; Mon, 23 Aug 2021 02:55:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A8B98385C413 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gotplt.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 86CB1322739 for ; Mon, 23 Aug 2021 02:55:27 +0000 (UTC) Received: from pdx1-sub0-mail-a30.g.dreamhost.com (100-105-161-185.trex-nlb.outbound.svc.cluster.local [100.105.161.185]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id EE149322693 for ; Mon, 23 Aug 2021 02:55:26 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a30.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.105.161.185 (trex/6.3.3); Mon, 23 Aug 2021 02:55:27 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Decisive-Lonely: 3768269e07882e50_1629687327350_4208133060 X-MC-Loop-Signature: 1629687327350:1329494965 X-MC-Ingress-Time: 1629687327349 Received: from pdx1-sub0-mail-a30.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a30.g.dreamhost.com (Postfix) with ESMTP id A61AE7EECF for ; Sun, 22 Aug 2021 19:55:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gotplt.org; h=subject:from :to:references:message-id:date:mime-version:in-reply-to :content-type:content-transfer-encoding; s=gotplt.org; bh=qG89NJ fgSJaTuZQWBJbjNG2n2QA=; b=uuwXG7c83HEPjai9H6ZlLO988xRkeyxPHypans 5RvTRrqIu2uRh/qWbw8+8ZCLTI3OVSlLOj94+sY4zTvt6WpNHs59fRYk2e+ZqFjf befMoOA0Csx4D4ZG++Qa1U1iwWRqnBz5X7T0yAJ4a0Vg2OX+fIlOl1wceeGXfOqd Xogcc= Received: from [192.168.1.167] (unknown [1.186.224.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a30.g.dreamhost.com (Postfix) with ESMTPSA id 6A6957EECA for ; Sun, 22 Aug 2021 19:55:24 -0700 (PDT) Subject: [PING2][PATCH] iconvconfig: Fix behaviour with --prefix [BZ #28199] X-DH-BACKEND: pdx1-sub0-mail-a30 From: Siddhesh Poyarekar To: libc-alpha@sourceware.org References: <20210809062740.322823-1-siddhesh@sourceware.org> <7c7ccf14-978d-473a-78ca-9b2d7854c7e7@gotplt.org> Message-ID: <2260715e-720a-5cef-de36-9d1926583d2b@gotplt.org> Date: Mon, 23 Aug 2021 08:25:20 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <7c7ccf14-978d-473a-78ca-9b2d7854c7e7@gotplt.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" Ping! On 8/17/21 8:28 AM, Siddhesh Poyarekar wrote: > Ping! >=20 > On 8/9/21 11:57 AM, Siddhesh Poyarekar via Libc-alpha wrote: >> The consolidation of configuration parsing broke behaviour with >> --prefix, where the prefix bled into the modules cache.=C2=A0 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 >> Reported-by: Michael Hudson-Doyle >> Signed-off-by: Siddhesh Poyarekar >> --- >> =C2=A0 iconv/gconv_conf.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 |=C2=A0 2 +- >> =C2=A0 iconv/gconv_parseconfdir.h | 21 +++++++++++++++------ >> =C2=A0 iconv/iconvconfig.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |= 16 ++++++++++++---- >> =C2=A0 3 files changed, 28 insertions(+), 11 deletions(-) >> >> diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c >> index 62bee28769..cc391d8f93 100644 >> --- a/iconv/gconv_conf.c >> +++ b/iconv/gconv_conf.c >> @@ -478,7 +478,7 @@ __gconv_read_conf (void) >> =C2=A0=C2=A0=C2=A0 __gconv_get_path (); >> =C2=A0=C2=A0=C2=A0 for (cnt =3D 0; __gconv_path_elem[cnt].name !=3D NU= LL; ++cnt) >> -=C2=A0=C2=A0=C2=A0 gconv_parseconfdir (__gconv_path_elem[cnt].name, >> +=C2=A0=C2=A0=C2=A0 gconv_parseconfdir (NULL, __gconv_path_elem[cnt].n= ame, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 __gconv_path_elem[cnt].len); >> =C2=A0 #endif >> diff --git a/iconv/gconv_parseconfdir.h b/iconv/gconv_parseconfdir.h >> index 2f062689ec..38ffa9353a 100644 >> --- a/iconv/gconv_parseconfdir.h >> +++ b/iconv/gconv_parseconfdir.h >> @@ -38,8 +38,9 @@ >> =C2=A0 /* Name of the file containing the module information in the=20 >> directories >> =C2=A0=C2=A0=C2=A0=C2=A0 along the path.=C2=A0 */ >> -static const char gconv_conf_filename[] =3D "gconv-modules"; >> -static const char gconv_conf_dirname[] =3D "gconv-modules.d"; >> +#define GCONV_CONF_FILENAME "gconv-modules" >> +static const char gconv_conf_filename[] =3D GCONV_CONF_FILENAME; >> +static const char gconv_conf_dirname[] =3D GCONV_CONF_FILENAME ".d"; >> =C2=A0 static void add_alias (char *); >> =C2=A0 static void add_module (char *, const char *, size_t, int); >> @@ -110,19 +111,27 @@ read_conf_file (const char *filename, const char= =20 >> *directory, size_t dir_len) >> =C2=A0=C2=A0=C2=A0 return true; >> =C2=A0 } >> +/* Prefix DIR (with length DIR_LEN) with PREFIX if the latter is=20 >> non-NULL and >> +=C2=A0=C2=A0 parse configuration in it.=C2=A0 */ >> + >> =C2=A0 static __always_inline bool >> -gconv_parseconfdir (const char *dir, size_t dir_len) >> +gconv_parseconfdir (const char *prefix, const char *dir, size_t dir_l= en) >> =C2=A0 { >> =C2=A0=C2=A0=C2=A0 /* No slash needs to be inserted between dir and gc= onv_conf_filename; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dir already ends in a slash.=C2=A0= */ >> -=C2=A0 char *buf =3D malloc (dir_len + sizeof (gconv_conf_dirname)); >> +=C2=A0 size_t buflen =3D dir_len + sizeof (gconv_conf_dirname); >> +=C2=A0 char *buf =3D malloc (buflen + (prefix !=3D NULL ? strlen (pre= fix) : 0)); >> +=C2=A0 char *cp =3D buf; >> =C2=A0=C2=A0=C2=A0 bool found =3D false; >> =C2=A0=C2=A0=C2=A0 if (buf =3D=3D NULL) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return false; >> -=C2=A0 char *cp =3D mempcpy (mempcpy (buf, dir, dir_len), gconv_conf_= filename, >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 sizeof (gconv_conf_filename)); >> +=C2=A0 if (prefix !=3D NULL) >> +=C2=A0=C2=A0=C2=A0 cp =3D stpcpy (cp, prefix); >> + >> +=C2=A0 cp =3D mempcpy (mempcpy (cp, dir, dir_len), gconv_conf_filenam= e, >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sizeof (gconv_conf_filenam= e)); >> =C2=A0=C2=A0=C2=A0 /* Read the gconv-modules configuration file first.= =C2=A0 */ >> =C2=A0=C2=A0=C2=A0 found =3D read_conf_file (buf, dir, dir_len); >> diff --git a/iconv/iconvconfig.c b/iconv/iconvconfig.c >> index 783b2bbdbb..273a71f673 100644 >> --- a/iconv/iconvconfig.c >> +++ b/iconv/iconvconfig.c >> @@ -653,13 +653,21 @@ add_module (char *rp, const char *directory, >> =C2=A0 static int >> =C2=A0 handle_dir (const char *dir) >> =C2=A0 { >> +=C2=A0 char *newp =3D NULL; >> =C2=A0=C2=A0=C2=A0 size_t dirlen =3D strlen (dir); >> =C2=A0=C2=A0=C2=A0 bool found =3D false; >> -=C2=A0 char *fulldir =3D xasprintf ("%s%s%s", dir[0] =3D=3D '/' ? pre= fix : "", >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 dir, dir[dirlen - 1] !=3D '/' ? "/" : ""); >> +=C2=A0 /* End directory path with a '/' if it doesn't already.=C2=A0 = */ >> +=C2=A0 if (dir[dirlen - 1] !=3D '/') >> +=C2=A0=C2=A0=C2=A0 { >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 newp =3D xmalloc (dirlen + 2); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 memcpy (newp, dir, dirlen); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 newp[dirlen++] =3D '/'; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 newp[dirlen] =3D '\0'; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dir =3D newp; >> +=C2=A0=C2=A0=C2=A0 } >> -=C2=A0 found =3D gconv_parseconfdir (fulldir, strlen (fulldir)); >> +=C2=A0 found =3D gconv_parseconfdir (dir[0] =3D=3D '/' ? prefix : NUL= L, dir,=20 >> dirlen); >> =C2=A0=C2=A0=C2=A0 if (!found) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 { >> @@ -671,7 +679,7 @@ handle_dir (const char *dir) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "configur= ation files with names ending in .conf."); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >> -=C2=A0 free (fulldir); >> +=C2=A0 free (newp); >> =C2=A0=C2=A0=C2=A0 return found ? 0 : 1; >> =C2=A0 } >> >=20