[Mono-list] make check fails

Jonathan Pryor jonpryor at vt.edu
Tue Jun 26 17:53:45 EDT 2007


On Tue, 2007-06-26 at 17:28 +0200, Jurek Bartuszek wrote:
> > You should rather fix the problem on your system. Are you using a
> > chrooted environment for "make check"? Maybe it doesn't contain
> > /etc/group.
> 
> strange, I've tried to build mono outside the chrooted/sandboxed
> environment and still get the same error. The /etc/group file is present:
> 
> # ls -l /etc/group
> -rw-r--r-- 1 root root 827 cze 20 21:15 /etc/group
> 
> so I have no idea what's causing it.

This came up on #mono today in the context of
UnixUserInfo.GetLocalUsers() failing on some systems.  We finally solved
that, and I imagine the UnixGroupInfo problem is the same.

In short: execute the following command as the root user:

	touch /etc/default/nss
	chmod 664 /etc/default/nss

The Long sordid tale:

UnixGroupInfo.GetLocalGroups() and UnixUserInfo.GetLocalUsers() call
setgrent(3) and setpwent(3), respectively.  These functions return
`void', so to check for errors MonoPosixHelper has:

	int Mono_Posix_Syscall_setgrent (void)
	{
		errno = 0;
		setgrent ();
		return errno == 0 ? 0 : -1;
	}

(and similar for setpwent(3).)

I did this because that's what the man page implied I should do:

        Upon error, errno may be set.  If one wants to check errno after
        the call, it should be set to zero before the call.

OK, simple enough.  Yet it still fails.

The problem is that in this case, errno WILL be set to an UNDOCUMENTED
value -- in this case errno is set to ENOENT (because /etc/default/nss
doesn't exist) while the documented error values are EINTR, EIO, EMFILE,
ENFILE, ENOMEM, and ERANGE.

Apparently what MonoPosixHelper *needs* to do is check if errno is one
of these documented values, and if it is then flag an error condition,
otherwise, an error didn't occur.

Which means two things:

1. Errno can be set but "an error didn't occur," leading to...

2. Fugly code:

        int Mono_Posix_Syscall_setgrent (void)
        {
                int e;
                errno = 0;
                setgrent ();
                e = errno;
                if (e == EINTR || e == EIO || e == EMFILE || e == ENFILE
                ||
                                e == ENOMEM || e == ERANGE)
                        return -1;
                return 0;
        }

Blech!

I'll be fixing this in MonoPosixHelper later today or tomorrow, but I
don't know when this "fix" will make it into a proper release, so for
now just create /etc/default/nss and things should Just Work.

 - Jon




More information about the Mono-list mailing list