Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#326777 - 18/10/2009 03:59 running ancient code on a modern machine
DWallach
carpal tunnel

Registered: 30/04/2000
Posts: 3810
On an archaeological kick to read ancient email that I wrote some 20 years ago, I discovered that about a six window archive of my own email was missing. Undaunted, I decided to contact one of my friends, to whom I'd written a fair bit at the time, to see what he had.

Well, he somehow kept what appears to be a complete archive of what I sent him. He thoughtfully used Unix 'crypt' to encrypt it, presumably to keep prying eyes from sorting out what our private messages were about at the time. Needless to say, twenty years later, he's forgotten the encryption key, but he's still got the raw ciphertext and he's absolutely certain that he used Unix crypt.

Today, there are two tools that can break 'crypt' encryption. unixcrypt-breaker is point-and-shoot, clearly identifying a good bit of plaintext, but not enough to actually read it. It's clear where there are errors, but there's no mechanism to say 'that clearly must be a period.' The elder tool, the crypt breaker's workbench, has an interactive GUI, but it was written back in the 80's and it shows.

I first cleaned up the code enough that it would compile without errors. It's a termcap / curses application, using a bit of each, in ways that segfaults on my Mac. I attempted to hardcode around some of the nonsense, and ended up with something that runs, but displays incorrectly (and unusably). I'm probably going to have to burn a solid day to tear out all the old character graphics and port it to ncurses or even to a modern GUI app. But all so that I can read a small pile of 20 year old email. Worth it? Maybe.

Am I missing something? Is there some other modern port of the crypt breaker's workbench? Is there a binary that I can get which just runs?

Top
#326784 - 18/10/2009 13:02 Re: running ancient code on a modern machine [Re: DWallach]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14494
Loc: Canada
Rather than running the old code on a new machine/OS, why not hunt down a similarly old machine/OS ?

Top
#326785 - 18/10/2009 15:38 Re: running ancient code on a modern machine [Re: mlord]
drakino
carpal tunnel

Registered: 08/06/1999
Posts: 7868
No need for the old machine even, just fire up a VM and install an old OS into it. If you don't have something like VMWare Fusion already, the free Sun VirtualBox may meet your needs.

Top
#326786 - 18/10/2009 16:03 Re: running ancient code on a modern machine [Re: drakino]
DWallach
carpal tunnel

Registered: 30/04/2000
Posts: 3810
Okay, I've got VMware Fusion. What OS platform would you recommend to compile circa-1986 pre-ANSI C code built against termcap and curses?

Top
#326789 - 18/10/2009 20:32 Re: running ancient code on a modern machine [Re: DWallach]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
_________________________
Bitt Faulk

Top
#326792 - 18/10/2009 20:58 Re: running ancient code on a modern machine [Re: drakino]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14494
Loc: Canada
Originally Posted By: drakino
No need for the old machine even, just fire up a VM and install an old OS into it. If you don't have something like VMWare Fusion already, the free Sun VirtualBox may meet your needs.

I don't think that is going to work with software which predates the invention of the PCI bus.

Top
#326855 - 20/10/2009 15:13 Re: running ancient code on a modern machine [Re: mlord]
matthew_k
pooh-bah

Registered: 12/02/2002
Posts: 2298
Loc: Berkeley, California
I came across a similar problem that I'll have to solve this week for a client. He's got an old web site, circa 1998. It's got cgi-scripts running on Apache, now on an old redhat server. The cgi-scripts are written in C. And include a cgi-bin.h library of some sort. The cgi-scripts are very proprietary, people still pay by the month to access them, but there's no budget or desire to modernize them, as the original team has moved on.

Without realizing this I set up the new server with a 64bit ubuntu LTS install, and moved over the first web site which is just static content, and transferred email duties over to it, so now I've got a live server that I'm trying to migrate the old code to.

