[Mono-bugs] [Bug 80776][Nor] Changed - Syscall.getpwuid_r not working
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Sun Feb 11 17:09:47 EST 2007
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by mrj001 at shaw.ca.
http://bugzilla.ximian.com/show_bug.cgi?id=80776
--- shadow/80776 2007-02-10 16:45:04.000000000 -0500
+++ shadow/80776.tmp.25605 2007-02-11 17:09:47.000000000 -0500
@@ -70,6 +70,63 @@
I built a small c program to call getpwuid_r, and confirmed that this
function works correctly on my system. Therefore, it's somewhere
between the C# code and the c system call. I'll continue to look into
this as I get time.
+
+------- Additional Comments From mrj001 at shaw.ca 2007-02-11 17:09 -------
+This is surprising. Here is some output from a gdb session, where I
+single-stepped through Mono_Posix_Syscall_getpwuid_r:
+(gdb) n
+179 } while ((r = getpwuid_r (uid, &_pwbuf, buf, buflen,
+(struct passwd**) pwbufp)) &&
+(gdb) n
+182 if (r == 0 && copy_passwd (pwbuf, &_pwbuf) == -1)
+(gdb) p r
+$9 = 0
+(gdb) p uid
+$10 = 1000
+(gdb) p _pwbuf
+$11 = {pw_name = 0x828c868 "+", pw_passwd = 0x828c86a "", pw_uid = 0,
+pw_gid = 0,
+ pw_gecos = 0x828c86d "", pw_dir = 0x828c86e "", pw_shell = 0x828c86f ""}
+(gdb) print pwbufp
+$12 = (void **) 0xbfbed428
+(gdb) print *pwbufp
+$13 = (void *) 0x0
+(gdb) n
+184 free (buf);
+(gdb) n
+186 return r;
+(gdb) p r
+$14 = 0
+
+The value for _pwbuf indicates '+' for the user name. This appears to
+be due to my system being a NIS client. The user name being sought is
+one of the NIS user names. The '+' is literally in /etc/passwd.
+
+However, the following C program produces the correct output by
+calling the (same?) pwgetuid_r function!
+#include <pwd.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <stdio.h>
+
+void main()
+{
+ struct passwd pw, *ppw;
+ char buf[1024];
+ int r;
+ uid_t uid;
+
+ uid = getuid();
+ r = getpwuid_r(uid, &pw, buf, sizeof(buf) / sizeof(char), &ppw);
+ printf("r = %d\n", r);
+ printf("ppw = %X\n", ppw);
+ printf("User name: %s\n", ppw->pw_name);
+ printf("home dir: %s\n", ppw->pw_dir);
+}
+
+This is surprising!
+More investigation is required.
+
More information about the mono-bugs
mailing list