How to set LD_PRELOAD for su or sudo?

3.9k views Asked by At

I am working on CentOS 6.5. The version of my glibc is 2.14, and I accidentally link /lib64/libc.so.6 to a previous glibc(libc-2.12.so).

Then I run export LD_PRELOAD=/lib64/libc-2.14.so, most commands can be executed except su and sudo. When run su, it gives "Segmentation fault". When run sudo, it gives "su: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /lib64/libcrypt.so.1)".

How to set LD_PRELOAD for su and sudo, or what can I do to recover the glibc?

2

There are 2 answers

0
Employed Russian On

what can I do to recover the glibc?

This is a sysadmin question, more appropriate for serverfault, but one way to recover is:

  1. Boot from a rescue CD
  2. Mount root partition into /mnt
  3. Fix the symlink
  4. Reboot
1
n. m. could be an AI On

There is no way, by design. Setting LD_PRELOAD allows arbitrary code to be executed within the executable. It would be rather unwise to allow that while running a sensitive prvileged SUID program.