]>
Commit | Line | Data |
---|---|---|
546bc43b | 1 | /* $Header$ */ |
2 | ||
3 | /* (c) Copyright 1988 by the Massachusetts Institute of Technology. */ | |
4 | /* For copying and distribution information, please see the file */ | |
5 | /* <mit-copyright.h>. */ | |
6 | ||
7 | ||
8 | #include <mit-copyright.h> | |
7effed7d | 9 | #include <stdio.h> |
10 | #include <sys/file.h> | |
424ea315 | 11 | #include <fcntl.h> |
7effed7d | 12 | #include <des.h> |
5eaef520 | 13 | int debug = 0; /* goddamn des library breakage */ |
7effed7d | 14 | char string[] = "sms\0\0Athena\0\1"; |
15 | char srvtab[] = "/etc/srvtab"; | |
16 | char insecure[] = | |
17 | "\7\7\7This program MUST be run on the console, for security reasons.\n"; | |
18 | ||
5eaef520 | 19 | int main(int argc, char **argv) |
7effed7d | 20 | { |
5eaef520 | 21 | int fd; |
22 | C_Block key; | |
23 | char *tty, *ttyname(); | |
24 | tty = ttyname(0); | |
25 | if (!tty || strcmp(tty, "/dev/console")) | |
26 | { | |
27 | fprintf(stderr, insecure); | |
28 | exit(1); | |
7effed7d | 29 | } |
5eaef520 | 30 | fd = open(srvtab, O_WRONLY|O_APPEND, 0); |
31 | if (!fd) | |
32 | { | |
33 | perror(srvtab); | |
34 | exit(1); | |
7effed7d | 35 | } |
5eaef520 | 36 | if (sizeof(string) - 1 != 13) |
37 | { | |
38 | fprintf(stderr, "string size bad\n"); | |
39 | exit(1); | |
7effed7d | 40 | } |
5eaef520 | 41 | des_read_password(key, "Enter SMS update password: ", 0); |
42 | write(fd, string, sizeof(string) - 1); | |
43 | write(fd, key, sizeof(C_Block)); | |
44 | if (fsync(fd)) | |
45 | perror(srvtab); | |
46 | close(fd); | |
47 | printf("\nKey written.\n"); | |
7effed7d | 48 | } |