Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!husc6!cmcl2!phri!roy From: roy@phri.UUCP (Roy Smith) Newsgroups: comp.unix.wizards Subject: trouble with getpwuid(3) on SunOS-3.2 Message-ID: <2761@phri.UUCP> Date: Tue, 30-Jun-87 15:36:23 EDT Article-I.D.: phri.2761 Posted: Tue Jun 30 15:36:23 1987 Date-Received: Fri, 3-Jul-87 02:08:46 EDT Reply-To: roy@phri.UUCP (Roy Smith) Organization: Public Health Research Institute, NYC, NY Lines: 84 I've been having some strange problems with getpwuid(3) on a Sun-3.2 system. Here's a little program I wrote to demonstrate the problem: ---------------- # include # include main () { int i; struct passwd *pw; extern int errno; i = getuid(); printf ("i = %d, errno = %d\n", i, errno); perror (""); pw = getpwuid (i); printf ("pw = %#x, errno = %d\n", pw, errno); perror (""); if (pw != NULL) printf ("name = %s, dir = %s\n", pw->pw_name, pw->pw_dir); } ---------------- I've got Sun-3's running both 3.1 and 3.2. Alanine is a 3.1 machine; inosine runs 3.2. I can compile this program on either machine and run it on the same machine with no problem. If, however, I compile it on alanine and run in on inosine (3.2 is supposed to run 3.[01] binaries), I get: inosine% pw.alanine i = 101, errno = 0 Error 0 pw = 0, errno = 49 Can't assign requested address It correctly gets my uid, then the getpwuid() fails. The kicker is that if I login to another 3.2 machine and run the 3.1 binary, it works fine (sort of; see below): cytosine% pw.alanine i = 101, errno = 0 Error 0 pw = 0x215ac, errno = 48 Address already in use <-- huh? name = roy, dir = /usr/goober/roy So, there is obviously something wrong with the way we have inosine set up which allows 3.2 binaries using getpwuid to work properly, but not 3.1 binaries. As far as I can tell, however, both inosine and cytosine are configured the same. As long as the requested passwd entry is in the local /etc/passwd (i.e. you don't need a yellow pages call), it works fine no matter what machine I run it on; for example, a version of pw.c which has "getpwuid(7)" hardwired into it (correctly) gives me back the local entry for ingres: Error 0 pw = 0x215bc, errno = 0 name = ingres, dir = /usr/ingres I'm totally stumped. What could I possibly have set up wrong on inosine which would cause this behaviour? Also, why do I get an "address already in use" indication in errno when the getpwuid() call works? I know errno isn't cleared on non-error calls, but I don't understand where this is comming from anyway. It doesn't happen on non-yp calls (such as the ingres version above). BTW, I got onto this because Adobe's "enscript" (a 3.0 binary copied to the 3.2 server) started dumping core on inosine. Some dbxing showed that a getpwuid() call was failing, but enscript doesn't bother to check for errors (grrrrr...) and later gets a segmentation violation referencing through the null pointer that getpwuid() returns. The obvious and practical thing to do is to just recompile everything under 3.2, but that's not very satisfying. -- Roy Smith, {allegra,cmcl2,philabs}!phri!roy System Administrator, Public Health Research Institute 455 First Avenue, New York, NY 10016