Bug#630206: libnss-myhostname: FTBFS: fatal error: asm/types.h: No such file or directory

2011-06-12 Thread Christoph Egger
Package: src:libnss-myhostname
Version: 0.3-1
Severity: serious
Tags: sid wheezy
Justification: fails to build from source (but built successfully in the past)

Hi!

Your pacage failed to build on the kfreebsd-* buildds:
libtool: compile:  x86_64-kfreebsd-gnu-gcc -std=gnu99 -DHAVE_CONFIG_H -I. 
-I/build/buildd-libnss-myhostname_0.3-1-kfreebsd-amd64-oyrjWQ/libnss-myhostname-0.3
 -include ./config.h -Wall -g -O2 -Wall -W -Wextra -pedantic -pipe -Wformat 
-Wold-style-definition -Wdeclaration-after-statement -Wfloat-equal 
-Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes 
-Wredundant-decls -Wmissing-noreturn -Wshadow -Wendif-labels -Wpointer-arith 
-Wcast-align -Wwrite-strings -Winline -Wno-unused-parameter -ffast-math 
-fvisibility=hidden -fdiagnostics-show-option -MT netlink.lo -MD -MP -MF 
.deps/netlink.Tpo -c 
/build/buildd-libnss-myhostname_0.3-1-kfreebsd-amd64-oyrjWQ/libnss-myhostname-0.3/netlink.c
  -fPIC -DPIC -o .libs/netlink.o
/build/buildd-libnss-myhostname_0.3-1-kfreebsd-amd64-oyrjWQ/libnss-myhostname-0.3/netlink.c:25:23:
 fatal error: asm/types.h: No such file or directory
compilation terminated.
make[3]: *** [netlink.lo] Error 1

Full build log at
https://buildd.debian.org/status/fetch.php?pkg=libnss-myhostname&arch=kfreebsd-amd64&ver=0.3-1&stamp=1307742167

Regards

Christoph

If you have further questions please mail debian-...@lists.debian.org

-- 
9FED 5C6C E206 B70A 5857  70CA 9655 22B9 D49A E731
Debian Developer | Lisp Hacker | CaCert Assurer

A. Because it breaks the logical sequence of discussion
Q. Why is top posting bad?


pgpR1Vou4T6Sy.pgp
Description: PGP signature


Bug#630206: libnss-myhostname: FTBFS: fatal error: asm/types.h: No such file or directory

2011-06-12 Thread Joachim Breitner
Hi Christoph, Hello Lennart,

Am Sonntag, den 12.06.2011, 12:34 +0200 schrieb Christoph Egger:
> Package: src:libnss-myhostname
> Version: 0.3-1
> Severity: serious
> Tags: sid wheezy
> Justification: fails to build from source (but built successfully in the past)
> 
> Hi!
> 
> Your pacage failed to build on the kfreebsd-* buildds:
> libtool: compile:  x86_64-kfreebsd-gnu-gcc -std=gnu99 -DHAVE_CONFIG_H -I. 
> -I/build/buildd-libnss-myhostname_0.3-1-kfreebsd-amd64-oyrjWQ/libnss-myhostname-0.3
>  -include ./config.h -Wall -g -O2 -Wall -W -Wextra -pedantic -pipe -Wformat 
> -Wold-style-definition -Wdeclaration-after-statement -Wfloat-equal 
> -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes 
> -Wredundant-decls -Wmissing-noreturn -Wshadow -Wendif-labels -Wpointer-arith 
> -Wcast-align -Wwrite-strings -Winline -Wno-unused-parameter -ffast-math 
> -fvisibility=hidden -fdiagnostics-show-option -MT netlink.lo -MD -MP -MF 
> .deps/netlink.Tpo -c 
> /build/buildd-libnss-myhostname_0.3-1-kfreebsd-amd64-oyrjWQ/libnss-myhostname-0.3/netlink.c
>   -fPIC -DPIC -o .libs/netlink.o
> /build/buildd-libnss-myhostname_0.3-1-kfreebsd-amd64-oyrjWQ/libnss-myhostname-0.3/netlink.c:25:23:
>  fatal error: asm/types.h: No such file or directory
> compilation terminated.
> make[3]: *** [netlink.lo] Error 1
> 
> Full build log at
> https://buildd.debian.org/status/fetch.php?pkg=libnss-myhostname&arch=kfreebsd-amd64&ver=0.3-1&stamp=1307742167
>
> If you have further questions please mail debian-...@lists.debian.org


it seems that nss-myhostname has changed the way it acquires link
addresses between versions 0.2 to 0.3 to make use of the netlink
interface. This breaks the package on hurd and freebsd kernels. What
should we do here? I see three options:

 A. Mark the package as Linux-only. Least hassle, but of course not
great for the BSDers. Also, I would want to suggest to the
debian-installer folk to consider to install this by default instead of
having to generated a suitable /etc/hosts, and I’m sure they are more
likely to do so if the package works on all kernels.
PRO: No additional work.
CON: Probably no installation by default, and wider adoption of the tool
is, I think, also in Lennart’s interest.

 B. Ask Lennart to try to make his program portable.
