6.13. Mailman and Allegroserve

Final system setup requires you to do something along the lines of

    ScriptAlias   /mailman/     $prefix/cgi-bin/

and

    Alias         /pipermail/   $varprefix/archives/public/

The above is very Apache! Here follows the Allegroserve counterpart. Make sure you specify :setuid and :setgid arguments to net.aserve:start, otherwise the server will attempt to run cgi scripts as root, which is a Bad Thing.

  ;;;;;;;;;;;

  (in-package "NET.ASERVE")

  ;; what is the url prefix for mailman queries?

  (defparameter *mailman-prefix* "/mailman/")

  ;; where is mailman installed?

  (defparameter *mailman-root* "/usr/local/mailman/")
  (defun mailman-location (where)
    (merge-pathnames where *mailman-root*))

  ;; We want to convert "/mailman/admin/mylist" into
  ;; "/usr/local/mailman/cgi-bin/admin" and "/mylist"

  (defun mailman-cgi-names (uri-path)
    (let* ((uri-relative (uri-path (enough-uri uri-path
                                               *mailman-prefix*)))
           (where (position #\/ uri-relative))
           (program-name (subseq uri-relative 0 where))
           (program (merge-pathnames program-name
                                     (mailman-location "cgi-bin/"))))
      (values (namestring program)
              (and where
                   (subseq uri-relative where)))))

  (defun cgi-error-output (req ent istream)
    (declare (ignore req ent))
    (let ((ostream (error-stream)))
      (loop
       (let ((char (read-char-no-hang istream nil :eof)))
         (cond ((null char) (return nil))
               ((eq :eof char) (return t))
               (t (write-char char ostream)))))))

  (defun mailman-invoke-cgi (req ent)
    (let ((uri-path (request-decoded-uri-path req)))
      (multiple-value-bind (program path-info)
          (mailman-cgi-names uri-path)
        (unless (probe-file program)
          (error "Mailman program ~s not found." uri-path))
        (run-cgi-program req ent program
                         :path-info path-info
                         :error-output #'cgi-error-output))))

  (publish-prefix #| :host *my-vhost-names* |#
                  :prefix *mailman-prefix*
                  :function #'mailman-invoke-cgi)

  (publish-directory #| :host *my-vhost-names* |#
                     :prefix "/pipermail/"
                     :destination (namestring (mailman-location "archives/public/")))

Converted from the Mailman FAQ Wizard

This is one of many Frequently Asked Questions.

MailmanWiki: DOC/Mailman and Allegroserve (last edited 2015-01-31 02:36:58 by msapiro)