Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/gdb.c
Show First 20 Lines • Show All 161 Lines • ▼ Show 20 Lines | debug(const char *fmt, ...) | ||||
static FILE *logfile; | static FILE *logfile; | ||||
va_list ap; | va_list ap; | ||||
if (logfile == NULL) { | if (logfile == NULL) { | ||||
logfile = fopen("/tmp/bhyve_gdb.log", "w"); | logfile = fopen("/tmp/bhyve_gdb.log", "w"); | ||||
if (logfile == NULL) | if (logfile == NULL) | ||||
return; | return; | ||||
#ifndef WITHOUT_CAPSICUM | #ifndef WITHOUT_CAPSICUM | ||||
if (caph_limit_stream(fileno(logfile), CAPH_WRITE) == -1) { | if (caph_limit_stream(fileno(logfile), CAPH_WRITE) == -1) { | ||||
jhb: I would keep the == -1. | |||||
fclose(logfile); | fclose(logfile); | ||||
logfile = NULL; | logfile = NULL; | ||||
return; | return; | ||||
} | } | ||||
#endif | #endif | ||||
setlinebuf(logfile); | setlinebuf(logfile); | ||||
} | } | ||||
va_start(ap, fmt); | va_start(ap, fmt); | ||||
▲ Show 20 Lines • Show All 1,068 Lines • ▼ Show 20 Lines | |||||
void | void | ||||
limit_gdb_socket(int s) | limit_gdb_socket(int s) | ||||
{ | { | ||||
cap_rights_t rights; | cap_rights_t rights; | ||||
unsigned long ioctls[] = { FIONREAD }; | unsigned long ioctls[] = { FIONREAD }; | ||||
cap_rights_init(&rights, CAP_ACCEPT, CAP_EVENT, CAP_READ, CAP_WRITE, | cap_rights_init(&rights, CAP_ACCEPT, CAP_EVENT, CAP_READ, CAP_WRITE, | ||||
CAP_SETSOCKOPT, CAP_IOCTL); | CAP_SETSOCKOPT, CAP_IOCTL); | ||||
if (cap_rights_limit(s, &rights) == -1 && errno != ENOSYS) | if (caph_rights_limit(s, &rights) == -1) | ||||
errx(EX_OSERR, "Unable to apply rights for sandbox"); | errx(EX_OSERR, "Unable to apply rights for sandbox"); | ||||
if (cap_ioctls_limit(s, ioctls, nitems(ioctls)) == -1 && errno != ENOSYS) | if (caph_ioctls_limit(s, ioctls, nitems(ioctls)) == -1) | ||||
errx(EX_OSERR, "Unable to apply rights for sandbox"); | errx(EX_OSERR, "Unable to apply rights for sandbox"); | ||||
} | } | ||||
#endif | #endif | ||||
void | void | ||||
init_gdb(struct vmctx *_ctx, int sport, bool wait) | init_gdb(struct vmctx *_ctx, int sport, bool wait) | ||||
{ | { | ||||
struct sockaddr_in sin; | struct sockaddr_in sin; | ||||
▲ Show 20 Lines • Show All 48 Lines • Show Last 20 Lines |
I would keep the == -1.