]> andersk Git - moira.git/blob - update/smskey.c
assume POSIX
[moira.git] / update / smskey.c
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>
9 #include <stdio.h>
10 #include <sys/file.h>
11 #include <fcntl.h>
12 #include <des.h>
13 int debug=0;                    /* goddamn des library breakage */
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
19 main(argc,argv)
20     int argc;
21     char **argv;
22 {
23     int fd;
24     C_Block key;
25     char *tty, *ttyname();
26     tty = ttyname(0);
27     if (!tty || strcmp(tty, "/dev/console")) {
28         fprintf(stderr, insecure);
29         exit(1);
30     }
31     fd = open(srvtab, O_WRONLY|O_APPEND, 0);
32     if (!fd) {
33         perror(srvtab);
34         exit(1);
35     }
36     if (sizeof(string)-1 != 13) {
37         fprintf(stderr, "string size bad\n");
38         exit(1);
39     }
40     des_read_password(key, "Enter SMS update password: ", 0);
41     write(fd, string, sizeof(string)-1);
42     write(fd, key, sizeof(C_Block));
43     if (fsync(fd))
44         perror(srvtab);
45     close(fd);
46     printf("\nKey written.\n");
47 }
This page took 0.046491 seconds and 5 git commands to generate.