Skip to content
This repository has been archived by the owner on Oct 14, 2020. It is now read-only.

compilation of programs using libu2f-host fails: pkg-config file inconsistent with includes in public u2f-host.h header #13

Closed
stapelberg opened this issue Dec 24, 2014 · 8 comments

Comments

@stapelberg
Copy link

u2f-host/u2f-host.pc.in contains

Cflags: -I${includedir}/u2f-host

Therefore, running pkg-config --cflags results in:

$ pkg-config --cflags u2f-host       
-I/usr/local/include/u2f-host 

This means I need to use #include <u2f-host.h> in my program. However, the file /usr/local/include/u2f-host/u2f-host.h itself contains:

$ grep '^#include' /usr/local/include/u2f-host/u2f-host.h
#include <stdint.h>
#include <string.h>
#include <u2f-host/u2f-host-version.h>
#include <u2f-host/u2f-host-types.h>

…which fails, because the include path already contains the u2f-host directory, so the compiler is looking for the non-existant /usr/local/include/u2f-host/u2f-host/u2f-host-version.h file.

There are two ways to fix this:

  1. Change all includes to not use the u2f-host/ prefix, e.g. with sed -i -e 's,#include <u2f-host/,#include <,g' **/*.[ch]. This approach also requires changing the AM_CPPFLAGS line in src/Makefile.am to read AM_CPPFLAGS=-I$(top_srcdir) -I$(top_srcdir)/u2f-host -I$(top_builddir)
  2. Change the pkg-config file to use Cflags: -I${includedir} (stripping the u2f-host suffix). This will require changes in all downstream programs unless you also ship a compatibility u2f-host.h file in ${includedir} which includes u2f-host/u2f-host.h.

Not sure which approach you want to pursue, but the first one seems cleaner to me :).

Thanks!

@copumpkin
Copy link

👍

I'm also hoping to get https://lists.mindrot.org/pipermail/openssh-unix-dev/2014-December/033273.html off the ground 😄

@klali klali closed this as completed in b343e93 Aug 27, 2015
@katodev
Copy link

katodev commented Sep 4, 2015

Something went wrong with this fix.
I can't compile pam-u2f now and get this error:

/usr/include/u2f-host/u2f-host.h:24:30: fatal error: u2f-host-version.h: No such file or directory
#include <u2f-host-version.h>
^
compilation terminated.

@klali
Copy link
Member

klali commented Sep 4, 2015

I can't reproduce problems with this fix.
For me pam-u2f compile fine with this version of libu2f-host (and so does the travis build of pam-u2f). How did you install libu2f-host? can you configure pam-u2f with --disable-silent-rules and paste the line it's running when getting the error?

@Ikke
Copy link

Ikke commented Oct 4, 2015

I have the same kind of error:

libtool: compile: gcc -DDEBUG_PAM -DPAM_DEBUG -DPACKAGE_NAME="pam_u2f" -DPACKAGE_TARNAME="pam_u2f" -DPACKAGE_VERSION="1.0.1" "-DPACKAGE_STRING="pam_u2f 1.0.1"" -DPACKAGE_BUGREPORT="yubico-devel@googlegroups.com" -DPACKAGE_URL="" -DPACKAGE="pam_u2f" -DVERSION="1.0.1" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=".libs/" -DHAVE_SECURITY_PAM_APPL_H=1 -DHAVE_SECURITY_PAM_MODULES_H=1 -DHAVE_SECURITY__PAM_MACROS_H=1 -DHAVE_SECURITY_PAM_MODUTIL_H=1 -DHAVE_LIBPAM=1 -I. -D_FORTIFY_SOURCE=2 -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -MT util.lo -MD -MP -MF .deps/util.Tpo -c util.c -fPIC -DPIC -o .libs/util.o

In file included from util.c:8:0:
/usr/include/u2f-host/u2f-host.h:24:30: fatal error: u2f-host-version.h: No such file or directory

In the Makefile, I do see LIBU2FHOST_CFLAGS = -I/usr/include/u2f-host, but apparently, that's never used.

@klali
Copy link
Member

klali commented Oct 5, 2015

so if I look at that file for pam-u2f LIBU2FHOST_CFLAGS is added to AM_CPPFLAGS and it builds fine for me. Are you running autotools yourself on the project, in that case, what's your automake version? What platform?

@klali
Copy link
Member

klali commented Oct 5, 2015

what is the value of AM_CPPFLAGS in your makefile?

@katodev
Copy link

katodev commented Oct 5, 2015

When I patch u2f-host/u2f-host.h to the full path "#include <u2f-host/u2f-host-..." pam_u2f find the header file.

pam_u2f:
./configure --host=x86_64-suse-linux-gnu --build=x86_64-suse-linux-gnu --program-prefix= --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/lib --localstatedir=/var --sharedstatedir=/usr/com --mandir=/usr/share/man --infodir=/usr/share/info --disable-dependency-tracking --bindir=/usr/bin --with-pam-dir=/lib64/security --disable-static --disable-silent-rules

/bin/sh ./libtool --tag=CC --mode=compile gcc -DDEBUG_PAM -DPAM_DEBUG -DPACKAGE_NAME="pam_u2f" -DPACKAGE_TARNAME="pam_u2f" -DPACKAGE_VERSION="1.0.1" -DPACKAGE_STRING="pam_u2f\ 1.0.1" -DPACKAGE_BUGREPORT="yubico-devel@googlegroups.com" -DPACKAGE_URL="" -DPACKAGE="pam_u2f" -DVERSION="1.0.1" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=".libs/" -DHAVE_SECURITY_PAM_APPL_H=1 -DHAVE_SECURITY_PAM_MODULES_H=1 -DHAVE_SECURITY__PAM_MACROS_H=1 -DHAVE_SECURITY_PAM_MODUTIL_H=1 -DHAVE_LIBPAM=1 -I. -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -c -o pam-u2f.lo pam-u2f.c
[ 104s] /bin/sh ./libtool --tag=CC --mode=compile gcc -DDEBUG_PAM -DPAM_DEBUG -DPACKAGE_NAME="pam_u2f" -DPACKAGE_TARNAME="pam_u2f" -DPACKAGE_VERSION="1.0.1" -DPACKAGE_STRING="pam_u2f\ 1.0.1" -DPACKAGE_BUGREPORT="yubico-devel@googlegroups.com" -DPACKAGE_URL="" -DPACKAGE="pam_u2f" -DVERSION="1.0.1" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=".libs/" -DHAVE_SECURITY_PAM_APPL_H=1 -DHAVE_SECURITY_PAM_MODULES_H=1 -DHAVE_SECURITY__PAM_MACROS_H=1 -DHAVE_SECURITY_PAM_MODUTIL_H=1 -DHAVE_LIBPAM=1 -I. -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -c -o util.lo util.c
[ 104s] libtool: compile: gcc -DDEBUG_PAM -DPAM_DEBUG -DPACKAGE_NAME="pam_u2f" -DPACKAGE_TARNAME="pam_u2f" -DPACKAGE_VERSION="1.0.1" "-DPACKAGE_STRING="pam_u2f 1.0.1"" -DPACKAGE_BUGREPORT="yubico-devel@googlegroups.com" -DPACKAGE_URL="" -DPACKAGE="pam_u2f" -DVERSION="1.0.1" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=".libs/" -DHAVE_SECURITY_PAM_APPL_H=1 -DHAVE_SECURITY_PAM_MODULES_H=1 -DHAVE_SECURITY__PAM_MACROS_H=1 -DHAVE_SECURITY_PAM_MODUTIL_H=1 -DHAVE_LIBPAM=1 -I. -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -c util.c -fPIC -DPIC -o .libs/util.o
[ 104s] libtool: compile: gcc -DDEBUG_PAM -DPAM_DEBUG -DPACKAGE_NAME="pam_u2f" -DPACKAGE_TARNAME="pam_u2f" -DPACKAGE_VERSION="1.0.1" "-DPACKAGE_STRING="pam_u2f 1.0.1"" -DPACKAGE_BUGREPORT="yubico-devel@googlegroups.com" -DPACKAGE_URL="" -DPACKAGE="pam_u2f" -DVERSION="1.0.1" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=".libs/" -DHAVE_SECURITY_PAM_APPL_H=1 -DHAVE_SECURITY_PAM_MODULES_H=1 -DHAVE_SECURITY__PAM_MACROS_H=1 -DHAVE_SECURITY_PAM_MODUTIL_H=1 -DHAVE_LIBPAM=1 -I. -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -c pam-u2f.c -fPIC -DPIC -o .libs/pam-u2f.o
[ 105s] In file included from util.c:8:0:
[ 105s] /usr/include/u2f-host/u2f-host.h:24:30: fatal error: u2f-host-version.h: No such file or directory
[ 105s] #include <u2f-host-version.h>
[ 105s] ^
[ 105s] compilation terminated.

@klali
Copy link
Member

klali commented Oct 6, 2015

So to be clear.. The error here is that pam-u2f fails to add LIBU2FHOST_CFLAGS to the compilation directives. Exactly why this happens is unclear, but seems to be something that occurs with automake 1.15 in some configurations.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

5 participants