Merge pull request #287521 from prusnak/torsocks-darwin

torsocks: fix build on darwin
This commit is contained in:
Pavol Rusnak 2024-02-09 13:47:48 -03:00 committed by GitHub
commit 8be7559faa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 66 additions and 14 deletions

View file

@ -0,0 +1,33 @@
diff --git a/tests/test_dns.c b/tests/test_dns.c
index 7e07663..acf095c 100644
--- a/tests/test_dns.c
+++ b/tests/test_dns.c
@@ -76,6 +76,8 @@ static void test_gethostbyname(const struct test_host *host)
return;
}
+#ifdef __linux__
+
static void test_gethostbyaddr_r_failed(void)
{
int result;
@@ -129,6 +131,8 @@ static void test_gethostbyaddr_r(const struct test_host *host)
ok(1, "Resolved address");
}
+#endif
+
static void test_gethostbyaddr(const struct test_host *host)
{
struct hostent *he;
@@ -199,8 +203,10 @@ int main(int argc, char **argv)
test_getaddrinfo(&tor_check);
test_gethostbyname(&tor_dir_auth1);
test_gethostbyaddr(&tor_dir_auth2);
+#ifdef __linux__
test_gethostbyaddr_r(&tor_dir_auth2);
test_gethostbyaddr_r_failed();
+#endif
test_getaddrinfo(&tor_localhost);
end:

View file

@ -1,22 +1,39 @@
{ lib, stdenv, fetchgit, fetchurl, autoreconfHook, libcap }:
{ lib
, stdenv
, fetchFromGitLab
, fetchpatch
, autoreconfHook
, libcap
}:
stdenv.mkDerivation rec {
pname = "torsocks";
version = "2.3.0";
version = "2.4.0";
src = fetchgit {
url = "https://git.torproject.org/torsocks.git";
rev = "refs/tags/v${version}";
sha256 = "0x0wpcigf22sjxg7bm0xzqihmsrz51hl4v8xf91qi4qnmr4ny1hb";
src = fetchFromGitLab {
domain = "gitlab.torproject.org";
group = "tpo";
owner = "core";
repo = "torsocks";
rev = "v${version}";
sha256 = "sha256-ocJkoF9LMLC84ukFrm5pzjp/1gaXqDz8lzr9TdG+f88=";
};
nativeBuildInputs = [ autoreconfHook ];
patches = lib.optional stdenv.isDarwin
(fetchurl {
url = "https://trac.torproject.org/projects/tor/raw-attachment/ticket/28538/0001-Fix-macros-for-accept4-2.patch";
sha256 = "97881f0b59b3512acc4acb58a0d6dfc840d7633ead2f400fad70dda9b2ba30b0";
});
patches = [
# fix compatibility with C99
# https://gitlab.torproject.org/tpo/core/torsocks/-/merge_requests/9
(fetchpatch {
url = "https://gitlab.torproject.org/tpo/core/torsocks/-/commit/1171bf2fd4e7a0cab02cf5fca59090b65af9cd29.patch";
hash = "sha256-qu5/0fy72+02QI0cVE/6YrR1kPuJxsZfG8XeODqVOPY=";
})
# tsocks_libc_accept4 only exists on Linux, use tsocks_libc_accept on other platforms
(fetchpatch {
url = "https://gitlab.torproject.org/tpo/core/torsocks/uploads/eeec9833512850306a42a0890d283d77/0001-Fix-macros-for-accept4-2.patch";
hash = "sha256-XWi8+UFB8XgBFSl5QDJ+hLu/dH4CvAwYbeZz7KB10Bs=";
})
# no gethostbyaddr_r on darwin
./torsocks-gethostbyaddr-darwin.patch
];
postPatch = ''
# Patch torify_app()
@ -29,12 +46,14 @@ stdenv.mkDerivation rec {
src/bin/torsocks.in
'';
nativeBuildInputs = [ autoreconfHook ];
doInstallCheck = true;
installCheckTarget = "check-recursive";
meta = {
description = "Wrapper to safely torify applications";
homepage = "https://github.com/dgoulet/torsocks";
homepage = "https://gitlab.torproject.org/tpo/core/torsocks";
license = lib.licenses.gpl2;
platforms = lib.platforms.unix;
maintainers = with lib.maintainers; [ thoughtpolice ];