From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 8BAD55A0276 for ; Thu, 6 Apr 2023 05:28:27 +0200 (CEST) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4PsRm60QSSz4xFr; Thu, 6 Apr 2023 13:28:22 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1680751702; bh=Eah1Qdo+g8vx+RFlVD1Igvx0MJF4eEurx5bJ0HRqR3c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f0/8pXelEB3cyZioMj4bnRLwLwBX5XADc7rM9ddHalysFZHn82CDS+12kSUja48Id /srG0kinH7x28xWymhtRUzJKEjXTjsArh5ntnP978rGhObSAeW5de/aUOTPG+BCrFx obdaIbguoR9+9/yeEYAJ3MLuqzD2MIKfGbl+g0cs= From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH v2 13/14] nstool: Advertise the holder's cwd (in its mountns) across the socket Date: Thu, 6 Apr 2023 13:28:18 +1000 Message-Id: <20230406032819.707441-14-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230406032819.707441-1-david@gibson.dropbear.id.au> References: <20230406032819.707441-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: YI5HOZFTXLTOE2GE7U7XLNTCZA5OJGR2 X-Message-ID-Hash: YI5HOZFTXLTOE2GE7U7XLNTCZA5OJGR2 X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: This is possible useful in nstool info and has further uses for nstool exec. Signed-off-by: David Gibson --- test/nstool.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/nstool.c b/test/nstool.c index c224d23..ece566e 100644 --- a/test/nstool.c +++ b/test/nstool.c @@ -68,6 +68,7 @@ struct holder_info { pid_t pid; uid_t uid; gid_t gid; + char cwd[PATH_MAX]; }; static void usage(void) @@ -175,6 +176,8 @@ static void cmd_hold(int argc, char *argv[]) info.pid = getpid(); info.uid = getuid(); info.gid = getgid(); + if (!getcwd(info.cwd, sizeof(info.cwd))) + die("getcwd(): %s\n", strerror(errno)); do { int afd = accept(fd, NULL, NULL); @@ -312,6 +315,7 @@ static void cmd_info(int argc, char *argv[]) printf("\tPID:\t%d\n", info.pid); printf("\tUID:\t%u\n", info.uid); printf("\tGID:\t%u\n", info.gid); + printf("\tCWD:\t%s\n", info.cwd); } } -- 2.39.2