Sometimes getlogin() may fail, e.g., in a chroot() environment or due to NSS
misconfiguration. Loggin UID allows for investigation and troubleshooting in
such situation.
* SUCH DAMAGE.
*/
-#include <config.h>
#ident "$Id$"
int main (void)
{
const char *user, *tty;
+ uid_t uid;
tty = ttyname (0);
if (NULL == tty) {
if (NULL == user) {
user = "UNKNOWN";
}
+ uid = getuid (); /* getuid() is always successful */
openlog ("nologin", LOG_CONS, LOG_AUTH);
- syslog (LOG_CRIT, "Attempted login by %s on %s", user, tty);
+ syslog (LOG_CRIT, "Attempted login by %s (UID: %d) on %s", user, uid, tty);
closelog ();
printf ("%s", "This account is currently not available.\n");