From: djm Date: Fri, 6 Sep 2024 02:30:44 +0000 (+0000) Subject: make parsing user@host consistently look for the last '@' in the X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=93d5c99663b69aee95d1db6853737d705470b596;p=openbsd make parsing user@host consistently look for the last '@' in the string rather than the first. This makes it possible to use usernames that contain '@' characters. Prompted by Max Zettlmeißl; feedback/ok millert@ --- diff --git a/usr.bin/ssh/match.c b/usr.bin/ssh/match.c index 58888655f60..ff201142ee6 100644 --- a/usr.bin/ssh/match.c +++ b/usr.bin/ssh/match.c @@ -1,4 +1,4 @@ -/* $OpenBSD: match.c,v 1.44 2023/04/06 03:19:32 djm Exp $ */ +/* $OpenBSD: match.c,v 1.45 2024/09/06 02:30:44 djm Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -234,7 +234,7 @@ match_user(const char *user, const char *host, const char *ipaddr, /* test mode */ if (user == NULL && host == NULL && ipaddr == NULL) { - if ((p = strchr(pattern, '@')) != NULL && + if ((p = strrchr(pattern, '@')) != NULL && match_host_and_ip(NULL, NULL, p + 1) < 0) return -1; return 0; @@ -243,11 +243,11 @@ match_user(const char *user, const char *host, const char *ipaddr, if (user == NULL) return 0; /* shouldn't happen */ - if ((p = strchr(pattern, '@')) == NULL) + if (strrchr(pattern, '@') == NULL) return match_pattern(user, pattern); pat = xstrdup(pattern); - p = strchr(pat, '@'); + p = strrchr(pat, '@'); *p++ = '\0'; if ((ret = match_pattern(user, pat)) == 1) diff --git a/usr.bin/ssh/ssh-add.c b/usr.bin/ssh/ssh-add.c index c98442e47c0..05985900677 100644 --- a/usr.bin/ssh/ssh-add.c +++ b/usr.bin/ssh/ssh-add.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-add.c,v 1.172 2024/01/11 01:45:36 djm Exp $ */ +/* $OpenBSD: ssh-add.c,v 1.173 2024/09/06 02:30:44 djm Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -691,7 +691,7 @@ parse_dest_constraint_hop(const char *s, struct dest_constraint_hop *dch, memset(dch, '\0', sizeof(*dch)); os = xstrdup(s); - if ((host = strchr(os, '@')) == NULL) + if ((host = strrchr(os, '@')) == NULL) host = os; else { *host++ = '\0';