2 * appl/telnet/libtelnet/forward.c
6 * Copyright (c) 1983 Regents of the University of California.
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)
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. */
38 rd_and_store_for_creds(context
, auth_context
, inbuf
, ticket
)
40 krb5_auth_context auth_context
;
45 krb5_error_code retval
;
47 krb5_ccache ccache
= NULL
;
49 if ((retval
= krb5_rd_cred(context
, auth_context
, inbuf
, &creds
, NULL
)) != 0)
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)
58 if ((retval
= krb5_cc_initialize(context
, ccache
, ticket
->enc_part2
->client
)) != 0)
61 if ((retval
= krb5_cc_store_cred(context
, ccache
, *creds
)) != 0)
65 krb5_free_creds(context
, *creds
);
69 #endif /* defined(KRB5) && defined(FORWARD) */