/[winpt]/trunk/Src/wptGPG.cpp
ViewVC logotype

Diff of /trunk/Src/wptGPG.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 132 by twoaday, Mon Dec 19 13:05:59 2005 UTC revision 133 by twoaday, Mon Jan 9 09:15:29 2006 UTC
# Line 156  get_gnupg_keyring (int pub, int strict) Line 156  get_gnupg_keyring (int pub, int strict)
156      if (!path)      if (!path)
157          return NULL;          return NULL;
158      keyring = make_filename (path, pub? "pubring" : "secring", "gpg");      keyring = make_filename (path, pub? "pubring" : "secring", "gpg");
159      if (!strict && !file_exist_check (keyring)) {      if (strict && !file_exist_check (keyring)) {
160            free_if_alloc (path);
161            return keyring;
162        }
163        else if (!strict) {
164          free_if_alloc (path);          free_if_alloc (path);
165          return keyring;          return keyring;
166      }      }
# Line 419  check_gnupg_cfgfile (const char *fname, Line 423  check_gnupg_cfgfile (const char *fname,
423  } /* check_gnupg_cfgfile */  } /* check_gnupg_cfgfile */
424    
425    
426  /*  /* Usually GPG creates the pubring.gpg, secring.gpg on
427   * Check if both keyrings are located in the gnupg home directory.     the first start, but to make sure they always exist
428   */     create them empty if needed. */
429    static void
430    create_empty_keyring (int _pub)
431    {
432        char *name;
433        FILE *f;
434    
435        name = get_gnupg_keyring (_pub, 0);
436        if (file_exist_check (name) != 0) {
437            f = fopen (name, "ab");
438            if (f != NULL)
439                fclose (f);
440        }
441        free_if_alloc (name);
442    }
443    
444    
445    /* Check if both keyrings are located in the gnupg home directory. */
446  int  int
447  gnupg_access_files (void)  gnupg_access_files (void)
448  {  {
# Line 430  gnupg_access_files (void) Line 451  gnupg_access_files (void)
451      int secrings = 0, pubrings = 0;      int secrings = 0, pubrings = 0;
452      char *optfile;      char *optfile;
453    
454        create_empty_keyring (1);
455      if (gnupg_access_keyring (1))      if (gnupg_access_keyring (1))
456          rc = WPTERR_GPG_KEYRINGS;          rc = WPTERR_GPG_KEYRINGS;
457      else      else
458          pubring_ok = 1;          pubring_ok = 1;
459    
460        create_empty_keyring (0);
461      if (gnupg_access_keyring (0))      if (gnupg_access_keyring (0))
462          rc = WPTERR_GPG_KEYRINGS;          rc = WPTERR_GPG_KEYRINGS;
463      else      else
# Line 463  gnupg_access_files (void) Line 486  gnupg_access_files (void)
486          rc = WPTERR_GPG_KEYRINGS;          rc = WPTERR_GPG_KEYRINGS;
487      }      }
488      return rc;      return rc;
489  } /* gnupg_access_files */  }
490    
491    
492  static int  static int
# Line 476  create_gpg_options (void) Line 499  create_gpg_options (void)
499      if( s == NULL )      if( s == NULL )
500          return WPTERR_FILE_CREAT;          return WPTERR_FILE_CREAT;
501      optfile = make_filename (s, GPG_CONF, NULL);      optfile = make_filename (s, GPG_CONF, NULL);
502      fp = fopen( optfile, "wb" );      fp = fopen (optfile, "wb");
503      if( fp == NULL ) {        if (fp == NULL) {  
504          return WPTERR_FILE_CREAT;          return WPTERR_FILE_CREAT;
505          goto fail;          goto fail;
506      }      }
507      fwrite( options_skel, 1, strlen( options_skel ), fp );      fwrite (options_skel, 1, strlen (options_skel), fp);
508      fclose( fp );      fclose (fp);
509    
510  fail:  fail:
511      free_if_alloc( s );      free_if_alloc (s);
512      free_if_alloc( optfile );      free_if_alloc (optfile);
513      return 0;      return 0;
514  } /* create_gpg_options */  } /* create_gpg_options */
515    

Legend:
Removed from v.132  
changed lines
  Added in v.133

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26