kflags = key->flags | (pkey->flags & KEYFLAG_RESTRICTIONS)
| uid->flags;
-
+
switch (ascii_tolower (op))
{
case '[':
mutt_FormatString (dest, destlen, col, elsestring, mutt_attach_fmt, data, 0);
return (src);
}
-
+
static void pgp_entry (char *s, size_t l, MUTTMENU * menu, int num)
{
pgp_uid_t **KeyTable = (pgp_uid_t **) menu->data;
pgp_entry_t entry;
-
+
entry.uid = KeyTable[num];
entry.num = num + 1;
return 0;
if (pk->flags & KEYFLAG_CANTUSE)
return 0;
-
+
return 1;
}
static int pgp_id_matches_addr (ADDRESS *addr, ADDRESS *u_addr, pgp_uid_t *uid)
{
int rv = 0;
-
+
if (pgp_id_is_valid (uid))
rv |= PGP_KV_VALID;
if (pgp_id_is_strong (uid))
rv |= PGP_KV_STRONGID;
-
+
if (addr->mailbox && u_addr->mailbox
&& mutt_strcasecmp (addr->mailbox, u_addr->mailbox) == 0)
rv |= PGP_KV_ADDR;
-
+
if (addr->personal && u_addr->personal
&& mutt_strcasecmp (addr->personal, u_addr->personal) == 0)
rv |= PGP_KV_STRING;
-
+
return rv;
}
unusable = 1;
continue;
}
-
+
if (i == keymax)
{
keymax += 5;
safe_realloc (&KeyTable, sizeof (pgp_uid_t *) * keymax);
}
-
+
KeyTable[i++] = a;
}
}
snprintf (buf, sizeof (buf), _("PGP keys matching <%s>."), p->mailbox);
else
snprintf (buf, sizeof (buf), _("PGP keys matching \"%s\"."), s);
-
-
+
+
menu->title = buf;
kp = NULL;
mutt_clear_error ();
-
+
while (!done)
{
switch (mutt_menuLoop (menu))
}
if ((fp = safe_fopen (tempfile, "w")) == NULL)
{
- fclose (devnull);
+ safe_fclose (&devnull);
mutt_perror _("Can't create temporary file");
break;
}
{
mutt_perror _("Can't create filter");
unlink (tempfile);
- fclose (fp);
- fclose (devnull);
+ safe_fclose (&fp);
+ safe_fclose (&devnull);
}
mutt_wait_filter (thepid);
- fclose (fp);
- fclose (devnull);
+ safe_fclose (&fp);
+ safe_fclose (&devnull);
mutt_clear_error ();
snprintf (cmd, sizeof (cmd), _("Key ID: 0x%s"),
pgp_keyid (pgp_principal_key (KeyTable[menu->current]->parent)));
/* XXX make error reporting more verbose */
-
+
if (option (OPTPGPCHECKTRUST))
if (!pgp_key_is_valid (KeyTable[menu->current]->parent))
{
mutt_error _("This key can't be used: expired/disabled/revoked.");
break;
}
-
+
if (option (OPTPGPCHECKTRUST) &&
(!pgp_id_is_valid (KeyTable[menu->current])
|| !pgp_id_is_strong (KeyTable[menu->current])))
FREE (&KeyTable);
set_option (OPTNEEDREDRAW);
-
+
return (kp);
}
struct pgp_cache *l = NULL;
mutt_clear_error ();
-
+
resp[0] = 0;
if (whatfor)
{
snprintf (tmp, sizeof (tmp), "0x%s", pgp_keyid (pgp_principal_key (key)));
pgp_free_key (&key);
-
+
if (!tempf)
{
mutt_mktemp (tempfb);
if ((devnull = fopen ("/dev/null", "w")) == NULL) /* __FOPEN_CHECKED__ */
{
mutt_perror _("Can't open /dev/null");
- fclose (tempfp);
+ safe_fclose (&tempfp);
if (tempf == tempfb)
unlink (tempf);
return NULL;
mutt_message _("Invoking PGP...");
-
+
if ((thepid =
pgp_invoke_export (NULL, NULL, NULL, -1,
fileno (tempfp), fileno (devnull), tmp)) == -1)
{
mutt_perror _("Can't create filter");
unlink (tempf);
- fclose (tempfp);
- fclose (devnull);
+ safe_fclose (&tempfp);
+ safe_fclose (&devnull);
return NULL;
}
mutt_wait_filter (thepid);
- fclose (tempfp);
- fclose (devnull);
+ safe_fclose (&tempfp);
+ safe_fclose (&devnull);
att = mutt_new_body ();
att->filename = safe_strdup (tempf);
pgp_key_t matches = NULL;
pgp_key_t *last = &matches;
pgp_uid_t *q;
-
+
if (a && a->mailbox)
hints = pgp_add_string_to_hints (hints, a->mailbox);
if (a && a->personal)
keys = pgp_get_candidates (keyring, hints);
mutt_free_list (&hints);
-
+
if (!keys)
return NULL;
-
+
dprint (5, (debugfile, "pgp_getkeybyaddr: looking for %s <%s>.",
a->personal, a->mailbox));
}
pgp_free_key (&keys);
-
+
if (matches)
{
if (the_valid_key && !multi)
pgp_key_t k, kn;
pgp_uid_t *a;
short match;
+ size_t l;
+
+ if ((l = mutt_strlen (p)) && p[l-1] == '!')
+ p[l-1] = 0;
mutt_message (_("Looking for keys matching \"%s\"..."), p);
-
+
hints = pgp_add_string_to_hints (hints, p);
keys = pgp_get_candidates (keyring, hints);
mutt_free_list (&hints);
if (!keys)
- return NULL;
-
-
+ goto out;
+
for (k = keys; k; k = kn)
{
kn = k->next;
continue;
match = 0;
-
+
for (a = k->address; a; a = a->next)
{
dprint (5, (debugfile, "pgp_getkeybystr: matching \"%s\" against key %s, \"%s\": ",
break;
}
}
-
+
if (match)
{
*last = pgp_principal_key (k);
{
if ((k = pgp_select_key (matches, NULL, p)))
pgp_remove_key (&matches, k);
-
+
pgp_free_key (&matches);
+ if (!p[l-1])
+ p[l-1] = '!';
return k;
}
+out:
+ if (!p[l-1])
+ p[l-1] = '!';
return NULL;
}
-
-
#endif /* CRYPT_BACKEND_CLASSIC_PGP */