Subject: Re: Help for a procmail newbie? (or: how to make an ftpemail server) (fwd)

From: Adam Shostack <[email-masked]>
Date: Wed, 10 Aug 94 19:56:14 EDT

David W. Tamkin wrote, and forgot to cc: the list.  I'm taking the
liberty of responsding in this message.

| From: [email-masked] (David W. Tamkin)
| Subject: Re: Help for a procmail newbie? (or: how to make an ftpemail server)
| To: [email-masked] (Adam Shostack)
| Date: Wed, 10 Aug 1994 18:24:01 -0500 (CDT)
| 
| Adam Shostack wrote in response to Eileen Bauer,
| 
| | 	There are a number of issues.  First is to ensure that the
| | remote user can only do what you ok.  This rules out their use of the
| | characters outside the set [-_/A-Za-z].  (Other characters may have
| | evil meta-meanings.)
| 
| Digits are probably safe too, and allowing digits will make it a lot easier
| to come up with file and directory names.
| 
| Many file naming conventions also include periods, but two periods together
| are a problem; a period between two alphanumerics is likely safe.  You could
| have one condition requiring ' [-_/\.A-Za-z0-9]+$' and another rejecting 
| '[ /.]\.' so that ".." and "/." and " ." would all be disallowed.  That
| pretty much short-circuits any risk with periods.  (Note that inside
| brackets the period loses its metameaning and represents only literal
| periods.)

	I would disallow periods, and use underscores and dashes in
their place.  I don't see this as a major loss, and we avoid any
possible problems.  (I am, however, more paranoid than most in the
code I write.)

| | I think letting a space in is ok, but I'm not sure.
| 
| Spaces are possibly risky anyway, and filenames that contain spaces are a
| pain to maintain because of the need to quote them or to escape the space;
| moreover we can greatly simplify things by not allowing them, because then
| we don't have to require "SEND FILE" to be case-sensitive.  I'm for keeping
| spaces illegal.
| 
| So I think we can tweak Adam's ideas into this form:
| 
|  :0 # no need for D flag nor for 'A-Za-z' in the first condition
|  * ^Subject: SEND FILE [-_/0-9a-z.]+$
|  * !^Subject:.*[ /.]\.
|  * !^FROM_DAEMON
|  {
|     # FILE=`formail -x Subject: | sed 's/.* //'`
|     # As long as we have to call sed anyway, let it do both jobs:
|     FILE=`sed -n -e '/Subject:/s/.* //p' -e '/^$/q'`
| 
|     :0c # needs 0 and c and a pipe marker and formail should have -t option
	  # I said it wasn't tested. :)
|     | formail -rt -A"Precedence: junk";\
|        cat $HOME/.outbound/$FILE | $SENDMAIL -t
| 
|     :0: # needs a 0 and a local lockfile
|     $HOME/.outbound/.log
|  }
| 
| David W. Tamkin  P. O. Box 3284  Skokie IL  60076-6284
| [email-masked]   MCI Mail: 426-1818   +1 312 714 5610