1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-01-05 12:31:50 +01:00

* certdump.c (print_dn_part): Always print a leading slash,

removed NEED_DELIM arg and changed caller.

* export.c (gpgsm_export): Print LFs to FP and not stdout.
(print_short_info): Ditto.  Make use of gpgsm_print_name.

* server.c (cmd_export): Use output-fd instead of data lines; this
was actually the specified way.
This commit is contained in:
Werner Koch 2002-06-25 09:34:10 +00:00
parent 640688c4e2
commit 5c5a3f689a
5 changed files with 53 additions and 49 deletions

View File

@ -1,6 +1,20 @@
2002-06-25 Werner Koch <wk@gnupg.org>
* certdump.c (print_dn_part): Always print a leading slash,
removed NEED_DELIM arg and changed caller.
* export.c (gpgsm_export): Print LFs to FP and not stdout.
(print_short_info): Ditto. Make use of gpgsm_print_name.
* server.c (cmd_export): Use output-fd instead of data lines; this
was actually the specified way.
2002-06-24 Werner Koch <wk@gnupg.org> 2002-06-24 Werner Koch <wk@gnupg.org>
* gpgsm.c: Removed duped help entry for --list-keys.
* gpgsm.c, gpgsm.h: New option --debug-no-path-validation. * gpgsm.c, gpgsm.h: New option --debug-no-path-validation.
* certpath.c (gpgsm_validate_path): Use it here instead of the * certpath.c (gpgsm_validate_path): Use it here instead of the
debug flag hack. debug flag hack.

View File

@ -364,21 +364,16 @@ parse_dn (const unsigned char *string)
} }
static int static void
print_dn_part (FILE *fp, struct dn_array_s *dn, const char *key, print_dn_part (FILE *fp, struct dn_array_s *dn, const char *key)
int need_delim)
{ {
int any = 0; int any = 0;
for (; dn->key; dn++) for (; dn->key; dn++)
{ {
if (!strcmp (dn->key, key) && dn->value && *dn->value) if (!strcmp (dn->key, key) && dn->value && *dn->value)
{
if (need_delim)
{ {
putc ('/', fp); putc ('/', fp);
need_delim = 0;
}
if (any) if (any)
fputs (" + ", fp); fputs (" + ", fp);
else else
@ -387,7 +382,6 @@ print_dn_part (FILE *fp, struct dn_array_s *dn, const char *key,
any = 1; any = 1;
} }
} }
return any;
} }
/* Print all parts of a DN in a "standard" sequence. We first print /* Print all parts of a DN in a "standard" sequence. We first print
@ -398,13 +392,10 @@ print_dn_parts (FILE *fp, struct dn_array_s *dn)
const char *stdpart[] = { const char *stdpart[] = {
"CN", "OU", "O", "STREET", "L", "ST", "C", "EMail", NULL "CN", "OU", "O", "STREET", "L", "ST", "C", "EMail", NULL
}; };
int any=0, i; int i;
for (i=0; stdpart[i]; i++) for (i=0; stdpart[i]; i++)
{ print_dn_part (fp, dn, stdpart[i]);
if (print_dn_part (fp, dn, stdpart[i], any))
any = 1;
}
/* now print the rest without any specific ordering */ /* now print the rest without any specific ordering */
for (; dn->key; dn++) for (; dn->key; dn++)
@ -415,10 +406,7 @@ print_dn_parts (FILE *fp, struct dn_array_s *dn)
break; break;
} }
if (!stdpart[i]) if (!stdpart[i])
{ print_dn_part (fp, dn, dn->key);
if (print_dn_part (fp, dn, dn->key, any))
any = 1;
}
} }
} }

View File

