Skip to content

Commit eeb0c15

Browse files
authored
Revert "Fix usage of GSS_KRB5_CRED_NO_CI_FLAGS_X (#70447)" (#70747)
This reverts commit 84f7cad.
1 parent 344c792 commit eeb0c15

File tree

2 files changed

+15
-68
lines changed

2 files changed

+15
-68
lines changed

src/native/libs/System.Net.Security.Native/pal_gssapi.c

Lines changed: 15 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,7 @@ static gss_OID_desc gss_mech_ntlm_OID_desc = {.length = STRING_LENGTH(gss_ntlm_o
5858

5959
#if defined(GSS_SHIM)
6060

61-
#if HAVE_GSS_KRB5_CRED_NO_CI_FLAGS_X
62-
63-
#define FOR_ALL_OPTIONAL_GSS_FUNCTIONS \
64-
PER_FUNCTION_BLOCK(gss_set_cred_option) \
65-
PER_FUNCTION_BLOCK(GSS_KRB5_CRED_NO_CI_FLAGS_X)
66-
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-
69-
#else
70-
71-
#define FOR_ALL_OPTIONAL_GSS_FUNCTIONS
72-
73-
#endif //HAVE_GSS_KRB5_CRED_NO_CI_FLAGS_X
74-
75-
#define FOR_ALL_REQUIRED_GSS_FUNCTIONS \
61+
#define FOR_ALL_GSS_FUNCTIONS \
7662
PER_FUNCTION_BLOCK(gss_accept_sec_context) \
7763
PER_FUNCTION_BLOCK(gss_acquire_cred) \
7864
PER_FUNCTION_BLOCK(gss_acquire_cred_with_password) \
@@ -92,11 +78,14 @@ static gss_OID_desc gss_mech_ntlm_OID_desc = {.length = STRING_LENGTH(gss_ntlm_o
9278
PER_FUNCTION_BLOCK(gss_unwrap) \
9379
PER_FUNCTION_BLOCK(gss_wrap) \
9480
PER_FUNCTION_BLOCK(GSS_C_NT_USER_NAME) \
95-
PER_FUNCTION_BLOCK(GSS_C_NT_HOSTBASED_SERVICE) \
81+
PER_FUNCTION_BLOCK(GSS_C_NT_HOSTBASED_SERVICE)
9682

97-
#define FOR_ALL_GSS_FUNCTIONS \
98-
FOR_ALL_REQUIRED_GSS_FUNCTIONS \
99-
FOR_ALL_OPTIONAL_GSS_FUNCTIONS
83+
#if HAVE_GSS_KRB5_CRED_NO_CI_FLAGS_X
84+
85+
#define FOR_ALL_GSS_FUNCTIONS FOR_ALL_GSS_FUNCTIONS \
86+
PER_FUNCTION_BLOCK(gss_set_cred_option)
87+
88+
#endif //HAVE_GSS_KRB5_CRED_NO_CI_FLAGS_X
10089

10190
// define indirection pointers for all functions, like
10291
// static TYPEOF(gss_accept_sec_context)* gss_accept_sec_context_ptr;
@@ -129,7 +118,6 @@ static void* volatile s_gssLib = NULL;
129118

130119
#if HAVE_GSS_KRB5_CRED_NO_CI_FLAGS_X
131120
#define gss_set_cred_option(...) gss_set_cred_option_ptr(__VA_ARGS__)
132-
#define GSS_KRB5_CRED_NO_CI_FLAGS_X (*GSS_KRB5_CRED_NO_CI_FLAGS_X_ptr)
133121
#endif //HAVE_GSS_KRB5_CRED_NO_CI_FLAGS_X
134122

135123

@@ -150,27 +138,19 @@ static int32_t ensure_gss_shim_initialized()
150138
dlclose(lib);
151139
}
152140

153-
// initialize indirection pointers for all required functions, like:
141+
// initialize indirection pointers for all functions, like:
154142
// gss_accept_sec_context_ptr = (TYPEOF(gss_accept_sec_context)*)dlsym(s_gssLib, "gss_accept_sec_context");
155143
// 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; }
156144
#define PER_FUNCTION_BLOCK(fn) \
157145
fn##_ptr = (TYPEOF(fn)*)dlsym(s_gssLib, #fn); \
158146
if (fn##_ptr == NULL) { fprintf(stderr, "Cannot get symbol " #fn " from %s \nError: %s\n", gss_lib_name, dlerror()); return -1; }
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
147+
148+
FOR_ALL_GSS_FUNCTIONS
165149
#undef PER_FUNCTION_BLOCK
166150

167151
return 0;
168152
}
169153

170-
#else // GSS_SHIM
171-
172-
#define GSS_KRB5_CRED_NO_CI_FLAGS_X_AVAILABLE 1
173-
174154
#endif // GSS_SHIM
175155

176156
// transfers ownership of the underlying data from gssBuffer to PAL_GssBuffer
@@ -203,20 +183,10 @@ static uint32_t AcquireCredSpNego(uint32_t* minorStatus,
203183

204184
// 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
205185
#if HAVE_GSS_KRB5_CRED_NO_CI_FLAGS_X
206-
if (majorStatus == GSS_S_COMPLETE && GSS_KRB5_CRED_NO_CI_FLAGS_X_AVAILABLE)
186+
if (majorStatus == GSS_S_COMPLETE)
207187
{
208188
GssBuffer emptyBuffer = GSS_C_EMPTY_BUFFER;
209-
uint32_t tempMinorStatus;
210-
majorStatus = gss_set_cred_option(&tempMinorStatus, outputCredHandle, GSS_KRB5_CRED_NO_CI_FLAGS_X, &emptyBuffer);
211-
if (majorStatus == GSS_S_UNAVAILABLE || majorStatus == GSS_S_COMPLETE)
212-
{
213-
// preserve the original majorStatus/minorStatus from gss_acquire_cred
214-
majorStatus = GSS_S_COMPLETE;
215-
}
216-
else
217-
{
218-
*minorStatus = tempMinorStatus;
219-
}
189+
majorStatus = gss_set_cred_option(minorStatus, outputCredHandle, GSS_KRB5_CRED_NO_CI_FLAGS_X, &emptyBuffer);
220190
}
221191
#endif
222192

@@ -636,20 +606,10 @@ static uint32_t AcquireCredWithPassword(uint32_t* minorStatus,
636606

637607
// 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
638608
#if HAVE_GSS_KRB5_CRED_NO_CI_FLAGS_X
639-
if (!isNtlm && majorStatus == GSS_S_COMPLETE && GSS_KRB5_CRED_NO_CI_FLAGS_X_AVAILABLE)
609+
if (majorStatus == GSS_S_COMPLETE)
640610
{
641611
GssBuffer emptyBuffer = GSS_C_EMPTY_BUFFER;
642-
uint32_t tempMinorStatus;
643-
majorStatus = gss_set_cred_option(&tempMinorStatus, outputCredHandle, GSS_KRB5_CRED_NO_CI_FLAGS_X, &emptyBuffer);
644-
if (majorStatus == GSS_S_UNAVAILABLE || majorStatus == GSS_S_COMPLETE)
645-
{
646-
// preserve the original majorStatus/minorStatus from gss_acquire_cred_with_password
647-
majorStatus = GSS_S_COMPLETE;
648-
}
649-
else
650-
{
651-
*minorStatus = tempMinorStatus;
652-
}
612+
majorStatus = gss_set_cred_option(minorStatus, outputCredHandle, GSS_KRB5_CRED_NO_CI_FLAGS_X, &emptyBuffer);
653613
}
654614
#endif
655615

src/native/libs/configure.cmake

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,17 +1030,6 @@ check_include_files(
10301030
GSS/GSS.h
10311031
HAVE_GSSFW_HEADERS)
10321032

1033-
if (HAVE_GSSFW_HEADERS)
1034-
find_library(LIBGSS NAMES GSS)
1035-
elseif (HAVE_HEIMDAL_HEADERS)
1036-
find_library(LIBGSS NAMES gssapi)
1037-
else ()
1038-
find_library(LIBGSS NAMES gssapi_krb5)
1039-
endif ()
1040-
1041-
set (PREVIOUS_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
1042-
set (CMAKE_REQUIRED_LIBRARIES ${LIBGSS})
1043-
10441033
if (HAVE_GSSFW_HEADERS)
10451034
check_symbol_exists(
10461035
GSS_SPNEGO_MECHANISM
@@ -1065,8 +1054,6 @@ else ()
10651054
HAVE_GSS_KRB5_CRED_NO_CI_FLAGS_X)
10661055
endif ()
10671056

1068-
set (CMAKE_REQUIRED_LIBRARIES ${PREVIOUS_CMAKE_REQUIRED_LIBRARIES})
1069-
10701057
check_symbol_exists(getauxval sys/auxv.h HAVE_GETAUXVAL)
10711058
check_include_files(crt_externs.h HAVE_CRT_EXTERNS_H)
10721059

0 commit comments

Comments
 (0)