Compare commits
No commits in common. "filter" and "v1.4.3" have entirely different histories.
6 changed files with 24 additions and 132 deletions
41
Dockerfile
41
Dockerfile
|
@ -1,41 +0,0 @@
|
|||
#FROM debian:bookworm-20231030-slim
|
||||
FROM debian:bullseye-20220801
|
||||
|
||||
# need to add
|
||||
# removed
|
||||
# libsasl2-modules \
|
||||
# ca-certificates \
|
||||
|
||||
# version pinning is being handled in our from line
|
||||
# hadolint ignore=DL3008
|
||||
RUN true && \
|
||||
apt-get update && \
|
||||
groupadd --gid 1000 user && \
|
||||
useradd -m --home-dir /home/user --shell /bin/sh --uid 1000 --gid 1000 user && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
libsasl2-2 \
|
||||
libsasl2-dev \
|
||||
perl \
|
||||
libdatetime-format-dateparse-perl \
|
||||
autoconf \
|
||||
automake \
|
||||
zlib1g-dev \
|
||||
libdb-dev \
|
||||
libsasl2-dev \
|
||||
libssl-dev \
|
||||
gcc \
|
||||
make \
|
||||
git \
|
||||
&& \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/* && \
|
||||
true
|
||||
|
||||
# Built with
|
||||
# apt install build-essential dh-autoreconf git
|
||||
# apt install libssl-dev
|
||||
# apt install zlib1g-dev
|
||||
# apt install libsasl2-dev
|
||||
|
||||
WORKDIR /home/user
|
||||
USER user
|
3
build
3
build
|
@ -1,3 +0,0 @@
|
|||
#!/bin/sh
|
||||
# Note we assume this is run with podman. Take -u 0:0 out if using docker
|
||||
docker run -u 0:0 -it --rm -v $(pwd):/make -w /make isync-build make
|
23
configure.ac
23
configure.ac
|
@ -1,4 +1,4 @@
|
|||
AC_INIT([isync], [1.4.4])
|
||||
AC_INIT([isync], [1.4.3])
|
||||
AC_CONFIG_HEADERS([autodefs.h])
|
||||
|
||||
AC_CANONICAL_TARGET
|
||||
|
@ -62,8 +62,8 @@ if test "x$ob_cv_perl_ver" = "xno"; then
|
|||
fi
|
||||
|
||||
AC_CACHE_CHECK([whether strftime supports %z], ob_cv_strftime_z,
|
||||
[AC_RUN_IFELSE([AC_LANG_SOURCE([[
|
||||
#include <time.h>
|
||||
[AC_TRY_RUN(
|
||||
[#include <time.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(void)
|
||||
|
@ -73,7 +73,7 @@ int main(void)
|
|||
strftime(buf, sizeof(buf), "%z", localtime(&t));
|
||||
return !(buf[0] == '+' || buf[0] == '-');
|
||||
}
|
||||
]])], [ob_cv_strftime_z=yes], [ob_cv_strftime_z=no], [ob_cv_strftime_z="yes (assumed)"])])
|
||||
], [ob_cv_strftime_z=yes], [ob_cv_strftime_z=no], [ob_cv_strftime_z="yes (assumed)"])])
|
||||
if test "x$ob_cv_strftime_z" = x"no"; then
|
||||
AC_MSG_ERROR([libc lacks necessary feature])
|
||||
fi
|
||||
|
@ -96,7 +96,7 @@ fi
|
|||
|
||||
have_ssl_paths=
|
||||
AC_ARG_WITH(ssl,
|
||||
AS_HELP_STRING([--with-ssl[=PATH]], [where to look for SSL [detect]]),
|
||||
AC_HELP_STRING([--with-ssl[=PATH]], [where to look for SSL [detect]]),
|
||||
[ob_cv_with_ssl=$withval])
|
||||
if test "x$ob_cv_with_ssl" != xno; then
|
||||
case $ob_cv_with_ssl in
|
||||
|
@ -193,13 +193,12 @@ AC_CACHE_CHECK([for Berkeley DB >= 4.1], ac_cv_berkdb4,
|
|||
[ac_cv_berkdb4=no
|
||||
sav_LIBS=$LIBS
|
||||
LIBS="$LIBS -ldb"
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM(
|
||||
[#include <db.h>],
|
||||
[DB *db;
|
||||
db_create(&db, 0, 0);
|
||||
db->truncate(db, 0, 0, 0);
|
||||
db->open(db, 0, "foo", "foo", DB_HASH, DB_CREATE, 0);
|
||||
])], [ac_cv_berkdb4=yes], [])
|
||||
AC_TRY_LINK([#include <db.h>],
|
||||
[DB *db;
|
||||
db_create(&db, 0, 0);
|
||||
db->truncate(db, 0, 0, 0);
|
||||
db->open(db, 0, "foo", "foo", DB_HASH, DB_CREATE, 0)],
|
||||
[ac_cv_berkdb4=yes])
|
||||
LIBS=$sav_LIBS
|
||||
])
|
||||
if test "x$ac_cv_berkdb4" = xyes; then
|
||||
|
|
|
@ -877,11 +877,6 @@ parse_imap_list( imap_store_t *ctx, char **sp, parse_list_state_t *sts )
|
|||
bytes = (int)(cur->len = strtoul( s + 1, &s, 10 ));
|
||||
if (*s != '}' || *++s)
|
||||
goto bail;
|
||||
if ((uint)bytes >= INT_MAX) {
|
||||
error( "IMAP error: excessively large literal from %s "
|
||||
"- THIS MIGHT BE AN ATTEMPT TO HACK YOU!\n", ctx->conn.name );
|
||||
goto bail;
|
||||
}
|
||||
|
||||
s = cur->val = nfmalloc( cur->len + 1 );
|
||||
s[cur->len] = 0;
|
||||
|
@ -1439,10 +1434,6 @@ parse_list_rsp_p2( imap_store_t *ctx, list_t *list, char *cmd ATTR_UNUSED )
|
|||
}
|
||||
arg = list->val;
|
||||
argl = (int)list->len;
|
||||
if (argl > 1000) {
|
||||
warn( "IMAP warning: ignoring unreasonably long mailbox name '%.100s[...]'\n", arg );
|
||||
return LIST_OK;
|
||||
}
|
||||
// The server might be weird and have a non-uppercase INBOX. It
|
||||
// may legitimately do so, but we need the canonical spelling.
|
||||
normalize_INBOX( ctx, arg, argl );
|
||||
|
|
|
@ -920,28 +920,6 @@ maildir_compare( const void *l, const void *r )
|
|||
return strcmp( lm->base, rm->base );
|
||||
}
|
||||
|
||||
int is_gmail(const char* name) {
|
||||
// NOTE: This is not an exact science. For instance, there is a good
|
||||
// shot that mail sent from containers will end up matching this pattern
|
||||
char token[16]; // If host name is longer than 12, then we already have our answer
|
||||
|
||||
// we expect files in the form of: "1700172103.R12128272304961211247.hostname,U=27:2,S"
|
||||
// we are looking for "hostname"
|
||||
// All gmail mails have a hostname in the form of "ff6d55f971cc".
|
||||
// All are 12 characters long
|
||||
// All are hexadecimal
|
||||
if (sscanf(name, "%*[^.].%*[^.].%15[^,]", token) == 1) {
|
||||
token[14] = '\0';
|
||||
size_t len = strlen(token);
|
||||
if (len != 12) return 0;
|
||||
if (strspn(token, "0123456789abcdef") == len) return 1;
|
||||
}
|
||||
|
||||
// We are here because a) the input format is not as expected,
|
||||
// or b) the hostname is not gmail
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
maildir_scan( maildir_store_t *ctx, msg_t_array_alloc_t *msglist )
|
||||
{
|
||||
|
@ -1013,25 +991,9 @@ maildir_scan( maildir_store_t *ctx, msg_t_array_alloc_t *msglist )
|
|||
#endif /* USE_DB */
|
||||
return DRV_BOX_BAD;
|
||||
}
|
||||
const char *filter = getenv("MBSYNC_MAILDIR_IGNORE");
|
||||
const char *MAGIC_INCLUDE = "^[^\\.]+\\.[^\\.]+\\.[0-9a-f]{12}\\,.*";
|
||||
char *include = getenv("MBSYNC_MAILDIR_INCLUDE_ONLY");
|
||||
if (include && strncmp(MAGIC_INCLUDE, include, strlen(MAGIC_INCLUDE)) != 0) {
|
||||
include = NULL;
|
||||
error("MBSYNC_MAILDIR_INCLUDE_ONLY can only be '%s'\n", MAGIC_INCLUDE);
|
||||
}
|
||||
if (include && filter) {
|
||||
include = NULL;
|
||||
error("MBSYNC_MAILDIR_IGNORE cannot be used with MBSYNC_MAILDIR_INCLUDE_ONLY. INCLUDE_ONLY will be ignored\n");
|
||||
}
|
||||
|
||||
while ((e = readdir( d ))) {
|
||||
if (*e->d_name == '.')
|
||||
continue;
|
||||
if (filter && strstr(e->d_name, filter))
|
||||
continue;
|
||||
if (include && !is_gmail(e->d_name))
|
||||
continue;
|
||||
ctx->total_msgs++;
|
||||
ctx->recent_msgs += i;
|
||||
#ifdef USE_DB
|
||||
|
@ -1206,8 +1168,7 @@ maildir_scan( maildir_store_t *ctx, msg_t_array_alloc_t *msglist )
|
|||
}
|
||||
goto retry;
|
||||
}
|
||||
// The clipped value is good enough for MaxSize comparisons.
|
||||
entry->size = st.st_size > UINT_MAX ? UINT_MAX : (uint)st.st_size;
|
||||
entry->size = (uint)st.st_size;
|
||||
}
|
||||
if (want_tuid || want_msgid) {
|
||||
if (!(f = fopen( buf, "r" ))) {
|
||||
|
@ -1602,17 +1563,12 @@ maildir_fetch_msg( store_t *gctx, message_t *gmsg, msg_data_t *data, int minimal
|
|||
}
|
||||
}
|
||||
fstat( fd, &st );
|
||||
if (st.st_size > INT_MAX) {
|
||||
error( "Maildir error: %s is too big", buf );
|
||||
goto mbad;
|
||||
}
|
||||
data->len = st.st_size;
|
||||
if (data->date == -1)
|
||||
data->date = st.st_mtime;
|
||||
data->data = nfmalloc( data->len );
|
||||
if (read( fd, data->data, data->len ) != data->len) {
|
||||
sys_error( "Maildir error: cannot read %s", buf );
|
||||
mbad:
|
||||
close( fd );
|
||||
cb( DRV_MSG_BAD, aux );
|
||||
return;
|
||||
|
|
34
src/sync.c
34
src/sync.c
|
@ -406,11 +406,11 @@ copy_msg_bytes( char **out_ptr, const char *in_buf, uint *in_idx, uint in_len, i
|
|||
}
|
||||
|
||||
static int
|
||||
copy_msg_convert( int in_cr, int out_cr, copy_vars_t *vars, int t )
|
||||
copy_msg_convert( int in_cr, int out_cr, copy_vars_t *vars )
|
||||
{
|
||||
char *in_buf = vars->data.data;
|
||||
uint in_len = vars->data.len;
|
||||
uint idx = 0, sbreak = 0, ebreak = 0, break2 = UINT_MAX;
|
||||
uint idx = 0, sbreak = 0, ebreak = 0, break2 = 0;
|
||||
uint lines = 0, hdr_crs = 0, bdy_crs = 0, app_cr = 0, extra = 0;
|
||||
uint add_subj = 0;
|
||||
|
||||
|
@ -428,10 +428,9 @@ copy_msg_convert( int in_cr, int out_cr, copy_vars_t *vars, int t )
|
|||
if (!vars->minimal)
|
||||
goto oke;
|
||||
} else {
|
||||
if (break2 == UINT_MAX && vars->minimal &&
|
||||
starts_with_upper( in_buf + start, (int)(in_len - start), "SUBJECT:", 8 )) {
|
||||
if (!break2 && vars->minimal && !strncasecmp( in_buf + start, "Subject:", 8 )) {
|
||||
break2 = start + 8;
|
||||
if (break2 < in_len && in_buf[break2] == ' ')
|
||||
if (in_buf[break2] == ' ')
|
||||
break2++;
|
||||
}
|
||||
lines++;
|
||||
|
@ -442,7 +441,7 @@ copy_msg_convert( int in_cr, int out_cr, copy_vars_t *vars, int t )
|
|||
sbreak = ebreak = start;
|
||||
if (vars->minimal) {
|
||||
in_len = idx;
|
||||
if (break2 == UINT_MAX) {
|
||||
if (!break2) {
|
||||
break2 = start;
|
||||
add_subj = 1;
|
||||
}
|
||||
|
@ -452,8 +451,7 @@ copy_msg_convert( int in_cr, int out_cr, copy_vars_t *vars, int t )
|
|||
goto nloop;
|
||||
}
|
||||
}
|
||||
warn( "Warning: message %u from %s has incomplete header; skipping.\n",
|
||||
vars->msg->uid, str_fn[1-t] );
|
||||
/* invalid message */
|
||||
free( in_buf );
|
||||
return 0;
|
||||
oke:
|
||||
|
@ -495,16 +493,10 @@ copy_msg_convert( int in_cr, int out_cr, copy_vars_t *vars, int t )
|
|||
}
|
||||
|
||||
vars->data.len = in_len + extra;
|
||||
if (vars->data.len > INT_MAX) {
|
||||
warn( "Warning: message %u from %s is too big after conversion; skipping.\n",
|
||||
vars->msg->uid, str_fn[1-t] );
|
||||
free( in_buf );
|
||||
return 0;
|
||||
}
|
||||
char *out_buf = vars->data.data = nfmalloc( vars->data.len );
|
||||
idx = 0;
|
||||
if (vars->srec) {
|
||||
if (break2 < sbreak) {
|
||||
if (break2 && break2 < sbreak) {
|
||||
copy_msg_bytes( &out_buf, in_buf, &idx, break2, in_cr, out_cr );
|
||||
memcpy( out_buf, dummy_pfx, strlen(dummy_pfx) );
|
||||
out_buf += strlen(dummy_pfx);
|
||||
|
@ -520,7 +512,7 @@ copy_msg_convert( int in_cr, int out_cr, copy_vars_t *vars, int t )
|
|||
*out_buf++ = '\n';
|
||||
idx = ebreak;
|
||||
|
||||
if (break2 != UINT_MAX && break2 >= sbreak) {
|
||||
if (break2 >= sbreak) {
|
||||
copy_msg_bytes( &out_buf, in_buf, &idx, break2, in_cr, out_cr );
|
||||
if (!add_subj) {
|
||||
memcpy( out_buf, dummy_pfx, strlen(dummy_pfx) );
|
||||
|
@ -564,7 +556,9 @@ msg_fetched( int sts, void *aux )
|
|||
scr = (svars->drv[1-t]->get_caps( svars->ctx[1-t] ) / DRV_CRLF) & 1;
|
||||
tcr = (svars->drv[t]->get_caps( svars->ctx[t] ) / DRV_CRLF) & 1;
|
||||
if (vars->srec || scr != tcr) {
|
||||
if (!copy_msg_convert( scr, tcr, vars, t )) {
|
||||
if (!copy_msg_convert( scr, tcr, vars )) {
|
||||
warn( "Warning: message %u from %s has incomplete header.\n",
|
||||
vars->msg->uid, str_fn[1-t] );
|
||||
vars->cb( SYNC_NOGOOD, 0, vars );
|
||||
return;
|
||||
}
|
||||
|
@ -1696,11 +1690,7 @@ box_loaded( int sts, message_t *msgs, int total_msgs, int recent_msgs, void *aux
|
|||
JLOG( "> %u %u 0", (srec->uid[F], srec->uid[N]), "near side expired, orphaning far side" );
|
||||
srec->uid[N] = 0;
|
||||
} else {
|
||||
if (srec->msg[t] && (srec->msg[t]->status & M_FLAGS) &&
|
||||
// Ignore deleted flag, as that's what we'll change ourselves ...
|
||||
(((srec->msg[t]->flags & ~F_DELETED) != (srec->flags & ~F_DELETED)) ||
|
||||
// ... except for undeletion, as that's the opposite.
|
||||
(!(srec->msg[t]->flags & F_DELETED) && (srec->flags & F_DELETED))))
|
||||
if (srec->msg[t] && (srec->msg[t]->status & M_FLAGS) && srec->msg[t]->flags != srec->flags)
|
||||
notice( "Notice: conflicting changes in (%u,%u)\n", srec->uid[F], srec->uid[N] );
|
||||
if (svars->chan->ops[t] & OP_DELETE) {
|
||||
debug( " %sing delete\n", str_hl[t] );
|
||||
|
|
Loading…
Add table
Reference in a new issue