File dolly-0.64.2.obscpio of Package dolly

07070100000000000041ED000000000000000000000001623B5E1400000000000000000000000000000000000000000000001500000000dolly-0.64.2/.github07070100000001000041ED000000000000000000000001623B5E1400000000000000000000000000000000000000000000001F00000000dolly-0.64.2/.github/workflows07070100000002000081A4000000000000000000000001623B5E14000000DC000000000000000000000000000000000000002900000000dolly-0.64.2/.github/workflows/c-cpp.ymlname: C/C++ CI

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: make
      run: make dolly
  
07070100000003000081A4000000000000000000000001623B5E14000013D3000000000000000000000000000000000000001700000000dolly-0.64.2/CHANGELOGDolly: A programm to distribute partition-images and whole disks
over a fast, switched network.

Copyright: Felix Rauch <rauch@inf.ethz.ch> and ETH Zurich.

License: GNU General Public License.

History:

V 0.64.2 23-MAR-2022 Antoine Ginies <aginies@suse.com> Christian Goll <cgoll@suse.com>
  improved Makefile
  add a doly.conf configuration file
  add a firewalld rule
  typo fixes
  bug fixes
 
V 0.64.0 22-MAR-2022 Antoine Ginies <aginies@suse.com>
  add systemd socket support to start dolly clients
  nodes on demand from a dolly server

