]> andersk Git - moira.git/blame_incremental - update/smskey.c
Use krb5_error_code for return value of krb5 library functions.
[moira.git] / update / smskey.c
... / ...
CommitLineData
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 */
7
8#include <mit-copyright.h>
9#include <moira.h>
10
11#include <fcntl.h>
12#include <stdio.h>
13#include <string.h>
14#include <unistd.h>
15
16#include <des.h>
17
18RCSID("$Header$");
19
20int debug = 0; /* goddamn des library breakage */
21char string[] = "sms\0\0Athena\0\1";
22char srvtab[] = "/etc/srvtab";
23char insecure[] =
24 "\7\7\7This program MUST be run on the console, for security reasons.\n";
25
26int main(int argc, char **argv)
27{
28 int fd;
29 des_cblock key;
30 char *tty;
31 tty = ttyname(0);
32 if (!tty || strcmp(tty, "/dev/console"))
33 {
34 fprintf(stderr, insecure);
35 exit(1);
36 }
37 fd = open(srvtab, O_WRONLY|O_APPEND, 0);
38 if (!fd)
39 {
40 perror(srvtab);
41 exit(1);
42 }
43 if (sizeof(string) - 1 != 13)
44 {
45 fprintf(stderr, "string size bad\n");
46 exit(1);
47 }
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");
55 exit(0);
56}
This page took 0.031359 seconds and 5 git commands to generate.