I do not like Perl
Dec. 26th, 2008 02:10 amHave I mentioned that I do not like Perl? Yes, I think I have. Well, I'll say it again. Non-programmers should skip this post, which is just a long drawn-out whine about how Perl makes computers unnecessarily difficult to operate.
Today's job: install Bugzilla. Bugzilla has a neato feature where you can send it email and it will make a pretty bug report out of whatever you say. How do I know that? Wikipedia said so back in October (and I have a citation in an email to prove it), but there's no mention of it there now and no mention in the Bugzilla configuration manual. It's in the API manual.
So there’s this program that's supposed to read the email, which means I have
to tell the email system that all email received on behalf of some
nobody-would-ever-guess-it address should be processed by this program rather
than being held for someone to read. My laptop
uses postfix, so all I have to do is add this line to file
“/etc/aliases” and then recompile the aliases database:
nobody_will_ever_guess: |/usr/share/bugzilla3/lib/email_in.pl
Where the | character means “run this program when mail is received
for nobody_will_ever_guess@mymachine.ca”.
Okay, now send a test message to the special address. Fail: Permission denied. Set the ‘execute’ permission bit on the program file. Fail: Permission denied. Allow userid ‘nobody’ to access the program’s parent directory. Fail: Can’t find module Bugzilla.pm. Add a use lib statement to the program—didn't anybody test this thing? Fail: Can't find module Email::Reply.
Well, I guess that’s a reasonable error.
Bugzilla’s checksetup.pl script had warned me that module
Email::Reply was missing but optional. It even told me the exact command
needed to install it:
/usr/bin/perl -MCPAN -e 'install "Email::Reply"'
Piece of
cake! So I intone the command as instructed. Fail: Can’t
access server ftp://ftp.perl.org/CPAN. It's down for Christmas. But
ftp://cpan.org is up and has the same data—and Perl helpfully tells me
the comand to use to give it an alternate server: 'o conf urllist push
ftp://myurl/'. But it doesn’t tell me *where* to enter this
command! I try /usr/bin/perl -MCPAN and enter the
command o conf urllist push
ftp://cpan.org/. Fail: Bareword found where operator
expected. Maybe quotes around the URL? Fail:
Syntax error. Okay, I don’t speak Perl (apparently the correct
answer is q[ftp://cpan.org], which is both ugly *and* materially different from what was said in the hint) so I add a line to /etc/hosts to
make outgoing requests to "ftp.perl.org" actually get sent to "ftp.cpan.org"
(try *that*, Windows® mavens!). This produces a cascade of error messages
(because cpan.org is not equivalent to perl.org, but to perl.org/CPAN, so
all the URL paths are wrong) but somehow it manages to download the file
anyway!
Okay, now send the test message again. Fail: Permission denied, file /etc/bugzilla3/localconfig This is going to be a problem. The program is getting run as userid ‘nobody’ but all of Bugzilla’s files are restricted for access by userid ‘www-data’. I try fiddling around with the permissions a few times, but Fail fail fail: denied denied denied. I set the sticky-userID bit on the program. Fail: cannot exec sperl. Install Ubuntu package “perl-setuid”. Fail: Insecure dependency on chdir at line 31 of email_in.pl. Didn’t anybody test this thing? How can it possibly work without setuid, and how can it possibly work *with* setuid if they didn’t write it with the extra care required for such programs? The reason why it is calling chdir() is because it wants to include some subprograms from the same directory where email_in.pl is stored. In other words, it is assuming that the current directory is part of the library include path, which is absolutely not true for setuid programs.
So clearly this program is not supposed to be setuid. Postfix has a way to set the userid for subprograms that it runs, but I can’t figure out how to do that for programs specified using | in /etc/aliases. Maybe I should just install this thing on Company 𝔾’s server, which uses qmail instead of postfix. So I install Bugzilla there and configure it the same as on my laptop, including the feature “automatically compress BMP attachments to bugs as PNG”. Fail: Can’t find Perl module ImageMagick.
Okay, again this missing module is identified by checksetup.pl, which tells me to use one of those -MCPAN commands to install it. By now, perl.org is back up, so I don't have that problem again. It offers me a selection of mirror-servers and I select “carroll.cac.psu.edu” because it's first on the list. Oops! Apparently PSU doesn’t really have the CPAN files anymore—I get a cascade of errors and instructions to use "o conf urllist" again. Well, I know *that* won't work, so I scroll back through my Emacs shell buffer to find where it said “commit: wrote /usr/lib/perl5/5.8.8/CPAN/Config.pm” and then I edit that file to name one of the other mirror-servers. It successfully downloads the module but then Fail: cannot compile. Install Fedora package “ImageMagick-devel”. Fail: cannot find directory /usr/include/ImageMagick. Fuck CPAN and just install Fedora package “perl-ImageMagick”. Success!
So next I should try getting that program email_in.pl running under qmail on the company’s server, but it’s too late at night now. Fail: programmer time exhausted.