|
Re: Per-Domain-Quota in 2.2 with virtual domains turned on ?: msg#00643mail.imap.cyrus
Ken Murchison wrote: I just committed support for per-domain quotas which works for allSorry for not answering a longer time. I did not have the time to concentrate on cyrus the last days. I just updated from cvs and started looking at the domain quota. Could it be that the quota binary does not support the -f option for virtdomains correctly ? For me quota does not report anything for mailboxes for which cyradm displays data and so I think quota cannot fix also ?! Actually I wrote a patch last night to get rid of mkimap -d! I added a new switch to imap/imapoptions which is called virtdomains_autoconfig and defaults to disabled. If enabled the function mailbox_create() in mailbox.c creates the configdirectory/domain/d/domain/... and the sievedir/domain/d/domain/.... directories if compiled with USE_SIEVE and if the domain does not already exist. For me this patch compiles without warnings and seems to work but because I am a java programmer and are used to thinking in an objectoriented manner I do not have *the* 100% C knowledge. Mainly I do not know if the pointers buffers etc I used are used and initialized correctly or whatever. So this here needs definetley review and it would be great if someone could point out some errors I did or write some comments to this. --Christian-- schulte-22:31:03:~/cyrus-cvs/cyrus-imapd-2_2/imap >diff -c imapoptions.original imapoptions *** imapoptions.original Do Jan 30 22:28:27 2003 --- imapoptions Do Jan 30 22:30:20 2003 *************** *** 546,551 **** --- 546,557 ---- { "virtdomains", 0, SWITCH } /* Enable virtual domain support */ + { "virtdomains_autoconfig", 0, SWITCH } + /* Automatically configure the configdirectory tree. The default is + to run tools/mkimap -d for every new domain. Enabling this causes + automatic configuration of the configdirectory tree without the need of + tools/mkimap -d */ + /* .SH SEE ALSO .PP schulte-22:48:49:~/cyrus-cvs/cyrus-imapd-2_2/imap >diff -c mailbox.c.original mailbox.c *** mailbox.c.original Do Jan 30 22:23:22 2003 --- mailbox.c Do Jan 30 22:18:18 2003 *************** *** 1938,1944 **** --- 1938,1977 ---- return (stat(quota_path, &sbuf) != -1); } + /* creates directories a..z within a given path */ + int mailbox_virtdomains_createaz(char *path){ + char *a="XX"; + char alpha[60]="a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:w:x:y:z"; + char *p; + int save_errno; + struct stat sbuf; + + p=path+strlen(path); + a=strtok(strdup(alpha), ":"); + strcpy(p,a); + if (mkdir(path, 0755) == -1 && errno != EEXIST) { + save_errno = errno; + if (stat(path, &sbuf) == -1) { + errno = save_errno; + syslog(LOG_ERR, "IOERROR: creating directory %s: %m", path); + return IMAP_IOERROR; + } + } + while((a=strtok(NULL, ":"))){ + strcpy(p,a); + if (mkdir(path, 0755) == -1 && errno != EEXIST) { + save_errno = errno; + if (stat(path, &sbuf) == -1) { + errno = save_errno; + syslog(LOG_ERR, "IOERROR: creating directory %s: %m", path); + return IMAP_IOERROR; + } + } + } + return 0; + } + int mailbox_create(const char *name, char *path, const char *acl, *************** *** 1948,1953 **** --- 1981,1994 ---- { int r; char *p=path; + char cfgdir[MAX_MAILBOX_PATH]; + #ifdef USE_SIEVE + char sievedir[MAX_MAILBOX_PATH]; + #endif /* USE_SIEVE */ + char *myname=strdup(name); + char *myp=myname; + char *my2p; + char letter[2]; char quota_root[MAX_MAILBOX_PATH]; int hasquota; char fnamebuf[MAX_MAILBOX_PATH]; *************** *** 1977,1983 **** return IMAP_IOERROR; } } ! zeromailbox(mailbox); mailbox.quota.fd = -1; --- 2018,2109 ---- return IMAP_IOERROR; } } ! ! /* Create the domain also under the configdirectory if virtdomains_autoconfig. */ ! if(config_getswitch(IMAPOPT_VIRTDOMAINS_AUTOCONFIG)){ ! strcpy(cfgdir, config_getstring(IMAPOPT_CONFIGDIRECTORY)); ! myp=strchr(myp, '!'); ! // Only do something if there is an '!' character in the mailbox name ! if(myp){ ! *myp='\0'; ! strcat(cfgdir,"/domain/"); ! strncpy(letter, myname, 1); ! strcat(cfgdir,letter); ! strcat(cfgdir,"/"); ! strcat(cfgdir,myname); ! strcat(cfgdir,"/"); ! // Check if the domain already exists ! if(stat(cfgdir, &sbuf) != -1) goto sieve; ! syslog(LOG_INFO, "virtdomains_autoconfig: configuring %s", cfgdir); ! myp=cfgdir; ! while ((myp = strchr(myp+1, '/'))) { ! *myp = '\0'; ! if (mkdir(cfgdir, 0755) == -1 && errno != EEXIST) { ! save_errno = errno; ! if (stat(cfgdir, &sbuf) == -1) { ! errno = save_errno; ! syslog(LOG_ERR, "IOERROR: creating directory %s: %m", cfgdir); ! return IMAP_IOERROR; ! } ! } ! *myp = '/'; ! } ! myp=cfgdir+strlen(cfgdir); ! strcpy(myp,"user"); ! if (mkdir(cfgdir, 0755) == -1 && errno != EEXIST) { ! save_errno = errno; ! if (stat(cfgdir, &sbuf) == -1) { ! errno = save_errno; ! syslog(LOG_ERR, "IOERROR: creating directory %s: %m", cfgdir); ! return IMAP_IOERROR; ! } ! } ! strcat(cfgdir, "/"); ! my2p=cfgdir+strlen(cfgdir); ! r=mailbox_virtdomains_createaz(cfgdir); ! if(r!=0) return r; ! strcpy(myp,"quota"); ! if (mkdir(cfgdir, 0755) == -1 && errno != EEXIST) { ! save_errno = errno; ! if (stat(cfgdir, &sbuf) == -1) { ! errno = save_errno; ! syslog(LOG_ERR, "IOERROR: creating directory %s: %m", cfgdir); ! return IMAP_IOERROR; ! } ! } ! strcat(cfgdir, "/"); ! r=mailbox_virtdomains_createaz(cfgdir); ! if(r!=0) return r; ! sieve: ! #ifdef USE_SIEVE ! strcpy(sievedir, config_getstring(IMAPOPT_SIEVEDIR)); ! strcat(sievedir,"/domain/"); ! strcat(sievedir,letter); ! strcat(sievedir,"/"); ! strcat(sievedir,myname); ! strcat(sievedir,"/"); ! // Check if the domain already exists ! if(stat(sievedir, &sbuf) != -1) goto configured; ! syslog(LOG_INFO, "virtdomains_autoconfig: configuring %s", sievedir); ! myp=sievedir; ! while ((myp = strchr(myp+1, '/'))) { ! *myp = '\0'; ! if (mkdir(sievedir, 0755) == -1 && errno != EEXIST) { ! save_errno = errno; ! if (stat(sievedir, &sbuf) == -1) { ! errno = save_errno; ! syslog(LOG_ERR, "IOERROR: creating directory %s: %m", sievedir); ! return IMAP_IOERROR; ! } ! } ! *myp = '/'; ! } ! r=mailbox_virtdomains_createaz(sievedir); ! if(r!=0) return r; ! #endif /* USE_SIEVE */ ! configured: ! } ! } zeromailbox(mailbox); mailbox.quota.fd = -1; |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: sendmail+cyrus+spamassassin: 00643, Steve Barber |
|---|---|
| Next by Date: | Re: cyradm - urgent!: 00643, Shinichiro HIDA |
| Previous by Thread: | Re: Per-Domain-Quota in 2.2 with virtual domains turned on ?i: 00643, Ken Murchison |
| Next by Thread: | Re: Per-Domain-Quota in 2.2 with virtual domains turned on ?: 00643, Ken Murchison |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |