projects
/
gnus
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
(nnimap-parse-copied-articles): Allow for "<foo> OK" outputs from the server.
[gnus]
/
lisp
/
starttls.el
diff --git
a/lisp/starttls.el
b/lisp/starttls.el
index
6746439
..
4b4839a
100644
(file)
--- a/
lisp/starttls.el
+++ b/
lisp/starttls.el
@@
-1,7
+1,6
@@
;;; starttls.el --- STARTTLS functions
;;; starttls.el --- STARTTLS functions
-;; Copyright (C) 1999, 2000, 2002, 2003, 2004,
-;; 2005 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2011 Free Software Foundation, Inc.
;; Author: Daiki Ueno <ueno@unixuser.org>
;; Author: Simon Josefsson <simon@josefsson.org>
;; Author: Daiki Ueno <ueno@unixuser.org>
;; Author: Simon Josefsson <simon@josefsson.org>
@@
-10,20
+9,18
@@
;; This file is part of GNU Emacs.
;; This file is part of GNU Emacs.
-;; GNU Emacs is free software
;
you can redistribute it and/or modify
+;; GNU Emacs is free software
:
you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation
; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation
, either version 3 of the License, or
+;;
(at your option)
any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;; Commentary:
@@
-32,7
+29,7
@@
;; [RFC 2595] "Using TLS with IMAP, POP3 and ACAP"
;; by Chris Newman <chris.newman@innosoft.com> (1999/06)
;; [RFC 2595] "Using TLS with IMAP, POP3 and ACAP"
;; by Chris Newman <chris.newman@innosoft.com> (1999/06)
-;; This file now contain a combination of the two previous
+;; This file now contain
s
a combination of the two previous
;; implementations both called "starttls.el". The first one is Daiki
;; Ueno's starttls.el which uses his own "starttls" command line tool,
;; and the second one is Simon Josefsson's starttls.el which uses
;; implementations both called "starttls.el". The first one is Daiki
;; Ueno's starttls.el which uses his own "starttls" command line tool,
;; and the second one is Simon Josefsson's starttls.el which uses
@@
-44,7
+41,7
@@
;; both tools installed. It is recommended to use GNUTLS, though, as
;; it performs more verification of the certificates.
;; both tools installed. It is recommended to use GNUTLS, though, as
;; it performs more verification of the certificates.
-;; The GNUTLS support require GNUTLS 0.9.90 (released 2003-10-08) or
+;; The GNUTLS support require
s
GNUTLS 0.9.90 (released 2003-10-08) or
;; later, from <http://www.gnu.org/software/gnutls/>, or "starttls"
;; from <ftp://ftp.opaopa.org/pub/elisp/>.
;; later, from <http://www.gnu.org/software/gnutls/>, or "starttls"
;; from <ftp://ftp.opaopa.org/pub/elisp/>.
@@
-58,7
+55,7
@@
;; (message "STARTTLS output:\n%s" (starttls-negotiate tmp))
;; (process-send-string tmp "EHLO foo\n"))
;; (message "STARTTLS output:\n%s" (starttls-negotiate tmp))
;; (process-send-string tmp "EHLO foo\n"))
-;; An example run yield the following output:
+;; An example run yield
s
the following output:
;;
;; 220 yxa.extundo.com ESMTP Sendmail 8.12.11/8.12.11/Debian-3; Wed, 26 May 2004 19:12:29 +0200; (No UCE/UBE) logging access from: c494102a.s-bi.bostream.se(OK)-c494102a.s-bi.bostream.se [217.215.27.65]
;; 220 2.0.0 Ready to start TLS
;;
;; 220 yxa.extundo.com ESMTP Sendmail 8.12.11/8.12.11/Debian-3; Wed, 26 May 2004 19:12:29 +0200; (No UCE/UBE) logging access from: c494102a.s-bi.bostream.se(OK)-c494102a.s-bi.bostream.se [217.215.27.65]
;; 220 2.0.0 Ready to start TLS
@@
-146,15
+143,14
@@
i.e. when `starttls-use-gnutls' is nil."
(defcustom starttls-extra-args nil
"Extra arguments to `starttls-program'.
(defcustom starttls-extra-args nil
"Extra arguments to `starttls-program'.
-Th
is program is used when the `starttls' command is used,
-
i.e. when
`starttls-use-gnutls' is nil."
+Th
ese apply when the `starttls' command is used, i.e. when
+`starttls-use-gnutls' is nil."
:type '(repeat string)
:group 'starttls)
(defcustom starttls-extra-arguments nil
"Extra arguments to `starttls-program'.
:type '(repeat string)
:group 'starttls)
(defcustom starttls-extra-arguments nil
"Extra arguments to `starttls-program'.
-This program is used when GNUTLS is used, i.e. when
-`starttls-use-gnutls' is non-nil.
+These apply when GNUTLS is used, i.e. when `starttls-use-gnutls' is non-nil.
For example, non-TLS compliant servers may require
'(\"--protocols\" \"ssl3\"). Invoke \"gnutls-cli --help\" to
For example, non-TLS compliant servers may require
'(\"--protocols\" \"ssl3\"). Invoke \"gnutls-cli --help\" to
@@
-172,7
+168,7
@@
find out which parameters are available."
(defcustom starttls-connect "- Simple Client Mode:\n\n"
"*Regular expression indicating successful connection.
The default is what GNUTLS's \"gnutls-cli\" outputs."
(defcustom starttls-connect "- Simple Client Mode:\n\n"
"*Regular expression indicating successful connection.
The default is what GNUTLS's \"gnutls-cli\" outputs."
- ;; GNUTLS cli.c:main() print this string when it is starting to run
+ ;; GNUTLS cli.c:main() print
s
this string when it is starting to run
;; in the application read/write phase. If the logic, or the string
;; itself, is modified, this must be updated.
:version "22.1"
;; in the application read/write phase. If the logic, or the string
;; itself, is modified, this must be updated.
:version "22.1"
@@
-182,7
+178,7
@@
The default is what GNUTLS's \"gnutls-cli\" outputs."
(defcustom starttls-failure "\\*\\*\\* Handshake has failed"
"*Regular expression indicating failed TLS handshake.
The default is what GNUTLS's \"gnutls-cli\" outputs."
(defcustom starttls-failure "\\*\\*\\* Handshake has failed"
"*Regular expression indicating failed TLS handshake.
The default is what GNUTLS's \"gnutls-cli\" outputs."
- ;; GNUTLS cli.c:do_handshake() print this string on failure. If the
+ ;; GNUTLS cli.c:do_handshake() print
s
this string on failure. If the
;; logic, or the string itself, is modified, this must be updated.
:version "22.1"
:type 'regexp
;; logic, or the string itself, is modified, this must be updated.
:version "22.1"
:type 'regexp
@@
-200,10
+196,10
@@
The default is what GNUTLS's \"gnutls-cli\" outputs."
:group 'starttls)
(defun starttls-negotiate-gnutls (process)
:group 'starttls)
(defun starttls-negotiate-gnutls (process)
- "Negotiate TLS on
process
opened by `open-starttls-stream'.
-This should typically only be done once. It typically return a
+ "Negotiate TLS on
PROCESS
opened by `open-starttls-stream'.
+This should typically only be done once. It typically return
s
a
multi-line informational message with information about the
multi-line informational message with information about the
-handshake, or
NIL
on failure."
+handshake, or
nil
on failure."
(let (buffer info old-max done-ok done-bad)
(if (null (setq buffer (process-buffer process)))
;; XXX How to remove/extract the TLS negotiation junk?
(let (buffer info old-max done-ok done-bad)
(if (null (setq buffer (process-buffer process)))
;; XXX How to remove/extract the TLS negotiation junk?
@@
-243,22
+239,21
@@
handshake, or NIL on failure."
(defalias 'starttls-set-process-query-on-exit-flag
'process-kill-without-query)))
(defalias 'starttls-set-process-query-on-exit-flag
'process-kill-without-query)))
-(defun starttls-open-stream-gnutls (name buffer host
service
)
- (message "Opening STARTTLS connection to `%s
'..." hos
t)
+(defun starttls-open-stream-gnutls (name buffer host
port
)
+ (message "Opening STARTTLS connection to `%s
:%s'..." host por
t)
(let* (done
(old-max (with-current-buffer buffer (point-max)))
(process-connection-type starttls-process-connection-type)
(process (apply #'start-process name buffer
starttls-gnutls-program "-s" host
(let* (done
(old-max (with-current-buffer buffer (point-max)))
(process-connection-type starttls-process-connection-type)
(process (apply #'start-process name buffer
starttls-gnutls-program "-s" host
- "-p" (if (integerp
service
)
- (int-to-string
service
)
-
service
)
+ "-p" (if (integerp
port
)
+ (int-to-string
port
)
+
port
)
starttls-extra-arguments)))
(starttls-set-process-query-on-exit-flag process nil)
(while (and (processp process)
(eq (process-status process) 'run)
starttls-extra-arguments)))
(starttls-set-process-query-on-exit-flag process nil)
(while (and (processp process)
(eq (process-status process) 'run)
- (save-excursion
- (set-buffer buffer)
+ (with-current-buffer buffer
(goto-char old-max)
(not (setq done (re-search-forward
starttls-connect nil t)))))
(goto-char old-max)
(not (setq done (re-search-forward
starttls-connect nil t)))))
@@
-269,15
+264,16
@@
handshake, or NIL on failure."
(delete-region old-max done))
(delete-process process)
(setq process nil))
(delete-region old-max done))
(delete-process process)
(setq process nil))
- (message "Opening STARTTLS connection to `%s'...%s"
- host (if done "done" "failed"))
+ (message "Opening STARTTLS connection to `%s
:%s
'...%s"
+ host
port
(if done "done" "failed"))
process))
process))
-(defun starttls-open-stream (name buffer host service)
- "Open a TLS connection for a service to a host.
-Returns a subprocess-object to represent the connection.
+;;;###autoload
+(defun starttls-open-stream (name buffer host port)
+ "Open a TLS connection for a port to a host.
+Returns a subprocess object to represent the connection.
Input and output work as for subprocesses; `delete-process' closes it.
Input and output work as for subprocesses; `delete-process' closes it.
-Args are NAME BUFFER HOST
SERVICE
.
+Args are NAME BUFFER HOST
PORT
.
NAME is name for process. It is modified if necessary to make it unique.
BUFFER is the buffer (or `buffer-name') to associate with the process.
Process output goes at end of that buffer, unless you specify
NAME is name for process. It is modified if necessary to make it unique.
BUFFER is the buffer (or `buffer-name') to associate with the process.
Process output goes at end of that buffer, unless you specify
@@
-285,19
+281,33
@@
BUFFER is the buffer (or `buffer-name') to associate with the process.
BUFFER may be also nil, meaning that this process is not associated
with any buffer
Third arg is name of the host to connect to, or its IP address.
BUFFER may be also nil, meaning that this process is not associated
with any buffer
Third arg is name of the host to connect to, or its IP address.
-Fourth arg SERVICE is name of the service desired, or an integer
-specifying a port number to connect to."
+Fourth arg PORT is an integer specifying a port to connect to.
+If `starttls-use-gnutls' is nil, this may also be a service name, but
+GNUTLS requires a port number."
(if starttls-use-gnutls
(if starttls-use-gnutls
- (starttls-open-stream-gnutls name buffer host service)
+ (starttls-open-stream-gnutls name buffer host port)
+ (message "Opening STARTTLS connection to `%s:%s'" host (format "%s" port))
(let* ((process-connection-type starttls-process-connection-type)
(process (apply #'start-process
name buffer starttls-program
(let* ((process-connection-type starttls-process-connection-type)
(process (apply #'start-process
name buffer starttls-program
- host (format "%s"
service
)
+ host (format "%s"
port
)
starttls-extra-args)))
(starttls-set-process-query-on-exit-flag process nil)
process)))
starttls-extra-args)))
(starttls-set-process-query-on-exit-flag process nil)
process)))
+(defun starttls-any-program-available ()
+ (let ((program (if starttls-use-gnutls
+ starttls-gnutls-program
+ starttls-program)))
+ (condition-case ()
+ (progn
+ (call-process program)
+ program)
+ (error (progn
+ (message "No STARTTLS program was available (tried '%s')"
+ program)
+ nil)))))
+
(provide 'starttls)
(provide 'starttls)
-;;; arch-tag: 648b3bd8-63bd-47f5-904c-7c819aea2297
;;; starttls.el ends here
;;; starttls.el ends here