bug-glibc
[Top][All Lists]
Advanced

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

problem with getgrgid when using "gcc -static"


From: David Stuart
Subject: problem with getgrgid when using "gcc -static"
Date: Sun, 29 Sep 2002 12:58:21 -0400
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020605

Hi All,

I am having some kind of problem with my machine, and I really could use some help... my main problem is that rpm doesn't work, but I think I have boiled it down to this (after much pain and hard work):

Please note that I am not currently subscribed to either the bug-gcc list, or the bug-glibc list, so could you please CC my address on any replies?

First, take this program, place it into a file called "foo.c" ...

-----8<-----8<-----8<-----

/* foo.c */

#include <stdio.h>

#include <grp.h>

#include <sys/types.h>

#include <sys/stat.h>

#include <string.h>

#include <unistd.h>

#include <errno.h>

extern int errno;

char *getGname(gid_t gid)

{

       char *gnames;

       struct group *gr;

       gr = getgrgid(gid);

       if (gr) {

               gnames = strdup(gr->gr_name);

       } else {

               /* perror( strerror( errno )); */

               gnames = NULL;

       }

       return gnames;

}

int main ()

{

       struct stat sb;

       char * const file="foo";

       lstat(file, &sb);

       printf("uid: %d gid: %d\n",sb.st_uid,sb.st_gid);

       printf("group=%s\n", getGname(sb.st_gid));

}

/* end of foo.c */

-----8<-----8<-----8<-----

Now, here's the quirky part.

On my system, when I do this:

address@hidden C]$ gcc foo.c -o foo
address@hidden C]$ ./foo
uid: 500 gid: 100
group=users

Everything works fine. But, when I do this:

address@hidden C]$ gcc -static foo.c -o foo
address@hidden C]$ ./foo
uid: 500 gid: 100
group=(null)

the program cannot find the group entry for this user!

Can anyone explain to me how this could possibly happen, and (hopefully) what I need to fix on my system to get it working again?

here's some system info:

address@hidden C]$ rpm --query gcc
gcc-2.96-108.7.2
address@hidden C]$ rpm --query glibc
glibc-2.2.4-13
address@hidden C]$ cat ~/sysinfo.txt
Distribution:                  Red Hat Linux
Operating System:              Linux
Distribution Version:          Red Hat Linux release 7.2 (Enigma)

Operating System Version:      #2 Sun Sep 29 02:04:04 EDT 2002
Operating System Release:      2.4.18-10custom
Processor Type:                i686
Host Name:                     cpe0080c6f8615f.cpe.net.cable.rogers.com
User Name:                     dave
X Display Name:                :0
System Status: 12:57pm up 10:48, 2 users, load average: 0.00, 0.07, 0.06



Any help would be appreciated!

Dave





reply via email to

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