From 22e1a3a71ad6d108ff0c5f07f93c3fcbd30f8b40 Mon Sep 17 00:00:00 2001 From: "djm@openbsd.org" Date: Fri, 3 Jun 2022 04:30:46 +0000 Subject: upstream: Make SetEnv directives first-match-wins in both sshd_config and sshd_config; previously if the same name was reused then the last would win (which is the opposite to how the config is supposed to work). While there, make the ssh_config parsing more like sshd_config. bz3438, ok dtucker OpenBSD-Commit-ID: 797909c1e0262c0d00e09280459d7ab00f18273b --- misc.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'misc.c') diff --git a/misc.c b/misc.c index 85d22369..a8e87430 100644 --- a/misc.c +++ b/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.175 2022/03/20 08:51:21 djm Exp $ */ +/* $OpenBSD: misc.c,v 1.176 2022/06/03 04:30:47 djm Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * Copyright (c) 2005-2020 Damien Miller. All rights reserved. @@ -2793,3 +2793,20 @@ lookup_env_in_list(const char *env, char * const *envs, size_t nenvs) } return NULL; } + +const char * +lookup_setenv_in_list(const char *env, char * const *envs, size_t nenvs) +{ + char *name, *cp; + const char *ret; + + name = xstrdup(env); + if ((cp = strchr(name, '=')) == NULL) { + free(name); + return NULL; /* not env=val */ + } + *cp = '\0'; + ret = lookup_env_in_list(name, envs, nenvs); + free(name); + return ret; +} -- cgit v1.2.1