* bug#48601: [PATCH] Add support for plain SASL authentication to rcirc
@ 2021-05-23 12:16 Alex McGrath via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-05-23 16:24 ` bug#48601: [PATCH v2] " Alex McGrath via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-05-24 8:45 ` bug#48601: [PATCH v3] " Alex McGrath via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 2 replies; 7+ messages in thread
From: Alex McGrath via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-05-23 12:16 UTC (permalink / raw)
To: 48601
[-- Attachment #1: Type: text/plain, Size: 134 bytes --]
This adds support for PLAIN SASL authentication to rcirc.
ietf rfc: https://datatracker.ietf.org/doc/html/rfc4616
Thanks,
Alex
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Patch File --]
[-- Type: text/x-diff, Size: 4273 bytes --]
From 9ec0e5711621f17c8086365a15d80cb75352972b Mon Sep 17 00:00:00 2001
From: Alex McGrath <amk@amk.ie>
Date: Sun, 23 May 2021 12:47:17 +0100
Subject: [PATCH] Add support for SASL authentication to rcirc
---
lisp/net/rcirc.el | 39 +++++++++++++++++++++++++++++++++++++--
1 file changed, 37 insertions(+), 2 deletions(-)
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index 7251640bf2..f22096fc6d 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -245,13 +245,15 @@ The ARGUMENTS for each METHOD symbol are:
`chanserv': NICK CHANNEL PASSWORD
`bitlbee': NICK PASSWORD
`quakenet': ACCOUNT PASSWORD
+ `sasl': NICK PASSWORD
Examples:
((\"freenode\" nickserv \"bob\" \"p455w0rd\")
(\"freenode\" chanserv \"bob\" \"#bobland\" \"passwd99\")
(\"bitlbee\" bitlbee \"robert\" \"sekrit\")
(\"dal.net\" nickserv \"bob\" \"sekrit\" \"NickServ@services.dal.net\")
- (\"quakenet.org\" quakenet \"bobby\" \"sekrit\"))"
+ (\"quakenet.org\" quakenet \"bobby\" \"sekrit\")
+ (\"oftc\" sasl \"bob\" \"hunter2\"))"
:type '(alist :key-type (regexp :tag "Server")
:value-type (choice (list :tag "NickServ"
(const nickserv)
@@ -269,6 +271,10 @@ Examples:
(list :tag "QuakeNet"
(const quakenet)
(string :tag "Account")
+ (string :tag "Password"))
+ (list :tag "SASL"
+ (const sasl)
+ (string :tag "Nick")
(string :tag "Password")))))
(defcustom rcirc-auto-authenticate-flag t
@@ -543,6 +549,22 @@ If ARG is non-nil, instead prompt for connection parameters."
(defvar rcirc-connection-info nil)
(defvar rcirc-process nil)
+(defun rcirc-get-server-method (rcirc-server)
+ (catch 'method
+ (dolist (i rcirc-authinfo)
+ (let ((server (car i))
+ (method (cadr i)))
+ (when (and (string-match server rcirc-server))
+ (throw 'method method))))))
+
+(defun rcirc-get-server-password (rcirc-server)
+ (catch 'pass
+ (dolist (i rcirc-authinfo)
+ (let ((server (car i))
+ (args (cl-cdddr i)))
+ (when (and (string-match server rcirc-server))
+ (throw 'pass (car args)))))))
+
;;;###autoload
(defun rcirc-connect (server &optional port nick user-name
full-name startup-channels password encryption
@@ -598,6 +620,11 @@ If ARG is non-nil, instead prompt for connection parameters."
(rcirc-send-string process (concat "NICK " nick))
(rcirc-send-string process (concat "USER " user-name
" 0 * :" full-name))
+ ;; setup sasl, and initiate authentication
+ (when (and rcirc-auto-authenticate-flag
+ (eq (rcirc-get-server-method server) 'sasl))
+ (rcirc-send-string process "CAP REQ sasl")
+ (rcirc-send-string process "AUTHENTICATE PLAIN"))
;; setup ping timer if necessary
(unless rcirc-keepalive-timer
@@ -2922,7 +2949,8 @@ Passwords are stored in `rcirc-authinfo' (which see)."
(rcirc-send-privmsg
process
"&bitlbee"
- (concat "IDENTIFY " (car args)))))
+ (concat "IDENTIFY " (car args))))
+ (sasl nil))
;; quakenet authentication doesn't rely on the user's nickname.
;; the variable `nick' here represents the Q account name.
(when (eq method 'quakenet)
@@ -2968,6 +2996,13 @@ Passwords are stored in `rcirc-authinfo' (which see)."
(defun rcirc-handler-CTCP-response (process _target sender message)
(rcirc-print process sender "CTCP" nil message t))
+
+(defun rcirc-handler-AUTHENTICATE (process _cmd _args _text)
+ (rcirc-send-string process (format "AUTHENTICATE %s"
+ (base64-encode-string
+ (concat "\0" (rcirc-buffer-nick)
+ "\0" (rcirc-get-server-password rcirc-server))))))
+
\f
(defgroup rcirc-faces nil
"Faces for rcirc."
--
2.30.2
[-- Attachment #3: Type: text/plain, Size: 77 bytes --]
Date: Sun, 23 May 2021 13:16:02 +0100
Message-ID: <87lf85ir25.fsf@t480s.lan>
^ permalink raw reply related [flat|nested] 7+ messages in thread
* bug#48601: [PATCH v2] Add support for plain SASL authentication to rcirc
2021-05-23 12:16 bug#48601: [PATCH] Add support for plain SASL authentication to rcirc Alex McGrath via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-05-23 16:24 ` Alex McGrath via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-05-24 8:45 ` bug#48601: [PATCH v3] " Alex McGrath via Bug reports for GNU Emacs, the Swiss army knife of text editors
1 sibling, 0 replies; 7+ messages in thread
From: Alex McGrath via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-05-23 16:24 UTC (permalink / raw)
To: 48601
[-- Attachment #1: Type: text/plain, Size: 131 bytes --]
This fixes a couple of problems with the previous patch.
Mainly it uses user-name instead of nick for the SASL auth
Thanks,
Alex
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: SASL patch --]
[-- Type: text/x-diff, Size: 4315 bytes --]
From ff31781532f2da9da44e2c35961718719e962b39 Mon Sep 17 00:00:00 2001
From: Alex McGrath <amk@amk.ie>
Date: Sun, 23 May 2021 12:47:17 +0100
Subject: [PATCH] Add support for SASL authentication to rcirc
---
lisp/net/rcirc.el | 40 ++++++++++++++++++++++++++++++++++++++--
1 file changed, 38 insertions(+), 2 deletions(-)
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index 7251640bf2..d28fe708d2 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -245,13 +245,15 @@ The ARGUMENTS for each METHOD symbol are:
`chanserv': NICK CHANNEL PASSWORD
`bitlbee': NICK PASSWORD
`quakenet': ACCOUNT PASSWORD
+ `sasl': NICK PASSWORD
Examples:
((\"freenode\" nickserv \"bob\" \"p455w0rd\")
(\"freenode\" chanserv \"bob\" \"#bobland\" \"passwd99\")
(\"bitlbee\" bitlbee \"robert\" \"sekrit\")
(\"dal.net\" nickserv \"bob\" \"sekrit\" \"NickServ@services.dal.net\")
- (\"quakenet.org\" quakenet \"bobby\" \"sekrit\"))"
+ (\"quakenet.org\" quakenet \"bobby\" \"sekrit\")
+ (\"oftc\" sasl \"bob\" \"hunter2\"))"
:type '(alist :key-type (regexp :tag "Server")
:value-type (choice (list :tag "NickServ"
(const nickserv)
@@ -269,6 +271,10 @@ Examples:
(list :tag "QuakeNet"
(const quakenet)
(string :tag "Account")
+ (string :tag "Password"))
+ (list :tag "SASL"
+ (const sasl)
+ (string :tag "Nick")
(string :tag "Password")))))
(defcustom rcirc-auto-authenticate-flag t
@@ -543,6 +549,22 @@ If ARG is non-nil, instead prompt for connection parameters."
(defvar rcirc-connection-info nil)
(defvar rcirc-process nil)
+(defun rcirc-get-server-method (server)
+ (catch 'method
+ (dolist (i rcirc-authinfo)
+ (let ((server-i (car i))
+ (method (cadr i)))
+ (when (and (string-match server-i server))
+ (throw 'method method))))))
+
+(defun rcirc-get-server-password (server)
+ (catch 'pass
+ (dolist (i rcirc-authinfo)
+ (let ((server-i (car i))
+ (args (cl-cdddr i)))
+ (when (and (string-match server-i server))
+ (throw 'pass (car args)))))))
+
;;;###autoload
(defun rcirc-connect (server &optional port nick user-name
full-name startup-channels password encryption
@@ -598,6 +620,11 @@ If ARG is non-nil, instead prompt for connection parameters."
(rcirc-send-string process (concat "NICK " nick))
(rcirc-send-string process (concat "USER " user-name
" 0 * :" full-name))
+ ;; setup sasl, and initiate authentication
+ (when (and rcirc-auto-authenticate-flag
+ (eq (rcirc-get-server-method server) 'sasl))
+ (rcirc-send-string process "CAP REQ sasl")
+ (rcirc-send-string process "AUTHENTICATE PLAIN"))
;; setup ping timer if necessary
(unless rcirc-keepalive-timer
@@ -2922,7 +2949,8 @@ Passwords are stored in `rcirc-authinfo' (which see)."
(rcirc-send-privmsg
process
"&bitlbee"
- (concat "IDENTIFY " (car args)))))
+ (concat "IDENTIFY " (car args))))
+ (sasl nil))
;; quakenet authentication doesn't rely on the user's nickname.
;; the variable `nick' here represents the Q account name.
(when (eq method 'quakenet)
@@ -2968,6 +2996,14 @@ Passwords are stored in `rcirc-authinfo' (which see)."
(defun rcirc-handler-CTCP-response (process _target sender message)
(rcirc-print process sender "CTCP" nil message t))
+
+(defun rcirc-handler-AUTHENTICATE (process _cmd _args _text)
+ (rcirc-send-string process (format "AUTHENTICATE %s"
+ (base64-encode-string
+ ;; use connection user-name
+ (concat "\0" (nth 3 rcirc-connection-info)
+ "\0" (rcirc-get-server-password rcirc-server))))))
+
\f
(defgroup rcirc-faces nil
"Faces for rcirc."
--
2.30.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* bug#48601: [PATCH v3] Add support for plain SASL authentication to rcirc
2021-05-23 12:16 bug#48601: [PATCH] Add support for plain SASL authentication to rcirc Alex McGrath via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-05-23 16:24 ` bug#48601: [PATCH v2] " Alex McGrath via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-05-24 8:45 ` Alex McGrath via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-05-25 4:01 ` bug#48601: [PATCH] " Lars Ingebrigtsen
2021-06-24 16:19 ` Lars Ingebrigtsen
1 sibling, 2 replies; 7+ messages in thread
From: Alex McGrath via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-05-24 8:45 UTC (permalink / raw)
To: 48601
[-- Attachment #1: Type: text/plain, Size: 189 bytes --]
Sorry about the spam, should hopefully be a final version. Freenode
wasnt negotiating sasl the same way as the server I was testing with but
I think it is correct now
Thanks again,
Alex
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: V3 of sasl patch --]
[-- Type: text/x-diff, Size: 5020 bytes --]
From a7e10aa65086fa09e48d58c15aa6619b7927ef18 Mon Sep 17 00:00:00 2001
From: Alex McGrath <amk@amk.ie>
Date: Sun, 23 May 2021 12:47:17 +0100
Subject: [PATCH] Add support for SASL authentication to rcirc
---
lisp/net/rcirc.el | 42 ++++++++++++++++++++++++++++++++++++++++--
1 file changed, 40 insertions(+), 2 deletions(-)
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index 7251640bf2..9d66d0cd51 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -245,13 +245,15 @@ The ARGUMENTS for each METHOD symbol are:
`chanserv': NICK CHANNEL PASSWORD
`bitlbee': NICK PASSWORD
`quakenet': ACCOUNT PASSWORD
+ `sasl': NICK PASSWORD
Examples:
((\"freenode\" nickserv \"bob\" \"p455w0rd\")
(\"freenode\" chanserv \"bob\" \"#bobland\" \"passwd99\")
(\"bitlbee\" bitlbee \"robert\" \"sekrit\")
(\"dal.net\" nickserv \"bob\" \"sekrit\" \"NickServ@services.dal.net\")
- (\"quakenet.org\" quakenet \"bobby\" \"sekrit\"))"
+ (\"quakenet.org\" quakenet \"bobby\" \"sekrit\")
+ (\"oftc\" sasl \"bob\" \"hunter2\"))"
:type '(alist :key-type (regexp :tag "Server")
:value-type (choice (list :tag "NickServ"
(const nickserv)
@@ -269,6 +271,10 @@ Examples:
(list :tag "QuakeNet"
(const quakenet)
(string :tag "Account")
+ (string :tag "Password"))
+ (list :tag "SASL"
+ (const sasl)
+ (string :tag "Nick")
(string :tag "Password")))))
(defcustom rcirc-auto-authenticate-flag t
@@ -543,6 +549,22 @@ If ARG is non-nil, instead prompt for connection parameters."
(defvar rcirc-connection-info nil)
(defvar rcirc-process nil)
+(defun rcirc-get-server-method (server)
+ (catch 'method
+ (dolist (i rcirc-authinfo)
+ (let ((server-i (car i))
+ (method (cadr i)))
+ (when (and (string-match server-i server))
+ (throw 'method method))))))
+
+(defun rcirc-get-server-password (server)
+ (catch 'pass
+ (dolist (i rcirc-authinfo)
+ (let ((server-i (car i))
+ (args (cl-cdddr i)))
+ (when (and (string-match server-i server))
+ (throw 'pass (car args)))))))
+
;;;###autoload
(defun rcirc-connect (server &optional port nick user-name
full-name startup-channels password encryption
@@ -559,6 +581,7 @@ If ARG is non-nil, instead prompt for connection parameters."
(user-name (or user-name rcirc-default-user-name))
(full-name (or full-name rcirc-default-full-name))
(startup-channels startup-channels)
+ (use-sasl (eq (rcirc-get-server-method server) 'sasl))
(process (open-network-stream
(or server-alias server) nil server port-number
:type (or encryption 'plain))))
@@ -591,6 +614,8 @@ If ARG is non-nil, instead prompt for connection parameters."
(setq-local rcirc-server-parameters nil)
(add-hook 'auto-save-hook 'rcirc-log-write)
+ (when use-sasl
+ (rcirc-send-string process "CAP REQ sasl"))
;; identify
(unless (zerop (length password))
@@ -598,6 +623,10 @@ If ARG is non-nil, instead prompt for connection parameters."
(rcirc-send-string process (concat "NICK " nick))
(rcirc-send-string process (concat "USER " user-name
" 0 * :" full-name))
+ ;; setup sasl, and initiate authentication
+ (when (and rcirc-auto-authenticate-flag
+ use-sasl)
+ (rcirc-send-string process "AUTHENTICATE PLAIN"))
;; setup ping timer if necessary
(unless rcirc-keepalive-timer
@@ -2922,7 +2951,8 @@ Passwords are stored in `rcirc-authinfo' (which see)."
(rcirc-send-privmsg
process
"&bitlbee"
- (concat "IDENTIFY " (car args)))))
+ (concat "IDENTIFY " (car args))))
+ (sasl nil))
;; quakenet authentication doesn't rely on the user's nickname.
;; the variable `nick' here represents the Q account name.
(when (eq method 'quakenet)
@@ -2968,6 +2998,14 @@ Passwords are stored in `rcirc-authinfo' (which see)."
(defun rcirc-handler-CTCP-response (process _target sender message)
(rcirc-print process sender "CTCP" nil message t))
+
+(defun rcirc-handler-AUTHENTICATE (process _cmd _args _text)
+ (rcirc-send-string process (format "AUTHENTICATE %s"
+ (base64-encode-string
+ ;; use connection user-name
+ (concat "\0" (nth 3 rcirc-connection-info)
+ "\0" (rcirc-get-server-password rcirc-server))))))
+
\f
(defgroup rcirc-faces nil
"Faces for rcirc."
--
2.30.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* bug#48601: [PATCH] Add support for plain SASL authentication to rcirc
2021-05-24 8:45 ` bug#48601: [PATCH v3] " Alex McGrath via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2021-05-25 4:01 ` Lars Ingebrigtsen
2021-06-24 16:19 ` Lars Ingebrigtsen
1 sibling, 0 replies; 7+ messages in thread
From: Lars Ingebrigtsen @ 2021-05-25 4:01 UTC (permalink / raw)
To: Alex McGrath; +Cc: 48601
Alex McGrath <amk@amk.ie> writes:
> Sorry about the spam, should hopefully be a final version. Freenode
> wasnt negotiating sasl the same way as the server I was testing with but
> I think it is correct now
Thanks; this looks useful, but it isn't a "small change", so we'd need
to get the copyright assigned to the FSF before applying. Would you be
willing to sign such paperwork?
If so, the form below should get you started:
Please email the following information to assign@gnu.org, and we
will send you the assignment form for your past and future changes.
Please use your full legal name (in ASCII characters) as the subject
line of the message.
----------------------------------------------------------------------
REQUEST: SEND FORM FOR PAST AND FUTURE CHANGES
[What is the name of the program or package you're contributing to?]
Emacs
[Did you copy any files or text written by someone else in these changes?
Even if that material is free software, we need to know about it.]
[Do you have an employer who might have a basis to claim to own
your changes? Do you attend a school which might make such a claim?]
[For the copyright registration, what country are you a citizen of?]
[What year were you born?]
[Please write your email address here.]
[Please write your postal address here.]
[Which files have you changed so far, and which new files have you written
so far?]
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#48601: [PATCH] Add support for plain SASL authentication to rcirc
2021-05-24 8:45 ` bug#48601: [PATCH v3] " Alex McGrath via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-05-25 4:01 ` bug#48601: [PATCH] " Lars Ingebrigtsen
@ 2021-06-24 16:19 ` Lars Ingebrigtsen
2021-06-24 16:25 ` Philip Kaludercic
1 sibling, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2021-06-24 16:19 UTC (permalink / raw)
To: Alex McGrath; +Cc: Philip Kaludercic, 48601
Alex McGrath <amk@amk.ie> writes:
> Subject: [PATCH] Add support for SASL authentication to rcirc
I see that Alex' copyright assignment is complete, so we can merge this
patch now. But meanwhile, Philip has started a new branch for fixing up
various rcirc issues, so I wonder whether Philip wants to take this
patch via that branch, or whether I should apply it to the trunk.
Philip, do you have a preference here?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#48601: [PATCH] Add support for plain SASL authentication to rcirc
2021-06-24 16:19 ` Lars Ingebrigtsen
@ 2021-06-24 16:25 ` Philip Kaludercic
2021-06-24 16:45 ` Lars Ingebrigtsen
0 siblings, 1 reply; 7+ messages in thread
From: Philip Kaludercic @ 2021-06-24 16:25 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: Alex McGrath, 48601
Lars Ingebrigtsen <larsi@gnus.org> writes:
> Alex McGrath <amk@amk.ie> writes:
>
>> Subject: [PATCH] Add support for SASL authentication to rcirc
>
> I see that Alex' copyright assignment is complete, so we can merge this
> patch now. But meanwhile, Philip has started a new branch for fixing up
> various rcirc issues, so I wonder whether Philip wants to take this
> patch via that branch, or whether I should apply it to the trunk.
>
> Philip, do you have a preference here?
I'm not sure right now when the branch will be mergable, so it is
probably better to apply the changes now, and then I can resolve the
(minor) conflict later.
--
Philip K.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-06-24 16:45 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-23 12:16 bug#48601: [PATCH] Add support for plain SASL authentication to rcirc Alex McGrath via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-05-23 16:24 ` bug#48601: [PATCH v2] " Alex McGrath via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-05-24 8:45 ` bug#48601: [PATCH v3] " Alex McGrath via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-05-25 4:01 ` bug#48601: [PATCH] " Lars Ingebrigtsen
2021-06-24 16:19 ` Lars Ingebrigtsen
2021-06-24 16:25 ` Philip Kaludercic
2021-06-24 16:45 ` Lars Ingebrigtsen
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).