/[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 222 by twoaday, Thu Jun 1 08:30:46 2006 UTC revision 248 by twoaday, Fri Jul 28 11:11:09 2006 UTC
# Line 92  get_gnupg_path (void) Line 92  get_gnupg_path (void)
92      char *path;      char *path;
93    
94      path = get_reg_entry_gpg (GPG_REG_HOME);      path = get_reg_entry_gpg (GPG_REG_HOME);
95      if (path) {      if (path && dir_exist_check (path) == 0)
96          if (dir_exist_check (path) == 0)          return path;
97              return path;      free_if_alloc (path);
         free_if_alloc (path);  
     }  
98      path = multi_gnupg_path (1);      path = multi_gnupg_path (1);
99      return path;      return path;
100  }  }
# Line 162  get_gnupg_keyring (int pub, int strict) Line 160  get_gnupg_keyring (int pub, int strict)
160  /* Return the full path (with the gpg exe name). First the registry is scanned  /* Return the full path (with the gpg exe name). First the registry is scanned
161     for the entry 'gpgProgram'. If it wasn't set, the default path is the     for the entry 'gpgProgram'. If it wasn't set, the default path is the
162     appended string 'gpg.exe' is used. */     appended string 'gpg.exe' is used. */
   
 /* FIXME:  Use gpgme's engine info here. */  
163  char*  char*
164  get_gnupg_prog (void)  get_gnupg_prog (void)
165  {      {    
166      char *p;      char *path;
167      char *pgm = NULL;      char *pgm;
168    
169      p = get_reg_entry_gpg (GPG_REG_EXE);      pgm = get_reg_entry_gpg (GPG_REG_EXE);
170      if (!p) {      if (pgm)
171          char *path = get_gnupg_path ();          return pgm;
172          if (!path)      path = get_gnupg_path ();
173              return NULL;      if (!path)
174          pgm = make_filename (path, "gpg", "exe");          return NULL;    
175          free_if_alloc (path);      pgm = make_filename (path, "gpg", "exe");
176      }      free_if_alloc (path);    
     else {  
         pgm = m_strdup (p);  
         free_if_alloc (p);  
     }  
177      return pgm;      return pgm;
178  }  }
179    
# Line 198  default_key_from_cache (int *ret_no_usea Line 190  default_key_from_cache (int *ret_no_usea
190      char *keyid = NULL;      char *keyid = NULL;
191    
192      sec = keycache_get_ctx (0);      sec = keycache_get_ctx (0);
     if (!sec)  
         BUG (0);  
193      pub = keycache_get_ctx (1);      pub = keycache_get_ctx (1);
194      gpg_keycache_rewind (sec);      gpg_keycache_rewind (sec);
195      while (!gpg_keycache_next_key (sec, 1, &key)) {      while (!gpg_keycache_next_key (sec, 1, &key)) {
# Line 211  default_key_from_cache (int *ret_no_usea Line 201  default_key_from_cache (int *ret_no_usea
201          }          }
202      }      }
203      if (!keyid)      if (!keyid)
204          *ret_no_useable = 1;              *ret_no_useable = 1;
205      return keyid;      return keyid;
206  }  }
207    
# Line 377  check_gnupg_engine (const char *need_gpg Line 367  check_gnupg_engine (const char *need_gpg
367      }      }
368    
369      /* We need to exec GPG again to find out if IDEA is available. */      /* We need to exec GPG again to find out if IDEA is available. */
370      if (gpg_get_version (&eng))      if (gpg_get_version (&eng)) {
371            gpgme_release (ctx);
372          return -1;          return -1;
373        }
374      if (strstr (eng, "IDEA"))      if (strstr (eng, "IDEA"))
375          idea_available = 1;          idea_available = 1;
376      safe_free (eng);      safe_free (eng);
# Line 412  check_gnupg_cfgfile (const char *fname, Line 404  check_gnupg_cfgfile (const char *fname,
404    
405      *r_secrings = 0;      *r_secrings = 0;
406      *r_pubrings = 0;      *r_pubrings = 0;
407    
408      if (parse_gpg_options (fname, &opt))      if (parse_gpg_options (fname, &opt))
409          return WPTERR_FILE_OPEN;          return WPTERR_FILE_OPEN;
   
