[pkg-kolab] Bug#522715: kolab-cyrus-pop3d: Patch to limit POP3 mailbox size (e.g. for mobile clients) via username hack
Tor Slettnes
tor at slett.net
Mon Apr 6 04:42:46 UTC 2009
Package: kolab-cyrus-pop3d
Version: 2.2.13-5.1
Severity: wishlist
The following patch allows the client to append "-NNN" to the POP3 username
in order to see only the last NNN messages in the mailbox. This is useful
for many mobile clients (in particular, those on Nokia S60 phones such as
the N85, N96 etc), where retreiving all headers in very large mailboxes is
a problem due to resource limitations.
--- BEGIN debian/patches/26-pop3d-mbox-limit.dpatch ---
#! /bin/sh /usr/share/dpatch/dpatch-run
## 26-pop3d-mbox-limit.dpatch by Tor Slettnes <tor at slett.net>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Append "-nnn" to username to see only the last nnn messages
@DPATCH@
--- kolab-cyrus-imapd-2.2.13/imap/pop3d.c 2009-04-06 03:44:35.562887776 +0000
+++ pop3d.c 2009-04-06 03:47:28.734972204 +0000
@@ -119,6 +119,7 @@
static int popd_logfd = -1;
unsigned popd_exists = 0;
unsigned popd_login_time;
+static int popd_list_limit = 0;
struct msg {
unsigned uid;
unsigned size;
@@ -978,6 +979,7 @@
{
int sasl_result;
char *canon_user;
+ char *pos, *end;
assert(response != NULL);
@@ -986,6 +988,20 @@
return;
}
+ /* Hack: If the username ends with "-nnn", then only the last nnn */
+ /* messages in the mailbox are returned from the "list" command, */
+ /* and the suffix is removed from the username before proceeding. */
+
+ for (pos=response; (*pos!='\0') && !isspace(*pos); pos++)
+ {
+ if (*pos == '-')
+ {
+ popd_list_limit = strtoul(pos+1, &end, 10);
+ memmove(pos, end, strlen(end)+1);
+ break;
+ }
+ }
+
sasl_result = sasl_checkapop(popd_saslconn,
popd_apop_chal,
strlen(popd_apop_chal),
@@ -1037,6 +1053,7 @@
void cmd_user(char *user)
{
char *p, *dot, *domain;
+ char *pos, *end;
/* possibly disallow USER */
if (!(kflag || popd_starttls_done ||
@@ -1051,6 +1068,20 @@
return;
}
+
+ /* Hack: If the username ends with "-nnn", then only the last nnn */
+ /* messages in the mailbox are returned from the "list" command, */
+ /* and the suffix is removed from the username before proceeding. */
+ for (pos=user; (*pos!='\0') && !isspace(*pos); pos++)
+ {
+ if (*pos == '-')
+ {
+ popd_list_limit = strtoul(pos+1, &end, 10);
+ memmove(pos, end, strlen(end)+1);
+ break;
+ }
+ }
+
if (!(p = canonify_userid(user, NULL, NULL)) ||
/* '.' isn't allowed if '.' is the hierarchy separator */
(popd_namespace.hier_sep == '.' && (dot = strchr(p, '.')) &&
@@ -1380,6 +1411,7 @@
struct index_record record;
int minpoll;
int doclose = 0;
+ int offset = 0;
popd_login_time = time(0);
@@ -1435,10 +1467,15 @@
}
if (!r) {
popd_exists = mboxstruct.exists;
+ if ((popd_list_limit != 0) && (popd_exists > popd_list_limit))
+ {
+ offset = popd_exists - popd_list_limit;
+ popd_exists = popd_list_limit;
+ }
popd_msg = (struct msg *) xrealloc(popd_msg, (popd_exists+1) *
sizeof(struct msg));
for (msg = 1; msg <= popd_exists; msg++) {
- if ((r = mailbox_read_index_record(&mboxstruct, msg, &record))!=0)
+ if ((r = mailbox_read_index_record(&mboxstruct, msg+offset, &record))!=0)
break;
popd_msg[msg].uid = record.uid;
popd_msg[msg].size = record.size;
--- END debian/patches/26-pop3d-mbox-limit.dpatch ---
-- System Information:
Debian Release: 5.0
APT prefers stable
APT policy: (500, 'stable')
Architecture: i386 (i686)
Kernel: Linux 2.6.24-etchnhalf.1-686-bigmem (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages kolab-cyrus-pop3d depends on:
ii kolab-cyrus-common 2.2.13-5.1 Cyrus mail system (common files)
ii libasn1-8-heimdal 1.2.dfsg.1-2.1 Heimdal Kerberos - ASN.1 library
ii libc6 2.7-18 GNU C Library: Shared libraries
ii libcomerr2 1.41.3-1 common error description library
ii libdb4.2 4.2.52+dfsg-5 Berkeley v4.2 Database Libraries [
ii libgssapi2-heimdal 1.2.dfsg.1-2.1 Heimdal Kerberos - GSSAPI support
ii libkrb5-25-heimdal 1.2.dfsg.1-2.1 Heimdal Kerberos - libraries
ii libldap-2.4-2 2.4.11-1 OpenLDAP libraries
ii libroken18-heimdal 1.2.dfsg.1-2.1 Heimdal Kerberos - roken support l
ii libsasl2-2 2.1.22.dfsg1-23 Cyrus SASL - authentication abstra
ii libssl0.9.8 0.9.8g-15 SSL shared libraries
ii libwrap0 7.6.q-16 Wietse Venema's TCP wrappers libra
kolab-cyrus-pop3d recommends no packages.
kolab-cyrus-pop3d suggests no packages.
-- no debconf information
More information about the pkg-kolab-devel
mailing list