Annotation of 43BSDReno/kerberosIV/make_keypair/make_keypair.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1989 The Regents of the University of California.
                      3:  * All rights reserved.
                      4:  *
                      5:  * Redistribution and use in source and binary forms are permitted
                      6:  * provided that the above copyright notice and this paragraph are
                      7:  * duplicated in all such forms and that any documentation,
                      8:  * advertising materials, and other materials related to such
                      9:  * distribution and use acknowledge that the software was developed
                     10:  * by the University of California, Berkeley.  The name of the
                     11:  * University may not be used to endorse or promote products derived
                     12:  * from this software without specific prior written permission.
                     13:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
                     14:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
                     15:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     16:  */
                     17: 
                     18: #ifndef lint
                     19: static char sccsid[] = "@(#)make_keypair.c     1.5 (Berkeley) 6/25/90";
                     20: #endif /* not lint */
                     21: 
                     22: #include <sys/types.h>
                     23: #include <sys/file.h>
                     24: #include <netinet/in.h>
                     25: #include <stdio.h>
                     26: #include <netdb.h>
                     27: #include <kerberosIV/des.h>
                     28: #include <kerberosIV/krb.h>
                     29: #include "pathnames.h"
                     30: #include "register_proto.h"
                     31: 
                     32: extern void random_key(), herror();
                     33: void make_key(), usage();
                     34: 
                     35: main(argc, argv)
                     36:        int     argc;
                     37:        char    **argv;
                     38: {
                     39:        struct hostent  *hp;
                     40:        char            *addr;
                     41:        int             i;
                     42:        struct sockaddr_in      sin;
                     43: 
                     44:        if (argc != 2) {
                     45:                usage(argv[0]);
                     46:                exit(1);
                     47:        }
                     48: 
                     49:        if ((hp = gethostbyname(argv[1])) == NULL) {
                     50:                herror(argv[1]);
                     51:                exit(1);
                     52:        }
                     53: 
                     54:        for (i = 0; addr = hp->h_addr_list[i]; i++) {
                     55:                addr = hp->h_addr_list[i];
                     56:                bcopy(addr, &sin.sin_addr, hp->h_length);
                     57: 
                     58:                printf("Making key for host %s (%s)\n",
                     59:                        argv[1], inet_ntoa(sin.sin_addr));
                     60:                make_key(sin.sin_addr);
                     61:        }
                     62:        printf("==========\n");
                     63:        printf("One copy of the each key should be put in %s on the\n",
                     64:                SERVER_KEYDIR);
                     65:        printf("Kerberos server machine (mode 600, owner root).\n");
                     66:        printf("Another copy of each key should be put on the named\n");
                     67:        printf("client as %sXXX.XXX.XXX.XXX (same modes as above),\n",
                     68:                CLIENT_KEYFILE);
                     69:        printf("where the X's refer to digits of the host's inet address.\n");
                     70:        (void)fflush(stdout);
                     71:        exit(0);
                     72: }
                     73: 
                     74: void
                     75: make_key(addr)
                     76:        struct in_addr  addr;
                     77: {
                     78:        struct keyfile_data     kfile;
                     79:        char            namebuf[255];
                     80:        int             fd;
                     81: 
                     82:        (void)sprintf(namebuf, ".%s%s",
                     83:                CLIENT_KEYFILE,
                     84:                inet_ntoa(addr));
                     85:        fd = open(namebuf, O_WRONLY|O_CREAT, 0600);
                     86:        if (fd < 0) {
                     87:                perror("open");
                     88:                exit(1);
                     89:        }
                     90:        random_key(kfile.kf_key);
                     91:        printf("writing to file -> %s ...", namebuf);
                     92:        if (write(fd, &kfile, sizeof(kfile)) != sizeof(kfile)) {
                     93:                fprintf(stderr, "error writing file %s\n", namebuf);
                     94:        }
                     95:        printf("done.\n");
                     96:        (void)close(fd);
                     97:        return;
                     98: }
                     99: 
                    100: void
                    101: usage(name)
                    102:        char    *name;
                    103: {
                    104:        fprintf(stderr, "usage: %s host\n", name);
                    105: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.