Prompted by tedu@'s recent reply, here's a fix for getent(1) to lookup keys as UIDs only if the username lookup fails to prevent clobbering numerical usernames.
$ getent passwd 1000 kn kn:*:1000:1000:Klemens Nanni:/home/kn:/bin/ksh kn:*:1000:1000:Klemens Nanni:/home/kn:/bin/ksh $ ./obj/getent passwd 1000 kn 1000:*:1003:1003::/home/1000:/bin/ksh kn:*:1000:1000:Klemens Nanni:/home/kn:/bin/ksh OK? Index: getent.c =================================================================== RCS file: /cvs/src/usr.bin/getent/getent.c,v retrieving revision 1.20 diff -u -p -r1.20 getent.c --- getent.c 26 Sep 2018 16:39:19 -0000 1.20 +++ getent.c 1 Nov 2018 21:51:01 -0000 @@ -302,11 +302,11 @@ passwd(int argc, char *argv[]) PASSWDPRINT; } else { for (i = 2; i < argc; i++) { - uid = strtonum(argv[i], 0, UID_MAX, &err); - if (!err) - pw = getpwuid(uid); - else - pw = getpwnam(argv[i]); + if ((pw = getpwnam(argv[i])) == NULL) { + uid = strtonum(argv[i], 0, UID_MAX, &err); + if (err == NULL) + pw = getpwuid(uid); + } if (pw != NULL) PASSWDPRINT; else {