410      for (e = opt->list; e; e = e->next) {      for (e = opt->list; e; e = e->next) {
411          if (!strcmp( e->name, "secret-keyring")) {          if (!strcmp( e->name, "secret-keyring")) {
412              if (!file_exist_check (e->val))              if (!file_exist_check (e->val))
# Line 598  set_gnupg_default_key (const char *key) Line 590  set_gnupg_default_key (const char *key)
590    
591  /* Set the contents of the options file. */  /* Set the contents of the options file. */
592  int  int
593  set_gnupg_options( const char *buf, size_t buflen )  set_gnupg_options (const char *buf, size_t buflen)
594  {  {
595      FILE *fp;        FILE *fp;  
596      char *optfile = NULL;      char *optfile = NULL;
597    
598      optfile = get_gnupg_cfgfile( );      optfile = get_gnupg_cfgfile ();
599      if( optfile == NULL )      if (!optfile)
600          return WPTERR_FILE_CREAT;          return WPTERR_FILE_CREAT;
601    
602      fp = fopen( optfile, "wb" );      fp = fopen (optfile, "wb");
603      if( fp == NULL ) {      if (!fp) {
604          free_if_alloc( optfile );          free_if_alloc (optfile);
605          return WPTERR_FILE_CREAT;          return WPTERR_FILE_CREAT;
606      }      }
607      fwrite( buf, 1, buflen, fp );      fwrite (buf, 1, buflen, fp);
608      fclose( fp );      fclose (fp);
609      free_if_alloc( optfile );      free_if_alloc (optfile);
610      return 0;      return 0;
611  } /* set_gnupg_options */  }
612    
613    
614  /*  /*
615   * Check if the line contains a valid GPG argument.   * Check if the line contains a valid GPG argument.
616   */   */
617  static int  static int
618  check_line( const char *buf )  check_line (const char *buf)
619  {  {
620      int j, len;      int j, len;
621      int rc = 0;      int rc = 0;
622    
623      if( *buf == '#' || *buf == '\r' || *buf == '\n' )      if (*buf == '#' || *buf == '\r' || *buf == '\n')
624          return 1;          return 1;
625      rc = 0;      rc = 0;
626      for ( j = 0; valid_gpg_args[j]; j++ ) {      for (j = 0; valid_gpg_args[j]; j++) {
627          len = strlen( valid_gpg_args[j] );          len = strlen (valid_gpg_args[j]);
628          if( !strncmp( valid_gpg_args[j], buf, len ) )          if (!strncmp (valid_gpg_args[j], buf, len))
629              rc = 1;                  rc = 1;
630      }      }
631    
632      return rc;      return rc;
633  } /* check_line */  }
634    
635    
636  int  int
637  check_gnupg_options( const char *buf )  check_gnupg_options (const char *buf)
638  {  {
639      char line[1024];      char line[1024];
640      int nbytes = 0;      int nbytes = 0;
# Line 660  check_gnupg_options( const char *buf ) Line 653  check_gnupg_options( const char *buf )
653      }      }
654    
655      return 0;      return 0;
656  } /* check_gnupg_options */  }
657    
658    
659  /* Store the last access of the file inside the watcher @ctx. */  /* Store the last access of the file inside the watcher @ctx. */
# Line 717  init_gnupg_table (void) Line 710  init_gnupg_table (void)
710    
711      for (j = 0; j < gpg_table_count; j++) {      for (j = 0; j < gpg_table_count; j++) {
712          p = gpg_table[j].object = m_strdup (gpg_objs[j]);          p = gpg_table[j].object = m_strdup (gpg_objs[j]);
         if (!p)  
             BUG (NULL);  
713          memset (&gpg_table[j].access, 0, sizeof (FILETIME));          memset (&gpg_table[j].access, 0, sizeof (FILETIME));
714          memset (&gpg_table[j].last_access, 0, sizeof (FILETIME));          memset (&gpg_table[j].last_access, 0, sizeof (FILETIME));
715          gpg_table[j].modified = 0;          gpg_table[j].modified = 0;
# Line 1081  gnupg_backup_keyrings (int auto_backup, Line 1072  gnupg_backup_keyrings (int auto_backup,
1072          FILE *fp;          FILE *fp;
1073    
1074          dstpath = m_strdup (reg_prefs.backup.path);          dstpath = m_strdup (reg_prefs.backup.path);
         if (!dstpath)  
             BUG (0);  
1075          tmpfile = make_filename (reg_prefs.backup.path, "test", "tmp");          tmpfile = make_filename (reg_prefs.backup.path, "test", "tmp");
1076          fp = fopen (tmpfile, "wb");          fp = fopen (tmpfile, "wb");
1077          if (!fp)          if (!fp)
1078              rc = log_box (_("Backup"), MB_WARN|MB_RETRYCANCEL,              rc = log_box (_("Backup"), MB_WARN|MB_RETRYCANCEL,
1079                            _("The backup drive '%s' does not seems to accessable.\n"                            _("The backup drive '%s' does not seems to be accessable.\n"
1080                              "Please insert/check the drive to continue."), dstpath);                              "Please insert/check the drive to continue."), dstpath);
1081          else {          else {
1082              rc = 0;              rc = 0;

Legend:
Removed from v.222  
changed lines
  Added in v.248

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26