summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Chappa <chappa@washington.edu>2016-02-28 23:53:52 -0700
committerEduardo Chappa <chappa@washington.edu>2016-02-28 23:53:52 -0700
commit0bb3a0be1d23f86b4741102d3ea2c9fc4ef4b5af (patch)
tree51a2d8d59de4e0fb1a4abc3dcdca6c2db6f8e492
parentf79d3985bcf67ed2c0893c4a41fa8b7b1736a02a (diff)
downloadalpine-0bb3a0be1d23f86b4741102d3ea2c9fc4ef4b5af.tar.xz
* Changes to make Alpine build when PASSFILE is not specified and
adding memory freeing calls when necessary.
-rw-r--r--alpine/smime.c75
-rw-r--r--pith/imap.h2
-rw-r--r--pith/smime.c6
-rw-r--r--pith/smkeys.c8
-rw-r--r--pith/state.c31
-rw-r--r--pith/state.h6
6 files changed, 75 insertions, 53 deletions
diff --git a/alpine/smime.c b/alpine/smime.c
index 3ba7d397..7a4fde97 100644
--- a/alpine/smime.c
+++ b/alpine/smime.c
@@ -1378,6 +1378,42 @@ smime_setup_size(char **s, size_t buflen, size_t n)
}
#ifdef PASSFILE
+void manage_password_file_certificates(struct pine *ps)
+{
+ OPT_SCREEN_S screen;
+ int readonly_warning = 0, rv = 10, fline, state = 0;
+
+ dprint((9, "manage_password_file_certificates"));
+ ps->next_screen = SCREEN_FUN_NULL;
+
+ do {
+ CONF_S *ctmp = NULL, *first_line = NULL;
+
+ fline = rv >= 10 ? rv - 10 : 0;
+
+// smime_init();
+
+ smime_manage_password_file_certs_init(ps, &ctmp, &first_line, fline, &state);
+
+ if(ctmp == NULL){
+ ps->mangled_screen = 1;
+// smime_reinit();
+ return;
+ }
+
+ memset(&screen, 0, sizeof(screen));
+ screen.deferred_ro_warning = readonly_warning;
+ rv = conf_scroll_screen(ps, &screen, first_line,
+ _("MANAGE PASSWORD FILE CERTS"),
+ /* TRANSLATORS: Print something1 using something2.
+ configuration is something1 */
+ _("configuration"), 0, NULL);
+ } while (rv != 0);
+
+ ps->mangled_screen = 1;
+ smime_reinit();
+}
+
/* state: 0 = first time,
* 1 = second or another time
*/
@@ -1404,7 +1440,7 @@ smime_manage_password_file_certs_init(struct pine *ps, CONF_S **ctmp, CONF_S **f
}
pc = (PERSONAL_CERT *) ps_global->pwdcert;
- ps->pwdcertlist = cl = smime_X509_to_cert_info(pc->cert, pc->name);
+ ps->pwdcertlist = cl = smime_X509_to_cert_info(X509_dup(pc->cert), pc->name);
for(i = 0; i < sizeof(tmp) && i < (ps->ttyo ? ps->ttyo->screen_cols : sizeof(tmp)); i++)
tmp[i] = '-';
@@ -1634,43 +1670,6 @@ void manage_certificates(struct pine *ps, WhichCerts ctype)
smime_reinit();
}
-void manage_password_file_certificates(struct pine *ps)
-{
- OPT_SCREEN_S screen;
- int readonly_warning = 0, rv = 10, fline, state = 0;
-
- dprint((9, "manage_password_file_certificates"));
- ps->next_screen = SCREEN_FUN_NULL;
-
- do {
- CONF_S *ctmp = NULL, *first_line = NULL;
-
- fline = rv >= 10 ? rv - 10 : 0;
-
- smime_init();
-
- smime_manage_password_file_certs_init(ps, &ctmp, &first_line, fline, &state);
-
- if(ctmp == NULL){
- ps->mangled_screen = 1;
- smime_reinit();
- return;
- }
-
- memset(&screen, 0, sizeof(screen));
- screen.deferred_ro_warning = readonly_warning;
- rv = conf_scroll_screen(ps, &screen, first_line,
- _("MANAGE PASSWORD FILE CERTS"),
- /* TRANSLATORS: Print something1 using something2.
- configuration is something1 */
- _("configuration"), 0, NULL);
- } while (rv != 0);
-
- ps->mangled_screen = 1;
- smime_reinit();
-}
-
-
int
smime_helper_tool(struct pine *ps, int cmd, CONF_S **cl, unsigned flags)
{
diff --git a/pith/imap.h b/pith/imap.h
index 1b30e456..b6460e50 100644
--- a/pith/imap.h
+++ b/pith/imap.h
@@ -131,7 +131,7 @@ void imap_flush_passwd_cache(int);
void set_read_predicted(int);
void mm_login_work (NETMBX *mb,char *user,char *pwd,long trial,char *usethisprompt, char *altuserforcache);
-/* this is necessary to figure out the name of the password file of the application */
+/* this is necessary to figure out the name of the password file of the application. */
#ifdef PASSFILE
char *passfile_name(char *, char *, size_t);
#endif /* PASSFILE */
diff --git a/pith/smime.c b/pith/smime.c
index ab3961cd..9629f743 100644
--- a/pith/smime.c
+++ b/pith/smime.c
@@ -631,6 +631,7 @@ import_certificate(WhichCerts ctype)
* in the same private key, and if not, we ask the user for its location. If all
* of this works, we import the key and public to the password directory.
*/
+#ifdef PASSFILE
if(ctype == Password){
char PrivateKeyPath[MAXPATH+1], PublicCertPath[MAXPATH+1], s[MAXPATH+1];
char full_name_key[MAXPATH+1], full_name_cert[MAXPATH+1];
@@ -830,6 +831,7 @@ import_certificate(WhichCerts ctype)
return rc;
}
+#endif /* PASSFILE */
smime_init();
ps_global->mangled_screen = 1;
@@ -1288,7 +1290,7 @@ get_personal_certs(char *path)
strncpy(buf2, d->d_name, sizeof(buf2)-1);
buf2[sizeof(buf2)-1] = '\0';
/* chop off ".key" trailier */
- buf2[strlen(buf2)-4] = 0;
+ buf2[strlen(buf2)-4] = '\0';
/* Look for certificate */
cert = get_cert_for(buf2, Public, 1);
@@ -1300,6 +1302,8 @@ get_personal_certs(char *path)
pc = (PERSONAL_CERT *) fs_get(sizeof(*pc));
pc->cert = cert;
pc->name = cpystr(buf2);
+ strncat(buf2, EXTCERT(Public), 4);
+ pc->cname = cpystr(buf2);
/* Try to load the key with an empty password */
pc->key = load_key(pc, "", SM_NORMALCERT);
diff --git a/pith/smkeys.c b/pith/smkeys.c
index 415bc190..ce58ed41 100644
--- a/pith/smkeys.c
+++ b/pith/smkeys.c
@@ -1106,6 +1106,7 @@ mem_to_personal_certs(char *contents)
pc = (PERSONAL_CERT *) fs_get(sizeof(*pc));
pc->cert = cert;
pc->name = cpystr(name);
+ pc->cname = NULL;
pc->keytext = keytext; /* a pointer into contents */
pc->key = load_key(pc, "", SM_NORMALCERT);
@@ -1347,12 +1348,11 @@ void
free_personal_certs(PERSONAL_CERT **pc)
{
if(pc && *pc){
- free_personal_certs(&(*pc)->next);
if((*pc)->name)
fs_give((void **) &(*pc)->name);
- if((*pc)->name)
- fs_give((void **) &(*pc)->name);
+ if((*pc)->cname)
+ fs_give((void **) &(*pc)->cname);
if((*pc)->cert)
X509_free((*pc)->cert);
@@ -1360,6 +1360,8 @@ free_personal_certs(PERSONAL_CERT **pc)
if((*pc)->key)
EVP_PKEY_free((*pc)->key);
+ free_personal_certs(&(*pc)->next);
+
fs_give((void **) pc);
}
}
diff --git a/pith/state.c b/pith/state.c
index d4b8c092..6ac569c3 100644
--- a/pith/state.c
+++ b/pith/state.c
@@ -178,10 +178,10 @@ free_pine_struct(struct pine **pps)
if((*pps)->posting_charmap)
fs_give((void **)&(*pps)->posting_charmap);
-#ifdef PASSFILE
- if((*pps)->passfile)
- fs_give((void **)&(*pps)->passfile);
#ifdef SMIME
+ if((*pps)->pwdcertdir)
+ fs_give((void **)&(*pps)->pwdcertdir);
+
if((*pps)->pwdcert){
PERSONAL_CERT *pc;
@@ -189,9 +189,28 @@ free_pine_struct(struct pine **pps)
free_personal_certs(&pc);
(*pps)->pwdcert = NULL;
}
- if((*pps)->pwdcertdir)
- fs_give((void **)&(*pps)->pwdcertdir);
-#endif /* SMIME inside PASSFILE */
+
+ if((*pps)->pwdcertlist){
+ CertList *cert;
+
+ cert = (CertList *) (*pps)->pwdcertlist;
+ free_certlist(&cert);
+ (*pps)->pwdcertlist = NULL;
+ }
+
+ if((*pps)->backuppassword){
+ CertList *cert;
+
+ cert = (CertList *) (*pps)->backuppassword;
+ free_certlist(&cert);
+ (*pps)->backuppassword = NULL;
+ }
+#endif /* SMIME */
+
+
+#ifdef PASSFILE
+ if((*pps)->passfile)
+ fs_give((void **)&(*pps)->passfile);
#endif /* PASSFILE */
if((*pps)->hdr_colors)
diff --git a/pith/state.h b/pith/state.h
index 52628cf0..53db2bf9 100644
--- a/pith/state.h
+++ b/pith/state.h
@@ -353,15 +353,13 @@ struct pine {
PRINT_S *print;
#ifdef SMIME
- char *smimedir;
+ char *smimedir;
SMIME_STUFF_S *smime;
-#ifdef PASSFILE
char *pwdcertdir; /* path to location of certificates for password file */
- char *pwdcertcontent; /* No comment yet */
void *pwdcert; /* this is of type PERSONAL_CERT */
+ char *pwdcertcontent; /* No comment yet */
void *backuppassword; /* this is of type CertList */
void *pwdcertlist; /* this is of type CertList */
-#endif /* PASSFILE inside SMIME */
#endif /* SMIME */
struct variable *vars;