Are the binaries likely to work on a 32bit modern install of ubuntu? (I suppose this would be easy enough to test, but I didn't have one handy) I've got the original source, but no real clue how to go about finding the libraries on a modern system to get it to compile. Is there some compiler switch to make sure any 32bit logic works on the 64 bit machine? Should I just virtualize the current redhat machine and put it behind a (hopefully password protected) proxy?

Top
#326857 - 20/10/2009 15:37 Re: running ancient code on a modern machine [Re: matthew_k]
tman
carpal tunnel

Registered: 24/12/2001
Posts: 5528
Assuming you've got the required 32 bit libraries, a 32 bit binary should work fine in nearly all cases. As per usual with any migration, its all about the testing.

Top
#326858 - 20/10/2009 15:38 Re: running ancient code on a modern machine [Re: matthew_k]
peter
carpal tunnel

Registered: 13/07/2000
Posts: 4180
Loc: Cambridge, England
Originally Posted By: matthew_k
Are the binaries likely to work on a 32bit modern install of ubuntu? (I suppose this would be easy enough to test, but I didn't have one handy) I've got the original source, but no real clue how to go about finding the libraries on a modern system to get it to compile. Is there some compiler switch to make sure any 32bit logic works on the 64 bit machine?

Most (all?) 64-bit distros actually have a combined 32/64-bit userland, so that both 32-bit and 64-bit binaries can run. If you install the right libraries (and have the right kernel options set), even really old 32-bit a.out binaries can run on modern 64-bit systems.

If you do recompile the binaries, use "gcc -m32" to force the compiler to make 32-bit binaries even on a 64-bit system.

Peter

Top
#326862 - 20/10/2009 16:08 Re: running ancient code on a modern machine [Re: peter]
drakino
carpal tunnel

Registered: 08/06/1999
Posts: 7868
Icculus (Ryan Gordon) has been working on adding FatELF support to Linux. Basically a similar concept to OS X Universal Binaries, and other various fat binary implementations. An example Ubuntu VM is here.

Top
#326875 - 20/10/2009 19:29 Re: running ancient code on a modern machine [Re: matthew_k]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14494
Loc: Canada
Originally Posted By: matthew_k
Are the binaries likely to work on a 32bit modern install of ubuntu?

Maybe.

They might require the compat-libc5 library packages, and you may have to manually install /lib/ld-linux.so.1 before they are recognized as "executables". Or not. Try them.

Quote:
Should I just virtualize the current redhat machine and put it behind a (hopefully password protected) proxy?

Yes, absolutely virtualize it (the whole bundle.. just copy the hard disk). Then use the host machine security to protect them.

Cheers

Top
#326883 - 20/10/2009 21:51 Re: running ancient code on a modern machine [Re: mlord]
matthew_k
pooh-bah

Registered: 12/02/2002
Posts: 2298
Loc: Berkeley, California
Thanks for all the advice, I'll report back tomorrow with what progress I make.

Top
#326904 - 21/10/2009 13:35 Re: running ancient code on a modern machine [Re: matthew_k]
matthew_k
pooh-bah

Registered: 12/02/2002
Posts: 2298
Loc: Berkeley, California
Ok, so here's what I get when I try and run one of executables from the command line:
Code:
mkocher@ganesh:~$ ls -l passwd.cgi 
-r-xr-xr-x 1 mkocher mkocher 142411 2009-10-21 08:29 passwd.cgi
mkocher@ganesh:~$ file passwd.cgi 
passwd.cgi: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), 
for GNU/Linux 2.2.5, dynamically linked (uses shared libs), not stripped
mkocher@ganesh:~$ ./passwd.cgi 
-bash: ./passwd.cgi: No such file or directory

That doesn't mean a whole lot to me. Dynamically linked makes think this will never work. I'll move on to trying the package mlord mentioned.

Top
#326907 - 21/10/2009 14:05 Re: running ancient code on a modern machine [Re: matthew_k]
matthew_k
pooh-bah

Registered: 12/02/2002
Posts: 2298
Loc: Berkeley, California
Ok, the same executable on a 32bit ubuntu install gives me a little more:

./passwd.cgi: error while loading shared libraries: libdb-4.0.so: cannot open shared object file: No such file or directory

Top
#326917 - 21/10/2009 16:31 Re: running ancient code on a modern machine [Re: matthew_k]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14494
Loc: Canada
Post the output of: readelf -a passwd.cgi | grep interpreter

Top
#326920 - 21/10/2009 17:15 Re: running ancient code on a modern machine [Re: mlord]
matthew_k
pooh-bah

Registered: 12/02/2002
Posts: 2298
Loc: Berkeley, California
Code:
$ readelf -a passwd.cgi | grep interpreter
[Requesting program interpreter: /lib/ld-linux.so.2]

For libdb-4.0.so, I tried making a link to libdb-4.so, which at least let it move past the error, however, it got just as stuck on the next library.
Code:
./passwd.cgi: error while loading shared libraries: libmysqlclient.so.10: 
cannot open shared object file: No such file or directory

I've just found a couple Makefiles, the nominal one did not have valid paths. These may be, I haven't chased them all down yet:
Code:
CC=gcc -Dlinux -Wall -O
#CC=gcc -Dsolaris -Wall
#CC=cc -Dluke0
#DBINC=-I/usr/local/BerkeleyDB/include
DBINC=-I/usr/include
SQLINC=-I/usr/include/mysql 
CGIINC=-I/usr/local/etc/httpd/cgi-src/include
SQLLIB=-L/usr/lib/mysql -lmysqlclient 
DBLIB=-I/usr/lib -ldb -lcrypt
CGILIB=-L/usr/local/etc/httpd/cgi-src/lib -lcgihtml



Edited by matthew_k (21/10/2009 19:38)

Top
#326921 - 21/10/2009 17:28 Re: running ancient code on a modern machine [Re: matthew_k]
tman
carpal tunnel

Registered: 24/12/2001
Posts: 5528
Don't use code if you've got super long sentences. It messes up the formatting and makes the whole page really wide.

It uses MySQL and Berkeley Database? Odd.

Top
#326923 - 21/10/2009 17:35 Re: running ancient code on a modern machine [Re: tman]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31599
Loc: Seattle, WA
Originally Posted By: tman
Don't use code if you've got super long sentences.
It messes up the formatting and makes the whole page really
wide.


I've always wanted to figure out how to edit this BBS's
style sheet so that each post was fixed properly, with its
width settings configured so that they went the width of
the browser instead of the width of the parent element.

I don't know how to do that, though.

Anyone know how?
_________________________
Tony Fabris

Top
#326926 - 21/10/2009 17:41 Re: running ancient code on a modern machine [Re: tfabris]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
It'd have to be ported from using tables to using divs.
_________________________
Bitt Faulk

Top
#326927 - 21/10/2009 17:43 Re: running ancient code on a modern machine [Re: wfaulk]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31599
Loc: Seattle, WA
You can't say "I want this table to resize to the width of the browswer window"? Even with CSS?
_________________________
Tony Fabris

Top
#326928 - 21/10/2009 17:44 Re: running ancient code on a modern machine [Re: matthew_k]
peter
carpal tunnel

Registered: 13/07/2000
Posts: 4180
Loc: Cambridge, England
Originally Posted By: matthew_k
Quote:

$ readelf -a passwd.cgi | grep interpreter
[Requesting program interpreter: /lib/ld-linux.so.2]

For libdb-4.0.so, I tried making a link to libdb-4.so, which at least let it move past the error, however, it got just as stuck on the next library.
Quote:
./passwd.cgi: error while loading shared libraries: libmysqlclient.so.10: cannot open shared object file: No such file or directory

So carry on. Install the 32-bit libmysqlclient.so.10 package. To avoid getting these errors one-by-one, you can use
Code:
ldd ./passwd.cgi

to see a list all the dynamic libraries it's looking for. If it's looking for some in the wrong place (e.g. if libmysqlclient.so.10 is already installed but somewhere weird), then use
Code:
LD_LIBRARY_PATH=/dir/where/lib/is ldd ./passwd.cgi


Peter

Top
#326930 - 21/10/2009 18:22 Re: running ancient code on a modern machine [Re: tfabris]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
It's a nightmare of tables inside tables inside tables. Who knows?
_________________________
Bitt Faulk

Top
#326939 - 21/10/2009 21:03 Re: running ancient code on a modern machine [Re: wfaulk]
matthew_k
pooh-bah

Registered: 12/02/2002
Posts: 2298
Loc: Berkeley, California
Code:
# ldd ./passwd.cgi
linux-gate.so.1 =>  (0xb7f4b000)
libdb-4.0.so => /usr/lib/libdb-4.0.so (0xb7e1d000)
libcrypt.so.1 => /lib/tls/i686/cmov/libcrypt.so.1 (0xb7deb000)
libmysqlclient.so.10 => not found
libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7c9b000)
libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0xb7c83000)
/lib/ld-linux.so.2 (0xb7f4c000)

