source: trunk/athena/bin/rkinit/lib/rk_lib.c @ 12350

Revision 12350, 2.6 KB checked in by ghudson, 26 years ago (diff)
Some RCS ID cleanup: delete $Log$ and replace other RCS keywords with $Id$.
Line 
1/*
2 * $Id: rk_lib.c,v 1.5 1999-01-22 23:15:04 ghudson Exp $
3 *
4 * This file contains the non-rpc top-level rkinit library routines.
5 * The routines in the rkinit library that should be called from clients
6 * are exactly those defined in this file.
7 *
8 * The naming convetions used within the rkinit library are as follows:
9 * Functions intended for general client use start with rkinit_
10 * Functions intended for use only inside the library or server start with
11 * rki_
12 * Functions that do network communcation start with rki_rpc_
13 * Static functions can be named in any fashion.
14 */
15
16#if !defined(lint) && !defined(SABER) && !defined(LOCORE) && defined(RCS_HDRS)
17static char *rcsid = "$Id: rk_lib.c,v 1.5 1999-01-22 23:15:04 ghudson Exp $";
18#endif /* lint || SABER || LOCORE || RCS_HDRS */
19
20#include <stdio.h>
21#include <string.h>
22#include <setjmp.h>
23#include <krb.h>
24
25#ifdef SYSV
26#include <netdb.h>
27#endif
28#include <rkinit.h>
29#include <rkinit_private.h>
30#include <rkinit_err.h>
31
32#ifdef __STDC__
33char *rkinit_errmsg(char *string)
34#else
35char *rkinit_errmsg(string)
36  char *string;
37#endif /* __STDC__ */
38{
39    static char errmsg[BUFSIZ];
40
41    if (string) {
42        BCLEAR(errmsg);
43        strncpy(errmsg, string, sizeof(errmsg) - 1);
44    }
45
46    return(errmsg);
47}
48
49#ifdef __STDC__
50int rkinit(char *host, char *r_krealm, rkinit_info *info, int timeout)
51#else
52int rkinit(host, r_krealm, info, timeout)
53  char *host;
54  char *r_krealm;
55  rkinit_info *info;
56  int timeout;
57#endif /* __STDC__ */
58{
59    int status = RKINIT_SUCCESS;
60    int version = 0;
61    char phost[MAXHOSTNAMELEN];
62    jmp_buf timeout_env;
63    int (*old_alrm)();
64    char origtktfilename[MAXPATHLEN]; /* original ticket file name */
65    char tktfilename[MAXPATHLEN]; /* temporary client ticket file */
66
67    extern int (*rki_setup_timer())();
68    extern void rki_restore_timer();
69    extern void rki_cleanup_rpc();
70
71    BCLEAR(phost);
72    BCLEAR(origtktfilename);
73    BCLEAR(tktfilename);
74    BCLEAR(timeout_env);
75
76    initialize_rkin_error_table();
77
78    if (status = rki_setup_rpc(host))
79        return(status);
80
81    /* The alarm handler longjmps us to here. */
82    if ((status = setjmp(timeout_env)) == 0) {
83
84        strcpy(origtktfilename, tkt_string());
85        sprintf(tktfilename, "/tmp/tkt_rkinit.%d", getpid());
86        krb_set_tkt_string(tktfilename);
87
88        if (timeout)
89            old_alrm = rki_setup_timer(timeout_env);
90       
91        if ((status = rki_choose_version(&version)) == RKINIT_SUCCESS)
92            status = rki_get_tickets(version, host, r_krealm, info);
93    }
94   
95    if (timeout)
96        rki_restore_timer(old_alrm);
97
98    dest_tkt();
99    krb_set_tkt_string(origtktfilename);
100
101    rki_cleanup_rpc();
102
103    return(status);
104}
Note: See TracBrowser for help on using the repository browser.