Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/solaris/native/sun/security/jgss/wrapper/NativeFunc.c
32301 views
1
/*
2
* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
#include <stdio.h>
27
#include <stdlib.h>
28
#include <dlfcn.h>
29
#include "NativeFunc.h"
30
31
/* global GSS function table */
32
GSS_FUNCTION_TABLE_PTR ftab;
33
34
/* standard GSS method names (ordering is from mapfile) */
35
static const char RELEASE_NAME[] = "gss_release_name";
36
static const char IMPORT_NAME[] = "gss_import_name";
37
static const char COMPARE_NAME[] = "gss_compare_name";
38
static const char CANONICALIZE_NAME[] = "gss_canonicalize_name";
39
static const char EXPORT_NAME[] = "gss_export_name";
40
static const char DISPLAY_NAME[] = "gss_display_name";
41
static const char ACQUIRE_CRED[] = "gss_acquire_cred";
42
static const char RELEASE_CRED[] = "gss_release_cred";
43
static const char INQUIRE_CRED[] = "gss_inquire_cred";
44
static const char IMPORT_SEC_CONTEXT[] = "gss_import_sec_context";
45
static const char INIT_SEC_CONTEXT[] = "gss_init_sec_context";
46
static const char ACCEPT_SEC_CONTEXT[] = "gss_accept_sec_context";
47
static const char INQUIRE_CONTEXT[] = "gss_inquire_context";
48
static const char DELETE_SEC_CONTEXT[] = "gss_delete_sec_context";
49
static const char CONTEXT_TIME[] = "gss_context_time";
50
static const char WRAP_SIZE_LIMIT[] = "gss_wrap_size_limit";
51
static const char EXPORT_SEC_CONTEXT[] = "gss_export_sec_context";
52
static const char GET_MIC[] = "gss_get_mic";
53
static const char VERIFY_MIC[] = "gss_verify_mic";
54
static const char WRAP[] = "gss_wrap";
55
static const char UNWRAP[] = "gss_unwrap";
56
static const char INDICATE_MECHS[] = "gss_indicate_mechs";
57
static const char INQUIRE_NAMES_FOR_MECH[] = "gss_inquire_names_for_mech";
58
59
/* additional GSS methods not public thru mapfile */
60
61
static const char ADD_OID_SET_MEMBER[] = "gss_add_oid_set_member";
62
static const char DISPLAY_STATUS[] = "gss_display_status";
63
static const char CREATE_EMPTY_OID_SET[] = "gss_create_empty_oid_set";
64
static const char RELEASE_OID_SET[] = "gss_release_oid_set";
65
static const char RELEASE_BUFFER[] = "gss_release_buffer";
66
67
/**
68
* Initialize native GSS function pointers
69
*/
70
char* loadNative(const char *libName) {
71
72
char *error;
73
void *gssLib;
74
int failed;
75
OM_uint32 minor, major;
76
77
ftab = NULL;
78
failed = FALSE;
79
error = NULL;
80
81
gssLib = dlopen(libName, RTLD_NOW);
82
if (gssLib == NULL) {
83
failed = TRUE;
84
goto out;
85
}
86
87
/* global function table instance */
88
ftab = (GSS_FUNCTION_TABLE_PTR)malloc(sizeof(GSS_FUNCTION_TABLE));
89
if (ftab == NULL) {
90
failed = TRUE;
91
goto out;
92
}
93
94
ftab->releaseName = (RELEASE_NAME_FN_PTR)dlsym(gssLib, RELEASE_NAME);
95
if (ftab->releaseName == NULL) {
96
failed = TRUE;
97
goto out;
98
}
99
100
ftab->importName = (IMPORT_NAME_FN_PTR)dlsym(gssLib, IMPORT_NAME);
101
if (ftab->importName == NULL) {
102
failed = TRUE;
103
goto out;
104
}
105
106
ftab->compareName = (COMPARE_NAME_FN_PTR)dlsym(gssLib, COMPARE_NAME);
107
if (ftab->compareName == NULL) {
108
failed = TRUE;
109
goto out;
110
}
111
112
ftab->canonicalizeName = (CANONICALIZE_NAME_FN_PTR)
113
dlsym(gssLib, CANONICALIZE_NAME);
114
if (ftab->canonicalizeName == NULL) {
115
failed = TRUE;
116
goto out;
117
}
118
119
ftab->exportName = (EXPORT_NAME_FN_PTR)dlsym(gssLib, EXPORT_NAME);
120
if (ftab->exportName == NULL) {
121
failed = TRUE;
122
goto out;
123
}
124
125
ftab->displayName = (DISPLAY_NAME_FN_PTR)dlsym(gssLib, DISPLAY_NAME);
126
if (ftab->displayName == NULL) {
127
failed = TRUE;
128
goto out;
129
}
130
131
ftab->acquireCred = (ACQUIRE_CRED_FN_PTR)dlsym(gssLib, ACQUIRE_CRED);
132
if (ftab->acquireCred == NULL) {
133
failed = TRUE;
134
goto out;
135
}
136
137
ftab->releaseCred = (RELEASE_CRED_FN_PTR)dlsym(gssLib, RELEASE_CRED);
138
if (ftab->releaseCred == NULL) {
139
failed = TRUE;
140
goto out;
141
}
142
143
ftab->inquireCred = (INQUIRE_CRED_FN_PTR)dlsym(gssLib, INQUIRE_CRED);
144
if (ftab->inquireCred == NULL) {
145
failed = TRUE;
146
goto out;
147
}
148
149
ftab->importSecContext = (IMPORT_SEC_CONTEXT_FN_PTR)
150
dlsym(gssLib, IMPORT_SEC_CONTEXT);
151
if (ftab->importSecContext == NULL) {
152
failed = TRUE;
153
goto out;
154
}
155
156
ftab->initSecContext = (INIT_SEC_CONTEXT_FN_PTR)
157
dlsym(gssLib, INIT_SEC_CONTEXT);
158
if (ftab->initSecContext == NULL) {
159
failed = TRUE;
160
goto out;
161
}
162
163
ftab->acceptSecContext = (ACCEPT_SEC_CONTEXT_FN_PTR)
164
dlsym(gssLib, ACCEPT_SEC_CONTEXT);
165
if (ftab->acceptSecContext == NULL) {
166
failed = TRUE;
167
goto out;
168
}
169
170
ftab->inquireContext = (INQUIRE_CONTEXT_FN_PTR)
171
dlsym(gssLib, INQUIRE_CONTEXT);
172
if (ftab->inquireContext == NULL) {
173
failed = TRUE;
174
goto out;
175
}
176
177
ftab->deleteSecContext = (DELETE_SEC_CONTEXT_FN_PTR)
178
dlsym(gssLib, DELETE_SEC_CONTEXT);
179
if (ftab->deleteSecContext == NULL) {
180
failed = TRUE;
181
goto out;
182
}
183
184
ftab->contextTime = (CONTEXT_TIME_FN_PTR)dlsym(gssLib, CONTEXT_TIME);
185
if (ftab->contextTime == NULL) {
186
failed = TRUE;
187
goto out;
188
}
189
190
ftab->wrapSizeLimit = (WRAP_SIZE_LIMIT_FN_PTR)
191
dlsym(gssLib, WRAP_SIZE_LIMIT);
192
if (ftab->wrapSizeLimit == NULL) {
193
failed = TRUE;
194
goto out;
195
}
196
197
ftab->exportSecContext = (EXPORT_SEC_CONTEXT_FN_PTR)
198
dlsym(gssLib, EXPORT_SEC_CONTEXT);
199
if (ftab->exportSecContext == NULL) {
200
failed = TRUE;
201
goto out;
202
}
203
204
ftab->getMic = (GET_MIC_FN_PTR)dlsym(gssLib, GET_MIC);
205
if (ftab->getMic == NULL) {
206
failed = TRUE;
207
goto out;
208
}
209
210
ftab->verifyMic = (VERIFY_MIC_FN_PTR)dlsym(gssLib, VERIFY_MIC);
211
if (ftab->verifyMic == NULL) {
212
failed = TRUE;
213
goto out;
214
}
215
216
ftab->wrap = (WRAP_FN_PTR)dlsym(gssLib, WRAP);
217
if (ftab->wrap == NULL) {
218
failed = TRUE;
219
goto out;
220
}
221
222
ftab->unwrap = (UNWRAP_FN_PTR)dlsym(gssLib, UNWRAP);
223
if (ftab->unwrap == NULL) {
224
failed = TRUE;
225
goto out;
226
}
227
228
ftab->indicateMechs = (INDICATE_MECHS_FN_PTR)dlsym(gssLib, INDICATE_MECHS);
229
if (ftab->indicateMechs == NULL) {
230
failed = TRUE;
231
goto out;
232
}
233
234
ftab->inquireNamesForMech = (INQUIRE_NAMES_FOR_MECH_FN_PTR)
235
dlsym(gssLib, INQUIRE_NAMES_FOR_MECH);
236
if (ftab->inquireNamesForMech == NULL) {
237
failed = TRUE;
238
goto out;
239
}
240
241
ftab->addOidSetMember = (ADD_OID_SET_MEMBER_FN_PTR)
242
dlsym(gssLib, ADD_OID_SET_MEMBER);
243
if (ftab->addOidSetMember == NULL) {
244
failed = TRUE;
245
goto out;
246
}
247
248
ftab->displayStatus = (DISPLAY_STATUS_FN_PTR)
249
dlsym(gssLib, DISPLAY_STATUS);
250
if (ftab->displayStatus == NULL) {
251
failed = TRUE;
252
goto out;
253
}
254
255
ftab->createEmptyOidSet = (CREATE_EMPTY_OID_SET_FN_PTR)
256
dlsym(gssLib, CREATE_EMPTY_OID_SET);
257
if (ftab->createEmptyOidSet == NULL) {
258
failed = TRUE;
259
goto out;
260
}
261
262
ftab->releaseOidSet = (RELEASE_OID_SET_FN_PTR)
263
dlsym(gssLib, RELEASE_OID_SET);
264
if (ftab->releaseOidSet == NULL) {
265
failed = TRUE;
266
goto out;
267
}
268
269
ftab->releaseBuffer = (RELEASE_BUFFER_FN_PTR)
270
dlsym(gssLib, RELEASE_BUFFER);
271
if (ftab->releaseBuffer == NULL) {
272
failed = TRUE;
273
goto out;
274
}
275
276
ftab->mechs = GSS_C_NO_OID_SET;
277
major = (*ftab->indicateMechs)(&minor, &(ftab->mechs));
278
if (ftab->mechs == NULL || ftab->mechs == GSS_C_NO_OID_SET) {
279
failed = TRUE;
280
goto out;
281
}
282
283
284
out:
285
if (failed == TRUE) {
286
error = dlerror();
287
if (gssLib != NULL) dlclose(gssLib);
288
if (ftab != NULL) free(ftab);
289
}
290
return error;
291
}
292
293