pax_global_header00006660000000000000000000000064132272651400014514gustar00rootroot0000000000000052 comment=ec6c7763f40eb6944a807a41e49cd199182a9fcb dms-1.0.8.1/000077500000000000000000000000001322726514000124445ustar00rootroot00000000000000dms-1.0.8.1/.gitignore000066400000000000000000000012001322726514000144250ustar00rootroot00000000000000# Ignore these pythonisms __pycache__/ *.pyc # Vim backup file *.swp log/ var/ dnspython-tests/ /zone_tool~* # Ignore when py-magcode-core symlinked in for work magcode # Passwords can be found in here - we don't woant to commit them! etc/dms.conf etc/rsync-slave-password # Apache config etc/vhost-dms-freebsd # Don't archive python build directory build # Stuff in debian we should not worry about /debian/dms-core/ /debian/dms-dr/ /debian/dms-wsgi/ /debian/dms/ /debian/tmp/ /debian/*.debhelper* /debian/*.substvars /debian/files /debian/debhelper-build-stamp # Sphinx doc files to ignore doc/_build/ # Ignore python dist directory dist dms-1.0.8.1/.gitmodules000066400000000000000000000000001322726514000146070ustar00rootroot00000000000000dms-1.0.8.1/COPYING000066400000000000000000001045131322726514000135030ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. 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 them 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 prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. 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. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey 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; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If 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 convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU 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 that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. 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. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 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. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. 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 state 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 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 3 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, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program 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, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU 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 Lesser General Public License instead of this License. But first, please read . dms-1.0.8.1/INSTALL000066400000000000000000000006411322726514000134760ustar00rootroot00000000000000To Install: See the PDF doc/DMS-090713-1002-38.pdf, 'Master Server Install from Source Repository at the bottom of the index in the technical section. The contents of this PDF is being entered intoa new Website for the project. Note: dms depends on py-magcode-core up at https://github.com/grantma/py-magcode-core.git Matthew Grant Sun, 14 Jul 2013 21:20:59 +1200 dms-1.0.8.1/Makefile000066400000000000000000000307121322726514000141070ustar00rootroot00000000000000#!/usr/bin/env make # # Copyright (c) Net24 Limited, Christchurch, New Zealand 2011-2012 # and Voyager Internet Ltd, New Zealand, 2012-2013 # # This file is part of py-magcode-core. # # Py-magcode-core 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 3 of the License, or # (at your option) any later version. # # Py-magcode-core 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 py-magcode-core. If not, see . # DESTDIR = # # Installation Makefile for DMS # # This is rough! FIXME! OSNAME := $(shell uname -s) DOCDIR := doc DOCTARGETS := html ETCDIR := /etc DAEMONUSER := dmsdmd DAEMONGROUP := dmsdmd DMSGROUP := dms CONFSUBDIRS := master-config-templates config-templates server-config-templates \ server-admin-config CONFFILES = dms.conf rsync-dnsconf-password rsync-dnssec-password pgpassfile \ dr-settings.sh CONFBINDFILES = named.conf named.conf.options named.conf.local named-dr-replica.conf CONFDMSDMDFILES = envvars prepare-environment post-start MASTERINCFILES = server-acl.conf zones.conf WSGISCRIPTS = admin_dms.wsgi helpdesk_dms.wsgi value_reseller_dms.wsgi \ hosted_dms.wsgi LISTZONEWSGISCRIPTS = list_zone.wsgi ifeq ($(OSNAME), Linux) PREFIX=/usr/local CONFDIR=$(DESTDIR)$(ETCDIR)/dms CONFBINDDIR=$(DESTDIR)$(ETCDIR)/dms/bind CONFDMSDMDDIR=$(DESTDIR)$(ETCDIR)/dms/dmsdmd SYSCTLDIR=$(DESTDIR)$(ETCDIR)/sysctl.d NAMEDDATADIR=$(DESTDIR)/var/lib/bind NAMEDDYNAMICDIR=$(DESTDIR)/var/lib/bind/dynamic NAMEDKEYDIR=$(DESTDIR)/var/lib/bind/keys NAMEDDSDIR=$(DESTDIR)/var/lib/bind/ds NAMEDSLAVEDIR=$(DESTDIR)/var/cache/bind/slave NAMEDSLAVELNDATA=../../cache/bind/slave NAMEDSLAVELN=$(DESTDIR)/var/lib/bind/slave NAMEDMASTERLNDATA=/etc/bind/master NAMEDMASTERLN=$(DESTDIR)/var/lib/bind/master NAMEDMASTERDIR=$(DESTDIR)$(ETCDIR)/bind/master VARCONFDIR=$(DESTDIR)/var/lib/dms NAMEDCONFDIR=$(DESTDIR)$(VARCONFDIR)/master-config NAMEDSERVERCONFDIR=$(DESTDIR)$(VARCONFDIR)/rsync-config RNDCCONFDIR=$(DESTDIR)$(VARCONFDIR)/rndc LOGDIR=$(DESTDIR)/var/log/dms RUNDIR=$(DESTDIR)/run/dms BACKUPDIR=$(DESTDIR)/var/backups SYSTEMDCONFDIR=$(DESTDIR)/lib/systemd/system PYTHON_INTERPRETER ?= /usr/bin/python3 PYTHON_SETUP_OPTS = --install-layout=deb PGUSER=postgres PGGROUP=postgres else ifeq ($(OSNAME), FreeBSD) PREFIX = /usr/local CONFDIR = $(DESTDIR)$(PREFIX)$(ETCDIR)/dms CONFBINDDIR=$(DESTDIR)$(PREFIX)$(ETCDIR)/dms/bind CONFDMSDMDDIR=$(DESTDIR)$(PREFIX)$(ETCDIR)/dms/dmsdmd NAMEDCONFDIR=$(DESTDIR)$(ETCDIR)/namedb/master-config NAMEDSERVERCONFDIR=$(DESTDIR)$(ETCDIR)/namedb/rsync-config RNDCCONFDIR=$(DESTDIR)$(ETCDIR)/nameddb NAMEDDYNAMICDIR=$(DESTDIR)$(ETCDIR)/namedb/dynamic NAMEDKEYDIR=$(DESTDIR)$(ETCDIR)/namedb/keys NAMEDDSDIR=$(DESTDIR)$(ETCDIR)/namedb/ds VARCONFDIR = $(DESTDIR)/var/lib/dms LOGDIR = $(DESTDIR)/var/log/dms RUNDIR = $(DESTDIR)/var/run/dms PYTHON_INTERPRETER ?= $(PREFIX)/bin/python3.4 PYTHON_SETUP_OPTS = PGUSER=pgsql PGGROUP=pgsql else PREFIX = /usr/local CONFDIR = $(DESTDIR)$(PREFIX)/dms$(ETCDIR) CONFBINDDIR=$(DESTDIR)$(PREFIX)/dms$(ETCDIR)/bind CONFDMSDMDDIR=$(DESTDIR)$(PREFIX)/dms$(ETCDIR)/dmsdmd NAMEDCONFDIR=$(DESTDIR)$(PREFIX)/namedb$(ETCDIR)/master-config NAMEDSERVERCONFDIR=$(DESTDIR)$(PREFIX)/namedb$(ETCDIR)/rsync-config RNDCCONFDIR=$(DESTDIR)$(PREFIX)/namedb$(ETCDIR) NAMEDDYNAMICDIR=$(DESTDIR)$(PREFIX)/namedb$(ETCDIR)/dynamic NAMEDKEYDIR=$(DESTDIR)$(PREFIX)/namedb$(ETCDIR)/keys NAMEDDSDIR=$(DESTDIR)$(PREFIX)/namedb$(ETCDIR)/ds VARCONFDIR = $(DESTDIR)$(PREFIX)/dms/var LOGDIR = $(DESTDIR)$(PREFIX)/dms/log RUNDIR = $(DESTDIR)$(PREFIX)/dms/var PYTHON_INTERPRETER ?= $(PREFIX)/bin/python3.4 PYTHON_SETUP_OPTS = PGUSER=pgsql PGGROUP=pgsql endif SHAREDIR = $(DESTDIR)$(PREFIX)/share/dms DOCUMENTATIONDIR = $(DESTDIR)$(PREFIX)/share/doc/dms-doc BINDIR = $(DESTDIR)$(PREFIX)/bin SBINDIR = $(DESTDIR)$(PREFIX)/sbin MANDIR = $(DESTDIR)$(PREFIX)/man INSTALL = /usr/bin/install .PHONY: install install-dir install-conf install-python install-bin \ install-wsgi clean clean-python build-python doc all: build-python install: install-conf install-bin install-wsgi install-doc install-dir: - $(INSTALL) -d $(BINDIR) - $(INSTALL) -d $(SBINDIR) - $(INSTALL) -d $(MANDIR) - $(INSTALL) -d $(CONFDIR) - $(INSTALL) -d $(CONFBINDDIR) - $(INSTALL) -d $(CONFDMSDMDDIR) - $(INSTALL) -d $(NAMEDCONFDIR) - $(INSTALL) -d $(NAMEDSERVERCONFDIR) - $(INSTALL) -d $(NAMEDDYNAMICDIR) - $(INSTALL) -d $(NAMEDKEYDIR) - $(INSTALL) -d $(NAMEDDSDIR) - $(INSTALL) -d $(RNDCCONFDIR) - $(INSTALL) -d $(VARCONFDIR)/dms-sg - $(INSTALL) -d $(LOGDIR) - $(INSTALL) -d $(RUNDIR) - $(INSTALL) -d $(SHAREDIR) - $(INSTALL) -d $(SHAREDIR)/dr_scripts - $(INSTALL) -d $(SHAREDIR)/setup_scripts - $(INSTALL) -d $(SHAREDIR)/postgresql - $(INSTALL) -d $(VARCONFDIR)/postgresql ifeq ($(OSNAME), Linux) - $(INSTALL) -d $(SYSCTLDIR) - $(INSTALL) -d $(BACKUPDIR) - $(INSTALL) -d $(SYSTEMDCONFDIR) endif ifndef DMS_DEB_BUILD chown root:bind $(CONFBINDDIR) chmod 2755 $(CONFBINDDIR) chown $(DAEMONUSER):bind $(NAMEDCONFDIR) chmod 2755 $(NAMEDCONFDIR) chown bind:bind $(NAMEDSERVERCONFDIR) chmod 755 $(NAMEDSERVERCONFDIR) chown bind:$(DAEMONGROUP) $(NAMEDDYNAMICDIR) chmod 2775 $(NAMEDDYNAMICDIR) chown bind:$(DAEMONGROUP) $(NAMEDKEYDIR) chmod 2775 $(NAMEDKEYDIR) chown $(DAEMONUSER):$(DAEMONGROUP) $(VARCONFDIR)/dms-sg chown $(DAEMONUSER):$(DAEMONGROUP) $(LOGDIR) chown $(DAEMONUSER):$(DAEMONGROUP) $(RUNDIR) endif ifeq ($(OSNAME), Linux) - $(INSTALL) -d $(NAMEDMASTERDIR) - $(INSTALL) -d $(NAMEDSLAVEDIR) ifndef DMS_DEB_BUILD chown root:bind $(NAMEDSLAVEDIR) chmod 775 $(NAMEDSLAVEDIR) endif - ln -snf $(NAMEDSLAVELNDATA) $(NAMEDSLAVELN) - ln -snf $(NAMEDMASTERLNDATA) $(NAMEDMASTERLN) endif install-conf: install-dir for f in $(CONFFILES); do \ if [ ! -f $(CONFDIR)/$${f}.sample ]; then \ $(INSTALL) -m 644 \ etc/$${f}.sample $(CONFDIR)/$${f}.sample; \ fi; \ if [ ! -f $(CONFDIR)/$$f ]; then \ $(INSTALL) -m 644 \ etc/$${f}.sample $(CONFDIR)/$$f; \ fi; \ done ifndef DMS_DEB_BUILD for f in $(CONFFILES); do \ chmod 640 $(CONFDIR)/$$f; \ done chown root:$(DMSGROUP) $(CONFDIR)/dms.conf chmod 640 $(CONFDIR)/dms.conf chown root:$(DAEMONGROUP) $(CONFDIR)/rsync-dnsconf-password chmod 640 $(CONFDIR)/rsync-dnsconf-password chown root:$(DAEMONGROUP) $(CONFDIR)/rsync-dnssec-password chmod 640 $(CONFDIR)/rsync-dnssec-password chown $(PGUSER):$(PGGROUP) $(CONFDIR)/pgpassfile chmod 600 $(CONFDIR)/pgpassfile chmod 644 $(CONFDIR)/dr-settings.sh endif for d in $(CONFSUBDIRS); do \ if [ ! -e $(CONFDIR)/$$d ]; then \ cp -R etc/$${d} $(CONFDIR); \ fi; \ done for f in $(MASTERINCFILES); do \ touch $(NAMEDCONFDIR)/$$f; \ done for f in $(CONFBINDFILES); do \ $(INSTALL) -m 644 etc/debian/bind/$${f} $(CONFBINDDIR); \ done for f in $(CONFDMSDMDFILES); do \ $(INSTALL) -m 644 etc/dmsdmd/$${f} $(CONFDMSDMDDIR); \ done chmod 755 $(CONFDMSDMDDIR)/prepare-environment chmod 755 $(CONFDMSDMDDIR)/post-start ifndef DMS_DEB_BUILD for f in $(MASTERINCFILES); do \ chown $(DAEMONUSER):bind $(NAMEDCONFDIR)/$$f; \ done for f in $(CONDBINDFILES); do \ chown root:bind $(CONFBINDDIR)/$$f; \ done endif ifeq ($(OSNAME), Linux) - $(INSTALL) -m 644 etc/debian/sysctl.d/30-dms-core-net.conf \ $(SYSCTLDIR) - $(INSTALL) -m 644 etc/systemd/system/dmsdmd.service $(SYSTEMDCONFDIR) \ && perl -pe 's~^ExecStart=/\S+/dmsdmd\s+(.*)$$~ExecStart=$(PREFIX)/sbin/dmsdmd \1~' -i $(SYSTEMDCONFDIR)/dmsdmd.service; endif install-wsgi: install-dir $(INSTALL) -d $(CONFDIR)/wsgi-scripts/list_zone; \ $(INSTALL) -d $(CONFDIR)/wsgi-scripts/dms; \ for f in $(WSGISCRIPTS); do \ $(INSTALL) -m 644 wsgi-scripts/dms/$$f \ $(CONFDIR)/wsgi-scripts/dms; \ done; \ for f in $(LISTZONEWSGISCRIPTS); do \ $(INSTALL) -m 644 wsgi-scripts/list_zone/$$f \ $(CONFDIR)/wsgi-scripts/list_zone; \ done; clean-python: - rm -rf build build-python: @$(PYTHON_INTERPRETER) setup.py build install-python: build-python install-dir # Allow python directory to be symlinked for development and debug if [ ! -e $(SHAREDIR) -o ! -L $(SHAREDIR) ]; then \ $(PYTHON_INTERPRETER) setup.py install --install-pure=$(SHAREDIR) --install-scripts=$(SHAREDIR) $(PYTHON_SETUP_OPTS) ; \ fi install-bin: install-python - for P in dyndns_tool dmsdmd zone_tool; do \ $(INSTALL) -m 755 $${P} $(SHAREDIR) \ && perl -pe 's~^#!/\S+/python3.[0-9]$$~#!$(PYTHON_INTERPRETER)~' -i $(SHAREDIR)/$${P}; \ done; - $(INSTALL) -m 755 dns-createzonekeys $(SHAREDIR) - $(INSTALL) -m 755 dns-recreateds $(SHAREDIR) - for S in dms_start_as_replica dms_promote_replica dms_master_down; do \ $(INSTALL) -m 755 dr_scripts/$${S} $(SHAREDIR)/dr_scripts; \ done; - $(INSTALL) -m 755 dr_scripts/etckeeper_git_shell $(SHAREDIR)/dr_scripts \ && perl -pe 's~^#!/\S+/python3.[0-9]\s+.*$$~#!$(PYTHON_INTERPRETER)~' -i $(SHAREDIR)/dr_scripts/etckeeper_git_shell - $(INSTALL) -m 644 postgresql/dms-schema-pg.sql $(SHAREDIR)/postgresql - $(INSTALL) -m 644 postgresql/dms-init-pg.sql $(SHAREDIR)/postgresql ifeq ($(OSNAME), Linux) - $(INSTALL) -m 755 postgresql/dms_createdb $(SHAREDIR)/postgresql \ && perl -pe 's~^DBLIBDIR=.*$$~DBLIBDIR=$(PREFIX)/share/dms/postgresql~' -i $(SHAREDIR)/postgresql/dms_createdb - $(INSTALL) -m 755 postgresql/pg_dumpallgz $(SHAREDIR)/postgresql \ && perl -pe 's~^#!/\S+/python3.[0-9]\s+.*$$~#!$(PYTHON_INTERPRETER)~' -i $(SHAREDIR)/postgresql/pg_dumpallgz - $(INSTALL) -m 644 postgresql/pg_hba.conf $(SHAREDIR)/postgresql - $(INSTALL) -m 644 postgresql/pg_ident.conf $(SHAREDIR)/postgresql - $(INSTALL) -m 644 postgresql/postgresql.conf $(SHAREDIR)/postgresql - $(INSTALL) -m 644 postgresql/30-dms-core-shm.conf $(SYSCTLDIR) endif ln -snf $(SHAREDIR)/dmsdmd $(SBINDIR) ln -snf $(SHAREDIR)/dyndns_tool $(SBINDIR) ln -snf $(SHAREDIR)/dns-createzonekeys $(SBINDIR) ln -snf $(SHAREDIR)/dns-recreateds $(SBINDIR) ln -snf $(SHAREDIR)/zone_tool $(BINDIR) ln -snf $(SHAREDIR)/zone_tool~rnano $(BINDIR) ln -snf $(SHAREDIR)/zone_tool~rvim $(BINDIR) ln -snf $(SHAREDIR)/dr_scripts/etckeeper_git_shell $(SBINDIR) ln -snf $(SHAREDIR)/dr_scripts/dms_start_as_replica $(SBINDIR) ln -snf $(SHAREDIR)/dr_scripts/dms_start_as_replica $(SBINDIR)/dms_promote_replica ln -snf $(SHAREDIR)/dr_scripts/dms_start_as_replica $(SBINDIR)/dms_prepare_binddata ln -snf $(SHAREDIR)/dr_scripts/dms_start_as_replica $(SBINDIR)/dms_master_down ln -snf $(SHAREDIR)/dr_scripts/dms_start_as_replica $(SBINDIR)/dms_master_up ln -snf $(SHAREDIR)/dr_scripts/dms_start_as_replica $(SBINDIR)/dms_update_wsgi_dns ifeq ($(OSNAME), Linux) ln -snf $(SHAREDIR)/postgresql/dms_createdb $(SBINDIR)/dms_createdb ln -snf $(SHAREDIR)/postgresql/dms_createdb $(SBINDIR)/dms_admindb ln -snf $(SHAREDIR)/postgresql/dms_createdb $(SBINDIR)/dms_dropdb ln -snf $(SHAREDIR)/postgresql/dms_createdb $(SBINDIR)/dms_editconfigdb ln -snf $(SHAREDIR)/postgresql/dms_createdb $(SBINDIR)/dms_rmconfigdb ln -snf $(SHAREDIR)/postgresql/dms_createdb $(SBINDIR)/dms_reconfigdb ln -snf $(SHAREDIR)/postgresql/dms_createdb $(SBINDIR)/dms_startdb ln -snf $(SHAREDIR)/postgresql/dms_createdb $(SBINDIR)/dms_stopdb ln -snf $(SHAREDIR)/postgresql/dms_createdb $(SBINDIR)/dms_statusdb ln -snf $(SHAREDIR)/postgresql/dms_createdb $(SBINDIR)/dms_showconfigdb ln -snf $(SHAREDIR)/postgresql/dms_createdb $(SBINDIR)/dms_restoredb ln -snf $(SHAREDIR)/postgresql/dms_createdb $(SBINDIR)/dms_dumpdb ln -snf $(SHAREDIR)/postgresql/dms_createdb $(SBINDIR)/dms_upgradedb ln -snf $(SHAREDIR)/postgresql/dms_createdb $(SBINDIR)/dms_sqldb ln -snf $(SHAREDIR)/postgresql/dms_createdb $(SBINDIR)/dms_pg_basebackup ln -snf $(SHAREDIR)/postgresql/dms_createdb $(SBINDIR)/dms_write_recovery_conf ln -snf $(SHAREDIR)/postgresql/dms_createdb $(SBINDIR)/dms_replicadb ln -snf $(SHAREDIR)/postgresql/dms_createdb $(SBINDIR)/dms_promotedb ln -snf $(SHAREDIR)/postgresql/dms_createdb $(SBINDIR)/dms_move_xlog ln -snf $(SHAREDIR)/postgresql/dms_createdb $(SBINDIR)/dms_pgversion ln -snf $(SHAREDIR)/postgresql/pg_dumpallgz $(SBINDIR)/pg_dumpallgz endif doc: make -C $(DOCDIR) $(DOCTARGETS) install-doc: doc - for D in $(DOCTARGETS); do \ install -d $(DOCUMENTATIONDIR)/$${D}; \ cp -R $(DOCDIR)/_build/$${D}/* $(DOCUMENTATIONDIR)/$${D}; \ done; clean: clean-python make -C $(DOCDIR) clean dms-1.0.8.1/README000066400000000000000000000021401322726514000133210ustar00rootroot00000000000000dms, the DNS Management System This code comprises the dmsdmd DNS management daemon, zone_tool, dyndns_tool, the Python 3 dms modules, and associated SQL schemas and management shell scripts. See INSTALL for installation instructions. Note: dms depends on py-magcode-core up at https://github.com/grantma/py-magcode-core.git Programming kindly sponsored by Voyager Internet Ltd, http://www.voyager.co.nz/ Released under GPL v3 or later. See COPYING. Dms 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 3 of the License, or at your option) any later version. Dms 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 dms. If not, see . Matthew Grant Sun, 14 Jul 2013 21:18:00 +1200 dms-1.0.8.1/debian/000077500000000000000000000000001322726514000136665ustar00rootroot00000000000000dms-1.0.8.1/debian/README.Debian000066400000000000000000001266731322726514000157460ustar00rootroot00000000000000DNS Management System --------------------- The DNS Management System (DMS) is designed to have a master/replica master setup. It is a complex setup, requiring the hand configuration of database, DNS server, and other components. Single Master Server -------------------- If your setup does not require one of the components such as quagga, dms-wsgi, or etckeeper, just skip that section. Just install dms-core apt-get install --install-recommends --install-suggested dms-core At least install reccomends above, as this will pull in IPSEC to protect the connections between the master and slave servers. This is fair more secure than relying on MD5 HMAC for tamper proofing. DNS Topology ------------ The description below will set up a Master DR setup with hidden master DNS. Other topogies are possible, which are useful for smaller environments. You can run without DR, and the Master server can also be 'unhidden' on the Internet itself. Just take what you need from below. A PDF of the Wiki for DMS for when it was internal to Net24 is available up at http://mattgrant.net.nz/software/dms It is advisable to get this and read it, as it will explain a lot of how this all functions. There is a wiki documentation area to be set up, keep an eye on http://mattgrant.net.nz/software/dms for news of this. vim --- Create the file /etc/vim/vimrc.local and add the following to it to enable DNS syntax highlighting etc: ----- "Turn on syntax highlighting for DNS etc filetype plugin indent on syntax on ----- Repeat on DR master server as well. less ---- Set the follwoing environment variable in /etc/profile, or /etc/bashrc LESS=-MMRi This will display the colorized output produced by colordiff Repeat on DR master server as well. etckeeper and ssh ----------------- etckeeper is a tool to keep the contents of /etc in a git VCS. When combined with ssh and the appropriate git remote setup with cron, it allows the /etc of the other machine in the master/replica DR pair to be kept on its alternate, and vice-versa. The following is a safeguard against Murphies law (ie Back hoe fade, backups required at disconnected data centre or offline storage 2 days away). My own experience is my witness. This protects aginst the /etc on the master being updated, the replica being missed, and then finding that things aren't working on the replica when the master dies , with no record of the updates needed to machine configuration. For information on etckeeper usage, see /usr/share/doc/etckeeper/README.gz Example for diffing/checking out /etc/racoon/racoon-tool.conf from other machine: dms-master1:/etc# git diff dms-master2/master racoon/racoon-tool.conf dms-master1:/etc# git checkout dms-master2/master racoon/racoon-tool.conf dms-master1:/etc# git checkout HEAD racoon/racoon-tool.conf 1) etckeeper installation. Before installing etckeeper, you need to add a .gitignore to /etc to prevent /etc/shadow and other secrets files from ending up in etckeeper for security reasons. The contents of the seed /etc/.gitignore file is: ----- # Ignore these files for security reasons krb5.keytab shadow shadow- racoon/psk.txt ipsec.secrets ssl/ ssh/moduli ssh/ssh_host_* ----- You probably have to purge etckeeper removing the initial /etc git archive if you are reading this, create the .gitignore file, and reinstall etckeeper: # dpkg --purge etckeeper # vi /etc/.gitignore # aptitude install etckeeper Now would be a good time to install dms on both Master and Replica # apt-get install --install-recommends --install-suggested dms as this will install scripts needed for ssh configuration following. 1) Set up ssh. As root on both boxes, turn off the following settings in sshd_config: RSAAuthentication no PubkeyAuthentication no RhostsRSAAuthentication no HostbasedAuthentication no ChallengeResponseAuthentication no PasswordAuthentication no GSSAPIAuthentication no X11Forwarding no UsePAM no Then add the following to /etc/ssh/sshd_config, and adjust your network and administrative sshd authentication settings: ----- UsePAM no AllowTcpForwarding no AllowAgentForwarding no X11Forwarding no PermitTunnel no AllowGroups sudo root # Section for DMS master/replica servers Match Address 2001:db8:f012:2::3/128,2001:db8:ba69::3/128 PubkeyAuthentication yes # PermitRootLogin forced-commands-only # The above only works with commands given in authorized_keys PermitRootLogin without-password ForceCommand /usr/sbin/etckeeper_git_shell # Section for administrative access Match Address 2001:db8:ba69::/48,192.0.2.0/24,201.0.113.2/32 PermitRootLogin yes GSSAPIAuthentication yes PubkeyAuthentication yes MaxAuthTries 10 X11Forwarding yes AllowTcpForwarding yes AllowAgentForwarding yes ----- Reload sshd on both servers: # service ssh reload Create a passwordless ssh key on both servers as root, and copy the public part of the key to /root/.ssh/authorized_keys. # mkdir /root/.ssh # ssh-keygen -f /root/.ssh/id_gitserve_rsa -t rsa -q -N '' # vi /root/.ssh/config and set contents of ssh config as follows, changing Host as appropriate: ----- Host dms3-dr* IdentityFile ~/.ssh/id_gitserve_rsa ----- It is also a good idea to set up a /etc/hosts file entries on each server. Set up /root/.ssh/authorized_keys: ----- # mkdir /root/.ssh # cat - > /root/.ssh/authorized_keys ----- Cut and paste /root/.ssh/id_gitserve_rsa.pub from other machine into above, finishing with ^D. Then do vice-versa, to make the other direction functional. Check that things work on both hosts: # ssh -l root dms-master2 Rejected Connection to dms-master2 closed. etc. Note: Stopping ssh and running sshd from the commandline '/usr/sbin/sshd -d' on one, and then using 'ssh -vl root' on the other (and vice versa) is very useful for connection debugging. 2) Git remote set up to pair up /etc archives. As root do: dms-master1# git remote add dms-master2 ssh://dms-master2.someorg.net/etc and vice versa Check that both work by executing: dms-master1:/etc# git fetch --quiet dms-master2 and vice versa 3) Set up crond. Edit the file /etc/cron.d/dms-core, uncomment the line for git fetch, and set the remote name: ----- # Replicate etckeeper archive every 4 hours 7 */4 * * * root cd /etc && /usr/bin/git fetch --quiet dms-master2 ----- Do test each cron command by running it from the root command line. IPSEC set up ------------ The DMS system uses IPSEC to authenticate server access to the master servers, encrypting and/or integrity protecting the outgoing zone transfers, rndc and configuration rsync traffic. Each server has IPSEC configured and active to both the replica servers (master and DR). The master and replica have IPSEC configured as well. Both replica servers and 2 slaves should be PSK keyed with each other if DNSSEC authentication is to be used for the majority of slaves. This ensures that the DNSSEC CERT records can be progated for use. Make SURE each individual IPSEC connection has a unique PSK key for security. They can be generated easily, and cut/paste over terminal root session, so no big loss if they are lost. Just make sure you have 'out-of-band' access via ssh. Read through the Strongswan section as it has some useful tips on PSK generation and other matters. Sysctl IPSEC settings --------------------- To prevent network problems with running out of buffers, create the file /etc/sysctl.d/30-dms-core-net.conf with the following contents: ---- # Tune kernel for heavy IPSEC DNS work. # Up the max connection buffers net.core.somaxconn=8192 net.core.netdev_max_backlog=8192 # Reduce TCP final timeout net.ipv4.tcp_fin_timeout=10 # Increase size of xfrm tables net.ipv6.xfrm6_gc_thresh=16384 net.ipv4.xfrm4_gc_thresh=16384 ---- and then reload sysctls with # service procps start Strongswan IPSEC set up ----------------------- This is only covering basic PSK set up. If X509 needed see the Strongswan wiki: http://wiki.strongswan.org/projects/strongswan/wiki/UserDocumentation The same PSK has to be at each end of the IPSEC 'connection'. Generate PSK key with openssl: # openssl rand -hex 64 and place in /etc/ipsec.secrets: ----- 2001:db8:345:678:2::beef : PSK 0xe788749d48c0a020bc26b15685ad7ea1630c090072acf3f1eeac14dfec90bd4c1ff86fbf82b219cb5c309c3c6ede2d072784823a69271eccce166421317be006 ----- Note format, "IPv6/IPv4/DNS-type-id : PSK 0xdaedbefdeadbeef" ... Racoon also takes hex strings as PSK, just add the '0x' to the random number. Sha1 and sha256 only use 64 bytes (512 bits) for the key. sha384 and better 128 bytes. Making the strings longer does not make sense, and can result in some wacky behaviour with strongswan! Set up /etc/ipsec.conf at each end: ----- conn %default ikelifetime=60m keylife=20m rekeymargin=3m keyingtries=1 keyexchange=ikev2 mobike=no installpolicy=yes conn dms-master2 authby=secret right=2001:db8:f012:2::2 rightid=dms-master2.someorg.net left=2001:db8:f012:2::3 leftid=dms-master1.someorg.net type=transport #ah=sha256-modp2048,sha1-modp1024 auto=route ----- and vice versa. Note use of id statements. It saves having to bury IP numbers in more than one place. "auto=route" sets up SPD (use ip xfrm policy to inspect), and when dynamically bring up the connection when needed. AH (authentication header) can be turned on by defining AH protocol at each end. This is useful inside DMZ or back end networks, and allows the traffic to be inpected by a decent filtering firewall. Reload ipsec by: ----- dms-master1 # ipsec reload dms-master1 # ipsec rereadsecrets dms4-master # ipsec reload dms4-master # ipsec rereadsecrets Enter a separate PSK in /etc/ipsec.secrets for each IPSEC connection. Useful ipsec commands are: # ipsec status # ipsec statusall # ip xfrm policy # ip xfrm state # ipsec up # ipsec down # ipsec reload # ipsec rereadsecrets # ipsec restart. Test the connection by pinging the far end - tests unencrypted reachability, and then telnet/netcat the different TCP ports used across the link. This will involve ports 873 (rsync), 953 (rndc/named), 53 (named) to each slave, and port 53 on the masters (from slave). Between both the replica servers (master and DR), port 5432 (postgresql) has to be reachable, as well as port 22 (ssh). Port 80 (http) for apt-get updates may also be involved. Racoon IPSEC set up ------------------- An alternative to Strongswan is to use racoon. This might be a better solution if you are working with a lot of NetBSD or FreeBSD based systems. This is only covering basic PSK set up. For X509 etc, see /usr/share/doc/racoon/README.Debian On each machine, dpkg-reconfigure racoon, and choose the "racoon-tool" configuration method. Edit /etc/racoon/racoon-tool.conf, and add the machines source IP address: ----- connection(%default): src_ip: 192.168.102.2 admin_status: disabled ----- Add the other replica server and each DNS as a separate configuration fragment in /etc/racoon/racoon-tool.conf.d, named after the machine's short hostname: ----- peer(192.168.102.2): connection(dms-master2-eth1): dst_ip: 192.168.102.2 # defaults to esp # encap: ah admin_status: enabled ----- For the replica servers, if you want to inspect/control traffic select ah IPSEC encapsulation. Note, racoon-tool sets up a transport mode IPSEC connection if no src_range/dst_range parameters are given. For Racoon-tool only, transport mode used to not encrypt ICMP traffic, as that can complicate UDP/TCP connection issues extensively. This will be changed very shortly to conventionally encrypting IPSEC to be compatible with other IPSEC solutions. Also enter a separate PSK in /etc/racoon/psk.txt for each IPSEC connection. Useful racoon-tool commands are: # racoon-tool vlist # racoon-tool spddump # racoon-tool saddump # racoon-tool vup # racoon-tool vdown # racoon-tool reload # racoon-tool restart. Test the connection by pinging the far end - tests unencrypted reachability, and then telnet/netcat the different TCP ports used across the link. This will involve ports 873 (rsync), 953 (rndc/named), 53 (named) to each slave, and port 53 on the masters (from slave). Between both the replica servers (master and DR), port 5432 (postgresql) has to be reachable, as well as port 22 (ssh). Port 80 (http) for apt-get updates may also be involved. Firewalling on IPSEC links to Master Servers -------------------------------------------- The Master servers need protection on the IPSEC connections from the slave servers, and each other as the SPD does not have any sense fo connection direction, and it ispossble to connect to all the services on the Master Servers. The netscript-ipfilter package can save the iptables/ip6tables filters that you create. Use the policy match module to match decrypted traffic coming from the IPSEC connection An example ip6tables output: shalom-ext: -root- [/tmp/zones] # ip6tables -vnL INPUT Chain INPUT (policy ACCEPT 472K packets, 134M bytes) pkts bytes target prot opt in out source destination 0 0 REJECT all * * fd14:828:ba69:2::3 ::/0 reject-with icmp6-port-unreachable 157K 20M ipsec-in all * * ::/0 ::/0 policy match dir in pol ipsec shalom-ext: -root- [/tmp/zones] # ip6tables -vnL ipsec-in Chain ipsec-in (1 references) pkts bytes target prot opt in out source destination 138K 16M ACCEPT all * * ::/0 ::/0 ctstate RELATED,ESTABLISHED 0 0 ACCEPT udp * * ::/0 ::/0 udp spt:500 dpt:500 0 0 icmphost icmpv6 * * ::/0 ::/0 198 18580 ACCEPT udp * * ::/0 ::/0 ctstate NEW udp dpt:53 17474 3629K ACCEPT udp * * ::/0 ::/0 ctstate NEW udp dpt:514 118 9440 ACCEPT tcp * * ::/0 ::/0 ctstate NEW tcp dpt:53 0 0 ACCEPT tcp * * 2001:470:f012:2::3 ::/0 ctstate NEW tcp dpt:953 0 0 ACCEPT tcp * * 2001:470:f012:2::3 ::/0 ctstate NEW tcp dpt:5432 0 0 ACCEPT tcp * * 2001:470:f012:2::3 ::/0 ctstate NEW tcp dpt:5433 0 0 ACCEPT tcp * * 2001:470:f012:2::3 ::/0 ctstate NEW tcp dpt:873 0 0 ACCEPT tcp * * 2001:470:f012:2::3 ::/0 ctstate NEW tcp dpt:22 0 0 ACCEPT tcp * * 2001:470:f012:2::3 ::/0 ctstate NEW tcp dpt:113 0 0 ACCEPT tcp * * 2001:470:f012:2::3 ::/0 tcp dpt:80 ctstate NEW 0 0 tcp * * 2001:470:f012:2::3 ::/0 tcp dpt:80 ctstate NEW 0 0 ACCEPT tcp * * fd14:828:ba69:1:21c:f0ff:fefa:f3c0 ::/0 ctstate NEW tcp dpt:80 128 10240 ACCEPT tcp * * fd14:828:ba69:1:21c:f0ff:fefa:f3c0 ::/0 ctstate NEW tcp dpt:22 0 0 ACCEPT tcp * * 2001:470:c:110e::2 ::/0 ctstate NEW tcp dpt:80 0 0 ACCEPT tcp * * 2001:470:66:23::2 ::/0 ctstate NEW tcp dpt:80 607 43704 log all * * ::/0 ::/0 shalom-ext: -root- [/tmp/zones] The icmphost and log chains are created by using 'netscript ip6filter exec log' and 'netscript ip6filter exec icmphost'. IPv6 helper chains created from RFC 4890 - 'Recommendations for Filtering ICMPv6 Messages in Firewalls' Read /etc/netscript/network.conf, and the manpage netscript The useful commands are: netscript ipfilter/ip6filter reload netscript ipfilter/ip6filter save netscript ipfilter/ip6filter exec icmphost (create an incoming ICMP filter for host traffic) netscript ipfilter/ip6filter usebackup PostgresQL DB Setup and Master/Replica Configuration ---------------------------------------------------- DB user and DB creation only has to happen on the initial master server, as it will be 'mirrored' to the replica once DB replication is established. The replica server will configured to run in 'hot-standby' mode so that we can verify mirroring by read-only means using zone_tool. Though the master and replica can run the PGSQL dms cluster on port 5433 or other port, it is reccommended to swap the ports with the main cluster, and revert the main cluster to manual start up. Edit postgresql.conf /etc/postgresql/9.3/main and /etc/postgresql/9.3/dms, and swap the settings for 'port =', making dms port 5432. Edit /etc/postgresql/9.3/main/start.conf, and set it to manual. Stop posgresql, and start it, (restart will probably result in failure due to a port clash...): # pg_ctlcluster 9.3 main stop # service postgresql stop # service postgresql start Use etckeeper to migrate the configuration to the replica: dms-master1:/etc# etckeeper commit dms-master2:/etc# git fetch dms-master1 dms-master2:/etc/# git checkout dms-master1/master postgresql/9.3/main postgresql/9.3/dms dms-master2:/etc# pg_ctlcluster 9.3 main stop dms-master2:/etc# service postgresql stop dms-master2:/etc# service postgresql start On the master, set the DB passwords for the dms user and the ruser (they will be copied to the replica when mirroring is started): root@dms-master1:/home/grantma# pwgen -acn 16 10 (to pick your password) root@dms-master1:/home/grantma# psql -U pgsql dms psql (9.3.3) Type "help" for help. dms=# \password ruser Enter new password: Enter it again: dms=# \password dms Enter new password: Enter it again: dms=# \q Note: The pgsql database super user exists for cross OS/distro compatibility reasons. Record the 2 passwords you have just set for reference. Put the ruser password in /etc/dms/pgpassfile on both machines, updating the hostnames part of the entry as well, which is in the standard PGSQL format (see section 31.14 in "PostgreSQL 9.3.3 Documentation"). NB: You will have to alter the machine name and password. Use vi or vim as root to prevent permissions and ownership alteration. Also edit /etc/dms/dms.conf, and set the dms db_password for zone_tool on both machines as zone_tool uses password access unless user is in pg_ident.conf Connecting Replica and Starting Replication ------------------------------------------- On the master, and replica, set the replication address in pg_hba.conf: dms-master1:/root# dms_admindb -r dms-master2.someorg.net dms-master2:/root# dms_admindb -r dms-master1.someorg.net Set up PGSQL recovery.conf, and start replica DB: dms-master2:/root# service postgresql stop dms-master2:/root# dms_pg_basebackup dms-master1.someorg.net dms-master2:/root# dms_write_recovery_conf dms-master1.someorg.net dms-master2:/root# service postgresql start Note: The above is seeing DB replica functionality from the default DB as master Edit /etc/dms/dr-settings.sh, and update DR_PARTNER to the name of the opposite server in the DR pair. Check that replication is running by seeing if zone_tool can access default configuration settings: dms-master2:/root# zone_tool show_config root@dms-master2:/home/grantma# zone_tool show_config auto_dnssec: false default_ref: someorg default_sg: someorg-one default_stype: bind9 edit_lock: false event_max_age: 120.0 inc_updates: false nsec3: false soa_expire: 7d soa_minimum: 24h soa_mname: ns1.someorg.net. (someorg-one) soa_refresh: 7200 soa_retry: 7200 soa_rname: soa.someorg.net. syslog_max_age: 120.0 use_apex_ns: true zi_max_age: 90.0 zi_max_num: 25 zone_del_age: 0.0 zone_del_pare_age: 90.0 zone_ttl: 24h Master/Replica rsyncd setup --------------------------- Both the machines will have to rsync from one another, depending on which is running as the DR replica. So we are setting up rsync client passwords, and rsyncd configuration on one, and using the same settings on the other machine. Add the following to /etc/rsyncd.conf ----- hosts allow = 2001:db8:f012:2::2/128 2001:db8:f012:2::3/128 secrets file = /etc/rsyncd.secrets [dnsconf] path = /var/lib/dms/rsync-config uid=bind gid=bind comment = Slave server config area auth users = dnsconf use chroot = yes read only = no [dnssec] path = /var/lib/bind/keys uid=bind gid=dmsdmd comment = DNSSEC key data area auth users = dnssec use chroot = yes read only = no ----- adjusting IP addresses as needed. And also set up the /etc/rsyncd.secrets file: ----- dnsconf:SuperSecret dnssec:PlainlyNotSecret ----- making it only readable by root: # chown root:root /etc/rsyncd.secrets # chmod 600 /etc/rsyncd.secrets and set the passwords /etc/dms/rsync-dnssec-password and /etc/dms/rsync-dnsconf-password using vi to preserve permissions. and enable the rsyncd daemon in /etc/default/rsync, and start the service. # service rsync start Use etckeeper to mirror the config to the replica: dms-master1:/etc# etckeeper commit dms-master2:/etc# git fetch dms-master1 dms-master2:/etc/# git checkout dms-master1/master rsyncd.secrets rsyncd.conf /etc/default/rsync dms/rsync-dnsconf-password dms/rsync-dnssec-password dms-master2:/etc/# chmod 600 /etc/rsyncd.secrets And start rsyncd on the replica as well. Check that you can connect to the rsync port on one from the other machine, and vice-versa. root@dms-master2:/home/grantma# telnet dms-master1 rsync Trying 192.168.101.2... Connected to dms-master1.someorg.net. Escape character is '^]'. @RSYNCD: 30.0 ^]c telnet> c Connection closed. root@dms-master2:/home/grantma# Lets create the master sg, and disabled replica servers (DMS master and DR), and check that the DR slave named config can be rsynced. dms-master1:/etc/# zone_tool zone_tool > create_sg -p someorg-master /etc/dms/server-config-templates 2001:db8:f012:2::2 2001:db8:f012:2::3 zone_tool > create_server -g someorg-master dms-master2 2001:db8:f012:2::2 zone_tool > create_server -g someorg-master dms-master1 2001:db8:f012:2::3 zone_tool > rsync_server_admin_config dms-master2 no_rndc zone_tool > dms-master2:/etc/# zone_tool zone_tool > rsync_server_admin_config dms-master1 no_rndc zone_tool > Look in /var/log/syslog on the rsyncd server to debug issues. Setting up rsyslog on Master and Replica ---------------------------------------- On the master, create the file /etc/rsyslog.d/00network.conf with the contents: ----- # provides UDP syslog reception $ModLoad imudp $UDPServerRun 514 # provides TCP syslog reception $ModLoad imtcp $InputTCPServerRun 514 #$AllowedSender UDP, [2001:db8:c:110e::2] #$AllowedSender TCP, [2001:db8:c:110e::2] #$AllowedSender UDP, [2001:db8:66:23::2] #$AllowedSender TCP, [2001:db8:66:23::2] #$AllowedSender UDP, [2001:db8:ba69:1:21c:f0ff:fefa:f3c0] #$AllowedSender TCP, [2001:db8:ba69:1:21c:f0ff:fefa:f3c0] ----- All replica and slave DNS servers will have to be entered into this file. Also alter the file /etc/rsyslog.d/pgsql and change the contents to: ----- ### Configuration file for rsyslog-pgsql ### Changes are preserved $ModLoad ompgsql local7.* /var/log/local7.log local7.* :ompgsql:/var/run/postgresql,dms,rsyslog, ----- Do the same for the replica, apart from the following: IMPORTANT: On the Replica, comment out the last local7.* line. Don't change the contents of that line, as the administration scripts go searching for exactly that line. Replica file is as follows: ----- ### Configuration file for rsyslog-pgsql ### Changes are preserved $ModLoad ompgsql local7.* /var/log/local7.log #local7.* :ompgsql:/var/run/postgresql,dms,rsyslog, ----- The default configuration propagated to the DMS servers uses local7 as the named logging facility. Setting initial DR settings on both machines -------------------------------------------- On both machines, edit /etc/dms/dr-settings.sh, and set DR_PARTNER to the name of the opposite machine. dms-master1# vi /etc/dms/dr-settings.sh # Settings file for dr-scripts and Net24 PG database scripts # DR Partner server host name # ie default dms_start_as_replica master # This is the exact DNS/host name which you have to replicate from DR_PARTNER="dms4-d4-dr.someorg.net . . . The rest of the file is for type of DR fail over - by IP on a loop back interface and/or routing, or by a failover domain in the DNS. We will set this up later. Setting up Bind9 master DNS server ---------------------------------- Create all the required TSIG rndc and dynamic DNS update keys, and generate required /etc/bind/rndc.conf: (If any of these commands stall, VM/machine does not have enough entropy. Make sure haveged is installed and running.) root@dms-master1:/etc/dms/bind# zone_tool generate_tsig_key -f update-ddns hmac-sha256 update-session.key root@dms-master1:/etc/dms/bind# zone_tool generate_tsig_key -f rndc-key hmac-md5 rndc-local.key root@dms-master1:/etc/dms/bind# zone_tool generate_tsig_key -f remote-key hmac-md5 rndc-remote.key root@dms-master1:/etc/dms/bind# zone_tool write_rndc_conf -f root@dms-master1:/etc/dms/bind# cp -a rndc-remote.key /etc/dms/server-admin-config/bind9 root@dms-master1:/etc/dms/bind# cp rndc-remote.key /var/lib/dms/rsync-config Add the /etc/dms/bind/named.conf to /etc/default/bind9, and add a line to get rid of the default rndc.key to stop rndc complaining: ----- # Get rid of default bind9 rndc.key, that debian install scripts always # generate Stops rndc complaining: rm -f /etc/bind/rndc.key # run resolvconf? RESOLVCONF=no # startup options for the server OPTIONS="-u bind -c /etc/dms/bind/named.conf" ----- Create /etc/bind/rndc.conf, to include the following: ----- # include rndc configuration generated by DMS zone_tool include "/var/lib/dms/rndc/rndc.conf"; ----- Restart named to make sure all is good: root@dms-master1:/etc/bind# service bind9 stop root@dms-master1:/etc/bind# service bind9 start root@dms-master1:/etc/bind# rndc status version: 9.9.5-2-Debian CPUs found: 1 worker threads: 1 number of zones: 5 debug level: 0 xfers running: 0 xfers deferred: 0 soa queries in progress: 0 query logging is OFF recursive clients: 0/0/1000 tcp clients: 0/100 server is up and running Enable dmsdmd, the dynamic DNS update and DMS event daemon by editing /etc/default/dmsdmd, setting DMSDMD_ENABLE=true, and start it: root@dms-master1:/etc# vi /etc/default/dmsdmd root@dms-master1:/etc# service dmsdmd start [ ok ] Starting dmsdmd: dmsdmd. root@dms-master1:/etc# service dmsdmd status [ ok ] dmsdmd is running. Enable the master server so that the server SM can monitor named on the machine (briefly, this server twitters to itself): root@dms-master1:/etc# zone_tool enable_server dms-master1 This means that when dmsdmd is started, it will set up an index in the Master SM in the DB to the Master server in the ServerSM table (important for keeping track of where the master is for human output and ServerSM functionality - uses machines actual network addresses cf. master_address and master_alt_address in replica SG) And make sure you can create a domain: root@dms-master1:/etc/dms/bind# zone_tool create_zone foo.bar.org root@dms-master1:/etc/dms/bind# zone_tool show_zone foo.bar.org $TTL 24h $ORIGIN foo.bar.org. ; ; Zone: foo.bar.org. ; Reference: someorg ; zi_id: 1 ; ctime: Mon Jul 2 11:30:26 2012 ; mtime: Mon Jul 2 11:31:03 2012 ; ptime: Mon Jul 2 11:31:03 2012 ; ;| Apex resource records for foo.bar.org. ;!REF:someorg @ IN SOA ( ns1.someorg.net. ;Master NS soa.someorg.net. ;RP email 2012070200 ;Serial yyyymmddnn 7200 ;Refresh 7200 ;Retry 604800 ;Expire 86400 ;Minimum/Ncache ) IN NS ns2.someorg.net. IN NS ns1.someorg.net. root@dms-master1:/etc/dms/bind# zone_tool show_zonesm foo.bar.org name: foo.bar.org. alt_sg_name: None auto_dnssec: False ctime: Mon Jul 2 11:30:26 2012 deleted_start: None edit_lock: False edit_lock_token: None inc_updates: False lock_state: EDIT_UNLOCK mtime: Mon Jul 2 11:30:26 2012 nsec3: False reference: someorg soa_serial: 2012070200 sg_name: someorg-one state: PUBLISHED use_apex_ns: True zi_candidate_id: 1 zi_id: 1 zone_id: 1 zone_type: DynDNSZoneSM zi_id: 1 ctime: Mon Jul 2 11:30:26 2012 mtime: Mon Jul 2 11:31:03 2012 ptime: Mon Jul 2 11:31:03 2012 soa_expire: 7d soa_minimum: 24h soa_mname: ns1.someorg.net. soa_refresh: 7200 soa_retry: 7200 soa_rname: soa.someorg.net. soa_serial: 2012070200 soa_ttl: None zone_id: 1 zone_ttl: 24h root@dms-master1:/etc/dms/bind# dig -t AXFR +noall +answer foo.bar.org @localhost foo.bar.org. 86400 IN SOA ns1.someorg.net. soa.someorg.net. 2012070200 7200 7200 604800 86400 foo.bar.org. 86400 IN NS ns1.someorg.net. foo.bar.org. 86400 IN NS ns2.someorg.net. foo.bar.org. 86400 IN SOA ns1.someorg.net. soa.someorg.net. 2012070200 7200 7200 604800 86400 root@dms-master1:/etc/dms/bind# zone_tool delete_zone foo.bar.org Reflect the bind and dms directories to the DR via etckeeper: root@dms-master1:/etc# etckeeper commit root@dms-master2:/etc# git fetch dms-master1 root@dms-master2:/etc# git checkout dms-master1/master dms/bind root@dms-master2:/etc# git checkout dms-master1/master bind root@dms-master2:/etc# git checkout dms-master1/master default/bind9 Setting UP DR bind9 slave server on Replica ------------------------------------------- Edit /etc/dms/server-admin-config/bind9/controls.conf and add each masters IP address to the uncommented inet allow line. IPv4 address will have to be prefixed with '::ffff:' as by default Linux binds v6 sockets to IPv4. Rsync the admin config from the master to the DR replica, not doing any rndc reconfig: root@dms-master1:/etc# zone_tool rsync_server_admin_config dms-master2 no_rndc Copy the /etc/dms/server-admin-config/bind9 directory to /var/lib/dms/rsync-config root@dms-master1:/etc# cp -a /etc/dms/server-admin-config/bind9/* /var/lib/dms/rsync-config root@dms-master1:/etc# chown bind:bind /var/lib/dms/rsync-config/* Reflect the bind directory to the DR via etckeeper: root@dms-master1:/etc# etckeeper commit root@dms-master2:/etc# git fetch dms-master1 root@dms-master2:/etc# git checkout dms-master1/master dms/server-admin-config To apply permissions on master to replica: root@dms-master2:/etc# git checkout dms-master1/master .etckeeper root@dms-master2:/etc# etckeeper init root@dms-master2:/etc# etckeeper commit Create rndc.conf include needed to start bind. root@dms-master2:/etc# zone_tool write_rndc_conf On the replica, Edit /etc/default/bind9, adding '-c /etc/bind/named-dr-replica.conf' to OPTIONS, and restart named. root@dms-master2:/etc# service bind9 restart On the master, enable the DR replica server in the replica SG: root@dms-master1:/etc# zone_tool enable_server dms-master2 Check by switching between master and replica: root@dms-master1:/etc# dms_master_down root@dms-master2:/etc/# dms_promote_replica root@dms-master1:/etc# dms_start_as_replica dms-master2.someorg.net Wait for synchronisation to be shown 15 - 20 minutes: root@dms-master2:/etc# zone_tool show_replica_sg -v sg_name: someorg-master config_dir: /etc/dms/server-config-templates master_address: 192.168.101.2 master_alt_address: 192.168.102.2 replica_sg: True sg_id: 2 zone_count: 0 Slave Servers: dms-master2 192.168.102.2 OK dms-master1 192.168.101.2 OK and switch back as above. Importing Zones to DMS system ----------------------------- Set the default settings shown in zone_tool show_config on the DMS master. root@dms-master1:/etc# zone_tool show_config root@dms-master1:/etc# zone_tool set_config soa_mname ns1.foo.bar.net root@dms-master1:/etc# zone_tool set_config soa_rname soa.foo.bar.net root@dms-master1:/etc# zone_tool set_config default_sg foo-bar-net root@dms-master1:/etc# zone_tool set_config default_ref FOO-BAR-NET root@dms-master1:/etc# zone_tool show_apex_ns root@dms-master1:/etc# zone_tool edit_apex_ns Create the default sg root@dms-master1:/etc# zone_tool create_sg someorg-one Aside: Apex ns records can be created and edited for each server group. By default, the apex_ns records for the default SG are used. Use: zone_tool> show_apex_ns some-sg zone_tool> edit_apex_ns some-sg to create and edit the apex NS server names. Create all required reverse zone on the master, setting the zone_tool create_zone inc_updates flag argument so that auto reverse zone records can be created and managed. root@dms-master1:/etc# zone_tool create_zone 2001:2e8:2012::/32 inc_updates Import all the zones. First of all, load the apex zone which contains the ns1/ns2 records with no_use_apex_ns, then load all the rest. Its an idea to have a look at the edit_lock flag at the same time for those top zone(s). Note that zone_tool load_zones requires all files to be named by full domain name. root@dms-master1:/some/dir/with/zone/files# zone_tool load_zone foo.bar.net foo.bar.net no_use_apex_ns edit_lock root@dms-master1:/some/dir/with/zone/files# zone_tool load_zones * Setting up failover domain -------------------------- This is the easiest way to repoint the Web UIs at the correct master server. Anothe alternative is to use a loop back interface with a floating IP address, and propagation via routing or simply by being on the ethernet segment. At the moment the itnerface method requires the installation of netscript-2.4 instead of ifupdown. 1. Create a failover domain This needs to be updateable by incremental updates --- zone_tool > create_zone failover.somorg.net inc_updates --- 2. Edit /etc/dms/dr-settings.sh, enable DMSDRDNS, set DMS_FAILOVER_DOMAIN, the DMS_WSGI_LABEL (DNS host that 'floats' to where master is), and the TTL ---- # zone_tool update_rrs settings, for WSGI DNS name # Uses a CNAME based template. # Following is a flag to turn it on or off DMSDRDNS=true # If not defined or empty, the following is set to the hostname DMS_MASTER="" DMS_FAILOVER_DOMAIN="failover.someorg.net." DMS_WSGI_LABEL="dms-server" DMS_WSGI_TTL="30s" DMS_UPDATE_RRS_TEMPLATE=' $ORIGIN @@DMS_FAILOVER_DOMAIN@@ $UPDATE_TYPE wsgi-failover ;!RROP:UPDATE_RRTYPE @@DMS_WSGI_LABEL@@ @@DMS_WSGI_TTL@@ IN CNAME @@DMS_MASTER@@ ' ---- 3. Repeat 2. on DR server 4. Fail over system back and forth to establish DNS records and test dms-master1 # dms_master_down dms-master2 # dms_promote_replica dms-master1 # dms_start_as_replica . . . and reverse: . . . dms-master2 # dms_master_down dms-master1 # dms_promote_replica dms-master2 # dms_start_as_replica And you should be good to go, with a DMS WSGI server name of "dms-server.failover.someorg.net." Setting up WSGI on apache ------------------------- Enable WSGI in /etc/dms/dr-settings.sh on both machines by editing file. Include the /etc/dms/dms-wsgi-apache.conf fragment into the file /etc/apache2/sites-available/default-ssl Set the apache log level to info, delete the cgi-bin section, and set up the SSL certificates. Create the htpasswd file /etc/dms/htpasswd-dms, and set the passwords for admin-dms, helpdesk-dms, value-reseller-dms, hosted-dms WSGI users. Also don't forget to: dms-master1 # cd /etc/dms dms-master1 # chown root:www-data htpasswd-dms dms-master1 # chmod 640 htpasswd-dms Use a2ensite and a2dissite to enable the SSL default site # a2dissite default # a2ensite default-ssl Reload apache2 # service apache2 reload Reflect configuration as above to DR partner server Check that it functions by using curl on the master server: # cd /tmp # cp -a /usr/share/doc/dms-core/examples/wsgi-json-testing . # cd wsgi-json-testing Edit json-test.sh so that it works for you, re URLs and user/password. test4.jsonrpc uses list_zone, so try that first to check WSGI is live. # ./json-test.sh test4 It is helpful to edit curl command to include --insecure if you are using a self-signed SSL cert It may take a while before anything shows up if you have imported tens of thousands of zone. Full error information will be shown in the configured apache error log /var/log/apache2/error.log. You can also try some of the other example tests as well after editing them for the current setup. Edit the WSGI configuration in /etc/dms to your liking. See documentation for more details. Mirror apache2 config to other DR partner server. dms-master1 # etckeeper commit dms-master2 # cd /etc dms-master2 # git fetch dms-master1 dms-master2 # git checkout dms-master1/master apache2 dms/htpasswd-dms \ dms/dms-wsgi-apache.conf dms/wsgi-scripts Fix permissions: dms-master2 # git checkout dms-master1/master .etckeeper dms-master2 # etckeeper init dms-master2 # etckeeper commit NOTE: Also try some of the readonly tests on the other DR partner server to make sure WSGI is functional there. You will have to fail over to do this. ================================= Setting up a Slave DNS Server ================================= Based on Debian Wheezy. Has 2 connections back to DMS DR partner servers. You can leave one server out for racoon if only running one single DMS master server. To prevent installation of recommended packages add the following to /etc/apt/apt.conf.d/00local.conf: ---- // No point in installing a lot of fat on VM servers APT::Install-Recommends "0"; APT::Install-Suggests "0"; ---- Install these packages: ---- # aptitude install bind9 strongswan rsync cron-apt bind9-host dnsutils \ screen psmisc procps tree sysstat lsof telnet-ssl apache2-utils ntp ---- IPSEC ----- See section above on IPSEC for how to do this. Rsync ----- 1. Edit /etc/default/rsync, and enable rsyncd 2. Create /etc/rsyncd.conf: ---- hosts allow = 2001:db8:f012:2::2/128 2001:db8:f012:2::3/128 secrets file = /etc/rsyncd.secrets [dnsconf] path = /srv/dms/rsync-config uid=bind gid=bind comment = Slave server config area auth users = dnsconf use chroot = yes read only = no ---- 3. Create /etc/rsyncd.secrets ---- dnsconf:SuperSecretRsyncSlavePasswoord ---- 4. Do this at the shell to create target /srv/dms/rsync-config directory: ---- # mkdir -p /srv/dms/rsync-config # chown bind:bind /srv/dms/rsync-config ---- 5. And named slave directory ---- # mkdir /var/cache/bind/slave # chown root:bind /var/cache/bind/slave # chmod 775 /var/cache/bind/slave ---- 6. Start rsyncd Edit /etc/default/rsync to enable daemon ---- # service rsync start ---- 7. Test connectivity from DMS Masters ---- dms-master1# telnet new-slave domain dms-master1# telnet new-slave rsync dms-master2# telnet new-slave domain dms-master2# telnet new-slave rsync Test by rsyncing config to slave - needed for configuring bind9 zone_tool> create_server new-slave-name ip-address zone_tool> rsync_server_admin_config new-slave-name no_rndc ---- Bind9 ----- Change /etc/bind/named.conf.options to the following: ---- options { directory "/var/cache/bind"; // If there is a firewall between you and nameservers you want // to talk to, you may need to fix the firewall to allow multiple // ports to talk. See http://www.kb.cert.org/vuls/id/800113 // If your ISP provided one or more IP addresses for stable // nameservers, you probably want to use them as forwarders. // Uncomment the following block, and insert the addressesm replacing // the all-0's placeholder. // forwarders { // 0.0.0.0; // }; //======================================================================== // If BIND logs error messages about the root key being expired, // you will need to update your keys. See https://www.isc.org/bind-keys //======================================================================== // dnssec-validation auto; // auth-nxdomain no; # conform to RFC1035 listen-on { localhost; }; listen-on-v6 { any; }; include "/srv/dms/rsync-config/options.conf"; }; ---- Note that the listen directives are given in file, Debian options commented out, as they are set in the rsynced include at the bottom. Change /etc/bind/named.conf.local to the following: ---- // // Do any local configuration here // // Consider adding the 1918 zones here, if they are not used in your // organization //include "/etc/bind/zones.rfc1918"; // rndc config include "/etc/bind/rndc.key"; include "/srv/dms/rsync-config/rndc-remote.key"; include "/srv/dms/rsync-config/controls.conf"; // Logging configuration include "/srv/dms/rsync-config/logging.conf"; // Secondary zones include "/srv/dms/rsync-config/bind9.conf"; ---- This file is used to include all the required bits from the /srv/dms/rsync-config directory. All this configuration can now be updated from the master server, and the slave reconfigured – but watch it when you go changing the rndc keys. Restart bind9 ---- # touch /srv/dms/rsync-config/bind9.conf # chown bind:bind /srv/dms/rsync-config/bind9.conf # service bind9 restart ---- and check /var/log/syslog for any errors. Check that on the master servers that zone_tool rsync_server_admin_config works, by default will rndc the slave ---- dms-master1# zone_tool write_rndc_conf dms-master1# zone_tool rsync_server_admin_config new-slave dms-master2# zone_tool write_rndc_conf dms-master2# zone_tool rsync_server_admin_config new-slave ---- Enable Server ------------- On the live DMS master, enable the slave, and watch that it changes state to OK. This may take 15-20 minutes NOTE: a reconfig_sg may be needed to initial seed zone config files on master. These files are autmatically created/updated if a new domain is added to the server group. ---- dms-master-live# zone_tool zone_tool > enable_server zone_tool > reconfig_sg someorg-one . . . zone_tool > ls_pending_events ServerSMCheckServer dms-master2 Fri Mar 14 11:28:55 2014 ServerSMConfigure dms-slave1 Fri Mar 14 11:31:35 2014 ServerSMCheckServer dms-master1 Fri Mar 14 11:28:54 2014 . . . zone_tool > show_sg someorg-one sg_name: someorg-one config_dir: /etc/dms/server-config-templates master_address: None master_alt_address: None replica_sg: False zone_count: 4 DNS server status: dms-slave1 fd14:828:ba69:7::18 OK zone_tool > ---- -- Matt Grant Fri, 07 Mar 2014 14:50:58 +1300 dms-1.0.8.1/dms-test-sm000077500000000000000000000021501322726514000145450ustar00rootroot00000000000000#!/usr/bin/env python3.2 # # Copyright (c) Net24 Limited, Christchurch, New Zealand 2011-2012 # and Voyager Internet Ltd, New Zealand, 2012-2013 # # This file is part of py-magcode-core. # # Py-magcode-core 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 3 of the License, or # (at your option) any later version. # # Py-magcode-core 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 py-magcode-core. If not, see . # """Stub file File system location of this file determines the first entry on sys.path, thus its placement, and symlinks from /usr/local/sbin. """ from dms.app.dms_test_sm import DmsTestApp # Do the business process = DmsTestApp() process.main() dms-1.0.8.1/dms/000077500000000000000000000000001322726514000132275ustar00rootroot00000000000000dms-1.0.8.1/dms/__init__.py000066400000000000000000000016031322726514000153400ustar00rootroot00000000000000# # Copyright (c) Net24 Limited, Christchurch, New Zealand 2011-2012 # and Voyager Internet Ltd, New Zealand, 2012-2013 # # This file is part of py-magcode-core. # # Py-magcode-core 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 3 of the License, or # (at your option) any later version. # # Py-magcode-core 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 py-magcode-core. If not, see . # """ Make this directory a Python Module """ dms-1.0.8.1/dms/app/000077500000000000000000000000001322726514000140075ustar00rootroot00000000000000dms-1.0.8.1/dms/app/__init__.py000066400000000000000000000016031322726514000161200ustar00rootroot00000000000000# # Copyright (c) Net24 Limited, Christchurch, New Zealand 2011-2012 # and Voyager Internet Ltd, New Zealand, 2012-2013 # # This file is part of py-magcode-core. # # Py-magcode-core 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 3 of the License, or # (at your option) any later version. # # Py-magcode-core 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 py-magcode-core. If not, see . # # This makes the directory a python package dms-1.0.8.1/dms/app/dms_sa_sandpit.py000066400000000000000000000041031322726514000173470ustar00rootroot00000000000000#!/usr/bin/env python3.2 # # Copyright (c) Net24 Limited, Christchurch, New Zealand 2011-2012 # and Voyager Internet Ltd, New Zealand, 2012-2013 # # This file is part of py-magcode-core. # # Py-magcode-core 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 3 of the License, or # (at your option) any later version. # # Py-magcode-core 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 py-magcode-core. If not, see . # """Test Utility Program implemented by subclassing magcode.core.process.Process, and replacing the main() method. """ import os import sys from magcode.core.process import Process from magcode.core.globals_ import * from magcode.core.database import * from dms.globals_ import * from dms.database.zone_instance import ZoneInstance from dms.database.zone_sm import ZoneSM settings['config_section'] = 'DEFAULT' class DmsSaSandpitApp(Process): """ Process Main Daemon class """ # def parse_argv_left(self, argv_left): # """ # Handle any arguments left after processing all switches # # Override in application if needed. # """ # if (len(argv_left) == 0): # self.usage_short() # sys.exit(os.EX_USAGE) # # self.argv_left = argv_left # def main_process(self): """Main process for dms_test_sa_sandpit """ # Connect to database, intialise SQL Alchemy setup_sqlalchemy() db_session = sql_data['scoped_session_class']() import pdb; pdb.set_trace() sys.exit(os.EX_OK) if (__name__ is "__main__"): exit_code = DmsSaSandpitApp(sys.argv, len(sys.argv)) sys.exit(exit_code) dms-1.0.8.1/dms/app/dms_test_pypostgresql.py000066400000000000000000000047151322726514000210460ustar00rootroot00000000000000#!/usr/bin/env python3.2 # # Copyright (c) Net24 Limited, Christchurch, New Zealand 2011-2012 # and Voyager Internet Ltd, New Zealand, 2012-2013 # # This file is part of py-magcode-core. # # Py-magcode-core 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 3 of the License, or # (at your option) any later version. # # Py-magcode-core 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 py-magcode-core. If not, see . # """Test Utility Program implemented by subclassing magcode.core.process.Process, and replacing the main() method. """ import os import sys from magcode.core.process import Process from magcode.core.globals_ import * from magcode.core.database import * from dms.globals_ import * settings['config_section'] = 'DEFAULT' @saregister class TestPyPostgresql(object): """ Reference object for tagging data in database with things like customer IDs. """ _table = 'test_pypostgresql' def __init__(self, name, inet='192.168.1.1/24', cidr='192.168.110.0/24', macaddr='de:ad:00:be:00:ef' ): """ Initialize a Test Object """ self.name = name self.inet = inet self.cidr = cidr self.macaddr = macaddr class DmsTestPyPostgresqlApp(Process): """ Process Main Daemon class """ # def parse_argv_left(self, argv_left): # """ # Handle any arguments left after processing all switches # # Override in application if needed. # """ # if (len(argv_left) == 0): # self.usage_short() # sys.exit(os.EX_USAGE) # # self.argv_left = argv_left # def main_process(self): """Main process for dms_test_pypostgresql """ # Connect to database, intialise SQL Alchemy setup_sqlalchemy() db_session = sql_data['scoped_session_class']() import pdb; pdb.set_trace() sys.exit(os.EX_OK) if (__name__ is "__main__"): exit_code = DmsTestPyPostgresqlApp(sys.argv, len(sys.argv)) sys.exit(exit_code) dms-1.0.8.1/dms/app/dms_test_sm.py000066400000000000000000000046031322726514000167050ustar00rootroot00000000000000#!/usr/bin/env python3.2 # # Copyright (c) Net24 Limited, Christchurch, New Zealand 2011-2012 # and Voyager Internet Ltd, New Zealand, 2012-2013 # # This file is part of py-magcode-core. # # Py-magcode-core 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 3 of the License, or # (at your option) any later version. # # Py-magcode-core 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 py-magcode-core. If not, see . # """Test Utility Program implemented by subclassing magcode.core.process.Process, and replacing the main() method. """ import os import sys import pwd import time import json from magcode.core.process import Process from magcode.core.globals_ import * from magcode.core.database import * from magcode.core.database.event import Event from magcode.core.database.process_sm import new_process from dms.globals_ import * settings['config_section'] = 'DEFAULT' class DmsTestApp(Process): """ Process Main Daemon class """ def parse_argv_left(self, argv_left): """ Handle any arguments left after processing all switches Override in application if needed. """ if (len(argv_left) == 0): self.usage_short() sys.exit(os.EX_USAGE) self.argv_left = argv_left def main_process(self): """Main process for dms-test-sm """ # Connect to database, intialise SQL Alchemy setup_sqlalchemy() executable = self.argv_left[0] name = os.path.basename(executable) db_session = sql_data['scoped_session_class']() new_process(db_session=db_session, commit=True, name=name, exec_path=executable, argv = self.argv_left, stdin="GUMBOOT\n", success_event=Event(), success_event_kwargs={'role_id': 4, 'zone_id': 1000}) sys.exit(os.EX_OK) if (__name__ is "__main__"): exit_code = DmsTestApp(sys.argv, len(sys.argv)) sys.exit(exit_code) dms-1.0.8.1/dms/app/dmsdmd.py000077500000000000000000000247141322726514000156440ustar00rootroot00000000000000#!/usr/bin/env python3.2 # # Copyright (c) Net24 Limited, Christchurch, New Zealand 2011-2012 # and Voyager Internet Ltd, New Zealand, 2012-2013 # # This file is part of py-magcode-core. # # Py-magcode-core 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 3 of the License, or # (at your option) any later version. # # Py-magcode-core 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 py-magcode-core. If not, see . # """Main DNS Management Daemon Code Program implemented by subclassing magcode.core.process.Process, and replacing the main() method. """ import os import os.path import errno import sys import pwd import time import copy import signal import gc import json import psutil from magcode.core.process import ProcessDaemon from magcode.core.process import SignalHandler from magcode.core.globals_ import * from magcode.core.database import * from magcode.core.database.event import EventQueue from magcode.core.utility import get_numeric_setting from magcode.core.utility import get_boolean_setting # import to pull in and init ProcessSM import magcode.core.database.process_sm # import to pull in and init ZoneSMs import dms.database.zone_sm from magcode.core.utility import connect_test_address from dms.database.master_sm import recalc_machine_dns_server_info from dms.database.server_sm import init_soaquery_rcodes # import to fully init settings for config file DEFAULT section from dms.globals_ import update_engine from dms.dyndns_update import DynDNSUpdate from dms.exceptions import DynDNSCantReadKeyError USAGE_MESSAGE = "Usage: %s [-dhv] [-c config_file]" COMMAND_DESCRIPTION = "DMS DNS Management Daemon" class SIGUSR1Handler(SignalHandler): """ Handle a SIGUSR1 signal. Just make action() return False to wake loop """ def action(self): log_info('SIGUSR1 received - running event queue.') return False class DmsDMDProcess(ProcessDaemon): """ Process Main Daemon class """ def __init__(self, *args, **kwargs): super().__init__(usage_message=USAGE_MESSAGE, command_description=COMMAND_DESCRIPTION, *args, **kwargs) def init_signals(self): """ Initialise signal handlers for the daemon """ super().init_signals() self.register_signal_handler(signal.SIGUSR1, SIGUSR1Handler()) def init_master_dns_address(self): """ Master dns server setting in an IP addr Results determined by getaddrinfo(3) and thus by /etc/hosts contents, or else DNS if hostname not in /etc/hosts! """ test_hostname = settings['master_dns_server'] if not test_hostname: test_hostname = socket.getfqdn() connect_retry_wait = get_numeric_setting('connect_retry_wait', float) exc_msg = '' for t in range(3): try: # Transform any hostname to an IP address settings['master_dns_server'] = connect_test_address( test_hostname, port=settings['master_dns_port']) break except(IOError, OSError) as exc: exc_msg = str(exc) time.sleep(connect_retry_wait) continue else: log_error("Testing master DNS server IP address '%s:%s' - %s" % (test_hostname, settings['master_dns_port'], exc_msg)) systemd_exit(os.EX_NOHOST, SDEX_CONFIG) # If we get here without raising an exception, we can talk to # the server address (mostly) return def init_master_dns_server_data(self): """ Read in configuration values for these, and then process them This is a bit messy, but it does the job just here. """ # We use config file initially to set list this_servers_addresses = settings['this_servers_addresses'] if isinstance(this_servers_addresses, str): try: this_servers_addresses = settings['this_servers_addresses']\ .replace(',', ' ')\ .replace("'", ' ')\ .replace('"', ' ')\ .replace('[', ' ')\ .replace(']', ' ')\ .strip().split() except ValueError as exc: log_error("Could not parse 'this_servers_addresses' to obtain" " list of this servers DNS listening addresses - %s" % str(exc)) systemd_exit(os.EX_CONFIG, SDEX_CONFIG) settings['this_servers_addresses'] = this_servers_addresses # Recalculate host information - this will do nothing # if 'ifconfig -a' et al won't work ifconfig_exc = (True if not settings['this_servers_addresses'] else False) try: db_session = sql_data['scoped_session_class']() recalc_machine_dns_server_info(db_session, ifconfig_exc) db_session.commit() except Exception as exc: log_error(str(exc)) systemd_exit(os.EX_UNAVAILABLE, SDEX_NOTRUNNING) log_info("List of local IPs, 'this_servers_addresses' - %s" % ', '.join(settings['this_servers_addresses'])) log_info("Master DNS server on this machine, 'master_dns_server' - %s" % settings['master_dns_server']) def init_update_engines(self): """ Initialise the update engines used """ connect_retry_wait = get_numeric_setting('connect_retry_wait', float) error_str = '' for t in range(3): try: dyndns_engine = DynDNSUpdate(settings['dns_server'], settings['dyndns_key_file'], settings['dyndns_key_name']) break except (DynDNSCantReadKeyError, IOError, OSError) as exc: error_str = ("Can't connect to named for dynamic updates - %s" % str(exc)) time.sleep(connect_retry_wait) continue # Process above error... else: log_error("%s" % error_str) systemd_exit(os.EX_NOHOST, SDEX_CONFIG) update_engine['dyndns'] = dyndns_engine def do_garbage_collect(self): """ Do Resource Release exercise at low memory threshold, blow up over max """ error_str = '' try: rss_mem_usage = (float(self.proc_monitor.memory_info().rss) /1024/1024) except AttributeError: # Deal with a change in name of get_memory_info() method rss_mem_usage = (float(self.proc_monitor.get_memory_info().rss) /1024/1024) except Exception as exc: error_str = str(exc) # Process above error... if (error_str): log_error("Error obtaining resource usage - %s" % error_str) systemd_exit(os.EX_SOFTWARE, SDEX_NOTRUNNING) memory_exec_threshold = get_numeric_setting('memory_exec_threshold', float) if (rss_mem_usage > memory_exec_threshold): log_warning('Memory exec threshold %s MB reached, actual %s MB - execve() to reclaim.' % (memory_exec_threshold, rss_mem_usage)) file_path = os.path.join(sys.path[0], sys.argv[0]) file_path = os.path.normpath(file_path) os.execve(file_path, sys.argv, os.environ) else: # Spend idle time being RAM thrifty... gc.collect() return def main_process(self): """Main process for dmsdmd """ if (settings['rpdb2_wait']): # a wait to attach with rpdb2... log_info('Waiting for rpdb2 to attach.') time.sleep(float(settings['rpdb2_wait'])) log_info('program starting.') log_debug("The daemon_canary is: '%s'" % settings['daemon_canary']) # Do a nice output message to the log pwnam = pwd.getpwnam(settings['run_as_user']) log_debug("PID: %s daemon: '%s' User: '%s' UID: %d GID %d" % (os.getpid(), self.i_am_daemon(), pwnam.pw_name, os.getuid(), os.getgid())) # Check we can reach DNS server self.init_update_engines() # Initialise ServerSM rcodes from settings init_soaquery_rcodes() # Initialize master dns address if required self.init_master_dns_address() # Connect to database, intialise SQL Alchemy setup_sqlalchemy() # Initialize master DNS server data self.init_master_dns_server_data() # Create a queue event_queue = EventQueue() # Create a Process object so that we can check in on ourself resource # wise self.proc_monitor = psutil.Process(pid=os.getpid()) # Initialise a few nice things for the loop debug_mark = get_boolean_setting('debug_mark') sleep_time = get_numeric_setting('sleep_time', float) # test Read this value... master_hold_timeout = get_numeric_setting('master_hold_timeout', float) if (settings['memory_debug']): # Turn on memory debugging log_info('Turning on GC memory debugging.') gc.set_debug(gc.DEBUG_LEAK) # Process Main Loop while (self.check_signals()): event_queue.process_queue() if event_queue.queue_empty(): self.do_garbage_collect() if debug_mark: log_debug("----MARK---- sleep(%s) seconds ----" % sleep_time) time.sleep(sleep_time) log_info('Exited main loop - process terminating normally.') sys.exit(os.EX_OK) if (__name__ is "__main__"): exit_code = DmsDMDProcess(sys.argv, len(sys.argv)) sys.exit(exit_code) dms-1.0.8.1/dms/app/dyndns_tool.py000066400000000000000000000301051322726514000167140ustar00rootroot00000000000000#!/usr/bin/env python3.2 # # Copyright (c) Net24 Limited, Christchurch, New Zealand 2011-2012 # and Voyager Internet Ltd, New Zealand, 2012-2013 # # This file is part of py-magcode-core. # # Py-magcode-core 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 3 of the License, or # (at your option) any later version. # # Py-magcode-core 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 py-magcode-core. If not, see . # """Test Utility Program implemented by subclassing net.24.core.process.Process, and replacing the main() method. """ import os import sys import io import re import tempfile import stat import socket from subprocess import check_call from subprocess import CalledProcessError import dns.zone from magcode.core.process import Process from magcode.core.process import BooleanCmdLineArg from magcode.core.process import BaseCmdLineArg from magcode.core.globals_ import * from dms.dyndns_update import DynDNSUpdate from dms.database.resource_record import dnspython_to_rr from dms.database.zone_instance import ZoneInstance from dms.exceptions import DynDNSCantReadKeyError from dms.exceptions import NoSuchZoneOnServerError from magcode.core.database import RCODE_OK from magcode.core.database import RCODE_ERROR from magcode.core.database import RCODE_RESET from magcode.core.database import RCODE_FATAL from magcode.core.database import RCODE_NOCHANGE USAGE_MESSAGE = "Usage: %s [-dfhknprsuvy] [-c config_file] [dns-server]" COMMAND_DESCRIPTION = "Edit or manipulate a domain directly via dynamic DNS" settings['config_section'] = 'DEFAULT' class NoSOASerialUpdateCmdLineArg(BooleanCmdLineArg): """ Process verbose command Line setting """ def __init__(self): BooleanCmdLineArg.__init__(self, short_arg='n', long_arg='no-serial', help_text="Don't update SOA serial no", settings_key = 'no_serial', settings_default_value = False, settings_set_value = True) class WrapSOASerialCmdLineArg(BooleanCmdLineArg): """ Process verbose command Line setting """ def __init__(self): BooleanCmdLineArg.__init__(self, short_arg='r', long_arg='wrap-serial', help_text="Wrap SOA serial no", settings_key = 'wrap_serial', settings_default_value = False, settings_set_value = True) class UpdateSOASerialCmdLineArg(BooleanCmdLineArg): """ Process verbose command Line setting """ def __init__(self): BooleanCmdLineArg.__init__(self, short_arg='u', long_arg='update-serial', help_text="Just update SOA serial normally", settings_key = 'update_serial', settings_default_value = False, settings_set_value = True) class ForceUpdateCmdLineArg(BooleanCmdLineArg): """ Process verbose command Line setting """ def __init__(self): BooleanCmdLineArg.__init__(self, short_arg='f', long_arg='force-update', help_text="Force update if file unchanged", settings_key = 'force_update', settings_default_value = False, settings_set_value = True) class ClearDnskeyCmdLineArg(BooleanCmdLineArg): """ Process verbose command Line setting """ def __init__(self): BooleanCmdLineArg.__init__(self, short_arg='y', long_arg='clear-dnskey', help_text="Delete apex DNSKEY RRs", settings_key = 'clear_dnskey', settings_default_value = False, settings_set_value = True) class ClearNsec3CmdLineArg(BooleanCmdLineArg): """ Process verbose command Line setting """ def __init__(self): BooleanCmdLineArg.__init__(self, short_arg='k', long_arg='clear-nsec3', help_text="Delete NSEC3PARAM RR", settings_key = 'clear_nsec3', settings_default_value = False, settings_set_value = True) class Nsec3SeedCmdLineArg(BooleanCmdLineArg): """ Process verbose command Line setting """ def __init__(self): BooleanCmdLineArg.__init__(self, short_arg='s', long_arg='nsec3-seed', help_text="Create NSEC3PARAM RR", settings_key = 'nsec3_seed', settings_default_value = False, settings_set_value = True) class PortCmdLineArg(BaseCmdLineArg): """ Handle configuration file setting """ def __init__(self): BaseCmdLineArg.__init__(self, short_arg='p:', long_arg="port=", help_text="set DNS server port") def process_arg(self, process, value, *args, **kwargs): """ Set configuration file name """ settings['dns_port'] = value class DynDNSTool(Process): """ Process Main Daemon class """ def __init__(self, *args, **kwargs): Process.__init__(self, usage_message=USAGE_MESSAGE, command_description=COMMAND_DESCRIPTION, *args, **kwargs) self.cmdline_arg_list.append(NoSOASerialUpdateCmdLineArg()) self.cmdline_arg_list.append(WrapSOASerialCmdLineArg()) self.cmdline_arg_list.append(UpdateSOASerialCmdLineArg()) self.cmdline_arg_list.append(ForceUpdateCmdLineArg()) self.cmdline_arg_list.append(Nsec3SeedCmdLineArg()) self.cmdline_arg_list.append(ClearNsec3CmdLineArg()) self.cmdline_arg_list.append(ClearDnskeyCmdLineArg()) self.cmdline_arg_list.append(PortCmdLineArg()) def parse_argv_left(self, argv_left): """ Handle any arguments left after processing all switches Override in application if needed. """ if (len(argv_left) != 1 and len(argv_left) != 2): self.usage_short() sys.exit(os.EX_USAGE) self.argv_left = argv_left self.zone_name = argv_left[0] if not re.match('^[\S\.]+$', self.zone_name): self.usage_short() sys.exit(os.EX_USAGE) if (not self.zone_name.endswith('.')): self.zone_name += '.' if (len(argv_left) ==2): if not re.match('^[\S\.]+$', argv_left[1]): self.usage_short() sys.exit(os.EX_USAGE) settings['dns_server'] = argv_left[1] def _get_editor(self): """ Work out the users preference of editor, and return that """ editor = os.getenvb(b'VISUAL') if (editor): return editor editor = os.getenvb(b'EDITOR') if (editor): return editor editor = b'/usr/bin/sensible-editor' if os.path.isfile(editor): return editor editor = b'/usr/bin/editor' if os.path.isfile(editor): return editor # Fall back if none of the above is around... return b'/usr/bin/vi' def main_process(self): """Main process editzone """ def clean_up(): if (tmp_file): os.unlink(tmp_file) tmp_file = '' # Get update session object error_str = '' try: update_session = DynDNSUpdate(settings['dns_server'], settings['dyndns_key_file'], settings['dyndns_key_name'], ) except (socket.error, DynDNSCantReadKeyError, IOError) as exc: error_str = str(exc) # Process above error... if (error_str): log_error("%s" % error_str) sys.exit(os.EX_NOHOST) # Do AXFR to obtain current zone data msg = None try: (zone, dnskey_flag, nesc3param_flag) \ = update_session.read_zone(self.zone_name) except NoSuchZoneOnServerError as exc: msg = str(exc) if msg: log_error(msg) sys.exit(os.EX_NOINPUT) # Only edit zone if not wrapping SOA serial number if (not settings['wrap_serial'] and not settings['update_serial'] and not settings['nsec3_seed'] and not settings['clear_nsec3'] and not settings['clear_dnskey']): # Write zone out to a temporary file (fd, tmp_file) = tempfile.mkstemp(prefix=settings['process_name'] + '-', suffix='.zone') os.close(fd) zone.to_file(tmp_file) # Edit zone data old_stat = os.stat(tmp_file) editor = self._get_editor() try: output = check_call([editor, tmp_file]) except CalledProcessError as exc: log_error("editor exited with '%s'." % exc.returncode) sys.exit(os.EX_SOFTWARE) new_stat = os.stat(tmp_file) if (not settings['force_update'] and old_stat[stat.ST_MTIME] == new_stat[stat.ST_MTIME] and old_stat[stat.ST_SIZE] == new_stat[stat.ST_SIZE] and old_stat[stat.ST_INO] == new_stat[stat.ST_INO]): log_info("File '%s' unchanged after editing - exiting." % tmp_file) clean_up() sys.exit(os.EX_OK) # Read in file and form zi structure zone = dns.zone.from_file(tmp_file, self.zone_name) # At the moment these values are just for the sake of it. zi = ZoneInstance(soa_refresh='5m', soa_retry='5m', soa_expire='7d', soa_minimum='600') for rdata in zone.iterate_rdatas(): zi.add_rr(dnspython_to_rr(rdata)) # Update Zone in DNS rcode, msg, soa_serial, *stuff = update_session.update_zone( self.zone_name, zi, force_soa_serial_update=not(settings['no_serial']), wrap_serial_next_time=settings['wrap_serial'], nsec3_seed=settings['nsec3_seed'], clear_nsec3=settings['clear_nsec3'], clear_dnskey=settings['clear_dnskey'] ) if rcode == RCODE_NOCHANGE: log_info(msg) sys.exit(os.EX_OK) # Delete temporary file clean_up() if rcode == RCODE_ERROR: log_warning(msg) sys.exit(os.EX_TEMPFAIL) elif rcode == RCODE_RESET: log_error(msg) sys.exit(os.EX_IOERR) elif rcode == RCODE_FATAL: log_error(msg) sys.exit(os.EX_IOERR) # Everything good - Lets GO! if (settings['verbose']): log_info(msg) else: log_debug(msg) sys.exit(os.EX_OK) if (__name__ is "__main__"): exit_code = DynDNSTool(sys.argv, len(sys.argv)) sys.exit(exit_code) dms-1.0.8.1/dms/app/zone_tool.py000066400000000000000000007166321322726514000164100ustar00rootroot00000000000000#!/usr/bin/env python3.2 # # Copyright (c) Net24 Limited, Christchurch, New Zealand 2011-2012 # and Voyager Internet Ltd, New Zealand, 2012-2013 # # This file is part of py-magcode-core. # # Py-magcode-core 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 3 of the License, or # (at your option) any later version. # # Py-magcode-core 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 py-magcode-core. If not, see . # """Zone Tool command line zone management program Program implemented by subclassing net.24.core.process.Process, and replacing the main() method. """ import os import sys import io import tempfile import stat import socket import cmd import re import errno import signal import time import shlex import grp import pwd import syslog from getopt import gnu_getopt from getopt import GetoptError from textwrap import TextWrapper from subprocess import check_call from subprocess import check_output from subprocess import Popen from subprocess import PIPE from subprocess import STDOUT from subprocess import CalledProcessError from os.path import basename from pyparsing import ParseBaseException from pyparsing import ParseException from pyparsing import ParseFatalException from pyparsing import ParseSyntaxException from pyparsing import RecursiveGrammarException import dns.ttl import sqlalchemy.exc from magcode.core.process import Process from magcode.core.process import BooleanCmdLineArg from magcode.core.process import BaseCmdLineArg from magcode.core.process import SignalBusiness from magcode.core.process import SignalHandler from magcode.core.globals_ import * from magcode.core.database import * from magcode.core.database.event import ESTATE_NEW from magcode.core.database.event import ESTATE_RETRY from dms.globals_ import * from magcode.core.system_editor_pager import SystemEditorPager from dms.cmdline_engine import CmdLineEngine from dms.cmdline_engine import config_keys from dms.cmdline_engine import server_types from dms.cmdline_engine import tsig_key_algorithms from dms.zone_text_util import data_to_bind from dms.zone_text_util import bind_to_data from dms.database import zone_cfg from dms.database.server_sm import SSTATE_OK from dms.database.server_sm import SSTATE_CONFIG from dms.database.server_sm import SSTATE_DISABLED from dms.exceptions import * from dms.dns import label_re from dms.dns import DOMN_LBLSEP from dms.dns import DOMN_LBLREGEXP from dms.dns import DOMN_CHRREGEXP from dms.dns import DOMN_LBLLEN from dms.dns import DOMN_MAXLEN USAGE_MESSAGE = "Usage: %s [-dfhv] [-c config_file] " COMMAND_DESCRIPTION = "Edit a domain in the DMS" # Internal globals to program engine = None db_session = None switch_dict = {} # Command line processing functions class DoHelp(Exception): """ Argument processing exception - no match """ class DoNothing(Exception): """ Argument check error, go back to command line """ # Argument parsing functions used in ZoneToolCmd class below # Global module namspace as it makes code below a lot tidier ERROR_PREFIX = '*** ' ERROR_INDENT = ' ' OUTPUT_INDENT = ' ' _stdout = None error_msg_wrapper = TextWrapper(initial_indent = ERROR_PREFIX, subsequent_indent = ERROR_INDENT) result_msg_wrapper = TextWrapper(initial_indent = ERROR_INDENT, subsequent_indent = ERROR_INDENT) output_msg_wrapper = TextWrapper(initial_indent = OUTPUT_INDENT + ' ', subsequent_indent = OUTPUT_INDENT + ' ') def ln2strs(arg): """ Splits arg into arguments, and returns tuple of args """ return tuple(map(str, shlex.split(arg))) def arg_domain_name_text(domain_name, **kwargs): """ Process a """ # Check routines also over in dms.dns if this needs to be changed if not re.match(DOMN_CHRREGEXP, domain_name): print(error_msg_wrapper.fill(" can in some cases be a valid IP address or networ/mask, or if a domain contain the characters '-a-zA-Z0-9.'"), file=_stdout) return None if not domain_name.endswith(DOMN_LBLSEP): domain_name += DOMN_LBLSEP if len(domain_name) > DOMN_MAXLEN: print(ERROR_PREFIX + " is %s long, must be <= %s." % (len(domain_name), DOMN_MAXLEN), file=_stdout) return None labels = domain_name.split(DOMN_LBLSEP) if labels[-1] != '': print(error_msg_wrapper.fill("'%s' is no the root domain." % labels[-1]), file=_stdout) return None for lbl in labels[:-1]: # Skip 'root' zone if not lbl: print(error_msg_wrapper.fill( " '%s' cannot have empty labels." % domain_name.lower()), file=_stdout) return None if len(lbl) > DOMN_LBLLEN: print(error_msg_wrapper.fill( ' - label longer than %s characters' % DOMN_LBLLEN), file=_stdout) return None if not label_re.search(lbl): print(error_msg_wrapper.fill( " - invalid label '%s'" % lbl), file=_stdout) return None if lbl[0] == '-' or lbl[-1] == '-': print(error_msg_wrapper.fill( " - invalid label '%s'" % lbl), file=_stdout) return None return {'name': domain_name.lower()} def arg_domain_name_net(domain_name, **kwargs): """ Process a Handles Ip addresses, nets, and text """ # Check routines also over in dms.dns if this needs to be changed # See if it has a netmask if domain_name.find('/') < 0: return arg_domain_name_text(domain_name, **kwargs) # Split to mask and network try: (network, mask) = domain_name.split('/') except ValueError: print(error_msg_wrapper.fill( "For a network, only one '/' can be given"), file=_stdout) return None try: mask = int(mask) except ValueError: print(error_msg_wrapper.fill( "network mask must be a valid decimal number."), file=_stdout) return None # Determine network family if network.find(':') >= 0 and network.find('.') < 0: try: socket.inet_pton(socket.AF_INET6, network) if mask not in range(4, 65, 4): print(error_msg_wrapper.fill( "IPv6 network mask must be a multiple of 4 between 4 and 64"), file=_stdout) return None return {'name': domain_name.lower()} except socket.error: pass elif network.isdigit() or network.find('.') >= 0 and network.find(':') < 0: try: network = network[:-1] if network.endswith('.') else network num_bytes = len(network.split('.')) if num_bytes < 4: network += (4 - num_bytes) * '.0' socket.inet_pton(socket.AF_INET, network) if mask not in (8, 16, 24): print(error_msg_wrapper.fill( "IPv4 network mask must be 8, 16, or 24"), file=_stdout) return None return {'name': domain_name.lower()} except socket.error: pass print(error_msg_wrapper.fill("network/mask - invalid network '%s' given." % domain_name), file=_stdout) return None def arg_domain_name(domain_name, **kwargs): """ Process a Handles IP addresses, nets, and text """ # Check routines also over in dms.dns if this needs to be changed # Check for network addresses try: socket.inet_pton(socket.AF_INET, domain_name) return {'name': domain_name.lower()} except socket.error: pass try: socket.inet_pton(socket.AF_INET6, domain_name) return {'name': domain_name.lower()} except socket.error: pass return arg_domain_name_net(domain_name, **kwargs) def arg_domain1_name(domain1_name, **kwargs): """ Process a Handles IP addresses, nets and text """ result = arg_domain_name(domain1_name, **kwargs) if not result: return None return {'domain1_name': result['name']} def arg_domain2_name(domain2_name, **kwargs): """ Process a Handles IP addresses, nets and text """ result = arg_domain_name(domain2_name, **kwargs) if not result: return None return {'domain2_name': result['name']} def arg_src_domain_name(src_domain_name, **kwargs): """ Process a Handles IP addresses, nets and text """ result = arg_domain_name(src_domain_name, **kwargs) if not result: return None return {'src_name': result['name']} def arg_key_name(key_name, **kwargs): """ Process a TSIG key name """ result = arg_domain_name_text(key_name, **kwargs) if result: return {'key_name': result['name']} return None def arg_label(label, **kwargs): """ Process a