Skip to content

Commit

Permalink
[Fix 3.1] Add support for Shim gss api on Linux to delay loading libg…
Browse files Browse the repository at this point in the history
…ssapi_krb5.so (#1696)

Porting #1411 to 3.1-servicing.
  • Loading branch information
David-Engel authored Aug 9, 2022
1 parent d272da8 commit 96f9532
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ internal static extern void ReleaseGssBuffer(
IntPtr bufferPtr,
ulong length);

[DllImport(Interop.Libraries.NetSecurityNative, EntryPoint = "NetSecurityNative_EnsureGssInitialized")]
private static extern int EnsureGssInitialized();

[DllImport(Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_DisplayMinorStatus")]
internal static extern Status DisplayMinorStatus(
out Status minorStatus,
Expand Down Expand Up @@ -109,5 +112,17 @@ internal enum GssFlags : uint
GSS_C_EXTENDED_ERROR_FLAG = 0x4000,
GSS_C_DELEG_POLICY_FLAG = 0x8000
}

// This constructor is added to address the issue with net6 regarding
// Shim gss api on Linux to delay loading libgssapi_krb5.so
// issue https://github.com/dotnet/SqlClient/issues/1390
// dotnet runtime issue https://github.com/dotnet/runtime/pull/55037
static NetSecurityNative()
{
if (Environment.Version.Major >= 6)
{
EnsureGssInitialized();
}
}
}
}

0 comments on commit 96f9532

Please sign in to comment.