From 405c749fed4827b758384a60dd164efd2b3cf489 Mon Sep 17 00:00:00 2001 From: Lain Iwakura Date: Wed, 15 Oct 2025 14:43:47 +0300 Subject: meow --- no_shell.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 no_shell.c (limited to 'no_shell.c') diff --git a/no_shell.c b/no_shell.c new file mode 100644 index 0000000..a06c10a --- /dev/null +++ b/no_shell.c @@ -0,0 +1,39 @@ +/* /usr/local/sbin/no_shell + friendly restricted shell for my mail server with optional password change + version v3.1 +*/ + +#include +#include +#include +#include + +int main(void) { + const char *username = getenv("USER"); + if (!username || !*username) + username = "(unknown)"; + + fputs("No-no-no, no shell for you\n", stdout); + fputs("For shell access contact lain@lainmail.xyz\n\n", stdout); + printf("Would you like to change your password, %s? [y/N]: ", username); + fflush(stdout); + + char choice = 0; + scanf(" %c", &choice); + + openlog("no_shell", LOG_PID | LOG_NDELAY, LOG_AUTH); + syslog(LOG_NOTICE, "login attempt for %s", username); + closelog(); + + if (choice == 'y' || choice == 'Y') { + printf("\nStarting password change for %s...\n\n", username); + fflush(stdout); + execl("/usr/bin/passwd", "passwd", username, (char *)NULL); + perror("execl"); + exit(1); + } + + printf("\nOkay, goodbye!\n"); + fflush(stdout); + return 2; +} -- cgit 1.4.1-2-gfad0