From 19009f995996bf91e0f1b832a3279bc2cc8a1708 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 14 Sep 2007 13:38:36 +0000 Subject: [PATCH] Print used library version with --version. Typo fixes --- ChangeLog | 4 ++++ agent/agent.h | 2 +- common/ChangeLog | 2 +- configure.ac | 2 ++ g10/ChangeLog | 5 +++++ g10/gpg.c | 48 ++++++++++++++++++++++++++++++++++++++++++- sm/ChangeLog | 5 +++++ sm/gpgsm.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++-- 8 files changed, 116 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 234924be1..c224aacda 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2007-09-14 Werner Koch + + * configure.ac (GNUPG_LIBASSUAN_VERSION): New. + 2007-09-10 Werner Koch Released 2.0.7. diff --git a/agent/agent.h b/agent/agent.h index c37a22c3d..7d76e4380 100644 --- a/agent/agent.h +++ b/agent/agent.h @@ -80,7 +80,7 @@ struct unsigned long max_cache_ttl; /* Default. */ unsigned long max_cache_ttl_ssh; /* for SSH. */ - /* Flag disallowin bypassing of the warning. */ + /* Flag disallowing bypassing of the warning. */ int enforce_passphrase_constraints; /* The require minmum length of a passphrase. */ unsigned int min_passphrase_len; diff --git a/common/ChangeLog b/common/ChangeLog index 8dc830894..a9b799b4c 100644 --- a/common/ChangeLog +++ b/common/ChangeLog @@ -8,7 +8,7 @@ 2007-08-28 Werner Koch - * gettime.c (check_isotime, add_isotime): New. Orginally written + * gettime.c (check_isotime, add_isotime): New. Originally written for DirMngr by me. (add_days_to_isotime): New. (date2jd, jd2date, days_per_month, days_per_year): New. Taken from diff --git a/configure.ac b/configure.ac index 1c929a3a9..e1608de48 100644 --- a/configure.ac +++ b/configure.ac @@ -608,6 +608,8 @@ if test "$have_libassuan" = "yes"; then AM_CHECK_LIBASSUAN("$NEED_LIBASSUAN_API:1.0.1", [AC_DEFINE(HAVE_ASSUAN_SET_IO_MONITOR, 1, [Define to 1 if you have the `assuan_set_io_monitor' function.])],) + AC_DEFINE_UNQUOTED(GNUPG_LIBASSUAN_VERSION, "$libassuan_version", + [version of the libbassuan library]) fi diff --git a/g10/ChangeLog b/g10/ChangeLog index 4dc911019..6c5067d2e 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,8 @@ +2007-09-14 Werner Koch + + * gpg.c (build_lib_list): New. + (my_strusage): Print lib info. + 2007-08-27 Werner Koch * trustdb.c (USE_INTERNAL_REGEX): Remove support. diff --git a/g10/gpg.c b/g10/gpg.c index bda2257ee..599b7df5a 100644 --- a/g10/gpg.c +++ b/g10/gpg.c @@ -727,6 +727,7 @@ static int maybe_setuid = 1; static char *build_list( const char *text, char letter, const char *(*mapf)(int), int (*chkf)(int) ); +static char *build_lib_list (const char *text); static void set_cmd( enum cmd_and_opt_values *ret_cmd, enum cmd_and_opt_values new_cmd ); static void print_mds( const char *fname, int algo ); @@ -739,7 +740,7 @@ static void emergency_cleanup (void); static const char * my_strusage( int level ) { - static char *digests, *pubkeys, *ciphers, *zips; + static char *digests, *pubkeys, *ciphers, *zips, *libs; const char *p; switch( level ) { case 11: p = "gpg (GnuPG)"; @@ -807,6 +808,11 @@ my_strusage( int level ) check_compress_algo); p = zips; break; + case 38: + if (!libs) + libs = build_lib_list(_("Used libraries:")); + p = libs; + break; default: p = NULL; } @@ -869,6 +875,46 @@ build_list( const char *text, char letter, } +static char * +build_lib_list (const char *text) +{ + struct { const char *name; const char *version; } array[3]; + int idx; + size_t n; + char *list, *p; + + if (maybe_setuid) + gcry_control (GCRYCTL_INIT_SECMEM, 0, 0); /* Drop setuid. */ + + idx = 0; + array[idx].name = "gcrypt"; + array[idx++].version = gcry_check_version (NULL); + array[idx].name = NULL; + array[idx++].version = NULL; + + n = strlen (text) + 1; + for (idx=0; array[idx].name; idx++) + { + n += 2 + strlen (array[idx].name); + if (array[idx].version) + n += 1 + strlen (array[idx].version) + 1; + } + n++; + list = xmalloc (n+1); + p = stpcpy (stpcpy (list, text), " "); + for (idx=0; array[idx].name; idx++) + { + if (idx) + p = stpcpy (p, ", "); + p = stpcpy (p, array[idx].name); + if (array[idx].version) + p = stpcpy (stpcpy (stpcpy (p, "("), array[idx].version), ")"); + } + strcpy (p, "\n"); + return list; +} + + static void wrong_args( const char *text) { diff --git a/sm/ChangeLog b/sm/ChangeLog index f0d80e233..63a790bcc 100644 --- a/sm/ChangeLog +++ b/sm/ChangeLog @@ -1,3 +1,8 @@ +2007-09-14 Werner Koch + + * gpgsm.c (build_lib_list): New. + (my_strusage): Print lib info. + 2007-08-24 Werner Koch * Makefile.am (common_libs): Swap libkeybox and jnlib. diff --git a/sm/gpgsm.c b/sm/gpgsm.c index c51eabd6d..0d6da9548 100644 --- a/sm/gpgsm.c +++ b/sm/gpgsm.c @@ -481,6 +481,7 @@ static int default_validation_model; static char *build_list (const char *text, const char *(*mapf)(int), int (*chkf)(int)); +static char *build_lib_list (const char *text); static void set_cmd (enum cmd_and_opt_values *ret_cmd, enum cmd_and_opt_values new_cmd ); @@ -553,7 +554,7 @@ our_md_test_algo (int algo) static const char * my_strusage( int level ) { - static char *digests, *pubkeys, *ciphers; + static char *digests, *pubkeys, *ciphers, *libs; const char *p; switch (level) @@ -593,7 +594,12 @@ my_strusage( int level ) digests = build_list("Hash: ", gcry_md_algo_name, our_md_test_algo ); p = digests; break; - + case 38: + if (!libs) + libs = build_lib_list(_("Used libraries:")); + p = libs; + break; + default: p = NULL; break; } return p; @@ -632,6 +638,49 @@ build_list (const char *text, const char * (*mapf)(int), int (*chkf)(int)) return list; } +static char * +build_lib_list (const char *text) +{ + struct { const char *name; const char *version; } array[5]; + int idx; + size_t n; + char *list, *p; + + if (maybe_setuid) + gcry_control (GCRYCTL_INIT_SECMEM, 0, 0); /* Drop setuid. */ + + idx = 0; + array[idx].name = "gcrypt"; + array[idx++].version = gcry_check_version (NULL); + array[idx].name = "ksba"; + array[idx++].version = ksba_check_version (NULL); + array[idx].name = "assuan"; + array[idx++].version = GNUPG_LIBASSUAN_VERSION; + array[idx].name = NULL; + array[idx++].version = NULL; + + n = strlen (text) + 1; + for (idx=0; array[idx].name; idx++) + { + n += 2 + strlen (array[idx].name); + if (array[idx].version) + n += 1 + strlen (array[idx].version) + 1; + } + n++; + list = xmalloc (n+1); + p = stpcpy (stpcpy (list, text), " "); + for (idx=0; array[idx].name; idx++) + { + if (idx) + p = stpcpy (p, ", "); + p = stpcpy (p, array[idx].name); + if (array[idx].version) + p = stpcpy (stpcpy (stpcpy (p, "("), array[idx].version), ")"); + } + strcpy (p, "\n"); + return list; +} + /* Set the file pointer into binary mode if required. */ static void