@@ -64,13 +64,15 @@ static gss_OID_desc gss_mech_ntlm_OID_desc = {.length = STRING_LENGTH(gss_ntlm_o
6464 PER_FUNCTION_BLOCK(gss_set_cred_option) \
6565 PER_FUNCTION_BLOCK(GSS_KRB5_CRED_NO_CI_FLAGS_X)
6666
67+ #define GSS_KRB5_CRED_NO_CI_FLAGS_X_AVAILABLE (gss_set_cred_option_ptr != NULL && GSS_KRB5_CRED_NO_CI_FLAGS_X_ptr != NULL)
68+
6769#else
6870
6971#define FOR_ALL_OPTIONAL_GSS_FUNCTIONS
7072
7173#endif //HAVE_GSS_KRB5_CRED_NO_CI_FLAGS_X
7274
73- #define FOR_ALL_GSS_FUNCTIONS \
75+ #define FOR_ALL_REQUIRED_GSS_FUNCTIONS \
7476 PER_FUNCTION_BLOCK(gss_accept_sec_context) \
7577 PER_FUNCTION_BLOCK(gss_acquire_cred) \
7678 PER_FUNCTION_BLOCK(gss_acquire_cred_with_password) \
@@ -91,6 +93,9 @@ static gss_OID_desc gss_mech_ntlm_OID_desc = {.length = STRING_LENGTH(gss_ntlm_o
9193 PER_FUNCTION_BLOCK(gss_wrap) \
9294 PER_FUNCTION_BLOCK(GSS_C_NT_USER_NAME) \
9395 PER_FUNCTION_BLOCK(GSS_C_NT_HOSTBASED_SERVICE) \
96+
97+ #define FOR_ALL_GSS_FUNCTIONS \
98+ FOR_ALL_REQUIRED_GSS_FUNCTIONS \
9499 FOR_ALL_OPTIONAL_GSS_FUNCTIONS
95100
96101// define indirection pointers for all functions, like
@@ -145,19 +150,27 @@ static int32_t ensure_gss_shim_initialized()
145150 dlclose (lib );
146151 }
147152
148- // initialize indirection pointers for all functions, like:
153+ // initialize indirection pointers for all required functions, like:
149154 // gss_accept_sec_context_ptr = (TYPEOF(gss_accept_sec_context)*)dlsym(s_gssLib, "gss_accept_sec_context");
150155 // if (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; }
151156#define PER_FUNCTION_BLOCK (fn ) \
152157 fn##_ptr = (TYPEOF(fn)*)dlsym(s_gssLib, #fn); \
153158 if (fn##_ptr == NULL) { fprintf(stderr, "Cannot get symbol " #fn " from %s \nError: %s\n", gss_lib_name, dlerror()); return -1; }
154-
155- FOR_ALL_GSS_FUNCTIONS
159+ FOR_ALL_REQUIRED_GSS_FUNCTIONS
160+ #undef PER_FUNCTION_BLOCK
161+ // for optional functions skip the error check
162+ #define PER_FUNCTION_BLOCK (fn ) \
163+ fn##_ptr = (TYPEOF(fn)*)dlsym(s_gssLib, #fn);
164+ FOR_ALL_OPTIONAL_GSS_FUNCTIONS
156165#undef PER_FUNCTION_BLOCK
157166
158167 return 0 ;
159168}
160169
170+ #else // GSS_SHIM
171+
172+ #define GSS_KRB5_CRED_NO_CI_FLAGS_X_AVAILABLE 1
173+
161174#endif // GSS_SHIM
162175
163176// transfers ownership of the underlying data from gssBuffer to PAL_GssBuffer
@@ -190,7 +203,7 @@ static uint32_t AcquireCredSpNego(uint32_t* minorStatus,
190203
191204 // call gss_set_cred_option with GSS_KRB5_CRED_NO_CI_FLAGS_X to support Kerberos Sign Only option from *nix client against a windows server
192205#if HAVE_GSS_KRB5_CRED_NO_CI_FLAGS_X
193- if (majorStatus == GSS_S_COMPLETE )
206+ if (majorStatus == GSS_S_COMPLETE && GSS_KRB5_CRED_NO_CI_FLAGS_X_AVAILABLE )
194207 {
195208 GssBuffer emptyBuffer = GSS_C_EMPTY_BUFFER ;
196209 uint32_t tempMinorStatus ;
@@ -622,7 +635,7 @@ static uint32_t AcquireCredWithPassword(uint32_t* minorStatus,
622635
623636 // call gss_set_cred_option with GSS_KRB5_CRED_NO_CI_FLAGS_X to support Kerberos Sign Only option from *nix client against a windows server
624637#if HAVE_GSS_KRB5_CRED_NO_CI_FLAGS_X
625- if (!isNtlm && majorStatus == GSS_S_COMPLETE )
638+ if (!isNtlm && majorStatus == GSS_S_COMPLETE && GSS_KRB5_CRED_NO_CI_FLAGS_X_AVAILABLE )
626639 {
627640 GssBuffer emptyBuffer = GSS_C_EMPTY_BUFFER ;
628641 uint32_t tempMinorStatus ;
0 commit comments