From dd43556d0b937070df00fdf1052323300aa28305 Mon Sep 17 00:00:00 2001 From: Yann Weber Date: Sat, 30 Jun 2018 11:01:47 +0200 Subject: [PATCH] Alpine linux musl libc bugfixes --- README.md | 8 ++++++-- SConstruct | 2 +- src/SConscript | 3 +++ src/libiptc/libiptc.h | 2 +- src/netsplit.c | 6 +++--- src/ntkresolv.c | 8 ++++++++ src/xmalloc.c | 1 + 7 files changed, 23 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 9144fdb..d1b446b 100644 --- a/README.md +++ b/README.md @@ -58,9 +58,13 @@ For Archlinux, Try this. sudo pacman -S zlib gmp lib32-gmp openssl lib32-openssl libgee pth libgcrypt autoconf cmake autogen gawk scons git -For AlpineLinux Try this. +For AlpineLinux, Try this. - apk add scons libssl1.0 openssl libgee gmp gmp-dev libgcrypt gawk zlib zlib-dev gcc pkgconf pkgconfig libc-dev libressl-dev libexecinfo-dev linux-headers + apk add scons libssl1.0 openssl libgee gmp gmp-dev libgcrypt gawk zlib zlib-dev gcc pkgconf pkgconfig libc-dev libressl-dev libexecinfo-dev linux-headers python + +For Debian, Try this. + + apt-get install build-essential scons libgcrypt20-dev libssl1.0-dev libgmp-dev zlib1g-dev To compile the code you can do this: diff --git a/SConstruct b/SConstruct index e68c476..6426e17 100644 --- a/SConstruct +++ b/SConstruct @@ -22,7 +22,7 @@ opts.AddVariables(('CONF_DIR', """Directory where the Netsukuku configuration fi opts.Add('CC', 'The C compiler.') opts.Add('CXX', 'The C++ compiler.') -env = Environment(options = opts, ENV = os.environ, CCFLAGS = ' -Wall') +env = Environment(options = opts, ENV = os.environ, CCFLAGS = ['-Wall', '-ggdb']) env['platform'] = _platform.system().lower(); env["CC"] = os.getenv("CC") or env["CC"] diff --git a/src/SConscript b/src/SConscript index b44d030..cfe268b 100644 --- a/src/SConscript +++ b/src/SConscript @@ -107,6 +107,9 @@ if not os.path.exists("config.log") and not env.GetOption('clean'): print 'Did not find the openssl headers, exiting!' Execute(Delete('config.log')) Exit(1) + + if conf.CheckCHeader(["net/if.h", "netinet/in.h"]): + env.Append(CCFLAGS = ['-DHAVE_NET_IF_H']) env = conf.Finish() diff --git a/src/libiptc/libiptc.h b/src/libiptc/libiptc.h index 42f9141..c29be09 100644 --- a/src/libiptc/libiptc.h +++ b/src/libiptc/libiptc.h @@ -7,7 +7,7 @@ #include -#if defined(__GLIBC__) && __GLIBC__ == 2 +#ifdef HAVE_NET_IF_H #include #include #include diff --git a/src/netsplit.c b/src/netsplit.c index 331d325..4ae6edf 100644 --- a/src/netsplit.c +++ b/src/netsplit.c @@ -77,7 +77,7 @@ inet_mode (char *domain) char *ret; char *ret1; - char new_domain[MAXNAMLEN]; + char new_domain[NAME_MAX]; int rt_value; strcpy (new_domain, domain); @@ -141,7 +141,7 @@ ntk_mode (char *domain) char *ret; char *ret1; - char new_domain[MAXNAMLEN]; + char new_domain[NAME_MAX]; int rt_value; strcpy (new_domain, domain); @@ -197,7 +197,7 @@ ntk_mode (char *domain) domain_ip_processing (char *domain) { char *ret; - char new_domain[MAXNAMLEN]; + char new_domain[NAME_MAX]; int rt_value; int i; ret = strstr (domain, ".inet"); diff --git a/src/ntkresolv.c b/src/ntkresolv.c index 994e324..832830d 100644 --- a/src/ntkresolv.c +++ b/src/ntkresolv.c @@ -340,7 +340,11 @@ opts_set_question(char *arg) ntkresolv_safe_exit(1); } G_ALIGN(16); +#ifdef HAVE_NET_IF_H + memcpy(GQT->qstdata, &i6a.__in6_union, 16); +#else memcpy(GQT->qstdata, &i6a.__in6_u, 16); +#endif GQT->ipv = ANDNS_IPV6; return; case QTYPE_G: @@ -424,7 +428,11 @@ ip_bin_to_str(void *data, char *dst) via = (void *) (&ia); break; case AF_INET6: +#ifdef HAVE_NET_IF_H + memcpy(&(i6a.__in6_union), data, 16); +#else memcpy(&(i6a.__in6_u), data, 16); +#endif via = (void *) (&i6a); break; default: diff --git a/src/xmalloc.c b/src/xmalloc.c index 418d388..4879031 100644 --- a/src/xmalloc.c +++ b/src/xmalloc.c @@ -33,6 +33,7 @@ * xzalloc(size_t size) added. \*/ +#include #include #include