Skip to content

Commit 6407eae

Browse files
authored
improve symlink handling in Ping (#79323)
* improve symlink handling in Ping * update comment * feedback from review
1 parent d0a1ad2 commit 6407eae

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

src/libraries/Common/src/System/Net/NetworkInformation/UnixCommandLinePing.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@ private static bool IsBusyboxPing(string? pingBinary)
4040
{
4141
if (pingBinary != null)
4242
{
43-
string? linkedName = Interop.Sys.ReadLink(pingBinary);
44-
45-
// If pingBinary is not link linkedName will be null
46-
if (linkedName != null && linkedName.EndsWith("busybox", StringComparison.Ordinal))
43+
System.IO.FileSystemInfo? linkInfo = File.ResolveLinkTarget(pingBinary, returnFinalTarget: true);
44+
if (linkInfo?.Name.EndsWith("busybox", StringComparison.Ordinal) == true)
4745
{
4846
return true;
4947
}

src/libraries/System.Net.Ping/src/System.Net.Ping.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@
5656
Link="Common\Interop\Unix\Interop.Libraries.cs" />
5757
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.Close.cs"
5858
Link="Common\Interop\Unix\System.Native\Interop.Close.cs" />
59-
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.ReadLink.cs"
60-
Link="Common\Interop\Unix\System.Native\Interop.ReadLink.cs" />
6159
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.Socket.cs"
6260
Link="Common\Interop\Unix\System.Native\Interop.Socket.cs" />
6361
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.SocketAddress.cs"

0 commit comments

Comments
 (0)