Imported Upstream version 6.6.0.144

Former-commit-id: 335a70f3c58a7479968dcaae1d3412c2da9f9a3a
This commit is contained in:
Xamarin Public Jenkins (auto-signing) 2019-10-25 09:01:16 +00:00
parent 85bcceff8c
commit 790c4870fc
245 changed files with 629 additions and 257 deletions

View File

@ -1 +1 @@
3ba21059031b27874a35373e00bdcd91bd47de13
216affdcd7058ced57cbcc824d956ec0e5b9a8bb

View File

@ -1 +1 @@
e18300135ca50e7668c69f3ed3cd61dd3558d856
6301d90f695640f2efd76e1111b8e40dadbe7e98

View File

@ -15,9 +15,14 @@ internal static partial class Interop
{
private readonly Status _minorStatus;
public Status MajorStatus
{
get { return (Status)HResult; }
}
public Status MinorStatus
{
get { return _minorStatus;}
get { return _minorStatus; }
}
public GssApiException(string message) : base(message)
@ -25,21 +30,45 @@ internal static partial class Interop
}
public GssApiException(Status majorStatus, Status minorStatus)
: base(GetGssApiDisplayStatus(majorStatus, minorStatus))
: base(GetGssApiDisplayStatus(majorStatus, minorStatus, null))
{
HResult = (int)majorStatus;
_minorStatus = minorStatus;
}
private static string GetGssApiDisplayStatus(Status majorStatus, Status minorStatus)
public GssApiException(Status majorStatus, Status minorStatus, string helpText)
: base(GetGssApiDisplayStatus(majorStatus, minorStatus, helpText))
{
HResult = (int)majorStatus;
_minorStatus = minorStatus;
}
private static string GetGssApiDisplayStatus(Status majorStatus, Status minorStatus, string helpText)
{
string majorError = GetGssApiDisplayStatus(majorStatus, isMinor: false);
string minorError = GetGssApiDisplayStatus(minorStatus, isMinor: true);
string errorMessage;
return (majorError != null && minorError != null) ?
if (minorStatus != Status.GSS_S_COMPLETE)
{
string minorError = GetGssApiDisplayStatus(minorStatus, isMinor: true);
errorMessage = (majorError != null && minorError != null) ?
SR.Format(SR.net_gssapi_operation_failed_detailed, majorError, minorError) :
SR.Format(SR.net_gssapi_operation_failed, majorStatus.ToString("x"), minorStatus.ToString("x"));
}
else
{
errorMessage = (majorError != null) ?
SR.Format(SR.net_gssapi_operation_failed_detailed_majoronly, majorError) :
SR.Format(SR.net_gssapi_operation_failed_majoronly, majorStatus.ToString("x"));
}
if (!string.IsNullOrEmpty(helpText))
{
return errorMessage + " " + helpText;
}
return errorMessage;
}
private static string GetGssApiDisplayStatus(Status status, bool isMinor)
{

View File

@ -14,7 +14,7 @@ internal static partial class Interop
[StructLayout(LayoutKind.Sequential)]
internal unsafe struct GssBuffer : IDisposable
{
internal UInt64 _length;
internal ulong _length;
internal IntPtr _data;
internal int Copy(byte[] destination, int offset)

View File

@ -12,11 +12,120 @@ internal static partial class Interop
{
internal static partial class NetSecurityNative
{
#if ENABLE_GSS
#if !ENABLE_GSS
internal static void ReleaseGssBuffer(
IntPtr bufferPtr,
ulong length) => throw new PlatformNotSupportedException ();
internal static Status DisplayMinorStatus(
out Status minorStatus,
Status statusValue,
ref GssBuffer buffer) => throw new PlatformNotSupportedException ();
internal static Status DisplayMajorStatus(
out Status minorStatus,
Status statusValue,
ref GssBuffer buffer) => throw new PlatformNotSupportedException ();
internal static Status ImportUserName(
out Status minorStatus,
string inputName,
int inputNameByteCount,
out SafeGssNameHandle outputName) => throw new PlatformNotSupportedException ();
internal static Status ImportPrincipalName(
out Status minorStatus,
string inputName,
int inputNameByteCount,
out SafeGssNameHandle outputName) => throw new PlatformNotSupportedException ();
internal static Status ReleaseName(
out Status minorStatus,
ref IntPtr inputName) => throw new PlatformNotSupportedException ();
internal static Status InitiateCredSpNego(
out Status minorStatus,
SafeGssNameHandle desiredName,
out SafeGssCredHandle outputCredHandle) => throw new PlatformNotSupportedException ();
internal static Status InitiateCredWithPassword(
out Status minorStatus,
bool isNtlm,
SafeGssNameHandle desiredName,
string password,
int passwordLen,
out SafeGssCredHandle outputCredHandle) => throw new PlatformNotSupportedException ();
internal static Status ReleaseCred(
out Status minorStatus,
ref IntPtr credHandle) => throw new PlatformNotSupportedException ();
internal static Status InitSecContext(
out Status minorStatus,
SafeGssCredHandle initiatorCredHandle,
ref SafeGssContextHandle contextHandle,
bool isNtlmOnly,
SafeGssNameHandle targetName,
uint reqFlags,
byte[] inputBytes,
int inputLength,
ref GssBuffer token,
out uint retFlags,
out int isNtlmUsed) => throw new PlatformNotSupportedException ();
internal static Status InitSecContext(
out Status minorStatus,
SafeGssCredHandle initiatorCredHandle,
ref SafeGssContextHandle contextHandle,
bool isNtlmOnly,
IntPtr cbt,
int cbtSize,
SafeGssNameHandle targetName,
uint reqFlags,
byte[] inputBytes,
int inputLength,
ref GssBuffer token,
out uint retFlags,
out int isNtlmUsed) => throw new PlatformNotSupportedException ();
internal static Status AcceptSecContext(
out Status minorStatus,
ref SafeGssContextHandle acceptContextHandle,
byte[] inputBytes,
int inputLength,
ref GssBuffer token,
out uint retFlags) => throw new PlatformNotSupportedException ();
internal static Status DeleteSecContext(
out Status minorStatus,
ref IntPtr contextHandle) => throw new PlatformNotSupportedException ();
internal static Status GetUser(
out Status minorStatus,
SafeGssContextHandle acceptContextHandle,
ref GssBuffer token) => throw new PlatformNotSupportedException ();
private static Status Wrap(
out Status minorStatus,
SafeGssContextHandle contextHandle,
bool isEncrypt,
byte[] inputBytes,
int offset,
int count,
ref GssBuffer outBuffer) => throw new PlatformNotSupportedException ();
private static Status Unwrap(
out Status minorStatus,
SafeGssContextHandle contextHandle,
byte[] inputBytes,
int offset,
int count,
ref GssBuffer outBuffer) => throw new PlatformNotSupportedException ();
#else
[DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_ReleaseGssBuffer")]
internal static extern void ReleaseGssBuffer(
IntPtr bufferPtr,
UInt64 length);
ulong length);
[DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_DisplayMinorStatus")]
internal static extern Status DisplayMinorStatus(
@ -83,19 +192,42 @@ internal static partial class Interop
out uint retFlags,
out int isNtlmUsed);
[DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_InitSecContextEx")]
internal static extern Status InitSecContext(
out Status minorStatus,
SafeGssCredHandle initiatorCredHandle,
ref SafeGssContextHandle contextHandle,
bool isNtlmOnly,
IntPtr cbt,
int cbtSize,
SafeGssNameHandle targetName,
uint reqFlags,
byte[] inputBytes,
int inputLength,
ref GssBuffer token,
out uint retFlags,
out int isNtlmUsed);
[DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_AcceptSecContext")]
internal static extern Status AcceptSecContext(
out Status minorStatus,
ref SafeGssContextHandle acceptContextHandle,
byte[] inputBytes,
int inputLength,
ref GssBuffer token);
ref GssBuffer token,
out uint retFlags);
[DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_DeleteSecContext")]
internal static extern Status DeleteSecContext(
out Status minorStatus,
ref IntPtr contextHandle);
[DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_GetUser")]
internal static extern Status GetUser(
out Status minorStatus,
SafeGssContextHandle acceptContextHandle,
ref GssBuffer token);
[DllImport(Interop.Libraries.NetSecurityNative, EntryPoint="NetSecurityNative_Wrap")]
private static extern Status Wrap(
out Status minorStatus,
@ -114,6 +246,7 @@ internal static partial class Interop
int offset,
int count,
ref GssBuffer outBuffer);
#endif
internal static Status WrapBuffer(
out Status minorStatus,
@ -145,117 +278,33 @@ internal static partial class Interop
return Unwrap(out minorStatus, contextHandle, inputBytes, offset, count, ref outBuffer);
}
#else
internal static void ReleaseGssBuffer (
IntPtr bufferPtr,
UInt64 length) => throw new NotSupportedException ();
internal static Status DisplayMinorStatus (
out Status minorStatus,
Status statusValue,
ref GssBuffer buffer) => throw new NotSupportedException ();
internal static Status DisplayMajorStatus (
out Status minorStatus,
Status statusValue,
ref GssBuffer buffer) => throw new NotSupportedException ();
internal static Status ImportUserName (
out Status minorStatus,
string inputName,
int inputNameByteCount,
out SafeGssNameHandle outputName) => throw new NotSupportedException ();
internal static Status ImportPrincipalName (
out Status minorStatus,
string inputName,
int inputNameByteCount,
out SafeGssNameHandle outputName) => throw new NotSupportedException ();
internal static Status ReleaseName (
out Status minorStatus,
ref IntPtr inputName) => throw new NotSupportedException ();
internal static Status InitiateCredSpNego (
out Status minorStatus,
SafeGssNameHandle desiredName,
out SafeGssCredHandle outputCredHandle) => throw new NotSupportedException ();
internal static Status InitiateCredWithPassword (
out Status minorStatus,
bool isNtlm,
SafeGssNameHandle desiredName,
string password,
int passwordLen,
out SafeGssCredHandle outputCredHandle) => throw new NotSupportedException ();
internal static Status ReleaseCred (
out Status minorStatus,
ref IntPtr credHandle) => throw new NotSupportedException ();
internal static Status InitSecContext (
out Status minorStatus,
SafeGssCredHandle initiatorCredHandle,
ref SafeGssContextHandle contextHandle,
bool isNtlmOnly,
SafeGssNameHandle targetName,
uint reqFlags,
byte[] inputBytes,
int inputLength,
ref GssBuffer token,
out uint retFlags,
out int isNtlmUsed) => throw new NotSupportedException ();
internal static Status AcceptSecContext (
out Status minorStatus,
ref SafeGssContextHandle acceptContextHandle,
byte[] inputBytes,
int inputLength,
ref GssBuffer token) => throw new NotSupportedException ();
internal static Status DeleteSecContext (
out Status minorStatus,
ref IntPtr contextHandle) => throw new NotSupportedException ();
static Status Wrap(
out Status minorStatus,
SafeGssContextHandle contextHandle,
bool isEncrypt,
byte[] inputBytes,
int offset,
int count,
ref GssBuffer outBuffer) => throw new NotSupportedException ();
static Status Unwrap (
out Status minorStatus,
SafeGssContextHandle contextHandle,
byte[] inputBytes,
int offset,
int count,
ref GssBuffer outBuffer) => throw new NotSupportedException ();
internal static Status WrapBuffer (
out Status minorStatus,
SafeGssContextHandle contextHandle,
bool isEncrypt,
byte[] inputBytes,
int offset,
int count,
ref GssBuffer outBuffer) => throw new NotSupportedException ();
internal static Status UnwrapBuffer (
out Status minorStatus,
SafeGssContextHandle contextHandle,
byte[] inputBytes,
int offset,
int count,
ref GssBuffer outBuffer) => throw new NotSupportedException ();
#endif
// https://www.gnu.org/software/gss/reference/gss.pdf Page 65
internal const int GSS_C_ROUTINE_ERROR_OFFSET = 16;
// https://www.gnu.org/software/gss/reference/gss.pdf Page 9
internal enum Status : uint
{
GSS_S_COMPLETE = 0,
GSS_S_CONTINUE_NEEDED = 1
GSS_S_CONTINUE_NEEDED = 1,
GSS_S_BAD_MECH = 1 << GSS_C_ROUTINE_ERROR_OFFSET,
GSS_S_BAD_NAME = 2 << GSS_C_ROUTINE_ERROR_OFFSET,
GSS_S_BAD_NAMETYPE = 3 << GSS_C_ROUTINE_ERROR_OFFSET,
GSS_S_BAD_BINDINGS = 4 << GSS_C_ROUTINE_ERROR_OFFSET,
GSS_S_BAD_STATUS = 5 << GSS_C_ROUTINE_ERROR_OFFSET,
GSS_S_BAD_SIG = 6 << GSS_C_ROUTINE_ERROR_OFFSET,
GSS_S_NO_CRED = 7 << GSS_C_ROUTINE_ERROR_OFFSET,
GSS_S_NO_CONTEXT = 8 << GSS_C_ROUTINE_ERROR_OFFSET,
GSS_S_DEFECTIVE_TOKEN = 9 << GSS_C_ROUTINE_ERROR_OFFSET,
GSS_S_DEFECTIVE_CREDENTIAL = 10 << GSS_C_ROUTINE_ERROR_OFFSET,
GSS_S_CREDENTIALS_EXPIRED = 11 << GSS_C_ROUTINE_ERROR_OFFSET,
GSS_S_CONTEXT_EXPIRED = 12 << GSS_C_ROUTINE_ERROR_OFFSET,
GSS_S_FAILURE = 13 << GSS_C_ROUTINE_ERROR_OFFSET,
GSS_S_BAD_QOP = 14 << GSS_C_ROUTINE_ERROR_OFFSET,
GSS_S_UNAUTHORIZED = 15 << GSS_C_ROUTINE_ERROR_OFFSET,
GSS_S_UNAVAILABLE = 16 << GSS_C_ROUTINE_ERROR_OFFSET,
GSS_S_DUPLICATE_ELEMENT = 17 << GSS_C_ROUTINE_ERROR_OFFSET,
GSS_S_NAME_NOT_MN = 18 << GSS_C_ROUTINE_ERROR_OFFSET,
}
[Flags]

View File

@ -97,6 +97,7 @@ BEGIN_EXTERN_C
typedef int errno_t;
#ifndef HAVE_MEMCPY_S
inline static errno_t memcpy_s(void* dst, size_t sizeInBytes, const void* src, size_t count)
{
if (count > 0)
@ -124,5 +125,6 @@ inline static errno_t memcpy_s(void* dst, size_t sizeInBytes, const void* src, s
return 0;
}
#endif
END_EXTERN_C

View File

@ -816,6 +816,7 @@ static int32_t GetIPv4PacketInformation(struct cmsghdr* controlMessage, struct I
return 1;
}
#ifdef IPV6_PKTINFO
static int32_t GetIPv6PacketInformation(struct cmsghdr* controlMessage, struct IPPacketInformation* packetInfo)
{
assert(controlMessage != NULL);
@ -834,6 +835,7 @@ static int32_t GetIPv6PacketInformation(struct cmsghdr* controlMessage, struct I
return 1;
}
#endif
static struct cmsghdr* GET_CMSG_NXTHDR(struct msghdr* mhdr, struct cmsghdr* cmsg)
{
@ -1474,9 +1476,11 @@ static bool TryGetPlatformSocketOption(int32_t socketOptionName, int32_t socketO
*optName = SO_DEBUG;
return true;
#ifdef SO_ACCEPTCONN
case SocketOptionName_SO_ACCEPTCONN:
*optName = SO_ACCEPTCONN;
return true;
#endif
case SocketOptionName_SO_REUSEADDR:
*optName = SO_REUSEADDR;
@ -1638,9 +1642,11 @@ static bool TryGetPlatformSocketOption(int32_t socketOptionName, int32_t socketO
// case SocketOptionName_SO_IPV6_PROTECTION_LEVEL:
#ifdef IPV6_V6ONLY
case SocketOptionName_SO_IPV6_V6ONLY:
*optName = IPV6_V6ONLY;
return true;
#endif
#ifdef IPV6_RECVPKTINFO
case SocketOptionName_SO_IP_PKTINFO:
@ -1901,9 +1907,11 @@ static bool TryConvertProtocolTypePalToPlatform(int32_t palProtocolType, int* pl
*platformProtocolType = IPPROTO_UDP;
return true;
#ifdef IPPROTO_ICMPV6
case ProtocolType_PT_ICMPV6:
*platformProtocolType = IPPROTO_ICMPV6;
return true;
#endif
default:
*platformProtocolType = (int)palProtocolType;

View File

@ -111,7 +111,7 @@ static uint32_t NetSecurityNative_DisplayStatus(uint32_t* minorStatus,
assert(minorStatus != NULL);
assert(outBuffer != NULL);
uint32_t messageContext;
uint32_t messageContext = 0; // Must initialize to 0 before calling gss_display_status.
GssBuffer gssBuffer = {.length = 0, .value = NULL};
uint32_t majorStatus =
gss_display_status(minorStatus, statusValue, statusType, GSS_C_NO_OID, &messageContext, &gssBuffer);
@ -154,19 +154,36 @@ uint32_t NetSecurityNative_ImportPrincipalName(uint32_t* minorStatus,
assert(outputName != NULL);
assert(*outputName == NULL);
gss_OID nameType;
if (strchr(inputName, '/') != NULL)
// Principal name will usually be in the form SERVICE/HOST. But SPNEGO protocol prefers
// GSS_C_NT_HOSTBASED_SERVICE format. That format uses '@' separator instead of '/' between
// service name and host name. So convert input string into that format.
char* ptrSlash = memchr(inputName, '/', inputNameLen);
char* inputNameCopy = NULL;
if (ptrSlash != NULL)
{
nameType = GSS_KRB5_NT_PRINCIPAL_NAME;
inputNameCopy = (char*) malloc(inputNameLen);
if (inputNameCopy != NULL)
{
memcpy(inputNameCopy, inputName, inputNameLen);
inputNameCopy[ptrSlash - inputName] = '@';
inputName = inputNameCopy;
}
else
{
nameType = GSS_C_NT_HOSTBASED_SERVICE;
*minorStatus = 0;
return GSS_S_BAD_NAME;
}
}
GssBuffer inputNameBuffer = {.length = inputNameLen, .value = inputName};
return gss_import_name(minorStatus, &inputNameBuffer, nameType, outputName);
uint32_t result = gss_import_name(minorStatus, &inputNameBuffer, GSS_C_NT_HOSTBASED_SERVICE, outputName);
if (inputNameCopy != NULL)
{
free(inputNameCopy);
}
return result;
}
uint32_t NetSecurityNative_InitSecContext(uint32_t* minorStatus,
@ -180,6 +197,35 @@ uint32_t NetSecurityNative_InitSecContext(uint32_t* minorStatus,
PAL_GssBuffer* outBuffer,
uint32_t* retFlags,
int32_t* isNtlmUsed)
{
return NetSecurityNative_InitSecContextEx(minorStatus,
claimantCredHandle,
contextHandle,
isNtlm,
NULL,
0,
targetName,
reqFlags,
inputBytes,
inputLength,
outBuffer,
retFlags,
isNtlmUsed);
}
uint32_t NetSecurityNative_InitSecContextEx(uint32_t* minorStatus,
GssCredId* claimantCredHandle,
GssCtxId** contextHandle,
uint32_t isNtlm,
void* cbt,
int32_t cbtSize,
GssName* targetName,
uint32_t reqFlags,
uint8_t* inputBytes,
uint32_t inputLength,
PAL_GssBuffer* outBuffer,
uint32_t* retFlags,
int32_t* isNtlmUsed)
{
assert(minorStatus != NULL);
assert(contextHandle != NULL);
@ -189,12 +235,13 @@ uint32_t NetSecurityNative_InitSecContext(uint32_t* minorStatus,
assert(outBuffer != NULL);
assert(retFlags != NULL);
assert(isNtlmUsed != NULL);
assert(inputBytes != NULL || inputLength == 0);
assert(cbt != NULL || cbtSize == 0);
// Note: claimantCredHandle can be null
// Note: *contextHandle is null only in the first call and non-null in the subsequent calls
#if HAVE_GSS_SPNEGO_MECHANISM
gss_OID krbMech = GSS_KRB5_MECHANISM;
gss_OID desiredMech;
if (isNtlm)
{
@ -204,9 +251,8 @@ uint32_t NetSecurityNative_InitSecContext(uint32_t* minorStatus,
{
desiredMech = GSS_SPNEGO_MECHANISM;
}
gss_OID krbMech = GSS_KRB5_MECHANISM;
#else
gss_OID krbMech = (gss_OID)(unsigned long)gss_mech_krb5;
gss_OID_desc gss_mech_OID_desc;
if (isNtlm)
{
@ -218,14 +264,20 @@ uint32_t NetSecurityNative_InitSecContext(uint32_t* minorStatus,
}
gss_OID desiredMech = &gss_mech_OID_desc;
gss_OID krbMech = gss_mech_krb5;
#endif
*isNtlmUsed = 1;
GssBuffer inputToken = {.length = inputLength, .value = inputBytes};
GssBuffer gssBuffer = {.length = 0, .value = NULL};
gss_OID_desc* outmech;
struct gss_channel_bindings_struct gssCbt;
if (cbt != NULL)
{
memset(&gssCbt, 0, sizeof(struct gss_channel_bindings_struct));
gssCbt.application_data.length = (size_t)cbtSize;
gssCbt.application_data.value = cbt;
}
uint32_t majorStatus = gss_init_sec_context(minorStatus,
claimantCredHandle,
contextHandle,
@ -233,18 +285,14 @@ uint32_t NetSecurityNative_InitSecContext(uint32_t* minorStatus,
desiredMech,
reqFlags,
0,
GSS_C_NO_CHANNEL_BINDINGS,
(cbt != NULL) ? &gssCbt : GSS_C_NO_CHANNEL_BINDINGS,
&inputToken,
&outmech,
&gssBuffer,
retFlags,
NULL);
// Outmech can be null when gssntlmssp lib uses NTLM mechanism
if (outmech != NULL && gss_oid_equal(outmech, krbMech) != 0)
{
*isNtlmUsed = 0;
}
*isNtlmUsed = (isNtlm || majorStatus != GSS_S_COMPLETE || gss_oid_equal(outmech, krbMech) == 0) ? 1 : 0;
NetSecurityNative_MoveBuffer(&gssBuffer, outBuffer);
return majorStatus;
@ -254,7 +302,8 @@ uint32_t NetSecurityNative_AcceptSecContext(uint32_t* minorStatus,
GssCtxId** contextHandle,
uint8_t* inputBytes,
uint32_t inputLength,
PAL_GssBuffer* outBuffer)
PAL_GssBuffer* outBuffer,
uint32_t* retFlags)
{
assert(minorStatus != NULL);
assert(contextHandle != NULL);
@ -273,7 +322,7 @@ uint32_t NetSecurityNative_AcceptSecContext(uint32_t* minorStatus,
NULL,
NULL,
&gssBuffer,
0,
retFlags,
NULL,
NULL);
@ -281,6 +330,44 @@ uint32_t NetSecurityNative_AcceptSecContext(uint32_t* minorStatus,
return majorStatus;
}
uint32_t NetSecurityNative_GetUser(uint32_t* minorStatus,
GssCtxId* contextHandle,
PAL_GssBuffer* outBuffer)
{
assert(minorStatus != NULL);
assert(contextHandle != NULL);
assert(outBuffer != NULL);
gss_name_t srcName = GSS_C_NO_NAME;
uint32_t majorStatus = gss_inquire_context(minorStatus,
contextHandle,
&srcName,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL);
if (majorStatus == GSS_S_COMPLETE)
{
GssBuffer gssBuffer = {.length = 0, .value = NULL};
majorStatus = gss_display_name(minorStatus, srcName, &gssBuffer, NULL);
if (majorStatus == GSS_S_COMPLETE)
{
NetSecurityNative_MoveBuffer(&gssBuffer, outBuffer);
}
}
if (srcName != NULL)
{
majorStatus = gss_release_name(minorStatus, &srcName);
}
return majorStatus;
}
uint32_t NetSecurityNative_ReleaseCred(uint32_t* minorStatus, GssCredId** credHandle)
{
assert(minorStatus != NULL);
@ -417,3 +504,36 @@ uint32_t NetSecurityNative_InitiateCredWithPassword(uint32_t* minorStatus,
return NetSecurityNative_AcquireCredWithPassword(
minorStatus, isNtlm, desiredName, password, passwdLen, GSS_C_INITIATE, outputCredHandle);
}
uint32_t NetSecurityNative_IsNtlmInstalled()
{
#if HAVE_GSS_SPNEGO_MECHANISM
gss_OID ntlmOid = GSS_NTLM_MECHANISM;
#else
gss_OID ntlmOid = &gss_mech_ntlm_OID_desc;
#endif
uint32_t majorStatus;
uint32_t minorStatus;
gss_OID_set mechSet;
gss_OID_desc oid;
uint32_t foundNtlm = 0;
majorStatus = gss_indicate_mechs(&minorStatus, &mechSet);
if (majorStatus == GSS_S_COMPLETE)
{
for (size_t i = 0; i < mechSet->count; i++)
{
oid = mechSet->elements[i];
if ((oid.length == ntlmOid->length) && (memcmp(oid.elements, ntlmOid->elements, oid.length) == 0))
{
foundNtlm = 1;
break;
}
}
gss_release_oid_set(&minorStatus, &mechSet);
}
return foundNtlm;
}

View File

@ -115,6 +115,20 @@ DLLEXPORT uint32_t NetSecurityNative_InitSecContext(uint32_t* minorStatus,
uint32_t* retFlags,
int32_t* isNtlmUsed);
DLLEXPORT uint32_t NetSecurityNative_InitSecContextEx(uint32_t* minorStatus,
GssCredId* claimantCredHandle,
GssCtxId** contextHandle,
uint32_t isNtlm,
void* cbt,
int32_t cbtSize,
GssName* targetName,
uint32_t reqFlags,
uint8_t* inputBytes,
uint32_t inputLength,
PAL_GssBuffer* outBuffer,
uint32_t* retFlags,
int32_t* isNtlmUsed);
/*
Shims the gss_accept_sec_context method.
*/
@ -122,7 +136,8 @@ DLLEXPORT uint32_t NetSecurityNative_AcceptSecContext(uint32_t* minorStatus,
GssCtxId** contextHandle,
uint8_t* inputBytes,
uint32_t inputLength,
PAL_GssBuffer* outBuffer);
PAL_GssBuffer* outBuffer,
uint32_t* retFlags);
/*
@ -160,3 +175,15 @@ DLLEXPORT uint32_t NetSecurityNative_InitiateCredWithPassword(uint32_t* minorSta
char* password,
uint32_t passwdLen,
GssCredId** outputCredHandle);
/*
Shims the gss_indicate_mechs method to detect if NTLM mech is installed.
*/
DLLEXPORT uint32_t NetSecurityNative_IsNtlmInstalled(void);
/*
Shims gss_inquire_context and gss_display_name to get the remote user principal name.
*/
DLLEXPORT uint32_t NetSecurityNative_GetUser(uint32_t* minorStatus,
GssCtxId* contextHandle,
PAL_GssBuffer* outBuffer);

View File

@ -280,6 +280,8 @@ namespace System.IO
finally
{
StaticWatcherRunLoopManager.UnscheduleFromRunLoop(_eventStream);
_eventStream.Close();
_eventStream = null;
}
}
}

View File

@ -8,6 +8,7 @@ using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
namespace System.Linq
{
@ -212,6 +213,63 @@ namespace System.Linq
private static ILookup<string, MethodInfo> s_seqMethods;
[PreserveDependency ("Aggregate`1", "System.Linq.Enumerable")]
[PreserveDependency ("Aggregate`2", "System.Linq.Enumerable")]
[PreserveDependency ("Aggregate`3", "System.Linq.Enumerable")]
[PreserveDependency ("All`1", "System.Linq.Enumerable")]
[PreserveDependency ("Any`1", "System.Linq.Enumerable")]
[PreserveDependency ("Append`1", "System.Linq.Enumerable")]
[PreserveDependency ("Average", "System.Linq.Enumerable")]
[PreserveDependency ("Average`1", "System.Linq.Enumerable")]
[PreserveDependency ("Cast`1", "System.Linq.Enumerable")]
[PreserveDependency ("Concat`1", "System.Linq.Enumerable")]
[PreserveDependency ("Contains`1", "System.Linq.Enumerable")]
[PreserveDependency ("Count`1", "System.Linq.Enumerable")]
[PreserveDependency ("DefaultIfEmpty`1", "System.Linq.Enumerable")]
[PreserveDependency ("Distinct`1", "System.Linq.Enumerable")]
[PreserveDependency ("ElementAt`1", "System.Linq.Enumerable")]
[PreserveDependency ("ElementAtOrDefault`1", "System.Linq.Enumerable")]
[PreserveDependency ("Except`1", "System.Linq.Enumerable")]
[PreserveDependency ("First`1", "System.Linq.Enumerable")]
[PreserveDependency ("FirstOrDefault`1", "System.Linq.Enumerable")]
[PreserveDependency ("GroupBy`2", "System.Linq.Enumerable")]
[PreserveDependency ("GroupBy`3", "System.Linq.Enumerable")]
[PreserveDependency ("GroupBy`4", "System.Linq.Enumerable")]
[PreserveDependency ("GroupJoin`4", "System.Linq.Enumerable")]
[PreserveDependency ("Intersect`1", "System.Linq.Enumerable")]
[PreserveDependency ("Join`4", "System.Linq.Enumerable")]
[PreserveDependency ("Last`1", "System.Linq.Enumerable")]
[PreserveDependency ("LastOrDefault`1", "System.Linq.Enumerable")]
[PreserveDependency ("LongCount`1", "System.Linq.Enumerable")]
[PreserveDependency ("Max`1", "System.Linq.Enumerable")]
[PreserveDependency ("Max`2", "System.Linq.Enumerable")]
[PreserveDependency ("Min`1", "System.Linq.Enumerable")]
[PreserveDependency ("Min`2", "System.Linq.Enumerable")]
[PreserveDependency ("OfType`1", "System.Linq.Enumerable")]
[PreserveDependency ("OrderBy`2", "System.Linq.Enumerable")]
[PreserveDependency ("OrderByDescending`2", "System.Linq.Enumerable")]
[PreserveDependency ("Prepend`1", "System.Linq.Enumerable")]
[PreserveDependency ("Reverse`1", "System.Linq.Enumerable")]
[PreserveDependency ("Select`2", "System.Linq.Enumerable")]
[PreserveDependency ("SelectMany`2", "System.Linq.Enumerable")]
[PreserveDependency ("SelectMany`3", "System.Linq.Enumerable")]
[PreserveDependency ("SequenceEqual`1", "System.Linq.Enumerable")]
[PreserveDependency ("Single`1", "System.Linq.Enumerable")]
[PreserveDependency ("SingleOrDefault`1", "System.Linq.Enumerable")]
[PreserveDependency ("Skip`1", "System.Linq.Enumerable")]
[PreserveDependency ("SkipLast`1", "System.Linq.Enumerable")]
[PreserveDependency ("SkipWhile`1", "System.Linq.Enumerable")]
[PreserveDependency ("Sum", "System.Linq.Enumerable")]
[PreserveDependency ("Sum`1", "System.Linq.Enumerable")]
[PreserveDependency ("Take`1", "System.Linq.Enumerable")]
[PreserveDependency ("TakeLast`1", "System.Linq.Enumerable")]
[PreserveDependency ("TakeWhile`1", "System.Linq.Enumerable")]
[PreserveDependency ("ThenBy`2", "System.Linq.Enumerable")]
[PreserveDependency ("ThenByDescending`2", "System.Linq.Enumerable")]
[PreserveDependency ("Union`1", "System.Linq.Enumerable")]
[PreserveDependency ("Where`1", "System.Linq.Enumerable")]
[PreserveDependency ("Zip`3", "System.Linq.Enumerable")]
private static MethodInfo FindEnumerableMethod(string name, ReadOnlyCollection<Expression> args, params Type[] typeArgs)
{
if (s_seqMethods == null)

View File

@ -81,15 +81,23 @@ namespace System.Net.Http
}
}
public Uri RequestUri
{
get { return _requestUri; }
set
{
#if MONO
if ((value != null) && (!IsAllowedAbsoluteUri(value)))
{
throw new ArgumentException(SR.net_http_client_http_baseaddress_required, nameof(value));
}
#else
if ((value != null) && (value.IsAbsoluteUri) && (!HttpUtilities.IsHttpUri(value)))
{
throw new ArgumentException(SR.net_http_client_http_baseaddress_required, nameof(value));
}
#endif
CheckDisposed();
// It's OK to set 'null'. HttpClient will add the 'BaseAddress'. If there is no 'BaseAddress'

View File

@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Net;
using System.Net.Http.Headers;
using System.Threading;
using System.Threading.Tasks;
@ -76,7 +77,44 @@ namespace System.Net.Http
string challengeData = challenge.ChallengeData;
string spn = "HTTP/" + authUri.IdnHost;
// Calculate SPN (Service Principal Name) using the host name of the request.
// Use the request's 'Host' header if available. Otherwise, use the request uri.
// Ignore the 'Host' header if this is proxy authentication since we need to use
// the host name of the proxy itself for SPN calculation.
string hostName;
if (!isProxyAuth && request.HasHeaders && request.Headers.Host != null)
{
// Use the host name without any normalization.
hostName = request.Headers.Host;
if (NetEventSource.IsEnabled)
{
NetEventSource.Info(connection, $"Authentication: {challenge.AuthenticationType}, Host: {hostName}");
}
}
else
{
// Need to use FQDN normalized host so that CNAME's are traversed.
// Use DNS to do the forward lookup to an A (host) record.
// But skip DNS lookup on IP literals. Otherwise, we would end up
// doing an unintended reverse DNS lookup.
UriHostNameType hnt = authUri.HostNameType;
if (hnt == UriHostNameType.IPv6 || hnt == UriHostNameType.IPv4)
{
hostName = authUri.IdnHost;
}
else
{
IPHostEntry result = await Dns.GetHostEntryAsync(authUri.IdnHost).ConfigureAwait(false);
hostName = result.HostName;
}
}
string spn = "HTTP/" + hostName;
if (NetEventSource.IsEnabled)
{
NetEventSource.Info(connection, $"Authentication: {challenge.AuthenticationType}, SPN: {spn}");
}
ChannelBinding channelBinding = connection.TransportContext?.GetChannelBinding(ChannelBindingKind.Endpoint);
NTAuthentication authContext = new NTAuthentication(isServer:false, challenge.SchemeName, challenge.Credential, spn, ContextFlagsPal.Connection, channelBinding);
try
@ -135,4 +173,3 @@ namespace System.Net.Http
}
}
}

View File

@ -12,7 +12,7 @@ using System.Threading.Tasks;
namespace System.Net.Sockets
{
// Provides the underlying stream of data for network access.
public class NetworkStream : Stream
public partial class NetworkStream : Stream
{
// Used by the class to hold the underlying socket the stream uses.
private readonly Socket _streamSocket;

View File

@ -52,7 +52,7 @@ namespace System.Net.Sockets
internal Task<Socket> AcceptAsync(Socket acceptSocket)
{
// Get any cached SocketAsyncEventArg we may have.
TaskSocketAsyncEventArgs<Socket> saea = Interlocked.Exchange(ref LazyInitializer.EnsureInitialized(ref _cachedTaskEventArgs).TaskAccept, s_rentedSocketSentinel);
TaskSocketAsyncEventArgs<Socket> saea = Interlocked.Exchange(ref LazyInitializer.EnsureInitialized(ref _cachedTaskEventArgs, () => { return new CachedEventArgs(); }).TaskAccept, s_rentedSocketSentinel);
if (saea == s_rentedSocketSentinel)
{
// An instance was once created (or is currently being created elsewhere), but some other
@ -194,7 +194,7 @@ namespace System.Net.Sockets
return new ValueTask<int>(Task.FromCanceled<int>(cancellationToken));
}
AwaitableSocketAsyncEventArgs saea = LazyInitializer.EnsureInitialized(ref LazyInitializer.EnsureInitialized(ref _cachedTaskEventArgs).ValueTaskReceive);
AwaitableSocketAsyncEventArgs saea = LazyInitializer.EnsureInitialized(ref LazyInitializer.EnsureInitialized(ref _cachedTaskEventArgs, () => { return new CachedEventArgs(); } ).ValueTaskReceive, () => { return new AwaitableSocketAsyncEventArgs(); });
if (saea.Reserve())
{
Debug.Assert(saea.BufferList == null);
@ -343,7 +343,7 @@ namespace System.Net.Sockets
return new ValueTask<int>(Task.FromCanceled<int>(cancellationToken));
}
AwaitableSocketAsyncEventArgs saea = LazyInitializer.EnsureInitialized(ref LazyInitializer.EnsureInitialized(ref _cachedTaskEventArgs).ValueTaskSend);
AwaitableSocketAsyncEventArgs saea = LazyInitializer.EnsureInitialized(ref LazyInitializer.EnsureInitialized(ref _cachedTaskEventArgs, () => { return new CachedEventArgs(); } ).ValueTaskSend, () => { return new AwaitableSocketAsyncEventArgs(); });
if (saea.Reserve())
{
Debug.Assert(saea.BufferList == null);
@ -367,7 +367,7 @@ namespace System.Net.Sockets
return new ValueTask(Task.FromCanceled(cancellationToken));
}
AwaitableSocketAsyncEventArgs saea = LazyInitializer.EnsureInitialized(ref LazyInitializer.EnsureInitialized(ref _cachedTaskEventArgs).ValueTaskSend);
AwaitableSocketAsyncEventArgs saea = LazyInitializer.EnsureInitialized(ref LazyInitializer.EnsureInitialized(ref _cachedTaskEventArgs, () => { return new CachedEventArgs(); } ).ValueTaskSend, () => { return new AwaitableSocketAsyncEventArgs(); });
if (saea.Reserve())
{
Debug.Assert(saea.BufferList == null);
@ -644,7 +644,7 @@ namespace System.Net.Sockets
private Int32TaskSocketAsyncEventArgs RentSocketAsyncEventArgs(bool isReceive)
{
// Get any cached SocketAsyncEventArg we may have.
CachedEventArgs cea = LazyInitializer.EnsureInitialized(ref _cachedTaskEventArgs);
CachedEventArgs cea = LazyInitializer.EnsureInitialized(ref _cachedTaskEventArgs, () => { return new CachedEventArgs(); });
Int32TaskSocketAsyncEventArgs saea = isReceive ?
Interlocked.Exchange(ref cea.TaskReceive, s_rentedInt32Sentinel) :
Interlocked.Exchange(ref cea.TaskSend, s_rentedInt32Sentinel);

View File

@ -215,6 +215,7 @@ namespace System.Net.Sockets.Tests
[Theory]
[MemberData(nameof(ReadAsync_ContinuesOnCurrentContextIfDesired_MemberData))]
[SkipOnTargetFramework(TargetFrameworkMonikers.Mono, "Mono does not yet support `continueOnCapturedContext`.")]
public async Task ReadAsync_ContinuesOnCurrentSynchronizationContextIfDesired(
bool flowExecutionContext, bool? continueOnCapturedContext)
{

View File

@ -1 +1 @@
9c77e0fd0018e3a4328e0e3f0f167ee53b8b9ca5
bd5802af7c3f4bd7c01fbcc60f2a93213c20d5f3

View File

@ -3,8 +3,8 @@
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="Microsoft.Managed.Core.targets"/>
<PropertyGroup Condition="('$(TargetFrameworkIdentifier)' != '.NETCoreApp' OR '$(TargetFrameworkVersion)' != 'v3.0') AND
('$(TargetFrameworkIdentifier)' != '.NETStandard' OR '$(TargetFrameworkVersion)' != 'v2.1')">
<PropertyGroup Condition="('$(TargetFrameworkIdentifier)' != '.NETCoreApp' OR '$(_TargetFrameworkVersionWithoutV)' &lt; '3.0') AND
('$(TargetFrameworkIdentifier)' != '.NETStandard' OR '$(_TargetFrameworkVersionWithoutV)' &lt; '2.1')">
<MaxSupportedLangVersion Condition="'$(MaxSupportedLangVersion)' == ''">7.3</MaxSupportedLangVersion>
<LangVersion Condition="'$(LangVersion)' == ''">$(MaxSupportedLangVersion)</LangVersion>
</PropertyGroup>

View File

@ -1 +1 @@
98fa7406778f8dbfde086154f17ec8f1754a6261
282d58a6250a9638c4b645fc35acec89b5da9d1f

View File

@ -1 +1 @@
db091085345128e9fc42238e03e5e72b296fef55
50cd17bee38ed0b30fb18a1b2807366fb25d47ee

View File

@ -1 +1 @@
4f1824c7c9d77dd2bf072c2f1ed0c2393a80a4de
73e77c620d2f02401c2b04f632afab8301813e2a

View File

@ -1 +1 @@
99d862a2aef02f42e0405ab0b63e09a05bb255a5
f19a88d78b7db406c51b4105d4668cf6ac575a9d

View File

@ -55,12 +55,14 @@
.editorconfig Support
========================
The discovery of .editorconfig files depends on MSBuild features only available in version 16.1 and later. To avoid evaluation errors when
running under earlier versions of MSBuild we place the relevant properties and imports in a separate .targets file.
TODO: Inline the import when we no longer need to support earlier versions of MSBuild.
-->
<Import Project="Microsoft.Managed.EditorConfig.targets" Condition="$(MSBuildVersion) >= 16.1.0" />
<ItemGroup>
<_AllDirectoriesAbove Include="@(Compile->GetPathsOfAllDirectoriesAbove())" Condition="'$(DiscoverEditorConfigFiles)' != 'false'" />
<!-- Work around a GetPathsOfAllDirectoriesAbove() bug where it can return multiple equivalent paths when the
compilation includes linked files with relative paths - https://github.com/microsoft/msbuild/issues/4392 -->
<PotentialEditorConfigFiles Include="@(_AllDirectoriesAbove->'%(FullPath)'->Distinct()->Combine('.editorconfig'))" Condition="'$(DiscoverEditorConfigFiles)' != 'false'" />
<EditorConfigFiles Include="@(PotentialEditorConfigFiles->Exists())" Condition="'$(DiscoverEditorConfigFiles)' != 'false'" />
</ItemGroup>
<!--
========================

View File

@ -2,10 +2,10 @@
<!-- Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -->
<configuration>
<startup>
<AppContextSwitchOverrides value="Switch.System.Security.Cryptography.UseLegacyFipsThrow=false" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<runtime>
<AppContextSwitchOverrides value="Switch.System.Security.Cryptography.UseLegacyFipsThrow=false" />
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.CodeAnalysis.CSharp" publicKeyToken="31bf3856ad364e35" culture="neutral" />

View File

@ -41,7 +41,7 @@ static partial class Consts
// Use these assembly version constants to make code more maintainable.
//
public const string MonoVersion = "6.6.0.140";
public const string MonoVersion = "6.6.0.144";
public const string MonoCompany = "Mono development team";
public const string MonoProduct = "Mono Common Language Infrastructure";
public const string MonoCopyright = "(c) Various Mono authors";

View File

@ -350,6 +350,17 @@ class TestIfaces : ITest
}
}
public class RuntimeInvokeWithThrowClass
{
public RuntimeInvokeWithThrowClass()
{
}
public void RuntimeInvokeThrowMethod()
{
throw new Exception("thays");
}
}
public sealed class DebuggerTaskScheduler : TaskScheduler, IDisposable
{
private readonly BlockingCollection<Task> _tasks = new BlockingCollection<Task>();
@ -543,6 +554,10 @@ public class Tests : TestsBase, ITest2
run_step_out_void_async();
return 0;
}
if (args.Length > 0 && args [0] == "runtime_invoke_hybrid_exceptions") {
runtime_invoke_hybrid_exceptions();
return 0;
}
assembly_load ();
breakpoints ();
single_stepping ();
@ -2191,6 +2206,16 @@ public class Tests : TestsBase, ITest2
public static ref BlittableStruct get_ref_struct() {
return ref ref_return_struct;
}
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void runtime_invoke_hybrid_exceptions () {
Type rtType = Type.GetType("RuntimeInvokeWithThrowClass");
ConstructorInfo rtConstructor = rtType.GetConstructor(Type.EmptyTypes);
object rtObject = rtConstructor.Invoke(new object[] { });
MethodInfo rtMethod = rtType.GetMethod("RuntimeInvokeThrowMethod");
rtMethod.Invoke(rtObject, new object[] { });
}
}
public class SentinelClass : MarshalByRefObject {

View File

@ -1 +1 @@
3556e02df5f76abfe1e39d3c328d2f73485811aa
2bccbb137b170a01de42625d65883e868c508913

View File

@ -27,4 +27,6 @@ partial class SR
public const string SwitchExpressionException_UnmatchedValue = "Unmatched value was {0}.";
public const string Argument_InvalidRandomRange = "Range of random number does not contain at least one possibility.";
public const string BufferWriterAdvancedTooFar = "Cannot advance past the end of the buffer, which has a size of {0}.";
public const string net_gssapi_operation_failed_detailed_majoronly = "GSSAPI operation failed with error - {0}.";
public const string net_gssapi_operation_failed_majoronly = "SSAPI operation failed with status: {0}.";
}

View File

@ -1 +1 @@
e42d54426a1e1d3f1060ba459bf0d7df12630269
56458cedc0a306d35e8a68743d493b8814d3169d

View File

@ -1 +1 @@
71b4d242635c70c9b03cc24f4a5210cc898bf389
a59e995fac121cfdd11ce0d927c7d3b506365f17

View File

@ -1 +1 @@
454ae59b63749df1c592dc2130fa7213b2ef0e9c
9c3f946a8273486a46e3ecb65e87585d7503c454

View File

@ -1 +1 @@
a5c6aed95ba8bc49e3c1b969120cb70f6718271d
8af00e06323acee9808efc1f44407e4730cfa44b

View File

@ -1 +1 @@
912f8605f6a11f646d7e49ab09f34a1701fd9a3d
504693fe2c3e82688c9c46181b298c2d3170baf3

View File

@ -1 +1 @@
358ce5082e789676e06fdf6e7a1279f4186d31a7
d49fc5d9ffdec680a313e9b8599705a995e44eec

View File

@ -1 +1 @@
40787214b81a44904dfc445b7ad3740600a06e89
17172a10d1658aa249b6cee31d22aada88407ee3

View File

@ -1 +1 @@
20df8c42d768a08fd418bcd2f4cb8b18cdc0c758
abf11d020725669c6a911d5edbb6835d9cf97957

View File

@ -1 +1 @@
5e9053da5f69f969e75a3a8c05a6fe3bd1dc1d5e
d6abf4f9d5321c00e4a0e9e3db14c3e12fe8568d

View File

@ -1 +1 @@
24a1d0f66f4ff5e1eab59634988bbf3cf879f335
241fdf7497e5a17407016be28c37cd277be1b093

View File

@ -1 +1 @@
d75e6ff47e2c614235cf640ef55cdb8326b75ced
fdd96f02a656ffe6e476fde83e4774bf4827619b

View File

@ -1 +1 @@
8b6dc65e0cbc140249fa33142feac2235b0940ed
fd7e169e571897602d6585cf7aea84e5cdab5eee

Some files were not shown because too many files have changed in this diff Show More