unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#19074: 24.4; Bug in auth-source.el's search of OS X Keychain
@ 2014-11-17  4:04 John Mastro
  2014-11-17  5:38 ` bug#19074: " John Mastro
  0 siblings, 1 reply; 6+ messages in thread
From: John Mastro @ 2014-11-17  4:04 UTC (permalink / raw)
  To: 19074

The library `auth-source.el' contains code to search OS X's Keychain
(the backends `macos-keychain-generic' and `macos-keychain-internet').

Both backends are implemented by parsing the results of OS X's
/usr/bin/security. This parsing is done by
`auth-source-macos-keychain-search-items'. However, there's currently a
problem with this code in both the master and emacs-24 branches.

Specifically, the function `auth-source-macos-keychain-result-append' is
called three times, but each time its result is ignored.

A precise recipe from `emacs -Q' is a little difficult, because it
depends on OS X and what you have in your keychain. However, the below
is an example of what will work with the fix but not with the current
code.

A simple patch (against the emacs-24 batch) is attached. I don't yet
have paperwork on file with FSF, but I believe this is short/trivial
enough to be accepted anyway.

    ;; Example. With appropriate user/host, will be nil before patch but
    ;; return expected output after patch.
    (progn (require 'auth-source)
           (auth-source-macos-keychain-search
            :backend (auth-source-backend-parse 'macos-keychain-internet)
            :user "MY-USER"
            :host "MY-HOST"))

Patch:

diff --git a/lisp/gnus/auth-source.el b/lisp/gnus/auth-source.el
index a50ad75..72ec5f4 100644
--- a/lisp/gnus/auth-source.el
+++ b/lisp/gnus/auth-source.el
@@ -1779,29 +1779,29 @@ entries for git.gnus.org:
         (while (not (eobp))
           (cond
            ((looking-at "^password: \"\\(.+\\)\"$")
-            (auth-source-macos-keychain-result-append
-             ret
-             keychain-generic
-             "secret"
-             (lexical-let ((v (match-string 1)))
-               (lambda () v))))
+            (setq ret (auth-source-macos-keychain-result-append
+                       ret
+                       keychain-generic
+                       "secret"
+                       (lexical-let ((v (match-string 1)))
+                         (lambda () v)))))
            ;; TODO: check if this is really the label
            ;; match 0x00000007 <blob>="AppleID"
            ((looking-at "^[ ]+0x00000007 <blob>=\"\\(.+\\)\"")
-            (auth-source-macos-keychain-result-append
-             ret
-             keychain-generic
-             "label"
-             (match-string 1)))
+            (setq ret (auth-source-macos-keychain-result-append
+                       ret
+                       keychain-generic
+                       "label"
+                       (match-string 1))))
            ;; match "crtr"<uint32>="aapl"
            ;; match "svce"<blob>="AppleID"
            ((looking-at "^[ ]+\"\\([a-z]+\\)\"[^=]+=\"\\(.+\\)\"")
-            (auth-source-macos-keychain-result-append
-             ret
-             keychain-generic
-             (match-string 1)
-             (match-string 2))))
-            (forward-line)))
+            (setq ret (auth-source-macos-keychain-result-append
+                       ret
+                       keychain-generic
+                       (match-string 1)
+                       (match-string 2)))))
+          (forward-line)))
       ;; return `ret' iff it has the :secret key
       (and (plist-get ret :secret) (list ret))))

In GNU Emacs 24.4.1 (x86_64-apple-darwin14.0.0, NS apple-appkit-1343.14)
 of 2014-11-09 on nebula.local
Windowing system distributor `Apple', version 10.3.1343
Configured using:
 `configure --prefix=/usr/local/Cellar/emacs/24.4
 --enable-locallisppath=/usr/local/share/emacs/site-lisp
 --infodir=/usr/local/Cellar/emacs/24.4/share/info/emacs --without-dbus
 --with-gnutls --with-imagemagick --with-ns --disable-ns-self-contained'

Important settings:
  locale-coding-system: utf-8-unix

Major mode: Emacs-Lisp

Minor modes in effect:
  magit-auto-revert-mode: t
  diff-auto-refine-mode: t
  shell-dirtrack-mode: t
  flyspell-mode: t
  paredit-mode: t
  eldoc-mode: t
  elisp-slime-nav-mode: t
  whitespace-mode: t
  global-company-mode: t
  company-mode: t
  smartparens-global-strict-mode: t
  projectile-global-mode: t
  projectile-mode: t
  ido-vertical-mode: t
  ido-ubiquitous-mode: t
  flx-ido-mode: t
  ido-everywhere: t
  savehist-mode: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  guide-key-mode: t
  global-discover-mode: t
  discover-mode: t
  recentf-mode: t
  winner-mode: t
  global-auto-revert-mode: t
  global-page-break-lines-mode: t
  page-break-lines-mode: t
  delete-selection-mode: t
  show-paren-mode: t
  global-hl-line-mode: t
  tooltip-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  size-indication-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
