Index | Thread | Search

From:
Todd C. Miller <millert@openbsd.org>
Subject:
Re: [PATCH] ssh-add: Support @ in the user part of destination constraints
To:
Max Zettlmeißl <max@zettlmeissl.de>
Cc:
tech@openbsd.org
Date:
Thu, 05 Sep 2024 10:31:33 -0600

Download raw body.

Thread
On Tue, 20 Aug 2024 04:13:23 +0200, Max =?utf-8?Q?Zettlmei=C3=9Fl?= wrote:

> Properly adding a (complete) host constraint for one of my Git SSH
> identities was impossible because the string got split into username
> and host at the first @ sign, yet the username itself contains an @
> sign.
>
> This patch changes the behaviour to split on the last @ sign.
>
> In addition to running the patched version against all my constraints,
> I also tested it with the additional line `debug3_f("User: \"%s\"
> Host: \"%s\"", dch->user, dch->hostname);` to make sure that I have no
> off-by-one error which would lead to wrongly parsed components. I
> decided against including that in the patch.

This looks correct to me and is consistent with how we parse user@host
in other parts of the code.  For example, parse_user_host_path()
and parse_user_host_port() in misc.c all use strrchr().  So does
ssh.c when parsing something other than a uri.

It may be worth adding a parse_user_host() function to misc.c so
we parse this consistently everywhere.  But for now, this simple
one-liner seems fine.

 - todd