This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

problem with getgrgid when using "gcc -static"


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:

[dave@cpe0080c6f8615f C]$ gcc foo.c -o foo
[dave@cpe0080c6f8615f C]$ ./foo
uid: 500 gid: 100
group=users

Everything works fine. But, when I do this:

[dave@cpe0080c6f8615f C]$ gcc -static foo.c -o foo
[dave@cpe0080c6f8615f 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:

[dave@cpe0080c6f8615f C]$ rpm --query gcc
gcc-2.96-108.7.2
[dave@cpe0080c6f8615f C]$ rpm --query glibc
glibc-2.2.4-13
[dave@cpe0080c6f8615f 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]