SPC f u n c t i o n SPC A-H-s-÷µ¹¶ M-o C-x b <return> 
M-= M-= M-w C-x b C-g C-v C-v C-x b <return> M-o C-q 
` C-y ' M-q SPC l o o p s SPC t h r o u A-H-s-÷µ¹¶ g h 
SPC C-a C-e a n d SPC u s e s SPC <backspace> <return> 
M-o C-x b <return> C-p C-p C-p M-f M-f M-f M-= M-= 
M-w C-x b <return> M-o C-q ` C-y ' SPC t o SPC c o 
l l e A-H-s-÷µ¹¶ c t SPC i n f o r m a t i o n . SPC H 
o w e v e r , SPC t h e SPC r e s A-H-s-÷µ¹¶ u l <backspace> 
<backspace> <backspace> <backspace> <backspace> <backspace> 
<backspace> <backspace> <backspace> <backspace> <backspace> 
C-h C-h C-g C-n C-k I n A-H-s-÷µ¹¶ C-c C-j C-c C-j M-^ 
M-e C-k , SPC t h e SPC r e t u r n SPC c <backspace> 
v a l u e SPC o f A-H-s-÷µ¹¶ C-n <M-backspace> <M-backspace> 
w a s SPC b e i n g SPC i g n o r e d . SPC T h i A-H-s-÷µ¹¶ 
s SPC c a u s e d SPC t h e SPC i n t e n d e d SPC 
r e s u l t A-H-s-÷µ¹¶ SPC n o t SPC t o SPC b e SPC r 
e t u r n e d . C-n C-a C-k C-k C-p C-p C-p C-c C-c 
C-x C-f <backspace> <backspace> <backspace> d r o <return> 
<return> e m <return> p a t C-n <return> C-h C-k q 
M-x r e p o r t - e m a c s - b u g <return>

Recent messages:
Quit
Indenting region...done
Indenting region...done
Indenting region...done
Indenting region...done
Indenting region...done
Indenting region...done
Saving file /Users/jbm/src/emacs/emacs/.git/COMMIT_EDITMSG...
Wrote /Users/jbm/src/emacs/emacs/.git/COMMIT_EDITMSG
Git finished

Load-path shadows:
None found.

Features:
(shadow emacsbug expand-region text-mode-expansions
the-org-mode-expansions er-basic-expansions expand-region-core
expand-region-custom magit-key-mode magit view tramp tramp-compat
tramp-loaddefs trampver git-rebase-mode git-commit-mode log-edit
pcvs-util add-log idomenu imenu eieio-opt ace-window ace-jump-mode
diff-mode gnutls network-stream starttls tls mailalias mail-extr sort
hippie-exp org-rmail org-mhe org-irc org-info org-gnus org-docview
org-bibtex bibtex org-bbdb org-w3m ob-sh shell ob-python ob-clojure org
org-macro org-footnote org-pcomplete pcomplete org-list org-faces
org-entities noutline outline org-version ob-emacs-lisp ob ob-tangle
ob-ref ob-lob ob-table ob-exp org-src ob-keys ob-comint ob-core ob-eval
org-compat org-macs org-loaddefs cal-menu calendar cal-loaddefs
mule-util mu4e mu4e-speedbar speedbar sb-image ezimage dframe mu4e-main
mu4e-view epa derived epg browse-url mu4e-headers mu4e-compose
mu4e-draft mu4e-actions rfc2368 smtpmail sendmail mu4e-mark mu4e-message
html2text mu4e-proc mu4e-utils doc-view image-mode find-dired dired+
image-dired image-file dired-x dired-aux dired mu4e-lists mu4e-about
mu4e-vars message format-spec rfc822 mml mml-sec mm-decode mm-bodies
mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev
mail-utils gmm-utils mailheader mu4e-meta smex misearch multi-isearch
auth-source gnus-util mm-util mail-prsvr password-cache pp vc-git
flyspell ispell jka-compr disp-table paredit eldoc elisp-slime-nav
help-mode whitespace company-files company-keywords company-etags etags
company-gtags company-dabbrev-code company-dabbrev company-capf company
skewer-setup smartparens redshank-loader projectile ibuffer-vc ibuf-ext
ibuffer pkg-info find-func lisp-mnt epl grep compile comint thingatpt
ido-at-point ido-vertical-mode ido-ubiquitous warnings flx-ido flx ido
ibuf-macs savehist saveplace undo-tree diff key-chord guide-key
face-remap popwin discover makey man ansi-color recentf tree-widget
wid-edit browse-kill-ring winner ring diminish solarized-dark-theme
solarized-definitions cl autorevert filenotify page-break-lines delsel
paren hl-line server exec-path-from-shell rx easy-mmode advice help-fns
s ucs-normalize dash-functional dash subr-x pcase cl-macs gv finder-inf
eieio byte-opt bytecomp byte-compile cconv eieio-core edmacro kmacro
info easymenu slime-autoloads package epg-config cl-loaddefs cl-lib
time-date tooltip electric uniquify ediff-hook vc-hooks lisp-float-type
mwheel ns-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment lisp-mode prog-mode register page menu-bar
rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax
facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak
czech european ethiopic indian cyrillic chinese case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer nadvice loaddefs button
faces cus-face macroexp files text-properties overlay sha1 md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process cocoa ns multi-tty emacs)

