File openssh-7.2p2-ssh_case_insensitive_host_matching.patch of Package openssh.29886
From ada15ded642aeffdd594590da177d5a161621f5b Mon Sep 17 00:00:00 2001
From: Old openssh patches <pcerny@suse.com>
Date: Wed, 26 Oct 2022 09:56:48 +0200
Subject: [PATCH] openssh-7.2p2-ssh_case_insensitive_host_matching
# HG changeset patch
# Parent 3f4d92ce6f3b3aca2eb2bd9acc03adb723cf38c9
Match hostnames in a case-insensitive manner.
bsc#1017099
---
readconf.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/readconf.c b/readconf.c
index d1a556b0..b2763883 100644
--- a/readconf.c
+++ b/readconf.c
@@ -531,6 +531,7 @@ match_cfg_line(Options *options, char **condition, struct passwd *pw,
const char *filename, int linenum)
{
char *arg, *oattrib, *attrib, *cmd, *cp = *condition, *host, *criteria;
+ char *hostlc;
const char *ruser;
int r, port, this_result, result = 1, attributes = 0, negate;
char thishost[NI_MAXHOST], shorthost[NI_MAXHOST], portstr[NI_MAXSERV];
@@ -551,6 +552,10 @@ match_cfg_line(Options *options, char **condition, struct passwd *pw,
host = xstrdup(host_arg);
}
+ /* match_hostname() requires the hostname to be lowercase */
+ hostlc = xstrdup(host);
+ lowercase(hostlc);
+
debug2("checking match for '%s' host %s originally %s",
cp, host, original_host);
while ((oattrib = attrib = strdelim(&cp)) && *attrib != '\0') {
@@ -589,8 +594,8 @@ match_cfg_line(Options *options, char **condition, struct passwd *pw,
goto out;
}
if (strcasecmp(attrib, "host") == 0) {
- criteria = xstrdup(host);
- r = match_hostname(host, arg) == 1;
+ criteria = xstrdup(hostlc);
+ r = match_hostname(hostlc, arg) == 1;
if (r == (negate ? 1 : 0))
this_result = result = 0;
} else if (strcasecmp(attrib, "originalhost") == 0) {
@@ -663,6 +668,7 @@ match_cfg_line(Options *options, char **condition, struct passwd *pw,
if (result != -1)
debug2("match %sfound", result ? "" : "not ");
*condition = cp;
+ free(hostlc);
free(host);
return result;
}
--
2.38.0