{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/corefx/issues/12969","repository_url":"https://api.github.com/repos/dotnet/corefx","labels_url":"https://api.github.com/repos/dotnet/corefx/issues/12969/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/corefx/issues/12969/comments","events_url":"https://api.github.com/repos/dotnet/corefx/issues/12969/events","html_url":"https://github.com/dotnet/corefx/issues/12969","id":184952671,"number":12969,"title":" NetworkInterface.GetAllNetworkInterfaces() throws exception in cloud9 docker container.","user":{"login":"xplicit","id":1506904,"avatar_url":"https://avatars.githubusercontent.com/u/1506904?v=3","gravatar_id":"","url":"https://api.github.com/users/xplicit","html_url":"https://github.com/xplicit","followers_url":"https://api.github.com/users/xplicit/followers","following_url":"https://api.github.com/users/xplicit/following{/other_user}","gists_url":"https://api.github.com/users/xplicit/gists{/gist_id}","starred_url":"https://api.github.com/users/xplicit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xplicit/subscriptions","organizations_url":"https://api.github.com/users/xplicit/orgs","repos_url":"https://api.github.com/users/xplicit/repos","events_url":"https://api.github.com/users/xplicit/events{/privacy}","received_events_url":"https://api.github.com/users/xplicit/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dotnet/corefx/labels/area-System.Net","name":"area-System.Net","color":"d4c5f9"},{"url":"https://api.github.com/repos/dotnet/corefx/labels/X-Plat","name":"X-Plat","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-10-24T20:57:02Z","updated_at":"2016-10-24T21:40:11Z","closed_at":null,"body":"`NetworkInterface.GetAllNetworkInterfaces()` always throws exception if try to run it in cloud9 docker container.\r\n\r\nSteps to reproduce: create new workspace at www.c9.io, then install .net core v1.0.1 and type `dotnet new`. Then add following line in the `Main` method \r\n\r\n       NetworkInterface.GetAllNetworkInterfaces();\r\n\r\nand type `dotnet run` (you're possible need to add necessary references to `project.json`). It throws exception:\r\n\r\n     Unhandled Exception: System.UnauthorizedAccessException: Access to the path '/sys/class/net/lo/operstate' is denied. ---> System.IO.IOException: Permission denied\r\n       --- End of inner exception stack trace ---\r\n       at System.IO.UnixFileStream.CheckFileCall(Int64 result, Boolean ignoreNotSupported)\r\n       at System.IO.UnixFileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent)\r\n       at System.IO.UnixFileSystem.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent)\r\n       at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)\r\n       at System.IO.File.InternalReadAllText(String path, Encoding encoding)\r\n       at System.IO.File.ReadAllText(String path)\r\n       at System.Net.NetworkInformation.LinuxNetworkInterface.GetOperationalStatus(String name)\r\n       at System.Net.NetworkInformation.LinuxNetworkInterface..ctor(String name)\r\n       at System.Net.NetworkInformation.LinuxNetworkInterface.GetOrCreate(Dictionary`2 interfaces, String name)\r\n       at System.Net.NetworkInformation.LinuxNetworkInterface.<>c__DisplayClass5_0.<GetLinuxNetworkInterfaces>b__2(String name, LinkLayerAddressInfo* llAddr)\r\n       at Interop.Sys.EnumerateInterfaceAddresses(IPv4AddressDiscoveredCallback ipv4Found, IPv6AddressDiscoveredCallback ipv6Found, LinkLayerAddressDiscoveredCallback linkLayerFound)\r\n       at System.Net.NetworkInformation.LinuxNetworkInterface.GetLinuxNetworkInterfaces()\r\n       at System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()\r\n       at ConsoleApplication.Program.Main(String[] args)```\r\n\r\nThe bad thing that this exception cannot be catched by `catch (UnauthorizedAccessException)` nor `catch` block without type. What is weird, if try replace \r\n\r\n    NetworkInterface.GetAllNetworkInterfaces(); \r\n\r\nwith \r\n\r\n    File.ReadAllText(\"/sys/class/net/lo/operstate\").Trim();\r\n\r\nWhich is the cause of exception, then the exception can be handled by `catch (UnauthorizedAccessException)` block. So here is two issues: one of about access permissions to `/sys/class/net/lo/operstate` and second that the same exception sometimes can be handled sometimes can not. \r\n"},"comment":{"url":"https://api.github.com/repos/dotnet/corefx/issues/comments/255874308","html_url":"https://github.com/dotnet/corefx/issues/12969#issuecomment-255874308","issue_url":"https://api.github.com/repos/dotnet/corefx/issues/12969","id":255874308,"user":{"login":"mellinoe","id":8918977,"avatar_url":"https://avatars.githubusercontent.com/u/8918977?v=3","gravatar_id":"","url":"https://api.github.com/users/mellinoe","html_url":"https://github.com/mellinoe","followers_url":"https://api.github.com/users/mellinoe/followers","following_url":"https://api.github.com/users/mellinoe/following{/other_user}","gists_url":"https://api.github.com/users/mellinoe/gists{/gist_id}","starred_url":"https://api.github.com/users/mellinoe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mellinoe/subscriptions","organizations_url":"https://api.github.com/users/mellinoe/orgs","repos_url":"https://api.github.com/users/mellinoe/repos","events_url":"https://api.github.com/users/mellinoe/events{/privacy}","received_events_url":"https://api.github.com/users/mellinoe/received_events","type":"User","site_admin":false},"created_at":"2016-10-24T21:40:11Z","updated_at":"2016-10-24T21:40:11Z","body":"From reading around a bit, it sounds like c9.io might be using SELinux or AppArmor or something like that to block access to those folders. We most likely just need to protect against this case.\r\n\r\nI think these need to be upgraded to `catch (IOException)`:\r\n\r\nhttps://github.com/dotnet/corefx/blob/master/src/System.Net.NetworkInformation/src/System/Net/NetworkInformation/LinuxNetworkInterface.cs#L176\r\nhttps://github.com/dotnet/corefx/blob/master/src/System.Net.NetworkInformation/src/System/Net/NetworkInformation/LinuxNetworkInterface.cs#L110"}}
{"actor":{"display_login":"mellinoe"}}