diff options
| author | Lars Ingebrigtsen | 2019-09-20 21:25:47 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2019-09-20 22:10:52 +0200 |
| commit | a420f13155b71b68b964a51ff326ccdf441c2811 (patch) | |
| tree | f4b1b4825ce725ba032053a5c2c9e35bb204bf79 | |
| parent | 6d50010b34dbbcb90a7b4512f97e07fd8beceea5 (diff) | |
| download | emacs-a420f13155b71b68b964a51ff326ccdf441c2811.tar.gz emacs-a420f13155b71b68b964a51ff326ccdf441c2811.zip | |
Obfuscate auth-source secrets more
* lisp/auth-source.el (auth-source-netrc-normalize): Obfuscate
passwords stored in the lexical closure (bug#37196).
| -rw-r--r-- | lisp/auth-source.el | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/lisp/auth-source.el b/lisp/auth-source.el index 7d8657da110..83ed90a87f2 100644 --- a/lisp/auth-source.el +++ b/lisp/auth-source.el | |||
| @@ -1132,11 +1132,15 @@ FILE is the file from which we obtained this token." | |||
| 1132 | ((member k '("password")) "secret") | 1132 | ((member k '("password")) "secret") |
| 1133 | (t k))) | 1133 | (t k))) |
| 1134 | 1134 | ||
| 1135 | ;; send back the secret in a function (lexical binding) | 1135 | ;; Send back the secret in a function (lexical |
| 1136 | ;; binding). We slightly obfuscate the passwords | ||
| 1137 | ;; (that's the "(mapcar #+' ..)" stuff) to avoid | ||
| 1138 | ;; showing the passwords in clear text in backtraces | ||
| 1139 | ;; and the like. | ||
| 1136 | (when (equal k "secret") | 1140 | (when (equal k "secret") |
| 1137 | (setq v (let ((lexv v) | 1141 | (setq v (let ((lexv (mapcar #'1+ v)) |
| 1138 | (token-decoder nil)) | 1142 | (token-decoder nil)) |
| 1139 | (when (string-match "^gpg:" lexv) | 1143 | (when (string-match "^gpg:" v) |
| 1140 | ;; it's a GPG token: create a token decoder | 1144 | ;; it's a GPG token: create a token decoder |
| 1141 | ;; which unsets itself once | 1145 | ;; which unsets itself once |
| 1142 | (setq token-decoder | 1146 | (setq token-decoder |
| @@ -1147,9 +1151,11 @@ FILE is the file from which we obtained this token." | |||
| 1147 | filename) | 1151 | filename) |
| 1148 | (setq token-decoder nil))))) | 1152 | (setq token-decoder nil))))) |
| 1149 | (lambda () | 1153 | (lambda () |
| 1150 | (when token-decoder | 1154 | (if token-decoder |
| 1151 | (setq lexv (funcall token-decoder lexv))) | 1155 | (funcall token-decoder |
| 1152 | lexv)))) | 1156 | (apply #'string |
| 1157 | (mapcar #'1- lexv))) | ||
| 1158 | (apply #'string (mapcar #'1- lexv))))))) | ||
| 1153 | (setq ret (plist-put ret | 1159 | (setq ret (plist-put ret |
| 1154 | (auth-source--symbol-keyword k) | 1160 | (auth-source--symbol-keyword k) |
| 1155 | v)))) | 1161 | v)))) |