[Mono-dev] UnixUserInfo issues in OpenBSD

Jonathan Pryor jonpryor at vt.edu
Wed Oct 13 12:56:17 EDT 2010

On Wed, 2010-10-13 at 16:38 +0200, pablosantosluac at terra.es wrote:
> This is what I get:
> $ ./a.out tester
> # checking return value 1; errno=13

That's...horribly wrong.

First, what's errno=13?  (i.e. what EVALUE is 13?  I'm sure OpenBSD has
different values than Linux does.)

Regardless, OpenBSD doesn't appear to be conforming to the standard


        If successful, the getpwnam_r() function shall return zero;
        otherwise, an error number shall be returned to indicate the

The value '1' is likely not the correct errno for ERANGE (Under Linux,
EPERM has the value 1), and since the return value isn't -1
recheck_range() won't check errno against ERANGE either.

However, this does point out a bug in MonoPosixHelper: if getpwnam_r()
returns non-zero it should treat it as an error, which is clearly not
happening here (and is why we're printing garbage data to the screen).

This would only marginally help you, though, as it would result in no
users being found, ever.

The fundamental problem is that Mono_Posix_Syscall_getpwnam_r()'s logic
for checking for ERANGE (so it'll resize the buffer and try the call
again) is failing under OpenBSD, and from what I can see here the
problem is within OpenBSD, not MonoPosixHelper.

Patches welcome to properly support OpenBSD. :-)

 - Jon

More information about the Mono-devel-list mailing list