1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

Print library versions according to GNU standards.

This commit is contained in:
Werner Koch 2008-11-18 18:01:03 +00:00
parent 4b3389b7bd
commit 5dc1c18c3a
9 changed files with 162 additions and 102 deletions

View File

@ -1,3 +1,8 @@
2008-11-18 Werner Koch <wk@g10code.com>
* gpg-agent.c (make_libversion): New.
(my_strusage): Print libgcrypt version
2008-11-11 Werner Koch <wk@g10code.com>
* call-scd.c (membuf_data_cb): Change return type to

View File

@ -280,11 +280,30 @@ static unsigned long pth_thread_id (void)
Functions.
*/
static char *
make_libversion (const char *libname, const char *(*getfnc)(const char*))
{
const char *s;
char *result;
if (maybe_setuid)
{
gcry_control (GCRYCTL_INIT_SECMEM, 0, 0); /* Drop setuid. */
maybe_setuid = 0;
}
s = getfnc (NULL);
result = xmalloc (strlen (libname) + 1 + strlen (s) + 1);
strcpy (stpcpy (stpcpy (result, libname), " "), s);
return result;
}
static const char *
my_strusage (int level)
{
static char *ver_gcry;
const char *p;
switch (level)
{
case 11: p = "gpg-agent (GnuPG)";
@ -293,6 +312,12 @@ my_strusage (int level)
case 17: p = PRINTABLE_OS_NAME; break;
case 19: p = _("Please report bugs to <" PACKAGE_BUGREPORT ">.\n");
break;
case 20:
if (!ver_gcry)
ver_gcry = make_libversion ("libgcrypt", gcry_check_version);
p = ver_gcry;
break;
case 1:
case 40: p = _("Usage: gpg-agent [options] (-h for help)");
break;

View File

@ -1,3 +1,11 @@
2008-11-18 Werner Koch <wk@g10code.com>
* gpg.c (build_lib_list): Remove.
(make_libversion): New.
(my_strusage): Use it.
* gpgv.c (make_libversion): New.
(my_strusage): Print libgcrypt version.
2008-11-13 Werner Koch <wk@g10code.com>
* gpgv.c: Use new ARGPARSE macros and re-indent.

View File

@ -766,7 +766,6 @@ 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 );
@ -776,11 +775,30 @@ static void add_keyserver_url( const char *string, int which );
static void emergency_cleanup (void);
static char *
make_libversion (const char *libname, const char *(*getfnc)(const char*))
{
const char *s;
char *result;
if (maybe_setuid)
{
gcry_control (GCRYCTL_INIT_SECMEM, 0, 0); /* Drop setuid. */
maybe_setuid = 0;
}
s = getfnc (NULL);
result = xmalloc (strlen (libname) + 1 + strlen (s) + 1);
strcpy (stpcpy (stpcpy (result, libname), " "), s);
return result;
}
static const char *
my_strusage( int level )
{
static char *digests, *pubkeys, *ciphers, *zips, *libs;
const char *p;
static char *digests, *pubkeys, *ciphers, *zips, *ver_gcry;
const char *p;
switch( level ) {
case 11: p = "gpg (GnuPG)";
break;
@ -790,14 +808,20 @@ my_strusage( int level )
_("Please report bugs to <gnupg-bugs@gnu.org>.\n");
break;
case 20:
if (!ver_gcry)
ver_gcry = make_libversion ("libgcrypt", gcry_check_version);
p = ver_gcry;
break;
#ifdef IS_DEVELOPMENT_VERSION
case 20:
case 25:
p="NOTE: THIS IS A DEVELOPMENT VERSION!";
break;
case 21:
case 26:
p="It is only intended for test purposes and should NOT be";
break;
case 22:
case 27:
p="used in a production environment or with production keys!";
break;
#endif
@ -847,11 +871,6 @@ 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;
}
@ -914,46 +933,6 @@ 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)
{

View File

@ -87,10 +87,24 @@ static ARGPARSE_OPTS opts[] = {
int g10_errors_seen = 0;
static char *
make_libversion (const char *libname, const char *(*getfnc)(const char*))
{
const char *s;
char *result;
s = getfnc (NULL);
result = xmalloc (strlen (libname) + 1 + strlen (s) + 1);
strcpy (stpcpy (stpcpy (result, libname), " "), s);
return result;
}
static const char *
my_strusage( int level )
{
static char *ver_gcry;
const char *p;
switch (level)
{
case 11: p = "gpgv (GnuPG)";
@ -106,6 +120,13 @@ my_strusage( int level )
"Check signatures against known trusted keys\n");
break;
case 20:
if (!ver_gcry)
ver_gcry = make_libversion ("libgcrypt", gcry_check_version);
p = ver_gcry;
break;
default: p = NULL;
}
return p;

View File

@ -1,3 +1,8 @@
2008-11-18 Werner Koch <wk@g10code.com>
* scdaemon.c (make_libversion): New.
(my_strusage): Print libgcrypt and libksba version.
2008-11-03 Werner Koch <wk@g10code.com>
* command.c (server_local_s): Add field DISCONNECT_ALLOWED.

View File

@ -200,10 +200,30 @@ static int fixed_gcry_pth_init (void)
static char *
make_libversion (const char *libname, const char *(*getfnc)(const char*))
{
const char *s;
char *result;
if (maybe_setuid)
{
gcry_control (GCRYCTL_INIT_SECMEM, 0, 0); /* Drop setuid. */
maybe_setuid = 0;
}
s = getfnc (NULL);
result = xmalloc (strlen (libname) + 1 + strlen (s) + 1);
strcpy (stpcpy (stpcpy (result, libname), " "), s);
return result;
}
static const char *
my_strusage (int level)
{
static char *ver_gcry, *ver_ksba;
const char *p;
switch (level)
{
case 11: p = "scdaemon (GnuPG)";
@ -212,6 +232,16 @@ my_strusage (int level)
case 17: p = PRINTABLE_OS_NAME; break;
case 19: p = _("Please report bugs to <" PACKAGE_BUGREPORT ">.\n");
break;
case 20:
if (!ver_gcry)
ver_gcry = make_libversion ("libgcrypt", gcry_check_version);
p = ver_gcry;
break;
case 21:
if (!ver_ksba)
ver_ksba = make_libversion ("libksba", ksba_check_version);
p = ver_ksba;
break;
case 1:
case 40: p = _("Usage: scdaemon [options] (-h for help)");
break;

View File

@ -1,3 +1,9 @@
2008-11-18 Werner Koch <wk@g10code.com>
* gpgsm.c (make_libversion): New.
(my_strusage): Use new fucntion.
(build_lib_list): Remove.
2008-11-13 Werner Koch <wk@g10code.com>
* gpgsm.c: Remove all unused options. Use ARGPARSE macros.

View File

@ -413,7 +413,6 @@ 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 );
@ -479,10 +478,29 @@ our_md_test_algo (int algo)
}
static char *
make_libversion (const char *libname, const char *(*getfnc)(const char*))
{
const char *s;
char *result;
if (maybe_setuid)
{
gcry_control (GCRYCTL_INIT_SECMEM, 0, 0); /* Drop setuid. */
maybe_setuid = 0;
}
s = getfnc (NULL);
result = xmalloc (strlen (libname) + 1 + strlen (s) + 1);
strcpy (stpcpy (stpcpy (result, libname), " "), s);
return result;
}
static const char *
my_strusage( int level )
{
static char *digests, *pubkeys, *ciphers, *libs;
static char *digests, *pubkeys, *ciphers;
static char *ver_gcry, *ver_ksba;
const char *p;
switch (level)
@ -502,6 +520,17 @@ my_strusage( int level )
"default operation depends on the input data\n");
break;
case 20:
if (!ver_gcry)
ver_gcry = make_libversion ("libgcrypt", gcry_check_version);
p = ver_gcry;
break;
case 21:
if (!ver_ksba)
ver_ksba = make_libversion ("libksba", ksba_check_version);
p = ver_ksba;
break;
case 31: p = "\nHome: "; break;
case 32: p = opt.homedir; break;
case 33: p = _("\nSupported algorithms:\n"); break;
@ -522,11 +551,6 @@ 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;
}
@ -566,49 +590,6 @@ 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
@ -939,7 +920,7 @@ main ( int argc, char **argv)
}
/* initialize the secure memory. */
/* Initialize the secure memory. */
gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0);
maybe_setuid = 0;