1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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;
}
|