top: enable foreign users under 'u'/'U' task filtering
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>
This commit is contained in:
parent
9f4e72b208
commit
7b1f8fb173
11
top/top.c
11
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;
|
||||
|
Loading…
Reference in New Issue
Block a user