]> andersk Git - moira.git/blob - incremental/ksrvtgt.c
Diane Delgado's changes for a fixed table-locking order
[moira.git] / incremental / ksrvtgt.c
1 /*
2  * $Source$
3  * $Author$
4  *
5  * Copyright 1988 by the Massachusetts Institute of Technology. 
6  *
7  * For copying and distribution information, please see the file
8  * <mit-copyright.h>. 
9  *
10  * Get a ticket-granting-ticket given a service key file (srvtab)
11  * Modifed from the regular kerberos distribution in that it accepts
12  * the lifetime of the ticket as an command-line argument.
13  *
14  */
15
16 #include <stdio.h>
17 #include <sys/param.h>
18 #include <krb.h>
19 /*#include <conf.h>*/
20
21 char rcsid[] =
22     "$Header$";
23
24
25 void usage(argv)
26 char **argv;
27 {
28     fprintf(stderr,
29             "Usage: %s name instance [-r realm] [-s srvtab] [-l lifetime]\n",
30             argv[0]);
31     exit(1);
32 }
33
34
35 main(argc,argv)
36     int argc;
37     char **argv;
38 {
39     char realm[REALM_SZ + 1];
40     register int code;
41     int i, lifetime = 1;
42     char srvtab[MAXPATHLEN + 1];
43
44     bzero(realm, sizeof(realm));
45     bzero(srvtab, sizeof(srvtab));
46
47     if (argc < 3)
48       usage(argv);
49
50     for (i = 3; i < argc; i++) {
51         if (argv[i][0] != '-')
52           usage(argv);
53         switch (argv[i][1]) {
54         case 'r':
55             if (i + 1 >= argc)
56               usage(argv);
57             strncpy(realm, argv[i++ + 1], sizeof(realm) - 1);
58             break;
59         case 's':
60             if (i + 1 >= argc)
61               usage(argv);
62             strncpy(srvtab, argv[i++ + 1], sizeof(srvtab) - 1);
63             break;
64         case 'l':
65             if (i + 1 >= argc)
66               usage(argv);
67             lifetime = atoi(argv[i++ + 1]);
68             if (lifetime < 5)
69               lifetime = 1;
70             else
71               lifetime /= 5;
72             if (lifetime > 255)
73               lifetime = 255;
74             break;
75         default:
76             usage();
77         }
78     }
79
80     if (srvtab[0] == 0)
81         (void) strcpy(srvtab, KEYFILE);
82
83     if (realm[0] == 0)
84         if (krb_get_lrealm(realm, 1) != KSUCCESS)
85             (void) strcpy(realm, KRB_REALM);
86
87     code = krb_get_svc_in_tkt(argv[1], argv[2], realm,
88                               "krbtgt", realm, lifetime, srvtab);
89     if (code)
90         fprintf(stderr, "%s\n", krb_err_txt[code]);
91     exit(code);
92 }
93
This page took 0.144608 seconds and 5 git commands to generate.