--- dovecot-1.0.15.orig/dovecot-sieve/configure.in +++ dovecot-1.0.15/dovecot-sieve/configure.in @@ -0,0 +1,68 @@ +AC_INIT(dovecot-sieve, 1.0.2, [dovecot@dovecot.org]) +AC_CONFIG_SRCDIR([src]) + +AC_CONFIG_HEADERS([dsieve-config.h]) +AM_INIT_AUTOMAKE + +AM_MAINTAINER_MODE + +AC_PROG_CC +AC_PROG_CPP +AC_PROG_LEX +AC_PROG_YACC +AM_PROG_LIBTOOL + +AC_ARG_WITH(dovecot, +[ --with-dovecot[=DIR] Dovecot base directory (../)], + dovecotdir="$withval", + dovecotdir=../dovecot +) +old=`pwd` +cd $dovecotdir +dovecotdir=`pwd` +cd $old +AC_SUBST(dovecotdir) + +if ! test -f "$dovecotdir/dovecot-config"; then + echo + echo "dovecot-config not found from $dovecotdir, use --with-dovecot=PATH" + echo "to give path to compiled Dovecot sources or to a directory with the" + echo "installed dovecot-config file." + AC_MSG_ERROR([dovecot-config not found]) +fi + +if test -d "$dovecotdir/src"; then + # compiling against sources + have_dovecot_libs=yes +else + # compiling against installed headers + have_dovecot_libs=no +fi +AM_CONDITIONAL(HAVE_DOVECOT_LIBS, test "$have_dovecot_libs" = "yes") + +dnl replace relative ../ paths in the file with full paths +eval `cat $dovecotdir/dovecot-config|sed 's,\$(top_builddir)/,$dovecotdir/,g'` + +if test $have_dovecot_libs = yes; then + dovecot_incdir="$dovecotdir" +fi + +dnl * Regexp library check, from Cyrus IMAP +AC_SEARCH_LIBS(regcomp, rx regex, [ + CFLAGS="$CFLAGS -DENABLE_REGEX" + AC_CHECK_HEADER(rxposix.h, CFLAGS="$CFLAGS -DHAVE_RX")]) + +AC_SUBST(STORAGE_LIBS) +AC_SUBST(LIBICONV) +AC_SUBST(RAND_LIBS) +AC_SUBST(MODULE_LIBS) +AC_SUBST(dovecot_incdir) +AC_SUBST(moduledir) + +AC_CONFIG_FILES([ +Makefile +src/Makefile +src/libsieve/Makefile +stamp.h]) + +AC_OUTPUT --- dovecot-1.0.15.orig/dovecot-sieve/stamp.h.in +++ dovecot-1.0.15/dovecot-sieve/stamp.h.in @@ -0,0 +1 @@ + --- dovecot-1.0.15.orig/dovecot-sieve/Makefile.am +++ dovecot-1.0.15/dovecot-sieve/Makefile.am @@ -0,0 +1,10 @@ +SUBDIRS = src + +EXTRA_DIST = \ + COPYING.LGPL \ + ChangeLog + +if MAINTAINER_MODE +ChangeLog: .hg/dirstate + hg log --style=changelog > ChangeLog +endif --- dovecot-1.0.15.orig/dovecot-sieve/README +++ dovecot-1.0.15/dovecot-sieve/README @@ -0,0 +1,3 @@ +See INSTALL on how to install this plugin. + +The libsieve is based on Cyrus v2.2's libsieve. --- dovecot-1.0.15.orig/dovecot-sieve/autogen.sh +++ dovecot-1.0.15/dovecot-sieve/autogen.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +# If you've non-standard directories, set these +#ACLOCAL_DIR= +#GETTEXT_DIR= + +if test "$ACLOCAL_DIR" != ""; then + ACLOCAL="aclocal -I $ACLOCAL_DIR" + export ACLOCAL +fi + +if test ! -f ChangeLog; then + # automake dies unless this exists. It's generated in Makefile + touch -t `date +%m%d`0000 ChangeLog +fi + +autoreconf -i --- dovecot-1.0.15.orig/dovecot-sieve/INSTALL +++ dovecot-1.0.15/dovecot-sieve/INSTALL @@ -0,0 +1,25 @@ +Compiling +--------- + +Use --with-dovecot= to point to dovecot-config file's directory. +There are two possibilities where this could exist: + +1) If you configured Dovecot with --enable-header-install, you'll have +dovecot-config installed in $prefix/lib/dovecot/ directory. + +2) Compiled Dovecot sources' root directory. + +So for example: + +./configure --with-dovecot=/usr/local/lib/dovecot +make +sudo make install + +sievec and sieved binaries are built only if you use 2) method, because +they need to link with Dovecot's libraries. They can be used to compile and +decompile Sieve scripts. You probably don't need these. + +Configuring +----------- + +See the wiki page: http://wiki.dovecot.org/LDA/Sieve --- dovecot-1.0.15.orig/dovecot-sieve/NEWS +++ dovecot-1.0.15/dovecot-sieve/NEWS @@ -0,0 +1,3 @@ +v1.0 2006-11-05 Timo Sirainen + + * The first actual release --- dovecot-1.0.15.orig/dovecot-sieve/AUTHORS +++ dovecot-1.0.15/dovecot-sieve/AUTHORS @@ -0,0 +1,2 @@ +Timo Sirainen +CMU Sieve people, see src/libsieve/AUTHORS --- dovecot-1.0.15.orig/dovecot-sieve/COPYING.LGPL +++ dovecot-1.0.15/dovecot-sieve/COPYING.LGPL @@ -0,0 +1,510 @@ + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations +below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. +^L + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it +becomes a de-facto standard. To achieve this, non-free programs must +be allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. +^L + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control +compilation and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. +^L + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. +^L + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at least + three years, to give the same user the materials specified in + Subsection 6a, above, for a charge no more than the cost of + performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. +^L + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. +^L + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply, and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License +may add an explicit geographical distribution limitation excluding those +countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. +^L + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS +^L + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms +of the ordinary General Public License). + + To apply these terms, attach the following notices to the library. +It is safest to attach them to the start of each source file to most +effectively convey the exclusion of warranty; and each file should +have at least the "copyright" line and a pointer to where the full +notice is found. + + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or +your school, if any, to sign a "copyright disclaimer" for the library, +if necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James + Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + --- dovecot-1.0.15.orig/dovecot-sieve/src/Makefile.am +++ dovecot-1.0.15/dovecot-sieve/src/Makefile.am @@ -0,0 +1,32 @@ +SUBDIRS = libsieve + +AM_CPPFLAGS = \ + -I$(dovecot_incdir) \ + -I$(dovecot_incdir)/src/lib \ + -I$(dovecot_incdir)/src/lib-dict \ + -I$(dovecot_incdir)/src/lib-mail \ + -I$(dovecot_incdir)/src/lib-storage \ + -I$(dovecot_incdir)/src/deliver + +lda_moduledir = $(moduledir)/lda + +lib90_cmusieve_plugin_la_LDFLAGS = -module -avoid-version + +lda_module_LTLIBRARIES = \ + lib90_cmusieve_plugin.la + +lib90_cmusieve_plugin_la_LIBADD = \ + libsieve/libsieve.la + +lib90_cmusieve_plugin_la_SOURCES = \ + cmusieve-plugin.c \ + imparse.c \ + map.c \ + sieve-cmu.c + +noinst_HEADERS = \ + cmusieve-plugin.h \ + imparse.h \ + libconfig.h \ + map.h \ + xmalloc.h --- dovecot-1.0.15.orig/dovecot-sieve/src/imparse.h +++ dovecot-1.0.15/dovecot-sieve/src/imparse.h @@ -0,0 +1,6 @@ +#ifndef __IMPARSE_H +#define __IMPARSE_H + +extern int imparse_isatom (const char *s); + +#endif --- dovecot-1.0.15.orig/dovecot-sieve/src/cmusieve-plugin.c +++ dovecot-1.0.15/dovecot-sieve/src/cmusieve-plugin.c @@ -0,0 +1,87 @@ +/* Copyright (C) 2006 Timo Sirainen */ + +#include "lib.h" +#include "home-expand.h" +#include "deliver.h" +#include "cmusieve-plugin.h" + +#include +#include + +#define SIEVE_SCRIPT_PATH "~/.dovecot.sieve" + +static deliver_mail_func_t *next_deliver_mail; +struct et_list *_et_list = NULL; + +static const char *get_sieve_path(void) +{ + const char *script_path, *home; + struct stat st; + + home = getenv("HOME"); + + /* userdb may specify Sieve path */ + script_path = getenv("SIEVE"); + if (script_path != NULL) { + if (*script_path == '\0') { + /* disabled */ + return NULL; + } + script_path = home_expand(script_path); + + if (*script_path != '/' && *script_path != '\0') { + /* relative path. change to absolute. */ + script_path = t_strconcat(getenv("HOME"), "/", + script_path, NULL); + } + } else { + if (home == NULL) { + i_error("Per-user script path is unknown. See " + "http://wiki.dovecot.org/LDA/Sieve#location"); + return NULL; + } + + script_path = home_expand(SIEVE_SCRIPT_PATH); + } + + if (stat(script_path, &st) < 0) { + if (errno != ENOENT) + i_error("stat(%s) failed: %m", script_path); + + /* use global script instead, if one exists */ + script_path = getenv("SIEVE_GLOBAL_PATH"); + if (script_path == NULL) { + /* for backwards compatibility */ + script_path = getenv("GLOBAL_SCRIPT_PATH"); + } + } + + return script_path; +} + +static int +cmusieve_deliver_mail(struct mail_storage *storage, struct mail *mail, + const char *username, const char *mailbox) +{ + const char *script_path; + + script_path = get_sieve_path(); + if (script_path == NULL) + return 0; + + if (getenv("DEBUG") != NULL) + i_info("cmusieve: Using sieve path: %s", script_path); + + return cmu_sieve_run(storage, mail, script_path, username, mailbox); +} + +void cmusieve_plugin_init(void) +{ + next_deliver_mail = deliver_mail; + deliver_mail = cmusieve_deliver_mail; +} + +void cmusieve_plugin_deinit(void) +{ + deliver_mail = next_deliver_mail; +} --- dovecot-1.0.15.orig/dovecot-sieve/src/sieve-cmu.c +++ dovecot-1.0.15/dovecot-sieve/src/sieve-cmu.c @@ -0,0 +1,719 @@ +/* Copyright (C) 2005-2006 Timo Sirainen */ + +#include "lib.h" +#include "ioloop.h" +#include "array.h" +#include "hostpid.h" +#include "str.h" +#include "str-sanitize.h" +#include "write-full.h" +#include "message-date.h" +#include "mail-storage.h" +#include "deliver.h" +#include "duplicate.h" +#include "mail-send.h" +#include "smtp-client.h" +#include "libsieve/sieve_interface.h" +#include "cmusieve-plugin.h" + +#include +#include +#include +#include +#include + +/* data per script */ +typedef struct script_data { + const char *username; + struct mail_storage *storage; + string_t *errors; +} script_data_t; + +typedef struct { + struct mail *mail; + const char *mailbox; + const char *id; + const char *return_path; + const char *authuser; + + const char *temp[10]; +} sieve_msgdata_t; + +static const char *unfold_header(const char *str) +{ + char *new_str; + unsigned int i, j; + + for (i = 0; str[i] != '\0'; i++) { + if (str[i] == '\n') + break; + } + if (str[i] == '\0') + return str; + + /* @UNSAFE */ + new_str = t_malloc(i + strlen(str+i) + 1); + memcpy(new_str, str, i); + for (j = i; str[i] != '\0'; i++) { + if (str[i] == '\n') { + new_str[j++] = ' '; + i++; + i_assert(str[i] == ' ' || str[i] == '\t'); + } else { + new_str[j++] = str[i]; + } + } + new_str[j] = '\0'; + return new_str; +} + +static const char *const * +unfold_multiline_headers(const char *const *headers) +{ + const char **new_headers; + unsigned int i; + + /* see if there are any multiline headers */ + for (i = 0; headers[i] != NULL; i++) { + if (strchr(headers[i], '\n') != NULL) + break; + } + if (headers[i] == NULL) { + /* no multilines */ + return headers; + } + + /* @UNSAFE */ + for (; headers[i] != NULL; i++) ; + new_headers = t_new(const char *, i + 1); + for (i = 0; headers[i] != NULL; i++) + new_headers[i] = unfold_header(headers[i]); + return new_headers; +} + +/* gets the header "head" from msg. */ +static int getheader(void *v, const char *phead, const char ***body) +{ + sieve_msgdata_t *m = v; + const char *const *headers; + + if (phead==NULL) return SIEVE_FAIL; + headers = mail_get_headers(m->mail, phead); + if (headers != NULL) + headers = unfold_multiline_headers(headers); + *body = (const char **)headers; + + if (*body) { + return SIEVE_OK; + } else { + return SIEVE_FAIL; + } +} + +static int getsize(void *mc, int *size) +{ + sieve_msgdata_t *md = mc; + uoff_t psize; + + psize = mail_get_physical_size(md->mail); + if (psize == (uoff_t)-1) + return SIEVE_FAIL; + + *size = psize; + return SIEVE_OK; +} + +/* we use the temp field in message_data to avoid having to malloc memory + to return, and we also can't expose our the receipients to the message */ +static int getenvelope(void *mc, const char *field, const char ***contents) +{ + sieve_msgdata_t *m = (sieve_msgdata_t *) mc; + + if (!strcasecmp(field, "from")) { + if (m->return_path == NULL) { + /* invalid or missing return path */ + *contents = NULL; + return SIEVE_FAIL; + } + *contents = m->temp; + m->temp[0] = m->return_path; + m->temp[1] = NULL; + return SIEVE_OK; + } else if (!strcasecmp(field, "to")) { + *contents = m->temp; + m->temp[0] = /*FIXME:msg_getrcptall(m, m->cur_rcpt)*/m->authuser; + m->temp[1] = NULL; + return SIEVE_OK; + } else if (!strcasecmp(field, "auth") && m->authuser) { + *contents = m->temp; + m->temp[0] = m->authuser; + m->temp[1] = NULL; + return SIEVE_OK; + } else { + *contents = NULL; + return SIEVE_FAIL; + } +} + +static int sieve_redirect(void *ac, + void *ic __attr_unused__, + void *sc, void *mc, const char **errmsg) +{ + sieve_redirect_context_t *rc = (sieve_redirect_context_t *) ac; + script_data_t *sd = (script_data_t *) sc; + sieve_msgdata_t *m = mc; + const char *dupeid; + int res; + + /* if we have a msgid, we can track our redirects */ + dupeid = m->id == NULL ? NULL : t_strdup_printf("%s-%s", m->id, rc->addr); + if (dupeid != NULL) { + /* ok, let's see if we've redirected this message before */ + if (duplicate_check(dupeid, strlen(dupeid), sd->username)) { + /*duplicate_log(m->id, sd->username, "redirect");*/ + i_info("msgid=%s: discarded duplicate forward to <%s>", + str_sanitize(m->id, 80), str_sanitize(rc->addr, 80)); + return SIEVE_OK; + } + } + + if ((res = mail_send_forward(m->mail, rc->addr)) == 0) { + /* mark this message as redirected */ + i_info("msgid=%s: forwarded to <%s>", + m->id == NULL ? "" : str_sanitize(m->id, 80), + str_sanitize(rc->addr, 80)); + if (dupeid != NULL) { + duplicate_mark(dupeid, strlen(dupeid), sd->username, + ioloop_time + DUPLICATE_DEFAULT_KEEP); + } + return SIEVE_OK; + } else { + *errmsg = "Error sending mail"; + return SIEVE_FAIL; + } +} + +static int sieve_discard(void *ac __attr_unused__, + void *ic __attr_unused__, + void *sc __attr_unused__, void *mc, + const char **errmsg __attr_unused__) +{ + sieve_msgdata_t *md = mc; + + /* ok, we won't file it, but log it */ + i_info("msgid=%s: discarded", + md->id == NULL ? "" : str_sanitize(md->id, 80)); + return SIEVE_OK; +} + +static int sieve_reject(void *ac, + void *ic __attr_unused__, + void *sc, void *mc, const char **errmsg) +{ + sieve_reject_context_t *rc = (sieve_reject_context_t *) ac; + script_data_t *sd = (script_data_t *) sc; + sieve_msgdata_t *md = (sieve_msgdata_t *) mc; + int res; + + if (md->return_path == NULL) { + /* return message to who?!? */ + *errmsg = "No return-path for reply"; + return SIEVE_FAIL; + } + + if (strlen(md->return_path) == 0) { + i_info("msgid=%s: discarded reject to <>", + md->id == NULL ? "" : str_sanitize(md->id, 80)); + return SIEVE_OK; + } + + if ((res = mail_send_rejection(md->mail, sd->username, rc->msg)) == 0) { + i_info("msgid=%s: rejected", + md->id == NULL ? "" : str_sanitize(md->id, 80)); + return SIEVE_OK; + } else { + *errmsg = "Error sending mail"; + return SIEVE_FAIL; + } + return SIEVE_FAIL; +} + +static void get_flags(const sieve_imapflags_t *sieve_flags, + enum mail_flags *flags_r, const char *const **keywords_r) +{ + array_t ARRAY_DEFINE(keywords, const char *); + const char *name; + int i; + + *flags_r = 0; + + ARRAY_CREATE(&keywords, default_pool, const char *, 16); + for (i = 0; i < sieve_flags->nflags; i++) { + name = sieve_flags->flag[i]; + + if (name != NULL && *name != '\\') { + /* keyword */ + array_append(&keywords, &name, 1); + } else { + /* system flag */ + if (name == NULL || strcasecmp(name, "\\flagged") == 0) + *flags_r |= MAIL_FLAGGED; + else if (strcasecmp(name, "\\answered") == 0) + *flags_r |= MAIL_ANSWERED; + else if (strcasecmp(name, "\\deleted") == 0) + *flags_r |= MAIL_DELETED; + else if (strcasecmp(name, "\\seen") == 0) + *flags_r |= MAIL_SEEN; + else if (strcasecmp(name, "\\draft") == 0) + *flags_r |= MAIL_DRAFT; + } + } + + name = NULL; + array_append(&keywords, &name, 1); + + *keywords_r = array_count(&keywords) == 1 ? NULL : + array_get(&keywords, 0); +} + +static int sieve_fileinto(void *ac, + void *ic __attr_unused__, + void *sc, + void *mc, + const char **errmsg __attr_unused__) +{ + sieve_fileinto_context_t *fc = (sieve_fileinto_context_t *) ac; + script_data_t *sd = (script_data_t *) sc; + sieve_msgdata_t *md = (sieve_msgdata_t *) mc; + enum mail_flags flags; + const char *const *keywords; + + get_flags(fc->imapflags, &flags, &keywords); + + if (deliver_save(sd->storage, fc->mailbox, md->mail, flags, keywords) < 0) + return SIEVE_FAIL; + + return SIEVE_OK; +} + +static int sieve_keep(void *ac, + void *ic __attr_unused__, + void *sc, void *mc, const char **errmsg __attr_unused__) +{ + sieve_keep_context_t *kc = (sieve_keep_context_t *) ac; + script_data_t *sd = (script_data_t *) sc; + sieve_msgdata_t *md = (sieve_msgdata_t *) mc; + enum mail_flags flags; + const char *const *keywords; + + get_flags(kc->imapflags, &flags, &keywords); + + if (deliver_save(sd->storage, md->mailbox, md->mail, flags, keywords) < 0) + return SIEVE_FAIL; + + return SIEVE_OK; +} + +static bool contains_8bit(const char *msg) +{ + const unsigned char *s = (const unsigned char *)msg; + + for (; *s != '\0'; s++) { + if ((*s & 0x80) != 0) + return TRUE; + } + return FALSE; +} + +static int sieve_notify(void *ac, + void *ic __attr_unused__, + void *sc __attr_unused__, + void *mc, + const char **errmsg) +{ + sieve_notify_context_t *nc = (sieve_notify_context_t *) ac; + sieve_msgdata_t *m = mc; + + int nopt = 0; + FILE *f; + struct smtp_client *smtp_client; + const char *outmsgid; + + /* "default" is "mailto" as only one... */ + if (!strcasecmp(nc->method, "default")) nc->method = "mailto"; + /* check method */ + if (strcasecmp(nc->method, "mailto")) { + *errmsg = "Unknown [unimplemented] notify method"; + /* just log error, failed notify is not reason to abort all script. */ + i_info("SIEVE ERROR: Unknown [unimplemented] notify method <%s>", + nc->method); + return SIEVE_OK; + } + /* count options */ + while (nc->options[nopt]) { + smtp_client = smtp_client_open(nc->options[nopt], NULL, &f); + outmsgid = deliver_get_new_message_id(); + fprintf(f, "Message-ID: %s\r\n", outmsgid); + fprintf(f, "Date: %s\r\n", message_date_create(ioloop_time)); + fprintf(f, "X-Sieve: %s\r\n", SIEVE_VERSION); + if ( strcasecmp(nc->priority, "high") == 0 ) { + fprintf(f, "X-Priority: 1 (Highest)\r\n"); + fprintf(f, "Importance: High\r\n"); + } else if ( strcasecmp(nc->priority, "normal") == 0 ) { + fprintf(f, "X-Priority: 3 (Normal)\r\n"); + fprintf(f, "Importance: Normal\r\n"); + } else if ( strcasecmp(nc->priority, "low") == 0 ) { + fprintf(f, "X-Priority: 5 (Lowest)\r\n"); + fprintf(f, "Importance: Low\r\n"); + /* RFC: If no importance is given, the default value is "2 (Normal)" */ + } else { + fprintf(f, "X-Priority: 3 (Normal)\r\n"); + fprintf(f, "Importance: Normal\r\n"); + } + fprintf(f, "From: Postmaster <%s>\r\n", + deliver_set->postmaster_address); + fprintf(f, "To: <%s>\r\n", nc->options[nopt]); + fprintf(f, "Subject: [SIEVE] New mail notification\r\n"); + fprintf(f, "Auto-Submitted: auto-generated (notify)\r\n"); + fprintf(f, "Precedence: bulk\r\n"); + if (contains_8bit(nc->message)) { + fprintf(f, "MIME-Version: 1.0\r\n"); + fprintf(f, "Content-Type: text/plain; charset=UTF-8\r\n"); + fprintf(f, "Content-Transfer-Encoding: 8bit\r\n"); + } + fprintf(f, "\r\n"); + fprintf(f, "%s\r\n", nc->message); + if (smtp_client_close(smtp_client) == 0) { + i_info("msgid=%s: sent notification to <%s> (method=%s)", + m->id == NULL ? "" : str_sanitize(m->id, 80), + str_sanitize(nc->options[nopt], 80), nc->method); + } else { + i_info("msgid=%s: ERROR sending notification to <%s> " + "(method=%s)", + m->id == NULL ? "" : str_sanitize(m->id, 80), + str_sanitize(nc->options[nopt], 80), nc->method); + *errmsg = "Error sending notify mail"; + } + nopt = nopt + 1; + } + return SIEVE_OK; +} + +static int autorespond(void *ac, + void *ic __attr_unused__, + void *sc, + void *mc, + const char **errmsg __attr_unused__) +{ + sieve_autorespond_context_t *arc = (sieve_autorespond_context_t *) ac; + script_data_t *sd = (script_data_t *) sc; + sieve_msgdata_t *md = mc; + + /* ok, let's see if we've responded before */ + if (duplicate_check(arc->hash, arc->len, sd->username)) { + i_info("msgid=%s: discarded duplicate vacation response to <%s>", + md->id == NULL ? "" : str_sanitize(md->id, 80), + str_sanitize(md->return_path, 80)); + return SIEVE_DONE; + } + + duplicate_mark(arc->hash, arc->len, sd->username, + ioloop_time + arc->days * (24 * 60 * 60)); + + return SIEVE_OK; +} + +static int send_response(void *ac, + void *ic __attr_unused__, + void *sc, void *mc, + const char **errmsg) +{ + struct smtp_client *smtp_client; + FILE *f; + const char *outmsgid; + sieve_send_response_context_t *src = (sieve_send_response_context_t *) ac; + script_data_t *sdata = (script_data_t *) sc; + sieve_msgdata_t *md = mc; + + smtp_client = smtp_client_open(src->addr, NULL, &f); + + outmsgid = deliver_get_new_message_id(); + fprintf(f, "Message-ID: %s\r\n", outmsgid); + fprintf(f, "Date: %s\r\n", message_date_create(ioloop_time)); + + fprintf(f, "X-Sieve: %s\r\n", SIEVE_VERSION); + fprintf(f, "From: <%s>\r\n", src->fromaddr); + fprintf(f, "To: <%s>\r\n", src->addr); + fprintf(f, "Subject: %s\r\n", str_sanitize(src->subj, 80)); + if (md->id) fprintf(f, "In-Reply-To: %s\r\n", md->id); + fprintf(f, "Auto-Submitted: auto-replied (vacation)\r\n"); + fprintf(f, "Precedence: bulk\r\n"); + fprintf(f, "MIME-Version: 1.0\r\n"); + if (src->mime) { + fprintf(f, "Content-Type: multipart/mixed;" + "\r\n\tboundary=\"%s/%s\"\r\n", my_pid, deliver_set->hostname); + fprintf(f, "\r\nThis is a MIME-encapsulated message\r\n\r\n"); + fprintf(f, "--%s/%s\r\n", my_pid, deliver_set->hostname); + } else { + fprintf(f, "Content-Type: text/plain; charset=utf-8\r\n"); + fprintf(f, "Content-Transfer-Encoding: 8bit\r\n"); + fprintf(f, "\r\n"); + } + + fprintf(f, "%s\r\n", src->msg); + if (src->mime) + fprintf(f, "\r\n--%s/%s--\r\n", my_pid, deliver_set->hostname); + + if (smtp_client_close(smtp_client) == 0) { + duplicate_mark(outmsgid, strlen(outmsgid), + sdata->username, ioloop_time + DUPLICATE_DEFAULT_KEEP); + i_info("msgid=%s: sent vacation response to <%s>", + md->id == NULL ? "" : str_sanitize(md->id, 80), + str_sanitize(md->return_path, 80)); + return SIEVE_OK; + } else { + *errmsg = "Error sending mail"; + return SIEVE_FAIL; + } +} + +/* vacation support */ +sieve_vacation_t vacation = { + 1, /* min response */ + 31, /* max response */ + &autorespond, /* autorespond() */ + &send_response /* send_response() */ +}; + +/* imapflags support */ +static char *markflags[] = { "\\flagged" }; +static sieve_imapflags_t mark = { markflags, 1 }; + +static int sieve_parse_error_handler(int lineno, const char *msg, + void *ic __attr_unused__, + void *sc) +{ + script_data_t *sd = (script_data_t *) sc; + + if (sd->errors == NULL) { + sd->errors = str_new(default_pool, 1024); + i_info("sieve parse error: line %d: %s", lineno, msg); + } + + str_printfa(sd->errors, "line %d: %s\n", lineno, msg); + return SIEVE_OK; +} + +static int sieve_execute_error_handler(const char *msg, + void *ic __attr_unused__, + void *sc __attr_unused__, + void *mc __attr_unused__) +{ + i_info("sieve runtime error: %s", msg); + return SIEVE_OK; +} + +static sieve_interp_t *setup_sieve(void) +{ + sieve_interp_t *interp = NULL; + int res; + + res = sieve_interp_alloc(&interp, NULL); + if (res != SIEVE_OK) + i_fatal("sieve_interp_alloc() returns %d\n", res); + + res = sieve_register_redirect(interp, &sieve_redirect); + if (res != SIEVE_OK) + i_fatal("sieve_register_redirect() returns %d\n", res); + res = sieve_register_discard(interp, &sieve_discard); + if (res != SIEVE_OK) + i_fatal("sieve_register_discard() returns %d\n", res); + res = sieve_register_reject(interp, &sieve_reject); + if (res != SIEVE_OK) + i_fatal("sieve_register_reject() returns %d\n", res); + res = sieve_register_fileinto(interp, &sieve_fileinto); + if (res != SIEVE_OK) + i_fatal("sieve_register_fileinto() returns %d\n", res); + res = sieve_register_keep(interp, &sieve_keep); + if (res != SIEVE_OK) + i_fatal("sieve_register_keep() returns %d\n", res); + res = sieve_register_imapflags(interp, &mark); + if (res != SIEVE_OK) + i_fatal("sieve_register_imapflags() returns %d\n", res); + res = sieve_register_notify(interp, &sieve_notify); + if (res != SIEVE_OK) + i_fatal("sieve_register_notify() returns %d\n", res); + res = sieve_register_size(interp, &getsize); + if (res != SIEVE_OK) + i_fatal("sieve_register_size() returns %d\n", res); + res = sieve_register_header(interp, &getheader); + if (res != SIEVE_OK) + i_fatal("sieve_register_header() returns %d\n", res); + + res = sieve_register_envelope(interp, &getenvelope); + if (res != SIEVE_OK) + i_fatal("sieve_register_envelope() returns %d\n", res); + res = sieve_register_vacation(interp, &vacation); + if (res != SIEVE_OK) + i_fatal("sieve_register_vacation() returns %d\n", res); + res = sieve_register_parse_error(interp, &sieve_parse_error_handler); + if (res != SIEVE_OK) + i_fatal("sieve_register_parse_error() returns %d\n", res); + res = sieve_register_execute_error(interp, &sieve_execute_error_handler); + if (res != SIEVE_OK) + i_fatal("sieve_register_execute_error() returns %d\n", res); + + return interp; +} + +static int +dovecot_sieve_compile(sieve_interp_t *interp, script_data_t *sdata, + const char *script_path, const char *compiled_path) +{ + struct stat st, st2; + sieve_script_t *script; + bytecode_info_t *bc; + const char *temp_path; + FILE *f; + int fd, ret; + + if (stat(script_path, &st) < 0) { + if (errno == ENOENT) { + if (getenv("DEBUG") != NULL) { + i_info("cmusieve: Script not found: %s", + script_path); + } + return 0; + } + i_error("stat(%s) failed: %m", script_path); + return -1; + } + if (stat(compiled_path, &st2) < 0) { + if (errno != ENOENT) { + i_error("stat(%s) failed: %m", script_path); + return -1; + } + } else { + if (st.st_mtime <= st2.st_mtime) + return 1; + } + + /* need to compile */ + f = fopen(script_path, "r"); + if (f == NULL) { + i_error("fopen(%s) failed: %m", script_path); + return -1; + } + + ret = sieve_script_parse(interp, f, sdata, &script); + if (ret != SIEVE_OK) { + if (sdata->errors == NULL) { + sdata->errors = str_new(default_pool, 128); + str_printfa(sdata->errors, "parse error %d", ret); + } + return -1; + } + + if (sieve_generate_bytecode(&bc, script) < 0) { + i_error("sieve_generate_bytecode() failed"); + return -1; + } + + /* write to temp file */ + temp_path = t_strconcat(compiled_path, ".tmp", NULL); + fd = open(temp_path, O_CREAT | O_TRUNC | O_WRONLY, 0600); + if(fd == -1) { + i_error("open(%s) failed: %m", temp_path); + return -1; + } + + if (sieve_emit_bytecode(fd, bc) < 0) { + i_error("sieve_emit_bytecode() failed"); + return -1; + } + + if (close(fd) < 0) + i_error("close() failed: %m"); + + /* and finally replace the script */ + if (rename(temp_path, compiled_path) < 0) { + i_error("rename(%s, %s) failed: %m", temp_path, compiled_path); + return -1; + } + return 1; +} + +static void +dovecot_sieve_write_error_file(script_data_t *sdata, const char *path) +{ + int fd; + + fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, 0600); + if (fd == -1) { + i_error("open(%s) failed: %m", path); + return; + } + + if (write_full(fd, str_data(sdata->errors), str_len(sdata->errors)) < 0) + i_error("write_full(%s) failed: %m", path); + + if (close(fd) < 0) + i_error("close() failed: %m"); +} + +int cmu_sieve_run(struct mail_storage *storage, struct mail *mail, + const char *script_path, const char *username, + const char *mailbox) +{ + sieve_interp_t *interp; + sieve_bytecode_t *bytecode; + script_data_t sdata; + sieve_msgdata_t mdata; + const char *compiled_path, *path; + int ret; + + interp = setup_sieve(); + + memset(&sdata, 0, sizeof(sdata)); + sdata.username = username; + sdata.storage = storage; + + compiled_path = t_strconcat(script_path, "c", NULL); + ret = dovecot_sieve_compile(interp, &sdata, script_path, compiled_path); + + if (sdata.errors != NULL) { + if (getenv("DEBUG") != NULL) { + i_info("cmusieve: Compilation failed for %s: %s", + script_path, + str_sanitize(str_c(sdata.errors), 80)); + } + path = t_strconcat(script_path, ".err", NULL); + dovecot_sieve_write_error_file(&sdata, path); + str_free(&sdata.errors); + } + if (ret <= 0) + return ret; + + memset(&mdata, 0, sizeof(mdata)); + mdata.mail = mail; + mdata.mailbox = mailbox; + mdata.authuser = username; + mdata.id = mail_get_first_header(mail, "Message-ID"); + mdata.return_path = deliver_get_return_address(mail); + + if ((ret = sieve_script_load(compiled_path, &bytecode)) != SIEVE_OK) { + i_error("sieve_script_load(%s) failed: %d", compiled_path, ret); + return -1; + } + + if (getenv("DEBUG") != NULL) + i_info("cmusieve: Executing script %s", compiled_path); + + if (sieve_execute_bytecode(bytecode, interp, + &sdata, &mdata) != SIEVE_OK) { + i_error("sieve_execute_bytecode(%s) failed", compiled_path); + return -1; + } + + return 1; +} --- dovecot-1.0.15.orig/dovecot-sieve/src/xmalloc.h +++ dovecot-1.0.15/dovecot-sieve/src/xmalloc.h @@ -0,0 +1,26 @@ +#ifndef __XMALLOC_H +#define __XMALLOC_H + +#include +#include + +#define xmalloc(n) malloc(n) +#define xrealloc(n, m) realloc(n, m) +#define xzmalloc(n) calloc(n, 1) +#define xstrdup(s) strdup(s) + +/* missing headers.. */ +#include +#include +#include +#include + +/* dovecot kludges */ +#include "lib.h" + +/* we don't have strlcpy, but strocpy is the same except for return value */ +#define strlcpy strocpy + +#define lcase str_lcase + +#endif --- dovecot-1.0.15.orig/dovecot-sieve/src/imparse.c +++ dovecot-1.0.15/dovecot-sieve/src/imparse.c @@ -0,0 +1,57 @@ +/* + * Copyright (c) 1998-2003 Carnegie Mellon University. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The name "Carnegie Mellon University" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For permission or any other legal + * details, please contact + * Office of Technology Transfer + * Carnegie Mellon University + * 5000 Forbes Avenue + * Pittsburgh, PA 15213-3890 + * (412) 268-4387, fax: (412) 268-7395 + * tech-transfer@andrew.cmu.edu + * + * 4. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by Computing Services + * at Carnegie Mellon University (http://www.cmu.edu/computing/)." + * + * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE + * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * + */ +#include "imparse.h" + +int imparse_isatom(const char *s) +{ + int len = 0; + + if (!*s) return 0; + for (; *s; s++) { + len++; + if (*s & 0x80 || *s < 0x1f || *s == 0x7f || + *s == ' ' || *s == '{' || *s == '(' || *s == ')' || + *s == '\"' || *s == '%' || *s == '*' || *s == '\\') return 0; + } + if (len >= 1024) return 0; + return 1; +} --- dovecot-1.0.15.orig/dovecot-sieve/src/cmusieve-plugin.h +++ dovecot-1.0.15/dovecot-sieve/src/cmusieve-plugin.h @@ -0,0 +1,11 @@ +#ifndef __CMUSIEVE_PLUGIN_H +#define __CMUSIEVE_PLUGIN_H + +int cmu_sieve_run(struct mail_storage *storage, struct mail *mail, + const char *script_path, const char *username, + const char *mailbox); + +void cmusieve_plugin_init(void); +void cmusieve_plugin_deinit(void); + +#endif --- dovecot-1.0.15.orig/dovecot-sieve/src/libconfig.h +++ dovecot-1.0.15/dovecot-sieve/src/libconfig.h @@ -0,0 +1,8 @@ +#ifndef __LIBCONFIG_H +#define __LIBCONFIG_H + +#define IMAPOPT_RFC3028_STRICT 1 + +#define config_getswitch(n) 1 + +#endif --- dovecot-1.0.15.orig/dovecot-sieve/src/map.h +++ dovecot-1.0.15/dovecot-sieve/src/map.h @@ -0,0 +1,10 @@ +#ifndef __MAP_H +#define __MAP_H + +extern void map_refresh(int fd, int onceonly, const char **base, + unsigned long *len, unsigned long newlen, + const char *name, const char *mboxname); + +extern void map_free(const char **base, unsigned long *len); + +#endif --- dovecot-1.0.15.orig/dovecot-sieve/src/map.c +++ dovecot-1.0.15/dovecot-sieve/src/map.c @@ -0,0 +1,55 @@ +#include "lib.h" +#include "map.h" + +#include + +static ssize_t read_full_n(int fd, void *data, size_t size) +{ + ssize_t ret, all_ret = 0; + + while (size > 0) { + ret = read(fd, data, size); + if (ret <= 0) + return ret; + + data = PTR_OFFSET(data, ret); + all_ret += ret; + size -= ret; + } + + return all_ret; +} + +void map_refresh(int fd, int onceonly __attr_unused__, const char **base, + unsigned long *len, unsigned long newlen, + const char *name, const char *mboxname __attr_unused__) +{ + ssize_t ret; + void *p; + + if (newlen == 0) { + /* the file is a broken zero-byte file */ + *len = 0; + return; + } + + *base = p = i_malloc(newlen); + *len = newlen; + + ret = read_full_n(fd, p, newlen); + if (ret < 0) { + i_error("read_full_n(%s) failed: %m", name); + ret = 0; + } + + *len = ret; +} + +void map_free(const char **base, unsigned long *len __attr_unused__) +{ + char *x = (char *) *base; + + i_free(x); + *base = NULL; +} + --- dovecot-1.0.15.orig/dovecot-sieve/src/libsieve/comparator.c +++ dovecot-1.0.15/dovecot-sieve/src/libsieve/comparator.c @@ -0,0 +1,448 @@ +/* comparator.c -- comparator functions + * Larry Greenfield + * $Id$ + */ +/*********************************************************** + Copyright 1999 by Carnegie Mellon University + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Carnegie Mellon +University not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior +permission. + +CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO +THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE FOR +ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT +OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +******************************************************************/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include + +#include "xmalloc.h" +#include "comparator.h" +#include "tree.h" +#include "sieve.h" +#include "bytecode.h" + +/*!!! uses B_CONTAINS not CONTAINS, etc, only works with bytecode*/ + +extern int strcasecmp(const char *, const char *); + +typedef int (*compare_t)(const void *, const void *); + +/* --- relational comparators --- */ + +/* these are generic wrappers in which 'rock' is the compare function */ + +static int rel_eq(const char *text, const char *pat, void *rock) +{ + compare_t compar = (compare_t) rock; + + return (compar(text, pat) == 0); +} + +static int rel_ne(const char *text, const char *pat, void *rock) +{ + compare_t compar = (compare_t) rock; + + return (compar(text, pat) != 0); +} + +static int rel_gt(const char *text, const char *pat, void *rock) +{ + compare_t compar = (compare_t) rock; + + return (compar(text, pat) > 0); +} + +static int rel_ge(const char *text, const char *pat, void *rock) +{ + compare_t compar = (compare_t) rock; + + return (compar(text, pat) >= 0); +} + +static int rel_lt(const char *text, const char *pat, void *rock) +{ + compare_t compar = (compare_t) rock; + + return (compar(text, pat) < 0); +} + +static int rel_le(const char *text, const char *pat, void *rock) +{ + compare_t compar = (compare_t) rock; + + return (compar(text, pat) <= 0); +} + +/* --- i;octet comparators --- */ + +/* just compare the two; these should be NULL terminated */ +static int octet_cmp(const char *text, const char *pat) +{ + size_t sl; + int r; + + sl = strlen(text) < strlen(pat) ? strlen(text) : strlen(pat); + + r = memcmp(text, pat, sl); + + if (r == 0) + return (strlen(text) - strlen(pat)); + else + return r; +} + +/* we implement boyer-moore for hell of it, since this is probably + not very useful for sieve */ +#if 0 +int boyer_moore(char *text, char *pat) +{ + int i, j; /* indexes */ + int M = strlen(pat); /* length of pattern */ + int N = strlen(text); /* length of text */ + int skip[256]; /* table of how much to skip, based on each character */ + + /* initialize skip table */ + for (i = 0; i < 256; i++) + skip[i] = M; + for (i = 0; i < M; i++) + skip[(int) pat[i]] = M-i-1; + + /* look for pat in text */ + i = j = M-1; + do { + if (pat[j] == text[i]) { + i--; + j--; + } else { + if (M-j > skip[(int) text[i]]) { + i = i + M - j; + } else { + i = i + skip[(int) text[i]]; + } + j = M-1; + } + } while (!((j < 0) || (i >= N))); + /* i+1 is the position of the match if i < N */ + return (i < N) ? 1 : 0; +} +#endif + +/* we do a brute force attack */ +static int octet_contains(const char *text, const char *pat, + void *rock __attr_unused__) +{ + return (strstr(text, pat) != NULL); +} + +static int octet_matches_(const char *text, const char *pat, int casemap) +{ + const char *p; + const char *t; + char c; + + t = text; + p = pat; + for (;;) { + if (*p == '\0') { + /* ran out of pattern */ + return (*t == '\0'); + } + c = *p++; + switch (c) { + case '?': + if (*t == '\0') { + return 0; + } + t++; + break; + case '*': + while (*p == '*' || *p == '?') { + if (*p == '?') { + /* eat the character now */ + if (*t == '\0') { + return 0; + } + t++; + } + /* coalesce into a single wildcard */ + p++; + } + if (*p == '\0') { + /* wildcard at end of string, any remaining text is ok */ + return 1; + } + + while (*t != '\0') { + /* recurse */ + if (octet_matches_(t, p, casemap)) return 1; + t++; + } + case '\\': + p++; + /* falls through */ + default: + if (casemap && (toupper(c) == toupper(*t))) { + t++; + } else if (!casemap && (c == *t)) { + t++; + } else { + /* literal char doesn't match */ + return 0; + } + } + } + /* never reaches */ + abort(); +} + +static int octet_matches(const char *text, const char *pat, + void *rock __attr_unused__) +{ + return octet_matches_(text, pat, 0); +} + + +#ifdef ENABLE_REGEX +static int octet_regex(const char *text, const char *pat, + void *rock __attr_unused__) +{ + return (!regexec((regex_t *) pat, text, 0, NULL, 0)); +} +#endif + + +/* --- i;ascii-casemap comparators --- */ + + +/* use strcasecmp() as the compare function */ + +/* sheer brute force */ +static int ascii_casemap_contains(const char *text, const char *pat, + void *rock __attr_unused__) +{ + int N = strlen(text); + int M = strlen(pat); + int i, j; + + i = 0, j = 0; + while ((j < M) && (i < N)) { + if (toupper(text[i]) == toupper(pat[j])) { + i++; j++; + } else { + i = i - j + 1; + j = 0; + } + } + + return (j == M); /* we found a match! */ +} + +static int ascii_casemap_matches(const char *text, const char *pat, + void *rock __attr_unused__) +{ + return octet_matches_(text, pat, 1); +} + +/* i;ascii-numeric; only supports relational tests + * + * A \ B number not-num + * number A ? B B > A + * not-num A > B A == B + */ + + /* From RFC 2244: + * + * The i;ascii-numeric comparator interprets strings as decimal + * positive integers represented as US-ASCII digits. All values + * which do not begin with a US-ASCII digit are considered equal + * with an ordinal value higher than all non-NIL single-valued + * attributes. Otherwise, all US-ASCII digits (octet values + * 0x30 to 0x39) are interpreted starting from the beginning of + * the string to the first non-digit or the end of the string. + */ + +static int ascii_numeric_cmp(const char *text, const char *pat) +{ + unsigned text_digit_len; + unsigned pat_digit_len; + + if (isdigit((int) *pat)) { + if (isdigit((int) *text)) { + /* Count how many digits each string has */ + for (text_digit_len = 0; + isdigit((int) text[text_digit_len]); + text_digit_len++); + for (pat_digit_len = 0; + isdigit((int) pat[pat_digit_len]); + pat_digit_len++); + + if (text_digit_len < pat_digit_len) { + /* Pad "text" with leading 0s */ + while (pat_digit_len > text_digit_len) { + /* "text" can only be less or equal to "pat" */ + if ('0' < *pat) { + return (-1); + } + pat++; + pat_digit_len--; + } + } else if (text_digit_len > pat_digit_len) { + /* Pad "pad" with leading 0s */ + while (text_digit_len > pat_digit_len) { + /* "pad" can only be greater or equal to "text" */ + if (*text > '0') { + return 1; + } + text++; + text_digit_len--; + } + } + + /* CLAIM: If we here, we have two non-empty digital suffixes + of equal length */ + while (text_digit_len > 0) { + if (*text < *pat) { + return -1; + } else if (*text > *pat) { + return 1; + } + /* Characters are equal, carry on */ + text++; + pat++; + text_digit_len--; + } + + return (0); + } else { + return 1; + } + } else if (isdigit((int) *text)) { + return -1; + } else { + return 0; /* both not digits */ + } +} + +static comparator_t *lookup_rel(int relation) +{ + comparator_t *ret; + + ret = NULL; + switch (relation) + { + case B_EQ: + ret = &rel_eq; + break; + case B_NE: + ret = &rel_ne; + break; + case B_GT: + ret = &rel_gt; + break; + case B_GE: + ret = &rel_ge; + break; + case B_LT: + ret = &rel_lt; + break; + case B_LE: + ret = &rel_le; + } + + return ret; +} + +comparator_t *lookup_comp(int comp, int mode, int relation, + void **comprock) +{ + comparator_t *ret; + + ret = NULL; + *comprock = NULL; +#if VERBOSE + printf("comp%d mode%d relat%d \n", comp, mode, relation); +#endif + switch (comp) + { + case B_OCTET: + switch (mode) { + case B_IS: + ret = &rel_eq; + *comprock = (void **) &octet_cmp; + break; + case B_CONTAINS: + ret = &octet_contains; + break; + case B_MATCHES: + ret = &octet_matches; + break; +#ifdef ENABLE_REGEX + case B_REGEX: + ret = &octet_regex; + break; +#endif + case B_VALUE: + ret = lookup_rel(relation); + *comprock = (void **) &octet_cmp; + break; + } + break; /*end of octet */ + case B_ASCIICASEMAP: + switch (mode) { + case B_IS: + ret = &rel_eq; + *comprock = (void **) &strcasecmp; + break; + case B_CONTAINS: + ret = &ascii_casemap_contains; + break; + case B_MATCHES: + ret = &ascii_casemap_matches; + break; +#ifdef ENABLE_REGEX + case B_REGEX: + /* the ascii-casemap destinction is made during + the compilation of the regex in verify_regex() */ + ret = &octet_regex; + break; +#endif + case B_VALUE: + ret = lookup_rel(relation); + *comprock = &strcasecmp; + break; + } + break;/*end of ascii casemap */ + case B_ASCIINUMERIC: + switch (mode) { + case B_IS: + ret = &rel_eq; + *comprock = (void **) &ascii_numeric_cmp; + break; + case B_COUNT: + case B_VALUE: + ret = lookup_rel(relation); + *comprock = (void **) &ascii_numeric_cmp; + break; + } + break; + } + return ret; +} --- dovecot-1.0.15.orig/dovecot-sieve/src/libsieve/parseaddr.h +++ dovecot-1.0.15/dovecot-sieve/src/libsieve/parseaddr.h @@ -0,0 +1,69 @@ +/* parseaddr.h -- RFC 822 address parser + $Id$ + + * Copyright (c) 1998-2003 Carnegie Mellon University. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The name "Carnegie Mellon University" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For permission or any other legal + * details, please contact + * Office of Technology Transfer + * Carnegie Mellon University + * 5000 Forbes Avenue + * Pittsburgh, PA 15213-3890 + * (412) 268-4387, fax: (412) 268-7395 + * tech-transfer@andrew.cmu.edu + * + * 4. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by Computing Services + * at Carnegie Mellon University (http://www.cmu.edu/computing/)." + * + * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE + * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * + */ + +#ifndef INCLUDED_PARSEADDR_H +#define INCLUDED_PARSEADDR_H + +#ifndef P +#ifdef __STDC__ +#define P(x) x +#else +#define P(x) () +#endif +#endif + +struct address { + char *name; + char *route; + char *mailbox; + char *domain; + struct address *next; + char *freeme; /* If non-nil, free */ +}; + +extern void parseaddr_list P((const char *s, struct address **addrp)); +extern void parseaddr_free P((struct address *addr)); + + +#endif /* INCLUDED_PARSEADDR_H */ --- dovecot-1.0.15.orig/dovecot-sieve/src/libsieve/Makefile.am +++ dovecot-1.0.15/dovecot-sieve/src/libsieve/Makefile.am @@ -0,0 +1,80 @@ +pkglibexecdir = $(libexecdir)/dovecot + +noinst_LTLIBRARIES = libsieve.la + +AM_YFLAGS = -d -p $* + +AM_CPPFLAGS = \ + -I$(dovecot_incdir) \ + -I$(dovecot_incdir)/src/lib \ + -I$(top_srcdir)/src + +addr-lex.c: addr-lex.l + $(LEX) -t -Paddr addr-lex.l > addr-lex.c + +sieve-lex.c: sieve-lex.l + $(LEX) -t sieve-lex.l > sieve-lex.c + +libsieve_la_SOURCES = \ + addr.y \ + sieve.y \ + addr-lex.l \ + sieve-lex.l \ + bc_dump.c \ + bc_emit.c \ + bc_eval.c \ + bc_generate.c \ + comparator.c \ + interp.c \ + message.c \ + parseaddr.c \ + script.c \ + sieve_err.c \ + tree.c + +noinst_HEADERS = \ + addr.h \ + bytecode.h \ + comparator.h \ + interp.h \ + message.h \ + parseaddr.h \ + script.h \ + sieve.h \ + sieve_err.h \ + sieve_interface.h \ + tree.h + +if HAVE_DOVECOT_LIBS +pkglibexec_PROGRAMS = sievec sieved + +sievec_SOURCES = \ + sievec.c \ + ../map.c \ + ../imparse.c + +sieved_SOURCES = \ + sieved.c \ + ../map.c + +sievec_LDADD = \ + libsieve.la \ + $(dovecotdir)/src/lib/liblib.a + +sieved_LDADD = \ + libsieve.la \ + $(dovecotdir)/src/lib/liblib.a + +notbuilt_sources = +else +notbuilt_sources = sievec.c sieved.c +endif + +EXTRA_DIST = \ + addr-lex.l \ + sieve-lex.l \ + AUTHORS \ + COPYING \ + NEWS \ + README \ + $(notbuilt_sources) --- dovecot-1.0.15.orig/dovecot-sieve/src/libsieve/script.h +++ dovecot-1.0.15/dovecot-sieve/src/libsieve/script.h @@ -0,0 +1,74 @@ +/* script.h -- script definition + * Larry Greenfield + * $Id$ + */ +/*********************************************************** + Copyright 1999 by Carnegie Mellon University + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Carnegie Mellon +University not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior +permission. + +CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO +THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE FOR +ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT +OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +******************************************************************/ + +#ifndef SIEVE_SCRIPT_H +#define SIEVE_SCRIPT_H + +#include "sieve_interface.h" +#include "interp.h" +#include "tree.h" + +#define ADDRERR_SIZE 500 + +struct sieve_script { + sieve_interp_t interp; + + /* was a "require" done for these? */ + struct sieve_support { + int fileinto : 1; + int reject : 1; + int envelope : 1; + int vacation : 1; + int imapflags : 1; + int notify : 1; + int regex : 1; + int subaddress : 1; + int relational : 1; + int i_ascii_numeric: 1; + } support; + + void *script_context; + commandlist_t *cmds; + + int err; +}; + +struct sieve_bytecode +{ + sieve_interp_t *interp; + void *script_context; + + const char *data; + unsigned long len; + int fd; +}; + +/* generated by the yacc script */ +commandlist_t *sieve_parse(sieve_script_t *script, FILE *f); +int script_require(sieve_script_t *s, char *req); + +#endif --- dovecot-1.0.15.orig/dovecot-sieve/src/libsieve/comparator.h +++ dovecot-1.0.15/dovecot-sieve/src/libsieve/comparator.h @@ -0,0 +1,48 @@ +/* comparator.h + * Larry Greenfield + * $Id$ + */ +/*********************************************************** + Copyright 1999 by Carnegie Mellon University + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Carnegie Mellon +University not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior +permission. + +CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO +THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE FOR +ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT +OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +******************************************************************/ + +#ifndef COMPARATOR_H +#define COMPARATOR_H + +#ifdef ENABLE_REGEX +#ifdef HAVE_RX +#include +#else +#include +#include +#endif +#endif + +/* compares pat to text; returns 1 if it's true, 0 otherwise + first arg is text, second arg is pat, third arg is rock */ +typedef int comparator_t(const char *, const char *, void *); + +/* returns a pointer to a comparator function given it's name */ +comparator_t *lookup_comp(int comp, int mode, + int relation, void **rock); + +#endif --- dovecot-1.0.15.orig/dovecot-sieve/src/libsieve/README +++ dovecot-1.0.15/dovecot-sieve/src/libsieve/README @@ -0,0 +1,59 @@ +$Id$ + +CMU Sieve 2.1 +------------- + +This code is typically distributed as part of Cyrus imapd 1.6 and higher. +This code will be configured and compiled from the cyrus-imapd directory. + +Notes on implementation +----------------------- + +This is an implementation of a simple Sieve API. This API is +well-suited for incorporating in other programs, but is not +extensible. (If there is interest, we may implement an extensible API +in the future.) + +If you wish to compile Sieve without compiling all of imapd, you'll +have to create a Makefile for it. I recommend you use Makefile.in as +a guide. + +It should compile without libcyrus, but then it does not implement the +"address" test. That's just too much work to do when I have a neato +library to do it for me. + +There's a simple "test" application included, which is not built by +default (type "make test" to build it). It expects: + +test