Remove building with NOCRYPTO option
[minix3.git] / lib / libtelnet / forward.c
blobb97418dbcab725eaf337f90754a1be71668eac84
1 /*
2 * appl/telnet/libtelnet/forward.c
3 */
5 /*
6 * Copyright (c) 1983 Regents of the University of California.
7 * All rights reserved.
9 * Redistribution and use in source and binary forms are permitted
10 * provided that the above copyright notice and this paragraph are
11 * duplicated in all such forms and that any documentation,
12 * advertising materials, and other materials related to such
13 * distribution and use acknowledge that the software was developed
14 * by the University of California, Berkeley. The name of the
15 * University may not be used to endorse or promote products derived
16 * from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
19 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
23 /* General-purpose forwarding routines. These routines may be put into */
24 /* libkrb5.a to allow widespread use */
26 #if defined(KERBEROS) || defined(KRB5)
27 #include <stdio.h>
28 #include <netdb.h>
30 #include "k5-int.h"
32 extern char *line; /* see sys_term.c */
34 krb5_error_code rd_and_store_for_creds(krb5_context, krb5_auth_context, krb5_data *, krb5_ticket *);
36 /* Decode, decrypt and store the forwarded creds in the local ccache. */
37 krb5_error_code
38 rd_and_store_for_creds(context, auth_context, inbuf, ticket)
39 krb5_context context;
40 krb5_auth_context auth_context;
41 krb5_data *inbuf;
42 krb5_ticket *ticket;
44 krb5_creds **creds;
45 krb5_error_code retval;
46 char ccname[35];
47 krb5_ccache ccache = NULL;
49 if ((retval = krb5_rd_cred(context, auth_context, inbuf, &creds, NULL)) != 0)
50 return(retval);
52 snprintf(ccname, sizeof(ccname), "FILE:/tmp/krb5cc_p%d", getpid());
53 setenv(KRB5_ENV_CCNAME, ccname, 1);
55 if ((retval = krb5_cc_resolve(context, ccname, &ccache)) != 0)
56 goto cleanup;
58 if ((retval = krb5_cc_initialize(context, ccache, ticket->enc_part2->client)) != 0)
59 goto cleanup;
61 if ((retval = krb5_cc_store_cred(context, ccache, *creds)) != 0)
62 goto cleanup;
64 cleanup:
65 krb5_free_creds(context, *creds);
66 return retval;
69 #endif /* defined(KRB5) && defined(FORWARD) */