[csw-devel] SF.net SVN: gar:[6829] csw/mgar/pkg/cyrus_imapd/trunk

chninkel at users.sourceforge.net chninkel at users.sourceforge.net
Sun Oct 11 15:55:25 CEST 2009


Revision: 6829
          http://gar.svn.sourceforge.net/gar/?rev=6829&view=rev
Author:   chninkel
Date:     2009-10-11 13:55:25 +0000 (Sun, 11 Oct 2009)

Log Message:
-----------
cyrus_imapd: updated to 2.3.15
cyrus_imapd: switched to cswclassutils for SMF support and configuration file handling
cyrus_imapd: removed headers and static libraries
cyrus_imapd: switched to automatic gspec and depend file

Modified Paths:
--------------
    csw/mgar/pkg/cyrus_imapd/trunk/Makefile
    csw/mgar/pkg/cyrus_imapd/trunk/checksums
    csw/mgar/pkg/cyrus_imapd/trunk/files/CSWcyrusimapd.prototype
    csw/mgar/pkg/cyrus_imapd/trunk/files/cyrus_imapd.changelog.CSW

Added Paths:
-----------
    csw/mgar/pkg/cyrus_imapd/trunk/files/cswcyrus
    csw/mgar/pkg/cyrus_imapd/trunk/files/cyrus-imapd-2.3.15-autocreate-0.10-0.diff

Removed Paths:
-------------
    csw/mgar/pkg/cyrus_imapd/trunk/files/CSWcyrusimapd.depend
    csw/mgar/pkg/cyrus_imapd/trunk/files/CSWcyrusimapd.gspec
    csw/mgar/pkg/cyrus_imapd/trunk/files/CSWcyrusimapdutils.depend
    csw/mgar/pkg/cyrus_imapd/trunk/files/CSWcyrusimapdutils.gspec
    csw/mgar/pkg/cyrus_imapd/trunk/files/CSWpmcyrus.depend
    csw/mgar/pkg/cyrus_imapd/trunk/files/CSWpmcyrus.gspec
    csw/mgar/pkg/cyrus_imapd/trunk/files/cswcyrus.init
    csw/mgar/pkg/cyrus_imapd/trunk/files/i.conf
    csw/mgar/pkg/cyrus_imapd/trunk/files/r.conf
    csw/mgar/pkg/cyrus_imapd/trunk/files/svc-cswcyrus

Modified: csw/mgar/pkg/cyrus_imapd/trunk/Makefile
===================================================================
--- csw/mgar/pkg/cyrus_imapd/trunk/Makefile	2009-10-11 13:31:43 UTC (rev 6828)
+++ csw/mgar/pkg/cyrus_imapd/trunk/Makefile	2009-10-11 13:55:25 UTC (rev 6829)
@@ -29,7 +29,24 @@
   multiple SASL mechanisms, and the Sieve mail filtering language.
 endef
 
+PACKAGES = CSWcyrusimapd CSWcyrusimapdutils CSWpmcyrus
 
+SPKG_DESC_CSWcyrusimapd = Pop and Imap server from the Cyrus mail system
+CATALOGNAME_CSWcyrusimapd = cyrus_imapd
+REQUIRED_PKGS_CSWcyrusimapd = CSWosslrt CSWsasl CSWbdb4 CSWkrb5lib CSWtcpwrap CSWnetsnmp CSWpcrert
+SPKG_CLASSES_CSWcyrusimapd = none services cswpreserveconf cswinitsmf
+
+SPKG_DESC_CSWcyrusimapdutils = Various admin utilities for Cyrus Imapd/Popd
+CATALOGNAME_CSWcyrusimapdutils = cyrus_imapd_utils
+REQUIRED_PKGS_CSWcyrusimapdutils = CSWpmcyrus CSWosslrt CSWsasl CSWbdb4 CSWkrb5lib CSWpcrert
+SPKG_CLASSES_CSWcyrusimapd = none 
+
+SPKG_DESC_CSWpmcyrus = Perl interface to Cyrus Imap functions
+CATALOGNAME_CSWpmcyrus = pm_cyrus
+REQUIRED_PKGS_CSWpmcyrus = CSWperl CSWbdb4 CSWosslrt CSWsasl
+SPKG_CLASSES_CSWcyrusimapd = none
+
+
 ###### Upstream and opencsw files information #######
 
 #MASTER_SITES = ftp://ftp.andrew.cmu.edu/pub/cyrus-mail/ http://email.uoa.gr/download/cyrus/cyrus-imapd-$(GARVERSION)/
@@ -38,16 +55,17 @@
 # We define upstream file regex so we can be notifed of new upstream software release
 UFILES_REGEX = $(shell echo $(GARNAME) | tr '_' '-')-(\d+(?:\.\d+)*).tar.gz
 
-DISTFILES  = $(shell echo $(GARNAME) | tr '_' '-')-$(GARVERSION).tar.gz
-DISTFILES += $(call admfiles,CSWcyrusimapd,prototype preinstall depend checkinstall)
+DISTNAME = $(shell echo $(GARNAME) | tr '_' '-')-$(GARVERSION)
+
+DISTFILES  = $(DISTNAME).tar.gz
+DISTFILES += CSWcyrusimapd.prototype CSWcyrusimapd.preinstall CSWcyrusimapd.checkinstall
 DISTFILES += cyrus_imapd.changelog.CSW README.CSW
 DISTFILES += i.services r.services services
-DISTFILES += i.conf r.conf
-DISTFILES += cswcyrus.init cswcyrus.xml svc-cswcyrus
+DISTFILES += cswcyrus cswcyrus.xml
 DISTFILES += imapd.conf cyrus.conf
 
-DISTFILES += $(call admfiles,CSWpmcyrus,prototype depend)
-DISTFILES += $(call admfiles,CSWcyrusimapdutils,prototype depend)
+DISTFILES += CSWpmcyrus.prototype
+DISTFILES += CSWcyrusimapdutils.prototype
 DISTFILES += cyrus_imapd_utils.changelog.CSW
 DISTFILES += pm_cyrus.changelog.CSW
 
@@ -58,18 +76,11 @@
 # le fichier install-upgrade de cyrus 2.3.11 est incomplet
 DISTFILES += install-upgrade
 
-SPKG_CLASSES = none services conf
-
 # University of Athens patchs to allow autocreation of mailboxes
 # and autocreation of sub-lolders for filter rules
 #PATCHFILES = cyrus-imapd-$(GARVERSION)-autocreate-0.10-0.diff cyrus-imapd-$(GARVERSION)-autosieve-0.6.0.diff 
-PATCHFILES = cyrus-imapd-2.3.14-autocreate-0.10-0.diff cyrus-imapd-2.3.14-autosieve-0.6.0.diff 
+PATCHFILES = cyrus-imapd-2.3.15-autocreate-0.10-0.diff cyrus-imapd-2.3.14-autosieve-0.6.0.diff 
  
-# UPDATE: not necessary anymore, integrated upstream
-# This patch adds a new option which allows cyrus to
-# accept mails with 8bits characters in header
-# PATCHFILES += cyrus-imapd-2.2.7-munge8bit.patch
-
 # This patch makes cyrus more tolerant with mails containing
 # invalid From headers 
 # This avoids "Invalid Message header" error messages
@@ -89,9 +100,6 @@
 
 ##### Build and installation information #####
 
-# files are extracted in cyrus_imapd not cyrus-imapd
-WORKSRC = $(WORKDIR)/$(shell echo $(GARNAME) | tr '_' '-')-$(GARVERSION)
-
 CONFIGURE_ARGS = $(DIRPATHS)
 CONFIGURE_ARGS += --with-cyrus-prefix=$(prefix)
 CONFIGURE_ARGS += --with-service-path=$(libexecdir)/cyrus 
@@ -120,7 +128,7 @@
 pre-patch:
 	cp $(WORKDIR)/install-upgrade $(WORKSRC)/doc/text
 
-pre-configure:
+pre-configure-modulated:
 	# master is a too common name, so we rename it cyrus-master
 	cp $(WORKSRC)/man/master.8 $(WORKSRC)/man/cyrus-master.8
 	cp $(WORKSRC)/doc/man/master.8.html $(WORKSRC)/doc/man/cyrus-master.8.html
@@ -143,33 +151,48 @@
 
 pre-merge:
 	# we must create the directory where perl libraries will be installed
-	mkdir -p $(DESTDIR)/$(prefix)/lib/perl
-	mkdir -p $(DESTDIR)/$(sbindir)
-	mkdir -p $(DESTDIR)/$(sysconfdir)/cyrus
-	mkdir -p $(DESTDIR)/$(prefix)/share/doc/cyrus_imapd
+	mkdir -p $(PKGROOT)/$(prefix)/lib/perl
+	mkdir -p $(PKGROOT)/$(sbindir)
+	mkdir -p $(PKGROOT)/$(sysconfdir)/cyrus
+	mkdir -p $(PKGROOT)/$(prefix)/share/doc/cyrus_imapd
 	@$(MAKECOOKIE)
 
 post-merge:
