1 #include "k5-int.h" 2 3 krb5_error_code KRB5_CALLCONV 4 krb5_cc_copy_creds(krb5_context context, krb5_ccache incc, krb5_ccache outcc) 5 { 6 krb5_error_code code; 7 krb5_flags flags; 8 krb5_cc_cursor cur = 0; 9 krb5_creds creds; 10 11 flags = 0; /* turns off OPENCLOSE mode */ 12 if ((code = krb5_cc_set_flags(context, incc, flags))) 13 return(code); 14 /* the code for this will open the file for reading only, which 15 is not what I had in mind. So I won't turn off OPENCLOSE 16 for the output ccache */ 17 #if 0 18 if ((code = krb5_cc_set_flags(context, outcc, flags))) 19 return(code); 20 #endif 21 22 if ((code = krb5_cc_start_seq_get(context, incc, &cur))) 23 goto cleanup; 24 25 while (!(code = krb5_cc_next_cred(context, incc, &cur, &creds))) { 26 code = krb5_cc_store_cred(context, outcc, &creds); 27 krb5_free_cred_contents(context, &creds); 28 if (code) 29 goto cleanup; 30 } 31 32 if (code != KRB5_CC_END) 33 goto cleanup; 34 35 code = krb5_cc_end_seq_get(context, incc, &cur); 36 cur = 0; 37 if (code) 38 goto cleanup; 39 40 code = 0; 41 42 cleanup: 43 flags = KRB5_TC_OPENCLOSE; 44 45 /* If set then we are in an error pathway */ 46 if (cur) 47 krb5_cc_end_seq_get(context, incc, &cur); 48 49 if (code) 50 krb5_cc_set_flags(context, incc, flags); 51 else 52 code = krb5_cc_set_flags(context, incc, flags); 53 54 #if 0 55 if (code) 56 krb5_cc_set_flags(context, outcc, flags); 57 else 58 code = krb5_cc_set_flags(context, outcc, flags); 59 #endif 60 61 return(code); 62 } 63