Karl (supersat) wrote in supersat_tech,
Karl
supersat
supersat_tech

Note to self:

Messing with glibc is a bad, bad idea.

To make a long story short, I tried copying the binaries (and the libraries it depends on) for Apache2 PHP from my gentoo machine to a server at nEXGeN. I then got this error:

cerebellum:/usr/lib/apache2# /usr/sbin/apache2
/usr/sbin/apache2: /lib/libc.so.6: version `GLIBC_2.2' not found (required by /usr/sbin/apache2)
/usr/sbin/apache2: /lib/libc.so.6: version `GLIBC_2.3' not found (required by /usr/sbin/apache2)
/usr/sbin/apache2: /lib/libc.so.6: version `GLIBC_2.3' not found (required by /usr/lib/libaprutil-0.so.0)
...


I foolishly decide to upgrade libc.so.6. It's currently just a symlink to /lib/libc-2.1.3.so, so I figure I can just delete the symlink and upload a new version of libc.so.6. If it doesn't work, I can always fall back on the old version by recreating the symlink, right?

Wrong.

root@mask apache2 # scp /lib/libc.so.6 root@degdeg.com:/lib
root@degdeg.com's password:
bash: error in loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
lost connection


Well fuck.

I attempt to restore the symlink:

cerebellum:/lib# ln -s libc-2.1.3.so libc.so.6
ln: error in loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory


In a panic, I start running through the possibilities of restoring libc.so.6:

cerebellum:/lib# perl
perl: error in loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
cerebellum:/lib# nano
nano: error in loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
cerebellum:/lib# /bin/sh
/bin/sh: error in loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
cerebellum:/lib# ls -al
ls: error in loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
cerebellum:/lib# cp libc-2.1.3.so libc.so.6
cp: error in loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory


At this point I figure I'm pretty much fucked. The server is about 220 miles away, and no one is at nEXGeN to physically kick the server.

However, I notice that the FTP server is able to accept connections and transfer files. I wind up writing a small assembly program (which wouldn't depend on glibc) to recreate the symlink:

section .text
global _start

src db 'libc-2.1.3.so',0x0
dest db 'libc.so.6',0x0

_start:
mov edx,0
mov ecx, dest
mov ebx, src
mov eax, 83
int 0x80

mov eax,1
int 0x80


I compile it, turn it into an ELF, send it off, and try to execute it:
cerebellum:/lib# ~mrsaturn/omgwtf
bash: /home/mrsaturn/omgwtf: Permission denied


Fucking hell. I don't have any FTP program capable of doing chmods. I wind up being able to do it from the Windows FTP client:
ftp> literal site chmod 777 omgwtf
200 SITE CHMOD command successful.


And now, the moment of truth:

cerebellum:/lib# ~mrsaturn/omgwtf
cerebellum:/lib# ls -al
total 4732
...
lrwxrwxrwx 1 root root 13 Jul 12 23:04 libc.so.6 -> libc-2.1.3.so
...


At this point, I fall over in shock that I was actually able to revive the machine.
  • Post a new comment

    Error

    default userpic
  • 6 comments