aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2023-04-06 13:28:18 +1000
committerStefano Brivio <sbrivio@redhat.com>2023-04-08 01:12:10 +0200
commit98031bee73b30ec82a4bc5f078175061d6157b4f (patch)
tree9870917daee7b9514928008798bd8fed29c2e791
parent469b69aaa141a8163a6930e2dd4a25272a85d146 (diff)
downloadpasst-98031bee73b30ec82a4bc5f078175061d6157b4f.tar
passt-98031bee73b30ec82a4bc5f078175061d6157b4f.tar.gz
passt-98031bee73b30ec82a4bc5f078175061d6157b4f.tar.bz2
passt-98031bee73b30ec82a4bc5f078175061d6157b4f.tar.lz
passt-98031bee73b30ec82a4bc5f078175061d6157b4f.tar.xz
passt-98031bee73b30ec82a4bc5f078175061d6157b4f.tar.zst
passt-98031bee73b30ec82a4bc5f078175061d6157b4f.zip
nstool: Advertise the holder's cwd (in its mountns) across the socket
This is possible useful in nstool info and has further uses for nstool exec. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--test/nstool.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/test/nstool.c b/test/nstool.c
index e48a9c0..c7f2b25 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);
}
}