PRO: No Debian-specific changes required.
CON: More work for Lennart and, if I correctly read what he wrote about
systemd, he is in favor of choosing small code size over portability.

 C. Patch BSD-support ourself onto it.
PRO: It is not A, but does not require B to happen.
CON: Derivation from upstream, and someone else has to do the work, as I
don’t think I’ll be able to do that.


Unless either Lennart or someone else is willing to support BSD (and,
less importantly, Hurd), we will have to go with A.

Greetings,
Joachim


-- 
Joachim "nomeata" Breitner
Debian Developer
  nome...@debian.org | ICQ# 74513189 | GPG-Keyid: 4743206C
  JID: nome...@joachim-breitner.de | http://people.debian.org/~nomeata


signature.asc
Description: This is a digitally signed message part


Bug#630206: libnss-myhostname: FTBFS: fatal error: asm/types.h: No such file or directory

2011-06-13 Thread Lennart Poettering
On Sun, 12.06.11 21:35, Joachim Breitner (nome...@debian.org) wrote:

> Hi Christoph, Hello Lennart,
> 
> Am Sonntag, den 12.06.2011, 12:34 +0200 schrieb Christoph Egger:
> > Package: src:libnss-myhostname
> > Version: 0.3-1
> > Severity: serious
> > Tags: sid wheezy
> > Justification: fails to build from source (but built successfully in the 
> > past)
> > 
> > Hi!
> > 
> > Your pacage failed to build on the kfreebsd-* buildds:
> > libtool: compile:  x86_64-kfreebsd-gnu-gcc -std=gnu99 -DHAVE_CONFIG_H -I. 
> > -I/build/buildd-libnss-myhostname_0.3-1-kfreebsd-amd64-oyrjWQ/libnss-myhostname-0.3
> >  -include ./config.h -Wall -g -O2 -Wall -W -Wextra -pedantic -pipe -Wformat 
> > -Wold-style-definition -Wdeclaration-after-statement -Wfloat-equal 
> > -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes 
> > -Wredundant-decls -Wmissing-noreturn -Wshadow -Wendif-labels 
> > -Wpointer-arith -Wcast-align -Wwrite-strings -Winline -Wno-unused-parameter 
> > -ffast-math -fvisibility=hidden -fdiagnostics-show-option -MT netlink.lo 
> > -MD -MP -MF .deps/netlink.Tpo -c 
> > /build/buildd-libnss-myhostname_0.3-1-kfreebsd-amd64-oyrjWQ/libnss-myhostname-0.3/netlink.c
> >   -fPIC -DPIC -o .libs/netlink.o
> > /build/buildd-libnss-myhostname_0.3-1-kfreebsd-amd64-oyrjWQ/libnss-myhostname-0.3/netlink.c:25:23:
> >  fatal error: asm/types.h: No such file or directory
> > compilation terminated.
> > make[3]: *** [netlink.lo] Error 1
> > 
> > Full build log at
> > https://buildd.debian.org/status/fetch.php?pkg=libnss-myhostname&arch=kfreebsd-amd64&ver=0.3-1&stamp=1307742167
> >
> > If you have further questions please mail debian-...@lists.debian.org
> 
> 
> it seems that nss-myhostname has changed the way it acquires link
> addresses between versions 0.2 to 0.3 to make use of the netlink
> interface. This breaks the package on hurd and freebsd kernels. What
> should we do here? I see three options:

I think it is a major waste of time thinking about BSD and Hurd. 

That said, I'd be willing to merge a patch that adds support for those
legacy systems -- if it is minimal. Note however that it wouldn't be
release critical to me, i.e. I will not care if it works or not when
releasing a new version. But I geuss that doesn't matter much since it
is quite a finished project and I expect very few updates in the future.

So yupp, if you send me a minimal, non-intrusive patch with proper
coding style that does not pollute the Linux code I'd be willing to
merge it.

The emphasis is on non-intrusive minimalism.

>  B. Ask Lennart to try to make his program portable.

Nah, I will not work on this. Netlink is Linux specific -- it cannot be
made on the legacy kernels, and I don't care for the legacy kernels
anyway and won't spend time on them.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.



-- 
To UNSUBSCRIBE, email to debian-bugs-rc-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#630206: libnss-myhostname: FTBFS: fatal error: asm/types.h: No such file or directory

2011-06-13 Thread Robert Millan
2011/6/13 Lennart Poettering :
> I think it is a major waste of time thinking about BSD and Hurd.
>
> That said, I'd be willing to merge a patch that adds support for those
> legacy systems -- if it is minimal. Note however that it wouldn't be
> release critical to me, i.e. I will not care if it works or not when
> releasing a new version. But I geuss that doesn't matter much since it
> is quite a finished project and I expect very few updates in the future.

Seems simple enough, I'll give it a try.

-- 
Robert Millan



-- 
To UNSUBSCRIBE, email to debian-bugs-rc-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#630206: libnss-myhostname: FTBFS: fatal error: asm/types.h: No such file or directory

2011-06-13 Thread Robert Millan
tags 630206 patch
thanks

