Debian Codegraph @

lib/gssapi/mech/gss_add_cred_with_password.c

raw symbols SCIP
1 /*-
2 * Copyright (c) 2005 Doug Rabson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: src/lib/libgssapi/gss_add_cred.c,v 1.1 2005/12/29 14:40:20 dfr Exp $
27 */
28
29 #include "mech_locl.h"cxx . . $ `<file>/lib/gssapi/mech/mech_locl.h`/
30
31 GSSAPI_LIB_FUNCTIONcxx . . $ `lib/gssapi/gssapi/gssapi.h:50:9`! OM_uint32cxx . . $ OM_uint32# GSSAPI_LIB_CALLcxx . . $ `lib/gssapi/gssapi/gssapi.h:51:9`!
32 gss_add_cred_with_passwordcxx . . $ gss_add_cred_with_password(8e3313272d9201b6).(OM_uint32cxx . . $ OM_uint32# *minor_status,
33 gss_const_cred_id_tcxx . . $ gss_const_cred_id_t# input_cred_handle,
34 gss_const_name_tcxx . . $ gss_const_name_t# desired_name,
35 const gss_OIDcxx . . $ gss_OID# desired_mech,
36 const gss_buffer_tcxx . . $ gss_buffer_t# password,
37 gss_cred_usage_tcxx . . $ gss_cred_usage_t# cred_usage,
38 OM_uint32cxx . . $ OM_uint32# initiator_time_req,
39 OM_uint32cxx . . $ OM_uint32# acceptor_time_req,
40 gss_cred_id_tcxx . . $ gss_cred_id_t# *output_cred_handle,
41 gss_OID_setcxx . . $ gss_OID_set# *actual_mechs,
42 OM_uint32cxx . . $ OM_uint32# *initiator_time_rec,
43 OM_uint32cxx . . $ OM_uint32# *acceptor_time_rec)
44 {
45 OM_uint32cxx . . $ OM_uint32# major_status;
46 gssapi_mech_interfacecxx . . $ gssapi_mech_interface# m;
47 struct _gss_credcxx . . $ _gss_cred# *cred = (struct _gss_credcxx . . $ _gss_cred# *) input_cred_handle;
48 struct _gss_credcxx . . $ _gss_cred# *new_cred;
49 struct _gss_mechanism_credcxx . . $ _gss_mechanism_cred# *mc;
50 struct _gss_mechanism_namecxx . . $ _gss_mechanism_name# *mn = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
51 OM_uint32cxx . . $ OM_uint32# junk, time_req;
52
53 *minor_status = 0;
54 *output_cred_handle = GSS_C_NO_CREDENTIALcxx . . $ `lib/gssapi/gssapi/gssapi.h:219:9`!;
55 if (initiator_time_rec)
56 *initiator_time_rec = 0;
57 if (acceptor_time_rec)
58 *acceptor_time_rec = 0;
59 if (actual_mechs)
60 *actual_mechs = GSS_C_NO_OID_SETcxx . . $ `lib/gssapi/gssapi/gssapi.h:217:9`!;
61
62 m = __gss_get_mechanismcxx . . $ __gss_get_mechanism(9dbf46ac18a4fc51).(desired_mech);
63 if (m == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
64 *minor_status = 0;
65 return (GSS_S_BAD_MECHcxx . . $ `lib/gssapi/gssapi/gssapi.h:428:9`!);
66 }
67
68 new_cred = calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, sizeof(struct _gss_credcxx . . $ _gss_cred#));
69 if (new_cred == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
70 *minor_status = ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!;
71 return (GSS_S_FAILUREcxx . . $ `lib/gssapi/gssapi/gssapi.h:442:9`!);
72 }
73 HEIM_SLIST_INITcxx . . $ `lib/gssapi/mech/mechqueue.h:56:9`!(&new_cred->gc_mc);
74
75 /*
76 * Copy credentials from un-desired mechanisms to the new credential.
77 */
78 if (cred) {
79 HEIM_SLIST_FOREACHcxx . . $ `lib/gssapi/mech/mechqueue.h:87:9`!(mc, &cred->gc_mc, gmc_link) {
80 struct _gss_mechanism_credcxx . . $ _gss_mechanism_cred# *copy_mc;
81
82 if (gss_oid_equalcxx . . $ gss_oid_equal(a74df30558aacfd0).(mc->gmc_mech_oidcxx . . $ _gss_mechanism_cred#gmc_mech_oid., desired_mech)) {
83 continue;
84 }
85 copy_mc = _gss_copy_credcxx . . $ _gss_copy_cred(92bd8432b06c4b78).(mc);
86 if (copy_mc == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) {
87 gss_release_credcxx . . $ gss_release_cred(a0ef91bb08bbfd35).(&junk, (gss_cred_id_tcxx . . $ gss_cred_id_t# *)&new_cred);
88 *minor_status = ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!;
89 return (GSS_S_FAILUREcxx . . $ `lib/gssapi/gssapi/gssapi.h:442:9`!);
90 }
91 HEIM_SLIST_INSERT_HEADcxx . . $ `lib/gssapi/mech/mechqueue.h:65:9`!(&new_cred->gc_mc, copy_mc, gmc_link);
92 }
93 }
94
95 /*
96 * Figure out a suitable mn, if any.
97 */
98 if (desired_name != GSS_C_NO_NAMEcxx . . $ `lib/gssapi/gssapi/gssapi.h:213:9`!) {
99 major_status = _gss_find_mncxx . . $ _gss_find_mn(7b279b4ab36ab23c).(minor_status,
100 (struct _gss_namecxx . . $ _gss_name# *) desired_name,
101 desired_mech,
102 &mn);
103 if (major_status != GSS_S_COMPLETEcxx . . $ `lib/gssapi/gssapi/gssapi.h:383:9`!) {
104 gss_release_credcxx . . $ gss_release_cred(a0ef91bb08bbfd35).(&junk, (gss_cred_id_tcxx . . $ gss_cred_id_t# *)&new_cred);
105 return (major_status);
106 }
107 }
108
109 if (cred_usage == GSS_C_BOTHcxx . . $ `lib/gssapi/gssapi/gssapi.h:172:9`!)
110 time_req = initiator_time_req > acceptor_time_req ? acceptor_time_req : initiator_time_req;
111 else if (cred_usage == GSS_C_INITIATEcxx . . $ `lib/gssapi/gssapi/gssapi.h:173:9`!)
112 time_req = initiator_time_req;
113 else
114 time_req = acceptor_time_req;
115
116 major_status = _gss_acquire_mech_credcxx . . $ _gss_acquire_mech_cred(bcdcb3c8df302b03).(minor_status, m, mn,
117 GSS_C_CRED_PASSWORDcxx . . $ `lib/gssapi/gssapi_mech.h:578:9`!, password,
118 time_req, desired_mech,
119 cred_usage, &mc);
120 if (major_status != GSS_S_COMPLETEcxx . . $ `lib/gssapi/gssapi/gssapi.h:383:9`!) {
121 gss_release_credcxx . . $ gss_release_cred(a0ef91bb08bbfd35).(&junk, (gss_cred_id_tcxx . . $ gss_cred_id_t# *)&new_cred);
122 return (major_status);
123 }
124
125 HEIM_SLIST_INSERT_HEADcxx . . $ `lib/gssapi/mech/mechqueue.h:65:9`!(&new_cred->gc_mc, mc, gmc_link);
126
127 if (actual_mechs || initiator_time_rec || acceptor_time_rec) {
128 OM_uint32cxx . . $ OM_uint32# time_rec;
129
130 major_status = gss_inquire_credcxx . . $ gss_inquire_cred(6a795fde9b30f171).(minor_status,
131 (gss_cred_id_tcxx . . $ gss_cred_id_t#)new_cred,
132 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!,
133 &time_rec,
134 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!,
135 actual_mechs);
136 if (GSS_ERRORcxx . . $ `lib/gssapi/gssapi/gssapi.h:407:9`!(major_status)) {
137 gss_release_credcxx . . $ gss_release_cred(a0ef91bb08bbfd35).(&junk, (gss_cred_id_tcxx . . $ gss_cred_id_t# *)&new_cred);
138 return (major_status);
139 }
140 if (initiator_time_rec &&
141 (cred_usage == GSS_C_INITIATEcxx . . $ `lib/gssapi/gssapi/gssapi.h:173:9`! || cred_usage == GSS_C_BOTHcxx . . $ `lib/gssapi/gssapi/gssapi.h:172:9`!))
142 *initiator_time_rec = time_rec;
143 if (acceptor_time_rec &&
144 (cred_usage == GSS_C_ACCEPTcxx . . $ `lib/gssapi/gssapi/gssapi.h:174:9`! || cred_usage == GSS_C_BOTHcxx . . $ `lib/gssapi/gssapi/gssapi.h:172:9`!))
145 *acceptor_time_rec = time_rec;
146 }
147
148 *output_cred_handle = (gss_cred_id_tcxx . . $ gss_cred_id_t#) new_cred;
149 return (GSS_S_COMPLETEcxx . . $ `lib/gssapi/gssapi/gssapi.h:383:9`!);
150 }