diff options
| author | Leon Vack | 2021-01-11 15:51:14 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2021-01-11 15:51:14 +0100 |
| commit | 42e72f4adee8809ed754a14e11e058f40b337f78 (patch) | |
| tree | 2daca8aa3a56f8c9048029f7af367901245c28ea | |
| parent | 6129ebf4499ba641c3964eac4a028d4aa370f090 (diff) | |
| download | emacs-42e72f4adee8809ed754a14e11e058f40b337f78.tar.gz emacs-42e72f4adee8809ed754a14e11e058f40b337f78.zip | |
Support using auth-source for NickServ passwords in ERC
* lisp/etc/erc-services.el (erc-nickserv-passwords): Document that
the passwords are only used when erc-prompt-for-nickserv-password
is nil.
* (erc-use-auth-source-for-nickserv-password): New customizable
variable to enable checking auth-source for NickServ passwords.
* (etc-nickserv-get-password): New function to handle the lookup
of the NickServ password from both auth-source and the
erc-nickserv-passwords variable.
* (erc-nickserv-call-identify-function): Use new
erc-nickserv-get-password function to lookup NickServ passwords.
* (erc-nickserv-identify-autodetect, erc-nickserv-identify-on-connect,
erc-nickserv-identify-on-nick-change): Call
erc-nickserv-call-identify-function when
erc-use-auth-source-for-nickserv-password is set.
* etc/NEWS: Document change (bug#45340).
| -rw-r--r-- | etc/NEWS | 8 | ||||
| -rw-r--r-- | lisp/erc/erc-services.el | 56 | ||||
| -rw-r--r-- | lisp/window.el | 1 |
3 files changed, 53 insertions, 12 deletions
| @@ -1371,6 +1371,14 @@ https://www.w3.org/TR/xml/#charsets). Now it rejects such strings. | |||
| 1371 | 1371 | ||
| 1372 | ** erc | 1372 | ** erc |
| 1373 | 1373 | ||
| 1374 | *** erc-services.el now supports NickServ passwords from auth-source. | ||
| 1375 | The 'erc-use-auth-source-for-nickserv-password' variable enables querying | ||
| 1376 | auth-source for NickServ passwords. To enable this, add the following | ||
| 1377 | to your init file: | ||
| 1378 | |||
| 1379 | (setq erc-prompt-for-nickserv-password nil | ||
| 1380 | erc-use-auth-source-for-nickserv-password t) | ||
| 1381 | |||
| 1374 | --- | 1382 | --- |
| 1375 | *** The '/ignore' command will now ask for a timeout to stop ignoring the user. | 1383 | *** The '/ignore' command will now ask for a timeout to stop ignoring the user. |
| 1376 | Allowed inputs are seconds or ISO8601-like periods like "1h" or "4h30m". | 1384 | Allowed inputs are seconds or ISO8601-like periods like "1h" or "4h30m". |
diff --git a/lisp/erc/erc-services.el b/lisp/erc/erc-services.el index 4f9b0b199f9..9ef8b7f46ab 100644 --- a/lisp/erc/erc-services.el +++ b/lisp/erc/erc-services.el | |||
| @@ -168,8 +168,19 @@ You can also use \\[erc-nickserv-identify-mode] to change modes." | |||
| 168 | :group 'erc-services | 168 | :group 'erc-services |
| 169 | :type 'boolean) | 169 | :type 'boolean) |
| 170 | 170 | ||
| 171 | (defcustom erc-use-auth-source-for-nickserv-password nil | ||
| 172 | "Query auth-source for a password when identifiying to NickServ. | ||
| 173 | This option has an no effect if `erc-prompt-for-nickserv-password' | ||
| 174 | is non-nil, and passwords from `erc-nickserv-passwords' take | ||
| 175 | precedence." | ||
| 176 | :version "28.1" | ||
| 177 | :group 'erc-services | ||
| 178 | :type 'boolean) | ||
| 179 | |||
| 171 | (defcustom erc-nickserv-passwords nil | 180 | (defcustom erc-nickserv-passwords nil |
| 172 | "Passwords used when identifying to NickServ automatically. | 181 | "Passwords used when identifying to NickServ automatically. |
| 182 | `erc-prompt-for-nickserv-password' must be nil for these | ||
| 183 | passwords to be used. | ||
| 173 | 184 | ||
| 174 | Example of use: | 185 | Example of use: |
| 175 | (setq erc-nickserv-passwords | 186 | (setq erc-nickserv-passwords |
| @@ -375,7 +386,8 @@ Make sure it is the real NickServ for this network. | |||
| 375 | If `erc-prompt-for-nickserv-password' is non-nil, prompt the user for the | 386 | If `erc-prompt-for-nickserv-password' is non-nil, prompt the user for the |
| 376 | password for this nickname, otherwise try to send it automatically." | 387 | password for this nickname, otherwise try to send it automatically." |
| 377 | (unless (and (null erc-nickserv-passwords) | 388 | (unless (and (null erc-nickserv-passwords) |
| 378 | (null erc-prompt-for-nickserv-password)) | 389 | (null erc-prompt-for-nickserv-password) |
| 390 | (null erc-use-auth-source-for-nickserv-password)) | ||
| 379 | (let* ((network (erc-network)) | 391 | (let* ((network (erc-network)) |
| 380 | (sender (erc-nickserv-alist-sender network)) | 392 | (sender (erc-nickserv-alist-sender network)) |
| 381 | (identify-regex (erc-nickserv-alist-regexp network)) | 393 | (identify-regex (erc-nickserv-alist-regexp network)) |
| @@ -394,30 +406,49 @@ password for this nickname, otherwise try to send it automatically." | |||
| 394 | (defun erc-nickserv-identify-on-connect (_server nick) | 406 | (defun erc-nickserv-identify-on-connect (_server nick) |
| 395 | "Identify to Nickserv after the connection to the server is established." | 407 | "Identify to Nickserv after the connection to the server is established." |
| 396 | (unless (or (and (null erc-nickserv-passwords) | 408 | (unless (or (and (null erc-nickserv-passwords) |
| 397 | (null erc-prompt-for-nickserv-password)) | 409 | (null erc-prompt-for-nickserv-password) |
| 398 | (and (eq erc-nickserv-identify-mode 'both) | 410 | (null erc-use-auth-source-for-nickserv-password)) |
| 399 | (erc-nickserv-alist-regexp (erc-network)))) | 411 | (and (eq erc-nickserv-identify-mode 'both) |
| 412 | (erc-nickserv-alist-regexp (erc-network)))) | ||
| 400 | (erc-nickserv-call-identify-function nick))) | 413 | (erc-nickserv-call-identify-function nick))) |
| 401 | 414 | ||
| 402 | (defun erc-nickserv-identify-on-nick-change (nick _old-nick) | 415 | (defun erc-nickserv-identify-on-nick-change (nick _old-nick) |
| 403 | "Identify to Nickserv whenever your nick changes." | 416 | "Identify to Nickserv whenever your nick changes." |
| 404 | (unless (or (and (null erc-nickserv-passwords) | 417 | (unless (or (and (null erc-nickserv-passwords) |
| 405 | (null erc-prompt-for-nickserv-password)) | 418 | (null erc-prompt-for-nickserv-password) |
| 406 | (and (eq erc-nickserv-identify-mode 'both) | 419 | (null erc-use-auth-source-for-nickserv-password)) |
| 407 | (erc-nickserv-alist-regexp (erc-network)))) | 420 | (and (eq erc-nickserv-identify-mode 'both) |
| 421 | (erc-nickserv-alist-regexp (erc-network)))) | ||
| 408 | (erc-nickserv-call-identify-function nick))) | 422 | (erc-nickserv-call-identify-function nick))) |
| 409 | 423 | ||
| 424 | (defun erc-nickserv-get-password (nickname) | ||
| 425 | "Return the password for NICKNAME from configured sources. | ||
| 426 | |||
| 427 | It uses `erc-nickserv-passwords' and additionally auth-source | ||
| 428 | when `erc-use-auth-source-for-nickserv-password' is not nil." | ||
| 429 | (or | ||
| 430 | (when erc-nickserv-passwords | ||
| 431 | (cdr (assoc nickname | ||
| 432 | (nth 1 (assoc (erc-network) | ||
| 433 | erc-nickserv-passwords))))) | ||
| 434 | (when erc-use-auth-source-for-nickserv-password | ||
| 435 | (let* ((secret (nth 0 (auth-source-search | ||
| 436 | :max 1 :require '(:secret) | ||
| 437 | :host (erc-with-server-buffer erc-session-server) | ||
| 438 | :port (format ; ensure we have a string | ||
| 439 | "%s" (erc-with-server-buffer erc-session-port)) | ||
| 440 | :user nickname)))) | ||
| 441 | (when secret | ||
| 442 | (let ((passwd (plist-get secret :secret))) | ||
| 443 | (if (functionp passwd) (funcall passwd) passwd))))))) | ||
| 444 | |||
| 410 | (defun erc-nickserv-call-identify-function (nickname) | 445 | (defun erc-nickserv-call-identify-function (nickname) |
| 411 | "Call `erc-nickserv-identify'. | 446 | "Call `erc-nickserv-identify'. |
| 412 | Either call it interactively or run it with NICKNAME's password, | 447 | Either call it interactively or run it with NICKNAME's password, |
| 413 | depending on the value of `erc-prompt-for-nickserv-password'." | 448 | depending on the value of `erc-prompt-for-nickserv-password'." |
| 414 | (if erc-prompt-for-nickserv-password | 449 | (if erc-prompt-for-nickserv-password |
| 415 | (call-interactively 'erc-nickserv-identify) | 450 | (call-interactively 'erc-nickserv-identify) |
| 416 | (when erc-nickserv-passwords | 451 | (erc-nickserv-identify (erc-nickserv-get-password nickname)))) |
| 417 | (erc-nickserv-identify | ||
| 418 | (cdr (assoc nickname | ||
| 419 | (nth 1 (assoc (erc-network) | ||
| 420 | erc-nickserv-passwords)))))))) | ||
| 421 | 452 | ||
| 422 | (defvar erc-auto-discard-away) | 453 | (defvar erc-auto-discard-away) |
| 423 | 454 | ||
| @@ -451,6 +482,7 @@ When called interactively, read the password using `read-passwd'." | |||
| 451 | 482 | ||
| 452 | (provide 'erc-services) | 483 | (provide 'erc-services) |
| 453 | 484 | ||
| 485 | |||
| 454 | ;;; erc-services.el ends here | 486 | ;;; erc-services.el ends here |
| 455 | ;; | 487 | ;; |
| 456 | ;; Local Variables: | 488 | ;; Local Variables: |
diff --git a/lisp/window.el b/lisp/window.el index a6cdd4dec2f..5bb7d577aa1 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -8314,6 +8314,7 @@ indirectly called by the latter." | |||
| 8314 | (when (and (listp quad) | 8314 | (when (and (listp quad) |
| 8315 | (integerp (nth 3 quad)) | 8315 | (integerp (nth 3 quad)) |
| 8316 | (> (nth 3 quad) (window-total-height window))) | 8316 | (> (nth 3 quad) (window-total-height window))) |
| 8317 | (message "foo") | ||
| 8317 | (condition-case nil | 8318 | (condition-case nil |
| 8318 | (window-resize window (- (nth 3 quad) (window-total-height window))) | 8319 | (window-resize window (- (nth 3 quad) (window-total-height window))) |
| 8319 | (error nil))) | 8320 | (error nil))) |