20
20
#include <assert.h>
21
21
#include <string.h>
22
22
23
- #if defined(GSS_DYNAMIC_LIB )
23
+ #if defined(GSS_SHIM )
24
24
#include <dlfcn.h>
25
25
#include "pal_atomic.h"
26
26
#endif
@@ -53,7 +53,7 @@ static gss_OID_desc gss_mech_ntlm_OID_desc = {.length = ARRAY_SIZE(gss_ntlm_oid_
53
53
.elements = gss_ntlm_oid_value };
54
54
#endif
55
55
56
- #if defined(GSS_DYNAMIC_LIB )
56
+ #if defined(GSS_SHIM )
57
57
58
58
#define FOR_ALL_GSS_FUNCTIONS \
59
59
PER_FUNCTION_BLOCK(gss_accept_sec_context) \
@@ -131,15 +131,17 @@ static gss_shim_t* volatile s_gss_shim_ptr = NULL;
131
131
#define GSS_C_NT_HOSTBASED_SERVICE *s_gss_shim_ptr->GSS_C_NT_HOSTBASED_SERVICE_ptr
132
132
#define gss_mech_krb5 *s_gss_shim_ptr->gss_mech_krb5_ptr
133
133
134
+ #define gss_lib_name "libgssapi_krb5.so"
135
+
134
136
static int32_t ensure_gss_shim_initialized ()
135
137
{
136
138
if (s_gss_shim_ptr != NULL )
137
139
{
138
140
return 0 ;
139
141
}
140
142
141
- void * lib = dlopen (GSS_DYNAMIC_LIB , RTLD_LAZY );
142
- if (lib == NULL ) { fprintf (stderr , "Cannot load library %s \nError: %s\n" , GSS_DYNAMIC_LIB , dlerror ()); return -1 ; }
143
+ void * lib = dlopen (gss_lib_name , RTLD_LAZY );
144
+ if (lib == NULL ) { fprintf (stderr , "Cannot load library %s \nError: %s\n" , gss_lib_name , dlerror ()); return -1 ; }
143
145
144
146
// check is someone else has opened and published s_gssLib already
145
147
if (!pal_atomic_cas_ptr (& s_gssLib , lib , NULL ))
@@ -149,10 +151,10 @@ static int32_t ensure_gss_shim_initialized()
149
151
150
152
// initialize indirection pointers for all functions, like:
151
153
// s_gss_shim.gss_accept_sec_context_ptr = (TYPEOF(gss_accept_sec_context)*)dlsym(s_gssLib, "gss_accept_sec_context");
152
- // if (s_gss_shim.gss_accept_sec_context_ptr == NULL) { fprintf(stderr, "Cannot get symbol %s from %s \nError: %s\n", "gss_accept_sec_context", GSS_DYNAMIC_LIB , dlerror()); return -1; }
154
+ // if (s_gss_shim.gss_accept_sec_context_ptr == NULL) { fprintf(stderr, "Cannot get symbol %s from %s \nError: %s\n", "gss_accept_sec_context", gss_lib_name , dlerror()); return -1; }
153
155
#define PER_FUNCTION_BLOCK (fn ) \
154
156
s_gss_shim.fn##_ptr = (TYPEOF(fn)*)dlsym(s_gssLib, #fn); \
155
- if (s_gss_shim.fn##_ptr == NULL) { fprintf(stderr, "Cannot get symbol " #fn " from %s \nError: %s\n", GSS_DYNAMIC_LIB , dlerror()); return -1; }
157
+ if (s_gss_shim.fn##_ptr == NULL) { fprintf(stderr, "Cannot get symbol " #fn " from %s \nError: %s\n", gss_lib_name , dlerror()); return -1; }
156
158
157
159
FOR_ALL_GSS_FUNCTIONS
158
160
#undef PER_FUNCTION_BLOCK
@@ -163,7 +165,7 @@ static int32_t ensure_gss_shim_initialized()
163
165
return 0 ;
164
166
}
165
167
166
- #endif // GSS_DYNAMIC_LIB
168
+ #endif // GSS_SHIM
167
169
168
170
// transfers ownership of the underlying data from gssBuffer to PAL_GssBuffer
169
171
static void NetSecurityNative_MoveBuffer (gss_buffer_t gssBuffer , PAL_GssBuffer * targetBuffer )
@@ -687,7 +689,7 @@ uint32_t NetSecurityNative_IsNtlmInstalled()
687
689
688
690
int32_t NetSecurityNative_EnsureGssInitialized ()
689
691
{
690
- #if defined(GSS_DYNAMIC_LIB )
692
+ #if defined(GSS_SHIM )
691
693
return ensure_gss_shim_initialized ();
692
694
#else
693
695
return 0 ;
0 commit comments