~ubuntu-branches/ubuntu/karmic/gnupg2/karmic-updates

« back to all changes in this revision

Viewing changes to sm/import.c

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Viehmann
  • Date: 2008-10-04 10:25:53 UTC
  • mfrom: (5.1.15 intrepid)
  • Revision ID: james.westby@ubuntu.com-20081004102553-fv62pp8dsitxli47
Tags: 2.0.9-3.1
* Non-maintainer upload.
* agent/gpg-agent.c: Deinit the threading library before exec'ing
  the command to run in --daemon mode. And because that still doesn't
  restore the sigprocmask, do that manually. Closes: #499569

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *
6
6
 * GnuPG is free software; you can redistribute it and/or modify
7
7
 * it under the terms of the GNU General Public License as published by
8
 
 * the Free Software Foundation; either version 2 of the License, or
 
8
 * the Free Software Foundation; either version 3 of the License, or
9
9
 * (at your option) any later version.
10
10
 *
11
11
 * GnuPG is distributed in the hope that it will be useful,
14
14
 * GNU General Public License for more details.
15
15
 *
16
16
 * You should have received a copy of the GNU General Public License
17
 
 * along with this program; if not, write to the Free Software
18
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 
17
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
19
18
 */
20
19
 
21
20
#include <config.h>
34
33
#include "keydb.h"
35
34
#include "exechelp.h"
36
35
#include "i18n.h"
 
36
#include "sysutils.h"
37
37
 
38
38
struct stats_s {
39
39
  unsigned long count;
52
52
 
53
53
 
54
54
static void
55
 
print_imported_status (CTRL ctrl, ksba_cert_t cert, int new_cert)
 
55
print_imported_status (ctrl_t ctrl, ksba_cert_t cert, int new_cert)
56
56
{
57
57
  char *fpr;
58
58
     
75
75
   4 := "Error storing certificate".
76
76
*/
77
77
static void
78
 
print_import_problem (CTRL ctrl, ksba_cert_t cert, int reason)
 
78
print_import_problem (ctrl_t ctrl, ksba_cert_t cert, int reason)
79
79
{
80
80
  char *fpr = NULL;
81
81
  char buf[25];
100
100
 
101
101
 
102
102
void
103
 
print_imported_summary (CTRL ctrl, struct stats_s *stats)
 
103
print_imported_summary (ctrl_t ctrl, struct stats_s *stats)
104
104
{
105
105
  char buf[14*25];
106
106
 
146
146
 
147
147
 
148
148
static void
149
 
check_and_store (CTRL ctrl, struct stats_s *stats, ksba_cert_t cert, int depth)
 
149
check_and_store (ctrl_t ctrl, struct stats_s *stats,
 
150
                 ksba_cert_t cert, int depth)
150
151
{
151
152
  int rc;
152
153
 
171
172
     
172
173
     Optionally we do a full validation in addition to the basic test.
173
174
  */
174
 
  rc = gpgsm_basic_cert_check (cert);
 
175
  rc = gpgsm_basic_cert_check (ctrl, cert);
175
176
  if (!rc && ctrl->with_validation)
176
 
    rc = gpgsm_validate_chain (ctrl, cert, NULL, 0, NULL, 0);
 
177
    rc = gpgsm_validate_chain (ctrl, cert, "", NULL, 0, NULL, 0, NULL);
177
178
  if (!rc || (!ctrl->with_validation
178
179
              && gpg_err_code (rc) == GPG_ERR_MISSING_CERT) )
179
180
    {
215
216
             the chain.  This is required in case we already stored
216
217
             parent certificates in the ephemeral keybox.  Do not
217
218
             update the statistics, though. */
218
 
          if (!gpgsm_walk_cert_chain (cert, &next))
 
219
          if (!gpgsm_walk_cert_chain (ctrl, cert, &next))
219
220
            {
220
221
              check_and_store (ctrl, NULL, next, depth+1);
221
222
              ksba_cert_release (next);
244
245
 
245
246
 
246
247
static int
247
 
import_one (CTRL ctrl, struct stats_s *stats, int in_fd)
 
248
import_one (ctrl_t ctrl, struct stats_s *stats, int in_fd)
248
249
{
249
250
  int rc;
250
251
  Base64Context b64reader = NULL;
405
406
 
406
407
 
407
408
int
408
 
gpgsm_import (CTRL ctrl, int in_fd)
 
409
gpgsm_import (ctrl_t ctrl, int in_fd)
409
410
{
410
411
  int rc;
411
412
  struct stats_s stats;
423
424
 
424
425
 
425
426
int
426
 
gpgsm_import_files (CTRL ctrl, int nfiles, char **files,
 
427
gpgsm_import_files (ctrl_t ctrl, int nfiles, char **files,
427
428
                    int (*of)(const char *fname))
428
429
{
429
430
  int rc = 0;
481
482
  assert (i < sizeof argv);
482
483
 
483
484
  return gnupg_spawn_process (pgmname, argv, infile, outfile,
484
 
                              setup_pinentry_env,
 
485
                              setup_pinentry_env, 128,
485
486
                              statusfile, pid);
486
487
}
487
488
 
507
508
  int bad_pass = 0;
508
509
 
509
510
  if (!opt.protect_tool_program || !*opt.protect_tool_program)
510
 
    pgmname = GNUPG_DEFAULT_PROTECT_TOOL;
 
511
    pgmname = gnupg_module_name (GNUPG_MODULE_NAME_PROTECT_TOOL);
511
512
  else
512
513
    pgmname = opt.protect_tool_program;
513
514
 
517
518
     gpg-protect-tool will anyway parse the entire pkcs#12 message in
518
519
     memory, we simply use tempfiles here and pass them to
519
520
     the gpg-protect-tool. */
520
 
  tmpfp = tmpfile ();
 
521
  tmpfp = gnupg_tmpfile ();
521
522
  if (!tmpfp)
522
523
    {
523
 
      err = gpg_error_from_errno (errno);
 
524
      err = gpg_error_from_syserror ();
524
525
      log_error (_("error creating temporary file: %s\n"), strerror (errno));
525
526
      goto cleanup;
526
527
    }
528
529
    {
529
530
      if (nread && fwrite (buffer, nread, 1, tmpfp) != 1)
530
531
        {
531
 
          err = gpg_error_from_errno (errno);
 
532
          err = gpg_error_from_syserror ();
532
533
          log_error (_("error writing to temporary file: %s\n"),
533
534
                     strerror (errno));
534
535
          goto cleanup;
542
543
      goto cleanup;
543
544
    }
544
545
 
545
 
  certfp = tmpfile ();
 
546
  certfp = gnupg_tmpfile ();
546
547
  if (!certfp)
547
548
    {
548
 
      err = gpg_error_from_errno (errno);
 
549
      err = gpg_error_from_syserror ();
549
550
      log_error (_("error creating temporary file: %s\n"), strerror (errno));
550
551
      goto cleanup;
551
552
    }
621
622
    }
622
623
 
623
624
 
624
 
  /* If we found no error in the output of the cild, setup a suitable
 
625
  /* If we found no error in the output of the child, setup a suitable
625
626
     error code, which will later be reset if the exit status of the
626
627
     child is 0. */
627
628
  if (!child_err)
634
635
    fclose (fp);
635
636
  if (pid != -1)
636
637
    {
637
 
      if (!gnupg_wait_process (pgmname, pid))
 
638
      if (!gnupg_wait_process (pgmname, pid, NULL))
638
639
        child_err = 0;
639
640
    }
640
641
  if (!err)