From f320c2c12e38ed846233e77d82beb78b7c16da59 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 22 Jan 2007 14:38:18 +0000 Subject: [PATCH] * DNS resolution in dietlibc failed randomly on 64-bit platforms. Patch backported from dietlibc CVS. svn path=/nixpkgs/trunk/; revision=7743 --- pkgs/os-specific/linux/dietlibc/default.nix | 6 +- pkgs/os-specific/linux/dietlibc/dns64.patch | 109 ++++++++++++++++++ .../dietlibc/{no-wchar.h => no-wchar.patch} | 0 3 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 pkgs/os-specific/linux/dietlibc/dns64.patch rename pkgs/os-specific/linux/dietlibc/{no-wchar.h => no-wchar.patch} (100%) diff --git a/pkgs/os-specific/linux/dietlibc/default.nix b/pkgs/os-specific/linux/dietlibc/default.nix index 1b7ab2f1cc1..4a575c73f21 100644 --- a/pkgs/os-specific/linux/dietlibc/default.nix +++ b/pkgs/os-specific/linux/dietlibc/default.nix @@ -22,7 +22,11 @@ stdenv.mkDerivation { # wchar.h declares lots of functions that don't actually exist. # Remove them. - ./no-wchar.h + ./no-wchar.patch + + # Fix to get DNS resolution to work on 64-bit platforms. Taken + # from 0.31 CVS. + ./dns64.patch ]; } diff --git a/pkgs/os-specific/linux/dietlibc/dns64.patch b/pkgs/os-specific/linux/dietlibc/dns64.patch new file mode 100644 index 00000000000..47d54d1d16b --- /dev/null +++ b/pkgs/os-specific/linux/dietlibc/dns64.patch @@ -0,0 +1,109 @@ +Only in dietlibc-0.30: CHANGES.orig +diff -rc dietlibc-0.30-orig/libcruft/dnscruft2.c dietlibc-0.30/libcruft/dnscruft2.c +*** dietlibc-0.30-orig/libcruft/dnscruft2.c 2005-05-01 22:08:25.000000000 +0200 +--- dietlibc-0.30/libcruft/dnscruft2.c 2007-01-22 15:32:18.000000000 +0100 +*************** +*** 5,11 **** + #include + #include + #include +- #include + #include + #include + #include +--- 5,10 ---- +diff -rc dietlibc-0.30-orig/libcruft/dnscruft.c dietlibc-0.30/libcruft/dnscruft.c +*** dietlibc-0.30-orig/libcruft/dnscruft.c 2006-06-18 20:32:35.000000000 +0200 +--- dietlibc-0.30/libcruft/dnscruft.c 2007-01-22 15:32:18.000000000 +0100 +*************** +*** 45,53 **** + tmp=socket(PF_INET6,SOCK_DGRAM,IPPROTO_UDP); + if (tmp<0) return; + fcntl(tmp,F_SETFD,FD_CLOEXEC); + si.sin6_family=AF_INET6; +- si.sin6_port=0; +- memset(&si.sin6_addr,0,16); + if (bind(tmp,(struct sockaddr*)&si,sizeof(si))) return; + __dns_fd6=tmp; + } +--- 45,52 ---- + tmp=socket(PF_INET6,SOCK_DGRAM,IPPROTO_UDP); + if (tmp<0) return; + fcntl(tmp,F_SETFD,FD_CLOEXEC); ++ memset(&si,0,sizeof(si)); + si.sin6_family=AF_INET6; + if (bind(tmp,(struct sockaddr*)&si,sizeof(si))) return; + __dns_fd6=tmp; + } +diff -rc dietlibc-0.30-orig/libcruft/res_mkquery.c dietlibc-0.30/libcruft/res_mkquery.c +*** dietlibc-0.30-orig/libcruft/res_mkquery.c 2004-11-10 18:45:17.000000000 +0100 +--- dietlibc-0.30/libcruft/res_mkquery.c 2007-01-22 15:32:18.000000000 +0100 +*************** +*** 42,51 **** + int res_mkquery(int op, const char *dname, int class, int type, char* data, + int datalen, const unsigned char* newrr, char* buf, int buflen) { + unsigned char packet[512]; +! unsigned long len=0; +! memmove(packet,dnspacket,12); + if ((_res.options&RES_RECURSE)==0) packet[2]=0; +- *(unsigned short*)packet=rand(); + { + unsigned char* x; + const char* y,* tmp; +--- 42,55 ---- + int res_mkquery(int op, const char *dname, int class, int type, char* data, + int datalen, const unsigned char* newrr, char* buf, int buflen) { + unsigned char packet[512]; +! unsigned long len; +! +! memcpy(packet,dnspacket,12); +! len=rand(); +! packet[0]=len; +! packet[1]=len>>8; +! len=0; + if ((_res.options&RES_RECURSE)==0) packet[2]=0; + { + unsigned char* x; + const char* y,* tmp; +diff -rc dietlibc-0.30-orig/libcruft/res_query.c dietlibc-0.30/libcruft/res_query.c +*** dietlibc-0.30-orig/libcruft/res_query.c 2005-10-14 17:37:59.000000000 +0200 +--- dietlibc-0.30/libcruft/res_query.c 2007-01-22 15:32:18.000000000 +0100 +*************** +*** 99,105 **** + duh[1].fd=pnpfd; + } else { + duh[1].fd=-1; +! duh[1].revents=0; + } + + #endif +--- 99,105 ---- + duh[1].fd=pnpfd; + } else { + duh[1].fd=-1; +! duh[1].events=0; + } + + #endif +diff -rc dietlibc-0.30-orig/syscalls.s/__guard.S dietlibc-0.30/syscalls.s/__guard.S +*** dietlibc-0.30-orig/syscalls.s/__guard.S 2006-04-07 17:33:20.000000000 +0200 +--- dietlibc-0.30/syscalls.s/__guard.S 2007-01-22 15:32:18.000000000 +0100 +*************** +*** 1,3 **** +--- 1,4 ---- ++ #include + .data + .type __guard,@object + .global __guard +*************** +*** 5,9 **** +--- 6,14 ---- + .global __stack_chk_guard + __guard: + __stack_chk_guard: ++ #if __WORDSIZE == 64 ++ .quad 0xaff00 ++ #else + .long 0xaff00 ++ #endif + diff --git a/pkgs/os-specific/linux/dietlibc/no-wchar.h b/pkgs/os-specific/linux/dietlibc/no-wchar.patch similarity index 100% rename from pkgs/os-specific/linux/dietlibc/no-wchar.h rename to pkgs/os-specific/linux/dietlibc/no-wchar.patch