Skip to content

Instantly share code, notes, and snippets.

@ottidmes
Last active November 13, 2018 02:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ottidmes/981c9f2bb474036015745daf62c33100 to your computer and use it in GitHub Desktop.
Save ottidmes/981c9f2bb474036015745daf62c33100 to your computer and use it in GitHub Desktop.
#include <sys/socket.h>
#include <string.h>
// Needed to define `RTLD_NEXT`.
#define __USE_GNU
#include <dlfcn.h>
int connect(int fd, const struct sockaddr *orig_addr, socklen_t len) {
static int (*orig_connect)(int, const struct sockaddr*, socklen_t) = NULL;
if (!orig_connect) {
orig_connect = dlsym(RTLD_NEXT, "connect");
}
struct sockaddr addr = *orig_addr;
if (addr.sa_family == AF_UNIX && strcmp(addr.sa_data, "/dev/log") == 0) {
strcpy(addr.sa_data, "/dev/null");
}
return orig_connect(fd, &addr, len);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment