From 97c26c1924b076ef23ebe4381558e8aa025712b2 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 16:54:37 +0200 Subject: Adding upstream version 1:4.13+dfsg1. Signed-off-by: Daniel Baumann --- src/nologin.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/nologin.c (limited to 'src/nologin.c') diff --git a/src/nologin.c b/src/nologin.c new file mode 100644 index 0000000..a744281 --- /dev/null +++ b/src/nologin.c @@ -0,0 +1,41 @@ +/* + * SPDX-FileCopyrightText: 2004 The FreeBSD Project. + * + * SPDX-License-Identifier: BSD-2-Clause + */ + + +#ident "$Id$" + +#include +#include +#include +#include + +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; +} -- cgit v1.2.3