Re: Locking problem in Cyrus 2.0.16 Revisited
OK, had another crash today, but unfortunately the symbol table info for the lib files was not loading properly so I could not get full details.I did a make clean in the lib directory, recompiled cyrus and tested gdb and now the symbol table is loading properly. Next time I should be able to get full details. Here is what I had so far. The problem process appeared to be updating the seen file when doing a message copy. More details next crash Thanks, John Full details --- When I checked, I had three blocked imap processes for the user and seven lmtpd processes. cyrus27898 15692 0 Nov09 ?00:00:00 imapd cyrus21991 15692 0 Nov09 ?00:00:00 imapd cyrus 5332 15692 0 Nov09 ?00:00:00 imapd cyrus17070 15692 0 Nov09 ?00:00:00 lmtpd cyrus28341 15692 0 06:55 ?00:00:00 lmtpd cyrus29862 15692 0 13:42 ?00:00:00 lmtpd cyrus 9286 15692 0 16:01 ?00:00:00 lmtpd cyrus 2003 15692 0 18:52 ?00:00:01 lmtpd cyrus10304 15692 0 19:17 ?00:00:01 lmtpd cyrus23400 15692 0 19:56 ?00:00:00 lmtpd A quick check of the lmtpd's and two of the imap processes indicated that they were all blocked trying to access files locked by process 21991 for example: -- [root@borg /root]# gdb /usr/cyrus/bin/imapd 5332 0x4028a8a1 in __flock () from /lib/libc.so.6 (gdb) bt #0 0x4028a8a1 in __flock () from /lib/libc.so.6 #1 0x8079d27 in lock_reopen () #2 0x8062028 in mailbox_lock_header (mailbox=0xbfffedb0) at mailbox.c:812 #3 0x805f65d in append_setup (as=0xbfffedb0, name=0xb2c0 "user.lraven.Trash", format=0, userid=0x810fdd8 "lraven", auth_state=0x8110280, aclcheck=16, quotacheck=3061) at append.c:113 #4 0x80599ff in index_copy (mailbox=0x80fff40, sequence=0x810fce8 "6194", usinguid=1, name=0xb2c0 "user.lraven.Trash", copyuidp=0xb2bc) at index.c:1220 #5 0x80531eb in cmd_copy (tag=0x810fc08 "27", sequence=0x810fce8 "6194", name=0x810fd58 "INBOX.Trash", usinguid=1) at imapd.c:3192 #6 0x804d878 in cmdloop () at imapd.c:791 #7 0x804cf50 in service_main (argc=1, argv=0xbe14, envp=0xbe1c) at imapd.c:546 #8 0x804bd00 in main () #9 0x401d2f31 in __libc_start_main (main=0x804b8fc , argc=1, ubp_av=0xbe14, init=0x804a9e4 <_init>, fini=0x807e96c <_fini>, rtld_fini=0x4000e274 <_dl_fini>, stack_end=0xbe0c) at ../sysdeps/generic/libc-start.c:129 (gdb) up #1 0x8079d27 in lock_reopen () (gdb) up #2 0x8062028 in mailbox_lock_header (mailbox=0xbfffedb0) at mailbox.c:812 812 r = lock_reopen(mailbox->header_fd, fnamebuf, &sbuf, &lockfailaction ); (gdb) print fnamebuf $1 = "/var/spool/imap/3/user/lraven/Trash/cyrus.header\000*-@", '\000' , " Þÿ¿\000\000\000\000\002\000\000\000\000\000\000\Þÿ¿\000\000\000 \000\000\000\000\000L®-@\000\000\000\000\000\000\000\000|\027\000@|\n\000@\005\b \000\000\000\000\000\000\000\000\000\000\016\\000\200\201\000\000\001\000\00 0\000ÿ\001\000\000\000\000\000\000=6\000\000\000\000\000\000\000\000\000\000ì\00 6\000\000\000\000\000\000\000\020\000\000\b\000\000\000\000\000\000\000Ílì;\000\ 000\000\000ITì;L®-@ITì;\000\000\000\000\016\000"... (gdb) quit (gdb) quit The program is running. Quit anyway (and detach it)? (y or n) y Detaching from program: /usr/cyrus/bin/imapd, Pid 5332 [root@borg /root]# lsof -p 5332 | grep cyrus.header imapd 5332 cyrus memREG8,5 174 3145792 /var/spool/imap/3/use r/lraven/cyrus.header imapd 5332 cyrus memREG8,5 174 2998385 /var/spool/imap/3/use r/lraven/Trash/cyrus.header imapd 5332 cyrus 14u REG8,5 174 3145792 /var/spool/imap/3/use r/lraven/cyrus.header imapd 5332 cyrus 19u REG8,5 174 2998385 /var/spool/imap/3/use r/lraven/Trash/cyrus.header [root@borg /root]# grep 2998385 /proc/locks 6: FLOCK ADVISORY WRITE 21991 08:05:2998385 0 9223372036854775807 e03b23c0 e03 b2be0 e03b28c0 f57a4d60 6: -> FLOCK ADVISORY WRITE 27898 08:05:2998385 0 9223372036854775807 f57a4d60 f68f5aa0 6: -> FLOCK ADVISORY WRITE 5332 08:05:2998385 0 9223372036854775807 f68f5aa0 0 000 e03b23c0 -- looking at the errant process that had the lock(21991): [root@borg /rosof |gdb /usr/cyrus/bin/imapd 21991 0x4028a8a1 in __flock () from /lib/libc.so.6 (gdb) bt #0 0x4028a8a1 in __flock () from /lib/libc.so.6 #1 0x8079d27 in lock_reopen () #2 0x807b9f7 in starttxn_or_refetch () #3 0x807bb69 in myfetch () #4 0x807bc09 in fetchlock () #5 0x806f933 in seen_readit (seendb=0x810ea30, lastreadptr=0xbfffed38, lastuidptr=0xbfffed3c, lastchangeptr=0xbfffed40, seenuidsptr=0xbfffed44, rw=1) at seen_db.c:268 #6 0x806fab8 in seen_l
mh and cyrus
I want to perform some manipulations on cyrus folders and I read somewhere that the cyrus mail folders were similar to mh folders. Can I use the mh tools on cyrus folders? Lance
Re: RFC: Sieving mail delivered directly to shared/public folders
Here is the 21.K patch. Apologies if this makes for an unacceptably large email. - It adds a new command "folder" which takes a folder as a parameter to "timsieved" which allows a script to be associated with any folder or heirarchy of folders in the imap store. - It alters lmtpd to pick the appropriate sieve script for the folder being delivered to - i.e. the folder described by the left hand side of the email address. The patch is against current CVS (well, CVS of Thursday). It is made from "cvs diff -u /" - i.e. from the "cyrus-imapd" directory. It is very much a proof of concept. It compiles and does something ;-) - but I wouldn't rely on it to do any more than that. Regards, Ian Index: imap/lmtpd.c === RCS file: /cvs/src/cyrus/imap/lmtpd.c,v retrieving revision 1.75 diff -u -r1.75 lmtpd.c --- lmtpd.c 2001/10/02 21:08:10 1.75 +++ lmtpd.c 2001/11/08 18:29:38 @@ -734,8 +734,14 @@ int ret = 1; if (sd->mailboxname) { - strcpy(namebuf, lmtpd_namespace.prefix[NAMESPACE_INBOX]); - strcat(namebuf, sd->mailboxname); +/* Sieving a public or user folder ? */ +if ( strcmp( sd->username, "anyone" ) ) { + strcpy(namebuf, lmtpd_namespace.prefix[NAMESPACE_INBOX]); + strcat(namebuf, sd->mailboxname); +} +else { +strcpy(namebuf, sd->mailboxname); +} ret = deliver_mailbox(md->data, &mydata->stage, md->size, kc->imapflags->flag, kc->imapflags->nflags, @@ -748,7 +754,13 @@ if (!sd->authstate) return SIEVE_FAIL; - strcpy(namebuf, "INBOX"); + /* sieving a public or user folder ? */ +if ( strcmp( sd->username, "anyone" ) ) { + strcpy(namebuf, "INBOX"); +} +else { +strcpy( namebuf, sd->mailboxname ); +} ret = deliver_mailbox(md->data, &mydata->stage, md->size, kc->imapflags->flag, kc->imapflags->nflags, @@ -1018,10 +1030,30 @@ } } +static int mailbox_parent( char *mailboxname ) +{ +char *p; +int r = 1; +p = strrchr ( mailboxname, '.' ); +if ( p ) { + *p = '\0'; + r = 0; +} +return r; +} + + /* returns true if user has a sieve file */ -static FILE *sieve_find_script(const char *user) +static FILE *sieve_find_script(const char *user, char *mailboxname) { char buf[1024]; +char namebuf[MAX_MAILBOX_NAME]; +char namebuf2[MAX_MAILBOX_NAME]; +char script_path[MAX_MAILBOX_PATH]; +const char *sievesystemscripts = config_getstring( "sievedir", "/usr/sieve" ); +int r; +char *path, *acl; +FILE *sfp; if (strlen(user) > 900) { return NULL; @@ -1031,28 +1063,83 @@ /* duplicate delivery suppression is needed for sieve */ return NULL; } - -if (sieve_usehomedir) { /* look in homedir */ - struct passwd *pent = getpwnam(user); - if (pent == NULL) { - return NULL; +if ( strcmp( user, "anyone" ) ) { +if ( mailboxname ) { + strcpy(namebuf, lmtpd_namespace.prefix[NAMESPACE_INBOX]); + strcat(namebuf, mailboxname); } + else { + strcpy( namebuf, "INBOX" ); +} + +} +else { +strcpy(namebuf, lmtpd_namespace.prefix[NAMESPACE_SHARED]); +strcat(namebuf, mailboxname); +} + +mboxname_hiersep_toexternal(&lmtpd_namespace, namebuf); + +r = (*lmtpd_namespace.mboxname_tointernal)(&lmtpd_namespace, namebuf, + user, namebuf2); + +if ( mboxlist_lookup( namebuf2, &path, &acl, NULL ) == 0 ) { + syslog( LOG_INFO, "1 The folder exists" ); + +mailbox_hash_mbox( script_path, sievesystemscripts, namebuf2 ); + + syslog( LOG_INFO, "4 script is %s", script_path ); +} +else { +return NULL; +} + +snprintf(buf, sizeof(buf), "%s/default", script_path ); + +r = 0; +while (!r && ( syslog(LOG_INFO, "5 file is %s", buf ), sfp = fopen(buf, "r")) == +NULL) { + r = mailbox_parent( namebuf2 ); + mailbox_hash_mbox( script_path, sievesystemscripts, namebuf2 ); + snprintf(buf, sizeof(buf), "%s/default", script_path ); +} + +return sfp; - /* check ~USERNAME/.sieve */ - snprintf(buf, sizeof(buf), "%s/%s", pent->pw_dir, ".sieve"); -} else { /* look in sieve_dir */ - char hash; +#if 0 +if ( !strcmp( user, "anyone" ) ) { +const char *sievesystemscripts = config_getstring( "sievedir", "/usr/sieve" ); - hash = (char) dir_hash_c(user); +if ( sievesystemscripts == (const char *) 0 ) { +return NULL; /* Must have a script dir for this to work */ +} - snprintf(buf, sizeof(buf), "%s/%c/%s/default", sieve_dir, hash, user); +snprintf(buf, sizeof(buf), "%s/default", sie
Re: RFC: Sieving mail delivered directly to shared/public folders
On Sat, 2001-11-10 at 00:36, Nick Sayer wrote: > > > The big problem is that you can only have one script for the entire set > > of public folders. > > > > Unless you create multiple such users. > > > I'm sure that will work... but I think a more natural fit is "scripts go with folders" - because it is the mail being sieved - not the user. Think this way - Currently a folder has a set of ACLs - if you like, some properties that belong to the folder. By binding a sieve script to the folder we are extending the set of "properties" to also include a set of "methods". Only at the time when an action is to be taken, is the user taking that action tested against the folder - to see if the action that they want to take is allowable within the context of the security framework.