translate sendmsg so that tools like nslookup will show remote addresses;
i waited for three years and nobody did this; had to do it myself :-(
This commit is contained in:
parent
f66776b16a
commit
9244f58a4e
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: intercept-translate.c,v 1.8 2005/06/27 17:11:20 elad Exp $ */
|
||||
/* $NetBSD: intercept-translate.c,v 1.9 2006/04/16 05:19:02 provos Exp $ */
|
||||
/* $OpenBSD: intercept-translate.c,v 1.9 2002/08/01 20:16:45 provos Exp $ */
|
||||
/*
|
||||
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
|
||||
@ -30,7 +30,7 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: intercept-translate.c,v 1.8 2005/06/27 17:11:20 elad Exp $");
|
||||
__RCSID("$NetBSD: intercept-translate.c,v 1.9 2006/04/16 05:19:02 provos Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
@ -292,6 +292,54 @@ ic_print_sockaddr(char *buf, size_t buflen, struct intercept_translate *tl)
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
ic_get_msghdr(struct intercept_translate *trans, int fd, pid_t pid,
|
||||
void *addr)
|
||||
{
|
||||
struct msghdr msg;
|
||||
int len = sizeof(struct msghdr);
|
||||
|
||||
if (intercept.io(fd, pid, INTERCEPT_READ, addr,
|
||||
(void *)&msg, len) == -1)
|
||||
return (-1);
|
||||
|
||||
if (msg.msg_name == NULL) {
|
||||
trans->trans_data = NULL;
|
||||
trans->trans_size = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
trans->trans_size = msg.msg_namelen;
|
||||
trans->trans_data = malloc(len);
|
||||
if (trans->trans_data == NULL)
|
||||
return (-1);
|
||||
if (intercept.io(fd, pid, INTERCEPT_READ, msg.msg_name,
|
||||
(void *)trans->trans_data, trans->trans_size) == -1)
|
||||
return (-1);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
ic_print_msghdr(char *buf, size_t buflen, struct intercept_translate *tl)
|
||||
{
|
||||
int res = 0;
|
||||
if (tl->trans_size == 0) {
|
||||
snprintf(buf, buflen, "<unknown>");
|
||||
} else {
|
||||
res = ic_print_sockaddr(buf, buflen, tl);
|
||||
/*
|
||||
* disable replacement of this argument because it's two levels
|
||||
* deep and we cant replace that fast.
|
||||
*/
|
||||
tl->trans_size = 0;
|
||||
|
||||
/* TODO: make this less of a hack */
|
||||
}
|
||||
|
||||
return (res);
|
||||
}
|
||||
|
||||
struct intercept_translate ic_translate_string = {
|
||||
"string",
|
||||
ic_get_string, ic_print_filename,
|
||||
@ -317,3 +365,8 @@ struct intercept_translate ic_translate_connect = {
|
||||
ic_get_sockaddr, ic_print_sockaddr,
|
||||
/* XXX - Special handling */ 1,
|
||||
};
|
||||
|
||||
struct intercept_translate ic_translate_sendmsg = {
|
||||
"sockaddr",
|
||||
ic_get_msghdr, ic_print_msghdr,
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: intercept.h,v 1.18 2005/12/31 12:33:41 elad Exp $ */
|
||||
/* $NetBSD: intercept.h,v 1.19 2006/04/16 05:19:02 provos Exp $ */
|
||||
/* $OpenBSD: intercept.h,v 1.11 2002/08/04 04:15:50 provos Exp $ */
|
||||
/*
|
||||
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
|
||||
@ -183,6 +183,7 @@ extern struct intercept_translate ic_translate_filename;
|
||||
extern struct intercept_translate ic_translate_linkname;
|
||||
extern struct intercept_translate ic_translate_unlinkname;
|
||||
extern struct intercept_translate ic_translate_connect;
|
||||
extern struct intercept_translate ic_translate_sendmsg;
|
||||
|
||||
void intercept_freepid(pid_t);
|
||||
struct intercept_pid *intercept_findpid(pid_t);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: register.c,v 1.17 2006/04/15 20:35:24 provos Exp $ */
|
||||
/* $NetBSD: register.c,v 1.18 2006/04/16 05:19:02 provos Exp $ */
|
||||
/* $OpenBSD: register.c,v 1.11 2002/08/05 14:49:27 provos Exp $ */
|
||||
/*
|
||||
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
|
||||
@ -94,6 +94,11 @@ systrace_initcb(void)
|
||||
intercept_register_translation("netbsd", "setuid", 0, &ic_uidt);
|
||||
intercept_register_translation("netbsd", "setuid", 0, &ic_uname);
|
||||
|
||||
/* 28: sendmsg */
|
||||
X(intercept_register_sccb("netbsd", "sendmsg", trans_cb, NULL));
|
||||
intercept_register_translation("netbsd", "sendmsg", 1,
|
||||
&ic_translate_sendmsg);
|
||||
|
||||
/* 33: access [fsread] */
|
||||
X(intercept_register_sccb("netbsd", "access", trans_cb, NULL));
|
||||
tl = intercept_register_transfn("netbsd", "access", 0);
|
||||
@ -348,6 +353,11 @@ systrace_initcb(void)
|
||||
intercept_register_translation("native", "socket", 0, &ic_sockdom);
|
||||
intercept_register_translation("native", "socket", 1, &ic_socktype);
|
||||
|
||||
/* sendmsg */
|
||||
X(intercept_register_sccb("native", "sendmsg", trans_cb, NULL));
|
||||
intercept_register_translation("native", "sendmsg", 1,
|
||||
&ic_translate_sendmsg);
|
||||
|
||||
/* connect */
|
||||
X(intercept_register_sccb("native", "connect", trans_cb, NULL));
|
||||
intercept_register_translation("native", "connect", 1,
|
||||
|
Loading…
Reference in New Issue
Block a user