Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed pkcs11-register defaults on macOS and Windows #3053

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
17 changes: 16 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ environment:
PATH: C:\cygwin\bin;%PATH%
OPENPACE_VER: 1.1.3
ZLIB_VER_DOT: 1.2.12
GENGETOPT_VER: 2.23
matrix:
# not compatible with OpenSSL 1.1.1:
# - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
Expand Down Expand Up @@ -62,6 +63,12 @@ install:
If (!(Test-Path cpdksetup.exe )) {
appveyor DownloadFile "https://download.microsoft.com/download/1/7/6/176909B0-50F2-4DF3-B29B-830A17EA7E38/CPDK_RELEASE_UPDATE/cpdksetup.exe"
}
- ps: >-
If (!(Test-Path C:\gengetopt )) {
appveyor DownloadFile "https://ftp.gnu.org/gnu/gengetopt/gengetopt-${env:GENGETOPT_VER}.tar.xz" -FileName gengetopt.tar.xz
tar xJf gengetopt.tar.xz
Rename-Item -path "gengetopt-${env:GENGETOPT_VER}" -newName "c:\gengetopt"
}
- echo "Using %APPVEYOR_BUILD_WORKER_IMAGE% with %VCVARSALL%"
- call "%VCVARSALL%" %Platform%
- cpdksetup.exe /quiet
Expand Down Expand Up @@ -94,13 +101,20 @@ build_script:
}
$env:NMAKE_EXTRA+=" OPENPACE_DEF=/DENABLE_OPENPACE OPENPACE_DIR=C:\openpace-${env:OPENSSL_PF}"
}
If (!(Test-Path -Path "C:\gengetopt\gengetopt" )) {
cd C:\gengetopt
bash -c "exec 0</dev/null && ./configure --prefix=/ || cat config.log"
bash -c "exec 0</dev/null && make"
cd ${env:APPVEYOR_BUILD_FOLDER}
}
- bash -c "exec 0</dev/null && if [ \"$APPVEYOR_REPO_BRANCH\" == \"master\" -a -z \"$APPVEYOR_PULL_REQUEST_NUMBER\" ]; then ./bootstrap; fi"
- bash -c "exec 0</dev/null && if [ \"$APPVEYOR_REPO_BRANCH\" == \"master\" -a -n \"$APPVEYOR_PULL_REQUEST_NUMBER\" ]; then ./bootstrap.ci -s \"-pr$APPVEYOR_PULL_REQUEST_NUMBER\"; fi"
- bash -c "exec 0</dev/null && if [ \"$APPVEYOR_REPO_BRANCH\" != \"master\" -a -z \"$APPVEYOR_PULL_REQUEST_NUMBER\" ]; then ./bootstrap.ci -s \"-$APPVEYOR_REPO_BRANCH\"; fi"
- bash -c "exec 0</dev/null && if [ \"$APPVEYOR_REPO_BRANCH\" != \"master\" -a -n \"$APPVEYOR_PULL_REQUEST_NUMBER\" ]; then ./bootstrap.ci -s \"-$APPVEYOR_REPO_BRANCH-prAPPVEYOR_PULL_REQUEST_NUMBER\"; fi"
# disable features to speed up the script
- bash -c "exec 0</dev/null && ./configure --with-cygwin-native --disable-openssl --disable-readline --disable-zlib || cat config.log"
- bash -c "exec 0</dev/null && ./configure --with-cygwin-native --disable-openssl --disable-readline --disable-zlib GENGETOPT=/cygdrive/c/gengetopt/src/gengetopt --enable-cvcdir='%PROGRAMFILES%/OpenSC Project/OpenSC/cvc' --enable-x509dir='%PROGRAMFILES%/OpenSC Project/OpenSC/x509' || cat config.log"
- bash -c "exec 0</dev/null && rm src/getopt.h"
- bash -c "exec 0</dev/null && make cmdline -C src/tools"
- nmake /f Makefile.mak %NMAKE_EXTRA%
- cd win32 && nmake /nologo /f Makefile.mak %NMAKE_EXTRA% OpenSC.msi && cd ..
- move win32\OpenSC.msi %ARTIFACT%.msi
Expand Down Expand Up @@ -130,4 +144,5 @@ cache:
- C:\openpace -> .appveyor.yml
- C:\openpace-Win32 -> .appveyor.yml
- C:\openpace-Win64 -> .appveyor.yml
- C:\gengetopt -> .appveyor.yml
- cpdksetup.exe -> .appveyor.yml
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ tags
test-driver
.deps
.libs
.dirstamp
.#*#
.*.bak
.*.orig
Expand Down Expand Up @@ -59,6 +60,8 @@ test-driver
*.exp
*.res
*.ggo
*-cmdline.c
*-cmdline.h
ChangeLog

