Neat! I have to cringe as I read the source code though. There are only 19 commented lines out of 826! Also, it wasn't written with security in mind. For instance, if I have ftp access to an account on a machine running smtp.pl, I can execute arbitrary shell commands by uploading a file to my home directory named ".perlsmtp" containing the line "maildeliver = |/do/whatever".

Here's another thing that jumped out at me:

open(CONFIG, $_[0]) or die "Could not open config file $_[0]\n";

Randal would call this "running with scissors". You should always, always, always specify a mode for open(). E.g.:

open(CONFIG, "<$_[0]") or die "Could not open config file $_[0]\n" +;

Otherwise you run the risk of a malicious user sneaking a value like "|rm -rf /home" into the filename. The above example isn't exploitable in the smtp script, mind you, but seeing that, I have to wonder what other bad habits might be lurking in the other 825 lines.

-Matt


In reply to RE: An SMTP server in Perl by DrManhattan
in thread An SMTP server in Perl by strredwolf

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.