So by my reading libmysqlclient.so.10 is the only thing I need to find?

apt-get reports:
Code:
Package libmysqlclient10-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

I'm sure it has been "obsoleted" (is that really proper usage?) but I'm not sure it's available from another source. I can find RPMs that include it, and Dapper Drake (Ubuntu 6.0.2) has a package for it. Any chance I can just copy these .so files from the old server? Do they themselves have dependencies?

Top
#326940 - 21/10/2009 21:16 Re: running ancient code on a modern machine [Re: matthew_k]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
You can run ldd against those libraries, too, but it's slightly unusual for libraries to have dependencies on other libraries. And you should be able to just copy them over.
_________________________
Bitt Faulk

Top
#326941 - 21/10/2009 23:12 Re: running ancient code on a modern machine [Re: matthew_k]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14494
Loc: Canada
Here (attached) is a libmysqlclient.so.10 binary (from Ubuntu Dapper Drake).


Attachments
libmysqlclient.so.10 (253 downloads)


Top
#326943 - 21/10/2009 23:26 Re: running ancient code on a modern machine [Re: mlord]
matthew_k
pooh-bah

Registered: 12/02/2002
Posts: 2298
Loc: Berkeley, California
Thanks for the file, I put it in place and it's segfaulting, which is definite progress. I'll try the original .so files it was compiled against tonight or tomorrow when I can get a hold of them.

