From debbugs-submit-bounces@debbugs.gnu.org Fri May 24 11:48:01 2013 Received: (at submit) by debbugs.gnu.org; 24 May 2013 15:48:01 +0000 Received: from localhost ([127.0.0.1]:60478 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UfuDn-0003JG-Na for submit@debbugs.gnu.org; Fri, 24 May 2013 11:48:01 -0400 Received: from eggs.gnu.org ([208.118.235.92]:50003) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Ufs8Y-00050T-Bf for submit@debbugs.gnu.org; Fri, 24 May 2013 09:34:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ufs7T-0000F5-06 for submit@debbugs.gnu.org; Fri, 24 May 2013 09:33:25 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_05,RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:50616) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ufs7S-0000F0-Se for submit@debbugs.gnu.org; Fri, 24 May 2013 09:33:18 -0400 Received: from eggs.gnu.org ([208.118.235.92]:33014) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ufs7K-00019T-8Z for bug-coreutils@gnu.org; Fri, 24 May 2013 09:33:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ufs7A-0008WA-6m for bug-coreutils@gnu.org; Fri, 24 May 2013 09:33:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38759) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ufs79-0008To-R0 for bug-coreutils@gnu.org; Fri, 24 May 2013 09:33:00 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r4ODWvtQ000588 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 24 May 2013 09:32:58 -0400 Received: from [10.34.4.138] (unused-4-138.brq.redhat.com [10.34.4.138]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r4ODWub8009774; Fri, 24 May 2013 09:32:57 -0400 Message-ID: <1369402376.12421.5.camel@unused-4-242.brq.redhat.com> Subject: useless calls of setpwent()/setgrent() in stat From: =?ISO-8859-1?Q?Fridol=EDn_Pokorn=FD?= To: bug-coreutils@gnu.org Date: Fri, 24 May 2013 15:32:56 +0200 Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -4.2 (----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Fri, 24 May 2013 11:47:58 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) Hi, I am investigating an issue with stat. stat calls setpwent() (when resolving a username) and setgrent() (when resolving a group name). This has a bad impact when a LDAP is used and a database is quite large. It forces to download the whole database. According to RFC 2307, getpwuid()/getgrgid() are handled correctly with a search pattern to get an username/group name and there is no need to call setpwent()/setgrent(). My tests have approved this. Even when the LDAP is not used, I don't see the point of using setpwent() and setgrent() calls. On local system with /etc/passwd in use, these calls does nothing in fact. For example setpwent() should be used with functions getpwent()/endpwent(), on the other hand, setgrent() is designed to be used with getgrent()/endgrent() functions. I cannot find anything why are these functions used with getpwuid()/getgrgid(). Is there any non-documented behavior? For example nscd is using its own cache and these calls are, again, useless. I cannot determinate why these functions are called. They request additional computation which is not used. In my opinion, these spare calls should be removed. If these calls are useful, why there are no endpwent()/endgrent() calls? Thanks for your response! Best regards, Fridolin Pokorny. ---coreutils_old/src/stat.c 2013-05-24 08:14:35.922027283 +0200 +++ coreutils/src/stat.c 2013-05-24 08:14:56.076101484 +0200 @@ -965,7 +965,6 @@ print_stat (char *pformat, size_t prefix out_uint (pformat, prefix_len, statbuf->st_uid); break; case 'U': - setpwent (); pw_ent = getpwuid (statbuf->st_uid); out_string (pformat, prefix_len, pw_ent ? pw_ent->pw_name : "UNKNOWN"); @@ -974,7 +973,6 @@ print_stat (char *pformat, size_t prefix out_uint (pformat, prefix_len, statbuf->st_gid); break; case 'G': - setgrent (); gw_ent = getgrgid (statbuf->st_gid); out_string (pformat, prefix_len, gw_ent ? gw_ent->gr_name : "UNKNOWN"); From debbugs-submit-bounces@debbugs.gnu.org Fri May 24 13:23:47 2013 Received: (at 14462-done) by debbugs.gnu.org; 24 May 2013 17:23:47 +0000 Received: from localhost ([127.0.0.1]:60611 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UfviV-000744-BP for submit@debbugs.gnu.org; Fri, 24 May 2013 13:23:47 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]:34570) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UfviR-00073h-61 for 14462-done@debbugs.gnu.org; Fri, 24 May 2013 13:23:44 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id B7700A6001D; Fri, 24 May 2013 10:22:40 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fW91cPcsaPqp; Fri, 24 May 2013 10:22:40 -0700 (PDT) Received: from [192.168.1.9] (pool-71-108-49-126.lsanca.fios.verizon.net [71.108.49.126]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 5E658A60019; Fri, 24 May 2013 10:22:40 -0700 (PDT) Message-ID: <519FA1E0.9080303@cs.ucla.edu> Date: Fri, 24 May 2013 10:22:40 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 MIME-Version: 1.0 To: =?UTF-8?B?RnJpZG9sw61uIFBva29ybsO9?= Subject: Re: bug#14462: useless calls of setpwent()/setgrent() in stat References: <1369402376.12421.5.camel@unused-4-242.brq.redhat.com> In-Reply-To: <1369402376.12421.5.camel@unused-4-242.brq.redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 14462-done Cc: 14462-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.3 (-----) On 05/24/2013 06:32 AM, Fridol=C3=ADn Pokorn=C3=BD wrote: > I cannot determinate why these functions are called. Nor I. Thanks, I installed that patch and am marking this as done. From unknown Fri Aug 15 21:25:33 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 22 Jun 2013 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator