-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathresolv.c
39 lines (33 loc) · 801 Bytes
/
resolv.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <string.h>
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "preload.h"
#include "dbg.h"
#include "fopen.h"
static int hosts_intercept(const char *path, const char *modes)
{
return !strcmp(path, "/etc/jnpr-nc-hosts.new") ||
!strcmp(path, "/etc/jnpr-nc-hosts.bak") ||
!strcmp(path, "/etc/resolv.conf");
}
static FILE *hosts_fopen(struct fopen_info *info, const char *path,
const char *mode)
{
return tmpfile();
}
static int hosts_fclose(struct fopen_info *info)
{
return 0;
}
static struct fopen_intercept hosts_fopen_intercept = {
.intercept = hosts_intercept,
.fopen = hosts_fopen,
.fclose = hosts_fclose,
};
__attribute__((constructor))
static void resolv_init(void)
{
fopen_add_intercept(&hosts_fopen_intercept);
}