From patchwork Tue Jun 13 09:38:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 691972 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d91:0:0:0:0:0 with SMTP id b17csp362678wru; Tue, 13 Jun 2023 04:32:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6yg+0PnNzWzIPJdJUIZs4+VGVAMfE3NGGXp/q7TGMMuo1PiOMPVSAlmR9uGWQInWRDrOoq X-Received: by 2002:a05:6214:21ad:b0:5ef:5138:1e5d with SMTP id t13-20020a05621421ad00b005ef51381e5dmr11610127qvc.49.1686655923909; Tue, 13 Jun 2023 04:32:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686655923; cv=none; d=google.com; s=arc-20160816; b=kycUUukOf4/d6yJ8oam8IAUtHBEKa33PCdCbBFAARGkDqBEAubVRH7kmtYmuCvqLlw 9oMFCvk1F8dqxQyqIFIzbn6Re0C9svphGMQ3w6Rjp92VlaMv43BKTOMF6OoUzEWWss09 bN9z4eIyKvI4BK2AwRuCcf3BiMuxYbpXECW/F2xUOuY4CNcZusCNEBic55jx5dYSqMmf 5jKxQjQfC8CK34yNKMMaRDolHCYAn+R3SBoCmEsZs68PE5kVC4GfioAe8Gaf7Zo0dv5h /TtUpQrwblguANknnpetquHusN0yfRJZQakewM26dkUEwwPHy7oN8NJ7soGwfbBMKIxo rAhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=sITmXYQVztiFV0Fz7LLqlyOlCvRo8CYW3jqFEkjFY7A=; b=zq7LXC4hKAG47UDezEzjwrn+rFuE/aNQMXS+m+HKfdOLWEQqTMlDcEz2nzZynP6MUE DStfNBuUsMIwvqMB2V0wZwXVErQ8STm0kGsyISqMwH/Tw3/JH6RbLu79jN+HOWP81oY6 AUPMjR0iiezNejxGX16vO2ncLbH5AF8zVY5EOqoTlkVaPp14n+whvOveKiddB5Tj0Oje U5uL9karGhu8DEXhFj3zJ0F2YJCKwNqgt+LXPTUFHZvjWXTqBWI1Sxra4uCiC39HYRyv tqI/w49BRpcgM/xICpm+CbTV/MzRvWWLKhQBJvgsNWslPx/dLJBs9Cl6LB9aL6L15Q2e 8QRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T1InBtrB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 11-20020a0562140ccb00b0062b7a93eef2si3192663qvx.347.2023.06.13.04.32.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Jun 2023 04:32:03 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T1InBtrB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q90U8-00055Z-Mu; Tue, 13 Jun 2023 05:38:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q90U5-00054a-PF for qemu-devel@nongnu.org; Tue, 13 Jun 2023 05:38:43 -0400 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q90Tw-0005Uy-EB for qemu-devel@nongnu.org; Tue, 13 Jun 2023 05:38:41 -0400 Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-977d4a1cf0eso757518966b.1 for ; Tue, 13 Jun 2023 02:38:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686649108; x=1689241108; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sITmXYQVztiFV0Fz7LLqlyOlCvRo8CYW3jqFEkjFY7A=; b=T1InBtrB0winLJ23Quu7ivDlnmZDNGABI/CrerU2/H5RfXdeuvS6Nx0+hQTxqNfjQz cQ2G0PXKXegcXDvF0YlROhBqQ9Q4xwQ1JZhA5vKeqVXhE2kONcgc4ETXU8tE+zBr2JN2 op5muaNnR+FhjhrqIaPSpA+QFkDHp5TC3amNwfBijCB2d4vxENCLB0SGM3TA2y6+BhOC t6Ce8ZiZbgnPAYcnVWMaPDuIj5ly7HfWQT0zBn8sMYue6grEbSVVWK9PQJVmxXgL0Zrw UiAwJsIQa8oarjA/ypaEQmUljTQXYJA08HdDHc8Ck40oxV9gkTXG3j0z4iKixnSQXLKT hLJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686649108; x=1689241108; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sITmXYQVztiFV0Fz7LLqlyOlCvRo8CYW3jqFEkjFY7A=; b=TSHid7VS2UIwaSh21OWVIrjwv8kh19ffXTHto4dpGqZNx8GIVxrzgcABDM78oyhnw6 agQ9cyjzrPRKhe8ib2ngudUGRMXqCErJaloly/ZhhPdlpKUerMI3OYWXy0X4GZMwixVZ lQLrZ5h590LIg4ohAFwO9tEordWssh73tWD25Vgj5IjbEdRR+7D2d9axImohaZ5xutz2 5w5p1tTXjc4PbTLupRu8BFHr975rF6HUrkAh62RmnYxsghZn/T13hX5KPpgBdFr9Fih0 9kITcOvG9sBrU4UrWHyyWJCBnXqlCKFNfON8ftdTUDfoe9dwNfBe7v1Cp+F0Wl73Hyfi pEaQ== X-Gm-Message-State: AC+VfDxorRxbLFyo0BQELaQpAtWQPAmYMeC++Q+7NYux/i+uDUAdQMB7 gDhuXvbxvO3Y/abn7YCd2A6Xx6hnwxUKbUmjLGjjQw== X-Received: by 2002:a17:907:9617:b0:974:1f03:fcd1 with SMTP id gb23-20020a170907961700b009741f03fcd1mr11708489ejc.3.1686649108675; Tue, 13 Jun 2023 02:38:28 -0700 (PDT) Received: from localhost.localdomain ([185.140.244.249]) by smtp.gmail.com with ESMTPSA id s24-20020a1709060c1800b00969f25b96basm6363606ejf.204.2023.06.13.02.38.28 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 13 Jun 2023 02:38:28 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Andreas Schwab , Warner Losh , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 01/17] linux-user, bsd-user: Preserve incoming order of environment variables in the target Date: Tue, 13 Jun 2023 11:38:06 +0200 Message-Id: <20230613093822.63750-2-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230613093822.63750-1-philmd@linaro.org> References: <20230613093822.63750-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::635; envelope-from=philmd@linaro.org; helo=mail-ej1-x635.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Andreas Schwab Do not reverse the order of environment variables in the target environ array relative to the incoming environ order. Some testsuites depend on a specific order, even though it is not defined by any standard. Signed-off-by: Andreas Schwab Reviewed-by: Warner Losh Reviewed-by: Philippe Mathieu-Daudé Message-Id: Signed-off-by: Philippe Mathieu-Daudé --- bsd-user/main.c | 10 +++++++++- linux-user/main.c | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/bsd-user/main.c b/bsd-user/main.c index cd8b2a670f..b597328118 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -295,8 +295,16 @@ int main(int argc, char **argv) envlist = envlist_create(); - /* add current environment into the list */ + /* + * add current environment into the list + * envlist_setenv adds to the front of the list; to preserve environ + * order add from back to front + */ for (wrk = environ; *wrk != NULL; wrk++) { + continue; + } + while (wrk != environ) { + wrk--; (void) envlist_setenv(envlist, *wrk); } diff --git a/linux-user/main.c b/linux-user/main.c index 5e6b2e1714..dba67ffa36 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -692,8 +692,16 @@ int main(int argc, char **argv, char **envp) envlist = envlist_create(); - /* add current environment into the list */ + /* + * add current environment into the list + * envlist_setenv adds to the front of the list; to preserve environ + * order add from back to front + */ for (wrk = environ; *wrk != NULL; wrk++) { + continue; + } + while (wrk != environ) { + wrk--; (void) envlist_setenv(envlist, *wrk); }