nfc-tools / ifdnfc

PC/SC IFD Handler based on libnfc
GNU General Public License v3.0
34 stars 9 forks source link

Adds compatibility with OS X #4

Closed frankmorgner closed 8 years ago

frankmorgner commented 8 years ago

Fixes https://github.com/nfc-tools/ifdnfc/issues/3

I only fixed all compile time issues, but I haven't got the time/readers to test this.

@mouse07410 could you have a look? The configure script guesses the environment, use

./configure PKG_CONFIG_PATH=$LIBFNCPREFIX/lib/pkgconfig
mouse07410 commented 8 years ago

@frankmorgner merge it! It compiles and builds fine. Now - for the actual testing. ;)

(The only exception - for the initial configuration I used the complete shell script provided by Ludovic)

mouse07410 commented 8 years ago

@frankmorgner this config attempt ./configure PKG_CONFIG_PATH=$LIBFNCPREFIX/lib/pkgconfig did not work - it again wasn't able to find winscard.h.

Running Ludovic's config script after your patch, I was able to compile, build, and install ifdnfc.

The problem - after that no reader is detected at all:

$ opensc-tool -l
No smart card readers found.
$

Questions - how to restore the other readers, and how to debug this driver? Update/answer Other readers were recognized again after I removed /usr/libexec/SmartCardServices/drivers/ifdnfc-ccid.bundle and rebooted. Mere removal of that bundle did not restore functionality.

Thanks!

P.S. ifdnfc-activate gives a strange message:

$ /usr/local/bin/ifdnfc-activate status
Could not find a reader named: IFD-NFC
Cannot find a smart card reader.
$
frankmorgner commented 8 years ago

@mouse07410 could you paste or upload config.log with the error of using ./configure?

For debugging smart card reader drivers see http://ludovicrousseau.blogspot.de/2015/02/debug-smart-card-reader-driver-on.html

mouse07410 commented 8 years ago

could you paste or upload config.log with the error of using ./configure?

Certainly:

$ git clone https://github.com/nfc-tools/ifdnfc.git ifdnfc-test
Cloning into 'ifdnfc-test'...
remote: Counting objects: 272, done.
remote: Compressing objects: 100% (93/93), done.
remote: Total 272 (delta 180), reused 267 (delta 175), pack-reused 0
Receiving objects: 100% (272/272), 68.70 KiB | 0 bytes/s, done.
Resolving deltas: 100% (180/180), done.
Checking connectivity... done.
$ cd ifdnfc-test
$ ./configure PKG_CONFIG_PATH=/opt/local/lib/pkgconfig
-bash: ./configure: No such file or directory
$ autoreconf -i
glibtoolize: putting auxiliary files in '.'.
glibtoolize: copying file './ltmain.sh'
glibtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
glibtoolize: copying file 'm4/libtool.m4'
glibtoolize: copying file 'm4/ltoptions.m4'
glibtoolize: copying file 'm4/ltsugar.m4'
glibtoolize: copying file 'm4/ltversion.m4'
glibtoolize: copying file 'm4/lt~obsolete.m4'
configure.ac:10: installing './ar-lib'
configure.ac:10: installing './compile'
configure.ac:11: installing './config.guess'
configure.ac:11: installing './config.sub'
configure.ac:9: installing './install-sh'
configure.ac:9: installing './missing'
Makefile.am: installing './INSTALL'
src/Makefile.am: installing './depcomp'
$ ./configure PKG_CONFIG_PATH=/opt/local/lib/pkgconfig
checking for a BSD-compatible install... /opt/local/bin/ginstall -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /opt/local/bin/gmkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for style of include used by make... GNU
checking for gcc... clang
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether clang accepts -g... yes
checking for clang option to accept ISO C89... none needed
checking whether clang understands -c and -o together... yes
checking dependency style of clang... gcc3
checking for ar... ar
checking the archiver (ar) interface... ar
checking build system type... x86_64-apple-darwin14.5.0
checking host system type... x86_64-apple-darwin14.5.0
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by clang... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
checking if the linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) is GNU ld... no
checking for BSD- or MS-compatible name lister (nm)... /opt/local/bin/nm
checking the name lister (/opt/local/bin/nm) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 196608
checking how to convert x86_64-apple-darwin14.5.0 file names to x86_64-apple-darwin14.5.0 format... func_convert_file_noop
checking how to convert x86_64-apple-darwin14.5.0 file names to toolchain format... func_convert_file_noop
checking for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld option to reload object files... -r
checking for objdump... no
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for archiver @FILE support... no
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /opt/local/bin/nm output from clang object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for lipo... lipo
checking for otool... otool
checking for otool64... no
checking for -single_module linker flag... yes
checking for -exported_symbols_list linker flag... yes
checking for -force_load linker flag... yes
checking how to run the C preprocessor... clang -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if clang supports -fno-rtti -fno-exceptions... yes
checking for clang option to produce PIC... -fno-common -DPIC
checking if clang PIC flag -fno-common -DPIC works... yes
checking if clang static flag -static works... no
checking if clang supports -c -o file.o... yes
checking if clang supports -c -o file.o... (cached) yes
checking whether the clang linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin14.5.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking whether make supports nested variables... (cached) yes
checking whether we are using the GNU C++ compiler... yes
checking whether clang++ accepts -g... yes
checking dependency style of clang++... gcc3
checking how to run the C++ preprocessor... clang++ -E
checking for ld used by clang++... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
checking if the linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) is GNU ld... no
checking whether the clang++ linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... yes
checking for clang++ option to produce PIC... -fno-common -DPIC
checking if clang++ PIC flag -fno-common -DPIC works... yes
checking if clang++ static flag -static works... no
checking if clang++ supports -c -o file.o... yes
checking if clang++ supports -c -o file.o... (cached) yes
checking whether the clang++ linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin14.5.0 dyld
checking how to hardcode library paths into programs... immediate
checking for gawk... (cached) gawk
checking for gcc... (cached) clang
checking whether we are using the GNU C compiler... (cached) yes
checking whether clang accepts -g... (cached) yes
checking for clang option to accept ISO C89... (cached) none needed
checking whether clang understands -c and -o together... (cached) yes
checking dependency style of clang... (cached) gcc3
checking how to run the C preprocessor... clang -E
checking whether ln -s works... yes
checking whether make sets $(MAKE)... (cached) yes
checking for pkg-config... /opt/local/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for LIBNFC... yes
configure: WARNING: libpcsclite > 1.4.102 not found by pkg-config
checking winscard.h usability... no
checking winscard.h presence... no
checking for winscard.h... no
configure: error: winscard.h not found, install libpcsclite > 1.4.102 or use ./configure PCSC_CFLAGS=...
$ 