+	# we provide our class action scripts to modify /etc/inet/services
+	ginstall $(WORKDIR_FIRSTMOD)/*.services $(WORKDIR)/
+	ginstall -D $(WORKDIR_FIRSTMOD)/services $(PKGROOT)/etc/inet/services
+	
+	# configuration and init file installation
+	ginstall -D "$(WORKDIR_FIRSTMOD)/cswcyrus" "$(PKGROOT)/etc/opt/csw/init.d/cswcyrus"
+	ginstall -D "$(WORKDIR_FIRSTMOD)/cswcyrus.xml" "$(PKGROOT)/var/opt/csw/svc/manifest/network/cswcyrus.xml"
+	ginstall -D "$(WORKDIR_FIRSTMOD)/imapd.conf" "$(PKGROOT)/$(sysconfdir)/cyrus/imapd.conf.CSW"
+	ginstall -D "$(WORKDIR_FIRSTMOD)/cyrus.conf" "$(PKGROOT)/$(sysconfdir)/cyrus/cyrus.conf.CSW"
+
+
 	# we install binary under tools as part of the package
-	cp -r $(WORKSRC)/tools/* $(DESTDIR)$(sbindir)
-	ginstall -D $(DESTDIR)$(sbindir)/arbitronsort.pl $(DESTDIR)$(sbindir)/arbitronsort
+	cp -r $(WORKSRC_FIRSTMOD)/tools/* $(PKGROOT)$(sbindir)
+	ginstall -D $(PKGROOT)$(sbindir)/arbitronsort.pl $(PKGROOT)$(sbindir)/arbitronsort
 
 	# we want perl script to use opencsw perl
-	perl -pi -e 's/exec\s+perl/exec \/opt\/csw\/bin\/perl/g' $(DESTDIR)$(sbindir)/* $(DESTDIR)$(bindir)/*
+	perl -pi -e 's/exec\s+perl/exec \/opt\/csw\/bin\/perl/g' $(PKGROOT)$(sbindir)/* $(PKGROOT)$(bindir)/*
 	( for FILE in convert-sieve.pl mupdate-loadgen.pl translatesieve undohash upgradesieve arbitronsort; do \
-	    perl -pi -e 's/^#!\/usr\/(local\/)?bin\/perl/#!\/usr\/bin\/perl/' $(DESTDIR)$(sbindir)/$$FILE; \
+	    perl -pi -e 's/^#!\/usr\/(local\/)?bin\/perl/#!\/usr\/bin\/perl/' $(PKGROOT)$(sbindir)/$$FILE; \
 	    done )
 
 	# we install the documentation
-	cp -r $(WORKSRC)/doc/* $(DESTDIR)/$(docdir)/cyrus_imapd
+	cp -r $(WORKSRC_FIRSTMOD)/doc/* $(PKGROOT)/$(docdir)/cyrus_imapd
 	( for PKG in cyrus_imapd cyrus_imapd_utils pm_cyrus; do \
-		ginstall -D $(WORKDIR)/$$PKG.changelog.CSW $(DESTDIR)/$(docdir)/$$PKG/changelog.CSW; \
+		ginstall -D $(WORKDIR_FIRSTMOD)/$$PKG.changelog.CSW $(PKGROOT)/$(docdir)/$$PKG/changelog.CSW; \
+		ginstall -D $(WORKDIR_FIRSTMOD)/README.CSW $(PKGROOT)/$(docdir)/$$PKG/README.CSW; \
 	  done )
 
 	# we rename some tools with too generic names
-	ginstall -D $(DESTDIR)/$(sbindir)/mkimap $(DESTDIR)/$(sbindir)/mkdirs
+	ginstall -D $(PKGROOT)/$(sbindir)/mkimap $(PKGROOT)/$(sbindir)/mkdirs
 	( for FILE in mkdirs mknewsgroups dohash undohash rehash; do \
-		ginstall -D $(DESTDIR)/$(sbindir)/$$FILE $(DESTDIR)/$(sbindir)/cyrus-$$FILE; \
+		ginstall -D $(PKGROOT)/$(sbindir)/$$FILE $(PKGROOT)/$(sbindir)/cyrus-$$FILE; \
 	  done )
+	
+	# we fix some permission problems
+	chmod -R u+w "$(PKGROOT)/"
+
 	@$(MAKECOOKIE)
-	

Modified: csw/mgar/pkg/cyrus_imapd/trunk/checksums
===================================================================
--- csw/mgar/pkg/cyrus_imapd/trunk/checksums	2009-10-11 13:31:43 UTC (rev 6828)
+++ csw/mgar/pkg/cyrus_imapd/trunk/checksums	2009-10-11 13:55:25 UTC (rev 6829)
@@ -1,35 +1,26 @@
-a55d22e88ee57fa81da2ea75c6e0e3d8  download/CSWcyrusimapd.checkinstall
-248ac6089e88b4eb3365e48c897b9734  download/CSWcyrusimapd.depend
-7423d96cacb8162b7987c9983cc85171  download/CSWcyrusimapd.gspec
-5111a5573aa6d4878b852780aeae8a27  download/CSWcyrusimapd.preinstall
-a22944187eb6b75e2437aa9a4c754c07  download/CSWcyrusimapd.prototype
-4d5ad6d492ca45da347bd9bd48213ac4  download/CSWcyrusimapdutils.depend
-d47ff67f45001cdda175616a543d7052  download/CSWcyrusimapdutils.gspec
-7e99e825a1d6b134b91392beec1807f4  download/CSWcyrusimapdutils.prototype
-fc64965b3c22618fb6b1dff7306a78e7  download/CSWpmcyrus.depend
-fdb06983e1a6fdde58ec25834742cf5d  download/CSWpmcyrus.gspec
-404a6d2b6608c26aaef4e37095200105  download/CSWpmcyrus.prototype
-d0b97b33e75ac75f89ee6236a2d53f05  download/README.CSW
-9cbebaeeafa6eb3320eafa594c253bc1  download/compile_et
-a5326ab0d66431d057db02c5ae9c5e4a  download/cswcyrus.init
-628c5cf5f5b01f9e173e090ee0c969aa  download/cswcyrus.xml
-95d0eb720cb67d712ab799609c619929  download/cyrus-imapd-2.3.14-autocreate-0.10-0.diff
-4f010ee86b24f737c9de9fffa0d194e4  download/cyrus-imapd-2.3.14-autosieve-0.6.0.diff
-d89cb1b55023188938f332b7ef120fae  download/cyrus-imapd-2.3.15.tar.gz
-b4c99489eacf0fb7befeef5e3098a5c1  download/cyrus-imapd-2.3.7-nobarenewlinescheck.patch
-6127a7b62ec4679a54985f6a2d915e52  download/cyrus-imapd-acceptinvalidfrom.patch
-fdb3416ec41f3a56d1594ca25a6dcd7d  download/cyrus.conf
-81f9b346bf3c1803381c94ce33f2163e  download/cyrus_imapd.changelog.CSW
-d722bfe708263b946d7bbc7f4d0ddf46  download/cyrus_imapd_utils.changelog.CSW
-5375c25c8bc325a90553d0be87a64a04  download/et_c.awk
-d1d86e61463a1dfefccbadedb11a8604  download/et_h.awk
-9b2ae27f98333b73ff2b16ed98ee896a  download/i.conf
-79211aee56db01e15566ced1ba4078da  download/i.services
-908dbf764d3ccd541c4de881ac81a6ae  download/imapd.conf
-14bb6e8c6d6914351f80df293982e88a  download/install-upgrade
-e6730668fa500fc77120ee007e535274  download/pm_cyrus.changelog.CSW
-5d9e9fb1a5b6af82ce915f72ebc5e3b7  download/r.conf
-149ac6b6d82ef9ef4bb1b314f1a1cac4  download/r.services
-dce627f9a464ae4efe8a66c8dbd358d5  download/restore_allowplaintext_default.patch
-6dfee20f7c02139350caf9f75199e587  download/services
-d41d8cd98f00b204e9800998ecf8427e  download/svc-cswcyrus
+a55d22e88ee57fa81da2ea75c6e0e3d8  CSWcyrusimapd.checkinstall
+5111a5573aa6d4878b852780aeae8a27  CSWcyrusimapd.preinstall
+63f0e304d69648e4cbaf197a329f1537  CSWcyrusimapd.prototype
+7e99e825a1d6b134b91392beec1807f4  CSWcyrusimapdutils.prototype
+404a6d2b6608c26aaef4e37095200105  CSWpmcyrus.prototype
+d0b97b33e75ac75f89ee6236a2d53f05  README.CSW
+9cbebaeeafa6eb3320eafa594c253bc1  compile_et
+1c2b850f7a264704eefec741a75977ab  cswcyrus
+628c5cf5f5b01f9e173e090ee0c969aa  cswcyrus.xml
+4f010ee86b24f737c9de9fffa0d194e4  cyrus-imapd-2.3.14-autosieve-0.6.0.diff
+318f1d2bd48bb4a7c2db5fb9f82c9e3d  cyrus-imapd-2.3.15-autocreate-0.10-0.diff
+d89cb1b55023188938f332b7ef120fae  cyrus-imapd-2.3.15.tar.gz
+b4c99489eacf0fb7befeef5e3098a5c1  cyrus-imapd-2.3.7-nobarenewlinescheck.patch
+6127a7b62ec4679a54985f6a2d915e52  cyrus-imapd-acceptinvalidfrom.patch
+fdb3416ec41f3a56d1594ca25a6dcd7d  cyrus.conf
+e8868f4e344649d1f2939d5d00f3f800  cyrus_imapd.changelog.CSW
+d722bfe708263b946d7bbc7f4d0ddf46  cyrus_imapd_utils.changelog.CSW
+5375c25c8bc325a90553d0be87a64a04  et_c.awk
+d1d86e61463a1dfefccbadedb11a8604  et_h.awk
+79211aee56db01e15566ced1ba4078da  i.services
+908dbf764d3ccd541c4de881ac81a6ae  imapd.conf
+14bb6e8c6d6914351f80df293982e88a  install-upgrade
+e6730668fa500fc77120ee007e535274  pm_cyrus.changelog.CSW
+149ac6b6d82ef9ef4bb1b314f1a1cac4  r.services
+dce627f9a464ae4efe8a66c8dbd358d5  restore_allowplaintext_default.patch
+6dfee20f7c02139350caf9f75199e587  services

Deleted: csw/mgar/pkg/cyrus_imapd/trunk/files/CSWcyrusimapd.depend
===================================================================
--- csw/mgar/pkg/cyrus_imapd/trunk/files/CSWcyrusimapd.depend	2009-10-11 13:31:43 UTC (rev 6828)
+++ csw/mgar/pkg/cyrus_imapd/trunk/files/CSWcyrusimapd.depend	2009-10-11 13:55:25 UTC (rev 6829)
@@ -1,7 +0,0 @@
-P       CSWosslrt       - openssl - OpenSSL Secure Sockets Layer lib and utilities
-P       CSWsasl         - sasl - Simple Authentication and Security Layer
-P       CSWbdb4         - berkeleydb4 - embedded database libraries and utilities
-P	CSWkrb5lib
-P	CSWtcpwrap
-P	CSWnetsnmp
-P	CSWpcrert

Deleted: csw/mgar/pkg/cyrus_imapd/trunk/files/CSWcyrusimapd.gspec
===================================================================
--- csw/mgar/pkg/cyrus_imapd/trunk/files/CSWcyrusimapd.gspec	2009-10-11 13:31:43 UTC (rev 6828)
+++ csw/mgar/pkg/cyrus_imapd/trunk/files/CSWcyrusimapd.gspec	2009-10-11 13:55:25 UTC (rev 6829)
@@ -1,13 +0,0 @@
-%var            bitname cyrus_imapd
-%var            pkgname CSWcyrusimapd
-%include        url file://%{PKGLIB}/csw_dyndepend.gspec
-%copyright      url file://%{WORKSRC}/COPYRIGHT
-%var            RC_INIT_SCRIPT cswcyrus.init
-%var            SMF_SCRIPT svc-cswcyrus
-%var            SMF_MANIFEST cswcyrus.xml
-%var            INIT_KILL_PRIO 99
-%var            INIT_START_PRIO 10
-%var            CAN_BE_AUTOENABLED yes
-%var            SERVICE_CONF_FILES /opt/csw/etc/cyrus/cyrus.conf
-%var            SERVICE_NAME cyrus_imapd
-%include        url file://%{PKGLIB}/smf_enabled.gspec

Modified: csw/mgar/pkg/cyrus_imapd/trunk/files/CSWcyrusimapd.prototype
===================================================================
--- csw/mgar/pkg/cyrus_imapd/trunk/files/CSWcyrusimapd.prototype	2009-10-11 13:31:43 UTC (rev 6828)
+++ csw/mgar/pkg/cyrus_imapd/trunk/files/CSWcyrusimapd.prototype	2009-10-11 13:55:25 UTC (rev 6829)
@@ -1,11 +1,11 @@
-i i.conf=i.conf
-i r.conf=r.conf
-i i.services=i.services
-i r.services=r.services
-e services /etc/inet/services=services
+i i.services
+i r.services
+e services /etc/inet/services 0444 root sys
 d none /opt/csw/etc/cyrus 0755 root bin
-e conf /opt/csw/etc/cyrus/imapd.conf=imapd.conf 0640 root mail
-f none /opt/csw/etc/cyrus/cyrus.conf.CSW=cyrus.conf 0640 root mail
+d none /opt/csw/etc/pkg/CSWcyrusimapd 0755 root bin
+f cswinitsmf /etc/opt/csw/init.d/cswcyrus 0755 root bin
+f preserveconf /opt/csw/etc/cyrus/imapd.conf.CSW 0640 root mail
+f preserveconf /opt/csw/etc/cyrus/cyrus.conf.CSW 0640 root mail
 d none /opt/csw/var/cyrus 0755 cyrus mail
 d none /opt/csw/var/cyrus/sieve 0755 cyrus mail
 d none /opt/csw/var/cyrus/config 0755 cyrus mail
@@ -17,45 +17,6 @@
 d none /opt/csw/var/cyrus/config/ptclient 0755 cyrus mail
 d none /opt/csw/var/cyrus/mail 0755 cyrus mail
 d none /opt/csw/var/cyrus/mail/stage. 0755 cyrus mail
-d none /opt/csw/include/cyrus 0755 root bin
-f none /opt/csw/include/cyrus/acl.h 0644 root bin
-f none /opt/csw/include/cyrus/assert.h 0644 root bin
-f none /opt/csw/include/cyrus/auth.h 0644 root bin
-f none /opt/csw/include/cyrus/bsearch.h 0644 root bin
-f none /opt/csw/include/cyrus/byteorder64.h 0644 root bin
-f none /opt/csw/include/cyrus/charset.h 0644 root bin
-f none /opt/csw/include/cyrus/cyrusdb.h 0644 root bin
-f none /opt/csw/include/cyrus/glob.h 0644 root bin
-f none /opt/csw/include/cyrus/gmtoff.h 0644 root bin
-f none /opt/csw/include/cyrus/hash.h 0644 root bin
-f none /opt/csw/include/cyrus/hmac-md5.h 0644 root bin
-f none /opt/csw/include/cyrus/imapopts.h 0644 root bin
-f none /opt/csw/include/cyrus/imapurl.h 0644 root bin
-f none /opt/csw/include/cyrus/imclient.h 0644 root bin
-f none /opt/csw/include/cyrus/imparse.h 0644 root bin
-f none /opt/csw/include/cyrus/iptostring.h 0644 root bin
-f none /opt/csw/include/cyrus/libconfig.h 0644 root bin
-f none /opt/csw/include/cyrus/libcyr_cfg.h 0644 root bin
-f none /opt/csw/include/cyrus/lock.h 0644 root bin
-f none /opt/csw/include/cyrus/lsort.h 0644 root bin
-f none /opt/csw/include/cyrus/map.h 0644 root bin
-f none /opt/csw/include/cyrus/md5.h 0644 root bin
-f none /opt/csw/include/cyrus/mkgmtime.h 0644 root bin
-f none /opt/csw/include/cyrus/mpool.h 0644 root bin
-f none /opt/csw/include/cyrus/nonblock.h 0644 root bin
-f none /opt/csw/include/cyrus/parseaddr.h 0644 root bin
-f none /opt/csw/include/cyrus/prot.h 0644 root bin
-f none /opt/csw/include/cyrus/retry.h 0644 root bin
-f none /opt/csw/include/cyrus/rfc822date.h 0644 root bin
-f none /opt/csw/include/cyrus/strhash.h 0644 root bin
-f none /opt/csw/include/cyrus/stristr.h 0644 root bin
-f none /opt/csw/include/cyrus/sysexits.h 0644 root bin
-f none /opt/csw/include/cyrus/util.h 0644 root bin
-f none /opt/csw/include/cyrus/xmalloc.h 0644 root bin
-f none /opt/csw/include/cyrus/xstrlcat.h 0644 root bin
-f none /opt/csw/include/cyrus/xstrlcpy.h 0644 root bin
-f none /opt/csw/lib/libcyrus.a 0644 root bin
-f none /opt/csw/lib/libcyrus_min.a 0644 root bin
 f none /opt/csw/share/man/man3/imclient.3 0644 root bin
 f none /opt/csw/share/man/man5/imapd.conf.5 0644 root bin
 f none /opt/csw/share/man/man5/krb.equiv.5 0644 root bin
@@ -301,5 +262,5 @@
 f none /opt/csw/share/doc/cyrus_imapd/text/sieve-protocol 0644 root bin
 f none /opt/csw/share/doc/cyrus_imapd/text/sieve 0644 root bin
 f none /opt/csw/share/doc/cyrus_imapd/text/specs 0644 root bin
-f none /opt/csw/share/doc/cyrus_imapd/README.CSW=README.CSW 0644 root bin
+f none /opt/csw/share/doc/cyrus_imapd/README.CSW 0644 root bin
 f none /opt/csw/share/doc/cyrus_imapd/changelog.CSW 0644 root bin

Deleted: csw/mgar/pkg/cyrus_imapd/trunk/files/CSWcyrusimapdutils.depend
===================================================================
--- csw/mgar/pkg/cyrus_imapd/trunk/files/CSWcyrusimapdutils.depend	2009-10-11 13:31:43 UTC (rev 6828)
+++ csw/mgar/pkg/cyrus_imapd/trunk/files/CSWcyrusimapdutils.depend	2009-10-11 13:55:25 UTC (rev 6829)
@@ -1,6 +0,0 @@
-P       CSWpmcyrus
-P       CSWosslrt         - openssl - OpenSSL Secure Sockets Layer lib and utilities
-P       CSWsasl         - sasl - Simple Authentication and Security Layer
-P       CSWbdb4         - berkeleydb4 - embedded database libraries and utilities
-P	CSWkrb5lib
-P	CSWpcrert

Deleted: csw/mgar/pkg/cyrus_imapd/trunk/files/CSWcyrusimapdutils.gspec
===================================================================
--- csw/mgar/pkg/cyrus_imapd/trunk/files/CSWcyrusimapdutils.gspec	2009-10-11 13:31:43 UTC (rev 6828)
+++ csw/mgar/pkg/cyrus_imapd/trunk/files/CSWcyrusimapdutils.gspec	2009-10-11 13:55:25 UTC (rev 6829)
@@ -1,6 +0,0 @@
-%var            bitname cyrus_imapd_utils
-%var            pkgname CSWcyrusimapdutils
-%var            desc Various admin utilities for Cyrus Imapd/Popd
-%include        url file://%{PKGLIB}/csw_dyndepend.gspec
-%copyright      url file://%{WORKSRC}/COPYRIGHT
-

Deleted: csw/mgar/pkg/cyrus_imapd/trunk/files/CSWpmcyrus.depend
===================================================================
--- csw/mgar/pkg/cyrus_imapd/trunk/files/CSWpmcyrus.depend	2009-10-11 13:31:43 UTC (rev 6828)
+++ csw/mgar/pkg/cyrus_imapd/trunk/files/CSWpmcyrus.depend	2009-10-11 13:55:25 UTC (rev 6829)
@@ -1,4 +0,0 @@
-P       CSWperl
-P       CSWbdb4
-P       CSWosslrt
-P       CSWsasl

Deleted: csw/mgar/pkg/cyrus_imapd/trunk/files/CSWpmcyrus.gspec
===================================================================
--- csw/mgar/pkg/cyrus_imapd/trunk/files/CSWpmcyrus.gspec	2009-10-11 13:31:43 UTC (rev 6828)
+++ csw/mgar/pkg/cyrus_imapd/trunk/files/CSWpmcyrus.gspec	2009-10-11 13:55:25 UTC (rev 6829)
@@ -1,6 +0,0 @@
-%var            bitname pm_cyrus
-%var            pkgname CSWpmcyrus
-%var            desc Perl interface to Cyrus Imap functions
-%include        url file://%{PKGLIB}/csw_dyndepend.gspec
-%copyright      url file://%{WORKSRC}/COPYRIGHT
-

Copied: csw/mgar/pkg/cyrus_imapd/trunk/files/cswcyrus (from rev 6825, csw/mgar/pkg/cyrus_imapd/trunk/files/cswcyrus.init)
===================================================================
--- csw/mgar/pkg/cyrus_imapd/trunk/files/cswcyrus	                        (rev 0)
+++ csw/mgar/pkg/cyrus_imapd/trunk/files/cswcyrus	2009-10-11 13:55:25 UTC (rev 6829)
@@ -0,0 +1,78 @@
+#!/sbin/sh
+#
+# Cyrus startup script for opencsw
+#
+# Yann Rouillard <yann at blastwave.org>
+
+# cswclassutils smf variable
+#RC_KNUM 99  
+#RC_SNUM 10   
+#RC_KLEV 0,1,2,S   
+#RC_SLEV 3         
+#MANIFEST /var/opt/csw/svc/manifest/network/cswcyrus.xml
+
+
+PID_FILE="/var/run/cyrus-master.pid"
+COMMAND=/opt/csw/sbin/cyrus-master
+
+[ -f /opt/csw/etc/cyrus/cyrus.conf ] || exit 0
+
+check_proc ()
+{
+    if [ -f $1 ]; then
+        _PID=`cat $1 | head -1`
+        _COMMAND=`ps -p $_PID -o comm | tail -1`
+        [ "x$_COMMAND" = "x$2" ]
+    else
+        return 1
+    fi
+}
+
+
+case "$1" in
+    'start')
+	# Start Daemons.
+	if check_proc $PID_FILE $COMMAND; then
+	    echo "Cyrus seems to be already running. If it's not the case, you might want to delete the file $PID_FILE";
+	else
+	    /usr/ucb/echo -n "Starting Cyrus..."
+	    $COMMAND -d -p $PID_FILE
+	    if [ "$?" -eq 0 ]; then
+		echo "Ok" 
+	    else
+		echo "Failed"
+	    fi
+	fi
+	;;
+    
+    'stop')
+	#stop daemons.
+        if check_proc $PID_FILE $COMMAND; then
+	    /usr/ucb/echo -n "Stopping Cyrus..."
+	    kill `cat $PID_FILE`
+	    rm $PID_FILE
+	    echo "Ok"
+	else
+	    echo "Cyrus is not running";
+	fi
+	;;
+    
+   'restart')
+	$0 stop
+	$0 start
+	;;
+
+    'status')
+	if [ -r $PID_FILE ];then
+	    echo "Cyrus is running."
+	else
+	    echo "Cyrus is not running";
+	fi
+	;;	
+    
+    *)
+	echo "usage: cyrus {start|stop|restart|status}"
+	exit 1
+esac
+
+exit 0

Deleted: csw/mgar/pkg/cyrus_imapd/trunk/files/cswcyrus.init
===================================================================
--- csw/mgar/pkg/cyrus_imapd/trunk/files/cswcyrus.init	2009-10-11 13:31:43 UTC (rev 6828)
+++ csw/mgar/pkg/cyrus_imapd/trunk/files/cswcyrus.init	2009-10-11 13:55:25 UTC (rev 6829)
@@ -1,74 +0,0 @@
-#!/sbin/sh
-#
-# Cyrus startup script for blastwave
-#
-# Yann Rouillard <yann at blastwave.org>
-
-# chkconfig stuff
-# chkconfig: 3 90 10
-# description: Pop and Imap server from the Cyrus mail system
-
-PID_FILE="/var/run/cyrus-master.pid"
-COMMAND=/opt/csw/sbin/cyrus-master
-
-[ -f /opt/csw/etc/cyrus/cyrus.conf ] || exit 0
-
-check_proc ()
-{
-    if [ -f $1 ]; then
-        _PID=`cat $1 | head -1`
-        _COMMAND=`ps -p $_PID -o comm | tail -1`
-        [ "x$_COMMAND" = "x$2" ]
-    else
-        return 1
-    fi
-}
-
-
-case "$1" in
-    'start')
-	# Start Daemons.
-	if check_proc $PID_FILE $COMMAND; then
-	    echo "Cyrus seems to be already running. If it's not the case, you might want to delete the file $PID_FILE";
-	else
-	    /usr/ucb/echo -n "Starting Cyrus..."
-	    $COMMAND -d -p $PID_FILE
-	    if [ "$?" -eq 0 ]; then
-		echo "Ok" 
-	    else
-		echo "Failed"
-	    fi
-	fi
-	;;
-    
-    'stop')
-	#stop daemons.
-        if check_proc $PID_FILE $COMMAND; then
-	    /usr/ucb/echo -n "Stopping Cyrus..."
-	    kill `cat $PID_FILE`
-	    rm $PID_FILE
-	    echo "Ok"
-	else
-	    echo "Cyrus is not running";
-	fi
-	;;
-    
-   'restart')
-	$0 stop
-	$0 start
-	;;
-
-    'status')
-	if [ -r $PID_FILE ];then
-	    echo "Cyrus is running."
-	else
-	    echo "Cyrus is not running";
-	fi
-	;;	
-    
-    *)
-	echo "usage: cyrus {start|stop|restart|status}"
-	exit 1
-esac
-
-exit 0

Added: csw/mgar/pkg/cyrus_imapd/trunk/files/cyrus-imapd-2.3.15-autocreate-0.10-0.diff
===================================================================
--- csw/mgar/pkg/cyrus_imapd/trunk/files/cyrus-imapd-2.3.15-autocreate-0.10-0.diff	                        (rev 0)
+++ csw/mgar/pkg/cyrus_imapd/trunk/files/cyrus-imapd-2.3.15-autocreate-0.10-0.diff	2009-10-11 13:55:25 UTC (rev 6829)
@@ -0,0 +1,2399 @@
+diff -Naur cyrus-imapd-2.3.15.orig/imap/autosieve.c cyrus-imapd-2.3.15/imap/autosieve.c
+--- cyrus-imapd-2.3.15.orig/imap/autosieve.c	1970-01-01 01:00:00.000000000 +0100
++++ cyrus-imapd-2.3.15/imap/autosieve.c	2009-09-09 16:13:03.000000000 +0200
+@@ -0,0 +1,590 @@
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++
++#ifdef HAVE_UNISTD_H
++#include <unistd.h>
++#endif
++
++#include <errno.h>
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <sys/uio.h>
++#include <fcntl.h>
++#include <ctype.h>
++#include <time.h>
++#include <syslog.h>
++#include <com_err.h>
++#include <config.h>
++
++#include "global.h"
++#include "util.h"
++#include "xmalloc.h"
++#include "xstrlcpy.h"
++#include "xstrlcat.h"
++#include "mailbox.h"
++#include "imap_err.h"
++#include "sieve_interface.h"
++#include "script.h"
++
++#define TIMSIEVE_FAIL 	-1
++#define TIMSIEVE_OK 	0
++#define MAX_FILENAME	1024
++
++static int get_script_name(char *sievename, size_t buflen, const char *filename);
++static int get_script_dir(char *sieve_script_dir, size_t buflen, char *userid, const char *sieve_dir);
++int autoadd_sieve(char *userid, const char *source_script);
++
++//static void fatal(const char *s, int code);
++static void foo(void);
++static int sieve_notify(void *ac __attribute__((unused)),
++                        void *interp_context __attribute__((unused)),
++                        void *script_context __attribute__((unused)),
++                        void *message_context __attribute__((unused)),
++                        const char **errmsg __attribute__((unused)));
++static int mysieve_error(int lineno, const char *msg,
++                  void *i __attribute__((unused)), void *s);
++static int is_script_parsable(FILE *stream, char **errstr, sieve_script_t **ret);
++
++
++sieve_vacation_t vacation2 = {
++    0,                          /* min response */
++    0,                          /* max response */
++    (sieve_callback *) &foo,    /* autorespond() */
++    (sieve_callback *) &foo     /* send_response() */
++};
++
++
++/*
++ * Find the name of the sieve script
++ * given the source script and compiled script names
++ */
++static int get_script_name(char *sievename, size_t buflen, const char *filename)
++{
++  char *p;
++  int r;
++
++  p = strrchr(filename, '/');
++  if (p == NULL)
++      p = (char *) filename;
++  else
++      p++;
++
++  r = strlcpy(sievename, p, buflen) - buflen;
++  return (r >= 0 || r == -buflen ? 1 : 0);
++}
++
++
++/*
++ * Find the directory where the sieve scripts of the user
++ * reside
++ */
++static int get_script_dir(char *sieve_script_dir, size_t buflen, char *userid, const char *sieve_dir)
++{
++    char *user = NULL, *domain = NULL;
++
++    /* Setup the user and the domain */
++    if(config_virtdomains && (domain = strchr(userid, '@'))) {
++        user = (char *) xmalloc((domain - userid +1) * sizeof(char));
++        strlcpy(user, userid, domain - userid + 1);
++        domain++;
++    } else
++        user = userid;
++
++    /*  Find the dir path where the sieve scripts of the user will reside */   
++    if (config_virtdomains && domain) {
++         if(snprintf(sieve_script_dir, buflen, "%s%s%c/%s/%c/%s/",
++              sieve_dir, FNAME_DOMAINDIR, dir_hash_c(domain, config_fulldirhash), domain, dir_hash_c(user,config_fulldirhash), user) >= buflen) {
++                 free(user);
++                 return 1;
++ 	 }
++    } else {
++         if(snprintf(sieve_script_dir, buflen, "%s/%c/%s/", 
++     	      sieve_dir, dir_hash_c(user,config_fulldirhash), user) >= buflen) 
++                 return 1;
++    }
++
++    /* Free the xmalloced user memory, reserved above */
++    if(user != userid)
++        free(user);
++
++    return 0;
++}
++
++int autoadd_sieve(char *userid, const char *source_script)
++{   
++    sieve_script_t *s = NULL;
++    bytecode_info_t *bc = NULL;
++    char *err = NULL;
++    FILE *in_stream, *out_fp;
++    int out_fd, in_fd, r, k;
++    int do_compile = 0;
++    const char *sieve_dir = NULL;
++    const char *compiled_source_script = NULL;
++    char sievename[MAX_FILENAME];
++    char sieve_script_name[MAX_FILENAME];
++    char sieve_script_dir[MAX_FILENAME];
++    char sieve_bcscript_name[MAX_FILENAME];
++    char sieve_default[MAX_FILENAME];
++    char sieve_tmpname[MAX_FILENAME];
++    char sieve_bctmpname[MAX_FILENAME];
++    char sieve_bclink_name[MAX_FILENAME];
++    char buf[4096];
++    mode_t oldmask;
++    struct stat statbuf;
++
++    /* We don't support using the homedirectory, like timsieved */
++    if (config_getswitch(IMAPOPT_SIEVEUSEHOMEDIR)) {
++        syslog(LOG_WARNING,"autocreate_sieve: autocreate_sieve does not work with sieveusehomedir option in imapd.conf");
++        return 1;
++    }
++
++    /* Check if sievedir is defined in imapd.conf */
++    if(!(sieve_dir = config_getstring(IMAPOPT_SIEVEDIR))) { 
++        syslog(LOG_WARNING, "autocreate_sieve: sievedir option is not defined. Check imapd.conf");
++        return 1;
++    }
++
++    /* Check if autocreate_sieve_compiledscript is defined in imapd.conf */
++    if(!(compiled_source_script  = config_getstring(IMAPOPT_AUTOCREATE_SIEVE_COMPILEDSCRIPT))) {
++        syslog(LOG_WARNING, "autocreate_sieve: autocreate_sieve_compiledscript option is not defined. Compiling it");
++        do_compile = 1;
++    }
++
++    if(get_script_dir(sieve_script_dir, sizeof(sieve_script_dir), userid, sieve_dir)) {
++        syslog(LOG_WARNING, "autocreate_sieve: Cannot find sieve scripts directory");
++        return 1;
++    }
++
++    if (get_script_name(sievename, sizeof(sievename), source_script)) {
++        syslog(LOG_WARNING, "autocreate_sieve: Invalid sieve script %s", source_script);
++        return 1;
++    }
++
++    if(snprintf(sieve_tmpname, sizeof(sieve_tmpname), "%s%s.script.NEW",sieve_script_dir, sievename) >= sizeof(sieve_tmpname)) {
++        syslog(LOG_WARNING, "autocreate_sieve: Invalid sieve path %s, %s, %s", sieve_dir, sievename, userid);
++        return 1;
++    }
++    if(snprintf(sieve_bctmpname, sizeof(sieve_bctmpname), "%s%s.bc.NEW",sieve_script_dir, sievename) >= sizeof(sieve_bctmpname)) {
++        syslog(LOG_WARNING, "autocreate_sieve: Invalid sieve path %s, %s, %s", sieve_dir, sievename, userid);
++        return 1;
++    }    
++    if(snprintf(sieve_script_name, sizeof(sieve_script_name), "%s%s.script",sieve_script_dir, sievename) >= sizeof(sieve_script_name)) {
++        syslog(LOG_WARNING, "autocreate_sieve: Invalid sieve path %s, %s, %s", sieve_dir, sievename, userid);
++        return 1;
++    }
++    if(snprintf(sieve_bcscript_name, sizeof(sieve_bcscript_name), "%s%s.bc",sieve_script_dir, sievename) >= sizeof(sieve_bcscript_name)) {
++        syslog(LOG_WARNING, "autocreate_sieve: Invalid sieve path %s, %s, %s", sieve_dir, sievename, userid);
++        return 1;
++    }
++    if(snprintf(sieve_default, sizeof(sieve_default), "%s%s",sieve_script_dir,"defaultbc") >= sizeof(sieve_default)) {
++        syslog(LOG_WARNING, "autocreate_sieve: Invalid sieve path %s, %s, %s", sieve_dir, sievename, userid);
++        return 1;
++    }
++    if(snprintf(sieve_bclink_name, sizeof(sieve_bclink_name), "%s.bc", sievename) >= sizeof(sieve_bclink_name))  {
++        syslog(LOG_WARNING, "autocreate_sieve: Invalid sieve path %s, %s, %s", sieve_dir, sievename, userid);
++        return 1;
++    }
++
++    /* Check if a default sieve filter alrady exists */
++    if(!stat(sieve_default,&statbuf)) {
++        syslog(LOG_WARNING,"autocreate_sieve: Default sieve script already exists");
++        fclose(in_stream);
++        return 1;
++    }
++
++    /* Open the source script. if there is a problem with that exit */
++    in_stream = fopen(source_script, "r");
++    if(!in_stream) {
++        syslog(LOG_WARNING,"autocreate_sieve: Unable to open sieve script %s. Check permissions",source_script);
++        return 1;
++    }
++    
++    
++    /* 
++     * At this point we start the modifications of the filesystem 
++     */
++
++    /* Create the directory where the sieve scripts will reside */
++    r = cyrus_mkdir(sieve_script_dir, 0755);
++    if(r == -1) {
++        /* If this fails we just leave */
++        syslog(LOG_WARNING,"autocreate_sieve: Unable to create directory %s. Check permissions",sieve_script_name);
++        return 1;
++    }
++
++    /*
++     * We open the file that will be used as the bc file. If this file exists, overwrite it 
++     * since something bad has happened. We open the file here so that this error checking is
++     * done before we try to open the rest of the files to start copying etc. 
++     */
++    out_fd = open(sieve_bctmpname, O_CREAT|O_TRUNC|O_WRONLY, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
++    if(out_fd < 0) {
++        if(errno == EEXIST) {
++            syslog(LOG_WARNING,"autocreate_sieve: File %s already exists. Probaly left over. Ignoring",sieve_bctmpname);
++        } else if (errno == EACCES) {
++            syslog(LOG_WARNING,"autocreate_sieve: No access to create file %s. Check permissions",sieve_bctmpname);
++            fclose(in_stream);
++            return 1;
++        } else {
++            syslog(LOG_WARNING,"autocreate_sieve: Unable to create %s. Unknown error",sieve_bctmpname);
++            fclose(in_stream);
++            return 1;
++        }
++    }
++
++    if(!do_compile && compiled_source_script && (in_fd = open(compiled_source_script, O_RDONLY)) != -1) {
++        while((r = read(in_fd, buf, sizeof(buf))) > 0) {
++            if((k=write(out_fd, buf,r)) < 0) {
++                syslog(LOG_WARNING, "autocreate_sieve: Error writing to file: %s, error: %d", sieve_bctmpname, errno);
++                close(out_fd);
++                close(in_fd);
++                fclose(in_stream);
++                unlink(sieve_bctmpname);
++                return 1;
++           }
++        } 
++
++        if(r == 0) { /* EOF */
++            close(out_fd);
++            close(in_fd);
++        } else if (r < 0) {
++            syslog(LOG_WARNING, "autocreate_sieve: Error reading compiled script file: %s. Will try to compile it", 
++                           compiled_source_script);
++            close(in_fd);
++            do_compile = 1;
++            if(lseek(out_fd, 0, SEEK_SET)) {
++                syslog(LOG_WARNING, "autocreate_sieve: Major IO problem. Aborting");
++                return 1;
++            }
++        }
++        close(in_fd);
++    } else {
++        if(compiled_source_script)
++              syslog(LOG_WARNING,"autocreate_sieve: Problem opening compiled script file: %s. Compiling it", compiled_source_script);
++        do_compile = 1;
++    }
++
++
++    /* Because we failed to open a precompiled bc sieve script, we compile one */
++    if(do_compile) {
++       if(is_script_parsable(in_stream,&err, &s) == TIMSIEVE_FAIL) {
++            if(err && *err) {
++               syslog(LOG_WARNING,"autocreate_sieve: Error while parsing script %s.",err);
++               free(err);
++            } else
++                syslog(LOG_WARNING,"autocreate_sieve: Error while parsing script");
++    
++            unlink(sieve_bctmpname);
++            fclose(in_stream);
++            close(out_fd);
++            return 1;
++        }
++
++        /* generate the bytecode */
++        if(sieve_generate_bytecode(&bc, s) == TIMSIEVE_FAIL) {
++            syslog(LOG_WARNING,"autocreate_sieve: problem compiling sieve script");
++            /* removing the copied script and cleaning up memory */
++            unlink(sieve_bctmpname);
++            sieve_script_free(&s);
++            fclose(in_stream);
++            close(out_fd);
++            return 1;
++        }
++
++        if(sieve_emit_bytecode(out_fd, bc) == TIMSIEVE_FAIL) {
++            syslog(LOG_WARNING,"autocreate_sieve: problem emiting sieve script");
++            /* removing the copied script and cleaning up memory */
++            unlink(sieve_bctmpname);
++            sieve_free_bytecode(&bc);
++            sieve_script_free(&s);
++            fclose(in_stream);
++            close(out_fd);
++            return 1;
++        }
++
++        /* clean up the memory */
++        sieve_free_bytecode(&bc);
++        sieve_script_free(&s);
++    }
++
++    close(out_fd);
++    rewind(in_stream);
++
++    /* Copy the initial script */
++    oldmask = umask(077);
++    if((out_fp = fopen(sieve_tmpname, "w")) == NULL) {
++        syslog(LOG_WARNING,"autocreate_sieve: Unable to open %s destination sieve script", sieve_tmpname);
++        unlink(sieve_bctmpname);
++        umask(oldmask);
++        fclose(in_stream);
++        return 1;
++    }
++    umask(oldmask);
++
++    while((r = fread(buf,sizeof(char), sizeof(buf), in_stream))) {
++        if( fwrite(buf,sizeof(char), r, out_fp) != r) {
++            syslog(LOG_WARNING,"autocreate_sieve: Problem writing to sieve script file: %s",sieve_tmpname);
++            fclose(out_fp);
++            unlink(sieve_tmpname);
++            unlink(sieve_bctmpname);
++            fclose(in_stream);
++            return 1;
++        }
++    }
++    
++    if(feof(in_stream)) {
++        fclose(out_fp);
++    } else { /* ferror */
++        fclose(out_fp);
++        unlink(sieve_tmpname);
++        unlink(sieve_bctmpname);
++        fclose(in_stream);
++        return 1;
++    }
++
++    /* Renaming the necessary stuff */
++    if(rename(sieve_tmpname, sieve_script_name)) {
++        unlink(sieve_tmpname);
++        unlink(sieve_bctmpname);
++        return 1;
++    }
++
++    if(rename(sieve_bctmpname, sieve_bcscript_name)) {
++        unlink(sieve_bctmpname);
++        unlink(sieve_bcscript_name);
++        return 1;
++    }
++
++    /* end now with the symlink */
++    if(symlink(sieve_bclink_name, sieve_default)) {
++        if(errno != EEXIST) {
++            syslog(LOG_WARNING, "autocreate_sieve: problem making the default link.");
++            /* Lets delete the files */
++            unlink(sieve_script_name);
++            unlink(sieve_bcscript_name);
++        }
++    }
++
++    /* 
++     * If everything has succeeded AND we have compiled the script AND we have requested
++     * to generate the global script so that it is not compiled each time then we create it.
++     */
++    if(do_compile && 
++          config_getswitch(IMAPOPT_GENERATE_COMPILED_SIEVE_SCRIPT)) {
++
++        if(!compiled_source_script) {
++            syslog(LOG_WARNING, "autocreate_sieve: To save a compiled sieve script, autocreate_sieve_compiledscript must have been defined in imapd.conf");
++            return 0;
++        }
++
++        if(snprintf(sieve_tmpname, sizeof(sieve_tmpname), "%s.NEW", compiled_source_script) >= sizeof(sieve_tmpname))
++            return 0;
++
++        /*
++         * Copy everything from the newly created bc sieve sieve script.
++         */
++        if((in_fd = open(sieve_bcscript_name, O_RDONLY))<0) {
++            return 0;
++        }
++
++        if((out_fd = open(sieve_tmpname, O_CREAT|O_EXCL|O_WRONLY, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) < 0) {
++            if(errno == EEXIST) {
++               /* Someone is already doing this so just bail out. */
++               syslog(LOG_WARNING, "autocreate_sieve: %s already exists. Some other instance processing it, or it is left over", sieve_tmpname);
++                close(in_fd);
++                return 0; 
++            } else if (errno == EACCES) {
++                syslog(LOG_WARNING,"autocreate_sieve: No access to create file %s. Check permissions",sieve_tmpname);
++                close(in_fd);
++                return 0;
++            } else {
++                syslog(LOG_WARNING,"autocreate_sieve: Unable to create %s",sieve_tmpname);
++                close(in_fd);
++                return 0;
++            }
++        }
++
++        while((r = read(in_fd, buf, sizeof(buf))) > 0) {
++            if((k = write(out_fd,buf,r)) < 0) {
++                syslog(LOG_WARNING, "autocreate_sieve: Error writing to file: %s, error: %d", sieve_tmpname, errno);
++                close(out_fd);
++                close(in_fd);
++                unlink(sieve_tmpname);
++                return 0;
++           }
++        }
++
++        if(r == 0 ) { /*EOF */
++            close(out_fd);
++            close(in_fd);
++        } else if (r < 0) {
++                syslog(LOG_WARNING, "autocreate_sieve: Error writing to file: %s, error: %d", sieve_tmpname, errno);
++                close(out_fd);
++                close(in_fd);
++                unlink(sieve_tmpname);
++                return 0;
++        }
++
++        /* Rename the temporary created sieve script to its final name. */
++        if(rename(sieve_tmpname, compiled_source_script)) {
++            if(errno != EEXIST) {
++               unlink(sieve_tmpname);
++               unlink(compiled_source_script);
++        }
++            return 0;
++        }
++
++        syslog(LOG_NOTICE, "autocreate_sieve: Compiled sieve script was successfully saved in %s", compiled_source_script);
++    }
++
++    return 0;
++}
++
++/*static void fatal(const char *s, int code)
++{   
++    printf("Fatal error: %s (%d)\r\n", s, code);
++    exit(1);
++}*/
++
++/* to make larry's stupid functions happy :) */
++static void foo(void)
++{
++    fatal("stub function called", 0);
++}
++
++static int sieve_notify(void *ac __attribute__((unused)),
++                        void *interp_context __attribute__((unused)),
++                        void *script_context __attribute__((unused)),
++                        void *message_context __attribute__((unused)),
++                        const char **errmsg __attribute__((unused)))
++{
++    fatal("stub function called", 0);
++    return SIEVE_FAIL;
++}
++
++static int mysieve_error(int lineno, const char *msg,
++                  void *i __attribute__((unused)), void *s)
++{
++    char buf[1024];
++    char **errstr = (char **) s;
++
++    snprintf(buf, 80, "line %d: %s\r\n", lineno, msg);
++    *errstr = (char *) xrealloc(*errstr, strlen(*errstr) + strlen(buf) + 30);
++    syslog(LOG_DEBUG, "%s", buf);
++    strcat(*errstr, buf);
++
++    return SIEVE_OK;
++}
++
++/* end the boilerplate */
++
++/* returns TRUE or FALSE */
++int is_script_parsable(FILE *stream, char **errstr, sieve_script_t **ret)
++{
++    sieve_interp_t *i;
++    sieve_script_t *s;
++    int res;
++
++    res = sieve_interp_alloc(&i, NULL);
++    if (res != SIEVE_OK) {
++        syslog(LOG_WARNING, "sieve_interp_alloc() returns %d\n", res);
++        return TIMSIEVE_FAIL;
++    }
++
++    res = sieve_register_redirect(i, (sieve_callback *) &foo);
++    if (res != SIEVE_OK) {
++        syslog(LOG_WARNING, "sieve_register_redirect() returns %d\n", res);
++        return TIMSIEVE_FAIL;
++    }
++    res = sieve_register_discard(i, (sieve_callback *) &foo);
++    if (res != SIEVE_OK) {
++        syslog(LOG_WARNING, "sieve_register_discard() returns %d\n", res);
++        return TIMSIEVE_FAIL;
++    }
++    res = sieve_register_reject(i, (sieve_callback *) &foo);
++    if (res != SIEVE_OK) {
++        syslog(LOG_WARNING, "sieve_register_reject() returns %d\n", res);
++        return TIMSIEVE_FAIL;
++    }
++    res = sieve_register_fileinto(i, (sieve_callback *) &foo);
++    if (res != SIEVE_OK) {
++        syslog(LOG_WARNING, "sieve_register_fileinto() returns %d\n", res);
++        return TIMSIEVE_FAIL;
++    }
++    res = sieve_register_keep(i, (sieve_callback *) &foo);
++    if (res != SIEVE_OK) {
++        syslog(LOG_WARNING, "sieve_register_keep() returns %d\n", res);
++        return TIMSIEVE_FAIL;
++    }
++
++    res = sieve_register_imapflags(i, NULL);
++    if (res != SIEVE_OK) {
++        syslog(LOG_WARNING, "sieve_register_imapflags() returns %d\n", res);
++        return TIMSIEVE_FAIL;
++    }
++
++    res = sieve_register_size(i, (sieve_get_size *) &foo);
++    if (res != SIEVE_OK) {
++        syslog(LOG_WARNING, "sieve_register_size() returns %d\n", res);
++        return TIMSIEVE_FAIL;
++    }
++
++    res = sieve_register_header(i, (sieve_get_header *) &foo);
++    if (res != SIEVE_OK) {
++        syslog(LOG_WARNING, "sieve_register_header() returns %d\n", res);
++        return TIMSIEVE_FAIL;
++    }
++
++    res = sieve_register_envelope(i, (sieve_get_envelope *) &foo);
++    if (res != SIEVE_OK) {
++        syslog(LOG_WARNING, "sieve_register_envelope() returns %d\n", res);
++        return TIMSIEVE_FAIL;
++    }
++
++    res = sieve_register_vacation(i, &vacation2);
++    if (res != SIEVE_OK) {
++        syslog(LOG_WARNING, "sieve_register_vacation() returns %d\n", res);
++        return TIMSIEVE_FAIL;
++    }
++
++    res = sieve_register_notify(i, &sieve_notify);
++    if (res != SIEVE_OK) {
++        syslog(LOG_WARNING, "sieve_register_notify() returns %d\n", res);
++        return TIMSIEVE_FAIL;
++    }
++
++    res = sieve_register_parse_error(i, &mysieve_error);
++    if (res != SIEVE_OK) {
++        syslog(LOG_WARNING, "sieve_register_parse_error() returns %d\n", res);
++        return TIMSIEVE_FAIL;
++    }
++
++    rewind(stream);
++
++    *errstr = (char *) xmalloc(20 * sizeof(char));
++    strcpy(*errstr, "script errors:\r\n");
++
++    res = sieve_script_parse(i, stream, errstr, &s);
++
++    if (res == SIEVE_OK) {
++        if(ret) {
++            *ret = s;
++        } else {
++            sieve_script_free(&s);
++        }
++        free(*errstr);
++        *errstr = NULL;
++    }
++
++    /* free interpreter */
++    sieve_interp_free(&i);
++
++    return (res == SIEVE_OK) ? TIMSIEVE_OK : TIMSIEVE_FAIL;
++}
++
++/*
++ * Btw the initial date of this patch is Sep, 02 2004 which is the birthday of
++ * Pavlos. Author of cyrusmaster. So consider this patch as his birthday present
++ */
++
+diff -Naur cyrus-imapd-2.3.15.orig/imap/compile_sieve.c cyrus-imapd-2.3.15/imap/compile_sieve.c
+--- cyrus-imapd-2.3.15.orig/imap/compile_sieve.c	1970-01-01 01:00:00.000000000 +0100
++++ cyrus-imapd-2.3.15/imap/compile_sieve.c	2009-09-09 16:13:03.000000000 +0200
+@@ -0,0 +1,365 @@
++/* This tool compiles the sieve script from a command
++line so that it can be used wby the autoadd patch */
++#include <stdio.h>
++#include <stdlib.h>
++
++#include <config.h>
++#include <string.h>
++#ifdef HAVE_UNISTD_H
++#include <unistd.h>
++#endif
++#include <errno.h>
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <sys/uio.h>
++#include <fcntl.h>
++#include <ctype.h>
++#include <time.h>
++#include <com_err.h>
++
++#include "global.h"
++
++#include "util.h"
++#include "xmalloc.h"
++#include "xstrlcpy.h"
++#include "xstrlcat.h"
++#include "mailbox.h"
++#include "imap_err.h"
++#include "sieve_interface.h"
++#include "script.h"
++
++#include <pwd.h>
++
++#define TIMSIEVE_FAIL 		-1
++#define TIMSIEVE_OK 		0
++#define MAX_FILENAME_SIZE	100
++
++/* Needed by libconfig */
++const int config_need_data = 0;
++
++static int is_script_parsable(FILE *stream, char **errstr, sieve_script_t **ret);
++
++/*static void fatal(const char *s, int code)
++{   
++    printf("Fatal error: %s (%d)\r\n", s, code);
++
++    exit(1);
++}*/
++
++void usage(void)
++{
++    fprintf(stderr,
++            "Usage:\n\tcompile_sieve [-C <altconfig>] [-i <infile> -o <outfile>]\n");
++    exit(-1);
++}
++
++
++int main (int argc, char **argv)
++{   
++
++    sieve_script_t *s = NULL;
++    bytecode_info_t *bc = NULL;
++    char *err = NULL;
++    FILE *in_stream;
++    int  out_fd, opt;
++    char *source_script = NULL;
++    char *compiled_source_script = NULL;
++    char *alt_config = NULL;
++    extern char *optarg;
++    char sieve_tmpname[MAX_MAILBOX_NAME+1];
++
++    if (geteuid() == 0) fatal("must run as the Cyrus user", EC_USAGE);
++
++    while((opt = getopt(argc, argv, "C:i:o:")) != EOF) {
++        switch (opt) {
++            case 'C': /* alt config file */
++	        alt_config =  optarg;
++	        break;
++	    case 'i': /* input script file */
++		source_script = optarg;
++		break;
++	    case 'o': /* output script file */
++		compiled_source_script = optarg;
++		break;
++	    default:
++	        usage();
++		break;
++	}
++    }
++
++    if(source_script && !compiled_source_script) {
++	    fprintf(stderr, "No output file was defined\n");
++	    usage();
++    } else if (!source_script && compiled_source_script) {
++	    fprintf(stderr, "No input file was defined\n");
++	    usage();
++    }	
++
++    /*
++     * If no <infile> has been defined, then read them from
++     * the configuration file.
++     */
++    if (!source_script && !compiled_source_script) { 
++	    cyrus_init(alt_config, "compile_sieve", 0);
++
++	    /* Initially check if we want to have the sieve script created */
++	    if(!(source_script = (char *) config_getstring(IMAPOPT_AUTOCREATE_SIEVE_SCRIPT))) {
++        	fprintf(stderr,"autocreate_sieve_script option not defined. Check imapd.conf\n");
++	        return 1;
++	    }
++
++	    /* Check if we have an already compiled sieve script*/
++	    if(!(compiled_source_script = (char *) config_getstring(IMAPOPT_AUTOCREATE_SIEVE_COMPILEDSCRIPT))) {
++	        fprintf(stderr, "autocreate_sieve_compiledscript option not defined. Check imapd.conf\n");
++		return 1;
++	    }
++
++	    if(!strrchr(source_script,'/') || !strrchr(compiled_source_script,'/')) {
++       		/* 
++		 * At this point the only think that is inconsistent is the directory 
++		 * that was created. But if the user will have any sieve scripts then 
++		 * they will eventually go there, so no big deal 
++		 */
++	        fprintf(stderr, 
++			"In imapd.conf the full path of the filenames must be defined\n");
++	       	return 1;
++	    }
++    }
++
++    printf("input file : %s, output file : %s\n", source_script, compiled_source_script);
++
++
++    if(strlen(compiled_source_script) + sizeof(".NEW") + 1 > sizeof(sieve_tmpname)) {
++	    fprintf(stderr, "Filename %s is too big\n", compiled_source_script);
++	    return 1;
++    }
++    	
++    snprintf(sieve_tmpname, sizeof(sieve_tmpname), "%s.NEW", compiled_source_script);
++
++    in_stream = fopen(source_script,"r");
++
++    if(!in_stream) {
++        fprintf(stderr,"Unable to open %s source sieve script\n",source_script);
++        return 1; 
++    }
++
++    /* 
++     * We open the file that will be used as the bc file. If this file exists, overwrite it 
++     * since something bad has happened. We open the file here so that this error checking is
++     * done before we try to open the rest of the files to start copying etc. 
++     */
++    out_fd = open(sieve_tmpname, O_CREAT|O_EXCL|O_WRONLY, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
++    if(out_fd < 0) {
++        if(errno == EEXIST) {
++            fprintf(stderr, "File %s already exists\n", sieve_tmpname);
++        } else if (errno == EACCES) {
++            fprintf(stderr,"No access to create file %s. Please check that you have the correct permissions\n",
++			    sieve_tmpname);
++        } else {
++            fprintf(stderr,"Unable to create %s. Please check that you have the correct permissions\n", 
++			    sieve_tmpname);
++        }
++	
++	fclose(in_stream);
++	return 1;
++    }
++
++    if(is_script_parsable(in_stream,&err, &s) == TIMSIEVE_FAIL) {
++        if(err && *err) {
++           fprintf(stderr, "Error while parsing script %s\n",err);
++           free(err);
++        }
++        else
++            fprintf(stderr,"Error while parsing script\n");
++            unlink(sieve_tmpname);
++	    fclose(in_stream);
++	    close(out_fd);
++        return 1;
++   }
++
++
++    /* generate the bytecode */
++    if(sieve_generate_bytecode(&bc,s) == TIMSIEVE_FAIL) {
++        fprintf(stderr,"Error occured while compiling sieve script\n");
++        /* removing the copied script and cleaning up memory */
++        unlink(sieve_tmpname);
++        sieve_script_free(&s);
++        fclose(in_stream);
++        close(out_fd);
++        return 1;
++    }
++    if(sieve_emit_bytecode(out_fd,bc) == TIMSIEVE_FAIL) {
++        fprintf(stderr, "Error occured while emitting sieve script\n");
++        unlink(sieve_tmpname);
++        sieve_free_bytecode(&bc);
++        sieve_script_free(&s);
++        fclose(in_stream);
++        close(out_fd);
++        return 1;
++    }
++
++    /* clean up the memory */
++    sieve_free_bytecode(&bc);
++    sieve_script_free(&s);
++
++    close(out_fd);
++
++    if(rename(sieve_tmpname, compiled_source_script)) {
++        if(errno != EEXIST) {
++            unlink(sieve_tmpname);
++            unlink(compiled_source_script);
++            return 1;
++        }
++    }
++    return 0;
++}
++
++
++/* to make larry's stupid functions happy :) */
++static void foo(void)
++{
++    fatal("stub function called", 0);
++}
++
++extern sieve_vacation_t vacation2;/* = {
++    0,                          / min response /
++    0,                          / max response /
++    (sieve_callback *) &foo,    / autorespond() /
++    (sieve_callback *) &foo     / send_response() /
++}; */
++
++static int sieve_notify(void *ac __attribute__((unused)),
++                        void *interp_context __attribute__((unused)),
++                        void *script_context __attribute__((unused)),
++                        void *message_context __attribute__((unused)),
++                        const char **errmsg __attribute__((unused)))
++{
++    fatal("stub function called", 0);
++    return SIEVE_FAIL;
++}
++
++static int mysieve_error(int lineno, const char *msg,
++                  void *i __attribute__((unused)), void *s)
++{
++    char buf[1024];
++    char **errstr = (char **) s;
++
++    snprintf(buf, 80, "line %d: %s\r\n", lineno, msg);
++    *errstr = (char *) xrealloc(*errstr, strlen(*errstr) + strlen(buf) + 30);
++    fprintf(stderr, "%s\n", buf);
++    strcat(*errstr, buf);
++
++    return SIEVE_OK;
++}
++
++/* end the boilerplate */
++
++/* returns TRUE or FALSE */
++int is_script_parsable(FILE *stream, char **errstr, sieve_script_t **ret)
++{
++    sieve_interp_t *i;
++    sieve_script_t *s;
++    int res;
++
++    res = sieve_interp_alloc(&i, NULL);
++    if (res != SIEVE_OK) {
++        fprintf(stderr, "sieve_interp_alloc() returns %d\n", res);
++        return TIMSIEVE_FAIL;
++    }
++
++    res = sieve_register_redirect(i, (sieve_callback *) &foo);
++    if (res != SIEVE_OK) {
++        fprintf(stderr, "sieve_register_redirect() returns %d\n", res);
++        return TIMSIEVE_FAIL;
++    }
++    res = sieve_register_discard(i, (sieve_callback *) &foo);
++    if (res != SIEVE_OK) {
++        fprintf(stderr, "sieve_register_discard() returns %d\n", res);
++        return TIMSIEVE_FAIL;
++    }
++    res = sieve_register_reject(i, (sieve_callback *) &foo);
++    if (res != SIEVE_OK) {
++        fprintf(stderr, "sieve_register_reject() returns %d\n", res);
++        return TIMSIEVE_FAIL;
++    }
++    res = sieve_register_fileinto(i, (sieve_callback *) &foo);
++    if (res != SIEVE_OK) {
++        fprintf(stderr, "sieve_register_fileinto() returns %d\n", res);
++        return TIMSIEVE_FAIL;
++    }
++    res = sieve_register_keep(i, (sieve_callback *) &foo);
++    if (res != SIEVE_OK) {
++        fprintf(stderr, "sieve_register_keep() returns %d\n", res);
++        return TIMSIEVE_FAIL;
++    }
++
++    res = sieve_register_imapflags(i, NULL);
++    if (res != SIEVE_OK) {
++        fprintf(stderr, "sieve_register_imapflags() returns %d\n", res);
++        return TIMSIEVE_FAIL;
++    }
++
++    res = sieve_register_size(i, (sieve_get_size *) &foo);
++    if (res != SIEVE_OK) {
++        fprintf(stderr, "sieve_register_size() returns %d\n", res);
++        return TIMSIEVE_FAIL;
++    }
++
++    res = sieve_register_header(i, (sieve_get_header *) &foo);
++    if (res != SIEVE_OK) {
++        fprintf(stderr, "sieve_register_header() returns %d\n", res);
++        return TIMSIEVE_FAIL;
++    }
++
++    res = sieve_register_envelope(i, (sieve_get_envelope *) &foo);
++    if (res != SIEVE_OK) {
++        fprintf(stderr, "sieve_register_envelope() returns %d\n", res);
++        return TIMSIEVE_FAIL;
++    }
++
++    res = sieve_register_vacation(i, &vacation2);
++    if (res != SIEVE_OK) {
++        fprintf(stderr, "sieve_register_vacation() returns %d\n", res);
++        return TIMSIEVE_FAIL;
++    }
++
++    res = sieve_register_notify(i, &sieve_notify);
++    if (res != SIEVE_OK) {
++        fprintf(stderr, "sieve_register_notify() returns %d\n", res);
++        return TIMSIEVE_FAIL;
++    }
++
++    res = sieve_register_parse_error(i, &mysieve_error);
++    if (res != SIEVE_OK) {
++        fprintf(stderr, "sieve_register_parse_error() returns %d\n", res);
++        return TIMSIEVE_FAIL;
++    }
++
++    rewind(stream);
++
++    *errstr = (char *) xmalloc(20 * sizeof(char));
++    strcpy(*errstr, "script errors:\r\n");
++
++    res = sieve_script_parse(i, stream, errstr, &s);
++
++    if (res == SIEVE_OK) {
++        if(ret) {
++            *ret = s;
++        } else {
++            sieve_script_free(&s);
++        }
++        free(*errstr);
++        *errstr = NULL;
++    }
++
++    /* free interpreter */
++    sieve_interp_free(&i);
++
++    return (res == SIEVE_OK) ? TIMSIEVE_OK : TIMSIEVE_FAIL;
++}
++
++
++
++
++
++
+diff -Naur cyrus-imapd-2.3.15.orig/imap/imapd.c cyrus-imapd-2.3.15/imap/imapd.c
+--- cyrus-imapd-2.3.15.orig/imap/imapd.c	2009-07-29 17:51:21.000000000 +0200
++++ cyrus-imapd-2.3.15/imap/imapd.c	2009-09-09 16:13:03.000000000 +0200
+@@ -211,6 +211,7 @@
+ void motd_file(int fd);
+ void shut_down(int code);
+ void fatal(const char *s, int code);
++void autocreate_inbox(void);
+ 
+ void cmdloop(void);
+ void cmd_login(char *tag, char *user);
+@@ -2003,6 +2004,43 @@
+ }
+ 
+ /*
++ * Autocreate Inbox and subfolders upon login
++ */
++void autocreate_inbox()
++{
++    char inboxname[MAX_MAILBOX_NAME+1];
++    int autocreatequota;
++    int r;
++ 
++    /*
++     * Exlude admin's accounts
++     */
++    if (imapd_userisadmin || imapd_userisproxyadmin)
++        return;
++ 
++    /*
++     * Exclude anonymous
++     */
++    if (!strcmp(imapd_userid, "anonymous"))
++        return;
++ 
++    if ((autocreatequota = config_getint(IMAPOPT_AUTOCREATEQUOTA))) {
++        /* This is actyally not required
++           as long as the lenght of userid is ok */
++           r = (*imapd_namespace.mboxname_tointernal) (&imapd_namespace,
++                                      "INBOX", imapd_userid, inboxname);
++           if (!r)
++               r = mboxlist_lookup(inboxname, NULL, NULL);
++ 
++           if (r == IMAP_MAILBOX_NONEXISTENT) {
++                mboxlist_autocreateinbox(&imapd_namespace, imapd_userid,
++                         imapd_authstate, inboxname, autocreatequota);
++	   }
++     }
++}
++
++
++/*
+  * Perform a LOGIN command
+  */
+ void cmd_login(char *tag, char *user)
+@@ -2179,6 +2217,9 @@
+ 				strcspn(imapd_userid, "@") : 0);
+ 
+     freebuf(&passwdbuf);
++
++    autocreate_inbox();
++
+     return;
+ }
+ 
+@@ -2336,6 +2377,8 @@
+ 				config_virtdomains ?
+ 				strcspn(imapd_userid, "@") : 0);
+ 
++    autocreate_inbox();
++
+     return;
+ }
+ 
+diff -Naur cyrus-imapd-2.3.15.orig/imap/lmtpd.c cyrus-imapd-2.3.15/imap/lmtpd.c
+--- cyrus-imapd-2.3.15.orig/imap/lmtpd.c	2009-04-23 19:10:06.000000000 +0200
++++ cyrus-imapd-2.3.15/imap/lmtpd.c	2009-09-09 16:13:03.000000000 +0200
+@@ -117,6 +117,8 @@
+ static FILE *spoolfile(message_data_t *msgdata);
+ static void removespool(message_data_t *msgdata);
+ 
++static int autocreate_inbox(const char *user, const char *domain);
++
+ /* current namespace */
+ static struct namespace lmtpd_namespace;
+ 
+@@ -977,6 +979,86 @@
+     exit(code);
+ }
+ 
++
++/*
++ * Autocreate Inbox and subfolders upon login
++ */
++int autocreate_inbox(const char *user, const char *domain)
++{
++    struct auth_state *auth_state;
++    char inboxname[MAX_MAILBOX_NAME+1];
++    char *rcpt_userid = NULL;
++    int autocreatequota;
++    int r = 0;
++
++    if (user == NULL)
++          return IMAP_MAILBOX_NONEXISTENT;
++
++    if (domain != NULL) {
++	int k;
++	
++	rcpt_userid = (char *) xmalloc((strlen(user) + strlen(domain) + 2) * sizeof(char));
++	k = strlcpy(rcpt_userid, user, strlen(user) + 1);
++  	*(rcpt_userid + k) = '@';
++       strlcpy(rcpt_userid + k + 1, domain, strlen(domain) + 1);
++    } else {
++	rcpt_userid = (char *) user;
++    }
++
++
++    /*
++     * Exclude anonymous
++     */
++    if (!strcmp(rcpt_userid, "anonymous")) {
++	if (rcpt_userid != user) {
++	    free(rcpt_userid);
++	}
++
++        return IMAP_MAILBOX_NONEXISTENT;
++    }
++    
++    /*
++     * Check for autocreatequota and createonpost
++     */
++    if (!(autocreatequota = config_getint(IMAPOPT_AUTOCREATEQUOTA)) ||
++        !(config_getswitch(IMAPOPT_CREATEONPOST))) {
++	    
++	if (rcpt_userid != user) {
++	    free(rcpt_userid);
++	}
++	
++        return IMAP_MAILBOX_NONEXISTENT;
++     }
++
++
++    /*
++     * Exclude admin's accounts
++     */
++     auth_state = auth_newstate(rcpt_userid);
++     
++     if (global_authisa(auth_state, IMAPOPT_ADMINS)) {
++	if (rcpt_userid != user) {
++	    free(rcpt_userid);
++	}
++
++        return IMAP_MAILBOX_NONEXISTENT;
++     }
++     
++     r = (*lmtpd_namespace.mboxname_tointernal) (&lmtpd_namespace,
++                                "INBOX", rcpt_userid, inboxname);
++     
++     if (!r)
++ 	r = mboxlist_autocreateinbox(&lmtpd_namespace, rcpt_userid,
++                         auth_state, inboxname, autocreatequota);
++     
++     if (rcpt_userid != user) {
++	free(rcpt_userid);
++     }
++       
++     return r;
++}
++
++
+ static int verify_user(const char *user, const char *domain, char *mailbox,
+ 		       quota_t quotacheck, struct auth_state *authstate)
+ {
+@@ -1020,6 +1102,15 @@
+ 	 */
+ 	r = mlookup(namebuf, &server, &acl, NULL);
+ 
++	/* If user mailbox does not exist, then invoke autocreate inbox function */
++	if (r == IMAP_MAILBOX_NONEXISTENT) {
++	    r = autocreate_inbox(user, domain);
++
++	    /* Try to locate the mailbox again */
++	    if (!r)
++		r = mlookup(namebuf, &server, &acl, NULL);
++	}
++
+ 	if (r == IMAP_MAILBOX_NONEXISTENT && !user &&
+ 	    config_getswitch(IMAPOPT_LMTP_FUZZY_MAILBOX_MATCH) &&
+ 	    /* see if we have a mailbox whose name is close */
+@@ -1046,6 +1137,7 @@
+ 			     aclcheck, (quotacheck < 0)
+ 			     || config_getswitch(IMAPOPT_LMTP_STRICT_QUOTA) ?
+ 			     quotacheck : 0);
++
+ 	}
+     }
+ 
+diff -Naur cyrus-imapd-2.3.15.orig/imap/Makefile.in cyrus-imapd-2.3.15/imap/Makefile.in
+--- cyrus-imapd-2.3.15.orig/imap/Makefile.in	2009-03-30 18:04:56.000000000 +0200
++++ cyrus-imapd-2.3.15/imap/Makefile.in	2009-09-09 16:28:02.000000000 +0200
+@@ -101,7 +101,7 @@
+ 	convert_code.o duplicate.o saslclient.o saslserver.o signals.o \
+ 	annotate.o search_engines.o squat.o squat_internal.o mbdump.o \
+ 	imapparse.o telemetry.o user.o notify.o idle.o quota_db.o \
+-	sync_log.o $(SEEN) mboxkey.o backend.o tls.o message_guid.o \
++	sync_log.o autosieve.o $(SEEN) mboxkey.o backend.o tls.o message_guid.o \
+ 	statuscache_db.o
+ 
+ IMAPDOBJS=pushstats.o imapd.o proxy.o imap_proxy.o index.o version.o
+@@ -118,7 +118,7 @@
+ 	fud smmapd reconstruct quota mbpath ipurge cyr_dbtool cyr_synclog \
+ 	cyrdump chk_cyrus cvt_cyrusdb deliver ctl_mboxlist \
+ 	ctl_deliver ctl_cyrusdb squatter mbexamine cyr_expire arbitron \
+-	unexpunge cyr_df @IMAP_PROGS@
++	unexpunge cyr_df compile_sieve @IMAP_PROGS@
+ 
+ BUILTSOURCES = imap_err.c imap_err.h pushstats.c pushstats.h \
+ 	lmtpstats.c lmtpstats.h xversion.h mupdate_err.c mupdate_err.h \
+@@ -183,9 +183,9 @@
+ mupdate_err.h: mupdate_err.c
+ 
+ ### Services
+-idled: idled.o mutex_fake.o libimap.a $(DEPLIBS)
++idled: idled.o mutex_fake.o libimap.a $(SIEVE_LIBS) $(DEPLIBS)
+ 	$(CC) $(LDFLAGS) -o idled \
+-	 idled.o mutex_fake.o libimap.a $(DEPLIBS) $(LIBS)
++	 idled.o mutex_fake.o libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(LIBS)
+ 
+ lmtpd: lmtpd.o proxy.o $(LMTPOBJS) $(SIEVE_OBJS) mutex_fake.o \
+ 	 libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(SERVICE)
+@@ -199,166 +199,170 @@
+ 	 $(SERVICE) lmtpd.o proxy.o $(LMTPOBJS) $(SIEVE_OBJS) \
+ 	 mutex_fake.o libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(LIBS) $(LIB_WRAP)
+ 
+-imapd: $(IMAPDOBJS) mutex_fake.o libimap.a $(DEPLIBS) $(SERVICE)
++imapd: $(IMAPDOBJS) mutex_fake.o libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(SERVICE)
+ 	$(CC) $(LDFLAGS) -o imapd \
+ 	 $(SERVICE) $(IMAPDOBJS) mutex_fake.o \
+-	libimap.a $(DEPLIBS) $(LIBS) $(LIB_WRAP)
++	libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(LIBS) $(LIB_WRAP)
+ 
+-imapd.pure: $(IMAPDOBJS) mutex_fake.o libimap.a $(DEPLIBS) $(SERVICE)
++imapd.pure: $(IMAPDOBJS) mutex_fake.o libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(SERVICE)
+ 	$(PURIFY) $(PUREOPT) $(CC) $(LDFLAGS) -o imapd.pure \
+ 	 $(SERVICE) $(IMAPDOBJS) mutex_fake.o libimap.a \
+-	$(DEPLIBS) $(LIBS) $(LIB_WRAP)
++	$(SIEVE_LIBS) $(DEPLIBS) $(LIBS) $(LIB_WRAP)
+ 
+-imapd.quant: $(IMAPDOBJS) mutex_fake.o libimap.a $(DEPLIBS) $(SERVICE)
++imapd.quant: $(IMAPDOBJS) mutex_fake.o libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(SERVICE)
+ 	$(QUANTIFY) $(QUANTOPT) $(CC) $(LDFLAGS) -o imapd.quant \
+ 	 $(SERVICE) $(IMAPDOBJS) mutex_fake.o libimap.a \
+-	$(DEPLIBS) $(LIBS) $(LIB_WRAP)
++	$(SIEVE_LIBS) $(DEPLIBS) $(LIBS) $(LIB_WRAP)
+ 
+ mupdate: mupdate.o mupdate-slave.o mupdate-client.o mutex_pthread.o tls.o \
+-	libimap.a $(DEPLIBS)
++	libimap.a $(SIEVE_LIBS) $(DEPLIBS)
+ 	$(CC) $(LDFLAGS) -o mupdate \
+ 	 $(SERVICETHREAD) mupdate.o mupdate-slave.o mupdate-client.o \
+ 	 mutex_pthread.o tls.o libimap.a \
+-	 $(DEPLIBS) $(LIBS) $(LIB_WRAP) -lpthread
++	 $(SIEVE_LIBS) $(DEPLIBS) $(LIBS) $(LIB_WRAP) -lpthread
+ 
+ mupdate.pure: mupdate.o mupdate-slave.o mupdate-client.o mutex_pthread.o \
+-	libimap.a $(DEPLIBS)
++	libimap.a $(SIEVE_LIBS) $(DEPLIBS)
+ 	$(PURIFY) $(PUREOPT) $(CC) $(LDFLAGS) -o mupdate.pure \
+ 	 $(SERVICETHREAD) mupdate.o mupdate-slave.o mupdate-client.o \
+-	 mutex_pthread.o libimap.a $(DEPLIBS) $(LIBS) $(LIB_WRAP) -lpthread
++	 mutex_pthread.o libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(LIBS) $(LIB_WRAP) -lpthread
+ 
+ pop3d: pop3d.o proxy.o backend.o tls.o mutex_fake.o libimap.a \
+-	$(DEPLIBS) $(SERVICE)
++	$(SIEVE_LIBS) $(DEPLIBS) $(SERVICE)
+ 	$(CC) $(LDFLAGS) -o pop3d pop3d.o proxy.o backend.o tls.o $(SERVICE) \
+-	 mutex_fake.o libimap.a $(DEPLIBS) $(LIBS) $(LIB_WRAP)
++	 mutex_fake.o libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(LIBS) $(LIB_WRAP)
+ 
+ nntpd: nntpd.o proxy.o backend.o index.o smtpclient.o spool.o tls.o \
+-	 mutex_fake.o nntp_err.o libimap.a $(DEPLIBS) $(SERVICE)
++	 mutex_fake.o nntp_err.o libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(SERVICE)
+ 	$(CC) $(LDFLAGS) -o nntpd nntpd.o proxy.o backend.o index.o spool.o \
+ 	 smtpclient.o tls.o $(SERVICE) mutex_fake.o nntp_err.o \
+-	 libimap.a $(DEPLIBS) $(LIBS) $(LIB_WRAP)
++	 libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(LIBS) $(LIB_WRAP)
+ 
+-fud: fud.o libimap.a mutex_fake.o $(DEPLIBS) $(SERVICE)
++fud: fud.o libimap.a mutex_fake.o $(SIEVE_LIBS) $(DEPLIBS) $(SERVICE)
+ 	$(CC) $(LDFLAGS) -o fud $(SERVICE) fud.o mutex_fake.o libimap.a \
+-	$(DEPLIBS) $(LIBS) $(LIB_WRAP)
++	$(SIEVE_LIBS) $(DEPLIBS) $(LIBS) $(LIB_WRAP)
+ 
+-smmapd: smmapd.o libimap.a mutex_fake.o $(DEPLIBS) $(SERVICE)
++smmapd: smmapd.o libimap.a mutex_fake.o $(SIEVE_LIBS) $(DEPLIBS) $(SERVICE)
+ 	$(CC) $(LDFLAGS) -o smmapd $(SERVICE) smmapd.o mutex_fake.o libimap.a \
+-	$(DEPLIBS) $(LIBS) $(LIB_WRAP)
++	$(SIEVE_LIBS) $(DEPLIBS) $(LIBS) $(LIB_WRAP)
+ 
+ sync_server: sync_server.o sync_support.o sync_commit.o \
+-	imapparse.o tls.o libimap.a mutex_fake.o $(DEPLIBS) $(SERVICE)
++	imapparse.o tls.o libimap.a mutex_fake.o $(SIEVE_LIBS) $(DEPLIBS) $(SERVICE)
+ 	$(CC) $(LDFLAGS) -o \
+ 	sync_server sync_server.o sync_support.o sync_commit.o \
+ 	imapparse.o tls.o $(SERVICE) libimap.a mutex_fake.o \
+-	$(DEPLIBS) $(LIBS) $(LIB_WRAP)
++	$(SIEVE_LIBS) $(DEPLIBS) $(LIBS) $(LIB_WRAP)
+ 
+ ### Command Line Utilities
+-arbitron: arbitron.o $(CLIOBJS) libimap.a $(DEPLIBS)
++arbitron: arbitron.o $(CLIOBJS) libimap.a $(SIEVE_LIBS) $(DEPLIBS)
+ 	$(CC) $(LDFLAGS) -o arbitron arbitron.o $(CLIOBJS) \
+-	libimap.a $(DEPLIBS) $(LIBS)
++	libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(LIBS)
+ 
+-cyr_dbtool: cyr_dbtool.o mutex_fake.o libimap.a $(DEPLIBS)
++cyr_dbtool: cyr_dbtool.o mutex_fake.o libimap.a $(SIEVE_LIBS) $(DEPLIBS)
+ 	$(CC) $(LDFLAGS) -o cyr_dbtool cyr_dbtool.o $(CLIOBJS) \
+-	libimap.a $(DEPLIBS) $(LIBS)
++	libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(LIBS)
+ 
+-cyr_synclog: cyr_synclog.o mutex_fake.o libimap.a $(DEPLIBS)
++cyr_synclog: cyr_synclog.o mutex_fake.o libimap.a $(SIEVE_LIBS) $(DEPLIBS)
+ 	$(CC) $(LDFLAGS) -o cyr_synclog cyr_synclog.o $(CLIOBJS) \
+-	libimap.a $(DEPLIBS) $(LIBS)
++	libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(LIBS)
+ 
+-cvt_cyrusdb: cvt_cyrusdb.o mutex_fake.o libimap.a $(DEPLIBS)
++cvt_cyrusdb: cvt_cyrusdb.o mutex_fake.o libimap.a $(SIEVE_LIBS) $(DEPLIBS)
+ 	$(CC) $(LDFLAGS) -o cvt_cyrusdb cvt_cyrusdb.o $(CLIOBJS) \
+-	libimap.a $(DEPLIBS) $(LIBS)
++	libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(LIBS)
+ 
+-chk_cyrus: chk_cyrus.o mutex_fake.o libimap.a $(DEPLIBS)
++chk_cyrus: chk_cyrus.o mutex_fake.o libimap.a $(SIEVE_LIBS) $(DEPLIBS)
+ 	$(CC) $(LDFLAGS) -o chk_cyrus chk_cyrus.o $(CLIOBJS) \
+-	libimap.a $(DEPLIBS) $(LIBS)
++	libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(LIBS)
+ 
+-deliver: deliver.o $(LMTPOBJS) proxy.o mutex_fake.o libimap.a $(DEPLIBS)
++deliver: deliver.o $(LMTPOBJS) proxy.o mutex_fake.o libimap.a $(SIEVE_LIBS) $(DEPLIBS)
+ 	$(CC) $(LDFLAGS) -o deliver deliver.o $(LMTPOBJS) proxy.o \
+-	mutex_fake.o libimap.a $(DEPLIBS) $(LIBS)
++	mutex_fake.o libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(LIBS)
+ 
+-ctl_deliver: ctl_deliver.o $(CLIOBJS) libimap.a $(DEPLIBS)
++ctl_deliver: ctl_deliver.o $(CLIOBJS) libimap.a $(SIEVE_LIBS) $(DEPLIBS)
+ 	$(CC) $(LDFLAGS) -o \
+-	 $@ ctl_deliver.o $(CLIOBJS) libimap.a $(DEPLIBS) $(LIBS)
++	 $@ ctl_deliver.o $(CLIOBJS) libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(LIBS)
+ 
+-ctl_mboxlist: ctl_mboxlist.o mupdate-client.o $(CLIOBJS) libimap.a $(DEPLIBS)
++ctl_mboxlist: ctl_mboxlist.o mupdate-client.o $(CLIOBJS) libimap.a $(SIEVE_LIBS) $(DEPLIBS)
+ 	$(CC) $(LDFLAGS) -o $@ ctl_mboxlist.o mupdate-client.o $(CLIOBJS) \
+-	libimap.a $(DEPLIBS) $(LIBS)
++	libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(LIBS)
+ 
+-ctl_cyrusdb: ctl_cyrusdb.o $(CLIOBJS) libimap.a $(DEPLIBS)
++ctl_cyrusdb: ctl_cyrusdb.o $(CLIOBJS) libimap.a $(SIEVE_LIBS) $(DEPLIBS)
+ 	$(CC) $(LDFLAGS) -o \
+-	 $@ ctl_cyrusdb.o $(CLIOBJS) libimap.a $(DEPLIBS) $(LIBS)
++	 $@ ctl_cyrusdb.o $(CLIOBJS) libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(LIBS)
+ 
+-cyr_expire: cyr_expire.o $(CLIOBJS) libimap.a $(DEPLIBS)
++cyr_expire: cyr_expire.o $(CLIOBJS) libimap.a $(SIEVE_LIBS) $(DEPLIBS)
+ 	$(CC) $(LDFLAGS) -o $@ cyr_expire.o $(CLIOBJS) \
+-	libimap.a $(DEPLIBS) $(LIBS)
++	libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(LIBS)
+ 
+-fetchnews: fetchnews.o $(CLIOBJS) libimap.a $(DEPLIBS)
++fetchnews: fetchnews.o $(CLIOBJS) libimap.a $(SIEVE_LIBS) $(DEPLIBS)
+ 	$(CC) $(LDFLAGS) -o \
+-	 $@ fetchnews.o $(CLIOBJS) libimap.a $(DEPLIBS) $(LIBS)
++	 $@ fetchnews.o $(CLIOBJS) libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(LIBS)
+ 
+-squatter: squatter.o index.o squat_build.o $(CLIOBJS) libimap.a $(DEPLIBS)
++squatter: squatter.o index.o squat_build.o $(CLIOBJS) libimap.a $(SIEVE_LIBS) $(DEPLIBS)
+ 	$(CC) $(LDFLAGS) -o squatter squatter.o index.o squat_build.o \
+-	$(CLIOBJS) libimap.a $(DEPLIBS) $(LIBS)
++	$(CLIOBJS) libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(LIBS)
+ 
+-mbpath: mbpath.o $(CLIOBJS) libimap.a $(DEPLIBS)
++mbpath: mbpath.o $(CLIOBJS) libimap.a $(SIEVE_LIBS) $(DEPLIBS)
+ 	$(CC) $(LDFLAGS) -o mbpath mbpath.o $(CLIOBJS) libimap.a \
+-	$(DEPLIBS) $(LIBS)
++	$(SIEVE_LIBS) $(DEPLIBS) $(LIBS)
+ 
+-ipurge: ipurge.o $(CLIOBJS) libimap.a $(DEPLIBS)
++ipurge: ipurge.o $(CLIOBJS) libimap.a $(SIEVE_LIBS) $(DEPLIBS)
+ 	$(CC) $(LDFLAGS) -o ipurge ipurge.o $(CLIOBJS) \
+-	libimap.a $(DEPLIBS) $(LIBS)
++	libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(LIBS)
+ 
+-cyr_virusscan: cyr_virusscan.o index.o $(CLIOBJS) libimap.a $(DEPLIBS)
++cyr_virusscan: cyr_virusscan.o index.o $(CLIOBJS) libimap.a $(SIEVE_LIBS) $(DEPLIBS)
+ 	$(CC) $(LDFLAGS) -o cyr_virusscan cyr_virusscan.o index.o $(CLIOBJS) \
+-	libimap.a $(DEPLIBS) $(LIBS) -lclamav
++	libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(LIBS) -lclamav
+ 
+-cyrdump: cyrdump.o index.o $(CLIOBJS) libimap.a $(DEPLIBS)
++cyrdump: cyrdump.o index.o $(CLIOBJS) libimap.a $(SIEVE_LIBS) $(DEPLIBS)
+ 	$(CC) $(LDFLAGS) -o cyrdump cyrdump.o index.o $(CLIOBJS) \
+-	libimap.a $(DEPLIBS) $(LIBS)
++	libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(LIBS)
+ 
+-cyr_df: cyr_df.o $(CLIOBJS) libimap.a $(DEPLIBS)
++cyr_df: cyr_df.o $(CLIOBJS) libimap.a $(SIEVE_LIBS) $(DEPLIBS)
+ 	$(CC) $(LDFLAGS) -o \
+-	 cyr_df cyr_df.o $(CLIOBJS) libimap.a $(DEPLIBS) $(LIBS)
++	cyr_df cyr_df.o $(CLIOBJS) libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(LIBS)
+ 
+-mbexamine: mbexamine.o $(CLIOBJS) libimap.a $(DEPLIBS)
++mbexamine: mbexamine.o $(CLIOBJS) libimap.a $(SIEVE_LIBS) $(DEPLIBS)
+ 	$(CC) $(LDFLAGS) -o \
+-	 mbexamine mbexamine.o $(CLIOBJS) libimap.a $(DEPLIBS) $(LIBS)
++	 mbexamine mbexamine.o $(CLIOBJS) libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(LIBS)
+ 
+-reconstruct: reconstruct.o $(CLIOBJS) libimap.a $(DEPLIBS)
++reconstruct: reconstruct.o $(CLIOBJS) libimap.a $(SIEVE_LIBS) $(DEPLIBS)
+ 	$(CC) $(LDFLAGS) -o \
+-	 reconstruct reconstruct.o $(CLIOBJS) libimap.a $(DEPLIBS) $(LIBS)
++	 reconstruct reconstruct.o $(CLIOBJS) libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(LIBS)
+ 
+-quota: quota.o $(CLIOBJS) libimap.a $(DEPLIBS)
++quota: quota.o $(CLIOBJS) libimap.a $(SIEVE_LIBS) $(DEPLIBS)
+ 	$(CC) $(LDFLAGS) -o quota quota.o $(CLIOBJS) \
+-	libimap.a $(DEPLIBS) $(LIBS)
++	libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(LIBS)
+ 
+-tls_prune: tls_prune.o tls.o $(CLIOBJS) libimap.a $(DEPLIBS)
++tls_prune: tls_prune.o tls.o $(CLIOBJS) libimap.a $(SIEVE_LIBS) $(DEPLIBS)
+ 	$(CC) $(LDFLAGS) -o \
+-	 $@ tls_prune.o tls.o $(CLIOBJS) libimap.a $(DEPLIBS) $(LIBS)
++	 $@ tls_prune.o tls.o $(CLIOBJS) libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(LIBS)
+ 
+-unexpunge: unexpunge.o $(CLIOBJS) libimap.a $(DEPLIBS)
++unexpunge: unexpunge.o $(CLIOBJS) libimap.a $(SIEVE_LIBS) $(DEPLIBS)
+ 	$(CC) $(LDFLAGS) -o $@ unexpunge.o $(CLIOBJS) \
+-	libimap.a $(DEPLIBS) $(LIBS)
++	libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(LIBS)
+ 
+-make_md5: make_md5.o libimap.a mutex_fake.o $(DEPLIBS)
+-	$(CC) $(LDFLAGS) -o make_md5 make_md5.o libimap.a mutex_fake.o $(DEPLIBS) $(LIBS)
++make_md5: make_md5.o libimap.a mutex_fake.o $(SIEVE_LIBS) $(DEPLIBS)
++	$(CC) $(LDFLAGS) -o make_md5 make_md5.o libimap.a mutex_fake.o $(SIEVE_LIBS) $(DEPLIBS) $(LIBS)
+ 
+-make_sha1: make_sha1.o libimap.a mutex_fake.o $(DEPLIBS)
+-	$(CC) $(LDFLAGS) -o make_sha1 make_sha1.o libimap.a mutex_fake.o $(DEPLIBS) $(LIBS)
++make_sha1: make_sha1.o libimap.a mutex_fake.o $(SIEVE_LIBS) $(DEPLIBS)
++	$(CC) $(LDFLAGS) -o make_sha1 make_sha1.o libimap.a mutex_fake.o $(SIEVE_LIBS) $(DEPLIBS) $(LIBS)
+ 
+ sync_client: sync_client.o sync_support.o \
+-	backend.o tls.o imapparse.o libimap.a mutex_fake.o $(DEPLIBS)
++	backend.o tls.o imapparse.o libimap.a mutex_fake.o $(SIEVE_LIBS) $(DEPLIBS)
+ 	$(CC) $(LDFLAGS) -o \
+ 	sync_client sync_client.o sync_support.o \
+-	backend.o tls.o imapparse.o libimap.a mutex_fake.o $(DEPLIBS) $(LIBS)
++	backend.o tls.o imapparse.o libimap.a mutex_fake.o $(SIEVE_LIBS) $(DEPLIBS) $(LIBS)
+ 
+ sync_reset: sync_reset.o sync_support.o sync_commit.o \
+-	libimap.a mutex_fake.o $(DEPLIBS)
++	libimap.a mutex_fake.o $(SIEVE_LIBS) $(DEPLIBS)
+ 	$(CC) $(LDFLAGS) -o \
+ 	sync_reset sync_reset.o sync_support.o sync_commit.o \
+-	libimap.a mutex_fake.o $(DEPLIBS) $(LIBS)
++	libimap.a mutex_fake.o $(SIEVE_LIBS) $(DEPLIBS) $(LIBS)
++
++compile_sieve: compile_sieve.o libimap.a $(DEPLIBS) $(SIEVE_LIBS)
++	$(CC) $(LDFLAGS) -o compile_sieve compile_sieve.o $(CLIOBJS) \
++	libimap.a $(SIEVE_LIBS) $(DEPLIBS) $(LIBS)
+ 
+ ### Other Misc Targets
+ 
+diff -Naur cyrus-imapd-2.3.15.orig/imap/mboxlist.c cyrus-imapd-2.3.15/imap/mboxlist.c
+--- cyrus-imapd-2.3.15.orig/imap/mboxlist.c	2009-07-28 04:46:23.000000000 +0200
++++ cyrus-imapd-2.3.15/imap/mboxlist.c	2009-09-09 16:13:03.000000000 +0200
+@@ -83,6 +83,12 @@
+ #include "quota.h"
+ #include "sync_log.h"
+ 
++#ifdef USE_SIEVE
++extern int autoadd_sieve(char *userid, 
++		const char *source_script);
++#endif
++
++
+ #define DB config_mboxlist_db
+ #define SUBDB config_subscription_db
+ 
+@@ -100,11 +106,29 @@
+ static int mboxlist_changequota(const char *name, int matchlen, int maycreate,
+ 				void *rock);
+ 
++static int mboxlist_autochangesub(char *name, int matchlen, int maycreate,
++			      void *rock);
++
++static int mboxlist_autosubscribe_sharedfolders(struct namespace *namespace,
++                        char *userid, char *auth_userid,
++                        struct auth_state *auth_state);
++
+ struct change_rock {
+     struct quota *quota;
+     struct txn **tid;
+ };
+ 
++/*
++ * Struct needed to be passed as void *rock to
++ * mboxlist_autochangesub();
++ */
++struct changesub_rock_st {
++        char *userid;
++        char *auth_userid;
++        struct auth_state *auth_state;
++};
++
++
+ #define FNAME_SUBSSUFFIX ".sub"
+ 
+ /*
+@@ -3413,3 +3437,349 @@
+ 
+     return(config_delete_mode == IMAP_ENUM_DELETE_MODE_DELAYED);
+ }
++
++/*
++ * Automatically subscribe user to *ALL* shared folders,
++ * one has permissions to be subscribed to.
++ * INBOX subfolders are excluded.
++ */
++static int mboxlist_autochangesub(char *name, int matchlen, int maycreate,
++                        void *rock) {
++
++  struct changesub_rock_st *changesub_rock = (struct changesub_rock_st *) rock;
++  char *userid = changesub_rock->userid;
++  char *auth_userid = changesub_rock->auth_userid;
++  struct auth_state *auth_state = changesub_rock->auth_state;
++  int r;
++
++
++  if((strlen(name) == 5 && !strncmp(name, "INBOX", 5)) || /* Exclude INBOX */
++     (strlen(name) > 5  && !strncmp(name, "INBOX.",6)) || /* Exclude INBOX subfolders */
++     (strlen(name) > 4  && !strncmp(name, "user.", 5)))   /* Exclude other users' folders */
++	  return 0;
++
++     
++  r = mboxlist_changesub(name, userid, auth_state, 1, 0);
++
++  if (r) {
++      syslog(LOG_WARNING,
++             "autosubscribe: User %s to folder %s, subscription failed: %s",
++             auth_userid, name, error_message(r));
++  } else {
++      syslog(LOG_NOTICE,
++             "autosubscribe: User %s to folder %s, subscription succeeded",
++             auth_userid, name);
++  }
++
++  return 0;
++}
++
++#define SEP '|'
++
++/*
++ * Automatically subscribe user to a shared folder.
++ * Subscription is done successfully, if the shared
++ * folder exists and the user has the necessary 
++ * permissions.
++ */
++static int mboxlist_autosubscribe_sharedfolders(struct namespace *namespace,
++                        char *userid, char *auth_userid,
++                        struct auth_state *auth_state) {
++        
++    const char *sub ;
++    char *p, *q, *next_sub;
++    char folder[MAX_MAILBOX_NAME+1], name[MAX_MAILBOX_NAME+1], mailboxname[MAX_MAILBOX_NAME+1];
++    int len;
++    int r = 0;
++    int subscribe_all_sharedfolders = 0;
++
++    subscribe_all_sharedfolders = config_getswitch(IMAPOPT_AUTOSUBSCRIBE_ALL_SHAREDFOLDERS);
++
++    /*
++     * If subscribeallsharedfolders is set to yes in imapd.conf, then
++     * subscribe user to every shared folder one has the apropriate 
++     * permissions.
++     */
++    if(subscribe_all_sharedfolders) {
++       char pattern[MAX_MAILBOX_PATH+1];
++       struct changesub_rock_st changesub_rock;
++
++       strcpy(pattern, "*");
++       changesub_rock.userid = userid;
++       changesub_rock.auth_userid = auth_userid;
++       changesub_rock.auth_state = auth_state;
++
++       r = mboxlist_findall(namespace, pattern, 0, userid,
++                            auth_state, mboxlist_autochangesub, &changesub_rock);
++
++       return r;
++    }
++
++    if ((sub=config_getstring(IMAPOPT_AUTOSUBSCRIBESHAREDFOLDERS)) == NULL)
++       return r;
++
++    next_sub = (char *) sub;
++    while (*next_sub) {
++        for (p = next_sub ; isspace((int) *p) || *p == SEP ; p++);
++        for (next_sub = p ; *next_sub && *next_sub != SEP ; next_sub++);
++        for (q = next_sub ; q > p && (isspace((int) *q) || *q == SEP || !*q) ; q--);
++        if (!*p ) continue;
++
++        len = q - p + 1;
++        /* Check for folder length */
++        if (len  > sizeof(folder)-1)
++                continue;
++
++        if (!r) {
++                strncpy(folder, p, len);
++                folder[len] = '\0';
++
++               strlcpy(name, namespace->prefix[NAMESPACE_SHARED], sizeof(name));
++               len = strlcat(name, folder, sizeof(name));
++
++               r = (namespace->mboxname_tointernal) (namespace, name, userid,
++                                                                  mailboxname);
++       }
++                                                                  
++        if (!r)
++               r = mboxlist_changesub(mailboxname, userid, auth_state, 1, 0);
++
++        if (!r) {
++                syslog(LOG_NOTICE, "autosubscribe: User %s to %s succeeded", 
++                       userid, folder);
++        } else {
++                syslog(LOG_WARNING, "autosubscribe: User %s to %s failed: %s", 
++                       userid, folder, error_message(r));
++                r = 0;
++        }
++    }
++
++    return r;
++}
++
++
++
++int mboxlist_autocreateinbox(struct namespace *namespace,
++                        char *userid,
++                        struct auth_state *auth_state,
++                        char *mailboxname, int autocreatequota) {
++    char name [MAX_MAILBOX_NAME+1];
++    char folder [MAX_MAILBOX_NAME+1];
++    char *auth_userid = NULL;
++    char *partition = NULL;
++    const char *crt;
++    const char *sub;
++    char *p, *q, *next_crt, *next_sub;
++    int len;
++    int r = 0;
++    int numcrt = 0;
++    int numsub = 0;
++#ifdef USE_SIEVE
++    const char *source_script;
++#endif
++
++
++
++    auth_userid = auth_canonuser(auth_state);
++    if (auth_userid == NULL) {
++         /*
++          * Couldn't get cannon userid
++          */
++          syslog(LOG_ERR,
++                 "autocreateinbox: Could not get canonified userid for user %s", userid);
++          return IMAP_PARTITION_UNKNOWN;
++    }
++
++    /* Added this for debug information. */
++    syslog(LOG_DEBUG, "autocreateinbox: autocreate inbox for user %s was called", auth_userid);
++
++   /*
++    * While this is not needed for admins
++    * and imap_admins accounts, it would be
++    * better to separate *all* admins and
++    * proxyservers from normal accounts
++    * (accounts that have mailboxes).
++    * UOA Specific note(1): Even if we do not
++    * exclude these servers-classes here,
++    * UOA specific code, will neither return
++    * role, nor create INBOX, because none of these
++    * administrative accounts belong to  the
++    * mailRecipient objectclass, or have imapPartition.
++    * UOA Specific note(2): Another good reason for doing
++    * this, is to prevent the code, from getting into
++    * cyrus_ldap.c because of the continues MSA logins to LMTPd.
++    */
++
++   /*
++    * admins and the coresponding imap
++    * service, had already been excluded.
++    */
++
++   /*
++    * Do we really need group membership
++    * for admins or service_admins?
++    */
++    if (global_authisa(auth_state, IMAPOPT_ADMINS)) return 0;
++
++   /*
++    * Do we really need group membership
++    * for proxyservers?
++    */
++    if (global_authisa(auth_state, IMAPOPT_PROXYSERVERS)) return 0;
++
++    /* 
++     * Check if user belongs to the autocreate_users group. This option
++     * controls for whom the mailbox may be automatically created. Default
++     * value for this option is 'anyone'. So, if not declared, all mailboxes
++     * will be created.
++     */
++    if (!global_authisa(auth_state, IMAPOPT_AUTOCREATE_USERS)) {
++	    syslog(LOG_DEBUG, "autocreateinbox: User %s does not belong to the autocreate_users. No mailbox is created",
++			    auth_userid);
++	    return IMAP_MAILBOX_NONEXISTENT;
++    }
++
++#if 0
++        /*
++         * Get Partition info or return.
++         * (Here you should propably use
++         * you own "get_partition(char *userid)"
++         * function. Otherwise all new INBOXes will be
++         * created into whatever partition has been declared
++         * as default in your imapd.conf)
++         */
++
++        partition = get_partition(userid);
++        if (partition == NULL) {
++            /*
++             * Couldn't get partition info
++             */
++            syslog(LOG_ERR,
++                   "Could not get imapPartition info for user %s", userid);
++            return IMAP_PARTITION_UNKNOWN;
++        }
++#endif
++
++    r = mboxlist_createmailbox(mailboxname, MAILBOX_FORMAT_NORMAL, NULL,
++                                      1, userid, auth_state, 0, 0, 0);
++
++    if (!r && autocreatequota > 0)
++        r = mboxlist_setquota(mailboxname, autocreatequota, 0);
++
++    if (!r)
++        r = mboxlist_changesub(mailboxname, userid,
++                              auth_state, 1, 1);
++
++    if (!r) {
++       syslog(LOG_NOTICE, "autocreateinbox: User %s, INBOX was successfully created in partition %s", 
++               auth_userid, partition == NULL ? "default" : partition);
++    } else {
++       syslog(LOG_ERR, "autocreateinbox: User %s, INBOX failed. %s", 
++               auth_userid, error_message(r));
++    }
++
++#if 0
++    /* Allocated from get_partition, and not needed any more */
++    free_partition(partition);
++#endif
++
++    if (r) return r;
++
++    /* INBOX's subfolders */
++    if ((crt=config_getstring(IMAPOPT_AUTOCREATEINBOXFOLDERS)))
++        sub=config_getstring(IMAPOPT_AUTOSUBSCRIBEINBOXFOLDERS);
++
++    /* Roll through crt */
++    next_crt = (char *) crt;
++    while (next_crt!=NULL && *next_crt) {
++          for (p = next_crt ; isspace((int) *p) || *p == SEP ; p++);
++          for (next_crt = p ; *next_crt && *next_crt != SEP ; next_crt++);
++          for (q = next_crt ; q > p && (isspace((int) *q) || *q == SEP || !*q); q--);
++
++          if (!*p) continue;
++
++          len = q - p + 1;
++
++          /* First time we check for length */
++          if (len > sizeof(folder) - 5)
++              r = IMAP_MAILBOX_BADNAME;
++
++          if (!r) {
++                  strncpy(folder, p, len);
++                  folder[len] = '\0';
++
++                  strlcpy(name, namespace->prefix[NAMESPACE_INBOX], sizeof(name));
++                  len = strlcat(name, folder, sizeof(name));
++          }
++
++          if (!r)
++            r = (namespace->mboxname_tointernal) (namespace, name, userid,
++                                                 mailboxname);
++          if (!r)
++             r = mboxlist_createmailbox(mailboxname, MAILBOX_FORMAT_NORMAL, NULL,
++                                            1, userid, auth_state, 0, 0, 0);
++
++          if (!r) {
++            numcrt++;
++            syslog(LOG_NOTICE, "autocreateinbox: User %s, subfolder %s creation succeeded.", 
++               auth_userid, name);
++         } else {
++             syslog(LOG_WARNING, "autocreateinbox: User %s, subfolder %s creation failed. %s", 
++               auth_userid, name, error_message(r));
++             r=0;
++             continue;
++          }
++
++          /* Roll through sub */
++          next_sub = (char *) sub;
++          while (next_sub!=NULL && *next_sub) {
++                for (p = next_sub ; isspace((int) *p) || *p == SEP ; p++);
++                for (next_sub = p ; *next_sub && *next_sub != SEP ; next_sub++);
++                for (q = next_sub ; q > p && (isspace((int) *q) || *q == SEP || !*q) ; q--);
++                if (!*p ) continue;
++
++                len = q - p + 1;
++
++                if (len != strlen(folder) || strncmp(folder, p, len))
++                    continue;
++
++                r = mboxlist_changesub(mailboxname, userid, auth_state, 1, 1);
++
++               if (!r) {
++                   numsub++;
++                   syslog(LOG_NOTICE,"autocreateinbox: User %s, subscription to %s succeeded",
++                       auth_userid, name);
++               } else
++                    syslog(LOG_WARNING, "autocreateinbox: User %s, subscription to  %s failed. %s",
++                       auth_userid, name, error_message(r));
++
++                break;
++         }
++    }
++
++    if (crt!=NULL && *crt)
++       syslog(LOG_INFO, "User %s, Inbox subfolders, created %d, subscribed %d", 
++               auth_userid, numcrt, numsub);
++
++    /*
++     * Check if shared folders are available for subscription.
++     */
++    mboxlist_autosubscribe_sharedfolders(namespace, userid, auth_userid, auth_state);
++
++#ifdef USE_SIEVE
++    /*
++     * Here the autocreate sieve script feature is iniated from.
++     */
++    source_script = config_getstring(IMAPOPT_AUTOCREATE_SIEVE_SCRIPT);
++ 
++    if (source_script) {
++        if (!autoadd_sieve(userid, source_script))
++            syslog(LOG_NOTICE, "autocreate_sieve: User %s, default sieve script creation succeeded", auth_userid);
++        else
++            syslog(LOG_WARNING, "autocreate_sieve: User %s, default sieve script creation failed", auth_userid);
++    }
++#endif
++
++    return r;
++}
++
+diff -Naur cyrus-imapd-2.3.15.orig/imap/mboxlist.h cyrus-imapd-2.3.15/imap/mboxlist.h
+--- cyrus-imapd-2.3.15.orig/imap/mboxlist.h	2009-05-05 03:20:03.000000000 +0200
++++ cyrus-imapd-2.3.15/imap/mboxlist.h	2009-09-09 16:13:03.000000000 +0200
+@@ -216,4 +216,8 @@
+ int mboxlist_abort(struct txn *tid);
+ 
+ int mboxlist_delayed_delete_isenabled(void);
++int mboxlist_autocreateinbox(struct namespace *namespace,char *userid,
++                       struct auth_state *auth_state, char *mailboxname, 
++                       int autocreatequota);
++
+ #endif
+diff -Naur cyrus-imapd-2.3.15.orig/imap/pop3d.c cyrus-imapd-2.3.15/imap/pop3d.c
+--- cyrus-imapd-2.3.15.orig/imap/pop3d.c	2009-04-23 19:10:07.000000000 +0200
++++ cyrus-imapd-2.3.15/imap/pop3d.c	2009-09-09 16:13:03.000000000 +0200
+@@ -173,6 +173,8 @@
+ static char popd_apop_chal[45 + MAXHOSTNAMELEN + 1]; /* <rand.time at hostname> */
+ static void cmd_apop(char *response);
+ 
++static int autocreate_inbox(char *inboxname, char *userid);
++
+ static void cmd_auth(char *arg);
+ static void cmd_capa(void);
+ static void cmd_pass(char *pass);
+@@ -1246,6 +1248,7 @@
+ 	popd_userid = xstrdup(userbuf);
+ 	prot_printf(popd_out, "+OK Name is a valid mailbox\r\n");
+     }
++
+ }
+ 
+ void cmd_pass(char *pass)
+@@ -1549,6 +1552,43 @@
+ }
+ 
+ /*
++ * Autocreate Inbox and subfolders upon login
++ */
++int autocreate_inbox(char *inboxname, char *auth_userid)
++{
++    struct auth_state *auth_state;
++    int autocreatequota;
++    int r;
++
++    if (inboxname == NULL || auth_userid == NULL)
++	    return IMAP_MAILBOX_NONEXISTENT;
++    
++    /*
++     * Exclude anonymous
++     */
++    if (!strcmp(popd_userid, "anonymous"))
++        return IMAP_MAILBOX_NONEXISTENT;
++
++    /*
++     * Check for autocreatequota
++     */
++    if (!(autocreatequota = config_getint(IMAPOPT_AUTOCREATEQUOTA)))
++        return IMAP_MAILBOX_NONEXISTENT;
++
++    /*
++     * Exclude admin's accounts
++     */
++     auth_state = auth_newstate(popd_userid);
++     if (global_authisa(auth_state, IMAPOPT_ADMINS))
++          return IMAP_MAILBOX_NONEXISTENT;
++
++     r = mboxlist_autocreateinbox(&popd_namespace, auth_userid,
++                         auth_state, inboxname, autocreatequota);
++     return r;
++}
++
++
++/*
+  * Complete the login process by opening and locking the user's inbox
+  */
+ int openinbox(void)
+@@ -1577,6 +1617,12 @@
+ 
+     if (!r) r = mboxlist_detail(inboxname, &type, NULL, NULL,
+ 				&server, &acl, NULL);
++
++    /* Try once again after autocreate_inbox */
++    if (r == IMAP_MAILBOX_NONEXISTENT && !(r = autocreate_inbox(inboxname, userid)))
++	r = mboxlist_detail(inboxname, &type, NULL, NULL,
++				&server, &acl, NULL);
++
+     if (!r && (config_popuseacl = config_getswitch(IMAPOPT_POPUSEACL)) &&
+ 	(!acl ||
+ 	 !((myrights = cyrus_acl_myrights(popd_authstate, acl)) & ACL_READ))) {
+diff -Naur cyrus-imapd-2.3.15.orig/lib/auth.c cyrus-imapd-2.3.15/lib/auth.c
+--- cyrus-imapd-2.3.15.orig/lib/auth.c	2008-03-24 18:43:08.000000000 +0100
++++ cyrus-imapd-2.3.15/lib/auth.c	2009-09-09 16:13:03.000000000 +0200
+@@ -118,3 +118,11 @@
+ 
+     auth->freestate(auth_state);
+ }
++
++char *auth_canonuser(struct auth_state *auth_state)
++{
++    struct auth_mech *auth = auth_fromname();
++
++    return auth->auth_canonuser(auth_state);
++}
++
+diff -Naur cyrus-imapd-2.3.15.orig/lib/auth.h cyrus-imapd-2.3.15/lib/auth.h
+--- cyrus-imapd-2.3.15.orig/lib/auth.h	2008-03-24 18:43:08.000000000 +0100
++++ cyrus-imapd-2.3.15/lib/auth.h	2009-09-09 16:13:03.000000000 +0200
+@@ -55,6 +55,7 @@
+              const char *identifier);
+     struct auth_state *(*newstate)(const char *identifier);
+     void (*freestate)(struct auth_state *auth_state);
++    char *(*auth_canonuser)(struct auth_state *auth_state);
+ };
+ 
+ extern struct auth_mech *auth_mechs[];
+@@ -77,5 +78,6 @@
+  	 const char *identifier);
+ struct auth_state *auth_newstate(const char *identifier);
+ void auth_freestate(struct auth_state *auth_state);
++char *auth_canonuser(struct auth_state *auth_state);
+ 
+ #endif /* INCLUDED_AUTH_H */
+diff -Naur cyrus-imapd-2.3.15.orig/lib/auth_krb5.c cyrus-imapd-2.3.15/lib/auth_krb5.c
+--- cyrus-imapd-2.3.15.orig/lib/auth_krb5.c	2008-03-24 18:43:08.000000000 +0100
++++ cyrus-imapd-2.3.15/lib/auth_krb5.c	2009-09-09 16:13:03.000000000 +0200
+@@ -199,6 +199,14 @@
+     free(auth_state);
+ }
+ 
++static char *mycanonuser(struct auth_state *auth_state)
++{
++    if (auth_state)
++       return auth_state->userid;
++
++    return NULL;
++}
++
+ #else /* HAVE_GSSAPI_H */
+ 
+ static int mymemberof(
+@@ -230,6 +238,13 @@
+ 	fatal("Authentication mechanism (krb5) not compiled in", EC_CONFIG);
+ }
+ 
++static char *mycanonuser(
++    struct auth_state *auth_state __attribute__((unused)))
++{
++        fatal("Authentication mechanism (krb5) not compiled in", EC_CONFIG);
++	return NULL;
++}
++
+ #endif
+ 
+ struct auth_mech auth_krb5 = 
+@@ -240,4 +255,5 @@
+     &mymemberof,
+     &mynewstate,
+     &myfreestate,
++    &mycanonuser,
+ };
+diff -Naur cyrus-imapd-2.3.15.orig/lib/auth_krb.c cyrus-imapd-2.3.15/lib/auth_krb.c
+--- cyrus-imapd-2.3.15.orig/lib/auth_krb.c	2009-03-31 06:11:21.000000000 +0200
++++ cyrus-imapd-2.3.15/lib/auth_krb.c	2009-09-09 16:13:03.000000000 +0200
+@@ -341,6 +341,15 @@
+     free((char *)auth_state);
+ }
+ 
++static char *mycanonuser(struct auth_state *auth_state)
++{
++    if (auth_state)
++       return auth_state->userid;
++
++    return NULL;
++}
++
++
+ #else /* HAVE_KRB */
+ 
+ static int mymemberof(
+@@ -372,6 +381,13 @@
+ 	fatal("Authentication mechanism (krb) not compiled in", EC_CONFIG);
+ }
+ 
++static char *mycanonuser(
++    struct auth_state *auth_state __attribute__((unused)))
++{
++        fatal("Authentication mechanism (krb) not compiled in", EC_CONFIG);
++}
++
++
+ #endif
+ 
+ struct auth_mech auth_krb = 
+@@ -382,4 +398,5 @@
+     &mymemberof,
+     &mynewstate,
+     &myfreestate,
++    &mycanonuser,
+ };
+diff -Naur cyrus-imapd-2.3.15.orig/lib/auth_pts.c cyrus-imapd-2.3.15/lib/auth_pts.c
+--- cyrus-imapd-2.3.15.orig/lib/auth_pts.c	2008-03-24 18:43:08.000000000 +0100
++++ cyrus-imapd-2.3.15/lib/auth_pts.c	2009-09-09 16:13:03.000000000 +0200
+@@ -512,6 +512,14 @@
+     free(auth_state);
+ }
+ 
++static char *mycanonuser(struct auth_state *auth_state)
++{
++    if (auth_state)
++       return auth_state->userid.id;
++
++    return NULL;
++}
++
+ struct auth_mech auth_pts = 
+ {
+     "pts",		/* name */
+@@ -520,4 +528,5 @@
+     &mymemberof,
+     &mynewstate,
+     &myfreestate,
++    &mycanonuser,
+ };
+diff -Naur cyrus-imapd-2.3.15.orig/lib/auth_unix.c cyrus-imapd-2.3.15/lib/auth_unix.c
+--- cyrus-imapd-2.3.15.orig/lib/auth_unix.c	2009-03-31 06:11:22.000000000 +0200
++++ cyrus-imapd-2.3.15/lib/auth_unix.c	2009-09-09 16:13:03.000000000 +0200
+@@ -315,6 +315,16 @@
+     free((char *)auth_state);
+ }
+ 
++static char *mycanonuser(auth_state)
++    struct auth_state *auth_state;
++{
++    if (auth_state)
++         return auth_state->userid;
++
++    return NULL;
++}
++
++
+ 
+ struct auth_mech auth_unix = 
+ {
+@@ -324,4 +334,5 @@
+     &mymemberof,
+     &mynewstate,
+     &myfreestate,
++    &mycanonuser,
+ };
+diff -Naur cyrus-imapd-2.3.15.orig/lib/imapoptions cyrus-imapd-2.3.15/lib/imapoptions
+--- cyrus-imapd-2.3.15.orig/lib/imapoptions	2009-06-29 19:21:06.000000000 +0200
++++ cyrus-imapd-2.3.15/lib/imapoptions	2009-09-09 16:13:03.000000000 +0200
+@@ -198,6 +198,55 @@
+ /* Number of seconds to wait before returning a timeout failure when
+    performing a client connection (e.g., in a murder environment) */
+ 
++{ "createonpost", 0, SWITCH }
++/* If yes, when lmtpd receives an incoming mail for an INBOX that does not exist,
++   then the INBOX is automatically created by lmtpd. */
++
++{ "autocreateinboxfolders", NULL, STRING }
++/* If a user does not have an INBOX created then the INBOX as well as some INBOX 
++   subfolders are created under two conditions.
++     1. The user logins via the IMAP or the POP3 protocol. (autocreatequota option must have a nonzero value)
++     2. A message arrives for the user through the LMTPD protocol.(createonpost option must be yes)
++   autocreateinboxfolders is a list of INBOX's subfolders separated by a "|", that 
++   are automatically created by the server under the previous two situations. */
++
++{ "autosubscribeinboxfolders", NULL, STRING }
++/* A list of folder names, separated by "|", that the users get automatically subscribed to, 
++   when their INBOX is created. These folder names must have been included in the 
++   autocreateinboxfolders option of the imapd.conf. */
++
++{ "autosubscribesharedfolders", NULL, STRING }
++/* A list of shared folders (bulletin boards), separated by "|", that the users get
++   automatically subscribed to, after their INBOX is created. The shared folder must 
++   have been created and the user must have the required permissions to get subscribed 
++   to it. Otherwise, subscribing to the shared folder fails. */
++
++{ "autosubscribe_all_sharedfolders", 0, SWITCH }
++/* If set to yes, the user is automatically subscribed to all shared folders, one has permission
++   to subscribe to. */
++
++{ "autocreate_sieve_script", NULL, STRING }
++/* The full path of a file that contains a sieve script. This script automatically becomes a
++   user's initial default sieve filter script. When this option is not defined, no default 
++   sieve filter is created. The file must be readable by the cyrus daemon. */
++
++{ "autocreate_sieve_compiledscript", NULL, STRING }
++/* The full path of a file that contains a compiled in bytecode sieve script. This script 
++   automatically becomes a user's initial default sieve filter script.  If this option is 
++   not specified, or the filename doesn't exist then the script defined by 
++   autocreate_sieve_script is compiled on the fly and installed as the user's default
++   sieve script */
++
++{ "generate_compiled_sieve_script", 0, SWITCH }
++/* If set to yes and no compiled sieve script file exists, the sieve script which is 
++   compiled on the fly will be saved in the file name that autocreate_sieve_compiledscript 
++   option points to. In order a compiled script to be generated, autocreate_sieve_script and 
++   autocreate_sieve_compiledscript must have valid values */
++
++{ "autocreate_users", "anyone", STRING }
++/* A space separated list of users and/or groups that are allowed their INBOX to be
++   automatically created. */
++
+ { "configdirectory", NULL, STRING }
+ /* The pathname of the IMAP configuration directory.  This field is
+    required. */
+diff -Naur cyrus-imapd-2.3.15.orig/notifyd/Makefile.in cyrus-imapd-2.3.15/notifyd/Makefile.in
+--- cyrus-imapd-2.3.15.orig/notifyd/Makefile.in	2008-03-24 20:59:32.000000000 +0100
++++ cyrus-imapd-2.3.15/notifyd/Makefile.in	2009-09-09 16:13:03.000000000 +0200
+@@ -71,10 +71,11 @@
+ SERVICE=../master/service.o
+ 
+ IMAP_LIBS = @IMAP_LIBS@ @LIB_RT@
++SIEVE_LIBS = @SIEVE_LIBS@
+ IMAP_COM_ERR_LIBS = @IMAP_COM_ERR_LIBS@
+ LIB_WRAP = @LIB_WRAP@
+ LIBS = @ZEPHYR_LIBS@ @LIBS@ $(IMAP_COM_ERR_LIBS)
+-DEPLIBS=../imap/mutex_fake.o ../imap/libimap.a ../lib/libcyrus.a ../lib/libcyrus_min.a @DEPLIBS@
++DEPLIBS=../imap/mutex_fake.o ../imap/libimap.a $(SIEVE_LIBS) ../lib/libcyrus.a ../lib/libcyrus_min.a @DEPLIBS@
+ 
+ PURIFY=/usr/local/bin/purify
+ PUREOPT=-best-effort
+diff -Naur cyrus-imapd-2.3.15.orig/notifyd/notifyd.c cyrus-imapd-2.3.15/notifyd/notifyd.c
+--- cyrus-imapd-2.3.15.orig/notifyd/notifyd.c	2008-03-24 20:59:32.000000000 +0100
++++ cyrus-imapd-2.3.15/notifyd/notifyd.c	2009-09-09 16:13:03.000000000 +0200
+@@ -96,7 +96,7 @@
+ 
+ #define NOTIFY_MAXSIZE 8192
+ 
+-int do_notify()
++static int do_notify()
+ {
+     struct sockaddr_un sun_data;
+     socklen_t sunlen = sizeof(sun_data);
+diff -Naur cyrus-imapd-2.3.15.orig/ptclient/Makefile.in cyrus-imapd-2.3.15/ptclient/Makefile.in
+--- cyrus-imapd-2.3.15.orig/ptclient/Makefile.in	2008-03-24 19:34:22.000000000 +0100
++++ cyrus-imapd-2.3.15/ptclient/Makefile.in	2009-09-09 16:13:03.000000000 +0200
+@@ -57,10 +57,11 @@
+ AFS_LDFLAGS = @AFS_LDFLAGS@ @COM_ERR_LDFLAGS@
+ AFS_LIBS = @AFS_LIBS@
+ IMAP_LIBS = @IMAP_LIBS@ @LIB_RT@
++SIEVE_LIBS = @SIEVE_LIBS@
+ LIBS = $(IMAP_LIBS) @COM_ERR_LIBS@
+ LIB_SASL = @LIB_SASL@
+ LIB_WRAP = @LIB_WRAP@
+-DEPLIBS = ../imap/libimap.a ../lib/libcyrus.a ../lib/libcyrus_min.a @DEPLIBS@
++DEPLIBS = ../imap/libimap.a $(SIEVE_LIBS) ../lib/libcyrus.a ../lib/libcyrus_min.a @DEPLIBS@ 
+ UTIL_LIBS = ../imap/mutex_fake.o ../imap/cli_fatal.o
+ 
+ LDAP_LIBS=@LDAP_LIBS@
+diff -Naur cyrus-imapd-2.3.15.orig/README.autocreate cyrus-imapd-2.3.15/README.autocreate
+--- cyrus-imapd-2.3.15.orig/README.autocreate	1970-01-01 01:00:00.000000000 +0100
++++ cyrus-imapd-2.3.15/README.autocreate	2009-09-09 16:13:03.000000000 +0200
+@@ -0,0 +1,211 @@
++Cyrus IMAP autocreate Inbox patch
++----------------------------------
++
++NOTE : This patch has been created at the University of Athens. For more info, as well 
++as more patches on Cyrus IMAPD server, please visit http://email.uoa.gr/ 
++
++The design of Cyrus IMAP server does not predict the automatic creation of users'
++INBOX folders. The creation of a user's INBOX is considered to be an external task,
++that has to be completed as part of the user email account creation procedure. 
++Hence, to create a new email account the site administrator has to:
++
++  a) Include the new account in the user database for the authentication procedure
++     (e.g. sasldb, shadow, mysql, ldap).
++  b) Create the corresponding INBOX folder. 
++
++Alternatively, the user, if succesfully authenticated, may create his own INBOX folder,
++as long as the configuration of the site allows it (see "autocreatequota" in imapd.conf).
++Unlike what not careful readers may think, enabling the "autocreatequota" option, doesn't 
++lead to the automatic INBOX folder creation by Cyrus IMAP server.
++In fact, "autocreate" means that the IMAP clients are allowed to automatically create 
++the user INBOX. 
++
++This patch adds the functionality of automatic creation of the users' INBOX folders into
++the Cyrus IMAP server. It is implemented as two features, namely the  "create on login"
++and "create on post".
++ 
++
++
++Create on login
++===============
++This feauture provides automatic creation of a user's INBOX folder when all of the 
++following requirements are met:
++

@@ Diff output truncated at 100000 characters. @@

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list