procmail
[Top] [All Lists]

ANNOUNCE: new procmail modules available

1998-01-15 08:32:33

    Hi, Recently my fingers got brains of their own and here are
    couple of new modules that might interest you. The biggest project
    that I finished was the MPFS. It's finally ready. (TPFS
    has been improved as well, current release is 1.31.1.3)

    All these are included in the latest pm-code.shar (available
    from the file server mentioned in X-header)
    
    The docs from the new modules have been attached below.

    Cheers!
    jari

Pm-janslookup.rc -- run nslookup on variable INPUT

     Description
 
        This subroutine runs `nslookup' on given INPUT address. This may be
        an efective way to test if the address is known to internet. You
        could usethis information to see if some automated reply to
        a address can be sent.
 
        Do not however use this module to regularly check _all_ incoming
        from addresses with this subroutine for possible bogus UBE
        addresses, because calling nslookup
 
        o   may be slow, building to connection and querying the results
            may take several seconds. (some times, usually it's quote fast)
        o   consumes quite a lot resources.
 
        You can however check _some_ messages that are likely UBE to verify
        your doubts.
 
    Required settings
 
        PMSRC must point to source direcry of procmail code. This subroutine
        will include
 
        o   pm-javar.rc
        o   pm-jaaddr.rc
 
    Call arguments (variables to set before calling)
 
        o   INPUT, String from which the address is read. Must have @ char.
 
        From this INPUT, ingrid.sps.mot.com would be checked.
 
            "From: foo(_at_)ingrid(_dot_)sps(_dot_)mot(_dot_)com (Yoshiaki foo)"
 
    Return values
 
        o   Variable ERROR will be set to "yes" if nslookup failed or
            to "no" if nslookup succeeded.
 
    Usage example
 
        Read From field and address from it. This is lot faster than using
        external `formail' call.
 
            #   Check envelope From_ if this message was labelled possible UBE
            #   The flag MAYBE_UBE was raised before this recipe
 
            PMSRC       = $HOME/pm
            RC_NSLOOKUP = $PMSRC/pm-janslookup.rc
 
            :0
            * MAYBE_UBE ?? yes
            * ^From \/.*
            {
                INPUT = $MATCH
                #  Turn off the logging while executing this part
                VERBOSE=off   INCLUDERC = $RC_NSLOOKUP  VERBOSE=on
 
                :0
                * ERROR ?? yes
                {
                    #   Hmm, nslookup failed, can't send anything to this
                    #   address
                }
            }
 
        Second example, check if the address is reachable before sending reply
 
            INPUT     = `formail -rt -X To:`
            INCLUDERC = $RC_NSLOOKUP
 
            :0
            *    ERROR ?? no
            *$ ! ^X-Loop: $MY_XLOOP
            {
                # okay, the address seems to be reachable
            }
 
Pm-janetmind.rc -- handle http://minder.netmind.com/ messages

    Description
 
        http://minder.netmind.com/
        http://www.netmind.com/URL-minder/new/register.html
 
        ...Netmind, or The URL-minder is a free, automatic Web-surfing robot
        that keeps track of changes to Web pages that are important to you.
        When the URL-minder detects changes in any of the Web pages you
        have registered, it sends you e-mail. an efective way to test if
        the address is known to internet. You could usethis information to
        see if some automated reply to a address can be sent.
 
 
        In another words, if your're interested in some URL; say an FAQ page
        and any updates to them, you can tell Netmind to monitor the page
        changes for you and it send a message back every time page changes.
 
        This recipe "pretty formats" the announcements sent by Netmind
        by stripping the message to bare minimum. You usually arent interested
        in 4k message that mentiones "Note from our sponsors", "Try the free
        online demo" and rest. The only things saved from the message are:
 
        o   The changed url, which is moved to subject
        o   Cancellation url pointer
        o   url to the lists of your monitored urls
        o   your id number
 
    Required settings
 
        PMSRC must point to source direcry of procmail code. This subroutine
        will include
 
        o   pm-javar.rc
 
    Call arguments (variables to set before calling)
 
        o   MBOX, is this is "", then message is not saved anywhere.
            otherwise message is saved to folder MBOX.
 
    Return values
 
        (none)
 
    Usage example
 
            INCLUDERC = $PMSRC/pm-janetmind.rc
 
            :0:
            * netmind
            url.mbox
 
 


