-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix usage of GSS_KRB5_CRED_NO_CI_FLAGS_X #70447
Changes from 4 commits
023ec28
3490f24
2f3e77c
65b5ef7
2f7906a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1030,6 +1030,17 @@ check_include_files( | |
GSS/GSS.h | ||
HAVE_GSSFW_HEADERS) | ||
|
||
if (HAVE_GSSFW_HEADERS) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tagged you as a resident CMake expert. Honestly I have no idea what am I doing here and if I am doing it right... I basically took that block and reduced it to minimum necessary to get the checks working. I'm not sure if moving it is possible since the extra_libs.cmake is also needed for the single-file host builds where everything is linked statically. Maybe including the extra_libs.cmake is an option? I didn't see that pattern anywhere though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I forgot about apphost path. |
||
find_library(LIBGSS NAMES GSS) | ||
elseif (HAVE_HEIMDAL_HEADERS) | ||
find_library(LIBGSS NAMES gssapi) | ||
else () | ||
find_library(LIBGSS NAMES gssapi_krb5) | ||
endif () | ||
|
||
set (PREVIOUS_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) | ||
set (CMAKE_REQUIRED_LIBRARIES ${LIBGSS}) | ||
|
||
if (HAVE_GSSFW_HEADERS) | ||
check_symbol_exists( | ||
GSS_SPNEGO_MECHANISM | ||
|
@@ -1054,6 +1065,8 @@ else () | |
HAVE_GSS_KRB5_CRED_NO_CI_FLAGS_X) | ||
endif () | ||
|
||
set (CMAKE_REQUIRED_LIBRARIES ${PREVIOUS_CMAKE_REQUIRED_LIBRARIES}) | ||
|
||
check_symbol_exists(getauxval sys/auxv.h HAVE_GETAUXVAL) | ||
check_include_files(crt_externs.h HAVE_CRT_EXTERNS_H) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be simplified, since minorStatus value is unused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not unused, it is passed to the managed code (where it is indeed unused but that may change).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We usually delete the dead code and add code when needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this particular case, it's problematic to change the native prototypes because dotnet/sqlclient has a dependency on it. We are trying to improve the situation going forward by introducing the
NegotiateAuthentication
public API but that work didn't land yet.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As minimum, I would suggest to put the minor error code to tracing. e.g. make use of it for debugging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I double-checked and it's passed in exception already:
runtime/src/libraries/Common/src/Microsoft/Win32/SafeHandles/GssSafeHandles.cs
Line 126 in 6de7147
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your proposed change always overrides the
minor_status
fromgss_acquire_cred
if this code path is taken. The idea was to preserve fullgss_acquire_cred
status (major+minor) ifgss_set_cred_option
returnsGSS_S_UNAVAILABLE
orGSS_S_COMPLETE
.Apparently somewhere along the way I incorrectly dropped the
GSS_S_COMPLETE
from the firstif
. I'll fix that.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that fixing the
if
makes no difference since the managed code ignoresminorStatus
when the major one isGSS_S_COMPLETE
but I want to make the intention clear. That is, preserve the fullgss_acquire_cred
status ifgss_set_cred_option
succeeds or is unavailable. In all other cases return the full status fromgss_set_cred_option
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we handle
GSS_S_UNAVAILABLE
in managed code? It seems little bit strange to do the mapping here in PAL.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can map the whole call in PAL and call it from managed code. I don't think it's worth it, to be honest, but it would not be hard to do so. The downside is that SqlClient would not get this fix for free.
Essentially,
gss_set_cred_option
will succeed only on Kerberos and Negotiate-over-Kerberos where it does a pass-throughgss_set_cred_option
call to the underlying Kerberos GSSAPI provider. TheGSS_S_UNAVAILABLE
case happens when there's no Kerberos and GSSAPI maps to Negotiate-over-NTLM, forwards to NTLM provider and that one doesn't recognize theGSS_KRB5_CRED_NO_CI_FLAGS_X
option.