Description
In restricted environments such as a container with limited access, shared hosting, chroot and other forms of sandbox, .NET process may not have read permissions on procfs files, while the file may exist. This can lead to UnauthorizedAccessException
.
While most of the managed code reading procfs files in the runtime repo found by git grep /proc ':/*.cs' ':/!*[tT]est*'
seem to handle unauhorized access case, we should try to make the user-experience consistent and align varied styles where possible. A few examples:
and then there are cases in NetworkInformation
, which do not handle the exception at all. Majority of procfs files listed in NetworkInformation/NetworkFiles.cs
are read via StringParsingHelpers
. Some call sites catch IOException
and UnauthorizedAccessException
, others don't and it seems unintentional. For instance, GetIcmpV4Statistics
and GetTcpIPv4Statistics
docs do not mention PlatformNotSupportedException
, IOException
or UnauthorizedAccessException
are the possible exceptions which these APIs can throw, only NetworkInformationException
is noted.