Procan: try to find out VSOCK CID only when running as root
diff --git a/CHANGES b/CHANGES index 09231a8..d70478a 100644 --- a/CHANGES +++ b/CHANGES
@@ -54,6 +54,8 @@ 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 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);