2011/6/13 Robert Millan :
> 2011/6/13 Lennart Poettering :
>> I think it is a major waste of time thinking about BSD and Hurd.
>>
>> That said, I'd be willing to merge a patch that adds support for those
>> legacy systems -- if it is minimal. Note however that it wouldn't be
>> release critical to me, i.e. I will not care if it works or not when
>> releasing a new version. But I geuss that doesn't matter much since it
>> is quite a finished project and I expect very few updates in the future.
>
> Seems simple enough, I'll give it a try.

Patch attached.  To be applied after "mv netlink.h ifconf.h".

--
Robert Millan
diff -Nur -x aclocal.m4 -x configure -x doc libnss-myhostname-0.3/ifconf.c 
libnss-myhostname-0.3.new/ifconf.c
--- libnss-myhostname-0.3/ifconf.c  1970-01-01 01:00:00.0 +0100
+++ libnss-myhostname-0.3.new/ifconf.c  2011-06-13 14:06:34.0 +0200
@@ -0,0 +1,5 @@
+#ifdef __linux__
+#include "netlink.c"
+#else
+#include "legacy.c"
+#endif
diff -Nur -x aclocal.m4 -x configure -x doc libnss-myhostname-0.3/ifconf.h 
libnss-myhostname-0.3.new/ifconf.h
--- libnss-myhostname-0.3/ifconf.h  2011-05-09 15:00:58.0 +0200
+++ libnss-myhostname-0.3.new/ifconf.h  2011-06-13 14:01:28.0 +0200
@@ -3,6 +3,8 @@
 #ifndef foonetlinkhfoo
 #define foonetlinkhfoo
 
+#include 
+
 /***
   This file is part of nss-myhostname.
 
@@ -37,7 +39,7 @@
 #define _public_ __attribute__ ((visibility("default")))
 #define _hidden_ __attribute__ ((visibility("hidden")))
 
-int netlink_acquire_addresses(struct address **_list, unsigned *_n_list) 
_hidden_;
+int ifconf_acquire_addresses(struct address **_list, unsigned *_n_list) 
_hidden_;
 
 static inline size_t PROTO_ADDRESS_SIZE(int proto) {
 assert(proto == AF_INET || proto == AF_INET6);
@@ -45,4 +47,28 @@
 return proto == AF_INET6 ? 16 : 4;
 }
 
+static inline int address_compare(const void *_a, const void *_b) {
+const struct address *a = _a, *b = _b;
+
+/* Order lowest scope first, IPv4 before IPv6, lowest interface index 
first */
+
+if (a->scope < b->scope)
+return -1;
+if (a->scope > b->scope)
+return 1;
+
+if (a->family == AF_INET && b->family == AF_INET6)
+return -1;
+if (a->family == AF_INET6 && b->family == AF_INET)
+return 1;
+
+if (a->ifindex < b->ifindex)
+return -1;
+if (a->ifindex > b->ifindex)
+return 1;
+
+return 0;
+}
+
+
 #endif
