mirror of
https://repo.or.cz/socat.git
synced 2024-12-22 23:42:34 +00:00
Procan: try to find out VSOCK CID only when running as root
This commit is contained in:
parent
c3719e7603
commit
2a04219dee
2 changed files with 7 additions and 0 deletions
2
CHANGES
2
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)
|
||||
|
|
5
hostan.c
5
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);
|
||||
|
|
Loading…
Reference in a new issue