From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Leonidas Tsampros Newsgroups: gmane.emacs.devel Subject: [PATCH] ldap.el: use auth-source if passwd is not defined in ldap-host-parameters-list Date: Fri, 04 Mar 2011 22:47:20 +0200 Message-ID: <878vwuvciv.fsf@bifteki.lan> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1299271779 31605 80.91.229.12 (4 Mar 2011 20:49:39 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 4 Mar 2011 20:49:39 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Mar 04 21:49:35 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PvbwM-0003Pp-Va for ged-emacs-devel@m.gmane.org; Fri, 04 Mar 2011 21:49:35 +0100 Original-Received: from localhost ([127.0.0.1]:49382 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PvbwH-0000Yk-Cz for ged-emacs-devel@m.gmane.org; Fri, 04 Mar 2011 15:49:29 -0500 Original-Received: from [140.186.70.92] (port=51919 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pvbw7-0000Ww-Hs for emacs-devel@gnu.org; Fri, 04 Mar 2011 15:49:20 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pvbw2-0008O1-QZ for emacs-devel@gnu.org; Fri, 04 Mar 2011 15:49:15 -0500 Original-Received: from mail-wy0-f169.google.com ([74.125.82.169]:56373) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pvbw2-0008Nm-JP for emacs-devel@gnu.org; Fri, 04 Mar 2011 15:49:14 -0500 Original-Received: by wyi11 with SMTP id 11so2865830wyi.0 for ; Fri, 04 Mar 2011 12:49:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:sender:from:to:subject:date:message-id :user-agent:mime-version:content-type; bh=LaIBr0X/4+awKNd8lrPiYdtYzA1maD8GaxsX4trk8yE=; b=J0EE8F79HEADIO3ZS4cDP+FPZ1blUI9twXeKamJocKz/l8neOiRg3+XnzQQA5YJATq SchsVuLOb86jJzzjcERHuZMrP0AvueWK0IGW7k4uXGq040xWQ7Lo7F7FAofc7cDqdyLk j2fcK0M0NMHTlS+24G3QiTc/aRZKpLiiIH+O8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:subject:date:message-id:user-agent:mime-version :content-type; b=RFuHDAeMEchN9CrLphZoUWFRK/RKJIw25LaUTjoUYvSdxHayvdrijKaJ4EkXFbnyzh 9vWLvqYqtfT+lO5umoY1aSTbaNWFU9XtvOAkRaLiqVwTNQxEAFNZCiH6kt32mJhLa/eS tn86ZGV592tbX5Uav+t62veAcfBmC5XV8zQEM= Original-Received: by 10.227.200.76 with SMTP id ev12mr931043wbb.141.1299271752931; Fri, 04 Mar 2011 12:49:12 -0800 (PST) Original-Received: from bifteki.lan ([64.211.150.195]) by mx.google.com with ESMTPS id x1sm2090842wbh.2.2011.03.04.12.49.09 (version=SSLv3 cipher=OTHER); Fri, 04 Mar 2011 12:49:11 -0800 (PST) Original-Received: from ltsampros-ferrari-one-200 (localhost.localdomain [127.0.0.1]) by bifteki.lan (Postfix) with ESMTP id 1B86B64A1D2 for ; Fri, 4 Mar 2011 22:47:21 +0200 (EET) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.82.169 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:136778 Archived-At: --=-=-= Content-Type: text/plain Hi, Attached you can find a small patch to make ldap.el use auth-source if passwd is not defined in the ldap-host-parameters-list. I find it useful not to carry passwords in my configurations files, so I was motivated enough to do that for ldap.el since I use it through eudc-ldap. Thanks to nnimap.el from which I copied this piece of code. I do not think that I break any existing configuration with this patch but I'm not entirely sure about that. Best Regards, Leonidas Tsampros --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=ldap-auth-rework.txt Content-Description: ldap patch auth-source # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: ltsampros@upnet.gr-20110302174918-h06k6ohsksc8ymju # target_branch: file:///home/ltsampros/repos2/emacs/trunk/ # testament_sha1: 2d5eb512df6c9c23c2c736a832130bd0e48e6a4c # timestamp: 2011-03-02 19:54:44 +0200 # base_revision_id: schwab@linux-m68k.org-20110302104247-\ # z4p2vqooiv34g8bd # # Begin patch === modified file 'lisp/net/ldap.el' --- lisp/net/ldap.el 2011-01-25 04:08:28 +0000 +++ lisp/net/ldap.el 2011-03-02 17:49:18 +0000 @@ -36,6 +36,8 @@ (require 'custom) (eval-when-compile (require 'cl)) +(autoload 'auth-source-search "auth-source") + (defgroup ldap nil "Lightweight Directory Access Protocol." :version "21.1" @@ -512,7 +514,15 @@ (scope (plist-get search-plist 'scope)) (binddn (plist-get search-plist 'binddn)) (auth (plist-get search-plist 'auth)) - (passwd (plist-get search-plist 'passwd)) + (passwd (or (plist-get search-plist 'passwd) + (let ((found (nth 0 (auth-source-search :host (if (boundp 'host) host) + :create t)))) + (if found + (let ((secret (plist-get found :secret))) + (if (functionp secret) + (funcall secret) + secret)))) + )) (deref (plist-get search-plist 'deref)) (timelimit (plist-get search-plist 'timelimit)) (sizelimit (plist-get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