diff -Nur -x aclocal.m4 -x configure -x doc libnss-myhostname-0.3/legacy.c 
libnss-myhostname-0.3.new/legacy.c
--- libnss-myhostname-0.3/legacy.c  1970-01-01 01:00:00.0 +0100
+++ libnss-myhostname-0.3.new/legacy.c  2011-06-13 14:06:18.0 +0200
@@ -0,0 +1,116 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+  This file is part of nss-myhostname.
+
+  Copyright 2008-2011 Lennart Poettering
+  Copyright 2011 Robert millan
+
+  nss-myhostname is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public License
+  as published by the Free Software Foundation; either version 2.1 of
+  the License, or (at your option) any later version.
+
+  nss-myhostname is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with nss-myhostname; If not, see
+  .
+***/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "ifconf.h"
+
+int ifconf_acquire_addresses(struct address **_list, unsigned *_n_list) {
+
+struct address *list = NULL;
+unsigned n_list = 0;
+
+struct ifconf ifc;
+int fd, r = 1, want;
+unsigned int i;
+
+fd = socket (AF_INET6, SOCK_DGRAM, 0);
+
+want = sizeof (struct ifreq);
+ifc.ifc_req = NULL;
+
+do {
+want *= 2;
+
+ifc.ifc_req = realloc (ifc.ifc_req, want);
+if (! ifc.ifc_req) {
+r = -errno;
+goto finish;
+}
+
+ifc.ifc_len = want;
+  
+if (ioctl (fd, SIOCGIFCONF, &ifc) == -1) {
+r = -errno;
+goto finish;
+}
+} while (want == ifc.ifc_len);
+
+for (i = 0; i < ifc.ifc_len / sizeof (struct ifreq); i++) {
+int af = ifc.ifc_req[i].ifr_addr.sa_family;
+const void *cp;
+
+struct sockaddr_in6 *in6 = (void *) &ifc.ifc_req[i].ifr_addr;
+struct sockaddr_in *in

Bug#630206: libnss-myhostname: FTBFS: fatal error: asm/types.h: No such file or directory

2011-06-13 Thread Lennart Poettering
On Mon, 13.06.11 14:13, Robert Millan (r...@debian.org) wrote:

> tags 630206 patch
> thanks
> 
> 2011/6/13 Robert Millan :
> > 2011/6/13 Lennart Poettering :
> >> I think it is a major waste of time thinking about BSD and Hurd.
> >>
> >> That said, I'd be willing to merge a patch that adds support for those
> >> legacy systems -- if it is minimal. Note however that it wouldn't be
> >> release critical to me, i.e. I will not care if it works or not when
> >> releasing a new version. But I geuss that doesn't matter much since it
> >> is quite a finished project and I expect very few updates in the future.
> >
> > Seems simple enough, I'll give it a try.
> 
> Patch attached.  To be applied after "mv netlink.h ifconf.h".

Sounds mostly good. Can you prep a proper git patch please?

> diff -Nur -x aclocal.m4 -x configure -x doc libnss-myhostname-0.3/ifconf.c 
> libnss-myhostname-0.3.new/ifconf.c
> --- libnss-myhostname-0.3/ifconf.c1970-01-01 01:00:00.0 +0100
> +++ libnss-myhostname-0.3.new/ifconf.c2011-06-13 14:06:34.0 
> +0200
> @@ -0,0 +1,5 @@
> +#ifdef __linux__
> +#include "netlink.c"
> +#else
> +#include "legacy.c"
> +#endif

Urks, no. Please do this in Makefile.am.

> diff -Nur -x aclocal.m4 -x configure -x doc libnss-myhostname-0.3/ifconf.h 
> libnss-myhostname-0.3.new/ifconf.h
> --- libnss-myhostname-0.3/ifconf.h2011-05-09 15:00:58.0 +0200
> +++ libnss-myhostname-0.3.new/ifconf.h2011-06-13 14:01:28.0 
> +0200
> @@ -3,6 +3,8 @@
>  #ifndef foonetlinkhfoo
>  #define foonetlinkhfoo

Please fix the header here.

> +fd = socket (AF_INET6, SOCK_DGRAM, 0);

Please follow the coding style, we do not place a space between the
function name and the opening bracket.

Also, this will obviously fail if IPv6 is not enabled. I personally
don't care about that, but I am pretty sure the same kids who care about
Hurd also care about IPv6-free systems. It's up to you if you want to
fix this. I'd merge it either way.

This gets particularly strange given that SIOCGIFCONF according to the
(Linux) man page only returns IPv4 addresses.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.



-- 
To UNSUBSCRIBE, email to debian-bugs-rc-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#630206: libnss-myhostname: FTBFS: fatal error: asm/types.h: No such file or directory

2011-06-14 Thread Robert Millan
2011/6/13 Lennart Poettering :
>> +#ifdef __linux__
>> +#include "netlink.c"
>> +#else
>> +#include "legacy.c"
>> +#endif
>
> Urks, no. Please do this in Makefile.am.

Tried that, but it's a no-go.  Automake doesn't support
build time substitutions in _SOURCES AFAICT (its maintainers
seem to confirm this in
http://lists.gnu.org/archive/html/automake/2008-08/msg00047.html)

I fixed the style issues you commented, also rewrote the legacy
routine to use getifaddrs() which is more portable than SIOCGIFCONF
(I verified that Glibc implements this syscall on Linux, kFreeBSD and
the Hurd).

-- 
Robert Millan
commit 0d4d63ddc99b7b69f112757f6a5e8d8e87cd358f
Author: Robert Millan 
Date:   Tue Jun 14 17:43:22 2011 +0200

Use legacy getifaddrs() on GNU/kFreeBSD.

diff --git a/Makefile.am b/Makefile.am
index 7f2f3a3..c9cce51 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -43,8 +43,8 @@ homepage: all dist
 
 libnss_myhostname_la_SOURCES = \
nss-myhostname.c \
-   netlink.c \
-   netlink.h
+   ifconf.c \
+   ifconf.h
 
 libnss_myhostname_la_LDFLAGS = \
-avoid-version \
diff --git a/ifconf.c b/ifconf.c
new file mode 100644
index 000..e57ab61
--- /dev/null
+++ b/ifconf.c
@@ -0,0 +1,5 @@
+#ifdef __linux__
+#include "netlink.c"
+#else
+#include "legacy.c"
+#endif
diff --git a/ifconf.h b/ifconf.h
new file mode 100644
index 000..6b2c83f
--- /dev/null
+++ b/ifconf.h
@@ -0,0 +1,74 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+#ifndef fooifconfhfoo
+#define fooifconfhfoo
+
+#include 
+
+/***
+  This file is part of nss-myhostname.
+
+  Copyright 2008-2011 Lennart Poettering
+
+  nss-myhostname is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public License
+  as published by the Free Software Foundation; either version 2.1 of
+  the License, or (at your option) any later version.
+
+  nss-myhostname is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with nss-myhostname; If not, see
+  .
+***/
+
+#include 
+#include 
+#include 
+
+struct address {
+unsigned char family;
+uint8_t address[16];
+unsigned char scope;
+int ifindex;
+};
+
+#define _public_ __attribute__ ((visibility("default")))
+#define _hidden_ __attribute__ ((visibility("hidden")))
+
+int ifconf_acquire_addresses(struct address **_list, unsigned *_n_list) 
_hidden_;
+
+static inline size_t PROTO_ADDRESS_SIZE(int proto) {
+assert(proto == AF_INET || proto == AF_INET6);
+
+return proto == AF_INET6 ? 16 : 4;
+}
+
+static inline int address_compare(const void *_a, const void *_b) {
+const struct address *a = _a, *b = _b;
+
+/* Order lowest scope first, IPv4 before IPv6, lowest interface index 
first */
+
+if (a->scope < b->scope)
+return -1;
+if (a->scope > b->scope)
+return 1;
+
+if (a->family == AF_INET && b->family == AF_INET6)
+return -1;
+if (a->family == AF_INET6 && b->family == AF_INET)
+return 1;
+
+if (a->ifindex < b->ifindex)
+return -1;
+if (a->ifindex > b->ifindex)
+return 1;
+
+return 0;
+}
+
+
+#endif
diff --git a/legacy.c b/legacy.c
new file mode 100644
index 000..8e705c7
--- /dev/null
+++ b/legacy.c
@@ -0,0 +1,94 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+  This file is part of nss-myhostname.
+
+  Copyright 2008-2011 Lennart Poettering
+  Copyright 2011 Robert millan
+
+  nss-myhostname is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public License
+  as published by the Free Software Foundation; either version 2.1 of
+  the License, or (at your option) any later version.
+
+  nss-myhostname is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with nss-myhostname; If not, see
+  .
+***/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "ifconf.h"
+
+int ifconf_acquire_addresses(struct address **_list, unsigned *_n_list) {
+
+struct address *list = NULL;
+unsigned n_list = 0;
+
+struct ifaddrs *ifa = NULL;
+int r = 1;
+struct ifaddrs *i;
+int ifindex = 0;
+
+if (getifaddrs(&ifa) == -1) { 
+r = -errno;
+goto finish;
+}
+
+

Bug#630206: libnss-myhostname: FTBFS: fatal error: asm/types.h: No such file or directory

2011-06-14 Thread Lennart Poettering
On Tue, 14.06.11 17:49, Robert Millan (r...@debian.org) wrote:

> 2011/6/13 Lennart Poettering :
> >> +#ifdef __linux__
> >> +#include "netlink.c"
> >> +#else
> >> +#include "legacy.c"
> >> +#endif
> >
> > Urks, no. Please do this in Makefile.am.
> 
> Tried that, but it's a no-go.  Automake doesn't support
> build time substitutions in _SOURCES AFAICT (its maintainers
> seem to confirm this in
> http://lists.gnu.org/archive/html/automake/2008-08/msg00047.html)

Uh? No. Please use autoconf conditions and then do

if LEGACY
foo_SOURCES += legacy.c
else
foo_SOURCES += netlink.c
endif

In the Makefile.am file.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.



-- 
To UNSUBSCRIBE, email to debian-bugs-rc-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#630206: libnss-myhostname: FTBFS: fatal error: asm/types.h: No such file or directory

2011-06-14 Thread Robert Millan
2011/6/14 Lennart Poettering :
> if LEGACY
> foo_SOURCES += legacy.c
> else
> foo_SOURCES += netlink.c
> endif
>
> In the Makefile.am file.

Here.

-- 
Robert Millan
commit b930121bdba9981762b84f77226b221453226390
Author: Robert Millan 
Date:   Tue Jun 14 23:00:06 2011 +0200

Use legacy getifaddrs() on GNU/kFreeBSD.

diff --git a/Makefile.am b/Makefile.am
index 7f2f3a3..f82b8d4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -43,8 +43,13 @@ homepage: all dist
 
 libnss_myhostname_la_SOURCES = \
nss-myhostname.c \
-   netlink.c \
-   netlink.h
+   ifconf.h
+
+if LEGACY
+libnss_myhostname_la_SOURCES += legacy.c
+else
+libnss_myhostname_la_SOURCES += netlink.c
+endif
 
 libnss_myhostname_la_LDFLAGS = \
-avoid-version \
diff --git a/configure.ac b/configure.ac
index 38cd58f..30ebc44 100644
--- a/configure.ac
+++ b/configure.ac
@@ -33,6 +33,13 @@ AC_SUBST(PACKAGE_URL, 
[http://0pointer.de/lennart/projects/nss-myhostname/])
 
 ac_default_prefix="/"
 
+AC_CANONICAL_HOST
+case "$host_os" in
+   linux*) legacy=false ;;
+   *)  legacy=true ;;
+esac
+AM_CONDITIONAL([LEGACY], [test x$legacy = xtrue])
+
 # Checks for programs.
 AC_PROG_CC
 AC_PROG_CC_C99
diff --git a/ifconf.h b/ifconf.h
new file mode 100644
index 000..6b2c83f
--- /dev/null
+++ b/ifconf.h
@@ -0,0 +1,74 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+#ifndef fooifconfhfoo
+#define fooifconfhfoo
+
+#include 
+
+/***
+  This file is part of nss-myhostname.
+
+  Copyright 2008-2011 Lennart Poettering
+
+  nss-myhostname is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public License
+  as published by the Free Software Foundation; either version 2.1 of
+  the License, or (at your option) any later version.
+
+  nss-myhostname is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with nss-myhostname; If not, see
+  .
+***/
+
+#include 
+#include 
+#include 
+
+struct address {
+unsigned char family;
+uint8_t address[16];
+unsigned char scope;
+int ifindex;
+};
+
+#define _public_ __attribute__ ((visibility("default")))
+#define _hidden_ __attribute__ ((visibility("hidden")))
+
+int ifconf_acquire_addresses(struct address **_list, unsigned *_n_list) 
_hidden_;
+
+static inline size_t PROTO_ADDRESS_SIZE(int proto) {
+assert(proto == AF_INET || proto == AF_INET6);
+
+return proto == AF_INET6 ? 16 : 4;
+}
+
+static inline int address_compare(const void *_a, const void *_b) {
+const struct address *a = _a, *b = _b;
+
+/* Order lowest scope first, IPv4 before IPv6, lowest interface index 
first */
+
+if (a->scope < b->scope)
+return -1;
+if (a->scope > b->scope)
+return 1;
+
+if (a->family == AF_INET && b->family == AF_INET6)
+return -1;
+if (a->family == AF_INET6 && b->family == AF_INET)
+return 1;
+
+if (a->ifindex < b->ifindex)
+return -1;
+if (a->ifindex > b->ifindex)
+return 1;
+
+return 0;
+}
+
+
+#endif
diff --git a/legacy.c b/legacy.c
new file mode 100644
index 000..8e705c7
--- /dev/null
+++ b/legacy.c
@@ -0,0 +1,94 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+  This file is part of nss-myhostname.
+
+  Copyright 2008-2011 Lennart Poettering
+  Copyright 2011 Robert millan
+
+  nss-myhostname is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public License
+  as published by the Free Software Foundation; either version 2.1 of
+  the License, or (at your option) any later version.
+
+  nss-myhostname is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with nss-myhostname; If not, see
+  .
+***/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "ifconf.h"
+
+int ifconf_acquire_addresses(struct address **_list, unsigned *_n_list) {
+
+struct address *list = NULL;
+unsigned n_list = 0;
+
+struct ifaddrs *ifa = NULL;
+int r = 1;
+struct ifaddrs *i;
+int ifindex = 0;
+
+if (getifaddrs(&ifa) == -1) { 
+r = -errno;
+goto finish;
+}
+
+for (i = ifa; i != NULL; i = i->ifa_next) {
+int af;
+const v

Bug#630206: libnss-myhostname: FTBFS: fatal error: asm/types.h: No such file or directory

2011-06-14 Thread Ed Maste
On Mon, Jun 13, 2011 at 09:11:41AM +0200, Lennart Poettering wrote:

> Nah, I will not work on this. Netlink is Linux specific -- it cannot be
> made on the legacy kernels, and I don't care for the legacy kernels
> anyway and won't spend time on them.

At the BSDCan conference last month we had some early discussions on
the limitations to routing sockets and potential successors to them,
and the topic of implementing Netlink came up.  There is no specific
plan for this at the present time, but it may be the eventual solution
to issues such as this one.

Regards,
Ed



-- 
To UNSUBSCRIBE, email to debian-bugs-rc-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#630206: libnss-myhostname: FTBFS: fatal error: asm/types.h: No such file or directory

2011-06-15 Thread Lennart Poettering
On Tue, 14.06.11 23:01, Robert Millan (r...@debian.org) wrote:

> 2011/6/14 Lennart Poettering :
> > if LEGACY
> > foo_SOURCES += legacy.c
> > else
> > foo_SOURCES += netlink.c
> > endif
> >
> > In the Makefile.am file.
> 
> Here.

I have commited this now, though I am pretty sure this is actually
broken. You cannot just go and make up ifindexes. You need to determine
the kernel ifindexes for your interfaces. You probably simply need to
call if_nametoindex() on all ifa_name fields.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.



-- 
To UNSUBSCRIBE, email to debian-bugs-rc-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#630206: libnss-myhostname: FTBFS: fatal error: asm/types.h: No such file or directory

2011-06-16 Thread Robert Millan
2011/6/15 Lennart Poettering :
> I have commited this now, though I am pretty sure this is actually
> broken. You cannot just go and make up ifindexes. You need to determine
> the kernel ifindexes for your interfaces. You probably simply need to
> call if_nametoindex() on all ifa_name fields.

In my tests I didn't observe any ill effects.  What is this needed for?

-- 
Robert Millan



-- 
To UNSUBSCRIBE, email to debian-bugs-rc-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#630206: libnss-myhostname: FTBFS: fatal error: asm/types.h: No such file or directory

2011-06-16 Thread Lennart Poettering
On Thu, 16.06.11 10:59, Robert Millan (r...@debian.org) wrote:

> 
> 2011/6/15 Lennart Poettering :
> > I have commited this now, though I am pretty sure this is actually
> > broken. You cannot just go and make up ifindexes. You need to determine
> > the kernel ifindexes for your interfaces. You probably simply need to
> > call if_nametoindex() on all ifa_name fields.
> 
> In my tests I didn't observe any ill effects.  What is this needed for?

It's used all over the place. For example on IPv6 the ifindex is
required to make link-local addresses usable. (i.e. a link-local address
is private to a specific link, hence you need to specify the link
explicitly by means of the ifindex it is behind, which normally happens
automatically if you use getaddrinfo() but will not work for you.)

Also quite a few other APIs use ifindexes, for example the mcast APIs,
or IP_PKTINFO or IP_RECVINTERFACE or IPV6_PKTINFO or IP_MULTICAST_IF.

In general it is smart never to deal with interface names internally in
apps, but use ifindexes instead, since names can be changed dynamically,
and indexes are fixed during the entire existance of an
interface. interface names should only be use in user configuration and
for presentation purposes. (i.e. on the way in our out of a process, but
not in the process itself).

So, in short: you are at least breaking mcast, breaking link-local
addressing and matching up of addresses with packets right now. And
there's probably a lot more.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.



-- 
To UNSUBSCRIBE, email to debian-bugs-rc-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#630206: libnss-myhostname: FTBFS: fatal error: asm/types.h: No such file or directory

2011-06-17 Thread Joachim Breitner
Hi,

Am Dienstag, den 14.06.2011, 23:01 +0200 schrieb Robert Millan:
> 2011/6/14 Lennart Poettering :
> > if LEGACY
> > foo_SOURCES += legacy.c
> > else
> > foo_SOURCES += netlink.c
> > endif
> >
> > In the Makefile.am file.
> 
> Here.

I have applied and uploaded this patch to the Debian package. If there
will be a better patch that addresses the ifindex issue, I’ll be happy
to apply that as well.

BTW, Lennart, I am also applying the attached patch because
HOST_NAME_MAX does not always exist. If you could include that patch in
the next version as well, that would be great, as it further reduces the
difference to the Debian version.

Greetings,
Joachim

-- 
Joachim "nomeata" Breitner
Debian Developer
  nome...@debian.org | ICQ# 74513189 | GPG-Keyid: 4743206C
  JID: nome...@joachim-breitner.de | http://people.debian.org/~nomeata
From 818479cdd74dd257bf53d013c03aa404ed47331b Mon Sep 17 00:00:00 2001
From: Joachim Breitner 
Date: Fri, 4 Jun 2010 11:27:46 +0200
Subject: Fix building on kFreeBSD (MAX_HOST_NAME)

---
 configure.ac |   10 ++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/configure.ac b/configure.ac
index 38cd58f..a766d7a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -69,6 +69,16 @@ AC_FUNC_MALLOC
 AC_FUNC_SELECT_ARGTYPES
 AC_CHECK_FUNCS([gethostbyaddr gethostbyname gettimeofday inet_ntoa memset select socket strcspn strdup strerror strncasecmp strcasecmp strspn])
 
+# HOST_NAME_MAX not available on BSD-Kernels
+# first call to AC_CHECK_DECL can not be nested, thus add a dummy call here
+AC_CHECK_DECL(DUMMY,[],[])
+AC_CHECK_DECL(HOST_NAME_MAX,[],
+ AC_CHECK_DECL(_POSIX_HOST_NAME_MAX,
+ AC_DEFINE(HOST_NAME_MAX, _POSIX_HOST_NAME_MAX, []),
+  AC_DEFINE(HOST_NAME_MAX, 256, [Define to 256 if neither have HOST_NAME_MAX nor _POSIX_HOST_NAME_MAX]),
+  [[#include ]]),
+[[#include ]])
+
 # LYNX documentation generation
 ZP_LYNX_DOC
 
-- 
1.7.5.4



signature.asc
Description: This is a digitally signed message part


Bug#630206: libnss-myhostname: FTBFS: fatal error: asm/types.h: No such file or directory

2011-06-17 Thread Robert Millan
2011/6/17 Joachim Breitner :
> I have applied and uploaded this patch to the Debian package. If there
> will be a better patch that addresses the ifindex issue, I’ll be happy
> to apply that as well.

Thanks Joachim.  I may have a look at improving this, though not right now.

> BTW, Lennart, I am also applying the attached patch because
> HOST_NAME_MAX does not always exist. If you could include that patch in
> the next version as well, that would be great, as it further reduces the
> difference to the Debian version.

GNU/kFreeBSD has MAXHOSTNAMELEN, so you could just use this
macro if HOST_NAME_MAX isn't defined.  Please don't hardcode such
limits unnecessarily.

-- 
Robert Millan



--
To UNSUBSCRIBE, email to debian-bugs-rc-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#630206: libnss-myhostname: FTBFS: fatal error: asm/types.h: No such file or directory

2011-06-17 Thread Robert Millan
2011/6/17 Robert Millan :
>> BTW, Lennart, I am also applying the attached patch because
>> HOST_NAME_MAX does not always exist. If you could include that patch in
>> the next version as well, that would be great, as it further reduces the
>> difference to the Debian version.
>
> GNU/kFreeBSD has MAXHOSTNAMELEN, so you could just use this
> macro if HOST_NAME_MAX isn't defined.

Or just wait for HOST_NAME_MAX instead:

http://anonscm.debian.org/viewvc/glibc-bsd/trunk/glibc-ports/kfreebsd/bits/local_lim.h?r1=1685&r2=3460&view=patch

-- 
Robert Millan



-- 
To UNSUBSCRIBE, email to debian-bugs-rc-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#630206: libnss-myhostname: FTBFS: fatal error: asm/types.h: No such file or directory

2011-06-17 Thread Lennart Poettering
On Fri, 17.06.11 09:56, Joachim Breitner (nome...@debian.org) wrote:

> Hi,
> 
> Am Dienstag, den 14.06.2011, 23:01 +0200 schrieb Robert Millan:
> > 2011/6/14 Lennart Poettering :
> > > if LEGACY
> > > foo_SOURCES += legacy.c
> > > else
> > > foo_SOURCES += netlink.c
> > > endif
> > >
> > > In the Makefile.am file.
> > 
> > Here.
> 
> I have applied and uploaded this patch to the Debian package. If there
> will be a better patch that addresses the ifindex issue, I’ll be happy
> to apply that as well.

Hmpf. If you don't fix it nobody will.

When I merged this I kinda expected you'd be providing a follow-up patch
to fix this.

I am not sure I want to leave it in like this, because I'll take the
blame for this. Hence, I will revert the patch before the next release
if this is not fixed properly.

> BTW, Lennart, I am also applying the attached patch because
> HOST_NAME_MAX does not always exist. If you could include that patch in
> the next version as well, that would be great, as it further reduces the
> difference to the Debian version.

Ah, one of those Hurd "features". How useless...

Lennart

-- 
Lennart Poettering - Red Hat, Inc.



--
To UNSUBSCRIBE, email to debian-bugs-rc-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#630206: libnss-myhostname: FTBFS: fatal error: asm/types.h: No such file or directory

2011-06-17 Thread Lennart Poettering
On Fri, 17.06.11 11:16, Robert Millan (r...@debian.org) wrote:

> 
> 2011/6/17 Joachim Breitner :
> > I have applied and uploaded this patch to the Debian package. If there
> > will be a better patch that addresses the ifindex issue, I’ll be happy
> > to apply that as well.
> 
> Thanks Joachim.  I may have a look at improving this, though not right now.
> 
> > BTW, Lennart, I am also applying the attached patch because
> > HOST_NAME_MAX does not always exist. If you could include that patch in
> > the next version as well, that would be great, as it further reduces the
> > difference to the Debian version.
> 
> GNU/kFreeBSD has MAXHOSTNAMELEN, so you could just use this
> macro if HOST_NAME_MAX isn't defined.  Please don't hardcode such
> limits unnecessarily.

Is there any good reason why kfreebsd does not set HOST_NAME_MAX but
MAXHOSTNAMELEN? Or is it just to annoy people and to litter other
people's code with ifdef orgies?

HOST_NAME_MAX is POSIX, so I see really no reason to add some compat
kludgery, for MAXHOSTNAMELEN.

http://pubs.opengroup.org/onlinepubs/009695399/basedefs/limits.h.html

Fix your glibc first. And if there's a really good reason not to, then
at least supply me with a patch, because otherwise I don't care.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.



--
To UNSUBSCRIBE, email to debian-bugs-rc-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#630206: libnss-myhostname: FTBFS: fatal error: asm/types.h: No such file or directory

2011-06-17 Thread Robert Millan
2011/6/17 Lennart Poettering :
> Is there any good reason why kfreebsd does not set HOST_NAME_MAX but
> MAXHOSTNAMELEN?

No.

> Fix your glibc first.

I just did.  See my last mail.

-- 
Robert Millan



-- 
To UNSUBSCRIBE, email to debian-bugs-rc-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Bug#630206: libnss-myhostname: FTBFS: fatal error: asm/types.h: No such file or directory

2011-06-17 Thread Robert Millan
2011/6/17 Lennart Poettering :
>> I have applied and uploaded this patch to the Debian package. If there
>> will be a better patch that addresses the ifindex issue, I’ll be happy
>> to apply that as well.
>
> Hmpf. If you don't fix it nobody will.
>
> When I merged this I kinda expected you'd be providing a follow-up patch
> to fix this.

I may have time later to revisit this (unless someone beats me to it).  In
the meantime a patch that basically works is available.

> I am not sure I want to leave it in like this, because I'll take the
> blame for this. Hence, I will revert the patch before the next release
> if this is not fixed properly.

Understood.

-- 
Robert Millan



--
To UNSUBSCRIBE, email to debian-bugs-rc-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org



Processed: Re: Bug#630206: libnss-myhostname: FTBFS: fatal error: asm/types.h: No such file or directory

2011-06-13 Thread Debian Bug Tracking System
Processing commands for cont...@bugs.debian.org:

> tags 630206 patch
Bug #630206 [src:libnss-myhostname] libnss-myhostname: FTBFS: fatal error: 
asm/types.h: No such file or directory
Added tag(s) patch.
> thanks
Stopping processing here.

Please contact me if you need assistance.
-- 
630206: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=630206
Debian Bug Tracking System
Contact ow...@bugs.debian.org with problems


-- 
To UNSUBSCRIBE, email to debian-bugs-rc-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org