GNU bug report logs -
#14462
useless calls of setpwent()/setgrent() in stat
Previous Next
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your bug report
#14462: useless calls of setpwent()/setgrent() in stat
which was filed against the coreutils package, has been closed.
The explanation is attached below, along with your original report.
If you require more details, please reply to 14462 <at> debbugs.gnu.org.
--
14462: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=14462
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
On 05/24/2013 06:32 AM, Fridolín Pokorný wrote:
> I cannot determinate why these functions are called.
Nor I. Thanks, I installed that patch and am marking this as done.
[Message part 3 (message/rfc822, inline)]
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");
This bug report was last modified 12 years and 56 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.