3 ms·
> I realized a few years later that this was just an exercise in flexing the fact that I could probably bootstrap my way up from this with the C compiler to wr
by rootlocus 6y ago
> I realized a few years later that this was just an exercise in flexing the fact that I could probably bootstrap my way up from this with the C compiler to write a terrible editor, then write a terrible TCP client, find my way out to ftp.gnu.org, get wget, and keep going from there.
I assume by "a terrible TCP client" she means a TCP stack, so you don't have a TCP stack yet, so `/dev/tcp` wouldn't exist. Otherwise just opening a socket and sending the request would do the trick. Or maybe that's what she meant by "TCP client"? But writing an editor for that would be overkill I think.
Nice try though :)
- ilaksh 6y agoIt is unclear to me whether the C libs include TCP. If not then that seems like the main part of the work because once you have that then you can download everything else. Unless it was already in BIOS or some network hardware remote admin Intel thing and there was a way to hack into that to use it. Then you would not have to implement TCP IP. To me the question is what is the minimal part of TCP /IP that you would need. I guess also you need ethernet if that's not in the C libs. To cheat maybe your computer has a modem and there is a BBS - simpler protocol.
- datenwolf 6y ago> It is unclear to me whether the C libs include TCP. The exercise states that you have a Linux kernel and there is a network connection. If the kernel does not have TCP, but only offers a raw socket, well, then you have to write down a very simple TCP stack. But if the kernel does have TCP, the exercise boils down to writing a very simple HTTP client, a very simple DNS resolver and a bare bones XZ decompressor and tar reader. From there I'd grab myself https://alpha.de.repo.voidlinux.org/static/xbps-static-latest.x86_64-musl.tar.xz https://alpha.de.repo.voidlinux.org/static/xbps-static-lates... then execute ./xbps-install -S --repository=https://alpha.de.repo.voidlinux.org/current https://alpha.de.repo.voidlinux.org/current -r / base-system and call it a day.
- anthk 6y agoOr just get a static tar and xz static build, they must be somewhere. Better: busybox build. It already has tar, xz and wget. You just need to compile a simple HTTP client, or better: find a gopher mirror. Bare netcat would work against that. gopher://ftp.icm.edu.pl:70/1/vol/rzm6/busybox/binaries With NetCat: echo vol/rzm6/busybox/binaries/1.21.1/ | nc ftp.icm.edu.pl 70 echp vol/rzm6/busybox/binaries/1.21.1/busybox-i586 | nc ftp.icm.edu.pl 70 > busybox Then ln all the binaries. Or run busybox wget. Accesign the rest of the files is the same, just redirect the nc command to a file. If tar is missing, you can just get for sure an static build and compile it. Or try to find an sltar mirror to github ;). But that busybox has ustar, so look how easy it was with just netcat and Gopher, so writting an nc clone (openbsd's netcat portable version is really easy, altough there are another ones many more times dumbed down) would be the easiest win.
- datenwolf 6y ago> Or just get a static tar and xz static build, they must be somewhere. That is, that you can find them in an uncompressed form. If you fees adventurous you can probably coax the compressed data somehow through the bootloader decompressor, or the xz or deflate implementation found in the Linux kernel. Unfortunately these days modules tend to be compressed as well, but it should be possible to convice libdl to open a .ko file. If not you can always mmap it PROT_READ|PROT_EXEC and follow the symbols entries through the TLD yourself.
- anthk 6y agoBusybox has these in binary form, in either HTTP/FTP/Gopher servers or who knows which other protos. Pick your poison. Once you set a barebones connection to a gopher server from stdin using a little of C socket establishing code, you can just send the commands to fetch the binary, redirect it to a file and chmod(2) +x it with ease.
- chrisbroadfoot 6y ago> telnet, nc, ftp, ncftp, lftp, wget, curl, lynx, links? Luxury! Gone. No nc.