[network-manager-applet/lr/pkcs11: 12/18] build: optionally build with the GCR support



commit 5d0be8d56744b858d5158abdc63311ebb270df6c
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Sun Feb 19 13:14:52 2017 +0000

    build: optionally build with the GCR support
    
    This will be useful for the PKCS#11 token support.
    
    Unfortunatelly, GCR API is declared subject to change despite being in
    active use and not having changed in years. This is not a problem --
    if GCR ever deprecates this API, chances are it will provide a
    certificate chooser too and we'll be just able to drop ours. It doesn't
    seem like happening anytime soon.
    
    Let's do an extensive check of how good the available GCR version is and
    disable it if it's not good enough. We'll provide a sensible fallback
    anyway.

 Makefile.am  |    9 +++++--
 configure.ac |   71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 77 insertions(+), 3 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index fe3c718..4c5895e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -32,7 +32,8 @@ DISTCHECK_CONFIGURE_FLAGS = \
        --enable-introspection \
        --enable-more-warnings=error \
        --with-wwan \
-       --with-team
+       --with-team \
+       --with-gcr
 
 man_MANS =
 
@@ -528,13 +529,15 @@ src_libnma_libnma_la_CFLAGS = \
        "-I$(srcdir)/src/libnma" \
        $(GTK_CFLAGS) \
        $(LIBNM_CFLAGS) \
-       $(GUDEV_CFLAGS)
+       $(GUDEV_CFLAGS) \
+       $(GCR_CFLAGS)
 
 src_libnma_libnma_la_LIBADD = \
        src/wireless-security/libwireless-security-libnm.la \
        $(GTK_LIBS) \
        $(LIBNM_LIBS) \
-       $(GUDEV_LIBS)
+       $(GUDEV_LIBS) \
+       $(GCR_LIBS)
 
 EXTRA_src_libnma_libnma_la_DEPENDENCIES = src/libnma/libnma.ver
 
diff --git a/configure.ac b/configure.ac
index d1c8067..843ca32 100644
--- a/configure.ac
+++ b/configure.ac
@@ -165,6 +165,76 @@ else
 fi
 AM_CONDITIONAL(WITH_JANSSON, test "${with_team}" != "no")
 
