[Mono-list] Ldap and Mono.Unix, is it a bug?

Jonathan Pryor jonpryor at vt.edu
Thu May 18 19:14:15 EDT 2006


On Thu, 2006-05-18 at 15:33 -0300, Arx Henrique wrote:
> UnixUserInfo[] usuarios = Mono.Unix.UnixUserInfo.GetLocalUsers();
> 
> and my ldap server is up, i got this exception:
> 
> Unhandled Exception: System.IO.FileNotFoundException:  ---->
> Mono.Unix.UnixIOException:
> in [0x00005] (at
> /home/ingo/mono-1.1.13.6/mcs/class/Mono.Posix/Mono.Unix/UnixMarshal.cs:446)
> Mono.Unix.UnixMarshal:ThrowExceptionForLastError ()
> in [0x0004f] (at
> /home/ingo/mono-1.1.13.6/mcs/class/Mono.Posix/Mono.Unix/UnixUserInfo.cs:167)
> Mono.Unix.UnixUserInfo:GetLocalUsers ()

This is because the current version of GetLocalUsers() calls getpwent(3)
until it returns NULL, then reads errno to determine if an error
occurred.  When your LDAP server is running, errno is ENOENT instead of
0, so GetLocalUsers() thinks an error actually occurred, thus resulting
in the exception.

I have no idea why LDAP would be changing the behavior of getpwent(3) in
this fashion, and I don't know what a workaround would be either.

Even odder, ENOENT (the errno which maps to FileNotFoundException) isn't
even a valid error, according to the FC2 getpwent(3) man page...

> And sadly i cant upgrade to new mono version... :(

And a new mono version wouldn't fix this issue anyway... :-/

 - Jon




More information about the Mono-list mailing list