Pm-jasubject.rc -- Subject field cleaner and canonilizer (Re:)
 
    Description
 
        There are many different Email programs out there that add their
        own "reply" characters to the subject field. The most sad programs
        come usually from PC platform. Eg. Microsoft has gained a lot of
        bad reputation due to it's own standards.
 
        o   MS Explorer uses "Vs:"
        o   MS product X (??) uses "Sv:" and "FW:"
        o   Intelligent MUAs try to keep count of replies with
            "Re2:" or "Re[2]"
 
        They all must mean well, but there already is a de facto standard
        where message should contain only single "Re:" if message has been
        replied to (no matter how many times). This makes it possible to
        do efficient message threading by only using Subject and date fields.
        And grepping same subjects is lot easier than from this horrible mess:
 
            Subject: Re[32]: FW: Re: Re[15]: Sv: Re[9]: test message
 
        This recipe standardizes any subject (like above) that has been
        replied to, to de facto format:
 
             Subject: Re: test message
 
    Awk usage note
 
        `awk' is a samll but very efective program and much smaller than perl.
        See the verbose log and make sure your awk understands VAR="value"
        passing syntax. Change it to `nawk' or `gawk' if they work better than
        your standard awk
 
            AWK = "nawk"        # you may need this
 
    Input
 
        (none)
 
    Output
 
        (none)
 
    Example usage
 
        #   You need nothing special, just include this recipe
        INCLUDERC = $PMSRC/pm-jasubject.rc
 