Memory information:
((conses 16 759686 83978)
 (symbols 48 45387 18)
 (miscs 40 1637 1304)
 (strings 32 105380 22526)
 (string-bytes 1 3126833)
 (vectors 16 136035)
 (vector-slots 8 3699462 25228)
 (floats 8 25664 1278)
 (intervals 56 3552 721)
 (buffers 960 35))

-- 
jbm





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

* bug#19074: Bug in auth-source.el's search of OS X Keychain
  2014-11-17  4:04 bug#19074: 24.4; Bug in auth-source.el's search of OS X Keychain John Mastro
@ 2014-11-17  5:38 ` John Mastro
  2014-11-26 14:17   ` Ted Zlatanov
  0 siblings, 1 reply; 6+ messages in thread
From: John Mastro @ 2014-11-17  5:38 UTC (permalink / raw)
  To: 19074

I accidentally copied only part of the patch in my original email. The
full thing (via `git format-patch') follows.

-- 
jbm


From 2b968a29ff2a01e316e09faa4d765aca08cf0121 Mon Sep 17 00:00:00 2001
From: John Mastro <john.b.mastro@gmail.com>
Date: Sun, 16 Nov 2014 19:41:10 -0800
Subject: [PATCH] Fix auth-source.el bug regarding the OS X Keychain

In `auth-source-macos-keychain-search-items', the return value of
`auth-source-macos-keychain-result-append' was being ignored. This
caused the intended result not to be returned.
---
 lisp/gnus/auth-source.el | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/lisp/gnus/auth-source.el b/lisp/gnus/auth-source.el
index a50ad75..72ec5f4 100644
--- a/lisp/gnus/auth-source.el
+++ b/lisp/gnus/auth-source.el
@@ -1779,29 +1779,29 @@ entries for git.gnus.org:
         (while (not (eobp))
           (cond
            ((looking-at "^password: \"\\(.+\\)\"$")
-            (auth-source-macos-keychain-result-append
-             ret
-             keychain-generic
-             "secret"
-             (lexical-let ((v (match-string 1)))
-               (lambda () v))))
+            (setq ret (auth-source-macos-keychain-result-append
+                       ret
+                       keychain-generic
+                       "secret"
+                       (lexical-let ((v (match-string 1)))
+                         (lambda () v)))))
            ;; TODO: check if this is really the label
            ;; match 0x00000007 <blob>="AppleID"
            ((looking-at "^[ ]+0x00000007 <blob>=\"\\(.+\\)\"")
-            (auth-source-macos-keychain-result-append
-             ret
-             keychain-generic
-             "label"
-             (match-string 1)))
+            (setq ret (auth-source-macos-keychain-result-append
+                       ret
+                       keychain-generic
+                       "label"
+                       (match-string 1))))
            ;; match "crtr"<uint32>="aapl"
            ;; match "svce"<blob>="AppleID"
            ((looking-at "^[ ]+\"\\([a-z]+\\)\"[^=]+=\"\\(.+\\)\"")
-            (auth-source-macos-keychain-result-append
-             ret
-             keychain-generic
-             (match-string 1)
-             (match-string 2))))
-            (forward-line)))
+            (setq ret (auth-source-macos-keychain-result-append
+                       ret
+                       keychain-generic
+                       (match-string 1)
+                       (match-string 2)))))
+          (forward-line)))
       ;; return `ret' iff it has the :secret key
       (and (plist-get ret :secret) (list ret))))
 
-- 
2.1.3






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

* bug#19074: Bug in auth-source.el's search of OS X Keychain
  2014-11-17  5:38 ` bug#19074: " John Mastro
@ 2014-11-26 14:17   ` Ted Zlatanov
  2014-11-26 15:57     ` Stefan Monnier
  2014-11-26 22:30     ` Katsumi Yamaoka
  0 siblings, 2 replies; 6+ messages in thread
