summaryrefslogtreecommitdiff
path: root/pith
diff options
context:
space:
mode:
Diffstat (limited to 'pith')
-rw-r--r--pith/adrbklib.c2
-rw-r--r--pith/conf.c21
-rw-r--r--pith/flag.c5
-rw-r--r--pith/folder.c3
-rw-r--r--pith/icache.c4
-rw-r--r--pith/ldap.c130
-rw-r--r--pith/ldap.h11
-rw-r--r--pith/mailindx.c2
-rw-r--r--pith/mimedesc.c2
-rw-r--r--pith/osdep/mimedisp.c1
-rw-r--r--pith/pine.hlp7
-rw-r--r--pith/send.c3
-rw-r--r--pith/smkeys.c2
-rw-r--r--pith/state.h1
-rw-r--r--pith/stream.c2
-rw-r--r--pith/takeaddr.c2
16 files changed, 163 insertions, 35 deletions
diff --git a/pith/adrbklib.c b/pith/adrbklib.c
index a9135d8b..fc7803fb 100644
--- a/pith/adrbklib.c
+++ b/pith/adrbklib.c
@@ -4108,7 +4108,7 @@ delete_ab_entry(AdrBk *ab, a_c_arg_t delete_this_one, int save_it)
* #DELETED-YY/MM/DD#
* to the nickname.
*/
- now = time((time_t) 0);
+ now = time((time_t *) NULL);
tm_now = localtime(&now);
oldnick = ae_deleted->nickname;
diff --git a/pith/conf.c b/pith/conf.c
index e8c1ceb9..7f450be8 100644
--- a/pith/conf.c
+++ b/pith/conf.c
@@ -1701,9 +1701,24 @@ init_vars(struct pine *ps, void (*cmds_f) (struct pine *, char **))
GLO_SPELLER = cpystr(DF_VAR_SPELLER);
#endif
#ifdef SMIME
- GLO_PUBLICCERT_DIR = cpystr(DF_PUBLICCERT_DIR);
- GLO_PRIVATEKEY_DIR = cpystr(DF_PRIVATEKEY_DIR);
- GLO_CACERT_DIR = cpystr(DF_CACERT_DIR);
+ if(ps->smimedir){
+ snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%s/public", ps->smimedir);
+ tmp_20k_buf[SIZEOF_20KBUF-1] = '\0';
+ GLO_PUBLICCERT_DIR = cpystr(tmp_20k_buf);
+
+ snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%s/private", ps->smimedir);
+ tmp_20k_buf[SIZEOF_20KBUF-1] = '\0';
+ GLO_PRIVATEKEY_DIR = cpystr(tmp_20k_buf);
+
+ snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%s/ca", ps->smimedir);
+ tmp_20k_buf[SIZEOF_20KBUF-1] = '\0';
+ GLO_CACERT_DIR = cpystr(tmp_20k_buf);
+ }
+ else{
+ GLO_PUBLICCERT_DIR = cpystr(DF_PUBLICCERT_DIR);
+ GLO_PRIVATEKEY_DIR = cpystr(DF_PRIVATEKEY_DIR);
+ GLO_CACERT_DIR = cpystr(DF_CACERT_DIR);
+ }
#endif /* SMIME */
/*
diff --git a/pith/flag.c b/pith/flag.c
index 890feb56..5381aaf4 100644
--- a/pith/flag.c
+++ b/pith/flag.c
@@ -585,7 +585,7 @@ set_lflag(MAILSTREAM *stream, MSGNO_S *msgs, long int n, int f, int v)
int was_invisible, is_invisible;
int chk_thrd_cnt = 0, thrd_was_visible, was_hidden, is_hidden;
- if((*(peltp = (PINELT_S **) &mc->sparep) == NULL)){
+ if(*(peltp = (PINELT_S **) &mc->sparep) == NULL){
*peltp = (PINELT_S *) fs_get(sizeof(PINELT_S));
memset(*peltp, 0, sizeof(PINELT_S));
}
@@ -702,12 +702,13 @@ copy_lflags(MAILSTREAM *stream, MSGNO_S *msgmap, int from, int to)
set_lflags(stream, msgmap, to, 0);
- if(any_lflagged(msgmap, from))
+ if(any_lflagged(msgmap, from)){
for(i = 1L; i <= mn_get_total(msgmap); i++)
if(get_lflag(stream, msgmap, i, from))
set_lflag(stream, msgmap, i, to, 1);
else if(hide)
set_lflag(stream, msgmap, i, MN_HIDE, 1);
+ }
}
diff --git a/pith/folder.c b/pith/folder.c
index 5373bdfb..63f1b1d8 100644
--- a/pith/folder.c
+++ b/pith/folder.c
@@ -871,7 +871,7 @@ update_bboard_spec(char *bboard, char *buf, size_t buflen)
if(*bboard == '*')
bboard++;
- if(!nntp)
+ if(!nntp){
/*
* See if path portion looks newsgroup-ish while being aware
* of the "view" portion of the spec...
@@ -891,6 +891,7 @@ update_bboard_spec(char *bboard, char *buf, size_t buflen)
}
else if(!(isalnum((unsigned char) *p) || strindex(".-", *p)))
break;
+ }
snprintf(buf, buflen-(buf-origbuf), "%s%s%s",
(!nntp && *p) ? "#public" : "#news.",
diff --git a/pith/icache.c b/pith/icache.c
index 07152652..d7d5989d 100644
--- a/pith/icache.c
+++ b/pith/icache.c
@@ -261,7 +261,7 @@ fetch_ice(MAILSTREAM *stream, long unsigned int rawno)
/*
* any private elt data yet?
*/
- if((*(peltp = (PINELT_S **) &mc->sparep) == NULL)){
+ if(*(peltp = (PINELT_S **) &mc->sparep) == NULL){
*peltp = (PINELT_S *) fs_get(sizeof(PINELT_S));
memset(*peltp, 0, sizeof(PINELT_S));
}
@@ -291,7 +291,7 @@ fetch_ice_ptr(MAILSTREAM *stream, long unsigned int rawno)
/*
* any private elt data yet?
*/
- if((*(peltp = (PINELT_S **) &mc->sparep) == NULL)){
+ if(*(peltp = (PINELT_S **) &mc->sparep) == NULL){
*peltp = (PINELT_S *) fs_get(sizeof(PINELT_S));
memset(*peltp, 0, sizeof(PINELT_S));
}
diff --git a/pith/ldap.c b/pith/ldap.c
index cb7ff363..411b0516 100644
--- a/pith/ldap.c
+++ b/pith/ldap.c
@@ -402,7 +402,7 @@ ldap_lookup(LDAP_SERV_S *info, char *string, CUSTOM_FILT_S *cust,
char *mailattr, *snattr, *gnattr, *cnattr;
int we_cancel = 0, we_turned_on = 0;
LDAP_SERV_RES_S *serv_res = NULL;
- LDAP *ld;
+ LDAP *ld = NULL;
long pwdtrial = 0L;
int ld_errnum;
char *ld_errstr;
@@ -472,8 +472,15 @@ ldap_lookup(LDAP_SERV_S *info, char *string, CUSTOM_FILT_S *cust,
if((ld = ldap_init(serv, info->port)) == NULL)
#else
#if (LDAPAPI >= 11)
+#ifdef _WINDOWS
if((ld = ldap_init(serv, info->port)) == NULL)
#else
+ snprintf(tmp_20k_buf, SIZEOF_20KBUF, "ldap://%s:%d", serv, info->port);
+ tmp_20k_buf[SIZEOF_20KBUF-1] = '\0';
+
+ if(ldap_initialize(&ld, tmp_20k_buf) != LDAP_SUCCESS)
+#endif
+#else
if((ld = ldap_open(serv, info->port)) == NULL)
#endif
#endif
@@ -498,7 +505,11 @@ ldap_lookup(LDAP_SERV_S *info, char *string, CUSTOM_FILT_S *cust,
else if(!ps_global->intr_pending){
int proto = 3, tlsmustbail = 0;
char pwd[NETMAXPASSWD], user[NETMAXUSER];
+#ifdef _WINDOWS
char *passwd = NULL;
+#else
+ struct berval passwd = { 0 };
+#endif
char hostbuf[1024];
NETMBX mb;
#ifndef _WINDOWS
@@ -573,7 +584,12 @@ try_password_again:
snprintf(pmt, sizeof(pmt), " %s", (info->nick && *info->nick) ? info->nick : serv);
mm_login_work(&mb, user, pwd, pwdtrial, pmt, info->binddn);
if(pwd && pwd[0])
+#ifdef _WINDOWS
passwd = pwd;
+#else
+ passwd.bv_len = strlen(pwd);
+ passwd.bv_val = pwd;
+#endif
}
}
@@ -583,7 +599,12 @@ try_password_again:
* to tell the server we're v3 if the server supports v3, and if the
* server doesn't support v3 the bind is required.
*/
- if(tlsmustbail || ldap_simple_bind_s(ld, info->binddn, passwd) != LDAP_SUCCESS){
+ if(tlsmustbail
+#ifdef _WINDOWS
+ || ldap_simple_bind_s(ld, info->binddn, passwd) != LDAP_SUCCESS){
+#else
+ || ldap_sasl_bind_s(ld, info->binddn, LDAP_SASL_SIMPLE, &passwd, NULL, NULL, NULL) != LDAP_SUCCESS){
+#endif
wp_err->wp_err_occurred = 1;
ld_errnum = our_ldap_get_lderrno(ld, NULL, &ld_errstr);
@@ -606,8 +627,11 @@ try_password_again:
if(we_cancel)
cancel_busy_cue(-1);
-
+#ifdef _WINDOWS
ldap_unbind(ld);
+#else
+ ldap_unbind_ext(ld, NULL, NULL);
+#endif
wp_err->error = cpystr(ebuf);
q_status_message(SM_ORDER, 3, 5, wp_err->error);
display_message('x');
@@ -831,11 +855,22 @@ try_password_again:
else{
int msgid;
time_t start_time;
+ struct timeval tv = {0}, *tvp = NULL;
+
+ memset((void *)&tv, 0, sizeof(struct timeval));
+ tv.tv_sec = info->time;
+ tvp = &tv;
start_time = time((time_t *)0);
dprint((6, "ldap_lookup: calling ldap_search\n"));
+#ifdef _WINDOWS
msgid = ldap_search(ld, base, info->scope, filter, NULL, 0);
+#else
+ if(ldap_search_ext(ld, base, info->scope, filter, NULL, 0,
+ NULL, NULL, tvp, info->size, &msgid) != LDAP_SUCCESS)
+ msgid = -1;
+#endif
if(msgid == -1)
srch_res = our_ldap_get_lderrno(ld, NULL, NULL);
@@ -863,7 +898,11 @@ try_password_again:
}
else if(lres == 0){ /* timeout, no results available */
if(intr_happened){
+#ifdef _WINDOWS
ldap_abandon(ld, msgid);
+#else
+ ldap_abandon_ext(ld, msgid, NULL, NULL);
+#endif
srch_res = LDAP_PROTOCOL_ERROR;
if(our_ldap_get_lderrno(ld, NULL, NULL) == LDAP_SUCCESS)
our_ldap_set_lderrno(ld, LDAP_PROTOCOL_ERROR, NULL, NULL);
@@ -882,7 +921,11 @@ try_password_again:
}
else{
if(lres == 0)
+#ifdef _WINDOWS
ldap_abandon(ld, msgid);
+#else
+ ldap_abandon_ext(ld, msgid, NULL, NULL);
+#endif
srch_res = LDAP_TIMEOUT;
if(our_ldap_get_lderrno(ld, NULL, NULL) == LDAP_SUCCESS)
@@ -898,9 +941,25 @@ try_password_again:
}
}
else{
+#ifdef _WINDOWS
srch_res = ldap_result2error(ld, res, 0);
dprint((6, "lres=0x%x, srch_res=%d\n", lres,
srch_res));
+#else
+ int err;
+ char *dn, *text, **ref;
+ LDAPControl **srv;
+
+ dn = text = NULL; ref = NULL; srv = NULL;
+ srch_res = ldap_parse_result(ld, res,
+ &err, &dn, &text, &ref, &srv, 0);
+ dprint((6, "lres=0x%x, srch_res=%d, dn=%s, text=%s\n", lres,
+ srch_res, dn ? dn : "", text ? text : ""));
+ if(dn) ber_memfree(dn);
+ if(text) ber_memfree(text);
+ if(ref) ber_memvfree((void **) ref);
+ if(srv) ldap_controls_free(srv);
+#endif
}
}while(lres == 0 &&
!(intr_happened ||
@@ -925,7 +984,11 @@ try_password_again:
if(res)
ldap_msgfree(res);
if(ld)
+#ifdef _WINDOWS
ldap_unbind(ld);
+#else
+ ldap_unbind_ext(ld, NULL, NULL);
+#endif
res = NULL; ld = NULL;
}
@@ -957,8 +1020,12 @@ try_password_again:
if(res)
ldap_msgfree(res);
if(ld)
+#ifdef _WINDOWS
ldap_unbind(ld);
-
+#else
+ ldap_unbind_ext(ld, NULL, NULL);
+#endif
+
res = NULL; ld = NULL;
}
else{
@@ -1043,7 +1110,11 @@ try_password_again:
if(res)
ldap_msgfree(res);
if(ld)
+#ifdef _WINDOWS
ldap_unbind(ld);
+#else
+ ldap_unbind_ext(ld, NULL, NULL);
+#endif
res = NULL; ld = NULL;
}
@@ -1184,41 +1255,41 @@ address_from_ldap(LDAP_CHOOSE_S *winning_e)
a = ldap_next_attribute(winning_e->ld, winning_e->selected_entry, ber)){
int i;
char *p;
- char **vals;
+ struct berval **vals;
dprint((9, "attribute: %s\n", a ? a : "?"));
if(!ret_a->personal &&
strcmp(a, winning_e->info_used->cnattr) == 0){
dprint((9, "Got cnattr:"));
- vals = ldap_get_values(winning_e->ld, winning_e->selected_entry, a);
- for(i = 0; vals[i] != NULL; i++)
+ vals = ldap_get_values_len(winning_e->ld, winning_e->selected_entry, a);
+ for(i = 0; i < ldap_count_values_len(vals); i++)
dprint((9, " %s\n",
- vals[i] ? vals[i] : "?"));
+ vals[i] ? vals[i]->bv_val : "?"));
- if(vals && vals[0])
- ret_a->personal = cpystr(vals[0]);
+ if(ALPINE_LDAP_can_use(vals))
+ ret_a->personal = cpystr(vals[0]->bv_val);
- ldap_value_free(vals);
+ ldap_value_free_len(vals);
}
else if(!ret_a->mailbox &&
strcmp(a, winning_e->info_used->mailattr) == 0){
dprint((9, "Got mailattr:"));
- vals = ldap_get_values(winning_e->ld, winning_e->selected_entry, a);
- for(i = 0; vals[i] != NULL; i++)
+ vals = ldap_get_values_len(winning_e->ld, winning_e->selected_entry, a);
+ for(i = 0; i < ldap_count_values_len(vals); i++)
dprint((9, " %s\n",
- vals[i] ? vals[i] : "?"));
+ vals[i] ? vals[i]->bv_val : "?"));
/* use first one */
- if(vals && vals[0]){
- if((p = strindex(vals[0], '@')) != NULL){
+ if(ALPINE_LDAP_can_use(vals)){
+ if((p = strindex(vals[0]->bv_val, '@')) != NULL){
ret_a->host = cpystr(p+1);
*p = '\0';
}
- ret_a->mailbox = cpystr(vals[0]);
+ ret_a->mailbox = cpystr(vals[0]->bv_val);
}
- ldap_value_free(vals);
+ ldap_value_free_len(vals);
}
our_ldap_memfree(a);
@@ -1569,7 +1640,11 @@ free_ldap_result_list(LDAP_SERV_RES_S **r)
if((*r)->res)
ldap_msgfree((*r)->res);
if((*r)->ld)
+#ifdef _WINDOWS
ldap_unbind((*r)->ld);
+#else
+ ldap_unbind_ext((*r)->ld, NULL, NULL);
+#endif
if((*r)->info_used)
free_ldap_server_info(&(*r)->info_used);
if((*r)->serv)
@@ -1794,5 +1869,24 @@ ldap_translate(char *a, LDAP_SERV_S *info_used)
return(a);
}
+char **
+berval_to_array(struct berval **v)
+{
+ char **rv = NULL;
+ int i, len;
+
+ if(v == NULL) return rv;
+ len = ldap_count_values_len(v);
+
+ rv = fs_get((len+1)*sizeof(char *));
+ for(i = 0; i < len; i++)
+ if(ALPINE_LDAP_can_use_num(v, i))
+ rv[i] = cpystr(v[i]->bv_val);
+ else
+ rv[i] = NULL;
+ rv[len] = NULL;
+
+ return rv;
+}
#endif /* ENABLE_LDAP */
diff --git a/pith/ldap.h b/pith/ldap.h
index 43a5120d..ee9b8b87 100644
--- a/pith/ldap.h
+++ b/pith/ldap.h
@@ -67,7 +67,7 @@ typedef struct ldap_serv {
* ldap_get_dn
* ldap_first_attribute
* ldap_next_attribute
- * ldap_get_values
+ * ldap_get_values_len
* We call those from a half dozen functions. We could fix it by
* having a directory-character-set per server and passing that around
* in the LDAP_SERV_RES_S structure, I think. For now, let's go with
@@ -114,6 +114,14 @@ typedef enum {AlwaysDisplay,
DisplayForURL
} LDAPLookupStyle;
+#define ALPINE_LDAP_can_use_num(X, Y) \
+ ((X) != NULL && (X)[(Y)] != NULL \
+ && (X)[(Y)]->bv_val != NULL \
+ && (X)[(Y)]->bv_val[0] != '\0')
+
+#define ALPINE_LDAP_can_use(X) ALPINE_LDAP_can_use_num((X), 0)
+#define ALPINE_LDAP_usable(X, Y) ((Y) < ldap_count_values_len((X)) \
+ && ALPINE_LDAP_can_use_num((X), (Y)))
#define LDAP_TYPE_CN 0
#define LDAP_TYPE_SUR 1
@@ -162,6 +170,7 @@ ADDRESS *wp_lookups(char *, WP_ERR_S *, int);
int ldap_lookup_all(char *, int, int, LDAPLookupStyle, CUSTOM_FILT_S *,
LDAP_CHOOSE_S **, WP_ERR_S *, LDAP_SERV_RES_S **);
char *ldap_translate(char *, LDAP_SERV_S *);
+char **berval_to_array(struct berval **);
ADDRESS *address_from_ldap(LDAP_CHOOSE_S *);
LDAP_SERV_S *break_up_ldap_server(char *);
void free_ldap_server_info(LDAP_SERV_S **);
diff --git a/pith/mailindx.c b/pith/mailindx.c
index c3e035b2..a1e889e0 100644
--- a/pith/mailindx.c
+++ b/pith/mailindx.c
@@ -2945,7 +2945,7 @@ format_index_index_line(INDEXDATA_S *idata)
if(!ifield->ielem){
ielem = new_ielem(&ifield->ielem);
- if(color = hdr_color(itokens[itokensinv[cdesc->ctype].ctype].name, NULL, ps_global->index_token_colors)){
+ if((color = hdr_color(itokens[itokensinv[cdesc->ctype].ctype].name, NULL, ps_global->index_token_colors)) != NULL){
if(pico_usingcolor()){
ielem->color = new_color_pair(color->fg, color->bg);
ielem->type = eTypeCol;
diff --git a/pith/mimedesc.c b/pith/mimedesc.c
index 097f5cda..80d2f840 100644
--- a/pith/mimedesc.c
+++ b/pith/mimedesc.c
@@ -222,7 +222,7 @@ describe_mime(struct mail_bodystruct *body, char *prefix, int num,
(description && description[0]) ? ", \"" : "",
(description && description[0]) ? description : "",
(description && description[0]) ? "\"": "");
- string[sizeof(string)-1] =- '\0';
+ string[sizeof(string)-1] = '\0';
a->description = cpystr(string);
a->body = body;
diff --git a/pith/osdep/mimedisp.c b/pith/osdep/mimedisp.c
index b1462685..2ee99293 100644
--- a/pith/osdep/mimedisp.c
+++ b/pith/osdep/mimedisp.c
@@ -28,6 +28,7 @@ static char rcsid[] = "$Id: mimedisp.c 942 2008-03-04 18:21:33Z hubert@u.washing
#include "mimedisp.h"
#include "../charconv/utf8.h"
#ifdef OSX_TARGET
+#include "../../pith/osdep/collate.h" /* for strucmp */
#include <Security/AuthSession.h>
#endif
diff --git a/pith/pine.hlp b/pith/pine.hlp
index bbce2c3d..b568f2c4 100644
--- a/pith/pine.hlp
+++ b/pith/pine.hlp
@@ -140,7 +140,7 @@ with help text for the config screen and the composer that didn't have any
reasonable place to be called from.
Dummy change to get revision in pine.hlp
============= h_revision =================
-Alpine Commit 81 2015-05-17 19:13:29
+Alpine Commit 82 2015-07-24 22:13:48
============= h_news =================
<HTML>
<HEAD>
@@ -243,6 +243,11 @@ Additions include:
be transformed to UTF-8 for further transformation through internal
and user defined filters for saving.
+ <LI> Add command line argument -smimedir, which allows to specify
+ the default path for a directory that contains the public, private,
+ and ca directories. This is useful in case a user has a backup of
+ old certificates that cannot be installed in the ~/.alpine-smime
+ dir.
</UL>
diff --git a/pith/send.c b/pith/send.c
index c0337aea..1ba6266f 100644
--- a/pith/send.c
+++ b/pith/send.c
@@ -5701,7 +5701,7 @@ pine_pipe_soutr_nl (void *stream, char *s)
size_t n;
while(*s && rv){
- if((n = (p = strstr(s, "\015\012")) ? p - s : strlen(s)) != 0)
+ if((n = (p = strstr(s, "\015\012")) ? p - s : strlen(s)) != 0){
while((rv = write(((PIPE_S *)stream)->out.d, s, n)) != n)
if(rv < 0){
if(errno != EINTR){
@@ -5713,6 +5713,7 @@ pine_pipe_soutr_nl (void *stream, char *s)
s += rv;
n -= rv;
}
+ }
if(p && rv){
s = p + 2; /* write UNIX EOL */
diff --git a/pith/smkeys.c b/pith/smkeys.c
index 35228914..bb77b030 100644
--- a/pith/smkeys.c
+++ b/pith/smkeys.c
@@ -285,7 +285,7 @@ resort_certificates(CertList **data, WhichCerts ctype)
for(i = 0; cl; cl = cl->next, i++)
if(ctype != Private){ /* ctype == Public or ctype == CACerts */
- for(t = s = cl->name; t = strstr(s, ".crt"); s = t+1);
+ for(t = s = cl->name; (t = strstr(s, ".crt")) != NULL; s = t+1);
if (s) *(s-1) = '\0';
}
j = i;
diff --git a/pith/state.h b/pith/state.h
index bfbe7973..4c908106 100644
--- a/pith/state.h
+++ b/pith/state.h
@@ -355,6 +355,7 @@ struct pine {
PRINT_S *print;
#ifdef SMIME
+ char *smimedir;
SMIME_STUFF_S *smime;
#ifdef PASSFILE
void *pwdcert; /* this is of type PERSONAL_CERT */
diff --git a/pith/stream.c b/pith/stream.c
index de7c1ea0..cfdcc9a5 100644
--- a/pith/stream.c
+++ b/pith/stream.c
@@ -3293,7 +3293,7 @@ streams_died(void)
else{
if(!sp_noticed_dead_stream(m)){
sp_set_noticed_dead_stream(m, 1);
- folder = STREAMNAME(m);
+ folder = (unsigned char *) STREAMNAME(m);
/*
* If a cached stream died and then we tried to use it
* it could cause problems. We could warn about it here
diff --git a/pith/takeaddr.c b/pith/takeaddr.c
index 1fb22ef6..233a6987 100644
--- a/pith/takeaddr.c
+++ b/pith/takeaddr.c
@@ -1804,7 +1804,7 @@ detach_vcard_att(MAILSTREAM *stream, long int msgno, struct mail_bodystruct *bod
if(dtext)
fs_give((void **)&dtext);
- res[count] = '\0';
+ res[count] = NULL;
return(res);
}