From 7a389a2fc3bd8a7884f7703bee606f829b408fc2 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 19 Dec 2005 11:35:40 +0000 Subject: 22082: print out uid or gid in stat if name not available --- ChangeLog | 5 +++++ Src/Modules/stat.c | 24 ++++++++++++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index f66e4cf96..57c670d58 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-12-19 Peter Stephenson + + * 22082: Src/Modules/stat.c: print out UID or GID instead + of ??? if the user or group name is unavailable. + 2005-12-18 Wayne Davison * unposted: Etc/FAQ.yo, Zsh/contrib.yo: Changed some UTF-8 diff --git a/Src/Modules/stat.c b/Src/Modules/stat.c index 188b37fc7..01a050703 100644 --- a/Src/Modules/stat.c +++ b/Src/Modules/stat.c @@ -140,10 +140,16 @@ statuidprint(uid_t uid, char *outbuf, int flags) #ifdef HAVE_GETPWUID struct passwd *pwd; pwd = getpwuid(uid); - strcat(outbuf, pwd ? pwd->pw_name : "???"); -#else /* !HAVE_GETPWUID */ - strcat(outbuf, "???"); + if (pwd) + strcat(outbuf, pwd->pw_name); + else #endif /* !HAVE_GETPWUID */ + { + char *optr; + for (optr = outbuf; *optr; optr++) + ; + sprintf(optr, "%lu", (unsigned long)uid); + } if (flags & STF_RAW) strcat(outbuf, ")"); } @@ -163,10 +169,16 @@ statgidprint(gid_t gid, char *outbuf, int flags) #ifdef HAVE_GETGRGID struct group *gr; gr = getgrgid(gid); - strcat(outbuf, gr ? gr->gr_name : "???"); -#else /* !HAVE_GETGRGID */ - strcat(outbuf, "???"); + if (gr) + strcat(outbuf, gr->gr_name); + else #endif /* !HAVE_GETGRGID */ + { + char *optr; + for (optr = outbuf; *optr; optr++) + ; + sprintf(optr, "%lu", (unsigned long)gid); + } if (flags & STF_RAW) strcat(outbuf, ")"); } -- cgit 1.4.1