Gnus development mailing list
 help / color / mirror / Atom feed
* TEMP fix for POP3 auth
@ 1996-03-05  6:58 d. hall
  0 siblings, 0 replies; 3+ messages in thread
From: d. hall @ 1996-03-05  6:58 UTC (permalink / raw)


--Multipart_Tue_Mar__5_01:49:20_1996-1
Content-Type: text/plain; charset=US-ASCII

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))

--Multipart_Tue_Mar__5_01:49:20_1996-1
Content-Type: application/octet-stream; type=emacs-lisp
Content-Disposition: attachment; filename="retrieve.el"
Content-Transfer-Encoding: 7bit


(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)

--Multipart_Tue_Mar__5_01:49:20_1996-1--


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: TEMP fix for POP3 auth
  1996-03-05  6:49 d. hall
@ 1996-03-05 11:27 ` Greg Stark
  0 siblings, 0 replies; 3+ messages in thread
From: Greg Stark @ 1996-03-05 11:27 UTC (permalink / raw)
  Cc: Gnus List


please don't make yet another program to access pop servers unless you're
willing to support all the features of movemail.  movemail supports pop,
kerberos, and hesiod, unless you're going to support those features we're
going to end up with two separate programs instead of simply merging new
features into the existing mail interlock program.

i have no reason to think movemail is flawless, if you wanted to reimplement
it's features properly that would be better.  but it works, and what you want
to add is a relatively minor (though annoying) feature;  if you reimplement
everything else it's likely to break those features you never use.

--
greg


^ permalink raw reply	[flat|nested] 3+ messages in thread

* TEMP fix for POP3 auth
@ 1996-03-05  6:49 d. hall
  1996-03-05 11:27 ` Greg Stark
  0 siblings, 1 reply; 3+ messages in thread
From: d. hall @ 1996-03-05  6:49 UTC (permalink / 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)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1996-03-05 11:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-03-05  6:58 TEMP fix for POP3 auth d. hall
  -- strict thread matches above, loose matches on Subject: below --
1996-03-05  6:49 d. hall
1996-03-05 11:27 ` Greg Stark

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).