[racket] unpacking tarballs

From: Eli Barzilay (eli at barzilay.org)
Date: Thu Sep 2 07:01:26 EDT 2010

On Sep  2, Neil Van Dyke wrote:
> > .plt files are mime encoded gziped tars AFAIK.
> ".plt" files are base64'd and gzip'd, but I think that's not a
> conventional tar format they're using.  [...]

They're *very* different from tar archives.

> For picking apart a tarball, the options I see are:
> * Call a C library using the FFI.
> * Call the "tar" program.

These sound like a sane options if they're available.

> * Code up a "tar" format reader in Racket.

The problem there is that it's much easier to create a tar file than
to unpack one.  For the latter, you'd need to deal with the various
extensions and incompatible ad-hoc formats that were added to it.  I
don't remember the exact details, but IIRC, the GNU tar has some hacks
to deal with long path names, and there are also issues with including
information that wasn't intended to be stored in tar archives.

> Caution: When untarring to a filesystem, you have to be careful that you 
> don't overwrite files you don't mean to.  You also have to check for 
> security exploits that go up the directory tree to write files, or that 
> write so-called 'special' files, or files with other (privileged) owner 
> or special permissions.

(Yeah, that's fun too.)

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

Posted on the users mailing list.