Bug 36382 - CommonUnixIPGlobalProperties.DomainName does not work on solaris
Summary: CommonUnixIPGlobalProperties.DomainName does not work on solaris
Status: ASSIGNED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System (show other bugs)
Version: master
Hardware: PC Other
: --- normal
Target Milestone: Untriaged
Assignee: Raul
URL:
Depends on:
Blocks:
 
Reported: 2015-11-30 17:16 UTC by Raul
Modified: 2015-12-10 14:57 UTC (History)
2 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description Raul 2015-11-30 17:16:34 UTC
CommonUnixIPGlobalProperties assumes that libc has getdomainname and gethostname functions.
https://github.com/mono/mono/blob/9ea2f50a2adefdeadefbf8f49aa94404e3175a1f/mcs/class/System/System.Net.NetworkInformation/IPGlobalProperties.cs#L98

On solaris these functions are not defined on libc but instead they are defined on libnsl. You can see a related discussion at https://lists.gnu.org/archive/html/bug-gnulib/2010-11/msg00328.html.

Mono.Unix.Native.Syscall also defines getdomainname and gethostname. https://github.com/mono/mono/blob/b7a308f660de8174b64697a422abfc7315d07b8c/mcs/class/Mono.Posix/Mono.Unix.Native/Syscall.cs#L4230
This uses MPH lib which defines the functions here: https://github.com/mono/mono/blob/b7a308f660de8174b64697a422abfc7315d07b8c/support/unistd.c#L212

The patch at https://bugzilla.xamarin.com/show_bug.cgi?id=32010 will add the correct getdomainname and gethostname functions to unistd.c (maybe ?). In order to fix CommonUnixIPGlobalProperties I think we should have it call into Mono.Unix.Native.Syscall.getdomainname instead of declaring getdomainname as an extern to libc.

This popped up because the System.Net.CookieContainer class was migrated to use the ms reference sources. The ms reference sources grab the domain name https://github.com/Microsoft/referencesource/blob/master/System/net/System/Net/cookiecontainer.cs#L122.

A simple test case for solaris would be:

    new System.NetCookieContainer();


Also,
I'm not sure if calling getdomainname on libnsl is actually the correct thing to do here. According that that linked discussion the usage of getdomainname is discouraged because it really returns the NIS domainname, not necessarily the DNS domain name.
Comment 1 Andi McClure 2015-12-09 19:45:21 UTC
Hi Raul,

Although we have not fully updated our website to reflect this yet, we do not actively support solaris/sparc anymore. (On testing, I was not readily able to even compile current mono on a stock Solaris 11.) We are happy to take community patches, however.

Do you have the ability to compile Mono yourself? There are two things I am wondering:

- Have you had an opportunity to test the patch in #32010? Can you confirm it works?

- Would you be willing to submit a patch for the CommonUnixIPGlobalProperties issue? Unfortunately the mono class libraries cannot take a dependency on Mono.Posix, so what I would recommend is having something at compile time detect the platform is solaris  rather than and substitute libnsl in the DllImport.

I am assigning this bug to you, please feel free to assign back to me with your response.
Comment 2 Raul 2015-12-10 14:57:50 UTC
The specific environment I was using was SmartOS.

They use pkgsrc to build mono: https://pkgsrc.joyent.com

There are currently quite a few patches required to build mono successfully: ftp://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/lang/mono/patches/

I haven't tried to compile mono my self yet. I'm assuming it's as simple as running a bmake in the pkgsrc/mono directory.

I have not tried the patch in #32010 yet.

Do you have an example on how to perform the substitution?

I'm not sure I have the time to actually tackle the bug, but if I have time this weekend I'll see if I can get mono compiled.

Note You need to log in before you can comment on or make changes to this bug.