While debugging tests for a pinky PR (#3155), I saw some inconsistent behavior between GNU's users and who utils vs. ours. The PR adds a fake entry to the system's utmp file, since the GitHub CI runner doesn't log in to any accounts, so pinky wasn't displaying anything during testing and letting bugs slip through. Once that was working, our versions of users and who started displaying the runner from the fake entry, but GNU's still does not. I ran strace on them on my local system, and noticed that the GNU versions call kill($PID, 0), where $PID is the PID of the login shell associated with that user. I suspect that the GNU versions aren't taking utmp at its word, and are checking the return value of this kill() call to double check that the user from the login entry is still running a login shell. The fake entry added in #3155 gives a fake, very high (and therefore unlikely to be used in the span of a GH CI run) PID, so the check fails for GNU, but looks fine to ours.
To fix this, we need to:
The last step, adding the additional utmp entry, is necessary because without it, users and who are suffering from the same problem pinky was (no command output = behavior is mostly untested), but we can't just change the existing one lest this bug return.
While debugging tests for a
pinkyPR (#3155), I saw some inconsistent behavior between GNU'susersandwhoutils vs. ours. The PR adds a fake entry to the system's utmp file, since the GitHub CI runner doesn't log in to any accounts, sopinkywasn't displaying anything during testing and letting bugs slip through. Once that was working, our versions ofusersandwhostarted displaying the runner from the fake entry, but GNU's still does not. I ran strace on them on my local system, and noticed that the GNU versions callkill($PID, 0), where$PIDis the PID of the login shell associated with that user. I suspect that the GNU versions aren't taking utmp at its word, and are checking the return value of thiskill()call to double check that the user from the login entry is still running a login shell. The fake entry added in #3155 gives a fake, very high (and therefore unlikely to be used in the span of a GH CI run) PID, so the check fails for GNU, but looks fine to ours.To fix this, we need to:
userscheck the login PID is still runningwhocheck the login PID is still runningThe last step, adding the additional utmp entry, is necessary because without it,
usersandwhoare suffering from the same problempinkywas (no command output = behavior is mostly untested), but we can't just change the existing one lest this bug return.