dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / lib / gss_mechs / mech_krb5 / krb5 / ccache / cccopy.c
blobf0413e777581b6fcfabb04c2b6c75813ef23eac3
1 #pragma ident "%Z%%M% %I% %E% SMI"
3 #include "k5-int.h"
5 krb5_error_code KRB5_CALLCONV
6 krb5_cc_copy_creds(krb5_context context, krb5_ccache incc, krb5_ccache outcc)
8 krb5_error_code code;
9 krb5_flags flags;
10 krb5_cc_cursor cur = 0;
11 krb5_creds creds;
13 flags = 0; /* turns off OPENCLOSE mode */
14 if ((code = krb5_cc_set_flags(context, incc, flags)))
15 return(code);
16 /* the code for this will open the file for reading only, which
17 is not what I had in mind. So I won't turn off OPENCLOSE
18 for the output ccache */
19 #if 0
20 if ((code = krb5_cc_set_flags(context, outcc, flags)))
21 return(code);
22 #endif
24 if ((code = krb5_cc_start_seq_get(context, incc, &cur)))
25 goto cleanup;
27 while (!(code = krb5_cc_next_cred(context, incc, &cur, &creds))) {
28 code = krb5_cc_store_cred(context, outcc, &creds);
29 krb5_free_cred_contents(context, &creds);
30 if (code)
31 goto cleanup;
34 if (code != KRB5_CC_END)
35 goto cleanup;
37 code = krb5_cc_end_seq_get(context, incc, &cur);
38 cur = 0;
39 if (code)
40 goto cleanup;
42 code = 0;
44 cleanup:
45 flags = KRB5_TC_OPENCLOSE;
47 /* If set then we are in an error pathway */
48 if (cur)
49 krb5_cc_end_seq_get(context, incc, &cur);
51 if (code)
52 krb5_cc_set_flags(context, incc, flags);
53 else
54 code = krb5_cc_set_flags(context, incc, flags);
56 #if 0
57 if (code)
58 krb5_cc_set_flags(context, outcc, flags);
59 else
60 code = krb5_cc_set_flags(context, outcc, flags);
61 #endif
63 return(code);