summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Src/Modules/stat.c24
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 <pws@csr.com>
+
+ * 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 <wayned@users.sourceforge.net>
* 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, ")");
}