* 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>
* gpgsm.c: Removed duped help entry for --list-keys.
* gpgsm.c, gpgsm.h: New option --debug-no-path-validation.
* certpath.c (gpgsm_validate_path): Use it here instead of the
debug flag hack.

View File

@ -364,9 +364,8 @@ parse_dn (const unsigned char *string)
}
static int
print_dn_part (FILE *fp, struct dn_array_s *dn, const char *key,
int need_delim)
static void
print_dn_part (FILE *fp, struct dn_array_s *dn, const char *key)
{
int any = 0;
@ -374,11 +373,7 @@ print_dn_part (FILE *fp, struct dn_array_s *dn, const char *key,
{
if (!strcmp (dn->key, key) && dn->value && *dn->value)
{
if (need_delim)
{
putc ('/', fp);
need_delim = 0;
}
putc ('/', fp);
if (any)
fputs (" + ", fp);
else
@ -387,7 +382,6 @@ print_dn_part (FILE *fp, struct dn_array_s *dn, const char *key,
any = 1;
}
}
return any;
}
/* 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[] = {
"CN", "OU", "O", "STREET", "L", "ST", "C", "EMail", NULL
};
int any=0, i;
int i;
for (i=0; stdpart[i]; i++)
{
if (print_dn_part (fp, dn, stdpart[i], any))
any = 1;
}
print_dn_part (fp, dn, stdpart[i]);
/* now print the rest without any specific ordering */
for (; dn->key; dn++)
@ -415,10 +406,7 @@ print_dn_parts (FILE *fp, struct dn_array_s *dn)
break;
}
if (!stdpart[i])
{
if (print_dn_part (fp, dn, dn->key, any))
any = 1;
}
print_dn_part (fp, dn, dn->key);
}
}

View File

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

View File

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

View File

@ -443,12 +443,13 @@ static int
cmd_export (ASSUAN_CONTEXT ctx, char *line)
{
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;
STRLIST list, sl;
if (!fp)
return set_error (General_Error, "no data stream");
if (fd == -1)
return set_error (No_Output, NULL);
/* break the line down into an STRLIST */
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);
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;
}