diff options
| -rw-r--r-- | .dir-locals.el | 3 | ||||
| -rw-r--r-- | common/meson.build | 99 | ||||
| -rw-r--r-- | doc/manual/meson.build | 75 | ||||
| -rw-r--r-- | doc/manual/sysdir.xml.in | 1 | ||||
| -rw-r--r-- | doc/manual/userdir.xml.in | 1 | ||||
| -rw-r--r-- | doc/manual/version.xml.in | 1 | ||||
| -rw-r--r-- | meson.build | 368 | ||||
| -rw-r--r-- | meson_options.txt | 47 | ||||
| -rwxr-xr-x | p11-kit/gen-pkcs11-gnu.sh | 16 | ||||
| -rwxr-xr-x | p11-kit/gen-virtual-fixed.sh | 28 | ||||
| -rw-r--r-- | p11-kit/libp11-kit-0.dll.def | 101 | ||||
| -rw-r--r-- | p11-kit/libp11-kit.map | 105 | ||||
| -rw-r--r-- | p11-kit/meson.build | 299 | ||||
| -rwxr-xr-x | p11-kit/meson_post_install.sh | 15 | ||||
| -rw-r--r-- | p11-kit/pkcs11-gnu.c | 3 | ||||
| -rw-r--r-- | po/meson.build | 1 | ||||
| -rw-r--r-- | trust/meson.build | 162 | 
17 files changed, 1324 insertions, 1 deletions
| diff --git a/.dir-locals.el b/.dir-locals.el index 042381f..7335c23 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -1 +1,2 @@ -((c-mode . ((c-file-style . "linux")))) +((c-mode . ((c-file-style . "linux"))) + (meson-mode . ((indent-tabs-mode . nil)))) diff --git a/common/meson.build b/common/meson.build new file mode 100644 index 0000000..4614bcb --- /dev/null +++ b/common/meson.build @@ -0,0 +1,99 @@ +install_headers('pkcs11.h', 'pkcs11x.h', subdir: 'p11-kit-1/p11-kit') + +libp11_common_sources = [ +  'argv.c', +  'attrs.c', +  'array.c', +  'buffer.c', +  'compat.c', +  'constants.c', +  'debug.c', +  'dict.c', +  'hash.c', +  'lexer.c', +  'message.c', +  'path.c', +  'runtime.c', +  'url.c' +] + +libp11_common = static_library('p11-common', libp11_common_sources, +                               gnu_symbol_visibility: 'hidden', +                               include_directories: configinc) + +libp11_common_dep = declare_dependency(include_directories: [configinc, +                                                             commoninc], +                                       link_with: libp11_common) + +libp11_library = static_library('p11-library', 'library.c', +                                gnu_symbol_visibility: 'hidden', +                                include_directories: configinc) + +libp11_library_dep = declare_dependency(include_directories: [configinc, +                                                              commoninc], +                                        link_with: libp11_library) + +libp11_test_sources = [ +  'mock.c', +  'test.c' +] + +libp11_test = static_library('p11-test', libp11_test_sources, +                             include_directories: configinc) +libp11_test_dep = declare_dependency(include_directories: [configinc, +                                                           commoninc], +                                     link_with: libp11_test) + +libp11_tool_sources = [ +  'tool.c' +] + +if host_system != 'windows' +  libp11_tool_sources += ['unix-peer.c', 'unix-peer.h'] +endif + +libp11_tool = static_library('p11-tool', libp11_tool_sources, +                             include_directories: configinc) +libp11_tool_dep = declare_dependency(include_directories: [configinc, +                                                           commoninc], +                                     link_with: libp11_tool) + +# Tests ---------------------------------------------------------------- + +common_tests = [ +  'test-tests', +  'test-compat', +  'test-hash', +  'test-dict', +  'test-array', +  'test-constants', +  'test-attrs', +  'test-buffer', +  'test-url', +  'test-path', +  'test-lexer', +  'test-message', +  'test-argv', +  'test-runtime' +] + +foreach name : common_tests +  t = executable(name, '@0@.c'.format(name), +                 c_args: tests_c_args, +                 include_directories: configinc, +                 dependencies: dlopen_deps, +                 link_with: [libp11_test, libp11_common]) +  test(name, t) +endforeach + +common_progs = [ +  'frob-getauxval', +  'frob-getenv' +] + +foreach name : common_progs +  executable(name, '@0@.c'.format(name), +             include_directories: configinc, +             dependencies: dlopen_deps, +             link_with: [libp11_common]) +endforeach diff --git a/doc/manual/meson.build b/doc/manual/meson.build new file mode 100644 index 0000000..2214b75 --- /dev/null +++ b/doc/manual/meson.build @@ -0,0 +1,75 @@ +ignore_headers = [ +  'private.h', +  'pkcs11.h', +  'conf.h', +  'debug.h', +  'dict.h', +  'filter.h', +  'log.h', +  'mock.h', +  'modules.h', +  'pkcs11.h', +  'pkcs11i.h', +  'pkcs11x.h', +  'private.h', +  'client.h', +  'proxy.h', +  'rpc.h', +  'rpc-message.h', +  'util.h', +  'virtual.h', +  'virtual-fixed.h', +  'array.h', +  'compat.h' +] + +content_files = [ +  'p11-kit-config.xml', +  'p11-kit-sharing.xml', +  'p11-kit-devel.xml', +  'p11-kit-proxy.xml', +  'p11-kit-trust.xml', +  'p11-kit-remoting.xml', +  'p11-kit.xml', +  'pkcs11.conf.xml', +  'trust.xml', +  'annotation-glossary.xml' +] + +configure_file( +  input: 'version.xml.in', +  output: '@BASENAME@', +  configuration: {'VERSION', meson.project_version()}) + +configure_file( +  input: 'userdir.xml.in', +  output: '@BASENAME@', +  configuration: {'p11_user_config', p11_user_config}) + +configure_file( +  input: 'sysdir.xml.in', +  output: '@BASENAME@', +  configuration: {'p11_system_config', p11_system_config}) + +glib_prefix = dependency('glib-2.0').get_pkgconfig_variable('prefix') +fixxref_args = [ +  '--html-dir=' + (prefix / gnome.gtkdoc_html_dir(meson.project_name())), +  '--extra-dir=' + (glib_prefix / gnome.gtkdoc_html_dir('glib')), +] + +gnome.gtkdoc('p11-kit', +             main_xml: 'p11-kit-docs.xml', +             namespace: 'p11_kit', +             src_dir: 'p11-kit', +             dependencies: libffi_deps + dlopen_deps, +             scan_args: [ +               '--ignore-headers=' + ' '.join(ignore_headers), +               '--rebuild-types', +               '--deprecated-guards="P11_KIT_DISABLE_DEPRECATED"' +             ], +             scanobjs_args: [ +               '--version' +             ], +             content_files: content_files, +             fixxref_args: fixxref_args, +             install: true) diff --git a/doc/manual/sysdir.xml.in b/doc/manual/sysdir.xml.in new file mode 100644 index 0000000..8310c65 --- /dev/null +++ b/doc/manual/sysdir.xml.in @@ -0,0 +1 @@ +@p11_system_config@ diff --git a/doc/manual/userdir.xml.in b/doc/manual/userdir.xml.in new file mode 100644 index 0000000..4e9eea4 --- /dev/null +++ b/doc/manual/userdir.xml.in @@ -0,0 +1 @@ +@p11_user_config@ diff --git a/doc/manual/version.xml.in b/doc/manual/version.xml.in new file mode 100644 index 0000000..d78bda9 --- /dev/null +++ b/doc/manual/version.xml.in @@ -0,0 +1 @@ +@VERSION@ diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..77883e0 --- /dev/null +++ b/meson.build @@ -0,0 +1,368 @@ +project('p11-kit', 'c', +        version: '0.23.15', +        meson_version: '>= 0.49') + +version_arr = meson.project_version().split('.') +major_version = version_arr[0].to_int() +minor_version = version_arr[1].to_int() +micro_version = version_arr[2].to_int() + +cc = meson.get_compiler('c') + +current = 3 +revision = 0 +age = 3 + +soversion = current - age +library_version = '@0@.@1@.@2@'.format(soversion, age, revision) + +configinc = include_directories('.') +commoninc = include_directories('common') +p11kitinc = include_directories('p11-kit') +trustinc = include_directories('trust') + +add_project_arguments(['-D_GNU_SOURCE', '-DP11_KIT_FUTURE_UNSTABLE_API'], +                      language: 'c') + +conf = configuration_data() + +conf.set('PACKAGE_MAJOR', major_version) +conf.set('PACKAGE_MINOR', minor_version) + +host_system = host_machine.system() +conf.set(host_system == 'windows' ? 'OS_WIN32' : 'OS_UNIX', 1) + +if host_system == 'windows' +  shlext = '.dll' +  exeext = '.exe' +else +  shlext = '.so' +  exeext = '' +endif + +conf.set_quoted('SHLEXT', shlext) +conf.set_quoted('EXEEXT', exeext) + +if get_option('debug') +  conf.set('WITH_DEBUG', 1) +  conf.set('_DEBUG', 1) +endif + +conf.set10('WITH_STRICT', get_option('strict')) + +prefix = get_option('prefix') +datadir = get_option('datadir') +bindir = get_option('bindir') +libdir = get_option('libdir') +libexecdir = get_option('libexecdir') +sysconfdir = get_option('sysconfdir') +pkgdatadir = datadir / meson.project_name() +privatedir = libexecdir / meson.project_name() + +common_c_args = [ +  '-DBINDIR="@0@"'.format(prefix / bindir), +  '-DPRIVATEDIR="@0@"'.format(prefix / privatedir), +  '-DSYSCONFDIR="@0@"'.format(prefix / sysconfdir) +] + +top_source_dir = meson.current_source_dir() +top_build_dir = meson.current_build_dir() + +tests_c_args = [ +  '-DSRCDIR="@0@"'.format(top_source_dir), +  '-DBUILDDIR="@0@"'.format(top_build_dir) +] + +conf.set('SIZEOF_UNSIGNED_LONG', cc.sizeof('unsigned long')) + +pthread_create_deps = [] +nanosleep_deps = [] +dlopen_deps = [] +socket_deps = [] + +if host_system != 'windows' +  if not cc.has_function('pthread_create') +    libpthread = cc.find_library('pthread', required: false) +    if cc.has_function('pthread_create', dependencies: libpthread) +      pthread_create_deps += libpthread +    else +      error('could not find pthread_create') +    endif +  endif + +  if not cc.has_function('nanosleep') +    librt = cc.find_library('rt', required: false) +    if cc.has_function('nanosleep', dependencies: librt) +      nanosleep_deps += librt +    else +      error('could not find nanosleep') +    endif +  endif + +  if not cc.has_function('dlopen') +    libdl = cc.find_library('dl', required: false) +    if cc.has_function('dlopen', dependencies: libdl) +      dlopen_deps += libdl +    else +      error('could not find dlopen') +    endif +  endif + +  # for Solaris we need -lsocket -lnsl for socket stuff, gethostbyname +  # is just a dummy to find -lnsl +  libnsl = cc.find_library('nsl', required: false) +  if libnsl.found() +    if cc.has_function('gethostbyname', dependencies: libnsl) +      socket_deps += libnsl +    endif + +    libsocket = cc.find_library('socket', required: false) +    if libsocket.found() +      if cc.has_function('connect', dependencies: [libsocket, libnsl]) +        socket_deps += libsocket +      else +        error('could not find socket') +      endif +    endif +  endif + +  if cc.has_header('locale.h') +    conf.set('HAVE_LOCALE_H', 1) +    if cc.has_header_symbol('locale.h', 'locale_t') +      conf.set('HAVE_LOCALE_T', 1) +      if cc.has_function('newlocale', prefix: '#include <locale.h>') +        conf.set('HAVE_NEWLOCALE', 1) +      endif +      if cc.has_function('strerror_l', prefix: '#include <string.h>') +        conf.set('HAVE_STRERROR_L', 1) +      endif +    endif +  endif + +  # These are things we can work around +  headers = [ +    'sys/resource.h', +    'ucred.h' +  ] + +  foreach h : headers +    if cc.has_header(h) +      conf.set('HAVE_' + h.underscorify().to_upper(), 1) +    endif +  endforeach + +  functions = [ +    'fdwalk', +    'getauxval', +    'getexecname', +    'getpeereid', +    'getpeerucred', +    'getprogname', +    'getresuid', +    'issetugid', +    'mkdtemp', +    'mkstemp', +    'secure_getenv', +    'strndup' +  ] + +  foreach f : functions +    if cc.has_function(f) +      conf.set('HAVE_' + f.underscorify().to_upper(), 1) +    endif +  endforeach + +  if cc.has_member('struct dirent', 'd_type', prefix: '#include <dirent.h>') +    conf.set('HAVE_STRUCT_DIRENT_D_TYPE', 1) +  endif + +  tls_test_code_template = ''' +#include <stdlib.h> +int main (void) { +static @0@ foo; +return 0; +} +''' +  foreach keyword : ['_Thread_local', '__thread'] +    if cc.compiles(tls_test_code_template.format(keyword), +                   name: 'thread-local storage class') +      conf.set('P11_TLS_KEYWORD', keyword) +      break +    endif +  endforeach + +  if cc.has_function('gmtime_r') +    conf.set('HAVE_GMTIME_R', 1) +  else +    error('could not find required gmtime_r() function') +  endif + +  # Check if these are declared and/or available to link against +  program_invocation_short_name_test_code = ''' +#define _GNU_SOURCE +#include <errno.h> +int main (void) { program_invocation_short_name = "test"; } +''' +  if cc.links(program_invocation_short_name_test_code, +              name: 'program_invocation_short_name_test_code') +    conf.set('HAVE_PROGRAM_INVOCATION_SHORT_NAME', 1) +  else +    __progname_test_code = ''' +extern char *__progname; +int main (void) { __progname = (char*)0; return 0; } +''' +    if cc.links(__progname_test_code, name: '__progname') +      conf.set('HAVE___PROGNAME', 1) +    endif +  endif + +  __libc_enable_secure_test_code = ''' +extern int __libc_enable_secure; +int main (void) { __libc_enable_secure = 0; return 0; } +''' +  if cc.links(__libc_enable_secure_test_code, name: '__libc_enable_secure') +    conf.set('HAVE___LIBC_ENABLE_SECURE', 1) +  endif + +  foreach h : ['sys/types.h', 'signal.h'] +    foreach t : ['sighandler_t', 'sig_t', '__sighandler_t'] +      if cc.has_header_symbol(h, t) +        define = 'HAVE_' + t.underscorify().to_upper() +        conf.set(define, 1) +      endif +    endforeach +  endforeach +endif + +functions = [ +  'asprintf', +  'basename', +  'memdup', +  'reallocarray', +  'secure_getenv', +  'setenv', +  'strerror_r', +  'strnstr', +  'vasprintf' +] + +foreach f : functions +  if cc.has_function(f) +    conf.set('HAVE_' + f.underscorify().to_upper(), 1) +  endif +endforeach + +conf.set10('HAVE_DECL_ASPRINTF', +           cc.has_header_symbol('stdio.h', 'asprintf', +                                prefix: '#define _GNU_SOURCE')) + +conf.set10('HAVE_DECL_VASPRINTF', +           cc.has_header_symbol('stdio.h', 'vasprintf', +                                prefix: '#define _GNU_SOURCE')) + +conf.set10('HAVE_DECL_REALLOCARRAY', +           cc.has_header_symbol('stdlib.h', 'reallocarray')) + +# -------------------------------------------------------------------- +# libffi + +libffi_deps = [] +libffi = dependency('libffi', version: '>= 3.0.0', required: get_option('libffi')) +if libffi.found() +  conf.set('WITH_FFI', 1) +  libffi_deps += libffi +endif + +closures = get_option('closures') +if closures < 1 +  error('at least one closure must be compiled in') +endif + +conf.set('P11_VIRTUAL_MAX_FIXED', closures) + +# ------------------------------------------------------------------------------ +# PKCS#11 Directories + +p11_package_config_modules = get_option('module_config') +if p11_package_config_modules == '' +  p11_package_config_modules = pkgdatadir / 'modules' +endif + +p11_system_config = get_option('system_config') +if p11_system_config == '' +  p11_system_config = sysconfdir / 'pkcs11' +endif + +p11_user_config = get_option('user_config') +p11_module_path = get_option('module_path') +if p11_module_path == '' +  p11_module_path = libdir / 'pkcs11' +endif + +p11_system_config_file = p11_system_config / 'pkcs11.conf' +p11_system_config_modules = p11_system_config / 'modules' +p11_user_config_file = p11_user_config / 'pkcs11.conf' +p11_user_config_modules = p11_user_config / 'modules' + +# -------------------------------------------------------------------- +# Hash implementation + +hash_impl = get_option('hash_impl') +if hash_impl == 'freebl' +  libfreebl3 = cc.find_library('freebl3', required: false) +  if libfreebl3.found() and cc.has_function('NSSLOW_Init', +                                            dependencies: libfreebl3) +    conf.set('WITH_FREEBL', 1) +  else +    error('could not find the freebl3 library') +  endif +endif + +# -------------------------------------------------------------------- +# Trust Module + +with_trust_module = false +libtasn1_deps = [] +libtasn1 = dependency('libtasn1', version: '>= 2.3', +                      required: get_option('trust_module')) +if libtasn1.found() +  asn1Parser = find_program('asn1Parser', required: get_option('trust_module')) +  if asn1Parser.found() +    conf.set('WITH_ASN1', 1) +    libtasn1_deps += libtasn1 +    with_trust_module = true +  endif +endif + +trust_paths = get_option('trust_paths') +conf.set_quoted('TRUST_PATHS', trust_paths) + +# -------------------------------------------------------------------- +# systemd + +with_systemd = false +libsystemd_deps = [] +libsystemd = dependency('libsystemd', required: get_option('systemd')) +systemd = dependency('systemd', required: get_option('systemd')) +if libsystemd.found() and systemd.found() +  systemduserunitdir = systemd.get_pkgconfig_variable('systemduserunitdir') +  conf.set('WITH_SYSTEMD', 1) +  libsystemd_deps += libsystemd +  with_systemd = true +endif + +configure_file(output: 'config.h', configuration: conf) + +gnome = import('gnome') +i18n = import('i18n') +pkg = import('pkgconfig') + +subdir('common') +subdir('p11-kit') +if with_trust_module +  subdir('trust') +endif +if get_option('gtk_doc') +  subdir('doc/manual') +endif +subdir('po') diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..deda646 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,47 @@ +option('hash_impl', type : 'combo', +       value : 'internal', choices : ['internal', 'freebl'], +       description : 'Hash implementation to use') + +option('module_config', type : 'string', +       value : '', +       description : 'Module configuration files shipped by packages') + +option('system_config', type : 'string', +       value : '', +       description : 'Change PKCS#11 system config directory') + +option('user_config', type : 'string', +       value : '~/.config/pkcs11', +       description : 'Change PKCS#11 user config directory') + +option('module_path', type : 'string', +       value : '', +       description : 'Load modules with relative path names from here') + +option('libffi', type : 'feature', +       value : 'auto', +       description : 'Use libffi for building closures') + +option('closures', type : 'integer', +       value : 64, +       description : 'The number of precompiled closures, used when libffi is unavailable') + +option('trust_module', type : 'feature', +       value : 'auto', +       description : 'Build the trust module') + +option('trust_paths', type : 'string', +       value : '', +       description : 'Input paths for trust module') + +option('strict', type : 'boolean', +       value : false, +       description : 'Strict code compilation') + +option('systemd', type : 'feature', +       value : 'auto', +       description : 'Use systemd socket activation') + +option('gtk_doc', type : 'boolean', +       value : false, +       description : 'Build documentation using gtk-doc') diff --git a/p11-kit/gen-pkcs11-gnu.sh b/p11-kit/gen-pkcs11-gnu.sh new file mode 100755 index 0000000..a8b204d --- /dev/null +++ b/p11-kit/gen-pkcs11-gnu.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +source="$1" +target="$2" + +rm -f $target-t $target && \ +    { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ +      echo; \ +      echo '#include <stdlib.h>'; \ +      echo '#include "p11-kit/p11-kit.h"'; \ +      cat $source; \ +      echo "void *${target}_funcs[] = {" | sed 's/[^][ *a-z0-9_={]/_/g'; \ +      sed -n -e '/^typedef/d' -e 's/.* \(p11_kit_[^ ]*\) *(.*/	\1,/p' $source; \ +      echo '};'; \ +    } > $target-t && \ +    mv -f $target-t $target diff --git a/p11-kit/gen-virtual-fixed.sh b/p11-kit/gen-virtual-fixed.sh new file mode 100755 index 0000000..b4f0978 --- /dev/null +++ b/p11-kit/gen-virtual-fixed.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +target="$1" +closures="$2" + +rm -f $target-t $target && \ +  { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ +    echo; \ +    counter=0; \ +    while test $counter -lt $closures; do \ +      echo "P11_VIRTUAL_FIXED_FUNCTIONS($counter)"; \ +      counter=`expr $counter + 1`; \ +    done; \ +    echo; \ +    echo "CK_FUNCTION_LIST p11_virtual_fixed[P11_VIRTUAL_MAX_FIXED] = {"; \ +    counter=0; \ +    while test $counter -lt $closures; do \ +      echo "	P11_VIRTUAL_FIXED_INITIALIZER($counter),"; \ +      counter=`expr $counter + 1`; \ +    done; \ +    echo '};'; \ +    echo; \ +    counter=0; \ +    while test $counter -lt $closures; do \ +      echo "P11_VIRTUAL_FIXED_GET_FUNCTION_LIST($counter)"; \ +      counter=`expr $counter + 1`; \ +    done; \ +  } > $target-t && mv -f $target-t $target diff --git a/p11-kit/libp11-kit-0.dll.def b/p11-kit/libp11-kit-0.dll.def new file mode 100644 index 0000000..777d56a --- /dev/null +++ b/p11-kit/libp11-kit-0.dll.def @@ -0,0 +1,101 @@ +EXPORTS +C_GetFunctionList +p11_kit_be_loud +p11_kit_be_quiet +p11_kit_config_option +p11_kit_finalize_module +p11_kit_finalize_registered +p11_kit_initialize_module +p11_kit_initialize_registered +p11_kit_iter_add_callback +p11_kit_iter_add_filter +p11_kit_iter_begin +p11_kit_iter_begin_with +p11_kit_iter_destroy_object +p11_kit_iter_free +p11_kit_iter_get_attributes +p11_kit_iter_get_kind +p11_kit_iter_get_module +p11_kit_iter_get_object +p11_kit_iter_get_session +p11_kit_iter_get_slot +p11_kit_iter_get_slot_info +p11_kit_iter_get_token +p11_kit_iter_keep_session +p11_kit_iter_load_attributes +p11_kit_iter_new +p11_kit_iter_next +p11_kit_iter_set_uri +p11_kit_load_initialize_module +p11_kit_message +p11_kit_module_finalize +p11_kit_module_for_name +p11_kit_module_get_filename +p11_kit_module_get_flags +p11_kit_module_get_name +p11_kit_module_initialize +p11_kit_module_load +p11_kit_module_release +p11_kit_modules_finalize +p11_kit_modules_finalize_and_release +p11_kit_modules_initialize +p11_kit_modules_load +p11_kit_modules_load_and_initialize +p11_kit_modules_release +p11_kit_override_system_files +p11_kit_pin_file_callback +p11_kit_pin_get_length +p11_kit_pin_get_value +p11_kit_pin_new +p11_kit_pin_new_for_buffer +p11_kit_pin_new_for_string +p11_kit_pin_ref +p11_kit_pin_register_callback +p11_kit_pin_request +p11_kit_pin_unref +p11_kit_pin_unregister_callback +p11_kit_registered_module_to_name +p11_kit_registered_modules +p11_kit_registered_name_to_module +p11_kit_registered_option +p11_kit_remote_serve_module +p11_kit_remote_serve_token +p11_kit_remote_serve_tokens +p11_kit_set_progname +p11_kit_space_strdup +p11_kit_space_strlen +p11_kit_strerror +p11_kit_uri_any_unrecognized +p11_kit_uri_clear_attribute +p11_kit_uri_clear_attributes +p11_kit_uri_format +p11_kit_uri_free +p11_kit_uri_get_attribute +p11_kit_uri_get_attributes +p11_kit_uri_get_module_info +p11_kit_uri_get_module_name +p11_kit_uri_get_module_path +p11_kit_uri_get_pin_source +p11_kit_uri_get_pin_value +p11_kit_uri_get_pinfile +p11_kit_uri_get_slot_id +p11_kit_uri_get_slot_info +p11_kit_uri_get_token_info +p11_kit_uri_get_vendor_query +p11_kit_uri_match_attributes +p11_kit_uri_match_module_info +p11_kit_uri_match_slot_info +p11_kit_uri_match_token_info +p11_kit_uri_message +p11_kit_uri_new +p11_kit_uri_parse +p11_kit_uri_set_attribute +p11_kit_uri_set_attributes +p11_kit_uri_set_module_name +p11_kit_uri_set_module_path +p11_kit_uri_set_pin_source +p11_kit_uri_set_pin_value +p11_kit_uri_set_pinfile +p11_kit_uri_set_slot_id +p11_kit_uri_set_unrecognized +p11_kit_uri_set_vendor_query diff --git a/p11-kit/libp11-kit.map b/p11-kit/libp11-kit.map new file mode 100644 index 0000000..6a661f3 --- /dev/null +++ b/p11-kit/libp11-kit.map @@ -0,0 +1,105 @@ +LIBP11_KIT_1.0 { +	global: +		C_GetFunctionList; +		p11_kit_be_loud; +		p11_kit_be_quiet; +		p11_kit_config_option; +		p11_kit_finalize_module; +		p11_kit_finalize_registered; +		p11_kit_initialize_module; +		p11_kit_initialize_registered; +		p11_kit_iter_add_callback; +		p11_kit_iter_add_filter; +		p11_kit_iter_begin; +		p11_kit_iter_begin_with; +		p11_kit_iter_destroy_object; +		p11_kit_iter_free; +		p11_kit_iter_get_attributes; +		p11_kit_iter_get_kind; +		p11_kit_iter_get_module; +		p11_kit_iter_get_object; +		p11_kit_iter_get_session; +		p11_kit_iter_get_slot; +		p11_kit_iter_get_slot_info; +		p11_kit_iter_get_token; +		p11_kit_iter_keep_session; +		p11_kit_iter_load_attributes; +		p11_kit_iter_new; +		p11_kit_iter_next; +		p11_kit_iter_set_uri; +		p11_kit_load_initialize_module; +		p11_kit_message; +		p11_kit_module_finalize; +		p11_kit_module_for_name; +		p11_kit_module_get_filename; +		p11_kit_module_get_flags; +		p11_kit_module_get_name; +		p11_kit_module_initialize; +		p11_kit_module_load; +		p11_kit_module_release; +		p11_kit_modules_finalize; +		p11_kit_modules_finalize_and_release; +		p11_kit_modules_initialize; +		p11_kit_modules_load; +		p11_kit_modules_load_and_initialize; +		p11_kit_modules_release; +		p11_kit_override_system_files; +		p11_kit_pin_file_callback; +		p11_kit_pin_get_length; +		p11_kit_pin_get_value; +		p11_kit_pin_new; +		p11_kit_pin_new_for_buffer; +		p11_kit_pin_new_for_string; +		p11_kit_pin_ref; +		p11_kit_pin_register_callback; +		p11_kit_pin_request; +		p11_kit_pin_unref; +		p11_kit_pin_unregister_callback; +		p11_kit_registered_modules; +		p11_kit_registered_module_to_name; +		p11_kit_registered_name_to_module; +		p11_kit_registered_option; +		p11_kit_remote_serve_module; +		p11_kit_remote_serve_token; +		p11_kit_remote_serve_tokens; +		p11_kit_set_progname; +		p11_kit_space_strdup; +		p11_kit_space_strlen; +		p11_kit_strerror; +		p11_kit_uri_any_unrecognized; +		p11_kit_uri_clear_attribute; +		p11_kit_uri_clear_attributes; +		p11_kit_uri_format; +		p11_kit_uri_free; +		p11_kit_uri_get_attribute; +		p11_kit_uri_get_attributes; +		p11_kit_uri_get_module_info; +		p11_kit_uri_get_module_name; +		p11_kit_uri_get_module_path; +		p11_kit_uri_get_pinfile; +		p11_kit_uri_get_pin_source; +		p11_kit_uri_get_pin_value; +		p11_kit_uri_get_slot_id; +		p11_kit_uri_get_slot_info; +		p11_kit_uri_get_token_info; +		p11_kit_uri_get_vendor_query; +		p11_kit_uri_match_attributes; +		p11_kit_uri_match_module_info; +		p11_kit_uri_match_slot_info; +		p11_kit_uri_match_token_info; +		p11_kit_uri_message; +		p11_kit_uri_new; +		p11_kit_uri_parse; +		p11_kit_uri_set_attribute; +		p11_kit_uri_set_attributes; +		p11_kit_uri_set_module_name; +		p11_kit_uri_set_module_path; +		p11_kit_uri_set_pinfile; +		p11_kit_uri_set_pin_source; +		p11_kit_uri_set_pin_value; +		p11_kit_uri_set_slot_id; +		p11_kit_uri_set_unrecognized; +		p11_kit_uri_set_vendor_query; +	local: +		*; +}; diff --git a/p11-kit/meson.build b/p11-kit/meson.build new file mode 100644 index 0000000..33e1683 --- /dev/null +++ b/p11-kit/meson.build @@ -0,0 +1,299 @@ +install_headers('deprecated.h', +                'iter.h', +                'p11-kit.h', +                'pin.h', +                'remote.h', +                'uri.h', +                subdir: 'p11-kit-1/p11-kit') + +libp11_kit_internal_sources = [ +  'conf.c', +  'log.c', +  'filter.c', +  'rpc-transport.c', +  'rpc-message.c', +  'rpc-client.c' +] + +libp11_kit_internal_sources += custom_target('generate virtual-fixed-generated.h', +                                             output: 'virtual-fixed-generated.h', +                                             command: [ +                                               meson.current_source_dir() / 'gen-virtual-fixed.sh', +                                               '@OUTPUT@', '64' +                                             ]) +libp11_kit_internal_sources += 'virtual.c' + +libp11_kit_internal_c_args = [ +  '-DP11_SYSTEM_CONFIG_FILE="@0@"'.format(p11_system_config_file), +  '-DP11_SYSTEM_CONFIG_MODULES="@0@"'.format(p11_system_config_modules), +  '-DP11_PACKAGE_CONFIG_MODULES="@0@"'.format(p11_package_config_modules), +  '-DP11_USER_CONFIG_FILE="@0@"'.format(p11_user_config_file), +  '-DP11_USER_CONFIG_MODULES="@0@"'.format(p11_user_config_modules), +  '-DP11_MODULE_PATH="@0@"'.format(p11_module_path) +] + +libp11_kit_internal = static_library('p11-kit-internal', +                                     libp11_kit_internal_sources, +                                     dependencies: [libp11_common_dep, +                                                    libp11_library_dep] + libffi_deps, +                                     c_args: libp11_kit_internal_c_args, +                                     implicit_include_directories: false, +                                     gnu_symbol_visibility: 'hidden') + +libp11_kit_sources = [ +  'iter.c', +  'messages.c', +  'modules.c', +  'pin.c', +  'proxy.c', +  'proxy-init.c', +  'rpc-server.c', +  'uri.c', +  'util.c' +] + +libp11_kit_symbol_map = meson.current_source_dir() / 'libp11-kit.map' +libp11_kit_ldflags = cc.get_supported_link_arguments([ +  '-Wl,--version-script,' + libp11_kit_symbol_map +]) +libp11_kit_symbol_def = meson.current_source_dir() / 'libp11-kit-@0@.dll.def'.format(soversion) + +libp11_kit = shared_library('p11-kit', +                            libp11_kit_sources, +                            install: true, +                            version: library_version, +                            soversion: soversion, +                            dependencies: libffi_deps + dlopen_deps, +                            include_directories: [configinc, commoninc], +                            implicit_include_directories: false, +                            c_args: libp11_kit_internal_c_args, +                            link_args: libp11_kit_ldflags, +                            link_depends: [libp11_kit_symbol_map, +                                           libp11_kit_symbol_def], +                            link_with: libp11_kit_internal, +                            vs_module_defs: libp11_kit_symbol_def) + +libp11_kit_dep = declare_dependency(link_with: libp11_kit, +                                    include_directories: [configinc, commoninc]) + +meson.add_install_script( +  'meson_post_install.sh', +  libdir, +  datadir / 'p11-kit' / 'modules' +) + +if host_system != 'windows' +  shared_module('p11-kit-client', +                'client.c', 'client-init.c', +                name_prefix: '', +                include_directories: [configinc, commoninc], +                link_with: [libp11_kit_internal]) +endif + +fixtures_dir = meson.current_source_dir() / 'fixtures' + +if host_system == 'windows' +  libp11_kit_testable_c_args = [ +    '-DP11_SYSTEM_CONFIG_FILE="@0@"'.format(fixtures_dir / 'system-pkcs11.conf'), +    '-DP11_SYSTEM_CONFIG_MODULES="@0@"'.format(fixtures_dir / 'system-modules' / 'win32'), +    '-DP11_PACKAGE_CONFIG_MODULES="@0@"'.format(fixtures_dir / 'package-modules' / 'win32'), +    '-DP11_USER_CONFIG_FILE="@0@"'.format(fixtures_dir / 'user-pkcs11.conf'), +    '-DP11_USER_CONFIG_MODULES="@0@"'.format(fixtures_dir / 'user-modules' / 'win32') +  ] +else +  libp11_kit_testable_c_args = [ +    '-DP11_SYSTEM_CONFIG_FILE="@0@"'.format(fixtures_dir / 'system-pkcs11.conf'), +    '-DP11_SYSTEM_CONFIG_MODULES="@0@"'.format(fixtures_dir / 'system-modules'), +    '-DP11_PACKAGE_CONFIG_MODULES="@0@"'.format(fixtures_dir / 'package-modules'), +    '-DP11_USER_CONFIG_FILE="@0@"'.format(fixtures_dir / 'user-pkcs11.conf'), +    '-DP11_USER_CONFIG_MODULES="@0@"'.format(fixtures_dir / 'user-modules') +  ] +endif + +libp11_kit_testable_c_args += '-DP11_MODULE_PATH="@0@"'.format(meson.current_build_dir()) + +libp11_kit_testable = static_library('p11-kit-testable', +                                     libp11_kit_internal_sources, +                                     libp11_kit_sources, +                                     c_args: libp11_kit_testable_c_args, +                                     implicit_include_directories: false, +                                     dependencies: [libp11_common_dep, libp11_library_dep] + libffi_deps + dlopen_deps) + +p11_kit_sources = [ +  'lists.c', +  'p11-kit.c' +] + +executable('p11-kit', +           p11_kit_sources, +           c_args: common_c_args, +           dependencies: [libp11_tool_dep, libp11_common_dep] + libffi_deps + dlopen_deps, +           link_with: libp11_kit, +           install: true) + +executable('p11-kit-remote', +           'remote.c', +           c_args: common_c_args, +           dependencies: [libp11_tool_dep, libp11_common_dep] + libffi_deps + dlopen_deps, +           link_with: libp11_kit, +           install: true, +           install_dir: prefix / privatedir) + +executable('p11-kit-remote-testable', +           'remote.c', +           c_args: common_c_args, +           dependencies: [libp11_tool_dep, libp11_common_dep] + libffi_deps + dlopen_deps, +           link_with: libp11_kit_testable) + +executable('p11-kit-server', +           'server.c', +           c_args: common_c_args + [ +             '-DP11_KIT_REMOTE="p11-kit-remote"' +           ], +           dependencies: [libp11_tool_dep, libp11_common_dep] + libsystemd_deps + libffi_deps + dlopen_deps, +           implicit_include_directories: false, +           link_with: libp11_kit, +           install: true, +           install_dir: prefix / privatedir) + +executable('p11-kit-server-testable', +           'server.c', +           c_args: common_c_args + [ +             '-DP11_KIT_REMOTE="p11-kit-remote-testable"' +           ], +           implicit_include_directories: false, +           dependencies: [libp11_tool_dep, libp11_common_dep] + libsystemd_deps + libffi_deps + dlopen_deps, +           link_with: libp11_kit_testable) + +# Check if compilation succeeds with CRYPTOKI_GNU=1 + +pkcs11_gnu_headers = [ +  'iter.h', +  'pin.h', +  'uri.h' +] + +gnu_h_gen = generator(find_program('gen-pkcs11-gnu.sh'), +                      output: 'pkcs11-gnu-@BASENAME@.h', +                      arguments: ['@INPUT@', '@OUTPUT@']) + +gnu_h = gnu_h_gen.process(pkcs11_gnu_headers) + +static_library('p11-kit-pkcs11-gnu', +               gnu_h, +               'pkcs11-gnu.c', +               include_directories: [configinc, commoninc]) + +# Tests ---------------------------------------------------------------- + +p11_kit_tests = [ +  'test-progname', +  'test-util', +  'test-conf', +  'test-uri', +  'test-pin', +  'test-init', +  'test-modules', +  'test-deprecated', +  'test-proxy', +  'test-iter', +  'test-rpc', +  'test-virtual', +  'test-managed', +  'test-log', +  'test-filter', +  'test-transport' +] + +if host_system != 'windows' +  p11_kit_tests += 'test-server' +endif + +foreach name : p11_kit_tests +  t = executable(name, '@0@.c'.format(name), +                 c_args: tests_c_args + libp11_kit_testable_c_args, +                 include_directories: [configinc, commoninc], +                 dependencies: [libp11_test_dep, libp11_common_dep] + libffi_deps + dlopen_deps + pthread_create_deps, +                 link_with: libp11_kit_testable) +  test(name, t) +endforeach + +p11_kit_progs = [ +  'print-messages', +  'frob-setuid' +] + +foreach name : p11_kit_progs +  t = executable(name, '@0@.c'.format(name), +                 c_args: tests_c_args, +                 include_directories: [configinc, commoninc], +                 dependencies: [libp11_test_dep, libp11_common_dep] + libffi_deps + dlopen_deps + pthread_create_deps, +                 link_with: libp11_kit_testable) +endforeach + +p11_kit_tests_env = environment() +p11_kit_tests_env.set('abs_top_builddir', top_build_dir) +p11_kit_tests_env.set('P11_MODULE_PATH', meson.current_build_dir()) + +if host_system != 'windows' +  test('test-messages.sh', +       find_program('test-messages.sh'), +       env: p11_kit_tests_env) + +  test('test-server.sh', +       find_program('test-server.sh'), +       env: p11_kit_tests_env) +endif + +mock_sources = { +  'mock-one': ['mock-module-ep.c'], +  'mock-two': ['mock-module-ep2.c'], +  'mock-three': ['mock-module-ep.c'], +  'mock-four': ['mock-module-ep.c'], +  'mock-five': ['mock-module-ep3.c'], +  'mock-seven': ['mock-module-ep5.c'], +  'mock-eight': ['mock-module-ep6.c'], +  'mock-nine': ['mock-module-ep7.c'] +} + +if host_system != 'windows' +  mock_sources += {'mock-six': ['mock-module-ep4.c']} +endif + +foreach name, sources : mock_sources +  shared_module(name, +                sources, +                name_prefix: '', +                include_directories: [configinc, commoninc], +                dependencies: [libp11_test_dep, libp11_common_dep]) +endforeach + +p11_kit_pc_variables = [ +  'p11_module_configs=@0@'.format(prefix / p11_package_config_modules), +  'p11_module_path=@0@'.format(prefix / p11_module_path), +  'proxy_module=@0@/p11-kit-proxy.so'.format(prefix / libdir), +  'p11_system_config_modules=@0@'.format(prefix / p11_package_config_modules) +] + +if trust_paths != '' +  p11_kit_pc_variables += [ +    'p11_trust_paths=@0@'.format(trust_paths) +  ] +endif + +pkg.generate(libraries: libp11_kit, +             filebase: 'p11-kit-1', +             name: 'p11-kit', +             description: 'Library and proxy module for properly loading and sharing PKCS#11 modules.', +             subdirs: 'p11-kit-1', +             variables: p11_kit_pc_variables) + +pkcs11_conf_example_conf = configuration_data({ +  'p11_system_config_file': prefix / p11_system_config_file, +  'p11_user_config': prefix / p11_user_config +}) +pkcs11_conf_example = configure_file(input: 'pkcs11.conf.example.in', +                                     output: '@BASENAME@', +                                     configuration: pkcs11_conf_example_conf) +install_data(pkcs11_conf_example, +             install_dir: prefix / p11_system_config) diff --git a/p11-kit/meson_post_install.sh b/p11-kit/meson_post_install.sh new file mode 100755 index 0000000..9a59db8 --- /dev/null +++ b/p11-kit/meson_post_install.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +set +x + +libdir="$1" +p11_package_config_modules="$2" + +# Proxy module is actually same as library, so install a link +for i in so dylib; do +  test -f "$MESON_INSTALL_DESTDIR_PREFIX/$libdir/libp11-kit.$i" && +    ln -sf `readlink $MESON_INSTALL_DESTDIR_PREFIX/$libdir/libp11-kit.$i` \ +       "$MESON_INSTALL_DESTDIR_PREFIX/$libdir/p11-kit-proxy.$i" || true; +done + +mkdir -p "$MESON_INSTALL_DESTDIR_PREFIX/$p11_package_config_modules" diff --git a/p11-kit/pkcs11-gnu.c b/p11-kit/pkcs11-gnu.c new file mode 100644 index 0000000..86d9374 --- /dev/null +++ b/p11-kit/pkcs11-gnu.c @@ -0,0 +1,3 @@ +#include "pkcs11-gnu-iter.h" +#include "pkcs11-gnu-pin.h" +#include "pkcs11-gnu-uri.h" diff --git a/po/meson.build b/po/meson.build new file mode 100644 index 0000000..c6dddc8 --- /dev/null +++ b/po/meson.build @@ -0,0 +1 @@ +i18n.gettext(meson.project_name()) diff --git a/trust/meson.build b/trust/meson.build new file mode 100644 index 0000000..70786fa --- /dev/null +++ b/trust/meson.build @@ -0,0 +1,162 @@ +libtrust_data_sources = [ +  'asn1.c', +  'base64.c', +  'pem.c', +  'oid.c', +  'utf8.c', +  'x509.c' +] + +asn_sources = [ +  'basic.asn', +  'pkix.asn', +  'openssl.asn' +] + +asn_h_gen = generator(asn1Parser, +                      output: '@BASENAME@.h', +                      arguments: ['-o', '@OUTPUT@', '@INPUT@']) +asn_h = asn_h_gen.process(asn_sources) + +libtrust_data = static_library('libtrust-data', +                               asn_h, +                               libtrust_data_sources, +                               include_directories: [configinc, commoninc], +                               dependencies: libtasn1_deps) + +libtrust_sources = [ +  'builder.c', +  'digest.c', +  'index.c', +  'parser.c', +  'persist.c', +  'module.c', +  'save.c', +  'session.c', +  'token.c' +] + +install_data('p11-kit-trust.module', +             install_dir: prefix / p11_package_config_modules) + +p11_kit_trust_c_args = [ +  '-DP11_DEFAULT_TRUST_PREFIX="@0@"'.format(prefix / datadir), +  '-DP11_SYSTEM_TRUST_PREFIX="@0@"'.format(prefix / sysconfdir) +] + +shared_module('p11-kit-trust', +              libtrust_sources, +              'module-init.c', +              name_prefix: '', +	      c_args: p11_kit_trust_c_args, +              dependencies: [libp11_library_dep, +                             libp11_common_dep] + libtasn1_deps, +              link_with: libtrust_data, +              install: true, +              install_dir: prefix / p11_module_path) + +libtrust_testable_c_args = [ +  '-DP11_DEFAULT_TRUST_PREFIX="@0@"'.format(meson.current_build_dir() / 'default'), +  '-DP11_SYSTEM_TRUST_PREFIX="@0@"'.format(meson.current_build_dir() / 'system') +] + +libtrust_testable = static_library('libtrust-testable', +                                   libtrust_sources, +                                   include_directories: [configinc, commoninc], +                                   c_args: libtrust_testable_c_args, +                                   dependencies: libtasn1_deps) + +trust_sources = [ +  'anchor.c', +  'parser.c', +  'persist.c', +  'digest.c', +  'dump.c', +  'enumerate.c', +  'extract.c', +  'extract-jks.c', +  'extract-edk2.c', +  'extract-openssl.c', +  'extract-pem.c', +  'extract-cer.c', +  'list.c', +  'save.c', +  'trust.c' +] + +executable('trust', +           asn_h, +           trust_sources, +           c_args: common_c_args, +           link_with: libtrust_data, +           dependencies: [libp11_kit_dep, +                          libp11_common_dep, +                          libp11_tool_dep] + libffi_deps + dlopen_deps + libtasn1_deps, +           install: true) + +# Tests ---------------------------------------------------------------- + +libtrust_test_sources = [ +  'test-trust.c', +  'digest.c' +] + +libtrust_test = static_library('libtrust-test', +                               libtrust_test_sources, +                               include_directories: [configinc, commoninc]) + +trust_tests = [ +  'test-digest', +  'test-asn1', +  'test-base64', +  'test-pem', +  'test-oid', +  'test-utf8', +  'test-x509', +  'test-persist', +  'test-index', +  'test-parser', +  'test-builder', +  'test-token', +  'test-module', +  'test-save', +  'test-enumerate', +  'test-cer', +  'test-bundle', +  'test-openssl', +  'test-edk2', +  'test-jks' +] + +foreach name : trust_tests +  t = executable(name, '@0@.c'.format(name), +                 c_args: common_c_args + tests_c_args + libtrust_testable_c_args, +                 dependencies: [libp11_kit_dep, +                                libp11_library_dep, +                                libp11_test_dep, +                                libp11_common_dep] + dlopen_deps, +                 link_with: [libtrust_testable, libtrust_data, libtrust_test]) +  test(name, t) +endforeach + +trust_progs = [ +  'frob-pow', +  'frob-token', +  'frob-nss-trust', +  'frob-cert', +  'frob-bc', +  'frob-ku', +  'frob-eku', +  'frob-ext', +  'frob-oid' +] + +foreach name : trust_progs +  t = executable(name, '@0@.c'.format(name), +                 c_args: tests_c_args, +                 dependencies: [libp11_kit_dep, +                                libp11_library_dep, +                                libp11_test_dep, +                                libp11_common_dep] + libffi_deps + dlopen_deps, +                 link_with: [libtrust_testable, libtrust_data, libtrust_test]) +endforeach | 
