Subject | Hash | Author | Date (UTC) |
---|---|---|---|
Added support for FORCE_NET_V*_CONN_ERROR to return an error for connect syscall | c221dc3ff63bcd28c2053694177a9a09ef9a6570 | Catalin(ux) M. BOIE | 2019-03-20 18:26:19 |
rpm changelog | e7127f5191015b0b93c7108b6fa02fde7f0fe909 | Catalin(ux) M. BOIE | 2019-02-05 21:10:57 |
duilder update | 71425ef75fbc076d6601ceadd52e81e678aabe57 | Catalin(ux) M. BOIE | 2019-02-05 21:09:29 |
Switch to v0.13 | 7a5ed99fa6629ff9dbe16f6b015712a78854b621 | Catalin(ux) M. BOIE | 2019-02-05 21:08:06 |
Lots of changes | e11f13f4d11723f0c2c833ffbaca89e55d74e139 | Catalin(ux) M. BOIE | 2019-01-16 20:18:06 |
Restart accept interrupted by signal | d84134f3193fd2d4c5298eaded8ffade5d74d220 | Catalin(ux) M. BOIE | 2014-11-11 06:57:12 |
Bump version to 0.12 | ea1c70a262b706cd45f1eb98b6aa9805de300647 | Catalin(ux) M. BOIE | 2014-10-14 03:14:29 |
Added support to change poll timeout | d0e5782e1fb0da5db1291b3c518486d3ac8dec97 | Catalin(ux) M. BOIE | 2014-10-14 03:13:58 |
Fixed strcmp on a NULL variable | 59df6d596e3c842227f4f374b4b6635de3ce1c3e | Catalin(ux) M. BOIE | 2014-10-14 03:12:29 |
Added support for deny and fake for Kevin | d9598fd2ca7886484b78512d71dbd29059720832 | Catalin(ux) M. BOIE | 2012-07-18 21:13:20 |
Log also the version in the log file. | d5576baff697e87dfbbbcbfb77df4b364cee15a2 | Catalin(ux) M. BOIE | 2011-08-25 18:55:40 |
SOCK_DCCP is not defined on CentOS. :( | 303830a06b80962e417c01d88cae6d50e9182662 | Catalin(ux) M. BOIE | 2011-08-25 09:46:09 |
More fixes for spec file | 06d8c98718977c91419ffd6cabdd3e6bb57b8043 | Catalin(ux) M. BOIE | 2011-08-24 20:29:10 |
Added example for config file. | 20becba1955981d5c3642e802031c08c25c701cf | Catalin(ux) M. BOIE | 2011-08-24 20:26:19 |
Bump version to 0.10. | 9659780e6f025d10441c354eefe79e327a660c09 | Catalin(ux) M. BOIE | 2011-08-24 20:20:26 |
Ignore more files in repo. | c1121dc5f6644043314880361c24fc2172326c02 | Catalin(ux) M. BOIE | 2011-08-24 20:20:00 |
Big fix for stuck programs. Stupid. | f0ea19d9130bdc8851f08fb16a61a7be8da002cd | Catalin(ux) M. BOIE | 2011-08-24 20:19:56 |
More duilder updates | 83d91834796de59a679545c25d62a423d6f04f0e | Catalin(ux) M. BOIE | 2011-08-24 20:17:33 |
More stuff added to TODO | aaf5da40115dc3ee2562f42522468f5bd9362012 | Catalin(ux) M. BOIE | 2011-08-24 20:17:11 |
Corrected a merge problem. | bb0ce0b8b1c869572d15babb81543154f0c5db39 | Catalin(ux) M. BOIE | 2011-08-24 03:41:36 |
File | Lines added | Lines deleted |
---|---|---|
README | 7 | 0 |
force_bind.c | 53 | 0 |
test_client6-2.sh | 3 | 1 |
test_client6.c | 1 | 0 |
File README changed (mode: 100644) (index 68d1b9f..1d1d3e8) | |||
... | ... | Examples: | |
132 | 132 | export LD_PRELOAD=${LD_PRELOAD}:/usr/lib/force_bind.so | export LD_PRELOAD=${LD_PRELOAD}:/usr/lib/force_bind.so |
133 | 133 | your_program_here | your_program_here |
134 | 134 | ||
135 | 17. Forcing a return code for the connect() call | ||
136 | export FORCE_NET_V4_CONN_ERROR=refused | ||
137 | export FORCE_NET_V6_CONN_ERROR=refused | ||
138 | export LD_PRELOAD=${LD_PRELOAD}:/usr/lib/force_bind.so | ||
139 | your_program_here | ||
140 | # Supported errors: refused, unreach | ||
141 | |||
135 | 142 | Installation: | Installation: |
136 | 143 | - ./configure | - ./configure |
137 | 144 | - make | - make |
File force_bind.c changed (mode: 100644) (index 08980e9..2f77dc1) | |||
... | ... | static unsigned int verbose = 0; | |
134 | 134 | static char *log_file = NULL; | static char *log_file = NULL; |
135 | 135 | static FILE *Log = NULL; | static FILE *Log = NULL; |
136 | 136 | static int force_poll_timeout = -1000; | static int force_poll_timeout = -1000; |
137 | static char *force_v4_conn_error; | ||
138 | static char *force_v6_conn_error; | ||
137 | 139 | ||
138 | 140 | ||
139 | 141 | /* Helper functions */ | /* Helper functions */ |
142 | /* | ||
143 | * Transform an error string into the coresponding code | ||
144 | */ | ||
145 | static int error_to_code(const char *e) | ||
146 | { | ||
147 | if (strcmp(e, "refused") == 0) | ||
148 | return ECONNREFUSED; | ||
149 | |||
150 | if (strcmp(e, "unreach") == 0) | ||
151 | return ENETUNREACH; | ||
152 | |||
153 | return -1; | ||
154 | } | ||
155 | |||
140 | 156 | static char *sdomain(const int domain) | static char *sdomain(const int domain) |
141 | 157 | { | { |
142 | 158 | static char tmp[16]; | static char tmp[16]; |
... | ... | static void init(void) | |
540 | 556 | force_poll_timeout); | force_poll_timeout); |
541 | 557 | } | } |
542 | 558 | ||
559 | x = getenv("FORCE_NET_V6_CONN_ERROR"); | ||
560 | if (x != NULL) { | ||
561 | force_v6_conn_error = x; | ||
562 | xlog(1, "force_bind: conf: forcing ipv6 connection refused to %s.\n", | ||
563 | force_v6_conn_error); | ||
564 | } | ||
565 | |||
566 | x = getenv("FORCE_NET_V4_CONN_ERROR"); | ||
567 | if (x != NULL) { | ||
568 | force_v4_conn_error = x; | ||
569 | xlog(1, "force_bind: conf: forcing ipv4 connection refused to %s.\n", | ||
570 | force_v4_conn_error); | ||
571 | } | ||
572 | |||
543 | 573 | /******** Now, hijack system calls ********/ | /******** Now, hijack system calls ********/ |
544 | 574 | ||
545 | 575 | old_bind = dlsym(RTLD_NEXT, "bind"); | old_bind = dlsym(RTLD_NEXT, "bind"); |
... | ... | int accept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags) | |
1289 | 1319 | int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen) | int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen) |
1290 | 1320 | { | { |
1291 | 1321 | struct sockaddr_storage new_dest; | struct sockaddr_storage new_dest; |
1322 | struct node *q; | ||
1323 | char *error = NULL; | ||
1324 | int my_errno; | ||
1292 | 1325 | ||
1293 | 1326 | init(); | init(); |
1294 | 1327 | ||
1295 | 1328 | xlog(2, "force_bind: connect(sockfd=%d, ...)\n", sockfd); | xlog(2, "force_bind: connect(sockfd=%d, ...)\n", sockfd); |
1296 | 1329 | ||
1330 | q = get(sockfd); | ||
1331 | while (q != NULL) { | ||
1332 | switch (q->priv.domain) { | ||
1333 | case AF_INET: error = force_v4_conn_error; break; | ||
1334 | case AF_INET6: error = force_v6_conn_error; break; | ||
1335 | } | ||
1336 | if (!error) | ||
1337 | break; | ||
1338 | |||
1339 | my_errno = error_to_code(error); | ||
1340 | if (my_errno != -1) { | ||
1341 | errno = my_errno; | ||
1342 | return -1; | ||
1343 | } | ||
1344 | |||
1345 | xlog(0, "force_bind: [%s] error set by" | ||
1346 | " FORCE_NET_V*_CONN_ERROR is unknown! Ignoring it.\n"); | ||
1347 | break; | ||
1348 | } | ||
1349 | |||
1297 | 1350 | change_local_binding(sockfd); | change_local_binding(sockfd); |
1298 | 1351 | ||
1299 | 1352 | memcpy(&new_dest, addr, addrlen); | memcpy(&new_dest, addr, addrlen); |
File test_client6-2.sh copied from file test_client6-1.sh (similarity 70%) (mode: 100755) (index eeea81b..2bd1070) | |||
1 | 1 | #!/bin/sh | #!/bin/sh |
2 | 2 | ||
3 | # I am trying to get a connection refused for IPv6 | ||
4 | |||
3 | 5 | export FORCE_NET_VERBOSE=1 | export FORCE_NET_VERBOSE=1 |
4 | export FORCE_NET_FLOWINFO=0x7812345 | ||
6 | export FORCE_NET_V6_CONN_ERROR=refused | ||
5 | 7 | ||
6 | 8 | export LD_PRELOAD="${LD_PRELOAD}:./force_bind.so" | export LD_PRELOAD="${LD_PRELOAD}:./force_bind.so" |
7 | 9 |
File test_client6.c changed (mode: 100644) (index 6b148a7..7e67973) | |||
... | ... | int main(int argc, char *argv[]) | |
54 | 54 | return 1; | return 1; |
55 | 55 | } | } |
56 | 56 | ||
57 | fprintf(stderr, "Connecting...\n"); | ||
57 | 58 | err = connect(sock, (struct sockaddr *) &sa, sizeof(sa)); | err = connect(sock, (struct sockaddr *) &sa, sizeof(sa)); |
58 | 59 | if (err == -1) { | if (err == -1) { |
59 | 60 | perror("connect"); | perror("connect"); |