From: Dario Gjorgjevski <dario.gjorgjevski@gmail.com>
To: 38311@debbugs.gnu.org
Subject: bug#38311: [PATCH] Hide quoted passwords with spaces in Authinfo
Date: Thu, 21 Nov 2019 10:18:03 +0100 [thread overview]
Message-ID: <fv2zoj4kyxio50.fsf@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 778 bytes --]
The auth-source library hides passwords in authinfo-mode, putting an
overlay of "****" over them.
For example,
“machine localhost port sudo login root password foobar”
will show up as
“machine localhost port sudo login root password ****”.
However, it fails to properly hide passwords which are quoted and
contain spaces, even though those are still valid and parsed
successfully.
For example,
“machine localhost port sudo login root password "foo bar"”
will show up as
“machine localhost port sudo login root password **** bar"”.
The attached patch fixes this by using the same logic that
‘auth-source-netrc-parse-one’ uses to retrieve the field. The logic is
moved to a separate function.
Best regards,
Dario
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Hide quoted passwords with spaces in Authinfo --]
[-- Type: text/x-diff, Size: 1986 bytes --]
From 34f07b1dc8517d1c7e580bff1e5ac34b69c993d6 Mon Sep 17 00:00:00 2001
From: Dario Gjorgjevski <dario.gjorgjevski+git@gmail.com>
Date: Thu, 21 Nov 2019 10:10:32 +0100
Subject: [PATCH] Hide quoted passwords with spaces in Authinfo
To: bug-gnu-emacs@gnu.org
* lisp/auth-source.el (auth-source-netrc-looking-at-one): New
function, extracted from auth-source-netrc-parse-one.
(auth-source-netrc-parse-one, authinfo--hide-passwords): Use
auth-source-netrc-looking-at-one.
---
lisp/auth-source.el | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/lisp/auth-source.el b/lisp/auth-source.el
index 4926f67f0a..0800202914 100644
--- a/lisp/auth-source.el
+++ b/lisp/auth-source.el
@@ -1000,13 +1000,17 @@ auth-source-netrc-parse-next-interesting
(forward-line 1)
(skip-chars-forward "\t ")))
+(defun auth-source-netrc-looking-at-one ()
+ "Modify match data with one thing from the current buffer."
+ (or (looking-at "'\\([^']*\\)'")
+ (looking-at "\"\\([^\"]*\\)\"")
+ (looking-at "\\([^ \t\n]+\\)")))
+
(defun auth-source-netrc-parse-one ()
"Read one thing from the current buffer."
(auth-source-netrc-parse-next-interesting)
- (when (or (looking-at "'\\([^']*\\)'")
- (looking-at "\"\\([^\"]*\\)\"")
- (looking-at "\\([^ \t\n]+\\)"))
+ (when (auth-source-netrc-looking-at-one)
(forward-char (length (match-string 0)))
(prog1
(match-string-no-properties 1)
@@ -2427,7 +2431,7 @@ authinfo--hide-passwords
(while (re-search-forward (format "\\(\\s-\\|^\\)\\(%s\\)\\s-+"
authinfo-hidden)
nil t)
- (when (looking-at "[^\n\t ]+")
+ (when (auth-source-netrc-looking-at-one)
(let ((overlay (make-overlay (match-beginning 0) (match-end 0))))
(overlay-put overlay 'display (propertize "****"
'face 'warning))
--
2.17.1
next reply other threads:[~2019-11-21 9:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-21 9:18 Dario Gjorgjevski [this message]
2019-11-21 12:52 ` bug#38311: [PATCH] Hide quoted passwords with spaces in Authinfo Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fv2zoj4kyxio50.fsf@gmail.com \
--to=dario.gjorgjevski@gmail.com \
--cc=38311@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.