]>
Commit | Line | Data |
---|---|---|
7effed7d | 1 | #include <stdio.h> |
2 | #include <sys/file.h> | |
3 | #include <des.h> | |
4 | int debug=0; /* goddamn des library breakage */ | |
5 | char string[] = "sms\0\0Athena\0\1"; | |
6 | char srvtab[] = "/etc/srvtab"; | |
7 | char insecure[] = | |
8 | "\7\7\7This program MUST be run on the console, for security reasons.\n"; | |
9 | ||
10 | main(argc,argv) | |
11 | int argc; | |
12 | char **argv; | |
13 | { | |
14 | int fd; | |
15 | C_Block key; | |
16 | char *tty, *ttyname(); | |
17 | tty = ttyname(0); | |
18 | if (!tty || strcmp(tty, "/dev/console")) { | |
19 | fprintf(stderr, insecure); | |
20 | exit(1); | |
21 | } | |
22 | fd = open(srvtab, O_WRONLY|O_APPEND, 0); | |
23 | if (!fd) { | |
24 | perror(srvtab); | |
25 | exit(1); | |
26 | } | |
27 | if (sizeof(string)-1 != 13) { | |
28 | fprintf(stderr, "string size bad\n"); | |
29 | exit(1); | |
30 | } | |
31 | des_read_password(key, "Enter SMS update password: ", 0); | |
32 | write(fd, string, sizeof(string)-1); | |
33 | write(fd, key, sizeof(C_Block)); | |
34 | if (fsync(fd)) | |
35 | perror(srvtab); | |
36 | close(fd); | |
37 | printf("\nKey written.\n"); | |
38 | } |