![]() |
|
laziness, impatience, and hubris | |
PerlMonks |
Self Extracting Archives with Perl (almost)by deprecated (Priest) |
on Jan 21, 2001 at 07:00 UTC ( [id://53280]=CUFP: print w/replies, xml ) | Need Help?? |
I run a small network of servers running the
OpenNap
server. We've been having some issues lately with script
kiddies attacking the servers (we have 7 nodes at present),
and it has become difficult to maintain homogeneity among
the servers. So I decided I needed a good way to get files
from the hub server (mine) to the nodes on the network in
a uniform fashion. Since I cant assume that all the other
server owners will be able to use rsync or cvs or bitkeeper
or any of the other source-distribution systems, I began to
wonder what the best way to get them these files was. Of course,
I thought, use perl! So I thought, well, I can make a tarball,
and uuencode it, and then send it out through a CGI program.
But that leaves me with the problem that somebody may not be
able to use UU(en|de)code or tar very aptly. These things happen,
unfortunately. So since the tarball is uuencoded, I can actually
stick it IN a perl program and use a heredoc to stuff it into
a scalar, which can then be decompressed and everything. So I have
created a script that creates a new script with the encoded information
in it. It also adds relevent codelets to the new script so that
it should be able to decode and detar its files. So Ill give you
the code here, and then continue on below it:
Documentation for used modules: IO::Scalar Archive::Tar Convert::UU So. This actually does almost everything I want it to. It does choke, however, and doesnt extract the tarball. I think what I'm running into is a lack of understanding the way Archive::Tar works. I'm actually pretty stunned that the resulting code goes through perl -c without issues. The problem I'm having is that Archive::Tar isnt reporting any errors, and its not actually extracting the files. One thing of note here is that Archive::Tar lists an extract_files method in its documentation, but the extract method I found from looking through the source is much better. The filenames listed at the top are the first 10 lines from /usr/dict/words, and a copy of `which cat`. Relatively small files. Where do I go from here? I have posted this in CUFP because, gee, this is one damn cool use for perl IMHO. This should even be portable to MacOS and Windows. One final plan I have for this script is to include some weak encryption so that I dont have to worry about script kiddies downloading our users database and hacking us. But given the large amount of encryption modules available for perl, that part shouldnt be very tough.
thanks, fellow monks. Update:I have stopped using Archive::Tar and Convert:UU. Both modules are fine examples of how to do very specific things. They however dont play very well together. Not using either of these modules means I dont really need to use IO::Scalar, either (although that has to be one of the coooooolest modules I have ever played with. Our own japhy suggested pack which does UUencoding all by itself and doesnt require an extra module.An anonymous monk suggested using shar which I'm embarassed to admit I knew nothing about. It's a good idea except that it's not as portable as I'd like. Also, well, at this point I'm pretty attached to my idea and would like to keep this 100% perl. :) I will post the full code when I'm done with it. I'm moving along. --
Back to
Cool Uses for Perl
|
|