[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master ea0ea90 08/17: ldap-search-internal: Send password
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] master ea0ea90 08/17: ldap-search-internal: Send password to ldapsearch through a pipe |
Date: |
Fri, 23 Jan 2015 22:20:33 +0000 |
branch: master
commit ea0ea9003d498afaac6c90222dc63919679b1769
Author: Thomas Fitzsimmons <address@hidden>
Commit: Thomas Fitzsimmons <address@hidden>
ldap-search-internal: Send password to ldapsearch through a pipe
* net/ldap.el (ldap-ldapsearch-password-prompt): New defcustom.
(ldap-search-internal): Send password to ldapsearch through a pipe
instead of via the command line.
---
lisp/ChangeLog | 6 ++++++
lisp/net/ldap.el | 42 +++++++++++++++++++++++++++++++++---------
2 files changed, 39 insertions(+), 9 deletions(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index dc27519..10a2aa8 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,11 @@
2014-11-13 Thomas Fitzsimmons <address@hidden>
+ * net/ldap.el (ldap-ldapsearch-password-prompt): New defcustom.
+ (ldap-search-internal): Send password to ldapsearch through a pipe
+ instead of via the command line.
+
+2014-11-13 Thomas Fitzsimmons <address@hidden>
+
* net/ldap.el: Require password-cache.
(ldap-password-read): New function.
(ldap-search-internal): Call ldap-password-read when it is
diff --git a/lisp/net/ldap.el b/lisp/net/ldap.el
index 113a9bc..32e403a 100644
--- a/lisp/net/ldap.el
+++ b/lisp/net/ldap.el
@@ -159,6 +159,12 @@ Valid properties include:
(string :tag "Argument"))
:group 'ldap)
+(defcustom ldap-ldapsearch-password-prompt-regexp "Enter LDAP Password: "
+ "A regular expression used to recognize the `ldapsearch'
+program's password prompt."
+ :type 'regexp
+ :group 'ldap)
+
(defcustom ldap-ignore-attribute-codings nil
"If non-nil, do not encode/decode LDAP attribute values."
:type 'boolean
@@ -569,7 +575,7 @@ an alist of attribute/value pairs."
(sizelimit (plist-get search-plist 'sizelimit))
(withdn (plist-get search-plist 'withdn))
(numres 0)
- arglist dn name value record result)
+ arglist dn name value record result proc)
(if (or (null filter)
(equal "" filter))
(error "No search filter"))
@@ -600,9 +606,9 @@ an alist of attribute/value pairs."
(if (and auth
(equal 'simple auth))
(setq arglist (nconc arglist (list "-x"))))
- (if (and passwd
- (not (equal "" passwd)))
- (setq arglist (nconc arglist (list (format "-w%s" passwd)))))
+ ;; Allow passwd to be set to "", representing a blank password.
+ (if passwd
+ (setq arglist (nconc arglist (list "-W"))))
(if (and deref
(not (equal "" deref)))
(setq arglist (nconc arglist (list (format "-a%s" deref)))))
@@ -612,14 +618,32 @@ an alist of attribute/value pairs."
(if (and sizelimit
(not (equal "" sizelimit)))
(setq arglist (nconc arglist (list (format "-z%s" sizelimit)))))
- (apply #'call-process ldap-ldapsearch-prog
- ;; Ignore stderr, which can corrupt results
- nil (list buf nil) nil
- (append arglist ldap-ldapsearch-args filter))
+ (if passwd
+ (let* ((process-connection-type nil)
+ (proc (apply #'start-process "ldapsearch" buf
+ ldap-ldapsearch-prog
+ (append arglist ldap-ldapsearch-args
+ filter))))
+ (while (null (progn
+ (goto-char (point-min))
+ (re-search-forward
+ ldap-ldapsearch-password-prompt-regexp
+ (point-max) t)))
+ (accept-process-output proc 1))
+ (process-send-string proc passwd)
+ (process-send-string proc "\n")
+ (while (not (memq (process-status proc) '(exit signal)))
+ (sit-for 0.1)))
+ (apply #'call-process ldap-ldapsearch-prog
+ ;; Ignore stderr, which can corrupt results
+ nil (list buf nil) nil
+ (append arglist ldap-ldapsearch-args filter)))
(insert "\n")
(goto-char (point-min))
- (while (re-search-forward "[\t\n\f]+ " nil t)
+ (while (re-search-forward (concat "[\t\n\f]+ \\|"
+ ldap-ldapsearch-password-prompt-regexp)
+ nil t)
(replace-match "" nil nil))
(goto-char (point-min))
- [Emacs-diffs] master updated (fd62486 -> ac5475d), Stefan Monnier, 2015/01/23
- [Emacs-diffs] master 0dee070 02/17: Support new-style LDAP URIs in ldap-search-internal, Stefan Monnier, 2015/01/23
- [Emacs-diffs] master 090cbf9 01/17: Change eudc-server-hotlist from a defvar to a defcustom, Stefan Monnier, 2015/01/23
- [Emacs-diffs] master fa9a3ca 04/17: Improve eudc-inline-expansion-format's default value, Stefan Monnier, 2015/01/23
- [Emacs-diffs] master 6dda29f 03/17: Improve eudc-inline-query-format's default value, Stefan Monnier, 2015/01/23
- [Emacs-diffs] master c8d2553 05/17: Ignore text properties in eudc-expand-inline, Stefan Monnier, 2015/01/23
- [Emacs-diffs] master b7d2dfa 06/17: Change eudc-expansion-overwrites-query default to nil, Stefan Monnier, 2015/01/23
- [Emacs-diffs] master 6a3a3b0 09/17: Downcase field names in LDAP results, Stefan Monnier, 2015/01/23
- [Emacs-diffs] master 87ff9ae 07/17: Add password-cache support to ldap.el, Stefan Monnier, 2015/01/23
- [Emacs-diffs] master ea0ea90 08/17: ldap-search-internal: Send password to ldapsearch through a pipe,
Stefan Monnier <=
- [Emacs-diffs] master 1e1f5b9 10/17: Append LDAP wildcard character to end of search string, Stefan Monnier, 2015/01/23
- [Emacs-diffs] master 81d0909 12/17: Restore former eudc-expand-inline settings after a nonlocal exit, Stefan Monnier, 2015/01/23
- [Emacs-diffs] master 7860227 11/17: Do not ask the user for an LDAP base if a default has been provided, Stefan Monnier, 2015/01/23
- [Emacs-diffs] master 9006ccd 13/17: Handle nil password-cache in ldap-password-read, Stefan Monnier, 2015/01/23
- [Emacs-diffs] master 4a77d69 14/17: ldap-password-read: Validate password before caching it, Stefan Monnier, 2015/01/23
- [Emacs-diffs] master e56e1b9 16/17: Mention binddn in LDAP credentials error message, Stefan Monnier, 2015/01/23
- [Emacs-diffs] master a6d4651 15/17: Update LDAP configuration section of EUDC manual, Stefan Monnier, 2015/01/23
- [Emacs-diffs] master ac5475d 17/17: lisp/net/{eudc, ldap}: Merge branch streamline-eudc-configuration, Stefan Monnier, 2015/01/23