diff options
| author | Lain Iwakura <lain@iwakurahome.ru> | 2025-10-15 14:43:47 +0300 |
|---|---|---|
| committer | Lain Iwakura <lain@iwakurahome.ru> | 2025-10-15 14:43:47 +0300 |
| commit | 405c749fed4827b758384a60dd164efd2b3cf489 (patch) | |
| tree | 4883ebcfd453f36a5ffd838f599eeb191246c964 | |
| download | no_login-405c749fed4827b758384a60dd164efd2b3cf489.tar.gz no_login-405c749fed4827b758384a60dd164efd2b3cf489.zip | |
meow
Diffstat (limited to '')
| -rw-r--r-- | no_shell.c | 39 |
1 files changed, 39 insertions, 0 deletions
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 <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <syslog.h> + +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; +} |