From patchwork Thu May 30 19:19:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Dziedzic X-Patchwork-Id: 1941790 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=144xP4Gv; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=g3S31hnV; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Vqx0567sBz20WX for ; Fri, 31 May 2024 05:19:47 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DS7Ns2PHtjwVusrw0n8RmcyDZck/JhlzVYBrxKXKrC0=; b=144xP4GvUHJJrw EGPG+C3dfbyypOuvDUaY7F6w3ZWrxjQFvfUfHGt8XbHuLsrpByZgMd+hA1XCHOXFNjqrFeWRY+evC eAYu4u1H0bvmdhZ9+ombHPzV3YXXvlS/yXouwBsafk4zSgxI6OhunCil8zelq197PJitu8WlwwrgF h90Z4lBk3ArFfH16L5rO0+YGmqIGBvn5Xi0JMH9w6IYeUXEyNCXhd5YsfXOIyc8Nlu+jbHfzMNcNT f0k9VSSeH00GSMELdaHU9DmwwA8kOijPSX6FJR7om/mYIyYyYYe3/Q67j/URwwvtbKwoHNnt0YGcW gSp91NyoZpIEqpA9tT9Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sClJ1-00000008CTM-2Pw1; Thu, 30 May 2024 19:19:19 +0000 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sClIw-00000008CQy-2wug for hostap@lists.infradead.org; Thu, 30 May 2024 19:19:16 +0000 Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-a63036f2daaso135282666b.1 for ; Thu, 30 May 2024 12:19:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717096752; x=1717701552; darn=lists.infradead.org; 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=D8T0DrZMZzGxOnjyJe1X+PTbxVEPdeWgKDMMm+7dnlM=; b=g3S31hnVVI8jxIGu+ZEOo2Sy6m35s6Ge1R65Z/aO4vqpT4M9pSjjg5FXgLiZJpyD/Q jWwEuNgU22oKjfE8Q800YVLlhGt74egRq2HW0+JjeYXP/fxxSIDwKqnCdFnY4LaZPvGF pXYbxRB1xECCWHumq7nllc/rVKqUtjelt4v7DHCfbfeqmO5ou463PyNBgWiky+CXsIHA EbImIkvSUueFmnZ84PDujtX/e9jcZ9Uh19MTOvOjXEsDmqeOhPtRzeMLPH1xJEx4NA2m BFPUT5F1rl7VZDKDx/Ao2deSTGCaXQbfFQEka+9/OhcpRwurGUBWmjAs+SXFmhuP/F2l DPiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717096752; x=1717701552; 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=D8T0DrZMZzGxOnjyJe1X+PTbxVEPdeWgKDMMm+7dnlM=; b=YZVcl5V8dOfaVLmxEN3nSpmhIDA0knKiMdrtUoWWL3oqUeNA6zRcYHZCtn7kJ+AlIl A2BfdV5fVPP2iTKEU3WDhrowqu63ObmaTH1cdyZfoWw1BrxXp5nkg+AnzreoGz3ObBDb i/LfAOtNvEpcHdVfLWoBfFjCgaHNNcUMeAWRWAfavtpGNuwr9WHVWBbwKYVIzGC9r4Ge hQH2MUSVJ9ih2e1ajLDynClm2kTOD7xfhUgWmbkmgqMRodRYXpoRCKrOs+/hmVMjNfrW y6mAXWeQQ7d/H0/ksDwnU0+k88D5bhu+R+x0ndXNL89HHdDkNgnEBGgrNMFczJ0tADaV Qtdw== X-Gm-Message-State: AOJu0YwvI0q39C8EhoGyzTxEkZOyIWR8TGpRab/l4BC0G8HnBqufrtE7 7+po7yAPXRRm8a5wawXvrIIeRHn5e+OkIwfZ3wVLPuG0fpfytjyo28ga4Q== X-Google-Smtp-Source: AGHT+IH4UQW3zdpRWIbtgDVGLZ1SL0yJ7j0yBj1ewL7d4nz5XaAWpFUaUWcAetL7zKxEMFEbhhsOgg== X-Received: by 2002:a17:906:2b57:b0:a66:e439:e509 with SMTP id a640c23a62f3a-a66e439e5camr107196166b.22.1717096752034; Thu, 30 May 2024 12:19:12 -0700 (PDT) Received: from e850.NAT.swidnica_mmp.vectranet.pl (178235177153.dynamic-4-waw-k-1-1-0.vectranet.pl. [178.235.177.153]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a67e73fc1a5sm6629666b.53.2024.05.30.12.19.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 12:19:11 -0700 (PDT) From: Janusz Dziedzic To: hostap@lists.infradead.org Cc: j@w1.fi, Janusz Dziedzic Subject: [PATCH v2 4/5] tests: remotehost: ssh allow to skip user Date: Thu, 30 May 2024 21:19:03 +0200 Message-Id: <20240530191904.1426538-4-janusz.dziedzic@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240530191904.1426538-1-janusz.dziedzic@gmail.com> References: <20240530191904.1426538-1-janusz.dziedzic@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240530_121914_791811_C6BB82F6 X-CRM114-Status: GOOD ( 11.31 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Allow to skip user name when we run ssh user@hostname. We can specify user name in .ssh/config and simplify using network name spaces mapped per user. Eg. of .ssh/config Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:62e listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [janusz.dziedzic(at)gmail.com] -0.0 T_SCC_BODY_TEXT_LINE No description available. X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Allow to skip user name when we run ssh user@hostname. We can specify user name in .ssh/config and simplify using network name spaces mapped per user. Eg. of .ssh/config Host localhost HostName localhost User root Host test1 HostName testpc User wlan1 Signed-off-by: Janusz Dziedzic --- tests/hwsim/remotehost.py | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/tests/hwsim/remotehost.py b/tests/hwsim/remotehost.py index d0efa210b..7bbf12d63 100644 --- a/tests/hwsim/remotehost.py +++ b/tests/hwsim/remotehost.py @@ -83,7 +83,10 @@ class Host(): if self.host is None: return self.local_execute(command) - cmd = ["ssh", self.user + "@" + self.host, ' '.join(command)] + if self.user: + cmd = ["ssh", self.user + "@" + self.host, ' '.join(command)] + else: + cmd = ["ssh", self.host, ' '.join(command)] _cmd = self.name + " execute: " + ' '.join(cmd) logger.debug(_cmd) err = tempfile.TemporaryFile() @@ -114,7 +117,10 @@ class Host(): if self.host is None: cmd = _command else: - cmd = ["ssh", self.user + "@" + self.host, ' '.join(_command)] + if self.user: + cmd = ["ssh", self.user + "@" + self.host, ' '.join(_command)] + else: + cmd = ["ssh", self.host, ' '.join(_command)] _cmd = self.name + " thread_run: " + ' '.join(cmd) logger.debug(_cmd) t = threading.Thread(target=execute_thread, name=filename, args=(cmd, res)) @@ -174,7 +180,10 @@ class Host(): _command = [filename] + command if self.host: - cmd = ["ssh", self.user + "@" + self.host, ' '.join(_command)] + if self.user: + cmd = ["ssh", self.user + "@" + self.host, ' '.join(_command)] + else: + cmd = ["ssh", self.host, ' '.join(_command)] else: cmd = _command @@ -261,12 +270,18 @@ class Host(): def get_logs(self, local_log_dir=None): for log in self.logs: if local_log_dir: - self.local_execute(["scp", self.user + "@[" + self.host + "]:" + log, local_log_dir]) + if self.user: + self.local_execute(["scp", self.user + "@[" + self.host + "]:" + log, local_log_dir]) + else: + self.local_execute(["scp", "[" + self.host + "]:" + log, local_log_dir]) self.execute(["rm", log]) del self.logs[:] def send_file(self, src, dst): if self.host is None: return - self.local_execute(["scp", src, - self.user + "@[" + self.host + "]:" + dst]) + if self.user: + self.local_execute(["scp", src, + self.user + "@[" + self.host + "]:" + dst]) + else: + self.local_execute(["scp", src, "[" + self.host + "]:" + dst])