emacs-erc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bug#74516: 31.0.50; ERC 5.6.1-git: [PATCH] allow port as string in a


From: J.P.
Subject: Re: bug#74516: 31.0.50; ERC 5.6.1-git: [PATCH] allow port as string in auth-source params
Date: Mon, 25 Nov 2024 19:36:00 -0800
User-agent: Gnus/5.13 (Gnus v5.13)

Trevor Arjeski <tmarjeski@gmail.com> writes:

> Reproduction steps:
>
> 1. Have an entry in .authinfo, such as
>         machine yourbouncer login nick password hunter2 port 7777
>
> 2. Using the following code in init.el, open emacs
> 3. M-x erc-connect
> 4. Notice ERC tries connecting without password
> 5. Change erc-port to be an integer (commented out below)
> 6. Retry steps 2 - 4
>
> [3. text/x-org]
> #+BEGIN_SRC emacs-lisp
> (use-package erc
>   :ensure nil
>   :preface
>   (defun erc-connect ()
>     (interactive)
>     (erc :server erc-server
>          :port erc-port
>          :user erc-nick))
>   :custom
>   (erc-server "yourbouncer")
>   (erc-port "7777") ;; (erc-port 7777) is working
>   (erc-nick "nick"))
> #+END_SRC

Thanks. I can reproduce this.

> From 9468a786fb8c0ef950117e78395592f2e11613c2 Mon Sep 17 00:00:00 2001
> From: Trevor Arjeski <tmarjeski@gmail.com>
> Date: Sun, 24 Nov 2024 23:35:41 +0300
> Subject: [PATCH] erc: allow port as string in auth-source params
>
> Checking the equality of the given `erc-session-port' with "irc" is
> unnecessary since:
>
> 1. "irc" is already added to the list of ports
> 2. /etc/services may contain "ircs-u" (or other) as the desired port

I think it makes sense to allow entries to specify well known service
names. And I suppose it couldn't hurt to also at least implicitly
support numeric strings, although that sounds like bad UX if anyone
should need to resort to that just to differentiate between entries.

> If the correct port/service is missing then the auth-source query will
> fail for a seemingly unknown reason.

IIRC, all params appearing in an auth-source entry are basically
required, and a successful query must therefore supply all of them.
However, such a query may specify additional, unmatched or partially
matched parameters.

> This also allows a user to `(setopt erc-port "1234")', intentionally or
> accidentally, and still be able to use .authinfo for password
> management.
> ---
>  lisp/erc/erc.el | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
> index 7028d0a68cc..81818a7227e 100644
> --- a/lisp/erc/erc.el
> +++ b/lisp/erc/erc.el
> @@ -4675,8 +4675,7 @@ erc--auth-source-determine-params-defaults
>                    (list net erc-server-announced-name erc-session-server)))
>           (ports (list (cl-typecase erc-session-port
>                          (integer (number-to-string erc-session-port))
> -                        (string (and (string= erc-session-port "irc")
> -                                     erc-session-port)) ; or nil
> +                        (string erc-session-port) ; or nil

I've changed this slightly to become nil if `erc-session-port' is the
empty string or "irc".

>                          (t erc-session-port))
>                        "irc")))
>      (list (cons :host (delq nil hosts))

I've also added a companion patch that changes some foundational
behavior so that `erc-session-port' can more easily be set to a string
to accommodate service names. With your example of

  machine mybouncer port ircs-u login mynick password hunter2

if someone tries to connect with

  (setopt auth-source-do-cache nil
          auth-source-debug t)
  (erc-tls :server "mybouncer" :nick "mynick")

they should still be denied. But adding

  :port "ircs-u"

to the invocation or doing something like

  (setopt erc-port "ircs-u")

beforehand should see them succeed, assuming ircs-u appears in their
/etc/services as a port listened on by their bouncer.

Please try these out when you get a chance and give feedback if
possible. Thanks.

Attachment: 0001-5.6.1-Allow-querying-auth-source-with-port-as-string.patch
Description: Text Data

Attachment: 0002-5.6.1-Only-normalize-ports-for-equality-comparisons-.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]