Regarding debugging - I restarted the ifdreader daemon as per Ludovic's blog, and now the situation is different & better:

$ $ ifdnfc-activate status
IFD-NFC is inactive.
$ ifdnfc-activate yes
Activating ifdnfc with "pn53x_usb:160:013"...
IFD-NFC is active using .
$ opensc-tool -l
# Detected readers (pcsc)
Nr.  Card  Features  Name
0    No              SCM Micro SCL3711 Contactless Reader & NFC
1    Yes             Yubico Yubikey NEO OTP+U2F+CCID
$ pkcs15-tool --reader 0 -c
Card not present.
$ pkcs15-tool --reader 1 -c
X.509 Certificate [Certificate for PIV Authentication]
    Object Flags   : [0x0]
    Authority      : no
    Path           : 
    ID             : 01
.........

And config.log: config.log.txt

frankmorgner commented 8 years ago

you cloned https://github.com/nfc-tools/ifdnfc, but that's not where you merged my PR. That's why ./configure failed.

mouse07410 commented 8 years ago

that's not where you merged my PR

You're right! After (re-)doing it correctly, compile and build succeeds:

......
LIBNFC_CFLAGS:        -I/opt/local/include -I/opt/local/include/libusb-1.0 
LIBNFC_LIBS:          -L/opt/local/lib -lnfc -lusb 
PCSC_CFLAGS:          -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/PCSC.framework/Versions/Current/Headers -DRESPONSECODE_DEFINED_IN_WINTYPES_H -I/Users/ur20980/src/ifdnfc-test//MacOSX
PCSC_LIBS:            -framework PCSC
BUNDLE_HOST:          MacOS
DYN_LIB_EXT:          dylib

checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Info.plist
config.status: creating src/Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
$ make all
/Applications/Xcode.app/Contents/Developer/usr/bin/make  all-recursive
Making all in src
  CC       libifdnfc_la-ifd-nfc.lo
  CC       libifdnfc_la-atr.lo
  CCLD     libifdnfc.la
  CC       ifdnfc_activate-ifdnfc-activate.o
  CCLD     ifdnfc-activate
make[2]: Nothing to be done for `all-am'.
$ 

Now - to the real problems: :-)

$ src/ifdnfc-activate status
IFD-NFC is inactive.
$ src/ifdnfc-activate yes
Activating ifdnfc with "pn53x_usb:160:013"...
IFD-NFC is inactive.
$
frankmorgner commented 8 years ago

I don't currently have the resources to resolve the remaining issue.

mouse07410 commented 8 years ago

@frankmorgner could you perhaps merge this commit? Because whatever else, it makes things better.

frankmorgner commented 8 years ago

@LudovicRousseau, could you?