bug-glibc
[Top][All Lists]
Advanced

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

Question about static linking and glibc


From: David Stuart
Subject: Question about static linking and glibc
Date: Tue, 01 Oct 2002 23:02:59 -0400
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020605

Hi All,

(note, I'm not subscribed to this list, please CC me personally when replying)

Based on my previous conversation with Zack Weinberg, I understand that one is not supposed to statically link programs that use any of the "getXXbyYY" or "getXXid" routines.. I have noticed that whenever I do on my machine, a system call like "getgrgid" will always return null, even if the group exists. The same might be happening for the getpwuid call as well (see my previous post titled "problem with getgrgid when using gcc -static").

But if this is the case, I have a REAL problem.

I have repeatedly been getting the error message from rpm "error: Bad owner/group: [my rpm file]" when trying to rebuild an rpm. I have traced the issue to somewhere in glibc.

Consider for a moment that rpm is a statically linked executable:

address@hidden NVIDIA_kernel-1.0-2960]$ ldd `which rpm`
       not a dynamic executable

Also, note the following code from rpm-4.0.4-7x:

-------------------------------------
/**
* Check that file owner and group are known.
* @param urlfn        file url
* @return        0 on success
*/
static int checkOwners(const char * urlfn)
   /address@hidden fileSystem @*/
   /address@hidden fileSystem @*/
{
   struct stat sb;

   if (Lstat(urlfn, &sb)) {
   rpmError(RPMERR_BADSPEC, _("Bad source: %s: %s\n"),
       urlfn, strerror(errno));
   return RPMERR_BADSPEC;
   }
   if (!getUname(sb.st_uid) || !getGname(sb.st_gid)) {
rpmError(RPMERR_BADSPEC, _("Bad owner/group: %s\n"), urlfn); /* <---- MY ERROR MESSAGE */
   return RPMERR_BADSPEC;
   }

   return 0;
}

const char *getUname(uid_t uid)
{
   struct passwd *pw;
   int x;

   for (x = 0; x < uid_used; x++) {
   if (unames[x] == NULL) continue;
   if (uids[x] == uid)
       return unames[x];
   }

   /* XXX - This is the other hard coded limit */
   if (x == 1024)
   rpmlog(RPMLOG_CRIT, _("getUname: too many uid's\n"));
   uid_used++;
pw = getpwuid(uid);
   uids[x] = uid;
   unames[x] = (pw ? xstrdup(pw->pw_name) : NULL);
   return unames[x];
}

const char *getGname(gid_t gid)
{
   struct group *gr;
   int x;

   for (x = 0; x < gid_used; x++) {
   if (gnames[x] == NULL) continue;
   if (gids[x] == gid)
       return gnames[x];
   }

   /* XXX - This is the other hard coded limit */
   if (x == 1024)
   rpmlog(RPMLOG_CRIT, _("getGname: too many gid's\n"));
   gid_used++;
gr = getgrgid(gid);
   gids[x] = gid;
   gnames[x] = (gr ? xstrdup(gr->gr_name) : NULL);
   return gnames[x];
}
-------------------------------------


The important part to notice here is that rpm is statically linked, AND it uses the functions getgrgid and getpwuid to obtain group and user information, consistently causing the aforementioned error message and subsequent bashing of my skull against the wall.

Since RPM must work for the thousands of redhat users out there, I assume that it must therefore be possible to statically link an executable and use these functions. Therefore I must conclude that my system is somehow misconfigured, or has a corrupt file that needs to be replaced.

Can anyone help me before I go bonkers??





reply via email to

[Prev in Thread] Current Thread [Next in Thread]