[Mew-dist 15696] mew-1.95b93 POP3 CRAM-MD5
Hajimu UMEMOTO
ume at example.com
2000年 12月 30日 (土) 05:47:21 JST
梅本@IMASYです。
CRAM-MD5 な POP3 が欲しくて、やっつけで使えるようにしたので、一応投
げておきます。
-------------- next part --------------
Index: mew-1.95b93/mew-pop.el
diff -u mew-1.95b93/mew-pop.el.orig mew-1.95b93/mew-pop.el
--- mew-1.95b93/mew-pop.el.orig Thu Dec 28 16:52:43 2000
+++ mew-1.95b93/mew-pop.el Sat Dec 30 05:31:44 2000
@@ -18,7 +18,7 @@
(defsubst mew-pop-info (name)
(if (or (not (intern-soft name))
(not (boundp (intern name))))
- (set (intern name) (make-vector 19 nil)))
+ (set (intern name) (make-vector 20 nil)))
(symbol-value (intern-soft name)))
(defsubst mew-pop-get-status (name)
@@ -78,6 +78,9 @@
(defsubst mew-pop-get-case (name)
(aref (mew-pop-info name) 18))
+(defsubst mew-pop-get-string (name)
+ (aref (mew-pop-info name) 19))
+
(defsubst mew-pop-set-status (name status)
(aset (mew-pop-info name) 0 status))
@@ -135,6 +138,9 @@
(defsubst mew-pop-set-case (name case)
(aset (mew-pop-info name) 18 case))
+(defsubst mew-pop-set-string (name string)
+ (aset (mew-pop-info name) 19 string))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Process name
@@ -158,6 +164,8 @@
(defvar mew-pop-fsm
'(("grtg" nil ("+OK" . "pswd"))
("apop" nil ("+OK" . "list") ("-ERR" . "wpwd"))
+ ("auth" nil ("+" . "cram-md5") ("-ERR" . "wpwd"))
+ ("cram-md5" nil ("+OK" . "list") ("-ERR" . "wpwd"))
("user" nil ("+OK" . "pass") ("-ERR" . "wpwd2"))
("pass" nil ("+OK" . "list") ("-ERR" . "wpwd"))
("list" t ("+OK" . "uidl"))
@@ -375,6 +383,11 @@
(goto-char (1- (point-max)))
(looking-at "\n$"))))
(setq next (mew-pop-fsm-next status "+OK")))
+ ((and (string= status "auth")
+ (and (goto-char (point-min)) (looking-at "\\+"))
+ (and (goto-char (1- (point-max))) (looking-at "\n$")))
+ (mew-pop-set-string pnm string)
+ (setq next (mew-pop-fsm-next status "+")))
(t
(setq stay 1)))
(if stay
@@ -461,6 +474,9 @@
((or (eq auth 'pass) (eq auth 'user))
(mew-pop-set-status pnm "user")
(mew-pop-command-user pro pnm))
+ ((eq auth 'auth)
+ (mew-pop-set-status pnm "auth")
+ (mew-pop-command-auth-cram-md5 pro pnm))
(t
(mew-pop-set-status pnm "apop")
(mew-pop-command-apop pro pnm)))))
@@ -501,11 +517,27 @@
(process-send-string
pro (format "apop %s %s%s" (mew-pop-get-user pnm) kmd5 mew-cs-eol))))
+(defun mew-pop-command-auth-cram-md5 (pro pnm)
+ (mew-pop-set-try pnm 0)
+ (process-send-string
+ pro (format "AUTH CRAM-MD5%s" mew-cs-eol)))
+
+(defun mew-pop-command-cram-md5 (pro pnm)
+ (let ((str (mew-pop-get-string pnm))
+ challenge passwd cram-md5)
+ (if (string-match " \\([A-Za-z0-9+/]+=*\\)" str) ;; xxx
+ (setq challenge (mew-match 1 str)))
+ (setq passwd (mew-input-passwd "CRAM-MD5: " (mew-pop-passtag pnm)))
+ (setq cram-md5 (mew-cram-md5 (mew-pop-get-user pnm) passwd challenge))
+ (process-send-string pro (format "%s%s" cram-md5 mew-cs-eol))))
+
(defun mew-pop-command-wpwd (pro pnm)
(let ((auth (mew-pop-get-auth pnm)))
(cond
((or (eq auth 'pass) (eq auth 'user))
(message "POP password is wrong!"))
+ ((eq auth 'auth)
+ (message "AUTH password is wrong!"))
(t
(message "APOP password is wrong!"))))
(mew-passwd-set-passwd (mew-pop-passtag pnm) nil)
-------------- next part --------------
梅本 肇 @ インターネット互助会横浜 http://www.imasy.org/~ume/
ume at example.com ume at example.com ume@{,jp.}FreeBSD.org
プログラムは書いた人の意図ではなく書かれた通り動く
Mew-dist メーリングリストの案内