+dnl GCR for PKCS#11 enabled certificate chooser
+AC_ARG_WITH(gcr, AS_HELP_STRING([--with-gcr], [Enable advanced certificate chooser (default: auto)]))
+if (test "${with_gcr}" == "no"); then
+    have_gcr=no
+else
+    PKG_CHECK_MODULES(GCR,
+                      [gcr-3 >= 3.14, gck-1 >= 3.14],
+                      dnl GCR API is declared subject to change, do an extensive check of the prototypes
+                      GCR_CFLAGS="$GCR_CFLAGS -DGCR_API_SUBJECT_TO_CHANGE -DGCK_API_SUBJECT_TO_CHANGE"
+                      CFLAGS_SAVED="$CFLAGS"
+                      CFLAGS="$CFLAGS $GCR_CFLAGS"
+                      AC_MSG_CHECKING([for GCR usefulness])
+                      AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+                                        #include <gcr/gcr.h>
+                                        #include <gck/gck.h>
+
+                                        const GckAttribute *gck_attributes_find (GckAttributes *attrs, 
gulong attr_type);
+                                        gboolean gck_attributes_find_string (GckAttributes *attrs, gulong 
attr_type, gchar **value);
+                                        gboolean gck_attributes_find_ulong (GckAttributes *attrs, gulong 
attr_type, gulong *value);
+                                        GckAttributes *gck_attributes_new_empty (gulong first_type, ...);
+                                        void gck_attributes_unref (gpointer attrs);
+                                        void gck_builder_add_all (GckBuilder *builder, GckAttributes *attrs);
+                                        void gck_builder_add_only (GckBuilder *builder, GckAttributes 
*attrs, gulong only_type, ...);
+                                        GckAttributes *gck_builder_end (GckBuilder *builder);
+                                        GckBuilder *gck_builder_new (GckBuilderFlags flags);
+                                        void gck_enumerator_next_async (GckEnumerator *self, gint 
max_objects, GCancellable *cancellable,
+                                                                        GAsyncReadyCallback callback, 
gpointer user_data);
+                                        GList *gck_enumerator_next_finish (GckEnumerator *self, GAsyncResult 
*result, GError **error);
+                                        void gck_list_unref_free (GList *reflist);
+                                        GList *gck_modules_get_slots (GList *modules, gboolean 
token_present);
+                                        void gck_modules_initialize_registered_async (GCancellable 
*cancellable, GAsyncReadyCallback callback,
+                                                                                      gpointer user_data);
+                                        GList *gck_modules_initialize_registered_finish (GAsyncResult 
*result, GError **error);
+                                        void gck_object_get_async (GckObject *self, const gulong 
*attr_types, guint n_attr_types,
+                                                                   GCancellable *cancellable, 
GAsyncReadyCallback callback, gpointer user_data);
+                                        GckAttributes *gck_object_get_finish (GckObject *self, GAsyncResult 
*result, GError **error);
+                                        void gck_session_login_async (GckSession *self, gulong user_type, 
const guchar *pin,
+                                                                      gsize n_pin, GCancellable *cancellable,
+                                                                      GAsyncReadyCallback callback, gpointer 
user_data);
+                                        gboolean gck_session_login_finish (GckSession *self, GAsyncResult 
*result, GError **error);
+                                        GckSlotInfo *gck_slot_get_info (GckSlot *self);
+                                        GckTokenInfo *gck_slot_get_token_info (GckSlot *self);
+                                        void gck_slot_open_session_async (GckSlot *self, GckSessionOptions 
options, GCancellable *cancellable,
+                                                                          GAsyncReadyCallback callback, 
gpointer user_data);
+                                        GckSession *gck_slot_open_session_finish (GckSlot *self, 
GAsyncResult *result, GError **error);
+                                        void gck_token_info_free (GckTokenInfo *token_info);
+                                        gchar *gck_uri_build (GckUriData *uri_data, GckUriFlags flags);
+                                        void gck_uri_data_free (GckUriData *uri_data);
+                                        GckUriData *gck_uri_parse (const gchar *string, GckUriFlags flags, 
GError **error);
+                                        gchar *gcr_certificate_get_issuer_name (GcrCertificate *self);
+                                        gchar *gcr_certificate_get_subject_name (GcrCertificate *self);
+                                        GcrCertificate *gcr_simple_certificate_new (const guchar *data, 
gsize n_data);
+                                        ])],
+                                        have_gcr=yes,
+                                        have_gcr=no)
+                      AC_MSG_RESULT(${have_gcr})
+                      CFLAGS="$CFLAGS_SAVED",
+                      have_gcr=no);
+fi
+
+if (test "${have_gcr}" == "yes"); then
+     AC_DEFINE(WITH_GCR, 1, [Define if Gcr is available])
+else
+    if (test "${with_gcr}" == "yes"); then
+        AC_MSG_ERROR([gcr support was requested, but the gcr library is not available.])
+    fi
+    AC_DEFINE(WITH_GCR, 0, [Define if Gcr is available])
+fi
+AM_CONDITIONAL(WITH_GCR, test "${have_gcr}" == "yes")
+
 dnl Check for gobject introspection
 GOBJECT_INTROSPECTION_CHECK([0.9.6])
 
@@ -205,6 +275,7 @@ AC_OUTPUT
 
 echo ""
 echo "  Build legacy library libnm-gtk: --with-libnm-gtk=${with_libnm_gtk}"
+echo "  GCR: --with-gcr=$have_gcr"
 echo "  LTO: --enable-lto=$enable_lto"
 echo "  Linker garbage collection: --enable-ld-gc=$enable_ld_gc"
 echo ""


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]