mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-13 22:21:09 +02:00
2008-02-09 Marcus Brinkmann <marcus@g10code.de>
* gpg.c (main): New variable default_configname. Use it if save_configname is NULL (can happen if default configfile does not exist). Move default configname determination to ... (get_default_configname): ... this new function.
This commit is contained in:
parent
9c42222a7a
commit
791d8e6990
@ -1,3 +1,10 @@
|
|||||||
|
2008-02-09 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* gpg.c (main): New variable default_configname. Use it if
|
||||||
|
save_configname is NULL (can happen if default configfile does
|
||||||
|
not exist). Move default configname determination to ...
|
||||||
|
(get_default_configname): ... this new function.
|
||||||
|
|
||||||
2008-01-30 Werner Koch <wk@g10code.com>
|
2008-01-30 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
* keydb.c (maybe_create_keyring): Fixed last change.
|
* keydb.c (maybe_create_keyring): Fixed last change.
|
||||||
|
107
g10/gpg.c
107
g10/gpg.c
@ -1765,9 +1765,65 @@ gpg_deinit_default_ctrl (ctrl_t ctrl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char *
|
||||||
|
get_default_configname (void)
|
||||||
|
{
|
||||||
|
char *configname = NULL;
|
||||||
|
char *name = xstrdup ("gpg" EXTSEP_S "conf-" SAFE_VERSION);
|
||||||
|
char *ver = &name[strlen ("gpg" EXTSEP_S "conf-")];
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (configname)
|
||||||
|
{
|
||||||
|
char *tok;
|
||||||
|
|
||||||
|
xfree (configname);
|
||||||
|
configname = NULL;
|
||||||
|
|
||||||
|
if ((tok = strrchr (ver, SAFE_VERSION_DASH)))
|
||||||
|
*tok='\0';
|
||||||
|
else if ((tok = strrchr (ver, SAFE_VERSION_DOT)))
|
||||||
|
*tok='\0';
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
configname = make_filename (opt.homedir, name, NULL);
|
||||||
|
}
|
||||||
|
while (access (configname, R_OK));
|
||||||
|
|
||||||
|
xfree(name);
|
||||||
|
|
||||||
|
if (! configname)
|
||||||
|
configname = make_filename (opt.homedir, "gpg" EXTSEP_S "conf", NULL);
|
||||||
|
if (! access (configname, R_OK))
|
||||||
|
{
|
||||||
|
/* Print a warning when both config files are present. */
|
||||||
|
char *p = make_filename (opt.homedir, "options", NULL);
|
||||||
|
if (! access (p, R_OK))
|
||||||
|
log_info (_("NOTE: old default options file `%s' ignored\n"), p);
|
||||||
|
xfree (p);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Use the old default only if it exists. */
|
||||||
|
char *p = make_filename (opt.homedir, "options", NULL);
|
||||||
|
if (!access (p, R_OK))
|
||||||
|
{
|
||||||
|
xfree (configname);
|
||||||
|
configname = p;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
xfree (p);
|
||||||
|
}
|
||||||
|
|
||||||
|
return configname;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv )
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
ARGPARSE_ARGS pargs;
|
ARGPARSE_ARGS pargs;
|
||||||
IOBUF a;
|
IOBUF a;
|
||||||
@ -1784,6 +1840,7 @@ main (int argc, char **argv )
|
|||||||
FILE *configfp = NULL;
|
FILE *configfp = NULL;
|
||||||
char *configname = NULL;
|
char *configname = NULL;
|
||||||
char *save_configname = NULL;
|
char *save_configname = NULL;
|
||||||
|
char *default_configname = NULL;
|
||||||
unsigned configlineno;
|
unsigned configlineno;
|
||||||
int parse_debug = 0;
|
int parse_debug = 0;
|
||||||
int default_config = 1;
|
int default_config = 1;
|
||||||
@ -1960,49 +2017,10 @@ main (int argc, char **argv )
|
|||||||
|
|
||||||
|
|
||||||
/* Try for a version specific config file first */
|
/* Try for a version specific config file first */
|
||||||
if( default_config )
|
default_configname = get_default_configname ();
|
||||||
{
|
if (default_config)
|
||||||
char *name=xstrdup("gpg" EXTSEP_S "conf-" SAFE_VERSION);
|
configname = xstrdup (default_configname);
|
||||||
char *ver=&name[strlen("gpg" EXTSEP_S "conf-")];
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if(configname)
|
|
||||||
{
|
|
||||||
char *tok;
|
|
||||||
|
|
||||||
xfree(configname);
|
|
||||||
configname=NULL;
|
|
||||||
|
|
||||||
if((tok=strrchr(ver,SAFE_VERSION_DASH)))
|
|
||||||
*tok='\0';
|
|
||||||
else if((tok=strrchr(ver,SAFE_VERSION_DOT)))
|
|
||||||
*tok='\0';
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
configname = make_filename(opt.homedir,name,NULL);
|
|
||||||
}
|
|
||||||
while(access(configname,R_OK));
|
|
||||||
|
|
||||||
xfree(name);
|
|
||||||
|
|
||||||
if(!configname)
|
|
||||||
configname=make_filename(opt.homedir, "gpg" EXTSEP_S "conf", NULL );
|
|
||||||
if (!access (configname, R_OK))
|
|
||||||
{ /* Print a warning when both config files are present. */
|
|
||||||
char *p = make_filename(opt.homedir, "options", NULL );
|
|
||||||
if (!access (p, R_OK))
|
|
||||||
log_info (_("NOTE: old default options file `%s' ignored\n"), p);
|
|
||||||
xfree (p);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ /* Keep on using the old default one. */
|
|
||||||
xfree (configname);
|
|
||||||
configname = make_filename(opt.homedir, "options", NULL );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
argc = orig_argc;
|
argc = orig_argc;
|
||||||
argv = orig_argv;
|
argv = orig_argv;
|
||||||
pargs.argc = &argc;
|
pargs.argc = &argc;
|
||||||
@ -2867,10 +2885,11 @@ main (int argc, char **argv )
|
|||||||
directly after the option parsing. */
|
directly after the option parsing. */
|
||||||
if (cmd == aGPGConfList)
|
if (cmd == aGPGConfList)
|
||||||
{
|
{
|
||||||
gpgconf_list (save_configname);
|
gpgconf_list (save_configname ? save_configname : default_configname);
|
||||||
g10_exit (0);
|
g10_exit (0);
|
||||||
}
|
}
|
||||||
xfree (save_configname);
|
xfree (save_configname);
|
||||||
|
xfree (default_configname);
|
||||||
|
|
||||||
if( nogreeting )
|
if( nogreeting )
|
||||||
greeting = 0;
|
greeting = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user