Gnus development mailing list
 help / color / mirror / Atom feed
From: "d. hall" <dhall@illusion.apk.net>
Subject: TEMP fix for POP3 auth
Date: Tue, 5 Mar 1996 01:49:21 -0500	[thread overview]
Message-ID: <199603050649.BAA00623@illusion.apk.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 919 bytes --]

The following small snippet of emacs-lisp creates an asynch process via
popclient (by Carl Harris) to allow POP3 auth.  I have a synchronous
(open-network-stream) emacs-lisp function in the works for people who don't
have popclient available, unfortunately I don't have any specifications for
the POP3 protocal, so I've just been emulating popclient's reactions.

A couple notes:  Yes, I copied ange-ftp's password function (I still think
a password function should be a intrinsic byte-compiled emacs function
which "secures" the X server) since I'm going to add a secure to the
function.  I'm still trying to decipher's ange-ftp's ability to cache the
password while keeping it "directly" unreadable.

For an example I have as my retrieve-error-hook

(add-hook 'retrieve-error-hook	'retrieve-message-error)

(defun retrieve-message-error ()
  (message "Houston, we have a problem.")
  (wav-fx-play "houston.wav" 0.5))

[-- Attachment #2: retrieve.el --]
[-- Type: application/octet-stream, Size: 2715 bytes --]


(defun retrieve-read-passwd (prompt &optional default) "\
Read a password, echoing `.' for each character typed.

End with a RET, LFD, or ESC.  DEL or C-h rubs out.  C-u kills line.
Optional DEFAULT is password to start with."

  (let ((pass (if default default ""))
	(c 0)
	(echo-keystrokes 0)
	(cursor-in-echo-area t))
    (while (progn (message "%s%s"
			   prompt
			   (make-string (length pass) ?.))
		  (setq c (read-char))
		  (and (/= c ?\r) (/= c ?\n) (/= c ?\e)))
      (cond ((= c ?\C-u)
	     (setq pass ""))
	    ((if (and (/= c ?\b)
		      (/= c ?\177))
		 (setq pass (concat pass (char-to-string c)))))
	    ((if (> (length pass) 0)
	      (setq pass (substring pass 0 -1))))))
    (message "")
    (message nil)
    pass))

(defvar retrieve-user nil "\
*The login name of the user.
Got from the function `user-login-name' if undefined.")

(defvar retrieve-default-passwd nil "\
*The password for the POP3 server.
Got from the user if undefined.")

(defvar retrieve-default-host "pop" "\
Specify a default POP3 server.
This variable can be defined in paths.el, and really should not be set
by the user.")

(defvar retrieve-default-spool-file nil "\
Where the output of the POP3 mail will be placed.
This variable is \"/usr/spool/mail/$user\" by default.")

(defvar retrieve-mail-received-hook	nil)
(defvar retrieve-no-mail-received-hook	nil)
(defvar retrieve-passwd-invalid-hook	nil)
(defvar retrieve-error-hook		nil)

(defun retrieve-mail ()
  (interactive)
  (let ((user (or retrieve-user
		  (user-login-name)))
	(host retrieve-default-host)
	(file (or retrieve-default-spool-file
		  (getenv "MAIL")
		  (concat rmail-spool-directory (user-login-name))))
	(proc nil))
    (save-excursion
      (setq retrieve-default-passwd
	    (or retrieve-default-passwd
		(retrieve-read-passwd "Enter your password: ")))
      (setq proc
	    (start-process "retrieve" "*retrieve*" "popclient"
			   "-3"
			   "-v"
			   "-u" user
			   "-o" file
			   host))
      (set-process-filter	proc	'retrieve-filter)
      (set-process-sentinel	proc	'retrieve-sentinel))))

(defun retrieve-filter (proc stream)
  (unwind-protect
      (save-excursion
	(set-buffer "*retrieve*")
	(goto-char (point-max))
	(if (string-match "assword:" stream)
	    (process-send-string proc (concat
				       retrieve-default-passwd "\r"))
	  (insert stream))
	)))

(defun retrieve-sentinel (proc stream)
  (cond
   ((string-match "finished\n" stream)
    (run-hooks 'retrieve-mail-received-hook))
   ((string-match "code 1" stream)
    (run-hooks 'retrieve-no-mail-received-hook))
   ((string-match "code [234]" stream)
    (run-hooks 'retrieve-passwd-invalid-hook))
   (t (run-hooks 'retrieve-error-hook))))

(provide 'retrieve)

             reply	other threads:[~1996-03-05  6:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-03-05  6:49 d. hall [this message]
1996-03-05 11:27 ` Greg Stark
1996-03-05  6:58 d. hall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199603050649.BAA00623@illusion.apk.net \
    --to=dhall@illusion.apk.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).