1
0
mirror of https://passt.top/passt synced 2024-10-02 03:55:48 +00:00

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>
This commit is contained in:
David Gibson 2023-04-06 13:28:18 +10:00 committed by Stefano Brivio
parent 469b69aaa1
commit 98031bee73

View File

@ -68,6 +68,7 @@ struct holder_info {
pid_t pid; pid_t pid;
uid_t uid; uid_t uid;
gid_t gid; gid_t gid;
char cwd[PATH_MAX];
}; };
static void usage(void) static void usage(void)
@ -175,6 +176,8 @@ static void cmd_hold(int argc, char *argv[])
info.pid = getpid(); info.pid = getpid();
info.uid = getuid(); info.uid = getuid();
info.gid = getgid(); info.gid = getgid();
if (!getcwd(info.cwd, sizeof(info.cwd)))
die("getcwd(): %s\n", strerror(errno));
do { do {
int afd = accept(fd, NULL, NULL); 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("\tPID:\t%d\n", info.pid);
printf("\tUID:\t%u\n", info.uid); printf("\tUID:\t%u\n", info.uid);
printf("\tGID:\t%u\n", info.gid); printf("\tGID:\t%u\n", info.gid);
printf("\tCWD:\t%s\n", info.cwd);
} }
} }