From e538b9954956643623fe7f113b214b09109003db Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Thu, 2 Jan 2003 17:47:35 +0000 Subject: [PATCH] * keydb.c (keydb_add_resource): Don't assume that try_make_homedir terminates but check again for the existence of the directory and continue then. * openfile.c (copy_options_file): Print a warning if the skeleton file has active options. --- g10/ChangeLog | 8 ++++++++ g10/keydb.c | 23 +++++++++++++++-------- g10/openfile.c | 21 ++++++++++++++++++++- 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/g10/ChangeLog b/g10/ChangeLog index 33fd17f09..f43d97a5d 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,11 @@ +2003-01-02 Werner Koch + + * keydb.c (keydb_add_resource): Don't assume that try_make_homedir + terminates but check again for the existence of the directory and + continue then. + * openfile.c (copy_options_file): Print a warning if the skeleton + file has active options. + 2002-12-27 David Shaw * getkey.c (merge_selfsigs_main), main.h, sig-check.c diff --git a/g10/keydb.c b/g10/keydb.c index d8dd83fe6..d06454fc2 100644 --- a/g10/keydb.c +++ b/g10/keydb.c @@ -159,14 +159,21 @@ keydb_add_resource (const char *url, int force, int secret) last_slash_in_filename = strrchr (filename, DIRSEP_C); *last_slash_in_filename = 0; if (access(filename, F_OK)) - { /* on the first time we try to create the default - homedir and in this case the process will be - terminated, so that on the next invocation it can - read the options file in on startup */ - try_make_homedir (filename); - rc = G10ERR_OPEN_FILE; - *last_slash_in_filename = DIRSEP_C; - goto leave; + { /* On the first time we try to create the default + homedir and check again. */ + static int tried; + + if (!tried) + { + tried = 1; + try_make_homedir (filename); + } + if (access (filename, F_OK)) + { + rc = G10ERR_OPEN_FILE; + *last_slash_in_filename = DIRSEP_C; + goto leave; + } } *last_slash_in_filename = DIRSEP_C; diff --git a/g10/openfile.c b/g10/openfile.c index 64e1b8dc2..144118d34 100644 --- a/g10/openfile.c +++ b/g10/openfile.c @@ -301,6 +301,8 @@ copy_options_file( const char *destdir ) int linefeeds=0; int c; mode_t oldmask; + int esc = 0; + int any_option = 0; if( opt.dry_run ) return; @@ -329,12 +331,27 @@ copy_options_file( const char *destdir ) if( c == '\n' ) linefeeds++; } - else + else { putc( c, dst ); + if (c== '\n') + esc = 1; + else if (esc == 1) { + if (c == ' ' || c == '\t') + ; + else if (c == '#') + esc = 2; + else + any_option = 1; + } + } } fclose( dst ); fclose( src ); log_info(_("new configuration file `%s' created\n"), fname ); + if (any_option) + log_info (_("WARNING: options in `%s'" + " are not yet active during this run\n"), + fname); m_free(fname); } @@ -371,3 +388,5 @@ try_make_homedir( const char *fname ) /* g10_exit(1); */ } } + +