1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-04-12 22:11:29 +02:00

* g10.c: New command --gpgconf-list. (gpgconf_list): New. From Werner on

stable branch.
This commit is contained in:
David Shaw 2004-05-20 17:06:34 +00:00
parent 4eec3c186d
commit d201b2a92d
2 changed files with 59 additions and 11 deletions

View File

@ -1,3 +1,8 @@
2004-05-20 David Shaw <dshaw@jabberwocky.com>
* g10.c: New command --gpgconf-list.
(gpgconf_list): New. From Werner on stable branch.
2004-05-19 David Shaw <dshaw@jabberwocky.com> 2004-05-19 David Shaw <dshaw@jabberwocky.com>
* pubkey-enc.c (get_session_key, get_it), keyedit.c * pubkey-enc.c (get_session_key, get_it), keyedit.c

View File

@ -95,6 +95,7 @@ enum cmd_and_opt_values
aNRSignKey, aNRSignKey,
aNRLSignKey, aNRLSignKey,
aListConfig, aListConfig,
aGPGConfList,
aListPackets, aListPackets,
aEditKey, aEditKey,
aDeleteKeys, aDeleteKeys,
@ -397,6 +398,7 @@ static ARGPARSE_OPTS opts[] = {
{ aChangePIN, "change-pin", 256, N_("change a card's PIN")}, { aChangePIN, "change-pin", 256, N_("change a card's PIN")},
#endif #endif
{ aListConfig, "list-config", 256, "@"}, { aListConfig, "list-config", 256, "@"},
{ aGPGConfList, "gpgconf-list", 256, "@" },
{ aListPackets, "list-packets",256, "@"}, { aListPackets, "list-packets",256, "@"},
{ aExportOwnerTrust, "export-ownertrust", 256, "@"}, { aExportOwnerTrust, "export-ownertrust", 256, "@"},
{ aImportOwnerTrust, "import-ownertrust", 256, "@"}, { aImportOwnerTrust, "import-ownertrust", 256, "@"},
@ -1333,6 +1335,27 @@ list_config(char *items)
} }
/* List options and default values in the GPG Conf format. This is a
new tool distributed with gnupg 1.9.x but we also want some limited
support in older gpg versions. The output is the name of the
configuration file and a list of options available for editing by
gpgconf. */
static void
gpgconf_list (const char *configfile)
{
/* The following definitions are taken from gnupg/tools/gpgconf-comp.c. */
#define GC_OPT_FLAG_NONE 0UL
#define GC_OPT_FLAG_DEFAULT (1UL << 4)
printf ("gpgconf-gpg.conf:%lu:\"%s\n",
GC_OPT_FLAG_DEFAULT,configfile?configfile:"/dev/null");
printf ("verbose:%lu:\n", GC_OPT_FLAG_NONE);
printf ("quiet:%lu:\n", GC_OPT_FLAG_NONE);
printf ("keyserver:%lu:\n", GC_OPT_FLAG_NONE);
}
/* Collapses argc/argv into a single string that must be freed */ /* Collapses argc/argv into a single string that must be freed */
static char * static char *
collapse_args(int argc,char *argv[]) collapse_args(int argc,char *argv[])
@ -1376,6 +1399,7 @@ main( int argc, char **argv )
int detached_sig = 0; int detached_sig = 0;
FILE *configfp = NULL; FILE *configfp = NULL;
char *configname = NULL; char *configname = NULL;
char *save_configname = NULL;
unsigned configlineno; unsigned configlineno;
int parse_debug = 0; int parse_debug = 0;
int default_config = 1; int default_config = 1;
@ -1629,16 +1653,19 @@ main( int argc, char **argv )
{ {
switch( pargs.r_opt ) switch( pargs.r_opt )
{ {
case aCheckKeys: set_cmd( &cmd, aCheckKeys); break; case aCheckKeys:
case aListConfig: set_cmd( &cmd, aListConfig); break; case aListConfig:
case aListPackets: set_cmd( &cmd, aListPackets); break; case aGPGConfList:
case aImport: set_cmd( &cmd, aImport); break; case aListPackets:
case aFastImport: set_cmd( &cmd, aFastImport); break; case aImport:
case aSendKeys: set_cmd( &cmd, aSendKeys); break; case aFastImport:
case aRecvKeys: set_cmd( &cmd, aRecvKeys); break; case aSendKeys:
case aSearchKeys: set_cmd( &cmd, aSearchKeys); break; case aRecvKeys:
case aRefreshKeys: set_cmd( &cmd, aRefreshKeys); break; case aSearchKeys:
case aExport: set_cmd( &cmd, aExport); break; case aRefreshKeys:
case aExport:
set_cmd (&cmd, pargs.r_opt);
break;
case aListKeys: set_cmd( &cmd, aListKeys); break; case aListKeys: set_cmd( &cmd, aListKeys); break;
case aListSigs: set_cmd( &cmd, aListSigs); break; case aListSigs: set_cmd( &cmd, aListSigs); break;
case aExportSecret: set_cmd( &cmd, aExportSecret); break; case aExportSecret: set_cmd( &cmd, aExportSecret); break;
@ -2316,15 +2343,31 @@ main( int argc, char **argv )
} }
} }
if( configfp ) { if( configfp ) {
fclose( configfp ); fclose( configfp );
configfp = NULL; configfp = NULL;
m_free(configname); configname = NULL; /* Remember the first config file name. */
if (!save_configname)
save_configname = configname;
else
m_free(configname);
configname = NULL;
goto next_pass; goto next_pass;
} }
m_free( configname ); configname = NULL; m_free( configname ); configname = NULL;
if( log_get_errorcount(0) ) if( log_get_errorcount(0) )
g10_exit(2); g10_exit(2);
/* The command --gpgconf-list is pretty simple and may be called
directly after the option parsing. */
if (cmd == aGPGConfList)
{
gpgconf_list (save_configname);
g10_exit (0);
}
m_free (save_configname);
if( nogreeting ) if( nogreeting )
greeting = 0; greeting = 0;