On Thu, Jul 03, 2008 at 01:16:57PM +0200, Carlos García Gómez wrote:
I need to store last authentication time for imap login.
A simple solution is to look at the mtime timestamp on the 'cur'
subdirectory of the Maildir. This is because every time the user logs in,
any mail in new/ is moved to cur/, and this updates the timestamp on cur/.
This doesn't work if the user has no new mail, but you can add a simple
patch to update the cur/ directory in that case.
The attached patches are a couple of years old, you'll have to see if they
still apply cleanly. They have been posted before, e.g.
http://sourceforge.net/mailarchive/message.php?msg_id=20080401054905.GA13986%40uk.tiscali.com
Regards,
Brian.
diff -uNr courier-imap-4.0.3.orig/imap/imapscanclient.c
courier-imap-4.0.3/imap/imapscanclient.c
--- courier-imap-4.0.3.orig/imap/imapscanclient.c Tue Jul 20 00:54:14 2004
+++ courier-imap-4.0.3/imap/imapscanclient.cSun May 22 18:16:33 2005
@@ -358,6 +358,7 @@
struct dirent *de;
unsigned long left_unseen=0;
intdowritecache=0;
+intgotnew=0;
if (is_sharedsubdir(dir))
maildir_shared_sync(dir);
@@ -723,6 +724,7 @@
}
if (dirp) closedir(dirp);
+ if (n) gotnew = 1;
while (n)
{
@@ -749,6 +751,13 @@
}
} while (keepgoing);
}
+
+ /* Update the 'cur' timestamp if no new mail arrived */
+ if (!gotnew) {
+ strcpy(p+strlen(p)-3, cur);
+ utimes(p, 0);
+ }
+
free(p);
/*
diff -uNr courier-imap-4.0.3.orig/maildir/maildirgetnew.c
courier-imap-4.0.3/maildir/maildirgetnew.c
--- courier-imap-4.0.3.orig/maildir/maildirgetnew.c Tue Jun 8 23:44:24 2004
+++ courier-imap-4.0.3/maildir/maildirgetnew.c Sun May 22 18:09:46 2005
@@ -77,6 +77,7 @@
int n;
char *new_buf[20];
char *cur_buf[20];
+ int gotnew = 0;
do
{
@@ -125,6 +126,7 @@
}
}
if (dirp) closedir(dirp);
+ if (n) gotnew = 1;
while (n)
{
@@ -151,4 +153,7 @@
free(cp);
}
} while (keepgoing);
+
+ /* Update the 'cur' timestamp even if no new mail arrived */
+ if (!gotnew) utimes(curd, 0);
}
diff --exclude *~ -uNr sqwebmail-5.0.2.orig/sqwebmail/maildir.c
sqwebmail-5.0.2/sqwebmail/maildir.c
--- sqwebmail-5.0.2.orig/sqwebmail/maildir.cThu Oct 21 02:13:18 2004
+++ sqwebmail-5.0.2/sqwebmail/maildir.c Sun May 22 20:15:03 2005
@@ -1115,6 +1115,7 @@
DIR *dirp;
struct dirent *dire;
characl_buf[2];
+ int gotnew=0;
/* Delete old files in tmp */
@@ -1143,8 +1144,14 @@
rename(oldname, newname);
free(oldname);
free(newname);
+ gotnew=1;
}
if (dirp) closedir(dirp);
+ if (!gotnew) {
+ /* Update the 'cur' timestamp if no new mail arrived */
+ strcpy(dirbuf+strlen(dirbuf)-3, cur);
+ utimes(dirbuf, 0);
+ }
free(dirbuf);
/* Look for any messages mark as deleted. When we delete a message
-
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08___
Courier-imap mailing list
Courier-imap@lists.sourceforge.net
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-imap