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