Stop further socket() or connect() calls.

mal content artifact.one at googlemail.com
Wed Jul 5 01:15:49 UTC 2006


On 03/07/06, Peter Jeremy <peterjeremy at optushome.com.au> wrote:
> For dynamic executables, you could LD_PRELOAD a .so that replaces
> all the socket-related syscalls.

Excellent suggestion! Ok, I've created a basic .so file with the following
code, but I've basically got stuck because I don't know how the original
syscalls are defined and can't find the definitions in the source:

---
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/socket.h>

int socket(int d, int t, int prot)
{
  return __syscall(SYS_socket, d, t, prot);
}
int connect(int s, const struct sockaddr *sa, socklen_t len)
{
  return __syscall(SYS_connect, s, sa, len);
}
int bind(int s, const struct sockaddr *sa, socklen_t len)
{
  return __syscall(SYS_bind, s, sa, len);
}
int listen(int s, int bl)
{
  return __syscall(SYS_listen, s, bl);
}
---

This doesn't work, it causes various runtime errors.

Where are the system calls defined in the source? I could just
copy the definitions.

cheers
MC


More information about the freebsd-hackers mailing list