doc/tools/*-tool
Expand Down
4 changes: 4 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ AX_CODE_COVERAGE()

AX_CHECK_COMPILE_FLAG([-Wunknown-warning-option], [have_unknown_warning_option="yes"], [have_unknown_warning_option="no"])
AM_CONDITIONAL([HAVE_UNKNOWN_WARNING_OPTION], [test "${have_unknown_warning_option}" = "yes"])
AX_CHECK_COMPILE_FLAG([-Wshorten-64-to-32], [have_shorten_warning_option="yes"], [have_shorten_warning_option="no"])
AM_CONDITIONAL([HAVE_SHORTEN_WARNING_OPTION], [test "${have_shorten_warning_option}" = "yes"])
Comment on lines +151 to +152
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I mentioned this in some previous comments, given that we have this part of configure, can you remove it from the linux-strict build?

https://github.com/OpenSC/OpenSC/blob/master/.github/workflows/linux-strict.yml#L37

I think you can also remove the line following line altogether:

https://github.com/OpenSC/OpenSC/blob/master/.github/workflows/linux-strict.yml#L72


AX_VALGRIND_CHECK()

Expand Down Expand Up @@ -1013,6 +1015,7 @@ fi
AC_ARG_VAR([GENGETOPT],
[absolute path to gengetopt used for command line parsing of npa-tool])
AC_PATH_PROG(GENGETOPT, gengetopt, not found)
AM_CONDITIONAL([ENABLE_GENGETOPT], [test "${GENGETOPT}" != "not found"])
AC_ARG_VAR([CLANGTIDY],
[absolute path to clang-tidy used for static code analysis])
AC_PATH_PROG(CLANGTIDY, clang-tidy, not found)
Expand Down Expand Up @@ -1250,6 +1253,7 @@ PIV SM support: ${enable_piv_sm}
DNIe UI support: ${enable_dnie_ui}
Notification support: ${enable_notify}
Code coverage: ${enable_code_coverage}
gengetopt: ${GENGETOPT}

PC/SC default provider: ${DEFAULT_PCSC_PROVIDER}
PKCS11 default provider: $(eval eval eval echo "${DEFAULT_PKCS11_PROVIDER}")
Expand Down
1 change: 1 addition & 0 deletions packaging/opensc.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ BuildRequires: docbook-style-xsl
BuildRequires: autoconf automake libtool gcc
BuildRequires: bash-completion
BuildRequires: zlib-devel
BuildRequires: gengetopt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed for the build from the dist tarball? If so, it might be a problem as we do not have the gengetopt in RHEL (only in EPEL).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can build without gengetopt, but obviously OpenSC would not include egk-tool goid-tool opensc-asn1 pkcs11-register, opensc-notify and npa-tool.

# For tests
BuildRequires: libcmocka-devel
BuildRequires: vim-common
Expand Down
89 changes: 65 additions & 24 deletions src/tools/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,42 @@ do_subst = $(SED) \
-e 's,[@]X509DIR[@],$(X509DIR),g'

MAINTAINERCLEANFILES = $(srcdir)/Makefile.in $(srcdir)/versioninfo-tools.rc $(srcdir)/versioninfo-opensc-notify.rc
EXTRA_DIST = Makefile.mak versioninfo-tools.rc.in versioninfo-opensc-notify.rc.in goid-tool.ggo.in npa-tool.ggo.in opensc-notify.ggo.in egk-tool.ggo.in opensc-asn1.ggo.in org.opensc.notify.desktop.in exe.manifest pkcs11-register.desktop.in org.opensc-project.mac.pkcs11-register.plist.in org.opensc-project.mac.opensc-notify.plist.in
EXTRA_DIST = Makefile.mak versioninfo-tools.rc.in versioninfo-opensc-notify.rc.in goid-tool.ggo.in npa-tool.ggo.in opensc-notify.ggo.in egk-tool.ggo.in pkcs11-register.ggo.in opensc-asn1.ggo.in org.opensc.notify.desktop.in exe.manifest pkcs11-register.desktop.in org.opensc-project.mac.pkcs11-register.plist.in org.opensc-project.mac.opensc-notify.plist.in

noinst_HEADERS = util.h fread_to_eof.h \
egk-tool-cmdline.h goid-tool-cmdline.h npa-tool-cmdline.h \
opensc-asn1-cmdline.h opensc-notify-cmdline.h pkcs11-register-cmdline.h \
openpgp-tool-helpers.h
bin_PROGRAMS = opensc-tool opensc-explorer opensc-asn1 \
pkcs15-tool pkcs15-crypt pkcs11-tool pkcs11-register \
cardos-tool eidenv openpgp-tool iasecc-tool egk-tool goid-tool \
bin_PROGRAMS = opensc-tool opensc-explorer \
pkcs15-tool pkcs15-crypt pkcs11-tool \
cardos-tool eidenv openpgp-tool iasecc-tool \
dtrust-tool
if ENABLE_OPENSSL
bin_PROGRAMS += cryptoflex-tool pkcs15-init netkey-tool piv-tool \
westcos-tool sc-hsm-tool dnie-tool gids-tool
endif

if ENABLE_GENGETOPT
bin_PROGRAMS += egk-tool goid-tool opensc-asn1 pkcs11-register

if ENABLE_NOTIFY
bin_PROGRAMS += opensc-notify
endif
Comment on lines +38 to +43
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move these two blocks below the if ENABLE_OPENSSL to avoid closing and opening the ENABLE_OPENSSL block before and after this?


if ENABLE_OPENSSL
if ENABLE_OPENPACE
bin_PROGRAMS += npa-tool
endif
endif

if ENABLE_NOTIFY
bin_PROGRAMS += opensc-notify
%-cmdline.c: %.ggo.in
$(AM_V_GEN)f="$@"; $(do_subst) < "$<" | $(GENGETOPT) --file-name="$${f%.c}" --output-dir=$(builddir)
opensc-asn1-cmdline.c: opensc-asn1.ggo.in
$(AM_V_GEN)$(do_subst) < "$<" | $(GENGETOPT) --file-name="opensc-asn1-cmdline" --output-dir=$(builddir) --unamed-opts
egk-tool.c: egk-tool-cmdline.c
goid-tool.c: goid-tool-cmdline.c
opensc-asn1.c: opensc-asn1-cmdline.c
pkcs11-register.c: pkcs11-register-cmdline.c
npa-tool.c: npa-tool-cmdline.c
opensc-notify.c: opensc-notify-cmdline.c
endif

if ENABLE_OPENPACE
Expand Down Expand Up @@ -101,51 +117,76 @@ dnie_tool_LDADD = $(OPTIONAL_OPENSSL_LIBS)
gids_tool_SOURCES = gids-tool.c util.c
gids_tool_LDADD = $(OPTIONAL_OPENSSL_LIBS)

npa_tool_SOURCES = npa-tool.c fread_to_eof.c util.c npa-tool-cmdline.c
npa_tool_SOURCES = npa-tool.c fread_to_eof.c util.c
nodist_npa_tool_SOURCES = npa-tool-cmdline.c
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be nodist? I would say that we should generate these files during dist and include them in the release tarball, similarly as we include the configure.

npa_tool_LDADD = $(OPTIONAL_OPENSSL_LIBS) $(OPENPACE_LIBS)
npa_tool_CFLAGS = $(OPTIONAL_OPENSSL_CFLAGS) $(OPENPACE_CFLAGS)
npa_tool_CFLAGS = -I$(abs_builddir) $(OPTIONAL_OPENSSL_CFLAGS) $(OPENPACE_CFLAGS)
if HAVE_UNKNOWN_WARNING_OPTION
npa_tool_CFLAGS += -Wno-unknown-warning-option
endif
if HAVE_SHORTEN_WARNING_OPTION
npa_tool_CFLAGS += -Wno-shorten-64-to-32
endif

opensc_notify_SOURCES = opensc-notify.c opensc-notify-cmdline.c
opensc_notify_CFLAGS = $(PTHREAD_CFLAGS)
opensc_notify_SOURCES = opensc-notify.c
nodist_opensc_notify_SOURCES = opensc-notify-cmdline.c
opensc_notify_CFLAGS = -I$(abs_builddir) $(PTHREAD_CFLAGS)
if HAVE_UNKNOWN_WARNING_OPTION
opensc_notify_CFLAGS += -Wno-unknown-warning-option
endif
if HAVE_SHORTEN_WARNING_OPTION
opensc_notify_CFLAGS += -Wno-shorten-64-to-32
endif

egk_tool_SOURCES = egk-tool.c util.c egk-tool-cmdline.c
egk_tool_SOURCES = egk-tool.c util.c
nodist_egk_tool_SOURCES = egk-tool-cmdline.c
egk_tool_LDADD = $(OPTIONAL_ZLIB_LIBS)
egk_tool_CFLAGS = $(OPTIONAL_ZLIB_CFLAGS)
egk_tool_CFLAGS = -I$(abs_builddir) $(OPTIONAL_ZLIB_CFLAGS)
if HAVE_UNKNOWN_WARNING_OPTION
egk_tool_CFLAGS += -Wno-unknown-warning-option
endif
if HAVE_SHORTEN_WARNING_OPTION
egk_tool_CFLAGS += -Wno-shorten-64-to-32
endif

goid_tool_SOURCES = goid-tool.c util.c fread_to_eof.c goid-tool-cmdline.c
goid_tool_SOURCES = goid-tool.c util.c fread_to_eof.c
nodist_goid_tool_SOURCES = goid-tool-cmdline.c
goid_tool_LDADD = $(OPENPACE_LIBS)
goid_tool_CFLAGS = $(OPENPACE_CFLAGS)
goid_tool_CFLAGS = -I$(abs_builddir) $(OPENPACE_CFLAGS)
if HAVE_UNKNOWN_WARNING_OPTION
goid_tool_CFLAGS += -Wno-unknown-warning-option
endif
if HAVE_SHORTEN_WARNING_OPTION
goid_tool_CFLAGS += -Wno-shorten-64-to-32
endif

dtrust_tool_SOURCES = dtrust-tool.c util.c

opensc_asn1_SOURCES = opensc-asn1.c fread_to_eof.c opensc-asn1-cmdline.c
opensc_asn1_SOURCES = opensc-asn1.c fread_to_eof.c
nodist_opensc_asn1_SOURCES = opensc-asn1-cmdline.c
opensc_asn1_CFLAGS = -I$(abs_builddir)
if HAVE_UNKNOWN_WARNING_OPTION
opensc_asn1_CFLAGS = -Wno-unknown-warning-option
opensc_asn1_CFLAGS += -Wno-unknown-warning-option
endif
if HAVE_SHORTEN_WARNING_OPTION
opensc_asn1_CFLAGS += -Wno-shorten-64-to-32
endif

pkcs11_register_SOURCES = pkcs11-register.c fread_to_eof.c pkcs11-register-cmdline.c
pkcs11_register_SOURCES = pkcs11-register.c fread_to_eof.c
nodist_pkcs11_register_SOURCES = pkcs11-register-cmdline.c
pkcs11_register_LDADD = $(top_builddir)/src/common/libpkcs11.la
pkcs11_register_CFLAGS = -I$(abs_builddir)
if HAVE_UNKNOWN_WARNING_OPTION
pkcs11_register_CFLAGS = -Wno-unknown-warning-option
pkcs11_register_CFLAGS += -Wno-unknown-warning-option
endif
if HAVE_SHORTEN_WARNING_OPTION
pkcs11_register_CFLAGS += -Wno-shorten-64-to-32
endif

.PHONY: cmdline
cmdline:
@for f in *.ggo.in; do $(do_subst) < "$$f" > "$${f%.in}"; done
@for f in *.ggo; do $(GENGETOPT) --file-name="$${f%.ggo}-cmdline" --output-dir=$(builddir) < "$$f"; done
$(AM_V_GEN)$(GENGETOPT) --file-name=opensc-asn1-cmdline --output-dir=$(builddir) --unamed-opts < opensc-asn1.ggo
@for f in *.ggo.in; do $(do_subst) < "$$f" | $(GENGETOPT) --file-name="$${f%.ggo.in}-cmdline" --output-dir=$(builddir); done
$(AM_V_GEN)$(do_subst) < "opensc-asn1.ggo.in" | $(GENGETOPT) --file-name=opensc-asn1-cmdline --output-dir=$(builddir) --unamed-opts

if WIN32
LIBS += -lshlwapi
Expand Down Expand Up @@ -186,4 +227,4 @@ noinst_DATA = org.opensc-project.mac.pkcs11-register.plist org.opensc-project.ma
$(AM_V_GEN)$(do_subst) < $< > $@

clean-local:
rm -f $(abs_builddir)/npa-tool.ggo $(abs_builddir)/opensc-notify.ggo $(abs_builddir)/opensc-asn1.ggo $(abs_builddir)/goid-tool.ggo $(abs_builddir)/egk-tool.ggo org.opensc.notify.desktop pkcs11-register.desktop org.opensc-project.mac.opensc-notify.plist org.opensc-project.mac.pkcs11-register.plist
rm -f $(abs_builddir)/npa-tool.ggo $(abs_builddir)/opensc-notify.ggo $(abs_builddir)/opensc-asn1.ggo $(abs_builddir)/goid-tool.ggo $(abs_builddir)/egk-tool.ggo $(abs_builddir)/*cmdline* org.opensc.notify.desktop pkcs11-register.desktop org.opensc-project.mac.opensc-notify.plist org.opensc-project.mac.pkcs11-register.plist
2 changes: 1 addition & 1 deletion src/tools/Makefile.mak
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ default: all

TARGETS = opensc-tool.exe opensc-explorer.exe pkcs15-tool.exe pkcs15-crypt.exe \
pkcs11-tool.exe cardos-tool.exe eidenv.exe openpgp-tool.exe iasecc-tool.exe \
opensc-notify.exe egk-tool.exe goid-tool.exe dtrust-tool paccess-tool.exe \
opensc-notify.exe egk-tool.exe goid-tool.exe dtrust-tool.exe \
opensc-asn1.exe pkcs11-register.exe $(PROGRAMS_OPENSSL) $(PROGRAMS_OPENPACE)

OBJECTS = util.obj versioninfo-tools.res
Expand Down