V 0.63.6 13-OCT-2021 Antoine Ginies <aginies@suse.com>
  fix hostname resolution is not done in case of usage
  of an external configuration file (bsc#1191613)
  fix -Werror=format-security

V 0.63.5 07-OCT-2021 Antoine Ginies <aginies@suse.com>
  improve help usage information

V 0.63.4 11-SEP-2019 Christian Goll <cgoll@suse.com>
  fixed warnings for gcc 11

V 0.60 11-SEP-2019 Christian Goll <cgoll@suse.com>
  Added pure commandline feature, so that there is no need for
  a dolly configuration file. Also output to stdout is now possible.

V 0.59 09-APR-2019 Antoine Ginies <aginies@suse.com>
        Cleanup warning building
  Change default output in non verbose mode (get some stats)
  Add -b option to specify the TRANSFER_BLOCK_SIZE
  Add -u to specify the size of buffers for TCP sockets

V 0.58C 23-MAR-2005 David Mathog <mathog@caltech.edu>
       Changed TRANSFER_BLOCK_SIZE to T_B_SIZE and replaced all
       explicit 4096 with this define.  Similarly, replaced all
       4095 with T_B_SIZEM1.  This allows a test to see if increasing
       this from 4096 to 8192 speeds anything up.  Netpipe suggests
       it should.
       
       Added a flag -n = 'no sync'.  When dolly waits for sync
       on an 80 Mb file it can take twice as long for the transfer
       to finish.  When dolly exits the disk light does come on, so
       it appears that the data flushes to disk asynchronously anyway
       when sync() is omitted.  

 V 0.58 2-NOV-2004 David Mathog <mathog@caltech.edu>
        (plus some minor cleanups by Felix Rauch)
        Added changes to allow "/dev/stdin", "/dev/stdout" processing for
  input file and output file. "-" would have been used but
  that already has some other meanings in this program.
  This makes it easy to use dolly in a pipe
  like this:
  
  master:  tar cf - /tree_to_send | dolly -s -f config
  clients: dolly | tar xpf -
  
  In this mode compression should be disabled. That allows
  compression option to be used on each machines' pipe.
  
  Redirected messages which used to be to stdout to stderr.
  Also, since in some modes the main node knows the slave node
  names, but they don't, this information is put into the
  environment variable MYNODENAME and retrieved via
  getenv("MYNODENAME") in the program. If this succeeds the
  node will not even try gethostbyname(). For compatibility
  with other systems, dolly also checks the "HOST" environment
  variable.
  
  Default to TCP_NODELAY. Set large input/output buffers.
  Ignore errno EINTR on select on client. Option to suppress
  the warning (there can be a lot of them!).

V 0.57 8-MAY-2003 Felix Rauch <rauch@inf.ethz.ch>
       Splitted infiles and outfiles are now possible.
 Parameter 'hyphennormal' treats '-' as normal character in hostnames.

V 0.56 15-JAN-2003 David Mathog <mathog@mendel.bio.caltech.edu>
       Added parameter -S. Acts like -s except it doesn't
       check the hostname. Handy when multiple interfaces
       are present.

V 0.55 25-JUL-2001 Felix Rauch <rauch@inf.ethz.ch>
        Added parameter for timeout (-a) and version (-V).

V 0.54 30-MAY-2001 Felix Rauch <rauch@inf.ethz.ch>
        Fixed a bug with config-files larger than 1448 bytes.
	
V 0.53 25-MAI-2001 Felix Rauch <rauch@inf.ethz.ch>
        Allowed empty "dummy" parameter
   
V 0.52 25-MAI-2001 Christian Kurmann <kurmann@inf.ethz.ch>
        Integrated primary network hostname add to change primary device

V 0.51 21-MAR-2001 Felix Rauch <rauch@inf.ethz.ch>
        Extended dummy-mode with time limit
  Integrated use of extra network interfaces
 
V 0.5  March-2001 Christian Kurmann <kurmann@inf.ethz.ch>
        Started extensions to dolly for switch-benchmark.

V 0.4  25-11-2000 Felix Rauch <rauch@inf.ethz.ch>
        Started to include the possibility to write compressed outfiles.

V 0.3  01-FEB-2000 Felix Rauch <rauch@inf.ethz.ch>
        Dolly now supports tree topologies with any number of fanouts.
  (Trees are usually slower, so this change won't speed up dolly.
  I just implemented it to proove that it's really slower.
  See our Paper for EuroPar 2000 on our publications site
  http://www.cs.inf.ethz.ch/CoPs/publications/)

V 0.2  02-JUL-1999 Felix Rauch <rauch@inf.ethz.ch>
        Some improvements...

V 0.21 31-JAN-2000 Felix Rauch <rauch@inf.ethz.ch>
        Status information backflow, no longer a ring topology.

V 0.1  xy-MAR-1999 Felix Rauch <rauch@inf.ethz.ch>
        First version for benchmarks required. Presented results
  at Cluster Computing 99, Karlsruhe, Germany
07070100000004000081A4000000000000000000000001623B5E140000894D000000000000000000000000000000000000001500000000dolly-0.64.2/LICENSE                    GNU GENERAL PUBLIC LICENSE
                       Version 3, 29 June 2007

 Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
 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.

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    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 <https://www.gnu.org/licenses/>.

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:

    <program>  Copyright (C) <year>  <name of author>
    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
<https://www.gnu.org/licenses/>.

  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
<https://www.gnu.org/licenses/why-not-lgpl.html>.
07070100000005000081A4000000000000000000000001623B5E14000007DB000000000000000000000000000000000000001600000000dolly-0.64.2/MakefileCXX = g++
CC = gcc
CFLAGS += -std=gnu11 -s -O -fPIE $(RPM_OPT_FLAGS)
WARNINGS = -Werror -Wall -Wextra -pedantic-errors
LDFLAGS =
LIBRARIES =
BUILD_DIR = ./build
SOURCES = $(wildcard *.c)
OBJECTS = $(SOURCES:%.c=$(BUILD_DIR)/%.o)
DEPS = $(SOURCES:%.c=$(BUILD_DIR)/%.d)
# Can 
DEBUGFLAGS=-ggdb
VERSION=0.64.2

PREFIX ?= /usr
BINDIR ?= $(PREFIX)/bin
SBINDIR ?= $(PREFIX)/sbin
SYSTEMDDIR ?= $(PREFIX)/lib/systemd/system
FIREWALLDDIR ?= $(PREFIX)/lib/firewalld/services
DATADIR ?= $(PREFIX)/share
MANDIR ?= $(DATADIR)/man
SYSCONFDIR ?= /etc

EXECUTABLE = dolly

all: $(EXECUTABLE) man

tar: clean
	mkdir $(EXECUTABLE)-$(VERSION)
	find . -maxdepth 1 -type f -exec cp -a {} $(EXECUTABLE)-$(VERSION) \;
	tar cfj $(EXECUTABLE)-$(VERSION).tar.bz2 $(EXECUTABLE)-$(VERSION)
	rm -rf $(EXECUTABLE)-$(VERSION)

$(BUILD_DIR)/%.d: %.c
	@mkdir -p $(dir $@)
	$(CC) $< -MT $(BUILD_DIR)/$*.o -MM -MF $(BUILD_DIR)/$*.d

$(BUILD_DIR)/%.o: %.c
	@mkdir -p $(dir $@)
	$(CC) $< -o $@ -c $(CFLAGS) $(DEBUGFLAGS) $(WARNINGS)


$(EXECUTABLE): $(OBJECTS)
	@echo "Building $(EXECUTABLE)"
	$(CC) $(LDFLAGS) $(OBJECTS) -o $@ $(LIBRARIES)

.PHONY: clean       

clean:
	rm -rf $(EXECUTABLE) $(OBJECTS) $(DEPS)
	rm -rf $(EXECUTABLE)-$(VERSION) $(EXECUTABLE)-$(VERSION).tar.bz2
	rm -rf dolly.1*

dolly.1.gz:
	@echo "Building man page"
	pandoc --standalone -t man README.md -o dolly.1
	gzip dolly.1

man: dolly.1.gz

install:
	install -d -m 0755 $(DESTDIR)$(SBINDIR)
	install -d -m 0755 $(DESTDIR)$(SYSTEMDDIR)
	install -d -m 0755 $(DESTDIR)$(FIREWALLDDIR)
	install -d -m 0755 $(DESTDIR)$(SYSCONFDIR)
	install -m 0755 $(EXECUTABLE) $(DESTDIR)$(SBINDIR)
	install -m 0644 dolly.service $(DESTDIR)$(SYSTEMDDIR)
	install -m 0644 dolly.socket $(DESTDIR)$(SYSTEMDDIR)
	install -m 0644 dolly_firewall.xml $(DESTDIR)$(FIREWALLDDIR)/dolly.xml
	install -m 0644 dolly.conf $(DESTDIR)$(SYSCONFDIR)
	-test -e dolly.1.gz && install -d -m 0755 $(DESTDIR)$(MANDIR)/man1
	-test -e dolly.1.gz && install -m 0644 dolly.1.gz $(DESTDIR)$(MANDIR)/man1/

-include $(DEPS)
07070100000006000081A4000000000000000000000001623B5E14000046CF000000000000000000000000000000000000001700000000dolly-0.64.2/README.mdDOLLY
=====
A program to clone disks / partitions / data.
Take same amount of time to copy data to one node or to X nodes.

SYNOPSIS
========

dolly \[**-f** config\]

dolly \[**-I** infile\] \[**-O** outfile\|-\] \[**-H** hostlist\] 

dolly **-v** **-r** 40 **-S** SERVERIP **-H** IPNODE1,IPNODE2,IPNODE3 **-I** /dev/vdd **-O** /dev/vdd

DESCRIPTION
===========

Dolly is used to clone the installation of one machine to (possibly
many) other machines. It can distribute image-files (even gnu-zipped),
partitions or whole hard disk drives to other partitions or hard disk
drives. As it forms a "virtual TCP ring" to distribute data, it works
best with fast switched networks.

As dolly clones whole partitions block-wise.

OPTIONS
=======
If used without a configuration file following three commanline options must be
set:

**-I** FILE : FILE is used as input file.

**-O** FILE\|- : FILE will be used as output file, if '-' is used as FILE, the
output will printed to stdout.

**-H** HOSTLIST: A comma seperated hostlist, where then the first host of the list
is used as firstclient and the last host  as lastclient, like in the
configuration file.

Following other options are:

  **-h**
 :   Prints a short help and exits.

  **-V**
 :   Prints the version number as well as the date of that version and exits.

  **-v**
 :  This switches to verbose mode in which dolly prints out a little
    bit more information. This option is recommended if you want to
    know what's going on during cloning and it might be helpful during
    debugging.

  **-s**
 :  This option specifies the server machine and should only be used
    on the master. Dolly will warn you if the config file specifies
    another master than the machine on which this option is set.
    This option must be secified before the "-f" option!

  **-S**
 :  Same as "-s", but dolly will not warn you if the server's hostname
    and the name specified in the config file do not match.

 **-R**
 :  resolve the hostnames to ipv4 addresses

 **-6**
 :  resolve the hostnames to ipv6 addresses

  **-q**
 :  Usually dolly will print a warning when the select() system call
    is interrupted by a signal. This option suppresses these warnings.

  **-c**
 :  With this option it is possible to specify the uncompressed size
    of a compressed file. It's only needed for performance statistics
    at the end of a cloning process and not important if you are not
    interested in the statistics.

  **-d**
 :  Connect to systemd socket on clients nodes to start the dolly 
    service (port 9996). This option only available on command 
    line.
    **Warning !!**
    By default if you use the dolly.socket, the dolly.service start
    as root user, which means that you can delete all your nodes
    data easily while pushing into the ring data in the wrong place.
    There is **NO AUTH** process, which means that all nodes with a
    dolly socket open and listed as a target from the server will get
    the data.

  **-t** <seconds>
 :  When in dummy mode, this option allows to specify how long the
    testrun should approximately take. Since the dummy mode is mostly
    used for benchmarking purposes and single runs might result in
    different speeds (especially with many machines and bad switches
    or with small TCP segment sizes), it's more convenient to specify
    the run-lenght in seconds, as the benchmark-time becomes more
    predictable.
    
  **-f** <config file>
 :  This option is used to select the config file for this cloning
    process. This option makes only sense on the master machine and
    the configuration file must exist on the master.

  **-o** <logfile>
 :  This option specifies the logfile. Dolly will write some
    statistical information into the logfile. it is mostly
    used when benchmarking switches. The format of the lines in the
    logfile is as follows:
    Trans. data  Segsize Clients Time      Dataflow  Agg. dataflow
    [MB]         [Byte]  [#]     [s]       [MB/s]    [MB/s]

  **-a** <timeout>
 :  Sometimes it might be useful if Dolly would terminate instead of
    waiting indefinitely in case something goes wrong. This option
    lets you specify this timeout. If dolly could not transfer any
    data after <timeout> seconds, then it will simply print an error
    message and terminate. This feature might be especially useful for
    scripted and automatic installations (such as "CloneSys"), where
    you don't want to have dolly-processes hang around if a machine
    hangs.

  **-n**
 :  Do not sync() before exit. Thus, dolly will exit sooner, but data
    may not make it to disk if power fails soon after dolly exits.

  **-u** <size>
 :  Specify the size of buffers for TCP sockets. Should be a Multiple
    of 4K.

  **-b** <size>
 :  Option to specify the TRANSFER_BLOCK_SIZE. Should be a multiple of
    the size of buffers for TCP sockets.

 **-r** <n>
 :  Retry to connect to mode <n> times


CONFIGURATION FILE
==================

One can use either us the appropriate commandline options (-i,-o and -H) or a
configuration file for the cloning process is needed. Its format is strict, but
easy. It contains the following entries (note that the order of the entries is
fix): (The text after "Syntax:" explains the syntax of the entry, the lines
following "EG:" are example lines)

1. The file/partition you want to clone, preceeded by the keywords
   "infile" or "compressed infile" in case of a compressed image.
   This file or partitions needs to be available on the master only.
   Dolly will warn you if you try to use a compressed infile which
   does not end with ".gz". The compressed keyword is important so
   that the master can inform the clients when they have to use gunzip
   before writing a file. The optional keyword "split" after the
   filename instructs Dolly to read all files with the given name and
   an appended number, separated by an underscore.
   Syntax: [compressed] infile <input file or device> [split]
   EG: infile /dev/sda10
       Will just send the partition /dev/sda10 to all clients.
   EG: compressed infile /images/cloneimages/sda10_WinNTRes.gz
       Will send the given file compressed to all the clients,
       instructing them to uncompress the image before writing it.
   EG: infile /images/cloneimages/sda split
       Will send all files of the form /images/cloneimages/sda_<number>
       in order to the clients.
   EG: compressed infile /images/cloneimages/sda.gz split
       Will send all files of the form /images/cloneimages/sda.gz_<number>
       in order to the clients, instructing them to decompress the
       incoming stream before writing it.

2. The file or partition you want to write (usually its a partition,
   but you can also write to a file) after the keyword "outfile". This
   file needs to be available on the clients only. The optional
   keyword "compressed" instructs the server to compress the data
   before sending it, so the client will store the data
   compressed. The optional keyword "split" after the filename,
   followed by a number and a multiplier, instructs the client to
   write the data in junks of no more than the given size. This is
   useful if the file system on your client does not allow files
   greater than a certain size. The files will be stored with the
   given namen and an appended "_<number>".
   Syntax: [compressed] outfile <output file or device> [split <n>(k|M|G|T)]
   EG: outfile /dev/sda10
       Will store the incoming data stream to the partition sda10.
   EG: compressed outfile /images/cloneimages/sda10_SuSE81.gz
       Will store the compressed data stream in the given file.
   EG: compressed outfile /images/cloneimages/sda_all.gz split 2G
       Will store the incoming compressed data stream in the directory
      /images/cloneimages/ in files sda_all.gz_0, sda_all.gz_1 and so on.

-. Instead of the first two entries ("infile" and "outfile") it is
   also possible to use the single line "dummy [<MB>]", where <MB> is
   the number of Megabytes to transfer in dummy mode. If <MB> is set
   to 0, then the clients will just terminate. This is useful when
   benchmarking with different options, so the clients can run all the
   time. To finally terminate them on all clients, just set dummy to 0.
   NOTE: It is probably better to use the newer "-t" switch on the
   server to specify the number of seconds the benchmarks should
   run. In that case you can leave the <MB> blank.
   Syntax: dummy [<MB>]
   EG: dummy 128

-. The optional keyword "segsize" is mostly used to benchmark
   switches. It specifies the maximal size of TCP segments during the
   network transfer. Usually you don't need to specify this option at
   all.
   Syntax: segsize <TCP_MAXSEG size>
   EG: segsize 128
   
-. With the optional keyword "add" it is possible to add more
   interfaces to use. The network traffic is then evenly distributed
   across the interfaces. This option is useful if you have for
   example two fast ethernet interfaces in your machines: One for
   administrative purposes and one for your main application on the
   cluster. This option is not so useful if you have multiple
   interfaces with different bandwidths. In this case just use the
   fastest available.
   You have to specify the number of additional interfaces and the
   suffixes of thouse interfaces. For example, in a cluster where the
   machines are named slave0..slave15 on their default interfaces and
   all the machines have a second interface named
   slave0-fast..slave15-fast, you should use the line specified below
   (EG).
   Syntax: add <nr>:<suffix>{:<suffix>}
   EG: add 1:-fast

-. The optional keyword "fanout" was mostly used during performance
   tests of different network topologies. You barely need it in
   practice. Fanout specifies the number of outlinks from the server
   and the following machines (except the leafes). A fanout of 1 is a
   linear list (the default behaviour of Dolly and usually the
   fastest), 2 is a binary tree, 3 is a ternary tree, etc. Dolly
   automatically connects all the specified clients with the desired
   topology.
   Syntax: fanout <fanout>
   EG: fannout 1

-. The optional keyword "hypennormal" instructs Dolly to treat the '-'
   character in hostnames as any other character. By default the
   hyphen is used to separate the base hostnames from the names of the
   different interface (e.g. "node12-giga"). You might use this
   paramater if your hostnames include a hypen (like e.g. "node-12").
   Syntax: hyphennormal
   EG: hyphennormal
   
3. After the keyword "server" follows the hostname of the server (or
   master). This is required for the last machine in the ring to be
   able to send the end-acknowledge back to the server.
   Syntax: server <master machine>
   EG: server cluster-master

4. This entry has the keyword "firstclient" followed by the hostname
   of the first client in the ring. You should use the hostname of the
   machine here, not the name of the interface where you want to
   connect.
   Syntax: firstclient <name of first machine>
   EG: firstclient cluster-1

5. This entry has the keyword "lastclient" followed by the hostname of
   the last client in the ring. You should use the hostname of the
   machine here, not the name of the interface where you want to
   connect.
   Syntax: lastclient <name of last machine>
   EG: lastclient cluster-9

6. This entry specifies how many clients are in the ring. The keyword
   is "clients" followed by the actual number of clients. This number
   does not include the master.
   Syntax: clients <number of clients>
   EG: clients 9

7. The following lines contain the interface-names of the client
   machines. The number of machines must match the above number of
   clients (see 6.). You should use the name of the interface on
   which the machines will receive the data.   
   Syntax: <name of client 1>
           <name of client 2>
           [...]
           <name of client n>
   EG: cluster-1-giga
       cluster-2-giga
       [...]
       cluster-9-giga

8. The last entry in the config file consists of the keyword
   "endconfig" and marks the end of the configuration file.
   Syntax: endconfig
   EG: endconfig


NOTE on NODES HOSTNAMES
=======================

On some machines (e.g. with very small maintenance installations),
gethostbyname() does not return the hostname (I don't know why). If
you have that problem, you should make sure that the environment
variables MYNODENAME or HOST are set accordingly. Dolly first tries to
get the environment variable MYNODENAME, then HOST, then it tries
gethostbyname(). This feature was introduced in dolly version 0.58.


HOW IT WORKS
============

Setting up or upgrading a cluster of PCs typically leads to the
problem that many machines need the exact same files. There are
different approaches to distribute the setup of one "master" machine
to all the other machines in the cluster. Our approach is not
sophisticated, but simple and fast (at least for fast switched
networks). We send the data around in a "virtual TCP ring" from the
server to all the clients which store tha received data on their local
disks.

One machine is the master and distributes the data to the others. The
master can be a machine of the cluster or some other machine (in the
current version of dolly it should be the same architecture
though). It stores the image of the partition or disk to be cloned or
has the partition on a local disk. The server should be on a fast
switched network (as all the other machines too) for fast cloning.

All other machines are clients. They receive the data from the ring,
store it to the local disk and send it to the next machine in the
ring. It is important to note that all of this happens at the same
time.

The cloning process is depicted in the following two figures. Usually
there are more than two clients, but you get the idea:

      +========+  +==========+ +==========+
      | Master |  | Client 1 | | Client 2 |
      +====+===+  +===|======+ +====+=====+
            \         |            /
             \    +===+====+      /
              +===+ Switch |=====+
                  +========+

        Cloning process, physical network


     +========+  Data   +==========+  Data  +==========+
     | Master |========>| Client 1 |=======>| Client 2 |
     +========+         +==========+        +==========+
         ^                   |                   |
         | Data              | Data              | Data
         |                   V                   V
      +======+            +======+            +======+
      | Disk |            | Disk |            | Disk |
      +======+            +======+            +======+

     Cloning process, virtual network with TCP connections


We choose this method instead of a multicast scheme because it is
simple to implement, doesn't require the need to write a reliable
multicast protocol and works quite well with existing
technologies. One could also use the master as an NFS server and copy
the data to each client, but this puts quite a high load on the server
and makes it the bottleneck. Furthermore, it would not be possible to
directly clone partitions from one machine to some others without any
filesystem in the partition.


DIFFERENT CLONING POSSIBILITIES
===============================

There are different possibilities to clone your master machine:

- You already have an image of the partition which you want to clone
  on your master (raw or compressed). In this case you need Linux
  (some other UNIX might also work, but we haven't tested that yet) on
  your master and a Linux on each client.

- You want to clone a partition which is on a local disk of your
  master. In this case you need Linux (or probably another UNIX, we
  haven't tried that) on your master as well as on all the clients.
  You can use any Linux installation as long as it's not the one you
  want to clone (i.e. you can not clone the Linux which you are
  currently running in. See the warning below).

- You want to clone a whole disk including all the partitions. In this
  case you either need a second disk on all machines where your Linux
  used for the cloning process runs on (not the one you want to clone)
  or you need a small one-floppy-disk-Linux which you boot on all
  machines. In the later case you also need dolly on all machines
  (copy it to your floppy disk or mount it with NFS) and the
  config-file on the master.

WARNING: You can NOT clone an OS which is currently in use. That is why
         we have a small second Linux installation on all of our machines
         (or a small system that can be booted over the network by PXE),
         which we can boot to clone our regular Linux partition.


CHANGES 
=======

See CHANGELOG file

TODO
====

Add an AUTH method to validate client nodes from server.
            
EXAMPLE
=======

In this example we assume a cluster of 16 machines, named
node0..node15. We want to clone the partition sda5 from node0 to all
other nodes. The configuration file (let's name it dollytab.cfg)
should then look as follows:
```
infile /dev/sda5
outfile /dev/sda5
server node0
firstclient node1
lastclient node15
clients 15
node1
node2
node3
node4
node5
node6
node7
node8
node9
node10
node11
node12
node13
node14
node15
endconfig
```

Next, we start Dolly on all the clients. No options are required for
the clients (but you might want to add the "-v" option for verbose
progress reports). Finally, Dolly is started on the server as follows:
  dolly -v -s -f dollytab.cfg
That's all.


Bibliography
============

Felix Rauch, Christian Kurmann, Thomas M. Stricker: <em>Optimizing the
distribution of large data sets in theory and practice</em>. Concurrency
and Computation: Practice and Experience, volume 14, issue 3, pages
165-181, april 2002. (c) John Wiley & Sons, Ltd.

Maintained by Felix Rauch.
http://www.cs.inf.ethz.ch/~rauch/
Felix Rauch <rauch@inf.ethz.ch>

AUTHORS / CONTRIBUTORS
=======================
Felix Rauch <rauch@inf.ethz.ch>
Antoine Ginies <aginies@suse.com>
Christian Goll <cgoll@suse.com>
07070100000007000081A4000000000000000000000001623B5E140000865C000000000000000000000000000000000000001500000000dolly-0.64.2/dolly.c#include "dolly.h"
#include "transmit.h"
#include "files.h"
#include "movebytes.h"

/* Clients need the ports before they can listen, so we use defaults. */
const unsigned int dataport = 9998;
const unsigned int ctrlport = 9997;
const unsigned int systemdport = 9996;
const char* host_delim = ",";

FILE *stdtty;           /* file pointer to the standard terminal tty */


/* File descriptors for file I/O */
int input = -1, output = -1;


/* Numbers for splitted input/output files */
unsigned int input_nr = 0, output_nr = 0;


/* size of buffers for TCP sockets (approx. 100KB, multiple of 4 KB) */
unsigned int buffer_size = 98304;


/* Normal sockets for data transfer */
int datain[MAXFANOUT], dataout[MAXFANOUT];
int datasock = -1;

/* Special sockets for control information */
int ctrlin = -1, ctrlout[MAXFANOUT];
int ctrlsock = -1;

unsigned long long maxbytes = 0; /* max bytes to transfer */
unsigned long long maxcbytes = 0;/*     --  "  --  in compressed mode */
int dosync = 1;                  /* sync() after transfer */
int timeout = 0;                 /* Timeout for startup */
int verbignoresignals = 1;       /* warn on ignore signal errors */

int max_retries = 10;
char dollytab[256];



int flag_log = 0;
char logfile[256] = "";


/* Pipe descriptor in case data must be uncompressed before write */
int pd[2];
/* Pipe descriptor in case input data must be compressed */
int id[2]; 

/* PIDs of child processes */
int in_child_pid = 0, out_child_pid = 0;


/* Handles timeouts by terminating the program. */
static void alarm_handler() {
  fprintf(stderr, "Timeout reached (was set to %d seconds).\nTerminating.\n",
	  timeout);
  exit(1);
}

/* This functions prints all the parameters before starting.
   It's mostly used for debugging. */
static void print_params(struct dollytab* mydollytab) {
  unsigned int i;
  fprintf(stderr, "Parameter file: \n");
  if(mydollytab->compressed_in) {
    fprintf(stderr, "compressed ");
  }
  fprintf(stderr, "infile = '%s'", mydollytab->infile);
  if(mydollytab->input_split != 0) {
    fprintf(stderr, ", splitted in parts.\n");
  } else {
    fprintf(stderr, "\n");
  }
  if(mydollytab->compressed_out) {
    fprintf(stderr, "compressed ");
  }
  fprintf(stderr, "outfile = '%s'", mydollytab->outfile);
  if(mydollytab->output_split != 0) {
    fprintf(stderr, ", splitted in %llu byte parts.\n", mydollytab->output_split);
  } else {
    fprintf(stderr, "\n");
  }
  fprintf(stderr, "using data port %u\n", dataport);
  fprintf(stderr, "using ctrl port %u\n", ctrlport);
  if(mydollytab->flag_d) { fprintf(stderr, "using systemd port %u\n", systemdport); }
  fprintf(stderr, "myhostname = '%s'\n", mydollytab->myhostname);
  if(mydollytab->segsize > 0) {
    fprintf(stderr, "TCP segment size = %u\n", mydollytab->segsize);
  }
  if(mydollytab->add_nr > 0) {
    fprintf(stderr, "add_nr (extra network interfaces) = %u\n", mydollytab->add_nr);
    if(mydollytab->add_mode == 1) {
      fprintf(stderr, "Postfixes: ");
    } else if(mydollytab->add_mode == 2) {
      fprintf(stderr, "Midfixes: ");
    } else {
      fprintf(stderr, "Undefined value for add_mode: %d\n", mydollytab->add_mode);
      exit(1);
    }
    for(i = 0; i < mydollytab->add_nr; i++) {
      fprintf(stderr, "%s", mydollytab->add_name[i]);
      if(i < mydollytab->add_nr - 1) fprintf(stderr, ":");
    }
    fprintf(stderr, "\n");
  }
  if (mydollytab->add_primary == 1) {
    fprintf(stderr, "add to primary hostname = ");
    fprintf(stderr, "%s", mydollytab->add_name[0]);
    fprintf(stderr, "\n");
  }
  fprintf(stderr, "fanout = %u\n", mydollytab->fanout);
  fprintf(stderr, "nr_childs = %u\n", mydollytab->nr_childs);
  fprintf(stderr, "server = '%s'\n", mydollytab->servername);
  fprintf(stderr, "I'm %sthe server.\n", (mydollytab->meserver ? "" : "not "));
  fprintf(stderr, "I'm %sthe last host.\n", (mydollytab->melast ? "" : "not "));
  fprintf(stderr, "There are %u hosts in the ring (excluding server):\n",
	  mydollytab->hostnr);
  for(i = 0; i < mydollytab->hostnr; i++) {
    fprintf(stderr, "\t'%s'\n", mydollytab->hostring[i]);
  }
  fprintf(stderr, "Next hosts in ring:\n");
  if(mydollytab->nr_childs == 0) {
    fprintf(stderr, "\tnone.\n");
  } else {
    for(i = 0; i < mydollytab->nr_childs; i++) {
      fprintf(stderr, "\t%s (%d)\n",
	      mydollytab->hostring[mydollytab->nexthosts[i]], mydollytab->nexthosts[i]);
    }
  }
  fprintf(stderr, "All parameters read successfully.\n");
  if(mydollytab->compressed_in && !mydollytab->meserver) {
    fprintf(stderr,
	    "Will use gzip to uncompress data before writing.\n");
  } else if(mydollytab->compressed_in && mydollytab->meserver) {
    fprintf(stderr,
	    "Clients will have to use gzip to uncompress data before writing.\n");
  } else {
    fprintf(stderr, "No compression used.\n");
  }
  fprintf(stderr, "Using transfer size %d bytes.\n",(int) mydollytab->t_b_size);
}

static void open_insocks(struct dollytab * mydollytab) {
  struct sockaddr_in addr;
  int optval;
  int recv_size, sizeofint = sizeof(int);
  
  /* All machines have an incoming data link */
  datasock = socket(PF_INET, SOCK_STREAM, 0);
  if(datasock == -1) {
    perror("Opening input data socket");
    exit(1);
  }
  optval = 1;
  if(setsockopt(datasock, SOL_SOCKET, SO_REUSEADDR,
		&optval, sizeof(int)) == -1) {
    perror("setsockopt on datasock");
    exit(1);
  }
  
  /* Attempt to set TCP_NODELAY */
  optval = 1;
  if(setsockopt(datasock, IPPROTO_TCP, TCP_NODELAY,
        	&optval, sizeof(int)) < 0) {
    (void)fprintf(stderr, "setsockopt: TCP_NODELAY failed! errno = %d\n",
		  errno);
    // exit(1);
  }

  if(mydollytab->segsize > 0) {
    /* Attempt to set TCP_MAXSEG */
    fprintf(stderr, "Set TCP_MAXSEG to %u bytes\n", mydollytab->segsize);
    if(setsockopt(datasock, IPPROTO_TCP, TCP_MAXSEG,
		  &mydollytab->segsize, sizeof(int)) < 0) {
      (void) fprintf(stderr,"setsockopt: TCP_MAXSEG failed! errno=%d\n", errno);
      // exit(1);
    }
  }
  
  /* Attempt to set input BUFFER sizes */
  if(mydollytab->flag_v) { fprintf(stderr, "Buffer size: %u\n", SCKBUFSIZE); }
  if(setsockopt(datasock, SOL_SOCKET, SO_RCVBUF, &SCKBUFSIZE,sizeof(SCKBUFSIZE)) < 0) {
    (void) fprintf(stderr, "setsockopt: SO_RCVBUF failed! errno = %d\n",
		   errno);
    exit(556);
  }
  getsockopt(datasock, SOL_SOCKET, SO_RCVBUF,
	     (char *) &recv_size, (void *) &sizeofint);
  if(mydollytab->flag_v) {
    (void)fprintf(stderr, "Receive buffer is %d bytes\n", recv_size);
  }
  
  addr.sin_family = AF_INET;
  addr.sin_port = htons(dataport);
  addr.sin_addr.s_addr = htonl(INADDR_ANY);
  if (bind(datasock, (struct sockaddr *) &addr, sizeof(addr)) == -1) {
    perror("binding input data socket");
    exit(1);
  }
  if(listen(datasock, 1) == -1) {
    perror("listen input data socket");
    exit(1);
  }
  
  /* All machines have an incoming control link */
  ctrlsock = socket(PF_INET, SOCK_STREAM, 0);
  if(ctrlsock == -1) {
    perror("Opening input control socket");
    exit(1);
  }
  optval = 1;
  if(setsockopt(ctrlsock, SOL_SOCKET, SO_REUSEADDR,
		&optval, sizeof(int)) == -1) {
    perror("setsockopt on ctrlsock");
    exit(1);
  }
  addr.sin_family = AF_INET;
  addr.sin_port = htons(ctrlport);
  addr.sin_addr.s_addr = htonl(INADDR_ANY);
  if (bind(ctrlsock, (struct sockaddr *) &addr, sizeof(addr)) == -1) {
    perror("binding input control socket");
    exit(1);
  }
  if(listen(ctrlsock, 1) == -1) {
    perror("listen input control socket");
    exit(1);
  }
}

static void open_insystemdsocks(struct dollytab * mydollytab) {
  int clientSocket;
  unsigned int i;
  int Retval=-1;
  struct sockaddr_in serverAddr;
  socklen_t addr_size;
  serverAddr.sin_family = AF_INET;
  serverAddr.sin_port = htons(systemdport);
  if(mydollytab->flag_v) {
    fprintf(stderr, "Start dolly client using systemd socket on %u hosts, port %i:\n", mydollytab->hostnr, systemdport);
  }
  for(i = 0; i < mydollytab->hostnr; i++) {
      clientSocket = socket(PF_INET, SOCK_STREAM, 0);
      if(mydollytab->flag_v) {
        fprintf(stderr, "\t'%s'\n", mydollytab->hostring[i]);
      }
      serverAddr.sin_addr.s_addr = inet_addr(mydollytab->hostring[i]);
      /* Connect to the systemd socket of all client nodes to start the dolly service */
      addr_size = sizeof serverAddr;
      Retval = connect(clientSocket, (struct sockaddr *) &serverAddr, addr_size);
      if (Retval < 0) {
        fprintf(stderr, "Connection failed to %s ! dolly service wont be started !\n (Please do a: systemctl start dolly.socket)\n", mydollytab->hostring[i]);
      }
      close(clientSocket);
  }
}

static void open_outsocks(struct dollytab * mydollytab) {
  struct hostent *hent;
  struct sockaddr_in addrdata, addrctrl;
  int ret;
  int dataok = 0, ctrlok = 0, retry_count = 0;
  unsigned int i;
  int optval;
  unsigned int max = 0;
  char hn[256+32];
  int send_size, sizeofint = sizeof(int);

  if(mydollytab->nr_childs > 1) {
    max = mydollytab->nr_childs;
  } else if(mydollytab->add_nr > 0) {
    max = mydollytab->add_nr + 1;
  } else {
    max = 1;
  }
  for(i = 0; i < max; i++) {  /* For all childs we have */
    if(mydollytab->nr_childs > 1) {
      strcpy(hn, mydollytab->hostring[mydollytab->nexthosts[i]]);
    } else if(mydollytab->add_nr > 0) {
      if(mydollytab->add_mode == 1) {
	strcpy(hn, mydollytab->hostring[mydollytab->nexthosts[0]]);
	if(i > 0) {
	  strcat(hn, mydollytab->add_name[i - 1]);
	}
      } else if(mydollytab->add_mode == 2) {
	if(i == 0) {
	  strcpy(hn, mydollytab->hostring[mydollytab->nexthosts[0]]);
	} else {
	  int j = 0;
	  while(!isdigit(mydollytab->hostring[mydollytab->nexthosts[0]][j])) {
	    hn[j] = mydollytab->hostring[mydollytab->nexthosts[0]][j];
	    j++;
	  }
	  hn[j] = 0;
	  strcat(hn, mydollytab->add_name[i - 1]);
	  strcat(hn, &mydollytab->hostring[mydollytab->nexthosts[0]][j]);
	}
      } else {
	fprintf(stderr, "Undefined add_mode %d!\n", mydollytab->add_mode);
	exit(1);
      }
    } else if (mydollytab->add_primary) {
      assert(i < 1);
      
      if(mydollytab->add_mode == 1) {
        strcpy(hn, mydollytab->hostring[mydollytab->nexthosts[0]]);
        strcat(hn, mydollytab->add_name[0]);
      } else if(mydollytab->add_mode == 2) {
        int j = 0;
        while(!isdigit(mydollytab->hostring[mydollytab->nexthosts[0]][j])) {
          hn[j] = mydollytab->hostring[mydollytab->nexthosts[0]][j];
          j++;
        }
        hn[j] = 0;
        strcat(hn, mydollytab->add_name[0]);
        strcat(hn, &mydollytab->hostring[mydollytab->nexthosts[0]][j]);
      } else {
        fprintf(stderr, "Undefined add_mode %d!\n", mydollytab->add_mode);
        exit(1);
      }
    } else {
      assert(i < 1);
      strcpy(hn, mydollytab->hostring[mydollytab->nexthosts[i]]);
    }
    
    hent = gethostbyname(hn);
    //(void)fprintf(stderr,"DEBUG gethostbyname on >%s<\n",hn);
    if(hent == NULL) {
      char str[strlen(hn)+34];
      sprintf(str, "gethostbyname for host '%s' error %d",
	      hn, h_errno);
      herror(str);
      exit(1);
    }
    if(hent->h_addrtype != AF_INET) {
      fprintf(stderr, "Expected h_addrtype of AF_INET, got %d\n",
	      hent->h_addrtype);
    }

    if(mydollytab->flag_v) {
      fprintf(stderr, "Connecting to host %s...\n", hn);
      fflush(stderr);
    }
    
    /* Wait until we connected to everything... */
    dataok  = ctrlok = 0;
    do {
      dataout[i] = socket(PF_INET, SOCK_STREAM, 0);
      if(dataout[i] == -1) {
        perror("Opening output data socket");
        exit(1);
      }

      if((mydollytab->nr_childs > 1) || (i == 0)) {
        ctrlout[i] = socket(PF_INET, SOCK_STREAM, 0);
        if(ctrlout[i] == -1) {
          perror("Opening output control socket");
          exit(1);
        }
      }
      
      /* Attempt to set TCP_NODELAY */
      optval = 1;
      if(setsockopt(dataout[i], IPPROTO_TCP, TCP_NODELAY,
        	    &optval, sizeof(int)) < 0) {
        (void) fprintf(stderr,"setsockopt: TCP_NODELAY failed! errno = %d\n",
		       errno);
        exit(1);
      }

      if(mydollytab->segsize > 0) {
	/* Attempt to set TCP_MAXSEG */
        fprintf(stderr, "Set TCP_MAXSEG to %u bytes\n", mydollytab->segsize);
        if(setsockopt(dataout[i], IPPROTO_TCP, TCP_MAXSEG,
		      &mydollytab->segsize, sizeof(int)) < 0) {
	  (void) fprintf(stderr, "setsockopt: TCP_MAXSEG failed! errno = %d\n", 
			 errno);
      exit(1);
	}
      }
      if(setsockopt(dataout[i], SOL_SOCKET, SO_SNDBUF,&SCKBUFSIZE,sizeof(SCKBUFSIZE)) < 0) {
          (void) fprintf(stderr, "setsockopt: SO_SNDBUF failed! errno = %d\n", errno);
          exit(556);
      }
      getsockopt(dataout[i], SOL_SOCKET, SO_RCVBUF,
           (char *) &send_size, (void *) &sizeofint);
      //fprintf(stderr, "Send buffer %u is %d bytes\n", i, send_size);

      ///* Setup data port */
      addrdata.sin_family = hent->h_addrtype;
      addrdata.sin_port = htons(dataport);
      bcopy(hent->h_addr, &addrdata.sin_addr, hent->h_length);

      if((mydollytab->nr_childs > 1) || (i == 0)) {
        /* Setup control port */
        addrctrl.sin_family = hent->h_addrtype;
        addrctrl.sin_port = htons(ctrlport);
        bcopy(hent->h_addr, &addrctrl.sin_addr, hent->h_length);
      }
      
      if(!dataok) {
        retry_count = 0;
        do {
          ret = connect(dataout[i],
                  (struct sockaddr *)&addrdata, sizeof(addrdata));
          retry_count++;
        } while(retry_count < max_retries && ret == -1 && errno != ECONNREFUSED);
        if((ret == -1) && (errno == ECONNREFUSED)) {
          close(dataout[i]);
        } else if(ret == -1) {
          perror("connect");
          exit(1);
        } else {
          dataok = 1;
#ifdef DOLLY_NONBLOCK
          ret = fcntl(dataout[i], F_SETFL, O_NONBLOCK);
          if(ret == -1) {
            perror("fcntl");
          }
#endif /* DOLLY_NONBLOCK */
          if(mydollytab->add_nr > 0) {
            ret = write(dataout[i], &i, sizeof(i));
            if(ret == -1) {
              perror("Write fd-nr in open_outsocks()");
              exit(1);
            }
          }
          if(mydollytab->flag_v) {
            fprintf(stderr, "data ");
            fflush(stderr);
          }
        }
      }
      if(!ctrlok) {
	if((mydollytab->nr_childs > 1) || (i == 0)) {
    retry_count = 0;
    do {
      ret = connect(ctrlout[i],
        (struct sockaddr *)&addrctrl, sizeof(addrctrl));
      retry_count++;
    } while(retry_count < max_retries && ret == -1 && errno != ECONNREFUSED);
	  if((ret == -1) && (errno == ECONNREFUSED)) {
	    close(ctrlout[i]);
	  } else if(ret == -1) {
	    perror("connect");
	    exit(1);
	  } else {
	    ctrlok = 1;
	    if(mydollytab->flag_v) {
	      fprintf(stderr, "control ");
	      fflush(stderr);
	    }
	  }
	} else {
	  ctrlok = 1;
	}
      }
      if(dataok + ctrlok != 2) {
        sleep(1);
      }
    } while(dataok + ctrlok != 2);
    if(mydollytab->flag_v) {
      fprintf(stderr, "\b.\n");
    }
  }
}




static void buildring(struct dollytab * mydollytab) {
  socklen_t size;
  int ret = 0;
  unsigned int i = 0,j = 0,nr = 0;
  unsigned int ready_mach = 0;  /* Number of ready machines */
  char msg[1024];
  char info_buf[1024];

  if(!mydollytab->meserver) {
    /* Open the input sockets and wait for connections... */
    open_insocks(mydollytab);
    if(mydollytab->flag_v) {
      fprintf(stderr, "Accepting...");
      fflush(stderr);
    }
    
    /* All except the first accept a connection now */
    ctrlin = accept(ctrlsock, NULL, &size);
    if(ctrlin == -1) {
      perror("accept input control socket");
      exit(1);
    }
    if(mydollytab->flag_v) {
      fprintf(stderr, "control...\n");
      fflush(stderr);
    }
    
    /* Clients should now read everything from the ctrl-socket. */
    getparams(ctrlin,mydollytab);
    if(mydollytab->flag_v) {
      print_params(mydollytab);
    }

    datain[0] = accept(datasock, NULL, &size);
    if(datain[0] == -1) {
      perror("accept input data socket");
      exit(1);
    }
    if(mydollytab->add_nr > 0) {
      ret = read(datain[0], &nr, sizeof(nr));
      if(ret == -1) {
        perror("First read for nr in buildring");
        exit(1);
      }
      assert(nr == 0);
      for(i = 0; i < mydollytab->add_nr; i++) {
	datain[1 + i] = accept(datasock, NULL, &size);
	if(datain[1 + i] == -1) {
	  perror("accept extra input data socket");
	  exit(1);
	}
	ret = read(datain[1 + i], &nr, sizeof(nr));
	if(ret == -1) {
	  perror("Read for nr in buildring");
	  exit(1);
	}
	assert(nr == (1 + i));
      }
    }
    if(mydollytab->flag_v) {
      fprintf(stderr, "Connected data...done.\n");
    }
    /* The input sockets are now connected. */

    /* Give information back to server */
    sprintf(msg, "Host got parameters '%s'.\n", mydollytab->myhostname);
    ret = movebytes(ctrlin, WRITE, msg, strlen(msg),mydollytab);
    if((unsigned int) ret != strlen(msg)) {
      fprintf(stderr,
	      "Couldn't write got-parameters-message back to server "
	      "(sent %d instead of %zu bytes).\n",
	      ret, strlen(msg));
    }
  }

  if(mydollytab->meserver) {
    open_infile(1,mydollytab);
  } else {
    open_outfile(1,mydollytab);
  }

  /* All the machines except the leaf(s) need to open output sockets */
  if(!mydollytab->melast) {
    open_outsocks(mydollytab);
  }
  
  /* Finally, the first machine also accepts a connection */
  if(mydollytab->meserver) {
    char buf[mydollytab->t_b_size];
    ssize_t readsize;
    int fd, ret, maxsetnr = -1;
    fd_set real_set, cur_set;
    
    /* Send out dollytab */
    fd = open(dollytab, O_RDONLY);
    if(fd == -1) {
      perror("open dollytab");
      exit(1);
    }
    readsize = read(fd, buf, mydollytab->t_b_size);
    if(readsize == -1) {
      perror("read dollytab");
      exit(1);
    } else if(readsize == mydollytab->t_b_size) {
      fprintf(stderr, "Dollytab possibly too long, adjust program...\n");
      exit(1);
    } else if(readsize == 1448) {
      buf[1448] = ' ';
      readsize += 1;
    }
    for(i = 0; i < mydollytab->nr_childs; i++) {
      movebytes(ctrlout[i], WRITE, buf, readsize,mydollytab);
    }
    close(fd);


    /* Wait for backflow-information or the data socket connection */
    fprintf(stderr, "Waiting for ring to build...\n");
    FD_ZERO(&real_set);
    maxsetnr = -1;
    for(i = 0; i < mydollytab->nr_childs; i++) {
      FD_SET(ctrlout[i], &real_set);
      if(ctrlout[i] > maxsetnr) {
        maxsetnr = ctrlout[i];
      }
    }
    maxsetnr++;
    do {
      cur_set = real_set;
      ret = select(maxsetnr, &cur_set, NULL, NULL, NULL);
      if(ret == -1) {
        perror("select in buildring()\n");
        exit(1);
      }
      for(j = 0; j < mydollytab->nr_childs; j++) {
        if(FD_ISSET(ctrlout[j], &cur_set)) {
          ret = read(ctrlout[j], info_buf, 1024);
          if(ret == -1) {
            perror("read backflow in buildring");
            exit(1);
          }
          if(ret == 0) {
            fprintf(stderr, "read returned 0 from backflow in buildring.\n");
            exit(1);
          } else {
            char *p;
            
            p = info_buf;
            info_buf[ret] = 0;	
            if(mydollytab->flag_v) {
              fprintf(stderr, "%s", info_buf);
            }
            while((p = strstr(p, "ready")) != NULL) {
              ready_mach++;
              p++;
            }
            if(mydollytab->flag_v) {
              fprintf(stderr,
                "Machines left to wait for: %u\n", mydollytab->hostnr - ready_mach);
            }
          }
        }
      } /* For all childs */
    } while(ready_mach < mydollytab->hostnr);
  }

  if(mydollytab->flag_v) {
    fprintf(stderr, "Accepted.\n");
  }
  
  if(!mydollytab->meserver) {
    /* Send it further */
    if(!mydollytab->melast) {
      for(i = 0; i < mydollytab->nr_childs; i++) {
        movebytes(ctrlout[i], WRITE, mydollytab->dollybuf, mydollytab->dollybufsize,mydollytab);
      }
    }
    
    /* Give information back to server */
    sprintf(msg, "Host ready '%s'.\n", mydollytab->myhostname);
    ret = movebytes(ctrlin, WRITE, msg, strlen(msg),mydollytab);
    if((unsigned int) ret != strlen(msg)) {
      fprintf(stderr,
	      "Couldn't write ready-message back to server "
	      "(sent %d instead of %zu bytes).\n",
	      ret, strlen(msg));
    }
  }
}


static void usage(void) {
  fprintf(stderr, "\n");
  fprintf(stderr, "Dolly version: %s\n", version_string);
  fprintf(stderr, "\n");
  fprintf(stderr, "Dolly is a program to clone disks / partitions / data. It takes same amount of time to copy data to one node or to X nodes.\n");
  fprintf(stderr, "\n");
  fprintf(stderr,
	  "Usage: dolly [-hVvSsnYR] [-c <size>] [-b <size>] [-u <size>] [-f configfile] "
	  "[-o logfile] [-t time] -I [inputfile] -O [outpufile] -H [node1,node2,node3...]\n");
  fprintf(stderr, "\n");
  fprintf(stderr, "\tWithout any -s or -S option dolly will be a client\n");
  fprintf(stderr, "\t-s: this is the server, check hostname\n");
  fprintf(stderr, "\t-S <hostname>: use hostname as server\n");
  fprintf(stderr, "\t-R: resolve the hostnames to ipv4 addresses\n");
  fprintf(stderr, "\t-6: resolve the hostnames to ipv6 addresses\n");
  fprintf(stderr, "\t-V: Print version number and exit\n");
  fprintf(stderr, "\t-h: Print this help and exit\n");
  fprintf(stderr, "\t-d: connect to systemd socket on clients nodes to start the dolly service (port 9996)\n");
  fprintf(stderr, "\t-v: Verbose mode\n");
  fprintf(stderr, "\t-q: Suppresss \"ignored signal\" messages\n");
  fprintf(stderr, "\t-f <configfile>, where <configfile> is the "
	  "configuration file with all\n\t\tthe required information for "
	  "this run. Required on server only.\n");
  fprintf(stderr, "\t-o <logfile>: Write some statistical information  "
	  "in <logfile>\n");
  fprintf(stderr, "\t-a <timeout>: Lets dolly terminate if it could not transfer\n\t\tany data after <timeout> seconds.\n");
  fprintf(stderr, "\t-n: Do not sync before exit. Dolly exits sooner.\n");
  fprintf(stderr, "\t    Data may not make it to disk if power fails soon after dolly exits.\n\n");
  fprintf(stderr, "\tFollowing options can be used instead of a dollytab and\n");
  fprintf(stderr, "\timply the -S or -s option which must me preceded:\n");
  fprintf(stderr, "\t-H: comma seperated list of the hosts to send to\n");
  fprintf(stderr, "\t-I: input file\n");
  fprintf(stderr, "\t-O: output file (just - for output to stdout)\n\n");
  fprintf(stderr, "\tCustomize network transfer:\n");
  fprintf(stderr, "\t-b <size>, where size is the size of block to transfer (default 4096)\n");
  fprintf(stderr, "\t-u <size>, size of the buffer (multiple of 4K)\n");
  fprintf(stderr, "\t-c <size>, where size is uncompressed size of "
	  "compressed inputfile\n\t\t(for statistics only)\n");
  fprintf(stderr, "\n");
  fprintf(stderr, "Example of usage:\n");
  fprintf(stderr, "On client:\n");
  fprintf(stderr, "\tdolly -v\n");
  fprintf(stderr, "\n");
  fprintf(stderr, "On server:\n");
  fprintf(stderr, "\tdolly -s -H sle15sp32,sle15sp33,sle15sp34 -I files.tgz -O /tmp/files.tgz\n");
  exit(1);
}

int main(int argc, char *argv[]) {
  int c;
  unsigned int i;
  int flag_f = 0, flag_cargs = 0, generated_dolly = 0, me = -2;
  FILE *df;
  char *mnname = NULL, *tmp_str, *host_str, *a_str, *sp, *ip_addr;
  size_t nr_hosts = 0;
  int fd;
  struct dollytab* mydollytab = (struct dollytab*)malloc(sizeof(struct dollytab));
  struct sockaddr_in sock_address;
  init_dollytab(mydollytab);


  /* Parse arguments */
  while(1) {
    c = getopt(argc, argv, "a:b:c:f:r:u:vqo:S:shdnR46:V:I:O:Y:H:");
    if(c == -1) break;
    
    switch(c) {
    case 'f':
      /* Where to find the config-file. */
      if(strlen(optarg) > 255) {
        fprintf(stderr, "Name of config-file too long.\n");
        exit(1);
      }
      strcpy(dollytab, optarg);
      flag_f = 1;
      break;
    case 'R':
      if(mydollytab->resolve != 6 && mydollytab->resolve != 4) {
        mydollytab->resolve = 1;
      }
      break;
    case '6':
      mydollytab->resolve = 6;
      break;
    case '4':
      mydollytab->resolve = 4;
      break;
    case 'v':
      /* Verbose */
      mydollytab->flag_v = 1;
      break;
    case 'd':
      /* systemd socket activation */
      mydollytab->flag_d = 1;
      break;
    case 'o':
      /* log filename */
      if(strlen(optarg) > 255) {
        fprintf(stderr, "Name of log-file too long.\n");
        exit(1);
      }
      strcpy(logfile, optarg);
      flag_log = 1;
      break;

      /* This is now in the config file. */
    case 'c':
      mydollytab->compressed_in = 1;
      maxcbytes = atoi(optarg);
      break;
    case 'b':
      mydollytab->t_b_size = atoi(optarg);
      break;
    case 'u':
      buffer_size = atoi(optarg);
      break;
    case 'n':
      dosync = 0;
      break;
    case 's':
      /* This machine is the server. */
      mydollytab->meserver = 1;
      break;
    case 'S':
      /* This machine is the server - don't check hostname. */
      mydollytab->meserver = 1;
      if(strcmp(optarg,"-") < 0) {
        fprintf(stderr,"'%s' is not a valid servername\n",optarg);
        exit(1);
      }
      memcpy(mydollytab->servername,optarg,strlen(optarg));
      break;
    case 'a':
      i = atoi(optarg);
      if((int)i <= 0) {
        fprintf(stderr, "Timeout of %u doesn't make sense.\n", i);
        exit(1);
      }
      timeout = i;
      if(mydollytab->flag_v) {
        fprintf(stderr, "Will set timeout to %d seconds.\n", timeout);
      }
      signal(SIGALRM, alarm_handler);
      break;
    case  'r':
      max_retries = atoi(optarg);
      break;
    case 'h':
      /* Give a little help */
      usage();
      break;
    case 'q':
      verbignoresignals = 0;
      break;
    case 'V':
      fprintf(stderr, "Dolly version %s\n", version_string);
      exit(0);
      break;
    case 'I':
      if(strlen(optarg) > 255) {
        fprintf(stderr, "Name of input-file too long.\n");
        exit(1);
      }
      if (mydollytab->meserver == 0) {
        fprintf(stderr,"the -S/-s must preceed the -I option\n");
        exit(1);
      }
      memcpy(mydollytab->infile,optarg,strlen(optarg));
      flag_cargs = 1;
      break;

    case 'O':
      if(strlen(optarg) > 255) {
        fprintf(stderr, "Name of output-file too long.\n");
        exit(1);
      }
      if (mydollytab->meserver == 0) {
        fprintf(stderr,"the -S/-s must preceed the -O option\n");
        exit(1);
      }
      memcpy(mydollytab->outfile,optarg,strlen(optarg));
      flag_cargs = 1;
      break;

    case 'Y':
      mydollytab->hyphennormal = 1;
      break;

    case 'H':
      if (mydollytab->meserver == 0) {
        fprintf(stderr,"the -S/-s must preceed the -H option\n");
        exit(1);
      }
      /* copying string as it is modified*/
      a_str = strdup(optarg);
      tmp_str = a_str;
      while(*tmp_str) {
        if(*host_delim == *tmp_str) {
          nr_hosts++;
        }
        tmp_str++;
      }
      nr_hosts++;
      mydollytab->hostnr = nr_hosts;
      mydollytab->hostring = (char**) malloc(nr_hosts * sizeof(char *));
      /* now find the first host */
      host_str = strtok(a_str,host_delim);
      nr_hosts = 0;
      /* check if have to resolve the hostnames */
      while(host_str != NULL) {
        if(mydollytab->resolve == 0 && 
           inet_pton(AF_INET,host_str,&(sock_address.sin_addr)) == 1 &&
           inet_pton(AF_INET6,host_str,&(sock_address.sin_addr)) == 1) {
          mydollytab->hostring[nr_hosts] = (char *)malloc(strlen(host_str)+1);
          memcpy(mydollytab->hostring[nr_hosts], host_str,strlen(host_str));
        } else { 
          /* get memory for ip address */
          ip_addr = (char*)malloc(sizeof(char)*256);
          if(resolve_host(host_str,ip_addr,mydollytab->resolve)) {
            fprintf(stderr,"Could not resolve the host '%s'\n",host_str);
            exit(1);
          }
          mydollytab->hostring[nr_hosts] = (char *)malloc(strlen(ip_addr)+1);
          if(!mydollytab->hostring[nr_hosts]) {
            fprintf(stderr,"Could not get memory for hostring!\n");
            exit(1);
          }
          strcpy(mydollytab->hostring[nr_hosts],ip_addr);
          free(ip_addr);
        }
        host_str = strtok(NULL,host_delim);
        if(strcmp(mydollytab->hostring[nr_hosts], mydollytab->myhostname) == 0) {
          me = nr_hosts;
        } else if(!mydollytab->hyphennormal) {
          /* Check if the hostname is correct, but a different interface is used */
          if((sp = strchr(mydollytab->hostring[nr_hosts], '-')) != NULL) {
            if(strncmp(mydollytab->hostring[nr_hosts], mydollytab->myhostname, sp - mydollytab->hostring[nr_hosts]) == 0) {
              me = nr_hosts;
            }
          }
        }
        nr_hosts++;
      }
      /* Build up topology */
      mydollytab->nr_childs = 0;
      for(i = 0; i < mydollytab->fanout; i++) {
        if(mydollytab->meserver) {
          if(i + 1 <= mydollytab->hostnr) {
            mydollytab->nexthosts[i] = i;
            mydollytab->nr_childs++;
          }
        } else {
          if((me + 1) * mydollytab->fanout + 1 + i <= mydollytab->hostnr) {
            mydollytab->nexthosts[i] = (me + 1) * mydollytab->fanout + i;
            mydollytab->nr_childs++;
          }
        }
      }
      /* In a tree, we might have multiple last machines. */
      if(mydollytab->nr_childs == 0) {
        mydollytab->melast = 1;
      }

      free(a_str);
      /* make sure that we are the server */
      mydollytab->meserver = 1;
      flag_cargs = 1;
      break;
      
    default:
      fprintf(stderr, "Unknown option '%c'.\n", c);
      exit(1);
    }
 // always do hostname resolution
 //   if(flag_cargs) {
      /* only use HOST when servername or ip is not explictly set */
      if(strcmp(mydollytab->servername,"") == 0) {
        mnname = getenv("HOST");
        if(mydollytab->resolve != 0) {
          ip_addr = (char*)malloc(sizeof(char)*256);
          if(resolve_host(mnname,ip_addr,mydollytab->resolve)) {
            fprintf(stderr,"Could resolve the server address '%s'\n",mydollytab->servername);
            exit(1);
          }
          memcpy(mydollytab->myhostname,ip_addr,strlen(ip_addr));
          memcpy(mydollytab->servername,ip_addr,strlen(ip_addr));
          free(ip_addr);
        } else {
          memcpy(mydollytab->myhostname,mnname,strlen(mnname));
          memcpy(mydollytab->servername,mnname,strlen(mnname));
        }
      } else {
        /* check if we allready have a valid ip address */
        if(inet_pton(AF_INET,mydollytab->servername,&(sock_address.sin_addr)) == 0 &&
           inet_pton(AF_INET6,mydollytab->servername,&(sock_address.sin_addr)) == 0 &&
           mydollytab->resolve != 0) {
          ip_addr = (char*)malloc(sizeof(char)*256);
          if(resolve_host(mydollytab->servername,ip_addr,mydollytab->resolve)) {
            fprintf(stderr,"Could resolve the server address '%s'\n",mydollytab->servername);
            exit(1);
          }
          memcpy(mydollytab->servername,ip_addr,strlen(ip_addr));
          memcpy(mydollytab->myhostname,ip_addr,strlen(ip_addr));
          free(ip_addr);
        } else {
          memcpy(mydollytab->myhostname,mydollytab->servername,strlen(mydollytab->servername));
        }
      }

//    }
    if(flag_f && !flag_cargs) {
      /* Open the config-file */
      df = fopen(optarg, "r");
      if(df == NULL) {
        char errstr[256];
        sprintf(errstr, "fopen dollytab '%s'", optarg);
        perror(errstr);
        exit(1);
      }
      parse_dollytab(df,mydollytab);
      fclose(df);
    }
  }

  /* Did we get the parameters we need? */
  if(mydollytab->meserver && !flag_f && !flag_cargs) {
    fprintf(stderr, "Missing parameter -f <configfile>\n");
    exit(1);
  }
  if(flag_cargs) {
    if(strlen(mydollytab->outfile) == 0) {
      fprintf(stderr,"outfile via '-O FILE' must be set\n");
      exit(1);
    }
    if(strlen(mydollytab->infile) == 0) {
      fprintf(stderr,"inputfile via '-I [FILE|-]' must be set\n");
      exit(1);
    }
    if(strlen(dollytab) == 0) {
      generated_dolly = 1;
      strcpy(dollytab,"/tmp/dollygenXXXXXX");
      fd = mkstemp(dollytab);
      df = fdopen(fd,"w");
      if(df == NULL) {
        printf("Could not open temporary dollytab");
      }
      fprintf(df,"infile %s\n",mydollytab->infile);
      fprintf(df,"outfile %s\n",mydollytab->outfile);
      fprintf(df,"server %s\n",mydollytab->myhostname);
      fprintf(df,"firstclient %s\n",mydollytab->hostring[0]);
      fprintf(df,"lastclient %s\n",mydollytab->hostring[nr_hosts-1]);
      fprintf(df,"clients %u\n",mydollytab->hostnr);
      for(i = 0; i < mydollytab->hostnr; i++) {
        fprintf(df,"%s\n",mydollytab->hostring[i]);
        if(mydollytab->flag_v) { fprintf(stderr,"writing '%s'\n'",mydollytab->hostring[i]); }
      }
      fprintf(df,"endconfig\n");
      fclose(df);
    }
  }

  if(mydollytab->meserver && mydollytab->flag_v) {
    print_params(mydollytab);
  }

  /* try to open standard terminal output */
  /* if it fails, redirect stdtty to stderr */
  stdtty = fopen("/dev/tty","a");
  if (stdtty == NULL) {
      stdtty = stderr;
    }

  if(mydollytab->flag_d) {
    if (mydollytab->hostnr < 1) {
      fprintf(stderr, "\nAt least one node is needed, use the -H parameter\n");
      exit(1);
    }
    fprintf(stderr, "\nStart the dolly client on all nodes...\n");
    open_insystemdsocks(mydollytab);
  }

  if(mydollytab->flag_v) {
    fprintf(stderr, "\nTrying to build ring...\n");
  }
  
  alarm(timeout);

  buildring(mydollytab);
  
  if(mydollytab->meserver) {
    fprintf(stdtty, "Server: Sending data...\n");
  } else {    
    if(mydollytab->flag_v) {
      fprintf(stdtty, "Receiving...\n");
    }
  }

  transmit(mydollytab);
  /* remove the generated dollytab */
  if(generated_dolly) {
    unlink(dollytab);
  }
  close(datain[0]);
  close(ctrlin);
  close(datasock);
  close(ctrlsock);
  for(i = 0; i < mydollytab->nr_childs; i++) {
    close(ctrlout[i]);
    close(dataout[i]);
  }
  if(mydollytab->flag_v) {
    fprintf(stderr, "\n");
  }

  fclose(stdtty);
  for(i = 0; i < mydollytab->hostnr; i++) {
    free(mydollytab->hostring[i]);
  }
  free(mydollytab->hostring);
  free(mydollytab);
 
  exit(0);
}
07070100000008000081A4000000000000000000000001623B5E140000008C000000000000000000000000000000000000001800000000dolly-0.64.2/dolly.confinfile /dev/sda5
outfile /dev/sda5
server node1
hyphennormal
firstclient node2
lastclient node5
clients 4
node2
node3
node4
node5
endconfig
07070100000009000081A4000000000000000000000001623B5E140000084E000000000000000000000000000000000000001500000000dolly-0.64.2/dolly.h#ifndef DOLLY_H
#define DOLLY_H
static const char version_string[] = "0.64.2, 23-MAR-2022";

#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/poll.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/time.h>
#include <sys/mman.h>
#include <netinet/tcp.h>
#include <assert.h>
#include <ctype.h>
#include <signal.h>

#include "dollytab.h"
#include "transmit.h"

#define DOLLY_NONBLOCK 1                 /* Use nonblocking network sockets */
#define WRITE 1
#define READ 2

extern FILE *stdtty;           /* file pointer to the standard terminal tty */


/* Clients need the ports before they can listen, so we use defaults. */
extern const unsigned int dataport;
extern const unsigned int ctrlport;
extern const char* host_delim;

/* File descriptors for file I/O */
extern int input, output;

/* Numbers for splitted input/output files */
extern unsigned int input_nr, output_nr;


/* size of buffers for TCP sockets (approx. 100KB, multiple of 4 KB) */
extern unsigned int buffer_size ;

#define SCKBUFSIZE buffer_size
/* Normal sockets for data transfer */
extern int datain[MAXFANOUT], dataout[MAXFANOUT];
extern int datasock;

/* Special sockets for control information */
extern int ctrlin, ctrlout[MAXFANOUT];
extern int ctrlsock;

extern unsigned long long maxbytes; /* max bytes to transfer */
extern unsigned long long maxcbytes;/*     --  "  --  in compressed mode */
extern int dosync;                  /* sync() after transfer */
extern int timeout;                 /* Timeout for startup */
extern int verbignoresignals;       /* warn on ignore signal errors */

extern int max_retries;
extern char dollytab[256];



extern int flag_log;
extern char logfile[256];


/* Pipe descriptor in case data must be uncompressed before write */
extern int pd[2];
/* Pipe descriptor in case input data must be compressed */
extern int id[2]; 

/* PIDs of child processes */
extern int in_child_pid, out_child_pid;

#endif
0707010000000A000081A4000000000000000000000001623B5E1400000157000000000000000000000000000000000000001B00000000dolly-0.64.2/dolly.service[Unit]
Description=Dolly client daemon
Wants=dolly.socket
After=network.target
After=firewalld.service
After=iptables.service
Documentation=https://github.com/openSUSE/dolly

[Service]
Type=oneshot
Restart=no
ExecStart=/usr/sbin/dolly
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process

[Install]
WantedBy=multi-user.target
Also=dolly.socket
0707010000000B000081A4000000000000000000000001623B5E14000000DE000000000000000000000000000000000000001A00000000dolly-0.64.2/dolly.socket[Unit]
Description=Dolly local socket
Before=dolly.service


[Socket]
ListenStream=0.0.0.0:9996
Accept=no
Service=dolly.service
TriggerLimitIntervalSec=2
FlushPending=yes
SocketMode=0666

[Install]
WantedBy=sockets.target
0707010000000C000081A4000000000000000000000001623B5E14000000B6000000000000000000000000000000000000002000000000dolly-0.64.2/dolly_firewall.xml<?xml version="1.0" encoding="utf-8"?>
<service>
  <short>Dolly</short>
  <description>Enables TCP ports for Dolly</description>
  <port protocol="tcp" port="9996-9998"/>
</service>
0707010000000D000081A4000000000000000000000001623B5E1400003CD4000000000000000000000000000000000000001800000000dolly-0.64.2/dollytab.c#include "dollytab.h"
/* init the dollytab struct */
void init_dollytab(struct dollytab * mdt) {
  mdt->flag_v = 0;
  memset(mdt->myhostname,'\0',sizeof(mdt->myhostname));
  memset(mdt->servername,'\0',sizeof(mdt->servername));
  memset(mdt->infile,'\0',sizeof(mdt->infile));
  memset(mdt->outfile,'\0',sizeof(mdt->infile));
  memset(mdt->nexthosts,0,sizeof(mdt->nexthosts));
  memset(mdt->add_name,'\0',sizeof(mdt->add_name));
  mdt->meserver = 0;
  mdt->compressed_in = 0;
  mdt->compressed_out = 0;
  mdt->output_split = 0;
  mdt->input_split = 0;
  mdt->add_nr = 0;
  mdt->add_primary = 0;
  mdt->add_mode = 0;
  mdt->nr_childs = 0;
  mdt->hostnr = 0;
  mdt->melast = 0;
  mdt->hyphennormal = 0;
  mdt->fanout = 1;
  mdt->resolve = 0;
  mdt->dollybufsize = 0;
  mdt->segsize = 0;
  mdt->t_b_size = 4096;
  mdt->hostring = NULL;
}

/* Parses the config-file. The path to the file is given in dollytab */
void parse_dollytab(FILE *df,struct dollytab * mydollytab) {
  char str[256];
  char *sp, *sp2;
  unsigned int i;
  int me = -2;
	int family, name_status;
  int fm = AF_INET;
  char *mname = NULL;
	char host[NI_MAXHOST];
  struct ifaddrs *ifaddr, *ifa;
  /* Read the parameters... */
  /* First we want to know the input filename */
  if(fgets(str, 256, df) == NULL) {
    fprintf(stderr, "errno = %d\n", errno);
    perror("fgets for infile");
    exit(1);
  }
  sp2 = str;
  if(strncmp("compressed ", sp2, 11) == 0) {
    mydollytab->compressed_in = 1;
    sp2 += 11;
  } else {
    mydollytab->compressed_in = 0;
  }
  if(strncmp("infile ", sp2, 7) != 0) {
    fprintf(stderr, "Missing 'infile ' in config-file.\n");
    exit(1);
  }
  sp2 += 7;
  if(sp2[strlen(sp2)-1] == '\n') {
    sp2[strlen(sp2)-1] = '\0';
  }
  if((sp = strchr(sp2, ' ')) == NULL) {
    sp = sp2 + strlen(sp2);
  }
  if(mydollytab->compressed_in && (strncmp(&sp2[sp - sp2 - 3], ".gz", 3) != 0)) {
    char tmp_str[256];
    strncpy(tmp_str, sp2, sp - sp2);
    tmp_str[sp - sp2] = '\0';
    fprintf(stderr,
      "WARNING: Compressed outfile '%s' doesn't end with '.gz'!\n",
      tmp_str);
    }
    strncpy(mydollytab->infile, sp2, sp - sp2);
    sp++;
    if(strcmp(sp, "split") == 0) {
      mydollytab->input_split = 1;
    }
    
    /* Then we want to know the output filename */
    if(fgets(str, 256, df) == NULL) {
      perror("fgets for outfile");
      exit(1);
    }
    sp2 = str;
    if(strncmp("compressed ", sp2, 11) == 0) {
      mydollytab->compressed_out = 1;
      sp2 += 11;
    }
    if(strncmp("outfile ", sp2, 8) != 0) {
      fprintf(stderr, "Missing 'outfile ' in config-file.\n");
      exit(1);
    }
    sp2 += 8;
    if(sp2[strlen(sp2)-1] == '\n') {
      sp2[strlen(sp2)-1] = '\0';
    }
    if((sp = strchr(sp2, ' ')) == NULL) {
      sp = sp2 + strlen(sp2);
    }
    if(mydollytab->compressed_out && (strncmp(&sp2[sp - sp2 - 3], ".gz", 3) != 0)) {
      char tmp_str[256];
      strncpy(tmp_str, sp2, sp - sp2);
      tmp_str[sp - sp2] = '\0';
      fprintf(stderr,
        "WARNING: Compressed outfile '%s' doesn't end with '.gz'!\n",
        tmp_str);
    }
    strncpy(mydollytab->outfile, sp2, sp - sp2);
    sp++;
    if(strncmp(sp, "split ", 6) == 0) {
      unsigned long long size = 0;
      char *s = sp+6;
      while(isdigit(*s)) {
        size *= 10LL;
        size += (unsigned long long)(*s - '0');
        s++;
      }
      switch(*s) {
        case 'T': size *= 1024LL*1024LL*1024LL*1024LL; break;
        case 'G': size *= 1024LL*1024LL*1024LL; break;
        case 'M': size *= 1024LL*1024LL; break;
        case 'k': size *= 1024LL; break;
        default:
          fprintf(stderr, "Unknown multiplier '%c' for split size.\n", *s);
          break;
      }
      mydollytab->output_split = size;
      str[sp - str - 1] = '\0';
    }
  
  /* Get the optional TCPMaxSeg size */ 
  if(fgets(str, 256, df) == NULL) {
    perror("fgets on segsize or fanout");
    exit(1);
  }
  if(strncmp("segsize ", str, 8) == 0) {
    if(str[strlen(str)-1] == '\n') {
      str[strlen(str)-1] = '\0';
    }
    sp = strchr(str, ' ');
    if(sp == NULL) {
      fprintf(stderr, "Error segsize line.\n");
      exit(1);
    }
    mydollytab->segsize = atoi(sp + 1);
    if(fgets(str, 256, df) == NULL) {
      perror("fgets after segsize");
      exit(1);
    }
  }

  /* Get the optional extra network interfaces */
  /* Form of the line: add <nr_extra_interfaces>:<postfix>{:<postfix>} */
  if((strncmp("add ", str, 4) == 0) || (strncmp("add2 ", str, 5) == 0)) {
    char *s1, *s2;
    int max = 0, i;

    if(strncmp("add ", str, 4) == 0) {
      mydollytab->add_mode = 1;
    }
    if(strncmp("add2 ", str, 5) == 0) {
      mydollytab->add_mode = 2;
    }
    if(mydollytab->add_mode == 0) {
      fprintf(stderr,
	      "Bad add_mode: Choose 'add' or 'add2' in config-file.\n");
      exit(1);
    }
    
    s1 = str + 4;
    s2 = s1;
    while((*s2 != ':' && *s2 != '\n' && *s2 != 0)) s2++;
    if(*s2 == 0) {
      fprintf(stderr, "Error in add line: First colon missing.\n");
      exit(1);
    }
    *s2 = 0;
    max = atoi(s1);
    if(max < 0) {
      fprintf(stderr, "Error in add line: negative number.\n");
      exit(1);
    }
    if(max >= MAXFANOUT) {
      fprintf(stderr, "Error in add line: Number larger than MAXFANOUT.\n");
      exit(1);
    }
    if (max==0) {
      /* change names of primary interface */
      mydollytab->add_primary = 1;
      s1 = s2 + 1;
      s2++;
      while((*s2 != ':' && *s2 != '\n' && *s2 != 0)) s2++;
      if(*s2 == 0) {
        fprintf(stderr, "Error in add line: Preliminary end.\n");
        exit(1);
      }
      *s2 = 0;
      strcpy(mydollytab->add_name[0], s1);
    } else {
      for(i = 0; i < max; i++) {
	s1 = s2 + 1;
	s2++;
	while((*s2 != ':' && *s2 != '\n' && *s2 != 0)) s2++;
	if(*s2 == 0) {
	  fprintf(stderr, "Error in add line: Preliminary end.\n");
	  exit(1);
	}
	*s2 = 0;
	strcpy(mydollytab->add_name[i], s1);
      }
    }
    mydollytab->add_nr = max;
    if(fgets(str, 256, df) == NULL) {
      perror("fgets after add");
      exit(1);
    }
  }
  
  /* Get the fanout (1 = linear list, 2 = binary tree, ... */
  if(strncmp("fanout ", str, 7) == 0) {
    if(str[strlen(str)-1] == '\n') {
      str[strlen(str)-1] = '\0';
    }
    sp = strchr(str, ' ');
    if(sp == NULL) {
      fprintf(stderr, "Error in fanout line.\n");
      exit(1);
    }
    mydollytab->fanout = atoi(sp + 1);
    if(fgets(str, 256, df) == NULL) {
      perror("fgets after fanout");
      exit(1);
    }
  }

  /*
   * The parameter "hyphennormal" means that the hyphen '-' is treated
   * as any other character. The default is to treat it as a separator
   * between base hostname and the number of the node.
   */
  if(strncmp("hyphennormal", str, 12) == 0) {
    mydollytab->hyphennormal = 1;
    if(fgets(str, 256, df) == NULL) {
      perror("fgets after hyphennormal");
      exit(1);
    }
  }
  if(strncmp("hypheninterface", str, 12) == 0) {
    mydollytab->hyphennormal = 1;
    if(fgets(str, 256, df) == NULL) {
      perror("fgets after hypheninterface");
      exit(1);
    }
  }
  
  /* Get the server's name. */
  if(strncmp("server ", str, 7) != 0) {
    fprintf(stderr, "Missing 'server' in config-file.\n");
    exit(1);
  }
  if(str[strlen(str)-1] == '\n') {
    str[strlen(str)-1] = '\0';
  }
  sp = strchr(str, ' ');
  if(sp == NULL) {
    fprintf(stderr, "Error in firstclient line.\n");
    exit(1);
  }
  strncpy(mydollytab->servername, sp+1, strlen(sp));

  /* 
     disgusting hack to make -S work.  If the server name
     specified in the file is wrong bad things will probably happen!
  */
  
  if(mydollytab->meserver == 2){
    (void) strcpy(mydollytab->myhostname,mydollytab->servername);
    mydollytab->meserver = 1;
  }

  if(!(mydollytab->meserver ^ (strcmp(mydollytab->servername, mydollytab->myhostname) != 0))) {
    fprintf(stderr,
	    "Commandline parameter -s and config-file disagree on server!\n");
    fprintf(stderr, "  My name is '%s'.\n", mydollytab->myhostname);
    fprintf(stderr, "  The config-file specifies '%s'.\n", mydollytab->servername);
    exit(1);
  }
  
  /* We need to know the FIRST host of the ring. */
  /* (Do we still need the firstclient?)         */
  if(fgets(str, 256, df) == NULL) {
    perror("fgets for firstclient");
    exit(1);
  }
  if(strncmp("firstclient ", str, 12) != 0) {
    fprintf(stderr, "Missing 'firstclient ' in config-file.\n");
    exit(1);
  }
  if(str[strlen(str)-1] == '\n') {
    str[strlen(str)-1] = '\0';
  }
  sp = strchr(str, ' ');
  if(sp == NULL) {
    fprintf(stderr, "Error in firstclient line.\n");
    exit(1);
  }

  /* We need to know the LAST host of the ring. */
  if(fgets(str, 256, df) == NULL) {
    perror("fgets for lastclient");
    exit(1);
  }
  if(strncmp("lastclient ", str, 11) != 0) {
    fprintf(stderr, "Missing 'lastclient ' in config-file.\n");
    exit(1);
  }
  if(str[strlen(str)-1] == '\n') {
    str[strlen(str)-1] = '\0';
  }
  sp = strchr(str, ' ');
  if(sp == NULL) {
    fprintf(stderr, "Error in lastclient line.\n");
    exit(1);
  }
  if(strcmp(mydollytab->myhostname, sp+1) == 0) {
    mydollytab->melast = 1;
  } else {
    mydollytab->melast = 0;
  }

  /* Read in all the participating hosts. */
  if(fgets(str, 256, df) == NULL) {
    perror("fgets for clients");
    exit(1);
  }
  if(strncmp("clients ", str, 8) != 0) {
    fprintf(stderr, "Missing 'clients ' in config-file.\n");
    exit(1);
  }
  mydollytab->hostnr = atoi(str+8);
  if((mydollytab->hostnr < 1) || (mydollytab->hostnr > MAXHOSTS)) {
    fprintf(stderr, "I think %u numbers of hosts doesn't make much sense.\n",
	    mydollytab->hostnr);
    exit(1);
  }
  /* get a list to all availabel interfaces */
	if (getifaddrs(&ifaddr) == -1) {
		perror("getifaddrs");
		exit(EXIT_FAILURE);
	}
  mydollytab->hostring = (char **)malloc(mydollytab->hostnr * sizeof(char *));
  for(i = 0; i < mydollytab->hostnr; i++) {
    if(fgets(str, 256, df) == NULL) {
      char errstr[256];
      sprintf(errstr, "gets for host %u", i);
      perror(errstr);
      exit(1);
    }
    if(str[strlen(str)-1] == '\n') {
      str[strlen(str)-1] = '\0';
    }
    mydollytab->hostring[i] = (char *)malloc(strlen(str)+1);
    strcpy(mydollytab->hostring[i], str);

    /* Try to find next host in ring */
    /* if(strncmp(mydollytab->hostring[i], mydollytab->myhostname, strlen(mydollytab->myhostname)) == 0) { */
    for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
      if (ifa->ifa_addr == NULL) {
        continue;
      }
      family = ifa->ifa_addr->sa_family;
      if (family == fm) {
        name_status = getnameinfo( ifa->ifa_addr, (family == AF_INET) ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6) , host , NI_MAXHOST , NULL , 0 , NI_NUMERICHOST);
        if (name_status != 0) {
          printf("getnameinfo() failed: %s\n", gai_strerror(name_status));
          exit(EXIT_FAILURE);
        }
        if(strcmp(mydollytab->hostring[i],host) == 0) {
          me = i;
          strncpy(mydollytab->myhostname,host,strlen(host));
        } else if(!mydollytab->hyphennormal) {
          /* Check if the hostname is correct, but a different interface is used */
          if((sp = strchr(mydollytab->hostring[i], '-')) != NULL) {
            if(strncmp(mydollytab->hostring[i], host, sp - mydollytab->hostring[i]) == 0) {
              me = i;
              strncpy(mydollytab->myhostname,host,strlen(host));
            }
          }
        }
      }
    }
    /* check if hostname was in the configuration and not an ip */
    if(me == -2) {
       mname = getenv("MYNODENAME");
       if(mname != NULL) {
          if(strcmp(mydollytab->hostring[i],mname) == 0) {
            strncpy(mydollytab->myhostname,mname,strlen(mname));
            me = i;
            if(i == mydollytab->hostnr-1) {
             mydollytab->melast = 1;
            }
          }
       }
    }
    if(me == -2) {
       mname = getenv("HOST");
       if(mname != NULL) {
          if(strcmp(mydollytab->hostring[i],mname) == 0) {
            strncpy(mydollytab->myhostname,mname,strlen(mname));
            me = i;
            if(i == mydollytab->hostnr-1) {
             mydollytab->melast = 1;
            }
          }
       }
    }
  }
	freeifaddrs(ifaddr);
  if(!mydollytab->meserver && (me == -2)) {
    fprintf(stderr, "Couldn't find myself '%s' in hostlist.\n",mydollytab->myhostname);
    exit(1);
  }
  
  /* Build up topology */
  mydollytab->nr_childs = 0;
  
  for(i = 0; i < mydollytab->fanout; i++) {
    if(mydollytab->meserver) {
      if(i + 1 <= mydollytab->hostnr) {
        mydollytab->nexthosts[i] = i;
        mydollytab->nr_childs++;
      }
    } else {
      if((me + 1) * mydollytab->fanout + 1 + i <= mydollytab->hostnr) {
        mydollytab->nexthosts[i] = (me + 1) * mydollytab->fanout + i;
        mydollytab->nr_childs++;
      }
    }
  }
  /* In a tree, we might have multiple last machines. */
  if(mydollytab->nr_childs == 0) {
    mydollytab->melast = 1;
  }

  /* Did we reach the end? */
  if(fgets(str, 256, df) == NULL) {
    perror("fgets for endconfig");
    exit(1);
  }
  if(strncmp("endconfig", str, 9) != 0) {
    fprintf(stderr, "Missing 'endconfig' in config-file.\n");
    exit(1);
  }
  if((mydollytab->nr_childs > 1) && (mydollytab->add_nr > 0)) {
    fprintf(stderr, "Currently dolly supports either a fanout > 1\n"
	    "OR the use of extra network links, but not both.\n");
    exit(1);
  }
  if(mydollytab->flag_v) {
    fprintf(stderr, "done.\n");
  }
  if(mydollytab->flag_v) {
    if(!mydollytab->meserver) {
      fprintf(stderr, "I'm number %d\n", me);
    }
  }
}

/*
 * Clients read the parameters from the control-socket.
 * As they are already parsed from the config-file by the server,
 * we don't do much error-checking here.
 */
void getparams(int f,struct dollytab * mydollytab) {
  size_t readsize;
  ssize_t writesize;
  int fd, ret;
  FILE *dolly_df = NULL;
  char tmpfile[32] = "/tmp/dollytmpXXXXXX";

  if(mydollytab->flag_v) {
    fprintf(stderr, "Trying to read parameters...");
    fflush(stderr);
  }
  mydollytab->dollybuf = (char *)malloc(mydollytab->t_b_size);
  if(mydollytab->dollybuf == NULL) {
    fprintf(stderr, "Couldn't get memory for dollybuf.\n");
    exit(1);
  }

  readsize = 0;
  do {
    ret = read(f, mydollytab->dollybuf + readsize, mydollytab->t_b_size);
    if(ret == -1) {
      perror("read in getparams while");
      exit(1);
    } else if((ssize_t) ret == mydollytab->t_b_size) {  /* This will probably not happen... */
      fprintf(stderr, "Ups, the transmitted config-file seems to long.\n"
	      "Please rewrite dolly.\n");
      exit(1);
    }
    readsize += ret;
  } while(ret == 1448);
    mydollytab->dollybufsize = readsize;

  /* Write everything to a file so we can use parse_dollytab(FILE *)
     afterwards.  */
#if 0
  tmpfile = tmpnam(NULL);
  fd = open(tmpfile, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
#endif
  fd = mkstemp(tmpfile);
  if(fd == -1) {
    perror("Opening temporary file 'tmp' in getparams");
    exit(1);
  }
  writesize = write(fd, mydollytab->dollybuf, readsize);
  if(writesize == -1) {
    perror("Writing temporary file 'tmp' in getparams");
    exit(1);
  }
  dolly_df = fdopen(fd, "r");
  if(dolly_df == NULL) {
    perror("fdopen in getparams");
    exit(1);
  }
  rewind(dolly_df);
  if(mydollytab->flag_v) {
    fprintf(stderr, "done.\n");
  }
  if(mydollytab->flag_v) {
    fprintf(stderr, "Parsing parameters...");
    fflush(stderr);
  }
  parse_dollytab(dolly_df,mydollytab); 
  fclose(dolly_df);
  close(fd);
  unlink(tmpfile);
}

0707010000000E000081A4000000000000000000000001623B5E140000099E000000000000000000000000000000000000001800000000dolly-0.64.2/dollytab.h#ifndef DOLLYTAB_H
#define DOLLYTAB_H
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <ifaddrs.h>

#include "resolve.h"

#define MAXFANOUT 8
#define MAXHOSTS 65536

/* Size of blocks transf. to/from net/disk and one less than that */


struct dollytab {
  unsigned int flag_v;                 /* verbose */
  unsigned int flag_d;                 /* systemd */
  char myhostname[256];
  char servername[256];
  char infile[256];
  char outfile[256];
  char add_name[MAXFANOUT][32];
  unsigned int meserver; /* This machine sends the data. */
  int nexthosts[MAXFANOUT];
  int compressed_in;           /* compressed transfer or not? */
  int compressed_out;          /* write results compressed? */
  /* Sizes for splitted input/output files. 0 means "don't split" (default) */
  unsigned long long output_split;
  unsigned long long input_split;
  unsigned int fanout;   /* default is linear list */
  unsigned int add_nr; /* Number of extra links for data transfers */
  int add_primary; /* Addition Post- or Midfix for primary interf. */
/* Postfix or midfix? */
/* 0 = undefined, 1 = postfix, 2 = midfix */
/* Some explanations about the meanings of postfix and midfix:
   postfix ex.: hostname = "cops1", postfix = "-giga" -> "cops1-giga"
   midfix ex.: hostname = "xibalba101", midfix = "-fast" -> "xibalba-fast101"
*/
  unsigned short add_mode;
  unsigned int nr_childs;
  unsigned int hostnr;
  unsigned int melast;   /* This machine doesn't have children to send data */
  /* Postfix of extra network interface names */
  int hyphennormal;      /* '-' normal or interf. sep. in hostnames */
/* when 4 resolve hostanme to ipv4 addresses, when 6 try ipv6 addresse, do not resolve if anything else */
  unsigned int resolve;
  size_t dollybufsize;
  unsigned int segsize; /* TCP Segment Size (useful for benchmarking only) */
  ssize_t t_b_size; /* Size of blocks transf. to/from net/disk and one less than that */
  char **hostring;
  char *dollybuf;
};

void init_dollytab(struct dollytab *);
/* Parses the config-file. The path to the file is given in dollytab */
void parse_dollytab(FILE *df,struct dollytab*);

/*
 * Clients read the parameters from the control-socket.
 * As they are already parsed from the config-file by the server,
 * we don't do much error-checking here.
 */
void getparams(int f,struct dollytab*);
#endif
0707010000000F000081A4000000000000000000000001623B5E14000011A7000000000000000000000000000000000000001500000000dolly-0.64.2/files.c#include "files.h"
#include "dolly.h"
/*
 * If "try_hard" is 1, call must be succesful.
 * If try_hard is 1 and an input file can't be opened, the program terminates.
 * If try_hard is not 1 and an input file can't be opened, -1 is returend.
 */
int open_infile(int try_hard,struct dollytab * mydollytab) {
  char name[256+16];

  /* Close old input file if there is one */
  if(input != -1) {
    if(close(input) == -1) {
      perror("close() in open_infile()");
      exit(1);
    }
  }
  if(mydollytab->input_split != 0) {
    sprintf(name, "%s_%u", mydollytab->infile, input_nr);
  } else {
    strcpy(name, mydollytab->infile);
  }
  
  /* Files for input/output */
  if(!mydollytab->compressed_out) {
    /* Input is from file */
    input = open(name, O_RDONLY);
    if(input == -1) {
      if(try_hard == 1) {
        char str[strlen(name)+18];
        sprintf(str, "open inputfile '%s'", name);
        perror(str);
        exit(1);
      } else {
        return -1;
      }
    }
  } else {
    /* Input should be compressed first. */
    if(access(name, R_OK) == -1) {
      if(try_hard == 1) {
        char str[strlen(name)+18];
        sprintf(str, "open inputfile '%s'", name);
        perror(str);
        exit(1);
      } else {
        return -1;
      }
    }
    if(pipe(id) == -1) {
      perror("input pipe()");
      exit(1);
    }
    input = id[0];
    if((in_child_pid = fork()) == 0) {
      int fd;
      /* Here's the child. */
      close(id[0]);
      close(1);
      (void) !dup(id[1]);
      close(id[1]);
      if((fd = open(name, O_RDONLY)) == -1) {
        exit(1);
      }
      close(0);
      (void) !dup(fd);
      close(fd);
      if(execl("/usr/bin/gzip", "gzip", "-cf", NULL) == -1) {
        perror("execl for gzip in child");
        exit(1);
      }
    } else {
      /* Father */
      close(id[1]);
    }
  } /* endif compressed_out */
  input_nr++;
  return 0;
}

int open_outfile(int try_hard,struct dollytab * mydollytab) {
  char name[256+16];
  int is_device = 0;
  int is_pipe = 0;
  /* Close old output file, if there is one. */
  if(output != -1) {
    if(close(output) == -1) {
      perror("close() in open_outfile()");
      exit(1);
    }
  }
  if(mydollytab->output_split != 0) {
    sprintf(name, "%s_%u", mydollytab->outfile, output_nr);
  } else {
    strcpy(name, mydollytab->outfile);
  }
  /* check if file is under /dev, if not open even if the file does not exist. */
  if(strcmp("/dev/",name) > 0 ) {
    is_device = 1;
  }
  if(strcmp("-",name) == 0) {
    is_pipe = 1;
  }
  /* Setup the output files/pipes. */
  if(!mydollytab->compressed_in) {
    /* Output is to a file */
    if(!mydollytab->compressed_out && (mydollytab->output_split == 0) && is_device && !is_pipe) {
      /* E.g. partition-to-partition cloning */
      output = open(name, O_WRONLY);
    } else if(!mydollytab->compressed_out && !is_device && !is_pipe) {
      /* E.g. file to file cloning */
      output = open(name, O_WRONLY | O_CREAT, 0644);
    } else if(is_pipe) {
      output = 1;
    } else {
      /* E.g. partition-to-compressed-archive cloning */
      output = open(name, O_WRONLY | O_CREAT | O_EXCL, 0644);
    }
    if(output == -1) {
      char str[strlen(name)+19];
      sprintf(str, "open outputfile '%s'", name);
      perror(str);
      exit(1);
    }
  } else { /* Compressed_In */
    if(access(name, W_OK) == -1) {
      if(try_hard == 1) {
        char str[strlen(name)+19];
        sprintf(str, "open outputfile '%s'", name);
        perror(str);
        exit(1);
      } else {
        return -1;
      }
    }
    /* Pipe to gunzip */
    if(pipe(pd) == -1) {
      perror("output pipe");
      exit(1);
    }
    output = pd[1];
    if((out_child_pid = fork()) == 0) {
      int fd;
      /* Here's the child! */
      close(pd[1]);
      close(0);      /* Close stdin */
      (void) !dup(pd[0]);    /* Duplicate pipe on stdin */
      close(pd[0]);  /* Close the unused end of the pipe */
      if((fd = open(name, O_WRONLY)) == -1) {
        if(errno == ENOENT) {
          fprintf(stderr, "Outputfile in child does not exist.\n");
        }
        perror("open outfile in child");
        exit(1);
      }
      close(1);
      (void) !dup(fd);
      close(fd);
      /* Now stdout is redirected to our file */
      if(execl("/usr/bin/gunzip", "gunzip", "-c", NULL) == -1) {
        perror("execl for gunzip in child");
        exit(1);
      }
    } else {
      /* Father */
      close(pd[0]);
    }
  }
  output_nr++;
  return 0;
}
07070100000010000081A4000000000000000000000001623B5E14000000B7000000000000000000000000000000000000001500000000dolly-0.64.2/files.h#ifndef FILES_H
#define FILES_H
#include "dollytab.h"
int open_infile(int try_hard,struct dollytab * mydollytab);
int open_outfile(int try_hard,struct dollytab * mydollytab);

#endif
07070100000011000081A4000000000000000000000001623B5E1400000638000000000000000000000000000000000000001900000000dolly-0.64.2/movebytes.c#include "movebytes.h"
#include "dolly.h"

int movebytes(int fd, int dir, char *addr, unsigned int n,struct dollytab * mydollytab) {
  int ret, bytes;
  static int child_done = 0;
  
  bytes = 0;

  if(child_done && (dir == READ)) {
    child_done = 0;
    return 0;
  }
  while(0 != n) {
    if(dir == WRITE) {
      ret = write(fd, addr, n);
    } else if(dir == READ) {
      fflush(stderr);
      ret = read(fd, addr, n);
      if(((unsigned int)ret < n) && mydollytab->compressed_out && mydollytab->meserver) {
        int wret, status;
        sleep(1);
        wret = waitpid(in_child_pid, &status, WNOHANG);
        if(wret == -1) {
          perror("waitpid");
        } else if(wret == 0) {
          fprintf(stderr, "waitpid returned 0\n");
        } else {
          if(WIFEXITED(status)) {
            if(WEXITSTATUS(status) == 0) {
              child_done++;
              return ret;
            } else {
              fprintf(stderr, "Child terminated with return value %d\n",
                WEXITSTATUS(status));
            }
          }
        }
        (void) fprintf(stderr,"read returned %d\n", ret);
      }
    } else {
      fprintf(stderr, "Bad direction in movebytes!\n");
      ret = 0;
    }
    if(ret == -1) {
#ifdef DOLLY_NONBLOCK
      if(errno == EAGAIN) {
        continue;
      }
#endif /* DOLLY_NONBLOCK */
      perror("movebytes read/write");
      fprintf(stderr, "\terrno = %d\n", errno);
      exit(1);
    } else if(ret == 0) {
      return bytes;
    } else {
      addr += ret;
      n -= ret;
      bytes += ret;
    }
  }
  return bytes;
}

07070100000012000081A4000000000000000000000001623B5E140000009F000000000000000000000000000000000000001900000000dolly-0.64.2/movebytes.h#ifndef MOVEBYTES_H
#define MOVEBYTES_H
#include "dollytab.h"
int movebytes(int fd, int dir, char *addr, unsigned int n,struct dollytab * mydollytab);

#endif
07070100000013000081A4000000000000000000000001623B5E1400000ABD000000000000000000000000000000000000001700000000dolly-0.64.2/resolve.c#include "resolve.h"
#include<ifaddrs.h>
/* resolves the given hostname to ip address 
 * following conditions are met
 * dollytab.resolve = 1 -> use the first resolved ip address
 * dollytab.resolve = 4 -> force ipv4
 * dollytab.resolve = 6 -> force ipv6
 */
int resolve_host(char *hostname , char *ip, int mode) {
	struct addrinfo hints, *servinfo, *p;
	struct sockaddr_in *h;
	int rv;

	memset(&hints, 0, sizeof hints);
  if(mode == 4) {
    hints.ai_family = AF_INET;
  } else if (mode == 6) {
    hints.ai_family = AF_INET6;
  } else {
    hints.ai_family = AF_UNSPEC;
  }
	hints.ai_socktype = SOCK_STREAM;

	if ( (rv = getaddrinfo( hostname , NULL , &hints , &servinfo)) != 0) 
	{
		fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
		return 1;
	}

	// loop through all the results and connect to the first we can
	for(p = servinfo; p != NULL; p = p->ai_next) 
	{
		h = (struct sockaddr_in *) p->ai_addr;
		strcpy(ip , inet_ntoa( h->sin_addr ));
	}
	freeaddrinfo(servinfo); // all done with this structure
	return 0;
}

int resolve_host_replace(char *hostname , int mode) {
  char tmp_str[256];
  int retval = 0;
  retval = resolve_host(hostname,tmp_str,mode);
  if(retval == 0) {
    strncpy(hostname,tmp_str,256);
  }
  return retval;
}

int get_default_ip(char *hostname , int mode)  {
/*
 * Find local ip used as source ip in ip packets.
 * Read the /proc/net/route file
 */
  FILE *fhandle;
  char line[100] , *interface , *c;
  interface = NULL;
  fhandle = fopen("/proc/net/route" , "r");
  while(fgets(line , 100 , fhandle)) {
    interface = strtok(line , " \t");
    c = strtok(NULL , " \t");
    if(interface!=NULL && c!=NULL) {
      if(strcmp(c , "00000000") == 0) {
        break;
      }
    }
  }
  fclose(fhandle);
/* which family do we require , AF_INET or AF_INET6 */
  int fm = AF_UNSPEC;
  if(mode == 4) {
    fm = AF_INET;
  } else if (mode == 6) {
    fm = AF_INET6;
  }
  struct ifaddrs *ifaddr, *ifa;
	int family , s;
	char host[NI_MAXHOST];
	if (getifaddrs(&ifaddr) == -1) {
		perror("getifaddrs");
		exit(EXIT_FAILURE);
	}
/* Walk through linked list, maintaining head pointer so we can free list later */
	for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
		if (ifa->ifa_addr == NULL) {
			continue;
		}
		family = ifa->ifa_addr->sa_family;
		if(strcmp( ifa->ifa_name , interface) == 0) {
			if (family == fm) {
				s = getnameinfo( ifa->ifa_addr, (family == AF_INET) ? 
            sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6) , 
            host , NI_MAXHOST , NULL , 0 , NI_NUMERICHOST);
				if (s != 0) {
					printf("getnameinfo() failed: %s\n", gai_strerror(s));
					exit(EXIT_FAILURE);
				}
				strncpy(hostname,host,strlen(host));
			}
		}
	}
	freeifaddrs(ifaddr);
	return 0;
}

  
07070100000014000081A4000000000000000000000001623B5E14000002DE000000000000000000000000000000000000001700000000dolly-0.64.2/resolve.h#ifndef RESOLVE_H
#define RESOLVE_H
#include<stdio.h> //printf
#include<string.h> //memset
#include<stdlib.h> //for exit(0);
#include<sys/socket.h>
#include<errno.h> //For errno - the error number
#include<netdb.h>	//hostent
#include<arpa/inet.h>
/* resolves the given hostname to ip address 
 * following conditions are met
 * dollytab.resolve = 1 -> use the first resolved ip address
 * dollytab.resolve = 4 -> force ipv4
 * dollytab.resolve = 6 -> force ipv6
 */
int resolve_host(char *hostname , char *ip, int mode);
/* same but replaces the hostname */
int resolve_host_replace(char *hostname , int mode);
/* get the ip address for the interface used on the default route */
int get_default_ip(char *hostname , int mode);
#endif
07070100000015000081A4000000000000000000000001623B5E1400000436000000000000000000000000000000000000002400000000dolly-0.64.2/send_multiple_files.pl#!/usr/bin/perl
# quick way of sending multiple files to multiple nodes
#
use strict;

# basic dolly stuff
my $DOLLY = "/usr/sbin/dolly";
my $ARGS = "-dqs";

# list of nodes, adjust to your setup
my @NODES = qw(sle15sp42
       	sle15sp43
       	sle15sp44
	);

# files to transfert, adjust with your needs
# by default the output name will be the same as the input name 
my @INFILES = qw(/tmp/warewulf4-4.2.0-lp154.6.3.x86_64.rpm
		/tmp/warewulf4-overlay-4.2.0-lp154.6.3.x86_64.rpm
		);

# transfert all files from a directory
# !! the directory must be present on the client nodes
my @ALL_FILES_IN_DIR = glob("/tmp/*.*");

my @ALL = (@INFILES, @ALL_FILES_IN_DIR);

my $NODES;
foreach my $n (@NODES) { 
	$n and $NODES = "$n" . "," . $NODES; 
	}
# remove last comma
chop($NODES);

foreach my $INFILE (@ALL) {
	print("---------------------------------\n");
	print("Sending $INFILE to $NODES\n");
	# same input and output name
	my $OUTFILE= $INFILE;
	#print("$DOLLY $ARGS -H $NODES -I $INFILE -O $OUTFILE\n");
	system("$DOLLY $ARGS -H $NODES -I $INFILE -O $OUTFILE");
	sleep 1;
}
07070100000016000081A4000000000000000000000001623B5E140000378E000000000000000000000000000000000000001800000000dolly-0.64.2/transmit.c#include "transmit.h"
#include "dolly.h"
#include "movebytes.h"
#include "files.h"
/* The main transmitting function */
void transmit(struct dollytab * mydollytab) {
  char *buf_addr, *buf;
  unsigned long long t, transbytes = 0, lastout = 0;
  unsigned int bytes = mydollytab->t_b_size;
  int ret = 1, maxsetnr = 0;
  unsigned long td = 0, tdlast = 0;
  unsigned int i = 0,j = 0, a = 0;
  FILE *logfd = NULL;
  struct timeval tv1, tv2, tv3;
  fd_set real_set, cur_set;

  buf_addr = (char *)malloc(2 * (mydollytab->t_b_size-1));
  buf = (char *)((unsigned long)(buf_addr + mydollytab->t_b_size-1) & (~(mydollytab->t_b_size-1)));

  t = 0x7fffffff;
  t <<= 32;
  t |= 0xffffffff;
  maxbytes = 0;
#define ADJ_MAXSET(a) if((a)>maxsetnr){maxsetnr=(a);}
  if(!mydollytab->meserver) {
    FD_ZERO(&real_set);
    FD_SET(datain[0], &real_set);
    FD_SET(ctrlin, &real_set);
    ADJ_MAXSET(datain[0]);
    ADJ_MAXSET(ctrlin);
    if(!mydollytab->melast) {
      for(i = 0; i < mydollytab->nr_childs; i++) {
        FD_SET(ctrlout[i], &real_set);  /* Check ctrlout too for backflow */
        ADJ_MAXSET(ctrlout[i]);
      }
    }
    maxsetnr++;
  } else {
    FD_ZERO(&real_set);
    for(i = 0; i < mydollytab->nr_childs; i++) {
      FD_SET(ctrlout[i], &real_set);
      ADJ_MAXSET(ctrlout[i]);
    }
    maxsetnr++;
  }
#undef ADJ_MAXSET
  
  gettimeofday(&tv1, NULL);
  tv2 = tv1;
  
  while((mydollytab->meserver && (ret > 0)) || (!mydollytab->meserver && (t > 0))) {
    /* The server writes data as long has it can to the data stream.
       When there's nothing left, it writes the actual number of bytes
       to the control stream (as long long int).
    */
    if(mydollytab->meserver) {
      /*
       * Server part
       */
      ret = movebytes(input, READ, buf, bytes,mydollytab);
      maxbytes += ret;
      if(ret > 0) {
        if(mydollytab->add_nr == 0) {
          for(i = 0; i < mydollytab->nr_childs; i++) {
            movebytes(dataout[i], WRITE, buf, ret,mydollytab);
          }
        } else {
          static unsigned int cur_out = 0;
          movebytes(dataout[cur_out], WRITE, buf, ret,mydollytab);
          cur_out++;
          if(cur_out > mydollytab->add_nr) {
            cur_out = 0;
          }
        }
      } else {
        /* Here: ret <= 0 */
        int res = -1;
        if(mydollytab->input_split) {
          res = open_infile(0,mydollytab);
        }
        if(!mydollytab->input_split || (res < 0)) {
          if(mydollytab->flag_v) {
            fprintf(stderr, "\nRead %llu bytes from file(s).\n", maxbytes);
          }
          if(mydollytab->add_nr == 0) {
            for(i = 0; i < mydollytab->nr_childs; i++) {
              if(mydollytab->flag_v) {
                (void)fprintf(stderr, "Writing maxbytes = %llu to ctrlout\n",
                  maxbytes);
              }
              movebytes(ctrlout[i], WRITE, (char *)&maxbytes, 8,mydollytab);
              shutdown(dataout[i], 2);
            }
          } else {
            if(mydollytab->flag_v) {
              (void)fprintf(stderr, "Writing maxbytes = %llu to ctrlout\n",
                maxbytes);
            }
            movebytes(ctrlout[0], WRITE, (char *)&maxbytes, 8,mydollytab);
            for(i = 0; i <= mydollytab->add_nr; i++) {
              shutdown(dataout[i], 2);
            }
          }
      } else {
        /* Next input file opened */
        ret = 100000;
        continue;
      } /* end mydollytab->input_split */
    }
      //if(mydollytab->flag_v && (maxbytes - lastout >= 10000000)) {
      if(maxbytes - lastout >= 10000000) {
        tv3=tv2;
        gettimeofday(&tv2, NULL);
        td = (tv2.tv_sec*1000000 + tv2.tv_usec)
          - (tv1.tv_sec*1000000 + tv1.tv_usec);
        tdlast = (tv2.tv_sec*1000000 + tv2.tv_usec)
          - (tv3.tv_sec*1000000 + tv3.tv_usec);
        fprintf(stdtty,
          "\rSent MB: %.0f, MB/s: %.3f, Current MB/s: %.3f      ",
          (float)maxbytes/1000000,
          (float)maxbytes/td,(float)(maxbytes - lastout)/tdlast);
        fflush(stdtty);
        lastout = maxbytes;
      }
    } else {
      /*
       * Client part
       */
      unsigned int i, nr_descr;
      cur_set = real_set;
      ret = select(maxsetnr, &cur_set, NULL, NULL, NULL);
      if(ret == -1) {
        if(errno != EINTR) {
        /* MATHOG: (on above "if" statement)
         * Some signal was received, don't have a handler, ignore it.
         */
        perror("select");
        exit(1);
        }
        ret = 0;
      }
      if(ret < 1) {
	if(verbignoresignals) {
	  /* fr: Shouldn't that be a bit further up? */
	  (void)fprintf(stderr,
			"\nIgnoring unhandled signal (select() returned %d.\n",
			ret);
	}
      } else {
	nr_descr = ret;
	for(i = 0; i < nr_descr; i++) {
	  if(FD_ISSET(ctrlin, &cur_set)) {
	    char mybuf[128];

	    ret = read(ctrlin, mybuf, 128);
	    if(ret == -1) {
	      perror("read from ctrlin in transfer");
	      exit(1);
	    }
	    if(ret == 0) {
	      fprintf(stderr,
		      "Got 0 from ctrlin, but there should be something there!\n"
		      "Probably transmission interrupted, terminating.\n");
	      exit(1);
	    }
	    if(ret != 8) {
	      fprintf(stderr, "Got %d bytes from ctrlin in transfer, "
		      "expected 8.\n", ret);
	    }
	    maxbytes = *(unsigned long long *)&mybuf;
	    if(!mydollytab->melast) {
	      for(j = 0; j < mydollytab->nr_childs; j++) {
          movebytes(ctrlout[i], WRITE, (char *)&maxbytes, 8,mydollytab);
	      }
	    }
	    t = maxbytes - transbytes;
	    if(mydollytab->flag_v) {
	      fprintf(stderr,"\nMax. bytes will be %llu bytes. %llu bytes left.\n", maxbytes, t);
	    }
	    FD_CLR(ctrlin, &real_set);
	    FD_CLR(ctrlin, &cur_set);
	  } else if(FD_ISSET(datain[0], &cur_set)) {
	    /* There is data to be read from the net */
	    bytes = ((ssize_t) t >= mydollytab->t_b_size ? mydollytab->t_b_size : (ssize_t) t);
	    ret = movebytes(datain[0], READ, buf, bytes,mydollytab);
	      if(!mydollytab->output_split) {
          movebytes(output, WRITE, buf, ret,mydollytab);
	      } else {
          /* Check if output file needs to be split. */
          if((transbytes / mydollytab->output_split)
             != ((transbytes + ret) / mydollytab->output_split)) {
            size_t old_part, new_part;
            old_part = ret - (transbytes + ret) % mydollytab->output_split;
            new_part = ret - old_part;
            movebytes(output, WRITE, buf, old_part,mydollytab);
            open_outfile(1,mydollytab);
            movebytes(output, WRITE, buf + old_part, new_part,mydollytab);
          } else {
            movebytes(output, WRITE, buf, ret,mydollytab);
          }
	      } /* end input_split */
	    if(!mydollytab->melast) {
	      for(i = 0; i < mydollytab->nr_childs; i++) {
          movebytes(dataout[i], WRITE, buf, ret,mydollytab);
	      }
	    }
	    transbytes += ret;
	    t -= ret;
	    FD_CLR(datain[0], &cur_set);
	    /* Handle additional network interfaces, if available */
	    for(a = 1; a <= mydollytab->add_nr; a++) {
	      bytes = ((ssize_t)t >= mydollytab->t_b_size ? mydollytab->t_b_size :(ssize_t) t);
	      ret = movebytes(datain[a], READ, buf, bytes,mydollytab);
        movebytes(output, WRITE, buf, ret,mydollytab);
	      if(!mydollytab->melast) {
          movebytes(dataout[a], WRITE, buf, bytes,mydollytab);
	      }
	      transbytes += ret;
	      t -= ret;
	    }
	  } else { /* FD_ISSET(ctrlin[]) */
	    int foundfd = 0;

	    for(j = 0; j < mydollytab->nr_childs; j++) {
	      if(FD_ISSET(ctrlout[j], &cur_set)) {
          /* Backflow of control-information, just pass it on */
          ret = read(ctrlout[j], buf, mydollytab->t_b_size);
          if(ret == -1) {
            perror("read backflow in transmit");
            exit(1);
          }
          movebytes(ctrlin, WRITE, buf, ret,mydollytab);
          foundfd++;
          FD_CLR(ctrlout[j], &cur_set);
	      }
	    }
	    /* if nothing found */
	    if(foundfd == 0) {
	      fprintf(stderr,
		      "select returned without any ready fd, ret = %d.\n",
		      ret);
	      for(i = 0;(int) i < maxsetnr; i++) {
		if(FD_ISSET(i, &cur_set)) {
		  unsigned int j;
		  fprintf(stderr, "  file descriptor %u is set.\n", i);
		  for(j = 0; j < mydollytab->nr_childs; j++) {
		    if(FD_ISSET(ctrlout[j], &cur_set)) {
		      fprintf(stderr, "  (fd %u = ctrlout[%u])\n", i, j);
		    }
		  }
		  for(j = 0; j <= mydollytab->add_nr; j++) {
		    if(FD_ISSET(datain[j], &cur_set)) {
		      fprintf(stderr, "  (fd %u = datain[%u])\n", i, j);
		    }
		  }
		}
	      }
	      exit(1);
	    }
	  }
	}
      }
      if(mydollytab->flag_v && (transbytes - lastout >= 10000000)) {
	tv3=tv2;
	gettimeofday(&tv2, NULL);
	td = (tv2.tv_sec*1000000 + tv2.tv_usec)
	  - (tv1.tv_sec*1000000 + tv1.tv_usec);
	tdlast = (tv2.tv_sec*1000000 + tv2.tv_usec)
	  - (tv3.tv_sec*1000000 + tv3.tv_usec);
	fprintf(stdtty, "\rTransfered MB: %.0f, MB/s: %.3f, Current MB/s: %.3f      ", (float)transbytes/1000000, (float)transbytes/td,(float)(transbytes - lastout)/tdlast);
	fflush(stdtty);
	lastout = transbytes;
      }
    }
    alarm(0);  /* We did something, so turn off the timeout-alarm */
  } /* end while */
  gettimeofday(&tv2, NULL);
  td = (tv2.tv_sec*1000000 + tv2.tv_usec) - (tv1.tv_sec*1000000 + tv1.tv_usec);
  
  if(mydollytab->meserver) {
    if(mydollytab->flag_v) {
      fprintf(stdtty, "\rSent MB: %.0f.       \n", (float)maxbytes/1000000);
    }
 
    if(flag_log){
      logfd = fopen(logfile, "a");
      if(logfd == NULL) {
        perror("open logfile");
        exit(1);
      }
      if(mydollytab->compressed_in) {
        fprintf(logfd, "compressed ");
      }
      fprintf(logfd, "infile = '%s'\n", mydollytab->infile);
      if(mydollytab->compressed_out) {
        fprintf(logfd, "compressed ");
      }
      fprintf(logfd, "outfile = '%s'\n", mydollytab->outfile);
      if(mydollytab->flag_v) {
        if(mydollytab->segsize > 0) {
          fprintf(logfd, "TCP segment size : %u Byte (%u Byte eth)\n", 
            mydollytab->segsize,mydollytab->segsize+54);
        } else {
          fprintf(logfd,
            "Standard TCP segment size : 1460 Bytes (1514 Byte eth)\n");
        }
      } else {
        if(mydollytab->segsize > 0) {
          fprintf(logfd, " %8u", mydollytab->segsize);
        } else {
          fprintf(logfd, " %8d", 1460);
        }
      }
      
      if(mydollytab->flag_v) {
        fprintf(logfd, "Server : '%s'\n", mydollytab->myhostname);
        fprintf(logfd, "Fanout = %u\n", mydollytab->fanout);
        fprintf(logfd, "Nr of childs = %u\n", mydollytab->nr_childs);
        fprintf(logfd, "Nr of hosts = %u\n", mydollytab->hostnr);
      } else {
        fprintf(logfd, " %8u", mydollytab->hostnr);
      }
    }
  } else {
    fprintf(stderr, "Transfered MB: %.0f, MB/s: %.3f \n\n",
	    (float)transbytes/1000000, (float)transbytes/td);
    fprintf(stdtty, "\n");
  }
  
  close(output);
  if(dosync){
    sync();
    if(mydollytab->flag_v) {
      fprintf(stderr, "Synced.\n");
    }
  }
  if(mydollytab->meserver) {
    for(i = 0; i < mydollytab->nr_childs; i++) {
      if(mydollytab->flag_v) {
        fprintf(stderr, "Waiting for child %u.\n",i);
      }
      ret = movebytes(ctrlout[i], READ, buf, 8,mydollytab);
      if(ret != 8) {
        fprintf(stderr,
          "Server got only %d bytes back from client %u instead of 8\n",
          ret, i);
      }
    }
    buf[8] = 0;
    if(*(unsigned long long *)buf != maxbytes) {
      fprintf(stderr, "*** ERROR *** Didn't get correct maxbytes back!\n");
	      /* create unneeded error, so removing as only used for debugging 
	      "Got %lld (0x%016llx) instead of %lld (0x%016llx)\n",
	      *(unsigned long long *)&buf,
	      *(unsigned long long *)&buf,
	      maxbytes, maxbytes);
	      */
    } else {
      fprintf(stderr, "Transfert to all client nodes done.\n");
    }
    if(mydollytab->flag_v) {
      fprintf(stderr, "Time: %lu.%03lu\n", td / 1000000, td % 1000000);
      fprintf(stderr, "MBytes/s: %0.3f\n", (double)maxbytes / td);
      fprintf(stderr, "Aggregate MBytes/s: %0.3f\n",
	    (double)maxbytes * mydollytab->hostnr / td);
    }
    if(maxcbytes != 0) {
      fprintf(stderr, "Bytes written on each node: %llu\n", maxcbytes);
      fprintf(stderr, "MBytes/s written: %0.3f\n",
	      (double)maxcbytes / td);
      fprintf(stderr, "Aggregate MBytes/s written: %0.3f\n",
	      (double)maxcbytes * mydollytab->hostnr / td);
    }
    if(flag_log) {
      if(mydollytab->flag_v) {
        fprintf(logfd, "Time: %lu.%03lu\n", td / 1000000, td % 1000000);
        fprintf(logfd, "MBytes/s: %0.3f\n", (double)maxbytes / td);
        fprintf(logfd, "Aggregate MBytes/s: %0.3f\n",
        (double)maxbytes * mydollytab->hostnr / td);
        if(maxcbytes != 0) {
          fprintf(logfd, "Bytes written on each node: %llu\n", maxcbytes);
          fprintf(logfd, "MBytes/s written: %0.3f\n",
            (double)maxcbytes / td);
          fprintf(logfd, "Aggregate MBytes/s written: %0.3f\n",
            (double)maxcbytes * mydollytab->hostnr / td);
        }
      } else {
        fprintf(logfd, "%4lu.%06lu  ", td / 1000000, td % 1000000);
        fprintf(logfd, "%4.6f  ", (double)maxbytes / td);
        fprintf(logfd, "%4.6f  ",
          (double)maxbytes * mydollytab->hostnr / td);
        if(maxcbytes != 0) {
          fprintf(logfd, "Bytes written on each node: %llu\n", maxcbytes);
          fprintf(logfd, "MBytes/s written: %0.3f\n",
            (double)maxcbytes / td);
          fprintf(logfd, "Aggregate MBytes/s written: %0.3f\n",
            (double)maxcbytes * mydollytab->hostnr / td);
        }
        fprintf(logfd, "\n");
      }
      fclose(logfd);
    }
  } else if(!mydollytab->melast) {
    /* All clients except the last just transfer 8 bytes in the backflow */
    unsigned long long ll;
    for(i = 0; i < mydollytab->nr_childs; i++) {
      movebytes(ctrlout[i], READ, (char *)&ll, 8,mydollytab);
    }
    movebytes(ctrlin, WRITE, (char *)&ll, 8,mydollytab);
  } else if(mydollytab->melast) {
    movebytes(ctrlin, WRITE, (char *)&maxbytes, 8,mydollytab);
  }
  if(mydollytab->flag_v) {
    fprintf(stderr, "Transmitted.\n");
  }
  free(buf_addr);
}
07070100000017000081A4000000000000000000000001623B5E1400000071000000000000000000000000000000000000001800000000dolly-0.64.2/transmit.h#ifndef TRANSMIT_H
#define TRANSMIT_H
#include "dollytab.h"
void transmit(struct dollytab * mydollytab);
#endif

07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!283 blocks
openSUSE Build Service is sponsored by