summaryrefslogtreecommitdiffstats
path: root/src/nologin.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 14:54:37 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 14:54:37 +0000
commit97c26c1924b076ef23ebe4381558e8aa025712b2 (patch)
tree109724175f07436696f51b14b5abbd3f4d704d6d /src/nologin.c
parentInitial commit. (diff)
downloadshadow-97c26c1924b076ef23ebe4381558e8aa025712b2.tar.xz
shadow-97c26c1924b076ef23ebe4381558e8aa025712b2.zip
Adding upstream version 1:4.13+dfsg1.upstream/1%4.13+dfsg1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/nologin.c')
-rw-r--r--src/nologin.c41
1 files changed, 41 insertions, 0 deletions
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 <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;
+}