Merge pull request #122 from ivladdalvi/nologin-uid

Log UID in nologin
This commit is contained in:
Serge Hallyn 2018-08-13 18:37:02 -05:00 committed by GitHub
commit 6bf2d74dfc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,7 +24,6 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include <config.h>
#ident "$Id$" #ident "$Id$"
@ -36,6 +35,7 @@
int main (void) int main (void)
{ {
const char *user, *tty; const char *user, *tty;
uid_t uid;
tty = ttyname (0); tty = ttyname (0);
if (NULL == tty) { if (NULL == tty) {
@ -45,8 +45,9 @@ int main (void)
if (NULL == user) { if (NULL == user) {
user = "UNKNOWN"; user = "UNKNOWN";
} }
uid = getuid (); /* getuid() is always successful */
openlog ("nologin", LOG_CONS, LOG_AUTH); 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 (); closelog ();
printf ("%s", "This account is currently not available.\n"); printf ("%s", "This account is currently not available.\n");