From glibc-2.2.x to glibc-2.3.x

Grant Leslie grantl at nbnet.nb.ca
Sat Oct 26 15:29:19 PDT 2002


> Greg Schafer wrote:
> > But in our case, it has the unfortunate side effect of breaking
> > "statically
> > linked getpwuid() using binaries that are compiled and linked
> > against a glibc
> > less than or equal to 2.2.5 when run on a glibc-2.3 system for
> > eg: bash, ls,
> > tar, install, etc"    Whew, that was a mouthful :)
>
> If it's only getpwuid(), how ugly a hack ( and would it work? ) would
> something like this be?

This might show what I mean a little better?

[lfs:~$] cat mygetpwuid.c
#include <pwd.h>
#include <stdio.h>

#undef getpwuid

struct passwd *getpwuid (__uid_t id)
{
        struct passwd *my_passwd;

        printf("Using mygetpwuid!\n");

        my_passwd->pw_name="root";
        my_passwd->pw_passwd="x";
        my_passwd->pw_uid=0;
        my_passwd->pw_gid=0;
        my_passwd->pw_gecos="root";
        my_passwd->pw_dir="/root";
        my_passwd->pw_shell="/bin/sh";

        return my_passwd;
}
[lfs:~$] gcc -c mygetpwuid.c
[lfs:~$] cd bash-2.05a/
[lfs:~/bash-2.05a$] rm bash
[lfs:~/bash-2.05a$] make LOCAL_LIBS="../mygetpwuid.o"
rm -f bash
gcc -L./builtins -L./lib/readline -L./lib/readline -L./lib/glob -L./lib/tild
e -L./lib/malloc -L./lib/sh -static -static -rdynamic  -g -O2 -o bash
shell.o eval.o y.tab.o general.o make_cmd.o print_cmd.o  dispose_cmd.o
execute_cmd.o variables.o copy_cmd.o error.o expr.o flags.o jobs.o subst.o
hashcmd.o hashlib.o mailcheck.o trap.o input.o unwind_prot.o pathexp.o sig.o
test.o version.o alias.o array.o arrayfunc.o braces.o bracecomp.o bashhist.o
bashline.o  list.o stringlib.o locale.o findcmd.o redir.o pcomplete.o
pcomplib.o syntax.o
xmalloc.o -lbuiltins -lsh -lreadline -lhistory -lcurses -lglob -ltilde -lmal
loc ../mygetpwuid.o
ls -l bash
-rwxr-xr-x    1 lfs      lfs       2155583 Oct 26 19:24 bash
size bash
   text    data     bss     dec     hex filename
 881157   32368   24152  937677   e4ecd bash
[lfs:~/bash-2.05a$] ./bash
Using mygetpwuid!
[root:~/bash-2.05a$]

-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe lfs-dev' in the subject header of the message



More information about the lfs-dev mailing list