Changeset View
Changeset View
Standalone View
Standalone View
head/usr.sbin/bhyve/dbgport.c
Show All 24 Lines | |||||
* | * | ||||
* $FreeBSD$ | * $FreeBSD$ | ||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <sys/types.h> | #include <sys/types.h> | ||||
#ifndef WITHOUT_CAPSICUM | |||||
#include <sys/capsicum.h> | |||||
#endif | |||||
#include <sys/socket.h> | #include <sys/socket.h> | ||||
#include <netinet/in.h> | #include <netinet/in.h> | ||||
#include <netinet/tcp.h> | #include <netinet/tcp.h> | ||||
#include <sys/uio.h> | #include <sys/uio.h> | ||||
#include <err.h> | |||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <sysexits.h> | |||||
#include <fcntl.h> | #include <fcntl.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
#include <errno.h> | #include <errno.h> | ||||
#include "inout.h" | #include "inout.h" | ||||
#include "dbgport.h" | #include "dbgport.h" | ||||
#include "pci_lpc.h" | #include "pci_lpc.h" | ||||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | |||||
}; | }; | ||||
SYSRES_IO(BVM_DBG_PORT, 4); | SYSRES_IO(BVM_DBG_PORT, 4); | ||||
void | void | ||||
init_dbgport(int sport) | init_dbgport(int sport) | ||||
{ | { | ||||
int reuse; | int reuse; | ||||
#ifndef WITHOUT_CAPSICUM | |||||
cap_rights_t rights; | |||||
#endif | |||||
conn_fd = -1; | conn_fd = -1; | ||||
if ((listen_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { | if ((listen_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { | ||||
perror("socket"); | perror("socket"); | ||||
exit(1); | exit(1); | ||||
} | } | ||||
Show All 13 Lines | if (bind(listen_fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) { | ||||
perror("bind"); | perror("bind"); | ||||
exit(1); | exit(1); | ||||
} | } | ||||
if (listen(listen_fd, 1) < 0) { | if (listen(listen_fd, 1) < 0) { | ||||
perror("listen"); | perror("listen"); | ||||
exit(1); | exit(1); | ||||
} | } | ||||
#ifndef WITHOUT_CAPSICUM | |||||
cap_rights_init(&rights, CAP_ACCEPT, CAP_READ, CAP_WRITE); | |||||
if (cap_rights_limit(listen_fd, &rights) == -1 && errno != ENOSYS) | |||||
errx(EX_OSERR, "Unable to apply rights for sandbox"); | |||||
#endif | |||||
register_inout(&dbgport); | register_inout(&dbgport); | ||||
} | } |