Top
#326945 - 21/10/2009 23:33 Re: running ancient code on a modern machine [Re: matthew_k]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14494
Loc: Canada
I still think a good strategy would be to just take the original installation, *complete*, and stick it into a VM.

Cheers

Top
#326946 - 21/10/2009 23:36 Re: running ancient code on a modern machine [Re: mlord]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14494
Loc: Canada
Mmm.. compiler must be different (gee, what a surprise).

How about the Redhat9 version of libmysqlclient10?


Edited by mlord (21/10/2009 23:36)

Top
#326947 - 21/10/2009 23:38 Re: running ancient code on a modern machine [Re: mlord]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14494
Loc: Canada
Oh.. speaking of ancient Redhat .rpm files, here's an old script I once wrote to extract the contents of any .rpm file. I call it rpm_extract.sh:
Code:
#!/bin/bash
while [ ! "$1" = "" ]; do
        dir="${1%%.rpm}"
        if [ "$dir" == "$1" ]; then
                dir="${1%%.mvl}"        ## MontaVistaLinux (.mvl) rpm files
        fi
        echo "Extracting $1 to $dir"
        if [ ! -d "${dir}" ]; then
                mkdir "${dir}"
        fi
        cd "${dir}" && ( rpm2cpio "../$1" | cpio -i --make-directories )
        cd - &>/dev/null
        shift
done

Top