For clarity there are 4 pathes, the first 3 can be applied independently of each other and the fourth ties them together so that there is only one call to getpwnam in all of qpopper (not counting popauth.c)
genp_cleanup.patch just joins the three different genpath versions into one function, this just saves of some repetition of error checking and returning, I think there is quite a bit of other stuff in common between the 4 different methods but I made no attempt to sort that out as I wanted to change as little as possible. This involved cutting and pasting so hopefully nothing broke! Also GNPH_TMP doesn't seem to be used by anything...
pw_cleanup.patch inserts the pw member in the POP structure, this is then populated in pop_user. This means there is only one passwd file lookup going on in popper/*.c, there is still one in common/genpath.c
lock_mod.patch changed Qmaillock to take the filename as an argument rather than the user name. The results of genpath were already being cached in p->drop_name so this avoids calling genpath again and removes another dependency on looking up the passwd file.
Any of the above patches can be applied without the others, they all do independent clean up work. The last patch needs the others to really make sense.
one_getpwnam.patch changes genpath to take a passwd struct instead of just a username, this eliminates the final getpwnam.