getpwuid_r again (problem if compiling -static)




If I compile an app with -static I get the warning:

GLib-WARNING **: getpwuid_r(): failed due to: No such user 1000.

I think this is another glibc bug - it returns the wrong error code
when there is insufficient space.

Anyone else get it?

Damon

(CVS GTK+/GLib as of Thu Feb 18 08:24:12 1999,
2.0.7 test release of the GNU C Library - in Debian 2)


------------------------------------------------------
Small test program to test libc. Compile with -static.

#include <pwd.h>
#include <sys/types.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>

#define REAL_BUFFER_SIZE 256

void
try_getpwuid (int bufsize)
{
  struct passwd *pw = NULL;
  struct passwd pwd;
  char buffer[REAL_BUFFER_SIZE];
  int status, i;
  uid_t uid;

  uid = getuid();

  /* Reset errno. */
  errno = 0;

  status = getpwuid_r (uid, &pwd, buffer, bufsize, &pw);
  printf ("\nBuffer size passed to getpwuid_r: %i\n", bufsize);
  printf ("getpwuid_r returned: %i\n", status);

  if (status == 0)
    {
      /* Display all the passwd fields. */
      printf ("  Name: %s, Password: %s, UID: %i, GID: %i\n  Real Name: %s,
Home Directory: %s, Shell: %s\n",
	      pwd.pw_name, pwd.pw_passwd, pwd.pw_uid, pwd.pw_gid,
	      pwd.pw_gecos, pwd.pw_dir, pwd.pw_shell);
    }
  else
    {
      printf ("errno: %i (%s)\n", errno, strerror (errno));
    }
}

int
main (int argc, char *argv[])
{
  int i;
  for (i = 25; i < 200; i += 30)
    try_getpwuid (i);
}




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]