]> granicus.if.org Git - procps-ng/commitdiff
top: enable foreign users under 'u'/'U' task filtering
authorJim Warner <james.warner@comcast.net>
Tue, 18 Dec 2012 06:00:00 +0000 (00:00 -0600)
committerCraig Small <csmall@enc.com.au>
Sat, 22 Dec 2012 06:10:12 +0000 (17:10 +1100)
This commit will allow user filtering as long as there
is a valid number representing a potential user ID. It
will serve, for example, chroot environments where the
specific user may be unknown to a host, or vice versa.

(now that we know a '.' + 2 spaces is squeezed to one)
(everything's perfectly justified, but it's just luck)

Reference(s):
http://www.freelists.org/post/procps/top-enhancements-i-hope,1

Signed-off-by: Jim Warner <james.warner@comcast.net>
top/top.c

index ea64770c11b5466d60d50babadf5284a51c2ddb7..1786ab102a5d7bcffc6dfb2dc4a256ace4306e59 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -1174,9 +1174,16 @@ static const char *user_certify (WIN_t *q, const char *str, char typ) {
    Monpidsidx = 0;
    if (*str) {
       num = (uid_t)strtoul(str, &endp, 0);
-      if ('\0' == *endp)
+      if ('\0' == *endp) {
          pwd = getpwuid(num);
-      else
+         if (!pwd) {
+         /* allow foreign users, from e.g within chroot
+          ( thanks Dr. Werner Fink <werner@suse.de> ) */
+            q->usrseluid = num;
+            q->usrseltyp = typ;
+            return NULL;
+         }
+      } else
          pwd = getpwnam(str);
       if (!pwd) return N_txt(BAD_username_txt);
       q->usrseluid = pwd->pw_uid;