From: Ted Zlatanov @ 2014-11-26 14:17 UTC (permalink / raw)
  To: John Mastro, Glenn Morris, Stefan Monnier; +Cc: Katsumi Yamaoka, 19074-done

On Sun, 16 Nov 2014 21:38:32 -0800 John Mastro <jbm@jbm.io> wrote: 

JM> I accidentally copied only part of the patch in my original email. The
JM> full thing (via `git format-patch') follows.

Thanks, applied to emacs-24 branch as a bugfix:

commit a10e36a5d7fe95830e3f93dc7ae6f65507738978
Author: John Mastro <john.b.mastro@gmail.com>
Date:   Wed Nov 26 09:15:08 2014 -0500

    auth-source: Fix Mac OS X keychain lookups.
    
    * auth-source.el (auth-source-macos-keychain-search-items): Return
    result of `auth-source-macos-keychain-result-append' (bug#19074).

It will eventually get ported to Emacs master and to Gnus master as
well.  Glenn or Stefan, should I do that or wait for you?

Thanks!
Ted





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

* bug#19074: Bug in auth-source.el's search of OS X Keychain
  2014-11-26 14:17   ` Ted Zlatanov
@ 2014-11-26 15:57     ` Stefan Monnier
  2014-11-26 22:30     ` Katsumi Yamaoka
  1 sibling, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2014-11-26 15:57 UTC (permalink / raw)
  To: John Mastro; +Cc: Katsumi Yamaoka, 19074-done

> It will eventually get ported to Emacs master and to Gnus master as
> well.  Glenn or Stefan, should I do that or wait for you?

Feel free to merge emacs-24 into master any time you feel like it.

BUT: I really mean "merge the branch", not "cherrypick my change".


        Stefan





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

* bug#19074: Bug in auth-source.el's search of OS X Keychain
  2014-11-26 14:17   ` Ted Zlatanov
  2014-11-26 15:57     ` Stefan Monnier
@ 2014-11-26 22:30     ` Katsumi Yamaoka
  2014-11-27  1:24       ` Ted Zlatanov
  1 sibling, 1 reply; 6+ messages in thread
From: Katsumi Yamaoka @ 2014-11-26 22:30 UTC (permalink / raw)
  To: 19074-done; +Cc: John Mastro

On Wed, 26 Nov 2014 09:17:22 -0500, Ted Zlatanov wrote:
> Thanks, applied to emacs-24 branch as a bugfix:
[...]
>     auth-source: Fix Mac OS X keychain lookups.

>     * auth-source.el (auth-source-macos-keychain-search-items): Return
>     result of `auth-source-macos-keychain-result-append' (bug#19074).

> It will eventually get ported to Emacs master and to Gnus master as
> well.  Glenn or Stefan, should I do that or wait for you?

I've installed the fix in the Gnus master in advance of merging
it to the Emacs master. ;)  Thanks.





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

* bug#19074: Bug in auth-source.el's search of OS X Keychain
  2014-11-26 22:30     ` Katsumi Yamaoka
@ 2014-11-27  1:24       ` Ted Zlatanov
  0 siblings, 0 replies; 6+ messages in thread
From: Ted Zlatanov @ 2014-11-27  1:24 UTC (permalink / raw)
  To: Katsumi Yamaoka; +Cc: John Mastro, 19074-done

On Thu, 27 Nov 2014 07:30:12 +0900 Katsumi Yamaoka <yamaoka@jpl.org> wrote: 

KY> On Wed, 26 Nov 2014 09:17:22 -0500, Ted Zlatanov wrote:
>> Thanks, applied to emacs-24 branch as a bugfix:
...
>> It will eventually get ported to Emacs master and to Gnus master as
>> well.  Glenn or Stefan, should I do that or wait for you?

KY> I've installed the fix in the Gnus master in advance of merging
KY> it to the Emacs master. ;)  Thanks.

Excellent. I started with emacs-24 because I wanted to make sure it
showed up in the next 24.x release and we're asked to make changes there
before master/trunk, that's why this commit was a bit unusual.

Thanks for your help!
Ted





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

end of thread, other threads:[~2014-11-27  1:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-17  4:04 bug#19074: 24.4; Bug in auth-source.el's search of OS X Keychain John Mastro
2014-11-17  5:38 ` bug#19074: " John Mastro
2014-11-26 14:17   ` Ted Zlatanov
2014-11-26 15:57     ` Stefan Monnier
2014-11-26 22:30     ` Katsumi Yamaoka
2014-11-27  1:24       ` Ted Zlatanov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).