Pm-jasrv.rc -- Jari's MPFS (Mime Procmail 3.11+ File server)

    Description
 
        This is the MPFS (Mime procmail file server)
        and it can send MIME compliant messages with command
 
            "send FILE [WORD1] [WORD2]"
 
        Usually only the FILE is used, and the rest of the words are for
        special use like password and preventing file encoding.
 
    Overview of features
 
        o   x-gzip64 and text/plain MIME support
        o   requires procmail 3.11+ with MATCH operator \/
        o   requires `mmencode' and `gzip' executables to be present in PATH.
 
    Install: server file directory
 
        You have to create directory for the server where the files are kept.
        Usually I don't copy the files there, but whenever I want to put a
        file available, I draw a hard or softlink to a file.
 
            % mkdir $HOME/pm-server
            % cd $HOME/pm-server
 
            # Repeat this as needed for files you want to put available
            #
            % cd $HOME/pm-server
            % ln $HOME/txt/interesting-file.txt interesting-file.txt
 
        You define the server directory by changing
 
            JA_SRV_FILE_DIR = $HOME/pm-server
 
        The short server log is written to file:
 
            JA_SRV_LOG = $HOME/pm-server.log
 
        The incoming "send" request messages are stored here, which defaults to
        /dev/null, but you may want to set it to ~/Mail/spool/log.srv.spool and
        define In Emacs Gnus 5 group with `G` `m' `nnml' `log.srv.'
 
            JA_SRV_MSG_MBOX
 
    Install: special files
 
        Tweak this variable to commands you want to allow shell to execute
        in server's directory.
 
            JA_SRV_SH_COMMAND = "^(ls|what)$"
 
        There are some special `files' that this server accepts. They are
        not actually files at all, but commands passed to shell. Be sure
        that the commands exist in your system. See man pages for more if
        you want to know what these commands do.
 
            ls      -- list directory
            file    -- print file type information.
            what    -- prints all @(#) tags from files
            ident   -- print all $ $ tags from files
 
    Install: file `help'
 
        Users want to get a help file with message "send help" and the
        `help' is just a file in your server directory. Be sure to supply it
        prior any other files. You can always draw a link to a file if you
        don't want to name it that way (eg. if you keep several server help
        files in RCS tree)
 
            #   draw symlink to `help'
            #
            % ln -s $HOME/txt/srv-public-hlp.txt $HOME/server/help
 
    Basic usage in details
 
        The server accepts command in format
 
            "send FILE [CMD|PASSWORD]"
 
        Where FILE can be any name as long as it starts with [^ .]. The
        regexp says: Anything goes as long as FILE does _not_ start with
        space or period. This gives you quite a much freedom to construct
        filenames. if you want to hand out file
 
            .procmailrc
 
        you can't. Instead make a link to point to plain "procmailrc"
        without the leading period. There is also additional checks
        against possible security threat "../" like below; user can't
        request such file.
 
            ../../../gotcha  or  dir/../../gotcha
 
        The filename cannot contain special charcters like [*?<>{}()].
 
    Advanced usage
 
        [conversions]
 
        If some of your files are big, it makes sense to send them in
        compressed base64 format; which in MIME world is called content-type
        x-gzip64. You can set a regexp to encorce encoding for your big
        files before they are sent to user. The following setting will send
        all text files in compressed format to user.
 
            JA_SRV_XGZIP_REGXP = "\.txt"
 
        When the message is composed a header is inderted to message telling
        how the message is decoded, in case user doesn't have decent MUA that
        van handle the MIME type:
 
            X-comment: To decode, cat msg| mmencode -u| gzip -d > test.txt
 
        The CMD parameter after the FILE is optional and userr can override
        this base64 encoding and request plain file if he uses word "noconv".
 
            Subject: send FILE noconv
 
        [case sensitivity]
 
        By default the file server request word ("send") or file names are
        not case sensitive, unless you set
 
            JA_SRV_CMD_CASE_SENSITIVE   = "yes"
            JA_SRV_FILE_CASE_SENSITIVE  = "yes"
 
        In "no" case these are identical commands:
 
            Subject: Send Help
            Subject  SEND HELP
 
 
    Stopping server
 
        Sometimes you're making rearrangements in you file directory Or
        doing something else, and you are unable to respond to `send'
        requests. You can stop te server by setting
 
            JA_SRV_IN_USE = "no"
 
        And when the you want to enable the server again; just comment out
        the statement or assign `yes'. [The default is `yes']. When this
        variable is set to `no', server sends message from following variable
        as a response to any "send" request.
 
            JA_SRV_IN_USE_NO_MSG
 
    Using password to validate file requests
 
        You should be aware that this file server's implementation is public
        in nature. Anyone who asks for a file is allowed to get it. But it
        would be good if you could limit the access to documents with some
        simple way, like if you set up two file servers (see next chapter)
        where one is public and the other is interesting only to group of
        people. You can define a string that must be found in Subject field
        by setting the following variable
 
            JA_SRV_PASSWORD = ".*"    # default
 
        The default value will match anything in the subject, thus making the
        server public. But if you set it like this
 
            JA_SRV_PASSWORD ".*123"
 
        Then string "123" must be there somewhere in the line, like here
 
            Subject: send FILE 123
 
        Yes, "123" is actually a CMD definition, but it dosn't matter
        because there is no CMD 123. But the Subject now matches password
        and the server can be accessed. Of course the following is valid
        too.
 
            Subject: send FILE noconv 123
 
        If the password was wrong, server won't tell it. The message just
        lands to your mailbox in that case and you can investigate who
        tried to access the restricted server.
 
    Changing server's command string (multiple servers)
 
        The default command string is "send", but you can change it and thus
        create multiple services. Here is one example, where you have set up
        two file servers, each has its own directory.
 
            #   The public server
            #
            JA_SRV_CMD_STRING   = "send"
            JA_SRV_FILE_DIR     = $HOME/server/public
            INCLUDERC           = $HOME/procmail/pm-jasrv.rc
 
            #   Company server, only interests fellow workers
            #   Here "xyz-send" is just magig server request string.
            #   Notice: case sensitive.
            #
            JA_SRV_CMD_CASE_SENSITIVE   = "yes"
            JA_SRV_CMD_STRING           = "XYz-send"
            JA_SRV_FILE_DIR             = $HOME/server/public/xyz-dir
            JA_SRV_PASSWORD             = ".*12qw"
            INCLUDERC                   = $HOME/procmail/pm-jasrv.rc
 
    Notes from the author
 
        [basic Mime type note]
 
        All basic files that you send must be US-ASCII, 7bit. At least that
        is the default mime type used. See JA_SRV_CONTENT_TYPE. I once
        received following message back
 
           ----- Transcript of session follows -----
           554 <foo(_at_)bar>... Cannot send 8-bit data to 7-bit destination
           501 <foo(_at_)bar>... Data format error
 
        because in the previous releases, the MIME type headers were not
        in the message saying that the content really was plain 7bit ascii.
 
        [Sendig the file as is]
 
        Note, that the file is included "as is" without any extra
        *start-of-file* or *end-of-file* tags. This is possible, because
        the file file is sent in MIME format.
 
        [Using one line log entry]
 
        It may look very spartan to print a single line log entry. You see
        messages like above in the file server log. Using one line entry
        instead of multiline announcements makes it possible to write a small
        perl tool to parse information from a single line. If you get many
        file server messages per day, it it quiker to look at the single line
        entries too.
 
            [ja-srv1; sh file;  Foo Bar <foo(_at_)site(_dot_)com>;]
            [ja-srv1; send xxx-file.txt; Foo Bar <foo(_at_)site(_dot_)com>;]
                      |
                      Server request keyword (you may have server
                      servers by changing the keyword)
 
        [todo]
 
        I don't have a clear though right now how should I send out
        already compressed files "file.tar.gz". And how would I send
        multipart mime files in those cases.
 
        If you have suggestions or ideas, please drop mail to maintainer.
 
    Required settings
 
        PMSRC must point to source direcry of procmail code. This subroutine
        will include many pm-jasrv-*.rc modules from there.
 
        Please test the file Server in your environment before you start
        using it for every day. For example I had some weird local problem
        where PATH had /usr/contrib/bin/ where gzip was supposed to be, but
        in spite of my tries procmail didn't find it along the path. Don't
        ask why. I now use absolute binary name:
 
            GZIP = /usr/contrib/bin/gzip
 
        In addition, if your messages are not sent to recipient, but you
        get daemon message:
 
            ... Recipient names must be specified
 
        That's because you have setting SENDMAIL="sendmail"; which is not
        enough. It must be
 
            SENDMAIL = "sendmail -oi -t"
 
    Usage example
 
        This is how I have installed this Tiny Procmail File server
        into my .procmailrc. Notice that the file server code is used only
        if you get "send" request.
 
            #   Listen "send" requests.
            :0
            *   ^Subject: +send\>
            {
                JA_SRV_FILE_DIR = $HOME/fsrv    # Where to get the files
                JA_SRV_LOG      = $HIN          # Write log here
                JA_SRV_FROM     = $FFROM        # I have defined this already
                JA_SRV_SUBJECT  = $FSUBJ        # ..and this
 
                #   Semd these file in compressed format
                JA_SRV_XGZIP_REGXP = "\.txt|\.gui"
 
                #       Use File server now.
                #
                INCLUDERC       = $PMSRC/pm-jasrv.rc
            }
 
<Prev in Thread] Current Thread [Next in Thread>
  • ANNOUNCE: new procmail modules available, jari.aalto <=