@ -136,7 +136,7 @@ gpgsm_export (CTRL ctrl, STRLIST names, FILE *fp)
if (count) if (count)
putc ('\n', fp); putc ('\n', fp);
print_short_info (cert, fp); print_short_info (cert, fp);
putc ('\n', stdout); putc ('\n', fp);
} }
count++; count++;
@ -202,20 +202,14 @@ print_short_info (KsbaCert cert, FILE *fp)
KsbaSexp sexp; KsbaSexp sexp;
int idx; int idx;
fputs ("Issuer ...: ", fp); for (idx=0; (p = ksba_cert_get_issuer (cert, idx)); idx++)
p = ksba_cert_get_issuer (cert, 0);
if (p)
{ {
print_sanitized_string (fp, p, '\n'); fputs (!idx? "Issuer ...: "
xfree (p); : "\n aka ...: ", fp);
for (idx=1; (p = ksba_cert_get_issuer (cert, idx)); idx++) gpgsm_print_name (fp, p);
{
fputs ("\n aka ...: ", fp);
print_sanitized_string (fp, p, '\n');
xfree (p); xfree (p);
} }
} putc ('\n', fp);
putc ('\n', stdout);
fputs ("Serial ...: ", fp); fputs ("Serial ...: ", fp);
sexp = ksba_cert_get_serial (cert); sexp = ksba_cert_get_serial (cert);
@ -235,24 +229,20 @@ print_short_info (KsbaCert cert, FILE *fp)
} }
xfree (sexp); xfree (sexp);
} }
putc ('\n', stdout); putc ('\n', fp);
fputs ("Subject ..: ", fp); for (idx=0; (p = ksba_cert_get_subject (cert, idx)); idx++)
p = ksba_cert_get_subject (cert, 0);
if (p)
{ {
print_sanitized_string (fp, p, '\n'); fputs (!idx? "Subject ..: "
xfree (p); : "\n aka ..: ", fp);
for (idx=1; (p = ksba_cert_get_subject (cert, idx)); idx++) gpgsm_print_name (fp, p);
{
fputs ("\n aka ..: ", fp);
print_sanitized_string (fp, p, '\n');
xfree (p); xfree (p);
} }
} putc ('\n', fp);
else
fputs ("none", fp);
putc ('\n', stdout);
} }

View File

@ -214,7 +214,6 @@ static ARGPARSE_OPTS opts[] = {
{ aVerify, "verify" , 256, N_("verify a signature")}, { aVerify, "verify" , 256, N_("verify a signature")},
{ aVerifyFiles, "verify-files" , 256, "@" }, { aVerifyFiles, "verify-files" , 256, "@" },
{ aListKeys, "list-keys", 256, N_("list keys")}, { aListKeys, "list-keys", 256, N_("list keys")},
{ aListKeys, "list-keys", 256, N_("list keys")},
{ aListExternalKeys, "list-external-keys", 256, N_("list external keys")}, { aListExternalKeys, "list-external-keys", 256, N_("list external keys")},
{ aListSecretKeys, "list-secret-keys", 256, N_("list secret keys")}, { aListSecretKeys, "list-secret-keys", 256, N_("list secret keys")},
{ aListSigs, "list-sigs", 256, N_("list certificate chain")}, { aListSigs, "list-sigs", 256, N_("list certificate chain")},

View File

@ -443,12 +443,13 @@ static int
cmd_export (ASSUAN_CONTEXT ctx, char *line) cmd_export (ASSUAN_CONTEXT ctx, char *line)
{ {
CTRL ctrl = assuan_get_pointer (ctx); CTRL ctrl = assuan_get_pointer (ctx);
FILE *fp = assuan_get_data_fp (ctx); int fd = assuan_get_output_fd (ctx);
FILE *out_fp;
char *p; char *p;
STRLIST list, sl; STRLIST list, sl;
if (!fp) if (fd == -1)
return set_error (General_Error, "no data stream"); return set_error (No_Output, NULL);
/* break the line down into an STRLIST */ /* break the line down into an STRLIST */
list = NULL; list = NULL;
@ -473,8 +474,20 @@ cmd_export (ASSUAN_CONTEXT ctx, char *line)
} }
} }
gpgsm_export (ctrl, list, fp); out_fp = fdopen ( dup(fd), "w");
if (!out_fp)
{
free_strlist (list); free_strlist (list);
return set_error (General_Error, "fdopen() failed");
}
gpgsm_export (ctrl, list, out_fp);
fclose (out_fp);
free_strlist (list);
/* close and reset the fd */
close_message_fd (ctrl);
assuan_close_input_fd (ctx);
assuan_close_output_fd (ctx);
return 0; return 0;
} }