I have no idea why it's failing. Sorry. What I can do is send you a C program which closely mirrors what Mono.Unix is doing. Could you compile and run it, and see if it fails in the same ways? The program source is attached.
- Jon On Wed, 2010-10-13 at 10:43 +0200, pablosantosl...@terra.es wrote: > Hi all, > > The following simple program fails on OpenBSD: > > using System; > using Mono.Unix; > > public class Info > { > > public static void Main() > { > Console.WriteLine(Environment.UserName); > Console.WriteLine(new > UnixUserInfo(Environment.UserName).UserName); > Console.WriteLine(UnixUserInfo.GetRealUser().UserName); > } > } > > > Environment.UserName retrieves the right user. > > > The two next calls fail saying "invalid param": > > Console.WriteLine(new UnixUserInfo(Environment.UserName).UserName); > Console.WriteLine(UnixUserInfo.GetRealUser().UserName); > > It seems the problem is the return of the native method getpwuid_r, that > returns 1 instead of 0. > > I tried running as root to (suspected it could be a permissions issue) > but I get the same result. > > I thought it could be related to an old issue with UnixGroupInfo which > fails if the groups are incorrectly defined (have unexisting users) but > I think this time my config files are correctly set... :O > > Thanks, > > pablo > _______________________________________________ > Mono-devel-list mailing list > Mono-devel-list@lists.ximian.com > http://lists.ximian.com/mailman/listinfo/mono-devel-list
#include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <pwd.h> #include <errno.h> static inline int recheck_range (int ret) { printf ("# checking return value %i; errno=%i\n", ret, errno); if (ret == ERANGE) return 1; if (ret == -1) return errno == ERANGE; return 0; } static void dump_user (const char *user) { int r; struct passwd p, *prev; char *buf, *buf2; size_t buflen; buf = buf2 = NULL; buflen = 2; do { buf2 = realloc (buf, buflen *= 2); if (buf2 == NULL) { printf ("error: unable to allocate enough memory\n"); free (buf); return; } buf = buf2; errno = 0; } while ((r = getpwnam_r (user, &p, buf, buflen, &prev)) && recheck_range (r)); if (r == 0 && !prev) { printf ("User '%s' was not found.\n", user); free (buf); return; } printf ("User %s:\n", user); printf ("\t pw_name=%s\n", p.pw_name); printf ("\t pw_uid=%i\n", p.pw_uid); printf ("\t pw_gid=%i\n", p.pw_gid); printf ("\tpw_gecos=%s\n", p.pw_gecos); printf ("\t pw_dir=%s\n", p.pw_dir); printf ("\tpw_shell=%s\n", p.pw_shell); free (buf); } int main (int argc, char **argv) { int i; for (i = 1; i < argc; ++i) { dump_user (argv [i]); } return 0; }
_______________________________________________ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list