diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e594810 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.rpm +*.log +*spec-20* +*.tar.xz diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..95f28a1 --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +# Makefile for source rpm: e-smith-qmail +# $Id: Makefile,v 1.1 2016/02/05 21:46:43 stephdl Exp $ +NAME := e-smith-qmail +SPECFILE = $(firstword $(wildcard *.spec)) + +define find-makefile-common +for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done +endef + +MAKEFILE_COMMON := $(shell $(find-makefile-common)) + +ifeq ($(MAKEFILE_COMMON),) +# attept a checkout +define checkout-makefile-common +test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2 +endef + +MAKEFILE_COMMON := $(shell $(checkout-makefile-common)) +endif + +include $(MAKEFILE_COMMON) diff --git a/README.md b/README.md index b29f350..c1977bd 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,17 @@ -# e-smith-qmail +# e-smith-qmail -SMEServer Koozali developed git repo for e-smith-qmail smeserver \ No newline at end of file +SMEServer Koozali developed git repo for e-smith-qmail smeserver + +## Wiki +
https://wiki.koozali.org/ + +## Bugzilla +Show list of outstanding bugs: [here](https://bugs.koozali.org/buglist.cgi?component=e-smith-qmail&product=SME%20Server%2010.X&query_format=advanced&limit=0&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=CONFIRMED) + +## Description + +
*This description has been generated by an LLM AI system and cannot be relied on to be fully correct.* +*Once it has been checked, then this comment will be deleted* +
+ +E-smith-qmail is an open source email server software designed to facilitate email communication for small- and medium-sized businesses. It is highly customizable, with support for multiple domains, virtual domains, forwarding, aliases, and mailing lists, and its features can be adapted to meet the specific communication needs of any organization. With its straightforward web-based administration interface, e-smith-qmail can be easily configured for optimal security and performance. Additionally, its advanced spam filtering technology helps to ensure that email communication remains safe and secure for both senders and recipients. diff --git a/additional/COPYING b/additional/COPYING new file mode 100644 index 0000000..eeb586b --- /dev/null +++ b/additional/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 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. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, 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 or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +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 give any other recipients of the Program a copy of this License +along with the Program. + +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 Program or any portion +of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +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 Program, 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 Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) 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; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, 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 executable. However, as a +special exception, the source code 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. + +If distribution of executable or 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 counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program 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. + + 5. 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 Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program 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 to +this License. + + 7. 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 Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program 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 Program. + +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. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program 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. + + 9. The Free Software Foundation may publish revised and/or new versions +of the 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 Program +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 Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, 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 + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "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 PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. 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 PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. 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) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; 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. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/contriborbase b/contriborbase new file mode 100644 index 0000000..ef36a67 --- /dev/null +++ b/contriborbase @@ -0,0 +1 @@ +sme10 diff --git a/createlinks b/createlinks new file mode 100755 index 0000000..87d3764 --- /dev/null +++ b/createlinks @@ -0,0 +1,239 @@ +#!/usr/bin/perl -w + +use esmith::Build::CreateLinks qw(:all); +use File::Basename; +use File::Path; + +# email-conf - console-save, bootstrap-console-save, domain-create, domain-delete, +# ip-change, email-update, host-create, host-delete, host-modify, post-upgrade + + +foreach (qw( + bouncefrom + bouncehost + concurrencylocal + concurrencyremote + databytes + defaultdomain + defaulthost + doublebounceto + envnoathost + helohost + locals + me + plusdomain + rcpthosts + smtproutes + virtualdomains + )) +{ + templates2events("/var/qmail/control/$_", qw( + console-save + bootstrap-console-save + domain-create + domain-delete + ip-change + email-update + host-create + host-delete + host-modify + post-upgrade + e-smith-qmail-update + )); +} + +foreach (qw( + /var/qmail/alias/.qmail-default + /var/qmail/alias/.qmail-localdelivery-default + )) +{ + templates2events($_, qw( + console-save + bootstrap-console-save + domain-create + domain-delete + ip-change + email-update + host-create + host-delete + host-modify + post-upgrade + e-smith-qmail-update + )); +} + +templates2events("/var/qmail/alias/.qmail-shared" , qw(bootstrap-console-save user-create user-modify user-delete)); + +#-------------------------------------------------- +# actions for console-save event: +# write config files and create startup link +#-------------------------------------------------- +$event = "console-save"; + +# If qmail-send is running, it will receive the SIGHUP and ignore the +# start command. If it is not running then the signal will be ignored +# and qmail-send will read its new configuration files anyway. + +safe_symlink("sighup", "root/etc/e-smith/events/$event/services2adjust/qmail"); + +#-------------------------------------------------- +# actions for bootstrap-console-save event: +# write config files and create startup link +#-------------------------------------------------- +$event = "bootstrap-console-save"; + +event_link("pseudonym-cleanup", $event, "03"); +event_link("qmail-update-group", $event, "20"); +event_link("qmail-update-user", $event, "55"); +templates2events("/var/qmail/users/assign", $event); +safe_symlink("/var/qmail/bin/qmail-newu", "root/etc/e-smith/events/$event/S55email-assign"); + +#-------------------------------------------------- +# actions for domain-create event: +# rewrite config files and restart server +#-------------------------------------------------- +$event = "domain-create"; + +# If qmail-send is running, it will receive the SIGHUP and ignore the +# start command. If it is not running then the signal will be ignored +# and qmail-send will read its new configuration files anyway. + +safe_symlink("sighup", "root/etc/e-smith/events/$event/services2adjust/qmail"); + +#-------------------------------------------------- +# actions for domain-delete event: +# rewrite config files and restart server +#-------------------------------------------------- +$event = "domain-delete"; + + +# If qmail-send is running, it will receive the SIGHUP and ignore the +# start command. If it is not running then the signal will be ignored +# and qmail-send will read its new configuration files anyway. + +safe_symlink("sighup", "root/etc/e-smith/events/$event/services2adjust/qmail"); + +#-------------------------------------------------- +# actions for email-update event: +# email parameters have been changed in the e-smith +# manager; update system security, rewrite email config +# files, configure other system files (crontab is the +# important one), and restart server +#-------------------------------------------------- +$event = "email-update"; + +event_link("qmail-update-user", $event, "03"); +event_link("pseudonym-cleanup", $event, "30"); + +# If qmail-send is running, it will receive the SIGHUP and ignore the +# start command. If it is not running then the signal will be ignored +# and qmail-send will read its new configuration files anyway. + +safe_symlink("sighup", "root/etc/e-smith/events/$event/services2adjust/qmail"); +safe_symlink("adjust", "root/etc/e-smith/events/$event/services2adjust/masq"); +safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/smtp-auth-proxy"); + +#-------------------------------------------------- +# actions for group-create event: +#-------------------------------------------------- +$event = "group-create"; + +event_link("pseudonym-cleanup", $event, "03"); +event_link("qmail-update-group", $event, "20"); +templates2events("/var/qmail/users/assign", $event); +safe_symlink("/var/qmail/bin/qmail-newu", "root/etc/e-smith/events/$event/S55email-assign"); +safe_symlink("sighup", "root/etc/e-smith/events/$event/services2adjust/qmail"); + +#-------------------------------------------------- +# actions for group-delete event: +#-------------------------------------------------- +$event = "group-delete"; + +event_link("pseudonym-cleanup", $event, "03"); +event_link("qmail-delete-group", $event, "20"); +templates2events("/var/qmail/users/assign", $event); +safe_symlink("/var/qmail/bin/qmail-newu", "root/etc/e-smith/events/$event/S55email-assign"); +safe_symlink("sighup", "root/etc/e-smith/events/$event/services2adjust/qmail"); + +#-------------------------------------------------- +# actions for group-modify event: +#-------------------------------------------------- +$event = "group-modify"; + +event_link("pseudonym-cleanup", $event, "03"); +event_link("qmail-update-group", $event, "20"); +templates2events("/var/qmail/users/assign", $event); +safe_symlink("/var/qmail/bin/qmail-newu", "root/etc/e-smith/events/$event/S55email-assign"); +safe_symlink("sighup", "root/etc/e-smith/events/$event/services2adjust/qmail"); + +#-------------------------------------------------- +# actions for user-create event: +#-------------------------------------------------- +$event = "user-create"; + +event_link("qmail-update-user", $event, "20"); +event_link("qmail-update-group", $event, "20"); + +#-------------------------------------------------- +# actions for user-modify event +#-------------------------------------------------- +$event = "user-modify"; + +event_link("qmail-update-user", $event, "20"); +event_link("qmail-update-group", $event, "20"); + +#-------------------------------------------------- +# actions for user-modify-admin event +#-------------------------------------------------- +$event = "user-modify-admin"; + +event_link("qmail-update-user", $event, "20"); + +#-------------------------------------------------- +# actions for user-delete event +#-------------------------------------------------- +$event = "user-delete"; + +event_link("qmail-update-group", $event, "25"); + +#-------------------------------------------------- +# actions for ip-up event: +#-------------------------------------------------- +$event = "ip-up"; + +event_link("qmail-ipup", $event, "20"); + +#-------------------------------------------------- +# actions for ip-change event: +#-------------------------------------------------- +$event = "ip-change"; + +safe_symlink("sighup", "root/etc/e-smith/events/$event/services2adjust/qmail"); + +#-------------------------------------------------- +# actions for e-smith-qmail-update event: +#-------------------------------------------------- +$event = "e-smith-qmail-update"; + +safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/qmail"); +event_link("systemd-reload", $event, "89"); +event_link("systemd-default", $event, "88"); +event_link("pseudonym-cleanup", $event, "03"); + +#-------------------------------------------------- +# actions for pseudonym-{create,delete,modify} +#-------------------------------------------------- +foreach $event ( qw(pseudonym-create pseudonym-modify pseudonym-delete + user-create user-modify user-delete + )) +{ + event_link("pseudonym-cleanup", $event, "03"); + templates2events("/var/qmail/control/virtualdomains", $event); + templates2events("/var/qmail/users/assign", $event); + safe_symlink("/var/qmail/bin/qmail-newu", "root/etc/e-smith/events/$event/S55email-assign"); + safe_symlink("sighup", "root/etc/e-smith/events/$event/services2adjust/qmail"); +} + +safe_symlink(".qmail", "root/home/e-smith/.qmail-default"); +safe_symlink(".qmail-shared", "root/var/qmail/alias/.qmail-shared-default"); + diff --git a/e-smith-qmail.spec b/e-smith-qmail.spec new file mode 100644 index 0000000..3b251bf --- /dev/null +++ b/e-smith-qmail.spec @@ -0,0 +1,431 @@ +# $Id: e-smith-qmail.spec,v 1.17 2022/04/06 04:38:59 jpp Exp $ + +Summary: startup scripts for Dan Bernstein's qmail package +%define name e-smith-qmail +Name: %{name} +%define version 2.6.0 +%define release 15 +Version: %{version} +Release: %{release}%{?dist} +License: GPL +Group: Networking/Daemons +Source: %{name}-%{version}.tar.xz + +BuildRoot: /var/tmp/%{name}-%{version}-%{release}-buildroot +BuildRequires: e-smith-devtools >= 1.13.0-04 +BuildArchitectures: noarch +Requires: qmail +Requires: dot-forward +Requires: fastforward +Requires: runit +Requires: e-smith-email +Requires: qmail >= 1.03-17 +Provides: e-smith-mta +Conflicts: runit < 1.7 +Obsoletes: qmail-initscripts +Obsoletes: qmail-workaround +AutoReqProv: no + +%changelog +* Wed Jul 12 2023 cvs2git.sh aka Brian Read 2.6.0-15.sme +- Roll up patches and move to git repo [SME: 12338] + +* Wed Jul 12 2023 BogusDateBot +- Eliminated rpmbuild "bogus date" warnings due to inconsistent weekday, + by assuming the date is correct and changing the weekday. + +* Tue Apr 05 2022 Jean-Philippe Pialasse 2.6.0-14.sme +- fix multiple errors with pseudonyms in template [SME: 8591] + orphaned pseudonyms are associated to admin +- repopulate qmail assign db and sighup qmail on group event [SME: 11934] + +* Mon Nov 15 2021 Jean-Philippe Pialasse 2.6.0-13.sme +- can set to 0 ConcurrencyLocal or ConcurrencyRemote [SME: 11645] + this allows to disable of type of delivery + +* Thu Dec 10 2020 Michel Begue 2.6.0-12.sme +- add Requires=runit.service [SME: 11245] + +* Sun Dec 06 2020 Jean-Philipe Pialasse 2.6.0-11.sme +- fix missing actions for systemd on upgrade event [SME: 11105] + cleanup preset file + +* Fri Dec 04 2020 Jean-Philipe Pialasse 2.6.0-10.sme +- remove qmail link in init.d and whole rc.d [SME: 11105] + take 3 + +* Fri Dec 04 2020 Jean-Philipe Pialasse 2.6.0-9.sme +- remove qmail link in init.d [SME: 11105] + +* Thu Dec 03 2020 Jean-Philipe Pialasse 2.6.0-7.sme +- execute systemd-reload before service adjust in events [SME: 11228] +- remove S95reset-unsavedflag [SME: 11229] + +* Thu Nov 19 2020 Michel Begue 2.6.0-6.sme +- remove rc7.d link [SME: 11105] +- fix actions in e-smith-qmail-update [SME: 11152] + +* Sat Nov 14 2020 Michel Begue 2.6.0-5.sme +- Move qmail service to systemd [SME: 11105] +- Create e-smith-qmail-update event [SME: 11152] + +* Thu Jul 20 2017 Daniel Berteaud 2.6.0-4.sme +- Update aliases files for every groups passed as argument [SME: 10386] + +* Tue May 31 2016 Daniel Berteaud 2.6.0-3.sme +- Add possibility to exclude users or members of other groups from group + email address [SME: 9523] + +* Fri Apr 22 2016 Daniel Berteaud 2.6.0-2.sme +- Merge smtpd entry into qpsmtpd, same for ssmtpd into sqpsmtpd [SME: 9478] + +* Fri Feb 05 2016 stephane de Labrusse 2.6.0-1.sme +- Initial release to sme10 + +* Fri Jul 5 2013 Ian Wells 2.4.0-6.sme +- Simplify qmail concurrency templates [SME: 7750] + +* Thu May 23 2013 chris burnat 2.4.0-5.sme +- Modify domain style pseudonym pointing to user with dot in name, by Filippo Carletti [SME: 7614] + +* Wed May 15 2013 chris burnat 2.4.0-4.sme +- Reverse change in Template Qmail MaxMessageSize [SME: 7393] + +* Fri May 03 2013 chris burnat 2.4.0-3.sme +- Reverse Allow groups with dots [SME 6694] and modify domain style pseudonyms to point to the correct user, by Filippo Carletti [SME: 7572] + +* Thu Feb 21 2013 Ian Wells 2.4.0-2.sme +- Template Qmail MaxMessageSize [SME: 7393] + +* Wed Feb 6 2013 Shad L. Lords 2.4.0-1.sme +- Roll new stream for sme9 + +* Sun Jan 15 2012 Ian Wells 2.2.0-6.sme +- Allow groups with dots, by Filippo Carletti [SME: 6694] + +* Thu Oct 14 2010 Daniel Berteaud 2.2.0-5.sme +- Read number of log files to keep from the DB [SME: 5855] + +* Sat Sep 05 2009 Gavin Weight 2.2.0-4 +- SMTPSmartHost template incorrectly uses brackets to avoid MX lookups. [SME: 5456] + +* Mon May 18 2009 Gavin Weight 2.2.0-3 +- smtproutes template incorrectly uses brackets to avoid MX lookups. [SME: 5257] + +* Tue May 12 2009 Filippo Carletti 2.2.0-2 +- Remove qmail-workaround and obsolete it after patch to treat 0.0.0.0 as a + local ip [SME: 5171] + +* Tue Oct 7 2008 Shad L. Lords 2.2.0-1.sme +- Roll new stream to separate sme7/sme8 trees [SME: 4633] + +* Wed Apr 2 2008 Shad L. Lords 1.10.0-16 +- Create tcpto lockfile in run script [SME: 3055] + +* Wed Jan 09 2008 Stephen Noble 1.10.0-15 +- Domain catchall Redirection to Account [SME:1922] + +* Thu Sep 6 2007 Charlie Brady +- Apply a code tidyup patch from Gordon. [SME: 871] + +* Sun Apr 29 2007 Shad L. Lords +- Clean up spec so package can be built by koji/plague + +* Fri Apr 06 2007 Shad L. Lords 1.10.0-13 +- Change ownership/perms on /var/qmail/alias directory [SME: 2709] + +* Thu Feb 15 2007 Charlie Brady +- Use sv rather than deprecated runsvctrl in ip-up script. [SME: 2486] + +* Mon Jan 22 2007 Shad L. Lords 1.10.0-11 +- Allow admin user to be configured via users panel. [SME: 827] + +* Thu Dec 07 2006 Shad L. Lords +- Update to new release naming. No functional changes. +- Make Packager generic + +* Fri Aug 25 2006 Gordon Rowell 1.10.0-10 +- Force creation of junkmail folder as some users like to delete + it [SME: 1130] + +* Mon Aug 14 2006 Gordon Rowell 1.10.0-09 +- Allow optional EveryoneEmail property of user and 'admin' accounts + If set to 'no', do not include this user in the shared/everyone + email alias [SME: 1842] + +* Thu Aug 3 2006 Gordon Rowell 1.10.0-08 +- Allow optional $smtpd{HeloHost} value for configuring HELO host, + defaulting to $DomainName [SME: 1790] + +* Thu Jun 22 2006 Gordon Rowell 1.10.0-07 +- Default qmail{MaxMessageSize} to 15,000,000 bytes [SME: 1624] + +* Mon May 15 2006 Gordon Rowell 1.10.0-06 +- Bump version only [SME: 1415] + +* Wed May 10 2006 Gordon Rowell 1.10.0-05sme01 +- Allow optional MailServer property of domains db records and + deliver mail in this order of preference: + - As per the MailServer property of the domain + - $DelegateMailServer + - localhost (i.e. locally) + NOTE: + - If DelegateMailServer is not set, the users must exist on the + gateway or mail will be rejected + - If DelegateMailServer is set, all mail for the domain will be + forwarded to the relevant internal mail server [SME: 1253] + +* Wed May 10 2006 Gordon Rowell 1.10.0-04sme01 +- Remove virtualdomains entries for hosts db entries. We only + handle mail for domains without customisation [SME: 1415] + +* Sat Apr 8 2006 Charlie Brady 1.10.0-03 +- Update group .qmail files when deleting/modifying users. [SME: 1200] + +* Thu Mar 23 2006 Charlie Brady 1.10.0-02 +- Use shared library to block 0.0.0.0 MX mail loops. [SME: 1116] + +* Tue Mar 14 2006 Charlie Brady 1.10.0-01 +- Roll stable stream version. [SME: 1016] + +* Fri Mar 03 2006 Charlie Brady 1.9.1-05 +- Add ~alias/.qmail-shared-default symlink. [SME: 764] + +* Thu Feb 16 2006 Charlie Brady 1.9.1-04 +- Fix migration when AdminEmail is not set. [SME: 818] + +* Thu Feb 16 2006 Charlie Brady 1.9.1-03 +- Use standard user .qmail template for admin user. Migrate + AdminEmail setting to $admin{ForwardAddress}. [SME: 818] + +* Tue Jan 24 2006 Charlie Brady 1.9.1-02 +- Fix duplicate symlink creation attempt in bootstrap-console-save + directory (during RPM build). [SME: 555] + +* Wed Jan 11 2006 Gordon Rowell 1.9.1-01 +- Roll patches to 1.9.0-16 +- Change ~alias/.qmail{default,localdelivery-default,shared} into + directory templates [SME: 440] + +* Wed Nov 30 2005 Gordon Rowell 1.9.0-16 +- Bump release number only + +* Tue Nov 22 2005 Charlie Brady +- [1.9.0-15] +- Fix broken symlink in group-delete event. Delete -default .qmail file + when deleting group. [SF: 1363973] + +* Tue Nov 1 2005 Charlie Brady +- [1.9.0-14] +- Improve /var/qmail/users/assign/70pseudonyms error handling. [SF: 1337029] +- Fix error text from 60users template fragment. [SF: 1345206] + +* Fri Oct 21 2005 Gordon Rowell +- [1.9.0-13] +- Add quotes around 'Recipient unknown' when calling bouncesaying. + Otherwise we're trying to call a program called 'unknown' [SF: 1334002] + +* Wed Oct 19 2005 Charlie Brady +- [1.9.0-12] +- Ensure failsafe .qmail file if EmailForward property is not set. + [SF: 1330452] + +* Fri Oct 7 2005 Charlie Brady +- [1.9.0-11] +- Expand virtualdomains in pseudonym-* events. Replace use of control/1 + by generic actions, plus qmail-newu symlinked into event directories. + [SF: 1311349] + +* Mon Sep 26 2005 Gordon Rowell +- [1.9.0-10] +- Split up templates-user/.qmail into fragments which return + one or zero lines. It's much cleaner and helps with add-ons. + Move .qmail/20Forward -> 70Forward to leave more room for + add-ons [SF: 1252336] +- Minor fixups - thanks Stephen Noble [SF: 1252336] +- TODO: Remove the 10Filter stuff and migrate + qmail{DeliveryInstruction} and qmail{DeliveryType} + +* Mon Sep 19 2005 Gordon Rowell +- [1.9.0-09] +- Correct /var/qmail/users/assign/50system fragment so that + mail for system accounts is delivered to admin [SF: 1284311] + +* Tue Sep 13 2005 Gordon Rowell +- [1.9.0-08] +- Add extension address handling for pseudonyms and groups. + [SF: 1286823] + +* Mon Aug 22 2005 Charlie Brady +- [1.9.0-07] +- Make correct /service symlink, so that a runit finds the + run files. [SF: 1264668] + +* Wed Aug 10 2005 Shad Lords +- [1.9.0-06] +- Add empty template-begin header for users/assign +- Add requires for e-smith-email +- Add provides e-smith-mta + +* Tue Aug 9 2005 Charlie Brady +- [1.9.0-05] +- Add in all qmail specific code from e-smith-email. [SF: 1255261] + +* Wed Dec 29 2004 Charlie Brady +- [1.9.0-04] +- Remove dangling conf-migrate-* symlink [charlieb MN00062545] + +* Tue Dec 28 2004 Charlie Brady +- [1.9.0-03] +- Remove no longer needed conf-migrate-* action [charlieb MN00062545] +- Replace deprecated Copyright header with License header. + +* Thu Feb 12 2004 Michael Soulier +- [1.9.0-02] +- Updating with esmith::Build::CreateLinks, and the new genfilelist options. +- Yanked migrate-qmail-logfiles, as it was causing problems. + [msoulier dpar-20522] + +* Fri Feb 6 2004 Michael Soulier +- [1.9.0-01] +- rolling to dev - 1.9.0 + +* Thu Aug 28 2003 Michael Soulier +- [1.8.0-02] +- Adding K* init symlinks in runlevels 0, 1 and 6. [msoulier 9761] + +* Thu Jun 26 2003 Charlie Brady +- [1.8.0-01] +- Changing version to stable stream number - 1.8.0 + +* Wed Nov 6 2002 Charlie Brady +- [1.7.0-01] +- Rolling development stream version to 1.7.0 + +* Fri Oct 11 2002 Charlie Brady +- [1.6.0-01] +- Roll to maintained version number to 1.6.0 + +* Fri Oct 11 2002 Charlie Brady +- [1.6.0-01] +- Roll to maintained version number to 1.6.0 + +* Wed Aug 21 2002 Charlie Brady +- [1.5.1-01] +- Remove bogus e-smith-base dependency, which shows as an unmet + dependency on our workstations. +- Add rc7.d symlink [charlieb 4458] + +* Wed Jun 5 2002 Charlie Brady +- [1.5.0-01] +- Changing version to development stream number to 1.5.0 + +* Fri May 31 2002 Charlie Brady +- [1.4.0-01] +- Changing version to maintained stream number to 1.4.0 + +* Thu May 23 2002 Gordon Rowell +- [1.3.9-01] +- RPM rebuild forced by cvsroot2rpm + +* Thu May 23 2002 Gordon Rowell +- [1.3.8-01] +- testing co2rpm --force + +* Thu May 23 2002 Charlie Brady +- [1.3.7-01] +- Remove world read and execute permission from qmail log directory. + +* Thu Apr 18 2002 Gordon Rowell +- [1.3.6-01] +- /supervise/qmail -> /service/qmail [gordonr 3044] + +* Thu Apr 18 2002 Gordon Rowell +- [1.3.5-01] +- Added /bin, /usr/bin and /usr/local/bin to qmail's path [gordonr 3044] + +* Thu Apr 18 2002 Gordon Rowell +- [1.3.4-01] +- And create /var/log/qmail [gordonr 3044] + +* Thu Apr 18 2002 Gordon Rowell +- [1.3.3-01] +- And create directory for pipes to be written to [gordonr 3044] + +* Thu Apr 18 2002 Gordon Rowell +- [1.3.2-01] +- Created pipes, symlinks and empty files in SPEC file [gordonr 3044] + +* Thu Apr 18 2002 Gordon Rowell +- [1.3.1-01] +- Initial CVS import + +* Thu Apr 18 2002 Gordon Rowell +- [1.3.0-01] +- rollRPM: Rolled version number to 1.3.0-01. Includes patches up to 1.2.0-02. + +* Fri Aug 17 2001 gordonr +- [1.2.0-02] +- Autorebuild by rebuildRPM + +* Wed Aug 8 2001 Charlie Brady +- [1.2.0-01] +- Rolled version number to 1.2.0-01. Includes patches upto 1.1.0-04. + +* Tue May 1 2001 Peter Samuel +- [1.1.0-04] +- added /var/log/qmail to filelist + +* Tue May 1 2001 Peter Samuel +- [1.1.0-03] +- added migrate-qmail-logfiles action to post-upgrade + +* Mon Apr 30 2001 Peter Samuel +- [1.1.0-02] +- added conf-migrate-qmail-variables actions to migrate qmail.init + configuration variable to qmail +- added e-smith header to files + +* Mon Apr 30 2001 Peter Samuel +- [1.1.0-01] +- initial release + +%description +Startup scripts for Dan Bernstein's qmail package. + +%prep +%setup +rm -rf root/etc/rc.d +rm -rf root/usr/lib/systemd/system-preset + +%build +perl createlinks + +%install +rm -rf $RPM_BUILD_ROOT +(cd root ; find . -depth -print | cpio -dump $RPM_BUILD_ROOT) +rm -f %{name}-%{version}-%{release}-filelist +/sbin/e-smith/genfilelist $RPM_BUILD_ROOT \ + --dir '/var/service/qmail' 'attr(1755,root,root)' \ + --file '/var/service/qmail/down' 'attr(0644,root,root)' \ + --file '/var/service/qmail/run' 'attr(0755,root,root)' \ + --file '/var/service/qmail/control/1' 'attr(0750,root,root)' \ + --dir '/var/service/qmail/supervise' 'attr(0700,root,root)' \ + --dir '/var/service/qmail/log' 'attr(0755,root,root)' \ + --file '/var/service/qmail/log/run' 'attr(0755,root,root)' \ + --dir '/var/service/qmail/log/supervise' 'attr(0700,root,root)' \ + --dir '/var/log/qmail' 'attr(2750,qmaill,nofiles)' \ + --dir '/var/qmail/alias' 'attr(2755,alias,qmail)' \ + > %{name}-%{version}-%{release}-filelist +echo "%doc COPYING" >> %{name}-%{version}-%{release}-filelist + +%clean +rm -rf $RPM_BUILD_ROOT + +%pre +%preun +%post +%postun + +%files -f %{name}-%{version}-%{release}-filelist +%defattr(-,root,root) diff --git a/root/etc/e-smith/db/accounts/migrate/10AdminEmail b/root/etc/e-smith/db/accounts/migrate/10AdminEmail new file mode 100644 index 0000000..84a9c84 --- /dev/null +++ b/root/etc/e-smith/db/accounts/migrate/10AdminEmail @@ -0,0 +1,24 @@ +{ + my $conf = esmith::ConfigDB->open; + return unless $conf; + + my $admin_email = $conf->get_value_and_delete('AdminEmail'); + return unless defined $admin_email; + + my $admin = $DB->get('admin') || + $DB->new_record('admin', {type => 'system'}); + if ($admin_email) + { + $admin->merge_props( + EmailForward => 'forward', + ForwardAddress => $admin_email, + ); + } + else + { + $admin->merge_props( + EmailForward => 'local', + ForwardAddress => '', + ); + } +} diff --git a/root/etc/e-smith/db/configuration/defaults/qmail/MaxMessageSize b/root/etc/e-smith/db/configuration/defaults/qmail/MaxMessageSize new file mode 100644 index 0000000..a4511c3 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/qmail/MaxMessageSize @@ -0,0 +1 @@ +15000000 diff --git a/root/etc/e-smith/db/configuration/defaults/qmail/status b/root/etc/e-smith/db/configuration/defaults/qmail/status new file mode 100644 index 0000000..86981e6 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/qmail/status @@ -0,0 +1 @@ +enabled diff --git a/root/etc/e-smith/db/configuration/defaults/qmail/type b/root/etc/e-smith/db/configuration/defaults/qmail/type new file mode 100644 index 0000000..24e1098 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/qmail/type @@ -0,0 +1 @@ +service diff --git a/root/etc/e-smith/events/actions/pseudonym-cleanup b/root/etc/e-smith/events/actions/pseudonym-cleanup new file mode 100644 index 0000000..c25c9d3 --- /dev/null +++ b/root/etc/e-smith/events/actions/pseudonym-cleanup @@ -0,0 +1,22 @@ +#!/usr/bin/perl -w + +use strict; +use esmith::AccountsDB; +use esmith::event; + +my $accounts = esmith::AccountsDB->open() or + die "Unable to open accounts db: $!"; + +my ($self, $account) = @ARGV; + +# Find all "pseudonyms" entries in the e-smith accounts database and +# if the pseudonyms has an unexisting Account associated we change +# it to user "admin". + +foreach my $pseudo ( $accounts->pseudonyms ) { + unless ( $accounts->get($pseudo->prop('Account')) ) { + $pseudo->set_prop( 'Account', 'admin' ); + print "orphaned pseudonym " . $pseudo->key. " has been associated to admin account" + } +} + diff --git a/root/etc/e-smith/events/actions/qmail-delete-group b/root/etc/e-smith/events/actions/qmail-delete-group new file mode 100644 index 0000000..0c2aa0d --- /dev/null +++ b/root/etc/e-smith/events/actions/qmail-delete-group @@ -0,0 +1,36 @@ +#!/usr/bin/perl -w + +#---------------------------------------------------------------------- +# copyright (C) 1999-2005 MItel Networks Corporation +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +#---------------------------------------------------------------------- + +package esmith; + +use strict; +use Errno; + +my $event = $ARGV [0]; +my $groupName = $ARGV [1]; + +die "Groupname argument missing." unless defined ($groupName); + +$groupName =~ s/\./:/g; +unlink "/var/qmail/alias/.qmail-$groupName"; +unlink "/var/qmail/alias/.qmail-$groupName-default"; + +exit (0); diff --git a/root/etc/e-smith/events/actions/qmail-ipup b/root/etc/e-smith/events/actions/qmail-ipup new file mode 100644 index 0000000..ebcc1fd --- /dev/null +++ b/root/etc/e-smith/events/actions/qmail-ipup @@ -0,0 +1,26 @@ +#!/bin/sh + +#---------------------------------------------------------------------- +# copyright (C) 2001-2006 Mitel Networks Corporation +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +#---------------------------------------------------------------------- +#------------------------------------------------------------ +# Reset qmail TCP timeouts, and tell qmail-send to retry sending +#------------------------------------------------------------ + +/var/qmail/bin/qmail-tcpok +exec sv alarm /service/qmail diff --git a/root/etc/e-smith/events/actions/qmail-update-group b/root/etc/e-smith/events/actions/qmail-update-group new file mode 100644 index 0000000..2853906 --- /dev/null +++ b/root/etc/e-smith/events/actions/qmail-update-group @@ -0,0 +1,112 @@ +#!/usr/bin/perl -w + +#---------------------------------------------------------------------- +# copyright (C) 2002-2006 Mitel Networks Corporation +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +#---------------------------------------------------------------------- + +package esmith; + +use strict; +use Errno; +use esmith::ConfigDB; +use esmith::AccountsDB; +use esmith::util; + +my $c = esmith::ConfigDB->open_ro || die "Couldn't open config db\n"; +my $a = esmith::AccountsDB->open_ro || die "Couldn't open accounts db\n"; + +my $event = $ARGV [0] || die "Event name arg missing\n";; +my @groups; + +if (scalar @ARGV) +{ + @groups = map { $a->get($_); } @ARGV; + foreach my $g (@groups) + { + my $type = $g->prop('type'); + if ($type =~ /^user/) + { + # That's fine. We were probably just called from the user-delete + # event, in which case we want to update all of the groups. So, leave + # the groups array empty. + @groups = (); + last; + } + elsif ($type !~ /^group/){ + die "Expected a user or a group. Got neither: $type\n"; + } + } +} + +# Regenerate all the groups if the previous block failed in some way. +unless (@groups) +{ + @groups = $a->groups; +} + +foreach my $group (@groups) +{ + my $groupName = $group->key; + unless ($group->prop('type') eq 'group') + { + warn "Account $groupName is not a group account.\n"; + next; + } + my %properties = $group->props; + $groupName =~ s/\./:/g; + my $group = "/var/qmail/alias/.qmail-$groupName"; + my @group_members = split(/,/, $properties{Members}); + # Check if we should exclude members from this group email address + my @exclude_users = split(/,/, ($properties{EmailExcludeUsers} || '')); + my @exclude_groups = split(/,/, ($properties{EmailExcludeGroups} || '')); + foreach my $exclude_group (@exclude_groups){ + my $g = $a->get($exclude_group); + next unless $g; + push @exclude_users, split(/,/, ($g->prop('Members') || '')); + } + my %exclude = map { $_, 1 } @exclude_users; + @exclude_users = keys %exclude; + my @members = (); + foreach my $user (@group_members){ + next if grep { $_ eq $user } @exclude_users; + push @members, $user; + } + my $members = join(',', @members); + + esmith::util::processTemplate( + { + CONFREF => + { + Members => $members, + }, + + TEMPLATE_PATH => + "/var/qmail/alias/.qmail-group", + + OUTPUT_FILENAME => "/var/qmail/alias/.qmail-$groupName", + } + ); + + unless (-f "/var/qmail/alias/.qmail-$groupName-default") + { + symlink "/var/qmail/alias/.qmail-$groupName", + "/var/qmail/alias/.qmail-$groupName-default"; + } + +} +exit (0); diff --git a/root/etc/e-smith/events/actions/qmail-update-user b/root/etc/e-smith/events/actions/qmail-update-user new file mode 100644 index 0000000..e70f9cf --- /dev/null +++ b/root/etc/e-smith/events/actions/qmail-update-user @@ -0,0 +1,84 @@ +#!/usr/bin/perl -w + +#---------------------------------------------------------------------- +# copyright (C) 1999-2005 Mitel Networks Corporation +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +#---------------------------------------------------------------------- + +package esmith; + +use strict; +use Errno; +use esmith::ConfigDB; +use esmith::AccountsDB; +use esmith::templates; +use User::pwent; + + +my $accountsdb = esmith::AccountsDB->open_ro or + die "Could not open accounts db\n"; + +my $event = shift; +my $userName = shift; +my @users; + +if (defined $userName) +{ + my $user = $accountsdb->get($userName); + die + "Account $userName is not a user account; update email forwarding failed.\n" + unless $userName eq 'admin' || ($user && $user->prop('type') eq "user"); + @users = ($user); +} +else +{ + @users = ( $accountsdb->users, $accountsdb->get('admin') ); +} + +foreach my $user (@users) +{ + my $userName = $user->key; + + setpwent(); + my $home = getpwnam($userName)->dir; + for my $dotfile ( qw(.qmail .qmail-junkmail) ) + { + esmith::templates::processTemplate ( + { + MORE_DATA => + { + USERNAME => $userName , + }, + TEMPLATE_PATH => "/$dotfile", + TEMPLATE_EXPAND_QUEUE => + [ + "/etc/e-smith/templates-user-custom", + "/etc/e-smith/templates-user", + ], + OUTPUT_PREFIX => "$home", + UID => $userName, + GID => $userName, + PERMS => 0644, + } ); + }; + unless (-f "$home/.qmail-default") + { + symlink ".qmail", "$home/.qmail-default"; + } +} + +exit (0); diff --git a/root/etc/e-smith/templates-user/.qmail-junkmail/10deliver_to_junkmail b/root/etc/e-smith/templates-user/.qmail-junkmail/10deliver_to_junkmail new file mode 100644 index 0000000..9d7d795 --- /dev/null +++ b/root/etc/e-smith/templates-user/.qmail-junkmail/10deliver_to_junkmail @@ -0,0 +1,2 @@ +| [ -d ./Maildir/.junkmail/ ] || /var/qmail/bin/maildirmake ./Maildir/.junkmail/ +./Maildir/.junkmail/ diff --git a/root/etc/e-smith/templates-user/.qmail/00setup b/root/etc/e-smith/templates-user/.qmail/00setup new file mode 100644 index 0000000..119fcd3 --- /dev/null +++ b/root/etc/e-smith/templates-user/.qmail/00setup @@ -0,0 +1,14 @@ +{ + # vim: ft=perl: + die "USERNAME not set." unless defined ($USERNAME); + + use esmith::AccountsDB; + $adb = esmith::AccountsDB->open_ro or die "Couldn't open AccountsDB"; + + $user = $adb->get($USERNAME) or die "No user $USERNAME in AccountsDB"; + + %props = $user->props; + $props{EmailForward} ||= 'local'; + + $OUT = ''; +} diff --git a/root/etc/e-smith/templates-user/.qmail/10Filter b/root/etc/e-smith/templates-user/.qmail/10Filter new file mode 100644 index 0000000..9734f11 --- /dev/null +++ b/root/etc/e-smith/templates-user/.qmail/10Filter @@ -0,0 +1,20 @@ +{ + # vim: ft=perl: + $OUT = ''; + + $props{Filter} ||= 'yes'; + + return '# Filter property is no' + unless ($props{Filter} eq 'yes'); + + my $preprocessing = ""; + my $dt = $qmail{DeliveryType} || ''; + + if ($dt eq 'program') + { + $preprocessing .= '| '; + } + $preprocessing .= $qmail{DeliveryInstruction} || ''; + + $OUT = "$preprocessing\n" if $preprocessing; +} diff --git a/root/etc/e-smith/templates-user/.qmail/70Forward b/root/etc/e-smith/templates-user/.qmail/70Forward new file mode 100644 index 0000000..2e9ac93 --- /dev/null +++ b/root/etc/e-smith/templates-user/.qmail/70Forward @@ -0,0 +1,7 @@ +{ + # vim: ft=perl: + return '# Forward not set' + unless ($props{EmailForward} =~ /^(forward|both)$/); + + return '&' . $props{ForwardAddress}; +} diff --git a/root/etc/e-smith/templates-user/.qmail/90local b/root/etc/e-smith/templates-user/.qmail/90local new file mode 100644 index 0000000..5d43fa3 --- /dev/null +++ b/root/etc/e-smith/templates-user/.qmail/90local @@ -0,0 +1,7 @@ +{ + # vim: ft=perl: + return '# No local delivery' + unless ($props{EmailForward} =~ /^(local|both)$/); + + return './Maildir/'; +} diff --git a/root/etc/e-smith/templates.metadata/home/e-smith/.qmail b/root/etc/e-smith/templates.metadata/home/e-smith/.qmail new file mode 100644 index 0000000..1d723ad --- /dev/null +++ b/root/etc/e-smith/templates.metadata/home/e-smith/.qmail @@ -0,0 +1,3 @@ +UID="admin" +GID="admin" +PERMS=0640 diff --git a/root/etc/e-smith/templates.metadata/var/qmail/alias/.qmail-localdelivery-default b/root/etc/e-smith/templates.metadata/var/qmail/alias/.qmail-localdelivery-default new file mode 100644 index 0000000..0efc650 --- /dev/null +++ b/root/etc/e-smith/templates.metadata/var/qmail/alias/.qmail-localdelivery-default @@ -0,0 +1,2 @@ +UID="alias" +GID="qmail" diff --git a/root/etc/e-smith/templates.metadata/var/qmail/users/assign b/root/etc/e-smith/templates.metadata/var/qmail/users/assign new file mode 100644 index 0000000..5e9a173 --- /dev/null +++ b/root/etc/e-smith/templates.metadata/var/qmail/users/assign @@ -0,0 +1 @@ +FILTER=sub { $_[0] =~ /^\s*$/ ? '' : $_[0] } diff --git a/root/etc/e-smith/templates/var/qmail/alias/.qmail-default/50body b/root/etc/e-smith/templates/var/qmail/alias/.qmail-default/50body new file mode 100644 index 0000000..85ba071 --- /dev/null +++ b/root/etc/e-smith/templates/var/qmail/alias/.qmail-default/50body @@ -0,0 +1,5 @@ +{ + ($EmailUnknownUser eq "returntosender") ? + "| bouncesaying 'Recipient unknown'" : + "$EmailUnknownUser"; +} diff --git a/root/etc/e-smith/templates/var/qmail/alias/.qmail-group/50group_members b/root/etc/e-smith/templates/var/qmail/alias/.qmail-group/50group_members new file mode 100644 index 0000000..29e6237 --- /dev/null +++ b/root/etc/e-smith/templates/var/qmail/alias/.qmail-group/50group_members @@ -0,0 +1,5 @@ +{ + # Generic template to rebuild any .qmail-groupname file. Expects + # to be called with a CONFREF containing the group members. + $OUT .= join("\n", map { '&' . $_ } split(/,/, $Members)); +} diff --git a/root/etc/e-smith/templates/var/qmail/alias/.qmail-localdelivery-default/50body b/root/etc/e-smith/templates/var/qmail/alias/.qmail-localdelivery-default/50body new file mode 100644 index 0000000..157c4c9 --- /dev/null +++ b/root/etc/e-smith/templates/var/qmail/alias/.qmail-localdelivery-default/50body @@ -0,0 +1 @@ +| forward $DEFAULT@{"$SystemName.$DomainName"} diff --git a/root/etc/e-smith/templates/var/qmail/alias/.qmail-shared/50body b/root/etc/e-smith/templates/var/qmail/alias/.qmail-shared/50body new file mode 100644 index 0000000..44b6393 --- /dev/null +++ b/root/etc/e-smith/templates/var/qmail/alias/.qmail-shared/50body @@ -0,0 +1,13 @@ +{ + use esmith::AccountsDB; + my $a = esmith::AccountsDB->open_ro; + + $OUT = ''; + + for my $user ( $a->get('admin'), $a->users ) + { + next if ( ($user->prop('EveryoneEmail') || 'yes') eq 'no'); + + $OUT .= '&' . $user->key . "\n"; + } +} diff --git a/root/etc/e-smith/templates/var/qmail/control/bouncefrom b/root/etc/e-smith/templates/var/qmail/control/bouncefrom new file mode 100644 index 0000000..e3100ca --- /dev/null +++ b/root/etc/e-smith/templates/var/qmail/control/bouncefrom @@ -0,0 +1 @@ +MAILER-DAEMON diff --git a/root/etc/e-smith/templates/var/qmail/control/bouncehost b/root/etc/e-smith/templates/var/qmail/control/bouncehost new file mode 100644 index 0000000..24c4714 --- /dev/null +++ b/root/etc/e-smith/templates/var/qmail/control/bouncehost @@ -0,0 +1 @@ +{ $DomainName } diff --git a/root/etc/e-smith/templates/var/qmail/control/concurrencylocal b/root/etc/e-smith/templates/var/qmail/control/concurrencylocal new file mode 100644 index 0000000..566c73d --- /dev/null +++ b/root/etc/e-smith/templates/var/qmail/control/concurrencylocal @@ -0,0 +1 @@ +{ (defined $DB->get('qmail')->prop('ConcurrencyLocal')) ? $DB->get('qmail')->prop('ConcurrencyLocal') : "20"; } diff --git a/root/etc/e-smith/templates/var/qmail/control/concurrencyremote b/root/etc/e-smith/templates/var/qmail/control/concurrencyremote new file mode 100644 index 0000000..ba58fb1 --- /dev/null +++ b/root/etc/e-smith/templates/var/qmail/control/concurrencyremote @@ -0,0 +1 @@ +{ (defined $DB->get('qmail')->prop('ConcurrencyRemote'))? $DB->get('qmail')->prop('ConcurrencyRemote') : "20"; } diff --git a/root/etc/e-smith/templates/var/qmail/control/databytes b/root/etc/e-smith/templates/var/qmail/control/databytes new file mode 100644 index 0000000..832c147 --- /dev/null +++ b/root/etc/e-smith/templates/var/qmail/control/databytes @@ -0,0 +1 @@ +{ $DB->get('qmail')->prop('MaxMessageSize') || "0"; } diff --git a/root/etc/e-smith/templates/var/qmail/control/defaultdomain b/root/etc/e-smith/templates/var/qmail/control/defaultdomain new file mode 100644 index 0000000..24c4714 --- /dev/null +++ b/root/etc/e-smith/templates/var/qmail/control/defaultdomain @@ -0,0 +1 @@ +{ $DomainName } diff --git a/root/etc/e-smith/templates/var/qmail/control/defaulthost b/root/etc/e-smith/templates/var/qmail/control/defaulthost new file mode 100644 index 0000000..24c4714 --- /dev/null +++ b/root/etc/e-smith/templates/var/qmail/control/defaulthost @@ -0,0 +1 @@ +{ $DomainName } diff --git a/root/etc/e-smith/templates/var/qmail/control/doublebouncehost b/root/etc/e-smith/templates/var/qmail/control/doublebouncehost new file mode 100644 index 0000000..24c4714 --- /dev/null +++ b/root/etc/e-smith/templates/var/qmail/control/doublebouncehost @@ -0,0 +1 @@ +{ $DomainName } diff --git a/root/etc/e-smith/templates/var/qmail/control/doublebounceto b/root/etc/e-smith/templates/var/qmail/control/doublebounceto new file mode 100644 index 0000000..c3043ad --- /dev/null +++ b/root/etc/e-smith/templates/var/qmail/control/doublebounceto @@ -0,0 +1 @@ +{ $DB->get('qmail')->prop('DoubleBounceTo') || "postmaster"; } diff --git a/root/etc/e-smith/templates/var/qmail/control/envnoathost b/root/etc/e-smith/templates/var/qmail/control/envnoathost new file mode 100644 index 0000000..24c4714 --- /dev/null +++ b/root/etc/e-smith/templates/var/qmail/control/envnoathost @@ -0,0 +1 @@ +{ $DomainName } diff --git a/root/etc/e-smith/templates/var/qmail/control/helohost b/root/etc/e-smith/templates/var/qmail/control/helohost new file mode 100644 index 0000000..263e1c4 --- /dev/null +++ b/root/etc/e-smith/templates/var/qmail/control/helohost @@ -0,0 +1 @@ +{ $qpsmtpd{HeloHost} || $DomainName } diff --git a/root/etc/e-smith/templates/var/qmail/control/locals b/root/etc/e-smith/templates/var/qmail/control/locals new file mode 100644 index 0000000..b3e4f86 --- /dev/null +++ b/root/etc/e-smith/templates/var/qmail/control/locals @@ -0,0 +1,11 @@ +# +# Everything except the localhost and the local machine name is now +# treated as a virtual domain. +# +localhost +{"$SystemName.$DomainName"} +{ + return "# No ExternalIP" unless (defined $ExternalIP); + + return "[$ExternalIP]"; +} diff --git a/root/etc/e-smith/templates/var/qmail/control/me b/root/etc/e-smith/templates/var/qmail/control/me new file mode 100644 index 0000000..24c4714 --- /dev/null +++ b/root/etc/e-smith/templates/var/qmail/control/me @@ -0,0 +1 @@ +{ $DomainName } diff --git a/root/etc/e-smith/templates/var/qmail/control/plusdomain b/root/etc/e-smith/templates/var/qmail/control/plusdomain new file mode 100644 index 0000000..24c4714 --- /dev/null +++ b/root/etc/e-smith/templates/var/qmail/control/plusdomain @@ -0,0 +1 @@ +{ $DomainName } diff --git a/root/etc/e-smith/templates/var/qmail/control/smtproutes/00README b/root/etc/e-smith/templates/var/qmail/control/smtproutes/00README new file mode 100644 index 0000000..0df6333 --- /dev/null +++ b/root/etc/e-smith/templates/var/qmail/control/smtproutes/00README @@ -0,0 +1,25 @@ +{ + # + # qmail's smtproutes mechanism works such that the LAST BEST match + # found in /var/qmail/control/smtproutes will be used in preference + # to any other entry. + # + # Consider the following /var/qmail/control/smtproutes example: + # + # :smarthost.somewhere + # domain.place:some.host + # domain.place:other.host + # :some.other.smarthost.elsewhere + # + # Mail for user@domain.place will ALWAYS be delivered to + # other.host. The entry for some.host will NEVER be used. + # + # Mail for any other domain will ALWAYS be delivered to + # some.other.smarthost.elsewhere. The entry for smarthost.somewhere + # will NEVER be used. + # + # Therefore, if you wish to make any customisations to the + # /var/qmail/control/smtproutes templates, you must ensure that they + # appear AFTER the standard e-smith template entries. + # +} diff --git a/root/etc/e-smith/templates/var/qmail/control/smtproutes/10delegateMailServer b/root/etc/e-smith/templates/var/qmail/control/smtproutes/10delegateMailServer new file mode 100644 index 0000000..9db9c1f --- /dev/null +++ b/root/etc/e-smith/templates/var/qmail/control/smtproutes/10delegateMailServer @@ -0,0 +1,17 @@ +{ + $OUT = ""; + + use esmith::DomainsDB; + my $ddb = esmith::DomainsDB->open_ro(); + + for my $domain ( $ddb->domains ) + { + my $mail_server = $domain->prop('MailServer') + || $DelegateMailServer + || 'localhost'; + + next if ( $mail_server eq 'localhost' ); + + $OUT .= $domain->key . ":$mail_server\n"; + } +} diff --git a/root/etc/e-smith/templates/var/qmail/control/smtproutes/20SMTPSmartHost b/root/etc/e-smith/templates/var/qmail/control/smtproutes/20SMTPSmartHost new file mode 100644 index 0000000..cd7def9 --- /dev/null +++ b/root/etc/e-smith/templates/var/qmail/control/smtproutes/20SMTPSmartHost @@ -0,0 +1,28 @@ +{ + $OUT = ""; + + #-------------------------------------------------- + # Now check for SMTP smart host + #-------------------------------------------------- + + if ( + $SMTPSmartHost + && + ($SMTPSmartHost ne 'off') + && + ($SMTPSmartHost !~ /^\s*$/) + ) + { + # Is the smtp-auth-proxy enabled? + if (${'smtp-auth-proxy'}{'status'} eq 'enabled') + { + $OUT .= ":localhost:26"; + } + else + { + $OUT .= ":$SMTPSmartHost"; + } + } + + chomp ($OUT); +} diff --git a/root/etc/e-smith/templates/var/qmail/control/virtualdomains/80localdomains b/root/etc/e-smith/templates/var/qmail/control/virtualdomains/80localdomains new file mode 100644 index 0000000..37ae136 --- /dev/null +++ b/root/etc/e-smith/templates/var/qmail/control/virtualdomains/80localdomains @@ -0,0 +1,19 @@ +{ + $OUT = ''; + + use esmith::DomainsDB; + my $domainsdb = esmith::DomainsDB->open_ro(); + + for my $domain ($domainsdb->domains) + { + my $mail_server = $domain->prop('MailServer') + || $DelegateMailServer + || 'localhost'; + + next if ( $mail_server ne 'localhost' ); + + $emaildomain = $domain->key; + my $handler = $domain->prop('EmailTo') || "alias-localdelivery"; + $OUT .= "$emaildomain:$handler\n"; + } +} diff --git a/root/etc/e-smith/templates/var/qmail/control/virtualdomains/90pseudonyms b/root/etc/e-smith/templates/var/qmail/control/virtualdomains/90pseudonyms new file mode 100644 index 0000000..2d98c03 --- /dev/null +++ b/root/etc/e-smith/templates/var/qmail/control/virtualdomains/90pseudonyms @@ -0,0 +1,26 @@ +{ + my $dms = $DelegateMailServer; + + return "# DelegateMailServer is set" if ($dms && ($dms !~ /^\s*$/)); + + $OUT = ""; + + use esmith::AccountsDB; + + my $adb = esmith::AccountsDB->open_ro or die "Couldn't open AccountsDB"; + + for my $pseudo ($adb->pseudonyms) + { + next unless ($pseudo->key =~ /@/); + + my $account = $pseudo->prop("Account"); + $account = "admin" and warn $pseudo->prop("Account") . " is not a valid account, default to admin " unless $adb->get($account); + my $acct = $adb->get($account); + if ($acct->prop('type') eq "group") + { + $account =~ s/\./:/g; + } + + $OUT .= $pseudo->key . ":$account\n"; + } +} diff --git a/root/etc/e-smith/templates/var/qmail/users/assign/30admin b/root/etc/e-smith/templates/var/qmail/users/assign/30admin new file mode 100644 index 0000000..ab35603 --- /dev/null +++ b/root/etc/e-smith/templates/var/qmail/users/assign/30admin @@ -0,0 +1,32 @@ +{ + $OUT = ''; + + # Generate qmail user assignments for the admin user. This will be + # handled by ~admin/.qmail. + + my (undef, undef, $uid, $gid, undef, undef, undef, $dir, undef) + = getpwnam("admin"); + + # It is almost impossible to get Text::Template to output nothing + # on failure. It can be done by removing the newline at the end of + # this file but that is messy. Therefore, we'll simply return an + # error message that will make qmail-newu fail. Also send a + # warning message that will be captured in the logs. + + unless (defined $uid && defined $gid && defined $dir) + { + my $msg = + "Failed to obtain user details for \'admin\' " + . "while processing admin assignment."; + + warn "$msg\n"; + $OUT = $msg; + return; + } + + # Assign mail for the admin user itself, and for admin-ext. + + my $admin_assign = "admin:${uid}:${gid}:${dir}"; + $OUT .= "=admin:${admin_assign}:::\n"; + $OUT .= "+admin-:${admin_assign}:-::"; +} diff --git a/root/etc/e-smith/templates/var/qmail/users/assign/40alias b/root/etc/e-smith/templates/var/qmail/users/assign/40alias new file mode 100644 index 0000000..a051eac --- /dev/null +++ b/root/etc/e-smith/templates/var/qmail/users/assign/40alias @@ -0,0 +1,32 @@ +{ + $OUT = ''; + + # Generate qmail user assignments for the alias user. This will be + # handled by ~alias/.qmail. + + my (undef, undef, $uid, $gid, undef, undef, undef, $dir, undef) + = getpwnam("alias"); + + # It is almost impossible to get Text::Template to output nothing + # on failure. It can be done by removing the newline at the end of + # this file but that is messy. Therefore, we'll simply return an + # error message that will make qmail-newu fail. Also send a + # warning message that will be captured in the logs. + + unless (defined $uid && defined $gid && defined $dir) + { + my $msg = + "Failed to obtain user details for \'alias\' " + . "while processing alias assignment."; + + warn "$msg\n"; + $OUT = $msg; + return; + } + + # Assign mail for the alias user itself, and for alias-ext. + + my $alias_assign = "alias:${uid}:${gid}:${dir}"; + $OUT .= "=alias:${alias_assign}:::\n"; + $OUT .= "+alias-:${alias_assign}:-::"; +} diff --git a/root/etc/e-smith/templates/var/qmail/users/assign/45shared b/root/etc/e-smith/templates/var/qmail/users/assign/45shared new file mode 100644 index 0000000..2fd77de --- /dev/null +++ b/root/etc/e-smith/templates/var/qmail/users/assign/45shared @@ -0,0 +1,36 @@ +{ + $OUT = ''; + + # Generate qmail user assignments for the shared group. This will + # be handled by ~alias/.qmail-shared and ~alias/.qmail-shared-ext. + + my (undef, undef, $uid, $gid, undef, undef, undef, $dir, undef) + = getpwnam("alias"); + + # It is almost impossible to get Text::Template to output nothing + # on failure. It can be done by removing the newline at the end of + # this file but that is messy. Therefore, we'll simply return an + # error message that will make qmail-newu fail. Also send a + # warning message that will be captured in the logs. + + unless (defined $uid && defined $gid && defined $dir) + { + my $msg = + "Failed to obtain user details for \'alias\' " + . "while processing shared assignment."; + + warn "$msg\n"; + $OUT = $msg; + return; + } + + my $alias_assign = "alias:${uid}:${gid}:${dir}"; + + $OUT .= "=shared:${alias_assign}:-:shared:\n"; + $OUT .= "+shared-:${alias_assign}:-shared-::\n"; + + # Need to remove the final newline character. Blank lines in + # /var/qmail/users/assign are prohibited. + + chomp($OUT); +} diff --git a/root/etc/e-smith/templates/var/qmail/users/assign/50system b/root/etc/e-smith/templates/var/qmail/users/assign/50system new file mode 100644 index 0000000..8c70126 --- /dev/null +++ b/root/etc/e-smith/templates/var/qmail/users/assign/50system @@ -0,0 +1,56 @@ +{ + $OUT = ''; + + # Generate qmail user assignments for system accounts. These will + # be handled by admin. Make sure we DON'T reassign the admin or + # alias users! + + my (undef, undef, $uid, $gid, undef, undef, undef, $dir, undef) + = getpwnam("admin"); + + # It is almost impossible to get Text::Template to output nothing + # on failure. It can be done by removing the newline at the end of + # this file but that is messy. Therefore, we'll simply return an + # error message that will make qmail-newu fail. Also send a + # warning message that will be captured in the logs. + + unless (defined $uid && defined $gid && defined $dir) + { + my $msg = + "Failed to obtain user details for \'admin\' " + . "while processing system assignments."; + + warn "$msg\n"; + $OUT = $msg; + return; + } + + my $admin_assign = "admin:${uid}:${gid}:${dir}"; + + use esmith::AccountsDB; + my $adb = esmith::AccountsDB->open_ro(); + + foreach my $user ( $adb->get_all_by_prop( type => 'system' ) ) + { + next if ($user->key eq "admin"); + next if ($user->key eq "alias"); + next if ($user->key eq "shared"); + + # Assign mail for system_account@ + $OUT .= "=" . $user->key . ":${admin_assign}:::\n"; + + # Assign mail for system_account-ext@ + $OUT .= "+" . $user->key . "-:${admin_assign}:-::\n"; + } + + # Need to remove the final newline character. Blank lines in + # /var/qmail/users/assign are prohibited. + + chomp($OUT); + + # Failsafe: /var/qmail/users/assign cannot have blank lines. + # Therefore, if $OUT is empty, simply set up an assign for the + # admin user. + + $OUT = "=admin:${admin_assign}:::" unless $OUT; +} diff --git a/root/etc/e-smith/templates/var/qmail/users/assign/60users b/root/etc/e-smith/templates/var/qmail/users/assign/60users new file mode 100644 index 0000000..9a4fe7f --- /dev/null +++ b/root/etc/e-smith/templates/var/qmail/users/assign/60users @@ -0,0 +1,59 @@ +{ + $OUT = ''; + + # Generate qmail user assignments for users. These will be handled by + # ~user/.qmail. + + use esmith::AccountsDB; + my $adb = esmith::AccountsDB->open_ro(); + + foreach $user ( $adb->users ) + { + my $user_name = $user->key; + my (undef, undef, $uid, $gid, undef, undef, undef, $dir, undef) + = getpwnam($user_name); + + # It is almost impossible to get Text::Template to output nothing + # on failure. It can be done by removing the newline at the end of + # this file but that is messy. Therefore, we'll simply return an + # error message that will make qmail-newu fail. Also send a + # warning message that will be captured in the logs. + + unless (defined $uid && defined $gid && defined $dir) + { + my $msg = + "Failed to obtain user details for \'$user_name\' " + . "while processing user assignments."; + + warn "$msg\n"; + $OUT = $msg; + return; + } + + $user_assign = $user_name . ":${uid}:${gid}:${dir}"; + + # Assign mail for user@ + $OUT .= "=" . $user_name . ":${user_assign}:::\n"; + + # Assign mail for user-ext@ + $OUT .= "+" . $user_name . "-:${user_assign}:-::\n"; + } + + # Need to remove the final newline character. Blank lines in + # /var/qmail/users/assign are prohibited. + + chomp($OUT); + + # Failsafe: /var/qmail/users/assign cannot have blank lines. + # Therefore, if $OUT is empty, simply set up an assign for the + # alias user. + + unless ($OUT) + { + (undef, undef, $uid, $gid, undef, undef, undef, $dir, undef) + = getpwnam("alias"); + + $alias_assign = "alias:${uid}:${gid}:${dir}"; + $OUT = "=alias:${alias_assign}:::"; + } +} diff --git a/root/etc/e-smith/templates/var/qmail/users/assign/70pseudonyms b/root/etc/e-smith/templates/var/qmail/users/assign/70pseudonyms new file mode 100644 index 0000000..137cb8e --- /dev/null +++ b/root/etc/e-smith/templates/var/qmail/users/assign/70pseudonyms @@ -0,0 +1,147 @@ +{ + $OUT = ''; + + # Generate qmail user assignments for pseudonyms. These will + # be handled by ~user/.qmail in the case of a user pseudonym + # or by ~admin/.qmail in the case of a system pseudonym or by + # alias/.qmail-groupname in the case of a group pseudonym. + + my (undef, undef, $uid, $gid, undef, undef, undef, $dir, undef) + = getpwnam("alias"); + + # It is almost impossible to get Text::Template to output nothing + # on failure. It can be done by removing the newline at the end of + # this file but that is messy. Therefore, we'll simply return an + # error message that will make qmail-newu fail. Also send a + # warning message that will be captured in the logs. + + unless (defined $uid && defined $gid && defined $dir) + { + my $msg = + "Failed to obtain user details for \'alias\' " + . "while processing pseudonym assignments."; + + warn "$msg\n"; + $OUT = $msg; + return; + } + + my $alias_assign = "alias:${uid}:${gid}:${dir}"; + + undef $uid; + undef $gid; + undef $dir; + + (undef, undef, $uid, $gid, undef, undef, undef, $dir, undef) + = getpwnam("admin"); + + unless (defined $uid && defined $gid && defined $dir) + { + my $msg = + "Failed to obtain user details for \'admin\' " + . "while processing pseudonym assignments."; + + warn "$msg\n"; + $OUT = $msg; + return; + } + + my $admin_assign = "admin:${uid}:${gid}:${dir}"; + + # Create assignments for each pseudonym. + + use esmith::AccountsDB; + my $adb = esmith::AccountsDB->open_ro(); + + foreach $pseudonym ( $adb->pseudonyms ) + { + next if ( $pseudonym->key =~ /@/ ); # user@domain goes in virtualdomains + + my $account = $pseudonym->prop('Account'); + unless ($account) + { + my $key = $pseudonym->key; + warn "pseudonym $key has no account property, default to admin"; + $account = $adb->get('admin'); + #next; + } + + $account = $adb->get($pseudonym->prop('Account')); + unless ($account) + { + my $key = $pseudonym->key; + warn "pseudonym $key points to account which does not exist, default to admin"; + $account = $adb->get('admin'); + #next; + } + + my $i = 1; + while ( $account->prop('type') eq "pseudonym") + { + $account = $adb->get($account->prop('Account')); + unless ($account) + { + my $key = $pseudonym->key; + warn "pseudonym $key points to account which does not exist, default to admin"; + $account = $adb->get('admin'); + last; + } + $i ++; last if $i>10; + } + + if ($account->prop('type') eq "pseudonym") + { + warn "users/assign: Skipping " . $pseudonym->key . " - too many pseudonym levels\n"; + next; + } + + if ($account->prop('type') eq "user") + { + my (undef, undef, $uid, $gid, undef, undef, undef, $dir, undef) + = getpwnam($account->key); + + unless (defined $uid && defined $gid && defined $dir) + { + my $msg = + "Failed to obtain user details for \'" . $account->key . "\' " + . "while processing pseudonym assignments."; + + warn "$msg\n"; + $OUT = $msg; + return; + } + + $assign = $account->key . ":${uid}:${gid}:${dir}"; + + # Assign mail for user_pseudonym@ + $OUT .= "=" . $pseudonym->key . ":${assign}:::\n"; + $OUT .= "+" . $pseudonym->key . "-:${assign}:-::\n"; + next; + } + + if ($account->prop('type') eq "group" || $account->key eq "shared") + { + $OUT .= "=" . $pseudonym->key . ":${alias_assign}:-:" . $account->key . ":\n"; + $OUT .= "+" . $pseudonym->key . "-:${alias_assign}:-:" . $account->key . ":\n"; + next; + } + + if ($account->prop('type') eq "system" ) + { + $OUT .= "=" . $pseudonym->key . ":${admin_assign}:::\n"; + $OUT .= "+" . $pseudonym->key . "-:${admin_assign}:-::\n"; + next; + } + } + + # Need to remove the final newline character. Blank lines in + # /var/qmail/users/assign are prohibited. + + chomp($OUT); + + # Failsafe: /var/qmail/users/assign cannot have blank lines. + # Therefore, if $OUT is empty, simply set up an assign for the + # alias user. + + $OUT = "=alias:${alias_assign}:::" unless $OUT; +} diff --git a/root/etc/e-smith/templates/var/qmail/users/assign/80groups b/root/etc/e-smith/templates/var/qmail/users/assign/80groups new file mode 100644 index 0000000..2619336 --- /dev/null +++ b/root/etc/e-smith/templates/var/qmail/users/assign/80groups @@ -0,0 +1,51 @@ +{ + $OUT = ''; + + # Generate qmail user assignments for groups. These will be handled + # by ~alias/.qmail-groupname and ~alias/.qmail-groupname-ext. + + my (undef, undef, $uid, $gid, undef, undef, undef, $dir, undef) + = getpwnam("alias"); + + # It is almost impossible to get Text::Template to output nothing + # on failure. It can be done by removing the newline at the end of + # this file but that is messy. Therefore, we'll simply return an + # error message that will make qmail-newu fail. Also send a + # warning message that will be captured in the logs. + + unless (defined $uid && defined $gid && defined $dir) + { + my $msg = + "Failed to obtain user details for \'alias\' " + . "while processing group assignments."; + + warn "$msg\n"; + $OUT = $msg; + return; + } + + my $alias_assign = "alias:${uid}:${gid}:${dir}"; + + use esmith::AccountsDB; + my $adb = esmith::AccountsDB->open_ro(); + + foreach $group ( $adb->groups ) + { + # Assign mail for group@ + $OUT .= "=" . $group->key . ":${alias_assign}:-:" . $group->key . ":\n"; + + # Assign mail for group-ext@ + $OUT .= "+" . $group->key . "-:${alias_assign}:-" . $group->key . "-::\n"; + } + + # Need to remove the final newline character. Blank lines in + # /var/qmail/users/assign are prohibited. + + chomp($OUT); + + # Failsafe: /var/qmail/users/assign cannot have blank lines. + # Therefore, if $OUT is empty, simply set up an assign for the + # alias user. + + $OUT = "=alias:${alias_assign}:::" unless $OUT; +} diff --git a/root/etc/e-smith/templates/var/qmail/users/assign/template-begin b/root/etc/e-smith/templates/var/qmail/users/assign/template-begin new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/e-smith/templates/var/qmail/users/assign/template-end b/root/etc/e-smith/templates/var/qmail/users/assign/template-end new file mode 100644 index 0000000..9c558e3 --- /dev/null +++ b/root/etc/e-smith/templates/var/qmail/users/assign/template-end @@ -0,0 +1 @@ +. diff --git a/root/service/qmail b/root/service/qmail new file mode 120000 index 0000000..25cbd2d --- /dev/null +++ b/root/service/qmail @@ -0,0 +1 @@ +../var/service/qmail \ No newline at end of file diff --git a/root/usr/lib/systemd/system/qmail.service b/root/usr/lib/systemd/system/qmail.service new file mode 100644 index 0000000..9d1a745 --- /dev/null +++ b/root/usr/lib/systemd/system/qmail.service @@ -0,0 +1,15 @@ +[Unit] +Description=qmail, message transfer agent +After=network.target +Requires=runit.service + +[Service] +Type=oneshot +ExecStartPre=/sbin/e-smith/service-status qmail +ExecStart=/usr/bin/sv u /service/qmail +ExecStop=/usr/bin/sv stop /service/qmail +ExecReload=/usr/bin/sv t /service/qmail +RemainAfterExit=yes + +[Install] +WantedBy=sme-server.target diff --git a/root/var/log/qmail/.gitignore b/root/var/log/qmail/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/root/var/qmail/alias/.qmail-devnull b/root/var/qmail/alias/.qmail-devnull new file mode 100644 index 0000000..97aba37 --- /dev/null +++ b/root/var/qmail/alias/.qmail-devnull @@ -0,0 +1 @@ +# devnull - bit bucket - throw the mail away diff --git a/root/var/qmail/alias/.qmail-devnull-default b/root/var/qmail/alias/.qmail-devnull-default new file mode 100644 index 0000000..97aba37 --- /dev/null +++ b/root/var/qmail/alias/.qmail-devnull-default @@ -0,0 +1 @@ +# devnull - bit bucket - throw the mail away diff --git a/root/var/qmail/etc/service/qmail/down b/root/var/qmail/etc/service/qmail/down new file mode 100644 index 0000000..e69de29 diff --git a/root/var/service/qmail/down b/root/var/service/qmail/down new file mode 100644 index 0000000..e69de29 diff --git a/root/var/service/qmail/log/run b/root/var/service/qmail/log/run new file mode 100644 index 0000000..7659b93 --- /dev/null +++ b/root/var/service/qmail/log/run @@ -0,0 +1,30 @@ +#!/bin/sh + +#---------------------------------------------------------------------- +# copyright (C) 2001 e-smith, inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# Technical support for this program is available from e-smith, inc. +# Please visit our web site www.e-smith.com for details. +#---------------------------------------------------------------------- + +NUM=$(/sbin/e-smith/db configuration getprop qmail KeepLogFiles) + +exec \ + /usr/local/bin/setuidgid qmaill \ + /usr/local/bin/multilog t s5000000 \ + n${NUM:-10} \ + /var/log/qmail diff --git a/root/var/service/qmail/log/supervise/.gitignore b/root/var/service/qmail/log/supervise/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/root/var/service/qmail/run b/root/var/service/qmail/run new file mode 100644 index 0000000..dbcfd66 --- /dev/null +++ b/root/var/service/qmail/run @@ -0,0 +1,32 @@ +#!/bin/sh + +#---------------------------------------------------------------------- +# copyright (C) 2002-2006 Mitel Networks Corporation +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +#---------------------------------------------------------------------- +if [ ! -f /var/qmail/queue/lock/tcpto ] +then + dd bs=1024 count=1 if=/dev/zero of=/var/qmail/queue/lock/tcpto + chown qmailr:qmail /var/qmail/queue/lock/tcpto + chmod 644 /var/qmail/queue/lock/tcpto +fi + +exec \ + /usr/bin/env - PATH="/var/qmail/bin:/bin:/usr/bin:/usr/local/bin" \ + /var/qmail/bin/qmail-start \ + ./Maildir/ \ + 2>&1 diff --git a/root/var/service/qmail/supervise/.gitignore b/root/var/service/qmail/supervise/.gitignore new file mode 100644 index 0000000..e69de29