Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
35a79fc
[wasm] Reenable some skipped tests in System.Runtime.Extensions.Tests
Jul 8, 2020
5c905bf
[wasm] PathTests GetFullPath_CoreTests skip test case on browser
Jul 8, 2020
cad48bb
[wasm] System.Runtime.Extensions Tests throwing PNSE
Jul 9, 2020
f8b3c60
[wasm] System.Runtime.Extensions tests throwing Cannot wait on monito…
Jul 9, 2020
9e41643
[wasm] System.Runtime.Extensions tests with ActiveIssues
Jul 9, 2020
0558735
[wasm] System.Runtime.Extensions test throwing EntryPointNotFoundExce…
Jul 9, 2020
c05deb2
[wasm] AppDomainTests modify expected FriendlyName
Jul 9, 2020
b19d161
Add Environment.Browser to eliminate p-invokes that were not function…
Jul 10, 2020
f1a5975
Adjust ICU dependent tests
Jul 10, 2020
c128f6d
Remove browser skip on WorkingSet_Valid
Jul 10, 2020
9745d57
Feedback
Jul 10, 2020
ff310ff
Feedback PathTests.cs
Jul 10, 2020
4a223ed
[wasm] EnvironmentTests Assert Environment.Workinset equals 0
Jul 10, 2020
1038c09
[wasm] StringComparer Use IsNotInvariantGlobalization instead of IsIc…
Jul 10, 2020
bf0521e
Remove System.Runtime.Extensions from skip test list
Jul 10, 2020
b937af6
[wasm] Return emscripten for GetComputerName on Browser
Jul 10, 2020
53350a0
Add back in Environment.UnixOrBrowser
Jul 10, 2020
f625e66
Cleaned up a few comments
Jul 10, 2020
3a4ea9c
Merge branch 'master' into mdhwang/address_system_runtime_extensions_…
akoeplinger Jul 11, 2020
8d13b06
Merge branch 'master' into mdhwang/address_system_runtime_extensions_…
akoeplinger Jul 11, 2020
952997c
PR Feedback
Jul 12, 2020
c7343fa
One more thing...
Jul 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
One more thing...
  • Loading branch information
Steve Pfister committed Jul 13, 2020
commit c7343fac9925ece070b923ce72e3da7a603b814c
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,41 @@ public static unsafe string UserName

}
}

private static unsafe bool TryGetUserNameFromPasswd(byte* buf, int bufLen, out string? username)
{
// Call getpwuid_r to get the passwd struct
Interop.Sys.Passwd passwd;
int error = Interop.Sys.GetPwUidR(Interop.Sys.GetEUid(), out passwd, buf, bufLen);

// If the call succeeds, give back the user name retrieved
if (error == 0)
{
Debug.Assert(passwd.Name != null);
username = Marshal.PtrToStringAnsi((IntPtr)passwd.Name);
return true;
}

// If the current user's entry could not be found, give back null,
// but still return true (false indicates the buffer was too small).
if (error == -1)
{
username = null;
return true;
}

var errorInfo = new Interop.ErrorInfo(error);

// If the call failed because the buffer was too small, return false to
// indicate the caller should try again with a larger buffer.
if (errorInfo.Error == Interop.Error.ERANGE)
{
username = null;
return false;
}

// Otherwise, fail.
throw new IOException(errorInfo.GetErrorMessage(), errorInfo.RawErrno);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,42 +56,6 @@ private static string ExpandEnvironmentVariablesCore(string name)

public static int SystemPageSize => CheckedSysConf(Interop.Sys.SysConfName._SC_PAGESIZE);

private static unsafe bool TryGetUserNameFromPasswd(byte* buf, int bufLen, out string? username)
{
// Call getpwuid_r to get the passwd struct
Interop.Sys.Passwd passwd;
int error = Interop.Sys.GetPwUidR(Interop.Sys.GetEUid(), out passwd, buf, bufLen);

// If the call succeeds, give back the user name retrieved
if (error == 0)
{
Debug.Assert(passwd.Name != null);
username = Marshal.PtrToStringAnsi((IntPtr)passwd.Name);
return true;
}

// If the current user's entry could not be found, give back null,
// but still return true (false indicates the buffer was too small).
if (error == -1)
{
username = null;
return true;
}

var errorInfo = new Interop.ErrorInfo(error);

// If the call failed because the buffer was too small, return false to
// indicate the caller should try again with a larger buffer.
if (errorInfo.Error == Interop.Error.ERANGE)
{
username = null;
return false;
}

// Otherwise, fail.
throw new IOException(errorInfo.GetErrorMessage(), errorInfo.RawErrno);
}

public static string UserDomainName => MachineName;

/// <summary>Invoke <see cref="Interop.Sys.SysConf"/>, throwing if it fails.</summary>
Expand Down