shadow/src/nologin.c
Serge Hallyn f93cf255d4 Update licensing info
Closes #238

Update all files to list SPDX license shortname.  Most files are
BSD 3 clause license.

The exceptions are:

serge@sl ~/src/shadow$ git grep SPDX-License | grep -v BSD-3-Clause
contrib/atudel:# SPDX-License-Identifier: BSD-4-Clause
lib/tcbfuncs.c: * SPDX-License-Identifier: 0BSD
libmisc/salt.c: * SPDX-License-Identifier: Unlicense
src/login_nopam.c: * SPDX-License-Identifier: Unlicense
src/nologin.c: * SPDX-License-Identifier: BSD-2-Clause
src/vipw.c: * SPDX-License-Identifier: GPL-2.0-or-later

Signed-off-by: Serge Hallyn <serge@hallyn.com>
2021-12-23 19:36:50 -06:00

42 lines
811 B
C

/*
* SPDX-FileCopyrightText: 2004 The FreeBSD Project.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#ident "$Id$"
#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>
#include <unistd.h>
int main (void)
{
const char *user, *tty;
uid_t uid;
tty = ttyname (0);
if (NULL == tty) {
tty = "UNKNOWN";
}
user = getlogin ();
if (NULL == user) {
user = "UNKNOWN";
}
char *ssh_origcmd = getenv("SSH_ORIGINAL_COMMAND");
uid = getuid (); /* getuid() is always successful */
openlog ("nologin", LOG_CONS, LOG_AUTH);
syslog (LOG_CRIT, "Attempted login by %s (UID: %d) on %s%s%s",
user, uid, tty,
(ssh_origcmd ? " SSH_ORIGINAL_COMMAND=" : ""),
(ssh_origcmd ? ssh_origcmd : ""));
closelog ();
printf ("%s", "This account is currently not available.\n");
return EXIT_FAILURE;
}