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>
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;