1/* 2 * appl/telnet/libtelnet/forward.c 3 */ 4 5/* 6 * Copyright (c) 1983 Regents of the University of California. 7 * All rights reserved. 8 * 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. 20 */ 21 22 23/* General-purpose forwarding routines. These routines may be put into */ 24/* libkrb5.a to allow widespread use */ 25 26#if defined(KERBEROS) || defined(KRB5) 27#include <stdio.h> 28#include <netdb.h> 29#include <unistd.h> 30#include <krb5.h> 31 32extern char *line; /* see sys_term.c */ 33 34/* Decode, decrypt and store the forwarded creds in the local ccache. */ 35krb5_error_code 36rd_and_store_for_creds(context, auth_context, inbuf, ticket) 37 krb5_context context; 38 krb5_auth_context auth_context; 39 krb5_data *inbuf; 40 krb5_ticket *ticket; 41{ 42 krb5_creds **creds; 43 krb5_error_code retval; 44 char ccname[35]; 45 krb5_ccache ccache = NULL; 46#if 0 47 char *tty; 48#endif 49 50 if ((retval = krb5_rd_cred(context, auth_context, inbuf, &creds, NULL))) 51 return(retval); 52 53 sprintf(ccname, "FILE:/tmp/krb5cc_p%d", getpid()); 54 setenv("KRB5CCNAME", ccname, 1); 55 56 if ((retval = krb5_cc_resolve(context, ccname, &ccache))) 57 goto cleanup; 58 59 if ((retval = krb5_cc_initialize(context, ccache, ticket->enc_part2->client))) 60 goto cleanup; 61 62 if ((retval = krb5_cc_store_cred(context, ccache, *creds))) 63 goto cleanup; 64 65cleanup: 66 krb5_free_creds(context, *creds); 67 return retval; 68} 69 70#endif /* defined(KRB5) && defined(FORWARD) */ 71