From 2a04219dee13ac93d9cc2f8bd6d2a4025cc4e5c2 Mon Sep 17 00:00:00 2001 From: Gerhard Rieger Date: Thu, 26 Jan 2023 10:06:01 +0100 Subject: [PATCH] Procan: try to find out VSOCK CID only when running as root --- CHANGES | 2 ++ hostan.c | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/CHANGES b/CHANGES index 09231a8..d70478a 100644 --- a/CHANGES +++ b/CHANGES @@ -54,6 +54,8 @@ Corrections: restrictive mode. Furthermore Silla Rizzoli experienced that Minicom ignores lock files with mode 600, so it is set to 644 now. + Procan tries to find out VSOCK CID only when running as root + Features: VSOCK, VSOCK-L support options pf, socktype, prototype (currently useless) diff --git a/hostan.c b/hostan.c index dfa1b2e..07212af 100644 --- a/hostan.c +++ b/hostan.c @@ -112,11 +112,16 @@ static int iffan(FILE *outfile) { static int vsockan(FILE *outfile) { unsigned int cid; int vsock; + if (Getuid() != 0) { + return 1; + } if ((vsock = Open("/dev/vsock", O_RDONLY, 0)) < 0 ) { Warn1("open(\"/dev/vsock\", ...): %s", strerror(errno)); + return -1; } else if (Ioctl(vsock, IOCTL_VM_SOCKETS_GET_LOCAL_CID, &cid) < 0) { Warn2("ioctl(%d, IOCTL_VM_SOCKETS_GET_LOCAL_CID, ...): %s", vsock, strerror(errno)); + return -1; } else { Notice1("VSOCK CID=%u", cid); fprintf(outfile, "\nVSOCK_CID = %u\n", cid);