-
-
Save ottidmes/981c9f2bb474036015745daf62c33100 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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