From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id ED5415A026D for ; Tue, 4 Apr 2023 03:46:49 +0200 (CEST) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4Pr9bj4kxCz4xFp; Tue, 4 Apr 2023 11:46:41 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1680572801; bh=oZzS6MDTCxgX30QfJCvIqgIsn+MjYeNFvMR2zjlrbHk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m5Zkr4EeU7Q9vDQnqaB5hLtyUROkiOase5eW2sle6w5K9/dpfL4pT4d5WvpcHM0QZ 9mwzjVL5HlfkmHzg9/EtzaI+HevUg1KAnVbg8k1dgq3ufZOYWu5N51wOYPUNbiryRv LDgQkfoA+Hpt7a+oQMwbIjBLBLOt3PH8YPsxuRF4= From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH 13/14] nstool: Advertise the holder's cwd (in its mountns) across the socket Date: Tue, 4 Apr 2023 11:46:37 +1000 Message-Id: <20230404014638.3225556-14-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230404014638.3225556-1-david@gibson.dropbear.id.au> References: <20230404014638.3225556-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: 642SB2CDYHHN4GDPURDCTOSXYIWXXUBO X-Message-ID-Hash: 642SB2CDYHHN4GDPURDCTOSXYIWXXUBO 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 3ecc456..c07eabb 100644 --- a/test/nstool.c +++ b/test/nstool.c @@ -67,6 +67,7 @@ struct holder_info { pid_t pid; uid_t uid; gid_t gid; + char cwd[PATH_MAX]; }; static void usage(void) @@ -171,6 +172,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); @@ -308,6 +311,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