2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
5 #include "gssapiP_krb5.h"
7 OM_uint32 KRB5_CALLCONV
8 gss_krb5int_copy_ccache(minor_status
, cred_handle
, out_ccache
)
9 OM_uint32
*minor_status
;
10 gss_cred_id_t cred_handle
;
11 krb5_ccache out_ccache
;
14 krb5_gss_cred_id_t k5creds
;
15 krb5_cc_cursor cursor
;
20 /* validate the cred handle */
21 stat
= krb5_gss_validate_cred(minor_status
, cred_handle
);
25 k5creds
= (krb5_gss_cred_id_t
) cred_handle
;
26 code
= k5_mutex_lock(&k5creds
->lock
);
31 if (k5creds
->usage
== GSS_C_ACCEPT
) {
32 k5_mutex_unlock(&k5creds
->lock
);
33 *minor_status
= (OM_uint32
) G_BAD_USAGE
;
34 return(GSS_S_FAILURE
);
37 code
= krb5_gss_init_context(&context
);
39 k5_mutex_unlock(&k5creds
->lock
);
44 code
= krb5_cc_start_seq_get(context
, k5creds
->ccache
, &cursor
);
46 k5_mutex_unlock(&k5creds
->lock
);
48 save_error_info(*minor_status
, context
);
49 krb5_free_context(context
);
50 return(GSS_S_FAILURE
);
52 while (!code
&& !krb5_cc_next_cred(context
, k5creds
->ccache
, &cursor
, &creds
))
53 code
= krb5_cc_store_cred(context
, out_ccache
, &creds
);
54 krb5_cc_end_seq_get(context
, k5creds
->ccache
, &cursor
);
55 k5_mutex_unlock(&k5creds
->lock
);
56 krb5_free_context(context
);
59 save_error_info(*minor_status
, context
);
60 return(GSS_S_FAILURE
);
63 return(GSS_S_COMPLETE
);