Compare commits

...

3151 Commits

Author SHA1 Message Date
Wayne Davison
c02f4b232a Preparing for release of 2.6.6 2005-07-28 19:31:55 +00:00
Wayne Davison
d8edb8c614 Mentioned the final changes. 2005-07-28 19:24:22 +00:00
Wayne Davison
29050a2565 Incorporate the improvements made to the daemon/remote-shell sections. 2005-07-28 19:19:47 +00:00
Wayne Davison
04a13dd408 A fix for the itemized output to prevent superfluous 'p' flags. 2005-07-28 19:06:03 +00:00
Wayne Davison
32199c6b00 Removed a duplicated item. 2005-07-28 18:17:56 +00:00
Wayne Davison
870dddc5eb Mention the recent changes. 2005-07-28 17:42:56 +00:00
Wayne Davison
9d0d18b590 If the user has specified "pre-xfer exec" or "post-xfer exec", run
the indicated command(s), each at the appropriate time.
2005-07-28 17:15:47 +00:00
Wayne Davison
bec617b934 Added 2 new config options: "pre-xfer exec" and "post-xfer exec". 2005-07-28 17:15:44 +00:00
Wayne Davison
c20936b88b Document the new pre-/post-xfer exec config options. 2005-07-28 17:15:42 +00:00
Wayne Davison
0869881764 Regenerated. 2005-07-28 16:58:04 +00:00
Wayne Davison
a840b5c736 Removed one more client-oriented command-line syntax sentence. 2005-07-28 09:40:08 +00:00
Wayne Davison
2907884f94 Removed erroneous section on using daemon features over a
remote-shell connection -- client-use is better described in the
rsync manpage, and the advanced restricted-ssh section needs a
better treatment (perhaps as a support script).
2005-07-28 09:36:12 +00:00
Wayne Davison
754a080ffc Improved the sections dicussing the various types of transfer
connections and how a normal transfer differs from a daemon
transfer.
2005-07-28 09:18:20 +00:00
Wayne Davison
94f20a9f45 Document new --append option. 2005-07-28 01:46:16 +00:00
Wayne Davison
6cc1198288 Support new --append option. 2005-07-28 01:46:12 +00:00
Wayne Davison
a015788d21 Added the --append option. 2005-07-28 01:46:09 +00:00
Wayne Davison
c8d3465726 - Call set_modtime() with its new mode arg.
- Don't mask the mode bits being sent to do_chmod().
- Don't skip calling set_modtime() or do_chmod() when the item
  is a symlink.
2005-07-27 23:30:58 +00:00
Wayne Davison
00b9618460 - Fixed the mode comparison in itemize() to mask off the bits
outside of the CHMOD_BITS mask.
- Don't call do_chmod() unless HAVE_CHMOD is defined.
- Don't mask the mode bits being sent to do_chmod().
2005-07-27 23:30:55 +00:00
Wayne Davison
d11f5c6e2b - Don't call do_chmod() unless HAVE_CHMOD is defined.
- Made do_chmod() handle symlinks or return 1 if not possible.
- We now mask off the mode bits in do_chmod() sing CHMOD_BITS.
2005-07-27 23:30:53 +00:00
Wayne Davison
25007999df - Changed set_modtime() to take the file's mode as an arg.
- Made set_modtime() handle symlinks or return 1 if not possible.
2005-07-27 23:30:51 +00:00
Wayne Davison
8ce6546310 Check for the lchmod() and lutimes() functions. 2005-07-27 23:18:28 +00:00
Wayne Davison
151f59f155 Tweaked a comment and some null-char assignments. 2005-07-22 19:09:45 +00:00
Wayne Davison
89f2a4c231 Changed implied_dirs to only be non-0 if relative_paths is non-0. 2005-07-22 19:05:25 +00:00
Wayne Davison
496be30db6 Got rid of some unused externs. 2005-07-22 17:59:21 +00:00
Wayne Davison
cd426074e1 Updated to zlib 1.2.3. 2005-07-22 15:54:43 +00:00
Wayne Davison
3f7bfac2a0 Avoid newest test when no destination was specified. 2005-07-15 19:10:03 +00:00
Wayne Davison
9425918d74 Output a syntax error if both the source and destination are remote. 2005-07-15 19:06:43 +00:00
Wayne Davison
cc637fcc51 Preparing for release of 2.6.6pre1 2005-07-07 22:53:59 +00:00
Wayne Davison
9db1743490 Mentioned the zlib changes and tweaked a couple sentences. 2005-07-07 22:50:12 +00:00
Wayne Davison
ba3542cfcb - Attempt to make the discussion of host-specifying args less confusing.
- Fixed the names of the uid and gid daemon options in a sentence.
2005-07-07 21:33:40 +00:00
Wayne Davison
81f5b275db Changes for new zlib. 2005-07-07 21:29:57 +00:00
Wayne Davison
f3ee726894 Fixed a typo. 2005-07-07 21:19:14 +00:00
Wayne Davison
b5be9e6c5f Fix latest zlib security exploit (CAN-2005-2096). 2005-07-07 21:14:29 +00:00
Wayne Davison
1e1cf68934 Upgraded to version 1.2.2. 2005-07-07 20:48:02 +00:00
Wayne Davison
4a2744cee3 One more "#undef BAD" for AIX. 2005-07-07 20:37:31 +00:00
Wayne Davison
12febd804f Use a define to handle conflicting function read_buf instead of
renaming it in the code.
2005-07-07 20:17:35 +00:00
Wayne Davison
687c6b14a0 Changed "Overflow" back to "overflow". 2005-07-07 20:16:41 +00:00
Wayne Davison
a1f99493b3 Changed overflow() to overflow_exit(). 2005-07-07 19:49:14 +00:00
Wayne Davison
9819f005b6 Changed zBAD back to BAD (with a simpler kluge for AIX). 2005-07-07 19:31:23 +00:00
Wayne Davison
2a6793bf1f Fixed some whitespace to match the original source. 2005-07-07 19:22:55 +00:00
Wayne Davison
bf287ee946 Got rid of bogus RCS keyword expansions (that create differences
between these files and the original zlib source).
2005-07-07 19:15:44 +00:00
Wayne Davison
b8b0668e85 Mention the EEXIST fix. 2005-06-30 17:18:30 +00:00
Wayne Davison
092906933b Ignore EEXIST on second mkdir() call. 2005-06-30 17:03:14 +00:00
Wayne Davison
e8432be95f Mention the latest time-comparing fixes. 2005-06-28 00:15:44 +00:00
Wayne Davison
6ff2f4ba67 Use cmp_modtime() in a couple more spots where a local modtime is
compared with a remote modtime.
2005-06-28 00:12:08 +00:00
Wayne Davison
309a5be873 Fixed test to work when objdir != srcdir (thanks to Art Haas). 2005-06-24 02:14:12 +00:00
Wayne Davison
26c87bb630 Changed the arg-splitting code so that it can handle a literal
backslash prior to whitespace without treating it as escaped
whitespace (e.g. if we receive "foo\\ bar", it is two args,
while "foo\ bar" and "foo\\\ bar" are each just one).
2005-06-23 15:58:57 +00:00
Wayne Davison
ea9b2add97 Tweaked a comment in the perl code we output. 2005-06-23 15:53:26 +00:00
Wayne Davison
301569f081 Improved a couple sentences. 2005-06-20 07:01:29 +00:00
Wayne Davison
b21456102a Changed the code to use the single long-option hash from cull_options. 2005-06-17 23:23:00 +00:00
Wayne Davison
b8a47c9bc6 - Fixed a bug where the --*-dest options weren't being culled.
- Simplified the output format by putting all the long-name
  options into a single hash.
2005-06-17 23:16:22 +00:00
Wayne Davison
85fbfa10a8 - Improved some comments (some taken from the new cull-options output).
- Made the user-config sections easier to find.
- Default to running a fully-specified rsync executable so that there
  are not PATH surprises.
- A few minor tweaks to the arg-checking code to make it clearer without
  actually changing its logic.
2005-06-17 16:48:02 +00:00
Wayne Davison
555bc0e31a Another readability improvement in the perl code we output. 2005-06-17 16:29:21 +00:00
Wayne Davison
ef1233cbb3 Improved some of the comments that are output into the perl code. 2005-06-17 16:12:05 +00:00
Wayne Davison
1524815ed3 - Make sure that the command contained the '.' arg at the end of the
options.
- Fixed the expanding of wildcards for a restriction of '/'.
2005-06-17 05:14:15 +00:00
Wayne Davison
985af7035e - Be restrictive on matching the --sender option so that the user
can't fool us into thinking we're the sender by using a filename
  of --sender (or similar ploy).
- Make sure that our '..' check can't be fooled by sly backslashing.
- Tweaked some comments.
2005-06-17 04:50:22 +00:00
Wayne Davison
b3181708f2 Output a leading comment and surrounding blank lines. 2005-06-17 04:46:02 +00:00
Wayne Davison
3f6c17cf14 Mention rrsync changes. 2005-06-17 01:26:33 +00:00
Wayne Davison
2e5a7629c0 If SUBDIR is specified as a non-absolute path, make it absolute. 2005-06-17 01:17:44 +00:00
Wayne Davison
70318468df - Made it easy to configure the path of the rsync executable.
- Fully parse all legal options that might come from a stock rsync and
  validate/restrict any option's args (previously we rejected options
  with args).
- Made it easy to disable specific options.
- Properly handle a multi-arg copy's multiple args.
- Make sure that the restricted dir actually exists and we can chdir
  to it.
- Just reject any dangerous args that have .. in them instead of trying
  to munge them.
- We don't treat single-or double-quotes specially, just backslash-
  escaped characters.
- Turn on strict mode.
- Use the array-arg version of exec() so that we don't spawn a shell.
- Use File::Glob to glob wildcards in args.
- Tweaked the log-file format so that it logs the modified command
  without any "OK" suffix.
2005-06-16 19:30:53 +00:00
Wayne Davison
782d109121 A developer-oriented script that outputs perl code for valid server
options.
2005-06-16 19:17:47 +00:00
Wayne Davison
30e7b0b28d Mention latest fix. 2005-06-12 06:10:14 +00:00
Wayne Davison
910ee8c92e In clean_flist(), fixed the setting of the flist->high value for an
empty list so that it can't cause a crash if it gets passed to
flist_find().
2005-06-12 06:07:23 +00:00
Wayne Davison
8af1bc9011 - Added a comment to the filter_outfile function.
- Twiddled where the calls to filter_outfile happen.
2005-06-10 23:36:57 +00:00
Wayne Davison
6a12f0d619 Simplified the regular expressions for sed due to problems on some
OSes.
2005-06-10 21:56:52 +00:00
Wayne Davison
4f3be36e30 - Put the output we're expecting into an rsync.chk file, for easier
debugging on failures.
- Added the function filter_outfile() and used it in place of the
  various output-filtering commands.
- Use the sed rules for filtering the combination of --itemized
  output with double-verbose output so that we're sure there's no
  superfluous lines being output (which the old grep filtering
  would have ignored).
2005-06-10 20:33:57 +00:00
Wayne Davison
fc9d64c947 Several expansions of $srcdir were not double-quoted. 2005-06-10 20:04:42 +00:00
Wayne Davison
db10766ab2 One expansion of $srcdir wasn't double-quoted. 2005-06-10 20:04:11 +00:00
Wayne Davison
a3dcb79085 One more instance of the umask kluge was needed. 2005-06-10 18:02:14 +00:00
Wayne Davison
20667b6d7f Mention backup change. 2005-06-10 17:58:39 +00:00
Wayne Davison
93e28fbd99 Fixed a problem in the backing up of symlinks and devices: we
need to remove any old symlink/device/file to create the backup.
Also fixed a couple minor logic errors in the handling of symlinks
and devices.  NOTE:  the code still doesn't handle the changing of
a name from a dir to a non-dir or visa versa (which is a very old
deficiency in the code).
2005-06-10 17:57:18 +00:00
Wayne Davison
87a57a3072 Use umask kluge from rsync.fns to try to get rid of a potential
permissions difference when copying symlinks.
2005-06-10 17:51:33 +00:00
Wayne Davison
bad1fa4476 Make the sed commands compatible with Solaris (hopefully). 2005-06-10 17:21:52 +00:00
Wayne Davison
8fe27e7631 Starting NEWS for 2.6.6. 2005-06-10 17:17:38 +00:00
Wayne Davison
a1c75ed05c Aged news from NEWS file. 2005-06-10 17:17:24 +00:00
Wayne Davison
e73ad2be54 Got rid of some potentially unhandled permissions differences. 2005-06-10 17:06:43 +00:00
Wayne Davison
59b0e7a82d Changed the "max verbosity" setting from global to per-module. 2005-06-10 16:57:43 +00:00
Wayne Davison
b4fc3987f2 Use the new NOBODY_USER and NOBODY_GROUP configure defines. 2005-06-10 16:50:09 +00:00
Wayne Davison
58418cb0c4 Added a simple check to see if the /etc/group file has the
group "nobody" or "nogroup".
2005-06-10 16:46:50 +00:00
Wayne Davison
5794112ad0 Test that our outputting of itemized messages (as well as
double-verbose output) is happening correctly.
2005-06-09 22:27:59 +00:00
Wayne Davison
f2b6fe44a6 - Fixed the overzealous outputting of unchanged hard-linked items
when verbose > 1.
- An unchanged hard-link with -i (log-format w/%i) now changes the
  trailing dots to spaces.
2005-06-09 22:27:22 +00:00
Wayne Davison
215b444cae Don't set ITEM_REPORT_TIME when a hard-linked file is already
linked up as it should be and --times was not enabled.
2005-06-09 21:57:45 +00:00
Wayne Davison
a45f581b2a - Never output the '"FOO" is a hard link' message when -i (%i)
output is enabled.
- Go back to outputting '"FOO" is a hard link' message when -i (%i)
  is not enabled and verbose > 1.
2005-06-09 21:56:11 +00:00
Wayne Davison
dfdd71ecff Updated version to 2.6.6cvs. 2005-06-09 21:18:26 +00:00
Wayne Davison
2dfe1c37ad Preparing for release of 2.6.5 2005-06-02 03:57:58 +00:00
Wayne Davison
b9949780f4 Improved a few of the items. 2005-06-02 03:54:00 +00:00
Wayne Davison
5fe857d4be One more configure item. 2005-06-01 16:21:41 +00:00
Wayne Davison
3d86c6b18f Mention HAVE_REMSH fix. 2005-05-31 06:09:42 +00:00
Wayne Davison
0f0b2e66b8 Simplified the last change a bit. 2005-05-27 18:15:18 +00:00
Wayne Davison
5d24ee71ad Test for various past problems with --relative. 2005-05-27 18:09:34 +00:00
Wayne Davison
3a05c5d3ce If we unduplicate '.', make sure we also copy FLAG_DEL_HERE (in
addition to FLAG_TOP_DIR), so that the unduplication of a real
dir and an implied dir (implied by --relative) works right.
2005-05-27 18:04:04 +00:00
Wayne Davison
89ec535af5 - Only define HAVE_REMSH if it is going to have a non-0 value.
- Got rid of ssh warning that was added for 2.6.0.
2005-05-27 16:41:19 +00:00
Wayne Davison
e96d7972c4 Improved the opening comment. 2005-05-26 18:00:09 +00:00
Wayne Davison
962a3f0b6e Mention the latest bug-fix. 2005-05-25 15:52:03 +00:00
Wayne Davison
cbb5fa4f07 Handle nested "." dirs (caused by --relative and a trailing slash or
a trailing "/.") in f_name_cmp() when dirname is not an identical
pointer.
2005-05-25 01:24:01 +00:00
Wayne Davison
b57907efb2 Mention the output change for a mount-dir when -x is used. 2005-05-22 20:53:18 +00:00
Wayne Davison
26beb7861f - Don't stop deleting in a dir if one item fails.
- Don't skip deleting in a dir if the initial rmdir fails
  (2.6.4 only continued if it was a non-empty error).
2005-05-22 20:52:32 +00:00
Wayne Davison
6e8b9f1341 Must check FLAG_MOUNT_POINT in delete_in_dir() to avoid starting a
descent into a mounted directory when -x is specified.
2005-05-22 17:19:16 +00:00
Wayne Davison
6efe94167f Improved the SYMBOLIC LINKS section, as suggested by John. 2005-05-20 17:57:31 +00:00
Wayne Davison
51cc96e469 Improved a --files-from example (as suggested by Paul). 2005-05-20 17:39:10 +00:00
Wayne Davison
bdedced84b Tweaked a sentence. 2005-05-19 22:16:50 +00:00
Wayne Davison
f497ad722d Preparing for release of 2.6.5pre2 2005-05-19 21:45:41 +00:00
Wayne Davison
339eb8943e Tweaked the opening comments. 2005-05-19 21:42:20 +00:00
Wayne Davison
c36864e40e Mentioned the improved keep-alive code. 2005-05-19 21:38:25 +00:00
Wayne Davison
af6155bb0e Clarifications related to --dirs. 2005-05-19 21:36:30 +00:00
Wayne Davison
605fed4b46 Periodically call maybe_send_keepalive() when timeouts are in effect
(this ensures that the receiver doesn't timeout when we're still
doing work reading data from the generator).
2005-05-19 08:52:24 +00:00
Wayne Davison
ac40b74788 The global allowed_lull is now already set, so just set lull_mod. 2005-05-19 08:52:22 +00:00
Wayne Davison
3e6ddb3738 - Call the new set_io_timeout() function to set the timeout value.
- If the user specified a shorter timeout than the config-file,
  don't override the shorter value.
2005-05-19 08:52:19 +00:00
Wayne Davison
9ac756c6ea - The variable allowed_lull is now our global.
- Tweaked the --timeout option handling to call set_io_timeout().
2005-05-19 08:52:17 +00:00
Wayne Davison
3b0a30eba8 - Added set_io_timeout(), which sets all the timeout-dependent
variables when the timeout value changes.
- Split last_io into last_io_in and last_io_out.
- Made select_timeout static.
2005-05-19 08:52:13 +00:00
Wayne Davison
bac7259081 The latest bug-fix. 2005-05-19 00:02:29 +00:00
Wayne Davison
4d474ad513 One place that was testing errno for ENOTEMPTY was failing to
also test for EEXIST (which is returned by some OSes).
2005-05-19 00:00:28 +00:00
Wayne Davison
e50e82ab40 Fixed a typo. 2005-05-18 23:59:12 +00:00
Wayne Davison
4922175589 Two more items. 2005-05-17 15:08:05 +00:00
Wayne Davison
a289f89fbe Treat a trailing ".." dir-name as if "../" had been specified so
that we don't use the name in the destination path and save files
into a higher destination directory.
2005-05-14 18:44:57 +00:00
Wayne Davison
ba64001df8 Mention the latest bug fix. 2005-05-13 23:03:00 +00:00
Wayne Davison
b225b089b8 Have do_delete_pass() immediately return if list_only is set. 2005-05-13 23:00:20 +00:00
Wayne Davison
557a35f55b If adding a trailing dot to a directory name overflows
MAXPATHLEN, die with an overflow error.
2005-05-13 22:02:24 +00:00
Wayne Davison
1848fd6fa1 An example filter script to maintain .cvsinclude files. 2005-05-13 18:37:11 +00:00
Wayne Davison
f2a4853c93 Improved the use of the "remaining" var in readfd_unbuffered() to
make certain that the static value is always set correctly anytime
we call out to another function.
2005-05-12 17:36:29 +00:00
Wayne Davison
e65154085c Got rid of some code from writefd_unbuffered() that was only needed
back when the generator had a writeable pipe to the receiver.
2005-05-12 07:45:21 +00:00
Wayne Davison
e4676bb59b Make the --stats output come out after any delete-after messages. 2005-05-12 07:43:14 +00:00
Wayne Davison
3b968014c9 Improved a few sentences. 2005-05-12 07:34:45 +00:00
Wayne Davison
21b9b93377 Fixed a typo. 2005-05-10 18:31:46 +00:00
Wayne Davison
c4d1b2983d Preparing for release of 2.6.5pre1 2005-05-10 17:28:34 +00:00
Wayne Davison
7d7a34aeb2 Added more missing NEWS items. 2005-05-10 17:27:39 +00:00
Wayne Davison
65c84700fc Mention two more changes. 2005-05-10 16:55:22 +00:00
Wayne Davison
5a727522f0 Refer to the rsync daemon as a "daemon", not a "server". This is
to avoid confusion with the server that rsync runs in a normal
remote-shell transfer.
2005-05-10 16:14:26 +00:00
Wayne Davison
1599754727 - Improved the GENERAL section.
- Improved the description of --list-only.
- Added a VERSION section, like the rsyncd.conf manpage.
2005-05-10 16:04:02 +00:00
Wayne Davison
d90338cec6 Refer to the rsync daemon as a "daemon", not a "server". This is
to avoid confusion with the server that rsync runs in a normal
remote-shell transfer.
2005-05-10 16:00:24 +00:00
Wayne Davison
d0e94abb40 Fixed one synopsis line to make the DEST arg optional. 2005-05-09 15:39:24 +00:00
Wayne Davison
d8c4d6de10 Use new MAX_SERVER_ARGS define instead of hard-wired "100". 2005-05-03 17:04:26 +00:00
Wayne Davison
74ba98a51b There was no reason to have MAX_BASIS_DIRS factored into the
length of the argstr[] array.
2005-05-03 17:01:59 +00:00
Wayne Davison
c296031d9f Added MAX_SERVER_ARGS. 2005-05-03 17:00:47 +00:00
Wayne Davison
81c453b16a A few minor doc tweaks. 2005-05-03 16:47:03 +00:00
Wayne Davison
4a34c6f176 - Moved the --version option in the help text.
- Tweaked the --log-format option's description.
- Added a comment.
2005-05-03 16:46:49 +00:00
Wayne Davison
9b3150bd2e Mention the change in error message and exit status when we pull an
empty file list.
2005-05-03 16:45:40 +00:00
Wayne Davison
6f2245c8fa Tweaked the checking of the "limit" in safe_fname(). 2005-05-03 16:44:47 +00:00
Wayne Davison
0f9941dc5a Fixed a typo. 2005-05-03 16:03:31 +00:00
Wayne Davison
060f31500b - Improved the comments on the backslash-escaped output, and moved it
to the top in an "OUTPUT CHANGES" section.
- Added a mention of the generator's new output-flushing optimization.
2005-05-03 15:59:24 +00:00
Wayne Davison
7c2a83c635 Improved a sentence. 2005-05-03 15:58:06 +00:00
Wayne Davison
97e3c50cd9 Mention the '?'-in-filenames change. 2005-05-02 18:04:32 +00:00
Wayne Davison
b2360dabf6 Fixed some misspellings. 2005-05-02 17:27:20 +00:00
Wayne Davison
723160280f Tweaked the description of --from0. 2005-05-02 17:23:08 +00:00
Wayne Davison
fa92818af3 Tweaked the doc for --from0. 2005-05-02 17:22:42 +00:00
Wayne Davison
289a32167c Moved the max-size checking code down so that it only checks
regular files.
2005-04-28 16:26:23 +00:00
Wayne Davison
95e107db96 Moved the size-parsing code for --max-size into its own function. 2005-04-28 16:11:32 +00:00
Wayne Davison
513fd04d21 Set ignore_timeout before starting the transfer, regardless of
what protocol level is in effect.  This guards against the
generator timing out when the output pipe is full and the input
pipe (to the receiver) is slow.
2005-04-27 22:58:06 +00:00
Wayne Davison
7a16e12207 If the user specified --relative and a source dir with a trailing
slash, make sure we strip of the trailing "/." from the dir's len
(in del_hier_name_len) so that its subdirs get marked with
FLAG_DEL_HERE.
2005-04-27 22:56:47 +00:00
Wayne Davison
de8252f67f Added a new test to check how we interact with --link-dest and
--copy-dest.
2005-04-26 16:25:01 +00:00
Wayne Davison
98e4741463 A slightly better fix than the last one (though it won't make any
difference in how the code behaves due to how it is called).
2005-04-26 16:09:03 +00:00
Wayne Davison
028245a57b Mention newest fix. 2005-04-26 15:25:43 +00:00
Wayne Davison
2765f2e4a7 Fixed problem with -C when we're the sender, the remote is using an
older protocol, and we're not sending the exclude list (i.e. the
user didn't specify --delete or they specified --delete-ignored).
2005-04-26 15:24:40 +00:00
Wayne Davison
79db59d1a7 Try to make rsync's behavior w/o "--perms" a little clearer. 2005-04-25 19:30:29 +00:00
Wayne Davison
c48cff9fbe Fixed two typos. 2005-04-25 19:23:43 +00:00
Wayne Davison
f4b8e829e9 Mention fix for --one-file-system. 2005-04-24 22:35:03 +00:00
Wayne Davison
468d766819 Simplified the last change a little using a fix derived from
Mike Castle's suggestion.
2005-04-24 22:34:20 +00:00
Wayne Davison
f3ab64d3a8 When deleting files, we need to take any local FLAG_MOUNT_POINT
flag-bit and put it into the regular flist's flags for that dir,
and delete_in_dir() now refuses to delete a directory that has
that bit set.
2005-04-24 22:11:26 +00:00
Wayne Davison
a234bca4ef Reject any --remove-* options when read-only, just in case there
are new ones added in the future.
2005-04-24 16:19:16 +00:00
Wayne Davison
42e9c7eb56 Mention the latest fixes. 2005-04-24 00:34:39 +00:00
Wayne Davison
9d19f8a5fe When rsync encountered an empty file list, it behaved differently
when pulling files than when pushing files:  pulling it output a
(mostly) unhelpful error message and then exited with a 0 status,
even when the remote side exited with an error code.  I changed this
to output the normal end summary (when verbose) and to exit with the
status intact (just like when pushing files).
2005-04-23 22:30:08 +00:00
Wayne Davison
24e61cffe3 For those rare individuals without web access, mention how to
send bug reports via email.
2005-04-23 22:17:10 +00:00
Wayne Davison
3556fe5d86 Fixed a problem where a --link-dest hard-link could cause us to
miss out on the hard_link_cluster() call.
2005-04-23 19:46:22 +00:00
Wayne Davison
ee887d98f6 Two more tests:
- Update the hard-linked cluster and copy over the old versions.
- Add a new hard-linked item down in a new subdir to make sure that
  the new file doesn't get handled before the subdir gets created.
2005-04-23 18:20:47 +00:00
Wayne Davison
5c7b1feb4c Added --no-whole-file option to one of the runs. 2005-04-23 18:17:25 +00:00
Wayne Davison
3cd5301f40 - Added a new function, maybe_hard_link(), which now holds the code
(moved from hard_link_cluster()) that checks the inode/dev of an
  existing file and either does nothing (when properly linked), or
  removes the existing file before calling hard_link_one().
- Changed hard_link_check() so that it checks if the master item is
  marked with FINISHED_LINK (in its hlindex int), and if so, it
  finishes the current file by calling maybe_hard_link() (and
  marking it as finished too).  Otherwise it marks the item as
  skipped by setting hlindex to SKIPPED_LINK.
- Fixed the outputting of an error in hard_link_one() so that the
  message is always output when the caller did not request "terse"
  processing.
- Changed hard_link_cluster() so that it marks the master item with
  FINISHED_LINK and then links only the skipped items (marking them
  with FINISHED_LINK too).
2005-04-23 17:48:34 +00:00
Wayne Davison
d8169e6f6b - Call hard_link_check() with its new args.
- Got rid of a duplicate error after the hard_link_one() call.
2005-04-23 17:48:31 +00:00
Wayne Davison
c4833b024e Mention how a module reference doesn't need a trailing slash
to copy its contents.
2005-04-22 17:17:18 +00:00
Wayne Davison
2a5d5a8cc4 If we're outputting a message about the remote file in a
single-file transfer, we need to make sure that the file's
name is the generic-transfer name and not a local name.
2005-04-22 16:45:33 +00:00
Wayne Davison
f7112154e9 Moved "port" and "address" into the global section where they
belong.
2005-04-22 15:19:10 +00:00
Wayne Davison
f83051b2e3 Updated FSF's address and some minor non-license tweaks taken
from the latest GPL file on the web.
2005-04-17 08:25:50 +00:00
Wayne Davison
2e42adb302 Simplified the newly added test so that it should stop sporadically
failing.
2005-04-16 07:34:49 +00:00
Wayne Davison
c09ebb8c04 Call rsync via $RSYNC. 2005-04-15 17:39:35 +00:00
Wayne Davison
042dc7360e Make sure that the $chkdir has the same mtime/etc. as the
$fromdir.
2005-04-15 17:26:27 +00:00
Wayne Davison
7a6e294f7b Added a test that copies a single file with -H specified. 2005-04-15 08:28:02 +00:00
Wayne Davison
97e786c331 - Fixed a potential crash/infinite-loop bug if -H was used
when sending a single file.
- Made a couple variable improvements in link_idev_data().
- Got rid of the non-NULL check of hlink_list in init_hard_links()
  because is enough to just check file->link_u.links these days.
2005-04-15 08:26:58 +00:00
Wayne Davison
8ee6adefe3 Call logfile_close() and logfile_reopen() (tweaked function names). 2005-04-14 16:08:12 +00:00
Wayne Davison
64c37826e4 - Changed log_open() into two functions, logfile_open() and
logfile_reopen().
- Changed log_close() into logfile_close().
- Improved the logic in logit().
2005-04-14 16:08:10 +00:00
Wayne Davison
2e8015e0da Mention that less data is sent over the wire when --only-write-batch
is used and we're pushing files to a remote system.
2005-04-14 01:47:47 +00:00
Wayne Davison
5b6281afcf Got rid of ITEM_DUMMY_BIT. 2005-04-14 01:46:08 +00:00
Wayne Davison
e732fb0c4f - Got rid of the iflag kluge for 2.6.4pre3.
- When we're handling --only-write-batch on the client side, we now
  send all index/header info to the receiver (not just to the batch
  file, like we do with the xfer data) so that the connection cannot
  timeout.
2005-04-14 01:45:47 +00:00
Wayne Davison
b10917a426 Support the reception of a file-transfer header without xfer data
when we're on the server side and --only-write-batch was specified.
2005-04-14 01:42:13 +00:00
Wayne Davison
7ae64260e0 Mention how the daemon handles a failure to open a user-specified
"log file".
2005-04-12 23:09:35 +00:00
Wayne Davison
f97f6bcd3a Mention how we now handle a log-file that the daemon can't open. 2005-04-12 23:06:45 +00:00
Wayne Davison
e86d98cbaa Got rid of RERR_LOG_FAILURE. 2005-04-12 23:04:10 +00:00
Wayne Davison
6afb90778b If we can't open the daemon's log file, fall-back to using
syslog (rather than trying to output an error on stderr,
which would usually be lost, and then exiting).
2005-04-12 23:03:49 +00:00
Wayne Davison
32c7f91a14 A couple improvements for the --only-write-batch section. 2005-04-12 03:55:56 +00:00
Wayne Davison
b28a27e9e9 Mention the latest bug-fix. 2005-04-10 20:08:00 +00:00
Wayne Davison
15164c0aa9 Paul's patch to improve the "not creating new ..." message
for directories.
2005-04-10 19:44:16 +00:00
Wayne Davison
bf011fedfc Made the code a little cleaner by having gen_challenge() return
the challenge string base64-encoded (instead of forcing the caller
to handle this).  Also improved a couple comments.
2005-04-10 17:09:10 +00:00
Wayne Davison
d7d11b7ebd Mention fix for SUPPORT{,_HARD}_LINKS defines. 2005-04-10 07:17:47 +00:00
Wayne Davison
9a929c8f68 - Don't define HAVE_READLINK unless HAVE_READLINK is defined.
- Don't define SUPPORT_HARD_LINKS unless HAVE_LINK is defined.
2005-04-10 06:24:14 +00:00
Wayne Davison
298d8c0a9b Mention the new --only-write-batch=FILE option. 2005-04-09 18:59:59 +00:00
Wayne Davison
a054570942 - Use the new do_xfers variable in place of some dry_run checks
(with appropriate negation).
- If write_batch is < 0, we write out the file-transfer data to
  just the batch file, not the socket.
2005-04-09 18:59:57 +00:00
Wayne Davison
a0009fc30d - Use the new do_xfers variable in place of some dry_run checks
(with appropriate negation).
- If we get a transfer when write_batch is < 0, discard it.
2005-04-09 18:59:55 +00:00
Wayne Davison
beb51aa09e Use the new do_xfers variable in place of some dry_run checks
(with appropriate negation).
2005-04-09 18:59:52 +00:00
Wayne Davison
e8a96e275e - Only do read-/write-batch processing if we're not the server (needed
now that write_batch is no longer forced to 0 for the server).
- If write_batch is < 0, force "dry_run = 1" (but only after we've
  finished any appropriate write-batch file creation).
2005-04-09 18:59:49 +00:00
Wayne Davison
11e758a430 - Added do_xfers variable.
- Handle the new --only-write-batch=FILE option.
2005-04-09 18:59:47 +00:00
Wayne Davison
d630f53e0d Also change --only-write-batch to --read-batch (in addition to
changing --write-batch).
2005-04-09 18:59:44 +00:00
Wayne Davison
5918daf8a4 We no longer force write_batch to 0 for the server. 2005-04-09 18:59:42 +00:00
Wayne Davison
326bb56e40 Document the new --only-write-batch=FILE option. 2005-04-09 18:59:40 +00:00
Wayne Davison
f96154f44c Mention the latest changes. 2005-04-09 18:15:22 +00:00
Wayne Davison
45c5b903eb - Call auth_server() with its new "host" arg.
- Don't log an auth-failed error -- auth_server() now handles that.
2005-04-09 18:11:25 +00:00
Wayne Davison
5037cf3adf - Use the MD4_SUM_LENGTH define in place of some hard-wired values.
- Pass the hostname in to auth_server().
- Generate a unique error for each failure type in auth_server() so
  that the log-file contains why the authorization failed.
- Don't use sscanf() to parse the client's auth-challenge response.
2005-04-09 18:11:23 +00:00
Wayne Davison
180443af42 The "@ERROR" handler in start_inband_exchange() was not returning
the right value.
2005-04-09 16:49:51 +00:00
Wayne Davison
4f3f97fbde Fixed one typo and improved another sentence. 2005-04-08 01:40:57 +00:00
Wayne Davison
664cf3278a Make sure that "- !" or "+ !" aren't interpreted as a list-clearing
token.
2005-04-07 18:06:06 +00:00
Wayne Davison
cd36049cd1 Combine one of the backup tests with --delete-after. 2005-04-07 09:09:17 +00:00
Wayne Davison
c2523a0541 Don't call maybe_flush_socket() quite so often. 2005-04-07 08:32:32 +00:00
Wayne Davison
92739a0aa7 Mention the latest changes. 2005-04-07 08:28:06 +00:00
Wayne Davison
cd908ef4ff Fix a bug with --delete-after combined with --backup. 2005-04-07 08:13:44 +00:00
Wayne Davison
ebd33e0cea Use the new HAVE_LSEEK64 define. 2005-04-06 02:08:21 +00:00
Wayne Davison
5f2c5bf110 Added skipping of mkstemp() on HP-UX. 2005-04-06 02:07:21 +00:00
Wayne Davison
417099fa20 Periodically call maybe_flush_socket(). 2005-04-05 20:08:51 +00:00
Wayne Davison
626bec8e84 - Added maybe_flush_socket() for use by the generator.
- Always maintain the last_io value for the generator.
2005-04-05 20:07:42 +00:00
Wayne Davison
a06e2b7cab When doing a delete pass with do_progress output, get rid of the
temporary output (it used to always be covered up by output in
older versions, but it might be followed by a newline in newer
versions).
2005-04-05 19:51:13 +00:00
Wayne Davison
3ae5367ff2 Document the use of --address in client mode. 2005-04-05 06:00:17 +00:00
Wayne Davison
b4ef0bca47 Allows --address to be used in client mode. 2005-04-05 05:59:49 +00:00
Wayne Davison
4313d6f9c0 Changed the bind_address local variables to be named bind_addr
in order to avoid confusion with the bind_address global.
2005-04-05 05:52:49 +00:00
Wayne Davison
2a0dd9bd70 Make sure that the line buffer in readfd_unbuffered() is large
enough to handle long-filename messages on a system that has a
really short MAXPATHLEN value.  Also, make it large enough to
be able to comment on a MAXPATHLEN filename.
2005-04-04 17:27:56 +00:00
Wayne Davison
3eeac9bc7e In writefd_unbuffered(), make sure that we don't look at the r_fds
variable when we're ignoring msg_fd_in.
2005-04-04 00:48:39 +00:00
Wayne Davison
67de72bd9b Mention fix for --compare-dest. 2005-04-01 18:18:17 +00:00
Wayne Davison
552a218468 Make a local-copy caused by a not-quite-up-to-date --compare-dest
or --link-dest file be output as a 'c' (local change) when itemizing
or as transfered file when not itemizing.
2005-04-01 18:12:22 +00:00
Wayne Davison
d940151496 - Conditionally include <locale.h>.
- Conditionally call setlocale(LC_CTYPE, "").
2005-04-01 17:25:37 +00:00
Wayne Davison
f5c7f4abe7 - Changed version to 2.6.5cvs.
- Look for setlocale(), locale.h, and honor --disable-locale.
2005-04-01 17:25:34 +00:00
Wayne Davison
3ae6c1875d Starting the 2.6.5 news. 2005-04-01 17:25:28 +00:00
Wayne Davison
1ad6a7f611 Moved the 2.6.4 news here. 2005-04-01 17:25:26 +00:00
Wayne Davison
89d26123ff Changed safe_fname() to output \### (octal) to escape non-printable
characters (not ?) and \\ to escape \ itself.
2005-04-01 16:48:54 +00:00
Wayne Davison
46bffd98cb Fix the setting of module_dirlen for a module path of "/".
This fixes a crash in the exclude code when chroot is off.
2005-04-01 00:18:40 +00:00
Wayne Davison
41b84ce012 Don't try to tweak read-only dest-dir permissions in list-only mode. 2005-03-31 23:30:03 +00:00
Wayne Davison
de392f1e5c Preparing for release of 2.6.4 2005-03-31 03:14:34 +00:00
Wayne Davison
0455cd933d - Made the handling of adjacent percents (e.g. "%%b") work like it
did in older versions.
- Added a comment for log_format_has().
2005-03-31 03:01:26 +00:00
Wayne Davison
d9c0051fae In log_formatted(), add the newline to the format string so
that we can call rwrite() instead of rprintf().
2005-03-31 01:09:18 +00:00
Wayne Davison
126e7affb7 Enabled width-sizing for %L. 2005-03-31 00:50:58 +00:00
Wayne Davison
624d6be2a5 Use new log_format_has() function instead of strstr(). 2005-03-31 00:21:15 +00:00
Wayne Davison
16f960feb5 Added log_format_has(). 2005-03-31 00:19:13 +00:00
Wayne Davison
e145d51ba6 Make sure that we can't scan past the end of the format string. 2005-03-30 23:39:00 +00:00
Wayne Davison
dcbae65444 Optimized '%f' a little more. 2005-03-30 20:41:11 +00:00
Wayne Davison
b4bf2b5a7e Allow %i to have a field width. 2005-03-30 20:18:48 +00:00
Wayne Davison
9baed7609c - Allow the infix field width to start with a '-'.
- Apply the field width to all escapes, not just numeric ones.
2005-03-30 19:44:29 +00:00
Wayne Davison
1c2efa1706 Mention the numeric field width now possible in the % escapes. 2005-03-30 19:41:51 +00:00
Wayne Davison
80a24d52d4 Mention that the % escapes can now have a numeric infix. 2005-03-30 19:39:11 +00:00
Wayne Davison
af9f56a09d dropped the "const" from the return value of safe_fname() because
some callers would like to manipulate the string in the buffer.
2005-03-30 19:34:20 +00:00
Wayne Davison
ddd74b67be Allow the escapes in the log-format string to contain a numeric
field width (e.g. %8l %07p).
2005-03-30 18:27:09 +00:00
Wayne Davison
7b558d7f8b Fixed a comment. 2005-03-30 17:31:35 +00:00
Wayne Davison
c87ae64a82 Moved a call to output_summary() up a line. 2005-03-30 16:55:11 +00:00
Wayne Davison
b9f0ca7274 Tweaked a couple sentences. 2005-03-30 16:51:33 +00:00
Wayne Davison
c1759b9fa2 Changed %i to output '>' for a local copy. 2005-03-30 16:35:01 +00:00
Wayne Davison
9c63d83d3d Got rid of a useless extern. 2005-03-30 16:33:41 +00:00
Wayne Davison
1ed91a04fe - Fixed a potential crash if the receiver couldn't open the basis file
and the sender (possibly via a batch) tells us to use basis data.
- Enhanced the batched-update skipping message to indicate what phase
  is being skipped.
2005-03-29 22:05:33 +00:00
Wayne Davison
154cdaaa40 - Warn about missing batched updates the generator wants but the
batch doesn't have.
- Tweaked the "skipping ..." message that is output for already-
  applied batched updates.
2005-03-29 19:49:40 +00:00
Wayne Davison
33c4b445ef Split report() into handle_stats() and output_report() so that (1)
the report happens after all --delete-after activity has ceased when
pulling, and (2) a batch-file created when pushing gets the stats
values written out prior to any end-of-run keep-alive packets.
2005-03-29 11:11:35 +00:00
Wayne Davison
53135fe89a Changed maybe_emit_filelist_progress() and emit_filelist_progress()
to take an integer count instead of a struct file_list so that we
can pass in a file-list-count offset for delete's separate calls
to send_directory().
2005-03-29 10:57:31 +00:00
Wayne Davison
083acd496d Turn off do_progress during the file-update phase so that
--delete-during and --fuzzy don't get any superfluous
" N files..." lines output in the middle of the processing.
2005-03-29 10:41:26 +00:00
Wayne Davison
00348fd793 Preparing for release of 2.6.4pre4 2005-03-29 06:18:24 +00:00
Wayne Davison
ddb6fc696b Improved several items and preparing for final 2.6.4 release. 2005-03-29 06:15:47 +00:00
Wayne Davison
f7e48a5cb8 Add data for 2.6.4. 2005-03-29 06:15:08 +00:00
Wayne Davison
70352269ba If --delay-updates wasn't specified, write out two -1 indexes at
the same time to avoid a useless round-trip delay for an empty
delay-updates phase.
2005-03-29 01:04:20 +00:00
Wayne Davison
0b94147928 Added --protocol and made some batch-file improvements. 2005-03-28 20:54:06 +00:00
Wayne Davison
da9f59264f Added --protocol to --help output. 2005-03-28 20:40:25 +00:00
Wayne Davison
96b7b48efa Some temporary code for 2.6.4pre3 compatibility (which can be
safely removed for the next release).
2005-03-28 17:29:27 +00:00
Wayne Davison
aea4bf2894 Chaging ITEM_UNUSED back to ITEM_DUMMY_BIT for now -- we'll need
to get rid of it later on.
2005-03-28 17:08:47 +00:00
Wayne Davison
855ef72f3f Changed ITEM_DUMMY_BIT to ITEM_UNUSED. 2005-03-27 05:58:40 +00:00
Wayne Davison
98dc857b32 Got rid of temporary code that detected and rejected older 2.6.4
pre-release versions.
2005-03-27 05:58:38 +00:00
Wayne Davison
94af17a6eb Got rid of temporary code that set the ITEM_DUMMY_BIT. 2005-03-27 05:58:36 +00:00
Wayne Davison
00fd35482e --compress is now saved in a batch's option-state flags. 2005-03-27 05:49:24 +00:00
Wayne Davison
cc3e0770bc Decided that the '<' and '>' output in the %i format were
the opposite of what they should be.
2005-03-27 05:32:36 +00:00
Wayne Davison
e7f7064cc5 - Fixed a bug in the saving of the --dirs option's state.
- Added the saving of the --compress option's state.
- Deal with the xfer_dirs var in a better way for pre-29 batches.
2005-03-27 05:02:49 +00:00
Wayne Davison
7b759fe0df Mention that --dry-run no longer conflicts with the batch options. 2005-03-25 16:45:58 +00:00
Wayne Davison
254ee3baab - Don't complain if --dry-run is specified with --read-batch
or --write-batch.
- If --write-batch is combined with --dry-run, just disable
  --write-batch (that avoids trying to create a batch file
  and tells the user what would be transferred).
2005-03-24 16:41:16 +00:00
Wayne Davison
f957e8fdf9 If --dry-run is enabled with --read-batch, we must discard the
transfer data.
2005-03-24 16:38:34 +00:00
Wayne Davison
822012eea9 List /etc instead of /, but only if it exists and is readable. 2005-03-23 16:04:17 +00:00
Wayne Davison
bb21ecac5b Mention when we run fakeroot. 2005-03-18 02:10:34 +00:00
Wayne Davison
648859bda2 If we're not root and the "fakeroot" command is available, use it
to re-run the script while pretending to be root.
2005-03-18 02:07:25 +00:00
Wayne Davison
f328e0f3a8 Set a maximum distance-measure that find_fuzzy() will accept. 2005-03-17 08:59:48 +00:00
Wayne Davison
6012eaa183 Fixed a problem with the stripping of the .bak/.old/.orig suffixes
in find_filename_suffix().
2005-03-17 08:45:36 +00:00
Wayne Davison
da2a6c1f1c Fixed the -r kluge sent for pre-2.6.4 --list-only support. 2005-03-17 00:52:33 +00:00
Wayne Davison
0438f100ae We need to run our post-processing activities after the end of
the receiver's delay-update processing.
2005-03-17 00:41:18 +00:00
Wayne Davison
b95ad9ac55 Mention one other recent change. 2005-03-16 02:50:00 +00:00
Wayne Davison
828a256123 Preparing for release of 2.6.4pre3 2005-03-16 01:12:44 +00:00
Wayne Davison
ebf447ac81 Changed error message for incompatible 2.6.4 pre-release versions. 2005-03-16 01:06:33 +00:00
Wayne Davison
124f349ea1 Document error messages 6 and 25. 2005-03-15 23:23:45 +00:00
Wayne Davison
26718401fb Added the error message for RERR_LOG_FAILURE and used it when
the daemon can't open the log-file.
2005-03-15 23:23:41 +00:00
Wayne Davison
f463e20753 Added RERR_LOG_FAILURE define. 2005-03-15 23:23:39 +00:00
Wayne Davison
1129070514 - Made read_item_attrs() detect and reject a pre1/pre2 rsync (used
by both the sender and the receiver).
- Added an extra phase to the end of the transfer to better handle
  delayed updates that have hard links.
2005-03-15 19:19:44 +00:00
Wayne Davison
ac3f7b81f8 Added an extra phase to the end of the transfer to handle
delayed updates that have hard links.
2005-03-15 19:19:41 +00:00
Wayne Davison
62f9573fb3 - Added an extra phase to the end of the transfer to better handle
delayed updates that have hard links.
- Send the new ITEM_DUMMY_BIT to the sender so that we can figure
  out if the other side is pre1 or pre2 and let the receiver reject
  it.
2005-03-15 19:19:38 +00:00
Wayne Davison
6d0e5d2e62 Added ITEM_DUMMY_BIT and moved a few other 'ITEM_*'s around. 2005-03-15 19:19:36 +00:00
Wayne Davison
8b48bf1154 Tweaked the end-of-phase code. 2005-03-15 17:30:56 +00:00
Wayne Davison
42be53201f Handle --delay-updates at the end of the first phase. 2005-03-15 17:30:52 +00:00
Wayne Davison
c7791b8cb2 Mention the index number for an "invalid packet at end of run". 2005-03-15 17:30:50 +00:00
Wayne Davison
7e9059d60f Fixed a just-introduced crash bug in the --fuzzy processing. 2005-03-14 22:22:42 +00:00
Wayne Davison
f3ebe1a77e A simple test to ensure that fuzzy processing is working. 2005-03-14 22:17:25 +00:00
Wayne Davison
301fb56ce9 Split the conditional-directory sending out of send_file_name() into
a new function: send_if_directory().  This lets the code that is
recursively descending through the directories make its list of a
dir's contents and close the DIR handle before recursing into the
subdirs.  Also, the "recurse" var is just true/false once again.
2005-03-14 17:30:15 +00:00
Wayne Davison
aa7a6e878b The "recurse" value is back to being just 1 or 0 (true or false). 2005-03-14 17:30:13 +00:00
Wayne Davison
0a39837a62 Got rid of "fudged_recurse". 2005-03-14 17:30:10 +00:00
Wayne Davison
b2e8a9b293 Got rid of an unused extern. 2005-03-14 17:06:08 +00:00
Wayne Davison
a98ad81760 Got rid of some code in f_name_cmp() that tried to make all the
dirname pointers to equivalent strings have identical pointers.
2005-03-14 03:36:56 +00:00
Wayne Davison
ccc51c8331 The --fuzzy code now handles a file->dirname that has an identical
string as another file without being an identical pointer.
2005-03-14 03:35:40 +00:00
Wayne Davison
ee171c6da9 Document the latest %i output. 2005-03-13 05:36:13 +00:00
Wayne Davison
d5609e969d Output a '*' at the start of the %i string when deleting. 2005-03-13 05:35:49 +00:00
Wayne Davison
927c806841 - Improved a couple error messages.
- Improved a function name.
2005-03-13 05:34:00 +00:00
Wayne Davison
2da9dda1c0 Some misc. improvements (I hope). 2005-03-12 23:54:05 +00:00
Wayne Davison
3117bc16a5 Improved two sentences. 2005-03-12 23:52:18 +00:00
Wayne Davison
717b04306a Tweaked the name of a variable. 2005-03-12 23:52:08 +00:00
Wayne Davison
271220c542 Mention --copy-dest. 2005-03-11 19:23:09 +00:00
Wayne Davison
566a874141 Re-enabled the --copy-dest part of the test. 2005-03-11 17:36:05 +00:00
Wayne Davison
967866d4df Added --copy-dest logic, and improved the updating of --compare-dest
and --link-dest files that are up-to-date but have differing attributes.
2005-03-11 17:36:03 +00:00
Wayne Davison
1de3e99bc5 Added --copy-dest logic. 2005-03-11 17:35:59 +00:00
Wayne Davison
3e13004b6b Tweaked the comment on copy_file(). 2005-03-11 17:35:57 +00:00
Wayne Davison
2f03ce67d6 Document --copy-dest. 2005-03-11 17:35:54 +00:00
Wayne Davison
b9232d45eb - Fixed the reading of the fuzzy xname from the socket.
- Call read_item_attrs() with its new arg.
2005-03-10 00:06:01 +00:00
Wayne Davison
6087ef2a84 - Changed read_item_attrs() to return the length of the xname string.
- Tweaked the order of the args to write_item_attrs().
2005-03-10 00:05:58 +00:00
Wayne Davison
1f1d368ad5 - Improved the error-checking for some delete_item() calls.
- Move the non-regular-file delete-check above the alt-basis check
  where it belongs.
- Keep track of the real statret and real stat-struct for certain
  alt-basis scenarios (e.g. partial-dir and fuzzy) so that we send
  the right itemized change flags.
2005-03-09 23:46:28 +00:00
Wayne Davison
dd18526e5b Mention the latest protocol-29 changes. 2005-03-09 18:55:09 +00:00
Wayne Davison
4d53c4dd46 We now handle the reading and writing of extra basis-file info: the
fnamecmp_type byte, and the extra name (currently used for fuzzy
processing and hard-link status).
2005-03-09 18:54:19 +00:00
Wayne Davison
9e4a8d29b5 Got rid of the name-pipe, so we now read the fnamecmp_type data over
the socket for protocol >= 29, or handle it like the old days for
older protocol versions.  This means that we now validate this extra
data for safety (such as the fuzzy filename).
2005-03-09 18:54:16 +00:00
Wayne Davison
ef20efcbb6 Made itemize() output the fnamecmp_type and the fuzzy name based on
the new ITEM_BASIS_TYPE_FOLLOWS and ITEM_XNAME_FOLLOWS flags.  Got
rid of the name-pipe to the receiver.
2005-03-09 18:54:12 +00:00
Wayne Davison
c70e07d9ac Got rid of the name-pipe from the generator to the receiver. 2005-03-09 18:54:09 +00:00
Wayne Davison
b7d4d28bb3 When itemizing, we now set ITEM_LOCAL_CHANGE and ITEM_XNAME_FOLLOWS. 2005-03-09 18:54:06 +00:00
Wayne Davison
9a6ed83f2c - Made an overflow in read_vstring() return an error instead of dying.
- Got rid of a flush kluge that was needed for the name-pipe.
2005-03-09 18:54:02 +00:00
Wayne Davison
fd84673e54 Handle the new way that 'c' and 'h' get output by "%i". 2005-03-09 18:53:58 +00:00
Wayne Davison
57b12568e6 Complain if a feature that requires protocol 29 doesn't get it. 2005-03-09 18:53:55 +00:00
Wayne Davison
f9a9f54720 Made the dest_option string non-static. 2005-03-09 18:53:53 +00:00
Wayne Davison
3019a9bafd Changed some of the ITEM_* defines. 2005-03-09 18:53:49 +00:00
Wayne Davison
278e3d4f6e Mention the latest bug-fix. 2005-03-09 04:00:45 +00:00
Wayne Davison
9b9dd06894 We need to mention any change to a directory, not just a time change.
Yeah, this isn't very consistent with how files are treated, but it's
backward compatible.
2005-03-09 04:00:20 +00:00
Wayne Davison
1f7e29b99c Fixed the change-report output for a directory that has no
write permissions.
2005-03-09 03:49:07 +00:00
Wayne Davison
c2f0e6e5e3 Backward compatibility fix in read_iflags() (for protocols < 29). 2005-03-09 02:25:34 +00:00
Wayne Davison
c2b11ba017 Backed out the hack that reversed ITEM_REPORT_XATTRS with
ITEM_TRANSFER.  Yes, it allowed some kludge code that made backward
compatibility seamless, but it made it impossible to remove the hack
in the future.  This way, the backward compatibility is just
slightly inaccurate in the display of the first letter in the %i
output, and the only hack can be safely removed without causing
problems.
2005-03-06 23:37:42 +00:00
Wayne Davison
f75a53e71b - When --max-delete is exceeded, we now count how many deletions
would have happend, warn about the number skipped, and set
  io_error to IOERR_DEL_LIMIT.
- When dry_run > 1 (which indicates that the destinationdir is
  missing), skip deletions in that dir.  This fixes a bug in a
  copy that is creating the destination dir w/--delete enabled.
2005-03-05 18:58:42 +00:00
Wayne Davison
054abde25f Handle new IOERR_DEL_LIMIT bit in io_error. 2005-03-05 18:58:38 +00:00
Wayne Davison
24cecf1365 Define the message for RERR_DEL_LIMIT. 2005-03-05 18:58:35 +00:00
Wayne Davison
821ff7f49a Added RERR_DEL_LIMIT. 2005-03-05 18:58:32 +00:00
Wayne Davison
ff3d3c32d5 Added IOERR_DEL_LIMIT. 2005-03-05 18:58:29 +00:00
Wayne Davison
3b2ef5b11c Mention that --max-delete must be non-zero. 2005-03-05 18:58:26 +00:00
Wayne Davison
0394e34a69 Moved the end_progress() call from match.c to sender.c so that we
report progress on 0-length files when pushing files (the receiver
already called it, so we already produced progress on a 0-length
file when pulling).
2005-03-05 17:51:23 +00:00
Wayne Davison
56efa56474 Fixed the elapsed time reported for 0-length files. 2005-03-05 17:49:46 +00:00
Wayne Davison
ed7e79553e Don't try to determine the phase we're in by looking at the value
of csum_length -- it might have been computed to be SUM_LENGTH.
Instead, look at the "phase" variable directly.
2005-03-05 16:42:52 +00:00
Wayne Davison
dec71e94f3 Added a hack that uses the ITEM_REPORT_XATTRS bit (which is the old
ITEM_UPDATING bit) to make us compatible when sending/receiving bits
to/from an earlier pre-release.
2005-03-05 04:34:06 +00:00
Wayne Davison
ac4f91a5ee Added a hack that sets the ITEM_REPORT_XATTRS bit (which is the old
ITEM_UPDATING bit) when ITEM_TRANSFER or ITEM_LOCAL_CHANGE is set.
This lets us interact compatibly when sending itemized bits to an
earlier pre-release.
2005-03-05 04:34:04 +00:00
Wayne Davison
e957626347 Swapped the bit-values for ITEM_TRANSFER and ITEM_REPORT_XATTRS.
This lets us be more compatible with the earlier pre-releases
with a better heuristic for backward-compatible itemized bits.
2005-03-05 04:34:01 +00:00
Wayne Davison
b4875de45c Improved the description of when "h" is output by %i. 2005-03-05 00:34:02 +00:00
Wayne Davison
2cfe44eee4 Turned on -i for itemized output. 2005-03-05 00:23:55 +00:00
Wayne Davison
fad3dc421c - Updated to handle the new ITEM_* flags.
- Changed read_iflags() to read/write a suffixed hard-link name.
2005-03-05 00:21:59 +00:00
Wayne Davison
22907b6bd9 - Updated to handle the new ITEM_* flags.
- Send MSG_SUCCESS for hard-linked files when -H was specified.
2005-03-05 00:21:56 +00:00
Wayne Davison
3485ae8321 A few minor tweaks to improve two error messages and make better use
of the "the_file_list" global.
2005-03-05 00:21:54 +00:00
Wayne Davison
ca62acc3ca - Make use of the new ITEM_* flags to mention when things were
updated locally instead of being updated remotely.
- Added support for outputting 'a' in the itemized log-output (for
  future use in extended-attribute handling).
2005-03-05 00:21:50 +00:00
Wayne Davison
cdf236aaf5 - Made the sock_{in,out} variables non-static.
- Added hlink_list, a FIFO list of finished hard-link items.
- Made get_redo_num() check for finished hard-link items and
  call the generator when they are found.  This ensures that
  we finish all the hard-link items by the time the MSG_DONE
  is read and returned to the generator.
- Added get_hlink_num() to read the new hlink_list.
2005-03-05 00:21:48 +00:00
Wayne Davison
9f2e3c3f52 - Changed hlink_list[] to store file-list indexes instead of
pointers.
- Made hard_link_one() non-static so that the generator can call it.
  Improved it to do itemized output.
- Replaced do_hard_links() with hard_link_cluster(), which changes
  the hard-linking from a post-transfer loop into a per-cluster
  operation that occurs incrementally as the transfer updates (or
  finds unchanged) one item in the cluster.
2005-03-05 00:21:44 +00:00
Wayne Davison
ee1d11c495 - Updated itemize() to handle sending of hard-link-name info. Made
it non-static so the hard-link code can now output itemized
  messages.
- Made the locally-changed items (such as dirs and symlinks) itemize
  using a new ITEM_LOCAL_CHANGE flag instead of the (renamed)
  ITEM_TRANSFER flag (formerly ITEM_UPDATING).
- Improved the hard-link support by having a cluster of hard-linked
  files get processed as soon as we notice that a single item is
  already up-to-date, or it succssfully finishes being updated.
- The hard-linking that occurs when using --link-dest will now be
  mentioned at higher levels of verbosity IFF %i is in the log-
  format.
2005-03-05 00:21:42 +00:00
Wayne Davison
669e76717c - Changed ITEM_UPDATING to ITEM_TRANSFER.
- Added defines ITEM_HARD_LINKED, ITEM_LOCAL_CHANGE,
  ITEM_REPORT_XATTRS, and SIGNIFICANT_ITEM_FLAGS.
- Changed the "next" var in struct hlink into an int.
2005-03-05 00:21:39 +00:00
Wayne Davison
4e107712f3 Mention latest bug fixes. 2005-03-05 00:20:37 +00:00
Wayne Davison
85aa57a7dd In read_iflags(), we need to set buf to an empty string. 2005-03-04 18:01:16 +00:00
Wayne Davison
58a14ed950 Got rid of some code in the main recv_files() loop by calling the
new functions read_iflags() and maybe_log_item().
2005-03-04 16:54:08 +00:00
Wayne Davison
165e6d446c Moved some code out of the main loop in send_files() into a new
function called read_iflags() (which was made generic enough that
the receiver could use it too).  Also call the new maybe_log_item().
2005-03-04 16:53:26 +00:00
Wayne Davison
1c3e3679ef Added maybe_log_item() for use by the sender and receiver. 2005-03-04 16:52:00 +00:00
Wayne Davison
8a513e55b0 Document the new value of %L. 2005-03-04 16:11:09 +00:00
Wayne Davison
a314f7c155 Document latest format of %i. 2005-03-04 16:08:58 +00:00
Wayne Davison
9497b0d4e9 Call log_item() instead of log_recv(). 2005-03-04 16:08:16 +00:00
Wayne Davison
b694f8a245 Call log_item() instead of log_send(). 2005-03-04 16:08:02 +00:00
Wayne Davison
afc65a5acf - Replaced log_send() and log_recv() with log_item().
- Made log_formatted() and log_item() take an "hlink" arg that
  will be used to pass in a hard-link name for use in %L.
2005-03-04 16:07:50 +00:00
Wayne Davison
5f40615cd5 Use the new "the_file_list" global instead of our "the_flist" local. 2005-03-04 15:57:14 +00:00
Wayne Davison
c6816b9444 Transformed the push/pop functions for the redo-list into more
generic flist_num_{push,pop}() functions that can support other
folks caching off file-list index numbers.
2005-03-04 15:50:22 +00:00
Wayne Davison
46e99b09b9 Added read_vstring() and write_vstring() to io.c instead of
having this code in generator.c and receiver.c.
2005-03-04 15:38:58 +00:00
Wayne Davison
af436313a0 - Got rid of the checking of msg_fd_in in read_timeout() -- it was
only needed back when the generator was reading a separate redo
  pipe from the message pipe.
- Fixed a potential data corruption in the data that the generator
  is sending:  if a message comes in from the receiver, we now make
  sure that we can't put the forwarding of this message to the sender
  into the middle of a multiplexed-write record that the generator
  is trying to flush.
2005-03-04 08:58:27 +00:00
Wayne Davison
d64e6f42b4 Use the new "the_file_list" global. 2005-03-03 18:44:42 +00:00
Wayne Davison
a00628b335 - Set the new global "the_file_list".
- Got rid of test of read_batch in an am_sender section since
  there is never a sender process for --read-batch.
2005-03-03 18:44:06 +00:00
Wayne Davison
33ab4ad879 Simplified whole_file variable checking. 2005-03-03 02:58:48 +00:00
Wayne Davison
99eb41b25f Improved some text in --compare-dest and --link-dest. 2005-03-03 02:23:12 +00:00
Wayne Davison
e86ae6bc1f Don't kluge the value of statret for --whole-file. 2005-03-03 01:50:43 +00:00
Wayne Davison
c3cbcfb8ef Moved the checks for --ignore-existing and --update higher in
recv_generator() so that they don't trigger erroneously when
--link-dest is specified.
2005-03-03 01:33:51 +00:00
Wayne Davison
a1d23b5314 - Got rid of the SID_* flags -- use the ITEM_* flags directly.
- If --compare-dest find a file that is not the same in attributes,
  we need to copy the file.
2005-03-03 00:14:35 +00:00
Wayne Davison
d4d4890d4e Added ITEM_NO_DEST_AND_NO_UPDATE for use by the generator's
itemize() function.
2005-03-03 00:14:32 +00:00
Wayne Davison
30e66e53de Fixed the --compare-dest docs. 2005-03-02 18:01:23 +00:00
Wayne Davison
e224331729 When using multiple --compare-dest options, rsync should avoid
copying a file that has an exact match in any of the dirs.
2005-03-02 17:48:36 +00:00
Wayne Davison
70b54e4e43 Fixed a bug in the --dry-run output when using --link-dest. 2005-03-02 17:27:19 +00:00
Wayne Davison
9ba463435b If the multi-dest loop falls back to the best_match index,
we need to re-stat() the file to restore "st".
2005-03-02 09:51:54 +00:00
Wayne Davison
05ee48661c Tweaked the description for --rsync-path. 2005-03-02 09:17:42 +00:00
Wayne Davison
aef9882581 A little more tweaking to the multi-dest option loop. 2005-03-02 09:09:15 +00:00
Wayne Davison
78bcddcc6a Mention that specifying "/dir/**" is a safer way than "/dir/"
alone to ensure that files inside a dir are fully protected.
2005-03-02 01:48:25 +00:00
Wayne Davison
68e169ab4d Improved the description of --rsync-path. 2005-03-01 23:02:23 +00:00
Wayne Davison
f62eaa24f1 Made the multi-FOO-dest loop a little nicer. 2005-03-01 19:42:31 +00:00
Wayne Davison
d3e553b4bd Explicitly mention that "del." does include the trailing period. 2005-03-01 19:17:27 +00:00
Wayne Davison
3753975f48 Fixed two glitches Paul pointed out. 2005-03-01 17:28:46 +00:00
Wayne Davison
2d81114b23 Preparing for release of 2.6.4pre2 2005-03-01 06:22:19 +00:00
Wayne Davison
472135e0bc Mention the latest changes. 2005-03-01 06:05:23 +00:00
Wayne Davison
c60b7056b2 A few improvements to the new check_for_hostspec() function. 2005-03-01 05:49:11 +00:00
Wayne Davison
42ccb4c091 Made the argv/argc parsing a little nicer. 2005-03-01 03:39:35 +00:00
Wayne Davison
b31c92edcc - Look for last '@' in a user@host spec. 2005-03-01 03:39:32 +00:00
Wayne Davison
08b018304f Removed section on parsing IPv6 literal addresses. 2005-03-01 03:11:28 +00:00
Wayne Davison
d19320fdf6 Changed remote_filesfrom_file to filesfrom_host. 2005-03-01 03:10:59 +00:00
Wayne Davison
860236bf90 - Changes needed to handle new filesfrom_host variable.
- Changes needed to use check_for_hostspec() in place of find_colon().
2005-03-01 01:16:03 +00:00
Wayne Davison
4d3abf1360 Changes needed to use check_for_hostspec() in place of find_colon(). 2005-03-01 01:15:59 +00:00
Wayne Davison
305666bf59 - Changed find_colon() into check_for_hostspec(), extending it to
understand the rsync:://HOST:PORT/PATH format, allowing all HOSTs
  to be IPv6 literal addresses enclosed in '[' and ']', and changing
  it to return the 3 parts of the spec separately (host, port, and
  path).
- Relocated the code that handles the sanitation and validation of
  the files_from arg in order to make its placement a little more
  logical.
- Replaced remote_filesfrom_file with filesfrom_host, which makes
  the value of the files_from variable more intuitive.
2005-03-01 01:15:57 +00:00
Wayne Davison
b03c719f04 Enhanced the option-parsing failure mode to handle the situation
where the parser didn't get a chance to parse the --files-from
option yet, but we still need to know it was there in order to get
the error message back to the client.
2005-03-01 00:42:32 +00:00
Wayne Davison
62f27e3c02 Made a couple sentences about rsync:// syntax clearer. 2005-02-28 22:04:16 +00:00
Wayne Davison
4dc67d5e30 Improved a couple sentences. 2005-02-28 02:16:49 +00:00
Wayne Davison
8ebdc9724e Say "rsync 2.6.4" instead of "protocol 29". 2005-02-28 02:16:23 +00:00
Wayne Davison
9e0582f9bf Tweaked a comment. 2005-02-28 02:04:42 +00:00
Wayne Davison
705de51a73 Improved do_lseek()'s failure message. 2005-02-27 21:12:13 +00:00
Wayne Davison
1a8e5c97eb Complain if the run-terminating keep-alive packets aren't what
we expected.
2005-02-27 20:50:07 +00:00
Wayne Davison
55bb7fff14 Don't loop forever when the receiver is waiting around to be killed
at EOF -- it should be a rapidly arriving event, so only hang around
for 10 seconds, max., and then go ahead and report the "unexpectedly
closed" error.
2005-02-27 18:24:34 +00:00
Wayne Davison
662bdcd4ac Make sure that allowed_lull will not be computed as 0 if
io_timeout is 1.
2005-02-27 18:09:17 +00:00
Wayne Davison
fef101a548 Improved a couple sentences. 2005-02-27 18:01:32 +00:00
Wayne Davison
18a11cfd48 - Made the calls to maybe_send_keepalive() happen at better intervals.
- Call do_hard_links() with its new args.
2005-02-27 09:02:32 +00:00
Wayne Davison
0f80c3e886 Added 2 args to do_hard_links() so that it can call maybe_send_keepalive(). 2005-02-27 09:02:29 +00:00
Wayne Davison
f122383179 Mention the backup fix for redone files with --inplace. 2005-02-27 08:02:06 +00:00
Wayne Davison
e6bc6f4232 We need to turn off make_backups for the redo phase so that
the inplace processing doesn't make a second backup.
2005-02-27 07:50:43 +00:00
Wayne Davison
ac1cb9380d Tweaked an error message. 2005-02-27 07:34:27 +00:00
Wayne Davison
40df65fdb4 - Seems to me that sigusr2_handler() should call close_all() for
the sake of MS Windows.
- Improved some comments.
2005-02-27 07:33:01 +00:00
Wayne Davison
cb2e1f18c2 One more comment fix. 2005-02-26 22:14:40 +00:00
Wayne Davison
0ecd03e396 Fixed comment. 2005-02-26 22:02:38 +00:00
Wayne Davison
e6f5ac116b Improved a couple sentences. 2005-02-26 21:48:12 +00:00
Wayne Davison
051182cb75 Set kluge_around_eof to a -1 for the receiver's needs. 2005-02-26 20:58:08 +00:00
Wayne Davison
574c250093 If kluge_around_eof is < 0, we go into an msleep() loop instead
of exiting.
2005-02-26 20:58:05 +00:00
Wayne Davison
8dad7fc6ea Explicitly set kluge_around_eof to a 1 when it is needed. 2005-02-26 20:58:01 +00:00
Wayne Davison
b558728875 Added keep-alive checking during the directory-touching loop at
the end of the processing.
2005-02-26 20:43:14 +00:00
Wayne Davison
e777afad6f Set kludge_around_eof when the receiver is trying to read a
potential keep-alive message that may never come.
2005-02-26 20:21:12 +00:00
Wayne Davison
87703a1b1f Improved the comment for kludge_around_eof. 2005-02-26 20:21:08 +00:00
Wayne Davison
981b202661 Added "set -x". 2005-02-26 19:49:59 +00:00
Wayne Davison
13725744fd Decided I like "set -x" after all. 2005-02-26 19:47:43 +00:00
Wayne Davison
363c3ece3a Don't allow keep-alive sending if --read-batch is enabled. 2005-02-26 19:37:49 +00:00
Wayne Davison
47780ddfef Mention the new keep-alive handling and the devices-size fix. 2005-02-26 19:17:06 +00:00
Wayne Davison
251f22b5d7 Fixed a line-ordering problem. 2005-02-26 19:11:57 +00:00
Wayne Davison
4e0fcd85ae Handle keep-alive messages at the end of the transfer when
--delete-after is happening.
2005-02-26 18:57:57 +00:00
Wayne Davison
59faec8b8b - Moved all the file-deletion code here from flist.c and receiver.c.
- Call maybe_send_keepalive() from delete_in_dir() so that a really
  long delete-pass won't timeout.
- Renamed delete_files() -> do_delete_pass().
- Renamed delete_file() -> delete_item().
- Call get_dirlist() with its new arg.
2005-02-26 18:03:49 +00:00
Wayne Davison
32cbfe7b17 - Moved file-deletion code into generator.c.
- Made filesystem_dev a global that the generator can set during its
  delete pass.
- Fixed an off-by-one boundary check in send_directory().
- Added an arg to get_dirlist() so that delete_in_dir() can call it
  efficiently.
2005-02-26 18:03:46 +00:00
Wayne Davison
f08ca43472 Moved the delete-after support into generator.c. 2005-02-26 18:03:42 +00:00
Wayne Davison
8eb6cf784b Moved the delete-before support into generator.c. 2005-02-26 18:03:40 +00:00
Wayne Davison
7433d73adc - Moved the initialization of "itemizing", "maybe_PERMS_REPORT", and
"code" from recv_generator() to generate_files() so that they
  don't get recomputed for every file (we pass them as args now).
- Allow protocols < 29 to call maybe_send_keepalive() so that we can
  try to flush the output buffer if things are slow (though we can't
  send a keep-alive packet without protocol_version >= 29).
2005-02-26 06:52:55 +00:00
Wayne Davison
3221f451a0 Calling maybe_send_keepalive() for protocol_version < 29 is
now supported, though we can only try to flush the output
buffer if we're in a lull.
2005-02-26 06:43:15 +00:00
Wayne Davison
9e4536748d - Moved the description of '%i's output into the rsync manpage.
- A few minor tweaks to the "log format" setting.
2005-02-26 05:18:03 +00:00
Wayne Davison
ea67c71505 - We now mention what "%i" outputs under --itemize-changes.
- Improved the description of --log-format.
2005-02-26 05:16:26 +00:00
Wayne Davison
ea38b5af72 Mention the change in when --log-format outputs and how it
interacts with --verbose.
2005-02-26 05:11:46 +00:00
Wayne Davison
89d19eedef Call log_delete() from delete_file() anytime that DEL_TERSE is
not set (we used to only call if verbose or log_format were also
set).
2005-02-26 04:50:55 +00:00
Wayne Davison
41b5b5e756 The log_delete() function may now be called even when the client is
not getting delete messages, which ensures that the daemon's log-
file output includes all deletions when per-file logging is enabled.
2005-02-26 04:49:30 +00:00
Wayne Davison
a3e1363aaa Make sure that our protocol-28 compatibility is OK. 2005-02-26 03:22:05 +00:00
Wayne Davison
2217b30adf Fixed a problem sending include rules to an older rsync. 2005-02-26 02:56:30 +00:00
Wayne Davison
9ac2395bf0 - Call maybe_send_keepalive() if timeouts are enabled.
- Use the new ignore_timeout variable.
2005-02-25 22:01:36 +00:00
Wayne Davison
9e2409ab22 - Added variable "ignore_timeout" that lets the generator tell
us to ignore a timeout without turning off the timeout-related
  time-keeping that the keep-alive processing needs.
- Added a new function:  maybe_send_keepalive().
2005-02-25 21:58:13 +00:00
Wayne Davison
8e6cf5d189 Accept the new keep-alive (no-op) packet. 2005-02-25 21:56:00 +00:00
Wayne Davison
d17190df44 Don't add st_size from a device to stats.total_size. 2005-02-25 20:28:27 +00:00
Wayne Davison
fbe5eeb831 Mention how --backup sometimes implies --omit-dir-times. 2005-02-25 17:10:48 +00:00
Wayne Davison
ed9d969c4c Use the new am_starting_up value in who_am_i(). 2005-02-25 17:08:57 +00:00
Wayne Davison
7f2a1f651e Got rid of kluged value for am_sender, and instead added a new
variable named am_starting_up that is non-zero during the option
parsing.  This lets the who_am_i() routine output a better value
for debugging info that is output during the option parsing.
2005-02-25 17:08:31 +00:00
Wayne Davison
bbbb44ee0f Fixed some typos. 2005-02-25 02:30:38 +00:00
Wayne Davison
29fbd1eea6 Preparing for release of 2.6.4pre1 2005-02-23 03:22:53 +00:00
Wayne Davison
33f839b319 Tweaked an entry. 2005-02-23 03:17:11 +00:00
Wayne Davison
bc83274ad6 - Fixed a problem with full_fname() when curr_dir was "/".
- Made full_fname() consistently output a leading "/" for
  module paths no matter if chroot is in use or not.
2005-02-23 02:56:42 +00:00
Wayne Davison
38e3910b6f One more tweak to the need_name_pipe logic. 2005-02-23 02:14:00 +00:00
Wayne Davison
c26c51a7ee Commenting out link-dest test for now. 2005-02-23 02:13:33 +00:00
Wayne Davison
e9973668a4 Got rid of --copy-dest references. 2005-02-23 02:07:09 +00:00
Wayne Davison
4104c3bf52 Changed --copy-dest to --link-dest. 2005-02-23 02:06:33 +00:00
Wayne Davison
b7c2481933 Got rid of --copy-dest for now -- I think it should be made to do
the copying of unchanged files locally (like --link-dest does
using a hard link).
2005-02-23 02:05:34 +00:00
Wayne Davison
cfb691ac9a Fixed a problem with the last change. 2005-02-22 22:13:04 +00:00
Wayne Davison
cb8240a291 We need the name-pipe for --inplace these days. 2005-02-22 22:13:02 +00:00
Wayne Davison
352963ddc3 Always set the SID_USING_ALT_BASIS appropriately for the transfer,
even if --inplace wasn't specified.
2005-02-22 22:12:59 +00:00
Wayne Davison
8c57732324 More cleanups. 2005-02-22 21:56:32 +00:00
Wayne Davison
8a33c406b3 Trying to fix bug #2357. 2005-02-22 21:48:10 +00:00
Wayne Davison
340bd68f59 We now look for the ITEM_USING_ALT_BASIS flag for an --inplace
transer that is using an alternate basis file (instead of reading
an extra byte after the flag word).
2005-02-22 21:43:59 +00:00
Wayne Davison
8237f9305b We now set the ITEM_USING_ALT_BASIS flag for an --inplace transfer
that is using an alternate basis file (instead of sending an extra
byte after the flag word).
2005-02-22 21:43:57 +00:00
Wayne Davison
5b1c1eefda Added ITEM_USING_ALT_BASIS. 2005-02-22 21:43:54 +00:00
Wayne Davison
6258626751 Document an alternate way to achieve the effect of this script
through the use of awk and the more powerful --filter option.
2005-02-22 21:24:24 +00:00
Wayne Davison
87fd439059 When preforming a recursive delete, push/pop the per-dir merge rules. 2005-02-22 20:42:55 +00:00
Wayne Davison
564ef546a9 Sort the dir-list returned by get_dirlist() and the dir-list that
delete_in_dir() generates.
2005-02-22 03:37:18 +00:00
Wayne Davison
94dcbf8367 - Iterate through the deletion list in reverse order so that we
can't delete a backup file that we just created.
- The rename-directory-for-backup heuristic now checks the
  DEL_FORCE_RECURSE flag, not the zap_dir variable.  We also set
  the flag when we recurse so that only the root dir of a deleted
  hierarchy can be missing the flag (and thus be a call from the
  generator).
2005-02-22 03:16:41 +00:00
Wayne Davison
1bad11c759 Only rename a directory with the backup suffix if we're removing
it to replace it with a file of the same name.
2005-02-22 01:59:15 +00:00
Wayne Davison
ba679d5194 In make_simple_backup(), if the rename() failed because we tried
to rename a directory over a file or visa versa, try to handle it.
2005-02-22 01:57:58 +00:00
Wayne Davison
e1ad7fe63d A couple changes in delete_file() make us more compatible with
older versions: (1) we no longer complain if excluded files
sticking around cause us to not be able to remove a subdir, and
(2) we output the name of the removed subdir after it has been
successfully removed.
2005-02-22 00:42:12 +00:00
Wayne Davison
f18d87b6ed Added function check for vasprintf. 2005-02-21 18:58:09 +00:00
Wayne Davison
a6c15e9a38 - Added function tests for va_copy and __va_copy for snprintf.c code.
- Added AC_C_LONG_DOUBLE for snprintf.c code.
- Got rid of unneeded ino_t check.
2005-02-21 17:08:09 +00:00
Wayne Davison
64bba1465b Check SIZEOF_LONG_LONG instead of HAVE_LONG_LONG. 2005-02-21 17:02:53 +00:00
Wayne Davison
638e106568 - Moved delete_file() into flist.c.
- No need to separately test for (make_backups && !backup_dir)
  because omit_dir_times is now set under those circumstances.
2005-02-21 10:50:32 +00:00
Wayne Davison
34e18ecd61 - Moved delete_file() here from rsync.c and improved it to avoid
removing files we just backed up to the current directory and to
  rename a non-empty dir to dir~ (when no backup-dir is specified).
- Made delete_missing() static.
2005-02-21 10:50:30 +00:00
Wayne Davison
d4021b6d9b - Set omit_dir_times if backing up files w/o a backup dir.
- Only send an explicitly specified -O (--omit-dir-times)
  if it won't be inferred by the receiver.
2005-02-21 10:03:23 +00:00
Wayne Davison
40b1393880 Pass the file-diffing flag as an arg to checkit. 2005-02-21 07:27:28 +00:00
Wayne Davison
30688bf11b If checkit is passed a 4th arg, skip the file-diffing step.
This is used by the devices.test script.
2005-02-21 07:26:59 +00:00
Wayne Davison
a7d7a805dc Touch $tmpdir/do_not_diff_the_files so that checkit does not try
to diff the devices against each other.
2005-02-21 07:19:11 +00:00
Wayne Davison
4a239e98f6 Reposition log_open() and log_close(). 2005-02-21 00:38:15 +00:00
Wayne Davison
7b97c38898 Mention two more things. 2005-02-21 00:32:04 +00:00
Wayne Davison
1f35babc6b - For win32: made --no-detach the default for daemon mode.
- Added --detach (a --daemon option).
2005-02-21 00:31:31 +00:00
Wayne Davison
80ffc3de12 Updated to remove completed items and add a little more info for
other items.
2005-02-21 00:17:10 +00:00
Wayne Davison
507b61d5a6 Some minor tweaks. 2005-02-21 00:16:36 +00:00
Wayne Davison
8db3106e0b Mention the compression-mode fix for large block sizes. 2005-02-20 23:08:56 +00:00
Wayne Davison
1b1fef20b3 Tweaked the rprintf() that outputs about the delta-transmission
enablement.
2005-02-20 22:11:43 +00:00
Wayne Davison
22c7c5fb0b - Integrated the latest version from samba.
- Tweaked the order of the code in my_modf() to avoid
  a compiler warning.
2005-02-20 22:10:33 +00:00
Wayne Davison
13d00101e8 One more tweak to the "whoami" code. 2005-02-20 21:04:03 +00:00
Wayne Davison
3e7934a5fb Changed the memory implementation of --delay-updates so that it
only allocates memory to store needed bits, it sparsely allocates
the bits in 16KB chunks, and the bit-finding loop works in a more
efficient manner.
2005-02-20 20:55:24 +00:00
Wayne Davison
815193e89e Got rid of "set -x" (runtests.sh has a way to set this, if desired). 2005-02-20 17:24:15 +00:00
Wayne Davison
4fd4b3d667 Dropped a useless "const" from the definition of poptStrerror. 2005-02-20 17:21:13 +00:00
Wayne Davison
1526b8b17d Mark a couple unused variables. 2005-02-20 17:20:14 +00:00
Wayne Davison
732537212b Cast char* to uchar* when dereferencing characters for isdigit()
and isprint().
2005-02-20 17:07:31 +00:00
Wayne Davison
4adbb5f246 Have rule_strcmp() accept and return a uchar*. 2005-02-20 17:04:53 +00:00
Wayne Davison
30fa772457 A few improvements to the "test" commands to neaten them up and
to try to fix another problem under solaris.
2005-02-20 17:01:32 +00:00
Wayne Davison
ee03617b3d Cast a uchar* arg to char* for write_buf(). 2005-02-20 16:56:30 +00:00
Wayne Davison
19cb6106d2 Improved the testuser-setting code to try to get it to work
under solaris.
2005-02-20 16:27:10 +00:00
Wayne Davison
cd6bececc1 If --delay-updates is specified with --remove-sent-files, delay
the MSG_SUCCESS messages until we actually move the files into
place at the end.
2005-02-20 02:54:30 +00:00
Wayne Davison
88b93c6159 Corrected "log format" info and added info on --remove-sent-files. 2005-02-20 02:45:10 +00:00
Wayne Davison
b62fd39392 A small twiddle. 2005-02-20 01:14:27 +00:00
Wayne Davison
95306d9d50 - For every file that we send off to the receiver, mark it with
FLAG_SENT.
- Added successful_send(), which is called when MSG_SUCCESS was
  received from the receiver/generator side.  This function
  validates the message, and removes the indicated file/symlink
  (assuming that remove_sent_files was actually set).
2005-02-20 01:04:54 +00:00
Wayne Davison
3e870a6444 If --remove-sent-files was specified and we successfully updated a
file, send MSG_SUCCESS to the sender (through the generator).
2005-02-20 01:04:51 +00:00
Wayne Davison
bf26aa2219 - If --remove-sent-files was specified, abort if we're pulling from
a read-only module.
- If need_messages_from_generator is set, make sure that the
  connection between the generator to the sender has multiplexed
  I/O enabled.
2005-02-20 01:04:49 +00:00
Wayne Davison
9981c27ef1 Handle the new MSG_SUCCESS message for both the generator and the
sender.
2005-02-20 01:04:46 +00:00
Wayne Davison
fe96018750 If we update the contents of a symlink and --remove-sent-files
is enabled, tell the sender about it via MSG_SUCCESS.
2005-02-20 01:04:43 +00:00
Wayne Davison
07c6ae7de8 - Added --remove-sent-files option.
- If a server is refusing "delete" and we're the sender, also refuse
  the --remove-sent-files option.
2005-02-20 01:04:40 +00:00
Wayne Davison
e163683020 Document how refusing "delete" affects --remove-sent-files. 2005-02-20 01:04:37 +00:00
Wayne Davison
961103049b Document --remove-sent-files. 2005-02-20 01:04:34 +00:00
Wayne Davison
0254bd46ec Test --remove-sent-files. 2005-02-20 01:04:27 +00:00
Wayne Davison
8b806ed347 Disallow --remove-sent-files with a read-only server. 2005-02-20 01:04:12 +00:00
Wayne Davison
8e3ead09a3 Got rid of maybe_DEL_TERSE. 2005-02-20 00:47:15 +00:00
Wayne Davison
8715db2cab Tweaked some externs. 2005-02-20 00:16:23 +00:00
Wayne Davison
50839b4bb0 Tweaked some externs. 2005-02-19 23:42:09 +00:00
Wayne Davison
e1f40891c7 - Needed to use a name buffer in delete_missing() to avoid having
a recursive delete reuse our buffer from f_name().
- Moved the backup-handling into delete_file() in rsync.c.
- Moved the --max-delete counting into delete_file() in rsync.c.
2005-02-19 23:41:52 +00:00
Wayne Davison
042f470ef9 Made delete_file() backup files it is removing if --backup was specified. 2005-02-19 23:39:47 +00:00
Wayne Davison
40cc28516d Moved deletion_count here so that we honor --max-delete in
delete_file().
2005-02-19 23:24:41 +00:00
Wayne Davison
8174bc3506 If the server refuses a directory, don't allow any files to be
sent to the server inside that directory.
2005-02-19 23:01:52 +00:00
Wayne Davison
9118a09c77 Changed a couple log_recv() calls back to log_send(). 2005-02-19 22:57:08 +00:00
Wayne Davison
8324bd5c21 When logging PERMS_REPORT messages, send them with the FCLIENT code
if the daemon has "%i" in its log message (because it already got a
detailed log message from the generator).
2005-02-19 22:16:53 +00:00
Wayne Davison
7f37167da5 - Always send the itemized-info bytes on to the receiver. This
not only ensures that batch files are created consistently for
  push and pull, but allows a daemon to log itemized changes.
- Improved the logging of itemized changes for the daemon.
- Make sure we debug-log our presence in send_files().
2005-02-19 22:16:50 +00:00
Wayne Davison
227a9c41c1 - Improved the logging of itemized changes for the daemon.
- Make sure we debug-log our presence in recv_files().
2005-02-19 22:16:47 +00:00
Wayne Davison
6c3862fae3 Make use of new variables (log_format_has_i, log_format_has_o_or_i,
and daemon_log_format_has_i) and the new FCLIENT logging code to
output stats in the best way possible for both the client and the
daemon.
2005-02-19 22:16:45 +00:00
Wayne Davison
1eec003a80 The FCLIENT log code aviods putting the message into the daemon's
log file and instead sends a FINFO message to the client.  This is
used when the daemon wants to log a better message locally than it
is sending to the client.  Improved log_delete() to make use of this
idiom if it needs to log a separate delete message for the daemon
and the client.
2005-02-19 22:16:41 +00:00
Wayne Davison
684d7582b6 - Added log_format_has_i.
- Fixed a problem withe option-refusing code when it refuses the
  daemon options.
- Don't sent --itemize-changes (-i) to the server -- send an
  improved --log-format value instead.
2005-02-19 22:16:39 +00:00
Wayne Davison
f39b2060fe We now set daemon_log_format_has_i and daemon_log_format_has_o_or_i
instead of itemize_daemon_changes.
2005-02-19 22:16:35 +00:00
Wayne Davison
4f2ba7e056 No more need to clear itemize_changes based on protocol_version. 2005-02-19 22:16:33 +00:00
Wayne Davison
1dcf3b4345 Changed some of the values of the MSG_* defines. 2005-02-19 22:16:31 +00:00
Wayne Davison
aa57d14ae7 We now use a regular expression to parse the (restored to its previous
version) default logfile format.  Added parsing for a version of the
default logfile format where %o has been replaced with %i.
2005-02-19 19:36:54 +00:00
Wayne Davison
3c54d8a3ad Decided to leave the "log format" default the same as in
earlier versions.
2005-02-19 17:38:51 +00:00
Wayne Davison
c0814b813f If the "log format" has a %i in it, set itemize_daemon_changes. 2005-02-19 17:37:40 +00:00
Wayne Davison
088aff1a48 - Don't log a delete message to the daemon log in dry-run mode.
- The daemon's wrote/read log message now uses the terms
  sent/received.
2005-02-19 17:23:08 +00:00
Wayne Davison
d6707171e6 Decide whether to log a delete message via the default format by
checking the new log_format_has_o_or_i variable, not itemize_changes.
2005-02-19 03:54:13 +00:00
Wayne Davison
5c5e159892 - Set new variable, log_format_has_o_or_i.
- Make sure that -i can't be set w/o an actual %i in the log_format.
- Only need to pass -i to server if we're the sender.
- Only need to pass some --log-format information to the server in
  certain circumstances.
2005-02-19 03:54:11 +00:00
Wayne Davison
6d7b3d52dc Rules read in from per-dir merge files need to have non-applicable
rules filtered out before the rule gets stored (not in a post-
filtering pass like the rules that are read-in prior to the run).
2005-02-19 03:12:21 +00:00
Wayne Davison
591b908fbf Mention the change in the default "log format" daemon-config setting. 2005-02-19 03:03:13 +00:00
Wayne Davison
742be97ce4 Log items that are unchanged if verbose > 1. 2005-02-19 02:39:33 +00:00
Wayne Davison
1f30a674cd Notify the remote side about -i (if either specified or inferred from
the user's --log-format string) and, if we're not verbose but we're
logging messages, let the server know that --log-format was specified.
2005-02-19 02:39:30 +00:00
Wayne Davison
19bc826d8b - Tweaked the letters output by "%i", including adding support for
logging a deleted item and an identical item.
- Added log_delete(), a routine that either logs the fact that a
  deletion happened, or sends a MSG_DELETED message to the client
  side (or both if we're a daemon server receiver).
2005-02-19 02:39:26 +00:00
Wayne Davison
c786a7aec5 - Changed the calling args to delete_file() to take an st_mode instead
of a DEL_DIR flag.
- Call log_delete() instead of outputting "deleting ..." messages..
- Log deletions if either verbose or log-format is specified.
2005-02-19 02:39:23 +00:00
Wayne Davison
8a8356b7db - Send the itemized data for every file, changed or not, if verbose > 1.
- Don't call set_perms() with PERMS_REPORT if we're itemizing changes.
- Don't call delete_file() with DEL_TERSE if we're itemizing changes.
- Call delete_file() with its new arg.
2005-02-19 02:39:21 +00:00
Wayne Davison
0d67e00af8 - Allow send_msg() to be called by the delete code in flist.c and
have it figure out if it should send the message to our sibling
  or the other side.
- Handle the new MSG_DELETED message in both the generator and the
  sender.  This message is used to let the client side log each
  deletion when the server side is the receiver.
2005-02-19 02:39:18 +00:00
Wayne Davison
7448177753 - Call log_delete() instead of outputting a "deleting ..." message.
- Call delete_file() with its new arg.
2005-02-19 02:39:15 +00:00
Wayne Davison
90d151f423 If the protocol is less than 29, make sure itemize_changes is off. 2005-02-19 02:39:11 +00:00
Wayne Davison
9f7c5dabf8 - Got rid of DEL_DIR define.
- Added define for ITEM_DELETED.
2005-02-19 02:39:09 +00:00
Wayne Davison
a85a151430 - Mention that "%o" can now have the value "del."
- Updated the description of "%i" to reflect the latest functioning.
2005-02-19 02:39:06 +00:00
Wayne Davison
5dd97ab999 Fixed an inaccuracy in the --archive description. 2005-02-19 02:39:03 +00:00
Wayne Davison
8daa9925cc More improvements. 2005-02-18 21:24:00 +00:00
Wayne Davison
e844be4e7b - Use read_short() and write_short().
- If the user does not want itemized changes, don't log the name
  for attribute changes.
2005-02-18 20:17:24 +00:00
Wayne Davison
88b218fa5c - Tweaked code in itemize() a bit.
- Use the new write_short() function.
- Mention the delete() when an item replaces an item of a different type.
- Make sure that this replacing of a non-same item is marked as a new
  transfer in the itemized output.
2005-02-18 20:17:20 +00:00
Wayne Davison
e66d70e34c The '%n' escape needs to append a trailing slash onto a directory name. 2005-02-18 20:17:17 +00:00
Wayne Davison
9361f83933 Added read_short() and write_short(). 2005-02-18 20:17:15 +00:00
Wayne Davison
3b2bebbf90 Improved the "log format" section some more. 2005-02-18 20:17:12 +00:00
Wayne Davison
4f90eb433a Improved --verbose, --itemize-changes, and --log-format. 2005-02-18 20:17:09 +00:00
Wayne Davison
b485e0c16c Fixed/improved the comment before safe_name(). 2005-02-18 20:17:05 +00:00
Wayne Davison
bc1fac9648 Handle uchar and short as a function return type. 2005-02-18 20:16:59 +00:00
Wayne Davison
c78779cce3 - Fixed a few bugs and compile warnings.
- Use the long-option parser for better option handling.
- Output a usage message if the options are wrong.
- Improved the option-variable names.
- Parse the new default daemon log-file format.
- Handle filenames that have spaces in them.
2005-02-18 17:58:03 +00:00
Wayne Davison
702cd15cb0 For the server, don't ever intuit verbosity higher than what
the client asked for.
2005-02-18 17:36:12 +00:00
Wayne Davison
1da05366ad The daemon loop needs to call log_open() because it called log_close(). 2005-02-18 17:34:09 +00:00
Wayne Davison
2267efeac5 Made log_open() non-static and moved log_close() next to it. 2005-02-18 17:33:43 +00:00
Wayne Davison
15954da08f Updated the default "log format" string and the output of "%i". 2005-02-17 09:19:07 +00:00
Wayne Davison
b2dc7bad39 Changed the default log format. 2005-02-17 09:16:51 +00:00
Wayne Davison
d4e0196346 Use '.' for unchanged attributes in the %i output. 2005-02-17 09:16:23 +00:00
Wayne Davison
2fc50f5a98 More improvements for the description of the %i output. 2005-02-16 20:12:20 +00:00
Wayne Davison
bd5b85dbc7 Mention the new flag-word for protocol 29. 2005-02-16 17:08:04 +00:00
Wayne Davison
8a8324657e - The itemized flags are now 2 bytes instead of 1.
- Always send/receive the itemized flags for protocols >= 29.
- The output of the verbose log-the-transfer messages is always handled
  via log_send() (when we're the client).
2005-02-16 17:02:16 +00:00
Wayne Davison
4bb0af79b7 - The itemized flags are now 2 bytes instead of 1.
- Always send/receive the itemized flags for protocols >= 29.
- The output of the verbose log-the-transfer messages is always handled
  via log_recv() (when we're the client).
2005-02-16 17:02:13 +00:00
Wayne Davison
e3bcd89319 - The itemized flags are now 2 bytes instead of 1.
- Always send the itemized flags for protocols >= 29.
- Sent an itemized-flag update for dirs and symlinks for protocols >= 29
  (instead of outputting a message directly).
2005-02-16 17:02:11 +00:00
Wayne Davison
87383697e8 - Auto-set --verbose if --dry-run is specified w/o --log-format.
- When verbose w/o a log_format specified, set it to "%n%L".
- There's no longer a need to send -i to the server.
2005-02-16 17:02:08 +00:00
Wayne Davison
e4b808989e Moved the auto-setting of --verbose when --dry-run is specified into
options.c.
2005-02-16 17:02:05 +00:00
Wayne Davison
59e52bf276 Tweaked ITEM_MISSING_DATA. 2005-02-16 17:02:02 +00:00
Wayne Davison
9b40e44ef4 No need to handle itemize_changes anymore. 2005-02-16 17:01:59 +00:00
Wayne Davison
e92f21d2f7 Tweaked the mention of --itemize-changes. 2005-02-16 08:12:34 +00:00
Wayne Davison
910e89b963 - We now accept an itemized-changes flag-byte over the socket if we're
the local client and --itemized-changes was specified.  If the item
  is not being updated, just call log_recv().
- We reject an attempt to file-update any non-regular file, not just
  dirs.
- Avoid the verbose "log the transfer" output if --log-format was
  specified and log_before_transfer is in effect.
- Call log_recv() with its new iflags arg.
2005-02-16 08:10:45 +00:00
Wayne Davison
8a9cfb2459 - We now accept an itemized-changes flag byte over the socket if we're
in --itemized-changes mode.  If the item is not being updated,
  either pass it along to the receiver (if we're the server) or just
  call log_send().
- We reject an attempt to file-update any non-regular file, not just
  dirs.
- Avoid the verbose "log the transfer" output if --log-format was
  specified and log_before_transfer is in effect.
- Call log_send() with its new iflags arg.
2005-02-16 08:10:41 +00:00
Wayne Davison
41961db0bd Ensure that -i is set consistent with the batch's data. 2005-02-16 08:10:38 +00:00
Wayne Davison
e76518843d - If log_before_transfer is possible, don't force --verbose on for
--progress.
- If --log-format contains %i, set --itemize-changes (-i).
- Always send -i to the remote rsync if it was specified/implied.
2005-02-16 08:10:31 +00:00
Wayne Davison
ef74f5d626 - Improved log_formatted() to handle long filenames better.
- Added %i, for the list of itemized changes, %n for the normal
  filename (might be shorter than %f), and %L for a " -> symlink"
  string IIF the item is a symlink (else "").
- The log_{send,recv}() functions now take an "iflags" arg.
2005-02-16 08:10:28 +00:00
Wayne Davison
c557eb8cec Changed showchg() into itemize(), which now ships off a flag byte of
what changed over to the sender instead of outputting a string itself.
This does mean that we now ship off indexes of non-file items that got
updated, but the sender will know what to do with it.
2005-02-16 08:10:25 +00:00
Wayne Davison
0cc279e0d3 - Added the new ITEM_* flags for the itemized-changes flag passing.
- Also added defines for FLAG_SENT and MSG_SUCCESS.
2005-02-16 08:10:22 +00:00
Wayne Davison
0cfdf22655 Documented that -i now sets a default --log-format string. 2005-02-16 08:10:19 +00:00
Wayne Davison
527a010f10 Documented the new log-format escapes: %n, %L, and %i. 2005-02-16 08:10:13 +00:00
Wayne Davison
c8ca974634 Some tweaks to how --itemize-changes works. 2005-02-16 01:13:03 +00:00
Wayne Davison
3296f91bb0 Check for refusal of --delete-before when it is inferred. 2005-02-15 21:15:58 +00:00
Wayne Davison
e2124620eb Moved two paragraphs. 2005-02-15 20:42:36 +00:00
Wayne Davison
69864a5ccf Made showchg() use safe_fname(). 2005-02-15 20:41:37 +00:00
Wayne Davison
5b4e1f318d - Mention the addition of --itemize-changes.
- Mention the setting of read_only when a daemon is read-only.
2005-02-15 19:47:57 +00:00
Wayne Davison
b78296cb0b Decided on a better option name --itemize-changes (-i). 2005-02-15 07:41:13 +00:00
Wayne Davison
06a1dbad61 Implemented the --what-has-changed functionality. 2005-02-15 07:20:14 +00:00
Wayne Davison
93c31c1a6d Don't force -v with -n if -w was specified. 2005-02-15 07:20:11 +00:00
Wayne Davison
a8ed495833 If -w and -v are both on, don't output the "log the transfer"
verbose message.
2005-02-15 07:20:04 +00:00
Wayne Davison
4a14ed068c Added --what-has-changed (-w), which summaries the changes
being made to the files.
2005-02-15 07:20:01 +00:00
Wayne Davison
dc0f24976d Document --what-has-changed (-w). 2005-02-15 07:19:58 +00:00
Wayne Davison
1e7098b5e3 Fixed a typo. 2005-02-15 03:38:04 +00:00
Wayne Davison
2f24fb18c4 Make sure that there are no directory-time differences between the
dirs that might trip up the check of the merged copy.
2005-02-15 02:01:02 +00:00
Wayne Davison
96a8ca6d98 Had a report that the __attribute__ code needs to check for
__APPLE__ being defined, not APPLE.
2005-02-14 22:49:51 +00:00
Wayne Davison
37a5644576 One arg to matched() is supposed to be an int32. 2005-02-14 22:48:28 +00:00
Wayne Davison
a1cbe76e2c Changed one size_t var into an int32. 2005-02-14 22:47:42 +00:00
Wayne Davison
98bf61c80e Improved description of --whole-file option. 2005-02-14 19:09:30 +00:00
Wayne Davison
01f439ec6e Fixed a mismatch in the compressed-data handling between how the
sending side and the receiving side handled implicit (unsent) data.
2005-02-14 08:28:00 +00:00
Wayne Davison
acc461c7da Changed various token variables from "int"s to "int32"s. 2005-02-14 08:19:32 +00:00
Wayne Davison
1585958497 The count of chunks should really be an int32, not a size_t,
because that's the maximum size we can transmit over the wire.
2005-02-14 08:13:47 +00:00
Wayne Davison
7cacd47edd Changed the size_t variables into int32 variables. 2005-02-14 08:12:22 +00:00
Wayne Davison
e461b9bed4 Don't let --fuzzy be used with a protocol_version < 29. 2005-02-14 02:47:44 +00:00
Wayne Davison
3723c04850 Mention --fuzzy. 2005-02-14 02:41:35 +00:00
Wayne Davison
73273075c8 Added code to read a fuzzy-basis name from the generator. 2005-02-14 02:41:30 +00:00
Wayne Davison
8e85be0a16 Added handling for fuzzy-basis scanning. When a fuzzy filename is
chosen, the name is sent down the name-pipe to the receiver.
2005-02-14 02:41:27 +00:00
Wayne Davison
37802f40dc - If send_file_name() gets f set to -2, it skips the local filter rules.
- Added get_dirlist(), which returns a file_list structure for the
  desired directory, optionally with local filter rules disabled.
2005-02-14 02:41:23 +00:00
Wayne Davison
06b96ffa86 Set need_name_pipe if --fuzzy was specified. 2005-02-14 02:41:18 +00:00
Wayne Davison
c4ed1487f9 Added parsing for the --fuzzy (-y) option. 2005-02-14 02:41:15 +00:00
Wayne Davison
e64ae6d766 Added find_filename_suffix() and fuzzy_distance(). 2005-02-14 02:41:10 +00:00
Wayne Davison
5b4837552b Document the --fuzzy (-y) option. 2005-02-14 02:41:05 +00:00
Wayne Davison
d2004814f0 Changed #if to use "defined". 2005-02-14 02:34:01 +00:00
Wayne Davison
bf0c5bec45 If f_name_cmp() discovers that two directory strings compare to an
equal value without being equal pointers, substitute one of the
pointers for the other in the file list.  This optimizes future name
comparisons.  Note also that this optimization won't be triggered
very often (because rsync tends to send the names grouped by dir-
name at transmission time), but it's nice to be able to assume that
all files in the same dir have identical dir-name pointers after the
qsort is finished.
2005-02-14 01:29:17 +00:00
Wayne Davison
0dd046d36f Don't check defined-ness of SIZEOF_OFF64_T. 2005-02-14 00:58:10 +00:00
Wayne Davison
4f5b0756df John E. Malmberg convinced me to standardize on #ifs for defined
values instead of non-zero.
2005-02-14 00:53:43 +00:00
Wayne Davison
fe1c19dcdf In clean_flist(), if a duplicate is found for a dir and a non-dir,
always dump the non-dir (because the dir might have contents in
the list).
2005-02-13 22:48:38 +00:00
Wayne Davison
24b2096e86 The dir vs non-dir test now assumes the dir wins. 2005-02-13 22:48:35 +00:00
Wayne Davison
86e97e178d Mention the new sorting method for protocol 29. 2005-02-13 22:37:29 +00:00
Wayne Davison
905d906d69 Added a test for the merging of a dir and a non-dir with the same name. 2005-02-13 22:01:15 +00:00
Wayne Davison
abce74bb93 Added some missing commas in some option summary lines. 2005-02-13 21:50:55 +00:00
Wayne Davison
f5db099330 - Made receive_file_entry() return the file_struct pointer instead
of storing it into the files[] array.
- Made flist_find() return "no match" if the found item differs in
  its directory-ness from the search item.
- Changed f_name_cmp() to sort sub-directories after non-directories
  for each directory's contents.  This makes things like the upcoming
  --fuzzy patch easier to get right.
- One complicating factor is that clean_flist() needed some extra
  code to ensure that a directory doesn't duplicate a non-directory
  of the same name.
- Make sure that the "strip_root" code in clean_flist() (for relative
  paths) strips off all leading slashes.
2005-02-13 21:15:47 +00:00
Wayne Davison
122d1771db Improved the call to f_name_cmp(). 2005-02-13 20:06:18 +00:00
Wayne Davison
8824e2cee4 Changed the prefix on the fnc_state enums. 2005-02-13 10:23:56 +00:00
Wayne Davison
8a6f3fead8 Improved the summary for the -F option. 2005-02-13 05:45:42 +00:00
Wayne Davison
9c71f56a25 Improved the help text for -F. 2005-02-13 05:44:29 +00:00
Wayne Davison
f924946eba Improved the description of the --compress (-z) option. 2005-02-12 22:22:14 +00:00
Wayne Davison
32a5edf43f Improved the documentation of the --compress (-z) option. 2005-02-12 22:21:45 +00:00
Wayne Davison
9a338344da Forgot to make sure that the dir-times on the chkdir got synced
in the newest test case.
2005-02-12 21:22:21 +00:00
Wayne Davison
df337831dc When --dry-run is set, note when a directory is missing and avoid
trying to stat() any items inside that dir's hierarchy.  This fixes
a bug where a symlink to a dir getting replaced by a dir with
identical contents to the dir at the other end of the symlink would
not report the updated files in the new hierarchy. (See bug #1673)
2005-02-12 21:18:58 +00:00
Wayne Davison
bb558f6791 Some more improvements to exercise rule-restricted merge files
(i.e. exclude patterns only) and side-restricted filter rules.
2005-02-12 20:45:39 +00:00
Wayne Davison
22558cdd7e Improved checkit() and rsync_ls_lR() to work with filenames that
might have spaces.
2005-02-12 20:25:12 +00:00
Wayne Davison
28c54e81c1 Mention the protocol change for --delete-excluded. 2005-02-12 19:52:40 +00:00
Wayne Davison
0dfffb88e1 Document the new filter rule flags for sender-/receiver-specific
rules.
2005-02-12 19:52:34 +00:00
Wayne Davison
ed243f8c29 - Added modifiers for the include/exclude rules that makes them
apply to the indicated (sender/receiver) side.
- Added the hide/show and protect/risk filter rules as an alternate
  way to specify sender-/receiver-specific include/exclude rules.
- send_rules() now allows f_out to be -1 to indicate that the list
  should be scanned but not sent.
- send_rules() now filters the list to remove any items that don't
  apply to the current side (after sending the item to the other
  side when f_out != -1).
- {send,recv}_filter_list() now transfer the list, even when the
  receiver is the server and --delete-excluded was specified (the
  exchanged list is appropriately filtered, of course).
- recv_filter_list() uses send_rules() to trim non-applicable rules
  when we're a local-server (because we got our filter list without
  send/recv calls when fork() duplicated it).
2005-02-12 19:52:26 +00:00
Wayne Davison
a427e8938a - Define MATCHFLG_SENDER_SIDE and MATCHFLG_RECEIVER_SIDE.
- Updated MATCHFLGS_FROM_CONTAINER.
2005-02-12 19:52:22 +00:00
Wayne Davison
cc25d29132 We don't need to avoid the local filter list in send_file_name()
when --delete-excluded is set because our list has been trimmed to
only include rules that apply in the current mode.
2005-02-12 19:52:18 +00:00
Wayne Davison
134f43385b - Since send_file_list() is no longer called with f == -1, got rid
of all the conditional code to support that.
- Improved the comment before send_directory() to indicate that it
  gets called with f == -1 from delete_in_dir().
2005-02-12 18:40:15 +00:00
Wayne Davison
a5a264842e Don't use underscores in the example filter rules. 2005-02-11 23:16:41 +00:00
Wayne Davison
eed47b6b9c Made "i" a size_t in receive_sums(). 2005-02-11 20:46:55 +00:00
Wayne Davison
3841a04e88 A minor tweak for the dry_run logic. 2005-02-11 20:26:08 +00:00
Wayne Davison
9eef8f0b73 Improved the "refuse options" section, including an update
to the section that talked about --del being a popt alias
(which is no longer true).
2005-02-11 10:52:50 +00:00
Wayne Davison
c258230722 - Several improvements in describing how options imply other options.
- Improved --partial-dir.
2005-02-11 10:51:25 +00:00
Wayne Davison
345e0988cb Changed rule_match() to rule_strcmp(). Likewise for the
define RULE_MATCH() being changed into RULE_STRCMP().
2005-02-11 10:47:43 +00:00
Wayne Davison
3671987f4d - Added some new refused_* variables that note if certain options
have been refused on the server daemon.  This allows us to reject
  implied options (e.g. if --partial is refused and -P specified).
- Changed the handling of the --delete refusals from the old idiom
  of upgrading "delete" to "delete*" into the new idiom of checking
  if refused_delete is set when we determine --delete was implied.
- Changed the --del option from a popt alias into a normal option.
- Mark all the daemon options as refused when a daemon is parsing
  the over-the-socket options.
- Created a new function, create_refuse_error(), which is now called
  from all the spots that check for refused options.
- Don't call clean_fname() on an empty string -- either reject it
  or handle it without erroneously expanding the string.
- If --delay-updates was specified without a --partial-dir option,
  don't send the default "--partial-dir=.~tmp~" option if the server
  is the receiver -- just let it default.
2005-02-11 10:42:55 +00:00
Wayne Davison
5aa7b20a3e Have partial_dir_fname() also check if the dir is excluded
by the server, not just the partial file.
2005-02-11 09:58:31 +00:00
Wayne Davison
68795c640b If a --delay-update can't use the partial-dir (e.g. if a server
daemon excludes the dir or file), update the file without delay.
2005-02-11 09:56:28 +00:00
Wayne Davison
4f1f94d1de Improved the --modify-window description. 2005-02-09 17:08:23 +00:00
Wayne Davison
0f7e31f7d7 Improved several items and added a new section describing what is
different for protocol version 29.
2005-02-09 04:45:36 +00:00
Wayne Davison
2f3cad893b - Decided that flist_find() should be public, not static.
- Modified f_name_cmp() so that, beginning with protocol 29,
  it will guarantee that a directory name will sort one slot
  before its contents (prior versions could sort other items
  in between in rare instances).
2005-02-09 02:36:17 +00:00
Wayne Davison
e79666267d Also test the new long-named filter rules. 2005-02-08 19:30:07 +00:00
Wayne Davison
d91de04671 Mention the new long-name filter rules. 2005-02-08 19:06:30 +00:00
Wayne Davison
64b761c19a Allow a ',' to prefix the MODIFIERS for a single-letter filter rule. 2005-02-08 18:47:25 +00:00
Wayne Davison
a1ac8edd66 - Added long-name filter rules.
- Only parse the "!" token when MATCHFLG_NO_PREFIXES is set if
  MATCHFLG_CVS_IGNORE is also set.
2005-02-08 18:33:16 +00:00
Wayne Davison
1dca857b5b Fixed a typo. 2005-02-07 20:46:42 +00:00
Wayne Davison
f8cd88dbd1 - Added more calls to safe_fname().
- Improved safe_fname() so that it changes all non-printable chars
  into '?'s, and accomodates more simultaneous (and longer) names.
2005-02-07 20:41:43 +00:00
Wayne Davison
71903f601a Added missing calls to safe_fname() and full_fname(). 2005-02-07 20:40:18 +00:00
Wayne Davison
719bc858b5 Made NS define make use of safe_fname(). 2005-02-07 20:39:13 +00:00
Wayne Davison
a6126d678b Added missing call to safe_fname(). 2005-02-07 20:38:56 +00:00
Wayne Davison
4875d6b64d Adding more calls to safe_fname(). 2005-02-07 20:36:43 +00:00
Wayne Davison
54b4059856 Needed to call safe_fname() when listing the remote names. 2005-02-07 19:40:31 +00:00
Wayne Davison
38059f8e8e One more tweak. 2005-02-06 07:24:42 +00:00
Wayne Davison
bb5f4e7285 A few tweaks to the FILTER RULES section, including a mention of
using the +/- modifiers on merge-file rules.
2005-02-06 07:16:19 +00:00
Wayne Davison
448797a1e6 Fixed an off-by-one error in the prefix-length checking in
get_rule_prefix().
2005-02-05 06:53:20 +00:00
Wayne Davison
a261103ce0 Improved the name of a variable. 2005-02-05 05:30:06 +00:00
Wayne Davison
7b82b5adb3 Mention a couple more changes. 2005-02-05 01:38:19 +00:00
Wayne Davison
397a344364 Added the "C" modifier to the itemized list of +/- modifiers. 2005-02-05 00:03:46 +00:00
Wayne Davison
bafa48759f Mention the new --filter=-C syntax that lets you position the default
CVS rules within your other filter rules.
2005-02-04 23:57:26 +00:00
Wayne Davison
46db185081 - Moved get_cvs_excludes() up above its only use and made it static.
- Changed get_cvs_excludes() to make an mflags arg.
2005-02-04 22:32:17 +00:00
Wayne Davison
1412da7c32 If we're a "local server" (i.e. we just forked a server for a
local transfer), don't duplicate all the filter rules that we
already know about in the forked process.
2005-02-04 21:54:02 +00:00
Wayne Davison
d09e800a0e Fixed the way get_rule_prefix() turns the MATCHFLG_WORD_SPLIT flag
back into a modifier character.
2005-02-04 21:16:39 +00:00
Wayne Davison
53b417e414 - Added MATCHFLG_CVS_IGNORE.
- Made the match_flags var a uint32.
2005-02-04 21:13:12 +00:00
Wayne Davison
57dee64e82 - Moved the cvs_exclude checks into send_filter_list() and
recv_filter_list().  Because of this, we never skip these
  calls anymore, though read-batch processing indicates that
  the list should not really be sent by setting f_out to -1.
- Moved the definintion of the "local_server" variable here
  from options.c.
2005-02-04 21:13:09 +00:00
Wayne Davison
fdc795015f - Changed filter_rule() to add_rule().
- Improved the debug info coming from add_rule().
- Changed add_filter() to parse_rule() and add_filter_file()
  to parse_filter_file().
- Changed get_filter_tok() to parse_rule_tok().
- Made the mflags a uint32.
- Added an extra arg to get_rule_prefix() to indicate if we're
  building the options for transmission or other purposes.
- The 'C' modifier can now be applied to a '-' rule, so it now
  sets a new flag: MATCHFLG_CVS_IGNORE.
- The send_filter_list() and recv_filter_list() functions now handle
  all the logic needed to do the right thing for -C (this used to be
  in main.c).
2005-02-04 21:13:06 +00:00
Wayne Davison
3a5e9224d0 - Changed add_filter() to parse_rule() and add_filter_file()
to parse_filter_file().
- Moved the definintion of the "local_server" variable into main.c.
2005-02-04 21:13:03 +00:00
Wayne Davison
ebfd1a1cf7 Changed add_filter() to parse_rule() and add_filter_file()
to parse_filter_file().
2005-02-04 21:13:00 +00:00
Wayne Davison
dd667c2301 Call get_rule_prefix() with its new arg. 2005-02-04 21:12:56 +00:00
Wayne Davison
d727f0ff48 Fixed the MODIFIERS_MERGE_FILE define. 2005-02-04 00:48:18 +00:00
Wayne Davison
eb9b2e53c8 Changed delete_missing() to not limit the use of DEL_FORCE_RECURSE
to just --delete-during now that the other delete routines are using
delete_in_dir().
2005-02-03 19:19:39 +00:00
Wayne Davison
b6f06b8e8b Added an mflags arg to get_filter_tok(), add_filter_file(), and
add_filter().  This made for less flag conversion between various
MATCHFLG_* and XFLG_* values.  It also made it easy to fix a bug
in the handling of no-prefix per-directory include/exclude files.
We also use the new XFLG_OLD_PREFIXES and MATCHFLGS_FROM_CONTAINER
defines.
2005-02-03 19:00:20 +00:00
Wayne Davison
0a68f869d7 Call add_filter() and add_filter_file() with their new flag args. 2005-02-03 19:00:17 +00:00
Wayne Davison
3b2461cf2e - Got rid of a bunch of XFLG_* options.
- Added XFLG_OLD_PREFIXES and MATCHFLGS_FROM_CONTAINER defines.
2005-02-03 19:00:13 +00:00
Wayne Davison
346402ddbf Use the new negated exclude to filter out all non-dirs in a few
of the rsync commands.
2005-02-03 03:45:24 +00:00
Wayne Davison
44d60d5f83 Document the new "!" modifier for include/exclude filter rules (to
negate the match).
2005-02-03 03:37:02 +00:00
Wayne Davison
f2ae9e8583 Implemented a "!" modifier for filter rules that lets a rule trigger
on a non-matching pattern.
2005-02-03 03:36:58 +00:00
Wayne Davison
7c8e23bd9f Added MATCHFLG_NEGATE. 2005-02-03 03:36:55 +00:00
Wayne Davison
0752721dc3 Mention the latest delete optimization. 2005-02-03 02:01:22 +00:00
Wayne Davison
68a94ac30f Changed delete_files() to use the delete_in_dir() function, which
saves a ton of memory for a large set of files.
2005-02-03 02:01:20 +00:00
Wayne Davison
ee3751c8d7 - We now separate the user-specified top-dir flag (via the restored
FLAG_TOP_DIR) from the del-in-this-directory flag (FLAG_DEL_HERE).
  This was needed to properly handle -x in delete_in_dir().
- The delete_in_dir() function takes a slightly changed set of args.
- Always set the FLAG_DEL_HERE flags, not just for --delete-during.
2005-02-03 02:01:17 +00:00
Wayne Davison
ec33e0e6bd - Changed {XMIT,FLAG}_DEL_START back to {XMIT,FLAG}_TOP_DIR.
- Define FLAG_DEL_HERE.
2005-02-03 02:01:14 +00:00
Wayne Davison
31937d363b Call delete_in_dir() with its new args. 2005-02-03 02:01:11 +00:00
Wayne Davison
8982a89b24 In hlink_compare(), call f_name_cmp() directly instead of using
file_compare().
2005-02-03 01:19:03 +00:00
Wayne Davison
0492fdfb2e - Improved some comments.
- Changed the index passed to recv_generator() from "i" to "ndx".
- Call delete_in_dir() with its new args.
- During the redo phase, clear a bunch of options that might interfere
  with the generator deciding it needs to redo the file (for instance,
  --update-only could have interfered if --partial was specified).
2005-02-03 01:19:01 +00:00
Wayne Davison
14698a3a1a - Moved an optimization from file_compare() into f_name_cmp() (the one
that avoids doing a string-compare on two identical char pointers),
  making it just a wrapper for f_name_cmp().  Also made file_compare()
  static because everyone now calls f_name_cmp() directly.
- Improved the flist summary that is output at high verbosity.
- Improved delete_in_dir() to better handle the push/pop semantics
  based on the depth value that is now passed in as an arg (so that
  we don't have to parse it out of the paths each time).
2005-02-03 01:18:58 +00:00
Wayne Davison
8c2ffaf095 - If recv_files() is sent the index of a directory, complain about it
and die.
- Moved a few code snippets in recv_files() into better locations.
2005-02-03 00:19:40 +00:00
Wayne Davison
afd72c78bd If the generator sends us the index of a directory, generate an
error and die.
2005-02-02 17:15:22 +00:00
Wayne Davison
6bf822649b - Fixed a problem with the setting of the --recurse option from the
batch file.
- Save the state of the --dirs option in the batch flags in a way
  that is compatible with older protocol versions.
2005-02-02 09:40:45 +00:00
Wayne Davison
67dde16163 In read_sum_head: output the who_am_i() info in our error messages. 2005-02-01 16:42:01 +00:00
Wayne Davison
f1d5ba4005 Set am_sender to -1 until the end of the option parsing. This
lets who_am_i() output better values for the command-line
--filter/--include/--exclude options.
2005-02-01 09:46:42 +00:00
Wayne Davison
794b0a037f Changed who_am_i() to output "server" or "client" when am_sender
is negative.  This will only occur during the startup phase
before we know if we're the sender or not (e.g. when parsing
client-side --filter/--exclude/--include options).
2005-02-01 09:45:09 +00:00
Wayne Davison
c32edbe02e Make sure the %f expansion handles the new dir.root properly. 2005-02-01 09:23:59 +00:00
Wayne Davison
f3c3ed44e6 - Made flist_find() and receive_file_entry() static functions.
- Changed receive_file_entry() args.
- We now store the directory depth into file->dir.depth when
  receiving the file list.  This will be used to aid in the
  traversal of the file list on the receiving side for things
  such as the future --fuzzy option and better --delete-during
  processing.
- Fixed a bug when -R was used with "." as a source directory:
  subdirectories were not being promoted to FLAG_DEL_START when
  --delete-during was specified.
- Refer to the old basedir variable as dir.root.
- Got rid of the first-push code -- I decided that it wasn't
  the right thing to do for per-dir merge-file processing.
- Improved the flist_find() function to make it a little more
  optimal.  The new code no longer needs the inline function
  flist_up().
- In clean_flist() we now set two new values in the flist struct:
  "low" and "high".  These are used by the new flist_find().
- Tweaked the output_flist() function to output each entry's
  flags and to output the directory-depth on the receiving side
  in place of the directory-root (which is still output on the
  sending side).
2005-02-01 09:21:32 +00:00
Wayne Davison
f805730493 - Put "basedir" into a union "dir" and named it "root". The other
member of the union is "depth".
- Added members "low" and "high" to the file list structure (which
  are set when the list is cleaned).
- Got rid of the flist_up() inline function.
2005-02-01 09:21:30 +00:00
Wayne Davison
2b1366635d Refer to the old basedir variable as dir.root. 2005-02-01 09:21:28 +00:00
Wayne Davison
42f23f479d Fixed a typo in a variable name. 2005-02-01 08:12:00 +00:00
Wayne Davison
62bf783f06 Changed the "s" modifier to "w" for word-splitting tokens from a
merge filter file.  Also sprinkled some bf(...) macros into that
section.
2005-01-31 23:57:35 +00:00
Wayne Davison
0b2901b72d Changed the "s" modifier to "w" for a word-splitting merge file. 2005-01-31 23:51:54 +00:00
Wayne Davison
faa82484a5 - Mark references to command-line switches with the bf(...) macro.
- Changed some verb(...) macros to use other yodl idioms because
  yodl inserts way too much vertical whitespace surrounding the
  item.
- Some items weren't indenting enough in the manpage, though they
  were indenting fine in the HTML version, so used some creative
  idioms to get things to render well in both.
- Got rid of some empty lines in lists.
- Made several quote(...) items also tt(...).
2005-01-31 23:41:08 +00:00
Wayne Davison
4ccfd96cfe Tweaked one or more warning messages. 2005-01-31 19:13:19 +00:00
Wayne Davison
408aa7b24c Improved the exclude tests to make sure that the filter files
are interacting with --delete-during correctly.
2005-01-31 18:09:23 +00:00
Wayne Davison
776b9d1c00 Added "need_first_push" logic to delete_in_dir(). 2005-01-30 20:24:11 +00:00
Wayne Davison
c93fad5ee0 The --delete-during processing only happens during the first phase
(not the redo phase).  We also call delete_in_dir(NULL, NULL) to
make sure that all the local filter files get popped.
2005-01-30 10:06:18 +00:00
Wayne Davison
19b2a5d9fd delete_in_dir() now mananges the push/pop levels of nested
directories properly.
2005-01-30 10:01:21 +00:00
Wayne Davison
f1773e09ab - Now delete_in_dir() calls send_directory(), not send_file_name().
- Moved the local-list push/pop code out of send_directory() so that
  the callers (send_file_name() and delete_in_dir()) can call the
  push/pop functions themselves.  This is in preparation for
  delete_in_dir() getting fully correct push/pop semantics (for
  its --delete-during handling of per-dir filter files).
2005-01-30 09:12:55 +00:00
Wayne Davison
462c51d9a1 - Restored the io_error test to delete_files().
- Sanity check the dir_list value from send_file_list().
2005-01-30 07:35:13 +00:00
Wayne Davison
2430e98412 - Made delete_files() call send_file_list() and delete_missing()
instead of delete_in_dir().
- Tweaked check in front of delete_files() call.
2005-01-29 22:35:53 +00:00
Wayne Davison
78fc60cd29 If --recurse wasn't specified, turn off all the --delete* options. 2005-01-29 22:35:50 +00:00
Wayne Davison
864146de58 Tweaked check in front of delete_files() call. 2005-01-29 22:35:47 +00:00
Wayne Davison
45478cc79b - Improved the handling of -x with -K.
- Changed delete_in_dir() to only be used by the --delete-during
  option.
- Added delete_missing() that is used by both delete_files() and
  delete_in_dir().
- delete_files() still uses send_file_list(), but delete_in_dir()
  now uses send_file_name().
2005-01-29 22:35:44 +00:00
Wayne Davison
5454d22ad8 The --dirs was sending -k instead of -d. 2005-01-29 21:25:44 +00:00
Wayne Davison
dc1488ae47 - Document the new "/" modifier for -/+.
- "=" is no longer a valid separator for a filter rule.
2005-01-29 20:48:27 +00:00
Wayne Davison
0121a8ecad Renamed XFLG_ABS_PATH XFLG_ANCHORED2ABS. 2005-01-29 20:48:23 +00:00
Wayne Davison
7bc90b3066 Moved the module_id define into clientserver.c. 2005-01-29 20:48:20 +00:00
Wayne Davison
bf39270e0c - Renamed make_filter() to filter_rule().
- Added the "/" modifier to the -/+ filter rules to allow the
  rule to specify an absolute path (sets MATCHFLG_ABS_PATH).
- Added the passing of the xflgags to filter_rule() and key off
  XFLG_ANCHORED2ABS to prepend the current dirbuf value (was
  keing off MATCHFLG_ABS_PATH).
- We no longer allow a '=' to separate the filter rule from its
  arg (just a single space or an underscore).
- For triple verbose levels, mention when we look for a filter
  file even if we don't find it (used to only mention the file
  when it was found).
- A chrooted daemon process now includes /.cvsignore (inside the
  chrooted hierarchy) instead of $HOME/.cvsignore.
2005-01-29 20:48:17 +00:00
Wayne Davison
211bc43b6e - Moved the module_id definition from options.c to here.
- Use the new XFLG_ANCHORED2ABS name for the old XFLG_ABS_PATH
  define.
2005-01-29 20:48:14 +00:00
Wayne Davison
91c5833bd0 Change one call to add_cvs_excludes() to add_filter() to just add
the per-dir .cvsignore rule for protocols < 29.
2005-01-29 20:29:06 +00:00
Wayne Davison
8311f1c11e A minor change to the HAVE_GETPGRP code. 2005-01-28 23:00:58 +00:00
Wayne Davison
ae2836325f Fixed some typos. 2005-01-28 22:01:02 +00:00
Wayne Davison
a897af2cde Mention a few more things. 2005-01-28 21:48:32 +00:00
Wayne Davison
cc80022e84 Pass an unsigned character to isdigit(). 2005-01-28 21:32:20 +00:00
Wayne Davison
5a016db9b6 Don't allow the user to specify a filter file that is excluded
by a daemon's config options.
2005-01-28 21:28:08 +00:00
Wayne Davison
92e1aeede7 Got rid of an unreachable free() call. 2005-01-28 21:07:05 +00:00
Wayne Davison
f846a9bfe9 Cast each value referenced from the struct mallinfo to a long
in order to print it.
2005-01-28 21:05:50 +00:00
Wayne Davison
3db859e8b5 Don't set unsigned del_heir_name_len to -1 -- it's only used
if in_del_hier is non-zero, so it doesn't need to take on an
invalid value.
2005-01-28 21:03:50 +00:00
Wayne Davison
0eeb1cf83a Case uchar pointer to a char pointer when calling strlen(). 2005-01-28 21:02:15 +00:00
Wayne Davison
5f238db203 - Use "uchar" instead of "unsigned char".
- Tweaked an initializer to try to avoid a compiler warning.
2005-01-28 21:01:21 +00:00
Wayne Davison
422696201a Call the right stat function based on USE_STAT64_FUNCS. 2005-01-28 20:43:09 +00:00
Wayne Davison
58fef0ac38 Changed direct call to fstat() into a call to do_fstat(). 2005-01-28 20:41:36 +00:00
Wayne Davison
25e1181466 Use new USE_STAT64_FUNCS define. 2005-01-28 20:33:55 +00:00
Wayne Davison
5b5f7e3b59 - Use off_t if SIZEOF_OFF_T is 8.
- Define USE_STAT64_FUNCS if we defined STRUCT_STAT as
  "struct stat64".
2005-01-28 20:32:47 +00:00
Wayne Davison
dc3afaf6aa Changed "char" to "uchar" in delayed_bits's new_array() call. 2005-01-28 20:24:23 +00:00
Wayne Davison
1164f67827 Make use of new HAVE_STRUCT_STAT64 define. 2005-01-28 20:15:08 +00:00
Wayne Davison
c83a2c8ec5 Added a check for "struct stat64". 2005-01-28 20:15:06 +00:00
Wayne Davison
43d0f38b24 Do a better job defining an int32. Also define SIZEOF_INT32
instead of the (unused) LARGE_INT32 variable.
2005-01-28 19:03:16 +00:00
Wayne Davison
e95538ca2c - Changed the main core of system include files to use the same "#if"
idioms that configure uses.
- Use "#if" (not "#ifdef") for configure-defined macros.
- Use "#if !" (not "#ifndef") for configure-defined macros.
2005-01-28 18:50:54 +00:00
Wayne Davison
25ff04417e Use "#if" (not "#ifdef") for configure-defined macros. 2005-01-28 18:50:49 +00:00
Wayne Davison
63ecee4d1a Made log_open() static and made it die with an error if the
log-file can't be opened.
2005-01-28 17:42:21 +00:00
Wayne Davison
4c8f6b6a06 No need to call log_open() in start_accept_loop() because
rsync_module() calls log_init() before it gives up its privileges.
2005-01-28 17:33:57 +00:00
Wayne Davison
2161111900 Document the "max verbosity" setting. 2005-01-28 17:11:48 +00:00
Wayne Davison
24b0922b0e Document the --verbose (-v) option for the daemon. 2005-01-28 17:10:58 +00:00
Wayne Davison
186387301f - Moved read_only variable here from options.c
- Set read_only to 1 if the module is read-only.
- Make sure that the verbose level is 0 before we parse the client's
  options.
2005-01-28 17:10:16 +00:00
Wayne Davison
1bd9db74ba - Added --verbose option parsing to the daemon options.
- Moved read_only into clientserver.c.
2005-01-28 17:07:54 +00:00
Wayne Davison
df6933406f Got rid of unused mmap section. 2005-01-28 17:06:41 +00:00
Wayne Davison
d679c8390a Changed HAVE_OFF64_T to SIZEOF_OFF64_T. 2005-01-28 16:27:02 +00:00
Wayne Davison
d4daa7b68c Changed HAVE_OFF64_T to SIZEOF_OFF64_T. 2005-01-28 16:21:37 +00:00
Wayne Davison
44d98d6166 Improved the option summaries. 2005-01-28 09:55:36 +00:00
Wayne Davison
b3708acf27 Improved the option-descriptions in the --help text. 2005-01-28 09:55:18 +00:00
Wayne Davison
2c0fa6c5df More --delete-before improvements. 2005-01-28 08:01:33 +00:00
Wayne Davison
57f74bd1c2 One minor tweak to the --delete-before option-passing code. 2005-01-28 07:50:00 +00:00
Wayne Davison
598c409e63 Document --delete-before. 2005-01-28 07:39:59 +00:00
Wayne Davison
c6eb7fad68 Added back support for the --delete-before option so that future
verions of rsync can more easily change the default that --delete
implies and still support explicit --delete-before functionality
when interacting with older versions.
2005-01-28 07:39:09 +00:00
Wayne Davison
c561edaa72 Added a sanity check for the SIZEOF_INT64 define. 2005-01-28 06:51:44 +00:00
Wayne Davison
031fa9ad4d Use the new SIZEOF_INT64 define instead of INT64_IS_OFF_T. 2005-01-28 06:46:33 +00:00
Wayne Davison
d622d4bf30 - Switched the int64 code over to using the improved SIZEOF_*
macros.
- Define SIZEOF_INT64 to a value that is useable at compile time.
- Got rid of INT64_IS_OFF_T.
2005-01-28 06:45:16 +00:00
Wayne Davison
e32db5c9aa Switched the checks for "long long" and "off64_t" to use the
AC_CHECK_SIZEOF() macro since it now fully supports cross-
compiling.
2005-01-28 06:43:48 +00:00
Wayne Davison
4a6c209a13 Use SIGNED_CHAR_OK instead of HAVE_UNSIGNED_CHAR. 2005-01-28 02:01:18 +00:00
Wayne Davison
0d2aa5d9d7 - Made some of the tests work better when cross-compiling.
- Added descriptions for all config.h variables that had none.
- Changed HAVE_UNSIGNED_CHAR to SIGNED_CHAR_OK.
- Got rid of (the unused) HAVE_SHORT_INO_T.
- Changed version to 2.6.4cvs (long overdue).
2005-01-28 02:00:40 +00:00
Wayne Davison
e30b1fb8fd Added a few more details of changes since 2.6.3. 2005-01-28 01:56:50 +00:00
Wayne Davison
da1b6eeaf2 Mention the latest changes plus a few missed items. 2005-01-28 00:01:54 +00:00
Wayne Davison
01b835c237 Docment the new --delay-updates option. 2005-01-27 22:47:23 +00:00
Wayne Davison
48e1c8c69d Implement the new --delay-updates option. 2005-01-27 22:46:36 +00:00
Wayne Davison
f06e708282 Added the new --delay-updates option. 2005-01-27 22:46:14 +00:00
Wayne Davison
f0f7e760ae - Output the new flist time stats (when available).
- For protocol 29 and above, send the flist time stats to the
  client side (as needed).
2005-01-27 22:23:30 +00:00
Wayne Davison
31b4d25d10 Set the new stats.flist_buildtime and stats.flist_xfertime values. 2005-01-27 22:21:45 +00:00
Wayne Davison
d41988232e - Added a caveat to the definition of the int64 type.
- Added two time values to the stats struct.
2005-01-27 21:55:11 +00:00
Wayne Davison
880570f228 Added a missing newline to an error message. 2005-01-27 21:45:32 +00:00
Wayne Davison
72a90c750a Bumped the copyright year to 2005. 2005-01-27 21:42:56 +00:00
Wayne Davison
e1988bc744 Added .rsync-filter. 2005-01-25 18:16:34 +00:00
Wayne Davison
d6a3e37b83 If rsync is put in the background, output fewer progress-report
lines.
2005-01-25 17:16:13 +00:00
Wayne Davison
8261047b1e - Use the "--filter=._-" option instead of --exclude-from=- if the
protocol being saved is >= 29.
- Call the new get_rule_prefix() function to figure out the right
  rule prefix.
- Strip out the --filter and -f options from the cached command-line.
2005-01-25 12:13:53 +00:00
Wayne Davison
417b59997f - Moved the code that turns rule flags into chars into a new
function called get_rule_prefix().
- Don't pass the per-dir .cvsignore rule from -C for protocols < 29.
2005-01-25 12:10:31 +00:00
Wayne Davison
4366d2c428 In delete_files(), handle new DEL_NO_RECURSE flag (and use
renamed DEL_FORCE_RECURSE flag.
2005-01-25 12:07:13 +00:00
Wayne Davison
217cc3b045 - The call to delete_file() needs DEL_NO_RECURSE when handling
delete_before or delete_after or --dry-run will report too
  many deletions.
- Changed DEL_RECURSE to DEL_FORCE_RECURSE.
2005-01-25 12:05:20 +00:00
Wayne Davison
757e0a5445 Added DEL_NO_RECURSE and changed DEL_RECURSE to DEL_FORCE_RECURSE. 2005-01-25 12:02:08 +00:00
Wayne Davison
ddf6410130 Needed to call add_cvs_excludes() from one more code path. 2005-01-25 11:55:03 +00:00
Wayne Davison
7842418b7b Renamed several exclude-related functions/variables using new
filter terminology.
2005-01-25 10:39:14 +00:00
Wayne Davison
9624b86426 Mention the latest new options. 2005-01-25 04:00:31 +00:00
Wayne Davison
201a2fe5ff Added testing for --filter and merge-file features. 2005-01-25 03:18:29 +00:00
Wayne Davison
ed032a88b8 Mention that --del is a popt alias for --delete-during, so there's
no need to refuse "del" by name -- just refusing "delete-during" or
"delete*" is sufficient.
2005-01-25 03:09:06 +00:00
Wayne Davison
ae76a74043 Document the latest --delete options, including --delete-during. 2005-01-25 03:09:02 +00:00
Wayne Davison
3359acb8cb - Changed --delete to go back to defaulting to the delete-before
functionality.
- Got rid of --delete-before.
- Added --delete-during.
- Added a popt alias for --delete-during:  --del.
- Fixed a bug in the generation of the proper --delete options
  for the server.
- Generate an error if the user tries to specify both --delete-during
  and --delete-after.
2005-01-25 03:08:58 +00:00
Wayne Davison
a2b371cd52 Don't try to allocate zero bytes in push_local_excludes(). 2005-01-25 02:30:59 +00:00
Wayne Davison
dd69b3976a Document the new "filter" parameter. 2005-01-25 00:53:07 +00:00
Wayne Davison
16e5de84da Document --filter (-f) and -F, with lots of changes to the
include/exclude sections, including a little restructuring.
2005-01-25 00:53:03 +00:00
Wayne Davison
46fa602530 Some changes to support the new --filter option:
- Changed XFLG_WORDS_ONLY to XFLG_NO_PREFIXES.
- Added XFLG_DEF_EXCLUDE and XFLG_ABS_PATH.
- Added some new MATCHFLG_* values for the new merge-file support.
- Put the "slash_cnt" var (in the exclude_struct) into a union with
  the new megelist pointer.
2005-01-25 00:52:59 +00:00
Wayne Davison
aa4d3b4cc0 - Added parsing for --filter (-f) and -F.
- Changed the include/exclude calls to work with the new XFLG_* values.
2005-01-25 00:52:56 +00:00
Wayne Davison
73ed23495e Added the "filter" parameter. 2005-01-25 00:52:53 +00:00
Wayne Davison
c7d970f782 The calls into the exclude system changed a little for the new --filter
option:
- The special handling for cvs_exclude went away.
- Call push_local_excludes() and pop_local_excludes() instead of fiddling
  with the (no longer present) local_exclude_list var.
2005-01-25 00:52:50 +00:00
Wayne Davison
6dfd07d025 Implemented the core of the merge-file and per-dir merge-file support
for the --filter option.  Some noteworthy changes:
- Added push_local_excludes() and pop_local_excludes() to implement
  the changes needed as we go from directory to directory (this takes
  the place of the old local_exclude_list var that only handled the
  .cvsignore files).  These per-dir excludes are linked into the same
  exclude list as the global excludes.
- The exclude list is transferred as filter rules to an rsync that
  talks protocol 29 or above.  It limits itself to just include/exclude
  rules for older rsyncs.
2005-01-25 00:52:47 +00:00
Wayne Davison
e7bf7c0161 Some exclude changes for the new --filter option, including:
- Added module_dirlen var.
- Call set_excludes_dir() instead of setting exclude_path_prefix.
- Use the newest XFLG_* options.
2005-01-25 00:52:44 +00:00
Wayne Davison
f5a7b9e716 Improved the explanation for --omit-dir-times. 2005-01-25 00:47:35 +00:00
Wayne Davison
b951e023ec Moved the code that reads the extra byte for a modern inplace
transfer up nearer the code that reads the index.
2005-01-24 17:19:04 +00:00
Wayne Davison
3ea9bbd632 Optimized away the post-transfer directory loop in certain
circumstances.
2005-01-24 06:19:58 +00:00
Wayne Davison
aaca3daa27 Document --delete-before and --delete's new "during" behavior. 2005-01-24 01:41:57 +00:00
Wayne Davison
a51b316824 Added the delete-during handling (also selected with --delete) and
added --delete-before for the old delete logic.
2005-01-24 01:41:54 +00:00
Wayne Davison
928a00c474 Moved a call to add_cvs_exclude() from the delete code to one code-
path in this file.  This avoids a potential duplication of the
cvs-excludes that would occur in the old logic.
2005-01-24 01:41:51 +00:00
Wayne Davison
fa13f396d5 Added code to implement the delete-during handling. 2005-01-24 01:41:48 +00:00
Wayne Davison
3ab56a20ee Moved some of the delete code into flist.c since the generator now
calls it for the delete-during handling.
2005-01-24 01:41:45 +00:00
Wayne Davison
649f874292 Moved some of the delete code from receiver.c to here and implemented
the handling for delete_during (which is called from the generator).
2005-01-24 01:41:42 +00:00
Wayne Davison
90fdd89a0b Mention the --omit-dir-times option. 2005-01-24 00:56:37 +00:00
Wayne Davison
54e66f1d59 Document --omit-dir-times. 2005-01-24 00:51:38 +00:00
Wayne Davison
82471e68a8 Honor the new omit_dir_times var. 2005-01-24 00:51:34 +00:00
Wayne Davison
20fb7b9175 Added --omit-dir-times (-O). 2005-01-24 00:51:32 +00:00
Wayne Davison
859fdaad45 Mentioned the --dirs and --list-only options. 2005-01-24 00:34:53 +00:00
Wayne Davison
09ed309996 - Changed --keep-dirs (-k) into --dirs (-d).
- Document --list-only.
2005-01-24 00:17:42 +00:00
Wayne Davison
65e4cda059 - Changed --keep-dirs (-k) into --dirs (-d).
- Renamed keep_dirs to xfer_dirs.
- Mention --list-only in the --help.
2005-01-24 00:17:39 +00:00
Wayne Davison
7e037c4226 Renamed keep_dirs, "xfer_dirs". 2005-01-24 00:17:36 +00:00
Wayne Davison
f636c38440 Document the new --keep-dirs option. 2005-01-23 16:49:09 +00:00
Wayne Davison
b98f040ef2 Go back to requiring -r for deletes to happen. 2005-01-23 07:27:01 +00:00
Wayne Davison
e57211c544 When an option defined with POPT_ARG_VAL is being refused, we must
change it to POPT_ARG_NONE or it won't be refused.
2005-01-23 01:25:36 +00:00
Wayne Davison
48a1ff0d45 - Use the new delete_before var.
- Check the "keep_dirs" var instead of "recurse" to decide if
  delete is appropriate.
2005-01-22 22:48:40 +00:00
Wayne Davison
032dcf74b0 Check the "keep_dirs" var instead of "recurse" to decide if
delete-after is appropriate.
2005-01-22 22:48:37 +00:00
Wayne Davison
51d4839861 - We now set a delete_before variable for the --delete option.
- Reordered some of the options in the --help list.
- Made the popt-handling of the delete options simpler.
- Parse the new --keep-dirs option.
- Parse the new --list-only option.
- Set recurse to -1 (infinite) for the -r and -a options.
- Set keep_dirs for --list-only.
2005-01-22 22:48:34 +00:00
Wayne Davison
9f125ea7c1 - Implemented a new handling of the recurse variable: if it is
< 0, it specifies infinite recursion, otherwise it contains a
  count of how many levels of recursion we will allow.
- If the user is processing/listing a non-recursive directory/
  arg, send the contents.
2005-01-22 22:48:31 +00:00
Wayne Davison
9bcb25958d - Mustn't override a user-specified list_only value.
- Moved the computing of the options for the server down until
  after we've figured out the protocol_version for the transfer.
- If we're talking to a protocol-29 server in list-only mode,
  force the new --list-only mode (which avoids the -r with
  --exclude="/*/*" kluge).
- Output the options we sent to the daemon if verbose > 1.
2005-01-22 22:48:27 +00:00
Wayne Davison
866925bfb7 Changed the order of a few of the options in the options summary. 2005-01-22 20:32:03 +00:00
Wayne Davison
f8b3c05311 Mustn't override a user-specified list_only value. 2005-01-22 20:28:17 +00:00
Wayne Davison
353f272434 Changed a comment. 2005-01-22 20:27:22 +00:00
Wayne Davison
3d54c6ec46 Moved the /proc/mounts literal string nearer to the top. 2005-01-22 08:11:43 +00:00
Wayne Davison
71e27c463d - Changed XMIT_TOP_DIR to XMIT_DEL_START.
- Changed FLAG_TOP_DIR to FLAG_DEL_START.
2005-01-21 00:34:37 +00:00
Wayne Davison
8c48382049 Don't mention when the file-list is first allocated, just when it
expands.
2005-01-20 23:57:35 +00:00
Wayne Davison
11781089d1 In delete_file(): got rid of DEL_NO_RECURSE code and added
DEL_RECURSE code.  Improved the verbose output of a recursively
deleted directory when --dry-run is specified.
2005-01-20 23:51:57 +00:00
Wayne Davison
d97fd43a72 Decided that delete_in_dir()'s call to delete_file() would be
better using DEL_RECURSE.
2005-01-20 23:51:55 +00:00
Wayne Davison
f5ea4b3b39 Changed DEL_NO_RECURSE to DEL_RECURSE. 2005-01-20 23:51:52 +00:00
Wayne Davison
f227ffe4b9 Moved the dry_run check in set_perms() so that it only triggers if
we don't have a stat-buffer (and returns 1, not 0).
2005-01-20 23:01:34 +00:00
Wayne Davison
027428eb1d Got rid of the erroneous --dry-run short-circuit in the directory
handling.
2005-01-20 22:59:54 +00:00
Wayne Davison
15778afbdc In set_modtime(), the verbose message should be output even if
--dry-run was specified.
2005-01-20 22:58:30 +00:00
Wayne Davison
d06f63287e - Got rid of the uint64 typedef.
- Changed the dev/inode vars to use int64.
2005-01-20 22:43:32 +00:00
Wayne Davison
1490812ab2 Switched uint64 vars over to int64. 2005-01-20 22:42:47 +00:00
Wayne Davison
707415d4fc Use int64 instead of uint64. 2005-01-20 22:37:38 +00:00
Wayne Davison
9cea6ef1b6 Improved a confusing sentence in the description of subcomponent
include/exclude matching.
2005-01-20 19:31:42 +00:00
Wayne Davison
48ea74bf01 When outputting the file list created for the delete pass, identify
it as such.
2005-01-20 00:53:15 +00:00
Wayne Davison
026deaf759 Added an example of running mnt-excl remotely via ssh for a pull. 2005-01-19 21:07:09 +00:00
Wayne Davison
4c59971194 A perl script that outputs excludes for all mount points that affect
the supplied source dir (or all mount points if the arg is omitted).
The excludes are appropriately anchored relative to the supplied dir,
and honor rsync's trailing-slash idiom.
2005-01-19 21:00:26 +00:00
Wayne Davison
fd8571c2c9 Mention a change in the verbose output when deleting directories. 2005-01-19 20:32:25 +00:00
Wayne Davison
dd096ae080 - Updated delete_file() to take a flag arg that makes it more
flexible.  Optimized away a stat() call since the caller knows
  if the item to delete is a directory or not.
- Tweaked delete_file()'s "deleting ..." messages to include a
  trailing slash when we're deleting a directory.
- No need for conditional code around do_lstat() anymore.
2005-01-19 20:11:03 +00:00
Wayne Davison
eb1accaa91 Define the new DEL_* flags. 2005-01-19 20:11:00 +00:00
Wayne Davison
7e38410e47 - Moved write_sum_head() to io.c.
- Use the new delete_file() calling syntax.
2005-01-19 20:10:57 +00:00
Wayne Davison
d336388403 Got rid of delete_one() since we can (and do) use the updated
delete_file() call now.
2005-01-19 20:10:53 +00:00
Wayne Davison
c207d7ec62 Moved write_sum_head() here from generator.c. 2005-01-19 20:10:50 +00:00
Wayne Davison
018b28328c No need for conditional code around do_lstat() anymore. 2005-01-19 19:30:29 +00:00
Wayne Davison
0957a7463e When SUPPORT_LINKS is not defined, we now go ahead and provide
the do_lstat() function and just have it call do_stat().
2005-01-19 19:29:20 +00:00
Wayne Davison
c72f5bd9c4 A slight simplification to the no-implied-dirs change. 2005-01-19 00:34:13 +00:00
Wayne Davison
0f57446da7 Use the new "keep_dirs" var instead of separately checking the
"recurse" and "files_from" vars.  This also simplifies the case
where the code wants to send the implied dirs without recursing.
2005-01-19 00:24:35 +00:00
Wayne Davison
3a90ea0acd - Added new int, keep_dirs, which is set if either recurse or
files_from was specified.
- Pass the the sender the --no-implied-dirs option if --relative
  was specified (or implied) and the sender is not the client.
2005-01-19 00:23:32 +00:00
Paul Green
58af2f958c Fix typo in handling of lchown when the host operating system does
not implement it.  It should get mapped to chown.
2005-01-18 21:19:42 +00:00
Wayne Davison
a8fd4161bb Mention the latest changes. 2005-01-17 23:55:15 +00:00
Wayne Davison
53f8519a38 For --inplace over protocol-version 29 or greater, read the
type the type of basis file the generator is using from the
socket and set the new updating_basis_file var.
2005-01-17 23:11:26 +00:00
Wayne Davison
eb162f3b0a Mention the change in restrictions for --inplace. Also talk about
how --backup makes an --inplace transfer more optimal.
2005-01-17 23:11:22 +00:00
Wayne Davison
4ce838e1f1 We don't need to complain about --inplace being combined with one
of the --FOO-dest options anymore.
2005-01-17 23:11:18 +00:00
Wayne Davison
a36ffd3910 Changed the checks for --inplace to use the new updating_basis_file
variable.
2005-01-17 23:11:13 +00:00
Wayne Davison
17b5b32f75 For --inplace over protocol-version 29 or greater, tell the
sender what kind of a basis file we've selected.
2005-01-17 23:11:05 +00:00
Wayne Davison
9b919d590a - Moved read_sum_head() to io.c (because the generator uses it too).
- Tweaked the read_size var (formerly map_size) that gets passed to
  map_file().
2005-01-17 22:51:29 +00:00
Wayne Davison
80264051d8 Tweaked the read_size var (formerly map_size) that gets passed to
map_file().
2005-01-17 22:51:27 +00:00
Wayne Davison
188fed9570 Moved read_sum_head() here from sender.c (because the generator uses it
too) and improved it with better error checking.
2005-01-17 22:51:24 +00:00
Wayne Davison
eae7165c79 Make sure that we don't compute a block size larger than MAX_BLOCK_SIZE. 2005-01-17 22:51:21 +00:00
Wayne Davison
54281fe733 - Changed the map_size parameter to map_file() to be an int32 named
"read_size".
- Changed some int vars in map_ptr() needed to be int32 vars.
- All callers expect map_ptr() to return back the full "len" bytes,
  so we never shorten this value, even near EOF--the read will
  just get zero-padded, as needed.
- Die with an error if someone calls map_ptr() with a len < 0, or
  if read_size is computed as a value < 0.
2005-01-17 22:51:17 +00:00
Wayne Davison
2b2ea368aa - Incremented the PROTOCOL_VERSION to 29.
- Added define for MAX_BLOCK_SIZE.
- Reorder the variables in the structure defs to sort by size.
- Some vars in map_struct needed to be int32 instead of int.
2005-01-17 22:51:15 +00:00
Wayne Davison
67a28eb256 Got rid of an unneeded assert(). 2005-01-17 22:25:53 +00:00
Wayne Davison
f5d96a6f80 Added a commented-out RSYNC initialization that uses valgrind. 2005-01-17 22:24:08 +00:00
Wayne Davison
44ac015598 Put double-quotes around the --rsync-path arg. 2005-01-17 22:23:09 +00:00
Wayne Davison
89a9c0545e Collapsed two sed invocations into one. 2005-01-17 06:00:44 +00:00
Wayne Davison
3b26bba0c4 Fixed an off-by-one comparison against MAX_BASIS_DIRS. 2005-01-15 21:23:04 +00:00
Wayne Davison
2be2fb3ed3 Use the new FNAMECMP_BASIS_DIR_HIGH to improve a compare-dest check. 2005-01-15 21:17:39 +00:00
Wayne Davison
e341588a8a Define FNAMECMP_BASIS_DIR_LOW and FNAMECMP_BASIS_DIR_HIGH instead of
FNAMECMP_BASIS_DIR.
2005-01-15 21:17:36 +00:00
Wayne Davison
c56595d749 Make sure that the generator sent us a valid index into basis_dir[]. 2005-01-15 21:14:27 +00:00
Wayne Davison
ce0b384fa6 Made basis_dir_cnt non-static. 2005-01-15 21:12:58 +00:00
Wayne Davison
dfd7d541b0 Made compare_dest non-static. 2005-01-15 20:54:25 +00:00
Wayne Davison
ded4daf049 Some inplace-checking code should have been inside the #ifdef that
handles the case where --inplace cannot be supported.
2005-01-15 20:22:54 +00:00
Wayne Davison
361428213b Simplified the logic in allow_access() and tweaked some whitespace. 2005-01-15 20:06:48 +00:00
Wayne Davison
12a79db2f6 Simplified one "if" that checks if one of the --FOO-dest options
was specified.
2005-01-15 04:40:06 +00:00
Wayne Davison
e8b155a3be Improved the docs on --delete and --delete-after. 2005-01-14 19:49:35 +00:00
Wayne Davison
716b46c550 - We now remove the DEST~old~ dir instead of renaming it to DEST~new~.
- Improved the usage message and added an introductory comment.
2005-01-14 19:23:20 +00:00
Wayne Davison
9d954dca8c Make sure that the presence of a partial-dir file is noted, even
if --whole-file is in effect.  Also needed to force statret to 0
when using a partial-dir file.
2005-01-14 18:20:46 +00:00
Wayne Davison
7162c65df7 We also need the "name pipe" from the generator to the receiver
when --partial-dir was specified.
2005-01-14 18:18:31 +00:00
Wayne Davison
bd9fca4708 For the "unexpected tag" or "multiplexing overflow" messages, we
now output who_am_i() so we know who had the problem.
2005-01-14 18:17:32 +00:00
Wayne Davison
14d496cc8b Aid forward-compatibility in the include/exclude syntax by putting
a "- " in front of any name that starts with a '+' or a '-' and would
otherwise be unprefixed (the old code only did this if the '+' or '-'
was followed by a space).
2005-01-13 22:01:56 +00:00
Wayne Davison
106a8ad918 - Allow multiple source paths to be specified (and checked).
- Allow spaces and a few other extra chars in file names.
- For safety, disallow any option that takes an arg.  This should
  be improved in the future because it blocks options such as
  --block-size=N, but without this rule the user could specify
  something like --files-from=FILE or --backup-dir=DIR and have
  it affect files outside the desired SUBDIR restriction.
- Switched to SSH_CONNECTION from the deprecated SSH_CLIENT.
- Strip "::ffff:" from the start of an IP from SSH_CONNECTION.
2005-01-12 19:20:07 +00:00
Wayne Davison
44a82a175d This is Joe Smith's rrsync (restricted rsync) perl script. 2005-01-12 18:48:26 +00:00
Wayne Davison
99248631aa A simple Makefile. 2005-01-11 18:37:37 +00:00
Wayne Davison
2836ee9b02 A debug program to help diagnose data-transfer corruption problems. 2005-01-11 18:36:31 +00:00
Wayne Davison
d82773ffe9 Fixed the file_checksum1() function that is compiled only when
TEST_MDFOUR is defined:  it did not have the fix that the main
rsync code got back in protocol 27 to properly handle files
that are a multiple of 64-bytes long.
2005-01-10 20:52:08 +00:00
Wayne Davison
ec626b3f0e Two more fixes. 2005-01-10 10:08:59 +00:00
Wayne Davison
997d9ea67f Added a "overwriting_basis" arg to finish_transfer(). 2005-01-10 10:03:12 +00:00
Wayne Davison
aec6b9f86f - Call finish_transfer() with its new arg. This ensures that we only
create a backup file if we're about to overwrite the basis file.
- Only clear make_backups for the redo phase if partial_dir isn't set.
2005-01-10 10:03:10 +00:00
Wayne Davison
d45898df80 Call finish_transfer() with its new arg. 2005-01-10 10:03:06 +00:00
Wayne Davison
b0da4b23a0 Moved the reading of the final MSG_DONE message here from main.c
(this message comes from the receiver).  This ensures that any
redo-pass files and delete-after processing are known to be done
prior to the start of our hard-link and dir-time-munging loops.
2005-01-10 00:31:55 +00:00
Wayne Davison
bf18b7ca67 Moved the reading of the final MSG_DONE message from here to
generator.c (the message comes from the receiver).  This ensures
that any redo-pass files and delete-after processing are known to be
done prior to the start of the hard-link and dir-time-munging loops.
2005-01-10 00:31:55 +00:00
Wayne Davison
cc17fbfe7d Mention new atomic-rsync script. 2005-01-06 17:15:36 +00:00
Wayne Davison
fa170b2e5a A perl script to effect an atomic transfer of a set of files. 2005-01-06 17:13:31 +00:00
Wayne Davison
c61ba345f2 Decided that a cross-compling configure should default the
chown-follows-symlinks check to "yes".
2005-01-03 23:01:19 +00:00
Wayne Davison
ae09fb1f91 Improved the last addition. 2005-01-03 22:49:14 +00:00
Wayne Davison
70a2c84cd2 If lchown() is not available, we only skip the call to chown() for a
symlink if it will try to follow the symlink (as a normal OS should).
2005-01-03 22:47:55 +00:00
Wayne Davison
21524e3083 - Added a test to see if chown() follows symlinks.
- Check for getpgrp() and tcgetpgrp().
2005-01-03 22:42:55 +00:00
Wayne Davison
fbe2aba2e7 Mention lchown() fix. 2005-01-03 21:07:02 +00:00
Wayne Davison
a41a1e8718 If there is no lchown(), don't try to set the user & group of a symlink. 2005-01-03 21:05:39 +00:00
Wayne Davison
051547603a Moved kluged (conditional) define of lchown from rsync.h to syscall.c. 2005-01-03 21:03:33 +00:00
Wayne Davison
80a25bb880 Backed out changes to send_deflated_token() that surrounded the
call to deflate(..., Z_INSERT_ONLY) -- the underlying bug was
caused by the zlib code not handling Z_INSERT_ONLY in the case
where the server has disabled compression.
2005-01-02 09:08:59 +00:00
Wayne Davison
0301b334c7 Fixed Z_INSERT_ONLY support in deflate_stored(). 2005-01-02 09:03:44 +00:00
Wayne Davison
1492b4b2b2 The deflate_stored() function needed to support Z_INSERT_ONLY. 2005-01-02 08:49:47 +00:00
Wayne Davison
5b7bcac260 In send_deflated_token(), the section that handles "token != -2"
now breaks up the calls to deflate() into CHUNK_SIZE chunks, just
like the other sections of the code.
2005-01-02 00:55:55 +00:00
Wayne Davison
7fcbf9e43e - Use an int32 for the each block-size variable.
- Fixed a problem in send_deflated_token() where the data we are
  compressing might not finish processing in one call.
2005-01-01 21:08:20 +00:00
Wayne Davison
6c495e0da4 - Use an int32 for the each block-size variable.
- Fixed a potential overflow in the map_size calculation.
2005-01-01 21:08:17 +00:00
Wayne Davison
a06b419d42 Use an int32 for the each block-size variable. 2005-01-01 21:08:14 +00:00
Wayne Davison
a255c592e8 - Use an int32 for the each block-size variable.
- Improved the layout and error-checking of the code that
  calculates the block-size and the number of checksum bits.
2005-01-01 21:08:11 +00:00
Wayne Davison
7aac6604c4 - Use an int32 for the each block-size variable.
- Renamed the local block_size arg to blk_size (to avoid
  confusion with the global block_size variable).
2005-01-01 21:08:07 +00:00
Wayne Davison
deb5bf1dff - Use an int32 for each checksum length variable.
- Simplified some of the code, removing a useless memcpy().
2005-01-01 21:08:05 +00:00
Wayne Davison
3dfe6e97a7 Since lp_bind_address() can't return NULL, we need to check if it is
an empty string and ignore it when it is.
2004-12-31 09:41:04 +00:00
Wayne Davison
43bab4035b A minor improvement to the just-committed code. 2004-12-31 00:41:32 +00:00
Wayne Davison
ef0c03ff70 The code that tries to read an error from the socket in an abnormal-
exit situation was properly forcing the io_timeout value down to 30
seconds, but failing to set the select_timeout value.
2004-12-31 00:39:59 +00:00
Wayne Davison
ad54dcc827 Set select_timeout if the per-module timeout value was lower than
the default select_timeout value.
2004-12-31 00:35:03 +00:00
Wayne Davison
c0ab28d1d9 If we send --files-from to the remote server and relative-paths
are not enabled, we need to also send --no-relative.
2004-12-22 09:10:08 +00:00
Wayne Davison
5b2f48da27 Mention latest fix. 2004-12-16 22:48:31 +00:00
Wayne Davison
132fcf36b2 The "ignore nonreadable" daemon parameter no longer affects
symlinks that are being copied, even if they point nowhere.
2004-12-16 22:47:36 +00:00
Wayne Davison
4571df58c6 Got rid of the rare failure caused by a directory-time mismatch. 2004-12-14 19:41:19 +00:00
Wayne Davison
f6b384d41f Don't call do_lstat() unless SUPPORT_LINKS is defined. 2004-12-13 17:22:32 +00:00
Wayne Davison
c259892c3a Document the client version of the --port option. 2004-12-08 17:30:40 +00:00
Wayne Davison
b471329591 Allow --port to be used in client mode (as well as daemon mode). 2004-12-08 17:29:54 +00:00
Wayne Davison
3add5835db If rsync_port is 0, set it to RSYNC_PORT. 2004-12-08 17:11:15 +00:00
Wayne Davison
cf510ad2c5 Switching to a better rsync_port fix. 2004-12-08 17:09:59 +00:00
Wayne Davison
696a8d6191 Document the new "address" global option. 2004-12-06 22:45:10 +00:00
Wayne Davison
01f8a1155f Made --port and --address point the user at the relevant global
options in the rsyncd.conf manpage.
2004-12-06 22:45:07 +00:00
Wayne Davison
986aaaaa4b Check the global option "address" if the user didn't specify
an --address option when starting the daemon.
2004-12-06 22:45:03 +00:00
Wayne Davison
c96ee2310d Added support for the "address" option. 2004-12-06 22:45:00 +00:00
Wayne Davison
76cb2a3a4f Set default port value for a :: file-spec without a port number. 2004-12-06 17:57:06 +00:00
Wayne Davison
9bef934c76 Improved the examples for the --relative option. 2004-12-03 01:31:24 +00:00
Wayne Davison
85f14172dc Check the return value of flush_write_file() and report an error
if it reports failure.
2004-12-02 17:16:19 +00:00
Wayne Davison
4539c0d79f Improved the description of the --update option. 2004-11-30 20:43:06 +00:00
Wayne Davison
c3131af90a Improved some of the descriptions. 2004-11-30 06:07:50 +00:00
Wayne Davison
c2c14fa26e Removed some redundant words in a sentence. 2004-11-29 17:09:31 +00:00
Wayne Davison
e49f61f5fc Make some of the --*-dest comments clearer and more complete. 2004-11-27 22:09:33 +00:00
Wayne Davison
22f5bd5e35 Improved some of the items. 2004-11-27 21:55:05 +00:00
Wayne Davison
7a1b73b983 Mentioned the latest enhancements. 2004-11-27 18:26:30 +00:00
Wayne Davison
0c56b1add7 Allow "port" to be specified in the rsyncd.conf file. 2004-11-27 18:24:12 +00:00
Wayne Davison
1e60969646 Added tests for multiple --compare-dest options and --copy-dest. 2004-11-27 17:59:48 +00:00
Wayne Davison
ee29752217 Added support for multiple --*-dest options. 2004-11-27 17:56:58 +00:00
Wayne Davison
e012f858d6 - Added parsing for --copy-dest.
- Added support for multiple --*-dest options.
2004-11-27 17:52:51 +00:00
Wayne Davison
c3fad2e227 The compare_dest variable changed. 2004-11-27 17:52:49 +00:00
Wayne Davison
b7e8628c4b - Added support for --copy-dest, which behaves like --link-dest,
but it copies the identical files instead of hard-linking them.
- Added support for multiple --*-dest options.
2004-11-27 17:52:47 +00:00
Wayne Davison
e4977b0b9f - Define MAX_BASIS_DIRS.
- Renamed FNAMECMP_CMPDEST to FNAMECMP_BASIS_DIR.
2004-11-27 17:52:45 +00:00
Wayne Davison
b127c1dc58 Document --copy-dest and the support for multiple --*-dest options. 2004-11-27 17:52:42 +00:00
Wayne Davison
07bff66fb5 Fixed a socket-data conflict when verbosity is >= 2 and the
files-from list is coming from a remote receiver.
2004-11-20 17:10:54 +00:00
Wayne Davison
4a888ae6d4 Mention latest fix. 2004-11-20 07:23:20 +00:00
Wayne Davison
a0a33ee506 Call set_msg_fd_in() during the early phase of being a client sender
so that we monitor the socket for any messages that it might send to
us (and thus avoid a potential hang when verbosity is high).
2004-11-20 07:08:44 +00:00
Wayne Davison
98f8c9a5e5 Some minor improvements to read_msg_fd() made it safe to use both
set_msg_fd_in() and read_msg_fd() during the early phase of being
a client sender (up through the sending of the file list).  This
makes sure that the sender monitors the socket from the receiver
for any messages that it might send to us, and thus avoids a hang
when verbosity is high.
2004-11-20 07:07:37 +00:00
Wayne Davison
1f69bec480 Mention that the --bwlimit may now be combined with --daemon. 2004-11-17 19:41:09 +00:00
Wayne Davison
8f1b4f3642 - Mention the latest enhancements.
- Aged the 2.6.3 news into OLDNEWS.
2004-11-17 19:35:11 +00:00
Wayne Davison
ca39ebf9fb Aged the 2.6.3 release news. 2004-11-17 19:34:31 +00:00
Wayne Davison
9fb0844100 - Added the --bwlimit option to the options that are handled in
combination with --daemon.  This value is both a default bwlimit
  value and a maximum limit if the client asks for something larger.
- Enabled popt support for option aliases.
2004-11-17 19:29:20 +00:00
Wayne Davison
bdf278f7a5 Separate the daemon options from the normal client options. 2004-11-17 19:11:53 +00:00
Wayne Davison
c8f2f8572f Tweaked the error code for a pipe() failure. 2004-11-13 22:32:34 +00:00
Wayne Davison
5d54f33962 Mentioned the new fork() check. 2004-11-13 21:50:56 +00:00
Wayne Davison
ba449e444b Die with an appropriate error if do_fork() fails. 2004-11-13 21:49:26 +00:00
Wayne Davison
87ba7282f6 Mention the new --max-size option. 2004-11-11 01:45:31 +00:00
Wayne Davison
7d1bfaf7be Obey the max_size setting. 2004-11-11 01:45:28 +00:00
Wayne Davison
7d5acf1d44 Added the --max-size option. 2004-11-11 01:45:25 +00:00
Wayne Davison
3610c4583a Document --max-size. 2004-11-11 01:45:22 +00:00
Wayne Davison
41cfde6be3 Checking in the g2r-basis-filename patch that ensures that the receiver
uses the same basis file that the generator used (avoiding a duplicate
check that could cause a hang if a compare-dest file was a named pipe).
2004-11-03 20:30:31 +00:00
Wayne Davison
34bde8d54a Always include lib/snprintf.o when we include lib/compat.o. 2004-11-02 16:47:15 +00:00
Wayne Davison
1ed55e3e3e Mention latest fix. 2004-10-27 06:35:50 +00:00
Wayne Davison
f80a8520e8 Don't ever call make_backup() if we're removing a destination directory
(just remove it).
2004-10-27 06:34:13 +00:00
Wayne Davison
740bab942d Mention the latest bug-fix. 2004-10-18 20:44:09 +00:00
Wayne Davison
08b1b4860f Fixed an off-by-one error in the handling of --max-delete=N. 2004-10-18 20:41:57 +00:00
Wayne Davison
18ea5dc0d7 Mention new option parsing. 2004-10-14 17:11:28 +00:00
Wayne Davison
3ac7f5d4c1 Separate the daemon options so that the user can't mix client options
with daemon options and visa versa.
2004-10-14 17:08:15 +00:00
Wayne Davison
ad71500818 It seems that some popt releases don't define POPT_TABLEEND, so don't
use it.
2004-10-14 09:11:12 +00:00
Wayne Davison
b2ad840a6b Decided we don't need the build_gen target after all. 2004-10-12 20:08:51 +00:00
Wayne Davison
8db7cc2cff - Got rid of some awkward spacing in the long_options table.
- Use the POPT_TABLEEND macro to end the long_options table.
- Improved the count_args() function to accept a NULL pointer.
- Simplified the code that sets *argc using count_args().
2004-10-11 10:43:25 +00:00
Wayne Davison
ac1541f4b7 Mention the latest changes. 2004-10-10 20:33:07 +00:00
Wayne Davison
09e2bbce8a Call flush_write_file() in _exit_cleanup() if we are keeping a
partially-received file.
2004-10-10 20:31:54 +00:00
Wayne Davison
73496a36a1 Handle systems where the makedev() macro is named mkdev(). 2004-10-08 21:27:22 +00:00
Wayne Davison
8303cc1021 A new target, build_gen, works like gen w/o man-page generation. 2004-10-08 19:52:38 +00:00
Wayne Davison
ab759cd27b Improved an error message by using rsyserr(). 2004-10-07 17:02:39 +00:00
Wayne Davison
64444de582 Mention in -a's usage message that -H isn't implied. 2004-10-07 17:00:36 +00:00
Wayne Davison
e425fbe85d Re-enable the "!" token-handling in a .cvsignore file. 2004-10-06 00:10:08 +00:00
Wayne Davison
4f4b2f0927 The device-handling code is no longer omitted based on HAVE_MKNOD
(this is because do_mknod() might be using a different function
to handle fifos and sockets without the help of mknod().
2004-10-01 06:58:23 +00:00
Wayne Davison
da6eb9d123 Improved do_mknod() so that it handles creating a fifo file
and a socket file when mknod() itself does not.
2004-10-01 06:56:14 +00:00
Wayne Davison
1b15e07e99 Make sure that all programs that use syscall.o also include
lib/compat.o so that we can use strlcpy().
2004-10-01 06:53:26 +00:00
Wayne Davison
e49d720081 - Check if struct sockaddr_un has a sun_len member.
- Check if mknod() can make a fifo file.
- Check if mknod() can make a socket file.
2004-10-01 06:51:34 +00:00
Wayne Davison
3267d6a9ce Some systems need do_mkstemp() to use setmode() to set O_BINARY. 2004-10-01 02:34:22 +00:00
Wayne Davison
3ba2c330e1 Check for the setmode() function. 2004-10-01 02:31:10 +00:00
Wayne Davison
618c8a73db Preparing for release of 2.6.3 2004-09-30 16:36:42 +00:00
Wayne Davison
aa0ea373cd Mention the enhancement that was made (quite a while ago) to the
daemon's wildcard-expansion limit (formerly 1000 items, now memory
limited).
2004-09-30 10:46:43 +00:00
Wayne Davison
6c3fda83ba Refined the text of a few of the news items. 2004-09-30 09:58:39 +00:00
Wayne Davison
a3571c6cce - Mention the fix for lost output with 2>&1.
- Prepare the file for the 2.6.3 final release.
2004-09-30 09:37:38 +00:00
Wayne Davison
6fcedb7dbe Mention the (anticipated) 2.6.3 release date. 2004-09-30 09:36:29 +00:00
Wayne Davison
18882701d2 Set our stderr output to blocking I/O to avoid any loss of output. 2004-09-29 17:58:07 +00:00
Wayne Davison
30c041f9ad Changed the errors concerning the secrets file to output with FLOG
instead of FERROR.
2004-09-24 17:04:05 +00:00
Wayne Davison
be7cf82299 - Make sure that match_address() always restores the "tok" string,
even on error.
- Turned the various FERROR messages into (the more proper) FLOG.
2004-09-24 16:50:07 +00:00
Wayne Davison
fde045cd77 Turned the various FERROR messages into (the more proper) FLOG. 2004-09-24 16:39:41 +00:00
Wayne Davison
183150b741 Added some more --inplace info (i.e. it implies --partial and conflicts
with 3 basis-file-affecting options).
2004-09-23 21:15:04 +00:00
Wayne Davison
a2570930e8 Made the refused-option message clearer, like Paul suggested. 2004-09-23 17:39:05 +00:00
Wayne Davison
fdb6716c0f Create a FIFO using mkfifo. 2004-09-23 16:34:43 +00:00
Wayne Davison
a20a88d235 Assume that gettimeofday() takes two arguments when cross-compiling. 2004-09-23 16:00:44 +00:00
Wayne Davison
48d3ff94c9 Only output major/minor info for a character/block device, not for
a FIFO or a socket.
2004-09-23 05:33:48 +00:00
Wayne Davison
a33857da09 Mention that --partial-dir now sets an exclude that helps to avoid
losing the partial data when deleting, and avoid copying any partial
data from the sender.
2004-09-22 04:14:43 +00:00
Wayne Davison
13791b1eeb If the partial-dir value is relative, add a directory-exclude for it
to the end of the user's exclude list.
2004-09-22 04:12:13 +00:00
Wayne Davison
9a5e37fca8 In get_exclude_tok(), if XFLG_DIRECTORY was passed in the xflags,
set MATCHFLG_DIRECTORY in the mflags we return.
2004-09-22 04:11:15 +00:00
Wayne Davison
3e976df0fb Added XFLG_DIRECTORY define. 2004-09-22 04:10:10 +00:00
Wayne Davison
42afed9c1a Preparing for release of 2.6.3pre2 2004-09-21 16:10:35 +00:00
Wayne Davison
37c36e2692 Mention the daemon-socket-connection change. 2004-09-21 15:47:20 +00:00
Wayne Davison
7fbc7031f4 Mentioned a couple more changes. 2004-09-21 15:31:33 +00:00
Wayne Davison
9f004a9ea9 The delete_one() function no longer needs to handle the case where
it thinks it is removing a directory and it is really removing a
symlink.
2004-09-21 09:24:06 +00:00
Wayne Davison
23f4587f2b - Turned readlink_stat() into a static function.
- Made readlink_stat() no longer honor keep_dirlinks.
- The make_file() function now checks keep_dirlinks late in the
  function so that it only transforms a symlink to a local dir
  into a directory if the receiver also has a directory by that
  name.  This makes the use of --delete with --keep-dirlinks
  work much better.
2004-09-21 09:24:02 +00:00
Wayne Davison
4d8f5b0ae7 - Fixed a problem with the $bakdir value.
- Made the files have better contents to copy.
- Also test --backup without --backup-dir.
2004-09-20 19:50:04 +00:00
Wayne Davison
89389a29ef Output a backup message when verbose > 1 and we did a copy prior
to an --inplace update.
2004-09-20 19:47:59 +00:00
Wayne Davison
29fe3961ab Output the same backup-message prefix when verbose > 1 regardless of
the setting of --backup-dir.
2004-09-20 19:46:45 +00:00
Wayne Davison
4e8a085ac9 Use $diffopt instead of -u. 2004-09-20 05:17:57 +00:00
Wayne Davison
fb22c2774d Got rid of a superfluous static buffer. 2004-09-20 05:01:38 +00:00
Wayne Davison
7d059d4c37 A simple test of the backup functionality. 2004-09-20 04:59:01 +00:00
Wayne Davison
9715c5899a Improved a comment. 2004-09-20 04:17:42 +00:00
Wayne Davison
cc07f21211 Mention the new RSYNC_PARTIAL_DIR environment variable. 2004-09-18 17:37:54 +00:00
Wayne Davison
b4d1e854ef Document the new RSYNC_PARTIAL_DIR environment variable. 2004-09-18 17:35:20 +00:00
Wayne Davison
075aa18fd4 Look for the RSYNC_PARTIAL_DIR environment variable when --partial
was specified (and --partial-dir was not).
2004-09-18 17:34:56 +00:00
Wayne Davison
e0204f5621 Mention that older rsync versions had a problem with --link-dest and
how to work around it.
2004-09-18 01:49:19 +00:00
Wayne Davison
a9ac4411e5 Mention the latest changes. 2004-09-17 16:53:51 +00:00
Wayne Davison
50b31539c2 - Added the ability to parse a literal IPv6 address in an "rsync:" URL
(e.g. rsync://[2001:638:500:101::21]:873/module/dir).
- Improved a couple --files-from error messages.
2004-09-17 16:50:53 +00:00
Wayne Davison
56194bcd95 When outputting the flist info (in a debug-level of verbosity) we
now mention the UID of the file when we are the sender (as well as
when we are root).
2004-09-17 16:39:34 +00:00
Wayne Davison
eb8ffa9040 Actually, since the close calls shouldn't fail (now that listener
is properly set to -1 on close), we don't really need to play the
save-errno game after all.
2004-09-16 17:22:31 +00:00
Wayne Davison
a7a1cc2c75 Make sure that /etc and /bin actually are readable before we try
to list them.
2004-09-16 17:16:36 +00:00
Wayne Davison
ab217f7ffa - Set "listener" to -1 after we close it so that the error-handler
doesn't try to re-close it.
- Set blocking I/O before the second (final) connect() call.
2004-09-16 17:09:46 +00:00
Wayne Davison
a20c9893e4 Don't try to optimize-away the sending of the --delete option if
--delete-after was specified (since we don't know what the protocol
version will be yet).
2004-09-08 07:33:06 +00:00
Wayne Davison
3bb400ca14 If --backup was used with --inplace, we don't limit the basis-file
matches (as we normally would) because the receiver is using the
backup-file as the basis-file.
2004-09-07 21:45:19 +00:00
Wayne Davison
cd6aa5b5c0 When --backup is used with --inplace, we make a copy of the destination
file into its backup spot while generating the checksums.
2004-09-07 21:44:02 +00:00
Wayne Davison
dc55d7bdab If we're making backups with --inplace, use the backup file as the
basis file while still updating the real destination file inplace.
2004-09-07 21:34:26 +00:00
Wayne Davison
8b115ac8dc Turn off make_backups during the redo phase, just like the receiver. 2004-09-07 21:32:36 +00:00
Wayne Davison
c94e4afbfa Moved the code that determines the backup filename into a new function
named get_backup_name().
2004-09-07 21:29:26 +00:00
Wayne Davison
6566d205e2 Made full_write() non-static. 2004-09-07 21:26:26 +00:00
Wayne Davison
e484f0cc04 W mustn't backup an inplace file in finish_transfer(). 2004-09-07 20:37:36 +00:00
Wayne Davison
bd397b8cba Reject the use of --compare-dest or --link-dest with --inplace
(it will take extra code to suppor this).
2004-09-07 20:36:36 +00:00
Wayne Davison
f8c8ef9eac When we say we're skipping a non-regular file, actually skip it. 2004-09-07 19:49:09 +00:00
Wayne Davison
72c19bb3de A minor optimization to the partial-dir code. 2004-09-07 17:03:51 +00:00
Wayne Davison
89f7eff382 Fix the case where a partial-dir file exists but the destination
file does not.
2004-09-07 16:50:07 +00:00
Wayne Davison
b90a6d9ff6 Mention that --whole-file interferes with the reuse of a --partial-dir
file.
2004-09-07 16:49:10 +00:00
Wayne Davison
584ba4ebae Fixed a typo Paul pointed out. 2004-09-05 21:30:00 +00:00
Wayne Davison
ba3db4795e Allow the use of the --exclude*/--include* options to a server
process again, but make sure that the user didn't specify a
server-excluded file for one of the --*-from options.
2004-08-26 17:39:48 +00:00
Wayne Davison
59d73bf3d2 Some fixes & clarifications for the BATCH MODE section. 2004-08-18 07:50:36 +00:00
Wayne Davison
919ca3a3cc Few few more minor improvements to the existing change items. 2004-08-18 07:49:03 +00:00
Wayne Davison
5886edfac2 Corrected/enhanced a comment. 2004-08-18 07:00:17 +00:00
Wayne Davison
d414962af4 One more NEWS tweak. 2004-08-12 21:02:13 +00:00
Wayne Davison
8fb7db245a Mention the security fix. 2004-08-12 20:58:33 +00:00
Wayne Davison
6f0fc27e33 Got rid of one item. 2004-08-12 20:48:05 +00:00
Wayne Davison
9c54ad58f8 Preparing for release of 2.6.3pre1 2004-08-12 20:06:57 +00:00
Wayne Davison
f55c2dfc03 One last minor tweak to clean_fname(). 2004-08-12 20:04:47 +00:00
Wayne Davison
675ef1aa3a Tweaked the USAGE section a tad and added an ADVANCED USAGE section
that discusses how to request multiple names from a remote rsync.
2004-08-12 19:31:23 +00:00
Wayne Davison
ef57235623 Improved the build rule for getfsdev and added getfsdev.o to the
files we cleanup.
2004-08-12 18:59:03 +00:00
Wayne Davison
d66d07e883 If system won't let us set chmod bits, fall back to testing without
them set.
2004-08-12 18:51:35 +00:00
Wayne Davison
b92693daba - Made clean_flist()'s collapsing of ".." dirs optional by adding
a "BOOL collapse_dot_dot" arg.
- Improved some comments.
2004-08-12 18:20:14 +00:00
Wayne Davison
58b1999e08 Call clean_flist() with its new "collapse_dot_dot" arg. 2004-08-12 18:20:07 +00:00
Wayne Davison
8e5f029e02 One (hopefully) last change to the sanitize_path() code. 2004-08-12 10:13:45 +00:00
Wayne Davison
2d41264e9e Simplified sanitize_path() logic a little. 2004-08-12 09:32:16 +00:00
Wayne Davison
82c6be7edf More improvements and a couple missing items. 2004-08-12 01:27:26 +00:00
Wayne Davison
0219d4dfba Improved a comment. 2004-08-12 00:58:01 +00:00
Wayne Davison
391516da51 Got rid of a comment that became inapplicable. 2004-08-12 00:52:58 +00:00
Wayne Davison
1d6b8f9ad2 - Call sanitize_path() with updated args.
- Added count_dir_elements() function.
- Changed the args for sanitize_path() so that the caller can request
  the value for the rootdir and so that the caller tells us the current
  subdir depth instead of sending us a string that we have to figure it
  out from.
- Make sure that sanitize_path() doesn't mis-parse multiple adjacent
  slashes.
2004-08-11 23:41:06 +00:00
Wayne Davison
10796f4b6e Call sanitize_path() with updated args. 2004-08-11 23:41:03 +00:00
Wayne Davison
33ffd7c37d - Set the var lastdir_depth when setting lastdir.
- Call sanitize_path() with updated args.
2004-08-11 23:41:00 +00:00
Wayne Davison
21d1e929a0 Ignore new getfsdev executable. 2004-08-11 17:33:52 +00:00
Wayne Davison
d0bc3520de Make the text of the --times (-t) option more correct on what
happens if it is omitted.
2004-08-11 17:24:37 +00:00
Wayne Davison
9f18657889 A minor improvement in check_one_exclude(). 2004-08-10 18:15:33 +00:00
Wayne Davison
c16d69b292 Mention the early-chmod change. 2004-08-09 20:58:26 +00:00
Wayne Davison
ebeacb36fb Set each file's permissions and modtime before it gets renamed. 2004-08-09 20:57:10 +00:00
Wayne Davison
6558854dbe Do some simple tests with various read-only and set[ug]id files. 2004-08-09 20:52:35 +00:00
Wayne Davison
7d9d5d9478 Added a rule for building getfsdev and for requiring it to run "test". 2004-08-09 20:51:44 +00:00
Wayne Davison
630f548ff4 Made robust_rename() return a 1 if it had to copy the file. 2004-08-09 20:48:38 +00:00
Wayne Davison
100b62bb69 Output a device string for each file given on the command-line. 2004-08-09 20:46:54 +00:00
Wayne Davison
e012b94f21 Fixed a bug in clean_fname() that could sometimes leave a "dir/.."
sequence uncollapsed.
2004-08-07 20:56:41 +00:00
Wayne Davison
3104620cf0 Made clean_fname() return the length of the string. 2004-08-06 22:36:55 +00:00
Wayne Davison
ebdd24d6d0 An improved clean_fname() routine that is more efficient and will also
collapse ".." dirs that aren't at the start of the path.  Care was taken
to ensure that the cleaning of a name that goes over the socket is done
in the same way as the old code (because both sides call clean_fname()
on those file-list names).  This ensures compatibility with older rsync
versions.
2004-08-06 21:24:14 +00:00
Wayne Davison
7cd72c79ec Set "eob" correctly in add_exclude_file(). 2004-08-05 22:58:17 +00:00
Wayne Davison
84a6379565 Merged alloc_sanitize_path() into sanitize_path(), adding an extra arg
that indicates the destination dir for the resulting path (if the dest
is NULL, a buffer will be allocated) and having it return a value.
2004-08-05 21:57:11 +00:00
Wayne Davison
0a5f12720e Use the new sanitize_path() calling syntax. 2004-08-05 21:57:09 +00:00
Wayne Davison
73f7af0e88 If dry_run is > 1 then the destination directory was missing, so we
set stat_errno to ENOENT and statret to -1 without calling stat().
2004-08-05 18:18:36 +00:00
Wayne Davison
e5a96f0f54 In get_local_name(), if we would have created the destination dir but
were prevented by dry_run being set, increment dry_run so that the
generator knows that all the files are missing.
2004-08-05 18:17:44 +00:00
Wayne Davison
d73e7f6edd In set_refuse_options(): make sure we scan the whole list of options
and avoid complaining about a wild-card spec that actually matches
one or more options.
2004-08-04 21:20:34 +00:00
Wayne Davison
61542c41de Decided that we don't need to limit the block size after all now
that the map_file() code handles large block sizes better.
2004-08-03 15:41:16 +00:00
Wayne Davison
bd1a581bee Use MAX_MAP_SIZE in the args to map_file(). 2004-08-03 15:37:54 +00:00
Wayne Davison
6e8a1782ab - Changed the calling syntax for map_file() so that it takes both
a (possibly approximate) window size and an optional block size
  (which is used to round-up the window size if it is non-zero).
- Don't set window_start behind the supplied offset in map_ptr().
2004-08-03 08:05:29 +00:00
Wayne Davison
96d910c770 Call map_file() with its new args, including a suggested window
size.
2004-08-03 08:05:27 +00:00
Wayne Davison
7560c17adc We call map_ptr() with a data range than includes any unmatched data
(which we might need to reference again) in addition to the current
rolling-checksum block (this prevents the unmatched data from being
lost when we slide the buffer and read more data).
2004-08-03 08:05:23 +00:00
Wayne Davison
9cd339eb39 - Changed the description for --block-size in the --help text.
- Use the new MAX_BLOCK_SIZE to limit the block_size value.
2004-08-03 08:05:20 +00:00
Wayne Davison
f310029387 - Added define for MAX_BLOCK_SIZE.
- Increased the MAX_MAP_SIZE.
2004-08-03 08:05:17 +00:00
Wayne Davison
3ed8eb3f9c Updated the description of the --block-size option. 2004-08-03 07:58:48 +00:00
Wayne Davison
007351494d Mention the open64()/mkstemp64() configure change. 2004-08-02 22:06:17 +00:00
Wayne Davison
6dcb93208d Don't use mkstemp() if the OS has open64() but not mkstemp64(). 2004-08-02 21:56:07 +00:00
Wayne Davison
84e1a698bf Test for functions open64() and mkstemp64(). 2004-08-02 21:54:49 +00:00
Wayne Davison
0d7638eafd Got rid of trailing whitespace. 2004-08-02 16:49:20 +00:00
Wayne Davison
86e2f445f7 Mention the "refuse options" change. 2004-08-02 07:41:04 +00:00
Wayne Davison
093e816c37 Allow better wildcard matching against the short-option letters in
the "refuse options" handling.
2004-08-02 07:40:34 +00:00
Wayne Davison
1cb0a3edc6 Document the improved "refuse options" syntax. 2004-08-02 05:01:36 +00:00
Wayne Davison
06a5054273 - Extended the "refuse options" daemon setting to allow wildcards
and to allow single-letter option names.
- No need to send the various --delete* options or the --force option
  from the receiver to the sender.
2004-08-02 05:00:30 +00:00
Wayne Davison
acd0299243 Got rid of unused externs. 2004-08-02 04:50:33 +00:00
Wayne Davison
dca68b0aad - Changed "read so far" to "received so far".
- Output the who_am_i() information in the socket read/write errors to
  make it a little clearer who is complaining about what (for those
  familiar with rsync, at least -- e.g. it will help when users report
  errors).
2004-08-02 02:43:54 +00:00
Wayne Davison
c3ea09906d - Changed all the errors in parse_arguments() to use the err_buf so
that a client talking to a daemon server actually gets the error.
- If a daemon has a list of exclusions, apply that list to various
  options to ensure that an excluded file can't be affected.
- Fixed an arg-checking problem when --files-from got passed to a
  daemon.
2004-07-31 20:09:54 +00:00
Wayne Davison
bf4679e8a0 If we need to return an error during the startup phase and the other
side is expecting us to send them a files-from list, send the list
terminator before sending the error.
2004-07-31 19:55:42 +00:00
Wayne Davison
c4054610c8 Don't allow a --partial-dir setting to overwrite a server-excluded
file (affects a daemon receiver only).
2004-07-31 18:13:20 +00:00
Wayne Davison
f6c0d3d70b - Document the change to --copy-links.
- Improved the "OUTPUT CHANGES" section.
2004-07-31 16:20:28 +00:00
Wayne Davison
ef855d198e Document the old side-effect to --copy-links and that it no longer
happens in a modern rsync w/o --keep-dirlinks.
2004-07-31 16:19:14 +00:00
Wayne Davison
81b07870c8 One call to link_stat() (in set_perms()) needed to honor the setting
of keep_dirlinks if the current item is a directory.
2004-07-31 16:15:41 +00:00
Wayne Davison
bb6721dce6 Reset copy_links in the receiver. 2004-07-31 16:14:27 +00:00
Wayne Davison
446a2987cd Prominently mention the changes to the text that gets output. 2004-07-31 03:33:05 +00:00
Wayne Davison
4de2a17409 Changed "wrote"/"written" to "sent" and "read" to "received" in
the text that is output.
2004-07-31 03:32:42 +00:00
Wayne Davison
99d24f77ed - Mention the "list = no" change in error handling.
- Improved a few of the NEWS items.
2004-07-30 22:46:07 +00:00
Wayne Davison
c0422cea9f If someone is denied access to a "list = no" module, lie and tell them
that the module is "Unknown" (so the user can't probe to find unlisted
modules).
2004-07-30 20:07:52 +00:00
Wayne Davison
8b6ad0193d Don't ignore case in lp_number() because the rest of the daemon code
can't handle the case where the module name doesn't exactly match the
string the user provided.
2004-07-30 20:05:37 +00:00
Wayne Davison
33eff8bfd6 If we reject a name due to a server-exclude, someone is trying to hack
rsync (because the generator would not have included this file).  Respond
with an exit.
2004-07-30 07:02:37 +00:00
Wayne Davison
65af3dab03 Document the latest changes. 2004-07-29 18:08:16 +00:00
Wayne Davison
065a605270 Got rid of bogus compare_dest scan in skip_file() -- it must checksum
the same file that we used for the stat() (in the parent routine).
2004-07-29 16:45:48 +00:00
Wayne Davison
a7260c4037 Added the new --partial-dir option. 2004-07-29 16:06:38 +00:00
Wayne Davison
44cad59f2b Document the new --partial-dir option. 2004-07-29 16:06:34 +00:00
Wayne Davison
c52461f911 Check the error return of flush_write_file(). 2004-07-29 07:37:27 +00:00
Wayne Davison
7f459268d9 Added close_multiplexing_in() and renamed io_multiplexing_close()
to close_multiplexing_out().
2004-07-29 07:24:45 +00:00
Wayne Davison
9eeb3b9c88 Call the new close_multiplexing_in() function in the generator. 2004-07-29 07:24:00 +00:00
Wayne Davison
d1b31da71e If we fail writing to the socket and we're receiving error messages
from the other side via a multiplexed input, read the socket to see
if we get some errors that would explain why they went away.
2004-07-29 07:09:46 +00:00
Wayne Davison
89e540e638 One more inplace code tweak. 2004-07-29 06:59:30 +00:00
Wayne Davison
fab65a5bc2 Some minor fixes and improvements for the inplace code. 2004-07-29 06:40:26 +00:00
Wayne Davison
e7d13fe532 - Explicitly save the stat()'s errno so that we can be sure we're
testing the right thing lower down (and so that future code doesn't
  always have to remember to save it off and restore it).
- Improved a chunk of link_dest code.
- Handle the removal of a non-regular file without so much duplicated
  code.
2004-07-28 10:04:06 +00:00
Wayne Davison
ecc81fce17 Use the new safe_fname() function. 2004-07-26 16:36:59 +00:00
Wayne Davison
b4afd23c30 Allow safe_fname() to tweak up to two name at a time. 2004-07-26 16:34:36 +00:00
Wayne Davison
af1a3f9b6e Use safe_fname() in full_fname(). 2004-07-26 15:59:51 +00:00
Wayne Davison
820b6c9aa0 Added safe_fname() that converts any newlines in a name into '?'s. 2004-07-26 15:52:25 +00:00
Wayne Davison
3cb22c204c Made a comment better. 2004-07-26 05:38:02 +00:00
Wayne Davison
7432ccf4ed Some batch-mode changes. 2004-07-24 16:51:58 +00:00
Wayne Davison
6a48e792c1 Made the new option-twiddling message only output when verbose. 2004-07-24 16:51:16 +00:00
Wayne Davison
9459290ae7 Call read_stream_flags() as soon as we open the batch file for
reading.
2004-07-24 16:40:41 +00:00
Wayne Davison
741d654495 Call write_stream_flags() from start_write_batch(). 2004-07-24 16:39:53 +00:00
Wayne Davison
d3e182af09 Added write_stream_flags() to write the state of certain flags into
the batchfile and read_stream_flags() to read and twiddle the same
flags.  This ensures that the batchfile reading doesn't get confused
about what data to expect from the socket.
2004-07-24 16:38:49 +00:00
Wayne Davison
d9b4d267c7 Tweaked a compound line. 2004-07-23 16:59:38 +00:00
Wayne Davison
58c5c24555 Added a comment. 2004-07-23 16:59:22 +00:00
Wayne Davison
341c9a137f Some basic batch-mode tests. 2004-07-23 02:13:34 +00:00
Wayne Davison
871446fc98 Chris added a missing "not" to a comment. 2004-07-23 01:40:22 +00:00
Wayne Davison
0abda1b176 Fixed the opening comments. 2004-07-23 01:39:19 +00:00
Wayne Davison
394bcdb5e3 If we sucessfully renamed a file that has multiple links to it, unlink()
it to ensure that rename() didn't lie to us (which it does if you try to
rename() a file over another link to the same file).
2004-07-22 22:52:39 +00:00
Wayne Davison
28deecca55 Changed NO_INT64 to INT64_IS_OFF_T because off_t might actually be
64 bits.  The code now only complains if int64 is really too short.
2004-07-22 19:28:45 +00:00
Wayne Davison
4db88e5b8f Some --help text fixes. 2004-07-22 15:43:28 +00:00
Wayne Davison
75b243a51d Some more --inplace improvements. 2004-07-22 15:41:09 +00:00
Wayne Davison
9bccfc429c Should always call finish_transfer() for inplace handling, just like
for keep_partial handling.
2004-07-22 15:31:06 +00:00
Wayne Davison
077e59b769 The inplace handling in finish_transfer() now passes PERMS_SKIP_MTIME
to set_perms() if ok_to_set_time wasn't specified.
2004-07-22 15:30:04 +00:00
Wayne Davison
007e3c0e9a Need to output the "failed verification" error before sending the
MSG_REDO so that the output comes out in the right order.
2004-07-22 08:16:35 +00:00
Wayne Davison
e2bc412669 Added a warning message when a file fails to verify, letting the user
know if we retained it or discarded it.  Especially useful for batch-
reading mode where the old code could look like it did the update when
it really silently failed.
2004-07-22 04:15:18 +00:00
Wayne Davison
e344209582 Added even more double-quoting. 2004-07-22 03:23:04 +00:00
Wayne Davison
e76ca1458c No need to check both delete_after and delete_mode since the former
implies the latter.
2004-07-22 02:52:57 +00:00
Wayne Davison
16cc9ca2c9 In read_batch mode, we read ints from the new batch_gen_fd pipe and
only process the updates from the batch file when the generator has
indicated that it is ready (which ensures that all the necessary
dirs have been created).
2004-07-21 23:59:37 +00:00
Wayne Davison
8c90957ff5 Got rid of read_batch special case. 2004-07-21 23:59:33 +00:00
Wayne Davison
c0d8e84c9d Setup for read_batch mode a little differently:
- Avoid calling local_child().
- Create a pipe that lets the generator send us index values.
- Set batch_gen_fd for the receiver to read the pipe.
2004-07-21 23:59:31 +00:00
Wayne Davison
b0ad542928 Added batch_gen_fd. 2004-07-21 23:59:28 +00:00
Wayne Davison
727b35f665 In read_batch mode, we now let the code write out the index value
to the f_out pipe before we return from recv_generator().  This gives
the receiver something to sync with so that it doesn't rush ahead of
us (which could be bad if we didn't have a chance to create the
destination dirs yet).
2004-07-21 23:59:25 +00:00
Wayne Davison
aa4343211f Don't write out the protocol_version number in read_batch mode. 2004-07-21 23:59:22 +00:00
Wayne Davison
3611989355 Complain if the user combines --read-batch with --files-from. 2004-07-21 22:50:11 +00:00
Wayne Davison
3381b77d71 Improved the test a little. 2004-07-21 21:06:13 +00:00
Wayne Davison
dce70db374 Adding a test for the --compare-dest option. 2004-07-21 20:58:32 +00:00
Wayne Davison
2adbcdc7ea A couple am_sender checks (one negated) were not needed. 2004-07-21 20:17:02 +00:00
Wayne Davison
7e5fa372cf Call map_file() with the new block_size arg (had to delay the
call to map_file() until the block size was known).
2004-07-20 21:35:58 +00:00
Wayne Davison
6e45e1dd86 - Call map_file() with the new block_size arg (had to delay the
call to map_file() until the block size was known).
- Got rid of the setting of max_map_size.
2004-07-20 21:35:55 +00:00
Wayne Davison
7f290d5c82 - Added a new block_size arg to map_file(). Use it to set the
new def_window_size member variable.
- Got rid of max_map_size global (we use def_window_size now).
2004-07-20 21:35:52 +00:00
Wayne Davison
b6609cafae - Got rid of cleanup_buf (map-file cleanup is not needed).
- Renamed the cleanup_fd* vars.
2004-07-20 21:35:49 +00:00
Wayne Davison
efa95a1842 Call map_file() with its new block_size arg. 2004-07-20 21:35:46 +00:00
Wayne Davison
51bd4f0f3a Tweaked an error message. 2004-07-20 21:10:20 +00:00
Wayne Davison
562b61695e Added a def_window_size variable to struct map_struct. 2004-07-20 21:08:33 +00:00
Wayne Davison
98f51bfb56 - More batch-file improvements.
- A few spelling fixes.
2004-07-20 18:12:50 +00:00
Wayne Davison
73f0ce69e7 We now append the exclude list as a "here" document to the end of
the BATCH.sh file.
2004-07-20 17:07:55 +00:00
Wayne Davison
cf338ab1be Made write_sbuf() non-static. 2004-07-20 16:57:18 +00:00
Wayne Davison
66a9dc9639 Changed write_batch_argvs_file() to new write_batch_shell_file()
call (with extra arg).
2004-07-19 17:11:41 +00:00
Wayne Davison
8ed9d849dc Added new function discard_receive_data(). 2004-07-19 17:05:01 +00:00
Wayne Davison
5ebab6c10c - Don't allow some crafty user to try to force us to update a
server-excluded file.
- If get_tmpname() fails we need to discard the update using
  receive_data().
2004-07-19 16:37:30 +00:00
Wayne Davison
e7a69008e6 Do a better job of writing out the BATCH.sh file (i.e. quote special
characters and spaces in args, omit all the source args, omit the
include/exclude args if we can).
2004-07-19 08:27:17 +00:00
Wayne Davison
73e015683c Changed batch.rsync_argvs to batch.sh. 2004-07-19 03:59:35 +00:00
Wayne Davison
b462781fd0 Fixed the argv munging to work properly regardless of whether the
user specified a trailing '=VALUE' or put the value in a separate
arg.
2004-07-19 00:53:49 +00:00
Wayne Davison
93095cbe99 A very minor optimization was made to read_sbuf(), read_byte(),
write_sbuf(), and write_byte().
2004-07-17 21:17:34 +00:00
Wayne Davison
399371e7b5 - Improved the warning about --inplace.
- Fixed the sentence describing how to read standard input with
  --read-batch.
2004-07-17 16:44:16 +00:00
Wayne Davison
d7142e2328 Moved the read_batch abort check below the code that handles the
symlinks and devices.
2004-07-17 16:29:10 +00:00
Wayne Davison
1f75bb1066 Revamped some of the io variables and calls to make the various I/O
functions seemlessly work on fds that aren't for the main socket. This
involved changing some fd-variable names (to make them clearer), adding
io_set_sock_fds(), and making input buffering have a better enabled
flag (via an allocated buffer, just like the output buffering).  I also
got rid of the fd arg to some functions where the fd arg could only
specify the input or output fd for the socket (which we already know).
2004-07-17 15:20:00 +00:00
Wayne Davison
088adfacc1 Got rid of the arg to io_start_multiplex_out(). 2004-07-17 15:19:57 +00:00
Wayne Davison
da3478b2a7 - Got rid of the arg to the io_start_multiplex_{in,out}() calls.
- Call io_set_sock_fds().
2004-07-17 15:19:54 +00:00
Wayne Davison
5126ed1ef0 Changed a MIN() to a MAX() when setting max_map_size. 2004-07-17 10:59:14 +00:00
Wayne Davison
61fb21ad28 Mention the new --inplace option. 2004-07-17 00:00:27 +00:00
Wayne Davison
a3221d2ac1 My version of Mark Curtis's --inplace option. 2004-07-16 20:06:24 +00:00
Wayne Davison
2c713fcdfa Added a check for ftruncate. 2004-07-16 20:04:20 +00:00
Wayne Davison
afd8bdb907 Avoid some useless memory copying. 2004-07-16 18:08:52 +00:00
Wayne Davison
efd5ee5786 - Limit the maximum block size we compute for a file.
- Set max_map_size based on the current file's block size (so that
  map_ptr() is more efficient with large blocks).
2004-07-16 18:04:23 +00:00
Wayne Davison
510b4cd4d5 Added a max_map_size variable, initialized to MAX_MAP_SIZE. 2004-07-16 18:02:30 +00:00
Wayne Davison
de584c658c Limit the block-size that the user can specify. 2004-07-16 18:01:30 +00:00
Wayne Davison
6eb770bbcc Improved a sentence about --whole-file. 2004-07-16 17:14:55 +00:00
Wayne Davison
c7e11bfdc0 Make wf_writeBufSize based on a multiple of WRITE_SIZE instead
of the unrelated MAX_MAP_SIZE.
2004-07-16 01:32:02 +00:00
Wayne Davison
94327ff0c2 - Complain and die if --dry-run is used with a batch option.
- Improved the warning if a batch option gets sent to the server.
2004-07-15 19:06:32 +00:00
Wayne Davison
4602eafa87 Changed the batch examples to show how to do a remote read-batch
without first transferring the batch file.
2004-07-15 19:04:54 +00:00
Wayne Davison
bb3edc3b47 Expanded the comment on the new batch code. 2004-07-15 19:03:50 +00:00
Wayne Davison
c769702fe5 Mention that "-" can be used with --read-batch for reading from stdin. 2004-07-15 17:56:11 +00:00
Wayne Davison
dbbab0c4d2 Allow --read-batch=- to indicate stdin. 2004-07-15 17:01:51 +00:00
Wayne Davison
9b3318b0df We no longer refer to a batch "prefix". 2004-07-15 16:27:02 +00:00
Wayne Davison
0fac7fe8b8 Mention new batch-mode changes. 2004-07-15 03:13:09 +00:00
Wayne Davison
b9f592fbf5 My modified version of Chris Shoemaker's improved batch-file handling. 2004-07-15 02:20:08 +00:00
Wayne Davison
c7b1a56b3d Mention recent changes. 2004-07-14 17:11:53 +00:00
Wayne Davison
3896bca4d8 Tweaked some single-line ifs. 2004-07-14 16:41:10 +00:00
Wayne Davison
9774cc3344 The "len" to generate_and_send_sums() is supposed to be an OFF_T. 2004-07-14 16:40:08 +00:00
Wayne Davison
d3979b025d Committed a space-tweak from Chris Shoemaker. 2004-07-14 16:39:08 +00:00
Wayne Davison
01966df4f7 Improved the write_batch_argvs_file() routine so that it doesn't
need the character buffers and so that it properly removes the
hostname from the destination arg.
2004-07-14 07:20:18 +00:00
Wayne Davison
f38bd4a072 Got rid of the disable_deltas_p() function (the whole_file value
is now fully set before the generator forks).
2004-07-13 01:45:51 +00:00
Wayne Davison
b1df18d76f We now conditionally turn on whole_file in do_cmd() right before
calling local_child().
2004-07-13 01:44:03 +00:00
Wayne Davison
7daccb8e72 In generate_files(), changed arg "f" to "f_out", as Chris Shoemaker
suggested.
2004-07-12 20:42:48 +00:00
Wayne Davison
bb91a624f1 Made hard_link_check() compile when SUPPORT_HARD_LINKS isn't enabled. 2004-07-12 07:03:28 +00:00
Wayne Davison
a04d77bcbc Use want_i instead of last_i+1. 2004-07-07 08:38:40 +00:00
Wayne Davison
25bd99451c Make the GID_NONE define a little safer. 2004-07-07 08:25:13 +00:00
Wayne Davison
ed43d0a76d Added some missing $(srcdir) references. 2004-07-04 08:56:31 +00:00
Wayne Davison
066a844c4e Changed a "for" loop into a "do ... while" loop. 2004-07-04 08:07:23 +00:00
Wayne Davison
5e252dea4b Optimized away a loop in hash_search(). 2004-07-02 23:35:30 +00:00
Wayne Davison
d2a918b454 Some formatting tweaks. 2004-07-02 18:23:57 +00:00
Wayne Davison
da38e779ea Moved the verbose message about renaming the finished file down into
finish_transfer() so that it only gets output when we're actually going
to rename the file.
2004-07-02 18:13:53 +00:00
Wayne Davison
8186ae6bc0 Tweaked some formatting. 2004-07-02 18:12:24 +00:00
Wayne Davison
e1f67417d7 Some simple whitespace tweaks. 2004-06-30 07:27:30 +00:00
Wayne Davison
fd322eef82 Made recv_generator static. 2004-06-29 19:19:00 +00:00
Wayne Davison
d3a4375f78 Optimized away a call to cmp_modtime() for a compare-dest file. 2004-06-29 16:22:54 +00:00
Wayne Davison
78112d305b Mention the extended argv-overflow checking. 2004-06-29 15:13:18 +00:00
Wayne Davison
f7c3ee9932 Tweaked an overly-long line. 2004-06-29 15:12:01 +00:00
Wayne Davison
e7a392c77c A few more improvements to the anti-overflow args[] checking. 2004-06-28 17:45:40 +00:00
Wayne Davison
887e553f05 Make sure that do_cmd() doesn't overflow its arg-pointer array
(which was also made larger).
2004-06-28 17:25:14 +00:00
Wayne Davison
beb227ddf1 Got rid of a couple unneeded assignments. 2004-06-24 04:46:02 +00:00
Wayne Davison
84acca07ae Restoring correct skip_file() return semantics. 2004-06-23 21:21:19 +00:00
Wayne Davison
cc1e997dcd Thought skip_file() wasn't returning 1 for "skip" and 0 or "keep"
so I reversed the return.
2004-06-23 16:51:21 +00:00
Wayne Davison
a7026ba90a Fixed a newly-introduced problem in read_timeout() where FD_ZERO(&w_fds)
wasn't always called before w_fds was used.
2004-06-23 01:13:09 +00:00
Wayne Davison
3a69fad0f6 Some trivial format tweaks. 2004-06-20 21:48:06 +00:00
Wayne Davison
40564811ee Mentioned the latest socket change and fixed a few typos. 2004-06-20 20:37:06 +00:00
Wayne Davison
dcd08dc51c Restored the code in the IPV6_V6ONLY section that checks the
return value from setsockopt() with one improvement:  if the
user has used --ipv6 (-6) we don't discard the IPv6 socket.
This should help people using older Linux kernels that don't
implement IPv6 support quite right.
2004-06-20 19:51:19 +00:00
Wayne Davison
fdf57ede8c Tweaked a comment. 2004-06-20 19:47:05 +00:00
Wayne Davison
bd717af8ab Must not call check_timeout() before checking the errno value. 2004-06-19 07:09:57 +00:00
Wayne Davison
c54f5170bf Added some missing changes. 2004-06-19 06:55:58 +00:00
Wayne Davison
eae4e1f9f0 Some minor improved sentences. 2004-06-19 05:52:45 +00:00
Wayne Davison
9c513d678d Tweaked some comments. 2004-06-18 16:55:12 +00:00
Wayne Davison
d16c245fc4 Some helpful comments from Chris Shoemaker. 2004-06-18 16:50:20 +00:00
Wayne Davison
ec8290c897 Fixed some typos in a comment, moved an extern, and made a few
minor format tweaks.
2004-06-18 16:30:24 +00:00
Wayne Davison
b293a7f62c Improved a comment. 2004-06-18 16:29:21 +00:00
Wayne Davison
d67c8bdfc3 Moved the externs to the top and made a few trivial format tweaks. 2004-06-18 16:22:14 +00:00
Wayne Davison
e2ccd3578c Got rid of some trailing whitespace. 2004-06-18 16:00:33 +00:00
Wayne Davison
4e834af140 If --partial was specified, make sure that make_backup is turned
off during the second (retry) phase of the transfer to avoid
making a second backup of a file (which would lose the original).
2004-06-14 15:09:36 +00:00
Wayne Davison
7e5614383d Added a short msleep() after option_error() before we exit. This
ensures that the remote client has time to read our error message
while it is trying to write data to us before it gets a socket
error.
2004-06-13 14:18:48 +00:00
Wayne Davison
eb84a83b47 Changed the new code in delete_one() so that some compilers
don't complain about returning a value from a void function.
2004-06-12 21:30:07 +00:00
Wayne Davison
2c2898a388 Mention the bugfix in option-parsing error-reporting from a daemon. 2004-06-12 18:27:04 +00:00
Wayne Davison
1732b6c037 - Changed some FERROR log calls to FLOG.
- Improved the option-error-reporting to actually get the error back
  to the user (by getting I/O multiplexing started).
2004-06-12 18:22:39 +00:00
Wayne Davison
314f459161 - Made readlink_stat() and link_stat() optionally follow a symlink
to a dir.  This fixes deletions inside "kept" symlinked dirs.
- Call link_stat() with its new arg (for --keep-dirlinks support).
2004-06-11 07:40:57 +00:00
Wayne Davison
83926d3cae Make sure that keep_dirlinks is turned off for the sender. 2004-06-11 07:40:54 +00:00
Wayne Davison
6218c7bf42 - Moved --keep-dirlinks code over to flist.c.
- Call link_stat() with its new arg (for --keep-dirlinks support).
2004-06-11 07:40:51 +00:00
Wayne Davison
566fce3237 Made delete_one() handle a failed rmdir on a symlink when
--keep-dirlinks was specified.
2004-06-11 07:40:48 +00:00
Wayne Davison
373ef16010 Call link_stat() with its new arg (for --keep-dirlinks support). 2004-06-11 07:40:45 +00:00
Wayne Davison
ea76e76104 In set_filesystem(), call do_stat(), not link_stat() to ensure
that we get the directory behind it all.
2004-06-11 05:02:59 +00:00
Wayne Davison
9fd62d1588 The mkdir code should be using do_stat(), not do_lstat() to copy
each existing dir's mode & owner info.
2004-06-10 16:43:52 +00:00
Wayne Davison
b7061c82b4 Allow the argv list the daemon uses for globbing its args to grow. 2004-06-09 21:51:07 +00:00
Wayne Davison
6fb812f747 Removed some excessive parens. 2004-06-09 21:43:28 +00:00
Wayne Davison
40e8d11e64 Mentioned a couple more bugfixes. 2004-06-09 21:42:33 +00:00
Wayne Davison
73042aae5b Restore UNUSED() macro (the prior problems that prompted me to remove
it appear to have been a build-farm bug).
2004-06-09 21:41:21 +00:00
Wayne Davison
e5ce3bcf2c Needed to enclose the new symlink-warning code in an
"#if SUPPORT_LINKS" conditional.
2004-06-09 19:23:56 +00:00
Wayne Davison
c399d22a19 Renamed read_unbuffered() to readfd_unbuffered() so that it matches
writefd_unbuffered().
2004-06-09 03:07:50 +00:00
Wayne Davison
1ea087a794 - Made the maximum-fd computation prior to a select() use the same idiom
in both the read and write code (also use a better variable name).
- Made the bytes-available code at the end of the select() loop use the
  same flow of control in the read and the write code.
2004-06-08 22:18:04 +00:00
Wayne Davison
00bdf89977 Improved a comment in read_msg_fd() and made the byte-reading code
in read_timeout() a little better.
2004-06-08 16:23:54 +00:00
Wayne Davison
0bb4d17634 Improved rwrite() in two ways:
- We no longer assume that the buffer is null terminated (daemon
  mode would ignore the len when logging a message).
- Errors in daemon mode are now sent to both the log and the user.
2004-06-07 22:51:14 +00:00
Wayne Davison
f9c6b3e7d6 Increase the size of the message-receving buffer for error
messages sent from the receiver to the generator.
2004-06-07 22:47:01 +00:00
Wayne Davison
9e5a5ddb4c Changed a few FINFO messages to FLOG. 2004-06-07 22:33:01 +00:00
Wayne Davison
8c0d6a8432 Got rid of some am_daemon games in option_error(). 2004-06-07 22:05:22 +00:00
Wayne Davison
553f93758a Updated some exclude information that has changed. 2004-06-07 21:40:11 +00:00
Wayne Davison
a4a7e64c19 Don't report a "file vanished" error if a symlink points to nowhere
and -L was specified.
2004-06-07 19:59:20 +00:00
Wayne Davison
22832c30a0 Updated a couple things. 2004-06-06 20:41:01 +00:00
Wayne Davison
1a21666286 Tell folks to go to the bug-tracking page to report bugs. 2004-06-06 20:36:56 +00:00
Wayne Davison
4033b80b51 - Got rid of some useless calls to msg_list_push().
- Added a couple checks to ensure that the receiver doesn't mix two
  clashing kinds of writes on the msg_fd_out pipe.
- Made sure that the read code in the receiver flushes the msg_fd_out
  pipe, if needed.
2004-06-06 19:15:58 +00:00
Wayne Davison
99218d821b If the user specifies a small io_timeout value, lower select_timeout. 2004-06-06 19:02:40 +00:00
Wayne Davison
e626b29e10 Make sure our select calls don't sleep for over one minute at a time,
even when io_timeout is a longer value (though the code in options.c
might set it to a shorter value if io_timeout is small).
2004-06-06 19:02:09 +00:00
Wayne Davison
f89b936801 Don't use single-line "if (condition) statement;" idiom. 2004-06-06 18:36:22 +00:00
Wayne Davison
17f59e818d Mention changes to the patches dir. 2004-06-05 21:23:59 +00:00
Wayne Davison
b5bd5542eb Neatened up some of the glob-expand code and made a few other
minor tweaks.
2004-06-05 20:26:56 +00:00
Wayne Davison
2e94e70e2b Some superficial code tweaks. 2004-06-05 19:59:03 +00:00
Wayne Davison
4e1f385711 Mentioned new --keep-dirlinks option. 2004-06-05 16:19:02 +00:00
Wayne Davison
716e73d483 New --keep-dirlinks option. 2004-06-05 16:16:30 +00:00
Wayne Davison
5b36173d11 Mention new SSH_* vars. 2004-06-03 17:20:33 +00:00
Wayne Davison
b2ef4f6134 The daemon-over-ssh code now looks for $SSH_CONNECTION and $SSH2_CLIENT
as well as $SSH_CLIENT to figure out the remote IP address.
2004-06-03 17:20:21 +00:00
Wayne Davison
c7be6dec11 - Added older news from NEWS file.
- Added missing releases from the Partial Protocol History section.
2004-06-01 21:27:52 +00:00
Wayne Davison
bd1574b208 Moved older news to OLDNEWS. 2004-06-01 21:27:12 +00:00
Wayne Davison
f376e67420 Got rid of an unneeded character pointer in send_file_entry(). 2004-05-29 21:21:17 +00:00
Wayne Davison
ef0bc0abff Mention the --bwlimit change. 2004-05-28 19:42:06 +00:00
Wayne Davison
71e586304b Improvements to make --bwlimit work better. 2004-05-27 22:09:31 +00:00
Wayne Davison
3c74c3a358 Set a new variable, bwlimit_writemax, based on the value of the bwlimit
option.
2004-05-27 21:51:53 +00:00
Wayne Davison
edad5898f2 Got rid of a superfluous call to gettimeofday(). 2004-05-24 22:59:16 +00:00
Wayne Davison
fa0c1939ed The various include/exclude options are not used on the server side,
so if someone is trying something funny, just quit.
2004-05-24 18:38:05 +00:00
Wayne Davison
9a5ade185c Made full_fname()'s char-pointer arg const. 2004-05-24 08:10:22 +00:00
Wayne Davison
f1dd0f27cb - Properly quote the $excl references.
- Moved the creation of our .cvsignore exclude file.
2004-05-24 00:16:07 +00:00
Wayne Davison
f9e5a0cde2 Improved the depth calculation in sanitize_path() so that it properly
handles a trailing slash, a leading slash, and an empty string.
2004-05-23 23:46:56 +00:00
Wayne Davison
ead751c62b Moved a couple lines. 2004-05-22 19:29:53 +00:00
Wayne Davison
0058c58edd A few minor improvements to the existing items. 2004-05-22 19:24:24 +00:00
Wayne Davison
221ddb9456 Fixed a typo in the sending of the --checksum-seed option to the server. 2004-05-22 06:09:22 +00:00
Wayne Davison
65e2487096 Fixed the comment for get_exclude_tok(). 2004-05-22 05:32:20 +00:00
Wayne Davison
0501f36390 Tweaked the alloc/realloc code in flist_expand(). 2004-05-21 23:22:14 +00:00
Wayne Davison
96981b9cff Tell rsync to preserve permissions. 2004-05-21 10:06:09 +00:00
Wayne Davison
f51e87f5ad Another new option. 2004-05-21 10:00:21 +00:00
Wayne Davison
cb213f1c1b Got rid of a compiler warning (which was only output by certain
compilers).
2004-05-21 09:59:49 +00:00
Wayne Davison
c8d895de26 Added the --checksum-seed option. 2004-05-21 09:44:32 +00:00
Wayne Davison
e51094b721 - Improved option_error() to make sure that the user sees the error in
daemon mode.
- Got rid of some repetitious outputting of the same error-message.
2004-05-21 09:41:38 +00:00
Wayne Davison
b03bded70b Document a couple more changes. 2004-05-21 09:29:17 +00:00
Wayne Davison
ee1df1ccae If --backup was specified without a --backup-dir, don't preserve the
directory timestamps.
2004-05-21 08:43:03 +00:00
Wayne Davison
bc6ebcd248 Moved a few externs. 2004-05-21 08:40:25 +00:00
Wayne Davison
ba582f753a Changed sum_init() to take a seed value as an arg instead of always
using checksum_init.  This fixes an authentication problem in server
mode (as pointed out by Craig Barratt).
2004-05-21 08:27:04 +00:00
Wayne Davison
cbd85b472e - Mention the change to the daemon-mode's exclude handling.
- Mention the new "write only" daemon-config option.
- Fixed another entry to refer to the right files.
2004-05-19 22:20:56 +00:00
Wayne Davison
7a92ded39a Added the "write only" option to the daemon config file. 2004-05-19 22:19:19 +00:00
Wayne Davison
831f05df51 A few minor text improvements. 2004-05-18 09:54:52 +00:00
Wayne Davison
0d94a6a66c Added a little more quoting. 2004-05-18 09:47:42 +00:00
Wayne Davison
3e35c34b6b Output a message when we skip a server-excluded file. 2004-05-18 08:50:17 +00:00
Wayne Davison
03a9ca0a97 Document the latest changes. 2004-05-18 01:13:14 +00:00
Wayne Davison
6f481bb0e0 - Use fromdir, todir, and tmpdir instead of FROM, TO, and TMP.
- Added chkdir.
- Quote the dir expansions to avoid problems with spaces.
- Added "exclude = foobar.baz" the the rsync.conf file we create.
2004-05-18 00:41:55 +00:00
Wayne Davison
f98cc5685d Test that a config-file-specified exclude works right. 2004-05-18 00:41:51 +00:00
Wayne Davison
9135621ff9 Quote the dir expansions to avoid problems with spaces. 2004-05-18 00:41:49 +00:00
Wayne Davison
8624daa7f8 - Use fromdir and todir instead of FROM and TO.
- Quote the dir expansions to avoid problems with spaces.
2004-05-18 00:41:46 +00:00
Wayne Davison
3051c46dc3 - Use $suitedir to find rsync.fns.
- Use tmpdir instead of TMP.
2004-05-18 00:41:43 +00:00
Wayne Davison
e920830ec5 Use $suitedir to find rsync.fns. 2004-05-18 00:41:40 +00:00
Wayne Davison
7892e5ac77 - Use $suitedir to find rsync.fns.
- The values of fromdir, todir, and chkdir are already set.
2004-05-18 00:41:38 +00:00
Wayne Davison
b0e9bafc78 - Use $suitedir to find rsync.fns.
- The values of fromdir and todir are already set.
2004-05-18 00:41:35 +00:00
Wayne Davison
44aa070770 Removing obsoleted test.sh file (we used the runtests.sh framework for
some time now).
2004-05-18 00:32:36 +00:00
Wayne Davison
97f9dcae6a If the server has excluded a file, we now exclude it from being
uploaded as well as downloaded.
2004-05-18 00:14:10 +00:00
Wayne Davison
8cbf495a57 Renamed free_exclude_list() to clear_exclude_list(). 2004-05-16 23:54:12 +00:00
Wayne Davison
c1b29492c5 Moved the setting of ret->match_flags up a little in make_exclude(). 2004-05-16 14:08:34 +00:00
Wayne Davison
669a31924e - Save some memory in each exclude_struct item by dumping the "include"
and "directory" ints and using bits in the match_flags value instead.
- Added defines for the new match-flag values, including a new one that
  lets get_exclude_tok() properly return an indication that it parsed
  the list-clearing token.
2004-05-16 07:28:24 +00:00
Wayne Davison
5e972dcf34 - Switched the "include" and "directory" ints into bits in match_flags.
- Made some length vars unsigned.
2004-05-16 07:28:21 +00:00
Wayne Davison
8fcdc444df - Improved rsyserr() to prefix RSYNC_NAME (as the TODO requested),
to construct the string in a better manner, and to have a buffer
  big enough to hold a full MAXPATHLEN filename plus some error
  text.
- Fixed some comments referring to vsprintf() returning -1 -- our
  configuration process now ensures that we replace such a function
  with our own lib version.
2004-05-15 19:31:16 +00:00
Wayne Davison
619d21ffc9 - Complain about an exclude that was too long and then dump it
(used to be silently truncated).
- Include extra space in our exclude-reading buffers so that we
  can fit a 2-char prefix and a trailing slash and still handle
  a MAXPATHLEN name.
2004-05-15 19:31:13 +00:00
Wayne Davison
d62bcc17f3 Changed rprintf() calls that included strerror() to use rsyserr(). 2004-05-15 19:31:10 +00:00
Wayne Davison
982e05bbd5 Changed rprintf() calls that included strerror() to use rsyserr(). 2004-05-15 19:31:10 +00:00
Wayne Davison
a3c8b36863 Added rsyserr(). 2004-05-15 19:31:05 +00:00
Wayne Davison
630e3c408b Whitespace tweaks. 2004-05-15 19:09:42 +00:00
Wayne Davison
1082b52bd4 Changing if (!write_batch) in front of send_exclude_list() to
if (!read_batch) -- fixes hang.
2004-05-15 18:51:21 +00:00
Wayne Davison
914f3066bb Added a "gen" rule to remake various generated files: configure,
config.h.in, proto.h, rsync.1, and rsyncd.conf.5 .
2004-05-15 00:48:11 +00:00
Wayne Davison
de91e75724 In the debug output, distinguish between a user-requested clearing
of the exclude list and the popping of the local exclude list that
occurs when we finish each subdir.
2004-05-14 21:23:41 +00:00
Wayne Davison
384431886a Changed PERMS_SKIP_TIME to PERMS_SKIP_MTIME. 2004-05-13 18:51:22 +00:00
Wayne Davison
82b302d928 Got rid of some useless externs. 2004-05-13 18:41:17 +00:00
Wayne Davison
4ecc9e6b64 The finish_transfer() call takes an arg that specifies if we should set the
modtime or not on the finished file.  It calls set_perms(), which now takes a
flag arg that allows us to specify if we want to skip the modtime modification.
2004-05-13 07:08:25 +00:00
Wayne Davison
55e50d890b If the file did not transfer correctly, only save it if --partial was
specified.  We also skip the setting of the modtime too on a partial
copy (that way the partial file won't be confused with an up-to-date
copy of the original).
2004-05-13 07:08:22 +00:00
Wayne Davison
6e86c951d7 Call finish_transfer() with its new arg. Also put the externs
at the top and got rid of some trailing whitespace.
2004-05-13 07:08:18 +00:00
Wayne Davison
c41b52c487 Use the new PERMS_REPORT flag when calling set_perms(). 2004-05-13 06:55:01 +00:00
Wayne Davison
5c6fc4a6a3 Added PERMS_REPORT and PERMS_SKIP_TIME. 2004-05-13 06:53:23 +00:00
Wayne Davison
edecdad54d If we got a read-error on a file, make sure that the whole-file
checksum we send to the receiver is wrong (so they won't save
the bogus file).
2004-05-13 06:46:20 +00:00
Wayne Davison
5291364f1d Don't force the modtime on our backup dirs -- the dirs in the
backup hierarchy should have their own timestamps.
2004-05-13 06:34:03 +00:00
Wayne Davison
41cc97ae64 In send_files(), changed the name of the map_struct variable from
"buf" to "mbuf" (so that it wouldn't be so similar to the "buff"
variable nor use a name that is more typically a char* buffer).
2004-05-11 19:53:16 +00:00
Wayne Davison
bf2b7ddfc5 Use memset() to initialize a new map_struct. 2004-05-11 19:46:56 +00:00
Wayne Davison
eb0cbdaa90 Got rid of an unused extern. 2004-05-11 17:25:16 +00:00
Wayne Davison
0d0142e812 Got rid of unused externs. 2004-05-11 17:25:01 +00:00
Wayne Davison
a43e21e05c Let's just remove all the UNUSED() macros for now. 2004-05-08 22:49:58 +00:00
Wayne Davison
4135d091a6 Changed the non-globbing version of glob_expand_one() so that it
checks the maxargs argument instead of leaving it unused.
2004-05-08 20:03:39 +00:00
Wayne Davison
534407b1f4 One more attempt to get HP-UX's cc to build popt successfully. 2004-05-08 19:50:22 +00:00
Wayne Davison
18cc8c7ef1 Improved a comment and got rid of some trailing whitespace. 2004-05-08 19:37:28 +00:00
Wayne Davison
58c9b4b7f6 Tweaked the sizeof syntax and some multi-statement lines. 2004-05-08 19:26:53 +00:00
Wayne Davison
cde719f49f Changed the order of the msgcode enum so that new items now get added
at the start (which avoids the need for trailing-comma changes on old
entries when new ones are added).
2004-05-08 18:48:09 +00:00
Wayne Davison
38cab94d9a - Improved the get_secret()'s function comments, made it accept a line
that doesn't end with a newline, and optimized it a bit.
- Improved getpassf() to work if the line does not end with a newline.
2004-05-08 18:18:42 +00:00
Wayne Davison
6ed6d7f5a8 Improved the function comments for read_line() and slightly tweaked
its code.  Also changed "IO" to "I/O" in various comments.
2004-05-08 18:03:43 +00:00
Wayne Davison
e40a46de71 Document the -4, -6, --ipv4, --ipv6 options. 2004-05-07 00:18:37 +00:00
Wayne Davison
c5bf99a1c2 Correct a typo. 2004-05-06 21:29:36 +00:00
Wayne Davison
2c7d63c765 - Updated the comments for open_socket_in().
- Changed open_socket_in() to return an array of ints with a trailing -1
  value to indicate the end of the list.
- Use the out_of_memory() routine to complain about no memory.
- Undid the recent IPV6_V6ONLY change, as I think it would prevent the
  use of IPv6 sockets on some older systems.
- If we get an EADDRINUSE error and this is not the first socket in the
  list, suggest that the user try --ipv4 or --ipv6.
- When forking, the child now closes all the open bound sockets, not just
  one of them (I'm not talking about the fd from accept(), obviously).
2004-05-06 21:26:46 +00:00
Wayne Davison
3dd22903ac Introduced long-option names for -4 and -6. 2004-05-06 21:08:01 +00:00
Wayne Davison
d8d36af452 If we need to set IPV6_V6ONLY but setsockopt() fails, close the
socket and skip it.
2004-05-05 22:17:48 +00:00
Wayne Davison
e610e50f9c Added missing extern for read_batch. 2004-05-05 17:15:03 +00:00
Wayne Davison
935c64173f Don't force the whole-file option when using read-batch. 2004-05-05 16:23:49 +00:00
Wayne Davison
377dbd2075 Calls to make_bak_dir() should only happen when we fail to create a
file/dir/etc. with errno == ENOENT.
2004-05-04 03:10:45 +00:00
Wayne Davison
93272700d2 A slight refinement to my last patch. 2004-05-03 01:24:10 +00:00
Wayne Davison
d508258ad8 Fixed crash bug that can affect --delete in certain circumstances. 2004-05-03 01:18:07 +00:00
Wayne Davison
f57b2e6150 Got rid of a TODO comment that was fixed long ago. 2004-05-02 17:04:14 +00:00
Wayne Davison
af45f9e27e Renamed variable STRIP to INSTALL_STRIP to avoid an accidental match
with an environment variable in OpenBSD.
2004-05-02 16:52:52 +00:00
Wayne Davison
4c4d61b046 Got rid of trailing comma in an enum. 2004-05-02 16:34:33 +00:00
Wayne Davison
7561c3e132 Moved some news items under new headings. 2004-04-30 21:10:58 +00:00
Wayne Davison
1514ad2a80 Changed the order that ssh and rsh are mentioned. 2004-04-30 20:39:29 +00:00
Wayne Davison
d8195637d4 Additional testing confirmed the limited scope of the sources affected
by the -R sorting bug.
2004-04-30 19:14:52 +00:00
Wayne Davison
c8d771a0fb Preparing for release of 2.6.2 2004-04-30 18:03:33 +00:00
Wayne Davison
9130776c4e Mention the last few tweaks that made it into 2.6.2. 2004-04-30 17:53:51 +00:00
Wayne Davison
9eac94a4dd Improved the program that checks for broken large-file locking. 2004-04-30 17:38:22 +00:00
Wayne Davison
6e06d2f31a Don't rely on the local shell's wildcard expansion to make the test
work right -- it might not be quite as compatible as we need.
2004-04-30 17:24:49 +00:00
Wayne Davison
6a6d21136a Only refer to AI_NUMERICHOST if it is defined. 2004-04-30 16:10:45 +00:00
Wayne Davison
f28bd83346 Fixed a few typos. 2004-04-30 15:46:41 +00:00
Wayne Davison
96fb478eae Mention the desire to improve how a daemon returns errors. 2004-04-29 21:12:46 +00:00
Wayne Davison
8752b3fcd8 Describe the changes for 2.6.2. 2004-04-29 21:09:33 +00:00
Wayne Davison
55ffed7e42 Preparing for release of 2.6.2pre1 2004-04-29 20:36:22 +00:00
Wayne Davison
e00df64bae Got rid of unused check for sys/sysctl.h. 2004-04-29 19:40:17 +00:00
Wayne Davison
080ddf58ae Fixed a sorting problem when an entry has an empty (but not NULL)
dirname (which I had thought impossible, but it appears to occur
with --relative in some instances).
2004-04-29 19:37:15 +00:00
Wayne Davison
4ce48a5bfd Restore old behavior of logging most daemon errors instead of sending
them to the user.  This should eventually be improved to duplicate
some of these messages to the user to keep them informed about what
went wrong.
2004-04-29 19:34:31 +00:00
Wayne Davison
20bf7f847f Undefined __attribute__ in some circumstances. 2004-04-28 17:35:08 +00:00
Wayne Davison
b66d00853b Fixed the use of an uninitialized variable in map_uid() and map_gid(). 2004-04-28 17:31:31 +00:00
Wayne Davison
8b602edda4 In copy_file(), check len < 0 before checking the close() return values. 2004-04-27 19:59:37 +00:00
Wayne Davison
9f27cd8ca6 Check the return code from close() and output an error if it
fails.
2004-04-27 19:51:33 +00:00
Wayne Davison
b084f9e092 Got rid of a debug-output statement. 2004-04-27 16:41:33 +00:00
Wayne Davison
4220e1098e Preparing for release of 2.6.1 2004-04-27 03:55:37 +00:00
Wayne Davison
c30468169a - Tweaked the bullet char so that vim can auto-format the items more
easily (and then used vim to re-flow the items).
- Added a mention about the daemon security fix.
- Added the 2.6.1 release date.
2004-04-27 03:53:28 +00:00
Wayne Davison
c0d9e8c76b - Changed XFLG_NO_PREFIXES to XFLG_WORDS_ONLY.
- Got rid of HP-UX kludge (since it didn't help).
2004-04-27 01:36:16 +00:00
Wayne Davison
90a973fe8a Changed XFLG_NO_PREFIXES to XFLG_WORDS_ONLY. 2004-04-27 01:36:10 +00:00
Wayne Davison
7f0feb4dd6 - Changed XFLG_NO_PREFIXES to XFLG_WORDS_ONLY.
- Don't parse comment lines in add_exclude_file() when XFLG_WORD_SPLIT
  is set.
2004-04-27 01:36:06 +00:00
Wayne Davison
33a5432ea6 Got rid of HP-UX kludge (since it didn't help). 2004-04-27 01:36:00 +00:00
Wayne Davison
968ff560d2 Made a comment clearer. 2004-04-27 01:00:58 +00:00
Wayne Davison
cd59be1d5e One more try at getting the HP-UX system in the build farm to compile
popt.
2004-04-25 20:36:41 +00:00
Wayne Davison
8b2869c0d2 Don't use __attribute__((__unused__)) on HP-UX w/o gcc. 2004-04-25 16:10:09 +00:00
Wayne Davison
82a51ea53d Improved the debug string for the local_exclude_list. 2004-04-24 08:00:39 +00:00
Wayne Davison
20af605eba Improved the EXCLUDE PATTERNS section some more. 2004-04-24 06:16:04 +00:00
Wayne Davison
a6536635e3 Fixed a comment. 2004-04-23 08:09:13 +00:00
Wayne Davison
adddd075eb Mention how --update behaves when the type of the file differs on
the source and destination systems.
2004-04-23 05:14:39 +00:00
Wayne Davison
a0c823b22b Recently added caveat is no longer true. 2004-04-23 01:33:35 +00:00
Wayne Davison
9fdb334e85 Restore the old include behavior where a command-line include could
override a .cvsignore exclude.
2004-04-22 22:17:15 +00:00
Wayne Davison
f89e890b87 Got rid of a wrong paragraph. 2004-04-22 21:35:45 +00:00
Wayne Davison
1c666c3fcb Got rid of a bunch of cruft. 2004-04-22 21:17:58 +00:00
Wayne Davison
2a383be0f1 Updated the default list of cvs-excluded files and added some extra
info on how the option interacts with other include/exclude rules.
2004-04-22 18:17:30 +00:00
Wayne Davison
ac1d2d3384 Added "debug_type" to the exclude_list_struct. 2004-04-22 09:58:24 +00:00
Wayne Davison
acfcfa7053 No need to pass a debug string to check_exclude() anymore. 2004-04-22 09:58:21 +00:00
Wayne Davison
8ef81dd452 No need to pass a debug string to check_exclude() anymore. When we
free an exclude list, make sure we don't clear the debug_type string.
2004-04-22 09:58:18 +00:00
Wayne Davison
67340e9523 Initialize the new debug_type string in each exclude list and output
it in a couple extra debug messages.  When we free an exclude list,
make sure we don't clear the debug_type string.
2004-04-22 09:58:15 +00:00
Wayne Davison
a7ceddae34 Changed check_exclude()'s prototype. 2004-04-22 09:58:11 +00:00
Wayne Davison
24e1569f8b The debug output for add_exclude() now needs to limit the pattern to
print only "pat_len" chars.
2004-04-22 08:41:03 +00:00
Wayne Davison
de31639fff A couple minor text improvements. 2004-04-19 17:52:39 +00:00
Wayne Davison
8b46340924 Mentioned the better handling of option paths when a daemon is not
running with chroot enabled.
2004-04-18 06:29:06 +00:00
Wayne Davison
d008bcb5cd Made the device-changes section agree with the latest code. 2004-04-17 19:58:12 +00:00
Wayne Davison
0484b5b0b7 Preparing for release of 2.6.1pre-2 2004-04-17 18:40:16 +00:00
Wayne Davison
f01b6368a5 Mention that --from0 does not affect --cvs-exclude's reading of the
.cvsignore files.
2004-04-17 18:12:33 +00:00
Wayne Davison
40d38dc0be In add_exclude_file(), if we're word-splitting, stop reading a "line"
at any whitespace (so that we don't overflow the line buffer).
2004-04-17 17:55:45 +00:00
Wayne Davison
33a2361cc2 The inode and dev values in the idev struct are now uint64. 2004-04-17 17:14:16 +00:00
Wayne Davison
4124540d61 Changed the dev handling for -H back to using an opaque 64-bit
integer instead of trying to transfer it as separate major & minor
values.  Since the value is not interpreted by the receiving side
(just compared for equality), this is a safer way to go.
2004-04-17 17:14:12 +00:00
Wayne Davison
5f38126817 Use "uint64" instead of INO64_T (which is now gone). 2004-04-17 17:07:23 +00:00
Wayne Davison
b05b3c9b48 Fixed alloc_sanitize_path()'s handling of a rootdir == "/" (the old
code would generate a string that started with "//" instead of "/").
2004-04-17 17:06:03 +00:00
Wayne Davison
a03a9f4efe Don't say "skipped" if the file is just not being transferred (i.e.
when other updates, such as owner/permissions/etc. might be made).
2004-04-15 18:32:24 +00:00
Wayne Davison
3e55030372 Mention exclude improvements. 2004-04-15 18:23:52 +00:00
Wayne Davison
273c0420d0 Got rid of a couple useless lines. 2004-04-15 18:22:56 +00:00
Wayne Davison
5774786fa5 Moved some externs. 2004-04-15 16:55:23 +00:00
Wayne Davison
1a9ec1fd1c Got rid of zlib/dummy ("dummy" is in the zlib .cvsignore, where it
should be).
2004-04-15 06:54:14 +00:00
Wayne Davison
b2aa573b1c Our exclude lists are now comprised of a base structure with a head
and a tail pointer pointing to a linked list of items (rather than
an array of pointers that has to be reallocated all the time).
2004-04-14 23:33:40 +00:00
Wayne Davison
63d0331991 Added a "next" pointer to "exclude_struct" and added a new structure
for exclude lists, exclude_list_struct, that holds the head/tail
pointers for the list.
2004-04-14 23:33:37 +00:00
Wayne Davison
bf6dcd1713 Updated the exclude-list code to handle the new linked-list
structure format.
2004-04-14 23:33:34 +00:00
Wayne Davison
495723bb26 Updated the exclude-list code to handle the new linked-list
structure format.
2004-04-14 23:33:34 +00:00
Wayne Davison
911cb0662c Updated stub version of check_exclude(). 2004-04-14 22:49:54 +00:00
Wayne Davison
5387514eaf Added a description arg to check_exclude(). 2004-04-14 21:59:45 +00:00
Wayne Davison
61414c83ce The check_exclude() and report_exclude_result() functions now take a
description string that describes what kind of an include/exclude is
happening (which only gets output when verbose is set to 2 or more).
2004-04-14 21:59:41 +00:00
Wayne Davison
43a9d0e7c2 Improved the exclude testing by adding tests that exercise --cvs-exclude
and --delete-excluded.
2004-04-14 20:50:32 +00:00
Wayne Davison
df5cd107a5 Moved (and expanded) a verbose message from clientserver.c to socket.c
to solve an old FIXME comment.
2004-04-14 16:51:48 +00:00
Wayne Davison
abca4eba67 Fixed a potential problem parsing the "!" token from a word-split string. 2004-04-13 19:07:21 +00:00
Wayne Davison
96d3590a08 A few more improvements to get_exclude_tok() and add_exclude(). 2004-04-13 18:35:08 +00:00
Wayne Davison
8429aa9e0e Added an example for --link-dest. 2004-04-13 00:32:58 +00:00
Wayne Davison
79d4053048 Updated with latest news and some spelling mistakes corrected. 2004-04-12 18:03:08 +00:00
Wayne Davison
753b6b4692 Replaced MISSING_OK, MISSING_FATAL, ADD_INCLUDE, and ADD_EXCLUDE with
some new XFLG_* values (for the add_exclude*() function).
2004-04-12 17:42:35 +00:00
Wayne Davison
f8f726449b - add_exclude() now takes a flag int and can optionally word-split
items and/or ignore +/- prefixes.
- add_exclude_file() changed to take the same flags as add_exclude().
- add_exclude_line() was removed since add_exclude() can now do its job.
- make_exclude() now takes a size-limited string without a +/- prefix.
- add_cvs_excludes() was changed to word-split the items that come from
  a .cvsignore file, and to ignore all +/- prefixes in all the ignore
  sources.  Since CVS doesn't check if its ignore items are directories,
  the dir-names (e.g. SCCS, CVS, etc.) no longer have a trailing slash
  (making our excludes match CVS's ignores more exactly).
2004-04-12 17:42:32 +00:00
Wayne Davison
357406ecb2 Use the new XFLG_* flags to call the add_exclude*() functions. 2004-04-12 17:42:29 +00:00
Wayne Davison
3915fd7583 No need to cast st.st_rdev to DEV64_T anymore. 2004-04-12 16:52:43 +00:00
Wayne Davison
9c5e91f848 - Use dev_t instead of DEV64_T.
- Changed rdev_high to rdev_major.
- Use major(), minor(), and makedev() to manipulate device numbers.
- Send the major and minor values separately in protocol 28 and beyond.
2004-04-12 16:52:40 +00:00
Wayne Davison
af107f6c08 - Got rid of DEV64_T and changed the internal device variables to dev_t.
- Changed XMIT_SAME_HIGH_RDEV to XMIT_SAME_RDEV_MAJOR.
- Added XMIT_RDEV_MINOR_IS_SMALL.
2004-04-12 16:52:37 +00:00
Wayne Davison
a3dbb20a0e Fixed a bug where an exclude name that got sent over the wire could get
an extra "- " or "+ " parsed off the start of the name (i.e. we have to
quote excluded names that start with those strings with an extra "- "
at the start).
2004-04-10 10:31:11 +00:00
Wayne Davison
a3779426b6 UNUSED() misbehaves on HP-UX, not AIX. 2004-04-09 22:25:33 +00:00
Wayne Davison
2f5ca63d92 AIX doesn't like our UNUSED() macro, so let's eliminate it for them. 2004-04-09 21:51:34 +00:00
Wayne Davison
0e1d98ae92 Silence compiler warnings on Solaris. 2004-04-09 20:22:44 +00:00
Wayne Davison
04575bcab5 Missed one void-pointer-arithmetic case. 2004-04-09 20:17:01 +00:00
Wayne Davison
71b291d71b AIX's cc was complaining about the void* arithmetic. 2004-04-09 19:53:50 +00:00
Wayne Davison
decba3ae73 Removed debug code. 2004-04-09 19:18:34 +00:00
Wayne Davison
f8ed564c9f Changed sysmacros.h to sys/sysmacros.h. 2004-04-09 19:04:03 +00:00
Wayne Davison
47ba39bef6 Added some test code to assist in the remote debugging of the build
farm's Solaris machines.
2004-04-09 18:36:01 +00:00
Wayne Davison
71f7051489 Use MAJOR_IN_MKDEV and MAJOR_IN_SYSMACROS. 2004-04-09 18:10:03 +00:00
Wayne Davison
3c3791e8be Use AC_HEADER_MAJOR for better makedev/major/minor determination. 2004-04-09 18:09:16 +00:00
Wayne Davison
c39d6514ab Include <sys/mkdev.h> if it exists. 2004-04-09 17:59:50 +00:00
Wayne Davison
1cb6f3bf4d Added sys/mkdev.h to the searched-for headers. 2004-04-09 17:56:58 +00:00
Wayne Davison
f09dc86ab6 Added a couple extra character devices to be copied. 2004-04-09 00:36:45 +00:00
Wayne Davison
f26ac1e8cb If we're listing a device, output the major and minor device numbers. 2004-04-09 00:33:34 +00:00
Wayne Davison
84a3efa0ab Simplify the setting of rdev & rdev_high in send_file_entry(). 2004-04-08 23:15:39 +00:00
Wayne Davison
00ed4b5bf3 Fixed a bug in the sending of rdev when the high-bits match. 2004-04-08 23:05:36 +00:00
Wayne Davison
e2e053bbd7 Explicitly cast our ~0xFF mask using ~(DEV64_T)0xFF, just to be sure
(sign-extention would have probably made the former work OK).
2004-04-08 21:51:49 +00:00
Wayne Davison
f8b33ab379 Mention the rsync-daemon fix for --sufix=''. 2004-04-07 23:13:02 +00:00
Wayne Davison
5df1fcf245 If --daemon was specified, exit the option-parsing code before
adjusting various default values (the real defaults will get
set when the client's options arrive).
2004-04-07 23:09:14 +00:00
Wayne Davison
b1ad6a3260 Added a couple missing items. 2004-04-05 15:05:46 +00:00
Wayne Davison
6442ccc606 Decided against "Source root" in the exclude/include examples. 2004-04-03 20:47:54 +00:00
Wayne Davison
b21813060c Mentioned the CoW improvement and got rid of a bug-fix mention that
was for a bug introduced during the 2.6.1 developement.
2004-04-03 18:13:51 +00:00
Wayne Davison
706c75307a Use getaddrinfo() to figure out if a numeric address is IPv4 or IPv6. 2004-04-01 21:39:35 +00:00
Wayne Davison
2b284ee33d Last of the cleanup before the patching starts. 2004-04-01 21:08:24 +00:00
Wayne Davison
4cfa6156e3 A couple more minor twiddles. 2004-04-01 20:56:50 +00:00
Wayne Davison
c1e7217fcb Updated the sizeof syntax and trimmed some trailing whitespace. 2004-04-01 20:53:39 +00:00
Wayne Davison
4b2f6a7c37 Decided to use "nobody" instead of "guest". 2004-04-01 18:05:40 +00:00
Wayne Davison
a8726d2a06 Some more IOERR_VANISHED support. 2004-04-01 18:04:59 +00:00
Wayne Davison
b5ebe6d9c7 Improved the include/exclude example section some more. Document
the new username default of "guest" if neither USER or LOGNAME is
set in the environment.
2004-03-31 18:53:57 +00:00
Wayne Davison
ef383c0d32 The auth_client function must not return without outputting something
on the socket, so a NULL or empty username now defaults to "guest".
2004-03-31 18:52:38 +00:00
Wayne Davison
8dcf93356e Don't complain about a null --suffix if we're the server/sender (since
we might not have received the --backup-dir path from the client).
2004-03-31 17:02:22 +00:00
Martin Pool
ce5f2732e4 I'm no longer maintaining this. Tell people to use the lists instead. 2004-03-31 02:48:47 +00:00
Wayne Davison
3e89da86df The --files-from option needs to allow a server-sender to sometimes
have just 1 arg on the command-line.
2004-03-30 02:08:07 +00:00
Wayne Davison
f5450e791d Try to avoid running on a system that allows us to create devices
without being root (like cygwin) because rsync won't copy the
devices if it is not root.
2004-03-29 17:02:31 +00:00
Wayne Davison
cb984e620e In sigchild_handler(), finish with waitpid() before reinitializing
the SIGCHLD handling.
2004-03-29 16:30:53 +00:00
Wayne Davison
be92ac6c36 Added one more example to the new include/exclude section to show how
--relative works with a non-absolute path.
2004-03-27 20:04:04 +00:00
Wayne Davison
5dc6e9c9ca Mention that certain options treat an absolute path as relative to the
module's "path" dir, even when chroot is off.
2004-03-27 19:47:27 +00:00
Wayne Davison
0b79c324ca Improved the "relative to the destination dir" description for
several options.
2004-03-27 19:46:28 +00:00
Wayne Davison
f39b6638f6 Got rid of debug-output statement. 2004-03-27 19:42:13 +00:00
Wayne Davison
a4b6f30579 Try to make the complexities of includes/excludes a little more clear. 2004-03-27 18:25:41 +00:00
Wayne Davison
7be73df4e7 Optionally sanitize the args in parse_arguments() using the new
alloc_sanitize_path() function.
2004-03-27 09:46:42 +00:00
Wayne Davison
14b61c63f0 Added alloc_sanitize_path(). 2004-03-27 09:44:49 +00:00
Wayne Davison
75a64762c2 The args are now sanitized in parse_arguments() instead of here. 2004-03-27 09:44:01 +00:00
Wayne Davison
028fdddb49 Fixed a crash bug when hlink_list is NULL and a link_u.links
pointer in one of the file_struct nodes is not.
2004-03-26 16:46:20 +00:00
Wayne Davison
f86b0f2e7b Fixed a typo and made a sentence read better. 2004-03-26 15:51:51 +00:00
Wayne Davison
285fba0759 Preparing for release of 2.6.1pre-1 2004-03-24 21:59:07 +00:00
Wayne Davison
92b9eb978e Moved a few externs and made a couple formatting tweaks. 2004-03-23 16:50:40 +00:00
Wayne Davison
1e82e2cea6 Got rid of an ancient (and no longer relevant) comment. 2004-03-23 16:36:00 +00:00
Wayne Davison
a7ed6ca618 A few formatting tweaks in delete_file(). 2004-03-23 16:16:15 +00:00
Wayne Davison
b4b90120ff Fixed the test for sin_len as noted by Shinichi Maruyama. Changed
the define name generated for this test and the sa_len test.
2004-03-16 01:26:39 +00:00
Wayne Davison
16f72adc49 Changed HAVE_SOCKADDR_SIN_LEN to HAVE_SOCKADDR_IN_LEN. 2004-03-16 01:26:31 +00:00
Wayne Davison
3d06165389 Check robust_rename()'s return value using < 0. 2004-03-13 20:18:03 +00:00
Wayne Davison
fd4893155d Mention the changes in the "patches" dir. 2004-03-10 08:32:38 +00:00
Wayne Davison
67e78a8231 Use CHMOD_BITS instead of ~_S_IFMT. 2004-03-07 20:29:59 +00:00
Wayne Davison
6b320e4045 Improved an entry. 2004-03-06 20:07:24 +00:00
Wayne Davison
7e5cb90983 Other files use S_IWUSR instead of S_IWRITE, so use S_IWUSR and S_IRUSR. 2004-03-06 07:45:52 +00:00
Wayne Davison
8120a98f47 Define S_IRUSR if it doesn't already exist. 2004-03-06 07:43:55 +00:00
Wayne Davison
8f3f8eec08 Updated to version from autoconf 2.59 (2003-10-03). 2004-03-06 07:00:47 +00:00
Wayne Davison
386b93dc60 Updated to version from autoconf 2.59 (2003-08-18). 2004-03-06 07:00:16 +00:00
Wayne Davison
b3bc31102c Moved out the old news and improved the new. 2004-03-04 19:36:28 +00:00
Wayne Davison
0f1aa0d3e5 Moved the previous release's NEWS here. 2004-03-04 19:35:57 +00:00
Wayne Davison
7a08ae31d2 Progress improvement. 2004-02-28 02:02:37 +00:00
Wayne Davison
304f127f56 Improved the progress reporting/E.T.A. using a (slightly modifed)
patch from Timo Sirainen.
2004-02-28 02:00:57 +00:00
Wayne Davison
c338460d66 Got rid of some superfluous parens. 2004-02-27 08:03:49 +00:00
Wayne Davison
48d704af52 Tru64 fix. 2004-02-27 07:37:43 +00:00
Wayne Davison
ac7aa92290 Use new HAVE_SOCKADDR_SIN_LEN define (replaces HAVE_SOCKADDR_LEN). 2004-02-27 07:22:40 +00:00
Wayne Davison
0042f81894 We now set HAVE_SOCKADDR_SA_LEN and HAVE_SOCKADDR_SIN_LEN based on
sockaddr.sa_len and sockaddr.sin_len, respectively (replacing
HAVE_SOCKADDR_LEN).
2004-02-27 07:22:39 +00:00
Wayne Davison
2c836acb37 No longer needed. 2004-02-26 04:03:44 +00:00
Wayne Davison
a1d8f29a3d A couple AC_DEFINE() changes so that we can do without acconfig.h. 2004-02-26 04:03:35 +00:00
Wayne Davison
a174e1ed0f Tweaked some comments and some whitespace. 2004-02-25 21:20:59 +00:00
Wayne Davison
530adb7625 Configure addition. 2004-02-23 20:09:14 +00:00
Wayne Davison
cd3fe9fb03 Allow the default (system) rsyncd.conf file to be specified via configure. 2004-02-23 20:00:20 +00:00
Wayne Davison
a8edfd53d1 Trivial whitespace tweak. 2004-02-23 19:23:53 +00:00
Wayne Davison
dbb665180c Shouldn't ignore .cvsignore. 2004-02-23 18:19:13 +00:00
Wayne Davison
9d78ed31a7 A couple fixes from Shinichi Maruyama. 2004-02-23 07:03:03 +00:00
Wayne Davison
89afe532d7 Mentioned the recent change in slash handling. 2004-02-23 02:28:04 +00:00
Wayne Davison
c67d13866b Changed the literal 9000 into "OPT_REFUSED_BASE". 2004-02-22 08:56:43 +00:00
Wayne Davison
3b98b08c4d Another bug fix. 2004-02-21 21:39:54 +00:00
Wayne Davison
9c15534511 Got rid of the "refuse options" section. 2004-02-21 21:37:14 +00:00
Wayne Davison
55afbb522c Complain in the daemon log file if there is an unknown option in the
"refuse options" value.  Also changed the idiom used to mark refused
options in the popt struct.
2004-02-21 21:36:55 +00:00
Wayne Davison
27ed20f7a0 Fixed the "refuse options" setting in the daemon after Fabrice Bellet
identified what was wrong.
2004-02-21 21:12:49 +00:00
Wayne Davison
f567e9b3d7 - Guard against and out-of-memory condition.
- Don't use the NGROUPS_MAX define.
2004-02-20 17:09:30 +00:00
Wayne Davison
40ae4f93a0 Don't use NGROUPS_MAX define. 2004-02-20 17:01:33 +00:00
Wayne Davison
7a27e9b599 Don't use ENOMSG -- it's not portable. 2004-02-18 22:33:21 +00:00
Wayne Davison
62c9e6b3a5 Moved the EXDEV handling into robust_rename(). 2004-02-17 23:13:10 +00:00
Wayne Davison
cfeed4da95 - If we return an error because of dry_run being set, we now set errno.
- The do_mkstemp() routine now preserves the errno value from fchmod()
  if that call fails.
- Improved the CHECK_RO macro stuff.
2004-02-17 23:00:00 +00:00
Wayne Davison
4068d8617d We no longer munge a double-leading slash in do_open() because we
shouldn't generate a path with a double-leading slash anymore.
2004-02-17 22:49:19 +00:00
Wayne Davison
421c2a2448 Don't create a pathname that has two leading slashes (which we used
to do when the root of the transfer was "/").
2004-02-17 21:57:44 +00:00
J.W. Schultz
d1e7726460 Remove "Conditional -z for old protocols" because those old
protocols are no longer supported.
2004-02-14 01:43:24 +00:00
Wayne Davison
0596df00b3 Reordered the items inside the file_struct so that alignment padding
should be minimized.
2004-02-11 08:01:21 +00:00
Wayne Davison
417c99f637 If --backup was specified, the links we remove are backed up. 2004-02-11 05:03:04 +00:00
Wayne Davison
de0e225076 - Revised and optimized the directory-making code.
- Optimized the keep_backup() code.
2004-02-11 05:02:21 +00:00
Wayne Davison
e0391f8149 Added backup_dir_buf and backup_dir_remainder. 2004-02-11 04:30:41 +00:00
Wayne Davison
7de2483fbd Fixed a crash bug when keep_backup() calls make_file() and the lastdir
pointer is no longer valid.
2004-02-11 02:48:58 +00:00
Wayne Davison
65d6212d03 Got rid of hard-link message (since I don't think it was ever
output in older rsync versions).
2004-02-11 02:33:17 +00:00
Wayne Davison
4d4df3cd2b Another attempt at measuring the minimum alignment for a system. 2004-02-10 23:35:12 +00:00
J.W. Schultz
62125b10c9 Simplified test for hardlink in make_backup debug message to
avoid core-dump.
2004-02-10 23:23:09 +00:00
Wayne Davison
81c3a3a86e Got rid of useless extern. 2004-02-10 22:56:16 +00:00
Wayne Davison
61d35e1844 Trying a different MINALIGN because of core dumps on the sparc-64
build-farm machines.
2004-02-10 22:28:36 +00:00
J.W. Schultz
15f85b1f63 Revert pool_alloc's use of bomb if pool == NULL. 2004-02-10 21:11:24 +00:00
J.W. Schultz
5bf63a11f4 Keep in sync with protocol if idev data on stream but no hlink_pool. 2004-02-10 21:11:24 +00:00
Wayne Davison
97a67bdfa9 If XMIT_HAS_IDEV_DATA is set in receive_file_entry(), we now bomb out
if flist->hlink_pool isn't set (instead of neglecting to read the idev
info).
2004-02-10 17:53:52 +00:00
Wayne Davison
aa0b9ca174 If we call pool_alloc() on a NULL pool, bomb out with an error. 2004-02-10 17:52:31 +00:00
Wayne Davison
b96efc2f67 Empty-line tweaks. 2004-02-10 17:35:04 +00:00
Wayne Davison
be20dc3448 Changed a while loop to a for loop. 2004-02-10 17:34:05 +00:00
Wayne Davison
cb869c26d9 Tweaked an if. 2004-02-10 17:28:59 +00:00
Wayne Davison
7cf8e8d05d Changed flist_init() to use offsetof(). 2004-02-10 17:28:31 +00:00
Wayne Davison
54fd3e5020 Added lib/pool_alloc.h to the HEADERS. 2004-02-10 17:06:11 +00:00
J.W. Schultz
3e4916822d Dropped support for protocol versions less than 20 (2.3.0
released 15 Mar 1999) and activated warnings for protocols
less than 25 (2.5.0 released 23 Aug 2001)
2004-02-10 03:54:47 +00:00
J.W. Schultz
7efdcf3218 Added allocation pool code. 2004-02-10 03:26:41 +00:00
J.W. Schultz
9935066b70 Make idev, hlink and file_struct + strings use allocation
pools.
2004-02-10 03:23:37 +00:00
Wayne Davison
6c2e5b56e4 Die if we overflowed the args[] array when building up the remote
command in do_cmd().
2004-02-09 21:22:59 +00:00
Wayne Davison
2289bf64cc The batch-options now set checksum_seed to the appropriate fixed value. 2004-02-09 18:32:54 +00:00
Wayne Davison
b1bf649cba Set checksum_seed only if it is still zero. 2004-02-09 18:32:53 +00:00
Wayne Davison
8ee6eb7134 Made checksum_seed an extern. 2004-02-09 18:32:52 +00:00
Wayne Davison
f98c60bfa8 Use asprintf() in server_options() (plus a few more whitespace tweaks). 2004-02-09 18:10:57 +00:00
Wayne Davison
a5c1113971 Updated the sizeof syntax and tweaked some whitespace. 2004-02-09 17:45:22 +00:00
Wayne Davison
736f46d1d9 Got rid of unused true/false defines. 2004-02-07 18:40:52 +00:00
Wayne Davison
a8f7e4b835 Made a couple comments a little clearer. 2004-02-07 00:12:40 +00:00
Wayne Davison
9352b0649b Got rid of unused string_area struct. 2004-02-06 15:33:15 +00:00
J.W. Schultz
a85906c756 Start flist with a more reasonable size, grow it linearly
once it reaches a largish size (16 million files) and make it
actually match the comments so it may be used to initialize
flists of known size (create_flist_from_batch()).
2004-02-06 10:00:33 +00:00
J.W. Schultz
8aa81e06e6 Update TODO to reflect recent changes.
Hardlink handling is improved.

	String area code is gone for other reasons.
2004-02-06 07:26:15 +00:00
Wayne Davison
1f9ae80a3e Fixed the indentation in init_flist(). 2004-02-06 07:19:57 +00:00
J.W. Schultz
71020fc3aa Correct sizeof usage and other whitespace. 2004-02-06 04:51:09 +00:00
J.W. Schultz
7b74bba15e Added a total memory allocated (allmem) line to
show_malloc_stats.
2004-02-06 01:56:25 +00:00
J.W. Schultz
e5fbaa713a Cause all three processes to report memory stats when -vv --stats 2004-02-05 03:27:54 +00:00
Wayne Davison
6609a9f17e Mention a couple more changes. 2004-02-05 02:56:57 +00:00
Wayne Davison
5204e853e1 Now that the long-standing chgrp bug is fixed, go back to -vvv from -vvvv. 2004-02-05 01:37:08 +00:00
Wayne Davison
01363a24e2 Fixed a problem handling GID_NONE in match_gid(). 2004-02-05 01:32:38 +00:00
Wayne Davison
d49def4832 - Fixed a bug using --numeric-ids as non-root when the receiver
does not have permissions to set one or more of the gids.
- If the add_[ug]id() routine couldn't find a name for an ID, we
  still note the ID in our list of IDs so that we don't try to
  look it up again (and again).  (The name-less IDs are stripped
  when sending the IDs from the sender to the receiver.)
- Created a better add_to_list() function that handles the linking
  of the new node into the list (rather than the caller doing it).
- Added new internal functions for some receiver-side work that
  needed to be done in multiple places (the recv_add_[ug]id()
  functions).
- We output debug info even for ID mappings that have no names.
  This make the list complete and also notes which gids get
  mapped to -1 (GID_NONE).
- Turned several while loops into for loops.
2004-02-05 01:07:23 +00:00
Wayne Davison
4836c3eece Added new extern. 2004-02-05 00:46:32 +00:00
Wayne Davison
9f7b8c3b8f Only call add_uid() or add_gid() if numeric_ids is not set. 2004-02-05 00:44:11 +00:00
Wayne Davison
ade7292aee Moved a function. 2004-02-04 20:09:21 +00:00
Wayne Davison
dbd8811b85 If a gid doesn't have a name on the originating system, the receiver
won't see it in the list of IDs to remap.  That means that we need to
call the is_in_group() function from inside match_gid() to know if we
can set the group or not (if we're not root).
2004-02-04 19:25:11 +00:00
Wayne Davison
05118158f4 Improved the trailing comment. 2004-02-04 18:24:41 +00:00
Wayne Davison
1df395f7c2 Use the new HAVE_GETGROUPS define. 2004-02-04 17:49:36 +00:00
Wayne Davison
5fdf2e7063 Added function check for getgroups. 2004-02-04 17:21:48 +00:00
Wayne Davison
6fe05820ff Use MY_UID() instead of getuid(). 2004-02-04 17:06:07 +00:00
Wayne Davison
670d8abf80 Use MY_GID() instead of getgid(). 2004-02-04 17:05:44 +00:00
Wayne Davison
b2bffbb2ca Added two defines: MY_UID() and MY_GID(). 2004-02-04 17:04:58 +00:00
Wayne Davison
13a6d667d2 Added getegid to the functions we check. 2004-02-04 16:45:26 +00:00
Wayne Davison
1be77f8336 Added geteuid to the functions to check. 2004-02-04 16:33:34 +00:00
Wayne Davison
187e9c24f1 Another improvement to the debug info we output. 2004-02-04 16:27:47 +00:00
Wayne Davison
eddeaf76f8 Set the "max verbosity" global to 9. 2004-02-04 07:32:48 +00:00
Wayne Davison
33e9d10d2a Use the new lp_max_verbosity() value to limit the server's "verbose"
value.
2004-02-04 07:32:12 +00:00
Wayne Davison
46f7dc3bf6 Added "max verbosity" global parameter that allows you to configure
a higher debug level instead of the default of level-l verbosity.
2004-02-04 07:31:29 +00:00
Wayne Davison
555b0e20f7 Tweaked the new debug-logging strings. 2004-02-04 07:24:13 +00:00
Wayne Davison
a57dfe710d Turned on 4 -v options for some build-farm testing. 2004-02-04 06:15:24 +00:00
Wayne Davison
53adbd7a3d If we encounter an error, output the rsyncd.log file, if it exists. 2004-02-04 05:34:29 +00:00
Wayne Davison
17f033b725 Temporarily switch to 4 -v options. 2004-02-04 03:58:19 +00:00
Wayne Davison
cefed3e8dc Delay the output the (verbose > 3) list of files until we've had a
chance to map the uid/gid info in the receiver.
2004-02-04 03:52:51 +00:00
Wayne Davison
84fa865c0c Output some debug info if verbose > 3. 2004-02-04 03:50:16 +00:00
Wayne Davison
f05f993eb7 If we're dumping the file list (i.e. verbose > 3), mention the uid and/or
gid (depending on applicability).
2004-02-04 03:28:22 +00:00
Wayne Davison
e90cdb8adf Changed the -x code to allow -L to copy a file on another filesystem
that is pointed to by a symlink on our exclusive filesystem.
2004-02-04 03:25:18 +00:00
Wayne Davison
4250941710 Fixed a dropped '-'. 2004-02-04 03:01:32 +00:00
Wayne Davison
a2687b64a2 Added a little more compatibility code for non-standard systems. 2004-02-03 23:28:19 +00:00
Wayne Davison
c284f34a49 Some indentation fixes and the removal of some superfluous parens. 2004-02-03 23:04:25 +00:00
Wayne Davison
5f5be796b0 Changed a couple sizeof calls and improved some string handling in
the {send,recv}_exclude_list() calls.
2004-02-03 23:01:58 +00:00
Wayne Davison
5cb374364b Modified sizeof usage and eliminated trailing whitespace. 2004-02-03 22:48:32 +00:00
Wayne Davison
f15256e156 Added some temporary code to try to figure out what is going wrong
on one NetBSD box in our build farm.
2004-02-03 20:01:26 +00:00
Wayne Davison
ce37eb2d83 If verbose > 2, mention it if we're setting the uid or the gid. 2004-02-03 20:00:35 +00:00
J.W. Schultz
0d6e308b51 correct sizeof usage. 2004-02-03 06:21:56 +00:00
Wayne Davison
b1dab2363a Made hard-link sending compatible with pre-28 protocols again. 2004-02-03 04:21:15 +00:00
J.W. Schultz
bd6abc4939 Corrected sizeof usage:
sizeof obj
	sizeof (type)
2004-02-03 03:42:49 +00:00
Wayne Davison
96eeda0324 Fix for memset bug found by buildfarm. 2004-02-02 22:35:07 +00:00
Wayne Davison
4c4266d9c9 Change to try to debug a failure on the build farm. 2004-02-02 22:18:23 +00:00
Wayne Davison
54e87b4b06 Don't warn about lack of -l support if we're the sender -- we just won't
send the receiver any symlinks.
2004-02-02 21:33:10 +00:00
Wayne Davison
44e9e221f3 - Call init_flist().
- Got rid of the symbolic-links-warning code (it was not right, and it is
  now handled in options.c).
2004-02-02 21:33:06 +00:00
Wayne Davison
61dec11ae0 - Use as little memory as possible for the file_struct (saves another 3
bytes per file).
- Made the idev struct allocated by the group-malloc again (J.W. suggested
  the proper way to align it for all systems).
- Added init_flist().
2004-02-02 21:33:03 +00:00
Wayne Davison
5009de7d2d Added comment about the position of file_list's "flags" var. 2004-02-02 21:32:56 +00:00
Wayne Davison
67f3feebcb Don't free link_u.idev. 2004-02-02 21:32:52 +00:00
Wayne Davison
b22260749f Use "%H:%M:%S" instead of "%T" in strftime() call since it looks to be
more portable.
2004-02-02 21:02:13 +00:00
Wayne Davison
06d76beb28 Clarify the safe/unsafe symlink options in the usage text. 2004-02-02 18:25:37 +00:00
Wayne Davison
7af4227ac2 Clarify the various safe/unsafe symlink options. 2004-02-02 18:23:09 +00:00
Wayne Davison
9312b7325e Go back to using malloc() for the hard-link data structure (for now
at least).
2004-02-02 07:06:54 +00:00
Wayne Davison
c6edb381f5 Free the hlink data again. 2004-02-02 07:06:50 +00:00
Wayne Davison
a1d55ad095 Make sure that the idev struct's data is 4-byte aligned. 2004-02-02 06:52:49 +00:00
Wayne Davison
a289addd96 - Changed the file-list allocation to alloc all the memory we need
with one call, not with several mallocs and strdups.
- Got rid of string_area() stuff (as suggested in the "@todo").
- Enhanced free_file() to optionally free the whole struct or to
  clear it (since we don't need to do both).
- Don't zero out the other flist data when we're about to free it.
2004-02-02 05:06:36 +00:00
Wayne Davison
13c5b46361 Don't free the hlink data (it is not separately allocated anymore). 2004-02-02 05:06:35 +00:00
Wayne Davison
f3af206d8d Changed args to make_file() and free_file(). 2004-02-02 05:06:34 +00:00
Wayne Davison
df0054ab13 Added CLEAR_STRUCT and FREE_STRUCT defines. 2004-02-02 05:06:33 +00:00
Wayne Davison
0d162bd17c Added some missing #if SUPPORT_HARD_LINK and #if SUPPORT_LINK directives. 2004-02-01 17:37:14 +00:00
Wayne Davison
e1add89334 - Fixed the bug where the --daemon option would squelch all option errors
for later parameters.
- Complain if someone passes us -l and we don't support symlinks.
2004-02-01 17:29:41 +00:00
Wayne Davison
22d49dc429 Changed the rdev code to have both an "rdev" variable (which always
has the full device value) and an "rdev_high" variable (which zeros
the lower byte in the last rdev value).
2004-02-01 16:28:31 +00:00
Wayne Davison
1aa4caf318 One more improvement to the 0-flag-byte avoidance algorithm. 2004-01-31 22:40:55 +00:00
Wayne Davison
306ffb8c71 A small optimization to the symlink-send code, and an extra sanity
check to the symlink-receive code.
2004-01-31 21:01:01 +00:00
Wayne Davison
0a98201164 Fixed the test to ensure that we don't send a flag-byte of 0 to the
receiver when transferring the file list.
2004-01-31 20:24:52 +00:00
Wayne Davison
e0870f1d7a One more minor variable-name change. 2004-01-31 11:36:03 +00:00
Wayne Davison
1923b1fce4 Switched a buffer name in make_file() to make the code a little more
similar to what is in receive_file_entry().
2004-01-31 11:32:30 +00:00
Wayne Davison
5dc4003e63 Fixed the optional sanitization of the files_from arg. 2004-01-30 16:14:46 +00:00
Wayne Davison
37c817eb81 OK, "find ... -print0 | xargs -0 ..." wasn't portable. This is. 2004-01-28 01:39:29 +00:00
Wayne Davison
284d628a7c Got rid of indeterminacy in the overlapping-files. 2004-01-28 00:37:55 +00:00
Wayne Davison
ff3184ca1e A couple more unsigned char changes to silence compiler warnings
on signed-char systems (like Solaris).
2004-01-28 00:04:57 +00:00
Wayne Davison
12865a9762 New test to make sure that merging files from multiple directories
continues to work.
2004-01-27 23:56:00 +00:00
Wayne Davison
ea847c6232 Use who_am_i() to qualify some debug messages. 2004-01-27 23:13:15 +00:00
Wayne Davison
b695f2423d Set the am_generator flag. Use who_am_i(). 2004-01-27 23:13:14 +00:00
Wayne Davison
c3e5e5851b New function: who_am_i() returns "sender", "receiver", or "generator". 2004-01-27 23:13:13 +00:00
Wayne Davison
4337c8f856 Added "am_generator". 2004-01-27 23:13:12 +00:00
Wayne Davison
4c7e46079d Don't free lastdir! It is still needed by the flist basedir pointers.
Also, output the basedir pointer when dumping the flist for debugging.
2004-01-27 23:00:47 +00:00
Wayne Davison
72a6e63136 Relocated the externs. 2004-01-27 22:35:15 +00:00
Wayne Davison
37101856a6 Silenced some compiler warnings. 2004-01-27 16:27:05 +00:00
Wayne Davison
65fc84b32e Better pid handling. 2004-01-27 08:14:33 +00:00
Wayne Davison
45e08edb08 Cast getpid() to a long for output. 2004-01-27 08:02:31 +00:00
Wayne Davison
05b7bab8e1 Better pid handling. 2004-01-27 07:57:12 +00:00
Wayne Davison
904817552d Fixed a comment. 2004-01-27 07:48:57 +00:00
Wayne Davison
6e195fe975 Tweaked the externs. 2004-01-27 07:48:19 +00:00
Wayne Davison
3eaf615f40 Percentage of file-count output was off by one. 2004-01-27 06:51:39 +00:00
J.W. Schultz
6156e72f85 EXCLUDE PATTERNS is not just about syntax. 2004-01-27 05:00:43 +00:00
Wayne Davison
73a4bdfd77 Mention the latest -x improvement. Also improved the description of
one of my previous fixes.
2004-01-27 03:49:54 +00:00
Wayne Davison
4844449a5d Optimized the -x option by removing the skip_filesystem() call and using the
new FLAG_MOUNT_POINT flag.
2004-01-27 01:47:41 +00:00
Wayne Davison
ae289aec1e Added FLAG_MOUNT_POINT. 2004-01-27 01:47:40 +00:00
Wayne Davison
9e4c32ea54 Tweaked a comment. 2004-01-27 01:27:37 +00:00
Wayne Davison
a5f9cff256 Improved the differentiation of the transmit flags from the live flags
by naming the transmit flags with an XMIT_ prefix.  Improved the names
of two other flags, got rid of the LIVE_FLAGS mask, and shortened the
flag storage in the flist struct (to save memory).
2004-01-27 01:05:14 +00:00
Wayne Davison
d01d15e096 Use the new names for the transmit-flag defines. We also make sure
that the FLAG_TOP_DIR flag doesn't get set in the live data for a
non-directory (when it's used as a kluge to prevent a 0x00 byte being
sent over the wire for the flag data).
2004-01-27 01:05:13 +00:00
Wayne Davison
a53426441b Use the new names for the transmit-flag defines. 2004-01-27 01:05:12 +00:00
Wayne Davison
5d1966948e Fixed reference to -u that should have been -o. 2004-01-26 22:35:04 +00:00
J.W. Schultz
f673ea84b2 Back out bad refactor (thanks Wayne) 2004-01-26 20:54:02 +00:00
Wayne Davison
64f21c31bf Mention new hard-link optimization. 2004-01-26 04:21:59 +00:00
Wayne Davison
520cf41711 Added defines (FLAG_HLINK_EOL, HL_CHECK_MASTER, and HL_SKIP) and changed
the struct hlink to have an index into the hlink_list[] array instead of
a head pointer.
2004-01-25 22:32:11 +00:00
Wayne Davison
d38fc30563 We now link the hard-linked flist entries into a circular list, mark
the last item with FLAG_HLINK_EOL, and save off an index for our
master entry in the hlink_list[] array.  Added the hard_link_check()
function.
2004-01-25 22:32:10 +00:00
Wayne Davison
6dff599288 Use the new hard_link_check() function to figure out which one of the
hard-linked files to send (when -H was specified, of course).  Moved
the call to do_hard_links() and the final directory-permissions scan
into generate_files() from recv_files().
2004-01-25 22:32:09 +00:00
Wayne Davison
f746dda0a0 Moved the call to do_hard_links() and the final directory-permissions
scan from recv_files() into generate_files().
2004-01-25 22:32:08 +00:00
Wayne Davison
91a1e147ae Changed F_HEAD to F_HLINDEX. 2004-01-25 22:32:07 +00:00
Wayne Davison
40da904230 Tweaked a comment. 2004-01-25 22:32:05 +00:00
J.W. Schultz
34fada3012 Tightened up code in skip_filesystem() 2004-01-25 22:11:09 +00:00
Wayne Davison
f91e01d9a5 Replaced an snprintf() call with pathjoin(). 2004-01-24 22:12:58 +00:00
Wayne Davison
3048b0a8ea The static last_in value in match_gid() needed to default to -2 so
that we don't accidentally return a GID of 0 when we don't have the
permissions to set it.
2004-01-24 18:36:36 +00:00
Wayne Davison
d99b4ccf93 Another improvement in the "use chroot" section. 2004-01-24 01:48:12 +00:00
Wayne Davison
58811a0a38 Refer to I/O (not IO), ID (not id), and "an rsync" (not "a rsync"). 2004-01-23 16:58:24 +00:00
Wayne Davison
cb290916be Improved the "use chroot" discussion on ID mapping. 2004-01-23 16:55:40 +00:00
Wayne Davison
a2b0471f1d More changes to make the --owner and --group items clearer. 2004-01-23 16:40:17 +00:00
Wayne Davison
bb18e7550c Use "an" in front of rsync, not "a". 2004-01-23 09:34:04 +00:00
Wayne Davison
db2b5cb75f Tweaked the --help text to refer to I/O (not IO) and use "an" in
front of rsync (not "a").
2004-01-23 09:32:50 +00:00
Wayne Davison
fa8c787d8b Improved the "use chroot" section to mention how to get user/group
preservation by name (getting rid of the erroneous bit about the
--numeric-ids option being implied).
2004-01-23 09:30:45 +00:00
Wayne Davison
ec40899bb9 Improved comments on --owner and --groups, and removed misinformation
on a chroot daemon (it does not imply --numeric-ids).
2004-01-23 09:29:16 +00:00
Wayne Davison
b5accabaa7 Properly punctuate "etc." and changed all occurrences of "IO" to "I/O". 2004-01-23 08:59:19 +00:00
Wayne Davison
4e308a9526 Fixed two more misspelled words. 2004-01-23 02:02:51 +00:00
Wayne Davison
4d88810810 Some spelling corrections and other simple fixes. 2004-01-23 01:36:59 +00:00
Wayne Davison
f321922214 When setting an flist entry's flags, mask it with LIVE_FLAGS. 2004-01-22 18:39:32 +00:00
Wayne Davison
cab13afe8d A couple comment tweaks. 2004-01-22 18:37:26 +00:00
Wayne Davison
72fc7ec59b Made the getgroups() code a little more portable. This will hopefully
make the chgrp test work on the NetBSD and OpenBSD systems where it is
failing.
2004-01-22 09:16:21 +00:00
Wayne Davison
58743a87b8 Improved to add the default gid if it is missing from the list. 2004-01-22 09:13:36 +00:00
Wayne Davison
54bf456e85 Removed an obsolete comment. 2004-01-22 09:05:09 +00:00
Wayne Davison
a24639bb36 Tweaked an argv-type variable so that it's a little clearer what
the code is doing.  Also added a comment.
2004-01-22 04:40:33 +00:00
Wayne Davison
3fef53645d Use the new f_name_to() calling syntax. 2004-01-22 04:38:18 +00:00
Wayne Davison
882e689312 - Ensure in make_file() that we can't make a name that overflows
our buffers (note that receive_file_entry() already does this).
- Changed f_name_to() to not do any length checking since it is
  now redundant.
2004-01-22 04:38:17 +00:00
Wayne Davison
b0a93231cf Added more missing news. 2004-01-22 02:02:00 +00:00
Wayne Davison
0c819b76d6 New news. 2004-01-22 01:23:43 +00:00
Wayne Davison
ce58b1b479 Size-check the --temp-dir string so we don't have to worry about it
overflowing elsewhere in the code.
2004-01-22 01:20:24 +00:00
Wayne Davison
a16d8f2b25 Improved a couple comments. 2004-01-21 02:45:10 +00:00
Wayne Davison
59187666b9 Use new push_dir() syntax. 2004-01-20 17:46:31 +00:00
Wayne Davison
808c57c343 - Use the new push_dir() and pop_dir() calling syntax.
- The "olddir" handling changed to accommodate the above, and to
  avoid using malloc()/free().
2004-01-20 17:46:30 +00:00
Wayne Davison
4af8fe4e78 - Changed push_dir() to not take a "save" arg and to return 1 or 0
for success or failure instead of a string pointer.  The function
  also ensures that we don't overflow the curr_dir[] buffer.
- Changed pop_dir() to not free() anything and to return 1 or 0
  for success or failure.
2004-01-20 17:46:29 +00:00
Wayne Davison
4034cb3f71 Use new stringjoin() function. 2004-01-20 05:35:57 +00:00
Wayne Davison
6fc048f438 Find last '@' in the user@site string, just in case the username has
a '@' in it.
2004-01-20 05:27:09 +00:00
Wayne Davison
5d2a707139 Use new stringjoin() and pathjoin() functions. 2004-01-20 05:24:07 +00:00
Wayne Davison
81d2b0ef9d Use new pathjoin() function. 2004-01-20 05:15:14 +00:00
Wayne Davison
248ed45fc6 Use new pathjoin() function. 2004-01-20 05:09:36 +00:00
Wayne Davison
893c4cc056 Use new stringjoin() function. 2004-01-20 04:56:20 +00:00
Wayne Davison
a7725e6df9 Use new pathjoin() function. 2004-01-20 04:53:59 +00:00
Wayne Davison
368ad70e05 Added stringjoin() and pathjoin(). 2004-01-20 04:43:49 +00:00
J.W. Schultz
b7cee9498b Eliminate unneeded strlen after strlcpy. 2004-01-20 03:37:04 +00:00
Wayne Davison
72d45525d2 Make sure that strlcpy() returns the right value when the bufsize is 0. 2004-01-20 00:59:26 +00:00
Wayne Davison
1fb8ec4b0d Fixed a bug in strlcat() where it would not properly detect a no-change
condition if called with an initial string longer than the specified
size limit (due to an unsigned var's inability to go negative).
2004-01-20 00:29:49 +00:00
Wayne Davison
beb9368481 Make sure that the batch-prefix string isn't overly long (avoiding
a potential problem in the batch-filename code).
2004-01-19 23:33:02 +00:00
Wayne Davison
981555bddb Actually, let's avoid snprintf() where possible. 2004-01-19 23:28:57 +00:00
Wayne Davison
9c7527085c Use snprintf() instead of strlcpy()+strlcat(). 2004-01-18 21:22:49 +00:00
Wayne Davison
eddd5d129e A few minor string optimizations and a new complaint if we try to
send a truncated filename.
2004-01-17 19:45:26 +00:00
Wayne Davison
26f76b7912 Got rid of an extra call to io_start_buffering_out(). 2004-01-17 05:04:04 +00:00
Wayne Davison
32eda0961e Unified the externs. 2004-01-17 04:58:24 +00:00
Wayne Davison
66964002df A fix for --cvs-exclude. 2004-01-17 01:23:41 +00:00
Wayne Davison
57469f6c31 Items read from a per-directory .cvsignore file should be added to the
local_exclude_list, not the exclude_list.
2004-01-17 01:16:49 +00:00
Wayne Davison
13c7bcbb2b Output an error before we die if we get a wacko message from the receiver. 2004-01-16 16:31:47 +00:00
Wayne Davison
d48c806560 Clarified the --delete-after descriptions. 2004-01-15 17:45:53 +00:00
Wayne Davison
ad1a09a509 Clarified the --delete-after help text. 2004-01-15 17:43:34 +00:00
Wayne Davison
d6631cf3a5 If we're a daemon talking with a pre-28 protocol, use FERROR for a
vanished-file message (not FINFO).
2004-01-15 08:56:33 +00:00
Wayne Davison
5a8543b8b8 In two places: needed to use protocol_version, not PROTOCOL_VERSION. 2004-01-15 08:39:25 +00:00
Wayne Davison
19119cbd35 Changed version to "2.6.1cvs". 2004-01-15 08:16:40 +00:00
Wayne Davison
442743b83c Improved receiver/generator communications. 2004-01-15 07:51:37 +00:00
Wayne Davison
419896af47 - Define FULL_FLUSH and NORMAL_FLUSH.
- Got rid of FNONE from logcode enum.
- Created msgcode enum with MSG_DATA, MSG_REDO, MSG_DONE, etc.
2004-01-15 07:42:27 +00:00
Wayne Davison
0569a1339d - Got rid of the f_gen pipe.
- Use new send_msg() call with MSG_DONE or MSG_REDO.
2004-01-15 07:42:25 +00:00
Wayne Davison
f1e3656ee2 - Call io_flush() with its new FULL_FLUSH/NORMAL_FLUSH arg.
- Got rid of the recv_pipe between the receiver and the generator.
- Use new send_msg(MSG_DONE,...) call to signal the generator
  when the receiver is done.
- Use the new get_redo_num() call in the generator to read the
  final -1 from the receiver.
2004-01-15 07:42:21 +00:00
Wayne Davison
a644fc3cc4 - Moved err_list* stuff to io.c and renamed them to msg_list*.
- Call the new send_msg() function to send a remote log message.
2004-01-15 07:42:19 +00:00
Wayne Davison
d17e1dd2da - Moved the err_list* stuff here from log.c and renamed them msg_list*.
- Renamed log_error_fd to msg_fd_out, and io_error_fd to msg_fd_in.
- Added a redo_list* to keep track of any redo items that come over
  the message channel from the receiver to the generator.
- The io_flush() and msg_list_push() functions now take an arg:
  NORMAL_FLUSH or FULL_FLUSH.  The latter ensures that we don't lose
  any log messages that haven't gotten written from the msg_list.
- Added a send_msg() function that log.c calls to send any remote
  log messages.  It is also called to send the new MSG_REDO and
  MSG_DONE messages.
2004-01-15 07:42:17 +00:00
Wayne Davison
b9b15fb165 We now call get_redo_num() instead of reading f_recv (which was removed). 2004-01-15 07:42:15 +00:00
Wayne Davison
ef732c3b54 Call io_flush() with its new FULL_FLUSH option. 2004-01-15 07:42:12 +00:00
Wayne Davison
baa4212ae1 If the do_lchown() fails and we weren't trying to change the user,
the error now says that chgrp failed, not chown.
2004-01-15 07:08:00 +00:00
Wayne Davison
0be976ec0a Fixed a bug when a non-root user copies a GID=0 file with -g set
and no permissions to set group 0.
2004-01-15 07:06:45 +00:00
Wayne Davison
f7f10340d6 The HAS_INODE_DATA flag is no longer a part of the LIVE_FLAGS define. 2004-01-15 02:25:38 +00:00
Wayne Davison
68f9910d94 Explain the --progress output. 2004-01-13 18:50:40 +00:00
Wayne Davison
fb6e0ea120 Give the user an idea of how far along in the transfer we are
when using --progress.
2004-01-13 18:25:03 +00:00
Wayne Davison
97feb557ed Set stats.current_file_index. 2004-01-13 18:22:43 +00:00
Wayne Davison
dc8293ff73 Added current_file_index. 2004-01-13 18:22:13 +00:00
Wayne Davison
785db4ced0 Merged a couple more f != -1 if sections. 2004-01-13 06:27:30 +00:00
Wayne Davison
5562deb169 Moved a couple externs. 2004-01-13 05:13:57 +00:00
Wayne Davison
983b1ed321 Merged some "if (f != -1)" checks, put the clean_flist() call in the
right spot, and moved some externs.
2004-01-13 05:11:56 +00:00
Wayne Davison
548abf96ce Relocated some externs. 2004-01-13 04:50:45 +00:00
Wayne Davison
f8ebdf9265 More hard-link stuff. 2004-01-12 03:59:53 +00:00
Wayne Davison
aa23c22004 Changed the hard-link check. 2004-01-12 03:50:07 +00:00
Wayne Davison
1d5cda2265 Updated to perform a much more efficient hlink algorithm that doesn't
require any binary searching of hlink data.
2004-01-12 03:49:47 +00:00
Wayne Davison
fe70ad26d3 Added F_HEAD and F_NEXT defines. 2004-01-12 03:48:43 +00:00
Wayne Davison
0a00748901 Mention more of the latest changes. 2004-01-11 22:39:34 +00:00
Wayne Davison
03979352b4 More cleanup, fixing an error in the fatal-message strings that tried
to output the "filename" value when it might not be initialized.
2004-01-11 22:11:25 +00:00
Wayne Davison
cb7fb45e42 Updated a questioning comment. 2004-01-11 08:17:19 +00:00
Wayne Davison
92cc9dd7c2 Use the new dev+inode union in the flist_struct. 2004-01-11 07:56:14 +00:00
Wayne Davison
88a7fb3edd Moved the inode & dev items out of the flist_struct. Based on a
preliminary patch by J.W.
2004-01-11 07:55:53 +00:00
Wayne Davison
728d092201 Use the new union-ified flist_struct values. 2004-01-11 07:28:45 +00:00
Wayne Davison
80707c983c Put 3 flist_struct items into a union: rdev, sum, and link (all
mutually exclusive based on mode).  Based on an idea by J.W.
2004-01-11 07:28:23 +00:00
Wayne Davison
5911fee567 A slightly better reset mechanism for send_file_entry() and
receive_file_entry().
2004-01-10 22:13:19 +00:00
Wayne Davison
a09f6f55da Use the new LIVE_FLAGS define to fix a potential flag problem. 2004-01-10 21:10:04 +00:00
Wayne Davison
caf5cc9152 Added LIVE_FLAGS define. 2004-01-10 21:09:06 +00:00
Wayne Davison
58422e8393 Changed the call to write_batch_csum_info() to the latest syntax. 2004-01-10 20:16:18 +00:00
Wayne Davison
e8d3168e3a Massive rewrite to replace the file-list read/write code with calls to
send_file_entry() and receive_file_entry().  Other cleanups too.
2004-01-10 20:16:13 +00:00
Wayne Davison
7b1a0c19b8 Allow the send_file_entry() and receive_file_entry() routines to be
called by the batch processor.
2004-01-10 20:15:55 +00:00
Wayne Davison
536492752b Support the recent changes in the flist_struct. 2004-01-10 08:39:57 +00:00
Wayne Davison
7c4f063b13 Got rid of tmpsum[]. 2004-01-09 18:35:41 +00:00
Wayne Davison
1a62c49d31 Note latest changes. 2004-01-09 18:27:15 +00:00
Wayne Davison
fea4db62bd - Never allocate a useless sum array for a non-regular flist item.
- Don't transmit the sum array for non-regular files (p28 onward).
- Tweaked a couple comments.
2004-01-09 18:19:32 +00:00
Wayne Davison
4499c0eebd A couple minor code improvements. 2004-01-09 18:10:31 +00:00
Wayne Davison
0c42946536 Added an extra comment. 2004-01-09 16:53:55 +00:00
J.W. Schultz
ab264c9e79 Added a few more devices to the devices.test to hopefully
test same, same high and different device numbers.
2004-01-09 14:02:00 +00:00
J.W. Schultz
dd7fb70f6e Finished the last_* renameing and fixed a cast.. 2004-01-09 13:55:56 +00:00
Wayne Davison
30f337c9ef Updated the send_file_name() and receive_file_entry() functions to make
some of the variable names more logical in the new program flow.  Also
improved the setting of the new last_rdev value that only remembers the
high 3 bytes.
2004-01-08 22:45:12 +00:00
Wayne Davison
9d35271938 Changed the OLD_SAME_RDEV define to SAME_RDEV_pre28. 2004-01-08 22:45:07 +00:00
Wayne Davison
bbfb1d016b Added explicit call to AC_PROG_EGREP. 2004-01-08 18:33:38 +00:00
Wayne Davison
c4b4df4fb4 Optimized the sending of dev+inode data for hard-linking support
(but only when speaking protocol 28).
2004-01-08 11:29:50 +00:00
Wayne Davison
a6d89d18bf - Added flags HAS_INODE_DATA and SAME_DEV.
- Changed PROTOCOL_VERSION to 28 now.
2004-01-08 11:28:07 +00:00
Wayne Davison
75bc860093 Implemented an extended-flag-byte in the transfer protocol by moving
the SAME_RDEV bit into the next 8 bits and adding an EXTENDED_FLAG
bit.  Also modified the meaning of this bit for protocol 28 and above:
SAME_HIGH_RDEV indicates that all but the lowest byte matches.  The
older protocols get OLD_SAME_RDEV set (with the old semantics) for
compatibility.  Note also that protocol 28 isn't turned on yet.
2004-01-08 11:08:30 +00:00
Wayne Davison
02a279a75f Added EXTENDED_FLAGS and SAME_HIGH_RDEV. Changed SAME_RDEV to OLD_SAME_RDEV. 2004-01-08 11:08:30 +00:00
Wayne Davison
584c7bf76d Pass the $srcdir/wildtest.txt file on the command-line to wildtest. 2004-01-08 09:00:14 +00:00
Wayne Davison
c4cd2ca6bf We now take a TESTFILE arg on the command-line. 2004-01-08 08:59:52 +00:00
Wayne Davison
1ef00d2072 Improved the code in send_file_entry() and receive_file_entry() to
make it a little easier to read and a little more optimized.  Also
made the flag size in our function calls match the size of the flags
in the flist_struct.  These changes will make it easier for me to
optimize the sending of the hard-link data in a future commit.
2004-01-08 04:56:27 +00:00
Wayne Davison
4dd4c72790 Made the flags in the file_struct a little smaller. 2004-01-08 04:53:16 +00:00
Wayne Davison
6aae748ea7 - No need to check S_ISREG() on files already in the hlink_list.
- The realloc in init_hard_links() might fail if the list is empty
  (which can happen if there are no regular files in the transfer).
  I changed the code to free the list in that case.
2004-01-08 03:17:07 +00:00
Wayne Davison
aa953c3201 Old-protocols. 2004-01-08 00:47:17 +00:00
Wayne Davison
3f55bd5dad Got rid of support for protocols 17 and 18. 2004-01-08 00:45:41 +00:00
J.W. Schultz
279b1c1ebb Noted hardlink memory footprint reduction. 2004-01-07 11:38:23 +00:00
J.W. Schultz
fa45cda1aa Cosmetic changes to file_compare() for readability and to
match hlink_compare()
2004-01-07 09:11:56 +00:00
J.W. Schultz
11dc274054 Change hlink_list so we only have a list of pointers to
file_struct instead of a copy of the file_struct list.
2004-01-07 09:06:37 +00:00
Wayne Davison
e7bef92205 Batch-mode fix. 2004-01-06 05:35:55 +00:00
Wayne Davison
4a1991d7c5 Fixed a byte-order problem for batch-file processing on big-endian
systems (reported by Jay Fenlason).
2004-01-06 05:33:02 +00:00
Wayne Davison
13aefa1365 Some whitespace tweaks. 2004-01-05 03:57:15 +00:00
Wayne Davison
addf0c4a1c A few formatting tweaks. 2004-01-05 03:56:19 +00:00
Wayne Davison
25bfc8cea1 Use new recv_generator() calling syntax. 2004-01-04 19:18:37 +00:00
Wayne Davison
dfd5ba6ab7 Changed recv_generator() to take a "struct file_struct *" instead of
a "struct file_list *", which allows us to call it with a copy of the
current file_struct entry that we've modified.  This is better than
modifying the entry directly because the latter causes the shared
memory between the generator and the receiver to slowly vanish as
the in-memory changes happen.
2004-01-04 18:43:18 +00:00
Wayne Davison
393ba2214d Try using "id -un" before "whoami" since the latter doesn't exist on
SunOS systems (and I hope the former works -- we'll see).
2004-01-04 07:07:08 +00:00
Wayne Davison
f358487f8e Silence a compiler warning on Sun OS systems. 2004-01-04 07:06:05 +00:00
Wayne Davison
a18381aca6 Improved the text. 2004-01-03 20:50:51 +00:00
Wayne Davison
f6e54812b7 Fixed autom4te*.cache entry. 2004-01-03 19:49:52 +00:00
Wayne Davison
31e7451aa5 Mention more INTERNALS work. 2004-01-03 19:28:17 +00:00
Wayne Davison
0e36d9da42 More variable-size cleanup. 2004-01-03 19:28:03 +00:00
Wayne Davison
da9d12f5d9 Made the types used in the sum_buf and sum_struct structures consistent
with the variables in the code that manipulates these values.
2004-01-03 18:37:41 +00:00
J.W. Schultz
a60e2dca6b Create GID_NONE for use gid test readability. 2004-01-03 13:17:32 +00:00
Wayne Davison
86c4601e12 Fixed a name. 2004-01-03 09:48:52 +00:00
Wayne Davison
173f5bf8cf Fixed a size check in the new code. 2004-01-03 09:44:20 +00:00
Wayne Davison
823edc686f Document the latest changes. 2004-01-03 09:36:30 +00:00
Wayne Davison
a3a841073e Added support for "Basic" authentication to our proxy, based on a
patch by Bardur Arantsson.
2004-01-03 09:19:06 +00:00
Wayne Davison
57385128c3 Made base64_encode() non-static. 2004-01-03 08:53:36 +00:00
Wayne Davison
2990e06f29 Silence a compiler warning. 2004-01-03 01:12:10 +00:00
Wayne Davison
2ef2e822d1 Added missing '[]'s to AC_CHECK_FUNCS() calls so that this works
with autoconf 2.58 and above.
2004-01-03 00:40:55 +00:00
Wayne Davison
b7736c797c Some cosmetic tweaks. 2004-01-02 23:41:32 +00:00
Wayne Davison
9b9c8aaf4d Improved flush_write_file(). 2004-01-02 18:42:33 +00:00
Wayne Davison
b0fd253afc Applied a slightly-tweaked version of Oliver Braun's patch that
implements listening on multiple addresses and a fix for IPv6-only
systems.
2004-01-02 18:05:51 +00:00
Wayne Davison
e028b9ff53 Call bind() with the right ai_addr/ai_addrlen info. 2004-01-02 17:47:44 +00:00
Wayne Davison
9c07d25345 Tidied up a few things in preparation for changes. 2004-01-02 17:20:21 +00:00
Wayne Davison
7352b8736b Moved the is_in_group() function to uidlist.c. 2004-01-02 16:52:29 +00:00
Wayne Davison
5b540e86a4 Set the file's gid to -1 if we don't have permissions to set it. 2004-01-02 16:51:54 +00:00
Wayne Davison
6744b62ddd Fixed --link-dest's check for identicalness to ignore the uid if
non-root, and to ignore a gid of -1.
2004-01-02 16:50:06 +00:00
Wayne Davison
e90b8acec3 Silence some compiler warnings. 2004-01-02 08:50:25 +00:00
Wayne Davison
925c517f19 Improved the setting of cleanup_got_literal so that we know if the
current file received some literal data yet or not.
2004-01-02 08:38:35 +00:00
Wayne Davison
cc964a518c Use the new f_name_to() call instead of strlcat() an f_name(). 2004-01-02 08:36:58 +00:00
Wayne Davison
3309507dd3 Some minor changes to some if statements. 2004-01-02 08:33:57 +00:00
Wayne Davison
5e7dbaca50 Use buffered I/O to read the exclude list. 2004-01-02 08:31:12 +00:00
Wayne Davison
76c2194714 Applying my updated version of Craig Barratt's buffered I/O patch. 2004-01-02 08:29:49 +00:00
Wayne Davison
968c8030cf Some name tweaks. 2004-01-02 08:19:26 +00:00
Wayne Davison
446e239e2c Use the f_name_to() function to avoid having to strdup() the name that
f_name() returns.  Also used in a call to recv_generator() to keep the
name safe for the duration of the call.
2004-01-02 08:18:53 +00:00
Wayne Davison
e7bc9b64a3 Use f_name_to() when producing a name for the recv_generator() call.
This prevents things like the hard-link code from losing the name
before we're finished with it.
2004-01-02 08:05:20 +00:00
Wayne Davison
8018edd3aa Optimized f_name(), generating: (1) f_name_cmp(), which optimizes
comparing two file_struct elements without copying them first, and
(2) f_name_to() which lets us supply the destination buffer for a
f_name() call (to allow it to persist without an extra copy).
2004-01-02 07:57:02 +00:00
Wayne Davison
64c3523a6f Got rid of /* dw */ comments. 2004-01-02 07:42:20 +00:00
Wayne Davison
310c9f30f0 Optimized hard_link_one() to not call f_name() so many times. 2004-01-02 07:34:49 +00:00
Wayne Davison
5c1b7bfd2a No need to conditionally-compile EINTR code -- no other files do this. 2004-01-02 07:31:02 +00:00
Wayne Davison
faf11086d8 More twiddling of the wildcard verbage. 2004-01-02 07:11:32 +00:00
Wayne Davison
52fa4d7893 Improved the itemized discussion under the wildcard changes. 2004-01-01 22:37:13 +00:00
Wayne Davison
de0551020b Allow function return values to start with "const". 2004-01-01 21:10:50 +00:00
Wayne Davison
c1456d83a7 Tweaked the date. 2004-01-01 19:00:11 +00:00
Wayne Davison
1cbbaea957 Preparing for release of 2.6.0 2004-01-01 11:36:16 +00:00
Wayne Davison
f6aeaa74d1 One more tweak to --modify-window verbage. 2003-12-30 18:17:16 +00:00
Wayne Davison
6839140eb5 Shorten some of the lines in the --help output. 2003-12-30 18:16:25 +00:00
Wayne Davison
915dd20705 Shortened a few lines, plus a couple minor tweaks. 2003-12-30 17:44:01 +00:00
Wayne Davison
c53217a2b8 Changed the VERSION section to refer to 2.x instead of 2.0. 2003-12-29 09:58:06 +00:00
Wayne Davison
b2ac00eb16 Preparing for release of 2.6.0pre2 2003-12-28 21:11:38 +00:00
Wayne Davison
45ddbf6204 Make the upper copyright year "2004". 2003-12-28 20:48:06 +00:00
Wayne Davison
276877cf77 Aged news from NEWS to OLDNEWS. 2003-12-27 00:14:21 +00:00
Wayne Davison
6b45fcf160 Undid previous change. 2003-12-26 23:04:01 +00:00
Wayne Davison
49c24eccd4 A change that wasn't needed. 2003-12-26 22:59:53 +00:00
Wayne Davison
0d7d3763f2 Use %{version} to refer to the current version. 2003-12-24 17:48:25 +00:00
Wayne Davison
241dc65eee Getting rid of klunky *.tmpl files. 2003-12-24 17:46:46 +00:00
Wayne Davison
860bdd4571 Mention the new-backup-dir mode change. 2003-12-24 01:46:38 +00:00
Wayne Davison
55bf051bbc Getting rid of an extra newline that accidentally crept into the code. 2003-12-24 01:46:07 +00:00
Wayne Davison
423dba8ea1 Simplified an internal function's name to remove a potentially
cryptic suffix.
2003-12-24 01:14:16 +00:00
Wayne Davison
517c7b4dee Updated the copyright year. 2003-12-20 18:00:13 +00:00
Wayne Davison
18ced14631 Output a warning about the new remote-shell default if the --with-rsh
option wasn't used.
2003-12-20 17:57:47 +00:00
Wayne Davison
ce67256218 Output a newline before the heap statistics. 2003-12-20 16:57:24 +00:00
Wayne Davison
9e83fa99fe - Mention the extra newlines in the verbose/stats output.
- Made some spelling corrections.
2003-12-20 16:56:51 +00:00
Wayne Davison
256a9e376c Added a couple missing items from John Van Essen. 2003-12-20 16:51:13 +00:00
Wayne Davison
ef5075e092 Quiet a compiler warning. 2003-12-19 22:19:54 +00:00
Wayne Davison
65653a6596 Mention the change we made to help ssh cleanup the tty on Ctrl-C. 2003-12-19 20:21:17 +00:00
Wayne Davison
d5a0b48379 Do a small msleep() in the sig_int() handler before shutting down.
This kluge allows things like SIGINT to find our children before
we go throwing around SIGUSR1's at them.
2003-12-19 06:52:02 +00:00
Wayne Davison
314a74d731 Got rid of the RSYNC_RSH_IO stuff for now. 2003-12-17 09:29:35 +00:00
Wayne Davison
90e22f4b51 Backed out the RSYNC_RSH_IO support for now. 2003-12-17 09:28:45 +00:00
J.W. Schultz
ab304c268c Removed hardlink reporting bug from TODO list -- seems to be
fixed.
2003-12-17 00:52:01 +00:00
J.W. Schultz
16a3fec02d Added keword base reporting to TODO features list. 2003-12-17 00:49:50 +00:00
J.W. Schultz
abb0b532f8 Reorganized and cleaned up TODO list. 2003-12-17 00:47:39 +00:00
Wayne Davison
43cd760fc1 - Changed the places that talked about rsh being the default shell.
- Document the new RSYNC_RSH_IO environment variable.
2003-12-16 23:07:19 +00:00
Wayne Davison
9af87151ec We now support an environment variable named RSYNC_RSH_IO which lets the
user set the blocking-IO value for the shell specified by RSYNC_RSH.
2003-12-16 23:06:25 +00:00
Wayne Davison
8dd99390f5 Added RSYNC_RSH_IO_ENV. 2003-12-16 23:04:59 +00:00
Wayne Davison
e636af6b23 Mention change to ssh. 2003-12-16 19:48:25 +00:00
Wayne Davison
e3217f1448 Tweaked an obsolete comment. 2003-12-16 18:02:15 +00:00
Wayne Davison
66b711633f Improved the default-blocking-I/O code to discern rsh from ssh
properly.
2003-12-16 18:02:03 +00:00
Wayne Davison
f40f2fc8ce Made the default remote-shell be "ssh" (override with --with-rsh=FOO). 2003-12-16 18:01:06 +00:00
Wayne Davison
e6f9e388cf Moved the information on the single-use ssh key so that the --server
option wasn't being mentioned early in the rsync manpage (which has
confused at least one user trying to figure out the --daemon mode
command-line syntax).
2003-12-15 20:10:21 +00:00
Wayne Davison
3c1e2ad956 Document new error code 24. 2003-12-15 19:49:38 +00:00
Wayne Davison
e6d2799170 Updated version. 2003-12-15 19:04:04 +00:00
Wayne Davison
2cfbf4bc0e Changed the version to 2.6.0pre1. 2003-12-15 19:00:20 +00:00
Wayne Davison
f7731f1fc2 Removed some obsolete items. 2003-12-15 18:45:27 +00:00
Wayne Davison
7d3f8ae2df Make sure we only use blocking-I/O if blocking_io is > 0. 2003-12-15 18:45:07 +00:00
Wayne Davison
a60fdd63f4 Changed version to 2.6.0. 2003-12-15 18:25:10 +00:00
Wayne Davison
3a7dec59bc Changed version to 2.6.0 in preparation for new release. 2003-12-15 18:22:12 +00:00
Wayne Davison
880ae34190 Got rid of setgroups() caveat for OSX -- we fixed that a while back. 2003-12-15 18:20:06 +00:00
Wayne Davison
d00daf1f3f Mentioned the vanished-file warning enhancement. 2003-12-15 08:44:55 +00:00
Wayne Davison
17fadf7d40 Twiddled some whitespace and multi-line comments. 2003-12-15 08:14:27 +00:00
Wayne Davison
06c28400fa New "io_error" variable handling for RERR_VANISHED support. 2003-12-15 08:10:31 +00:00
Wayne Davison
6e35c72fdb Return new RERR_VANISHED code, as appropriate. 2003-12-15 08:08:44 +00:00
Wayne Davison
e2d22fee53 Added new IOERR_* defines. 2003-12-15 08:07:38 +00:00
Wayne Davison
1bca1de6cc Handle new RERR_VANISHED error. 2003-12-15 08:06:52 +00:00
Wayne Davison
e0ed4e4087 Added RERR_VANISHED. 2003-12-15 08:04:14 +00:00
Wayne Davison
4a7319be12 Neatened up some whitespace issues and made multi-line comments more
consistent.
2003-12-15 01:45:01 +00:00
Wayne Davison
55d5937dd6 Simplified the setting of the reading_remotely variable in function
read_filesfrom_line() now that remote_filesfrom_file is set more
often.
2003-12-15 00:54:44 +00:00
Wayne Davison
63596e1c4a If we're the server and --files-from is "-", set remote_filesfrom_file
to "-" as well (since the data is coming over the socket from the remote
side).
2003-12-15 00:53:07 +00:00
Wayne Davison
603e6b05c7 Neatened up the indentation. 2003-12-12 17:13:22 +00:00
J.W. Schultz
dfad66a838 Sanity check s2length on recept. 2003-12-06 21:35:34 +00:00
Wayne Davison
58cadc8608 Merged in the security fixes from 2.5.7. 2003-12-06 21:07:27 +00:00
J.W. Schultz
b11b50bcd0 Added reminder to update rsync.yo manpage when adding to
exit codes.
2003-10-25 20:02:45 +00:00
Wayne Davison
a73de5f3ba Added exit code 0. 2003-10-25 17:53:57 +00:00
Wayne Davison
84c3645cea Updated exit codes as Jon Jensen and J.W. suggested. 2003-10-25 16:21:41 +00:00
Wayne Davison
2a88a8cd30 Fixed an operator-precedence problem in the batch-mode code. 2003-10-13 23:46:08 +00:00
Wayne Davison
8a97fc2e1b Tried to improve the documentation surrounding a trailing-slash
source-dir transfer.
2003-10-07 20:33:08 +00:00
Wayne Davison
7a2fd68b96 Tweaked the just-added error message to use my new full_fname()
function.  Also removed some trailing whitespace from lines.
2003-09-16 05:33:09 +00:00
J.W. Schultz
6a7cc46cb2 Detect and report when open or opendir succeed but read and
readdir fail caused by network filesystems issues and
truncated files.
			Thanks to David Norwood and Michael Brown
2003-09-16 02:49:59 +00:00
Wayne Davison
aa6dc37ccb Mention my recent changes. 2003-09-11 05:00:52 +00:00
Wayne Davison
ea42541fe0 Improved file-related error messages by using the new
full_fname() function.
2003-09-11 04:53:05 +00:00
Wayne Davison
b7b2741f3a Tweaked an error message. 2003-09-11 04:53:01 +00:00
Wayne Davison
eb61be192d Added a new function, full_fname(), that makes a filename more complete
for error messages.  If the path is in a module, we ensure that the
"path" setting (from the config file) is not revealed, while still
reminding the user that the path is relative to the module's root.
2003-09-11 04:48:15 +00:00
Wayne Davison
9b9114e8cd Include a few new stubs to handle the new full_fname() function. 2003-09-11 04:48:13 +00:00
Wayne Davison
857e38bb45 Got rid of some "/* dw */" comments and fixed some line's indentation. 2003-09-11 04:48:09 +00:00
Wayne Davison
4ea812445d Got rid of some "/* dw */" comments. 2003-09-11 04:48:07 +00:00
Wayne Davison
e80a765412 If lp_path() returns "/", set exclude_path_prefix to "" (because the
exclude code doesn't want any trailing slashes).
2003-09-11 04:00:19 +00:00
Wayne Davison
15089022d4 Make sure that the new slash-stripping P_PATH code doesn't turn
a "/" into an empty string.
2003-09-11 03:49:53 +00:00
Wayne Davison
f69204adad Changed main() definition to avoid an extra prototype being put
into the proto.h file.
2003-09-10 08:27:34 +00:00
Wayne Davison
459a83c9cc Make sure that the "path" value has any trailing slashes removed. 2003-09-10 08:08:14 +00:00
Wayne Davison
6464bdbe13 Got rid of trailing whitespace. 2003-09-10 07:31:58 +00:00
Wayne Davison
4f3e9a0fba Added the new --protocol option. 2003-09-09 15:58:56 +00:00
Wayne Davison
8a9709dee5 Changed most instances of "remote_version" to "protocol_version", and
others to "remote_protocol".  Downgrade the protocol_version if the
remote_protocol" is lower.  Output the protocol values if the verbose
level is large enough.  Exit if the user tried to force a protocol
value that is not within the range that we can handle.  Fixed the
output of the "very old version of rsync" message to output the right
Client/Server string.
2003-09-09 15:58:53 +00:00
Wayne Davison
daa598df11 Changed most instances of "remote_version" to "protocol_version", and
others to "remote_protocol".  Downgrade the protocol_version if the
remote_protocol is lower.
2003-09-09 15:58:50 +00:00
Wayne Davison
d04e9c51b4 Changed "remote_version" to "protocol_version". 2003-09-09 15:58:48 +00:00
J.W. Schultz
d89a3a313a *** empty log message *** 2003-09-04 05:54:20 +00:00
J.W. Schultz
350e4e4dec Allow non-dir special files to be replaced with regular
files and fix error that caused directories in link-dest or
compare-dest to prevent the creation of files of same path.
2003-09-04 05:49:50 +00:00
Wayne Davison
c95dcb3935 Cast various s->blength references inside of MIN() macros to OFF_T
so that compilers don't warn about signed/unsigned comparisons.
2003-08-22 21:26:08 +00:00
Wayne Davison
1e4f48d6c4 Whitespace tweaks. 2003-08-22 05:51:42 +00:00
Wayne Davison
fb55e28d83 Fixed the multiplying of blength*blength so that it can't overflow
before it gets cast to a uint64.
2003-08-22 05:42:13 +00:00
Wayne Davison
067669dac7 Made the UNUSED(parameter) macro calls read a little nicer. 2003-08-22 05:04:13 +00:00
Wayne Davison
24c906d3f7 Mark unused vars. 2003-08-22 00:31:46 +00:00
Wayne Davison
14820f635d Make extra backup dirs mode 0700, not 0755. 2003-08-22 00:30:46 +00:00
Wayne Davison
59192f5650 Got rid of a duplicate include for malloc.h and improved the "do we
need malloc.h" logic a bit more.  (Trying to prevent #warning and
#error problems on *BSD systems.)
2003-08-21 23:54:20 +00:00
Wayne Davison
365346ca30 Got rid of signed/unsigned-comparison warning if st_rdev is signed. 2003-08-21 23:46:10 +00:00
Wayne Davison
d01350a881 Got rid of signed/unsigned-comparison warning if st_dev is signed. 2003-08-21 23:45:49 +00:00
Wayne Davison
38b02c13d0 Let's try only including malloc.h if stdlib.h isn't around (and it
exists).
2003-08-21 23:32:35 +00:00
Wayne Davison
b017ec4e13 Silenced a couple compiler warnings. 2003-08-21 23:28:24 +00:00
Wayne Davison
2c873122b3 Mention some more bug fixes. 2003-08-20 23:36:45 +00:00
Wayne Davison
6969ebcfcf Call setgroups(1, &gid) after setting the gid (rather than calling
setgroups(0, NULL) before).
2003-08-20 23:25:52 +00:00
Wayne Davison
1dbb94cadf Use the AVAIL_OUT_SIZE() macro in a few more places to ensure
that the avail_out buffer is big enough to uncompress all the
compressed data.
2003-08-20 10:37:53 +00:00
Wayne Davison
8a78bb963d Fixed a couple option-name typos (that had '_' instead of '-'). 2003-08-18 23:52:43 +00:00
Wayne Davison
6931c13800 - Made special exclusion-handling of '.' work in -R mode (so that we
can't accidentally lose the '.' dir and not transfer anything at all).
- Add a trailing '.' onto all '/'-trailing names, even '/' (fixes
  skipped deletions in -R mode from '/').
- Fixed loss of FLAG_DELETE on user-specified dir when unduplicating '.'
  (could happen on "./." or similar).
2003-08-17 21:29:11 +00:00
J.W. Schultz
e6e3f12ffc Whitespace and indentation cleanup. There is a lot of deep
indentation mostly due to read_batch but at least it is now
consistant.
2003-08-15 00:57:27 +00:00
J.W. Schultz
e2559dbedc Make --progress imply --verbose without incrementing verbosity. 2003-08-06 06:45:14 +00:00
Wayne Davison
1f3d6cdd86 Got rid of unused OPT_* enums. 2003-08-05 17:56:54 +00:00
Wayne Davison
4a7ee79d4d Improved the mkstemp error message. 2003-08-04 21:03:07 +00:00
Wayne Davison
0c2ef5f42d Make sure that the error message for mkstemp() includes the full
path of where we're trying to create the temp file.
2003-08-04 21:00:57 +00:00
Wayne Davison
ca20c7fd62 Instead of ignoring SIG_CHLD, reap zombies in the signal handler. 2003-08-04 18:27:27 +00:00
Wayne Davison
191e40da17 Change the way we pass the --suffix option to the remote process so
that a string that starts with ~ doesn't get modified.
2003-08-01 20:19:51 +00:00
Wayne Davison
80ddadb7e8 Complain if the --suffix value contains slashes (which is all too easy
to accidentally have happen if you try to specify "~" with --backup-dir).
2003-08-01 19:40:31 +00:00
Wayne Davison
31f3b68a97 We should bump the deletion_count for backed-up deleted files too. 2003-08-01 08:20:53 +00:00
Wayne Davison
d594399c6a Mention the --backup fix. 2003-08-01 08:01:15 +00:00
Wayne Davison
d74a2e3ed5 Properly handle the backup_suffix/backup_dir settings when deleting
files.  Also optimized the code that calls delete_one().  Don't
neglect to mention a file being deleted with --backup set.
2003-08-01 07:58:47 +00:00
Wayne Davison
d175d7e13e Got rid of suffix_specified and instead set backup_suffix to the
correct default value for the current backup_dir mode.  Added two
new values: backup_suffix_len and backup_dir_len.  Improved some
error-message code to not output duplicate errors.
2003-08-01 07:58:44 +00:00
Wayne Davison
daa8ce838b Use the new backup_suffix_len and backup_dir_len variables. Got rid
of the suffix_specified kludge.
2003-08-01 07:58:41 +00:00
Wayne Davison
b19fd07c02 Clarify some --backup/--backup-dir/--suffix issues. 2003-08-01 00:50:23 +00:00
J.W. Schultz
47d6a60c2f Whitespace and indentation fixes. 2003-07-31 09:32:15 +00:00
Wayne Davison
980821ebab No longer needed (replaced by wildmatch). 2003-07-30 06:13:47 +00:00
Wayne Davison
592f4696dc Updated the exclude/include section to mention the "**" vs "*" change. 2003-07-30 06:12:41 +00:00
Wayne Davison
8a7846f97e Changed the "**" description to reflect its no-longer-buggy behavior. 2003-07-30 06:12:33 +00:00
Wayne Davison
87f18b6289 Include "lib/wildmatch.h", not "lib/fnmatch.h" or <fnmatch.h>. 2003-07-30 06:12:31 +00:00
Wayne Davison
28063ba5b2 Got rid of test for fnmatch. 2003-07-30 06:12:29 +00:00
Wayne Davison
fe332038c6 Call wildmatch(), not fnmatch(). 2003-07-30 06:12:27 +00:00
Wayne Davison
3c0b1ebf78 Changed lib/fnmatch.o to lib/wildmatch.o. 2003-07-30 06:12:25 +00:00
Wayne Davison
f2fe4903c9 Made the list of exclude/include changes more prominent and clear. 2003-07-26 18:13:38 +00:00
Wayne Davison
3151cbae89 Some superficial tweaks I made while reading through the io.c code. 2003-07-26 17:55:07 +00:00
Wayne Davison
3c30b99059 Added one more test. 2003-07-14 15:46:34 +00:00
Wayne Davison
a7735ba085 Updated for latest character-class change. 2003-07-14 15:13:31 +00:00
Wayne Davison
d811b68901 Make sure that no character class can match a '/'. 2003-07-14 15:12:59 +00:00
Wayne Davison
1c8162a921 Optimized show_progress() to reduce the calls to gettimeofday() when
am_server is set.  No need to check do_progress here anymore, since
we aren't called if do_progress isn't set.
2003-07-08 16:54:53 +00:00
Wayne Davison
16417f8b9d Only call show_progress() and end_progress() if do_progress is set. 2003-07-08 16:49:10 +00:00
Wayne Davison
b49d381d05 Changed "./0123456789" to just ".0123456789". 2003-07-07 19:37:58 +00:00
Wayne Davison
7da9a16d10 I decided to go with the slightly simpler logic Thorild Selen suggested
in a subsequent email.
2003-07-07 18:37:38 +00:00
Wayne Davison
32f60a6e7b Improved deficiencies in the hostname-vs-address check (reintroduced in the
last revision) based on the suggestions of Thorild Selen.
2003-07-07 18:25:01 +00:00
Wayne Davison
b7db090661 Commented-out a test that wasn't consistent across all platforms. 2003-07-07 07:28:02 +00:00
Wayne Davison
136c5c5ec3 Silence some compiler warnings on HP-UX. 2003-07-07 07:22:08 +00:00
Wayne Davison
85b80fbc73 A few more tests. 2003-07-07 07:10:40 +00:00
Wayne Davison
16859cdbdc Improved the summary output to use correct English for all counts. 2003-07-07 07:08:24 +00:00
Wayne Davison
fc96552d26 Don't treat "[:" as the start of a named set if there's no ":]". 2003-07-07 07:07:16 +00:00
Wayne Davison
15bb997d0a Added a few more items to the tests. 2003-07-06 18:54:08 +00:00
Wayne Davison
b6b42c892c Improve the format of the --iterations output. 2003-07-06 18:29:24 +00:00
Wayne Davison
5bb920003e - Return ABORT_ALL for a syntax error in the pattern (not FALSE).
- Abort if the [:class:] name is not known.
2003-07-06 18:26:34 +00:00
Wayne Davison
37ff0e344d Added match for new "no errors" line from wildtest. 2003-07-06 17:41:37 +00:00
Wayne Davison
97d53f8c75 Switch to using an input file so that backslashes are specified
normally, and so that test additions and changes are easier.
2003-07-06 17:41:01 +00:00
Wayne Davison
f2ac84c36d Added some portability code for the ctype functions. 2003-07-06 16:29:32 +00:00
Wayne Davison
c21eeef5bc Updated for latest wildmatch.c changes. 2003-07-06 04:34:19 +00:00
Wayne Davison
e11c425119 - Added [:class:] handling to the character-class code.
- Use explicit unsigned characters for proper set checks.
- Made the character-class code honor backslash escapes.
- Accept '^' as a class-negation character in addition to '!'.
2003-07-06 04:33:54 +00:00
Wayne Davison
84229c7ac9 We now figure out if diff accepts -u and we'll use it instead of -c,
if possible.
2003-07-05 22:57:08 +00:00
Wayne Davison
c9a59880f0 Simplified the character-class code a bit. 2003-07-05 22:40:27 +00:00
Wayne Davison
9a17dddbc5 Fixed the output of popt errors and changed our one option to be
--iterations (-i).
2003-07-05 19:21:41 +00:00
Wayne Davison
277d99e8c9 A wildtest change to handle someone using the included popt lib. 2003-07-05 19:14:10 +00:00
Wayne Davison
2a1874cc82 Added dependencies for wildtest.o. 2003-07-05 19:06:49 +00:00
Wayne Davison
d5c973ccb7 Changed some names since "depth" wasn't really the right term. 2003-07-05 19:03:42 +00:00
Wayne Davison
37f3ce61bb Another change to the wildtest rule to make it more portable. 2003-07-05 18:55:09 +00:00
Wayne Davison
076f60eed0 Added a --depth option to report recursion depth values. 2003-07-05 18:49:38 +00:00
Wayne Davison
20b2e9cef7 Improved the ABORT logic to allow aborting consecutive "*" wildcards
back to a "**" wildcard.  Added optional debug code for recursion stats.
2003-07-05 18:48:34 +00:00
Wayne Davison
e37d8229f5 Changed the build rule for wildtest. 2003-07-05 18:46:02 +00:00
Wayne Davison
710faea9a4 Added in the ABORT optimization logic from a newer wildmat release,
adapted for our code that distinguishes "**" from "*".
2003-07-05 17:30:53 +00:00
Wayne Davison
70a6051cf1 Restored an isdigit() check in the match_address() function, but check
the last character in the hostname, not the first.
2003-07-05 07:39:57 +00:00
Wayne Davison
7a1f46b6ac A couple comment tweaks. 2003-07-05 07:22:13 +00:00
Wayne Davison
7ca9250db0 Changed "diff -u" back to "diff -c" (for portability). 2003-07-05 07:09:31 +00:00
Wayne Davison
af7086c63f Change most SAME-AS-FNMATCH "false" values to "true" (since we _should_
work the same as fnmatch in most cases, if fnmatch was actually working
right).
2003-07-05 07:03:56 +00:00
Wayne Davison
8808589277 Get rid of a couple compiler warnings. 2003-07-05 06:56:16 +00:00
Wayne Davison
6cd5096063 Don't define COMPARE_WITH_FNMATCH by default. 2003-07-05 06:53:41 +00:00
Wayne Davison
677cd34acd Include lib/wildmatch.h directly for now (until we make rsync.h include
it for us).
2003-07-05 00:13:38 +00:00
Wayne Davison
08c5385e65 Test the new wildmatch() routine using the wildtest executable. 2003-07-05 00:08:11 +00:00
Wayne Davison
d7bf70f196 Build "wildtest" for "make check". 2003-07-05 00:07:35 +00:00
Wayne Davison
6f3cff41dd Ignore "wildtest". 2003-07-05 00:05:33 +00:00
Wayne Davison
5de45bcadc A testbed to stress the new wildmatch() routine. 2003-07-05 00:05:02 +00:00
Wayne Davison
446ee5b110 A new wildcard-matching routine to replace the fnmatch code. 2003-07-05 00:03:36 +00:00
Wayne Davison
d3e6fd3910 Changed "diff -c" to "diff -u". 2003-07-04 23:56:59 +00:00
Wayne Davison
6813fa7eac Attempting to fix the snprintf() conflict on a gcc-using HPUX 11.11. 2003-07-04 15:36:39 +00:00
Wayne Davison
0f5a04e3ff Use "return" at the end of main() to silence some compilers. 2003-07-04 15:11:46 +00:00
Wayne Davison
8801138b47 Made rprintf() of size_t value portable. 2003-07-04 15:11:44 +00:00
Wayne Davison
2473391971 Improved upon my last patch to make it clearer and cleaner. 2003-07-04 07:47:09 +00:00
Wayne Davison
7d6879328a Changed the syntax of a comment. 2003-07-03 18:33:53 +00:00
Wayne Davison
900454132e Mention the compression (-z) fix. 2003-07-03 17:41:08 +00:00
Wayne Davison
92b8abfe80 Fixed a problem where we might not have enough room to compress
unsent tokens into the obuf in a single call.
2003-07-03 17:38:12 +00:00
Wayne Davison
52e628a861 Mention the exclude changes. 2003-07-01 22:01:48 +00:00
Wayne Davison
4791825d49 Modified the glob_expand_one() function to check the args against the
server's config-specified exclude list.  This prevents the user from
going around directory exclusions.  Fixed push_dir() to not append
"/." onto the end of the current path if it is called with "." as the
"dir" arg.  Made curr_dir[] exported so the exclude code can use it
(for the daemon-config absolute-path excludes).
2003-07-01 21:45:31 +00:00
Wayne Davison
d542c20c5f New stubs to get the test setup to compile with the exclude changes. 2003-07-01 21:45:29 +00:00
Wayne Davison
4762db4fc9 Added some defines for the various exclude-function arg literals.
Added MATCHFLG_ABS_PATH flag for absolute-path patterns.
2003-07-01 21:45:27 +00:00
Wayne Davison
8645af1d8c Changed add_exclude*() calls to use the revised arg syntax. 2003-07-01 21:45:23 +00:00
Wayne Davison
429f98283f Modifications to handle the new server_exclude_list, and to use the
revised calling syntax and new defines for the various exclude
functions.
2003-07-01 21:45:18 +00:00
Wayne Davison
5be7fa93fc Made make_exclude() store anchored config-file excludes with the full
path (clear to the root).  Changed several functions to make the args
more general (to support separated lists), more consistent, and easier
to understand.
2003-07-01 21:45:16 +00:00
Wayne Davison
837cbad97f We now put the excludes from the config file into a "server_exclude_list"
using the revised add_exclude_line() arg syntax.
2003-07-01 21:45:13 +00:00
Wayne Davison
af1d91c562 Call make_file() using the revised arg syntax and new defines. 2003-07-01 21:45:07 +00:00
Martin Pool
908f5a9f9f Add a comment about using getpassphrase() or readpassphrase() rather
than getpass().  No code change.
2003-06-17 04:46:32 +00:00
J.W. Schultz
9b74643315 Credit where due. 2003-06-10 00:21:34 +00:00
J.W. Schultz
986066873e Clarified EXCLUDE PATTERNS to enforce the relativity of
paths.  Replaced undefined "base dir" with a defined "top
dir".
2003-06-10 00:11:24 +00:00
J.W. Schultz
9533e15a79 Changed write file to cope with partial writes by looping
until complete or errno is set.
					(John Van Essen)
2003-05-22 23:24:44 +00:00
Wayne Davison
8dc74608a3 Updated the long description for the --perms option. 2003-05-16 04:23:34 +00:00
J.W. Schultz
3e85237e5f Added AIX and OSX build workaround notes. 2003-05-14 12:54:15 +00:00
Wayne Davison
9d0523ef4c Another MD4 fix for protocol 27 (from Christoph Bartelmus). 2003-05-12 20:38:07 +00:00
Wayne Davison
4a7144ee7e Cleaned up whitespace/indentation. 2003-05-10 08:33:08 +00:00
Wayne Davison
c120ff37f5 Optimized away 3 calls to strcmp(). 2003-05-10 00:56:08 +00:00
J.W. Schultz
83fd337d8e Modified the (in|ex)clude [from] option descriptions to
better highlight the non-equivalence with client-side
--exclude.
2003-05-09 12:04:24 +00:00
Jos Backus
707c1a3085 Remove generated file config.log. 2003-05-04 19:59:47 +00:00
J.W. Schultz
8294b00c11 Added --link-dest to the --help output. 2003-05-02 23:36:10 +00:00
Wayne Davison
da2bcdd1c2 Exclude/include bug fixes. 2003-05-01 19:39:20 +00:00
Wayne Davison
093acc5dad Changed the expected results to match the new bug-fixed behavior. 2003-05-01 19:34:01 +00:00
Wayne Davison
fd73b94d31 Tweaked the exclude_struct for our improved matching code. 2003-05-01 19:33:59 +00:00
Wayne Davison
38499c1a49 Mention that a pattern with "**" is matched against the entire path, even
if the pattern doesn't contain a slash.
2003-05-01 19:33:57 +00:00
Wayne Davison
170381c052 Fixed some matching bugs; made the logic of the matching code a little
clearer by using defined flags; added several comments; optimized the
matching of an anchored literal string.
2003-05-01 19:33:54 +00:00
Wayne Davison
8113a033dd Mention the improved trailing-slash-in-destination handling. 2003-04-24 16:26:53 +00:00
Wayne Davison
87cc45e136 Made my last change a little better. 2003-04-24 16:26:09 +00:00
Wayne Davison
f6b8d591f7 If the user specifies a trailing slash on the destination, make sure
that we treat it as a directory reference.
2003-04-24 16:14:33 +00:00
J.W. Schultz
d31c09c872 Copy relative path caviat from --compare-dest to
--link-dest.
2003-04-23 23:17:41 +00:00
Wayne Davison
337a1a86a7 Changed one part of the exclude-test setup to test the --existing
option.  Also tweaked a few comment lines.
2003-04-23 02:15:59 +00:00
Wayne Davison
b7dc46c0f6 Fixed a typo and added a couple clarifying phrases to the exclude
descriptions.
2003-04-22 18:09:22 +00:00
Wayne Davison
ff57065957 Test various exclude/include patterns. 2003-04-22 17:53:53 +00:00
Wayne Davison
0406a3a7a4 Changed test_xfail to test_fail. 2003-04-22 16:45:24 +00:00
Wayne Davison
bc3b5b2558 Fixed a problem with the test code and enabled it (since rsync's
duplicate-elimination code is now fixed).
2003-04-22 00:25:05 +00:00
J.W. Schultz
d1cce1dd92 Make explicit that (in|ex)clude patterns are for relative
paths and that the leading / is the equivalent of ^ in
regex.
2003-04-21 08:44:25 +00:00
Wayne Davison
7bb7058e8d Made a slight tweak to the previous --stats change. 2003-04-18 20:03:41 +00:00
Wayne Davison
727fa3688f Mention the change to the --stats output. 2003-04-17 23:46:01 +00:00
Wayne Davison
577ab12ce5 Only display the malloc stats if we're at least double-verbose (and
--stats was specified, of course).  Also made the output of the short
(2-line) transfer summary get prefixed with an empty line in all
cases (not just with --stats).
2003-04-17 23:44:25 +00:00
Wayne Davison
0f2ac85576 Some whitespace/indentation cleanup. 2003-04-17 01:44:33 +00:00
J.W. Schultz
fab1f8898e document bug fix for --link-dest and lack of -pgo. 2003-04-11 03:15:53 +00:00
restrict
f63d68be97 (Really mbp)
Test commit from restricted CVS account.  No changes.
2003-04-10 04:35:12 +00:00
Wayne Davison
58665d23b4 Fixed a weird line corruption in the last check-in and tweaked the
format to be the same as in older releases.
2003-04-10 03:06:28 +00:00
J.W. Schultz
195bd906a2 - Per-file dynamic block size is now sqrt(file length).
-	The per-file checksum size is determined according
	to an algorythm provided by Donovan Baarda which
	reduces the probability of rsync algorithm
	corrupting data and falling back using the whole md4
	checksums.
2003-04-10 02:04:58 +00:00
J.W. Schultz
fc1ae6582f - for protocol version >= 27, mdfour_tail() is called when the block size
(including checksum_seed) is a multiple of 64.  Previously it was not
   called, giving the wrong MD4 checksum.

 - for protocol version >= 27, a 64 bit bit counter is used in mdfour.c as
   required by the RFC.  Previously only a 32 bit bit counter was used,
   causing incorrect MD4 file checksums for file sizes >= 512MB - 4.
						-- Craig Barratt
2003-04-10 01:50:12 +00:00
J.W. Schultz
fc0257c9fd Now support dynamic per-file checksum2 size.
This pushes protocol version to 27
2003-04-10 01:13:30 +00:00
J.W. Schultz
91c4da3fda versions prior to 1.7.0 (protcol version 17) cannot talk to
protocol versions > 20 so bumping up the minimum protocol
version and excising the pre-17 cruft.
2003-04-10 00:13:48 +00:00
Paul Green
990ff150ef Fix bug reported by engard.ferenc at innomed.hu whereby using the %f format
in sprintf with a value like 0.025 produced 0.250.  We were dropping the
leading zeros before the fractional digits.
2003-04-09 21:10:18 +00:00
J.W. Schultz
e72b18a9bd Remove tempname length problem and files-from from TODO. 2003-04-01 03:44:50 +00:00
J.W. Schultz
bc63ae3f13 Removing vestigial support for protocol versions prior to 15. 2003-03-31 17:28:34 +00:00
J.W. Schultz
6e12886393 Logic error in preserve_perms + link_dest 2003-03-31 08:09:41 +00:00
Wayne Davison
b5ca91ae4b Fixed a typo. 2003-03-30 23:19:22 +00:00
Wayne Davison
89855e78ab Started a new section for the next release. 2003-03-30 23:15:01 +00:00
Wayne Davison
e106de49c8 Tweaked the O_BINARY code to the latest idiom. 2003-03-30 23:00:51 +00:00
Wayne Davison
afbcc8f216 Define O_BINARY as "0" if it isn't defined. 2003-03-30 23:00:49 +00:00
Wayne Davison
f177b7cca2 Documented --files-from, --no-relative, --no-implied-dirs, and --from0. 2003-03-30 23:00:47 +00:00
Wayne Davison
ea5164d181 Support the new --files-from, --no-relative, --no-implied-dirs, and --from0
options.  Moved the find_colon() routine here from main.c.
2003-03-30 23:00:42 +00:00
Wayne Davison
ccdff3ebbf Open the file in BINARY fd mode, handle the normal line-ending characters
better than before, and add support for the new --from0 option (which changes
the line separator to a null).
2003-03-30 23:00:40 +00:00
Wayne Davison
24d0fcde7f Support the new --files-from and --no-implied-dirs options. 2003-03-30 23:00:37 +00:00
Wayne Davison
56014c8c0a Support the new --files-from and --from0 options. 2003-03-30 23:00:35 +00:00
Wayne Davison
7c2a9e766c Support the new --files-from option. 2003-03-30 23:00:33 +00:00
J.W. Schultz
bb24028f51 Make link-dest aware of --perms, --owner and --group.
---- Chris Darroch
2003-03-26 20:26:06 +00:00
J.W. Schultz
52d3e10613 Prevent tempfile names from overflowing.
Debian BUG# 183667
2003-03-26 11:04:14 +00:00
J.W. Schultz
67863f46e3 Warn if 64bit value sent or received on system that doesn't
support 64bit integers.
2003-03-25 07:13:40 +00:00
J.W. Schultz
9c28e52628 Seperate the uint64_t macros from int64_t 2003-03-25 05:46:52 +00:00
J.W. Schultz
1b2f167546 Frustration mounting. I'll get it right eventually.
Thank goodness for the build farm.
2003-03-25 04:18:10 +00:00
J.W. Schultz
702d0c4529 earlier problem was a typo. 2003-03-25 04:09:43 +00:00
J.W. Schultz
51106bafc6 Another stab at uint64 because some platforms seem to have
problem with the unsigned off64_t
2003-03-25 03:14:27 +00:00
J.W. Schultz
42d4edc067 removed log_transfer() It was no more than a conditional
rprintf() with an unused param.
2003-03-25 02:28:54 +00:00
J.W. Schultz
fbc0bc4d53 Create uint64 for INO64_T and DEV64_T eliminating type mismatches. 2003-03-25 02:02:22 +00:00
J.W. Schultz
1b2db7aecb Increased maximum protocol version.
Added warning for deprecated protocol versions.
2003-03-24 22:42:46 +00:00
J.W. Schultz
1ce29566e7 Minor correction to protocol annotation. 2003-03-24 22:32:47 +00:00
J.W. Schultz
3742bf3ac3 Annotated each release with protocol version and
added protocol version history from rsync.h log.
2003-03-24 22:13:16 +00:00
Wayne Davison
18d6b679af The close_all() function was missing its "void" prototype. 2003-03-21 23:43:50 +00:00
Wayne Davison
dbda5fbf06 Get rid of eol whitespace. 2003-03-21 22:53:46 +00:00
Wayne Davison
2154309a54 Optimized the implied-directory code to avoid putting so many duplicate
dirs into the file list.
2003-03-21 22:10:44 +00:00
Wayne Davison
afb6e9450d - Use popt to better effect for the two options that can be both
set and unset by the user.
- Even more whitespace cleanup.
2003-03-21 19:17:23 +00:00
Wayne Davison
dfa3248380 - Simplified the whole-file option handling.
- Fixed some whitespace issues.
2003-03-21 18:58:50 +00:00
Wayne Davison
2cda256088 - Simplified the whole-file option handling.
- Cleaned up some whitespace issues.
2003-03-21 18:53:00 +00:00
Wayne Davison
d9c7edf63f - Fixed lots of line-indentation problems, including a really huge section
of non-batch-mode code that was indented at the same level as its
  surrounding "if" statement.
- Moved the heavily-used am_* flags into global extern vars instead of
  externing them again and again in individual functions.
- Got rid of line-ending whitespace.
2003-03-21 18:33:48 +00:00
J.W. Schultz
a151343943 Cleanup: Added header files to dependancies. 2003-03-21 07:42:19 +00:00
J.W. Schultz
85ed0aa396 Typo corrections.
Thanks to Paul Slootman <paul@debian.org>
2003-03-21 07:27:31 +00:00
J.W. Schultz
3019f95f37 Removing --csum-length option documentation since there is
no such option.
2003-03-21 04:39:11 +00:00
Paul Green
5702bc12b3 Apply patch from Steve Bonds to repair this test. 2003-02-19 16:22:50 +00:00
Paul Green
b0d791bb35 Patch from Roderick Schertler (roderick at argon.org) to ignore
non-POSIX directory mode bits that are used by AIX.
2003-02-18 18:07:36 +00:00
Paul Green
3903928ca0 Remove RedHat-specific .spec files in favor of the .spec files
maintained under packaging/lsb.
2003-02-18 16:50:25 +00:00
Wayne Davison
827c37f631 The sender no longer removes the duplicate names from the file list -- we
let the receiver do that, since they are the one that requests names and
we want to be sure the sender has any name the receiver may ask for.
2003-02-12 09:15:23 +00:00
David Dykstra
b45b059a3d Back out one of the changes in log.c revision 1.62, and always send errors
to the client after multiplexing is enabled.
2003-02-11 19:13:51 +00:00
Paul Green
f39281ae56 Patch from jw schultz to reword "link" to "connection" in a couple of
spots.
2003-02-10 14:51:09 +00:00
Paul Green
e2bea9eb8d Update packaging spec files per patch submitted by Horst von Brand.
In the future, we need to be sure to keep *.spec and *.spec.tmpl
identical...the release macro produces *.spec from *.spec.tmpl.
2003-02-05 18:41:53 +00:00
Paul Green
931a979904 Restored changes accidentally backed out by Dave Dykstra in previous revision. 2003-01-29 21:04:28 +00:00
Paul Green
3fccfafd30 Apply fix from Horst von Brand. See comments in rsync.spec. 2003-01-29 20:52:59 +00:00
David Dykstra
7a6fd4c1c7 preparing for release of 2.5.6 2003-01-28 05:28:42 +00:00
David Dykstra
8395d24616 Add header for 2.5.6 release. 2003-01-28 05:13:16 +00:00
David Dykstra
7d085960eb Remove the Cygwin msleep(100) before the generator kills the receiver,
because it caused the testsuite/unsafe-links test to hang.
2003-01-28 05:05:53 +00:00
David Dykstra
3884317181 Change the default of --modify-window back to 0 on Cygwin. 2003-01-28 03:11:57 +00:00
David Dykstra
089a2435f8 Ack! I had accidentally ifdefed out the kill from the generator to the
receiver process for every platform except Cygwin.
2003-01-28 03:03:55 +00:00
David Dykstra
8ed16deb24 Change so the delay before generator signals receiver is only done on Cygwin. 2003-01-28 02:51:03 +00:00
Paul Green
a577af9067 Added a TODO item about temporary file names bumping up against the
maximum name length.  (I have an unfinished patch that will address
this).
2003-01-27 16:33:47 +00:00
David Dykstra
59af13651b Move the sleep to workaround the default modify-window of 1 on Cygwin to
the beginning of "checkit" rather than the end of "hands_setup" because
sometimes files are modified just before checkit is called and the copy
finishes within one second so they're considered to be the same time.
I don't think this would be a problem in real life, so just change the
test.
2003-01-27 04:41:30 +00:00
David Dykstra
787568f371 Insert a 100ms sleep just before sending the USR2 signal to the
child receiver process to prevent some hangs on Cygwin.  Anthony
Heading discovered the workaround first and suggested 30ms, and
Greger Cronquist had better luck with 100ms.
2003-01-27 03:52:42 +00:00
David Dykstra
f0019fc506 Remove the "Connection reset by peer" from TODO 2003-01-27 03:36:54 +00:00
David Dykstra
9f639210ca Prevent the "Connection reset by peer" messages often seen from Cygwin.
Result of a lot of discussion over the last year and a half.  Based on
a patch from Randy O'Meara, cleaned up a bit by Max Bowsher.
2003-01-27 03:35:08 +00:00
David Dykstra
deec574421 Update date on man page. 2003-01-27 03:13:46 +00:00
David Dykstra
04657e42d5 Update rsyncd.conf documentation to be right for rsync server mode over a
remote shell.
2003-01-27 03:07:18 +00:00
David Dykstra
1b88775534 Change erroneous references to a --config-file option to the correct --config
option.
2003-01-27 02:48:14 +00:00
David Dykstra
7f6537557d Change news item about handling of text mode in files to just permitting
any of the standard line termination styles.
2003-01-26 20:49:24 +00:00
Wayne Davison
518233ca79 Got rid of recent O_TEXT* and O_BINARY* changes. 2003-01-26 20:11:16 +00:00
Wayne Davison
bc72130d71 Got rid of O_TEXT_STR and added code to strip '\r' from the end of the
lines we read.
2003-01-26 20:10:23 +00:00
Wayne Davison
855decd3a7 Added back the O_BINARY #ifdef. 2003-01-26 20:09:02 +00:00
Wayne Davison
0090cbdba6 Got rid of O_TEXT_STR change. 2003-01-26 20:07:55 +00:00
Wayne Davison
73ff720972 File I/O already handles '\r', so we can remove the O_TEXT flags. 2003-01-26 19:37:54 +00:00
David Dykstra
c561e1378d Remove a couple items I know are no longer needed. 2003-01-26 04:04:47 +00:00
David Dykstra
aa2c47d835 Better fix for infinite recursion; don't return from exit_cleanup
unless the nesting is already pretty deep, because there are normal
cases where exit_cleanup is nested shallowly.  Patch from Marc Espie,
posted by Brian Poole.
2003-01-26 03:53:34 +00:00
David Dykstra
536b84680b Open config files in text mode when O_TEXT is defined. This helps on
Cygwin when the config files are on a filesystem that is mounted in
binary mode.  Patch from Ville Herva.
2003-01-26 03:46:54 +00:00
David Dykstra
7508b795bf Tests that use hands_setup to make a test file directory and right
afterward make a copy were failing on cygwin because the default
--modify-windows now 1 on Cygwin.  Adding a 2 second sleep at the end of
hands_setup so that hopefully the tests will succeed because the copy
will be made more than 1 second away from the original.
2003-01-26 03:34:19 +00:00
Wayne Davison
76ee1d18bf Don't try to run daemon tests as "nobody". 2003-01-25 03:46:57 +00:00
Wayne Davison
379bc86547 Getting rid of recent "chown" since we decided to forego trying to run
the daemon tests as "nobody".
2003-01-25 03:45:40 +00:00
David Dykstra
066696644f Change default of --modify-window on Cygwin from 2 to 1 because that's all
that's needed on FAT filesystems.  NTFS filesystems can do with a window of
0, but it shouldn't hurt because it's highly unlikely that any given file
will be modified within one second of the time that rsync last copied it.
2003-01-24 22:07:22 +00:00
Paul Green
755bcd3722 Restore trailing newline character at the end of the file. 2003-01-23 17:18:20 +00:00
Paul Green
1985aa9666 Mentioned the fact that config.sub and config.guess got updated. 2003-01-22 22:59:35 +00:00
Paul Green
f4663a36da Updated config.sub and config.guess to latest revision. 2003-01-22 22:24:53 +00:00
Wayne Davison
521e6fdcfc Mention test-case fixes. 2003-01-21 20:25:44 +00:00
Wayne Davison
61ab574e38 Moved the chown from the download test to the upload test. 2003-01-21 20:19:53 +00:00
Wayne Davison
660cb6a085 Chown the $TO and $FROM directories to $RSYNCD_UID:$RSYNCD_GID (if we
can, and don't fail if we can't).
2003-01-21 20:19:53 +00:00
Wayne Davison
4274208833 Chown the $TO and $FROM directories to $RSYNCD_UID:$RSYNCD_GID (if we
can, and don't fail if we can't).
2003-01-21 19:30:51 +00:00
Wayne Davison
34db05b421 Put the UID and GID that rsyncd will run as into variables. 2003-01-21 19:28:29 +00:00
Wayne Davison
1657be22a3 Separated a cat "..." command out from inside a double-quoted string
so that we don't run afoul of some shells quoting quirks.  (As Brian
Poole suggested.)
2003-01-21 19:27:11 +00:00
David Dykstra
3636b9ffaa Change the name on the --modify-window default for Cygwin to Lapo Luchini. 2003-01-21 14:22:49 +00:00
David Dykstra
e3cd264571 Change version to working version 2.5.6pre3cvs 2003-01-21 04:23:43 +00:00
David Dykstra
69555b0943 Change version to 2.5.6pre2 2003-01-21 04:00:56 +00:00
Wayne Davison
522c05cf9a Declare preserve_perms for latest syscall.o. 2003-01-21 01:35:23 +00:00
David Dykstra
f0b4fdaf5e Ignore errors from chmod when --preserve-perms/-p/-a are not set.
Gnu cp behaves the same way.
2003-01-21 00:58:50 +00:00
Wayne Davison
ac6ce98375 Added a couple missing NEWS items. 2003-01-20 23:49:22 +00:00
David Dykstra
1b3cadaa39 Re-activate the piece of code that creates intervening directories
when --relative-paths is used.  The code was accidentally skipped starting
in CVS version 1.32 of receiver.c.  Noticed by Craig Barratt.
2003-01-20 23:32:17 +00:00
David Dykstra
61ca7d596c Update description of hosts allow for IPv6. From Bert Vermeulen. 2003-01-20 23:10:22 +00:00
David Dykstra
688d573295 Make the default for --modify-window be 2 on cygwin. 2003-01-20 23:09:24 +00:00
Wayne Davison
ec6e0bf0c0 Backed out Paul Green's IRIX patch since it didn't seem to be a part of
the Makefile fix and I like the old EXE syntax better.
2003-01-20 18:26:14 +00:00
David Dykstra
184dede92f Save the value of the test for getaddrinfo defines in the config cache. 2003-01-20 17:25:26 +00:00
David Dykstra
d2cc0323fb Also need to include lib/getnameinfo when the getaddrinfo defines don't exist. 2003-01-20 16:59:18 +00:00
David Dykstra
3a1eefd331 Oops, lib/getaddrinfo wasn't pulled in when the system doesn't define
AI_PASSIVE.
2003-01-20 16:27:34 +00:00
David Dykstra
824f1c7944 Only look for a system getaddrinfo/getnameinfo if AI_PASSIVE is defined
by system headers.  This fixes compile errors on Irix 6.5.
2003-01-20 15:04:16 +00:00
David Dykstra
7bc8218d81 Fix bug that causes messages like
rsync: stack overflow in function match_address
on openbsd.  Patch from Brian Poole <raj@cerias.purdue.edu>.
2003-01-20 13:46:28 +00:00
David Dykstra
a405cda63c Add unsafe-byname tests with symlink destinations ending in '..'. 2003-01-20 12:42:42 +00:00
Wayne Davison
7afa3a4a48 Optimized unsafe_symlink() to avoid malloc/free calls. 2003-01-19 21:37:11 +00:00
Wayne Davison
c80b3d8c3f Added "extern" to io_{read,write}_phase line (they were being
multiply defined).
2003-01-19 05:53:07 +00:00
Wayne Davison
ef6122c622 Got rid of trailing whitespace and tweaked a few things that might
possibly be affecting the IRIX build (but probably not).
2003-01-18 19:11:55 +00:00
Wayne Davison
75fb17b891 Define DBL_EPSILON if it doesn't exist. 2003-01-18 19:00:07 +00:00
Wayne Davison
2abbf2498f Trying out Paul Green's IRIX patch to see if it fixes the syntax
error in the Makefile.
2003-01-18 18:52:50 +00:00
Wayne Davison
b91b50c01f Fixed the bug in clean_flist() where it did not get rid of all duplicate
names if there were more than 2 identical names in a row.
2003-01-18 18:00:23 +00:00
David Dykstra
06891710f2 Change rsync help for -a to show that it is equivalent to -rlptgoD.
I've had to go to the man page many times for that information and I
finally got sick of it.
2003-01-16 21:02:43 +00:00
David Dykstra
b765ec32b9 Prevent infinite recursion in exit_cleanup(). Patch from Sviatoslav Sviridov. 2003-01-16 20:09:31 +00:00
Wayne Davison
a70d070cc5 Make unsafe_symlink() take const args so that we don't get any
compiler warnings when calling it with a const char *.
2003-01-15 17:49:44 +00:00
David Dykstra
1f1fbe187e Add news item about fix of --copy-unsafe-links 2003-01-15 16:41:51 +00:00
David Dykstra
fc63847406 Fix bug in --copy-unsafe that made it totally broken, and re-enable
the tests that tested it.  As far as I can tell, it was always broken
since the day I put it in years ago.  In my investigation into this I
was unable to figure out what in the world I was thinking back then,
to introduce a global variable with the wrong information in it rather
than using a parameter that was already available in readlink_stat
function.  That still bothers me a bit but I decided to stop worrying
about it.
2003-01-15 16:14:07 +00:00
David Dykstra
f58677d123 Don't use the return value from sprintf because it doesn't work on Sunos4. 2003-01-14 21:37:08 +00:00
David Dykstra
7ab1538861 Now that the 2.5.6pre1 snapshot has been made, change the version to
2.5.6pre2cvs.
2003-01-13 17:21:12 +00:00
David Dykstra
7ad0f94de9 Change version to 2.5.6pre1 2003-01-13 16:40:15 +00:00
Wayne Davison
8af534a52c Changed the alloca warning message. 2003-01-12 22:45:47 +00:00
Wayne Davison
7447419266 Use the old kludge of using malloc() if alloca() is missing. 2003-01-12 21:49:44 +00:00
David Dykstra
5216de37a4 Reduced the severity of the warning about missing alloca to a warning, and
changed the test to the common form of prefixing an x to both sides of
an equivalence because it didn't even notice a problem on the cray when
it was instead using test -n.
Also noticed an error in the test for ANSI c, doing a "$xac..." = xno"
when it should have been "x$ac..." = xno, so I fixed that too.
2003-01-12 04:02:25 +00:00
David Dykstra
ccc0d1eb1d Oops, had the sense of the test for the existence of alloca() backwards. 2003-01-12 03:28:13 +00:00
David Dykstra
7fc0890881 Make configure bomb if the included popt is needed but alloca is not
available, as apparently is the case on Cray UNICOS.  The AC_FUNC_ALLOCA
autoconf documentation talks about having an included alloca.c and
periodically calling alloca(0) to garbage collect when C_ALLOCA is defined,
but I don't know where to get the code or if there's anybody that cares
enough about the UNICOS port for it to be worth the trouble.
2003-01-12 03:11:38 +00:00
David Dykstra
b17f1d76c0 Cast the return from alloca to work better on UNICOS. 2003-01-11 19:01:31 +00:00
David Dykstra
451b5fc969 Cast the return of alloca to remove a fatal error on Cray UNICOS. 2003-01-11 14:39:41 +00:00
Wayne Davison
1e678fcab1 Yet another try at getting this to skip on cygwin. 2003-01-11 08:19:24 +00:00
Wayne Davison
48bcc6ee2b Hopefully this version will skip correctly on cygwin. 2003-01-11 07:39:49 +00:00
Wayne Davison
32734c7c3c Try a different tact to get cygwin to skip this test. 2003-01-11 07:22:40 +00:00
Wayne Davison
aaf375d0a5 The inet_pton() man page says we need to pass in a pointer to a
struct in_addr, which means passing &sin.sin_addr instead of
&sin.sin_addr.s_addr.  Also changed the AF_INET6 version to pass
&sin6.sin6_addr.  Hopefully this will fix UNICOS and not break
anyone else.
2003-01-11 02:05:56 +00:00
Wayne Davison
9680f811f6 Cast poptGetOptArg() to remove a compiler warning. 2003-01-11 01:29:30 +00:00
Wayne Davison
bda41fa509 + The prototype for isc_net_pton() should have been inet_pton().
+ Define IN_LOOPBACKNET if it is not already defined.
2003-01-10 20:09:58 +00:00
Wayne Davison
7ea84b6890 Only refer to S_ISVTX if S_ISVTX is defined. 2003-01-10 20:08:43 +00:00
Wayne Davison
cc234d944a + Fixed a comment that referred to isc_net_pton() instead of inet_pton().
+ Only prototype inet_pton6() if INET6 is defined.
2003-01-10 20:08:12 +00:00
Wayne Davison
ac84096d1f Don't use '#' in the dsttmp filename. 2003-01-10 19:58:51 +00:00
Wayne Davison
a1cc591b29 Paul Green's changes to add $(EXEEXT) and $(CPPFLAGS) as appropriate. 2003-01-10 19:58:16 +00:00
David Dykstra
da0405080e The call to test_skipped if makepath failed didn't work, presumably because
makepath is builtin and there's some problem with it causing /bin/sh to
exit on cygwin.  Parens around the call to makepath should help.
2003-01-10 18:32:59 +00:00
David Dykstra
0c0a3e2dd3 Clean up better after the testsuite check programs. Patch from J.W. Schultz. 2003-01-10 15:16:23 +00:00
David Dykstra
ad301e487c Skip the longdir test if the long directory can't even be created, such as
on cygwin (maybe only on certain filesystems?).
2003-01-10 15:06:10 +00:00
Wayne Davison
b5ae4aba38 Reset the io_error_fd right before the generator kills off the receiver
(because the death of the receiver will close the fd and cause the
generator to fail in any subsequent IO).
2003-01-10 08:32:09 +00:00
David Dykstra
8d2aad49e3 AI_NUMERICHOST is not defined on AIX. 2003-01-09 21:30:24 +00:00
David Dykstra
bc2b4963a0 Support IPv6 addresses with "hosts allow" and "hosts deny". Patch from
Hideaki Yoshifuji.
2003-01-09 21:14:10 +00:00
David Dykstra
ee7118a816 Fixed bug that caused rsync to lose exit status of its child processes.
Based on patch submited by David R. Staples.  Todd Vander Does contributed
the following test which showed the problem:
  > mkdir /tmp/nowrite
  > chmod -w /tmp/nowrite
  > rsync /etc/group /tmp/nowrite || echo $status
  mkstemp .group.cUaaeY failed
  rsync error: partial transfer (code 23) at main.c(518)
  23
  > rsync -e ssh loki:/etc/group /tmp/nowrite || echo $status
  mkstemp .group.1rayeY failed
  > rsync -e ssh loki:/etc/group /tmp/nowrite && echo $status
  mkstemp .group.fbaGiY failed
  0
The remote copy should have returned non-zero exit code like the local copy.
2003-01-09 19:04:06 +00:00
Wayne Davison
95dd949c09 Added .svn/ to the cvs_ignore_list and some trailing slashes to the
other dirs in the list.
2003-01-09 03:55:57 +00:00
Wayne Davison
9326552e66 Added .svn/ to the --cvs-exclude list and some trailing slashes to the
other dirs in the list.
2003-01-09 03:53:24 +00:00
Jos Backus
1e34e4b7cd Add "void" to some function definitions so that all declarations in proto.h
have full parameter lists. This helps unbreaking compilation on SCO UNIXWare.

Submitted by: Stephen Friedl
2002-12-24 07:42:04 +00:00
Jos Backus
06464f55e2 Change all relevant occurrences of `rsync'' and `$rsync_bin'' to the
canonical form ``$RSYNC'' (set in testsuite/rsync.fns). This prevents any
stray rsync binaries in the user's PATH from being picked up by the test
scripts and ensures that the newly built rsync binary is used always.
2002-12-24 07:25:25 +00:00
David Dykstra
1b85e3f1a0 When a file shows up as not existent during an rsync run, always check
to see if it excluded before reporting an error.  Previously it was only
checking for the exclusion if copy_links was enabled, but the error can
also occur if a file disappears during an rsync run.  Suggested by Eugene
V. Chupriyanov and Bo Kersey.
2002-12-11 18:48:27 +00:00
Jos Backus
eac9dc63e3 Fix the chgrp and hardlinks tests by running $RSYNC instead of relying on the
new rsync being in $PATH; it may pick up an old version, invalidating the
result of the tests. This is what the other tests do already.

Submitted by: Joel Shprentz <ShprentzJ@nima.mil>
2002-11-05 18:35:59 +00:00
David Dykstra
30e8c8e1e4 When using daemon mode over a remote shell program and not running as root,
default the config file to just "rsyncd.conf" in the current directory
instead of /etc/rsyncd.conf.  Also, fix problems with logging messages when
running daemon mode over a remote shell program: it was pretty much doing
the opposite of what it should have, sending early error messages to the
log and later messages to the client.  Switched it around so the very early
error messages go to the client and the later ones go to the log.
2002-08-30 23:27:26 +00:00
David Dykstra
d53d7795ee Change wording of --compare-dest option to refer to the --link-dest option. 2002-08-30 15:12:47 +00:00
David Dykstra
59c95e4243 Add --link-dest option from J.W. Schultz. 2002-08-29 14:44:55 +00:00
David Dykstra
f8a94f0de8 Patch from J.W. Schultz to have --include-from and --exclude-from on
filename "-" read from standard input.
2002-08-29 14:37:20 +00:00
Wayne Davison
3b5f6214a6 * Don't call getnameinfo() if we've already populated the addr_buf.
* Moved some structures in client_name() so that they remain in-scope for
  the entire function (since we set pointers to their storage location).
* Allow the dot-counting loop to increment to 4 instead of stopping at 3.
2002-08-02 17:11:39 +00:00
David Dykstra
542ad675b9 Put in better method of checking whether or not daemon over --rsh mode is
in place: simply check the "am_server" global variable, which is not set
true when the daemon is listening for connections (daemon_main is not
called in main.c if am_server is set).
2002-08-02 15:39:43 +00:00
David Dykstra
1e736b8ff7 Fix client_name to work on when INET6 is enabled but using a 4-part IPv4
IP address.  Tested on Linux, but only with an IPv4 ssh.  Somebody who has
IPv6 enabled on ssh needs to test it yet.
2002-08-02 15:05:03 +00:00
David Dykstra
a6d8c3f336 Fix last change to use correct IPv6 structure names when using INET6.
Doesn't yet look up names correctly on Linux with INET6 enabled, however;
needs further work but I don't have time right now.
2002-08-01 21:57:23 +00:00
Wayne Davison
bb4aa89c10 Don't pass "-l user" to the remote shell if we're starting a server-daemon
and the command already has a "-l user" option.
2002-08-01 20:46:59 +00:00
David Dykstra
09021eabb5 Fix to correctly identify remote IP address and host name when using
-e ssh and :: together.  Uses $SSH_CLIENT to locate the IP address
(was attempting to before but it didn't always work) and then uses
inet_pton() on that and getnameinfo() to find the name.
2002-08-01 19:17:00 +00:00
Wayne Davison
8d69d57113 Documented that the rsync:// URL syntax is now legal in the destination. 2002-08-01 17:55:40 +00:00
Wayne Davison
eaa4c150ab Mention the new rsync:// URL-in-the-destination syntax. 2002-08-01 17:55:11 +00:00
Wayne Davison
a125c82ad2 Allow the rsync:// URL syntax in the destination field. 2002-08-01 17:53:38 +00:00
Wayne Davison
93eff16a6a Document more recent changes. 2002-08-01 17:53:07 +00:00
Wayne Davison
d2d9fe184d Mention the recent commits. 2002-08-01 16:50:46 +00:00
David Dykstra
2d4ca358db Slight change to refer to the section CONNECTING TO AN RSYNC SERVER OVER A
REMOTE SHELL PROGRAM from within the --rsh option.
2002-08-01 16:21:20 +00:00
Wayne Davison
39993af514 The function passed to start_accept_loop() now takes 2 fd ints (for
the daemon via remote-shell support).
2002-08-01 00:37:08 +00:00
Wayne Davison
bef4934045 Document the new server-daemon via remote-shell mode. 2002-08-01 00:37:06 +00:00
Wayne Davison
1312d9fc47 If daemon_over_rsh is set, we limit the generated options to just
--server and --daemon.
2002-08-01 00:37:01 +00:00
Wayne Davison
75aeac44e8 Handle the new server-daemon via remote-shell mode. 2002-08-01 00:36:59 +00:00
Wayne Davison
68f40ebba9 Moved the end of start_socket_client() into a new function called
start_inband_exchange() and made several functions take two fds
(for the daemon via remote-shell support).  The start_daemon()
function is no longer static and now works on non-socket fds.
2002-08-01 00:36:56 +00:00
Wayne Davison
973007daac Changed auth_server() to take two fds (for the daemon via remote-shell
support).
2002-08-01 00:36:54 +00:00
Wayne Davison
8060514230 Stefan Nehlsen's fix of a timeout problem on large files.
(Modified to work with the latest CVS source.)
2002-07-31 21:20:07 +00:00
Wayne Davison
b1a2f37a6e Mention the popt upgrade. 2002-07-27 18:33:54 +00:00
Wayne Davison
7c66b86028 Check for the float.h header file (for popt). 2002-07-27 18:33:30 +00:00
Wayne Davison
cc248aae9b Updated to version 1.6.4. 2002-07-27 18:32:25 +00:00
Wayne Davison
ca23c51aeb - Fixed a crash in flist_find() when the last item in the flist has
been removed as a duplicate.
- Got rid of a compiler warning about mixed signed/unsigned types in a
  conditional expression.
2002-07-27 18:01:21 +00:00
David Dykstra
fca9a9b0f0 Document in --owner and "use chroot" that --numeric-ids is implied when
use chroot is yes.
2002-06-27 17:51:25 +00:00
John H Terpstra
1ea15dbe05 Added Solaris PkgInfo build script from Jens Apel <jens.apel@web.de> 2002-06-22 16:52:15 +00:00
David Dykstra
8e34cd41f0 Close previously opened file descriptor when mkstemp fails in recv_files().
Every other failure condition in that function was alreadying doing this,
and I saw a case with a lot of "mkstemp...No space left on device" messages
started becoming "mkstemp...Too many open files" messages because of this
bug.  Not that it makes a whole lot of difference, since nothing gets copied
because the disk was out of space.
2002-05-28 15:42:51 +00:00
David Dykstra
9ef1cc7cdf Clarify the relationship of max connections and lock file. 2002-05-16 21:07:23 +00:00
Martin Pool
411acbbc2a Better notes about handling IPv6 on old machines 2002-05-14 05:44:51 +00:00
Martin Pool
32e83406c4 Fix little mistake 2002-05-14 05:31:11 +00:00
Martin Pool
7e28fca126 Note about lchmod. 2002-05-14 05:25:46 +00:00
David Dykstra
e4ffb53900 Fix the rsync home page URL to drop a trailing "/rsync". 2002-05-13 18:34:37 +00:00
David Dykstra
7c2d381c28 Clarify that exclude/include options in rsyncd.conf apply only to files
sent from the server or deleted on the server.
2002-05-13 18:22:28 +00:00
Martin Pool
bde47ca7c5 Note that using the old sockets API probably will not work
sufficiently on some ipv6 systems.
2002-05-13 07:54:47 +00:00
Wayne Davison
ea7f8108b0 Make the -e text a little less chatty, and mention the legality of
command-line options in the RSYNC_RSH section.
2002-05-11 08:31:55 +00:00
Wayne Davison
98393ae2e2 Mention that the -e COMMAND can contain options. 2002-05-10 19:56:23 +00:00
David Dykstra
759ac87019 Submit enhancement from Michael Zimmerman to allow --suffix to be used
with --backup-dir.
2002-05-09 21:44:46 +00:00
David Dykstra
a1e0e45e01 Indicate that the exclude options in rsyncd.conf only apply when receiving
files to a server and not when sending files to it.
2002-05-09 19:03:40 +00:00
Wayne Davison
54170a084d Tweaked the --rsh option's description. 2002-05-06 19:05:05 +00:00
Wayne Davison
1bbf83c07d - Improved the references to rsh to better indicate that rsync may be
configured to use some other remote shell by default.
- Fixed the mention of ssh's preferred IO-blocking mode.
2002-05-06 19:02:44 +00:00
Wayne Davison
ccd2b499ed Mention that --delete-after now implies --delete. 2002-05-06 18:47:57 +00:00
Wayne Davison
1de50993a7 Made the --delete-after option imply --delete. 2002-05-03 22:59:17 +00:00
Wayne Davison
786c36876b Mentioned that --delete-after and --delete-excluded imply --delete. 2002-05-03 22:58:01 +00:00
Martin Pool
8bd1a73e14 Add note about resolving Debian gid problem. 2002-04-26 00:55:34 +00:00
Martin Pool
c7d692c3c3 Notes about handling machines lacking getaddrinfo(). 2002-04-24 01:13:26 +00:00
Martin Pool
f9b9e2f067 Note from Alberto Accomazzi that rsync urls are broken for upload 2002-04-19 05:33:36 +00:00
Martin Pool
dafe63ca98 Doc. 2002-04-16 01:38:21 +00:00
Martin Pool
f49a7b227f When -e is specified along with an rsyncd url, the client should get a
warning but it should not be treated as an error.  (Bill Nottingham)

  http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=62489
2002-04-15 07:50:18 +00:00
Martin Pool
f5e4eadb74 --no-blocking-io might be broken in the same way as --no-whole-file;
somebody needs to check.
2002-04-15 05:05:57 +00:00
Martin Pool
717eb9b883 Note about testing "refuse options" 2002-04-13 12:17:47 +00:00
Martin Pool
5ba268efa8 *** empty log message *** 2002-04-13 03:52:48 +00:00
Martin Pool
25ff30e804 Notes on testing, release, and todo items from the Debian paper. 2002-04-12 05:05:44 +00:00
Martin Pool
bdae761ee1 reformat 2002-04-12 04:22:52 +00:00
Martin Pool
5af50297be Note about manual revision. 2002-04-11 02:35:25 +00:00
Martin Pool
32f761755e Try to fix ctype issues by always calling these functions as
if (!isdigit(* (unsigned char *) p)) {

so that the argument is always in the range of unsigned char when
coerced to an int.

(See digit 1.)
2002-04-11 02:25:53 +00:00
Martin Pool
c4fea82ff9 Doc. 2002-04-11 02:21:41 +00:00
Martin Pool
6ded1170ac Doxygen 2002-04-11 02:18:51 +00:00
Martin Pool
991f90f296 Receiving an @ERROR line from the server is (I think) always fatal, so
the client should exit upon receiving one and not be surprised that
the socket closes.
2002-04-11 02:16:34 +00:00
Martin Pool
c979dad54a Fix old typo. 2002-04-11 02:11:50 +00:00
Martin Pool
136ac7ecec Receiving an @ERROR line from the server is (I think) always fatal, so
the client should exit upon receiving one and not be surprised that
the socket closes.
2002-04-11 01:56:35 +00:00
Martin Pool
3e8369b6dc Correction from Nelson Beebe: argument to functions such as isspace()
must be an int, not a char.  This could cause sign-extension problems.
2002-04-09 06:32:07 +00:00
Martin Pool
a7dc44d27d Doc.
Correction from Nelson Beebe: argument to functions such as isspace()
must be an int, not a char.  This could cause sign-extension problems.
2002-04-09 06:18:13 +00:00
Martin Pool
07a874fd9b Correction from Nelson Beebe: argument to functions such as isspace()
must be an int, not a char.  This could cause sign-extension problems.
2002-04-09 06:15:13 +00:00
Martin Pool
e35080cede long int and signedness fix from Nelson Beebe 2002-04-09 06:11:06 +00:00
Martin Pool
ce8149b6fe long int fix from Nelson Beebe 2002-04-09 06:03:50 +00:00
Martin Pool
a86179f429 Fix type error. 2002-04-09 05:32:52 +00:00
Martin Pool
56cf38ac98 Add RERR_OK == 0 2002-04-09 05:29:26 +00:00
Martin Pool
b0f451eb3b Doc _exit_cleanup. 2002-04-09 05:26:46 +00:00
Martin Pool
d0829892c6 Doc start_socket_client 2002-04-09 05:23:07 +00:00
Martin Pool
fdf88d7574 Doc start_socket_client 2002-04-09 05:20:30 +00:00
Martin Pool
595f2d4d97 Notes about supplementary groups and -z. 2002-04-09 05:14:59 +00:00
Martin Pool
cae95647a4 Doc. 2002-04-09 05:07:15 +00:00
Martin Pool
a254fd9798 Doc. 2002-04-09 05:03:45 +00:00
Martin Pool
805edf9d7d A bit more support for IO phase names. 2002-04-09 05:00:03 +00:00
Martin Pool
eca2adb4b3 OK, we can now get phase messages if we fail in send_file_entry 2002-04-09 04:50:25 +00:00
Martin Pool
4eea7793ea Doc
Try symlinks with an empty target
2002-04-09 04:49:42 +00:00
Martin Pool
67684d038d long int fix from Nelson Beebe 2002-04-09 04:49:23 +00:00
Martin Pool
98b332edea Fix typo.
Show io phase name in error message.
2002-04-09 04:41:03 +00:00
Martin Pool
e681e82066 Rather than a loop subtracting 1e6 to convert usecs to secs/usecs, just
use div/mod.
2002-04-09 04:33:32 +00:00
Martin Pool
08571358b1 Factor out bwlimit sleep code from writefd_unbuffered into its own function. 2002-04-09 04:29:46 +00:00
Martin Pool
8901a07fdb Clarify "error writing %d bytes" message. 2002-04-09 04:23:18 +00:00
Martin Pool
880da0072e Clean up docs. 2002-04-09 04:20:36 +00:00
Martin Pool
a83600cc82 Change error message "partial transfer" to "some files could not be
transferred".

I don't generally like changing that sort of thing, but I think this
one was a persistent source of confusion.
2002-04-08 09:10:50 +00:00
Martin Pool
dd0628f85f Note code cleanups 2002-04-08 09:09:03 +00:00
Martin Pool
e66dfd1879 Doc and indent only. 2002-04-08 09:05:26 +00:00
Martin Pool
bf2daeaf2d Remove redundant list of options. It might be nice to summarise the
most frequently-used ones in here.

Nelson Beebe pointed out that the information about bug tracking was
out of date.
2002-04-08 08:58:26 +00:00
Martin Pool
bd0ad74f4b Notes on MD4 performance. This quite unnecessarily takes up 90% of
CPU on a local transfer, without achieving anything useful.
2002-04-08 08:39:03 +00:00
Martin Pool
79f671cc7c Doc 2002-04-08 08:35:30 +00:00
Martin Pool
0f9c48b1d2 Doc file 2002-04-08 08:34:03 +00:00
Martin Pool
538ba24fd7 Doc match_sums. 2002-04-08 08:33:13 +00:00
Martin Pool
d37d8d7b69 Doc sum_update 2002-04-08 08:29:04 +00:00
Martin Pool
f4a0483ab8 Add manual prototype for maintainer-mode function 2002-04-08 08:24:59 +00:00
Martin Pool
f5f95a38c4 Document the perversely-named matched() function, which is called even
if we have not matched!
2002-04-08 08:23:50 +00:00
Martin Pool
3e7053ac59 With -vv, show state of --whole-file once at the start of the transfer. 2002-04-08 08:06:18 +00:00
Martin Pool
420ef2c419 Doc. 2002-04-08 08:02:08 +00:00
Martin Pool
9fb3f7a9ab Doc rsync_panic_handler() 2002-04-08 07:46:34 +00:00
Martin Pool
734a94a20c Clean up prototype.
Drop unused variables.
2002-04-08 07:42:54 +00:00
Martin Pool
b44be3e944 Fix prototype. 2002-04-08 07:39:56 +00:00
Martin Pool
fc0302cf07 Show panic_action in --version. 2002-04-08 07:36:05 +00:00
Martin Pool
4fdc39dde8 Allow panic_action to be configured through environment variable RSYNC_PANIC_ACTION. 2002-04-08 07:34:17 +00:00
Martin Pool
9a933bc2ce t_unsafe needs asnprintf on some platforms. 2002-04-08 06:23:34 +00:00
Martin Pool
524dc9afd6 correct behaviour is unclear 2002-04-08 06:18:03 +00:00
Martin Pool
e4d709cbf8 Cleanup 2002-04-08 06:01:26 +00:00
Martin Pool
48c1586cd1 handle yodl and vpath 2002-04-08 05:38:51 +00:00
Martin Pool
7bd0cf5b8f Clarify meaning of unsafe symlinks 2002-04-08 05:30:28 +00:00
Martin Pool
fcb69e5cdc Fix copyright. 2002-04-08 05:28:31 +00:00
Martin Pool
96557d23a3 Add more test cases.
Turn off -x.
2002-04-08 05:22:50 +00:00
Martin Pool
4e5db0ad4a Doc. 2002-04-08 05:21:51 +00:00
Martin Pool
c81a32f071 Add more test cases. 2002-04-08 05:19:41 +00:00
Martin Pool
6f2623fd69 Formatting cleanup. 2002-04-08 04:59:34 +00:00
Martin Pool
b4235b3165 Doc. 2002-04-08 04:48:51 +00:00
Martin Pool
d25c0e42c7 A test suite that calls unsafe_symlink() directly to see how it
handles different strings.
2002-04-08 04:47:01 +00:00
Martin Pool
0ecfbf27c3 Split code out into separate files and remove some global variables to
reduce symbol dependencies between files and therefore make it easier
to write unit tests.  The diff is large, but the actual code changes
are pretty small.
2002-04-08 04:16:46 +00:00
Martin Pool
fb4c98c2c8 Test harness for unsafe_symlink: just passes in argv[]. 2002-04-08 04:13:43 +00:00
Martin Pool
cd8e38b13f Little stub module that replaces functions such as rprintf called from
many places with a redirector to stderr.  If you just want to test a
particular routine you can link to this rather than the whole framework.
2002-04-08 04:12:31 +00:00
Martin Pool
b35d0d8e9a Split code out into separate files and remove some global variables to
reduce symbol dependencies between files and therefore make it easier
to write unit tests.  The diff is large, but the actual code changes
are pretty small.
2002-04-08 04:10:20 +00:00
Martin Pool
c948e309f2 Don't generate code for zlib and popt. 2002-04-08 04:00:24 +00:00
Martin Pool
d1f83bcc81 Doc. 2002-04-08 03:43:54 +00:00
Martin Pool
e0fde757fd Doc. 2002-04-08 03:38:36 +00:00
Martin Pool
25d34a5c80 Rearrange code slightly to avoid util.c depending on main.c. 2002-04-08 03:37:19 +00:00
Martin Pool
610364e3a6 Tune doxygen output, remove warning. 2002-04-08 03:13:11 +00:00
Martin Pool
036e70b024 Document unsafe_symlink(). 2002-04-08 03:10:01 +00:00
Martin Pool
ac13ad106a Clean up comments for Doxygen. 2002-04-08 03:03:04 +00:00
Martin Pool
bd9e9eccbd Doc. 2002-04-08 02:41:23 +00:00
Martin Pool
8ff9d697c9 Note on debugging daemon 2002-04-08 02:39:00 +00:00
Martin Pool
62b68c8046 Notes about logging. 2002-04-08 01:59:21 +00:00
Martin Pool
e4724e5c1c Note about two small bugs. 2002-04-05 07:25:06 +00:00
Martin Pool
559e727bf7 Test more permutations. 2002-04-05 07:13:01 +00:00
Martin Pool
126642b633 Fix filenames. 2002-04-05 07:04:23 +00:00
Martin Pool
cca4e06786 Get rid of testlink after use. 2002-04-05 07:00:53 +00:00
Martin Pool
2f1faea89b Test case for --copy-unsafe-links, contributed by Vladimír Michl,
converted to the test suite.  Thankyou!

It fails at the moment; I don't know if that's a test bug or an rsync bug.
2002-04-05 06:57:47 +00:00
Martin Pool
3d90ec146f Doc 2002-04-05 06:17:50 +00:00
Martin Pool
1bc209b441 Fix completely braindead previous patch. Thanks Jos. 2002-04-03 06:55:24 +00:00
Martin Pool
1433e6da69 Patch from Zoong Pham and Albert Chin to improve detection of
getaddrinfo on Tru64.

Also configure.in test for mkfifo and sys/un.h, although we don't
actually use that yet.
2002-04-03 06:03:27 +00:00
Martin Pool
f8f4c862e8 Change code that writes s_count to a batch file to squish it into an
int first -- a stopgap for compilers that reasonably complain about a
ternary that returns either a size_t or an int.

Really we should not write an int, but rather a larger type.  Somebody
more familiar with the batch code should look at it.
2002-04-03 05:55:54 +00:00
Martin Pool
226df8e717 Support Doxygen pretty-printer 2002-04-03 04:29:19 +00:00
Martin Pool
6c92af2067 Commit patch based on one from John L. Allen to fix "forward name
lookup failed" on AIX 4.3.3.

When doing an name->addr lookup on the client address, there's no
point including the service name, because it can't be spoofed and it
apparently causes trouble when not present in /etc/services.
2002-04-03 02:33:42 +00:00
Martin Pool
54c7298ce4 Roll over version and news. 2002-04-03 02:13:42 +00:00
Martin Pool
642a979a27 Note about --dry-run. 2002-04-03 00:10:11 +00:00
Martin Pool
e733c93423 Remove warning about "run autoconf". It tends to break too much with
CVS.
2002-04-02 02:00:29 +00:00
Martin Pool
ffdb58a51a Bump to 2.5.5. 2002-04-02 01:41:58 +00:00
Martin Pool
c053133207 If configured with --enable-maintainer-mode, then on receipt of a
fatal signal rsync will try to open an xterm running gdb, similarly to
Samba's "panic action" or GNOME's bug-buddy.
2002-03-27 05:10:44 +00:00
Martin Pool
9098bbf3b3 Improved network error handling. (Greg A. Woods) 2002-03-27 01:03:13 +00:00
Martin Pool
68618b8810 Shell scripts should explicitly "exit 0" for portability. Thanks Jos. 2002-03-26 10:36:45 +00:00
Martin Pool
e553d27f41 Fix suggested by Jos for hands.test. Some of the functionality
previously built into Phil's test was clashing with the runtests.sh
framework.  I think one of the core problems might be that scripts
which don't explicitly "exit 0" have return codes which vary depending
on the particular shell.  (c.f. the autoconf portability guide.)

This might break the Debian test suite but I'm afraid I don't know
enough about how it works yet.  Hopefully eventually it can become
just a wrapper around our 'make check'.
2002-03-26 10:28:57 +00:00
Martin Pool
d092924c63 Updated spec file from Jason Haar. Seems to mostly just change the
path for manuals, and bumps the version.
2002-03-26 05:15:09 +00:00
Martin Pool
34027489e0 Ignore autoconf cache. (??) 2002-03-26 01:27:24 +00:00
Martin Pool
d1239eae92 Jos points out that test -L is still broken on Solaris. Now we try up
front to detect a command that will work properly, and use that
consistently.

Also, in test report, show setting of $preserve_scratch.

Reset version.
2002-03-26 01:25:47 +00:00
Martin Pool
331050969b Bump version to 2.5.5rc1. 2002-03-25 23:22:08 +00:00
Martin Pool
259c3e72b0 Add note about possible hardlink bug. 2002-03-25 23:09:31 +00:00
Martin Pool
8f7a38336d Make the situation w.r.t. dynamically linking zlib and libpopt clear. 2002-03-25 09:42:36 +00:00
Martin Pool
999dfffc9b Add link to Apple bug. 2002-03-25 07:29:43 +00:00
Martin Pool
527a51cec5 Doc 2002-03-25 07:07:03 +00:00
Martin Pool
20c15aead5 Hm, strange off-by-one bug. 2002-03-25 06:59:17 +00:00
Martin Pool
fb859e5674 Apparently the OS X port of gcc gags on __attribute__. 2002-03-25 06:49:08 +00:00
Martin Pool
4f2dcb1714 If we discover a hardlink with -vv say what it's a link to. 2002-03-25 06:27:44 +00:00
Martin Pool
64e74631e0 Fix from Jos for batch mode on Solaris. 2002-03-25 06:06:29 +00:00
Martin Pool
fba31efb74 Disambiguate hard link messages. 2002-03-25 05:54:31 +00:00
Martin Pool
435f1ed70d Apparently SGI make doesn't like $< in non-implicit rules. 2002-03-25 04:36:56 +00:00
Martin Pool
94f34ca10a Doc. 2002-03-25 04:04:23 +00:00
Martin Pool
b0633744fa Note about mkdir bug. 2002-03-25 03:56:38 +00:00
Martin Pool
c127e8aaec Add a test case for trim_trailing_slashes, and make it handle other cases. 2002-03-25 03:51:17 +00:00
Martin Pool
bf4e725d5d Code that was meant to trim trailing slashes from mkdir() paths
actually did not; fix it.
2002-03-25 03:29:47 +00:00
Martin Pool
663717f465 Need to also delete getgroups when cleaning. 2002-03-25 03:26:28 +00:00
Martin Pool
12b159ac41 Define NGROUPS if not already done. 2002-03-25 03:18:36 +00:00
Martin Pool
9299c8f0b4 Clean testtmp*, because we now put tests in their own directories.
Add "make cleantests"
2002-03-25 03:16:35 +00:00
Martin Pool
dfef3f1099 Change chgrp.test to use our getgroups rather than the system's. 2002-03-25 03:01:37 +00:00
Martin Pool
fa3690f488 Initial revision. 2002-03-25 02:58:59 +00:00
Martin Pool
4acbfa2ade Add our own little tool to call getgroups(2) because it's too hard to
find a portable shell command that does it.
2002-03-25 02:55:52 +00:00
Martin Pool
ef86d74736 Clean up text. 2002-03-22 22:36:22 +00:00
Martin Pool
118f39d45b Clean up text. 2002-03-22 22:33:49 +00:00
Martin Pool
77867907ed Doc permissions while testing. 2002-03-22 06:22:53 +00:00
Martin Pool
98c1b32565 Rather than literally "nobody", try using uid/gid = 65534 as
"nobody".  The existing code kind-of assumes this.
2002-03-22 06:12:51 +00:00
Martin Pool
7a176e87d5 Better messages. 2002-03-22 06:09:09 +00:00
Martin Pool
79c9d8a180 Proper messages for skipped tests. 2002-03-22 06:07:50 +00:00
Martin Pool
7d8219327b If tests are skipped, explain why. 2002-03-22 06:03:46 +00:00
Martin Pool
4ac4bdbb38 More sgml cleanups. 2002-03-22 06:02:28 +00:00
Martin Pool
f494f2864c Doc about checkit. 2002-03-22 05:59:12 +00:00
Martin Pool
017f22b47f Add /usr/xpg4/bin/ to PATH to help solaris. 2002-03-22 05:52:09 +00:00
Martin Pool
dec41b556b Cope on systems without the whoami command. 2002-03-22 05:20:47 +00:00
Martin Pool
be2961da2c If there's an error in start_socket_client, print an explanation as
well as failing.

Doc.

Trying to work out why daemon-gzip-download.test fails on SCO with

  rsync error: unexplained error (code 190) at main.c(886)
2002-03-22 05:19:19 +00:00
Martin Pool
914cc65c9d Doc. 2002-03-22 05:14:44 +00:00
Martin Pool
6479c2ed3f Notes on logging etc 2002-03-22 05:11:39 +00:00
Martin Pool
c1a04ecbfd Doc. 2002-03-22 05:08:53 +00:00
Martin Pool
69b06c50c4 Use id -G rather than groups to get a list of groups for this
user, so that we can cope on systems like Cygwin that tend to have
group names containing spaces.
2002-03-22 05:06:36 +00:00
Martin Pool
6aaf8d8c10 * Make "make install-strip" works properly, and "make install"
accepts a DESTDIR variable for help in building binary packages.
      (Peter Breitenlohner)
2002-03-20 05:53:40 +00:00
Martin Pool
4cf64834ed Patch from Paul Haas:
* Fix situation where failure to fork (e.g. because out of process
      slots) would cause rsync to kill all processes owned by the
      current user.  Yes, really!  (Paul Haas, Martin Pool)

Also, add a little more documentation and paranoia to make sure we
never call kill(2) with a negative pid.
2002-03-20 01:09:49 +00:00
David Dykstra
b8709f5046 Now that whole_file and no_whole_file are separate variables, have the
--whole-file and --no-whole-file options set/reset both variables so if
more than one option is specified the last one will be the one honored.
2002-03-19 20:16:42 +00:00
Martin Pool
24448f741f Clean up sgml.
Add note about building with gcc.
2002-03-19 05:52:34 +00:00
Martin Pool
76533c52dc todo: Versions of read() and write() that corrupt the stream, or abruptly fail 2002-03-19 05:23:04 +00:00
Martin Pool
3ff984d7a7 Fix --help layout. 2002-03-19 05:09:19 +00:00
Martin Pool
7a52790b50 Fix overly long line in version. 2002-03-19 05:01:36 +00:00
Martin Pool
7b329a2d79 Follow advice from GPL to insert a disclaimer of warranty in the
version and help information.
2002-03-19 05:00:05 +00:00
Martin Pool
599dc93c64 Doc: Pipe program that makes slow/jerky connections. 2002-03-19 04:14:30 +00:00
Martin Pool
8b54f00466 Include all fields in the options table to quieten gcc warnings about
missing initializers.
2002-03-19 04:10:07 +00:00
Martin Pool
8469faef03 Intentional test of assert :_) 2002-03-19 03:59:51 +00:00
Martin Pool
bceec82f35 Previous solution for --no-whole-file would probably break when
connecting to old servers that don't have --no-whole-file.

Instead, we handle no_whole_file and whole_file separately, without
the magic -1 value.  We don't modify no_whole_file after
initialization.
2002-03-19 03:39:42 +00:00
Martin Pool
ed521de525 Sending --no-whole-file is no good because it will not work with old
versions of rsync.
2002-03-19 03:27:33 +00:00
Martin Pool
d157de203a Typo. 2002-03-19 03:23:08 +00:00
Martin Pool
1bfbf40bd5 Fix --whole-file problem that caused it to be the default even for
remote connections.  (Frank Schulz)

<http://lists.samba.org/pipermail/rsync/2002-March/006526.html>

Also, add documentation for whole_file and add assertions that the
value is valid.
2002-03-19 03:21:53 +00:00
Martin Pool
6d19c6742c Need a test for "refuse options" 2002-03-16 09:26:33 +00:00
Martin Pool
a628b06977 Note about 100295@bugs.debian.org 2002-03-16 09:11:56 +00:00
Martin Pool
6b2d24de2c Make sure that freeaddrinfo is called on all code paths leading away
from a call to getaddrinfo.  (Dave Dykstra)
<20011219085021.A23107@lucent.com>
2002-03-16 09:00:44 +00:00
Martin Pool
e23d790fa7 Doc: Note from Dave Dykstra that getaddrinfo calls must be paired with
freeaddrinfo().
2002-03-16 08:23:08 +00:00
Martin Pool
2a5904a580 Add more rules for make distclean. 2002-03-16 08:21:15 +00:00
Martin Pool
4610ac79c2 "make distclean": We try to delete built files from both the source
and build directories, just in case somebody previously configured
things in the source directory.
2002-03-16 08:18:19 +00:00
Martin Pool
142f5be922 Note about --progress patch. 2002-03-16 00:00:43 +00:00
Martin Pool
b17dd0c435 Note about debian #28416 2002-03-15 14:01:43 +00:00
Martin Pool
3669201179 Add debian bug # 2002-03-15 13:42:42 +00:00
Martin Pool
a5c48193c7 Keep stderr and stdout properly separated (Debian #23626) 2002-03-15 13:38:12 +00:00
Martin Pool
4366275bab Doc: Debian uses "nogroup" instead of group "nobody", so our defaults
are not so good.
2002-03-15 12:53:21 +00:00
Martin Pool
c579310a00 If we've finished transferring a file, show the time taken; otherwise
show expected time to complete.  That's kind of inconsistent, but
people can probably cope.  Hopefully we'll get more consistent and
complete progress reporting soon. (Cameron Simpson)
2002-03-15 12:45:10 +00:00
Martin Pool
96553aa7ef Typo. 2002-03-15 06:29:22 +00:00
Martin Pool
2094283b80 On Solaris, put /usr/ucb/bin at the end of the path to help find
utilities we might need.  (Like 'whoami' in this case.)
2002-03-15 06:28:58 +00:00
Martin Pool
4c631ac621 Try to handle 'test -L' on Sun. 2002-03-15 01:22:09 +00:00
Martin Pool
d96d3893dd Try to handle 'test -L' on Sun. 2002-03-15 01:08:53 +00:00
Martin Pool
b73b51a9e4 More notes 2002-03-15 01:04:25 +00:00
Martin Pool
3c1edccb7b Suggestion from david.e.sewell to add --diff. 2002-03-15 01:03:24 +00:00
David Dykstra
b23c290630 Eliminate extraneous "done" messages in verbose mode. Problem reported by
Lee Eakin.
2002-03-14 21:20:20 +00:00
Martin Pool
c7b562becf Correct the plural in "1 file to consider." (Greg Louis) 2002-03-14 12:00:12 +00:00
Martin Pool
5648a81936 Add phony target to run Splint. 2002-03-14 10:42:52 +00:00
Martin Pool
daa3d0e2da "make install-strip" works. (Greg Louis) 2002-03-14 10:38:55 +00:00
Martin Pool
c9a66d41fe Roll over news file; put in page markers. 2002-03-14 10:33:59 +00:00
Martin Pool
0ee1bd82c5 Bump version to 2.5.5cvs 2002-03-14 03:10:23 +00:00
Martin Pool
53e1f937bc Show user name and uname -a in the test output header, to aid in bug
reports.  (We mostly want to know if they're root or not.)
2002-03-14 03:04:36 +00:00
Martin Pool
604f343c49 Doc: "opening tcp connection to %s port %d" is kind of misleading when
running the test case.
2002-03-14 02:55:11 +00:00
Martin Pool
e9c4c3018b More notes on testing. 2002-03-13 04:25:10 +00:00
Martin Pool
db1babe6a9 If a child of the rsync daemon dies with a signal, we should notice
that when we reap it and log a message.
2002-03-13 00:25:00 +00:00
Martin Pool
f1abcc7a4c Bump version to 2.5.4. 2002-03-13 00:03:34 +00:00
Martin Pool
97e1254a2d Notes on chmod. 2002-03-12 23:55:33 +00:00
Martin Pool
89b0a3d963 If we get an error writing to a socket, then we should perhaps
continue trying to read to see if an error message comes across
  explaining why the socket is closed.  I'm not sure if this would
  work, but it would certainly make our messages more helpful.
2002-03-12 06:08:36 +00:00
Martin Pool
3a79260d3a Add link to purify replacement. 2002-03-12 05:48:57 +00:00
Martin Pool
43a4dc1053 Add link to purify replacement. 2002-03-12 05:47:45 +00:00
Martin Pool
e53fe9a278 Note about TDB. 2002-03-12 05:41:25 +00:00
Martin Pool
f5a95bb50b Notes on testing. 2002-03-12 05:39:29 +00:00
Martin Pool
0e23e41d48 Note about splint. 2002-03-12 05:33:39 +00:00
Martin Pool
ac69049ec2 Additional trivial merge patch from Jos 2002-03-12 02:07:36 +00:00
Martin Pool
b2a2dd1154 Get ready for new release. 2002-03-12 01:26:01 +00:00
Martin Pool
31837783c0 Update NEWS. 2002-03-12 01:22:56 +00:00
Martin Pool
d40fb72395 Get ready for new release. 2002-03-12 01:18:20 +00:00
Martin Pool
1c548d5e59 Bump version to 2.5.4pre1. 2002-03-12 01:15:49 +00:00
Martin Pool
be59d0ec23 Patch from Jos Backus to merge zlib-1.1.4. 2002-03-12 01:14:58 +00:00
Martin Pool
0bc467516a Merge the zlib fix properly; back out tridge's bandaid. 2002-03-12 00:33:51 +00:00
Martin Pool
844f11f284 Clarify behaviour of installcheck. 2002-03-12 00:22:22 +00:00
Martin Pool
1cf1e7b3b4 Rename to README.testsuite, and bring it up to date. 2002-03-12 00:20:16 +00:00
Martin Pool
18b72cc829 Try to download a tree over a compressed connection to a daemon. 2002-03-12 00:11:35 +00:00
Martin Pool
271f87e5d4 This test tries to upload a file over a compressed connection to the
server.  This ought to exercise (exorcise? :-) a bug in 2.5.3.  It
ought to fail there and pass with later versions.
2002-03-12 00:09:09 +00:00
Martin Pool
2e6c7f4549 Fix generated rsyncd.conf file for testing. 2002-03-12 00:04:03 +00:00
Andrew Tridgell
6819304740 a quick fix for a segmentation fault in zlib I am getting whenever I
try to upload a file from rsync 2.5.2 to rsync 2.5.3
2002-03-11 18:54:51 +00:00
Martin Pool
a795ab99c7 Set version to 2.5.3. 2002-03-11 05:58:31 +00:00
Martin Pool
567e56313a Merge zlib double-free bug forwarded by Mark J Cox. 2002-03-11 05:55:33 +00:00
Martin Pool
9e95e92bdf Note on zlib patch merge. 2002-03-11 05:52:22 +00:00
Martin Pool
be60c7b9d1 Try to merge across changes in zlib from 1.1.2 to 1.1.3. 2002-03-11 03:56:35 +00:00
Martin Pool
7d81641065 Note about merging zlib 1.1.3. 2002-03-11 03:44:44 +00:00
Martin Pool
17d8573ef0 Bump version to 2.5.3pre3. 2002-03-11 03:40:23 +00:00
Martin Pool
e2dd78f744 Add CVE number. 2002-03-11 03:39:49 +00:00
Martin Pool
06b91d8eb9 Try to merge across changes in zlib from 1.1.2 to 1.1.3. 2002-03-11 03:35:35 +00:00
Martin Pool
9ec5422c37 Try adding some FAQs from the FoM 2002-03-11 00:58:36 +00:00
Martin Pool
1935e11c3c Use SGML rather than texinfo. 2002-03-11 00:38:03 +00:00
Martin Pool
ec14031abd More merges into SGML. 2002-03-11 00:36:47 +00:00
Martin Pool
024a9bafbd Notes on processing the SGML stuff. 2002-03-11 00:27:42 +00:00
Martin Pool
27741d9fd9 Notes from Rasmus about statistics. 2002-03-08 04:41:11 +00:00
David Dykstra
e3bdb76326 Cygwin doesn't have setgroups() so probe for the function in configure
and don't try to call it if it doesn't exist.
2002-02-27 23:15:55 +00:00
David Dykstra
9369576459 I had accidentally deleted the case for --include-from when I added
the --no-blocking-io and --no-whole-file options.  This adds it back in.
2002-02-27 22:49:57 +00:00
Martin Pool
8a405c6ca1 Try out DocBook SGML to see if it's easier than Texinfo. 2002-02-25 20:07:11 +00:00
Martin Pool
94ad1c6477 Start of Python code to generate likely-looking pseudo random file
trees to reproducibly test performance on specified size sets.
2002-02-25 18:54:27 +00:00
Martin Pool
6f039cc2ac Merge Texinfo onto head. 2002-02-25 18:52:02 +00:00
Martin Pool
6216ca2c70 Add targets to build documentation from Texinfo. 2002-02-25 18:48:25 +00:00
Martin Pool
c6e27b608e More discussion about zlib. 2002-02-25 18:28:37 +00:00
Martin Pool
f76584a57c Scrappy notes on hot functions that should be fixed 2002-02-25 18:06:33 +00:00
Martin Pool
7bea78ced6 With -vv, client shows a message when opening a daemon connection via
an HTTP proxy.  This parallels the recent addition of a log message
for opening ssh connections.
2002-02-23 01:00:33 +00:00
Martin Pool
1264288cb5 With -vv, client shows a message when opening a daemon connection.
This parallels the recent addition of a log message for opening ssh
connections.
2002-02-23 00:57:30 +00:00
Martin Pool
0f0ea7f779 Add UNUSED macro that expands to a parameter attribute annotation on
gcc, to quieten its worries about parameters that must always be
unused.
2002-02-23 00:17:50 +00:00
Martin Pool
0b4af330ce Doc. 2002-02-23 00:12:11 +00:00
Martin Pool
6dd41b67fb print_child_argv can be static. 2002-02-23 00:05:06 +00:00
Martin Pool
1521eefb62 Make "make proto" work for VPATH builds. 2002-02-23 00:02:07 +00:00
Martin Pool
a036a0e818 Revert 1.134 -- this breaks Net/Free BSD. 2002-02-21 00:56:11 +00:00
Martin Pool
7583ded808 Make setgroups(0,0) unconditional -- accidentally thinking we have
don't it on a machine that does have supplementary groups would be a
security hole.  If this breaks anything we'll fix it later.
2002-02-21 00:45:48 +00:00
Martin Pool
78818f4465 Add bug # for #132272 2002-02-21 00:26:06 +00:00
Martin Pool
7a49cb5667 Patch from Albert Chin to fix getaddrinfo on Tru64 UNIX 5.x. 2002-02-19 23:40:47 +00:00
Martin Pool
23212669ac Bump version to 2.5.3pre1 2002-02-19 02:16:37 +00:00
Martin Pool
3ce0f9a653 Clean up error message 2002-02-19 01:41:20 +00:00
Martin Pool
d834adc14f Doc 2002-02-19 01:39:11 +00:00
Martin Pool
b84ba8967a rsync prefix on mkdir and pushdir error messages. 2002-02-19 01:07:24 +00:00
Martin Pool
79845f2834 Doc. 2002-02-18 23:36:10 +00:00
Martin Pool
78ece130a4 Change shell syntax to try to please Solaris 2002-02-18 23:09:50 +00:00
Martin Pool
bd37c66630 Fix error handling for failing to fork after accepting a connection --
close fd, sleep, then try again.
2002-02-18 22:58:49 +00:00
Martin Pool
371d1c36b3 Solaris does not have diff -u. 2002-02-18 22:55:21 +00:00
Martin Pool
d0f821ad3d Must use STRUCT_STAT not "struct stat" to be compatible with other
rsync functions.
2002-02-18 22:49:00 +00:00
Martin Pool
ded8347d6b Cope with BSD systems on which mkdir() will not accept a trailing
slash.

<http://www.opensource.apple.com/bugs/X/BSD%20Kernel/2734739.html>
2002-02-18 22:44:23 +00:00
Martin Pool
c4a5c57dc3 If the daemon is unable to fork a child to accept a connection, print
an error message.  (Colin Walters)
2002-02-18 22:38:03 +00:00
Martin Pool
404e813c52 Add -vvv trace statement to set_modtime to help with Debian bug
#100295.
2002-02-18 22:25:55 +00:00
Martin Pool
90d0a8db38 This test must specify --times because it compares listings that
include mtimes.
2002-02-18 22:14:46 +00:00
Martin Pool
956ff9ff72 Fix bug that made tls.o not be removed by 'make clean'. 2002-02-18 22:07:44 +00:00
Martin Pool
1eca49c6ed Doc:
#defiine lchown chown

could be bad on systems which have no lchown and where chown
follows symbollic links.  On such systems it might be better not to
try to chown symlinks at all.
2002-02-18 21:46:49 +00:00
Martin Pool
34758d5c15 Ignore SIGPIPE and allow EPIPE to get through to the program so that
we don't get stuck in a recursive loop trying to report a broken pipe
across that same broken pipe.  Debian bug #128632 (Colin Walters)
2002-02-18 20:06:57 +00:00
Martin Pool
befbfe6115 Fix for rsync server processes hanging around after the client
unexpectedly disconnects.  (Colin Walters) (Debian bug #128632)
2002-02-18 19:54:00 +00:00
Martin Pool
900748fca1 rwrite: Doc. 2002-02-18 19:51:12 +00:00
Martin Pool
87ee248169 Document multiplex stuff. 2002-02-18 19:44:04 +00:00
Martin Pool
bb7c4fa361 Doc. 2002-02-18 19:10:28 +00:00
David Dykstra
c613d37048 If a daemon prints an error message of @ERROR, have the client treat the
message as an FERROR rather than an FINFO.
2002-02-18 18:29:48 +00:00
David Dykstra
d52a22e4db Add item about fixing "out of memory in flist_expand" on Sunos4. 2002-02-14 15:27:55 +00:00
David Dykstra
6dfb45bcdf Added the two most important bug fixes to NEWS to make sure they're not
forgotten for the next release.
2002-02-13 18:57:06 +00:00
David Dykstra
145794936f Patch from Jos Backus <josb@cncdsl.com> to use HAVE_SOCKADDR_LEN rather
than HAVE_SOCK_SIN_LEN around use of sin_len.  Correct usage was already
in place in clientname.c.
2002-02-13 18:45:17 +00:00
David Dykstra
301c680fd7 Suggested patch from Jim Ogilvie <jogilvie@us.ibm.com> to print out the
system error message when mkstemp fails.
2002-02-13 18:42:20 +00:00
David Dykstra
d27cbec598 Reversing the order of maybe_emit_filelist_progress() and
emit_filelist_progress() makes the native compilers on systems
including Solaris and Irix happier.
2002-02-13 18:30:27 +00:00
David Dykstra
f5be54d6ab Some systems, notably Sunos4, do not support realloc(NULL, n), so if
nothing has yet been malloced in flist_expand(), call malloc instead of
realloc.  Problem introduced in revision 1.106 of flist.c on January 25.
2002-02-13 18:06:36 +00:00
Martin Pool
1e19f7ba5f At least change INO64_T and DEV64_T back to just 'int64', not
'unsigned int64'.  This should fix some compile problems on machines
where int64 is not a simple integer type, but I'm not convinced it is
the ideal fix.
2002-02-13 02:57:55 +00:00
Martin Pool
db719fb0d7 Factor out code for filelist progress. Copy&paste considered harmful.
Add a little doc about potential optimization of stat() calls.
2002-02-13 02:44:31 +00:00
Martin Pool
b0d4f4c10e Add a test that --owner correctly propagates ownership of files for a
local transfer as root.
2002-02-09 07:43:13 +00:00
Martin Pool
238d23d775 Add a test that --group correctly propagates groups of which the local
user is a member.
2002-02-09 07:42:37 +00:00
Martin Pool
c019068f06 Add $preserve_scratch and $always_log so if you want to see details
about successful tests, you can.
2002-02-09 03:36:33 +00:00
Martin Pool
715d1f4504 Oops -- have to call setgroups() before giving up root.
Doc some of the peculiarities about starting rsyncd as root vs
non-root.
2002-02-09 03:30:22 +00:00
Martin Pool
4f092bee9f Make sure we call setgroups() after setuid(). (Ethan Benson) 2002-02-09 02:18:42 +00:00
David Dykstra
1bbd10fe07 Remove the "rsync:" prefixes on FINFO messages. Return the "building file
list ... done" to the way it was in 2.5.1 and before when not using -P.
Apply the file list progress messages when receiving files in addition to
sending files.
2002-02-07 16:36:12 +00:00
David Dykstra
088aac8597 Make batch mode actually work and add man page documentation. From Jos Backus. 2002-02-06 21:20:48 +00:00
Martin Pool
81c652d5d2 Merge modified --with-rsh patch: we now determine the default
remote-execution command as follows:

 1) if --with-rsh is specified, use that.

 2) otherwise if remsh is in the path, use that.

 3) otherwise use rsh

If remsh is present, we always modify the order of parameters to suit
it.  This is a bit strange.
2002-02-06 04:37:09 +00:00
Martin Pool
d7761c1480 Doc: Rusty's /*/* exclude hack produces spurious output with -vv. 2002-02-06 04:34:40 +00:00
David Dykstra
93689aa51a Add --no-whole-file and --no-blocking-io options 2002-02-05 23:05:31 +00:00
Martin Pool
46e6ad492a Only print the command used to open connections with -vv, not just -v. 2002-02-05 00:37:53 +00:00
Martin Pool
97efa5c36c Roll over NEWS 2002-02-05 00:35:31 +00:00
Martin Pool
0b1ffe2755 Only print the command used to open connections with -vv, not just -v.
<Pine.LNX.4.33L2.0201301015260.11155-100000@phong.blorf.net>
2002-02-05 00:34:03 +00:00
Martin Pool
8c35542d1f Patch from wayned so that add_exclude_list produces clearer debugging
output with -vvv.
2002-02-05 00:25:52 +00:00
Andrew Tridgell
0e9480317d the signed/unsigned change seems to have caused a logic bug on some
systems (only those without large file support perhaps?)

this fixes it
2002-02-03 01:38:39 +00:00
David Dykstra
b695d088cf Better explanation of --force. It is applicable whenever --delete is
not in effect.
2002-01-29 21:52:57 +00:00
David Dykstra
81dc5750ca A more accurate description of --force as I know it. 2002-01-28 21:09:03 +00:00
David Dykstra
d82434cf27 Clarify the --force entry in the rsync man page. 2002-01-28 17:06:04 +00:00
Martin Pool
cd6058f3d4 Oops, version should be just 2.5.2. 2002-01-25 23:19:21 +00:00
Martin Pool
9be3ba223c Bump version to 2.5.3. 2002-01-25 23:16:18 +00:00
Martin Pool
a261989cda More signedness fixes; should be harmless. 2002-01-25 23:07:33 +00:00
Martin Pool
7b5c3eb05e io_end_buffering doesn't need (or use) it's fd parameter: there's only
one multiplexed stream.
2002-01-25 23:01:50 +00:00
Martin Pool
0feec72eee DEV64_t and INO64_T should probably be unsigned 2002-01-25 23:00:21 +00:00
Martin Pool
be8bd99aa4 check_name doesn't need a socklen_t, because it knows what is inside
each sockaddr type.
2002-01-25 22:59:37 +00:00
Martin Pool
355b8bcd73 Add test case for device nodes. This test will be skipped unless you
run "make check" as root.
2002-01-25 10:56:43 +00:00
Martin Pool
d58e4c273c When comparing directories, use find . to call diff, rather than
diff -r.  Two reasons: diff -r might not work everywhere, and it also
might complain about nonregular files.
2002-01-25 10:55:59 +00:00
Martin Pool
a217ad3095 Add test_skipped function. 2002-01-25 10:47:47 +00:00
Martin Pool
3d6feada8a New --ignore-existing option, patch previously distributed with
Vipul's Razor.  (Debian #124286)
2002-01-25 10:42:23 +00:00
Martin Pool
5f78da2025 Fix for device nodes. (dann frazier) (Debian #129135) 2002-01-25 10:39:08 +00:00
Martin Pool
a05e4fa512 Fix for device nodes. (dann frazier) (Debian #129135) 2002-01-25 10:28:13 +00:00
Martin Pool
2119a4c462 Another DEV64_T change. 2002-01-25 10:16:11 +00:00
Martin Pool
1d5a1da9f8 With -vv, when the file list grows, show a message. 2002-01-25 10:12:36 +00:00
Martin Pool
2e7d19945c With -vv, when the file list grows, show a message. 2002-01-25 10:12:02 +00:00
Martin Pool
5d2c5c4c73 Undo overzealous deletion. 2002-01-25 10:09:00 +00:00
Martin Pool
8694312695 Add dummy show_flist_stats(). 2002-01-25 10:06:36 +00:00
Martin Pool
d9d6bc5278 Factor out code to grow the file list into a common location. 2002-01-25 10:05:49 +00:00
Martin Pool
ebed4c3af0 indent -kr -i8 2002-01-25 09:59:00 +00:00
Martin Pool
172875cf15 Add link to the message that introduced string_area. 2002-01-25 09:54:21 +00:00
Martin Pool
4d26e9e4f4 mallinfo is implemented. 2002-01-25 09:45:45 +00:00
Martin Pool
8f4455f296 Notes about flist. 2002-01-25 09:44:17 +00:00
Martin Pool
2e1d43deb2 Ignore autoconf fluff. 2002-01-25 02:53:48 +00:00
Martin Pool
6780f72000 Add code to compare sin6_addrs. 2002-01-25 02:45:09 +00:00
Martin Pool
39e01d2d4b Back out last change -- to see whether an address is spoofed, we don't
want to look at the whole sockaddr, but rather just at the sin_addr
that it contains.

Also fix silly bug where ai_flags was set incorrectly for getaddrinfo.
2002-01-25 02:43:35 +00:00
Martin Pool
f75502950b compare_addrinfo_sockaddr: Add code to compare AF_INET6 addresses. 2002-01-25 02:37:20 +00:00
Martin Pool
974f27e7e9 Split out code to compare addrinfo and sockaddr into it's own
function.  The comparison cannot be done just byte-by-byte, because
different parts of the sockaddr will be meaningful depending on the
protocol.  It looks like on some systems the library sets the unused
parts to 0, but this is not reliable.  IPv6 not implemented yet.
2002-01-25 02:29:53 +00:00
Martin Pool
af32f69eb0 Doc. 2002-01-25 02:15:58 +00:00
Martin Pool
0cd2f40764 The name resolution stuff is getting complicated -- split it out into
its own file.
2002-01-25 02:13:04 +00:00
Martin Pool
0d95824995 Verbose messages for spoof check... doesn't work on old linux libc? 2002-01-24 09:42:52 +00:00
Martin Pool
bbc09ffba9 When doing a name->addr translation to check for spoofing, give the
resolver the address family of the original address as a hint, so that
we're more likely to find the correct A or AAAA record.,
2002-01-24 08:52:28 +00:00
Martin Pool
a4677968cf Message on successful configuration. 2002-01-24 08:50:35 +00:00
Martin Pool
03b1cddc31 Fix comment.
Bump version to 2.5.2pre3
2002-01-24 08:42:21 +00:00
Martin Pool
9c2dd04993 Name resolution on machines supporting IPv6 is improved. 2002-01-24 08:20:51 +00:00
Martin Pool
a84a93fafe ignore gmon.out 2002-01-24 08:19:28 +00:00
Martin Pool
5fdcc397b1 Fix getpeername call. 2002-01-24 08:16:27 +00:00
Martin Pool
5664871e5f size_t fix. 2002-01-24 08:09:46 +00:00
Martin Pool
55d9e0fada write_batch_csums_file: Opaque IO buffers should be void*. 2002-01-24 08:08:56 +00:00
Martin Pool
929e3011c6 Fix cast that was breaking HP/UX. 2002-01-24 08:07:35 +00:00
Martin Pool
07d70ff560 Move both calls to getpeername into a common wrapper function that
handles IPV4_MAPPED addresses.
2002-01-24 08:05:22 +00:00
Martin Pool
58c2960960 Must get declarations from addrinfo.h before prototypes. 2002-01-24 07:22:38 +00:00
Martin Pool
00d943d513 Another size_t warning 2002-01-24 05:57:49 +00:00
Martin Pool
71c780da06 check_name: Print out name *before* clobbering it. 2002-01-24 05:57:22 +00:00
Martin Pool
3b18cba889 Try to fix error on Solaris:
+ [ -f /export/home/build/build_farm/rsync/testtmp.symlink-ignore/to/referent ]
+ [ -d /export/home/build/build_farm/rsync/testtmp.symlink-ignore/to/from ]
+ [ -L /export/home/build/build_farm/rsync/testtmp.symlink-ignore/to/dangling ]
./testsuite/symlink-ignore.test: test: argument expected

Solaris says it supports -L, so I'm not sure what's happening...
2002-01-24 05:54:47 +00:00
Martin Pool
2974e20550 If name lookup fails, then show the relevant IP address in the error message. 2002-01-24 05:41:46 +00:00
Martin Pool
430d841a2c At the connections that just get a list of modules are not logged,
but they should be.
2002-01-24 04:49:07 +00:00
Martin Pool
31ec50d7da rsync_module: If host-based access fails, show the exact name/address
used for the check in the error message.  (Just in case...)
2002-01-24 04:41:09 +00:00
Martin Pool
5ad0e46f08 Show command used to start connection child. 2002-01-24 04:36:00 +00:00
Martin Pool
1b5814e338 indent -kr -i8 2002-01-24 04:26:55 +00:00
Martin Pool
255810c0d6 Doc.
Oops, connection program message was in the wrong place.
2002-01-24 04:24:12 +00:00
Martin Pool
5d2640376e Show helper program with -v when opening connection.
Doc.
2002-01-24 04:21:42 +00:00
Martin Pool
d02984bbb7 Doc. 2002-01-24 04:19:41 +00:00
Martin Pool
0f9555207a Fix const 2002-01-24 04:07:07 +00:00
Martin Pool
885448d74c Unbreak the old behavior of using UNKNOWN as a hostname if any of the
addr->name->addr translations fail, because people might count on this
in "hosts deny" lines.
2002-01-24 04:03:06 +00:00
Martin Pool
b14545b3ff Fix inverted sense of error check. 2002-01-24 03:31:28 +00:00
Martin Pool
9a5a86734f Refactor client_name() into smaller functions.
Better messages for DNS failure.

If we can get a reverse name for an IP address, but not confirm that
it is correct using a forward lookup then we still proceed to use the
name, but also emit a warning.
2002-01-24 03:28:20 +00:00
Martin Pool
d1d1505045 Doc. 2002-01-24 03:03:20 +00:00
Martin Pool
144ce1dc21 Bump version to 2.5.2pre2. 2002-01-24 03:01:42 +00:00
Martin Pool
aa126974ba log_formatted: Fill the log buffer with nuls to make sure we cannot
accidentally leave the string unterminated.
2002-01-24 02:41:38 +00:00
Martin Pool
707de53457 Another harmless size_t warning. 2002-01-24 02:33:45 +00:00
Martin Pool
10f83cf43d Doc. 2002-01-23 08:08:48 +00:00
Martin Pool
59ee743c5f More size_t fixes. 2002-01-23 08:04:54 +00:00
Martin Pool
d54765c442 Just for variety we have some socklen_t fixes too. 2002-01-23 07:57:43 +00:00
Martin Pool
91262d5d3e Refactor code in send_sums to remove repeated ternaries. 2002-01-23 07:54:13 +00:00
Martin Pool
1c09c743b1 indent -kr -i8 2002-01-23 07:52:52 +00:00
Martin Pool
06ce139fcc Fix more ints that ought to be size_t's. 2002-01-23 07:48:35 +00:00
Martin Pool
fae5bb3183 Doc.
do_hard_links() actually only looks at the global hardlink table, so
it can be a (void) fn.  (Another gcc warning...)
2002-01-23 07:42:30 +00:00
Martin Pool
6fe25398d6 Fix another int that ought to be a size_t. 2002-01-23 07:36:23 +00:00
Martin Pool
909ce14fc4 indent -kr -i8 2002-01-23 07:34:26 +00:00
Martin Pool
935b920120 Another signedness fix to quieten Sun cc warning. 2002-01-23 07:32:29 +00:00
Martin Pool
b31427cd4a Skip this for now; it's a known bug 2002-01-23 07:28:38 +00:00
Martin Pool
e2e3379d79 Bump version to 2.5.2pre1. 2002-01-23 07:22:03 +00:00
Martin Pool
6b1ef85dd8 Note batch-mode changes. 2002-01-23 07:18:58 +00:00
Martin Pool
92325ada0c Note about proxy authentication and SOCKS. 2002-01-23 07:12:57 +00:00
Martin Pool
1707e0f9e2 Indent. 2002-01-23 06:48:13 +00:00
Martin Pool
7ff701e816 Update thankyou list.
Clarify email addresses.
2002-01-23 05:59:10 +00:00
Martin Pool
2e3c141795 Note that batch mode is currently experimental. 2002-01-23 05:53:58 +00:00
Martin Pool
76f79ba748 Patch from Jos Backus -- Fix breakage from dev_t to DEV64_T in batch
mode.

Also, drop -f and -F for batch mode: these should be reserved for
options that are more commonly used.

It also appends a newline to the argvs file and skips adding the
source directory to the command line.
2002-01-23 05:51:06 +00:00
Martin Pool
9dd891bb28 Signedness security patch from Sebastian Krahmer <krahmer@suse.de> --
in some cases we were not sufficiently careful about reading integers
from the network.

Also, make sure log messages are always nul-terminated.
2002-01-23 04:57:18 +00:00
Martin Pool
99f106d1cf If using gcc, then also turn on -W to get even more warnings.
Remove obsolete message.
2002-01-23 03:52:06 +00:00
Martin Pool
3816cae745 Don't need to reread configuration on SIGHUP because we always do that
on new connections.
2002-01-21 01:57:13 +00:00
David Dykstra
759c0627e1 Aack! Since released version 2.5.0, the --whole-file option was accidentally
changed to --whole.  Change it back.  Anybody who wants to use this option
with any version of rsync will have to switch to using -W.
2002-01-15 21:25:55 +00:00
Martin Pool
e03dfae507 Change gratuituous strlcat's into strlcpy, since we already know the
length of the existing string.
2002-01-15 11:50:32 +00:00
Martin Pool
c7677b892a Clearer doc. 2002-01-15 11:32:30 +00:00
Martin Pool
da7b63972d Add --enable-profile to turn on gprof. This is not perfect, because
it seems to only write to ./gmon.out, and that causes trouble when
there are several rsync processes in the same directory.  But you can
make it work.
2002-01-15 11:20:26 +00:00
Martin Pool
499957d9ba Update 2002-01-15 10:47:59 +00:00
Martin Pool
582250008b The Ted T'so school of program optimization: make progress visible and
people will think it's faster.

So now with --progress rsync will show you how many files it has seen
as it builds the file_list.
2002-01-15 10:43:51 +00:00
Martin Pool
a9b31409d5 Remove unused variable. 2002-01-15 10:04:48 +00:00
Martin Pool
98355b8086 Oops, getaddrinfo returns an error code (not -1) for error. -Wall is
good.
2002-01-15 10:04:11 +00:00
Martin Pool
70ed474b38 Define _GNU_SOURCE so that we get all necessary prototypes. 2002-01-15 09:53:27 +00:00
Martin Pool
4775934364 If using GCC, try to turn on -Wall. I want to be clean with respect
to -Wall.
2002-01-15 09:43:21 +00:00
Martin Pool
25f2cb3d6b Fix for <http://rsync.samba.org/cgi-bin/rsync/incoming?id=3750>
temp files must be opened through do_open so that binary modes is used
on cygwin.  (Chris Boucher)
2002-01-14 00:16:51 +00:00
Martin Pool
154f9a3aca Ignore testtmp directories. 2002-01-13 23:57:13 +00:00
Martin Pool
b9df3bf20c DOc. 2002-01-11 08:37:42 +00:00
Martin Pool
6abd193fe3 Always use 64-bit ino_t and dev_t internally, so that we can detect
hardlinks if coming from a larger platform.  Add heaps of comments
explaining why this is so.
2002-01-11 08:25:32 +00:00
Martin Pool
362099a512 More comments about IPv6 stuff.
If a reverse name lookup fails, show the name that we were trying to
look up.
2002-01-11 08:24:34 +00:00
Martin Pool
fdfc3dc9f3 When checking what was copied, use specific -d -f -L flags to test
rather than -e.  (Perhaps Solaris doesn't have test -e?)
2002-01-11 08:08:34 +00:00
Martin Pool
4937459225 The current version of rsync is expected to fail to eliminate all
duplicates from list.
2002-01-11 08:02:43 +00:00
Martin Pool
be2f866b4c Add concept of expected-failure. 2002-01-11 08:01:05 +00:00
Martin Pool
f08aacf7d6 Give cleaner output from "make check" 2002-01-11 07:41:50 +00:00
Martin Pool
4fa6112efe Bump version number.
Now finished merging across work from experimental BK repository.
2002-01-11 07:30:50 +00:00
Martin Pool
1623ba6889 Improved duplicates test: check that each file is
copied once and exactly once.
2002-01-11 07:29:53 +00:00
Martin Pool
766526c791 Check whether code to eliminate duplicate filenames works
(hint: it does not.)
2002-01-11 07:29:02 +00:00
Martin Pool
5c15e29f2b Better mallinfo() output in --stats 2002-01-11 07:26:39 +00:00
Martin Pool
0413e1605f Update copyright 2002-01-11 07:25:54 +00:00
Martin Pool
0e5a1f8352 Doc 2002-01-11 07:24:31 +00:00
Martin Pool
e5a2b8544d Look for mallinfo() and use it to display
heap usage information in --stats
2002-01-11 07:16:11 +00:00
Martin Pool
736a6a291c In protocol version 26, always
send 64-bit ino_t and dev_t.  We also need to try to use 64-bit
ino_t internally *even if* this platform does not have 64-bit
inums itself, because we need to find duplicate inums when
coming from a larger platform with --hardlinks.
2002-01-11 07:15:16 +00:00
Martin Pool
6e69cff118 Autoindent
Add copyright
2002-01-11 07:11:43 +00:00
Martin Pool
cf72f20426 Improved test framework and test for hardlink handling 2002-01-11 07:11:23 +00:00
Martin Pool
d479210cee Bump version 2002-01-11 07:10:25 +00:00
Martin Pool
b781537597 Merge ChangeSet@1.12: Add test case for -H 2002-01-11 07:09:53 +00:00
Martin Pool
ea1438dad8 Merge ChangeSet@1.12: tls now shows number of links to a file to aid in testing -H 2002-01-11 07:09:22 +00:00
Martin Pool
d2e9d069b4 Merge ChangeSet@1.10: Documentation about flist scalabilityTODO 2002-01-11 07:07:49 +00:00
Martin Pool
58379559cc Merge ChangeSet@1.9: Documentation about flist scalability 2002-01-11 07:07:30 +00:00
Martin Pool
b3e6c81565 Merge ChangeSet@1.4: Documentation about flist scalability 2002-01-11 07:05:30 +00:00
Martin Pool
a6a3c3df45 Merge ChangeSet@1.4: Documentation about future development. 2002-01-11 07:04:37 +00:00
Martin Pool
6e3d4c4045 Oops, fix date. 2002-01-03 07:18:17 +00:00
rsync-bugs
ca60b701ee preparing for release of 2.5.1 2002-01-03 07:11:10 +00:00
Martin Pool
e24c0b98d7 Cleanup. 2002-01-03 07:08:35 +00:00
David Dykstra
f389ac80a9 Removed debugging statement that was added to sig_int() by the rsync+ patch
integration.  It was causing the format of the daemon log to be messed up
because of the leading \n.
2001-12-20 15:33:13 +00:00
Martin Pool
50f2f002d9 Suggestion from David Stein
verbose output

  Indicate whether files are new, updated, or deleted
2001-12-20 01:23:28 +00:00
Martin Pool
9ec7528475 Typo 2001-12-18 06:48:56 +00:00
Martin Pool
a8e2a43a09 Get rid of global_opts struct as suggested by Dave -- too many
problems with initialization.
2001-12-18 06:47:40 +00:00
Martin Pool
eb06fa95e4 Documentation fixes based on mail from Edward Welbourne, and an
attempted explanation of rsync's symbolic-link handling.
2001-12-18 06:45:28 +00:00
Martin Pool
1db8b61de7 Add an "unsafe" symlink to the symlink test case so we can see what happens. 2001-12-18 06:26:26 +00:00
Martin Pool
38c66db8d6 Note about hardlink performance. 2001-12-18 06:25:31 +00:00
Martin Pool
f8be7d4219 Refactor code for setting local address on outgoing connections. If a
local address is specified, then try all addrinfo records for it.
2001-12-18 06:21:33 +00:00
Martin Pool
13e29995f5 Get rid of global_opts struct as suggested by Dave -- too many
problems with initialization.

Change the algorithm from trying to open an inbound socket with
getaddrinfo: keep trying suggested addresses until we find one on
which we can both get a socket and bind.  Not convinced this is the
best, but it's probably better.
2001-12-18 05:54:57 +00:00
Martin Pool
7c583c7316 Note rsyncd-over-ssh and documentation TODOs. 2001-12-18 01:33:56 +00:00
Martin Pool
9fecec5e85 Fix from Jeff Garzik for inet_ntop prototype errors on some Linux
distributions: we were failing to define HAVE_INET_NTOP, so our
prototype in rsync.h came through.

Also rerun autoheader, and have comment for HAVE_SOCKADDR_STORAGE.
2001-12-18 01:32:27 +00:00
Martin Pool
9e696bd468 Update README so that Paulus doesn't get bug reports anymore :-)
I think this document needs to be reworked to better explain how to
use rsync, but not right now.
2001-12-18 01:07:20 +00:00
David Dykstra
6ab6d4bfc1 When INET6 is not defined, meaning that IPv6 is not supported, need to
initalize the global_opts.af_hint to AF_INET or systems such as Linux that
have a native getaddrinfo() because they support IPv6 will attempt to
create IPv6 sockets.  This brings up a problem with the new global_opts
structure; in order to initialize them to a value other than 0, we need to
explicitly initialize them all in an order that matches the order in
rsync.h.  I think that's more inconvenient & error prone than keeping
global variables.
2001-12-14 18:25:51 +00:00
David Dykstra
cb1bcc7ebb open_socket_in was attempting to try all the protocols returned from
getaddrinfo(), but only if a corresponding call to socket() returned one of
three *NOSUPPORT errno codes.  A Redhat 6.2 system was observed returning
EINVAL instead so it never went on to try IPv4.  This update adds EINVAL to
the list.  Question: why not always continue through the list regardless of
what errno is?
2001-12-14 18:00:54 +00:00
Martin Pool
19ba7d6318 Verbose. 2001-12-14 05:55:21 +00:00
Martin Pool
7753ca1f49 Only show test output if it failed. 2001-12-14 05:54:24 +00:00
Martin Pool
d52a796c39 Be less verbose. 2001-12-14 05:52:25 +00:00
Martin Pool
60514d457c Fix quoting. 2001-12-14 05:44:04 +00:00
Martin Pool
5bc00efe42 Perhaps Solaris sh wants us to explicitly exit 0, rather than just
using the last return code?
2001-12-14 05:27:42 +00:00
Martin Pool
c45f3133bc More error messages. 2001-12-14 05:19:15 +00:00
Martin Pool
fb47591de0 Typo. 2001-12-14 05:17:52 +00:00
Martin Pool
514d129c49 Make scratch directory properly. 2001-12-14 05:01:48 +00:00
Martin Pool
db843fc12d Doc. 2001-12-14 02:18:31 +00:00
Martin Pool
63787382d8 Clearer error messages. 2001-12-14 02:16:20 +00:00
Martin Pool
85d4d142d8 Clearer error messages. 2001-12-14 02:14:58 +00:00
Martin Pool
3cd2af41e4 Add a test that when none of -l, -L, -a are specified symlinks are not
copied at all.
2001-12-14 02:01:46 +00:00
Martin Pool
b214eda4f0 Clean scratch directory between each test run. 2001-12-14 01:52:43 +00:00
Martin Pool
0771727d41 Readlink(2) does not nul-terminate the output buffer, so we were
getting corrupt output when listing more than one symlink.
2001-12-14 01:48:48 +00:00
Martin Pool
a5d74a1876 Fix contact details. 2001-12-14 01:09:23 +00:00
Martin Pool
23bf32f767 Don't define DEBUG with --enable-debug, because that makes zlib emit strange messages 2001-12-09 21:48:13 +00:00
Martin Pool
87a819edee IRIX cc cares that the operands to the ternary have the same type. 2001-12-05 13:48:41 +00:00
Martin Pool
27a1234874 Be more strict about 'enum logcode' rather than int. IRIX compiler
picked this up -- quite neat.
2001-12-05 13:45:51 +00:00
Martin Pool
51f289d1e6 Some platforms don't have sa_family_t. 2001-12-05 13:44:37 +00:00
Martin Pool
d0d6dc61e8 Bump version 2001-12-05 13:41:38 +00:00
Martin Pool
d91c8c50d2 RFC2553 just says that sockaddr_storage has to have initial fields
isomorphic to sa_family etc from a struct sockaddr, not what they're
called.  On some platforms they seem not to be called ss_family.
Rather than guess, we will try casting to a sockaddr and looking
through that -- I think this is what the RFC intends.
2001-12-05 13:25:29 +00:00
Martin Pool
e20a4f84d6 Some platforms may have getaddrinfo() but not sockaddr_storage. 2001-12-05 13:19:16 +00:00
Martin Pool
bbd6f4ba8e Document --no-detach. 2001-12-05 13:10:24 +00:00
Martin Pool
2a951cd2f9 Fix help message for --address option 2001-12-05 13:06:26 +00:00
Martin Pool
a538066d5a Add --no-detach option for W32, daemontools, etc. 2001-12-05 13:03:16 +00:00
Martin Pool
c10b0bdd50 Doc 2001-12-05 13:02:11 +00:00
Martin Pool
431efc8979 Doc. 2001-12-05 12:56:06 +00:00
Martin Pool
2d6dbe290c Change back to using sockaddr_storage rather than sockaddr_in. If
sockaddr_storage is not defined, then supply our own definition that
will hopefully satisfy RFC2553 but also compile on all supported
platforms.

Thankyou to YOSHIFUJI Hideaki, SUMIKAWA Munechika and Jun-ichiro
"itojun" Hagino.
2001-12-05 12:48:46 +00:00
Martin Pool
c33e3e3967 Suggestions from KAME IPv6 newsletter. 2001-12-05 12:25:36 +00:00
Martin Pool
71b3374bd5 Note from tpot that sighup should have standard behaviour of reinitializing. 2001-12-05 00:58:20 +00:00
David Dykstra
de343e3cce Don't print out the directory name twice in verbose mode; it was being
printed a second time when the modification time of the directory was
being set, and that time around recv_files() calls recv_generator() with
an f_out of -1 so check that before printing the directory name.
2001-12-03 18:37:33 +00:00
Martin Pool
384958ed3d Note about crash from Ayamura KIKUCHI 2001-12-02 22:47:30 +00:00
Martin Pool
1cd5beeb06 batch reindent 2001-12-02 22:28:50 +00:00
Martin Pool
4c70e359d0 Bump version 2001-12-02 22:26:09 +00:00
Martin Pool
f9c3005bff Fix FP usage. 2001-12-02 14:12:03 +00:00
Martin Pool
9147074d8b Oops, units bug. 2001-12-02 13:58:03 +00:00
Martin Pool
7007bddaef Show time-remaining as hh:mm:ss. 2001-12-02 13:45:38 +00:00
Martin Pool
2f8dc29182 Update notes 2001-12-02 13:22:55 +00:00
Martin Pool
6066594bbe Improved estimation algorithm for time-to-complete. 2001-12-02 13:07:07 +00:00
Martin Pool
40c0289176 Typo fix by Tom Schmidt 2001-12-02 13:02:17 +00:00
Martin Pool
acf1af0cd9 const-cast required for silly UNICOS headers 2001-12-02 12:37:48 +00:00
Martin Pool
62791bdfa2 Also estimate time remaining. 2001-12-02 08:56:25 +00:00
Martin Pool
47f1218d69 Progress indicator now shows estimated rate of transfer (e.g. kB/s).
Based on a patch from Rik Faith, but modified to make sure we do only
one rprintf call, and that we never end up with two copies of the line
printed out.
2001-12-02 08:38:51 +00:00
Martin Pool
1179355dab Revert change from 1.39, because it causes a crash because of
attempting to free a static string.  (Thankyou to Paul Mackerras.)
There's still a small leak here.
2001-12-02 08:16:15 +00:00
Martin Pool
3d807132e4 Fix test suite breakage in calling tls.
Clean up test directory on completion.
2001-12-02 07:22:54 +00:00
Martin Pool
42d0b4c280 Bump version 2001-12-02 07:21:55 +00:00
Martin Pool
d313ae7d23 Move old news from release 2.5.0. 2001-12-02 07:17:50 +00:00
Martin Pool
28a69e25ea More notes from email. 2001-12-02 07:07:43 +00:00
Martin Pool
ad911a7ac3 Typo fix from Matt Kraai <kraai@debian.org> 2001-12-02 06:17:33 +00:00
Martin Pool
5575de140d Add note about device major/minor numbers, and about ACLs 2001-12-02 05:12:39 +00:00
David Dykstra
a5ce1eb1af Add "$(OBJS): config.h" so everything will rebuild if config.h changes. 2001-11-30 22:21:20 +00:00
Martin Pool
76a78cd8bc Add message to ignore warnings about mktemp 2001-11-30 22:06:29 +00:00
rsync-bugs
0b25efc12a Modified file stored as well 2001-11-30 00:31:06 +00:00
rsync-bugs
64cae087b6 preparing for release of 2.5.0 2001-11-30 00:29:46 +00:00
Martin Pool
b7cc59c503 Spec file needs to be generated from a template to include the version
number.
2001-11-30 00:29:20 +00:00
rsync-bugs
7eb8d18a99 preparing for release of 2.5.0 2001-11-30 00:23:11 +00:00
Martin Pool
e7bf3e5e87 Last bug fix for 2.5.0? Make the documentation for -a point out that
it does not in fact propagate hardlinsk.
2001-11-30 00:17:53 +00:00
Martin Pool
5aafd07b37 Note error cases that we ought to improve. 2001-11-30 00:16:14 +00:00
Martin Pool
053f3a831d Note other supported platforms 2001-11-30 00:15:32 +00:00
Martin Pool
a2d2e5c047 Add notes on things to do mentioned on the list in the last few months. 2001-11-29 01:31:31 +00:00
Martin Pool
dd3a922035 IPv6 support is now merged. 2001-11-29 00:23:29 +00:00
Martin Pool
0e916c6038 Just include rsync.h rather than all the individual headers.
(Suggestion from Dave Dykstra.)
2001-11-29 00:15:20 +00:00
Martin Pool
87fcb63975 No need to test for memcmp, because even broken ones are good enough
for our purposes.  (Patch from Dave Dykstra.)
2001-11-29 00:08:36 +00:00
Martin Pool
68b2cc5538 Show version when configuring.
If we don't seem to have an ANSI compiler, then omit a warning as soon
as that is discovered, because it is likely to break later configure
tests.  This doesn't seem to catch the particular HP-UX compiler I was
after, which is non-ANSI but only emits a warning on this configure
test.  Nevertheless probably better to have it in.
2001-11-29 00:04:48 +00:00
Martin Pool
4dcf3697ff Add list of platforms that build. 2001-11-28 07:49:32 +00:00
Martin Pool
ea77525546 Note half-baked Darwin IPv6 support. 2001-11-28 07:12:09 +00:00
Martin Pool
17d5a07ec2 Put back the --disable-ipv6 option. This should only be needed if
your platform seems to support ipv6, but actually it breaks.  This
seems to be the case for "powerpc-apple-darwin1.4".
2001-11-28 06:52:04 +00:00
Martin Pool
3966b9c609 Call this 2.4.7pre4 2001-11-28 04:32:33 +00:00
Martin Pool
1c47fbd96b Note on HP-UX's bundled so-called C compiler. 2001-11-28 04:10:39 +00:00
Martin Pool
1691bdcafc HP's cpp apparently can't handle whitespace before #include 2001-11-28 03:12:20 +00:00
Martin Pool
6a5ef41fb3 HP's cpp chokes on preprocessor directives that have whitespace before
the '#'.  Off to the Implant Office with you!
2001-11-28 02:55:20 +00:00
Martin Pool
09b6f4b00d Fix inet_ntop/pton names 2001-11-28 01:29:41 +00:00
Martin Pool
7067b0aa28 Protect AF_INET6 references with #ifdef INET6 2001-11-28 00:36:32 +00:00
Martin Pool
112e731150 Fix sh 2001-11-27 07:59:34 +00:00
Martin Pool
1336e41460 Show symlink targets 2001-11-27 07:56:33 +00:00
Martin Pool
7c1b7890d3 Be a bit more verbose 2001-11-27 07:54:48 +00:00
Martin Pool
dd0700b025 mtime and ownership of symlinks can be random, so don't print them. 2001-11-27 07:54:03 +00:00
Martin Pool
04d8e8b25f Be a bit more verbose 2001-11-27 07:32:42 +00:00
Martin Pool
3723efcb1d Try to fix headers for UNICOS 2001-11-27 07:23:58 +00:00
Martin Pool
054b40b6fa Unbreak recursive ls test 2001-11-27 07:19:37 +00:00
Martin Pool
6773a7798f Oops, fix bash syntax 2001-11-27 07:09:47 +00:00
Martin Pool
2d4c8e5945 The size of anything but a regular file is probably not worth thinking
about.
2001-11-27 07:07:36 +00:00
Martin Pool
087173c887 When producing a ls-style permissions string, also handle
sticky/setuid/setgid bits the same way as GNU ls.
2001-11-27 07:05:33 +00:00
Martin Pool
57835c00ad Use tls rather than the OS's ls(1) so that we have more chance of
reproducible results.
2001-11-27 06:51:51 +00:00
Martin Pool
4ed886ae6e Also list permissions, ownership, size, and mtime. 2001-11-27 06:45:47 +00:00
Martin Pool
740819ef7b Split code to generate "rwx-----" strings into lib/permstring.c so it
can be reused in tls.
2001-11-27 06:43:17 +00:00
Martin Pool
829230689e Build getaddr/nameinfo into lib/. 2001-11-27 06:41:38 +00:00
Martin Pool
77ba4cc2f9 make clean can rm config.cache but not config.h, or it wil jam.
Build getaddr/nameinfo into lib/.

Split code to generate "rwx-----" strings into lib/permstring.c so it
can be reused in tls.
2001-11-27 06:39:02 +00:00
Martin Pool
e94989fe4d Try to fix LIBOBJ detection of ntop/pton. 2001-11-27 06:17:33 +00:00
Martin Pool
c11b88061f Fix missing parameter in log call. 2001-11-27 06:01:05 +00:00
Martin Pool
647c5433f8 Make clean should also remove the autoconf cache etc. 2001-11-27 05:35:14 +00:00
Martin Pool
8f694072a5 Add Paul Vixie's implementation of inet_ntop and inet_pton for
platforms that don't have them.
2001-11-27 05:22:23 +00:00
Martin Pool
9a689986c6 Look in -lresolv for inet_ntop 2001-11-27 04:53:08 +00:00
Martin Pool
3174b31d96 Check for inet_ntop and inet_pton, which may be missing. 2001-11-27 03:49:53 +00:00
Martin Pool
4eb61975b7 Explain IPv6 merge. 2001-11-27 02:28:36 +00:00
David Dykstra
76e26e1042 Better fix for case of excluded symlinks that point nowhere when using
--copy-links.  The readlink_stat() does need to be done in the normal case
before checking the exclude patterns because it needs to know whether or
not a file is a directory in order to properly handle a trailing slash
in an exclude pattern.  This fix makes make_file() go ahead and call
readlink_stat() but then if the latter returns an ENOENT and copy_links is
on then it will only print an error if the path is not excluded.
2001-11-26 19:15:53 +00:00
Martin Pool
9069dfd005 Fix rename of global option 2001-11-26 08:21:30 +00:00
Martin Pool
2be5d2daad Remove kame cruft 2001-11-26 08:21:14 +00:00
Martin Pool
22cd0063e5 Attempted clean up some of the IPv6 tests. 2001-11-26 08:20:13 +00:00
Martin Pool
3d2e458a4d Fix a small memory leak that was causing an Insure warning. 2001-11-26 07:58:47 +00:00
Martin Pool
a57568d716 Oops, no C++ comments. 2001-11-26 07:47:59 +00:00
Martin Pool
61f543cade Kill a function for jra. 2001-11-26 07:11:55 +00:00
Martin Pool
b8771f9615 Try to be better about handling the results of getaddrinfo(): when
opening an inbound socket, we might get several address results,
e.g. for the machine's ipv4 and ipv6 name.

If binding a wildcard, then any one of them should do.  If an address
was specified but it's insufficiently specific then that's not our
fault.

However, some of the advertized addresses may not work because e.g. we
don't have IPv6 support in the kernel.  In that case go on and try all
addresses until one succeeds.
2001-11-26 07:10:06 +00:00
Martin Pool
d5d4b28220 Put the new address family option into an options struct. We have too
many globals already.

Better error messages for network-related failures.
2001-11-26 04:52:19 +00:00
Martin Pool
a037edaccd Silly autoconf 2001-11-26 01:49:33 +00:00
Martin Pool
356bbb8351 Check for -lnsl, -lsocket, etc, *before* looking for getaddrinfo,
because on Solaris (for one) it's not in libc.
2001-11-26 01:15:12 +00:00
Martin Pool
1f0fa9318a Remove highly suspicious redefinition of sockaddr structure -- there
seems no point using anything but the platform's native definition,
and if we can't get that from the system headers we're hosed anyhow.
2001-11-26 00:41:11 +00:00
Martin Pool
15c1707887 Remove check for buggy getaddrinfo for the time being -- it's unclear
how this is supposed to help.

Check for netdb.h
2001-11-26 00:23:29 +00:00
Martin Pool
9dec7aa9c1 Make some of the headers used by the KAME getaddrinfo implementation
be conditional -- they are missing on e.g. Solaris.  Not sure if this
will fix it.
2001-11-25 09:30:36 +00:00
Martin Pool
bc3d7454e0 Fix KAME patch to use proper autoconf AC_MSG macros rather than just echo/exit. 2001-11-24 05:38:35 +00:00
Martin Pool
56901bc7c3 Call this pre3. 2001-11-24 05:33:35 +00:00
Martin Pool
5c7f570b16 IPv6 is off by default. 2001-11-24 05:31:40 +00:00
Martin Pool
4f6e5fe323 IPv6 is off by default -- it seems to break header files on too many systems. 2001-11-24 05:30:27 +00:00
Martin Pool
7d682ffea7 Note IPv6 and nohang patches. 2001-11-24 05:13:12 +00:00
Martin Pool
cef40af209 Get rid of rule disliked by Sun Make. 2001-11-24 05:06:07 +00:00
Martin Pool
a358449ab1 Set rsync version in configure.in
Show IPv6 availability in --version.
2001-11-24 04:57:41 +00:00
Martin Pool
8ef6b72514 Fix Makefile syntax problem when LIBOBJS is defined. 2001-11-24 04:33:07 +00:00
Martin Pool
620bbabc61 Try to get IPv6 support, unless --disable-ipv6 is explicitly specified. 2001-11-24 04:29:37 +00:00
Martin Pool
7ef6aa6405 Improved error messages. 2001-11-24 04:22:20 +00:00
Martin Pool
7ad1d4fd66 Rebuild if headers changed. 2001-11-24 04:16:18 +00:00
Martin Pool
bf5c2bf604 More autoconf fixes. 2001-11-24 04:12:54 +00:00
Martin Pool
b8fe70a516 Ignore trash 2001-11-23 07:37:26 +00:00
Martin Pool
06963d0fca Merge KAME.net IPv6 patch: you can now (in theory) pass IPv6 hostnames
or literal IP addresses to rsync, and if your platform supports them
they will be used.  Also there are -4 and -6 command-line options to
choose the default address type.  Thankyou!
2001-11-23 07:35:49 +00:00
David Dykstra
b964901f7d Fix to make_file() to exit earlier if a file is excluded, because doing
readlink_stat() on an excluded file can be a problem when using the
--copy-links option (also known as -L) and the excluded file is a symlink
that points nowhere.
2001-11-16 19:19:44 +00:00
Martin Pool
b52c1d9d3a Document chroot confusion. 2001-11-09 06:58:39 +00:00
Martin Pool
a24e12e6dd More notes. 2001-09-12 14:35:39 +00:00
Martin Pool
3c6cd53b23 Think think. 2001-09-12 14:20:44 +00:00
Martin Pool
4f69fe59c7 Start to wrap up all thoughts on what should happen for rsync 3. 2001-09-12 08:51:24 +00:00
Martin Pool
d2e02b7d96 Fix from Marc Espie to make included-popt work with VPATH builds. 2001-09-12 08:46:29 +00:00
Andrew Tridgell
a57873b710 fixed check for timeout in generator
the generator can easily make no progress for a long time, so don't do
timeout processing checks
2001-09-09 04:42:09 +00:00
Andrew Tridgell
30ce7e8a64 64-bit files depends on the size of OFF_T, not off64_t 2001-09-09 04:41:14 +00:00
Andrew Tridgell
f0af1e5ec6 debian stable screws up largefile support for fcntl locking. This adds
a test for the screwup and disables largefile support
2001-09-08 12:48:50 +00:00
Martin Pool
f7ca98bdc4 Doc. 2001-09-07 07:57:10 +00:00
Martin Pool
7df0935a51 Add a little implementation of ls(1) so that we can look at all and
only the attributes of files that rsync is meant to synchronize.

Test cases should depend on testing tools.
2001-09-07 07:52:34 +00:00
Martin Pool
f22ee86517 Add a little implementation of ls(1) so that we can look at all and
only the attributes of files that rsync is meant to synchronize.
2001-09-07 07:52:09 +00:00
Martin Pool
8f98c608b9 Remove test trace stuff. 2001-09-07 07:50:31 +00:00
Martin Pool
32c58f06e0 Try to exit 0 if nothing fails. 2001-09-07 07:49:34 +00:00
Martin Pool
040f7b6595 Update copyright notice. 2001-09-07 07:35:08 +00:00
Martin Pool
d2476f0db3 Debug exit status -- on Sun1/cc all the tests pass, but make sees an
exit status of 1. ???
2001-09-06 13:12:28 +00:00
Martin Pool
952cf8f4f3 Oops, some machines don't have which. 2001-09-06 13:07:52 +00:00
Martin Pool
a138e47560 Oops, some machines don't have which. 2001-09-06 13:04:48 +00:00
Martin Pool
7d6916547f See if head(1) works -- broken on some systems? 2001-09-06 06:34:24 +00:00
Martin Pool
6cd7888e46 You cannot do "export VAR=VALUE" all on one line; the export must be
separate from the assignment.  (SCO SysV)
2001-09-06 06:30:09 +00:00
Martin Pool
1d54358e52 Fix selective definition of *snprintf. (Welcome to mbp's breakage world.) 2001-09-06 06:27:02 +00:00
Martin Pool
4c80c473ed More testsuite cleanups. Now I hope we cope without 'cp -a', though
we still need 'cp -p'.
2001-09-06 06:21:15 +00:00
Martin Pool
571a4b2654 BSD machines don't seem to have head(1). 2001-09-06 06:06:13 +00:00
Martin Pool
501972bf72 Split the 'longdir' test into its own script, and make it work without
'mkdir -p'.
2001-09-06 05:57:27 +00:00
Martin Pool
99cdaff70d Add a makepath() function to cope with machines that do not have
'mkdir -p'.  (Stone knives and bearskins...)
2001-09-06 05:52:40 +00:00
Martin Pool
c36b5017b8 Doc.
Look at $whichtests to run just a subset -- good for calling from Make.
2001-09-06 05:50:48 +00:00
Martin Pool
a4cf6bec19 Fix comment. 2001-09-06 04:56:55 +00:00
Martin Pool
0154b302ce Fiddle umask again. 2001-09-06 04:56:02 +00:00
Martin Pool
ec99e9da81 Clean up output a little. 2001-09-06 02:30:06 +00:00
Martin Pool
e052b21f32 Set umask so that symlinks will have the right permissions on BSD. 2001-09-06 02:26:21 +00:00
Martin Pool
b2f0246498 For log messages containing ridiculously long strings that might
overflow a buffer rsync no longer aborts, but rather prints an
ellipsis at the end of the string.  (Patch from Ed Santiago.)
2001-09-04 03:12:55 +00:00
Martin Pool
c1659c79ef Clean up from rsync+ patch; fix compiler warning. 2001-08-31 09:27:35 +00:00
Martin Pool
4a7cb3e8a8 Fix sh syntax for FreeBSD. 2001-08-31 09:26:34 +00:00
Martin Pool
0de40240bb If we're using built-in *printf functions, then provide prototypes. 2001-08-31 09:23:06 +00:00
Martin Pool
d79c77caca Cope on machines without INADDR_LOOPBACK. 2001-08-31 08:22:00 +00:00
Martin Pool
2b106d0b3a Ignore test tmp dir. 2001-08-31 08:16:23 +00:00
Martin Pool
8fef024528 Run the daemon test using faked tcp connections. 2001-08-31 08:13:57 +00:00
Martin Pool
6963e540db Grammar fix. 2001-08-31 08:12:35 +00:00
Martin Pool
3ef526f5fa Add comment about handling of 'use chroot' 2001-08-31 08:08:42 +00:00
Martin Pool
eecd22ff7b Merge in the LIBSMB_PROG idea from samba, so that you can do
RSYNC_CONNECT_PROG='./rsync --daemon' ./rsync -vvvvvv  localhost::

to test as a daemon without actually having to listen on a port.
2001-08-31 07:06:13 +00:00
Martin Pool
add7e8fb6b Doc.
Try to give a better error message when there is a remote option error.
2001-08-31 06:48:35 +00:00
Martin Pool
f6e09367a7 Option should be --recursive, not --recurse. (This is what it was in
--help and 2.4.6.)
2001-08-31 06:29:45 +00:00
Martin Pool
3aae15ecfb Fix rsyncd.conf generation. 2001-08-31 05:49:16 +00:00
Martin Pool
f5ad6eb18d Fix message. 2001-08-31 05:48:19 +00:00
Martin Pool
7f1b717ac7 Show rsync version before doing anything else. 2001-08-31 05:45:49 +00:00
Martin Pool
55bdb41632 Skip SSH tests if $rsync_enable_ssh_tests is not set 2001-08-31 05:41:45 +00:00
David Dykstra
7c06e407ec The --compare-dest option was not listed as accepting a string parameter
like it was supposed to.  There should probably be a testsuite test for
--compare-dest.
2001-08-30 16:24:03 +00:00
Martin Pool
c13ad7ec47 fix bashism 2001-08-30 08:28:53 +00:00
Martin Pool
d2094cc33d Split out generic functions for starting rsyncd. 2001-08-30 07:14:57 +00:00
Martin Pool
c3469aed19 Notes on an interactive shell for rsync. 2001-08-30 07:11:46 +00:00
Martin Pool
232ce2b2c8 Start testing daemon functionality 2001-08-30 07:10:45 +00:00
Martin Pool
882582b307 Run all scripts in the testsuite/ directory, not just named ones. I'd
like to make this script not rsync-specific if possible.
2001-08-30 07:10:20 +00:00
Martin Pool
ebaa0489b4 Abandoned 2001-08-30 06:56:57 +00:00
Martin Pool
1a1c244dc3 Obsolete 2001-08-30 06:54:59 +00:00
Martin Pool
320989b05d On BSD, this seemed to always exit after test failure. Try different
shell syntax.
2001-08-30 06:54:15 +00:00
Martin Pool
9d682a8dc1 More debug output for testing SSH. 2001-08-30 06:51:58 +00:00
Martin Pool
37c3cf430d Try using diff -c' not diff -u' because the latter seems to be
broken on SCO2.
2001-08-30 06:35:48 +00:00
Martin Pool
751411c40d Use rsync source rather than /etc for files because things in /etc
might be protected or missing on some systems.
2001-08-29 09:38:28 +00:00
Martin Pool
6a46226b3a BSD doesn't have /etc/resolv.conf or /etc/inittab, and hands.test was
trying to use them as a source of noise.
2001-08-29 09:27:43 +00:00
Martin Pool
42e66aa24c Apparently `set -x' in the shell works on some Bourne shells, but not SCO. 2001-08-29 09:24:35 +00:00
Martin Pool
5cb1f5c795 Apparently '!' to invert a pipeline result doesn't work on UnixWare. 2001-08-29 09:23:19 +00:00
Martin Pool
12b9c8409e Return the *number of tests that failed*, so that it will show up
nicely in the overall summary.
2001-08-29 09:20:35 +00:00
Martin Pool
e8ca590142 Cleanup check_logs feature.
`ps ax' is not portable -- don't use it to generate random text.  Use
`ls -lR' instead.
2001-08-29 09:18:45 +00:00
Martin Pool
863dff5179 Cleanup check_logs feature. 2001-08-29 09:15:17 +00:00
Martin Pool
3fedd74ba2 Clean up Phil's test more.
Make the checkit() routine more generic.

Split out ssh tests.
2001-08-29 09:13:01 +00:00
Martin Pool
78ffe4787f $RSYNC and similar variables must be set to absolute path so that it
can be passed to --rsync-path.

Add a nopersist=yes option that makes runtests bomb out as soon as one
test fails -- this is good if you're watching the trace output.
2001-08-29 09:12:05 +00:00
Martin Pool
a4b4af889b $RSYNC must be set to absolute path so that it can be passed to --rsync-path 2001-08-29 09:11:14 +00:00
Martin Pool
d286ee98b9 Count overall failure if some expected scripts were missing. 2001-08-29 08:48:00 +00:00
Martin Pool
42be591878 Remove testtmp directory on 'clean'.
Run test scripts in POSIX mode to try to catch portability problems.
2001-08-29 08:46:18 +00:00
Martin Pool
3a4c683f04 More test case work:
* make sure to build rsync before running 'make check'

 * Put back in the loglevel concept from the samba scripts.  If >8,
   then turn on shell tracing.

 * Allow tests to return 77 if they want to count as 'skipped'.

 * Add more docs.

 * Mangle Phil's script to get ready to run on non-Linux systems: we
   need to not use shell functions, cp -a, etc.  Not there yet.
2001-08-29 08:13:19 +00:00
Martin Pool
e7d29902a6 Redraft testsuite driver script to unify 'make check', 'make
installcheck' and buildfarm tests.

Add note from discussion with Tim about finding files/directories
under different circumstances.  Now works (?) with VPATH build.
2001-08-29 07:33:27 +00:00
Martin Pool
64bd756832 Add comment: cyeoh says that getpass is deprecated, because it may
return a truncated password on some systems, and it is not in the LSB.
2001-08-29 07:23:30 +00:00
David Dykstra
8642efd0d6 The --with-rsync-path configure option was using the wrong configure
variable "$with_rsync_name" instead of "$with_rsync_path".
2001-08-27 16:23:41 +00:00
Martin Pool
063393d62d Only use the "@RSYNC EXIT" tag if we're talking to a client about
version 25.  This prevents it appearing and messing up the module list
when an old client connects to a 2.4.7 server.
2001-08-23 06:14:54 +00:00
Martin Pool
7a55d06e0d Allow the server to terminate the module list by just closing the
socket, rather than sending a proper EXIT command.  Keep the
global-variable hack to do this, but try to make it only apply in the
specific case where that occurs, not on all lines we read.
2001-08-22 04:15:50 +00:00
Martin Pool
6f82f7a6f6 Add a little more protocol documentation. 2001-08-22 04:14:05 +00:00
Martin Pool
33d213bb37 Note about cross-testing different versions. 2001-08-22 04:09:07 +00:00
Martin Pool
a426e396c4 Return 1 if any tests failed so that the build farm can pick it up. 2001-08-21 14:06:52 +00:00
Martin Pool
fafeb69cb6 Change test directory again. 2001-08-21 13:44:08 +00:00
Martin Pool
b9277bdb6a Don't look at $srcdir if it's not set. (Why isn't it set??) 2001-08-21 13:26:30 +00:00
Martin Pool
b53713d322 Show trace while testing. 2001-08-21 13:20:53 +00:00
Martin Pool
2f22174f21 Try again to find the right directory on both local and farm builds. 2001-08-21 13:10:18 +00:00
Martin Pool
d820215b35 More test suite stuff 2001-08-21 13:00:55 +00:00
Martin Pool
ea4a03762a Print source directory. 2001-08-21 12:49:23 +00:00
Martin Pool
46ef7d1dc8 Update notes; add idea about rsyncsh 2001-08-18 23:50:27 +00:00
Martin Pool
e340a8203e Export autoconf settings to test scripts. Use this to cope with
systems that don't use "echo -n".
2001-08-17 01:57:42 +00:00
Martin Pool
3459d319d1 Set up scratch directory for tests. 2001-08-17 01:44:13 +00:00
Martin Pool
09ec75a629 Don't pause at end of tests. 2001-08-17 01:43:13 +00:00
Martin Pool
4df7868d39 Try to fix "make check" directory path.
Don't wait for input at end of tests.
2001-08-17 01:34:31 +00:00
Martin Pool
bc888e05da Find the right directory to run the test components. 2001-08-17 00:58:21 +00:00
Martin Pool
26c7f120e6 Try to get test scripts to run properly. 2001-08-17 00:51:20 +00:00
Martin Pool
5b7be6ee4a Show number of passed/failed/skipped tests. 2001-08-16 09:37:54 +00:00
Martin Pool
951351a537 Don't print test headers unless the test is about to run. 2001-08-16 09:35:21 +00:00
Martin Pool
0b21c485ec Note test suite.
Note autoconf2.52 is required.
2001-08-16 09:16:08 +00:00
Martin Pool
068a7221ce Move Phil Hand's test under the control of the master test suite. 2001-08-16 09:13:37 +00:00
Martin Pool
a4772a4dbc Start to unify the "make check" and build farm test suites 2001-08-16 09:08:29 +00:00
Martin Pool
2ee91aedb1 Use set -x until this script works properly. 2001-08-16 08:13:13 +00:00
Martin Pool
d95447229b Fix typo. 2001-08-16 08:12:55 +00:00
Martin Pool
40ec33b604 Gave directory its proper name 2001-08-16 07:08:26 +00:00
Martin Pool
35e3b2d555 fix filename 2001-08-16 06:27:51 +00:00
Martin Pool
aa9c2df9d9 Updated directory name for rsync tests 2001-08-16 06:24:56 +00:00
Martin Pool
f472cdf017 Try to execute rsync --version as part of the test suite -- see if
this works on the farm.
2001-08-16 05:44:17 +00:00
Martin Pool
1dc587af1b Fix cast warning. 2001-08-15 08:52:10 +00:00
Martin Pool
aeb6292d0d Try to get tests to run with old buildfarm clients 2001-08-15 08:06:26 +00:00
Martin Pool
7d91d5a619 Check that gethostbyname does actually return AF_INET addresses, since
that's all we can handle.

Also, try a new method of handling in_addr and hostent that will
hopefully work on Cray machines without 32-bit types.
2001-08-15 07:52:28 +00:00
Martin Pool
7169bb4aa9 Fix a bug introduced in 1.119, whereby strings like
"mirror.aarnet.edu.au::" were not properly digested.

It wasn't even my bug! :-)
2001-08-15 07:50:07 +00:00
Martin Pool
2db52650fc Fix another format cast. 2001-08-15 06:50:46 +00:00
Martin Pool
c1f62a573a Use socklen_t for getpeername, since we hopefully now have it defined
on all platforms.
2001-08-15 06:47:40 +00:00
Martin Pool
08a740ff43 Fix casts when some variables are printed out. 2001-08-15 06:41:24 +00:00
Martin Pool
b67381d0dc Drop dead variables introduced in rsync+ patch. 2001-08-15 06:38:23 +00:00
Martin Pool
07e9500818 Fix trace message which was missing a parameter.
Drop dead variable introduced in rsync+ patch.
2001-08-15 06:34:28 +00:00
Martin Pool
c77cf82206 Add the start of a buildfarm test suite for rsync. It doesn't do much
yet -- I just want to see if it runs.
2001-08-15 05:47:57 +00:00
Martin Pool
f8014b864e Typo. Shouldn't depend on assert(). 2001-08-15 05:47:29 +00:00
Martin Pool
d58911fb37 Better error messages for DNS. 2001-08-15 05:08:07 +00:00
Martin Pool
b335d74565 Fix bug in --address handling. 2001-08-15 05:07:29 +00:00
Martin Pool
3405fe45f4 Note UNICOS works again 2001-08-14 02:28:12 +00:00
Martin Pool
095efec1d6 Spec file from Jason Haar that works on RedHat 7.1. Not tested by me yet. 2001-08-14 02:24:09 +00:00
Martin Pool
7ca6e85649 Commit getconf/socklen_t/largefile patch suggested by Albert Chin.
This is tested on
  Solaris 2.5.2, 2.6, 7, 8/SPARC, HP-UX 10.20, 11.00,
  Tru64 UNIX 4.0D, 5.0A, IRIX 6.2, 6.5, AIX 4.3.2
and it works ok.

This patch *requires* autoconf 2.52.
2001-08-14 02:18:04 +00:00
Martin Pool
74be4fc399 Remove incorrect news message 2001-08-14 02:14:09 +00:00
Martin Pool
3b4b1984ef Update version message to mention batch files. 2001-08-14 02:08:17 +00:00
Martin Pool
6902ed178b Merge across rsync+ patch; add a little documentation to the manpage. More documentation would be better. 2001-08-14 02:04:47 +00:00
Martin Pool
fab9a9c547 Another try at socklen_t: just check for it, and otherwise use int.
The HP manual says this will work on old HP/UX versions; I'm not sure
about other systems.  Possibly it will break on old BSD-derived
systems with 32-bit int, 64-bit size_t and no socklen_t, if there are
any such.
2001-08-08 10:04:40 +00:00
Andrew Tridgell
376acbfad5 don't need to lookup our own name in open_socket_in() 2001-08-08 08:55:24 +00:00
Martin Pool
12458878c2 Try various different types as replacements for socklen_t until we
find one that works.  This helps on platforms like HP/UX and UNICOS
where the argument to getsockopt is neither socklen_t nor int.
2001-08-08 08:11:50 +00:00
Martin Pool
546434f867 Two more instances of socklen_t. 2001-08-06 12:31:23 +00:00
Martin Pool
ac2a1a449d Use socklen_t if defined, or otherwise int. This tries to fix
warnings on platforms (e.g. AIX) where this type is defined and not
int.
2001-08-06 12:27:04 +00:00
Martin Pool
e1bd49d6f3 Try to fix "infinite loop" warning on AIX and other compilers. (We
exit on a signal.)
2001-08-06 12:25:45 +00:00
Martin Pool
ab94af5c6f Correct over-zealous edit for UNICOS. 2001-08-06 12:23:50 +00:00
Martin Pool
c88ca682ef Fix for UNICOS CC: first argument to readlink must not be const, or we
get an error.
2001-08-06 12:16:20 +00:00
Martin Pool
fc990e81cb Document autoconf updates. 2001-08-06 08:51:48 +00:00
Martin Pool
e2ba16ccea Fix check for ino_t to work with both autoconf2.50 and autoconf2.13. 2001-08-06 08:49:19 +00:00
Martin Pool
76d4988d06 Fix m4 quoting to make autoconf2.50 happy. I checked it still works
on 2.13.  See "info:(autoconf)New Macros".
2001-08-06 08:41:13 +00:00
Martin Pool
25ea348bd1 Summarize all the changes since 2.4.6 so we have them in one place. 2001-08-06 04:31:05 +00:00
Andrew Tridgell
8ca5756339 updated config scripts from subversion 2001-07-22 02:39:06 +00:00
Andrew Tridgell
029c171330 reap children in sigchld handler 2001-07-17 10:48:31 +00:00
Andrew Tridgell
8f04bb36e7 prevent nasty error msgs when listing shares 2001-07-17 10:45:54 +00:00
Andrew Tridgell
b7334b4c31 removed remnant test code for cray 2001-06-28 05:07:15 +00:00
Andrew Tridgell
a7f8404ecd fixed md4 on 64 bit boxes 2001-06-26 03:09:14 +00:00
Andrew Tridgell
6c65e14634 applied simple nohang patch from Wayne Davison 2001-06-26 01:20:42 +00:00
David Dykstra
ddd491d45e Improve the description of --with-default-rsync. 2001-06-22 20:36:43 +00:00
Andrew Tridgell
5d78a10232 allow shell wildcards in auth users lines 2001-06-22 10:16:04 +00:00
Martin Pool
4d66e00afa If binding to a low-numbered port fails with EACCES, then the error
message should explain that you probably need to be root.

(Why leave off the final S?  Kernighan must have been a *really* slow
typist.)
2001-06-21 06:19:00 +00:00
Martin Pool
531d06b824 Fix from Wayne Davison:
The --cvs-exclude option is broken in the CVS version of rsync
  because of a cut-and-paste-induced bug in exclude.c:

  This bug could cause the sending rsync to crash when it dereferenced
  a NULL pointer.
2001-06-21 06:15:34 +00:00
David Dykstra
c6a7f2f48a Simplify the --with-rsync-path option implementation. Can directly pass
the double-quotes to AC_DEFINE_UNQUOTED instead of having a separate step.
2001-06-13 16:47:22 +00:00
David Dykstra
d4e4cbe105 Use 3rd parameter in AC_DEFINE and AC_DEFINE_UNQUOTED to avoid having to
manually put the defines into acconfig.h.
2001-06-12 21:35:26 +00:00
David Dykstra
41bd28fee3 Add --with-rsync-path option. 2001-06-12 19:33:41 +00:00
David Dykstra
a1a440c23e Make --whole-file the default when source and target are on the local machine. 2001-05-29 14:37:54 +00:00
David Dykstra
089e73f8d6 Ran rsync.yo through yodl2man to produce rsync.1. I found that the string
"file(s)" in rsync.yo was being improperly translated by yodl2man so I
changed it to just "files".
2001-05-24 18:01:56 +00:00
David Dykstra
2c5548d25e Add --ignore-errors documentation. 2001-05-22 14:33:38 +00:00
Andrew Tridgell
65c2a918d4 forgot 1 place that used slprintf 2001-05-07 08:59:48 +00:00
Andrew Tridgell
8950ac03f8 imported new snprintf.c from samba, got rid of slprintf 2001-05-07 06:59:37 +00:00
Andrew Tridgell
26ef00bd3c no space after -I or Tru64 barfs 2001-05-06 13:25:11 +00:00
Andrew Tridgell
efe3037cf5 use _S_IFLNK not S_IFLNK 2001-05-02 11:13:21 +00:00
Andrew Tridgell
f62c17e378 use mkstemp on systems where it is secure 2001-05-02 08:33:18 +00:00
Andrew Tridgell
0f62178580 better pid file location 2001-05-02 05:05:12 +00:00
Andrew Tridgell
81c99202d3 use %.0f instead of %ld 2001-04-13 12:25:19 +00:00
David Dykstra
3473b5b4d8 Add the words "on destination machine" to the --compare-dist description
in rsync.yo.  Re-ran yodl2man which I see pulled in a few other changes
from rsync.yo that hadn't yet made it into rsync.1.
2001-03-23 15:12:52 +00:00
Andrew Tridgell
ba35824322 "rsync error" is better than "transfer error", especially for -h 2001-03-23 03:46:56 +00:00
Andrew Tridgell
6afe7f23b0 got rid of dependency on alloca in popt 2001-03-23 03:44:50 +00:00
Andrew Tridgell
19b27a485e improved error handling again. Now we report messages for the remote
shell failing and propogate errors in a better fashion
2001-03-23 01:26:04 +00:00
Andrew Tridgell
ff81e809f4 new error handling system
we now give a non-0 exit code if *any* of the files we have been asked
to transfer fail to transfer
2001-03-22 07:36:51 +00:00
Andrew Tridgell
fd2dd2aa23 better error msg for "invalid uid" and "invalid gid" 2001-03-21 23:44:48 +00:00
Andrew Tridgell
82ed910630 i hate makefiles that automatically run configure
:)
2001-03-21 23:36:23 +00:00
Andrew Tridgell
90ba34e27c I came up with a new way of avoiding the error handling lockup bug in
rsync. It isn't pretty, but it does work and should completely avoid
that class of lockup.
2001-03-21 13:12:44 +00:00
Martin Pool
8ee3d639b2 Check for alloca.h and mcheck.h, as included popt needs to know about
them.
2001-03-20 05:26:27 +00:00
Martin Pool
0c5a792ac7 Oops, fix edit mistake. 2001-03-19 08:19:11 +00:00
Martin Pool
2af27ad9aa More accurately, the uid/gid is set to -2, not "nobody". 2001-03-17 01:35:59 +00:00
Martin Pool
3b2b534567 Add some todo comments. 2001-03-17 01:34:22 +00:00
Martin Pool
3fa64fd008 Don't unconditionally define _LARGEFILE_SOURCE, but instead include
some autoconf-2.13 macros that make the appropriate settings.  Thanks
to Albert Chin <china@thewrittenword.com> and Paul Eggert
<eggert@twinsun.com>.
2001-03-17 01:06:34 +00:00
Martin Pool
b557c4c7eb Define _LARGE_FILES to turn on LFS support on AIX (and some others?).
See http://www.rs6000.ibm.com/doc_link/en_US/a_doc_lib/aixprggd/genprogc/prg_lrg_files.htm

Thanks to Todd Willeat <TWilleat@MHP.SMHS.com>
2001-03-16 05:23:33 +00:00
Martin Pool
0882faa2b2 Doc. 2001-03-16 02:11:53 +00:00
Martin Pool
3cd5eb3b3b Add my name and a suggestion to read the FAQ for unanswered questions. 2001-02-27 01:49:19 +00:00
Martin Pool
4ff3d9d6b4 Explain that the mktemp warning is harmless.
If the autoconf inputs are changed, then try to reconfigure.  Don't
worry if we can't do it, though.
2001-02-27 01:46:34 +00:00
Martin Pool
26c08b6c21 Add some brief notes on how to install. 2001-02-24 01:45:21 +00:00
Martin Pool
4db4149283 popt-1.5 is const-correct. 2001-02-24 01:39:19 +00:00
Martin Pool
1ac15cd8ad Upgrade from including popt1.2 to a version of popt1.5 trimmed down to
include only source and build from our Makefile.
Don't scan for libpopt if we're using our own; this makes
autoconf confused.
2001-02-24 01:37:48 +00:00
Martin Pool
b348deae3d Upgrade from popt 1.2 to a cut-down 1.5 2001-02-24 01:32:22 +00:00
Martin Pool
18c71e96f8 Doc. 2001-02-23 01:45:46 +00:00
Martin Pool
f0f5767f15 Change from getopt to popt -- requires const-correctness on arguments. 2001-02-23 01:44:56 +00:00
Martin Pool
15b7b73d7d Change from getopt to popt.
Add comments.
Show listening port number in startup log message.
2001-02-23 01:44:04 +00:00
Martin Pool
e420b9d854 Change from getopt to popt.
Add comment.
2001-02-23 01:02:55 +00:00
Martin Pool
2855f61f4a Change from getopt to popt.
Include more details in --version output: say whether symlinks and
hardlinks are supported.
When hardlink support is missing, explain whether the problem is on
the client or server.
When a bad option is encountered, don't just print it to stderr but
send it to the rsync log mechanism.  (However, server errors currently
seem to get lost in transit because of bugs in logging.)
2001-02-23 01:02:31 +00:00
Martin Pool
2d1ebe9c72 Change from getopt to popt.
Automatically build included libpopt if there is none on the system,
or if --with-included-popt is specified.
Add --enable-debug.
2001-02-23 00:48:11 +00:00
Martin Pool
c485a357cc Change from getopt to popt.
Automatically build included libpopt if there is none on the system.
2001-02-23 00:47:09 +00:00
Martin Pool
5013576705 Change from getopt to popt. 2001-02-23 00:45:07 +00:00
Martin Pool
8886f8d0e6 Add comments.
Better error message in the case of eof on read_timeout.
2001-02-22 13:02:39 +00:00
Martin Pool
fcb6d28d0b Note about multiplexing. 2001-02-22 13:01:27 +00:00
Martin Pool
62402cb14b Check in built-in copy of libpopt in preparation for switching
from getopt
2001-02-22 13:01:09 +00:00
Martin Pool
305ab1331b Doc. 2001-02-21 08:25:07 +00:00
Martin Pool
8212336aaa More explanation of return values. 2001-02-21 08:16:45 +00:00
Martin Pool
3e3dcd624f Better message grammar. 2001-02-21 07:18:50 +00:00
Martin Pool
b30b3bb899 Call this 2.4.6dev so that we don't get bug reports claiming to be
about 2.4.6.
2001-02-14 22:59:03 +00:00
Martin Pool
55b64e4b5e Add table of exit values, from errcode.h. 2001-02-14 22:47:28 +00:00
Martin Pool
e411463442 Document shortcoming of "unrecognised option" message. 2001-02-08 03:28:19 +00:00
Martin Pool
660c6fbdaa Include strerror message when there's a socket error. 2001-01-08 10:25:00 +00:00
Martin Pool
ce6c7c6318 Improved error message. 2001-01-08 03:39:53 +00:00
Martin Pool
fa994de488 Ignore generated files that are not stored in CVS. 2001-01-08 03:39:32 +00:00
Martin Pool
2348926995 Typo fix from Jim Meyering 2001-01-08 01:10:58 +00:00
David Dykstra
735a816e54 Better explain how the --blocking-io option works. 2001-01-05 17:57:11 +00:00
Martin Pool
a1b1b1da46 Add comments. 2000-11-15 05:53:45 +00:00
Martin Pool
c3563c46ed Doc. 2000-11-15 03:16:06 +00:00
Martin Pool
0c80cd8ee9 In --version, say whether we have socketpair() or not 2000-11-10 03:41:47 +00:00
Martin Pool
b79f79e3aa Ignore dummy output file 2000-11-10 03:41:17 +00:00
Martin Pool
af642a61b3 If an error occurs, print an explanatory string rather
than just an RERR code.
2000-11-10 03:28:15 +00:00
Martin Pool
ef1aa91039 Doc. 2000-11-10 03:17:08 +00:00
Martin Pool
1960e2280c Drop dead variable. 2000-11-09 09:45:19 +00:00
Martin Pool
7c1b4daa6f Document getsockopt POSIX confusion. 2000-11-09 09:27:34 +00:00
Martin Pool
7a24c346b0 Print a warning message in the version if the platform cannot support 32-bit ints 2000-11-09 09:05:14 +00:00
Martin Pool
64c2cf8fea Better error messages 2000-11-09 09:02:16 +00:00
Martin Pool
81d538ce23 Better error messages when unlink fails 2000-11-08 09:45:16 +00:00
Martin Pool
e327acece4 Better error messages when unlink fails 2000-11-08 09:32:11 +00:00
Martin Pool
4e40377ac2 Better error messages when unlink fails 2000-11-08 09:32:10 +00:00
Martin Pool
eeb1568fd5 Correct license name. Note new address of pserver. Correct documentation. 2000-11-02 11:38:13 +00:00
Martin Pool
0ba481368c Add some comments. 2000-11-02 11:37:34 +00:00
Andrew Tridgell
38bf526fc5 fix bug in handling of : 2000-10-31 10:59:50 +00:00
Martin Pool
bc363ea983 Display a warning about pointlessly using --rsh with clientserver mode. 2000-10-31 01:05:42 +00:00
Martin Pool
84f69dad19 Draft documentation of the client-server protocol. 2000-10-26 08:05:36 +00:00
Martin Pool
4a13b9d57a Print strerror when a system error occurs; add a new function rsyserr
to do this.  This is not used in every case yet -- I've just changed a
few cases that were causing trouble.  Please convert others as you see them.
2000-10-26 07:31:29 +00:00
Martin Pool
a039749b4c Print strerror when a system error occurs; add a new function rsyserr
to do this.  This is not used in every case yet -- I've just changed a
few cases that were causing trouble.  Please convert others as you see them.
2000-10-26 07:24:18 +00:00
David Dykstra
15b84e142a Make sure the log file is always opened before root privileges (if any)
are given up.
2000-10-25 19:57:42 +00:00
David Dykstra
45a8354004 When running as --daemon in the background and using a "log file" rsyncd.conf
directive, close the log file every time it is open when going to sleep on
the socket.  This allows the log file to get cleaned out by another process.
2000-10-24 18:50:08 +00:00
Andrew Tridgell
c32d024071 don't clobber argv[0], so ps shows the right thing 2000-10-19 00:47:48 +00:00
David Dykstra
205c27ac67 Add note in "secrets file" section to see "strict modes". 2000-10-13 13:49:31 +00:00
Martin Pool
f5c2081302 Clear up conditions for running as root. 2000-10-13 03:28:12 +00:00
Martin Pool
e6c64e7933 Oops: manpage updates should go into the yodl source. 2000-10-13 03:25:07 +00:00
Martin Pool
a036580649 Quick list of things to do. 2000-10-11 00:57:27 +00:00
Martin Pool
796d484b44 Clearer "nothing to do" message. 2000-10-10 01:26:55 +00:00
Martin Pool
1f52f4c407 Get rid of const modifiers; they're problematic with old compilers. 2000-10-09 03:48:47 +00:00
Martin Pool
d567322fbc include/exclude cluestick: with -vv, print out whether files are
included or excluded and why.
2000-10-09 03:46:38 +00:00
John H Terpstra
3ff1e677a1 Added provision for packaging for Linux Standards Base compliant Linux systems. 2000-09-11 18:04:35 +00:00
Andrew Tridgell
ef325f0cf4 neater getconf test 2000-09-06 07:15:37 +00:00
rsync-bugs
3d8810c928 preparing for release of 2.4.6 2000-09-06 02:47:00 +00:00
Andrew Tridgell
d153974ee2 README update 2000-09-06 02:39:45 +00:00
Andrew Tridgell
5b56cc19fb added --modify-window option from David Bolen <db3l@fitlinxx.com> 2000-09-06 02:12:13 +00:00
Andrew Tridgell
c48b22c858 minor man page update 2000-09-06 01:27:46 +00:00
Andrew Tridgell
65d0a49f5c removed spurious error message 2000-09-06 00:48:52 +00:00
Andrew Tridgell
6a48ca56eb added LFS support for Solaris 8 2000-09-05 23:21:27 +00:00
Andrew Tridgell
a20aa42ac4 a simple fix to the memory problems with the string pool patch. The
string pools conflict with the lastdir memory saving tricks.
2000-08-31 23:01:28 +00:00
Andrew Tridgell
e92ee12893 make sure we don't chew too much CPU when the outgoing fd is full 2000-08-29 05:07:08 +00:00
Andrew Tridgell
5c66303ad6 some string_area cleanups 2000-08-29 04:47:39 +00:00
Andrew Tridgell
27e3e9c906 detect list_only a bit earlier 2000-08-29 04:46:50 +00:00
Andrew Tridgell
f0b36a48c8 the 2nd half of the hack 2000-08-29 04:46:27 +00:00
Andrew Tridgell
25cf88936f a hack to make listing remote sites (by leaving off a target) more
useful
2000-08-29 04:45:49 +00:00
Andrew Tridgell
ae682c3e11 got rid of some unused variables 2000-08-19 15:25:05 +00:00
rsync-bugs
99994aef3e preparing for release of 2.4.5 2000-08-19 13:10:57 +00:00
Andrew Tridgell
78043d1969 man page updates 2000-08-19 13:04:48 +00:00
Andrew Tridgell
43e46b4cf6 allow 0.0.0.0/0 syntax in hosts allow/deny
patch from Charles Levert <charles@comm.polymtl.ca>
2000-08-19 13:04:29 +00:00
Andrew Tridgell
9ec16c83be added msleep() function 2000-08-19 12:53:51 +00:00
Andrew Tridgell
a24c687094 sleep for a smaller time while waiting for a process to exit 2000-08-19 12:53:24 +00:00
Andrew Tridgell
60cb2f9016 added "ignore nonreadable" option (useful for hiding files in public archives) 2000-08-19 12:53:00 +00:00
Andrew Tridgell
ac1a0994b6 added an explicit noexcludes flag to make_file()
this fixes a bug with --backup-dir and -x

added "ignore nonreadable" option (useful for hiding files in public archives)
2000-08-19 12:52:39 +00:00
Andrew Tridgell
f2cbf44ba5 added an explicit noexcludes flag to make_file() 2000-08-19 12:51:26 +00:00
Andrew Tridgell
dab552237e I don't like automatic header dependencies 2000-08-19 12:51:00 +00:00
Andrew Tridgell
2201ba580e added MacOS support to config.guess (from wsanchez@apple.com) 2000-08-19 12:09:52 +00:00
Andrew Tridgell
b7c33e3bde fixed backup_dir bug introduced with recent memory handling patches 2000-08-19 11:06:04 +00:00
Andrew Tridgell
82980a2384 fixed timing problem with cleanup and io_flush() by using non-blocking
waitpid()
2000-08-16 08:34:18 +00:00
David Dykstra
b6a30afc98 Undo last setting of blocking_io. I hadn't reviewed the code well enough;
turns out that when client is talking to a server daemon it never executes
this leg of code.  Oops.  The people who said it made a difference when
they changed the code must have been wrong.
2000-08-04 21:26:17 +00:00
David Dykstra
ed91f3e418 Turn on blocking_io when starting client of rsync server daemon. 2000-08-04 21:18:23 +00:00
David Dykstra
60c8d7bc7f Enable --compare-dest to work in combination with --always-checksum.
Problem and suggested patch from Dean Scothern dino@cricinfo.com (although
I re-wrote the patch).
2000-08-04 21:11:46 +00:00
rsync-bugs
5783c065ba preparing for release of 2.4.4 2000-07-29 05:05:38 +00:00
Andrew Tridgell
adc19c987b fix from T.J.Adye@rl.ac.uk for final goodbye message with new protocol 2000-07-29 04:58:24 +00:00
Andrew Tridgell
3d38277706 optimisations from Rich Salz <rsalz@caveosystems.com> 2000-07-29 04:52:05 +00:00
Andrew Tridgell
64c704f0b9 added blocking-io docs 2000-07-29 04:41:19 +00:00
Andrew Tridgell
69c6522734 added *.bz2 and *.tbz to default dont compress list 2000-06-24 13:20:21 +00:00
Andrew Tridgell
0f8f98c8ff added insure debug support 2000-06-24 13:19:53 +00:00
Andrew Tridgell
e384bfbdcb if the remote shell is rsh then use blocking IO 2000-06-24 13:19:25 +00:00
Andrew Tridgell
08e5094d7f added some comments on blocking-io 2000-06-23 13:54:29 +00:00
Andrew Tridgell
4b3977bf00 get rid of annoying symlink error messages 2000-06-23 13:54:08 +00:00
Andrew Tridgell
c80ccabb0c added --blocking-io option 2000-06-23 13:50:18 +00:00
David Dykstra
ef5d23ebcd Add --bwlimit option contributed by Matthew Demicco and Jamie Gritton. 2000-06-06 21:13:05 +00:00
David Dykstra
27b9a19be0 Do better job at describing exclude/include in man page. Based on suggestions
from Harry Putnam <reader@newsguy.com>.
2000-05-19 14:58:28 +00:00
Andrew Tridgell
14175f1e77 fixed bug in replacement inet_aton() 2000-04-19 05:49:15 +00:00
Andrew Tridgell
269833af78 test was the wrong way around 2000-04-19 05:44:43 +00:00
Andrew Tridgell
fca3ef06cd autoconf test for broken solaris inet_aton() 2000-04-19 05:33:39 +00:00
Andrew Tridgell
07a14ef8b2 by default don't gzip .iso images 2000-04-19 05:33:06 +00:00
rsync-bugs
21cde2888c preparing for release of 2.4.3 2000-04-09 02:53:57 +00:00
Andrew Tridgell
4a7481889c use 1 second sleeps in the sleep loop as some OSes (NT for example)
don't get interrupted during a sleep.
2000-04-09 02:32:57 +00:00
Andrew Tridgell
0adb99b9dc don't pprint the IO timeout message if we are a server or daemon (can
cause recursive error messages)
2000-04-09 02:32:18 +00:00
Andrew Tridgell
36349ea0be a very simple fix - if I'd only thought if it last week :)
rsh relies on stdin being blocking
ssh relies on stdout being non-blocking

what we've done before is to set both stdin and stdout to either
blocking or non-blocking. Now I set stdin to blocking and stdout to
non-blocking. This seems to fix all cases I've tested.
2000-04-09 02:16:42 +00:00
rsync-bugs
ec3f7d1b61 preparing for release of 2.4.2 2000-03-30 14:24:37 +00:00
Andrew Tridgell
f0359dd00d went back to non-blokcing IO
it looks like ssh is willing to accept a non-blocking fd when used as
a transport, this seems to avoid the Solaris socketpair bug
2000-03-30 14:15:00 +00:00
Andrew Tridgell
ef55c686bc add a --ignore-errors option 2000-03-21 04:06:04 +00:00
David Dykstra
5f7ce2041c Describe symbolic link handling when writing to a "use chroot = no" module. 2000-02-25 17:02:45 +00:00
David Dykstra
328fcf113a Somebody was confused into thinking that "Here are some examples" in the
section on exclude/include was supposed to be about "+/-" so I changed
the statement to "Here are some exclude/include examples".
2000-02-22 19:47:44 +00:00
David Dykstra
24c857f1de Change socketpair test to verify that it works rather than just exists,
because I have an obscure system (Amdahl's UTS 2.1.2) in which socketpair()
exists but is broken.
2000-02-22 15:55:40 +00:00
David Dykstra
a784e10d00 Move the checking for -lsocket -lnsl ahead of the checking for most of
the functions, especially "socketpair" so that socket-related functions will
be properly discovered on SVR4-based systems such as Solaris.  Problem
discovered by Kenji Miyake <kenji@miyake.org>
2000-02-15 22:44:18 +00:00
rsync-bugs
7eb6bf0397 preparing for release of 2.4.1 2000-01-30 01:02:59 +00:00
Andrew Tridgell
49d6fdc036 patch from Jim Delahanty <mail_us@swbell.net> to ensure files are
deleted after being backed up in a rename operation
2000-01-30 00:56:43 +00:00
Andrew Tridgell
8b35435f7c another hang-at-end fix. It looks like we are more sensiitive to
these with socketpairs. The receiver now sleeps until it gets a signal
to tell it to exit

also fixed test.sh to use the current version remotely
2000-01-30 00:50:19 +00:00
Andrew Tridgell
8ada751890 damn.
with the new error handling code it is possible for rsync to get stuck
on the final transaction, leaving it hung.

looks like 2.4.1 will be pretty soon
2000-01-29 23:49:36 +00:00
rsync-bugs
1a52e84874 preparing for release of 2.4.0 2000-01-29 11:35:39 +00:00
Andrew Tridgell
53c5cbed23 change version to 2.4.0pre2 2000-01-29 05:25:53 +00:00
Andrew Tridgell
4a81463880 use full buffer length, not strlen 2000-01-29 05:16:13 +00:00
Andrew Tridgell
09b7f5dbb1 move the read only daemon test to after the protocol setup 2000-01-29 05:02:23 +00:00
Andrew Tridgell
6d7b6081ac damn!
the last pre-release had a bug that didn't setup the multiplexing
correctly. This means that pre-release will get "unexpected tag -7"
whenm talking to the fixed code.
2000-01-29 04:50:01 +00:00
Andrew Tridgell
31b7d79afe I've decided that this release will be 2.4.0, updated version to 2.4.0pre1 2000-01-29 03:11:07 +00:00
Andrew Tridgell
b2999e457f don't need PIPE_BUF any more 2000-01-29 02:56:36 +00:00
Andrew Tridgell
0f3203c312 fixed some logcode warnings 2000-01-29 02:49:03 +00:00
Andrew Tridgell
a2edb26cd6 fixed a bug in test suite that I introduced yesterday 2000-01-29 02:39:52 +00:00
Andrew Tridgell
9bec528606 runtime detect fnmatch() bug if ** is used.
its all too common to compile with a working libc and run on a broken
one.
2000-01-29 02:35:01 +00:00
Andrew Tridgell
2f0e3b30a9 changed version to 2.3.3pre2 2000-01-28 15:35:08 +00:00
Andrew Tridgell
ff41a59f58 - switched on multiplexing for all connections, not just daemon
connections (this fixes the stderr/stdout problem). Upped
  protocol version for backward compat
- use multiplexing on error fd
- upped minimal protocol version
- got rid of some ugly code in the write buffering
2000-01-28 15:29:59 +00:00
Andrew Tridgell
08f15335b5 switch to using socketpair instead of pipe if possible. This fixes the
ssh clag problems as long as you also fix the same problem in sshd

removed all the old read buffering code from io.c as this was only
there to try to reduce the chance of clagging up sshd.
2000-01-28 12:37:58 +00:00
Andrew Tridgell
bd36966bed report exit code when failing a test 2000-01-27 04:54:02 +00:00
Andrew Tridgell
f76933b149 fixed the error code problem with test.sh
(was a minor bug in send_file_list)
2000-01-27 04:53:39 +00:00
Andrew Tridgell
378a074c82 patch from James Delahanty <jimd@gie.com> to make --backup-dir work
cross-filesystem
2000-01-27 02:45:56 +00:00
Andrew Tridgell
c36cd31713 the convoluted nest of #ifdefs that is fnmatch.c caught us again. On
my system the LIBC tests meant it never compiled and we used the
broken system one.

hacked it so it does compile
2000-01-25 14:17:21 +00:00
Andrew Tridgell
5e12ce1186 fix segv bug in --progress handling 2000-01-25 13:16:42 +00:00
Andrew Tridgell
166aa72332 patch from David Murn to make sure the final 100% is always printed
when using --progress
2000-01-25 06:39:33 +00:00
Andrew Tridgell
f9f6184f38 updated version.h 2000-01-25 01:33:05 +00:00
Andrew Tridgell
f625af9400 updated config.guess from latest autoconf CVS tree 2000-01-24 13:12:20 +00:00
Andrew Tridgell
fc7952e7f3 updated --password-file docs 2000-01-24 12:28:45 +00:00
Andrew Tridgell
cbce490e13 reinstated the MAX_READ_BUFFER code. Its a nasty tradeoff - using lots
of memory vs. ssh bugs. uggh.
2000-01-24 12:23:39 +00:00
Andrew Tridgell
74a7f81d57 updated a debug message 2000-01-24 12:22:58 +00:00
Andrew Tridgell
5b5591d8a8 make the replacement inet_aton() function independent of
inet_addr(). Some systems were detecting a missing inet_aton(), but
actually had it and inet_addr() called it, causing infinite recursion
2000-01-24 12:02:44 +00:00
Andrew Tridgell
c55f70218c fixed a rare SEGV that can happen when a file disappears (due to
another program) during an update
2000-01-24 11:41:08 +00:00
Andrew Tridgell
6957ae33a9 moved file deletion to before the fork() to prevent a race condition
pointed out by byrnes@curl.com
2000-01-24 11:20:25 +00:00
Andrew Tridgell
8a5d6bba09 don't use stderr after we become a daemon 2000-01-24 09:19:44 +00:00
Andrew Tridgell
1d2c275fff I can't believe it - solaris allows unlink of a non-empty directory as
root, leaving a corrupt filesystem. Are those guys on drugs?

try to avoid the problem as best we can.
2000-01-24 09:13:39 +00:00
Andrew Tridgell
d0fd26aa16 added some more debug info to the "buffer overflow in
receive_file_entry" message
2000-01-24 08:16:57 +00:00
Andrew Tridgell
e20c5e9521 -a now implies -o and -D whether you are root or not 2000-01-24 05:52:44 +00:00
Andrew Tridgell
66203a982b added --backup-dir option from Bob Edwards
this is very useful for incremental backups
2000-01-24 04:58:53 +00:00
Andrew Tridgell
b315601ce0 removed Daves include-only optimisation. One of the bug reports turned
out to be caused by it and it seems rather a lot of extra effort for
what must really be a minor optimisation in most cases
2000-01-23 13:16:30 +00:00
Andrew Tridgell
5f808dfbd7 fix a problem with files > 2GB
(thanks to T.J.Adye@rl.ac.uk)
2000-01-23 12:30:34 +00:00
Andrew Tridgell
0b73ca12fa added --max-delete option 2000-01-23 11:43:04 +00:00
Andrew Tridgell
03e2d0e329 fixed mdfour code on Cray (64 bit problems)
Thanks to roebel@kgw.tu-berlin.de
2000-01-23 11:26:10 +00:00
Andrew Tridgell
182517e692 removed u_sleep() as it is no longer used anywhere 2000-01-23 07:38:20 +00:00
Andrew Tridgell
554e0a8dd0 added some really ugly code to allow errors to propogate to
clients when writing to a rsync server

it works like this:

- we have an extra pipe from the receiver to the generator
- the server always runs with multiplexing on
- errors from the generator go down the multiplexed connection
- errors from the receiver go over the pipe, and from there to
  the multiplexed conn

it required some incredibly ugly code. damn.
2000-01-23 07:36:56 +00:00
Andrew Tridgell
b0f3f5784c open on paths starting with // fails on win32 2000-01-23 03:00:27 +00:00
Andrew Tridgell
3060d4aa1d handle systems that don't take a 2nd argument to gettimeofday() 2000-01-23 02:16:51 +00:00
Andrew Tridgell
1347d5126a added --existing option, similar to one suggested by Gildas Quiniou <gildas@stip.fr> 2000-01-23 01:53:18 +00:00
Andrew Tridgell
5d1e1dcf4b don't try to write errors to a dead socket 2000-01-23 01:11:43 +00:00
David Dykstra
74f5442401 Make all the rsync objects dependent on all the header files except the
zlib header fiels in Makefile.in.  I've been burned several times because
objects did not get rebuilt when header files changed.
2000-01-10 22:39:45 +00:00
David Dykstra
c08bb0fb73 Needed to comment out the inclusion of headers in fnmatch.c because it
couldn't find some of them (especially <fnmatch.h>, because it wasn't
looking in the current directory).  The header files are included better
from ../rsync.h.
2000-01-10 20:36:20 +00:00
Andrew Tridgell
e30f065766 make --address work for a client connecting to a server 2000-01-10 04:49:51 +00:00
David Dykstra
9dce9b45b3 Upgrade lib/fnmatch.[ch] to the latest from glibc-2.1.2 because the
FNM_PATHNAME flag (to stop at slashes in path names) was not working.

Ironically, the bug in glibc's fnmatch was reported on the rsync mailing
list in late October, and rsync's configure.in was changed to detect the
bad glibc and use the internal fnmatch, but the internal fnmatch was based
on the same buggy glibc!
2000-01-07 17:58:44 +00:00
David Dykstra
60be6acf46 If a destination file cannot be opened, pretend it doesn't exist rather
than skipping it and thus not updating it.  For example, the ownership or
mode on a file may prevent opening it, but the directory may still be
writable so the file could be completely replaced.
2000-01-06 16:15:36 +00:00
Andrew Tridgell
a5827a28d2 when we do a lchown() on a file we have to flush the cached perms on
the file if the file has the setuid or setgid bits set as the chown
has a side effect of removing the setuid and setgid bits.
we re-do the stat in this case
2000-01-06 00:26:00 +00:00
David Dykstra
dcc875e41e Define the WEXITSTATUS macro for systems that don't have it. 1999-12-29 21:11:57 +00:00
David Dykstra
128cf58433 When writing to a daemon with read only = false and uid = root and -g,
was not preserving group permisions.  Bug was introduced March 1 in
version 1.100 of rsync.c with an error in re-ordering of the boolean
expressions.  In order to completely preserve the earlier semantics,
change_gid should depend on "(am_root || !am_daemon)", but I don't see why
group ownership should behave differently in a non-root daemon.
1999-12-29 20:50:48 +00:00
David Dykstra
7e0ca8e2f0 When not using -p and file being copied to already existed, was mistakenly
using all the mode bits of the existing file rather than just the permissions,
including the file type.
1999-12-29 20:45:23 +00:00
Andrew Tridgell
d79d1c69f7 fixed a bug with waitpid() - I'd forgotten about WEXITSTATUS ! 1999-12-09 06:46:11 +00:00
Andrew Tridgell
a7d068abff fixed man page typo 1999-12-03 04:24:25 +00:00
Andrew Tridgell
7f931a0002 fixed a segv bug when handling symlinks.
thanks to taver@otenet.gr
1999-12-02 05:50:09 +00:00
Andrew Tridgell
07b7c86c06 don't write more than PIPE_BUF bytes in any one write() in io.c
this makes sure that the write never blocks.
1999-11-23 08:43:16 +00:00
Andrew Tridgell
1f5c6343e6 removed old non-blocking fd code (a hangover from a earlier version of
io.c). Thanks to Theo for pointing out this brokenness.
1999-11-15 01:32:20 +00:00
rsync-bugs
290b615a16 preparing for release of 2.3.2 1999-11-08 13:15:48 +00:00
Andrew Tridgell
57df171bc0 added --delete-after option (suggested by Jason) 1999-11-08 13:03:05 +00:00
Andrew Tridgell
f08baea3dd removed ACCESSPERMS mask when transferring a file without perms
copy. This makes us match GNU cp more closely.
1999-11-08 10:47:14 +00:00
Andrew Tridgell
2fb139c11b fixed passing of directory exclude options to remote side (thanks to
andrewdagger@xerox.gbr.com)

added note about multiple excludes per exclude option
1999-11-08 09:12:42 +00:00
David Dykstra
3420c8e6e0 Fixed bug introduced by calling do_open() for O_RDONLY files. Changed it
so the check for dry_run and CHECK_RO are not done when flags is O_RDONLY.
Only do the adding of O_BINARY, which was the intention.
1999-11-04 15:43:38 +00:00
Andrew Tridgell
b17bc22bb3 added a replacement inet_aton() for systems that don't have it.
thanks to Dave for pointing this out.
1999-11-01 21:35:15 +00:00
Andrew Tridgell
3adffb52e6 forgot to commit the fnmatch.h changes 1999-11-01 21:25:39 +00:00
Andrew Tridgell
4df9f36841 solved the problem of not using the right permissions when
preserve_perms is off.
1999-10-31 04:28:03 +00:00
Andrew Tridgell
5c9730a46c added --address option for virtual hosting 1999-10-31 03:21:02 +00:00
Andrew Tridgell
d9fcc198cf added -P option
it is equivalent to --partial --progress
1999-10-31 02:47:30 +00:00
Andrew Tridgell
c831379436 updated test suite from Phil. 1999-10-31 02:39:34 +00:00
Andrew Tridgell
d73ee7b70e updated rsync-path man page entry 1999-10-31 02:37:21 +00:00
Andrew Tridgell
cda2ae84b3 added "ignore errors" option in rsyncd.conf 1999-10-31 02:19:24 +00:00
Andrew Tridgell
e7d6e0aa0c updated the configure test for fnmatch() to see if FNM_PATHNAME is
working correctly.
1999-10-27 13:17:16 +00:00
Andrew Tridgell
8c9fd200f9 use do_open() instead of open() in several places to help the WinXX port
and O_BINARY
1999-10-25 22:04:09 +00:00
David Dykstra
79f118d859 Minor change suggesting people put in the right path in inetd.conf.
Suggested by Roger Price <rprice@cs.uml.edu>
1999-10-19 17:50:39 +00:00
Andrew Tridgell
7b10f91d8f added a note about using -v with --progress 1999-09-06 02:04:20 +00:00
Andrew Tridgell
3d19b4c83e separated out the make_backup code in preparation for some patches
from Bob Edwards
1999-08-30 08:19:47 +00:00
David Dykstra
79452d4693 Add a couple clarifying points to the sanitize_path() comments.
One is a note that a leading "/" in a symlink target will not behave
exactly as if a chroot had occurred, but I decided it wasn't worth the
making it the same.

The other is note about an extra harmless trailing "." that is added under
some rare circumstances.
1999-07-09 17:07:59 +00:00
David Dykstra
cb13abfed0 Fix significant security holes with "use chroot = no" in an rsync daemon:
1. The file paths being sent and received were not "sanitized" to
	ensure that there weren't any ".." components that would escape the
	top level directory.  This can't happen with the standard rsync
	client, but it could be exploited on both read and write if someone
	modified an rsync client.  This fix sanitizes all incoming and
	outgoing paths when "use chroot = no".

    2. If a module is also "read only = no", clients could have created
	symbolic links with ".." components that would allow writing
	outside of the module.  This could happen with the standard rsync
	client.  This fix sanitizes all incoming symbolic link targets
	when "use chroot = no".

Previously, only top-level paths (anything passed in command line arguments)
were sanitized.  Sorry, I didn't think about the individual file paths
before now.
1999-07-09 15:49:46 +00:00
Andrew Tridgell
0503f06089 continue calling waitpid() while still reapingchildren (patch from
Matti Aarnio)
1999-06-27 04:12:12 +00:00
Andrew Tridgell
f855a7d01a fixed a bug that made us use only 16 bits of the file checksum when
comparing checksums for the --checksum (-c) option.
1999-06-26 01:06:38 +00:00
Andrew Tridgell
4c3b4b2557 added RSYNC_PROXY support from Stephen Rothwell. This allows access to
rsync servers via a web proxy (useful for getting through firewalls)
1999-04-13 03:53:30 +00:00
175 changed files with 36600 additions and 11839 deletions

View File

@@ -1,21 +1,25 @@
.ignore
.cvsignore
ID
Makefile
a
b
autom4te*.cache
confdefs.h
config.cache
config.h
config.log
config.status
dist.tar.gz
conftest.c
conftest.log
dox
getgroups
gmon.out
rsync
rsync-*
rsync.aux
rsync.dvi
rsync.log
tech_report.aux
tech_report.dvi
tech_report.log
tech_report.ps
test
shconfig
testdir
tests-dont-exist
testtmp
testtmp.*
tls
trimslash
t_unsafe
wildtest
getfsdev
.rsync-filter

11
COPYING
View File

@@ -2,7 +2,7 @@
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@@ -279,7 +279,7 @@ POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Programs
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
@@ -291,7 +291,7 @@ convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
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
@@ -305,14 +305,15 @@ the "copyright" line and a pointer to where the full notice is found.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.

187
Doxyfile Normal file
View File

@@ -0,0 +1,187 @@
# Doxyfile 1.2.15
#---------------------------------------------------------------------------
# General configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = rsync
PROJECT_NUMBER = HEAD
OUTPUT_DIRECTORY = dox
OUTPUT_LANGUAGE = English
EXTRACT_ALL = YES
EXTRACT_PRIVATE = YES
EXTRACT_STATIC = YES
EXTRACT_LOCAL_CLASSES = YES
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = NO
STRIP_FROM_PATH = *source
INTERNAL_DOCS = YES
STRIP_CODE_COMMENTS = NO
CASE_SENSE_NAMES = YES
SHORT_NAMES = NO
HIDE_SCOPE_NAMES = YES
VERBATIM_HEADERS = YES
SHOW_INCLUDE_FILES = YES
JAVADOC_AUTOBRIEF = YES
INHERIT_DOCS = YES
INLINE_INFO = YES
SORT_MEMBER_DOCS = NO
DISTRIBUTE_GROUP_DOC = NO
TAB_SIZE = 8
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
ALIASES =
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
OPTIMIZE_OUTPUT_FOR_C = YES
OPTIMIZE_OUTPUT_JAVA = NO
SHOW_USED_FILES = YES
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = NO
WARNINGS = NO
WARN_IF_UNDOCUMENTED = NO
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = .
FILE_PATTERNS = *.c \
*.h
RECURSIVE = YES
EXCLUDE = proto.h \
zlib \
popt
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS =
EXAMPLE_RECURSIVE = NO
IMAGE_PATH =
INPUT_FILTER =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = YES
INLINE_SOURCES = YES
REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = YES
COLS_IN_ALPHA_INDEX = 3
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
GENERATE_CHI = NO
BINARY_TOC = NO
TOC_EXPAND = NO
DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 3
GENERATE_TREEVIEW = NO
TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
GENERATE_LATEX = NO
LATEX_OUTPUT = latex
LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO
PAPER_TYPE = a4wide
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = YES
USE_PDFLATEX = YES
LATEX_BATCHMODE = YES
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
GENERATE_MAN = NO
MAN_OUTPUT = man
MAN_EXTENSION = .3
MAN_LINKS = NO
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
GENERATE_XML = NO
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = NO
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED =
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::addtions related to external references
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE =
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = YES
HAVE_DOT = YES
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
TEMPLATE_RELATIONS = YES
HIDE_UNDOC_RELATIONS = YES
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
GRAPHICAL_HIERARCHY = YES
DOT_IMAGE_FORMAT = png
DOT_PATH =
DOTFILE_DIRS =
MAX_DOT_GRAPH_WIDTH = 1024
MAX_DOT_GRAPH_HEIGHT = 1024
GENERATE_LEGEND = YES
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::addtions related to the search engine
#---------------------------------------------------------------------------
SEARCHENGINE = NO
CGI_NAME = search.cgi
CGI_URL =
DOC_URL =
DOC_ABSPATH =
BIN_ABSPATH = /usr/local/bin/
EXT_DOC_PATHS =

58
INSTALL Normal file
View File

@@ -0,0 +1,58 @@
To build and install rsync
$ ./configure
$ make
# make install
You may set the installation directory and other parameters by options
to ./configure. To see them, use:
$ ./configure --help
As of 2.4.7, rsync uses Eric Troan's popt option-parsing library. A
cut-down copy of release 1.5 is included in the rsync distribution,
and will be used if there is no popt library on your build host, or if
the --with-included-popt option is passed to ./configure.
If you configure using --enable-maintainer-mode, then rsync will try
to pop up an xterm on DISPLAY=:0 if it crashes. You might find this
useful, but it should be turned off for production builds.
RPM NOTES
---------
Under packaging you will find .spec files for several distributions.
The .spec file in packaging/lsb can be used for Linux systems that
adhere to the Linux Standards Base (e.g., RedHat and others).
HP-UX NOTES
-----------
The HP-UX 10.10 "bundled" C compiler seems not to be able to cope with
ANSI C. You may see this error message in config.log if ./configure
fails:
(Bundled) cc: "configure", line 2162: error 1705: Function prototypes are an ANSI feature.
Install gcc or HP's "ANSI/C Compiler".
MAC OSX NOTES
-------------
Mac OS X (Darwin) seems to have an IPv6 stack, but it does not
completely implement the "New Sockets" API.
<http://www.ipv6.org/impl/mac.html> says that Apple do not support
IPv6 yet. If your build fails, try again with --disable-ipv6.
IBM AIX NOTES
-------------
IBM AIX has a largefile problem with mkstemp. See IBM PR-51921.
The workaround is to append the below to config.h
#ifdef _LARGE_FILES
#undef HAVE_SECURE_MKSTEMP
#endif

View File

@@ -9,65 +9,128 @@ mandir=@mandir@
LIBS=@LIBS@
CC=@CC@
CFLAGS=@CFLAGS@
CPPFLAGS=@CPPFLAGS@
EXEEXT=@EXEEXT@
LDFLAGS=@LDFLAGS@
INSTALLCMD=@INSTALL@
INSTALLMAN=@INSTALL@
srcdir=@srcdir@
VPATH=$(srcdir)
SHELL=/bin/sh
VERSION=@VERSION@
.SUFFIXES:
.SUFFIXES: .c .o
LIBOBJ=lib/getopt.o lib/fnmatch.o lib/compat.o lib/snprintf.o lib/mdfour.o
ZLIBOBJ=zlib/deflate.o zlib/infblock.o zlib/infcodes.o zlib/inffast.o \
zlib/inflate.o zlib/inftrees.o zlib/infutil.o zlib/trees.o \
zlib/zutil.o zlib/adler32.o
OBJS1=rsync.o generator.o receiver.o cleanup.o sender.o exclude.o util.o main.o checksum.o match.o syscall.o log.o
OBJS2=options.o flist.o io.o compat.o hlink.o token.o uidlist.o socket.o fileio.o
HEADERS=byteorder.h config.h errcode.h proto.h rsync.h lib/pool_alloc.h
LIBOBJ=lib/wildmatch.o lib/compat.o lib/snprintf.o lib/mdfour.o \
lib/permstring.o lib/pool_alloc.o @LIBOBJS@
ZLIBOBJ=zlib/deflate.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o \
zlib/trees.o zlib/zutil.o zlib/adler32.o zlib/compress.o zlib/crc32.o
OBJS1=rsync.o generator.o receiver.o cleanup.o sender.o exclude.o util.o \
main.o checksum.o match.o syscall.o log.o backup.o
OBJS2=options.o flist.o io.o compat.o hlink.o token.o uidlist.o socket.o \
fileio.o batch.o clientname.o
OBJS3=progress.o pipe.o
DAEMON_OBJ = params.o loadparm.o clientserver.o access.o connection.o authenticate.o
OBJS=$(OBJS1) $(OBJS2) $(DAEMON_OBJ) $(LIBOBJ) $(ZLIBOBJ)
popt_OBJS=popt/findme.o popt/popt.o popt/poptconfig.o \
popt/popthelp.o popt/poptparse.o
OBJS=$(OBJS1) $(OBJS2) $(OBJS3) $(DAEMON_OBJ) $(LIBOBJ) $(ZLIBOBJ) @BUILD_POPT@
TLS_OBJ = tls.o syscall.o lib/compat.o lib/snprintf.o lib/permstring.o
# Programs we must have to run the test cases
CHECK_PROGS = rsync$(EXEEXT) tls$(EXEEXT) getgroups$(EXEEXT) getfsdev$(EXEEXT) \
trimslash$(EXEEXT) t_unsafe$(EXEEXT) wildtest$(EXEEXT)
# Objects for CHECK_PROGS to clean
CHECK_OBJS=getgroups.o getfsdev.o t_stub.o t_unsafe.o trimslash.o wildtest.o
# note that the -I. is needed to handle config.h when using VPATH
.c.o:
@OBJ_SAVE@
$(CC) -I. -I$(srcdir) $(CFLAGS) -c $< @CC_SHOBJ_FLAG@
$(CC) -I. -I$(srcdir) $(CFLAGS) $(CPPFLAGS) -c $< @CC_SHOBJ_FLAG@
@OBJ_RESTORE@
all: rsync
man: rsync.1 rsyncd.conf.5
all: rsync$(EXEEXT)
install: all
-mkdir -p ${bindir}
${INSTALLCMD} -m 755 rsync ${bindir}
-mkdir -p ${mandir}/man1
-mkdir -p ${mandir}/man5
${INSTALLCMD} -m 644 $(srcdir)/rsync.1 ${mandir}/man1
${INSTALLCMD} -m 644 $(srcdir)/rsyncd.conf.5 ${mandir}/man5
-mkdir -p ${DESTDIR}${bindir}
${INSTALLCMD} ${INSTALL_STRIP} -m 755 rsync$(EXEEXT) ${DESTDIR}${bindir}
-mkdir -p ${DESTDIR}${mandir}/man1
-mkdir -p ${DESTDIR}${mandir}/man5
${INSTALLMAN} -m 644 $(srcdir)/rsync.1 ${DESTDIR}${mandir}/man1
${INSTALLMAN} -m 644 $(srcdir)/rsyncd.conf.5 ${DESTDIR}${mandir}/man5
install-strip:
$(MAKE) INSTALLCMD='$(INSTALLCMD) -s' install
$(MAKE) INSTALL_STRIP='-s' install
rsync: $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o rsync $(OBJS) $(LIBS)
rsync$(EXEEXT): $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
rsync.1: rsync.yo
yodl2man -o rsync.1 rsync.yo
$(OBJS): $(HEADERS)
rsyncd.conf.5: rsyncd.conf.yo
yodl2man -o rsyncd.conf.5 rsyncd.conf.yo
tls$(EXEEXT): $(TLS_OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(TLS_OBJ) $(LIBS)
getgroups$(EXEEXT): getgroups.o
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ getgroups.o $(LIBS)
getfsdev$(EXEEXT): getfsdev.o
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ getfsdev.o $(LIBS)
TRIMSLASH_OBJ = trimslash.o syscall.o lib/compat.o lib/snprintf.o
trimslash$(EXEEXT): $(TRIMSLASH_OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(TRIMSLASH_OBJ) $(LIBS)
T_UNSAFE_OBJ = t_unsafe.o syscall.o util.o t_stub.o lib/compat.o lib/snprintf.o
t_unsafe$(EXEEXT): $(T_UNSAFE_OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(T_UNSAFE_OBJ) $(LIBS)
gen: $(srcdir)/configure $(srcdir)/config.h.in proto man
man: $(srcdir)/rsync.1 $(srcdir)/rsyncd.conf.5
$(srcdir)/configure: $(srcdir)/configure.in $(srcdir)/aclocal.m4
cd $(srcdir); autoconf
$(srcdir)/config.h.in: $(srcdir)/configure.in $(srcdir)/aclocal.m4
cd $(srcdir); autoheader
$(srcdir)/rsync.1: $(srcdir)/rsync.yo
yodl2man -o $(srcdir)/rsync.1 $(srcdir)/rsync.yo
$(srcdir)/rsyncd.conf.5: $(srcdir)/rsyncd.conf.yo
yodl2man -o $(srcdir)/rsyncd.conf.5 $(srcdir)/rsyncd.conf.yo
proto:
cat *.c | awk -f mkproto.awk > proto.h
cat $(srcdir)/*.c $(srcdir)/lib/compat.c | awk -f $(srcdir)/mkproto.awk >$(srcdir)/proto.h.new
if diff $(srcdir)/proto.h $(srcdir)/proto.h.new >/dev/null; then \
rm $(srcdir)/proto.h.new; \
else \
mv $(srcdir)/proto.h.new $(srcdir)/proto.h; \
fi
clean:
rm -f *~ $(OBJS) rsync
clean: cleantests
rm -f *~ $(OBJS) $(TLS_OBJ) $(CHECK_PROGS) $(CHECK_OBJS)
cleantests:
rm -rf ./testtmp*
# We try to delete built files from both the source and build
# directories, just in case somebody previously configured things in
# the source directory.
distclean: clean
rm -f config.h config.cache config.status Makefile
rm -f Makefile config.h config.status
rm -f $(srcdir)/Makefile $(srcdir)/config.h $(srcdir)/config.status
rm -f config.cache config.log
rm -f $(srcdir)/config.cache $(srcdir)/config.log
rm -f shconfig $(srcdir)/shconfig
# this target is really just for my use. It only works on a limited
# range of machines and is used to produce a list of potentially
@@ -75,4 +138,60 @@ distclean: clean
finddead:
nm *.o */*.o |grep 'U ' | awk '{print $$2}' | sort -u > nmused.txt
nm *.o */*.o |grep 'T ' | awk '{print $$3}' | sort -u > nmfns.txt
comm -13 nmused.txt nmfns.txt
comm -13 nmused.txt nmfns.txt
# 'check' is the GNU name, 'test' is the name for everybody else :-)
.PHONY: check test
test: check
# There seems to be no standard way to specify some variables as
# exported from a Makefile apart from listing them like this.
# This depends on building rsync; if we need any helper programs it
# should depend on them too.
# We try to run the scripts with POSIX mode on, in the hope that will
# catch Bash-isms earlier even if we're running on GNU. Of course, we
# might lose in the future where POSIX diverges from old sh.
check: all $(CHECK_PROGS)
POSIXLY_CORRECT=1 TOOLDIR=`pwd` rsync_bin=`pwd`/rsync$(EXEEXT) srcdir="$(srcdir)" $(srcdir)/runtests.sh
wildtest.o: wildtest.c lib/wildmatch.c rsync.h
wildtest$(EXEEXT): wildtest.o
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ wildtest.o @BUILD_POPT@ $(LIBS)
# This does *not* depend on building or installing: you can use it to
# check a version installed from a binary or some other source tree,
# if you want.
installcheck: $(CHECK_PROGS)
POSIXLY_CORRECT=1 TOOLDIR=`pwd` rsync_bin="$(bindir)/rsync$(EXEEXT)" srcdir="$(srcdir)" $(srcdir)/runtests.sh
# TODO: Add 'dist' target; need to know which files will be included
# Run the SPLINT (Secure Programming Lint) tool. <www.splint.org>
.PHONY: splint
splint:
splint +unixlib +gnuextensions -weak rsync.c
rsync.dvi: doc/rsync.texinfo
texi2dvi -o $@ $<
rsync.ps: rsync.dvi
dvips -ta4 -o $@ $<
rsync.pdf: doc/rsync.texinfo
texi2dvi -o $@ --pdf $<
doxygen:
cd $(srcdir) && rm dox/html/* && doxygen
# for maintainers only
doxygen-upload:
rsync -avzv $(srcdir)/dox/html/ --delete \
samba.org:/home/httpd/html/rsync/doxygen/head/

65
NEWS Normal file
View File

@@ -0,0 +1,65 @@
NEWS for rsync 2.6.6 (28 Jul 2005)
Protocol: 29 (unchanged)
Changes since 2.6.5:
SECURITY FIXES:
- The zlib code was upgraded to version 1.2.3 in order to make it more
secure. While the widely-publicized security problem in zlib 1.2.2 did
not affect rsync, another security problem surfaced that affects rsync's
zlib 1.1.4.
BUG FIXES:
- The setting of flist->high in clean_flist() was wrong for an empty list.
This could cause flist_find() to crash in certain rare circumstances
(e.g. if just the right directory setup was around when --fuzzy was
combined with --link-dest).
- The outputting of hard-linked files when verbosity was > 1 was not right:
without -i it would output the name of each hard-linked file as though
it had been changed (it now outputs a "is hard linked" message for the
file); with -i it would output all dots for the unchanged attributes of
a hard-link (it now changes those dots to spaces, as is done for other
totally unchanged items).
- When backing up a changed symlink or device, get rid of any old backup
item so that we don't get an "already exists" error.
- A couple places that were comparing a local and a remote modification-
time were not honoring the --modify-window option.
- Fixed a bug where the 'p' (permissions) itemized-changes flag might get
set too often (if some non-significant mode bits differed).
- Fixed a really old, minor bug that could cause rsync to warn about being
unable to mkdir() a path that ends in "/." because it just created the
directory (required --relative, --no-implied-dirs, a source path that
ended in either a trailing slash or a trailing "/.", and a non-existing
destination dir to tickle the bug in a recent version).
ENHANCEMENTS:
- Made the "max verbosity" setting in the rsyncd.conf file settable on a
per-module basis (which now matches the documentation).
- The support/rrsync script has been upgraded to verify the args of options
that take args (instead of rejecting any such options). The script was
also changed to try to be more secure and to fix a problem in the parsing
of a pull operation that has multiple sources.
- Improved the documentation that explains the difference between a
normal daemon transfer and a daemon-over remote-shell transfer.
- Some of the diffs supplied in the patches dir were fixed and/or
improved.
BUILD CHANGES:
- Made configure define NOBODY_USER (currently hard-wired to "nobody") and
NOBODY_GROUP (set to either "nobody" or "nogroup" depending on what we
find in the /etc/group file).
- Added a test to the test suite, itemized.test, that tests the output of
-i (log-format w/%i) and some double-verbose messages.

1668
OLDNEWS Normal file
View File

File diff suppressed because it is too large Load Diff

120
README
View File

@@ -1,7 +1,7 @@
WHAT IS RSYNC?
--------------
rsync is a replacement for rcp that has many more features.
rsync is a replacement for scp/rcp that has many more features.
rsync uses the "rsync algorithm" which provides a very fast method for
bringing remote files into sync. It does this by sending just the
@@ -18,83 +18,25 @@ this package.
USAGE
-----
Basically you use rsync just like rcp, but rsync has many additional options.
Basically you use rsync just like rcp, but rsync has many additional
options. To get a complete list of supported options type
Here is a brief description of rsync usage:
Usage: rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST
or rsync [OPTION]... [USER@]HOST:SRC DEST
or rsync [OPTION]... SRC [SRC]... DEST
or rsync [OPTION]... [USER@]HOST::SRC [DEST]
or rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST
or rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]
SRC on single-colon remote HOST will be expanded by remote shell
SRC on server remote HOST may contain shell wildcards or multiple
sources separated by space as long as they have same top-level
Options
-v, --verbose increase verbosity
-q, --quiet decrease verbosity
-c, --checksum always checksum
-a, --archive archive mode
-r, --recursive recurse into directories
-R, --relative use relative path names
-b, --backup make backups (default ~ suffix)
--suffix=SUFFIX override backup suffix
-u, --update update only (don't overwrite newer files)
-l, --links preserve soft links
-L, --copy-links treat soft links like regular files
--copy-unsafe-links copy links outside the source tree
--safe-links ignore links outside the destination tree
-H, --hard-links preserve hard links
-p, --perms preserve permissions
-o, --owner preserve owner (root only)
-g, --group preserve group
-D, --devices preserve devices (root only)
-t, --times preserve times
-S, --sparse handle sparse files efficiently
-n, --dry-run show what would have been transferred
-W, --whole-file copy whole files, no incremental checks
-x, --one-file-system don't cross filesystem boundaries
-B, --block-size=SIZE checksum blocking size (default 700)
-e, --rsh=COMMAND specify rsh replacement
--rsync-path=PATH specify path to rsync on the remote machine
-C, --cvs-exclude auto ignore files in the same way CVS does
--delete delete files that don't exist on the sending side
--delete-excluded also delete excluded files on the receiving side
--partial keep partially transferred files
--force force deletion of directories even if not empty
--numeric-ids don't map uid/gid values by user/group name
--timeout=TIME set IO timeout in seconds
-I, --ignore-times don't exclude files that match length and time
--size-only only use file size when determining if a file should be transferred
-T --temp-dir=DIR create temporary files in directory DIR
--compare-dest=DIR also compare destination files relative to DIR
-z, --compress compress file data
--exclude=PATTERN exclude files matching PATTERN
--exclude-from=FILE exclude patterns listed in FILE
--include=PATTERN don't exclude files matching PATTERN
--include-from=FILE don't exclude patterns listed in FILE
--version print version number
--daemon run as a rsync daemon
--config=FILE specify alternate rsyncd.conf file
--port=PORT specify alternate rsyncd port number
--stats give some file transfer stats
--progress show progress during transfer
--log-format=FORMAT log file transfers using specified format
--password-file=FILE get password from FILE
-h, --help show this help screen
rsync --help
and see the manual for more information.
SETUP
-----
Rsync uses rsh or ssh for communication. It does not need to be setuid
and requires no special privileges for installation. It does not
require a inetd entry or a daemon. You must, however, have a working
rsh or ssh system. Using ssh is recommended for its security
features.
Rsync normally uses ssh or rsh for communication. It does not need to
be setuid and requires no special privileges for installation. You
must, however, have a working ssh or rsh system. Using ssh is
recommended for its security features.
Alternatively, rsync can run in `daemon' mode, listening on a socket.
This is generally used for public file distribution, although
authentication and access control are available.
To install rsync, first run the "configure" script. This will create a
Makefile and config.h appropriate for your system. Then type
@@ -125,8 +67,7 @@ There is a mailing list for the discussion of rsync and its
applications. It is open to anyone to join. I will announce new
versions on this list.
To join the mailing list send mail to listproc@samba.org with
no subject and a body of "subscribe rsync Your Name".
To join the mailing list see the web page at http://lists.samba.org/
To send mail to everyone on the list send it to rsync@samba.org
@@ -135,15 +76,21 @@ BUG REPORTS
-----------
If you have web access then please look at
http://rsync.samba.org/rsync/
This will give you access to the bug tracking system used by the
developers of rsync and will allow you to look at other bug reports or
submit a new bug report.
http://rsync.samba.org/
If you don't have web access then mail bug reports to
rsync-bugs@samba.org or (if you think it will be of interest to lots
of people) send it to rsync@samba.org
That page contains links to the current bug list, and information on
how to report a bug well. You might also like to try searching the
internet for the error message you've received, or looking in the
mailing list archives at
http://mail-archive.com/rsync@lists.samba.org/
To send a bug report, follow the instructions on the bug-tracking
page of the web site.
If you don't have web access, email your bug report to
rsync@lists.samba.org.
CVS TREE
@@ -153,10 +100,10 @@ If you want to get the very latest version of rsync direct from the
source code repository then you can use anonymous cvs. You will need a
recent version of cvs then use the following commands:
cvs -d :pserver:cvs@cvs.samba.org:/cvsroot login
cvs -d :pserver:cvs@pserver.samba.org:/cvsroot login
Password: cvs
cvs -d :pserver:cvs@cvs.samba.org:/cvsroot co rsync
cvs -d :pserver:cvs@pserver.samba.org:/cvsroot co rsync
Look at the cvs documentation for more details.
@@ -164,11 +111,12 @@ Look at the cvs documentation for more details.
COPYRIGHT
---------
Rsync was written by Andrew Tridgell and Paul Mackerras, and is
available under the Gnu Public License.
rsync was originally written by Andrew Tridgell and has been improved
by many developers around the world. rsync may be used, modified and
redistributed only under the terms of the GNU General Public License,
found in the file COPYING in this distribution, or at
tridge@samba.org
paulus@cs.anu.edu.au
http://www.fsf.org/licenses/gpl.html
AVAILABILITY

658
TODO Normal file
View File

@@ -0,0 +1,658 @@
-*- indented-text -*-
BUGS ---------------------------------------------------------------
Do not rely on having a group called "nobody"
FEATURES ------------------------------------------------------------
Use chroot only if supported
Allow supplementary groups in rsyncd.conf 2002/04/09
Handling IPv6 on old machines
Other IPv6 stuff:
Add ACL support 2001/12/02
Lazy directory creation
proxy authentication 2002/01/23
SOCKS 2002/01/23
FAT support
Allow forcing arbitrary permissions 2002/03/12
--diff david.e.sewell 2002/03/15
Add daemon --no-fork option
Create more granular verbosity jw 2003/05/15
DOCUMENTATION --------------------------------------------------------
Keep list of open issues and todos on the web site
Perhaps redo manual as SGML
LOGGING --------------------------------------------------------------
Memory accounting
Improve error messages
Better statistics: Rasmus 2002/03/08
Perhaps flush stdout like syslog
Log deamon sessions that just list modules
Log child death on signal
Log errors with function that reports process of origin
verbose output David Stein 2001/12/20
internationalization
DEVELOPMENT --------------------------------------------------------
Handling duplicate names
Use generic zlib 2002/02/25
TDB: 2002/03/12
Splint 2002/03/12
PERFORMANCE ----------------------------------------------------------
File list structure in memory
Traverse just one directory at a time
Allow skipping MD4 file_sum 2002/04/08
Accelerate MD4
TESTING --------------------------------------------------------------
Torture test
Cross-test versions 2001/08/22
Test on kernel source
Test large files
Create mutator program for testing
Create configure option to enable dangerous tests
If tests are skipped, say why.
Test daemon feature to disallow particular options.
Create pipe program for testing
Create test makefile target for some tests
RELATED PROJECTS -----------------------------------------------------
rsyncsh
http://rsync.samba.org/rsync-and-debian/
rsyncable gzip patch
rsyncsplit as alternative to real integration with gzip?
reverse rsync over HTTP Range
BUGS ---------------------------------------------------------------
Do not rely on having a group called "nobody"
http://www.linuxbase.org/spec/refspecs/LSB_1.1.0/gLSB/usernames.html
On Debian it's "nogroup"
-- --
FEATURES ------------------------------------------------------------
Use chroot only if supported
If the platform doesn't support it, then don't even try.
If running as non-root, then don't fail, just give a warning.
(There was a thread about this a while ago?)
http://lists.samba.org/pipermail/rsync/2001-August/thread.html
http://lists.samba.org/pipermail/rsync/2001-September/thread.html
-- --
Allow supplementary groups in rsyncd.conf 2002/04/09
Perhaps allow supplementary groups to be specified in rsyncd.conf;
then make the first one the primary gid and all the rest be
supplementary gids.
-- --
Handling IPv6 on old machines
The KAME IPv6 patch is nice in theory but has proved a bit of a
nightmare in practice. The basic idea of their patch is that rsync
is rewritten to use the new getaddrinfo()/getnameinfo() interface,
rather than gethostbyname()/gethostbyaddr() as in rsync 2.4.6.
Systems that don't have the new interface are handled by providing
our own implementation in lib/, which is selectively linked in.
The problem with this is that it is really hard to get right on
platforms that have a half-working implementation, so redefining
these functions clashes with system headers, and leaving them out
breaks. This affects at least OSF/1, RedHat 5, and Cobalt, which
are moderately improtant.
Perhaps the simplest solution would be to have two different files
implementing the same interface, and choose either the new or the
old API. This is probably necessary for systems that e.g. have
IPv6, but gethostbyaddr() can't handle it. The Linux manpage claims
this is currently the case.
In fact, our internal sockets interface (things like
open_socket_out(), etc) is much narrower than the getaddrinfo()
interface, and so probably simpler to get right. In addition, the
old code is known to work well on old machines.
We could drop the rather large lib/getaddrinfo files.
-- --
Other IPv6 stuff:
Implement suggestions from http://www.kame.net/newsletter/19980604/
and ftp://ftp.iij.ad.jp/pub/RFC/rfc2553.txt
If a host has multiple addresses, then listen try to connect to all
in order until we get through. (getaddrinfo may return multiple
addresses.) This is kind of implemented already.
Possibly also when starting as a server we may need to listen on
multiple passive addresses. This might be a bit harder, because we
may need to select on all of them. Hm.
-- --
Add ACL support 2001/12/02
Transfer ACLs. Need to think of a standard representation.
Probably better not to even try to convert between NT and POSIX.
Possibly can share some code with Samba.
NOTE: there is a patch that implements this in the "patches" subdir.
-- --
Lazy directory creation
With the current common --include '*/' --exclude '*' pattern, people
can end up with many empty directories. We might avoid this by
lazily creating such directories.
-- --
proxy authentication 2002/01/23
Allow RSYNC_PROXY to be http://user:pass@proxy.foo:3128/, and do
HTTP Basic Proxy-Authentication.
Multiple schemes are possible, up to and including the insanity that
is NTLM, but Basic probably covers most cases.
-- --
SOCKS 2002/01/23
Add --with-socks, and then perhaps a command-line option to put them
on or off. This might be more reliable than LD_PRELOAD hacks.
-- --
FAT support
rsync to a FAT partition on a Unix machine doesn't work very well at
the moment. I think we get errors about invalid filenames and
perhaps also trying to do atomic renames.
I guess the code to do this is currently #ifdef'd on Windows;
perhaps we ought to intelligently fall back to it on Unix too.
-- --
Allow forcing arbitrary permissions 2002/03/12
On 12 Mar 2002, Dave Dykstra <dwd@bell-labs.com> wrote:
> If we would add an option to do that functionality, I
> would vote for one that was more general which could mask
> off any set of permission bits and possibly add any set of
> bits. Perhaps a chmod-like syntax if it could be
> implemented simply.
I think that would be good too. For example, people uploading files
to a web server might like to say
rsync -avzP --chmod a+rX ./ sourcefrog.net:/home/www/sourcefrog/
Ideally the patch would implement as many of the gnu chmod semantics
as possible. I think the mode parser should be a separate function
that passes back something like (mask,set) description to the rest
of the program. For bonus points there would be a test case for the
parser.
Possibly also --chown
(Debian #23628)
NOTE: there is a patch that implements this in the "patches" subdir.
-- --
--diff david.e.sewell 2002/03/15
Allow people to specify the diff command. (Might want to use wdiff,
gnudiff, etc.)
Just diff the temporary file with the destination file, and delete
the tmp file rather than moving it into place.
Interaction with --partial.
Security interactions with daemon mode?
-- --
Add daemon --no-fork option
Very useful for debugging. Also good when running under a
daemon-monitoring process that tries to restart the service when the
parent exits.
-- --
Create more granular verbosity jw 2003/05/15
Control output with the --report option.
The option takes as a single argument (no whitespace) a
comma delimited lists of keywords.
This would separate debugging from "logging" as well as
fine grained selection of statistical reporting and what
actions are logged.
http://lists.samba.org/archive/rsync/2003-May/006059.html
-- --
DOCUMENTATION --------------------------------------------------------
Keep list of open issues and todos on the web site
-- --
Perhaps redo manual as SGML
The man page is getting rather large, and there is more information
that ought to be added.
TexInfo source is probably a dying format.
Linuxdoc looks like the most likely contender. I know DocBook is
favoured by some people, but it's so bloody verbose, even with emacs
support.
-- --
LOGGING --------------------------------------------------------------
Memory accounting
At exit, show how much memory was used for the file list, etc.
Also we do a wierd exponential-growth allocation in flist.c. I'm
not sure this makes sense with modern mallocs. At any rate it will
make us allocate a huge amount of memory for large file lists.
-- --
Improve error messages
If we hang or get SIGINT, then explain where we were up to. Perhaps
have a static buffer that contains the current function name, or
some kind of description of what we were trying to do. This is a
little easier on people than needing to run strace/truss.
"The dungeon collapses! You are killed." Rather than "unexpected
eof" give a message that is more detailed if possible and also more
helpful.
If we get an error writing to a socket, then we should perhaps
continue trying to read to see if an error message comes across
explaining why the socket is closed. I'm not sure if this would
work, but it would certainly make our messages more helpful.
What happens if a directory is missing -x attributes. Do we lose
our load? (Debian #28416) Probably fixed now, but a test case would
be good.
When running as a daemon, some errors should both be returned to the
user and logged. This will make interacting with a daemon less
cryptic.
-- --
Better statistics: Rasmus 2002/03/08
<Rasmus>
hey, how about an rsync option that just gives you the
summary without the list of files? And perhaps gives
more information like the number of new files, number
of changed, deleted, etc. ?
<mbp>
nice idea there is --stats but at the moment it's very
tridge-oriented rather than user-friendly it would be
nice to improve it that would also work well with
--dryrun
-- --
Perhaps flush stdout like syslog
Perhaps flush stdout after each filename, so that people trying to
monitor progress in a log file can do so more easily. See
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=48108
-- --
Log deamon sessions that just list modules
At the connections that just get a list of modules are not logged,
but they should be.
-- --
Log child death on signal
If a child of the rsync daemon dies with a signal, we should notice
that when we reap it and log a message.
-- --
Log errors with function that reports process of origin
Use a separate function for reporting errors; prefix it with
"rsync:" or "rsync(remote)", or perhaps even "rsync(local
generator): ".
-- --
verbose output David Stein 2001/12/20
At end of transfer, show how many files were or were not transferred
correctly.
-- --
internationalization
Change to using gettext(). Probably need to ship this for platforms
that don't have it.
Solicit translations.
Does anyone care? Before we bother modifying the code, we ought to
get the manual translated first, because that's possibly more useful
and at any rate demonstrates desire.
-- --
DEVELOPMENT --------------------------------------------------------
Handling duplicate names
Some folks would like rsync to be deterministic in how it handles
duplicate names that come from mering multiple source directories
into a single destination directory; e.g. the last name wins. We
could do this by switching our sort algorithm to one that will
guarantee that the names won't be reordered. Alternately, we could
assign an ever-increasing number to each item as we insert it into
the list and then make sure that we leave the largest number when
cleaning the file list (see clean_flist()). Another solution would
be to add a hash table, and thus never put any duplicate names into
the file list (and bump the protocol to handle this).
-- --
Use generic zlib 2002/02/25
Perhaps don't use our own zlib.
Advantages:
- will automatically be up to date with bugfixes in zlib
- can leave it out for small rsync on e.g. recovery disks
- can use a shared library
- avoids people breaking rsync by trying to do this themselves and
messing up
Should we ship zlib for systems that don't have it, or require
people to install it separately?
Apparently this will make us incompatible with versions of rsync
that use the patched version of rsync. Probably the simplest way to
do this is to just disable gzip (with a warning) when talking to old
versions.
-- --
TDB: 2002/03/12
Rather than storing the file list in memory, store it in a TDB.
This *might* make memory usage lower while building the file list.
Hashtable lookup will mean files are not transmitted in order,
though... hm.
This would neatly eliminate one of the major post-fork shared data
structures.
-- --
Splint 2002/03/12
Build rsync with SPLINT to try to find security holes. Add
annotations as necessary. Keep track of the number of warnings
found initially, and see how many of them are real bugs, or real
security bugs. Knowing the percentage of likely hits would be
really interesting for other projects.
-- --
PERFORMANCE ----------------------------------------------------------
File list structure in memory
Rather than one big array, perhaps have a tree in memory mirroring
the directory tree.
This might make sorting much faster! (I'm not sure it's a big CPU
problem, mind you.)
It might also reduce memory use in storing repeated directory names
-- again I'm not sure this is a problem.
-- --
Traverse just one directory at a time
Traverse just one directory at a time. Tridge says it's possible.
At the moment rsync reads the whole file list into memory at the
start, which makes us use a lot of memory and also not pipeline
network access as much as we could.
-- --
Allow skipping MD4 file_sum 2002/04/08
If we're doing a local transfer, or using -W, then perhaps don't
send the file checksum. If we're doing a local transfer, then
calculating MD4 checksums uses 90% of CPU and is unlikely to be
useful.
We should not allow it to be disabled separately from -W, though
as it is the only thing that lets us know when the rsync algorithm
got out of sync and messed the file up (i.e. if the basis file
changed between checksum generation and reception).
-- --
Accelerate MD4
Perhaps borrow an assembler MD4 from someone?
Make sure we call MD4 with properly-sized blocks whenever possible
to avoid copying into the residue region?
-- --
TESTING --------------------------------------------------------------
Torture test
Something that just keeps running rsync continuously over a data set
likely to generate problems.
-- --
Cross-test versions 2001/08/22
Part of the regression suite should be making sure that we
don't break backwards compatibility: old clients vs new
servers and so on. Ideally we would test both up and down
from the current release to all old versions.
Run current rsync versions against significant past releases.
We might need to omit broken old versions, or versions in which
particular functionality is broken
It might be sufficient to test downloads from well-known public
rsync servers running different versions of rsync. This will give
some testing and also be the most common case for having different
versions and not being able to upgrade.
The new --protocol option may help in this.
-- --
Test on kernel source
Download all versions of kernel; unpack, sync between them. Also
sync between uncompressed tarballs. Compare directories after
transfer.
Use local mode; ssh; daemon; --whole-file and --no-whole-file.
Use awk to pull out the 'speedup' number for each transfer. Make
sure it is >= x.
-- --
Test large files
Sparse and non-sparse
-- --
Create mutator program for testing
Insert bytes, delete bytes, swap blocks, ...
-- --
Create configure option to enable dangerous tests
-- --
If tests are skipped, say why.
-- --
Test daemon feature to disallow particular options.
-- --
Create pipe program for testing
Create pipe program that makes slow/jerky connections for
testing Versions of read() and write() that corrupt the
stream, or abruptly fail
-- --
Create test makefile target for some tests
Separate makefile target to run rough tests -- or perhaps
just run them every time?
-- --
RELATED PROJECTS -----------------------------------------------------
rsyncsh
Write a small emulation of interactive ftp as a Pythonn program
that calls rsync. Commands such as "cd", "ls", "ls *.c" etc map
fairly directly into rsync commands: it just needs to remember the
current host, directory and so on. We can probably even do
completion of remote filenames.
-- --
http://rsync.samba.org/rsync-and-debian/
-- --
rsyncable gzip patch
Exhaustive, tortuous testing
Cleanups?
-- --
rsyncsplit as alternative to real integration with gzip?
-- --
reverse rsync over HTTP Range
Goswin Brederlow suggested this on Debian; I think tridge and I
talked about it previous in relation to rproxy.
Addendum: It looks like someone is working on a version of this:
http://zsync.moria.org.uk/
-- --

247
access.c
View File

@@ -26,57 +26,192 @@
static int match_hostname(char *host, char *tok)
{
if (!host || !*host) return 0;
return (fnmatch(tok, host, 0) == 0);
if (!host || !*host)
return 0;
return wildmatch(tok, host);
}
static int match_binary(char *b1, char *b2, char *mask, int addrlen)
{
int i;
for (i = 0; i < addrlen; i++) {
if ((b1[i] ^ b2[i]) & mask[i])
return 0;
}
return 1;
}
static void make_mask(char *mask, int plen, int addrlen)
{
int w, b;
w = plen >> 3;
b = plen & 0x7;
if (w)
memset(mask, 0xff, w);
if (w < addrlen)
mask[w] = 0xff & (0xff<<(8-b));
if (w+1 < addrlen)
memset(mask+w+1, 0, addrlen-w-1);
return;
}
static int match_address(char *addr, char *tok)
{
char *p;
unsigned long a, t, mask = (unsigned long)~0;
struct addrinfo hints, *resa, *rest;
int gai;
int ret = 0;
int addrlen = 0;
#ifdef HAVE_STRTOL
long int bits;
#else
int bits;
#endif
char mask[16];
char *a = NULL, *t = NULL;
unsigned int len;
if (!addr || !*addr) return 0;
if (!isdigit(tok[0])) return 0;
if (!addr || !*addr)
return 0;
p = strchr(tok,'/');
if (p) *p = 0;
a = inet_addr(addr);
t = inet_addr(tok);
if (p) {
*p = '/';
}
*p = '\0';
len = p - tok;
} else
len = strlen(tok);
if (t == INADDR_NONE) {
rprintf(FERROR,"malformed address %s\n", tok);
/* Fail quietly if tok is a hostname (not an address) */
if (strspn(tok, ".0123456789") != len
#ifdef INET6
&& strchr(tok, ':') == NULL
#endif
) {
if (p)
*p = '/';
return 0;
}
a = ntohl(a);
t = ntohl(t);
memset(&hints, 0, sizeof(hints));
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
#ifdef AI_NUMERICHOST
hints.ai_flags = AI_NUMERICHOST;
#endif
if (p) {
if (strchr(p+1,'.')) {
mask = inet_addr(p+1);
if (mask == INADDR_NONE) {
rprintf(FERROR,"malformed mask in %s\n", tok);
return 0;
}
mask = ntohl(mask);
} else {
int bits = atoi(p+1);
if (bits <= 0 || bits > 32) {
rprintf(FERROR,"malformed mask in %s\n", tok);
return 0;
}
mask &= (mask << (32-bits));
}
if (getaddrinfo(addr, NULL, &hints, &resa) != 0) {
if (p)
*p = '/';
return 0;
}
return ((a&mask) == (t&mask));
gai = getaddrinfo(tok, NULL, &hints, &rest);
if (p)
*p++ = '/';
if (gai != 0) {
rprintf(FLOG, "error matching address %s: %s\n",
tok, gai_strerror(gai));
freeaddrinfo(resa);
return 0;
}
if (rest->ai_family != resa->ai_family) {
ret = 0;
goto out;
}
switch(resa->ai_family) {
case PF_INET:
a = (char *)&((struct sockaddr_in *)resa->ai_addr)->sin_addr;
t = (char *)&((struct sockaddr_in *)rest->ai_addr)->sin_addr;
addrlen = 4;
break;
#ifdef INET6
case PF_INET6:
{
struct sockaddr_in6 *sin6a, *sin6t;
sin6a = (struct sockaddr_in6 *)resa->ai_addr;
sin6t = (struct sockaddr_in6 *)rest->ai_addr;
a = (char *)&sin6a->sin6_addr;
t = (char *)&sin6t->sin6_addr;
addrlen = 16;
#ifdef HAVE_SOCKADDR_IN6_SCOPE_ID
if (sin6t->sin6_scope_id &&
sin6a->sin6_scope_id != sin6t->sin6_scope_id) {
ret = 0;
goto out;
}
#endif
break;
}
#endif
default:
rprintf(FLOG, "unknown family %u\n", rest->ai_family);
ret = 0;
goto out;
}
bits = -1;
if (p) {
if (inet_pton(resa->ai_addr->sa_family, p, mask) <= 0) {
#ifdef HAVE_STRTOL
char *ep = NULL;
#else
unsigned char *pp;
#endif
#ifdef HAVE_STRTOL
bits = strtol(p, &ep, 10);
if (!*p || *ep) {
rprintf(FLOG, "malformed mask in %s\n", tok);
ret = 0;
goto out;
}
#else
for (pp = (unsigned char *)p; *pp; pp++) {
if (!isascii(*pp) || !isdigit(*pp)) {
rprintf(FLOG, "malformed mask in %s\n", tok);
ret = 0;
goto out;
}
}
bits = atoi(p);
#endif
if (bits == 0) {
ret = 1;
goto out;
}
if (bits < 0 || bits > (addrlen << 3)) {
rprintf(FLOG, "malformed mask in %s\n", tok);
ret = 0;
goto out;
}
}
} else {
bits = 128;
}
if (bits >= 0)
make_mask(mask, bits, addrlen);
ret = match_binary(a, t, mask, addrlen);
out:
freeaddrinfo(resa);
freeaddrinfo(rest);
return ret;
}
static int access_match(char *list, char *addr, char *host)
@@ -84,12 +219,14 @@ static int access_match(char *list, char *addr, char *host)
char *tok;
char *list2 = strdup(list);
if (!list2) out_of_memory("access_match");
if (!list2)
out_of_memory("access_match");
strlower(list2);
if (host) strlower(host);
if (host)
strlower(host);
for (tok=strtok(list2," ,\t"); tok; tok=strtok(NULL," ,\t")) {
for (tok = strtok(list2, " ,\t"); tok; tok = strtok(NULL, " ,\t")) {
if (match_hostname(host, tok) || match_address(addr, tok)) {
free(list2);
return 1;
@@ -102,29 +239,25 @@ static int access_match(char *list, char *addr, char *host)
int allow_access(char *addr, char *host, char *allow_list, char *deny_list)
{
/* if theres no deny list and no allow list then allow access */
if ((!deny_list || !*deny_list) && (!allow_list || !*allow_list))
return 1;
if (allow_list && !*allow_list)
allow_list = NULL;
if (deny_list && !*deny_list)
deny_list = NULL;
/* if there is an allow list but no deny list then allow only hosts
on the allow list */
if (!deny_list || !*deny_list)
return(access_match(allow_list, addr, host));
/* If we match an allow-list item, we always allow access. */
if (allow_list) {
if (access_match(allow_list, addr, host))
return 1;
/* For an allow-list w/o a deny-list, disallow non-matches. */
if (!deny_list)
return 0;
}
/* if theres a deny list but no allow list then allow
all hosts not on the deny list */
if (!allow_list || !*allow_list)
return(!access_match(deny_list,addr,host));
/* if there are both type of list then allow all hosts on the
allow list */
if (access_match(allow_list,addr,host))
return 1;
/* if there are both type of list and it's not on the allow then
allow it if its not on the deny */
if (access_match(deny_list,addr,host))
/* If we match a deny-list item (and got past any allow-list
* items), we always disallow access. */
if (deny_list && access_match(deny_list, addr, host))
return 0;
/* Allow all other access. */
return 1;
}

View File

@@ -1,12 +0,0 @@
#undef HAVE_BROKEN_READDIR
#undef HAVE_ERRNO_DECL
#undef HAVE_LONGLONG
#undef HAVE_OFF64_T
#undef HAVE_REMSH
#undef HAVE_UNSIGNED_CHAR
#undef HAVE_UTIMBUF
#undef ino_t
#undef HAVE_CONNECT
#undef HAVE_SHORT_INO_T
#undef HAVE_GETOPT_LONG
#undef REPLACE_INET_NTOA

48
aclocal.m4 vendored
View File

@@ -21,3 +21,51 @@ AC_DEFUN(AC_VALIDATE_CACHE_SYSTEM_TYPE, [
ac_cv_build_system_type="$build"
ac_cv_target_system_type="$target"
])
dnl Check for socklen_t: historically on BSD it is an int, and in
dnl POSIX 1g it is a type of its own, but some platforms use different
dnl types for the argument to getsockopt, getpeername, etc. So we
dnl have to test to find something that will work.
dnl This is no good, because passing the wrong pointer on C compilers is
dnl likely to only generate a warning, not an error. We don't call this at
dnl the moment.
AC_DEFUN([TYPE_SOCKLEN_T],
[
AC_CHECK_TYPE([socklen_t], ,[
AC_MSG_CHECKING([for socklen_t equivalent])
AC_CACHE_VAL([rsync_cv_socklen_t_equiv],
[
# Systems have either "struct sockaddr *" or
# "void *" as the second argument to getpeername
rsync_cv_socklen_t_equiv=
for arg2 in "struct sockaddr" void; do
for t in int size_t unsigned long "unsigned long"; do
AC_TRY_COMPILE([
#include <sys/types.h>
#include <sys/socket.h>
int getpeername (int, $arg2 *, $t *);
],[
$t len;
getpeername(0,0,&len);
],[
rsync_cv_socklen_t_equiv="$t"
break
])
done
done
if test "x$rsync_cv_socklen_t_equiv" = x; then
AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
fi
])
AC_MSG_RESULT($rsync_cv_socklen_t_equiv)
AC_DEFINE_UNQUOTED(socklen_t, $rsync_cv_socklen_t_equiv,
[type to use in place of socklen_t if not defined])],
[#include <sys/types.h>
#include <sys/socket.h>])
])

View File

@@ -1,16 +1,17 @@
/*
Copyright (C) Andrew Tridgell 1998
/* -*- c-file-style: "linux"; -*-
Copyright (C) 1998-2000 by Andrew Tridgell
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -19,11 +20,14 @@
/* support rsync authentication */
#include "rsync.h"
extern char *password_file;
extern int am_root;
/***************************************************************************
encode a buffer using base64 - simple and slow algorithm. null terminates
the result.
***************************************************************************/
static void base64_encode(char *buf, int len, char *out)
void base64_encode(char *buf, int len, char *out)
{
char *b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
int bit_offset, byte_offset, idx, i;
@@ -32,7 +36,7 @@ static void base64_encode(char *buf, int len, char *out)
memset(out, 0, bytes+1);
for (i=0;i<bytes;i++) {
for (i = 0; i < bytes; i++) {
byte_offset = (i*6)/8;
bit_offset = (i*6)%8;
if (bit_offset < 3) {
@@ -47,240 +51,264 @@ static void base64_encode(char *buf, int len, char *out)
}
}
/* create a 16 byte challenge buffer */
/* Generate a challenge buffer and return it base64-encoded. */
static void gen_challenge(char *addr, char *challenge)
{
char input[32];
char md4_out[MD4_SUM_LENGTH];
struct timeval tv;
memset(input, 0, sizeof(input));
memset(input, 0, sizeof input);
strlcpy((char *)input, addr, 17);
gettimeofday(&tv, NULL);
sys_gettimeofday(&tv);
SIVAL(input, 16, tv.tv_sec);
SIVAL(input, 20, tv.tv_usec);
SIVAL(input, 24, getpid());
sum_init();
sum_update(input, sizeof(input));
sum_end(challenge);
sum_init(0);
sum_update(input, sizeof input);
sum_end(md4_out);
base64_encode(md4_out, MD4_SUM_LENGTH, challenge);
}
/* return the secret for a user from the sercret file. maximum length
is len. null terminate it */
/* Return the secret for a user from the secret file, null terminated.
* Maximum length is len (not counting the null). */
static int get_secret(int module, char *user, char *secret, int len)
{
char *fname = lp_secrets_file(module);
int fd, found=0;
char line[MAXPATHLEN];
char *p, *pass=NULL;
STRUCT_STAT st;
int ok = 1;
extern int am_root;
int fd, ok = 1;
char ch, *p;
if (!fname || !*fname) return 0;
if (!fname || !*fname)
return 0;
fd = open(fname,O_RDONLY);
if (fd == -1) return 0;
if ((fd = open(fname, O_RDONLY)) < 0)
return 0;
if (do_stat(fname, &st) == -1) {
rprintf(FERROR,"stat(%s) : %s\n", fname, strerror(errno));
rsyserr(FLOG, errno, "stat(%s)", safe_fname(fname));
ok = 0;
} else if (lp_strict_modes(module)) {
if ((st.st_mode & 06) != 0) {
rprintf(FERROR,"secrets file must not be other-accessible (see strict modes option)\n");
rprintf(FLOG, "secrets file must not be other-accessible (see strict modes option)\n");
ok = 0;
} else if (am_root && (st.st_uid != 0)) {
rprintf(FERROR,"secrets file must be owned by root when running as root (see strict modes)\n");
rprintf(FLOG, "secrets file must be owned by root when running as root (see strict modes)\n");
ok = 0;
}
}
if (!ok) {
rprintf(FERROR,"continuing without secrets file\n");
rprintf(FLOG, "continuing without secrets file\n");
close(fd);
return 0;
}
while (!found) {
int i = 0;
memset(line, 0, sizeof(line));
while (i<(sizeof(line)-1)) {
if (read(fd, &line[i], 1) != 1) {
memset(line, 0, sizeof(line));
close(fd);
return 0;
}
if (line[i] == '\r') continue;
if (line[i] == '\n') break;
i++;
}
line[i] = 0;
if (line[0] == '#') continue;
p = strchr(line,':');
if (!p) continue;
*p = 0;
if (strcmp(user, line)) continue;
pass = p+1;
found = 1;
if (*user == '#') {
/* Reject attempt to match a comment. */
close(fd);
return 0;
}
close(fd);
if (!found) return 0;
/* Try to find a line that starts with the user name and a ':'. */
p = user;
while (1) {
if (read(fd, &ch, 1) != 1) {
close(fd);
return 0;
}
if (ch == '\n')
p = user;
else if (p) {
if (*p == ch)
p++;
else if (!*p && ch == ':')
break;
else
p = NULL;
}
}
/* Slurp the secret into the "secret" buffer. */
p = secret;
while (len > 0) {
if (read(fd, p, 1) != 1 || *p == '\n')
break;
if (*p == '\r')
continue;
p++;
len--;
}
*p = '\0';
close(fd);
strlcpy(secret, pass, len);
return 1;
}
static char *getpassf(char *filename)
{
char buffer[100];
int len=0;
int fd=0;
STRUCT_STAT st;
int ok = 1;
extern int am_root;
char *envpw=getenv("RSYNC_PASSWORD");
char buffer[512], *p;
int fd, n, ok = 1;
char *envpw = getenv("RSYNC_PASSWORD");
if (!filename) return NULL;
if (!filename)
return NULL;
if ( (fd=open(filename,O_RDONLY)) == -1) {
rprintf(FERROR,"could not open password file \"%s\"\n",filename);
if (envpw) rprintf(FERROR,"falling back to RSYNC_PASSWORD environment variable.\n");
if ((fd = open(filename,O_RDONLY)) < 0) {
rsyserr(FERROR, errno, "could not open password file \"%s\"",
safe_fname(filename));
if (envpw)
rprintf(FERROR, "falling back to RSYNC_PASSWORD environment variable.\n");
return NULL;
}
if (do_stat(filename, &st) == -1) {
rprintf(FERROR,"stat(%s) : %s\n", filename, strerror(errno));
rsyserr(FERROR, errno, "stat(%s)", safe_fname(filename));
ok = 0;
} else if ((st.st_mode & 06) != 0) {
rprintf(FERROR,"password file must not be other-accessible\n");
ok = 0;
} else if (am_root && (st.st_uid != 0)) {
} else if (am_root && st.st_uid != 0) {
rprintf(FERROR,"password file must be owned by root when running as root\n");
ok = 0;
}
if (!ok) {
rprintf(FERROR,"continuing without password file\n");
if (envpw) rprintf(FERROR,"using RSYNC_PASSWORD environment variable.\n");
if (envpw)
rprintf(FERROR, "using RSYNC_PASSWORD environment variable.\n");
close(fd);
return NULL;
}
if (envpw) rprintf(FERROR,"RSYNC_PASSWORD environment variable ignored\n");
if (envpw)
rprintf(FERROR, "RSYNC_PASSWORD environment variable ignored\n");
buffer[sizeof(buffer)-1]='\0';
if ( (len=read(fd,buffer,sizeof(buffer)-1)) > 0)
{
char *p = strtok(buffer,"\n\r");
close(fd);
if (p) p = strdup(p);
return p;
}
n = read(fd, buffer, sizeof buffer - 1);
close(fd);
if (n > 0) {
buffer[n] = '\0';
if ((p = strtok(buffer, "\n\r")) != NULL)
return strdup(p);
}
return NULL;
}
/* generate a 16 byte hash from a password and challenge */
/* Generate an MD4 hash created from the combination of the password
* and the challenge string and return it base64-encoded. */
static void generate_hash(char *in, char *challenge, char *out)
{
char buf[16];
char buf[MD4_SUM_LENGTH];
sum_init();
sum_init(0);
sum_update(in, strlen(in));
sum_update(challenge, strlen(challenge));
sum_end(buf);
base64_encode(buf, 16, out);
base64_encode(buf, MD4_SUM_LENGTH, out);
}
/* possible negotiate authentication with the client. Use "leader" to
start off the auth if necessary
return NULL if authentication failed
return "" if anonymous access
otherwise return username
*/
char *auth_server(int fd, int module, char *addr, char *leader)
/* Possibly negotiate authentication with the client. Use "leader" to
* start off the auth if necessary.
*
* Return NULL if authentication failed. Return "" if anonymous access.
* Otherwise return username.
*/
char *auth_server(int f_in, int f_out, int module, char *host, char *addr,
char *leader)
{
char *users = lp_auth_users(module);
char challenge[16];
char b64_challenge[30];
char challenge[MD4_SUM_LENGTH*2];
char line[MAXPATHLEN];
static char user[100];
char secret[100];
char pass[30];
char pass2[30];
char *tok;
char secret[512];
char pass2[MD4_SUM_LENGTH*2];
char *tok, *pass;
/* if no auth list then allow anyone in! */
if (!users || !*users) return "";
if (!users || !*users)
return "";
gen_challenge(addr, challenge);
base64_encode(challenge, 16, b64_challenge);
io_printf(fd,"%s%s\n", leader, b64_challenge);
io_printf(f_out, "%s%s\n", leader, challenge);
if (!read_line(fd, line, sizeof(line)-1)) {
if (!read_line(f_in, line, sizeof line - 1)
|| (pass = strchr(line, ' ')) == NULL) {
rprintf(FLOG, "auth failed on module %s from %s (%s): "
"invalid challenge response\n",
lp_name(module), host, addr);
return NULL;
}
*pass++ = '\0';
memset(user, 0, sizeof(user));
memset(pass, 0, sizeof(pass));
if (!(users = strdup(users)))
out_of_memory("auth_server");
if (sscanf(line,"%99s %29s", user, pass) != 2) {
return NULL;
}
users = strdup(users);
if (!users) return NULL;
for (tok=strtok(users," ,\t"); tok; tok = strtok(NULL," ,\t")) {
if (strcmp(tok, user) == 0) break;
for (tok = strtok(users, " ,\t"); tok; tok = strtok(NULL, " ,\t")) {
if (wildmatch(tok, line))
break;
}
free(users);
if (!tok) {
return NULL;
}
memset(secret, 0, sizeof(secret));
if (!get_secret(module, user, secret, sizeof(secret)-1)) {
memset(secret, 0, sizeof(secret));
rprintf(FLOG, "auth failed on module %s from %s (%s): "
"unauthorized user\n",
lp_name(module), host, addr);
return NULL;
}
generate_hash(secret, b64_challenge, pass2);
memset(secret, 0, sizeof(secret));
if (strcmp(pass, pass2) == 0)
return user;
memset(secret, 0, sizeof secret);
if (!get_secret(module, line, secret, sizeof secret - 1)) {
memset(secret, 0, sizeof secret);
rprintf(FLOG, "auth failed on module %s from %s (%s): "
"missing secret for user \"%s\"\n",
lp_name(module), host, addr, line);
return NULL;
}
return NULL;
generate_hash(secret, challenge, pass2);
memset(secret, 0, sizeof secret);
if (strcmp(pass, pass2) != 0) {
rprintf(FLOG, "auth failed on module %s from %s (%s): "
"password mismatch\n",
lp_name(module), host, addr);
return NULL;
}
return strdup(line);
}
void auth_client(int fd, char *user, char *challenge)
{
char *pass;
char pass2[30];
extern char *password_file;
char pass2[MD4_SUM_LENGTH*2];
if (!user || !*user) return;
if (!user || !*user)
user = "nobody";
if (!(pass=getpassf(password_file)) && !(pass=getenv("RSYNC_PASSWORD"))) {
if (!(pass = getpassf(password_file))
&& !(pass = getenv("RSYNC_PASSWORD"))) {
/* XXX: cyeoh says that getpass is deprecated, because
* it may return a truncated password on some systems,
* and it is not in the LSB.
*
* Andrew Klein says that getpassphrase() is present
* on Solaris and reads up to 256 characters.
*
* OpenBSD has a readpassphrase() that might be more suitable.
*/
pass = getpass("Password: ");
}
if (!pass || !*pass) {
if (!pass)
pass = "";
}
generate_hash(pass, challenge, pass2);
io_printf(fd, "%s %s\n", user, pass2);
}

280
backup.c Normal file
View File

@@ -0,0 +1,280 @@
/*
Copyright (C) Andrew Tridgell 1999
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* backup handling code */
#include "rsync.h"
extern int verbose;
extern int backup_suffix_len;
extern int backup_dir_len;
extern unsigned int backup_dir_remainder;
extern char backup_dir_buf[MAXPATHLEN];
extern char *backup_suffix;
extern char *backup_dir;
extern int am_root;
extern int preserve_devices;
extern int preserve_links;
extern int preserve_hard_links;
extern int orig_umask;
extern int safe_symlinks;
/* make a complete pathname for backup file */
char *get_backup_name(char *fname)
{
if (backup_dir) {
if (stringjoin(backup_dir_buf + backup_dir_len, backup_dir_remainder,
fname, backup_suffix, NULL) < backup_dir_remainder)
return backup_dir_buf;
} else {
if (stringjoin(backup_dir_buf, MAXPATHLEN,
fname, backup_suffix, NULL) < MAXPATHLEN)
return backup_dir_buf;
}
rprintf(FERROR, "backup filename too long\n");
return NULL;
}
/* simple backup creates a backup with a suffix in the same directory */
static int make_simple_backup(char *fname)
{
int rename_errno;
char *fnamebak = get_backup_name(fname);
if (!fnamebak)
return 0;
while (1) {
if (do_rename(fname, fnamebak) == 0) {
if (verbose > 1) {
rprintf(FINFO, "backed up %s to %s\n",
safe_fname(fname),
safe_fname(fnamebak));
}
break;
}
/* cygwin (at least version b19) reports EINVAL */
if (errno == ENOENT || errno == EINVAL)
break;
rename_errno = errno;
if (errno == EISDIR && do_rmdir(fnamebak) == 0)
continue;
if (errno == ENOTDIR && do_unlink(fnamebak) == 0)
continue;
rsyserr(FERROR, rename_errno, "rename %s to backup %s",
safe_fname(fname), safe_fname(fnamebak));
errno = rename_errno;
return 0;
}
return 1;
}
/****************************************************************************
Create a directory given an absolute path, perms based upon another directory
path
****************************************************************************/
static int make_bak_dir(char *fullpath)
{
STRUCT_STAT st;
char *rel = fullpath + backup_dir_len;
char *end = rel + strlen(rel);
char *p = end;
while (strncmp(fullpath, "./", 2) == 0)
fullpath += 2;
/* Try to find an existing dir, starting from the deepest dir. */
while (1) {
if (--p == fullpath) {
p += strlen(p);
goto failure;
}
if (*p == '/') {
*p = '\0';
if (do_mkdir(fullpath, 0777 & ~orig_umask) == 0)
break;
if (errno != ENOENT) {
rsyserr(FERROR, errno,
"make_bak_dir mkdir %s failed",
full_fname(fullpath));
goto failure;
}
}
}
/* Make all the dirs that we didn't find on the way here. */
while (1) {
if (p >= rel) {
/* Try to transfer the directory settings of the
* actual dir that the files are coming from. */
if (do_stat(rel, &st) < 0) {
rsyserr(FERROR, errno,
"make_bak_dir stat %s failed",
full_fname(rel));
} else {
do_lchown(fullpath, st.st_uid, st.st_gid);
do_chmod(fullpath, st.st_mode);
}
}
*p = '/';
p += strlen(p);
if (p == end)
break;
if (do_mkdir(fullpath, 0777 & ~orig_umask) < 0) {
rsyserr(FERROR, errno, "make_bak_dir mkdir %s failed",
full_fname(fullpath));
goto failure;
}
}
return 0;
failure:
while (p != end) {
*p = '/';
p += strlen(p);
}
return -1;
}
/* robustly move a file, creating new directory structures if necessary */
static int robust_move(char *src, char *dst)
{
if (robust_rename(src, dst, 0755) < 0 && (errno != ENOENT
|| make_bak_dir(dst) < 0 || robust_rename(src, dst, 0755) < 0))
return -1;
return 0;
}
/* If we have a --backup-dir, then we get here from make_backup().
* We will move the file to be deleted into a parallel directory tree. */
static int keep_backup(char *fname)
{
STRUCT_STAT st;
struct file_struct *file;
char *buf;
int kept = 0;
int ret_code;
/* return if no file to keep */
if (do_lstat(fname, &st) < 0)
return 1;
if (!(file = make_file(fname, NULL, NO_FILTERS)))
return 1; /* the file could have disappeared */
if (!(buf = get_backup_name(fname)))
return 0;
/* Check to see if this is a device file, or link */
if (IS_DEVICE(file->mode) && am_root && preserve_devices) {
do_unlink(buf);
if (do_mknod(buf, file->mode, file->u.rdev) < 0
&& (errno != ENOENT || make_bak_dir(buf) < 0
|| do_mknod(buf, file->mode, file->u.rdev) < 0)) {
rsyserr(FERROR, errno, "mknod %s failed",
full_fname(buf));
} else if (verbose > 2) {
rprintf(FINFO, "make_backup: DEVICE %s successful.\n",
safe_fname(fname));
}
kept = 1;
do_unlink(fname);
}
if (!kept && S_ISDIR(file->mode)) {
/* make an empty directory */
if (do_mkdir(buf, file->mode) < 0
&& (errno != ENOENT || make_bak_dir(buf) < 0
|| do_mkdir(buf, file->mode) < 0)) {
rsyserr(FINFO, errno, "mkdir %s failed",
full_fname(buf));
}
ret_code = do_rmdir(fname);
if (verbose > 2) {
rprintf(FINFO, "make_backup: RMDIR %s returns %i\n",
full_fname(fname), ret_code);
}
kept = 1;
}
#ifdef SUPPORT_LINKS
if (!kept && preserve_links && S_ISLNK(file->mode)) {
if (safe_symlinks && unsafe_symlink(file->u.link, buf)) {
if (verbose) {
rprintf(FINFO, "ignoring unsafe symlink %s -> %s\n",
full_fname(buf), file->u.link);
}
kept = 1;
} else {
do_unlink(buf);
if (do_symlink(file->u.link, buf) < 0
&& (errno != ENOENT || make_bak_dir(buf) < 0
|| do_symlink(file->u.link, buf) < 0)) {
rsyserr(FERROR, errno, "link %s -> \"%s\"",
full_fname(buf),
safe_fname(file->u.link));
}
do_unlink(fname);
kept = 1;
}
}
#endif
if (!kept && !S_ISREG(file->mode)) {
rprintf(FINFO, "make_bak: skipping non-regular file %s\n",
safe_fname(fname));
return 1;
}
/* move to keep tree if a file */
if (!kept) {
if (robust_move(fname, buf) != 0) {
rsyserr(FERROR, errno, "keep_backup failed: %s -> \"%s\"",
full_fname(fname), safe_fname(buf));
} else if (st.st_nlink > 1) {
/* If someone has hard-linked the file into the backup
* dir, rename() might return success but do nothing! */
robust_unlink(fname); /* Just in case... */
}
}
set_perms(buf, file, NULL, 0);
free(file);
if (verbose > 1) {
rprintf(FINFO, "backed up %s to %s\n",
safe_fname(fname), safe_fname(buf));
}
return 1;
}
/* main backup switch routine */
int make_backup(char *fname)
{
if (backup_dir)
return keep_backup(fname);
return make_simple_backup(fname);
}

235
batch.c Normal file
View File

@@ -0,0 +1,235 @@
/* -*- c-file-style: "linux" -*-
Weiss 1/1999
Batch utilities for rsync.
*/
#include "rsync.h"
#include <time.h>
extern int am_sender;
extern int eol_nulls;
extern int recurse;
extern int xfer_dirs;
extern int preserve_links;
extern int preserve_hard_links;
extern int preserve_devices;
extern int preserve_uid;
extern int preserve_gid;
extern int always_checksum;
extern int do_compression;
extern int protocol_version;
extern char *batch_name;
extern struct filter_list_struct filter_list;
static int *flag_ptr[] = {
&recurse, /* 0 */
&preserve_uid, /* 1 */
&preserve_gid, /* 2 */
&preserve_links, /* 3 */
&preserve_devices, /* 4 */
&preserve_hard_links, /* 5 */
&always_checksum, /* 6 */
&xfer_dirs, /* 7 (protocol 29) */
&do_compression, /* 8 (protocol 29) */
NULL
};
static char *flag_name[] = {
"--recurse (-r)",
"--owner (-o)",
"--group (-g)",
"--links (-l)",
"--devices (-D)",
"--hard-links (-H)",
"--checksum (-c)",
"--dirs (-d)",
"--compress (-z)",
NULL
};
void write_stream_flags(int fd)
{
int i, flags;
/* Start the batch file with a bitmap of data-stream-affecting
* flags. */
if (protocol_version < 29)
flag_ptr[7] = NULL;
for (i = 0, flags = 0; flag_ptr[i]; i++) {
if (*flag_ptr[i])
flags |= 1 << i;
}
write_int(fd, flags);
}
void read_stream_flags(int fd)
{
int i, flags;
if (protocol_version < 29)
flag_ptr[7] = NULL;
for (i = 0, flags = read_int(fd); flag_ptr[i]; i++) {
int set = flags & (1 << i) ? 1 : 0;
if (*flag_ptr[i] != set) {
if (verbose) {
rprintf(FINFO,
"%sing the %s option to match the batchfile.\n",
set ? "Sett" : "Clear", flag_name[i]);
}
*flag_ptr[i] = set;
}
}
if (protocol_version < 29) {
if (recurse)
xfer_dirs |= 1;
else if (xfer_dirs < 2)
xfer_dirs = 0;
}
}
static void write_arg(int fd, char *arg)
{
char *x, *s;
if (*arg == '-' && (x = strchr(arg, '=')) != NULL) {
write(fd, arg, x - arg + 1);
arg += x - arg + 1;
}
if (strpbrk(arg, " \"'&;|[]()$#!*?^\\") != NULL) {
write(fd, "'", 1);
for (s = arg; (x = strchr(s, '\'')) != NULL; s = x + 1) {
write(fd, s, x - s + 1);
write(fd, "'", 1);
}
write(fd, s, strlen(s));
write(fd, "'", 1);
return;
}
write(fd, arg, strlen(arg));
}
static void write_filter_rules(int fd)
{
struct filter_struct *ent;
write_sbuf(fd, " <<'#E#'\n");
for (ent = filter_list.head; ent; ent = ent->next) {
unsigned int plen;
char *p = get_rule_prefix(ent->match_flags, "- ", 0, &plen);
write_buf(fd, p, plen);
write_sbuf(fd, ent->pattern);
if (ent->match_flags & MATCHFLG_DIRECTORY)
write_byte(fd, '/');
write_byte(fd, eol_nulls ? 0 : '\n');
}
if (eol_nulls)
write_sbuf(fd, ";\n");
write_sbuf(fd, "#E#");
}
/* This routine tries to write out an equivalent --read-batch command
* given the user's --write-batch args. However, it doesn't really
* understand most of the options, so it uses some overly simple
* heuristics to munge the command line into something that will
* (hopefully) work. */
void write_batch_shell_file(int argc, char *argv[], int file_arg_cnt)
{
int fd, i, len;
char *p, filename[MAXPATHLEN];
stringjoin(filename, sizeof filename,
batch_name, ".sh", NULL);
fd = do_open(filename, O_WRONLY | O_CREAT | O_TRUNC,
S_IRUSR | S_IWUSR | S_IEXEC);
if (fd < 0) {
rsyserr(FERROR, errno, "Batch file %s open error",
safe_fname(filename));
exit_cleanup(1);
}
/* Write argvs info to BATCH.sh file */
write_arg(fd, argv[0]);
if (filter_list.head) {
if (protocol_version >= 29)
write_sbuf(fd, " --filter=._-");
else
write_sbuf(fd, " --exclude-from=-");
}
for (i = 1; i < argc - file_arg_cnt; i++) {
p = argv[i];
if (strncmp(p, "--files-from", 12) == 0
|| strncmp(p, "--filter", 8) == 0
|| strncmp(p, "--include", 9) == 0
|| strncmp(p, "--exclude", 9) == 0) {
if (strchr(p, '=') == NULL)
i++;
continue;
}
if (strcmp(p, "-f") == 0) {
i++;
continue;
}
write(fd, " ", 1);
if (strncmp(p, "--write-batch", len = 13) == 0
|| strncmp(p, "--only-write-batch", len = 18) == 0) {
write(fd, "--read-batch", 12);
if (p[len] == '=') {
write(fd, "=", 1);
write_arg(fd, p + len + 1);
}
} else
write_arg(fd, p);
}
if (!(p = check_for_hostspec(argv[argc - 1], &p, &i)))
p = argv[argc - 1];
write(fd, " ${1:-", 6);
write_arg(fd, p);
write_byte(fd, '}');
if (filter_list.head)
write_filter_rules(fd);
if (write(fd, "\n", 1) != 1 || close(fd) < 0) {
rsyserr(FERROR, errno, "Batch file %s write error",
safe_fname(filename));
exit_cleanup(1);
}
}
void show_flist(int index, struct file_struct **fptr)
{
/* for debugging show_flist(flist->count, flist->files * */
int i;
for (i = 0; i < index; i++) {
rprintf(FINFO, "flist->flags=%#x\n", fptr[i]->flags);
rprintf(FINFO, "flist->modtime=%#lx\n",
(long unsigned) fptr[i]->modtime);
rprintf(FINFO, "flist->length=%.0f\n",
(double) fptr[i]->length);
rprintf(FINFO, "flist->mode=%#o\n", (int) fptr[i]->mode);
rprintf(FINFO, "flist->basename=%s\n",
safe_fname(fptr[i]->basename));
if (fptr[i]->dirname) {
rprintf(FINFO, "flist->dirname=%s\n",
safe_fname(fptr[i]->dirname));
}
if (am_sender && fptr[i]->dir.root) {
rprintf(FINFO, "flist->dir.root=%s\n",
safe_fname(fptr[i]->dir.root));
}
}
}
/* for debugging */
void show_argvs(int argc, char *argv[])
{
int i;
rprintf(FINFO, "BATCH.C:show_argvs,argc=%d\n", argc);
for (i = 0; i < argc; i++)
rprintf(FINFO, "i=%d,argv[i]=%s\n", i, safe_fname(argv[i]));
}

View File

@@ -1,17 +1,17 @@
/*
/*
Copyright (C) Andrew Tridgell 1996
Copyright (C) Paul Mackerras 1996
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -23,24 +23,24 @@ int csum_length=2; /* initial value */
#define CSUM_CHUNK 64
int checksum_seed = 0;
extern int remote_version;
extern int checksum_seed;
extern int protocol_version;
/*
a simple 32 bit checksum that can be upadted from either end
(inspired by Mark Adler's Adler-32 checksum)
*/
uint32 get_checksum1(char *buf1,int len)
uint32 get_checksum1(char *buf1, int32 len)
{
int i;
int32 i;
uint32 s1, s2;
schar *buf = (schar *)buf1;
s1 = s2 = 0;
for (i = 0; i < (len-4); i+=4) {
s2 += 4*(s1 + buf[i]) + 3*buf[i+1] + 2*buf[i+2] + buf[i+3] +
s2 += 4*(s1 + buf[i]) + 3*buf[i+1] + 2*buf[i+2] + buf[i+3] +
10*CHAR_OFFSET;
s1 += (buf[i+0] + buf[i+1] + buf[i+2] + buf[i+3] + 4*CHAR_OFFSET);
s1 += (buf[i+0] + buf[i+1] + buf[i+2] + buf[i+3] + 4*CHAR_OFFSET);
}
for (; i < len; i++) {
s1 += (buf[i]+CHAR_OFFSET); s2 += s1;
@@ -49,35 +49,43 @@ uint32 get_checksum1(char *buf1,int len)
}
void get_checksum2(char *buf,int len,char *sum)
void get_checksum2(char *buf, int32 len, char *sum)
{
int i;
int32 i;
static char *buf1;
static int len1;
static int32 len1;
struct mdfour m;
if (len > len1) {
if (buf1) free(buf1);
buf1 = (char *)malloc(len+4);
if (buf1)
free(buf1);
buf1 = new_array(char, len+4);
len1 = len;
if (!buf1) out_of_memory("get_checksum2");
if (!buf1)
out_of_memory("get_checksum2");
}
mdfour_begin(&m);
memcpy(buf1,buf,len);
if (checksum_seed) {
SIVAL(buf1,len,checksum_seed);
len += 4;
}
for(i = 0; i + CSUM_CHUNK <= len; i += CSUM_CHUNK) {
mdfour_update(&m, (uchar *)(buf1+i), CSUM_CHUNK);
}
if (len - i > 0) {
/*
* Prior to version 27 an incorrect MD4 checksum was computed
* by failing to call mdfour_tail() for block sizes that
* are multiples of 64. This is fixed by calling mdfour_update()
* even when there are no more bytes.
*/
if (len - i > 0 || protocol_version >= 27) {
mdfour_update(&m, (uchar *)(buf1+i), (len-i));
}
mdfour_result(&m, (uchar *)sum);
}
@@ -88,27 +96,29 @@ void file_checksum(char *fname,char *sum,OFF_T size)
struct map_struct *buf;
int fd;
OFF_T len = size;
char tmpchunk[CSUM_CHUNK];
struct mdfour m;
memset(sum,0,csum_length);
fd = open(fname,O_RDONLY);
if (fd == -1) return;
buf = map_file(fd,size);
memset(sum,0,MD4_SUM_LENGTH);
fd = do_open(fname, O_RDONLY, 0);
if (fd == -1)
return;
buf = map_file(fd, size, MAX_MAP_SIZE, CSUM_CHUNK);
mdfour_begin(&m);
for(i = 0; i + CSUM_CHUNK <= len; i += CSUM_CHUNK) {
memcpy(tmpchunk, map_ptr(buf,i,CSUM_CHUNK), CSUM_CHUNK);
mdfour_update(&m, (uchar *)tmpchunk, CSUM_CHUNK);
mdfour_update(&m, (uchar *)map_ptr(buf, i, CSUM_CHUNK),
CSUM_CHUNK);
}
if (len - i > 0) {
memcpy(tmpchunk, map_ptr(buf,i,len-i), len-i);
mdfour_update(&m, (uchar *)tmpchunk, (len-i));
}
/* Prior to version 27 an incorrect MD4 checksum was computed
* by failing to call mdfour_tail() for block sizes that
* are multiples of 64. This is fixed by calling mdfour_update()
* even when there are no more bytes. */
if (len - i > 0 || protocol_version >= 27)
mdfour_update(&m, (uchar *)map_ptr(buf, i, len-i), len-i);
mdfour_result(&m, (uchar *)sum);
@@ -117,64 +127,58 @@ void file_checksum(char *fname,char *sum,OFF_T size)
}
void checksum_init(void)
{
if (remote_version >= 14)
csum_length = 2; /* adaptive */
else
csum_length = SUM_LENGTH;
}
static int sumresidue;
static int32 sumresidue;
static char sumrbuf[CSUM_CHUNK];
static struct mdfour md;
void sum_init(void)
void sum_init(int seed)
{
char s[4];
mdfour_begin(&md);
sumresidue=0;
SIVAL(s,0,checksum_seed);
sum_update(s,4);
sumresidue = 0;
SIVAL(s, 0, seed);
sum_update(s, 4);
}
void sum_update(char *p,int len)
/**
* Feed data into an MD4 accumulator, md. The results may be
* retrieved using sum_end(). md is used for different purposes at
* different points during execution.
*
* @todo Perhaps get rid of md and just pass in the address each time.
* Very slightly clearer and slower.
**/
void sum_update(char *p, int32 len)
{
int i;
if (len + sumresidue < CSUM_CHUNK) {
memcpy(sumrbuf+sumresidue, p, len);
memcpy(sumrbuf + sumresidue, p, len);
sumresidue += len;
return;
}
if (sumresidue) {
i = MIN(CSUM_CHUNK-sumresidue,len);
memcpy(sumrbuf+sumresidue,p,i);
mdfour_update(&md, (uchar *)sumrbuf, (i+sumresidue));
int32 i = CSUM_CHUNK - sumresidue;
memcpy(sumrbuf + sumresidue, p, i);
mdfour_update(&md, (uchar *)sumrbuf, CSUM_CHUNK);
len -= i;
p += i;
}
for(i = 0; i + CSUM_CHUNK <= len; i += CSUM_CHUNK) {
memcpy(sumrbuf,p+i,CSUM_CHUNK);
mdfour_update(&md, (uchar *)sumrbuf, CSUM_CHUNK);
while (len >= CSUM_CHUNK) {
mdfour_update(&md, (uchar *)p, CSUM_CHUNK);
len -= CSUM_CHUNK;
p += CSUM_CHUNK;
}
if (len - i > 0) {
sumresidue = len-i;
memcpy(sumrbuf,p+i,sumresidue);
} else {
sumresidue = 0;
}
sumresidue = len;
if (sumresidue)
memcpy(sumrbuf, p, sumresidue);
}
void sum_end(char *sum)
{
if (sumresidue) {
if (sumresidue || protocol_version >= 27)
mdfour_update(&md, (uchar *)sumrbuf, sumresidue);
}
mdfour_result(&md, (uchar *)sum);
}

165
cleanup.c
View File

@@ -1,17 +1,19 @@
/*
Copyright (C) Andrew Tridgell 1996
/* -*- c-file-style: "linux" -*-
Copyright (C) 1996-2000 by Andrew Tridgell
Copyright (C) Paul Mackerras 1996
Copyright (C) 2002 by Martin Pool
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -19,50 +21,138 @@
#include "rsync.h"
/* handling the cleanup when a transfer is interrupted is tricky when
--partial is selected. We need to ensure that the partial file is
kept if any real data has been transferred */
int cleanup_got_literal=0;
extern int io_error;
extern int keep_partial;
extern int log_got_error;
extern char *partial_dir;
/**
* Close all open sockets and files, allowing a (somewhat) graceful
* shutdown() of socket connections. This eliminates the abortive
* TCP RST sent by a Winsock-based system when the close() occurs.
**/
void close_all(void)
{
#ifdef SHUTDOWN_ALL_SOCKETS
int max_fd;
int fd;
int ret;
STRUCT_STAT st;
max_fd = sysconf(_SC_OPEN_MAX) - 1;
for (fd = max_fd; fd >= 0; fd--) {
if ((ret = do_fstat(fd, &st)) == 0) {
if (is_a_socket(fd))
ret = shutdown(fd, 2);
ret = close(fd);
}
}
#endif
}
/**
* @file cleanup.c
*
* Code for handling interrupted transfers. Depending on the @c
* --partial option, we may either delete the temporary file, or go
* ahead and overwrite the destination. This second behaviour only
* occurs if we've sent literal data and therefore hopefully made
* progress on the transfer.
**/
/**
* Set to True once literal data has been sent across the link for the
* current file. (????)
*
* Handling the cleanup when a transfer is interrupted is tricky when
* --partial is selected. We need to ensure that the partial file is
* kept if any real data has been transferred.
**/
int cleanup_got_literal = 0;
static char *cleanup_fname;
static char *cleanup_new_fname;
static struct file_struct *cleanup_file;
static int cleanup_fd1, cleanup_fd2;
static struct map_struct *cleanup_buf;
static int cleanup_pid = 0;
extern int io_error;
static int cleanup_fd_r, cleanup_fd_w;
static pid_t cleanup_pid = 0;
pid_t cleanup_child_pid = -1;
/**
* Eventually calls exit(), passing @p code, therefore does not return.
*
* @param code one of the RERR_* codes from errcode.h.
**/
void _exit_cleanup(int code, const char *file, int line)
{
extern int keep_partial;
int ocode = code;
static int inside_cleanup = 0;
if (code == 0 && io_error) code = RERR_FILEIO;
if (inside_cleanup > 10) {
/* prevent the occasional infinite recursion */
return;
}
inside_cleanup++;
signal(SIGUSR1, SIG_IGN);
signal(SIGUSR2, SIG_IGN);
if (cleanup_got_literal && cleanup_fname && keep_partial) {
char *fname = cleanup_fname;
cleanup_fname = NULL;
if (cleanup_buf) unmap_file(cleanup_buf);
if (cleanup_fd1 != -1) close(cleanup_fd1);
if (cleanup_fd2 != -1) close(cleanup_fd2);
finish_transfer(cleanup_new_fname, fname, cleanup_file);
if (verbose > 3) {
rprintf(FINFO,"_exit_cleanup(code=%d, file=%s, line=%d): entered\n",
code, safe_fname(file), line);
}
io_flush();
if (cleanup_fname)
do_unlink(cleanup_fname);
if (code) {
kill_all(SIGUSR1);
}
if ((cleanup_pid != 0) && (cleanup_pid == (int) getpid())) {
char *pidf = lp_pid_file();
if (pidf && *pidf) {
unlink(lp_pid_file());
if (cleanup_child_pid != -1) {
int status;
if (waitpid(cleanup_child_pid, &status, WNOHANG) == cleanup_child_pid) {
status = WEXITSTATUS(status);
if (status > code)
code = status;
}
}
if (code) log_exit(code, file, line);
if (cleanup_got_literal && cleanup_fname && keep_partial
&& handle_partial_dir(cleanup_new_fname, PDIR_CREATE)) {
char *fname = cleanup_fname;
cleanup_fname = NULL;
if (cleanup_fd_r != -1)
close(cleanup_fd_r);
if (cleanup_fd_w != -1) {
flush_write_file(cleanup_fd_w);
close(cleanup_fd_w);
}
finish_transfer(cleanup_new_fname, fname, cleanup_file, 0,
!partial_dir);
}
io_flush(FULL_FLUSH);
if (cleanup_fname)
do_unlink(cleanup_fname);
if (code)
kill_all(SIGUSR1);
if (cleanup_pid && cleanup_pid == getpid()) {
char *pidf = lp_pid_file();
if (pidf && *pidf)
unlink(lp_pid_file());
}
if (code == 0) {
if (io_error & IOERR_DEL_LIMIT)
code = RERR_DEL_LIMIT;
if (io_error & IOERR_VANISHED)
code = RERR_VANISHED;
if (io_error & IOERR_GENERAL || log_got_error)
code = RERR_PARTIAL;
}
if (code)
log_exit(code, file, line);
if (verbose > 2) {
rprintf(FINFO,"_exit_cleanup(code=%d, file=%s, line=%d): about to call exit(%d)\n",
ocode, safe_fname(file), line, code);
}
close_all();
exit(code);
}
@@ -74,17 +164,16 @@ void cleanup_disable(void)
void cleanup_set(char *fnametmp, char *fname, struct file_struct *file,
struct map_struct *buf, int fd1, int fd2)
int fd_r, int fd_w)
{
cleanup_fname = fnametmp;
cleanup_new_fname = fname;
cleanup_file = file;
cleanup_buf = buf;
cleanup_fd1 = fd1;
cleanup_fd2 = fd2;
cleanup_fd_r = fd_r;
cleanup_fd_w = fd_w;
}
void cleanup_set_pid(int pid)
void cleanup_set_pid(pid_t pid)
{
cleanup_pid = pid;
}

348
clientname.c Normal file
View File

@@ -0,0 +1,348 @@
/* -*- c-file-style: "linux" -*-
rsync -- fast file replication program
Copyright (C) 1992-2001 by Andrew Tridgell <tridge@samba.org>
Copyright (C) 2001, 2002 by Martin Pool <mbp@samba.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* @file clientname.c
*
* Functions for looking up the remote name or addr of a socket.
*
* This file is now converted to use the new-style getaddrinfo()
* interface, which supports IPv6 but is also supported on recent
* IPv4-only machines. On systems that don't have that interface, we
* emulate it using the KAME implementation.
**/
#include "rsync.h"
static const char default_name[] = "UNKNOWN";
extern int am_daemon;
extern int am_server;
/**
* Return the IP addr of the client as a string
**/
char *client_addr(int fd)
{
static char addr_buf[100];
static int initialised;
struct sockaddr_storage ss;
socklen_t length = sizeof ss;
char *ssh_info, *p;
if (initialised)
return addr_buf;
initialised = 1;
if (am_server) { /* daemon over --rsh mode */
strcpy(addr_buf, "0.0.0.0");
if ((ssh_info = getenv("SSH_CONNECTION")) != NULL
|| (ssh_info = getenv("SSH_CLIENT")) != NULL
|| (ssh_info = getenv("SSH2_CLIENT")) != NULL) {
strlcpy(addr_buf, ssh_info, sizeof addr_buf);
/* Truncate the value to just the IP address. */
if ((p = strchr(addr_buf, ' ')) != NULL)
*p = '\0';
}
} else {
client_sockaddr(fd, &ss, &length);
getnameinfo((struct sockaddr *)&ss, length,
addr_buf, sizeof addr_buf, NULL, 0, NI_NUMERICHOST);
}
return addr_buf;
}
static int get_sockaddr_family(const struct sockaddr_storage *ss)
{
return ((struct sockaddr *) ss)->sa_family;
}
/**
* Return the DNS name of the client.
*
* The name is statically cached so that repeated lookups are quick,
* so there is a limit of one lookup per customer.
*
* If anything goes wrong, including the name->addr->name check, then
* we just use "UNKNOWN", so you can use that value in hosts allow
* lines.
*
* After translation from sockaddr to name we do a forward lookup to
* make sure nobody is spoofing PTR records.
**/
char *client_name(int fd)
{
static char name_buf[100];
static char port_buf[100];
static int initialised;
struct sockaddr_storage ss;
socklen_t ss_len;
if (initialised)
return name_buf;
strcpy(name_buf, default_name);
initialised = 1;
memset(&ss, 0, sizeof ss);
if (am_server) { /* daemon over --rsh mode */
char *addr = client_addr(fd);
struct addrinfo hint, *answer;
int err;
memset(&hint, 0, sizeof hint);
#ifdef AI_NUMERICHOST
hint.ai_flags = AI_NUMERICHOST;
#endif
hint.ai_socktype = SOCK_STREAM;
if ((err = getaddrinfo(addr, NULL, &hint, &answer)) != 0) {
rprintf(FLOG, "malformed address %s: %s\n",
addr, gai_strerror(err));
return name_buf;
}
switch (answer->ai_family) {
case AF_INET:
ss_len = sizeof (struct sockaddr_in);
memcpy(&ss, answer->ai_addr, ss_len);
break;
#ifdef INET6
case AF_INET6:
ss_len = sizeof (struct sockaddr_in6);
memcpy(&ss, answer->ai_addr, ss_len);
break;
#endif
}
freeaddrinfo(answer);
} else {
ss_len = sizeof ss;
client_sockaddr(fd, &ss, &ss_len);
}
if (lookup_name(fd, &ss, ss_len, name_buf, sizeof name_buf,
port_buf, sizeof port_buf) == 0)
check_name(fd, &ss, name_buf);
return name_buf;
}
/**
* Get the sockaddr for the client.
*
* If it comes in as an ipv4 address mapped into IPv6 format then we
* convert it back to a regular IPv4.
**/
void client_sockaddr(int fd,
struct sockaddr_storage *ss,
socklen_t *ss_len)
{
memset(ss, 0, sizeof *ss);
if (getpeername(fd, (struct sockaddr *) ss, ss_len)) {
/* FIXME: Can we really not continue? */
rsyserr(FLOG, errno, "getpeername on fd%d failed", fd);
exit_cleanup(RERR_SOCKETIO);
}
#ifdef INET6
if (get_sockaddr_family(ss) == AF_INET6 &&
IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)ss)->sin6_addr)) {
/* OK, so ss is in the IPv6 family, but it is really
* an IPv4 address: something like
* "::ffff:10.130.1.2". If we use it as-is, then the
* reverse lookup might fail or perhaps something else
* bad might happen. So instead we convert it to an
* equivalent address in the IPv4 address family. */
struct sockaddr_in6 sin6;
struct sockaddr_in *sin;
memcpy(&sin6, ss, sizeof sin6);
sin = (struct sockaddr_in *)ss;
memset(sin, 0, sizeof *sin);
sin->sin_family = AF_INET;
*ss_len = sizeof (struct sockaddr_in);
#ifdef HAVE_SOCKADDR_IN_LEN
sin->sin_len = *ss_len;
#endif
sin->sin_port = sin6.sin6_port;
/* There is a macro to extract the mapped part
* (IN6_V4MAPPED_TO_SINADDR ?), but it does not seem
* to be present in the Linux headers. */
memcpy(&sin->sin_addr, &sin6.sin6_addr.s6_addr[12],
sizeof sin->sin_addr);
}
#endif
}
/**
* Look up a name from @p ss into @p name_buf.
*
* @param fd file descriptor for client socket.
**/
int lookup_name(int fd, const struct sockaddr_storage *ss,
socklen_t ss_len,
char *name_buf, size_t name_buf_len,
char *port_buf, size_t port_buf_len)
{
int name_err;
/* reverse lookup */
name_err = getnameinfo((struct sockaddr *) ss, ss_len,
name_buf, name_buf_len,
port_buf, port_buf_len,
NI_NAMEREQD | NI_NUMERICSERV);
if (name_err != 0) {
strcpy(name_buf, default_name);
rprintf(FLOG, "name lookup failed for %s: %s\n",
client_addr(fd), gai_strerror(name_err));
return name_err;
}
return 0;
}
/**
* Compare an addrinfo from the resolver to a sockinfo.
*
* Like strcmp, returns 0 for identical.
**/
int compare_addrinfo_sockaddr(const struct addrinfo *ai,
const struct sockaddr_storage *ss)
{
int ss_family = get_sockaddr_family(ss);
const char fn[] = "compare_addrinfo_sockaddr";
if (ai->ai_family != ss_family) {
rprintf(FLOG, "%s: response family %d != %d\n",
fn, ai->ai_family, ss_family);
return 1;
}
/* The comparison method depends on the particular AF. */
if (ss_family == AF_INET) {
const struct sockaddr_in *sin1, *sin2;
sin1 = (const struct sockaddr_in *) ss;
sin2 = (const struct sockaddr_in *) ai->ai_addr;
return memcmp(&sin1->sin_addr, &sin2->sin_addr,
sizeof sin1->sin_addr);
}
#ifdef INET6
if (ss_family == AF_INET6) {
const struct sockaddr_in6 *sin1, *sin2;
sin1 = (const struct sockaddr_in6 *) ss;
sin2 = (const struct sockaddr_in6 *) ai->ai_addr;
if (ai->ai_addrlen < sizeof (struct sockaddr_in6)) {
rprintf(FLOG, "%s: too short sockaddr_in6; length=%d\n",
fn, ai->ai_addrlen);
return 1;
}
if (memcmp(&sin1->sin6_addr, &sin2->sin6_addr,
sizeof sin1->sin6_addr))
return 1;
#ifdef HAVE_SOCKADDR_IN6_SCOPE_ID
if (sin1->sin6_scope_id != sin2->sin6_scope_id)
return 1;
#endif
return 0;
}
#endif /* INET6 */
/* don't know */
return 1;
}
/**
* Do a forward lookup on @p name_buf and make sure it corresponds to
* @p ss -- otherwise we may be being spoofed. If we suspect we are,
* then we don't abort the connection but just emit a warning, and
* change @p name_buf to be "UNKNOWN".
*
* We don't do anything with the service when checking the name,
* because it doesn't seem that it could be spoofed in any way, and
* getaddrinfo on random service names seems to cause problems on AIX.
**/
int check_name(int fd,
const struct sockaddr_storage *ss,
char *name_buf)
{
struct addrinfo hints, *res, *res0;
int error;
int ss_family = get_sockaddr_family(ss);
memset(&hints, 0, sizeof hints);
hints.ai_family = ss_family;
hints.ai_flags = AI_CANONNAME;
hints.ai_socktype = SOCK_STREAM;
error = getaddrinfo(name_buf, NULL, &hints, &res0);
if (error) {
rprintf(FLOG, "forward name lookup for %s failed: %s\n",
name_buf, gai_strerror(error));
strcpy(name_buf, default_name);
return error;
}
/* Given all these results, we expect that one of them will be
* the same as ss. The comparison is a bit complicated. */
for (res = res0; res; res = res->ai_next) {
if (!compare_addrinfo_sockaddr(res, ss))
break; /* OK, identical */
}
if (!res0) {
/* We hit the end of the list without finding an
* address that was the same as ss. */
rprintf(FLOG, "no known address for \"%s\": "
"spoofed address?\n", name_buf);
strcpy(name_buf, default_name);
} else if (res == NULL) {
/* We hit the end of the list without finding an
* address that was the same as ss. */
rprintf(FLOG, "%s is not a known address for \"%s\": "
"spoofed address?\n", client_addr(fd), name_buf);
strcpy(name_buf, default_name);
}
freeaddrinfo(res0);
return 0;
}

View File

@@ -1,162 +1,280 @@
/*
Copyright (C) Andrew Tridgell 1998
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* -*- c-file-style: "linux"; -*-
*
* Copyright (C) 1998-2001 by Andrew Tridgell <tridge@samba.org>
* Copyright (C) 2001-2002 by Martin Pool <mbp@samba.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* the socket based protocol for setting up a connection wit rsyncd */
/**
* @file
*
* The socket based protocol for setting up a connection with
* rsyncd.
**/
#include "rsync.h"
extern int module_id;
extern int read_only;
extern int verbose;
extern int list_only;
extern int am_sender;
extern int am_server;
extern int am_daemon;
extern int am_root;
extern int rsync_port;
char *auth_user;
extern int kluge_around_eof;
extern int daemon_over_rsh;
extern int sanitize_paths;
extern int filesfrom_fd;
extern int remote_protocol;
extern int protocol_version;
extern int io_timeout;
extern int orig_umask;
extern int no_detach;
extern int default_af_hint;
extern char *bind_address;
extern struct filter_list_struct server_filter_list;
extern char *config_file;
extern char *files_from;
char *auth_user;
int read_only = 0;
int daemon_log_format_has_i = 0;
int daemon_log_format_has_o_or_i = 0;
int module_id = -1;
/* Length of lp_path() string when in daemon mode & not chrooted, else 0. */
unsigned int module_dirlen = 0;
/**
* Run a client connected to an rsyncd. The alternative to this
* function for remote-shell connections is do_cmd().
*
* After negotiating which module to use and reading the server's
* motd, this hands over to client_run(). Telling the server the
* module will cause it to chroot/setuid/etc.
*
* Instead of doing a transfer, the client may at this stage instead
* get a listing of remote modules and exit.
*
* @return -1 for error in startup, or the result of client_run().
* Either way, it eventually gets passed to exit_cleanup().
**/
int start_socket_client(char *host, char *path, int argc, char *argv[])
{
int fd, i;
char *sargs[MAX_ARGS];
int sargc=0;
char line[MAXPATHLEN];
char *p, *user=NULL;
extern int remote_version;
extern int am_sender;
int fd, ret;
char *p, *user = NULL;
/* This is redundant with code in start_inband_exchange(), but this
* short-circuits a problem in the client before we open a socket,
* and the extra check won't hurt. */
if (*path == '/') {
rprintf(FERROR,"ERROR: The remote path must start with a module name\n");
rprintf(FERROR,
"ERROR: The remote path must start with a module name not a /\n");
return -1;
}
p = strchr(host, '@');
if (p) {
if ((p = strrchr(host, '@')) != NULL) {
user = host;
host = p+1;
*p = 0;
*p = '\0';
}
if (!user) user = getenv("USER");
if (!user) user = getenv("LOGNAME");
fd = open_socket_out(host, rsync_port);
if (fd == -1) {
fd = open_socket_out_wrapped(host, rsync_port, bind_address,
default_af_hint);
if (fd == -1)
exit_cleanup(RERR_SOCKETIO);
ret = start_inband_exchange(user, path, fd, fd, argc);
return ret ? ret : client_run(fd, fd, -1, argc, argv);
}
int start_inband_exchange(char *user, char *path, int f_in, int f_out,
int argc)
{
int i;
char *sargs[MAX_ARGS];
int sargc = 0;
char line[MAXPATHLEN];
char *p;
if (argc == 0 && !am_sender)
list_only |= 1;
if (*path == '/') {
rprintf(FERROR,
"ERROR: The remote path must start with a module name\n");
return -1;
}
server_options(sargs,&sargc);
if (!user)
user = getenv("USER");
if (!user)
user = getenv("LOGNAME");
io_printf(f_out, "@RSYNCD: %d\n", protocol_version);
if (!read_line(f_in, line, sizeof line - 1)) {
rprintf(FERROR, "rsync: did not see server greeting\n");
return -1;
}
if (sscanf(line,"@RSYNCD: %d", &remote_protocol) != 1) {
/* note that read_line strips of \n or \r */
rprintf(FERROR, "rsync: server sent \"%s\" rather than greeting\n",
line);
return -1;
}
if (protocol_version > remote_protocol)
protocol_version = remote_protocol;
if (list_only && protocol_version >= 29)
list_only |= 2;
/* set daemon_over_rsh to false since we need to build the
* true set of args passed through the rsh/ssh connection;
* this is a no-op for direct-socket-connection mode */
daemon_over_rsh = 0;
server_options(sargs, &sargc);
sargs[sargc++] = ".";
if (path && *path)
if (path && *path)
sargs[sargc++] = path;
sargs[sargc] = NULL;
io_printf(fd,"@RSYNCD: %d\n", PROTOCOL_VERSION);
if (!read_line(fd, line, sizeof(line)-1)) {
return -1;
}
if (sscanf(line,"@RSYNCD: %d", &remote_version) != 1) {
return -1;
}
if (verbose > 1)
print_child_argv(sargs);
p = strchr(path,'/');
if (p) *p = 0;
io_printf(fd,"%s\n",path);
io_printf(f_out, "%s\n", path);
if (p) *p = '/';
/* Old servers may just drop the connection here,
rather than sending a proper EXIT command. Yuck. */
kluge_around_eof = list_only && protocol_version < 25 ? 1 : 0;
while (1) {
if (!read_line(fd, line, sizeof(line)-1)) {
if (!read_line(f_in, line, sizeof line - 1)) {
rprintf(FERROR, "rsync: didn't get server startup line\n");
return -1;
}
if (strncmp(line,"@RSYNCD: AUTHREQD ",18) == 0) {
auth_client(fd, user, line+18);
auth_client(f_out, user, line+18);
continue;
}
if (strcmp(line,"@RSYNCD: OK") == 0) break;
rprintf(FINFO,"%s\n", line);
if (strcmp(line,"@RSYNCD: OK") == 0)
break;
if (strcmp(line,"@RSYNCD: EXIT") == 0) {
/* This is sent by recent versions of the
* server to terminate the listing of modules.
* We don't want to go on and transfer
* anything; just exit. */
exit(0);
}
if (strncmp(line, "@ERROR", 6) == 0) {
rprintf(FERROR, "%s\n", line);
/* This is always fatal; the server will now
* close the socket. */
return -1;
}
rprintf(FINFO, "%s\n", line);
}
kluge_around_eof = 0;
for (i = 0; i < sargc; i++) {
io_printf(f_out, "%s\n", sargs[i]);
}
io_printf(f_out, "\n");
if (protocol_version < 23) {
if (protocol_version == 22 || !am_sender)
io_start_multiplex_in();
}
for (i=0;i<sargc;i++) {
io_printf(fd,"%s\n", sargs[i]);
}
io_printf(fd,"\n");
if (remote_version > 17 && !am_sender)
io_start_multiplex_in(fd);
return client_run(fd, fd, -1, argc, argv);
return 0;
}
static int rsync_module(int fd, int i)
static int rsync_module(int f_in, int f_out, int i)
{
int argc=0;
char *argv[MAX_ARGS];
int argc = 0;
int maxargs;
char **argv;
char **argp;
char line[MAXPATHLEN];
uid_t uid = (uid_t)-2;
uid_t uid = (uid_t)-2; /* canonically "nobody" */
gid_t gid = (gid_t)-2;
char *p;
char *addr = client_addr(fd);
char *host = client_name(fd);
#ifdef HAVE_PUTENV
char *s;
#endif
char *addr = client_addr(f_in);
char *host = client_name(f_in);
char *name = lp_name(i);
int use_chroot = lp_use_chroot(i);
int start_glob=0;
int start_glob = 0;
int ret;
char *request=NULL;
extern int am_sender;
extern int remote_version;
extern int am_root;
char *request = NULL;
if (!allow_access(addr, host, lp_hosts_allow(i), lp_hosts_deny(i))) {
rprintf(FERROR,"rsync denied on module %s from %s (%s)\n",
name, client_name(fd), client_addr(fd));
io_printf(fd,"@ERROR: access denied to %s from %s (%s)\n",
name, client_name(fd), client_addr(fd));
return -1;
}
if (!claim_connection(lp_lock_file(i), lp_max_connections(i))) {
if (errno) {
rprintf(FERROR,"failed to open lock file %s : %s\n",
lp_lock_file(i), strerror(errno));
io_printf(fd,"@ERROR: failed to open lock file %s : %s\n",
lp_lock_file(i), strerror(errno));
} else {
rprintf(FERROR,"max connections (%d) reached\n",
lp_max_connections(i));
io_printf(fd,"@ERROR: max connections (%d) reached - try again later\n", lp_max_connections(i));
rprintf(FLOG, "rsync denied on module %s from %s (%s)\n",
name, host, addr);
if (!lp_list(i))
io_printf(f_out, "@ERROR: Unknown module '%s'\n", name);
else {
io_printf(f_out,
"@ERROR: access denied to %s from %s (%s)\n",
name, host, addr);
}
return -1;
}
auth_user = auth_server(fd, i, addr, "@RSYNCD: AUTHREQD ");
if (am_daemon && am_server) {
rprintf(FLOG, "rsync allowed access on module %s from %s (%s)\n",
name, host, addr);
}
if (!claim_connection(lp_lock_file(i), lp_max_connections(i))) {
if (errno) {
rsyserr(FLOG, errno, "failed to open lock file %s",
safe_fname(lp_lock_file(i)));
io_printf(f_out, "@ERROR: failed to open lock file\n");
} else {
rprintf(FLOG, "max connections (%d) reached\n",
lp_max_connections(i));
io_printf(f_out, "@ERROR: max connections (%d) reached -- try again later\n",
lp_max_connections(i));
}
return -1;
}
auth_user = auth_server(f_in, f_out, i, host, addr, "@RSYNCD: AUTHREQD ");
if (!auth_user) {
rprintf(FERROR,"auth failed on module %s from %s (%s)\n",
name, client_name(fd), client_addr(fd));
io_printf(fd,"@ERROR: auth failed on module %s\n",name);
return -1;
io_printf(f_out, "@ERROR: auth failed on module %s\n", name);
return -1;
}
module_id = i;
@@ -164,168 +282,300 @@ static int rsync_module(int fd, int i)
if (lp_read_only(i))
read_only = 1;
am_root = (getuid() == 0);
if (lp_transfer_logging(i)) {
if (log_format_has(lp_log_format(i), 'i'))
daemon_log_format_has_i = 1;
if (daemon_log_format_has_i
|| log_format_has(lp_log_format(i), 'o'))
daemon_log_format_has_o_or_i = 1;
}
am_root = (MY_UID() == 0);
if (am_root) {
p = lp_uid(i);
if (!name_to_uid(p, &uid)) {
if (!isdigit(*p)) {
rprintf(FERROR,"Invalid uid %s\n", p);
io_printf(fd,"@ERROR: invalid uid\n");
if (!isdigit(*(unsigned char *)p)) {
rprintf(FLOG, "Invalid uid %s\n", p);
io_printf(f_out, "@ERROR: invalid uid %s\n", p);
return -1;
}
}
uid = atoi(p);
}
p = lp_gid(i);
if (!name_to_gid(p, &gid)) {
if (!isdigit(*p)) {
rprintf(FERROR,"Invalid gid %s\n", p);
io_printf(fd,"@ERROR: invalid gid\n");
if (!isdigit(*(unsigned char *)p)) {
rprintf(FLOG, "Invalid gid %s\n", p);
io_printf(f_out, "@ERROR: invalid gid %s\n", p);
return -1;
}
}
gid = atoi(p);
}
}
/* TODO: If we're not root, but the configuration requests
* that we change to some uid other than the current one, then
* log a warning. */
/* TODO: Perhaps take a list of gids, and make them into the
* supplementary groups. */
if (use_chroot || (module_dirlen = strlen(lp_path(i))) == 1) {
module_dirlen = 0;
set_filter_dir("/", 1);
} else
set_filter_dir(lp_path(i), module_dirlen);
p = lp_filter(i);
parse_rule(&server_filter_list, p, MATCHFLG_WORD_SPLIT,
XFLG_ANCHORED2ABS);
p = lp_include_from(i);
add_exclude_file(p, 1, 1);
parse_filter_file(&server_filter_list, p, MATCHFLG_INCLUDE,
XFLG_ANCHORED2ABS | XFLG_OLD_PREFIXES | XFLG_FATAL_ERRORS);
p = lp_include(i);
add_include_line(p);
parse_rule(&server_filter_list, p,
MATCHFLG_INCLUDE | MATCHFLG_WORD_SPLIT,
XFLG_ANCHORED2ABS | XFLG_OLD_PREFIXES);
p = lp_exclude_from(i);
add_exclude_file(p, 1, 0);
parse_filter_file(&server_filter_list, p, 0,
XFLG_ANCHORED2ABS | XFLG_OLD_PREFIXES | XFLG_FATAL_ERRORS);
p = lp_exclude(i);
add_exclude_line(p);
parse_rule(&server_filter_list, p, MATCHFLG_WORD_SPLIT,
XFLG_ANCHORED2ABS | XFLG_OLD_PREFIXES);
log_open();
log_init();
#ifdef HAVE_PUTENV
s = lp_prexfer_exec(i);
p = lp_postxfer_exec(i);
if ((s && *s) || (p && *p)) {
char *modname, *modpath, *hostaddr, *hostname, *username;
int status;
if (asprintf(&modname, "RSYNC_MODULE_NAME=%s", name) < 0
|| asprintf(&modpath, "RSYNC_MODULE_PATH=%s", lp_path(i)) < 0
|| asprintf(&hostaddr, "RSYNC_HOST_ADDR=%s", addr) < 0
|| asprintf(&hostname, "RSYNC_HOST_NAME=%s", host) < 0
|| asprintf(&username, "RSYNC_USER_NAME=%s", auth_user) < 0)
out_of_memory("rsync_module");
putenv(modname);
putenv(modpath);
putenv(hostaddr);
putenv(hostname);
putenv(username);
umask(orig_umask);
if (s && *s) {
status = system(s);
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
rprintf(FLOG, "prexfer-exec failed\n");
io_printf(f_out, "@ERROR: prexfer-exec failed\n");
return -1;
}
}
if (p && *p) {
pid_t pid = fork();
if (pid < 0) {
rsyserr(FLOG, errno, "fork failed");
io_printf(f_out, "@ERROR: fork failed\n");
return -1;
}
if (pid) {
char *ret1, *ret2;
waitpid(pid, &status, 0);
if (asprintf(&ret1, "RSYNC_RAW_STATUS=%d", status) > 0)
putenv(ret1);
if (WIFEXITED(status))
status = WEXITSTATUS(status);
else
status = -1;
if (asprintf(&ret2, "RSYNC_EXIT_STATUS=%d", status) > 0)
putenv(ret2);
system(p);
_exit(status);
}
}
umask(0);
}
#endif
if (use_chroot) {
/*
* XXX: The 'use chroot' flag is a fairly reliable
* source of confusion, because it fails under two
* important circumstances: running as non-root,
* running on Win32 (or possibly others). On the
* other hand, if you are running as root, then it
* might be better to always use chroot.
*
* So, perhaps if we can't chroot we should just issue
* a warning, unless a "require chroot" flag is set,
* in which case we fail.
*/
if (chroot(lp_path(i))) {
rprintf(FERROR,"chroot %s failed\n", lp_path(i));
io_printf(fd,"@ERROR: chroot failed\n");
rsyserr(FLOG, errno, "chroot %s failed",
safe_fname(lp_path(i)));
io_printf(f_out, "@ERROR: chroot failed\n");
return -1;
}
if (!push_dir("/", 0)) {
rprintf(FERROR,"chdir %s failed\n", lp_path(i));
io_printf(fd,"@ERROR: chdir failed\n");
if (!push_dir("/")) {
rsyserr(FLOG, errno, "chdir %s failed\n",
safe_fname(lp_path(i)));
io_printf(f_out, "@ERROR: chdir failed\n");
return -1;
}
} else {
if (!push_dir(lp_path(i), 0)) {
rprintf(FERROR,"chdir %s failed\n", lp_path(i));
io_printf(fd,"@ERROR: chdir failed\n");
if (!push_dir(lp_path(i))) {
rsyserr(FLOG, errno, "chdir %s failed\n",
safe_fname(lp_path(i)));
io_printf(f_out, "@ERROR: chdir failed\n");
return -1;
}
sanitize_paths = 1;
}
if (am_root) {
/* XXXX: You could argue that if the daemon is started
* by a non-root user and they explicitly specify a
* gid, then we should try to change to that gid --
* this could be possible if it's already in their
* supplementary groups. */
/* TODO: Perhaps we need to document that if rsyncd is
* started by somebody other than root it will inherit
* all their supplementary groups. */
if (setgid(gid)) {
rprintf(FERROR,"setgid %d failed\n", gid);
io_printf(fd,"@ERROR: setgid failed\n");
rsyserr(FLOG, errno, "setgid %d failed", (int)gid);
io_printf(f_out, "@ERROR: setgid failed\n");
return -1;
}
#ifdef HAVE_SETGROUPS
/* Get rid of any supplementary groups this process
* might have inheristed. */
if (setgroups(1, &gid)) {
rsyserr(FLOG, errno, "setgroups failed");
io_printf(f_out, "@ERROR: setgroups failed\n");
return -1;
}
#endif
if (setuid(uid)) {
rprintf(FERROR,"setuid %d failed\n", uid);
io_printf(fd,"@ERROR: setuid failed\n");
rsyserr(FLOG, errno, "setuid %d failed", (int)uid);
io_printf(f_out, "@ERROR: setuid failed\n");
return -1;
}
am_root = (getuid() == 0);
am_root = (MY_UID() == 0);
}
io_printf(fd,"@RSYNCD: OK\n");
io_printf(f_out, "@RSYNCD: OK\n");
maxargs = MAX_ARGS;
if (!(argv = new_array(char *, maxargs)))
out_of_memory("rsync_module");
argv[argc++] = "rsyncd";
while (1) {
if (!read_line(fd, line, sizeof(line)-1)) {
if (!read_line(f_in, line, sizeof line - 1))
return -1;
}
if (!*line) break;
if (!*line)
break;
p = line;
argv[argc] = strdup(p);
if (!argv[argc]) {
return -1;
if (argc == maxargs) {
maxargs += MAX_ARGS;
if (!(argv = realloc_array(argv, char *, maxargs)))
out_of_memory("rsync_module");
}
if (!(argv[argc] = strdup(p)))
out_of_memory("rsync_module");
if (start_glob) {
if (start_glob == 1) {
request = strdup(p);
start_glob++;
}
glob_expand(name, argv, &argc, MAX_ARGS, !use_chroot);
} else {
glob_expand(name, &argv, &argc, &maxargs);
} else
argc++;
}
if (strcmp(line,".") == 0) {
if (strcmp(line, ".") == 0)
start_glob = 1;
}
if (argc == MAX_ARGS) {
return -1;
}
}
if (!use_chroot) {
/*
* Note that this is applied to all parameters, whether or not
* they are filenames, but no other legal parameters contain
* the forms that need to be sanitized so it doesn't hurt;
* it is not known at this point which parameters are files
* and which aren't.
*/
for (i = 1; i < argc; i++) {
sanitize_path(argv[i]);
}
}
verbose = 0; /* future verbosity is controlled by client options */
argp = argv;
ret = parse_arguments(&argc, (const char ***) &argp, 0);
ret = parse_arguments(argc, argv, 0);
if (filesfrom_fd == 0)
filesfrom_fd = f_in;
if (request) {
if (*auth_user) {
rprintf(FINFO,"rsync %s %s from %s@%s (%s)\n",
am_sender?"on":"to",
rprintf(FLOG, "rsync %s %s from %s@%s (%s)\n",
am_sender ? "on" : "to",
request, auth_user, host, addr);
} else {
rprintf(FINFO,"rsync %s %s from %s (%s)\n",
am_sender?"on":"to",
rprintf(FLOG, "rsync %s %s from %s (%s)\n",
am_sender ? "on" : "to",
request, host, addr);
}
free(request);
}
#if !TRIDGE
#ifndef DEBUG
/* don't allow the logs to be flooded too fast */
if (verbose > 1) verbose = 1;
if (verbose > lp_max_verbosity(i))
verbose = lp_max_verbosity(i);
#endif
argc -= optind;
argp = argv + optind;
optind = 0;
if (remote_version > 17 && am_sender)
io_start_multiplex_out(fd);
if (protocol_version < 23
&& (protocol_version == 22 || am_sender))
io_start_multiplex_out();
else if (!ret) {
/* We have to get I/O multiplexing started so that we can
* get the error back to the client. This means getting
* the protocol setup finished first in later versions. */
setup_protocol(f_out, f_in);
if (!am_sender) {
/* Since we failed in our option parsing, we may not
* have finished parsing that the client sent us a
* --files-from option, so look for it manually.
* Without this, the socket would be in the wrong
* state for the upcoming error message. */
if (!files_from) {
int i;
for (i = 0; i < argc; i++) {
if (strncmp(argv[i], "--files-from", 12) == 0) {
files_from = "";
break;
}
}
}
if (files_from)
write_byte(f_out, 0);
}
io_start_multiplex_out();
}
if (!ret) {
option_error();
msleep(400);
exit_cleanup(RERR_UNSUPPORTED);
}
if (lp_timeout(i)) {
extern int io_timeout;
io_timeout = lp_timeout(i);
}
if (lp_timeout(i) && lp_timeout(i) > io_timeout)
set_io_timeout(lp_timeout(i));
start_server(fd, fd, argc, argp);
start_server(f_in, f_out, argc, argp);
return 0;
}
@@ -336,129 +586,143 @@ static void send_listing(int fd)
{
int n = lp_numservices();
int i;
for (i=0;i<n;i++)
for (i = 0; i < n; i++) {
if (lp_list(i))
io_printf(fd, "%-15s\t%s\n", lp_name(i), lp_comment(i));
io_printf(fd, "%-15s\t%s\n", lp_name(i), lp_comment(i));
}
if (protocol_version >= 25)
io_printf(fd,"@RSYNCD: EXIT\n");
}
/* this is called when a socket connection is established to a client
/* this is called when a connection is established to a client
and we want to start talking. The setup of the system is done from
here */
static int start_daemon(int fd)
int start_daemon(int f_in, int f_out)
{
char line[200];
char *motd;
int i = -1;
extern char *config_file;
extern int remote_version;
int i;
if (!lp_load(config_file, 0)) {
io_set_sock_fds(f_in, f_out);
if (!lp_load(config_file, 0))
exit_cleanup(RERR_SYNTAX);
log_init();
if (!am_server) {
set_socket_options(f_in, "SO_KEEPALIVE");
set_socket_options(f_in, lp_socket_options());
set_nonblocking(f_in);
}
set_socket_options(fd,"SO_KEEPALIVE");
set_socket_options(fd,lp_socket_options());
io_printf(fd,"@RSYNCD: %d\n", PROTOCOL_VERSION);
io_printf(f_out, "@RSYNCD: %d\n", protocol_version);
motd = lp_motd_file();
if (motd && *motd) {
FILE *f = fopen(motd,"r");
while (f && !feof(f)) {
int len = fread(line, 1, sizeof(line)-1, f);
int len = fread(line, 1, sizeof line - 1, f);
if (len > 0) {
line[len] = 0;
io_printf(fd,"%s", line);
io_printf(f_out, "%s", line);
}
}
if (f) fclose(f);
io_printf(fd,"\n");
if (f)
fclose(f);
io_printf(f_out, "\n");
}
if (!read_line(fd, line, sizeof(line)-1)) {
if (!read_line(f_in, line, sizeof line - 1))
return -1;
if (sscanf(line,"@RSYNCD: %d", &remote_protocol) != 1) {
io_printf(f_out, "@ERROR: protocol startup error\n");
return -1;
}
if (protocol_version > remote_protocol)
protocol_version = remote_protocol;
line[0] = 0;
if (!read_line(f_in, line, sizeof line - 1))
return -1;
if (!*line || strcmp(line, "#list") == 0) {
send_listing(f_out);
return -1;
}
if (sscanf(line,"@RSYNCD: %d", &remote_version) != 1) {
io_printf(fd,"@ERROR: protocol startup error\n");
if (*line == '#') {
/* it's some sort of command that I don't understand */
io_printf(f_out, "@ERROR: Unknown command '%s'\n", line);
return -1;
}
while (i == -1) {
line[0] = 0;
if (!read_line(fd, line, sizeof(line)-1)) {
return -1;
}
if (!*line || strcmp(line,"#list")==0) {
send_listing(fd);
return -1;
}
if (*line == '#') {
/* it's some sort of command that I don't understand */
io_printf(fd,"@ERROR: Unknown command '%s'\n", line);
return -1;
}
i = lp_number(line);
if (i == -1) {
io_printf(fd,"@ERROR: Unknown module '%s'\n", line);
return -1;
}
}
return rsync_module(fd, i);
if ((i = lp_number(line)) < 0) {
char *addr = client_addr(f_in);
char *host = client_name(f_in);
rprintf(FLOG, "unknown module '%s' tried from %s (%s)\n",
line, host, addr);
io_printf(f_out, "@ERROR: Unknown module '%s'\n", line);
return -1;
}
return rsync_module(f_in, f_out, i);
}
int daemon_main(void)
{
extern char *config_file;
extern int orig_umask;
char *pid_file;
if (is_a_socket(STDIN_FILENO)) {
int i;
/* we are running via inetd - close off stdout and
stderr so that library functions (and getopt) don't
try to use them. Redirect them to /dev/null */
for (i=1;i<3;i++) {
close(i);
* stderr so that library functions (and getopt) don't
* try to use them. Redirect them to /dev/null */
for (i = 1; i < 3; i++) {
close(i);
open("/dev/null", O_RDWR);
}
set_nonblocking(STDIN_FILENO);
return start_daemon(STDIN_FILENO);
return start_daemon(STDIN_FILENO, STDIN_FILENO);
}
become_daemon();
if (!no_detach)
become_daemon();
if (!lp_load(config_file, 1)) {
fprintf(stderr,"failed to load config file %s\n", config_file);
if (!lp_load(config_file, 1))
exit_cleanup(RERR_SYNTAX);
}
log_open();
if (rsync_port == 0 && (rsync_port = lp_rsync_port()) == 0)
rsync_port = RSYNC_PORT;
if (bind_address == NULL && *lp_bind_address())
bind_address = lp_bind_address();
rprintf(FINFO,"rsyncd version %s starting\n",VERSION);
log_init();
rprintf(FLOG, "rsyncd version %s starting, listening on port %d\n",
RSYNC_VERSION, rsync_port);
/* TODO: If listening on a particular address, then show that
* address too. In fact, why not just do inet_ntop on the
* local address??? */
if (((pid_file = lp_pid_file()) != NULL) && (*pid_file != '\0')) {
char pidbuf[16];
int fd;
int pid = (int) getpid();
pid_t pid = getpid();
cleanup_set_pid(pid);
if ((fd = do_open(lp_pid_file(), O_WRONLY|O_CREAT|O_TRUNC,
0666 & ~orig_umask)) == -1) {
cleanup_set_pid(0);
fprintf(stderr,"failed to create pid file %s\n", pid_file);
exit_cleanup(RERR_FILEIO);
cleanup_set_pid(0);
rsyserr(FLOG, errno, "failed to create pid file %s",
safe_fname(pid_file));
exit_cleanup(RERR_FILEIO);
}
slprintf(pidbuf, sizeof(pidbuf), "%d\n", pid);
snprintf(pidbuf, sizeof pidbuf, "%ld\n", (long)pid);
write(fd, pidbuf, strlen(pidbuf));
close(fd);
}
@@ -466,4 +730,3 @@ int daemon_main(void)
start_accept_loop(rsync_port, start_daemon);
return -1;
}

118
compat.c
View File

@@ -17,59 +17,93 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* compatability routines for older rsync protocol versions */
/**
* @file compat.c
*
* Compatibility routines for older rsync protocol versions.
**/
#include "rsync.h"
extern int am_server;
int remote_protocol = 0;
extern int csum_length;
extern int preserve_links;
extern int preserve_perms;
extern int preserve_devices;
extern int preserve_uid;
extern int preserve_gid;
extern int preserve_times;
extern int always_checksum;
extern int checksum_seed;
extern int remote_version;
extern int verbose;
extern int am_server;
extern int am_sender;
extern int inplace;
extern int fuzzy_basis;
extern int read_batch;
extern int checksum_seed;
extern int basis_dir_cnt;
extern int protocol_version;
extern char *dest_option;
void setup_protocol(int f_out,int f_in)
{
if (remote_version == 0) {
if (am_server) {
remote_version = read_int(f_in);
write_int(f_out,PROTOCOL_VERSION);
} else {
write_int(f_out,PROTOCOL_VERSION);
remote_version = read_int(f_in);
}
if (remote_protocol == 0) {
if (!read_batch)
write_int(f_out, protocol_version);
remote_protocol = read_int(f_in);
if (protocol_version > remote_protocol)
protocol_version = remote_protocol;
}
if (read_batch && remote_protocol > protocol_version) {
rprintf(FERROR, "The protocol version in the batch file is too new (%d > %d).\n",
remote_protocol, protocol_version);
exit_cleanup(RERR_PROTOCOL);
}
if (remote_version < MIN_PROTOCOL_VERSION ||
remote_version > MAX_PROTOCOL_VERSION) {
rprintf(FERROR,"protocol version mismatch - is your shell clean?\n");
if (verbose > 3) {
rprintf(FINFO, "(%s) Protocol versions: remote=%d, negotiated=%d\n",
am_server? "Server" : "Client", remote_protocol, protocol_version);
}
if (remote_protocol < MIN_PROTOCOL_VERSION
|| remote_protocol > MAX_PROTOCOL_VERSION) {
rprintf(FERROR,"protocol version mismatch -- is your shell clean?\n");
rprintf(FERROR,"(see the rsync man page for an explanation)\n");
exit_cleanup(RERR_PROTOCOL);
}
if (verbose > 2)
rprintf(FINFO, "local_version=%d remote_version=%d\n",
PROTOCOL_VERSION, remote_version);
if (remote_version >= 12) {
if (am_server) {
checksum_seed = time(NULL);
write_int(f_out,checksum_seed);
} else {
checksum_seed = read_int(f_in);
}
}
checksum_init();
}
if (remote_protocol < OLD_PROTOCOL_VERSION) {
rprintf(FINFO,"%s is very old version of rsync, upgrade recommended.\n",
am_server? "Client" : "Server");
}
if (protocol_version < MIN_PROTOCOL_VERSION) {
rprintf(FERROR, "--protocol must be at least %d on the %s.\n",
MIN_PROTOCOL_VERSION, am_server? "Server" : "Client");
exit_cleanup(RERR_PROTOCOL);
}
if (protocol_version > PROTOCOL_VERSION) {
rprintf(FERROR, "--protocol must be no more than %d on the %s.\n",
PROTOCOL_VERSION, am_server? "Server" : "Client");
exit_cleanup(RERR_PROTOCOL);
}
if (fuzzy_basis && protocol_version < 29) {
rprintf(FERROR,
"--fuzzy requires protocol 29 or higher (negotiated %d).\n",
protocol_version);
exit_cleanup(RERR_PROTOCOL);
}
if (basis_dir_cnt && inplace && protocol_version < 29) {
rprintf(FERROR,
"%s with --inplace requires protocol 29 or higher (negotiated %d).\n",
dest_option, protocol_version);
exit_cleanup(RERR_PROTOCOL);
}
if (basis_dir_cnt > 1 && protocol_version < 29) {
rprintf(FERROR,
"Multiple %s options requires protocol 29 or higher (negotiated %d).\n",
dest_option, protocol_version);
exit_cleanup(RERR_PROTOCOL);
}
if (am_server) {
if (!checksum_seed)
checksum_seed = time(NULL);
write_int(f_out, checksum_seed);
} else {
checksum_seed = read_int(f_in);
}
}

1119
config.guess vendored
View File

File diff suppressed because it is too large Load Diff

764
config.sub vendored
View File

File diff suppressed because it is too large Load Diff

View File

@@ -1,35 +1,327 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(byteorder.h)
AC_INIT()
AC_CONFIG_SRCDIR([byteorder.h])
AC_CONFIG_HEADER(config.h)
AC_PREREQ(2.59)
# compile with optimisation and without debugging by default
CFLAGS=${CFLAGS-"-O"}
RSYNC_VERSION=2.6.6
AC_SUBST(RSYNC_VERSION)
AC_MSG_NOTICE([Configuring rsync $RSYNC_VERSION])
AC_CANONICAL_SYSTEM
AC_VALIDATE_CACHE_SYSTEM_TYPE
AC_DEFINE_UNQUOTED(RSYNC_VERSION, ["$RSYNC_VERSION"], [rsync release version])
LDFLAGS=${LDFLAGS-""}
AC_CANONICAL_TARGET([])
dnl Checks for programs.
AC_PROG_CC
AC_PROG_CPP
AC_PROG_EGREP
AC_PROG_INSTALL
AC_PROG_CC_STDC
AC_SUBST(SHELL)
AC_DEFINE([_GNU_SOURCE], 1,
[Define _GNU_SOURCE so that we get all necessary prototypes])
if test "x$ac_cv_prog_cc_stdc" = xno
then
AC_MSG_WARN([rsync requires an ANSI C compiler and you don't seem to have one])
fi
# We must decide this before testing the compiler.
# Please allow this to default to yes, so that your users have more
# chance of getting a useful stack trace if problems occur.
AC_MSG_CHECKING([whether to include debugging symbols])
AC_ARG_ENABLE(debug,
AC_HELP_STRING([--enable-debug],
[including debugging symbols and features (default yes)]),
[], [])
if test x"$enable_debug" = x"no"
then
AC_MSG_RESULT(no)
CFLAGS=${CFLAGS-"-O"}
else
AC_MSG_RESULT([yes])
# leave CFLAGS alone; AC_PROG_CC will try to include -g if it can
dnl AC_DEFINE(DEBUG, 1, [Define to turn on debugging code that may slow normal operation])
dnl CFLAGS=${CFLAGS-"-g"}
fi
AC_ARG_ENABLE(profile,
AC_HELP_STRING([--enable-profile],
[turn on CPU profiling (default no)],
[], []))
if test x"$enable_profile" = xyes
then
CFLAGS="$CFLAGS -pg"
fi
# Specifically, this turns on panic_action handling.
AC_ARG_ENABLE(maintainer-mode,
AC_HELP_STRING([--enable-maintainer-mode],
[turn on extra debug features],
[], []))
if test x"$enable_maintainer_mode" = xyes
then
CFLAGS="$CFLAGS -DMAINTAINER_MODE"
fi
# This is needed for our included version of popt. Kind of silly, but
# I don't want our version too far out of sync.
CFLAGS="$CFLAGS -DHAVE_CONFIG_H"
# If GCC, turn on warnings.
if test x"$GCC" = x"yes"
then
CFLAGS="$CFLAGS -Wall -W"
fi
AC_ARG_WITH(included-popt,
[ --with-included-popt use bundled popt library, not from system])
AC_ARG_WITH(rsync-path,
[ --with-rsync-path=PATH set default --rsync-path to PATH (default: rsync)],
[ RSYNC_PATH="$with_rsync_path" ],
[ RSYNC_PATH="rsync" ])
AC_DEFINE_UNQUOTED(RSYNC_PATH, "$RSYNC_PATH", [location of rsync on remote machine])
AC_ARG_WITH(rsyncd-conf,
AC_HELP_STRING([--with-rsyncd-conf=PATH], [set configuration file for rsync server to PATH (default: /etc/rsyncd.conf)]),
[ if test ! -z "$with_rsyncd_conf" ; then
case $with_rsyncd_conf in
yes|no)
RSYNCD_SYSCONF="/etc/rsyncd.conf"
;;
/*)
RSYNCD_SYSCONF="$with_rsyncd_conf"
;;
*)
AC_MSG_ERROR(You must specify an absolute path to --with-rsyncd-conf=PATH)
;;
esac
else
RSYNCD_SYSCONF="/etc/rsyncd.conf"
fi ],
[ RSYNCD_SYSCONF="/etc/rsyncd.conf" ])
AC_DEFINE_UNQUOTED(RSYNCD_SYSCONF, "$RSYNCD_SYSCONF", [location of configuration file for rsync server])
AC_ARG_WITH(rsh,
AC_HELP_STRING([--with-rsh=CMD], [set remote shell command to CMD (default: ssh)]))
AC_CHECK_PROG(HAVE_REMSH, remsh, 1, 0)
AC_DEFINE_UNQUOTED(HAVE_REMSH, $HAVE_REMSH)
if test x$HAVE_REMSH = x1; then
AC_DEFINE(HAVE_REMSH, 1, [Define to 1 if remote shell is remsh, not rsh])
fi
if test x"$with_rsh" != x
then
RSYNC_RSH="$with_rsh"
else
RSYNC_RSH="ssh"
fi
AC_DEFINE_UNQUOTED(RSYNC_RSH, "$RSYNC_RSH", [default -e command])
AC_MSG_CHECKING([the group for user "nobody"])
if grep '^nobody:' /etc/group >/dev/null 2>&1; then
NOBODY_GROUP=nobody
elif grep '^nogroup:' /etc/group >/dev/null 2>&1; then
NOBODY_GROUP=nogroup
else
NOBODY_GROUP=nobody # test for others?
fi
AC_MSG_RESULT($NOBODY_GROUP)
AC_DEFINE_UNQUOTED(NOBODY_USER, "nobody", [unprivileged user--e.g. nobody])
AC_DEFINE_UNQUOTED(NOBODY_GROUP, "$NOBODY_GROUP", [unprivileged group for unprivileged user])
# arrgh. libc in the current debian stable screws up the largefile
# stuff, getting byte range locking wrong
AC_CACHE_CHECK([for broken largefile support],rsync_cv_HAVE_BROKEN_LARGEFILE,[
AC_TRY_RUN([
#define _FILE_OFFSET_BITS 64
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/wait.h>
int main(void)
{
struct flock lock;
int status;
char tpl[32] = "/tmp/locktest.XXXXXX";
int fd = mkstemp(tpl);
if (fd < 0) {
strcpy(tpl, "conftest.dat");
fd = open(tpl, O_CREAT|O_RDWR, 0600);
}
lock.l_type = F_WRLCK;
lock.l_whence = SEEK_SET;
lock.l_start = 0;
lock.l_len = 1;
lock.l_pid = 0;
fcntl(fd,F_SETLK,&lock);
if (fork() == 0) {
lock.l_start = 1;
_exit(fcntl(fd,F_SETLK,&lock) == 0);
}
wait(&status);
unlink(tpl);
exit(WEXITSTATUS(status));
}
],
rsync_cv_HAVE_BROKEN_LARGEFILE=yes,rsync_cv_HAVE_BROKEN_LARGEFILE=no,rsync_cv_HAVE_BROKEN_LARGEFILE=cross)])
if test x"$rsync_cv_HAVE_BROKEN_LARGEFILE" != x"yes"; then
AC_SYS_LARGEFILE
fi
ipv6type=unknown
ipv6lib=none
ipv6trylibc=yes
AC_ARG_ENABLE(ipv6,
AC_HELP_STRING([--disable-ipv6], [don't even try to use IPv6]))
dnl Do you want to disable use of locale functions
AH_TEMPLATE([CONFIG_LOCALE],
[Undefine if you don't want locale features. By default this is defined.])
AC_ARG_ENABLE([locale],
AC_HELP_STRING([--disable-locale], [turn off locale features]),
[if test x$enableval = xyes; then
AC_DEFINE(CONFIG_LOCALE)
fi],
AC_DEFINE(CONFIG_LOCALE)
)
if test "x$enable_ipv6" != xno
then
AC_MSG_CHECKING([ipv6 stack type])
for i in inria kame linux-glibc linux-inet6 toshiba v6d zeta; do
case $i in
inria)
# http://www.kame.net/
AC_EGREP_CPP(yes, [
#include <netinet/in.h>
#ifdef IPV6_INRIA_VERSION
yes
#endif],
[ipv6type=$i;
AC_DEFINE(INET6, 1, [true if you have IPv6])
])
;;
kame)
# http://www.kame.net/
AC_EGREP_CPP(yes, [
#include <netinet/in.h>
#ifdef __KAME__
yes
#endif],
[ipv6type=$i;
AC_DEFINE(INET6, 1, [true if you have IPv6])])
;;
linux-glibc)
# http://www.v6.linux.or.jp/
AC_EGREP_CPP(yes, [
#include <features.h>
#if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
yes
#endif],
[ipv6type=$i;
AC_DEFINE(INET6, 1, [true if you have IPv6])])
;;
linux-inet6)
# http://www.v6.linux.or.jp/
if test -d /usr/inet6 -o -f /usr/inet6/lib/libinet6.a; then
ipv6type=$i
ipv6lib=inet6
ipv6libdir=/usr/inet6/lib
ipv6trylibc=yes;
AC_DEFINE(INET6, 1, [true if you have IPv6])
CFLAGS="-I/usr/inet6/include $CFLAGS"
fi
;;
toshiba)
AC_EGREP_CPP(yes, [
#include <sys/param.h>
#ifdef _TOSHIBA_INET6
yes
#endif],
[ipv6type=$i;
ipv6lib=inet6;
ipv6libdir=/usr/local/v6/lib;
AC_DEFINE(INET6, 1, [true if you have IPv6])])
;;
v6d)
AC_EGREP_CPP(yes, [
#include </usr/local/v6/include/sys/v6config.h>
#ifdef __V6D__
yes
#endif],
[ipv6type=$i;
ipv6lib=v6;
ipv6libdir=/usr/local/v6/lib;
AC_DEFINE(INET6, 1, [true if you have IPv6])])
;;
zeta)
AC_EGREP_CPP(yes, [
#include <sys/param.h>
#ifdef _ZETA_MINAMI_INET6
yes
#endif],
[ipv6type=$i;
ipv6lib=inet6;
ipv6libdir=/usr/local/v6/lib;
AC_DEFINE(INET6, 1, [true if you have IPv6])])
;;
esac
if test "$ipv6type" != "unknown"; then
break
fi
done
AC_MSG_RESULT($ipv6type)
AC_SEARCH_LIBS(getaddrinfo, inet6)
fi
AC_MSG_CHECKING([whether to call shutdown on all sockets])
case $host_os in
*cygwin* ) AC_MSG_RESULT(yes)
AC_DEFINE(SHUTDOWN_ALL_SOCKETS, 1,
[Define to 1 if sockets need to be shutdown])
;;
* ) AC_MSG_RESULT(no);;
esac
AC_C_BIGENDIAN
AC_HEADER_DIRENT
AC_HEADER_TIME
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h unistd.h utime.h grp.h)
AC_CHECK_HEADERS(compat.h sys/param.h ctype.h sys/wait.h sys/ioctl.h)
AC_CHECK_HEADERS(sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h)
AC_CHECK_HEADERS(glob.h)
AC_CHECK_HEADERS(sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h \
unistd.h utime.h grp.h compat.h sys/param.h ctype.h sys/wait.h \
sys/ioctl.h sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h \
sys/un.h glob.h mcheck.h arpa/inet.h arpa/nameser.h locale.h \
netdb.h malloc.h float.h)
AC_HEADER_MAJOR
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(long long)
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(off_t)
AC_CHECK_SIZEOF(off64_t)
AC_C_INLINE
AC_C_LONG_DOUBLE
AC_TYPE_SIGNAL
AC_TYPE_UID_T
@@ -38,119 +330,21 @@ AC_TYPE_OFF_T
AC_TYPE_SIZE_T
AC_TYPE_PID_T
AC_TYPE_GETGROUPS
AC_STRUCT_ST_RDEV
AC_CHECK_TYPE(ino_t,unsigned)
AC_CHECK_MEMBERS([struct stat.st_rdev])
TYPE_SOCKLEN_T
AC_CACHE_CHECK([for errno in errno.h],rsync_cv_errno, [
AC_TRY_COMPILE([#include <errno.h>],[int i = errno],
rsync_cv_errno=yes,rsync_cv_have_errno_decl=no)])
if test x"$rsync_cv_errno" = x"yes"; then
AC_DEFINE(HAVE_ERRNO_DECL)
fi
AC_FUNC_MEMCMP
AC_FUNC_UTIME_NULL
AC_CHECK_FUNCS(waitpid wait4 getcwd strdup strerror chown chmod mknod)
AC_CHECK_FUNCS(fchmod fstat strchr readlink link utime utimes strftime)
AC_CHECK_FUNCS(memmove lchown vsnprintf snprintf setsid glob strpbrk)
AC_CHECK_FUNCS(strlcat strlcpy)
AC_CACHE_CHECK([for working fnmatch],rsync_cv_HAVE_FNMATCH,[
AC_TRY_RUN([#include <fnmatch.h>
main() { exit(fnmatch("*.o", "x.o", FNM_PATHNAME) == 0? 0: 1); }],
rsync_cv_HAVE_FNMATCH=yes,rsync_cv_HAVE_FNMATCH=no,rsync_cv_HAVE_FNMATCH=cross)])
if test x"$rsync_cv_HAVE_FNMATCH" = x"yes"; then
AC_DEFINE(HAVE_FNMATCH)
fi
# sometimes getopt_long cannot parse same arguments twice
# e.g. on certain versions of CygWin32
AC_CACHE_CHECK([for working getopt_long],rsync_cv_HAVE_GETOPT_LONG,[
AC_TRY_RUN([#include <getopt.h>
main() {
int i, x = 0; char *argv[] = { "x", "--xx" };
struct option o[] = {{"xx", 0, 0, 1}, {0,0,0,0}};
getopt_long(2, argv, "x", o, &i) == 1 ? x++ : 0; optind = 0;
getopt_long(2, argv, "x", o, &i) == 1 ? x++ : 0;
exit(x == 2 ? 0 : 1);
}], rsync_cv_HAVE_GETOPT_LONG=yes,rsync_cv_HAVE_GETOPT_LONG=no,
rsync_cv_HAVE_GETOPT_LONG=cross)])
if test x"$rsync_cv_HAVE_GETOPT_LONG" = x"yes"; then
AC_DEFINE(HAVE_GETOPT_LONG)
fi
AC_CACHE_CHECK([for long long],rsync_cv_HAVE_LONGLONG,[
AC_TRY_RUN([#include <stdio.h>
main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
rsync_cv_HAVE_LONGLONG=yes,rsync_cv_HAVE_LONGLONG=no,rsync_cv_HAVE_LONGLONG=cross)])
if test x"$rsync_cv_HAVE_LONGLONG" = x"yes"; then
AC_DEFINE(HAVE_LONGLONG)
fi
AC_CACHE_CHECK([for off64_t],rsync_cv_HAVE_OFF64_T,[
AC_TRY_RUN([#include <stdio.h>
#include <sys/stat.h>
main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
rsync_cv_HAVE_OFF64_T=yes,rsync_cv_HAVE_OFF64_T=no,rsync_cv_HAVE_OFF64_T=cross)])
if test x"$rsync_cv_HAVE_OFF64_T" = x"yes"; then
AC_DEFINE(HAVE_OFF64_T)
fi
AC_CACHE_CHECK([for short ino_t],rsync_cv_HAVE_SHORT_INO_T,[
AC_TRY_RUN([#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
main() { if (sizeof(ino_t) < sizeof(unsigned int)) return 0; return 1; }],
rsync_cv_HAVE_SHORT_INO_T=yes,rsync_cv_HAVE_SHORT_INO_T=no,rsync_cv_HAVE_SHORT_INO_T=cross)])
if test x"$rsync_cv_HAVE_SHORT_INO_T" = x"yes"; then
AC_DEFINE(HAVE_SHORT_INO_T)
fi
AC_CACHE_CHECK([for unsigned char],rsync_cv_HAVE_UNSIGNED_CHAR,[
AC_TRY_RUN([#include <stdio.h>
main() { char c; c=250; exit((c > 0)?0:1); }],
rsync_cv_HAVE_UNSIGNED_CHAR=yes,rsync_cv_HAVE_UNSIGNED_CHAR=no,rsync_cv_HAVE_UNSIGNED_CHAR=cross)])
if test x"$rsync_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
AC_DEFINE(HAVE_UNSIGNED_CHAR)
fi
AC_CACHE_CHECK([for broken readdir],rsync_cv_HAVE_BROKEN_READDIR,[
AC_TRY_RUN([#include <sys/types.h>
#include <dirent.h>
main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
di->d_name[0] == 0) exit(0); exit(1);} ],
rsync_cv_HAVE_BROKEN_READDIR=yes,rsync_cv_HAVE_BROKEN_READDIR=no,rsync_cv_HAVE_BROKEN_READDIR=cross)])
if test x"$rsync_cv_HAVE_BROKEN_READDIR" = x"yes"; then
AC_DEFINE(HAVE_BROKEN_READDIR)
fi
AC_CACHE_CHECK([for utimbuf],rsync_cv_HAVE_UTIMBUF,[
AC_TRY_COMPILE([#include <sys/types.h>
#include <utime.h>],
[struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
rsync_cv_HAVE_UTIMBUF=yes,rsync_cv_HAVE_UTIMBUF=no,rsync_cv_HAVE_UTIMBUF=cross)])
if test x"$rsync_cv_HAVE_UTIMBUF" = x"yes"; then
AC_DEFINE(HAVE_UTIMBUF)
fi
AC_CACHE_CHECK([for broken inet_ntoa],rsync_cv_REPLACE_INET_NTOA,[
AC_TRY_RUN([
#include <stdio.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
main() { struct in_addr ip; ip.s_addr = 0x12345678;
if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); }
exit(1);}],
rsync_cv_REPLACE_INET_NTOA=yes,rsync_cv_REPLACE_INET_NTOA=no,rsync_cv_REPLACE_INET_NTOA=cross)])
if test x"$rsync_cv_REPLACE_INET_NTOA" = x"yes"; then
AC_DEFINE(REPLACE_INET_NTOA)
AC_DEFINE(HAVE_ERRNO_DECL, 1, [Define to 1 if errno is declared in errno.h])
fi
# The following test taken from the cvs sources
# If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
# These need checks to be before checks for any other functions that
# might be in the same libraries.
# The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
# libsocket.so which has a bad implementation of gethostbyname (it
# only looks in /etc/hosts), so we only look for -lsocket if we need
@@ -175,15 +369,119 @@ if test x"$ac_cv_func_connect" = x"no"; then
esac
dnl We can't just call AC_CHECK_FUNCS(connect) here, because the value
dnl has been cached.
if test x"$ac_cv_lib_socket_connect" = x"yes" ||
if test x"$ac_cv_lib_socket_connect" = x"yes" ||
test x"$ac_cv_lib_inet_connect" = x"yes"; then
# ac_cv_func_connect=yes
# don't! it would cause AC_CHECK_FUNC to succeed next time configure is run
AC_DEFINE(HAVE_CONNECT)
AC_DEFINE(HAVE_CONNECT, 1, [Define to 1 if you have the "connect" function])
fi
fi
#
AC_CHECK_LIB(resolv, inet_ntop)
dnl AC_MSG_NOTICE([Looking in libraries: $LIBS])
AC_CHECK_FUNCS(inet_ntop, , [AC_LIBOBJ(lib/inet_ntop)])
AC_CHECK_FUNCS(inet_pton, , [AC_LIBOBJ(lib/inet_pton)])
# Irix 6.5 has getaddrinfo but not the corresponding defines, so use
# builtin getaddrinfo if one of the defines don't exist
AC_CACHE_CHECK([whether defines needed by getaddrinfo exist],
rsync_cv_HAVE_GETADDR_DEFINES,[
AC_EGREP_CPP(yes, [
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#ifdef AI_PASSIVE
yes
#endif],
rsync_cv_HAVE_GETADDR_DEFINES=yes,
rsync_cv_HAVE_GETADDR_DEFINES=no)])
if test x"$rsync_cv_HAVE_GETADDR_DEFINES" = x"yes"; then
# Tru64 UNIX has getaddrinfo() but has it renamed in libc as
# something else so we must include <netdb.h> to get the
# redefinition.
AC_CHECK_FUNCS(getaddrinfo, ,
[AC_MSG_CHECKING([for getaddrinfo by including <netdb.h>])
AC_TRY_LINK([#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>],[getaddrinfo(NULL, NULL, NULL, NULL);],
[AC_MSG_RESULT([yes])
AC_DEFINE(HAVE_GETADDRINFO, 1,
[Define to 1 if you have the "getaddrinfo" function.])],
[AC_MSG_RESULT([no])
AC_LIBOBJ(lib/getaddrinfo)])])
AC_CHECK_FUNCS(getnameinfo, , [AC_LIBOBJ(lib/getnameinfo)])
else
AC_LIBOBJ(lib/getaddrinfo)
AC_LIBOBJ(lib/getnameinfo)
fi
AC_CHECK_MEMBER([struct sockaddr.sa_len],
[ AC_DEFINE(HAVE_SOCKADDR_LEN, 1, [Do we have sockaddr.sa_len?]) ],
[],
[
#include <sys/types.h>
#include <sys/socket.h>
])
AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
[ AC_DEFINE(HAVE_SOCKADDR_IN_LEN, 1, [Do we have sockaddr_in.sin_len?]) ],
[],
[
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
])
AC_CHECK_MEMBER([struct sockaddr_un.sun_len],
[ AC_DEFINE(HAVE_SOCKADDR_UN_LEN, 1, [Do we have sockaddr_un.sun_len?]) ],
[],
[
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
])
AC_MSG_CHECKING(struct sockaddr_storage)
AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/socket.h>],
[struct sockaddr_storage x;],
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1,
[Define to 1 if you have struct sockaddr_storage.] ),
AC_MSG_RESULT(no))
AC_CHECK_MEMBER([struct sockaddr_in6.sin6_scope_id],
[ AC_DEFINE(HAVE_SOCKADDR_IN6_SCOPE_ID, 1, [Do we have sockaddr_in6.sin6_scope_id?]) ],
[],
[
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
])
AC_MSG_CHECKING(struct stat64)
AC_TRY_COMPILE([#include <stdio.h>
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#if HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#if STDC_HEADERS
# include <stdlib.h>
# include <stddef.h>
#else
# if HAVE_STDLIB_H
# include <stdlib.h>
# endif
#endif
],[struct stat64 st;],
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_STRUCT_STAT64,1,[Define to 1 if you have struct stat64.]),
AC_MSG_RESULT(no))
# if we can't find strcasecmp, look in -lresolv (for Unixware at least)
#
AC_CHECK_FUNCS(strcasecmp)
@@ -191,6 +489,231 @@ if test x"$ac_cv_func_strcasecmp" = x"no"; then
AC_CHECK_LIB(resolv, strcasecmp)
fi
dnl At the moment we don't test for a broken memcmp(), because all we
dnl need to do is test for equality, not comparison, and it seems that
dnl every platform has a memcmp that can do at least that.
dnl AC_FUNC_MEMCMP
AC_FUNC_UTIME_NULL
AC_FUNC_ALLOCA
AC_CHECK_FUNCS(waitpid wait4 getcwd strdup strerror chown chmod mknod mkfifo \
fchmod fstat strchr readlink link utime utimes strftime mtrace ftruncate \
memmove lchown vsnprintf snprintf vasprintf asprintf setsid glob strpbrk \
strlcat strlcpy strtol mallinfo getgroups setgroups geteuid getegid \
setlocale setmode open64 lseek64 mkstemp64 va_copy __va_copy)
AC_CHECK_FUNCS(getpgrp tcgetpgrp)
if test $ac_cv_func_getpgrp = yes; then
AC_FUNC_GETPGRP
fi
# Determine whether chown follows symlinks (it should).
AC_CACHE_CHECK([whether chown() dereferences symlinks],rsync_cv_chown_follows_symlink,[
AC_TRY_RUN([
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <stdlib.h>
#include <errno.h>
main() {
char const *dangling_symlink = "conftest.dangle";
unlink(dangling_symlink);
if (symlink("conftest.no-such", dangling_symlink) < 0) abort();
if (chown(dangling_symlink, getuid(), getgid()) < 0 && errno == ENOENT) exit(0);
exit(1);
}],
rsync_cv_chown_follows_symlink=yes,rsync_cv_chown_follows_symlink=no,rsync_cv_chown_follows_symlink=yes)])
if test $rsync_cv_chown_follows_symlink = no; then
AC_DEFINE(CHOWN_MODIFIES_SYMLINK, 1, [Define to 1 if chown modifies symlinks.])
fi
AC_CACHE_CHECK([for working socketpair],rsync_cv_HAVE_SOCKETPAIR,[
AC_TRY_RUN([
#include <sys/types.h>
#include <sys/socket.h>
main() {
int fd[2];
exit((socketpair(AF_UNIX, SOCK_STREAM, 0, fd) != -1) ? 0 : 1);
}],
rsync_cv_HAVE_SOCKETPAIR=yes,rsync_cv_HAVE_SOCKETPAIR=no,rsync_cv_HAVE_SOCKETPAIR=cross)])
if test x"$rsync_cv_HAVE_SOCKETPAIR" = x"yes"; then
AC_DEFINE(HAVE_SOCKETPAIR, 1, [Define to 1 if you have the "socketpair" function])
fi
if test x"$with_included_popt" != x"yes"
then
AC_CHECK_LIB(popt, poptGetContext, , [with_included_popt=yes])
fi
AC_MSG_CHECKING([whether to use included libpopt])
if test x"$with_included_popt" = x"yes"
then
AC_MSG_RESULT($srcdir/popt)
BUILD_POPT='$(popt_OBJS)'
CFLAGS="$CFLAGS -I$srcdir/popt"
if test x"$ALLOCA" != x
then
# this can be removed when/if we add an included alloca.c;
# see autoconf documentation on AC_FUNC_ALLOCA
AC_MSG_WARN([included libpopt will use malloc, not alloca (which wastes a small amount of memory)])
fi
else
AC_MSG_RESULT(no)
fi
AC_CACHE_CHECK([for unsigned char],rsync_cv_SIGNED_CHAR_OK,[
AC_TRY_COMPILE([],[signed char *s = ""],
rsync_cv_SIGNED_CHAR_OK=yes,rsync_cv_SIGNED_CHAR_OK=no)])
if test x"$rsync_cv_SIGNED_CHAR_OK" = x"yes"; then
AC_DEFINE(SIGNED_CHAR_OK, 1, [Define to 1 if "signed char" is a valid type])
fi
AC_CACHE_CHECK([for broken readdir],rsync_cv_HAVE_BROKEN_READDIR,[
AC_TRY_RUN([#include <sys/types.h>
#include <dirent.h>
main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
di->d_name[0] == 0) exit(0); exit(1);} ],
rsync_cv_HAVE_BROKEN_READDIR=yes,rsync_cv_HAVE_BROKEN_READDIR=no,rsync_cv_HAVE_BROKEN_READDIR=cross)])
if test x"$rsync_cv_HAVE_BROKEN_READDIR" = x"yes"; then
AC_DEFINE(HAVE_BROKEN_READDIR, 1, [Define to 1 if readdir() is broken])
fi
AC_CACHE_CHECK([for utimbuf],rsync_cv_HAVE_UTIMBUF,[
AC_TRY_COMPILE([#include <sys/types.h>
#include <utime.h>],
[struct utimbuf tbuf; tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
rsync_cv_HAVE_UTIMBUF=yes,rsync_cv_HAVE_UTIMBUF=no)])
if test x"$rsync_cv_HAVE_UTIMBUF" = x"yes"; then
AC_DEFINE(HAVE_UTIMBUF, 1, [Define to 1 if you have the "struct utimbuf" type])
fi
AC_CACHE_CHECK([if gettimeofday takes tz argument],rsync_cv_HAVE_GETTIMEOFDAY_TZ,[
AC_TRY_COMPILE([#include <sys/time.h>
#include <unistd.h>],
[struct timeval tv; exit(gettimeofday(&tv, NULL));],
rsync_cv_HAVE_GETTIMEOFDAY_TZ=yes,rsync_cv_HAVE_GETTIMEOFDAY_TZ=no)])
if test x"$rsync_cv_HAVE_GETTIMEOFDAY_TZ" != x"no"; then
AC_DEFINE(HAVE_GETTIMEOFDAY_TZ, 1, [Define to 1 if gettimeofday() takes a time-zone arg])
fi
AC_CACHE_CHECK([for C99 vsnprintf],rsync_cv_HAVE_C99_VSNPRINTF,[
AC_TRY_RUN([
#include <sys/types.h>
#include <stdarg.h>
void foo(const char *format, ...) {
va_list ap;
int len;
char buf[5];
va_start(ap, format);
len = vsnprintf(0, 0, format, ap);
va_end(ap);
if (len != 5) exit(1);
if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
exit(0);
}
main() { foo("hello"); }
],
rsync_cv_HAVE_C99_VSNPRINTF=yes,rsync_cv_HAVE_C99_VSNPRINTF=no,rsync_cv_HAVE_C99_VSNPRINTF=cross)])
if test x"$rsync_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [Define to 1 if vsprintf has a C99-compatible return value])
fi
AC_CACHE_CHECK([for secure mkstemp],rsync_cv_HAVE_SECURE_MKSTEMP,[
AC_TRY_RUN([#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
main() {
struct stat st;
char tpl[20]="/tmp/test.XXXXXX";
int fd = mkstemp(tpl);
if (fd == -1) exit(1);
unlink(tpl);
if (fstat(fd, &st) != 0) exit(1);
if ((st.st_mode & 0777) != 0600) exit(1);
exit(0);
}],
rsync_cv_HAVE_SECURE_MKSTEMP=yes,
rsync_cv_HAVE_SECURE_MKSTEMP=no,
rsync_cv_HAVE_SECURE_MKSTEMP=cross)])
if test x"$rsync_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
case $target_os in
hpux*)
dnl HP-UX has a broken mkstemp() implementation they refuse to fix,
dnl so we noisily skip using it. See HP change request JAGaf34426
dnl for details. (sbonds)
AC_MSG_WARN(Skipping broken HP-UX mkstemp() -- using mktemp() instead)
;;
*)
AC_DEFINE(HAVE_SECURE_MKSTEMP, 1, [Define to 1 if mkstemp() is available and works right])
;;
esac
fi
AC_CACHE_CHECK([for broken inet_ntoa],rsync_cv_REPLACE_INET_NTOA,[
AC_TRY_RUN([
#include <stdio.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
main() { struct in_addr ip; ip.s_addr = 0x12345678;
if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(1); }
exit(0);}],
rsync_cv_REPLACE_INET_NTOA=no,rsync_cv_REPLACE_INET_NTOA=yes,rsync_cv_REPLACE_INET_NTOA=cross)])
if test x"$rsync_cv_REPLACE_INET_NTOA" = x"yes"; then
AC_DEFINE(REPLACE_INET_NTOA, 1, [Define to 1 if inet_ntoa() needs to be replaced])
fi
AC_CACHE_CHECK([for broken inet_aton],rsync_cv_REPLACE_INET_ATON,[
AC_TRY_RUN([
#include <stdio.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
main() { struct in_addr ip;
if (inet_aton("example", &ip) == 0) exit(0); exit(1);}],
rsync_cv_REPLACE_INET_ATON=no,rsync_cv_REPLACE_INET_ATON=yes,rsync_cv_REPLACE_INET_ATON=cross)])
if test x"$rsync_cv_REPLACE_INET_ATON" = x"yes"; then
AC_DEFINE(REPLACE_INET_ATON, 1, [Define to 1 if inet_aton() needs to be replaced])
fi
AC_CACHE_CHECK([if mknod creates FIFOs],rsync_cv_MKNOD_CREATES_FIFOS,[
AC_TRY_RUN([
#include <stdio.h>
#include <sys/stat.h>
#include <errno.h>
main() { int rc, ec; char *fn = "fifo-test";
unlink(fn); rc = mknod(fn,S_IFIFO,0600); ec = errno; unlink(fn);
if (rc) {printf("%d %d\n",rc,ec); return ec;}
return 0;}],
rsync_cv_MKNOD_CREATES_FIFOS=yes,rsync_cv_MKNOD_CREATES_FIFOS=no,rsync_cv_MKNOD_CREATES_FIFOS=cross)])
if test x"$rsync_cv_MKNOD_CREATES_FIFOS" = x"yes"; then
AC_DEFINE(MKNOD_CREATES_FIFOS, 1, [Define to 1 if mknod() can create FIFOs.])
fi
AC_CACHE_CHECK([if mknod creates sockets],rsync_cv_MKNOD_CREATES_SOCKETS,[
AC_TRY_RUN([
#include <stdio.h>
#include <sys/stat.h>
#include <errno.h>
main() { int rc, ec; char *fn = "sock-test";
unlink(fn); rc = mknod(fn,S_IFSOCK,0600); ec = errno; unlink(fn);
if (rc) {printf("%d %d\n",rc,ec); return ec;}
return 0;}],
rsync_cv_MKNOD_CREATES_SOCKETS=yes,rsync_cv_MKNOD_CREATES_SOCKETS=no,rsync_cv_MKNOD_CREATES_SOCKETS=cross)])
if test x"$rsync_cv_MKNOD_CREATES_SOCKETS" = x"yes"; then
AC_DEFINE(MKNOD_CREATES_SOCKETS, 1, [Define to 1 if mknod() can create sockets.])
fi
#
# The following test was mostly taken from the tcl/tk plus patches
#
@@ -220,6 +743,11 @@ fi
AC_SUBST(OBJ_SAVE)
AC_SUBST(OBJ_RESTORE)
AC_SUBST(CC_SHOBJ_FLAG)
AC_SUBST(BUILD_POPT)
AC_CONFIG_FILES([Makefile lib/dummy zlib/dummy popt/dummy shconfig])
AC_OUTPUT
AC_OUTPUT(Makefile lib/dummy zlib/dummy)
AC_MSG_RESULT()
AC_MSG_RESULT([ rsync ${RSYNC_VERSION} configuration successful])
AC_MSG_RESULT()

82
csprotocol.txt Normal file
View File

@@ -0,0 +1,82 @@
This is kind of informal and may be wrong, but it helped me. It's
basically a summary of clientserver.c and authenticate.c.
-- Martin Pool <mbp@samba.org>
$Id$
This is the protocol used for rsync --daemon; i.e. connections to port
873 rather than invocations over a remote shell.
When the server accepts a connection, it prints a greeting
@RSYNCD: <version>
where <version> is the numeric version; currently 24. It follows this
with a free text message-of-the-day. It expects to see a similar
greeting back from the client.
The server is now in the connected state. The client can either send
the command
#list
to get a listing of modules, or the name of a module. After this, the
connection is now bound to a particular module. Access per host for
this module is now checked, as is per-module connection limits.
If authentication is required to use this module, the server will say
@RSYNCD: AUTHREQD <challenge>
where <challenge> is a random string of base64 characters. The client
must respond with
<user> <response>
where <user> is the username they claim to be, and <response> is the
base64 form of the MD4 hash of challenge+password.
At this point the server applies all remaining constraints before
handing control to the client, including switching uid/gid, setting up
include and exclude lists, moving to the root of the module, and doing
chroot.
If the login is acceptable, then the server will respond with
@RSYNCD: OK
The client now writes some rsync options, as if it were remotely
executing the command. The server parses these arguments as if it had
just been invoked with them, but they're added to the existing state.
So if the client specifies a list of files to be included or excluded,
they'll defer to existing limits specified in the server
configuration.
At this point the client and server both switch to using a
multiplexing layer across the socket. The main point of this is to
allow the server to asynchronously pass errors back, while still
allowing streamed and pipelined data.
Unfortunately, the multiplex protocol is not used at every stage. We
start up in plain socket mode and then change over by calling
io_start_buffering. Of course both the client and the server have to
do this at the same point.
The server then talks to the client as normal across the socket,
passing checksums, file lists and so on. For documentation of that,
stay tuned (or write it yourself!).
------------
Protocol version changes
25 (2001-08-20, 2.4.7pre2)
Send an explicit "@RSYNC EXIT" command at the end of the
module listing. We never intentionally end the transmission
by just closing the socket anymore.

2
doc/.cvsignore Normal file
View File

@@ -0,0 +1,2 @@
rsync.pdf
rsync.ps

20
doc/README-SGML Normal file
View File

@@ -0,0 +1,20 @@
Handling the rsync SGML documentation
rsync documentation is now primarily in Docbook format. Docbook is an
SGML/XML documentation format that is becoming standard on free
operating systems. It's also used for Samba documentation.
The SGML files are source code that can be translated into various
useful output formats, primarily PDF, HTML, Postscript and plain text.
To do this transformation on Debian, you should install the
docbook-utils package. Having done that, you can say
docbook2pdf rsync.sgml
and so on.
On other systems you probably need James Clark's "sp" and "JadeTeX"
packages. Work it out for yourself and send a note to the mailing
list.

42
doc/profile.txt Normal file
View File

@@ -0,0 +1,42 @@
Notes on rsync profiling
strlcpy is hot:
0.00 0.00 1/7735635 push_dir [68]
0.00 0.00 1/7735635 pop_dir [71]
0.00 0.00 1/7735635 send_file_list [15]
0.01 0.00 18857/7735635 send_files [4]
0.04 0.00 129260/7735635 send_file_entry [18]
0.04 0.00 129260/7735635 make_file [20]
0.04 0.00 141666/7735635 send_directory <cycle 1> [36]
2.29 0.00 7316589/7735635 f_name [13]
[14] 11.7 2.42 0.00 7735635 strlcpy [14]
Here's the top few functions:
46.23 9.57 9.57 13160929 0.00 0.00 mdfour64
14.78 12.63 3.06 13160929 0.00 0.00 copy64
11.69 15.05 2.42 7735635 0.00 0.00 strlcpy
10.05 17.13 2.08 41438 0.05 0.38 sum_update
4.11 17.98 0.85 13159996 0.00 0.00 mdfour_update
1.50 18.29 0.31 file_compare
1.45 18.59 0.30 129261 0.00 0.01 send_file_entry
1.23 18.84 0.26 2557585 0.00 0.00 f_name
1.11 19.07 0.23 1483750 0.00 0.00 u_strcmp
1.11 19.30 0.23 118129 0.00 0.00 writefd_unbuffered
0.92 19.50 0.19 1085011 0.00 0.00 writefd
0.43 19.59 0.09 156987 0.00 0.00 read_timeout
0.43 19.68 0.09 129261 0.00 0.00 clean_fname
0.39 19.75 0.08 32887 0.00 0.38 matched
0.34 19.82 0.07 1 70.00 16293.92 send_files
0.29 19.89 0.06 129260 0.00 0.00 make_file
0.29 19.95 0.06 75430 0.00 0.00 read_unbuffered
mdfour could perhaps be made faster:
/* NOTE: This code makes no attempt to be fast! */
There might be an optimized version somewhere that we can borrow.

351
doc/rsync.sgml Normal file
View File

@@ -0,0 +1,351 @@
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V4.1//EN">
<book id="rsync">
<bookinfo>
<title>rsync</title>
<copyright>
<year>1996 -- 2002</year>
<holder>Martin Pool</holder>
<holder>Andrew Tridgell</holder>
</copyright>
<author>
<firstname>Martin</firstname>
<surname>Pool</surname>
</author>
</bookinfo>
<chapter>
<title>Introduction</title>
<para>rsync is a flexible program for efficiently copying files or
directory trees.
<para>rsync has many options to select which files will be copied
and how they are to be transferred. It may be used as an
alternative to ftp, http, scp or rcp.
<para>The rsync remote-update protocol allows rsync to transfer just
the differences between two sets of files across the network link,
using an efficient checksum-search algorithm described in the
technical report that accompanies this package.</para>
<para>Some of the additional features of rsync are:</para>
<itemizedlist>
<listitem>
<para>support for copying links, devices, owners, groups and
permissions
</para>
</listitem>
<listitem>
<para>
exclude and exclude-from options similar to GNU tar
</para>
</listitem>
<listitem>
<para>
a CVS exclude mode for ignoring the same files that CVS would ignore
</listitem>
<listitem>
<para>
can use any transparent remote shell, including rsh or ssh
</listitem>
<listitem>
<para>
does not require root privileges
</listitem>
<listitem>
<para>
pipelining of file transfers to minimize latency costs
</listitem>
<listitem>
<para>
support for anonymous or authenticated rsync servers (ideal for
mirroring)
</para>
</listitem>
</itemizedlist>
</chapter>
<chapter>
<title>Using rsync</title>
<section>
<title>
Introductory example
</title>
<para>
Probably the most common case of rsync usage is to copy files
to or from a remote machine using
<application>ssh</application> as a network transport. In
this situation rsync is a good alternative to
<application>scp</application>.
</para>
<para>
The most commonly used arguments for rsync are
</para>
<variablelist>
<varlistentry>
<term><option>-v</option></term>
<listitem>
<para>Be verbose. Primarily, display the name of each file as it is copied.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-a</option></term>
<listitem>
<para>
Reproduce the structure and attributes of the origin files as exactly
as possible: this includes copying subdirectories, symlinks, special
files, ownership and permissions. (@xref{Attributes to
copy}.)
</para>
</listitem>
</varlistentry>
</variablelist>
<para><option>-v </option>
<para><option>-z</option>
Compress network traffic, using a modified version of the
@command{zlib} library.</para>
<para><option>-P</option>
Display a progress indicator while files are transferred. This should
normally be ommitted if rsync is not run on a terminal.
</para>
</section>
<section>
<title>Local and remote</title>
<para>There are six different ways of using rsync. They
are:</para>
<!-- one of (CALLOUTLIST GLOSSLIST ITEMIZEDLIST ORDEREDLIST SEGMENTEDLIST SIMPLELIST VARIABLELIST CAUTION IMPORTANT NOTE TIP WARNING LITERALLAYOUT PROGRAMLISTING PROGRAMLISTINGCO SCREEN SCREENCO SCREENSHOT SYNOPSIS CMDSYNOPSIS FUNCSYNOPSIS CLASSSYNOPSIS FIELDSYNOPSIS CONSTRUCTORSYNOPSIS DESTRUCTORSYNOPSIS METHODSYNOPSIS FORMALPARA PARA SIMPARA ADDRESS BLOCKQUOTE GRAPHIC GRAPHICCO MEDIAOBJECT MEDIAOBJECTCO INFORMALEQUATION INFORMALEXAMPLE INFORMALFIGURE INFORMALTABLE EQUATION EXAMPLE FIGURE TABLE MSGSET PROCEDURE SIDEBAR QANDASET ANCHOR BRIDGEHEAD REMARK HIGHLIGHTS ABSTRACT AUTHORBLURB EPIGRAPH INDEXTERM REFENTRY SECTION) -->
<orderedlist>
<listitem>
<para>
for copying local files. This is invoked when neither
source nor destination path contains a @code{:} separator
<listitem>
<para>
for copying from the local machine to a remote machine using
a remote shell program as the transport (such as rsh or
ssh). This is invoked when the destination path contains a
single @code{:} separator.
<listitem>
<para>
for copying from a remote machine to the local machine
using a remote shell program. This is invoked when the source
contains a @code{:} separator.
<listitem>
<para>
for copying from a remote rsync server to the local
machine. This is invoked when the source path contains a @code{::}
separator or a @code{rsync://} URL.
<listitem>
<para>
for copying from the local machine to a remote rsync
server. This is invoked when the destination path contains a @code{::}
separator.
<listitem>
<para>
for listing files on a remote machine. This is done the
same way as rsync transfers except that you leave off the
local destination.
</listitem>
</orderedlist>
<para>
Note that in all cases (other than listing) at least one of the source
and destination paths must be local.
<para>
Any one invocation of rsync makes a copy in a single direction. rsync
currently has no equivalent of @command{ftp}'s interactive mode.
@cindex @sc{nfs}
@cindex network filesystems
@cindex remote filesystems
<para>
rsync's network protocol is generally faster at copying files than
network filesystems such as @sc{nfs} or @sc{cifs}. It is better to
run rsync on the file server either as a daemon or over ssh than
running rsync giving the network directory.
</para>
</section>
</chapter>
<chapter>
<title>Frequently asked questions</title>
<!-- one of (CALLOUTLIST GLOSSLIST ITEMIZEDLIST ORDEREDLIST SEGMENTEDLIST SIMPLELIST VARIABLELIST CAUTION IMPORTANT NOTE TIP WARNING LITERALLAYOUT PROGRAMLISTING PROGRAMLISTINGCO SCREEN SCREENCO SCREENSHOT SYNOPSIS CMDSYNOPSIS FUNCSYNOPSIS CLASSSYNOPSIS FIELDSYNOPSIS CONSTRUCTORSYNOPSIS DESTRUCTORSYNOPSIS METHODSYNOPSIS FORMALPARA PARA SIMPARA ADDRESS BLOCKQUOTE GRAPHIC GRAPHICCO MEDIAOBJECT MEDIAOBJECTCO INFORMALEQUATION INFORMALEXAMPLE INFORMALFIGURE INFORMALTABLE EQUATION EXAMPLE FIGURE TABLE MSGSET PROCEDURE SIDEBAR QANDASET ANCHOR BRIDGEHEAD REMARK HIGHLIGHTS ABSTRACT AUTHORBLURB EPIGRAPH INDEXTERM SECTION SIMPLESECT REFENTRY SECT1) -->
<qandaset>
<!-- one of (QANDADIV QANDAENTRY) -->
<qandaentry>
<question>
<!-- one of (CALLOUTLIST GLOSSLIST ITEMIZEDLIST ORDEREDLIST
SEGMENTEDLIST SIMPLELIST VARIABLELIST CAUTION IMPORTANT NOTE
TIP WARNING LITERALLAYOUT PROGRAMLISTING PROGRAMLISTINGCO
SCREEN SCREENCO SCREENSHOT SYNOPSIS CMDSYNOPSIS FUNCSYNOPSIS
CLASSSYNOPSIS FIELDSYNOPSIS CONSTRUCTORSYNOPSIS
DESTRUCTORSYNOPSIS METHODSYNOPSIS FORMALPARA PARA SIMPARA
ADDRESS BLOCKQUOTE GRAPHIC GRAPHICCO MEDIAOBJECT
MEDIAOBJECTCO INFORMALEQUATION INFORMALEXAMPLE
INFORMALFIGURE INFORMALTABLE EQUATION EXAMPLE FIGURE TABLE
PROCEDURE ANCHOR BRIDGEHEAD REMARK HIGHLIGHTS INDEXTERM) -->
<para>Are there mailing lists for rsync?
</question>
<answer>
<para>Yes, and you can subscribe and unsubscribe through a
web interface at
<ulink
url="http://lists.samba.org/">http://lists.samba.org/</ulink>
</para>
<para>
If you are having trouble with the mailing list, please
send mail to the administrator
<email>rsync-admin@lists.samba.org</email>
not to the list itself.
</para>
<para>
The mailing list archives are searchable. Use
<ulink url="http://google.com/">Google</ulink> and prepend
the search with <userinput>site:lists.samba.org
rsync</userinput>, plus relevant keywords.
</para>
</answer>
</qandaentry>
<qandaentry>
<question>
<para>
Why is rsync so much bigger when I build it with
<command>gcc</command>?
</para>
</question>
<answer>
<para>
On gcc, rsync builds by default with debug symbols
included. If you strip both executables, they should end
up about the same size. (Use <command>make
install-strip</command>.)
</para>
</answer>
</qandaentry>
<qandaentry>
<question>
<para>Is rsync useful for a single large file like an ISO image?</para>
</question>
<answer>
<para>
Yes, but note the following:
<para>
Background: A common use of rsync is to update a file (or set of files) in one location from a more
correct or up-to-date copy in another location, taking advantage of portions of the files that are
identical to speed up the process. (Note that rsync will transfer a file in its entirety if no copy
exists at the destination.)
<para>
(This discussion is written in terms of updating a local copy of a file from a correct file in a
remote location, although rsync can work in either direction.)
<para>
The file to be updated (the local file) must be in a destination directory that has enough space for
two copies of the file. (In addition, keep an extra copy of the file to be updated in a different
location for safety -- see the discussion (below) about rsync's behavior when the rsync process is
interrupted before completion.)
<para>
The local file must have the same name as the remote file being sync'd to (I think?). If you are
trying to upgrade an iso from, for example, beta1 to beta2, rename the local file to the same name
as the beta2 file. *(This is a useful thing to do -- only the changed portions will be
transmitted.)*
<para>
The extra copy of the local file kept in a different location is because of rsync's behavior if
interrupted before completion:
<para>
* If you specify the --partial option and rsync is interrupted, rsync will save the partially
rsync'd file and throw away the original local copy. (The partially rsync'd file is correct but
truncated.) If rsync is restarted, it will not have a local copy of the file to check for duplicate
blocks beyond the section of the file that has already been rsync'd, thus the remainder of the rsync
process will be a "pure transfer" of the file rather than taking advantage of the rsync algorithm.
<para>
* If you don't specify the --partial option and rsync is interrupted, rsync will throw away the
partially rsync'd file, and, when rsync is restarted starts the rsync process over from the
beginning.
<para>
Which of these is most desirable depends on the degree of commonality between the local and remote
copies of the file *and how much progress was made before the interruption*.
<para>
The ideal approach after an interruption would be to create a new file by taking the original file
and deleting a portion equal in size to the portion already rsync'd and then appending *the
remaining* portion to the portion of the file that has already been rsync'd. (There has been some
discussion about creating an option to do this automatically.)
The --compare-dest option is useful when transferring multiple files, but is of no benefit in
transferring a single file. (AFAIK)
*Other potentially useful information can be found at:
-[3]http://twiki.org/cgi-bin/view/Wikilearn/RsyncingALargeFile
This answer, formatted with "real" bullets, can be found at:
-[4]http://twiki.org/cgi-bin/view/Wikilearn/RsyncingALargeFileFAQ*
</para>
</answer>
</qandaentry>
</qandaset>
</chapter>
<appendix>
<title>Other Resources</title>
<para><ulink url="http://www.ccp14.ac.uk/ccp14admin/rsync/"></ulink></para>
</appendix>
</book>

View File

@@ -1,9 +1,33 @@
/* error codes returned by rsync */
/* -*- c-file-style: "linux"; -*-
Copyright (C) 1998-2000 by Andrew Tridgell
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* error codes returned by rsync. If you change these, please also update the
* string mappings in log.c and the EXIT VALUES in rsync.yo
*/
#define RERR_OK 0
#define RERR_SYNTAX 1 /* syntax or usage error */
#define RERR_PROTOCOL 2 /* protocol incompatibility */
#define RERR_FILESELECT 3 /* errors selecting input/output files, dirs */
#define RERR_UNSUPPORTED 4 /* requested action not supported */
#define RERR_UNSUPPORTED 4 /* requested action not supported */
#define RERR_STARTCLIENT 5 /* error starting client-server protocol */
#define RERR_SOCKETIO 10 /* error in socket IO */
#define RERR_FILEIO 11 /* error in file IO */
@@ -14,5 +38,24 @@
#define RERR_SIGNAL 20 /* status returned when sent SIGUSR1, SIGINT */
#define RERR_WAITCHILD 21 /* some error returned by waitpid() */
#define RERR_MALLOC 22 /* error allocating core memory buffers */
#define RERR_PARTIAL 23 /* partial transfer */
#define RERR_VANISHED 24 /* file(s) vanished on sender side */
#define RERR_DEL_LIMIT 25 /* skipped some deletes due to --max-delete */
#define RERR_TIMEOUT 30 /* timeout in data send/receive */
/* Although it doesn't seem to be specified anywhere,
* ssh and the shell seem to return these values:
*
* 124 if the command exited with status 255
* 125 if the command is killed by a signal
* 126 if the command cannot be run
* 127 if the command is not found
*
* and we could use this to give a better explanation if the remote
* command is not found.
*/
#define RERR_CMD_FAILED 124
#define RERR_CMD_KILLED 125
#define RERR_CMD_RUN 126
#define RERR_CMD_NOTFOUND 127

1482
exclude.c
View File

File diff suppressed because it is too large Load Diff

206
fileio.c
View File

@@ -1,29 +1,31 @@
/*
/*
Copyright (C) Andrew Tridgell 1998
Copyright (C) 2002 by Martin Pool
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
File IO utilities used in rsync
File IO utilities used in rsync
*/
#include "rsync.h"
extern int sparse_files;
static char last_byte;
static int last_sparse;
extern int sparse_files;
int sparse_end(int f)
{
@@ -36,13 +38,13 @@ int sparse_end(int f)
}
static int write_sparse(int f,char *buf,int len)
static int write_sparse(int f,char *buf,size_t len)
{
int l1=0,l2=0;
size_t l1=0, l2=0;
int ret;
for (l1=0;l1<len && buf[l1]==0;l1++) ;
for (l2=0;l2<(len-l1) && buf[len-(l2+1)]==0;l2++) ;
for (l1 = 0; l1 < len && buf[l1] == 0; l1++) {}
for (l2 = 0; l2 < len-l1 && buf[len-(l2+1)] == 0; l2++) {}
last_byte = buf[len-1];
@@ -50,38 +52,83 @@ static int write_sparse(int f,char *buf,int len)
last_sparse=1;
if (l1 > 0) {
do_lseek(f,l1,SEEK_CUR);
do_lseek(f,l1,SEEK_CUR);
}
if (l1 == len)
if (l1 == len)
return len;
if ((ret=write(f,buf+l1,len-(l1+l2))) != len-(l1+l2)) {
if (ret == -1 || ret == 0) return ret;
ret = write(f, buf + l1, len - (l1+l2));
if (ret == -1 || ret == 0)
return ret;
else if (ret != (int) (len - (l1+l2)))
return (l1+ret);
}
if (l2 > 0)
do_lseek(f,l2,SEEK_CUR);
return len;
}
static char *wf_writeBuf;
static size_t wf_writeBufSize;
static size_t wf_writeBufCnt;
int write_file(int f,char *buf,int len)
int flush_write_file(int f)
{
int ret = 0;
char *bp = wf_writeBuf;
while (wf_writeBufCnt > 0) {
if ((ret = write(f, bp, wf_writeBufCnt)) < 0) {
if (errno == EINTR)
continue;
return ret;
}
wf_writeBufCnt -= ret;
bp += ret;
}
return ret;
}
/*
* write_file does not allow incomplete writes. It loops internally
* until len bytes are written or errno is set.
*/
int write_file(int f,char *buf,size_t len)
{
int ret = 0;
if (!sparse_files) {
return write(f,buf,len);
}
while (len>0) {
int len1 = MIN(len, SPARSE_WRITE_SIZE);
int r1 = write_sparse(f, buf, len1);
while (len > 0) {
int r1;
if (sparse_files) {
int len1 = MIN(len, SPARSE_WRITE_SIZE);
r1 = write_sparse(f, buf, len1);
} else {
if (!wf_writeBuf) {
wf_writeBufSize = WRITE_SIZE * 8;
wf_writeBufCnt = 0;
wf_writeBuf = new_array(char, wf_writeBufSize);
if (!wf_writeBuf)
out_of_memory("write_file");
}
r1 = MIN(len, wf_writeBufSize - wf_writeBufCnt);
if (r1) {
memcpy(wf_writeBuf + wf_writeBufCnt, buf, r1);
wf_writeBufCnt += r1;
}
if (wf_writeBufCnt == wf_writeBufSize) {
if (flush_write_file(f) < 0)
return -1;
if (!r1 && len)
continue;
}
}
if (r1 <= 0) {
if (ret > 0) return ret;
if (ret > 0)
return ret;
return r1;
}
len -= r1;
@@ -92,75 +139,67 @@ int write_file(int f,char *buf,int len)
}
/* this provides functionality somewhat similar to mmap() but using
read(). It gives sliding window access to a file. mmap() is not
used because of the possibility of another program (such as a
mailer) truncating the file thus giving us a SIGBUS */
struct map_struct *map_file(int fd,OFF_T len)
/* This provides functionality somewhat similar to mmap() but using read().
* It gives sliding window access to a file. mmap() is not used because of
* the possibility of another program (such as a mailer) truncating the
* file thus giving us a SIGBUS. */
struct map_struct *map_file(int fd, OFF_T len, int32 read_size,
int32 blk_size)
{
struct map_struct *map;
map = (struct map_struct *)malloc(sizeof(*map));
if (!map) out_of_memory("map_file");
if (!(map = new(struct map_struct)))
out_of_memory("map_file");
if (blk_size && (read_size % blk_size))
read_size += blk_size - (read_size % blk_size);
memset(map, 0, sizeof map[0]);
map->fd = fd;
map->file_size = len;
map->p = NULL;
map->p_size = 0;
map->p_offset = 0;
map->p_fd_offset = 0;
map->p_len = 0;
map->def_window_size = read_size;
return map;
}
/* slide the read window in the file */
char *map_ptr(struct map_struct *map,OFF_T offset,int len)
char *map_ptr(struct map_struct *map, OFF_T offset, int32 len)
{
int nread;
int32 nread;
OFF_T window_start, read_start;
int window_size, read_size, read_offset;
int32 window_size, read_size, read_offset;
if (len == 0) {
if (len == 0)
return NULL;
}
/* can't go beyond the end of file */
if (len > (map->file_size - offset)) {
len = map->file_size - offset;
if (len < 0) {
rprintf(FERROR, "invalid len passed to map_ptr: %ld\n",
(long)len);
exit_cleanup(RERR_FILEIO);
}
/* in most cases the region will already be available */
if (offset >= map->p_offset &&
offset+len <= map->p_offset+map->p_len) {
return (map->p + (offset - map->p_offset));
}
if (offset >= map->p_offset && offset+len <= map->p_offset+map->p_len)
return map->p + (offset - map->p_offset);
/* nope, we are going to have to do a read. Work out our desired window */
if (offset > 2*CHUNK_SIZE) {
window_start = offset - 2*CHUNK_SIZE;
window_start &= ~((OFF_T)(CHUNK_SIZE-1)); /* assumes power of 2 */
} else {
window_start = 0;
}
window_size = MAX_MAP_SIZE;
if (window_start + window_size > map->file_size) {
window_start = offset;
window_size = map->def_window_size;
if (window_start + window_size > map->file_size)
window_size = map->file_size - window_start;
}
if (offset + len > window_start + window_size) {
window_size = (offset+len) - window_start;
}
if (len > window_size)
window_size = len;
/* make sure we have allocated enough memory for the window */
if (window_size > map->p_size) {
map->p = (char *)Realloc(map->p, window_size);
if (!map->p) out_of_memory("map_ptr");
map->p = realloc_array(map->p, char, window_size);
if (!map->p)
out_of_memory("map_ptr");
map->p_size = window_size;
}
/* now try to avoid re-reading any bytes by reusing any bytes from the previous
buffer. */
/* Now try to avoid re-reading any bytes by reusing any bytes
* from the previous buffer. */
if (window_start >= map->p_offset &&
window_start < map->p_offset + map->p_len &&
window_start + window_size >= map->p_offset + map->p_len) {
@@ -175,18 +214,27 @@ char *map_ptr(struct map_struct *map,OFF_T offset,int len)
}
if (read_size <= 0) {
rprintf(FINFO,"Warning: unexpected read size of %d in map_ptr\n", read_size);
rprintf(FERROR, "invalid read_size of %ld in map_ptr\n",
(long)read_size);
exit_cleanup(RERR_FILEIO);
} else {
if (map->p_fd_offset != read_start) {
if (do_lseek(map->fd,read_start,SEEK_SET) != read_start) {
rprintf(FERROR,"lseek failed in map_ptr\n");
OFF_T ret = do_lseek(map->fd, read_start, SEEK_SET);
if (ret != read_start) {
rsyserr(FERROR, errno,
"lseek returned %.0f, not %.0f",
(double)ret, (double)read_start);
exit_cleanup(RERR_FILEIO);
}
map->p_fd_offset = read_start;
}
if ((nread=read(map->fd,map->p + read_offset,read_size)) != read_size) {
if (nread < 0) nread = 0;
if (nread < 0) {
nread = 0;
if (!map->status)
map->status = errno;
}
/* the best we can do is zero the buffer - the file
has changed mid transfer! */
memset(map->p+read_offset+nread, 0, read_size - nread);
@@ -196,18 +244,22 @@ char *map_ptr(struct map_struct *map,OFF_T offset,int len)
map->p_offset = window_start;
map->p_len = window_size;
return map->p + (offset - map->p_offset);
return map->p;
}
void unmap_file(struct map_struct *map)
int unmap_file(struct map_struct *map)
{
int ret;
if (map->p) {
free(map->p);
map->p = NULL;
}
memset(map, 0, sizeof(*map));
ret = map->status;
memset(map, 0, sizeof map[0]);
free(map);
}
return ret;
}

2188
flist.c
View File

File diff suppressed because it is too large Load Diff

View File

File diff suppressed because it is too large Load Diff

23
getfsdev.c Normal file
View File

@@ -0,0 +1,23 @@
#include "rsync.h"
int main(int argc, char *argv[])
{
STRUCT_STAT st;
int ret;
while (--argc > 0) {
#ifdef USE_STAT64_FUNCS
ret = stat64(*++argv, &st);
#else
ret = stat(*++argv, &st);
#endif
if (ret < 0) {
fprintf(stderr, "Unable to stat `%s'\n", *argv);
exit(1);
}
printf("%ld/%ld\n", (long)major(st.st_dev),
(long)minor(st.st_dev));
}
return 0;
}

68
getgroups.c Normal file
View File

@@ -0,0 +1,68 @@
/*
* Copyright (C) 2002 by Martin Pool
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* @file getgroups.c
*
* Print out the gids of all groups for the current user. This is
* like `id -G` on Linux, but it's too hard to find a portable
* equivalent.
**/
#include "rsync.h"
int
main(UNUSED(int argc), UNUSED(char *argv[]))
{
int n, i;
gid_t *list;
gid_t gid = MY_GID();
int gid_in_list = 0;
#ifdef HAVE_GETGROUPS
if ((n = getgroups(0, NULL)) < 0) {
perror("getgroups");
return 1;
}
#else
n = 0;
#endif
list = (gid_t*)malloc(sizeof (gid_t) * (n + 1));
if (!list) {
fprintf(stderr, "out of memory!\n");
exit(1);
}
#ifdef HAVE_GETGROUPS
if (n > 0)
n = getgroups(n, list);
#endif
for (i = 0; i < n; i++) {
printf("%lu ", (unsigned long)list[i]);
if (list[i] == gid)
gid_in_list = 1;
}
/* The default gid might not be in the list on some systems. */
if (!gid_in_list)
printf("%lu", (unsigned long)gid);
printf("\n");
return 0;
}

324
hlink.c
View File

@@ -1,17 +1,18 @@
/*
/*
Copyright (C) Andrew Tridgell 1996
Copyright (C) Paul Mackerras 1996
Copyright (C) 2002 by Martin Pool <mbp@samba.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -21,136 +22,247 @@
extern int dry_run;
extern int verbose;
extern int make_backups;
extern int log_format_has_i;
extern struct file_list *the_file_list;
#if SUPPORT_HARD_LINKS
static int hlink_compare(struct file_struct *f1,struct file_struct *f2)
#ifdef SUPPORT_HARD_LINKS
#define SKIPPED_LINK (-1)
#define FINISHED_LINK (-2)
#define FPTR(i) (the_file_list->files[i])
#define LINKED(p1,p2) (FPTR(p1)->F_DEV == FPTR(p2)->F_DEV \
&& FPTR(p1)->F_INODE == FPTR(p2)->F_INODE)
static int hlink_compare(int *int1, int *int2)
{
if (!S_ISREG(f1->mode) && !S_ISREG(f2->mode)) return 0;
if (!S_ISREG(f1->mode)) return -1;
if (!S_ISREG(f2->mode)) return 1;
struct file_struct *f1 = FPTR(*int1);
struct file_struct *f2 = FPTR(*int2);
if (f1->dev != f2->dev)
return (int)(f1->dev>f2->dev?1:-1);
if (f1->F_DEV != f2->F_DEV)
return (int) (f1->F_DEV > f2->F_DEV ? 1 : -1);
if (f1->inode != f2->inode)
return (int)(f1->inode>f2->inode?1:-1);
if (f1->F_INODE != f2->F_INODE)
return (int) (f1->F_INODE > f2->F_INODE ? 1 : -1);
return file_compare(&f1,&f2);
return f_name_cmp(f1, f2);
}
static struct file_struct *hlink_list;
static int *hlink_list;
static int hlink_count;
/* Analyze the data in the hlink_list[], remove items that aren't multiply
* linked, and replace the dev+inode data with the hlindex+next linked list. */
static void link_idev_data(void)
{
int cur, from, to, start;
alloc_pool_t hlink_pool;
alloc_pool_t idev_pool = the_file_list->hlink_pool;
hlink_pool = pool_create(128 * 1024, sizeof (struct hlink),
out_of_memory, POOL_INTERN);
for (from = to = 0; from < hlink_count; from++) {
start = from;
while (1) {
cur = hlink_list[from];
if (from == hlink_count-1
|| !LINKED(cur, hlink_list[from+1]))
break;
pool_free(idev_pool, 0, FPTR(cur)->link_u.idev);
FPTR(cur)->link_u.links = pool_talloc(hlink_pool,
struct hlink, 1, "hlink_list");
FPTR(cur)->F_HLINDEX = to;
FPTR(cur)->F_NEXT = hlink_list[++from];
}
pool_free(idev_pool, 0, FPTR(cur)->link_u.idev);
if (from > start) {
int head = hlink_list[start];
FPTR(cur)->link_u.links = pool_talloc(hlink_pool,
struct hlink, 1, "hlink_list");
FPTR(head)->flags |= FLAG_HLINK_TOL;
FPTR(cur)->F_HLINDEX = to;
FPTR(cur)->F_NEXT = head;
FPTR(cur)->flags |= FLAG_HLINK_EOL;
hlink_list[to++] = head;
} else
FPTR(cur)->link_u.links = NULL;
}
if (!to) {
free(hlink_list);
hlink_list = NULL;
pool_destroy(hlink_pool);
hlink_pool = NULL;
} else {
hlink_count = to;
hlink_list = realloc_array(hlink_list, int, hlink_count);
if (!hlink_list)
out_of_memory("init_hard_links");
}
the_file_list->hlink_pool = hlink_pool;
pool_destroy(idev_pool);
}
#endif
void init_hard_links(struct file_list *flist)
void init_hard_links(void)
{
#if SUPPORT_HARD_LINKS
#ifdef SUPPORT_HARD_LINKS
int i;
if (flist->count < 2) return;
if (hlink_list) free(hlink_list);
if (!(hlink_list =
(struct file_struct *)malloc(sizeof(hlink_list[0])*flist->count)))
if (hlink_list)
free(hlink_list);
if (!(hlink_list = new_array(int, the_file_list->count)))
out_of_memory("init_hard_links");
for (i = 0; i < flist->count; i++)
memcpy(&hlink_list[i], flist->files[i], sizeof(hlink_list[0]));
hlink_count = 0;
for (i = 0; i < the_file_list->count; i++) {
if (FPTR(i)->link_u.idev)
hlink_list[hlink_count++] = i;
}
qsort(hlink_list,flist->count,
sizeof(hlink_list[0]),
(int (*)())hlink_compare);
qsort(hlink_list, hlink_count,
sizeof hlink_list[0], (int (*)()) hlink_compare);
hlink_count=flist->count;
if (!hlink_count) {
free(hlink_list);
hlink_list = NULL;
} else
link_idev_data();
#endif
}
/* check if a file should be skipped because it is the same as an
earlier hard link */
int check_hard_link(struct file_struct *file)
#ifdef SUPPORT_HARD_LINKS
static int maybe_hard_link(struct file_struct *file, int ndx,
char *fname, int statret, STRUCT_STAT *st,
char *toname, STRUCT_STAT *to_st,
int itemizing, enum logcode code)
{
#if SUPPORT_HARD_LINKS
int low=0,high=hlink_count-1;
int ret=0;
if (!hlink_list || !S_ISREG(file->mode)) return 0;
while (low != high) {
int mid = (low+high)/2;
ret = hlink_compare(&hlink_list[mid],file);
if (ret == 0) {
low = mid;
break;
}
if (ret > 0)
high=mid;
else
low=mid+1;
}
if (hlink_compare(&hlink_list[low],file) != 0) return 0;
if (low > 0 &&
S_ISREG(hlink_list[low-1].mode) &&
file->dev == hlink_list[low-1].dev &&
file->inode == hlink_list[low-1].inode)
return 1;
#endif
return 0;
}
#if SUPPORT_HARD_LINKS
static void hard_link_one(int i)
{
STRUCT_STAT st1,st2;
if (link_stat(f_name(&hlink_list[i-1]),&st1) != 0) return;
if (link_stat(f_name(&hlink_list[i]),&st2) != 0) {
if (do_link(f_name(&hlink_list[i-1]),f_name(&hlink_list[i])) != 0) {
if (verbose > 0)
rprintf(FINFO,"link %s => %s : %s\n",
f_name(&hlink_list[i]),
f_name(&hlink_list[i-1]),strerror(errno));
return;
if (statret == 0) {
if (st->st_dev == to_st->st_dev
&& st->st_ino == to_st->st_ino) {
if (itemizing) {
itemize(file, ndx, statret, st,
ITEM_LOCAL_CHANGE | ITEM_XNAME_FOLLOWS,
0, "");
}
return 0;
}
} else {
if (st2.st_dev == st1.st_dev && st2.st_ino == st1.st_ino) return;
if (robust_unlink(f_name(&hlink_list[i])) != 0 ||
do_link(f_name(&hlink_list[i-1]),f_name(&hlink_list[i])) != 0) {
if (verbose > 0)
rprintf(FINFO,"link %s => %s : %s\n",
f_name(&hlink_list[i]),
f_name(&hlink_list[i-1]),strerror(errno));
return;
if (make_backups) {
if (!make_backup(fname))
return -1;
} else if (robust_unlink(fname)) {
rsyserr(FERROR, errno, "unlink %s failed",
full_fname(fname));
return -1;
}
}
if (verbose > 0)
rprintf(FINFO,"%s => %s\n",
f_name(&hlink_list[i]),f_name(&hlink_list[i-1]));
return hard_link_one(file, ndx, fname, statret, st, toname,
0, itemizing, code);
}
#endif
/* create any hard links in the flist */
void do_hard_links(struct file_list *flist)
int hard_link_check(struct file_struct *file, int ndx, char *fname,
int statret, STRUCT_STAT *st, int itemizing,
enum logcode code, int skip)
{
#if SUPPORT_HARD_LINKS
int i;
if (!hlink_list) return;
for (i=1;i<hlink_count;i++) {
if (S_ISREG(hlink_list[i].mode) &&
S_ISREG(hlink_list[i-1].mode) &&
hlink_list[i].basename && hlink_list[i-1].basename &&
hlink_list[i].dev == hlink_list[i-1].dev &&
hlink_list[i].inode == hlink_list[i-1].inode) {
hard_link_one(i);
}
#ifdef SUPPORT_HARD_LINKS
int head;
if (!file->link_u.links)
return 0;
if (skip && !(file->flags & FLAG_HLINK_EOL))
head = hlink_list[file->F_HLINDEX] = file->F_NEXT;
else
head = hlink_list[file->F_HLINDEX];
if (ndx != head) {
struct file_struct *head_file = FPTR(head);
if (!log_format_has_i && verbose > 1) {
rprintf(FINFO, "\"%s\" is a hard link\n",
safe_fname(f_name(file)));
}
if (head_file->F_HLINDEX == FINISHED_LINK) {
STRUCT_STAT st2;
char *toname = f_name(head_file);
if (link_stat(toname, &st2, 0) < 0) {
rsyserr(FERROR, errno, "stat %s failed",
full_fname(toname));
return -1;
}
maybe_hard_link(file, ndx, fname, statret, st,
toname, &st2, itemizing, code);
file->F_HLINDEX = FINISHED_LINK;
} else
file->F_HLINDEX = SKIPPED_LINK;
return 1;
}
#endif
return 0;
}
#ifdef SUPPORT_HARD_LINKS
int hard_link_one(struct file_struct *file, int ndx, char *fname,
int statret, STRUCT_STAT *st, char *toname, int terse,
int itemizing, enum logcode code)
{
if (do_link(toname, fname)) {
if (terse) {
if (!verbose)
return -1;
code = FINFO;
} else
code = FERROR;
rsyserr(code, errno, "link %s => %s failed",
full_fname(fname), safe_fname(toname));
return -1;
}
if (itemizing) {
itemize(file, ndx, statret, st,
ITEM_LOCAL_CHANGE | ITEM_XNAME_FOLLOWS, 0,
terse ? "" : toname);
}
if (code && verbose && !terse) {
rprintf(code, "%s => %s\n",
safe_fname(fname), safe_fname(toname));
}
return 0;
}
#endif
void hard_link_cluster(struct file_struct *file, int master, int itemizing,
enum logcode code)
{
#ifdef SUPPORT_HARD_LINKS
char hlink1[MAXPATHLEN];
char *hlink2;
STRUCT_STAT st1, st2;
int statret, ndx = master;
file->F_HLINDEX = FINISHED_LINK;
if (link_stat(f_name_to(file, hlink1), &st1, 0) < 0)
return;
if (!(file->flags & FLAG_HLINK_TOL)) {
while (!(file->flags & FLAG_HLINK_EOL)) {
ndx = file->F_NEXT;
file = FPTR(ndx);
}
}
do {
ndx = file->F_NEXT;
file = FPTR(ndx);
if (file->F_HLINDEX != SKIPPED_LINK)
continue;
hlink2 = f_name(file);
statret = link_stat(hlink2, &st2, 0);
maybe_hard_link(file, ndx, hlink2, statret, &st2,
hlink1, &st1, itemizing, code);
file->F_HLINDEX = FINISHED_LINK;
} while (!(file->flags & FLAG_HLINK_EOL));
#endif
}

View File

@@ -208,7 +208,7 @@ else
# Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
dsttmp=$dstdir/_inst.$$_
# Move or copy the file name to the temp name

1490
io.c
View File

File diff suppressed because it is too large Load Diff

View File

@@ -1,49 +1 @@
.cvsignore
Makefile
a
b
config.cache
config.h
config.log
config.status
dist.tar.gz
dummy
rsync
rsync-0.1
rsync-0.1
rsync-0.1
rsync-0.1.tar.gz
rsync-0.2
rsync-0.2
rsync-0.2.tar.gz
rsync-0.3
rsync-0.3
rsync-0.3.tar.gz
rsync-0.4
rsync-0.4
rsync-0.4.tar.gz
rsync-0.5
rsync-0.5
rsync-0.5
rsync-0.5
rsync-0.5
rsync-0.5
rsync-0.5
rsync-0.5
rsync-0.5.tar.gz
rsync-0.6
rsync-0.7
rsync-0.7
rsync-0.8
rsync-0.8
rsync-0.8
rsync-0.8
rsync-ERSION
rsync.aux
rsync.dvi
rsync.log
tech_report.aux
tech_report.dvi
tech_report.log
tech_report.ps
test

View File

@@ -1,5 +1,6 @@
/*
Copyright (C) Andrew Tridgell 1998
Copyright (C) 2002 by Martin Pool
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
@@ -16,11 +17,15 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
compatibility functions - replacing functions for platforms that don't
have them.
/**
* @file compat.c
*
* Reimplementations of standard functions for platforms that don't
* have them.
**/
*/
#include "rsync.h"
@@ -78,9 +83,11 @@
#endif
#ifndef HAVE_STRPBRK
/* Find the first ocurrence in S of any character in ACCEPT.
derived from glibc
*/
/**
* Find the first ocurrence in @p s of any character in @p accept.
*
* Derived from glibc
**/
char *strpbrk(const char *s, const char *accept)
{
while (*s != '\0') {
@@ -95,53 +102,103 @@
}
#endif
#ifdef REPLACE_INET_NTOA
char *rep_inet_ntoa(struct in_addr ip)
{
unsigned char *p = (unsigned char *)&ip.s_addr;
static char buf[18];
#if WORDS_BIGENDIAN
slprintf(buf, 18, "%d.%d.%d.%d",
(int)p[0], (int)p[1], (int)p[2], (int)p[3]);
#else
slprintf(buf, 18, "%d.%d.%d.%d",
(int)p[3], (int)p[2], (int)p[1], (int)p[0]);
#endif
return buf;
}
#endif
#ifndef HAVE_STRLCPY
/* like strncpy but does not 0 fill the buffer and always null
terminates. bufsize is the size of the destination buffer */
/**
* Like strncpy but does not 0 fill the buffer and always null
* terminates.
*
* @param bufsize is the size of the destination buffer.
*
* @return index of the terminating byte.
**/
size_t strlcpy(char *d, const char *s, size_t bufsize)
{
size_t len = strlen(s);
size_t ret = len;
if (len >= bufsize) len = bufsize-1;
memcpy(d, s, len);
d[len] = 0;
if (bufsize > 0) {
if (len >= bufsize)
len = bufsize-1;
memcpy(d, s, len);
d[len] = 0;
}
return ret;
}
#endif
#ifndef HAVE_STRLCAT
/* like strncat but does not 0 fill the buffer and always null
terminates. bufsize is the length of the buffer, which should
be one more than the maximum resulting string length */
/**
* Like strncat() but does not 0 fill the buffer and always null
* terminates.
*
* @param bufsize length of the buffer, which should be one more than
* the maximum resulting string length.
**/
size_t strlcat(char *d, const char *s, size_t bufsize)
{
size_t len1 = strlen(d);
size_t len2 = strlen(s);
size_t ret = len1 + len2;
if (len1+len2 >= bufsize) {
len2 = bufsize - (len1+1);
}
if (len2 > 0) {
if (len1 < bufsize - 1) {
if (len2 >= bufsize - len1)
len2 = bufsize - len1 - 1;
memcpy(d+len1, s, len2);
d[len1+len2] = 0;
}
return ret;
}
#endif
#ifdef REPLACE_INET_NTOA
char *rep_inet_ntoa(struct in_addr ip)
{
unsigned char *p = (unsigned char *)&ip.s_addr;
static char buf[18];
#ifdef WORDS_BIGENDIAN
snprintf(buf, 18, "%d.%d.%d.%d",
(int)p[0], (int)p[1], (int)p[2], (int)p[3]);
#else
snprintf(buf, 18, "%d.%d.%d.%d",
(int)p[3], (int)p[2], (int)p[1], (int)p[0]);
#endif
return buf;
}
#endif
#ifdef REPLACE_INET_ATON
int inet_aton(const char *cp, struct in_addr *inp)
{
unsigned int a1, a2, a3, a4;
unsigned long ret;
if (strcmp(cp, "255.255.255.255") == 0) {
inp->s_addr = (unsigned) -1;
return 0;
}
if (sscanf(cp, "%u.%u.%u.%u", &a1, &a2, &a3, &a4) != 4 ||
a1 > 255 || a2 > 255 || a3 > 255 || a4 > 255) {
return 0;
}
ret = (a1 << 24) | (a2 << 16) | (a3 << 8) | a4;
inp->s_addr = htonl(ret);
if (inp->s_addr == (unsigned) -1) {
return 0;
}
return 1;
}
#endif
/* some systems don't take the 2nd argument */
int sys_gettimeofday(struct timeval *tv)
{
#ifdef HAVE_GETTIMEOFDAY_TZ
return gettimeofday(tv, NULL);
#else
return gettimeofday(tv);
#endif
}

View File

@@ -1,204 +0,0 @@
#include "../rsync.h"
#ifndef HAVE_FNMATCH
/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
NOTE: The canonical source of this file is maintained with the GNU C Library.
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#if defined (STDC_HEADERS) || !defined (isascii)
#define ISASCII(c) 1
#else
#define ISASCII(c) isascii(c)
#endif
#define ISUPPER(c) (ISASCII (c) && isupper (c))
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C
Library, but also included in many other GNU distributions. Compiling
and linking in this code is a waste when using the GNU C library
(especially if it is a shared library). Rather than having every GNU
program understand `configure --with-gnu-libc' and omit the object files,
it is simpler to just do this in the source for each such file. */
#if !defined(__GNU_LIBRARY__) && !defined(STDC_HEADERS)
extern int errno;
#endif
/* Match STRING against the filename pattern PATTERN, returning zero if
it matches, nonzero if not. */
int
fnmatch (pattern, string, flags)
const char *pattern;
const char *string;
int flags;
{
register const char *p = pattern, *n = string;
register char c;
/* Note that this evalutes C many times. */
#define FOLD(c) ((flags & FNM_CASEFOLD) && ISUPPER (c) ? tolower (c) : (c))
while ((c = *p++) != '\0')
{
c = FOLD (c);
switch (c)
{
case '?':
if (*n == '\0')
return FNM_NOMATCH;
else if ((flags & FNM_FILE_NAME) && *n == '/')
return FNM_NOMATCH;
else if ((flags & FNM_PERIOD) && *n == '.' &&
(n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
return FNM_NOMATCH;
break;
case '\\':
if (!(flags & FNM_NOESCAPE))
{
c = *p++;
c = FOLD (c);
}
if (FOLD (*n) != c)
return FNM_NOMATCH;
break;
case '*':
if ((flags & FNM_PERIOD) && *n == '.' &&
(n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
return FNM_NOMATCH;
for (c = *p++; c == '?' || c == '*'; c = *p++, ++n)
if (((flags & FNM_FILE_NAME) && *n == '/') ||
(c == '?' && *n == '\0'))
return FNM_NOMATCH;
if (c == '\0')
return 0;
{
char c1 = (!(flags & FNM_NOESCAPE) && c == '\\') ? *p : c;
c1 = FOLD (c1);
for (--p; *n != '\0'; ++n)
if ((c == '[' || FOLD (*n) == c1) &&
fnmatch (p, n, flags & ~FNM_PERIOD) == 0)
return 0;
return FNM_NOMATCH;
}
case '[':
{
/* Nonzero if the sense of the character class is inverted. */
register int not;
if (*n == '\0')
return FNM_NOMATCH;
if ((flags & FNM_PERIOD) && *n == '.' &&
(n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
return FNM_NOMATCH;
not = (*p == '!' || *p == '^');
if (not)
++p;
c = *p++;
for (;;)
{
register char cstart = c, cend = c;
if (!(flags & FNM_NOESCAPE) && c == '\\')
cstart = cend = *p++;
cstart = cend = FOLD (cstart);
if (c == '\0')
/* [ (unterminated) loses. */
return FNM_NOMATCH;
c = *p++;
c = FOLD (c);
if ((flags & FNM_FILE_NAME) && c == '/')
/* [/] can never match. */
return FNM_NOMATCH;
if (c == '-' && *p != ']')
{
cend = *p++;
if (!(flags & FNM_NOESCAPE) && cend == '\\')
cend = *p++;
if (cend == '\0')
return FNM_NOMATCH;
cend = FOLD (cend);
c = *p++;
}
if (FOLD (*n) >= cstart && FOLD (*n) <= cend)
goto matched;
if (c == ']')
break;
}
if (!not)
return FNM_NOMATCH;
break;
matched:;
/* Skip the rest of the [...] that already matched. */
while (c != ']')
{
if (c == '\0')
/* [... (unterminated) loses. */
return FNM_NOMATCH;
c = *p++;
if (!(flags & FNM_NOESCAPE) && c == '\\')
/* XXX 1003.2d11 is unclear if this is right. */
++p;
}
if (not)
return FNM_NOMATCH;
}
break;
default:
if (c != FOLD (*n))
return FNM_NOMATCH;
}
++n;
}
if (*n == '\0')
return 0;
if ((flags & FNM_LEADING_DIR) && *n == '/')
/* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz". */
return 0;
return FNM_NOMATCH;
}
#else /* HAVE_FNMATCH */
void fnmatch_dummy(void) {}
#endif

View File

@@ -1,69 +0,0 @@
/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
NOTE: The canonical source of this file is maintained with the GNU C Library.
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifndef _FNMATCH_H
#define _FNMATCH_H 1
#ifdef __cplusplus
extern "C" {
#endif
#if defined (__cplusplus) || (defined (__STDC__) && __STDC__)
#undef __P
#define __P(protos) protos
#else /* Not C++ or ANSI C. */
#undef __P
#define __P(protos) ()
/* We can get away without defining `const' here only because in this file
it is used only inside the prototype for `fnmatch', which is elided in
non-ANSI C where `const' is problematical. */
#endif /* C++ or ANSI C. */
/* We #undef these before defining them because some losing systems
(HP-UX A.08.07 for example) define these in <unistd.h>. */
#undef FNM_PATHNAME
#undef FNM_NOESCAPE
#undef FNM_PERIOD
/* Bits set in the FLAGS argument to `fnmatch'. */
#define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */
#define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */
#define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */
#if !defined (_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 2 || defined (_GNU_SOURCE)
#define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */
#define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */
#define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */
#endif
/* Value returned by `fnmatch' if STRING does not match PATTERN. */
#define FNM_NOMATCH 1
/* Match STRING against the filename pattern PATTERN,
returning zero if it matches, FNM_NOMATCH if not. */
extern int fnmatch __P ((const char *__pattern, const char *__string,
int __flags));
#ifdef __cplusplus
}
#endif
#endif /* fnmatch.h */

View File

@@ -1,751 +0,0 @@
#include "../rsync.h"
#ifndef HAVE_GETOPT_LONG
/* Getopt for GNU.
NOTE: getopt is now part of the C library, so if you don't know what
"Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
before changing it!
Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
Ditto for AIX 3.2 and <stdlib.h>. */
#ifndef _NO_PROTO
#define _NO_PROTO
#endif
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C
Library, but also included in many other GNU distributions. Compiling
and linking in this code is a waste when using the GNU C library
(especially if it is a shared library). Rather than having every GNU
program understand `configure --with-gnu-libc' and omit the object files,
it is simpler to just do this in the source for each such file. */
#if defined (_LIBC) || !defined (__GNU_LIBRARY__)
/* This is for other GNU distributions with internationalized messages.
The GNU C Library itself does not yet support such messages. */
#if HAVE_LIBINTL_H
# include <libintl.h>
#else
# define gettext(msgid) (msgid)
#endif
/* This version of `getopt' appears to the caller like standard Unix `getopt'
but it behaves differently for the user, since it allows the user
to intersperse the options with the other arguments.
As `getopt' works, it permutes the elements of ARGV so that,
when it is done, all the options precede everything else. Thus
all application programs are extended to handle flexible argument order.
Setting the environment variable POSIXLY_CORRECT disables permutation.
Then the behavior is completely standard.
GNU application programs can use a third alternative mode in which
they can distinguish the relative order of options and other arguments. */
/* For communication from `getopt' to the caller.
When `getopt' finds an option that takes an argument,
the argument value is returned here.
Also, when `ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
char *optarg = NULL;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
and for communication between successive calls to `getopt'.
On entry to `getopt', zero means this is the first call; initialize.
When `getopt' returns EOF, this is the index of the first of the
non-option elements that the caller should itself scan.
Otherwise, `optind' communicates from one call to the next
how much of ARGV has been scanned so far. */
/* XXX 1003.2 says this must be 1 before any call. */
int optind = 0;
/* The next char to be scanned in the option-element
in which the last option character we returned was found.
This allows us to pick up the scan where we left off.
If this is zero, or a null string, it means resume the scan
by advancing to the next ARGV-element. */
static char *nextchar;
/* Callers store zero here to inhibit the error message
for unrecognized options. */
int opterr = 1;
/* Set to an option character which was unrecognized.
This must be initialized on some systems to avoid linking in the
system's own getopt implementation. */
int optopt = '?';
/* Describe how to deal with options that follow non-option ARGV-elements.
If the caller did not specify anything,
the default is REQUIRE_ORDER if the environment variable
POSIXLY_CORRECT is defined, PERMUTE otherwise.
REQUIRE_ORDER means don't recognize them as options;
stop option processing when the first non-option is seen.
This is what Unix does.
This mode of operation is selected by either setting the environment
variable POSIXLY_CORRECT, or using `+' as the first character
of the list of option characters.
PERMUTE is the default. We permute the contents of ARGV as we scan,
so that eventually all the non-options are at the end. This allows options
to be given in any order, even with programs that were not written to
expect this.
RETURN_IN_ORDER is an option available to programs that were written
to expect options and other ARGV-elements in any order and that care about
the ordering of the two. We describe each non-option ARGV-element
as if it were the argument of an option with character code 1.
Using `-' as the first character of the list of option characters
selects this mode of operation.
The special argument `--' forces an end of option-scanning regardless
of the value of `ordering'. In the case of RETURN_IN_ORDER, only
`--' can cause `getopt' to return EOF with `optind' != ARGC. */
static enum
{
REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
} ordering;
/* Value of POSIXLY_CORRECT environment variable. */
static char *posixly_correct;
#ifdef __GNU_LIBRARY__
/* We want to avoid inclusion of string.h with non-GNU libraries
because there are many ways it can cause trouble.
On some systems, it contains special magic macros that don't work
in GCC. */
#include <string.h>
#define my_index strchr
#else
/* Avoid depending on library functions or files
whose names are inconsistent. */
char *getenv ();
static char *
my_index (str, chr)
const char *str;
int chr;
{
while (*str)
{
if (*str == chr)
return (char *) str;
str++;
}
return 0;
}
/* If using GCC, we can safely declare strlen this way.
If not using GCC, it is ok not to declare it. */
#ifdef __GNUC__
/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h.
That was relevant to code that was here before. */
#if !defined (__STDC__) || !__STDC__
/* gcc with -traditional declares the built-in strlen to return int,
and has done so at least since version 2.4.5. -- rms. */
extern int strlen (const char *);
#endif /* not __STDC__ */
#endif /* __GNUC__ */
#endif /* not __GNU_LIBRARY__ */
/* Handle permutation of arguments. */
/* Describe the part of ARGV that contains non-options that have
been skipped. `first_nonopt' is the index in ARGV of the first of them;
`last_nonopt' is the index after the last of them. */
static int first_nonopt;
static int last_nonopt;
/* Exchange two adjacent subsequences of ARGV.
One subsequence is elements [first_nonopt,last_nonopt)
which contains all the non-options that have been skipped so far.
The other is elements [last_nonopt,optind), which contains all
the options processed since those non-options were skipped.
`first_nonopt' and `last_nonopt' are relocated so that they describe
the new indices of the non-options in ARGV after they are moved. */
static void
exchange (argv)
char **argv;
{
int bottom = first_nonopt;
int middle = last_nonopt;
int top = optind;
char *tem;
/* Exchange the shorter segment with the far end of the longer segment.
That puts the shorter segment into the right place.
It leaves the longer segment in the right place overall,
but it consists of two parts that need to be swapped next. */
while (top > middle && middle > bottom)
{
if (top - middle > middle - bottom)
{
/* Bottom segment is the short one. */
int len = middle - bottom;
register int i;
/* Swap it with the top part of the top segment. */
for (i = 0; i < len; i++)
{
tem = argv[bottom + i];
argv[bottom + i] = argv[top - (middle - bottom) + i];
argv[top - (middle - bottom) + i] = tem;
}
/* Exclude the moved bottom segment from further swapping. */
top -= len;
}
else
{
/* Top segment is the short one. */
int len = top - middle;
register int i;
/* Swap it with the bottom part of the bottom segment. */
for (i = 0; i < len; i++)
{
tem = argv[bottom + i];
argv[bottom + i] = argv[middle + i];
argv[middle + i] = tem;
}
/* Exclude the moved top segment from further swapping. */
bottom += len;
}
}
/* Update records for the slots the non-options now occupy. */
first_nonopt += (optind - last_nonopt);
last_nonopt = optind;
}
/* Initialize the internal data when the first call is made. */
static const char *
_getopt_initialize (optstring)
const char *optstring;
{
/* Start processing options with ARGV-element 1 (since ARGV-element 0
is the program name); the sequence of previously skipped
non-option ARGV-elements is empty. */
first_nonopt = last_nonopt = optind = 1;
nextchar = NULL;
posixly_correct = getenv ("POSIXLY_CORRECT");
/* Determine how to handle the ordering of options and nonoptions. */
if (optstring[0] == '-')
{
ordering = RETURN_IN_ORDER;
++optstring;
}
else if (optstring[0] == '+')
{
ordering = REQUIRE_ORDER;
++optstring;
}
else if (posixly_correct != NULL)
ordering = REQUIRE_ORDER;
else
ordering = PERMUTE;
return optstring;
}
/* Scan elements of ARGV (whose length is ARGC) for option characters
given in OPTSTRING.
If an element of ARGV starts with '-', and is not exactly "-" or "--",
then it is an option element. The characters of this element
(aside from the initial '-') are option characters. If `getopt'
is called repeatedly, it returns successively each of the option characters
from each of the option elements.
If `getopt' finds another option character, it returns that character,
updating `optind' and `nextchar' so that the next call to `getopt' can
resume the scan with the following option character or ARGV-element.
If there are no more option characters, `getopt' returns `EOF'.
Then `optind' is the index in ARGV of the first ARGV-element
that is not an option. (The ARGV-elements have been permuted
so that those that are not options now come last.)
OPTSTRING is a string containing the legitimate option characters.
If an option character is seen that is not listed in OPTSTRING,
return '?' after printing an error message. If you set `opterr' to
zero, the error message is suppressed but we still return '?'.
If a char in OPTSTRING is followed by a colon, that means it wants an arg,
so the following text in the same ARGV-element, or the text of the following
ARGV-element, is returned in `optarg'. Two colons mean an option that
wants an optional arg; if there is text in the current ARGV-element,
it is returned in `optarg', otherwise `optarg' is set to zero.
If OPTSTRING starts with `-' or `+', it requests different methods of
handling the non-option ARGV-elements.
See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
Long-named options begin with `--' instead of `-'.
Their names may be abbreviated as long as the abbreviation is unique
or is an exact match for some defined option. If they have an
argument, it follows the option name in the same ARGV-element, separated
from the option name by a `=', or else the in next ARGV-element.
When `getopt' finds a long-named option, it returns 0 if that option's
`flag' field is nonzero, the value of the option's `val' field
if the `flag' field is zero.
The elements of ARGV aren't really const, because we permute them.
But we pretend they're const in the prototype to be compatible
with other systems.
LONGOPTS is a vector of `struct option' terminated by an
element containing a name which is zero.
LONGIND returns the index in LONGOPT of the long-named option found.
It is only valid when a long-named option has been found by the most
recent call.
If LONG_ONLY is nonzero, '-' as well as '--' can introduce
long-named options. */
int
_getopt_internal (argc, argv, optstring, longopts, longind, long_only)
int argc;
char *const *argv;
const char *optstring;
const struct option *longopts;
int *longind;
int long_only;
{
optarg = NULL;
if (optind == 0)
optstring = _getopt_initialize (optstring);
if (nextchar == NULL || *nextchar == '\0')
{
/* Advance to the next ARGV-element. */
if (ordering == PERMUTE)
{
/* If we have just processed some options following some non-options,
exchange them so that the options come first. */
if (first_nonopt != last_nonopt && last_nonopt != optind)
exchange ((char **) argv);
else if (last_nonopt != optind)
first_nonopt = optind;
/* Skip any additional non-options
and extend the range of non-options previously skipped. */
while (optind < argc
&& (argv[optind][0] != '-' || argv[optind][1] == '\0'))
optind++;
last_nonopt = optind;
}
/* The special ARGV-element `--' means premature end of options.
Skip it like a null option,
then exchange with previous non-options as if it were an option,
then skip everything else like a non-option. */
if (optind != argc && !strcmp (argv[optind], "--"))
{
optind++;
if (first_nonopt != last_nonopt && last_nonopt != optind)
exchange ((char **) argv);
else if (first_nonopt == last_nonopt)
first_nonopt = optind;
last_nonopt = argc;
optind = argc;
}
/* If we have done all the ARGV-elements, stop the scan
and back over any non-options that we skipped and permuted. */
if (optind == argc)
{
/* Set the next-arg-index to point at the non-options
that we previously skipped, so the caller will digest them. */
if (first_nonopt != last_nonopt)
optind = first_nonopt;
return EOF;
}
/* If we have come to a non-option and did not permute it,
either stop the scan or describe it to the caller and pass it by. */
if ((argv[optind][0] != '-' || argv[optind][1] == '\0'))
{
if (ordering == REQUIRE_ORDER)
return EOF;
optarg = argv[optind++];
return 1;
}
/* We have found another option-ARGV-element.
Skip the initial punctuation. */
nextchar = (argv[optind] + 1
+ (longopts != NULL && argv[optind][1] == '-'));
}
/* Decode the current option-ARGV-element. */
/* Check whether the ARGV-element is a long option.
If long_only and the ARGV-element has the form "-f", where f is
a valid short option, don't consider it an abbreviated form of
a long option that starts with f. Otherwise there would be no
way to give the -f short option.
On the other hand, if there's a long option "fubar" and
the ARGV-element is "-fu", do consider that an abbreviation of
the long option, just like "--fu", and not "-f" with arg "u".
This distinction seems to be the most useful approach. */
if (longopts != NULL
&& (argv[optind][1] == '-'
|| (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1])))))
{
char *nameend;
const struct option *p;
const struct option *pfound = NULL;
int exact = 0;
int ambig = 0;
int indfound;
int option_index;
for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
/* Do nothing. */ ;
/* Test all long options for either exact match
or abbreviated matches. */
for (p = longopts, option_index = 0; p->name; p++, option_index++)
if (!strncmp (p->name, nextchar, nameend - nextchar))
{
if (nameend - nextchar == strlen (p->name))
{
/* Exact match found. */
pfound = p;
indfound = option_index;
exact = 1;
break;
}
else if (pfound == NULL)
{
/* First nonexact match found. */
pfound = p;
indfound = option_index;
}
else
/* Second or later nonexact match found. */
ambig = 1;
}
if (ambig && !exact)
{
if (opterr)
fprintf (stderr, gettext ("%s: option `%s' is ambiguous\n"),
argv[0], argv[optind]);
nextchar += strlen (nextchar);
optind++;
return '?';
}
if (pfound != NULL)
{
option_index = indfound;
optind++;
if (*nameend)
{
/* Don't test has_arg with >, because some C compilers don't
allow it to be used on enums. */
if (pfound->has_arg)
optarg = nameend + 1;
else
{
if (opterr)
if (argv[optind - 1][1] == '-')
/* --option */
fprintf (stderr,
gettext ("%s: option `--%s' doesn't allow an argument\n"),
argv[0], pfound->name);
else
/* +option or -option */
fprintf (stderr,
gettext ("%s: option `%c%s' doesn't allow an argument\n"),
argv[0], argv[optind - 1][0], pfound->name);
nextchar += strlen (nextchar);
return '?';
}
}
else if (pfound->has_arg == 1)
{
if (optind < argc)
optarg = argv[optind++];
else
{
if (opterr)
fprintf (stderr,
gettext ("%s: option `%s' requires an argument\n"),
argv[0], argv[optind - 1]);
nextchar += strlen (nextchar);
return optstring[0] == ':' ? ':' : '?';
}
}
nextchar += strlen (nextchar);
if (longind != NULL)
*longind = option_index;
if (pfound->flag)
{
*(pfound->flag) = pfound->val;
return 0;
}
return pfound->val;
}
/* Can't find it as a long option. If this is not getopt_long_only,
or the option starts with '--' or is not a valid short
option, then it's an error.
Otherwise interpret it as a short option. */
if (!long_only || argv[optind][1] == '-'
|| my_index (optstring, *nextchar) == NULL)
{
if (opterr)
{
if (argv[optind][1] == '-')
/* --option */
fprintf (stderr, gettext ("%s: unrecognized option `--%s'\n"),
argv[0], nextchar);
else
/* +option or -option */
fprintf (stderr, gettext ("%s: unrecognized option `%c%s'\n"),
argv[0], argv[optind][0], nextchar);
}
nextchar = (char *) "";
optind++;
return '?';
}
}
/* Look at and handle the next short option-character. */
{
char c = *nextchar++;
char *temp = my_index (optstring, c);
/* Increment `optind' when we start to process its last character. */
if (*nextchar == '\0')
++optind;
if (temp == NULL || c == ':')
{
if (opterr)
{
if (posixly_correct)
/* 1003.2 specifies the format of this message. */
fprintf (stderr, gettext ("%s: illegal option -- %c\n"),
argv[0], c);
else
fprintf (stderr, gettext ("%s: invalid option -- %c\n"),
argv[0], c);
}
optopt = c;
return '?';
}
if (temp[1] == ':')
{
if (temp[2] == ':')
{
/* This is an option that accepts an argument optionally. */
if (*nextchar != '\0')
{
optarg = nextchar;
optind++;
}
else
optarg = NULL;
nextchar = NULL;
}
else
{
/* This is an option that requires an argument. */
if (*nextchar != '\0')
{
optarg = nextchar;
/* If we end this ARGV-element by taking the rest as an arg,
we must advance to the next element now. */
optind++;
}
else if (optind == argc)
{
if (opterr)
{
/* 1003.2 specifies the format of this message. */
fprintf (stderr,
gettext ("%s: option requires an argument -- %c\n"),
argv[0], c);
}
optopt = c;
if (optstring[0] == ':')
c = ':';
else
c = '?';
}
else
/* We already incremented `optind' once;
increment it again when taking next ARGV-elt as argument. */
optarg = argv[optind++];
nextchar = NULL;
}
}
return c;
}
}
int
getopt (argc, argv, optstring)
int argc;
char *const *argv;
const char *optstring;
{
return _getopt_internal (argc, argv, optstring,
(const struct option *) 0,
(int *) 0,
0);
}
int
getopt_long (argc, argv, options, long_options, opt_index)
int argc;
char *const *argv;
const char *options;
const struct option *long_options;
int *opt_index;
{
return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
}
#endif /* _LIBC or not __GNU_LIBRARY__. */
#ifdef TEST
/* Compile with -DTEST to make an executable for use in testing
the above definition of `getopt'. */
int
main (argc, argv)
int argc;
char **argv;
{
int c;
int digit_optind = 0;
while (1)
{
int this_option_optind = optind ? optind : 1;
c = getopt (argc, argv, "abc:d:0123456789");
if (c == EOF)
break;
switch (c)
{
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
if (digit_optind != 0 && digit_optind != this_option_optind)
printf ("digits occur in two different argv-elements.\n");
digit_optind = this_option_optind;
printf ("option %c\n", c);
break;
case 'a':
printf ("option a\n");
break;
case 'b':
printf ("option b\n");
break;
case 'c':
printf ("option c with value `%s'\n", optarg);
break;
case '?':
break;
default:
printf ("?? getopt returned character code 0%o ??\n", c);
}
}
if (optind < argc)
{
printf ("non-option ARGV-elements: ");
while (optind < argc)
printf ("%s ", argv[optind++]);
printf ("\n");
}
exit (0);
}
#endif /* TEST */
#else /* HAVE_GETOPT_LONG */
void getopt_dummy(void) {}
#endif

View File

@@ -1,129 +0,0 @@
/* Declarations for getopt.
Copyright (C) 1989, 90, 91, 92, 93, 94 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifndef _GETOPT_H
#define _GETOPT_H 1
#ifdef __cplusplus
extern "C" {
#endif
/* For communication from `getopt' to the caller.
When `getopt' finds an option that takes an argument,
the argument value is returned here.
Also, when `ordering' is RETURN_IN_ORDER,
each non-option ARGV-element is returned here. */
extern char *optarg;
/* Index in ARGV of the next element to be scanned.
This is used for communication to and from the caller
and for communication between successive calls to `getopt'.
On entry to `getopt', zero means this is the first call; initialize.
When `getopt' returns EOF, this is the index of the first of the
non-option elements that the caller should itself scan.
Otherwise, `optind' communicates from one call to the next
how much of ARGV has been scanned so far. */
extern int optind;
/* Callers store zero here to inhibit the error message `getopt' prints
for unrecognized options. */
extern int opterr;
/* Set to an option character which was unrecognized. */
extern int optopt;
/* Describe the long-named options requested by the application.
The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
of `struct option' terminated by an element containing a name which is
zero.
The field `has_arg' is:
no_argument (or 0) if the option does not take an argument,
required_argument (or 1) if the option requires an argument,
optional_argument (or 2) if the option takes an optional argument.
If the field `flag' is not NULL, it points to a variable that is set
to the value given in the field `val' when the option is found, but
left unchanged if the option is not found.
To have a long-named option do something other than set an `int' to
a compiled-in constant, such as set a value from `optarg', set the
option's `flag' field to zero and its `val' field to a nonzero
value (the equivalent single-letter option character, if there is
one). For long options that have a zero `flag' field, `getopt'
returns the contents of the `val' field. */
struct option
{
#if defined (__STDC__) && __STDC__
const char *name;
#else
char *name;
#endif
/* has_arg can't be an enum because some compilers complain about
type mismatches in all the code that assumes it is an int. */
int has_arg;
int *flag;
int val;
};
/* Names for the values of the `has_arg' field of `struct option'. */
#define no_argument 0
#define required_argument 1
#define optional_argument 2
#if defined (__STDC__) && __STDC__
#ifdef __GNU_LIBRARY__
/* Many other libraries have conflicting prototypes for getopt, with
differences in the consts, in stdlib.h. To avoid compilation
errors, only prototype getopt for the GNU C library. */
extern int getopt (int argc, char *const *argv, const char *shortopts);
#else /* not __GNU_LIBRARY__ */
extern int getopt ();
#endif /* __GNU_LIBRARY__ */
extern int getopt_long (int argc, char *const *argv, const char *shortopts,
const struct option *longopts, int *longind);
extern int getopt_long_only (int argc, char *const *argv,
const char *shortopts,
const struct option *longopts, int *longind);
/* Internal only. Users should not call this directly. */
extern int _getopt_internal (int argc, char *const *argv,
const char *shortopts,
const struct option *longopts, int *longind,
int long_only);
#else /* not __STDC__ */
extern int getopt ();
extern int getopt_long ();
extern int getopt_long_only ();
extern int _getopt_internal ();
#endif /* __STDC__ */
#ifdef __cplusplus
}
#endif
#endif /* _GETOPT_H */

184
lib/inet_ntop.c Normal file
View File

@@ -0,0 +1,184 @@
/*
* Copyright (C) 1996-2001 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "rsync.h"
#define NS_INT16SZ 2
#define NS_IN6ADDRSZ 16
/*
* WARNING: Don't even consider trying to compile this on a system where
* sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
*/
static const char *inet_ntop4(const unsigned char *src, char *dst,
size_t size);
#ifdef AF_INET6
static const char *inet_ntop6(const unsigned char *src, char *dst,
size_t size);
#endif
/* char *
* isc_net_ntop(af, src, dst, size)
* convert a network format address to presentation format.
* return:
* pointer to presentation format address (`dst'), or NULL (see errno).
* author:
* Paul Vixie, 1996.
*/
const char *
inet_ntop(int af, const void *src, char *dst, size_t size)
{
switch (af) {
case AF_INET:
return (inet_ntop4(src, dst, size));
#ifdef AF_INET6
case AF_INET6:
return (inet_ntop6(src, dst, size));
#endif
default:
errno = EAFNOSUPPORT;
return (NULL);
}
/* NOTREACHED */
}
/* const char *
* inet_ntop4(src, dst, size)
* format an IPv4 address
* return:
* `dst' (as a const)
* notes:
* (1) uses no statics
* (2) takes a unsigned char* not an in_addr as input
* author:
* Paul Vixie, 1996.
*/
static const char *
inet_ntop4(const unsigned char *src, char *dst, size_t size)
{
static const char *fmt = "%u.%u.%u.%u";
char tmp[sizeof "255.255.255.255"];
if ((size_t)sprintf(tmp, fmt, src[0], src[1], src[2], src[3]) >= size)
{
errno = ENOSPC;
return (NULL);
}
strcpy(dst, tmp);
return (dst);
}
/* const char *
* isc_inet_ntop6(src, dst, size)
* convert IPv6 binary address into presentation (printable) format
* author:
* Paul Vixie, 1996.
*/
#ifdef AF_INET6
static const char *
inet_ntop6(const unsigned char *src, char *dst, size_t size)
{
/*
* Note that int32_t and int16_t need only be "at least" large enough
* to contain a value of the specified size. On some systems, like
* Crays, there is no such thing as an integer variable with 16 bits.
* Keep this in mind if you think this function should have been coded
* to use pointer overlays. All the world's not a VAX.
*/
char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp;
struct { int base, len; } best, cur;
unsigned int words[NS_IN6ADDRSZ / NS_INT16SZ];
int i;
/*
* Preprocess:
* Copy the input (bytewise) array into a wordwise array.
* Find the longest run of 0x00's in src[] for :: shorthanding.
*/
memset(words, '\0', sizeof words);
for (i = 0; i < NS_IN6ADDRSZ; i++)
words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
best.base = -1;
cur.base = -1;
for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
if (words[i] == 0) {
if (cur.base == -1)
cur.base = i, cur.len = 1;
else
cur.len++;
} else {
if (cur.base != -1) {
if (best.base == -1 || cur.len > best.len)
best = cur;
cur.base = -1;
}
}
}
if (cur.base != -1) {
if (best.base == -1 || cur.len > best.len)
best = cur;
}
if (best.base != -1 && best.len < 2)
best.base = -1;
/*
* Format the result.
*/
tp = tmp;
for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
/* Are we inside the best run of 0x00's? */
if (best.base != -1 && i >= best.base &&
i < (best.base + best.len)) {
if (i == best.base)
*tp++ = ':';
continue;
}
/* Are we following an initial run of 0x00s or any real hex? */
if (i != 0)
*tp++ = ':';
/* Is this address an encapsulated IPv4? */
if (i == 6 && best.base == 0 &&
(best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
if (!inet_ntop4(src+12, tp,
sizeof tmp - (tp - tmp)))
return (NULL);
tp += strlen(tp);
break;
}
tp += sprintf(tp, "%x", words[i]);
}
/* Was it a trailing run of 0x00's? */
if (best.base != -1 && (best.base + best.len) ==
(NS_IN6ADDRSZ / NS_INT16SZ))
*tp++ = ':';
*tp++ = '\0';
/*
* Check for overflow, copy, and we're done.
*/
if ((size_t)(tp - tmp) > size) {
errno = ENOSPC;
return (NULL);
}
strcpy(dst, tmp);
return (dst);
}
#endif /* AF_INET6 */

212
lib/inet_pton.c Normal file
View File

@@ -0,0 +1,212 @@
/*
* Copyright (C) 1996-2001 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "rsync.h"
#define NS_INT16SZ 2
#define NS_INADDRSZ 4
#define NS_IN6ADDRSZ 16
/*
* WARNING: Don't even consider trying to compile this on a system where
* sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
*/
static int inet_pton4(const char *src, unsigned char *dst);
#ifdef INET6
static int inet_pton6(const char *src, unsigned char *dst);
#endif
/* int
* inet_pton(af, src, dst)
* convert from presentation format (which usually means ASCII printable)
* to network format (which is usually some kind of binary format).
* return:
* 1 if the address was valid for the specified address family
* 0 if the address wasn't valid (`dst' is untouched in this case)
* -1 if some other error occurred (`dst' is untouched in this case, too)
* author:
* Paul Vixie, 1996.
*/
int
inet_pton(int af,
const char *src,
void *dst)
{
switch (af) {
case AF_INET:
return (inet_pton4(src, dst));
#ifdef INET6
case AF_INET6:
return (inet_pton6(src, dst));
#endif
default:
errno = EAFNOSUPPORT;
return (-1);
}
/* NOTREACHED */
}
/* int
* inet_pton4(src, dst)
* like inet_aton() but without all the hexadecimal and shorthand.
* return:
* 1 if `src' is a valid dotted quad, else 0.
* notice:
* does not touch `dst' unless it's returning 1.
* author:
* Paul Vixie, 1996.
*/
static int
inet_pton4(src, dst)
const char *src;
unsigned char *dst;
{
static const char digits[] = "0123456789";
int saw_digit, octets, ch;
unsigned char tmp[NS_INADDRSZ], *tp;
saw_digit = 0;
octets = 0;
*(tp = tmp) = 0;
while ((ch = *src++) != '\0') {
const char *pch;
if ((pch = strchr(digits, ch)) != NULL) {
unsigned int new = *tp * 10 + (pch - digits);
if (new > 255)
return (0);
*tp = new;
if (! saw_digit) {
if (++octets > 4)
return (0);
saw_digit = 1;
}
} else if (ch == '.' && saw_digit) {
if (octets == 4)
return (0);
*++tp = 0;
saw_digit = 0;
} else
return (0);
}
if (octets < 4)
return (0);
memcpy(dst, tmp, NS_INADDRSZ);
return (1);
}
/* int
* inet_pton6(src, dst)
* convert presentation level address to network order binary form.
* return:
* 1 if `src' is a valid [RFC1884 2.2] address, else 0.
* notice:
* (1) does not touch `dst' unless it's returning 1.
* (2) :: in a full address is silently ignored.
* credit:
* inspired by Mark Andrews.
* author:
* Paul Vixie, 1996.
*/
#ifdef INET6
static int
inet_pton6(src, dst)
const char *src;
unsigned char *dst;
{
static const char xdigits_l[] = "0123456789abcdef",
xdigits_u[] = "0123456789ABCDEF";
unsigned char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp;
const char *xdigits, *curtok;
int ch, saw_xdigit;
unsigned int val;
memset((tp = tmp), '\0', NS_IN6ADDRSZ);
endp = tp + NS_IN6ADDRSZ;
colonp = NULL;
/* Leading :: requires some special handling. */
if (*src == ':')
if (*++src != ':')
return (0);
curtok = src;
saw_xdigit = 0;
val = 0;
while ((ch = *src++) != '\0') {
const char *pch;
if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
pch = strchr((xdigits = xdigits_u), ch);
if (pch != NULL) {
val <<= 4;
val |= (pch - xdigits);
if (val > 0xffff)
return (0);
saw_xdigit = 1;
continue;
}
if (ch == ':') {
curtok = src;
if (!saw_xdigit) {
if (colonp)
return (0);
colonp = tp;
continue;
}
if (tp + NS_INT16SZ > endp)
return (0);
*tp++ = (unsigned char) (val >> 8) & 0xff;
*tp++ = (unsigned char) val & 0xff;
saw_xdigit = 0;
val = 0;
continue;
}
if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) &&
inet_pton4(curtok, tp) > 0) {
tp += NS_INADDRSZ;
saw_xdigit = 0;
break; /* '\0' was seen by inet_pton4(). */
}
return (0);
}
if (saw_xdigit) {
if (tp + NS_INT16SZ > endp)
return (0);
*tp++ = (unsigned char) (val >> 8) & 0xff;
*tp++ = (unsigned char) val & 0xff;
}
if (colonp != NULL) {
/*
* Since some memmove()'s erroneously fail to handle
* overlapping regions, we'll do the shift by hand.
*/
const int n = tp - colonp;
int i;
for (i = 1; i <= n; i++) {
endp[- i] = colonp[n - i];
colonp[n - i] = 0;
}
tp = endp;
}
if (tp != endp)
return (0);
memcpy(dst, tmp, NS_IN6ADDRSZ);
return (1);
}
#endif

View File

@@ -28,30 +28,23 @@
static struct mdfour *m;
#define F(X,Y,Z) (((X)&(Y)) | ((~(X))&(Z)))
#define G(X,Y,Z) (((X)&(Y)) | ((X)&(Z)) | ((Y)&(Z)))
#define H(X,Y,Z) ((X)^(Y)^(Z))
#ifdef LARGE_INT32
#define lshift(x,s) ((((x)<<(s))&0xFFFFFFFF) | (((x)>>(32-(s)))&0xFFFFFFFF))
#else
#define lshift(x,s) (((x)<<(s)) | ((x)>>(32-(s))))
#endif
#define MASK32 (0xffffffff)
#define ROUND1(a,b,c,d,k,s) a = lshift(a + F(b,c,d) + X[k], s)
#define ROUND2(a,b,c,d,k,s) a = lshift(a + G(b,c,d) + X[k] + 0x5A827999,s)
#define ROUND3(a,b,c,d,k,s) a = lshift(a + H(b,c,d) + X[k] + 0x6ED9EBA1,s)
#define F(X,Y,Z) ((((X)&(Y)) | ((~(X))&(Z))))
#define G(X,Y,Z) ((((X)&(Y)) | ((X)&(Z)) | ((Y)&(Z))))
#define H(X,Y,Z) (((X)^(Y)^(Z)))
#define lshift(x,s) (((((x)<<(s))&MASK32) | (((x)>>(32-(s)))&MASK32)))
#define ROUND1(a,b,c,d,k,s) a = lshift((a + F(b,c,d) + M[k])&MASK32, s)
#define ROUND2(a,b,c,d,k,s) a = lshift((a + G(b,c,d) + M[k] + 0x5A827999)&MASK32,s)
#define ROUND3(a,b,c,d,k,s) a = lshift((a + H(b,c,d) + M[k] + 0x6ED9EBA1)&MASK32,s)
/* this applies md4 to 64 byte chunks */
static void mdfour64(uint32 *M)
{
int j;
uint32 AA, BB, CC, DD;
uint32 X[16];
uint32 A,B,C,D;
for (j=0;j<16;j++)
X[j] = M[j];
A = m->A; B = m->B; C = m->C; D = m->D;
AA = A; BB = B; CC = C; DD = D;
@@ -64,6 +57,7 @@ static void mdfour64(uint32 *M)
ROUND1(A,B,C,D, 12, 3); ROUND1(D,A,B,C, 13, 7);
ROUND1(C,D,A,B, 14, 11); ROUND1(B,C,D,A, 15, 19);
ROUND2(A,B,C,D, 0, 3); ROUND2(D,A,B,C, 4, 5);
ROUND2(C,D,A,B, 8, 9); ROUND2(B,C,D,A, 12, 13);
ROUND2(A,B,C,D, 1, 3); ROUND2(D,A,B,C, 5, 5);
@@ -82,15 +76,11 @@ static void mdfour64(uint32 *M)
ROUND3(A,B,C,D, 3, 3); ROUND3(D,A,B,C, 11, 9);
ROUND3(C,D,A,B, 7, 11); ROUND3(B,C,D,A, 15, 15);
A += AA; B += BB; C += CC; D += DD;
A += AA; B += BB;
C += CC; D += DD;
#ifdef LARGE_INT32
A &= 0xFFFFFFFF; B &= 0xFFFFFFFF;
C &= 0xFFFFFFFF; D &= 0xFFFFFFFF;
#endif
for (j=0;j<16;j++)
X[j] = 0;
A &= MASK32; B &= MASK32;
C &= MASK32; D &= MASK32;
m->A = A; m->B = B; m->C = C; m->D = D;
}
@@ -119,29 +109,53 @@ void mdfour_begin(struct mdfour *md)
md->C = 0x98badcfe;
md->D = 0x10325476;
md->totalN = 0;
md->totalN2 = 0;
}
static void mdfour_tail(unsigned char *in, int n)
static void mdfour_tail(unsigned char *in, uint32 n)
{
unsigned char buf[128];
uint32 M[16];
uint32 b;
extern int protocol_version;
m->totalN += n;
b = m->totalN * 8;
/*
* Count total number of bits, modulo 2^64
*/
m->totalN += n << 3;
if (m->totalN < (n << 3)) {
m->totalN2++;
}
m->totalN2 += n >> 29;
memset(buf, 0, 128);
if (n) memcpy(buf, in, n);
buf[n] = 0x80;
if (n <= 55) {
copy4(buf+56, b);
copy4(buf+56, m->totalN);
/*
* Prior to protocol version 27 only the number of bits
* modulo 2^32 was included. MD4 requires the number
* of bits modulo 2^64, which was fixed starting with
* protocol version 27.
*/
if (protocol_version >= 27) {
copy4(buf+60, m->totalN2);
}
copy64(M, buf);
mdfour64(M);
} else {
copy4(buf+120, b);
copy4(buf+120, m->totalN);
/*
* Prior to protocol version 27 only the number of bits
* modulo 2^32 was included. MD4 requires the number
* of bits modulo 2^64, which was fixed starting with
* protocol version 27.
*/
if (protocol_version >= 27) {
copy4(buf+124, m->totalN2);
}
copy64(M, buf);
mdfour64(M);
copy64(M, buf+64);
@@ -149,20 +163,23 @@ static void mdfour_tail(unsigned char *in, int n)
}
}
void mdfour_update(struct mdfour *md, unsigned char *in, int n)
void mdfour_update(struct mdfour *md, unsigned char *in, uint32 n)
{
uint32 M[16];
if (n == 0) mdfour_tail(in, n);
m = md;
if (n == 0) mdfour_tail(in, n);
while (n >= 64) {
copy64(M, in);
mdfour64(M);
in += 64;
n -= 64;
m->totalN += 64;
m->totalN += 64 << 3;
if (m->totalN < 64 << 3) {
m->totalN2++;
}
}
if (n) mdfour_tail(in, n);
@@ -189,9 +206,11 @@ void mdfour(unsigned char *out, unsigned char *in, int n)
}
#ifdef TEST_MDFOUR
int protocol_version = 28;
static void file_checksum1(char *fname)
{
int fd, i;
int fd, i, was_multiple_of_64 = 1;
struct mdfour md;
unsigned char buf[64*1024], sum[16];
@@ -205,9 +224,13 @@ static void file_checksum1(char *fname)
while (1) {
int n = read(fd, buf, sizeof(buf));
if (n <= 0) break;
if (n <= 0)
break;
was_multiple_of_64 = !(n % 64);
mdfour_update(&md, buf, n);
}
if (was_multiple_of_64 && protocol_version >= 27)
mdfour_update(&md, buf, 0);
close(fd);

View File

@@ -21,11 +21,12 @@
struct mdfour {
uint32 A, B, C, D;
uint32 totalN;
uint32 totalN; /* bit count, lower 32 bits */
uint32 totalN2; /* bit count, upper 32 bits */
};
void mdfour_begin(struct mdfour *md);
void mdfour_update(struct mdfour *md, unsigned char *in, int n);
void mdfour_update(struct mdfour *md, unsigned char *in, uint32 n);
void mdfour_result(struct mdfour *md, unsigned char *out);
void mdfour(unsigned char *out, unsigned char *in, int n);

63
lib/permstring.c Normal file
View File

@@ -0,0 +1,63 @@
/*
Copyright (C) Andrew Tridgell 1996
Copyright (C) Paul Mackerras 1996
Copyright (C) 2001 by Martin Pool <mbp@samba.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "rsync.h"
/**
* Produce a string representation of Unix mode bits like that used by
* ls(1).
*
* @param buf buffer of at least 11 characters
**/
void permstring(char *perms,
int mode)
{
static const char *perm_map = "rwxrwxrwx";
int i;
strcpy(perms, "----------");
for (i=0;i<9;i++) {
if (mode & (1<<i)) perms[9-i] = perm_map[8-i];
}
/* Handle setuid/sticky bits. You might think the indices are
* off by one, but remember there's a type char at the
* start. */
if (mode & S_ISUID)
perms[3] = (mode & S_IXUSR) ? 's' : 'S';
if (mode & S_ISGID)
perms[6] = (mode & S_IXGRP) ? 's' : 'S';
#ifdef S_ISVTX
if (mode & S_ISVTX)
perms[9] = (mode & S_IXOTH) ? 't' : 'T';
#endif
if (S_ISLNK(mode)) perms[0] = 'l';
if (S_ISDIR(mode)) perms[0] = 'd';
if (S_ISBLK(mode)) perms[0] = 'b';
if (S_ISCHR(mode)) perms[0] = 'c';
if (S_ISSOCK(mode)) perms[0] = 's';
if (S_ISFIFO(mode)) perms[0] = 'p';
}

3
lib/permstring.h Normal file
View File

@@ -0,0 +1,3 @@
#define PERMSTRING_SIZE 11
void permstring(char *perms, int mode);

199
lib/pool_alloc.3 Normal file
View File

@@ -0,0 +1,199 @@
.ds d \-\^\-
.ds o \fR[\fP
.ds c \fR]\fP
.ds | \fR|\fP
.de D
\\.B \*d\\$1
..
.de DI
\\.BI \*d\\$1 \\$2
..
.de DR
\\.BR \*d\\$1 \\$2
..
.de Di
\\.BI \*d\\$1 " \\$2"
..
.de Db
\\.B \*d\\$1 " \\$2"
..
.de Df
\\.B \*d\*ono\*c\\$1
..
.de See
See \fB\\$1\fP for details.
..
.de SeeIn
See \fB\\$1\fP in \fB\\$2\fP for details.
..
.TH POOL_ALLOC 3
.SH NAME
pool_alloc, pool_free, pool_talloc, pool_tfree, pool_create, pool_destroy
\- Allocate and free memory in managed allocation pools.
.SH SYNOPSIS
.B #include "pool_alloc.h"
\fBstruct alloc_pool *pool_create(size_t \fIsize\fB, size_t \fIquantum\fB, void (*\fIbomb\fB)(char *), int \fIflags\fB);
\fBvoid pool_destroy(struct alloc_pool *\fIpool\fB);
\fBvoid *pool_alloc(struct alloc_pool *\fIpool\fB, size_t \fIsize\fB, char *\fImsg\fB);
\fBvoid pool_free(struct alloc_pool *\fIpool\fB, sise_t \fIsize\fB, void *\fIaddr\fB);
\fBvoid *pool_talloc(struct alloc_pool *\fIpool\fB, \fItype\fB), int \fIcount\fB, char *\fImsg\fB);
\fBvoid pool_tfree(struct alloc_pool *\fIpool\fB, \fItype\fB, int \fIcount\fB, void *\fIaddr\fB);
.SH DESCRIPTION
.P
The pool allocation routines use
.B malloc()
for underlying memory management.
What allocation pools do is cause
memory within a given pool to be in large contigious blocks
(called extents) that when freed will be reusable. Unlike
.B malloc()
the allocations are not managed individually.
Instead each extent tracks the total free memory within the
extent. Each extent can either be used to allocate memory
or to manage the freeing of memory within that extent.
When an extent has less free memory than a given
allocation request or when the first request to free
memory within that extent is received the extent ceases to
be used for allocation.
.P
This form of memory management is suited to large numbers of small
related allocations that are held for a while
and then freed as a group.
Because the
underlying allocations are done in large contigious extents
when an extent is freed it releases a large enough
contigious block of memory to be useful to subsequent
.B malloc()
and
.B pool_alloc()
calls even if allocations from other pools or from
.B malloc()
are made between allocations from a given pool.
.P
.B pool_create()
Creates an allocation pool for subsequent calls to the pool
allocation functions.
When an extent is created for allocations it will be
.I size
bytes.
Allocations from the pool have their sizes rounded up to a
multiple of
.I quantum
bytes in length.
Specifying
.B 0
for
.I quantum
Will produce a quantum that should meet maximal allignment
on most platforms.
If the
.B POOL_QALIGN
.I flag
is set allocations will be aligned to addresses that are a
multiple of
.IR quantum .
If the
.B POOL_CLEAR
.I flag
is set all allocations from the pool will be zero filled.
.P
.B pool_destroy()
destroys an allocation pool and frees all memory allocated
in that pool.
.P
.B pool_alloc()
allocates
.I size
bytes from the specified
.IR pool .
If
.I size
is
.B 0
.I quantum
bytes will be freed.
If the requested memory cannot be allocated
.B pool_alloc()
will call
.I bomb()
function, if defined, with
.I msg
as it's sole argument and
.B NULL
will be returned.
.P
.B pool_free()
frees
.I size
bytes pointed to by
.I addr
previously allocated in the specified
.IR pool .
The memory freed within an extent will not be reusable until
all of the memory in that extent has been freed but
depending on the order in which the
allocations are freed some extents may be released for reuse
while others are still in use.
If
.I size
is
.B 0
.I quantum
bytes will be freed.
If
.I addr
is
.B 0
no memory will be freed but subsequent allocations will come
from a new extent.
.P
.B pool_talloc()
is a macro that take a
.I type
and
.I count
instead of
.I size
and will cast the return value to the correct type.
.P
.B pool_tfree
is a macro to free memory previously allocated in the
specified
.IR pool .
.SH RETURN VALUE
.B pool_create()
returns a pointer to
.BR "struct alloc_pool" .
.P
.B pool_alloc()
and
.B pool_talloc()
return pointers to the allocated memory,
or NULL if the request fails.
For each extent so long as no allocations are smaller than varaible
allignment requirements this pointer will be suitably
alligned for any kind of variable.
The return type of
.B pool_alloc()
will normally require casting to the desired type but
.B pool_talloc()
will returns a pointer of the requested
.IR type .
.P
.BR pool_free() ,
.B pool_tfree()
and
.B pool_destroy()
return no value.
.SH SEE ALSO
.nf
malloc(3)
.SH AUTHOR
pool_alloc was created by J.W. Schultz of Pegasystems Technologies.
.SH BUGS AND ISSUES

304
lib/pool_alloc.c Normal file
View File

@@ -0,0 +1,304 @@
#include "rsync.h"
#define POOL_DEF_EXTENT (32 * 1024)
struct alloc_pool
{
size_t size; /* extent size */
size_t quantum; /* allocation quantum */
struct pool_extent *live; /* current extent for
* allocations */
struct pool_extent *free; /* unfreed extent list */
void (*bomb)();
/* function to call if
* malloc fails */
int flags;
/* statistical data */
unsigned long e_created; /* extents created */
unsigned long e_freed; /* extents detroyed */
int64 n_allocated; /* calls to alloc */
int64 n_freed; /* calls to free */
int64 b_allocated; /* cum. bytes allocated */
int64 b_freed; /* cum. bytes freed */
};
struct pool_extent
{
void *start; /* starting address */
size_t free; /* free bytecount */
size_t bound; /* bytes bound by padding,
* overhead and freed */
struct pool_extent *next;
};
struct align_test {
void *foo;
int64 bar;
};
#define MINALIGN offsetof(struct align_test, bar)
/* Temporarily cast a void* var into a char* var when adding an offset (to
* keep some compilers from complaining about the pointer arithmetic). */
#define PTR_ADD(b,o) ( (void*) ((char*)(b) + (o)) )
alloc_pool_t
pool_create(size_t size, size_t quantum,
void (*bomb)(char *), int flags)
{
struct alloc_pool *pool;
if (!(pool = (struct alloc_pool*) malloc(sizeof (struct alloc_pool))))
return pool;
memset(pool, 0, sizeof (struct alloc_pool));
pool->size = size /* round extent size to min alignment reqs */
? (size + MINALIGN - 1) & ~(MINALIGN - 1)
: POOL_DEF_EXTENT;
if (pool->flags & POOL_INTERN)
{
pool->size -= sizeof (struct pool_extent);
flags |= POOL_APPEND;
}
pool->quantum = quantum ? quantum : MINALIGN;
pool->bomb = bomb;
pool->flags = flags;
return pool;
}
void
pool_destroy(alloc_pool_t p)
{
struct alloc_pool *pool = (struct alloc_pool *) p;
struct pool_extent *cur, *next;
if (!pool)
return;
if (pool->live)
{
cur = pool->live;
free(cur->start);
if (!(pool->flags & POOL_APPEND))
free(cur);
}
for (cur = pool->free; cur; cur = next)
{
next = cur->next;
free(cur->start);
if (!(pool->flags & POOL_APPEND))
free(cur);
}
free(pool);
}
void *
pool_alloc(alloc_pool_t p, size_t len, char *bomb)
{
struct alloc_pool *pool = (struct alloc_pool *) p;
if (!pool)
return NULL;
if (!len)
len = pool->quantum;
else if (pool->quantum > 1 && len % pool->quantum)
len += pool->quantum - len % pool->quantum;
if (len > pool->size)
goto bomb;
if (!pool->live || len > pool->live->free)
{
void *start;
size_t free;
size_t bound;
size_t sqew;
size_t asize;
if (pool->live)
{
pool->live->next = pool->free;
pool->free = pool->live;
}
free = pool->size;
bound = 0;
asize = pool->size;
if (pool->flags & POOL_APPEND)
asize += sizeof (struct pool_extent);
if (!(start = (void *) malloc(asize)))
goto bomb;
if (pool->flags & POOL_CLEAR)
memset(start, 0, pool->size);
if (pool->flags & POOL_APPEND)
{
pool->live = PTR_ADD(start, free);
}
else if (!(pool->live = (struct pool_extent *) malloc(sizeof (struct pool_extent))))
{
goto bomb;
}
if (pool->flags & POOL_QALIGN && pool->quantum > 1
&& (sqew = (size_t)PTR_ADD(start, free) % pool->quantum))
{
bound += sqew;
free -= sqew;
}
pool->live->start = start;
pool->live->free = free;
pool->live->bound = bound;
pool->live->next = NULL;
pool->e_created++;
}
pool->n_allocated++;
pool->b_allocated += len;
pool->live->free -= len;
return PTR_ADD(pool->live->start, pool->live->free);
bomb:
if (pool->bomb)
(*pool->bomb)(bomb);
return NULL;
}
void
pool_free(alloc_pool_t p, size_t len, void *addr)
{
struct alloc_pool *pool = (struct alloc_pool *) p;
struct pool_extent *cur;
struct pool_extent *prev;
if (!pool)
return;
if (!len)
len = pool->quantum;
else if (pool->quantum > 1 && len % pool->quantum)
len += pool->quantum - len % pool->quantum;
if (!addr && pool->live)
{
pool->live->next = pool->free;
pool->free = pool->live;
pool->live = NULL;
return;
}
pool->n_freed++;
pool->b_freed += len;
cur = pool->live;
if (cur
&& addr >= cur->start
&& addr < PTR_ADD(cur->start, pool->size))
{
if (addr == PTR_ADD(cur->start, cur->free))
{
if (pool->flags & POOL_CLEAR)
memset(addr, 0, len);
pool->b_freed += len;
} else {
cur->bound += len;
}
if (cur->free + cur->bound >= pool->size)
{
size_t sqew;
cur->free = pool->size;
cur->bound = 0;
if (pool->flags & POOL_QALIGN && pool->quantum > 1
&& (sqew = (size_t)PTR_ADD(cur->start, cur->free) % pool->quantum))
{
cur->bound += sqew;
cur->free -= sqew;
}
}
return;
}
for (prev = NULL, cur = pool->free; cur; prev = cur, cur = cur->next)
{
if (addr >= cur->start
&& addr < PTR_ADD(cur->start, pool->size))
break;
}
if (!cur)
return;
if (prev)
{
prev->next = cur->next;
cur->next = pool->free;
pool->free = cur;
}
cur->bound += len;
if (cur->free + cur->bound >= pool->size)
{
pool->free = cur->next;
free(cur->start);
if (!(pool->flags & POOL_APPEND))
free(cur);
pool->e_freed++;
}
return;
}
#define FDPRINT(label, value) \
snprintf(buf, BUFSIZ, label, value), \
write(fd, buf, strlen(buf));
#define FDEXTSTAT(ext) \
snprintf(buf, BUFSIZ, " %12ld %5ld\n", \
(long) ext->free, \
(long) ext->bound), \
write(fd, buf, strlen(buf))
void
pool_stats(alloc_pool_t p, int fd, int summarize)
{
struct alloc_pool *pool = (struct alloc_pool *) p;
struct pool_extent *cur;
char buf[BUFSIZ];
if (!pool)
return;
FDPRINT(" Extent size: %12ld\n", (long) pool->size);
FDPRINT(" Alloc quantum: %12ld\n", (long) pool->quantum);
FDPRINT(" Extents created: %12ld\n", pool->e_created);
FDPRINT(" Extents freed: %12ld\n", pool->e_freed);
FDPRINT(" Alloc count: %12.0f\n", (double) pool->n_allocated);
FDPRINT(" Free Count: %12.0f\n", (double) pool->n_freed);
FDPRINT(" Alloc bytes: %12.0f\n", (double) pool->b_allocated);
FDPRINT(" Free bytes: %12.0f\n", (double) pool->b_freed);
if (summarize)
return;
if (!pool->live && !pool->free)
return;
write(fd, "\n", 1);
if (pool->live)
{
FDEXTSTAT(pool->live);
}
strcpy(buf, " FREE BOUND\n");
write(fd, buf, strlen(buf));
for (cur = pool->free; cur; cur = cur->next)
{
FDEXTSTAT(cur);
}
}

20
lib/pool_alloc.h Normal file
View File

@@ -0,0 +1,20 @@
#include <stddef.h>
#define POOL_CLEAR (1<<0) /* zero fill allocations */
#define POOL_QALIGN (1<<1) /* align data to quanta */
#define POOL_INTERN (1<<2) /* Allocate extent structures */
#define POOL_APPEND (1<<3) /* or appended to extent data */
typedef void *alloc_pool_t;
alloc_pool_t pool_create(size_t size, size_t quantum, void (*bomb)(char *), int flags);
void pool_destroy(alloc_pool_t pool);
void *pool_alloc(alloc_pool_t pool, size_t size, char *bomb);
void pool_free(alloc_pool_t pool, size_t size, void *addr);
#define pool_talloc(pool, type, count, bomb) \
((type *)pool_alloc(pool, sizeof(type) * count, bomb))
#define pool_tfree(pool, type, count, addr) \
(pool_free(pool, sizeof(type) * count, addr))

View File

File diff suppressed because it is too large Load Diff

229
lib/wildmatch.c Normal file
View File

@@ -0,0 +1,229 @@
/*
** Do shell-style pattern matching for ?, \, [], and * characters.
** It is 8bit clean.
**
** Written by Rich $alz, mirror!rs, Wed Nov 26 19:03:17 EST 1986.
** Rich $alz is now <rsalz@bbn.com>.
**
** Modified by Wayne Davison to special-case '/' matching, to make '**'
** work differently than '*', and to fix the character-class code.
*/
#include "rsync.h"
/* What character marks an inverted character class? */
#define NEGATE_CLASS '!'
#define NEGATE_CLASS2 '^'
#define FALSE 0
#define TRUE 1
#define ABORT_ALL -1
#define ABORT_TO_STARSTAR -2
#define CC_EQ(class, len, litmatch) ((len) == sizeof (litmatch)-1 \
&& *(class) == *(litmatch) \
&& strncmp((char*)class, litmatch, len) == 0)
#if defined STDC_HEADERS || !defined isascii
# define ISASCII(c) 1
#else
# define ISASCII(c) isascii(c)
#endif
#ifdef isblank
# define ISBLANK(c) (ISASCII(c) && isblank(c))
#else
# define ISBLANK(c) ((c) == ' ' || (c) == '\t')
#endif
#ifdef isgraph
# define ISGRAPH(c) (ISASCII(c) && isgraph(c))
#else
# define ISGRAPH(c) (ISASCII(c) && isprint(c) && !isspace(c))
#endif
#define ISPRINT(c) (ISASCII(c) && isprint(c))
#define ISDIGIT(c) (ISASCII(c) && isdigit(c))
#define ISALNUM(c) (ISASCII(c) && isalnum(c))
#define ISALPHA(c) (ISASCII(c) && isalpha(c))
#define ISCNTRL(c) (ISASCII(c) && iscntrl(c))
#define ISLOWER(c) (ISASCII(c) && islower(c))
#define ISPUNCT(c) (ISASCII(c) && ispunct(c))
#define ISSPACE(c) (ISASCII(c) && isspace(c))
#define ISUPPER(c) (ISASCII(c) && isupper(c))
#define ISXDIGIT(c) (ISASCII(c) && isxdigit(c))
#ifdef WILD_TEST_ITERATIONS
int wildmatch_iteration_count;
#endif
static int domatch(const uchar *p, const uchar *text)
{
int matched, special;
uchar ch, prev;
#ifdef WILD_TEST_ITERATIONS
wildmatch_iteration_count++;
#endif
for ( ; (ch = *p) != '\0'; text++, p++) {
if (*text == '\0' && ch != '*')
return FALSE;
switch (ch) {
case '\\':
/* Literal match with following character. Note that the test
* in "default" handles the p[1] == '\0' failure case. */
ch = *++p;
/* FALLTHROUGH */
default:
if (*text != ch)
return FALSE;
continue;
case '?':
/* Match anything but '/'. */
if (*text == '/')
return FALSE;
continue;
case '*':
if (*++p == '*') {
while (*++p == '*') {}
special = TRUE;
}
else
special = FALSE;
if (*p == '\0') {
/* Trailing "**" matches everything. Trailing "*" matches
* only if there are no more slash characters. */
return special? TRUE : strchr((char*)text, '/') == NULL;
}
for ( ; *text; text++) {
if ((matched = domatch(p, text)) != FALSE) {
if (!special || matched != ABORT_TO_STARSTAR)
return matched;
}
else if (!special && *text == '/')
return ABORT_TO_STARSTAR;
}
return ABORT_ALL;
case '[':
ch = *++p;
#ifdef NEGATE_CLASS2
if (ch == NEGATE_CLASS2)
ch = NEGATE_CLASS;
#endif
/* Assign literal TRUE/FALSE because of "matched" comparison. */
special = ch == NEGATE_CLASS? TRUE : FALSE;
if (special) {
/* Inverted character class. */
ch = *++p;
}
prev = 0;
matched = FALSE;
do {
if (!ch)
return ABORT_ALL;
if (ch == '\\') {
ch = *++p;
if (!ch)
return ABORT_ALL;
if (*text == ch)
matched = TRUE;
}
else if (ch == '-' && prev && p[1] && p[1] != ']') {
ch = *++p;
if (ch == '\\') {
ch = *++p;
if (!ch)
return ABORT_ALL;
}
if (*text <= ch && *text >= prev)
matched = TRUE;
ch = 0; /* This makes "prev" get set to 0. */
}
else if (ch == '[' && p[1] == ':') {
const uchar *s;
int i;
for (s = p += 2; (ch = *p) && ch != ']'; p++) {}
if (!ch)
return ABORT_ALL;
i = p - s - 1;
if (i < 0 || p[-1] != ':') {
/* Didn't find ":]", so treat like a normal set. */
p = s - 2;
ch = '[';
if (*text == ch)
matched = TRUE;
continue;
}
if (CC_EQ(s,i, "alnum")) {
if (ISALNUM(*text))
matched = TRUE;
}
else if (CC_EQ(s,i, "alpha")) {
if (ISALPHA(*text))
matched = TRUE;
}
else if (CC_EQ(s,i, "blank")) {
if (ISBLANK(*text))
matched = TRUE;
}
else if (CC_EQ(s,i, "cntrl")) {
if (ISCNTRL(*text))
matched = TRUE;
}
else if (CC_EQ(s,i, "digit")) {
if (ISDIGIT(*text))
matched = TRUE;
}
else if (CC_EQ(s,i, "graph")) {
if (ISGRAPH(*text))
matched = TRUE;
}
else if (CC_EQ(s,i, "lower")) {
if (ISLOWER(*text))
matched = TRUE;
}
else if (CC_EQ(s,i, "print")) {
if (ISPRINT(*text))
matched = TRUE;
}
else if (CC_EQ(s,i, "punct")) {
if (ISPUNCT(*text))
matched = TRUE;
}
else if (CC_EQ(s,i, "space")) {
if (ISSPACE(*text))
matched = TRUE;
}
else if (CC_EQ(s,i, "upper")) {
if (ISUPPER(*text))
matched = TRUE;
}
else if (CC_EQ(s,i, "xdigit")) {
if (ISXDIGIT(*text))
matched = TRUE;
}
else /* malformed [:class:] string */
return ABORT_ALL;
ch = 0; /* This makes "prev" get set to 0. */
}
else if (*text == ch)
matched = TRUE;
} while (prev = ch, (ch = *++p) != ']');
if (matched == special || *text == '/')
return FALSE;
continue;
}
}
return *text == '\0';
}
/* Find the pattern (p) in the text string (t). */
int wildmatch(const char *p, const char *t)
{
#ifdef WILD_TEST_ITERATIONS
wildmatch_iteration_count = 0;
#endif
return domatch((const uchar*)p, (const uchar*)t) == TRUE;
}

3
lib/wildmatch.h Normal file
View File

@@ -0,0 +1,3 @@
/* wildmatch.h */
int wildmatch(const char *p, const char *text);

View File

@@ -1,17 +1,22 @@
/* This is based on loadparm.c from Samba, written by Andrew Tridgell
and Karl Auer */
/*
/* some fixes
*
* Copyright (C) 2001, 2002 by Martin Pool <mbp@samba.org>
*/
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -31,7 +36,7 @@
* 3) add it to the list of available functions (eg: using FN_GLOBAL_STRING())
* 4) If it's a global then initialise it in init_globals. If a local
* (ie. service) parameter then initialise it in the sDefault structure
*
*
*
* Notes:
* The configuration file is processed sequentially for speed. It is NOT
@@ -43,6 +48,8 @@
*
*/
/* TODO: Parameter to set debug level on server. */
#include "rsync.h"
#define PTR_DIFF(p1,p2) ((ptrdiff_t)(((char *)(p1)) - (char *)(p2)))
#define strequal(a,b) (strcasecmp(a,b)==0)
@@ -54,7 +61,7 @@ typedef char pstring[1024];
typedef enum
{
P_BOOL,P_BOOLREV,P_CHAR,P_INTEGER,P_OCTAL,
P_STRING,P_GSTRING,P_ENUM,P_SEP
P_PATH,P_STRING,P_GSTRING,P_ENUM,P_SEP
} parm_type;
typedef enum
@@ -77,8 +84,6 @@ struct parm_struct
unsigned flags;
};
static BOOL bLoaded = False;
#ifndef GLOBAL_NAME
#define GLOBAL_NAME "global"
#endif
@@ -88,7 +93,7 @@ static BOOL bLoaded = False;
#define iSERVICE(i) (*pSERVICE(i))
#define LP_SNUM_OK(iService) (((iService) >= 0) && ((iService) < iNumServices))
/*
/*
* This structure describes global (ie., server-wide) parameters.
*/
typedef struct
@@ -96,16 +101,17 @@ typedef struct
char *motd_file;
char *log_file;
char *pid_file;
int syslog_facility;
char *socket_options;
char *bind_address;
int syslog_facility;
int rsync_port;
} global;
static global Globals;
/*
* This structure describes a single service.
/*
* This structure describes a single service.
*/
typedef struct
{
@@ -114,9 +120,11 @@ typedef struct
char *comment;
char *lock_file;
BOOL read_only;
BOOL write_only;
BOOL list;
BOOL use_chroot;
BOOL transfer_logging;
BOOL ignore_errors;
char *uid;
char *gid;
char *hosts_allow;
@@ -124,6 +132,7 @@ typedef struct
char *auth_users;
char *secrets_file;
BOOL strict_modes;
char *filter;
char *exclude;
char *exclude_from;
char *include;
@@ -131,38 +140,49 @@ typedef struct
char *log_format;
char *refuse_options;
char *dont_compress;
char *prexfer_exec;
char *postxfer_exec;
int timeout;
int max_connections;
int max_verbosity;
BOOL ignore_nonreadable;
} service;
/* This is a default service used to prime a services structure */
static service sDefault =
static service sDefault =
{
NULL, /* name */
NULL, /* path */
NULL, /* comment */
DEFAULT_LOCK_FILE, /* lock file */
True, /* read only */
False, /* write only */
True, /* list */
True, /* use chroot */
False, /* transfer logging */
"nobody",/* uid */
"nobody",/* gid */
False, /* ignore errors */
NOBODY_USER,/* uid */
NOBODY_GROUP,/* gid */
NULL, /* hosts allow */
NULL, /* hosts deny */
NULL, /* auth users */
NULL, /* secrets file */
True, /* strict modes */
NULL, /* filter */
NULL, /* exclude */
NULL, /* exclude from */
NULL, /* include */
NULL, /* include from */
"%o %h [%a] %m (%u) %f %l", /* log format */
NULL, /* refuse options */
"*.gz *.tgz *.zip *.z *.rpm *.deb", /* dont compress */
"*.gz *.tgz *.zip *.z *.rpm *.deb *.iso *.bz2 *.tbz", /* dont compress */
NULL, /* prexfer_exec */
NULL, /* postxfer_exec */
0, /* timeout */
0 /* max connections */
0, /* max connections */
1, /* max verbosity */
False /* ignore nonreadable */
};
@@ -204,7 +224,7 @@ static struct enum_list enum_facilities[] = {
{ LOG_NEWS, "news" },
#endif
#ifdef LOG_AUTH
{ LOG_AUTH, "security" },
{ LOG_AUTH, "security" },
#endif
#ifdef LOG_SYSLOG
{ LOG_SYSLOG, "syslog" },
@@ -250,16 +270,21 @@ static struct parm_struct parm_table[] =
{"socket options", P_STRING, P_GLOBAL, &Globals.socket_options,NULL, 0},
{"log file", P_STRING, P_GLOBAL, &Globals.log_file, NULL, 0},
{"pid file", P_STRING, P_GLOBAL, &Globals.pid_file, NULL, 0},
{"port", P_INTEGER, P_GLOBAL, &Globals.rsync_port, NULL, 0},
{"address", P_STRING, P_GLOBAL, &Globals.bind_address, NULL, 0},
{"timeout", P_INTEGER, P_LOCAL, &sDefault.timeout, NULL, 0},
{"max connections", P_INTEGER, P_LOCAL, &sDefault.max_connections,NULL, 0},
{"max verbosity", P_INTEGER, P_LOCAL, &sDefault.max_verbosity,NULL, 0},
{"name", P_STRING, P_LOCAL, &sDefault.name, NULL, 0},
{"comment", P_STRING, P_LOCAL, &sDefault.comment, NULL, 0},
{"lock file", P_STRING, P_LOCAL, &sDefault.lock_file, NULL, 0},
{"path", P_STRING, P_LOCAL, &sDefault.path, NULL, 0},
{"path", P_PATH, P_LOCAL, &sDefault.path, NULL, 0},
{"read only", P_BOOL, P_LOCAL, &sDefault.read_only, NULL, 0},
{"write only", P_BOOL, P_LOCAL, &sDefault.write_only, NULL, 0},
{"list", P_BOOL, P_LOCAL, &sDefault.list, NULL, 0},
{"use chroot", P_BOOL, P_LOCAL, &sDefault.use_chroot, NULL, 0},
{"ignore nonreadable",P_BOOL, P_LOCAL, &sDefault.ignore_nonreadable, NULL, 0},
{"uid", P_STRING, P_LOCAL, &sDefault.uid, NULL, 0},
{"gid", P_STRING, P_LOCAL, &sDefault.gid, NULL, 0},
{"hosts allow", P_STRING, P_LOCAL, &sDefault.hosts_allow, NULL, 0},
@@ -267,14 +292,20 @@ static struct parm_struct parm_table[] =
{"auth users", P_STRING, P_LOCAL, &sDefault.auth_users, NULL, 0},
{"secrets file", P_STRING, P_LOCAL, &sDefault.secrets_file,NULL, 0},
{"strict modes", P_BOOL, P_LOCAL, &sDefault.strict_modes,NULL, 0},
{"filter", P_STRING, P_LOCAL, &sDefault.filter, NULL, 0},
{"exclude", P_STRING, P_LOCAL, &sDefault.exclude, NULL, 0},
{"exclude from", P_STRING, P_LOCAL, &sDefault.exclude_from,NULL, 0},
{"include", P_STRING, P_LOCAL, &sDefault.include, NULL, 0},
{"include from", P_STRING, P_LOCAL, &sDefault.include_from,NULL, 0},
{"transfer logging", P_BOOL, P_LOCAL, &sDefault.transfer_logging,NULL,0},
{"ignore errors", P_BOOL, P_LOCAL, &sDefault.ignore_errors,NULL,0},
{"log format", P_STRING, P_LOCAL, &sDefault.log_format, NULL, 0},
{"refuse options", P_STRING, P_LOCAL, &sDefault.refuse_options,NULL, 0},
{"dont compress", P_STRING, P_LOCAL, &sDefault.dont_compress,NULL, 0},
#ifdef HAVE_PUTENV
{"pre-xfer exec", P_STRING, P_LOCAL, &sDefault.prexfer_exec, NULL, 0},
{"post-xfer exec", P_STRING, P_LOCAL, &sDefault.postxfer_exec,NULL, 0},
#endif
{NULL, P_BOOL, P_NONE, NULL, NULL, 0}
};
@@ -284,7 +315,7 @@ Initialise the global parameter structure.
***************************************************************************/
static void init_globals(void)
{
memset(&Globals, 0, sizeof(Globals));
memset(&Globals, 0, sizeof Globals);
#ifdef LOG_DAEMON
Globals.syslog_facility = LOG_DAEMON;
#endif
@@ -299,8 +330,8 @@ static void init_locals(void)
/*
In this section all the functions that are used to access the
parameters from the rest of the program are defined
In this section all the functions that are used to access the
parameters from the rest of the program are defined
*/
#define FN_GLOBAL_STRING(fn_name,ptr) \
@@ -327,15 +358,20 @@ FN_GLOBAL_STRING(lp_log_file, &Globals.log_file)
FN_GLOBAL_STRING(lp_pid_file, &Globals.pid_file)
FN_GLOBAL_STRING(lp_socket_options, &Globals.socket_options)
FN_GLOBAL_INTEGER(lp_syslog_facility, &Globals.syslog_facility)
FN_GLOBAL_INTEGER(lp_rsync_port, &Globals.rsync_port)
FN_GLOBAL_STRING(lp_bind_address, &Globals.bind_address)
FN_LOCAL_STRING(lp_name, name)
FN_LOCAL_STRING(lp_comment, comment)
FN_LOCAL_STRING(lp_path, path)
FN_LOCAL_STRING(lp_lock_file, lock_file)
FN_LOCAL_BOOL(lp_read_only, read_only)
FN_LOCAL_BOOL(lp_write_only, write_only)
FN_LOCAL_BOOL(lp_list, list)
FN_LOCAL_BOOL(lp_use_chroot, use_chroot)
FN_LOCAL_BOOL(lp_transfer_logging, transfer_logging)
FN_LOCAL_BOOL(lp_ignore_errors, ignore_errors)
FN_LOCAL_BOOL(lp_ignore_nonreadable, ignore_nonreadable)
FN_LOCAL_STRING(lp_uid, uid)
FN_LOCAL_STRING(lp_gid, gid)
FN_LOCAL_STRING(lp_hosts_allow, hosts_allow)
@@ -343,6 +379,7 @@ FN_LOCAL_STRING(lp_hosts_deny, hosts_deny)
FN_LOCAL_STRING(lp_auth_users, auth_users)
FN_LOCAL_STRING(lp_secrets_file, secrets_file)
FN_LOCAL_BOOL(lp_strict_modes, strict_modes)
FN_LOCAL_STRING(lp_filter, filter)
FN_LOCAL_STRING(lp_exclude, exclude)
FN_LOCAL_STRING(lp_exclude_from, exclude_from)
FN_LOCAL_STRING(lp_include, include)
@@ -350,16 +387,18 @@ FN_LOCAL_STRING(lp_include_from, include_from)
FN_LOCAL_STRING(lp_log_format, log_format)
FN_LOCAL_STRING(lp_refuse_options, refuse_options)
FN_LOCAL_STRING(lp_dont_compress, dont_compress)
FN_LOCAL_STRING(lp_prexfer_exec, prexfer_exec)
FN_LOCAL_STRING(lp_postxfer_exec, postxfer_exec)
FN_LOCAL_INTEGER(lp_timeout, timeout)
FN_LOCAL_INTEGER(lp_max_connections, max_connections)
FN_LOCAL_INTEGER(lp_max_verbosity, max_verbosity)
/* local prototypes */
static int strwicmp( char *psz1, char *psz2 );
static int map_parameter( char *parmname);
static BOOL set_boolean( BOOL *pb, char *parmvalue );
static int strwicmp(char *psz1, char *psz2);
static int map_parameter(char *parmname);
static BOOL set_boolean(BOOL *pb, char *parmvalue);
static int getservicebyname(char *name, service *pserviceDest);
static void copy_service( service *pserviceDest,
service *pserviceSource);
static void copy_service(service *pserviceDest, service *pserviceSource);
static BOOL do_parameter(char *parmname, char *parmvalue);
static BOOL do_section(char *sectionname);
@@ -373,19 +412,33 @@ static void init_service(service *pservice)
copy_service(pservice,&sDefault);
}
static void string_set(char **s, char *v)
/**
* Assign a copy of @p v to @p *s. Handles NULL strings. @p *v must
* be initialized when this is called, either to NULL or a malloc'd
* string.
*
* @fixme There is a small leak here in that sometimes the existing
* value will be dynamically allocated, and the old copy is lost.
* However, we can't always deallocate the old value, because in the
* case of sDefault, it points to a static string. It would be nice
* to have either all-strdup'd values, or to never need to free
* memory.
**/
static void string_set(char **s, const char *v)
{
if (!v) {
*s = NULL;
return;
}
*s = strdup(v);
if (!*s) exit_cleanup(RERR_MALLOC);
if (!*s)
exit_cleanup(RERR_MALLOC);
}
/***************************************************************************
add a new service to the services array initialising it with the given
add a new service to the services array initialising it with the given
service
***************************************************************************/
static int add_a_service(service *pservice, char *name)
@@ -397,7 +450,7 @@ static int add_a_service(service *pservice, char *name)
tservice = *pservice;
/* it might already exist */
if (name)
if (name)
{
i = getservicebyname(name,NULL);
if (i >= 0)
@@ -406,10 +459,10 @@ static int add_a_service(service *pservice, char *name)
i = iNumServices;
ServicePtrs = (service **)Realloc(ServicePtrs,sizeof(service *)*num_to_alloc);
ServicePtrs = realloc_array(ServicePtrs, service *, num_to_alloc);
if (ServicePtrs)
pSERVICE(iNumServices) = (service *)malloc(sizeof(service));
pSERVICE(iNumServices) = new(service);
if (!ServicePtrs || !pSERVICE(iNumServices))
return(-1);
@@ -419,7 +472,7 @@ static int add_a_service(service *pservice, char *name)
init_service(pSERVICE(i));
copy_service(pSERVICE(i),&tservice);
if (name)
string_set(&iSERVICE(i).name,name);
string_set(&iSERVICE(i).name,name);
return(i);
}
@@ -443,11 +496,12 @@ static int strwicmp(char *psz1, char *psz2)
/* sync the strings on first non-whitespace */
while (1)
{
while (isspace(*psz1))
while (isspace(* (unsigned char *) psz1))
psz1++;
while (isspace(*psz2))
while (isspace(* (unsigned char *) psz2))
psz2++;
if (toupper(*psz1) != toupper(*psz2) || *psz1 == '\0' || *psz2 == '\0')
if (toupper(* (unsigned char *) psz1) != toupper(* (unsigned char *) psz2)
|| *psz1 == '\0' || *psz2 == '\0')
break;
psz1++;
psz2++;
@@ -456,7 +510,7 @@ static int strwicmp(char *psz1, char *psz2)
}
/***************************************************************************
Map a parameter's string representation to something we can use.
Map a parameter's string representation to something we can use.
Returns False if the parameter string is not recognised, else TRUE.
***************************************************************************/
static int map_parameter(char *parmname)
@@ -466,7 +520,7 @@ static int map_parameter(char *parmname)
if (*parmname == '-')
return(-1);
for (iIndex = 0; parm_table[iIndex].label; iIndex++)
for (iIndex = 0; parm_table[iIndex].label; iIndex++)
if (strwicmp(parm_table[iIndex].label, parmname) == 0)
return(iIndex);
@@ -477,7 +531,7 @@ static int map_parameter(char *parmname)
/***************************************************************************
Set a boolean variable from the text value stored in the passed string.
Returns True in success, False if the passed string does not correctly
Returns True in success, False if the passed string does not correctly
represent a boolean.
***************************************************************************/
static BOOL set_boolean(BOOL *pb, char *parmvalue)
@@ -511,7 +565,7 @@ static int getservicebyname(char *name, service *pserviceDest)
int iService;
for (iService = iNumServices - 1; iService >= 0; iService--)
if (strwicmp(iSERVICE(iService).name, name) == 0)
if (strwicmp(iSERVICE(iService).name, name) == 0)
{
if (pserviceDest != NULL)
copy_service(pserviceDest, pSERVICE(iService));
@@ -527,7 +581,7 @@ static int getservicebyname(char *name, service *pserviceDest)
Copy a service structure to another
***************************************************************************/
static void copy_service(service *pserviceDest,
static void copy_service(service *pserviceDest,
service *pserviceSource)
{
int i;
@@ -535,9 +589,9 @@ static void copy_service(service *pserviceDest,
for (i=0;parm_table[i].label;i++)
if (parm_table[i].ptr && parm_table[i].class == P_LOCAL) {
void *def_ptr = parm_table[i].ptr;
void *src_ptr =
void *src_ptr =
((char *)pserviceSource) + PTR_DIFF(def_ptr,&sDefault);
void *dest_ptr =
void *dest_ptr =
((char *)pserviceDest) + PTR_DIFF(def_ptr,&sDefault);
switch (parm_table[i].type)
@@ -557,6 +611,7 @@ static void copy_service(service *pserviceDest,
*(char *)dest_ptr = *(char *)src_ptr;
break;
case P_PATH:
case P_STRING:
string_set(dest_ptr,*(char **)src_ptr);
break;
@@ -577,6 +632,7 @@ static BOOL lp_do_parameter(int snum, char *parmname, char *parmvalue)
int parmnum, i;
void *parm_ptr=NULL; /* where we are going to store the result */
void *def_ptr=NULL;
char *cp;
parmnum = map_parameter(parmname);
@@ -623,6 +679,15 @@ static BOOL lp_do_parameter(int snum, char *parmname, char *parmvalue)
sscanf(parmvalue,"%o",(int *)parm_ptr);
break;
case P_PATH:
string_set(parm_ptr,parmvalue);
if ((cp = *(char**)parm_ptr) != NULL) {
int len = strlen(cp);
while (len > 1 && cp[len-1] == '/') len--;
cp[len] = '\0';
}
break;
case P_STRING:
string_set(parm_ptr,parmvalue);
break;
@@ -674,7 +739,7 @@ static BOOL do_section(char *sectionname)
init_locals();
/* if we've just struck a global section, note the fact. */
bInGlobalSection = isglobal;
bInGlobalSection = isglobal;
/* check for multiple global sections */
if (bInGlobalSection)
@@ -706,27 +771,33 @@ static BOOL do_section(char *sectionname)
/***************************************************************************
Load the services array from the services file. Return True on success,
Load the services array from the services file. Return True on success,
False on failure.
***************************************************************************/
BOOL lp_load(char *pszFname, int globals_only)
{
extern int am_server;
extern int am_daemon;
extern int am_root;
pstring n2;
BOOL bRetval;
bRetval = False;
bInGlobalSection = True;
init_globals();
pstrcpy(n2,pszFname);
if (pszFname)
pstrcpy(n2,pszFname);
else if (am_server && am_daemon && !am_root)
pstrcpy(n2,RSYNCD_USERCONF);
else
pstrcpy(n2,RSYNCD_SYSCONF);
/* We get sections first, so have to start 'behind' to make up */
iServiceIndex = -1;
bRetval = pm_process(n2, globals_only?NULL:do_section, do_parameter);
bLoaded = True;
return (bRetval);
}
@@ -751,7 +822,7 @@ int lp_number(char *name)
int iService;
for (iService = iNumServices - 1; iService >= 0; iService--)
if (strequal(lp_name(iService), name))
if (strcmp(lp_name(iService), name) == 0)
break;
return (iService);

690
log.c
View File

@@ -1,35 +1,106 @@
/*
Copyright (C) Andrew Tridgell 1998
/* -*- c-file-style: "linux"; -*-
Copyright (C) 1998-2001 by Andrew Tridgell <tridge@samba.org>
Copyright (C) 2000-2001 by Martin Pool <mbp@samba.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
logging and utility functions
Logging and utility functions.
tridge, May 1998
Mapping to human-readable messages added by Martin Pool
<mbp@samba.org>, Oct 2000.
*/
#include "rsync.h"
extern int verbose;
extern int dry_run;
extern int am_daemon;
extern int am_server;
extern int am_sender;
extern int local_server;
extern int quiet;
extern int module_id;
extern int msg_fd_out;
extern int protocol_version;
extern int preserve_times;
extern int log_format_has_o_or_i;
extern int daemon_log_format_has_o_or_i;
extern char *auth_user;
extern char *log_format;
static int log_initialised;
static int logfile_was_closed;
static char *logfname;
static FILE *logfile;
struct stats stats;
int log_got_error = 0;
struct {
int code;
char const *name;
} const rerr_names[] = {
{ RERR_SYNTAX , "syntax or usage error" },
{ RERR_PROTOCOL , "protocol incompatibility" },
{ RERR_FILESELECT , "errors selecting input/output files, dirs" },
{ RERR_UNSUPPORTED, "requested action not supported" },
{ RERR_STARTCLIENT, "error starting client-server protocol" },
{ RERR_SOCKETIO , "error in socket IO" },
{ RERR_FILEIO , "error in file IO" },
{ RERR_STREAMIO , "error in rsync protocol data stream" },
{ RERR_MESSAGEIO , "errors with program diagnostics" },
{ RERR_IPC , "error in IPC code" },
{ RERR_SIGNAL , "received SIGUSR1 or SIGINT" },
{ RERR_WAITCHILD , "some error returned by waitpid()" },
{ RERR_MALLOC , "error allocating core memory buffers" },
{ RERR_PARTIAL , "some files could not be transferred" },
{ RERR_VANISHED , "some files vanished before they could be transferred" },
{ RERR_TIMEOUT , "timeout in data send/receive" },
{ RERR_CMD_FAILED , "remote shell failed" },
{ RERR_CMD_KILLED , "remote shell killed" },
{ RERR_CMD_RUN , "remote command could not be run" },
{ RERR_CMD_NOTFOUND,"remote command not found" },
{ RERR_DEL_LIMIT , "the --max-delete limit stopped deletions" },
{ 0, NULL }
};
/*
* Map from rsync error code to name, or return NULL.
*/
static char const *rerr_name(int code)
{
int i;
for (i = 0; rerr_names[i].name; i++) {
if (rerr_names[i].code == code)
return rerr_names[i].name;
}
return NULL;
}
static void logit(int priority, char *buf)
{
if (logfile_was_closed)
logfile_reopen();
if (logfile) {
fprintf(logfile,"%s [%d] %s",
fprintf(logfile,"%s [%d] %s",
timestring(time(NULL)), (int)getpid(), buf);
fflush(logfile);
} else {
@@ -37,31 +108,14 @@ static void logit(int priority, char *buf)
}
}
void log_open(void)
static void syslog_init()
{
static int initialised;
static int been_here = 0;
int options = LOG_PID;
time_t t;
char *logf;
if (initialised) return;
initialised = 1;
/* this looks pointless, but it is needed in order for the
C library on some systems to fetch the timezone info
before the chroot */
t = time(NULL);
localtime(&t);
/* optionally use a log file instead of syslog */
logf = lp_log_file();
if (logf && *logf) {
extern int orig_umask;
int old_umask = umask(022 | orig_umask);
logfile = fopen(logf, "a");
umask(old_umask);
if (been_here)
return;
}
been_here = 1;
#ifdef LOG_NDELAY
options |= LOG_NDELAY;
@@ -74,100 +128,233 @@ void log_open(void)
#endif
#ifndef LOG_NDELAY
logit(LOG_INFO,"rsyncd started\n");
logit(LOG_INFO, "rsyncd started\n");
#endif
}
/* this is the rsync debugging function. Call it with FINFO, FERROR or FLOG */
void rprintf(int fd, const char *format, ...)
static void logfile_open(void)
{
va_list ap;
char buf[1024];
int len;
FILE *f=NULL;
extern int am_daemon;
extern int quiet;
extern int orig_umask;
int old_umask = umask(022 | orig_umask);
logfile = fopen(logfname, "a");
umask(old_umask);
if (!logfile) {
int fopen_errno = errno;
/* Rsync falls back to using syslog on failure. */
syslog_init();
rsyserr(FERROR, fopen_errno,
"failed to open log-file %s", logfname);
rprintf(FINFO, "Ignoring \"log file\" setting.\n");
}
}
void log_init(void)
{
time_t t;
if (log_initialised)
return;
log_initialised = 1;
/* this looks pointless, but it is needed in order for the
* C library on some systems to fetch the timezone info
* before the chroot */
t = time(NULL);
localtime(&t);
/* optionally use a log file instead of syslog */
logfname = lp_log_file();
if (logfname && *logfname)
logfile_open();
else
syslog_init();
}
void logfile_close(void)
{
if (logfile) {
logfile_was_closed = 1;
fclose(logfile);
logfile = NULL;
}
}
void logfile_reopen(void)
{
if (logfile_was_closed) {
logfile_was_closed = 0;
logfile_open();
}
}
/* this is the underlying (unformatted) rsync debugging function. Call
* it with FINFO, FERROR or FLOG */
void rwrite(enum logcode code, char *buf, int len)
{
FILE *f = NULL;
/* recursion can happen with certain fatal conditions */
if (quiet != 0 && fd == FINFO) return;
if (quiet && code == FINFO)
return;
va_start(ap, format);
len = vslprintf(buf, sizeof(buf), format, ap);
va_end(ap);
if (len < 0) exit_cleanup(RERR_MESSAGEIO);
if (len > sizeof(buf)-1) exit_cleanup(RERR_MESSAGEIO);
if (len < 0)
exit_cleanup(RERR_MESSAGEIO);
buf[len] = 0;
if (fd == FLOG) {
if (am_daemon) logit(LOG_INFO, buf);
if (am_server && msg_fd_out >= 0) {
/* Pass the message to our sibling. */
send_msg((enum msgcode)code, buf, len);
return;
}
if (am_daemon) {
static int depth;
int priority = LOG_INFO;
if (fd == FERROR) priority = LOG_WARNING;
if (code == FCLIENT)
code = FINFO;
else if (am_daemon) {
static int in_block;
char msg[2048];
int priority = code == FERROR ? LOG_WARNING : LOG_INFO;
if (depth) return;
if (in_block)
return;
in_block = 1;
if (!log_initialised)
log_init();
strlcpy(msg, buf, MIN((int)sizeof msg, len + 1));
logit(priority, msg);
in_block = 0;
depth++;
if (code == FLOG || !am_server)
return;
} else if (code == FLOG)
return;
log_open();
if (!io_multiplex_write(fd, buf, strlen(buf))) {
logit(priority, buf);
if (am_server) {
/* Pass the message to the non-server side. */
if (io_multiplex_write((enum msgcode)code, buf, len))
return;
if (am_daemon) {
/* TODO: can we send the error to the user somehow? */
return;
}
depth--;
return;
}
if (fd == FERROR) {
if (code == FERROR) {
log_got_error = 1;
f = stderr;
}
}
if (fd == FINFO) {
extern int am_server;
if (am_server)
f = stderr;
else
f = stdout;
}
if (code == FINFO)
f = am_server ? stderr : stdout;
if (!f) exit_cleanup(RERR_MESSAGEIO);
if (!f)
exit_cleanup(RERR_MESSAGEIO);
if (fwrite(buf, len, 1, f) != 1) exit_cleanup(RERR_MESSAGEIO);
if (fwrite(buf, len, 1, f) != 1)
exit_cleanup(RERR_MESSAGEIO);
if (buf[len-1] == '\r' || buf[len-1] == '\n') fflush(f);
if (buf[len-1] == '\r' || buf[len-1] == '\n')
fflush(f);
}
void rflush(int fd)
/* This is the rsync debugging function. Call it with FINFO, FERROR or
* FLOG. */
void rprintf(enum logcode code, const char *format, ...)
{
va_list ap;
char buf[MAXPATHLEN+512];
size_t len;
va_start(ap, format);
len = vsnprintf(buf, sizeof buf, format, ap);
va_end(ap);
/* Deal with buffer overruns. Instead of panicking, just
* truncate the resulting string. (Note that configure ensures
* that we have a vsnprintf() that doesn't ever return -1.) */
if (len > sizeof buf - 1) {
const char ellipsis[] = "[...]";
/* Reset length, and zero-terminate the end of our buffer */
len = sizeof buf - 1;
buf[len] = '\0';
/* Copy the ellipsis to the end of the string, but give
* us one extra character:
*
* v--- null byte at buf[sizeof buf - 1]
* abcdefghij0
* -> abcd[...]00 <-- now two null bytes at end
*
* If the input format string has a trailing newline,
* we copy it into that extra null; if it doesn't, well,
* all we lose is one byte. */
strncpy(buf+len-sizeof ellipsis, ellipsis, sizeof ellipsis);
if (format[strlen(format)-1] == '\n') {
buf[len-1] = '\n';
}
}
rwrite(code, buf, len);
}
/* This is like rprintf, but it also tries to print some
* representation of the error code. Normally errcode = errno.
*
* Unlike rprintf, this always adds a newline and there should not be
* one in the format string.
*
* Note that since strerror might involve dynamically loading a
* message catalog we need to call it once before chroot-ing. */
void rsyserr(enum logcode code, int errcode, const char *format, ...)
{
va_list ap;
char buf[MAXPATHLEN+512];
size_t len;
strcpy(buf, RSYNC_NAME ": ");
len = (sizeof RSYNC_NAME ": ") - 1;
va_start(ap, format);
len += vsnprintf(buf + len, sizeof buf - len, format, ap);
va_end(ap);
if (len < sizeof buf) {
len += snprintf(buf + len, sizeof buf - len,
": %s (%d)\n", strerror(errcode), errcode);
}
if (len >= sizeof buf)
exit_cleanup(RERR_MESSAGEIO);
rwrite(code, buf, len);
}
void rflush(enum logcode code)
{
FILE *f = NULL;
extern int am_daemon;
if (am_daemon) {
return;
}
if (fd == FLOG) {
if (code == FLOG) {
return;
}
}
if (fd == FERROR) {
if (code == FERROR) {
f = stderr;
}
}
if (fd == FINFO) {
extern int am_server;
if (am_server)
if (code == FINFO) {
if (am_server)
f = stderr;
else
f = stdout;
}
}
if (!f) exit_cleanup(RERR_MESSAGEIO);
fflush(f);
@@ -176,154 +363,313 @@ void rflush(int fd)
/* a generic logging routine for send/recv, with parameter
substitiution */
static void log_formatted(int fd,
char *format, char *op, struct file_struct *file,
struct stats *initial_stats)
* substitiution */
static void log_formatted(enum logcode code, char *format, char *op,
struct file_struct *file, struct stats *initial_stats,
int iflags, char *hlink)
{
extern int module_id;
extern char *auth_user;
char buf[1024];
char buf2[1024];
char buf[MAXPATHLEN+1024], buf2[MAXPATHLEN], fmt[32];
char *p, *s, *n;
int l;
extern struct stats stats;
extern int am_sender;
extern int am_daemon;
size_t len, total;
int64 b;
strlcpy(buf, format, sizeof(buf));
for (s=&buf[0];
s && (p=strchr(s,'%')); ) {
n = NULL;
s = p + 1;
*fmt = '%';
switch (p[1]) {
/* We expand % codes one by one in place in buf. We don't
* copy in the terminating null of the inserted strings, but
* rather keep going until we reach the null of the format. */
total = strlcpy(buf, format, sizeof buf);
if (total > MAXPATHLEN) {
rprintf(FERROR, "log-format string is WAY too long!\n");
exit_cleanup(RERR_MESSAGEIO);
}
buf[total++] = '\n';
buf[total] = '\0';
for (p = buf; (p = strchr(p, '%')) != NULL; ) {
s = p++;
n = fmt + 1;
if (*p == '-')
*n++ = *p++;
while (isdigit(*(uchar*)p) && n - fmt < (int)(sizeof fmt) - 8)
*n++ = *p++;
if (!*p)
break;
*n = '\0';
n = NULL;
switch (*p) {
case 'h': if (am_daemon) n = client_name(0); break;
case 'a': if (am_daemon) n = client_addr(0); break;
case 'l':
slprintf(buf2,sizeof(buf2),"%.0f",
(double)file->length);
case 'l':
strlcat(fmt, ".0f", sizeof fmt);
snprintf(buf2, sizeof buf2, fmt,
(double)file->length);
n = buf2;
break;
case 'p':
slprintf(buf2,sizeof(buf2),"%d",
(int)getpid());
case 'p':
strlcat(fmt, "ld", sizeof fmt);
snprintf(buf2, sizeof buf2, fmt,
(long)getpid());
n = buf2;
break;
case 'o': n = op; break;
case 'f':
slprintf(buf2, sizeof(buf2), "%s/%s",
file->basedir?file->basedir:"",
f_name(file));
clean_fname(buf2);
n = buf2;
if (*n == '/') n++;
case 'f':
n = safe_fname(f_name(file));
if (am_sender && file->dir.root) {
pathjoin(buf2, sizeof buf2,
file->dir.root, n);
/* The buffer from safe_fname() has more
* room than MAXPATHLEN, so this is safe. */
if (fmt[1])
strcpy(n, buf2);
else
n = buf2;
}
clean_fname(n, 0);
if (*n == '/')
n++;
break;
case 'n':
n = safe_fname(f_name(file));
if (S_ISDIR(file->mode)) {
/* The buffer from safe_fname() has more
* room than MAXPATHLEN, so this is safe. */
strcat(n, "/");
}
break;
case 'L':
if (hlink && *hlink) {
n = safe_fname(hlink);
strcpy(buf2, " => ");
} else if (S_ISLNK(file->mode) && file->u.link) {
n = safe_fname(file->u.link);
strcpy(buf2, " -> ");
} else {
n = "";
if (!fmt[1])
break;
strcpy(buf2, " ");
}
strlcat(fmt, "s", sizeof fmt);
snprintf(buf2 + 4, sizeof buf2 - 4, fmt, n);
n = buf2;
break;
case 'm': n = lp_name(module_id); break;
case 't': n = timestring(time(NULL)); break;
case 'P': n = lp_path(module_id); break;
case 'u': n = auth_user; break;
case 'b':
case 'b':
if (am_sender) {
b = stats.total_written -
b = stats.total_written -
initial_stats->total_written;
} else {
b = stats.total_read -
b = stats.total_read -
initial_stats->total_read;
}
slprintf(buf2,sizeof(buf2),"%.0f", (double)b);
strlcat(fmt, ".0f", sizeof fmt);
snprintf(buf2, sizeof buf2, fmt, (double)b);
n = buf2;
break;
case 'c':
case 'c':
if (!am_sender) {
b = stats.total_written -
b = stats.total_written -
initial_stats->total_written;
} else {
b = stats.total_read -
b = stats.total_read -
initial_stats->total_read;
}
slprintf(buf2,sizeof(buf2),"%.0f", (double)b);
strlcat(fmt, ".0f", sizeof fmt);
snprintf(buf2, sizeof buf2, fmt, (double)b);
n = buf2;
break;
case 'i':
if (iflags & ITEM_DELETED) {
n = "*deleting";
break;
}
n = buf2 + MAXPATHLEN - 32;
n[0] = iflags & ITEM_LOCAL_CHANGE
? iflags & ITEM_XNAME_FOLLOWS ? 'h' : 'c'
: !(iflags & ITEM_TRANSFER) ? '.'
: !local_server && *op == 's' ? '<' : '>';
n[1] = S_ISDIR(file->mode) ? 'd'
: IS_DEVICE(file->mode) ? 'D'
: S_ISLNK(file->mode) ? 'L' : 'f';
n[2] = !(iflags & ITEM_REPORT_CHECKSUM) ? '.' : 'c';
n[3] = !(iflags & ITEM_REPORT_SIZE) ? '.' : 's';
n[4] = !(iflags & ITEM_REPORT_TIME) ? '.'
: !preserve_times || IS_DEVICE(file->mode)
|| S_ISLNK(file->mode) ? 'T' : 't';
n[5] = !(iflags & ITEM_REPORT_PERMS) ? '.' : 'p';
n[6] = !(iflags & ITEM_REPORT_OWNER) ? '.' : 'o';
n[7] = !(iflags & ITEM_REPORT_GROUP) ? '.' : 'g';
n[8] = !(iflags & ITEM_REPORT_XATTRS) ? '.' : 'a';
n[9] = '\0';
if (iflags & (ITEM_IS_NEW|ITEM_MISSING_DATA)) {
char ch = iflags & ITEM_IS_NEW ? '+' : '?';
int i;
for (i = 2; n[i]; i++)
n[i] = ch;
} else if (n[0] == '.' || n[0] == 'h') {
int i;
for (i = 2; n[i]; i++) {
if (n[i] != '.')
break;
}
if (!n[i]) {
for (i = 2; n[i]; i++)
n[i] = ' ';
}
}
break;
}
if (!n) continue;
/* "n" is the string to be inserted in place of this % code. */
if (!n)
continue;
if (n != buf2 && fmt[1]) {
strlcat(fmt, "s", sizeof fmt);
snprintf(buf2, sizeof buf2, fmt, n);
n = buf2;
}
len = strlen(n);
l = strlen(n);
/* Subtract the length of the escape from the string's size. */
total -= p - s + 1;
if ((l-1) + ((int)(s - &buf[0])) > sizeof(buf)) {
rprintf(FERROR,"buffer overflow expanding %%%c - exiting\n",
if (len + total >= (size_t)sizeof buf) {
rprintf(FERROR,
"buffer overflow expanding %%%c -- exiting\n",
p[0]);
exit_cleanup(RERR_MESSAGEIO);
}
if (l != 2) {
memmove(s+(l-1), s+1, strlen(s+1)+1);
}
memcpy(p, n, l);
/* Shuffle the rest of the string along to make space for n */
if (len != (size_t)(p - s + 1))
memmove(s + len, p + 1, total - (s - buf) + 1);
total += len;
s = p+l;
/* Insert the contents of string "n", but NOT its null. */
if (len)
memcpy(s, n, len);
/* Skip over inserted string; continue looking */
p = s + len;
}
rprintf(fd,"%s\n", buf);
rwrite(code, buf, total);
}
/* log the outgoing transfer of a file */
void log_send(struct file_struct *file, struct stats *initial_stats)
/* Return 1 if the format escape is in the log-format string (e.g. look for
* the 'b' in the "%9b" format escape). */
int log_format_has(const char *format, char esc)
{
extern int module_id;
extern int am_server;
extern char *log_format;
const char *p;
if (!format)
return 0;
for (p = format; (p = strchr(p, '%')) != NULL; ) {
if (*++p == '-')
p++;
while (isdigit(*(uchar*)p))
p++;
if (!*p)
break;
if (*p == esc)
return 1;
}
return 0;
}
/* log the transfer of a file */
void log_item(struct file_struct *file, struct stats *initial_stats,
int iflags, char *hlink)
{
char *s_or_r = am_sender ? "send" : "recv";
if (lp_transfer_logging(module_id)) {
log_formatted(FLOG, lp_log_format(module_id), "send", file, initial_stats);
log_formatted(FLOG, lp_log_format(module_id), s_or_r,
file, initial_stats, iflags, hlink);
} else if (log_format && !am_server) {
log_formatted(FINFO, log_format, "send", file, initial_stats);
log_formatted(FINFO, log_format, s_or_r,
file, initial_stats, iflags, hlink);
}
}
/* log the incoming transfer of a file */
void log_recv(struct file_struct *file, struct stats *initial_stats)
void maybe_log_item(struct file_struct *file, int iflags, int itemizing,
char *buf)
{
extern int module_id;
extern int am_server;
extern char *log_format;
if (lp_transfer_logging(module_id)) {
log_formatted(FLOG, lp_log_format(module_id), "recv", file, initial_stats);
} else if (log_format && !am_server) {
log_formatted(FINFO, log_format, "recv", file, initial_stats);
}
int significant_flags = iflags & SIGNIFICANT_ITEM_FLAGS;
int see_item = itemizing && (significant_flags || *buf || verbose > 1);
int local_change = iflags & ITEM_LOCAL_CHANGE
&& (!(iflags & ITEM_XNAME_FOLLOWS) || significant_flags);
if (am_server) {
if (am_daemon && !dry_run && see_item)
log_item(file, &stats, iflags, buf);
} else if (see_item || local_change || *buf
|| (S_ISDIR(file->mode) && significant_flags))
log_item(file, &stats, iflags, buf);
}
/* called when the transfer is interrupted for some reason */
void log_delete(char *fname, int mode)
{
static struct file_struct file;
int len = strlen(fname);
char *fmt;
file.mode = mode;
file.basename = fname;
if (!verbose && !log_format)
;
else if (am_server && protocol_version >= 29 && len < MAXPATHLEN) {
if (S_ISDIR(mode))
len++; /* directories include trailing null */
send_msg(MSG_DELETED, fname, len);
} else {
fmt = log_format_has_o_or_i ? log_format : "deleting %n";
log_formatted(FCLIENT, fmt, "del.", &file, &stats,
ITEM_DELETED, NULL);
}
if (!am_daemon || dry_run || !lp_transfer_logging(module_id))
return;
fmt = daemon_log_format_has_o_or_i ? lp_log_format(module_id) : "deleting %n";
log_formatted(FLOG, fmt, "del.", &file, &stats, ITEM_DELETED, NULL);
}
/*
* Called when the transfer is interrupted for some reason.
*
* Code is one of the RERR_* codes from errcode.h, or terminating
* successfully.
*/
void log_exit(int code, const char *file, int line)
{
if (code == 0) {
extern struct stats stats;
rprintf(FLOG,"wrote %.0f bytes read %.0f bytes total size %.0f\n",
rprintf(FLOG,"sent %.0f bytes received %.0f bytes total size %.0f\n",
(double)stats.total_written,
(double)stats.total_read,
(double)stats.total_size);
} else {
rprintf(FLOG,"transfer interrupted (code %d) at %s(%d)\n",
code, file, line);
const char *name;
name = rerr_name(code);
if (!name)
name = "unexplained error";
/* VANISHED is not an error, only a warning */
if (code == RERR_VANISHED) {
rprintf(FINFO, "rsync warning: %s (code %d) at %s(%d)\n",
name, code, file, line);
} else {
rprintf(FERROR, "rsync error: %s (code %d) at %s(%d)\n",
name, code, file, line);
}
}
}
/* log the incoming transfer of a file for interactive use, this
will be called at the end where the client was run
it i called when a file starts to be transferred
*/
void log_transfer(struct file_struct *file, const char *fname)
{
extern int verbose;
if (!verbose) return;
rprintf(FINFO,"%s\n", fname);
}

1204
main.c
View File

File diff suppressed because it is too large Load Diff

346
match.c
View File

@@ -1,17 +1,17 @@
/*
/*
Copyright (C) Andrew Tridgell 1996
Copyright (C) Paul Mackerras 1996
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -19,12 +19,13 @@
#include "rsync.h"
extern int csum_length;
extern int verbose;
extern int am_server;
extern int do_progress;
extern int checksum_seed;
extern int append_mode;
extern int remote_version;
int updating_basis_file;
typedef unsigned short tag;
@@ -43,74 +44,88 @@ static int total_matches;
extern struct stats stats;
struct target {
tag t;
int i;
tag t;
int32 i;
};
static struct target *targets;
static int *tag_table;
static int32 *tag_table;
#define gettag2(s1,s2) (((s1) + (s2)) & 0xFFFF)
#define gettag(sum) gettag2((sum)&0xFFFF,(sum)>>16)
static int compare_targets(struct target *t1,struct target *t2)
{
return((int)t1->t - (int)t2->t);
return (int)t1->t - (int)t2->t;
}
static void build_hash_table(struct sum_struct *s)
{
int i;
int32 i;
if (!tag_table)
tag_table = (int *)malloc(sizeof(tag_table[0])*TABLESIZE);
if (!tag_table)
tag_table = new_array(int32, TABLESIZE);
targets = (struct target *)malloc(sizeof(targets[0])*s->count);
if (!tag_table || !targets)
out_of_memory("build_hash_table");
targets = new_array(struct target, s->count);
if (!tag_table || !targets)
out_of_memory("build_hash_table");
for (i=0;i<s->count;i++) {
targets[i].i = i;
targets[i].t = gettag(s->sums[i].sum1);
}
for (i = 0; i < s->count; i++) {
targets[i].i = i;
targets[i].t = gettag(s->sums[i].sum1);
}
qsort(targets,s->count,sizeof(targets[0]),(int (*)())compare_targets);
qsort(targets,s->count,sizeof(targets[0]),(int (*)())compare_targets);
for (i=0;i<TABLESIZE;i++)
tag_table[i] = NULL_TAG;
for (i = 0; i < TABLESIZE; i++)
tag_table[i] = NULL_TAG;
for (i=s->count-1;i>=0;i--) {
tag_table[targets[i].t] = i;
}
for (i = s->count; i-- > 0; )
tag_table[targets[i].t] = i;
}
static OFF_T last_match;
static void matched(int f,struct sum_struct *s,struct map_struct *buf,
OFF_T offset,int i)
/**
* Transmit a literal and/or match token.
*
* This delightfully-named function is called either when we find a
* match and need to transmit all the unmatched data leading up to it,
* or when we get bored of accumulating literal data and just need to
* transmit it. As a result of this second case, it is called even if
* we have not matched at all!
*
* @param i If >0, the number of a matched token. If 0, indicates we
* have only literal data.
**/
static void matched(int f, struct sum_struct *s, struct map_struct *buf,
OFF_T offset, int32 i)
{
OFF_T n = offset - last_match;
OFF_T j;
int32 n = offset - last_match; /* max value: block_size (int32) */
int32 j;
if (verbose > 2 && i >= 0)
rprintf(FINFO,"match at %d last_match=%d j=%d len=%d n=%d\n",
(int)offset,(int)last_match,i,(int)s->sums[i].len,(int)n);
if (verbose > 2 && i >= 0) {
rprintf(FINFO,
"match at %.0f last_match=%.0f j=%d len=%ld n=%ld\n",
(double)offset, (double)last_match, i,
(long)s->sums[i].len, (long)n);
}
send_token(f,i,buf,last_match,n,i<0?0:s->sums[i].len);
send_token(f, i, buf, last_match, n, i < 0 ? 0 : s->sums[i].len);
data_transfer += n;
if (i >= 0) {
stats.matched_data += s->sums[i].len;
n += s->sums[i].len;
}
for (j=0;j<n;j+=CHUNK_SIZE) {
int n1 = MIN(CHUNK_SIZE,n-j);
sum_update(map_ptr(buf,last_match+j,n1),n1);
for (j = 0; j < n; j += CHUNK_SIZE) {
int32 n1 = MIN(CHUNK_SIZE, n - j);
sum_update(map_ptr(buf, last_match + j, n1), n1);
}
@@ -119,126 +134,161 @@ static void matched(int f,struct sum_struct *s,struct map_struct *buf,
else
last_match = offset;
if (buf)
if (buf && do_progress)
show_progress(last_match, buf->file_size);
if (i == -1) end_progress();
}
static void hash_search(int f,struct sum_struct *s,
struct map_struct *buf,OFF_T len)
struct map_struct *buf, OFF_T len)
{
OFF_T offset;
int j,k, last_i;
int end;
OFF_T offset, end, backup;
int32 k, want_i;
char sum2[SUM_LENGTH];
uint32 s1, s2, sum;
uint32 s1, s2, sum;
int more;
schar *map;
/* last_i is used to encourage adjacent matches, allowing the RLL coding of the
output to work more efficiently */
last_i = -1;
/* want_i is used to encourage adjacent matches, allowing the RLL
* coding of the output to work more efficiently. */
want_i = 0;
if (verbose > 2)
rprintf(FINFO,"hash search b=%d len=%d\n",s->n,(int)len);
if (verbose > 2) {
rprintf(FINFO, "hash search b=%ld len=%.0f\n",
(long)s->blength, (double)len);
}
k = (int32)MIN(len, (OFF_T)s->blength);
map = (schar *)map_ptr(buf, 0, k);
k = MIN(len, s->n);
map = (schar *)map_ptr(buf,0,k);
sum = get_checksum1((char *)map, k);
s1 = sum & 0xFFFF;
s2 = sum >> 16;
if (verbose > 3)
rprintf(FINFO, "sum=%.8x k=%d\n", sum, k);
rprintf(FINFO, "sum=%.8x k=%ld\n", sum, (long)k);
offset = 0;
end = len + 1 - s->sums[s->count-1].len;
if (verbose > 3)
rprintf(FINFO,"hash search s->n=%d len=%d count=%d\n",
s->n,(int)len,s->count);
if (verbose > 3) {
rprintf(FINFO, "hash search s->blength=%ld len=%.0f count=%.0f\n",
(long)s->blength, (double)len, (double)s->count);
}
do {
tag t = gettag2(s1,s2);
int done_csum2 = 0;
j = tag_table[t];
int32 j = tag_table[t];
if (verbose > 4)
rprintf(FINFO,"offset=%d sum=%08x\n",(int)offset,sum);
if (j == NULL_TAG) {
rprintf(FINFO,"offset=%.0f sum=%08x\n",(double)offset,sum);
if (j == NULL_TAG)
goto null_tag;
}
sum = (s1 & 0xffff) | (s2 << 16);
tag_hits++;
for (; j<s->count && targets[j].t == t; j++) {
int l, i = targets[j].i;
if (sum != s->sums[i].sum1) continue;
do {
int32 l, i = targets[j].i;
if (sum != s->sums[i].sum1)
continue;
/* also make sure the two blocks are the same length */
l = MIN(s->n,len-offset);
if (l != s->sums[i].len) continue;
l = (int32)MIN((OFF_T)s->blength, len-offset);
if (l != s->sums[i].len)
continue;
/* in-place: ensure chunk's offset is either >= our
* offset or that the data didn't move. */
if (updating_basis_file && s->sums[i].offset < offset
&& !(s->sums[i].flags & SUMFLG_SAME_OFFSET))
continue;
if (verbose > 3)
rprintf(FINFO,"potential match at %d target=%d %d sum=%08x\n",
(int)offset,j,i,sum);
rprintf(FINFO,"potential match at %.0f target=%.0f %.0f sum=%08x\n",
(double)offset,(double)j,(double)i,sum);
if (!done_csum2) {
map = (schar *)map_ptr(buf,offset,l);
get_checksum2((char *)map,l,sum2);
done_csum2 = 1;
}
if (memcmp(sum2,s->sums[i].sum2,csum_length) != 0) {
if (memcmp(sum2,s->sums[i].sum2,s->s2length) != 0) {
false_alarms++;
continue;
}
/* we've found a match, but now check to see
if last_i can hint at a better match */
for (j++; j<s->count && targets[j].t == t; j++) {
int i2 = targets[j].i;
if (i2 == last_i + 1) {
if (sum != s->sums[i2].sum1) break;
if (memcmp(sum2,s->sums[i2].sum2,csum_length) != 0) break;
/* we've found an adjacent match - the RLL coder
will be happy */
i = i2;
break;
}
/* When updating in-place, the best possible match is
* one with an identical offset, so we prefer that over
* the following want_i optimization. */
if (updating_basis_file) {
do {
int32 i2 = targets[j].i;
if (s->sums[i2].offset != offset)
continue;
if (i2 != i) {
if (sum != s->sums[i2].sum1)
break;
if (memcmp(sum2, s->sums[i2].sum2,
s->s2length) != 0)
break;
i = i2;
}
/* This chunk was at the same offset on
* both the sender and the receiver. */
s->sums[i].flags |= SUMFLG_SAME_OFFSET;
goto set_want_i;
} while (++j < s->count && targets[j].t == t);
}
last_i = i;
/* we've found a match, but now check to see
* if want_i can hint at a better match. */
if (i != want_i && want_i < s->count
&& (!updating_basis_file || s->sums[want_i].offset >= offset
|| s->sums[want_i].flags & SUMFLG_SAME_OFFSET)
&& sum == s->sums[want_i].sum1
&& memcmp(sum2, s->sums[want_i].sum2, s->s2length) == 0) {
/* we've found an adjacent match - the RLL coder
* will be happy */
i = want_i;
}
set_want_i:
want_i = i + 1;
matched(f,s,buf,offset,i);
offset += s->sums[i].len - 1;
k = MIN((len-offset), s->n);
map = (schar *)map_ptr(buf,offset,k);
k = (int32)MIN((OFF_T)s->blength, len-offset);
map = (schar *)map_ptr(buf, offset, k);
sum = get_checksum1((char *)map, k);
s1 = sum & 0xFFFF;
s2 = sum >> 16;
matches++;
break;
}
} while (++j < s->count && targets[j].t == t);
null_tag:
backup = offset - last_match;
/* We sometimes read 1 byte prior to last_match... */
if (backup < 0)
backup = 0;
/* Trim off the first byte from the checksum */
map = (schar *)map_ptr(buf,offset,k+1);
more = offset + k < len;
map = (schar *)map_ptr(buf, offset - backup, k + more + backup)
+ backup;
s1 -= map[0] + CHAR_OFFSET;
s2 -= k * (map[0]+CHAR_OFFSET);
/* Add on the next byte (if there is one) to the checksum */
if (k < (len-offset)) {
s1 += (map[k]+CHAR_OFFSET);
if (more) {
s1 += map[k] + CHAR_OFFSET;
s2 += s1;
} else {
} else
--k;
}
/* By matching early we avoid re-reading the
data 3 times in the case where a token
@@ -246,66 +296,92 @@ static void hash_search(int f,struct sum_struct *s,
match. The 3 reads are caused by the
running match, the checksum update and the
literal send. */
if (offset-last_match >= CHUNK_SIZE+s->n &&
(end-offset > CHUNK_SIZE)) {
matched(f,s,buf,offset - s->n, -2);
}
if (backup >= s->blength+CHUNK_SIZE && end-offset > CHUNK_SIZE)
matched(f, s, buf, offset - s->blength, -2);
} while (++offset < end);
matched(f,s,buf,len,-1);
map_ptr(buf,len-1,1);
matched(f, s, buf, len, -1);
map_ptr(buf, len-1, 1);
}
void match_sums(int f,struct sum_struct *s,struct map_struct *buf,OFF_T len)
/**
* Scan through a origin file, looking for sections that match
* checksums from the generator, and transmit either literal or token
* data.
*
* Also calculates the MD4 checksum of the whole file, using the md
* accumulator. This is transmitted with the file as protection
* against corruption on the wire.
*
* @param s Checksums received from the generator. If <tt>s->count ==
* 0</tt>, then there are actually no checksums for this file.
*
* @param len Length of the file to send.
**/
void match_sums(int f, struct sum_struct *s, struct map_struct *buf, OFF_T len)
{
char file_sum[MD4_SUM_LENGTH];
last_match = 0;
false_alarms = 0;
tag_hits = 0;
matches=0;
data_transfer=0;
matches = 0;
data_transfer = 0;
sum_init();
sum_init(checksum_seed);
if (len > 0 && s->count>0) {
if (append_mode) {
OFF_T j = 0;
for (j = CHUNK_SIZE; j < s->flength; j += CHUNK_SIZE) {
sum_update(map_ptr(buf, last_match, CHUNK_SIZE),
CHUNK_SIZE);
last_match = j;
}
if (last_match < s->flength) {
int32 len = s->flength - last_match;
sum_update(map_ptr(buf, last_match, len), len);
last_match = s->flength;
}
s->count = 0;
}
if (len > 0 && s->count > 0) {
build_hash_table(s);
if (verbose > 2)
if (verbose > 2)
rprintf(FINFO,"built hash table\n");
hash_search(f,s,buf,len);
if (verbose > 2)
if (verbose > 2)
rprintf(FINFO,"done hash search\n");
} else {
OFF_T j;
/* by doing this in pieces we avoid too many seeks */
for (j=0;j<(len-CHUNK_SIZE);j+=CHUNK_SIZE) {
int n1 = MIN(CHUNK_SIZE,(len-CHUNK_SIZE)-j);
matched(f,s,buf,j+n1,-2);
}
matched(f,s,buf,len,-1);
for (j = last_match + CHUNK_SIZE; j < len; j += CHUNK_SIZE)
matched(f, s, buf, j, -2);
matched(f, s, buf, len, -1);
}
sum_end(file_sum);
/* If we had a read error, send a bad checksum. */
if (buf && buf->status != 0)
file_sum[0]++;
if (remote_version >= 14) {
if (verbose > 2)
rprintf(FINFO,"sending file_sum\n");
write_buf(f,file_sum,MD4_SUM_LENGTH);
}
if (verbose > 2)
rprintf(FINFO,"sending file_sum\n");
write_buf(f,file_sum,MD4_SUM_LENGTH);
if (targets) {
free(targets);
targets=NULL;
}
if (verbose > 2)
rprintf(FINFO, "false_alarms=%d tag_hits=%d matches=%d\n",
false_alarms, tag_hits, matches);
total_tag_hits += tag_hits;
total_false_alarms += false_alarms;
total_matches += matches;

View File

@@ -58,7 +58,7 @@ BEGIN {
next;
}
!/^OFF_T|^size_t|^off_t|^pid_t|^unsigned|^mode_t|^DIR|^user|^int|^char|^uint|^struct|^BOOL|^void|^time/ {
!/^OFF_T|^size_t|^off_t|^pid_t|^unsigned|^mode_t|^DIR|^user|^int|^char|^uint|^uchar|^short|^struct|^BOOL|^void|^time|^const/ {
next;
}

1760
options.c
View File

File diff suppressed because it is too large Load Diff

88
packaging/lsb/rsync.spec Normal file
View File

@@ -0,0 +1,88 @@
Summary: A program for synchronizing files over a network.
Name: rsync
Version: 2.6.6
Release: 1
Group: Applications/Internet
Source: ftp://rsync.samba.org/pub/rsync/rsync-%{version}.tar.gz
URL: http://rsync.samba.org/
Prefix: %{_prefix}
BuildRoot: /var/tmp/%{name}-root
License: GPL
%description
Rsync uses a reliable algorithm to bring remote and host files into
sync very quickly. Rsync is fast because it just sends the differences
in the files over the network instead of sending the complete
files. Rsync is often used as a very powerful mirroring process or
just as a more capable replacement for the rcp command. A technical
report which describes the rsync algorithm is included in this
package.
%prep
%setup -q
%build
%configure
make
%install
rm -rf $RPM_BUILD_ROOT
%makeinstall
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root)
%doc COPYING README tech_report.tex
%{_prefix}/bin/rsync
%{_mandir}/man1/rsync.1*
%{_mandir}/man5/rsyncd.conf.5*
%changelog
* Thu Jan 30 2003 Horst von Brand <vonbrand@inf.utfsm.cl>
Fixed "Sept" date in %changelog here
Use %{_mandir} to point to manpages
Support for compressed manpages (* at end catches them in %files)
Add doc/README-SGML and doc/rsync.sgml to %doc
* Mon Sep 11 2000 John H Terpstra <jht@turbolinux.com>
Changed target paths to be Linux Standards Base compliant
* Mon Jan 25 1999 Stefan Hornburg <racke@linuxia.de>
quoted RPM_OPT_FLAGS for the sake of robustness
* Mon May 18 1998 Andrew Tridgell <tridge@samba.anu.edu.au>
reworked for auto-building when I release rsync (tridge@samba.anu.edu.au)
* Sat May 16 1998 John H Terpstra <jht@aquasoft.com.au>
Upgraded to Rsync 2.0.6
-new feature anonymous rsync
* Mon Apr 6 1998 Douglas N. Arnold <dna@math.psu.edu>
Upgrade to rsync version 1.7.2.
* Sun Mar 1 1998 Douglas N. Arnold <dna@math.psu.edu>
Built 1.6.9-1 based on the 1.6.3-2 spec file of John A. Martin.
Changes from 1.6.3-2 packaging: added latex and dvips commands
to create tech_report.ps.
* Mon Aug 25 1997 John A. Martin <jam@jamux.com>
Built 1.6.3-2 after finding no rsync-1.6.3-1.src.rpm although there
was an ftp://ftp.redhat.com/pub/contrib/alpha/rsync-1.6.3-1.alpha.rpm
showing no packager nor signature but giving
"Source RPM: rsync-1.6.3-1.src.rpm".
Changes from 1.6.2-1 packaging: added '$RPM_OPT_FLAGS' to make, strip
to '%build', removed '%prefix'.
* Thu Apr 10 1997 Michael De La Rue <miked@ed.ac.uk>
rsync-1.6.2-1 packaged. (This entry by jam to credit Michael for the
previous package(s).)

View File

@@ -1,81 +0,0 @@
Summary: Program for efficient remote updates of files.
Name: rsync
Version: 2.3.1
Release: 1
Copyright: GPL
Group: Applications/Networking
Source: ftp://samba.anu.edu.au/pub/rsync/rsync-2.3.1.tar.gz
URL: http://samba.anu.edu.au/rsync/
Packager: Andrew Tridgell <tridge@samba.anu.edu.au>
BuildRoot: /tmp/rsync
%description
rsync is a replacement for rcp that has many more features.
rsync uses the "rsync algorithm" which provides a very fast method for
bringing remote files into sync. It does this by sending just the
differences in the files across the link, without requiring that both
sets of files are present at one of the ends of the link beforehand.
A technical report describing the rsync algorithm is included with
this package.
%changelog
* Mon Jan 25 1999 Stefan Hornburg <racke@linuxia.de>
quoted RPM_OPT_FLAGS for the sake of robustness
* Mon May 18 1998 Andrew Tridgell <tridge@samba.anu.edu.au>
reworked for auto-building when I release rsync (tridge@samba.anu.edu.au)
* Sat May 16 1998 John H Terpstra <jht@aquasoft.com.au>
Upgraded to Rsync 2.0.6
-new feature anonymous rsync
* Mon Apr 6 1998 Douglas N. Arnold <dna@math.psu.edu>
Upgrade to rsync version 1.7.2.
* Sun Mar 1 1998 Douglas N. Arnold <dna@math.psu.edu>
Built 1.6.9-1 based on the 1.6.3-2 spec file of John A. Martin.
Changes from 1.6.3-2 packaging: added latex and dvips commands
to create tech_report.ps.
* Mon Aug 25 1997 John A. Martin <jam@jamux.com>
Built 1.6.3-2 after finding no rsync-1.6.3-1.src.rpm although there
was an ftp://ftp.redhat.com/pub/contrib/alpha/rsync-1.6.3-1.alpha.rpm
showing no packager nor signature but giving
"Source RPM: rsync-1.6.3-1.src.rpm".
Changes from 1.6.2-1 packaging: added '$RPM_OPT_FLAGS' to make, strip
to '%build', removed '%prefix'.
* Thu Apr 10 1997 Michael De La Rue <miked@ed.ac.uk>
rsync-1.6.2-1 packaged. (This entry by jam to credit Michael for the
previous package(s).)
%prep
%setup
%build
./configure --prefix=/usr
make CFLAGS="$RPM_OPT_FLAGS"
strip rsync
%install
mkdir -p $RPM_BUILD_ROOT/usr/{bin,man/{man1,man5}}
install -m755 rsync $RPM_BUILD_ROOT/usr/bin
install -m644 rsync.1 $RPM_BUILD_ROOT/usr/man/man1
install -m644 rsyncd.conf.5 $RPM_BUILD_ROOT/usr/man/man5
%clean
rm -rf $RPM_BUILD_ROOT
%files
%attr(-,root,root) /usr/bin/rsync
%attr(-,root,root) /usr/man/man1/rsync.1
%attr(-,root,root) /usr/man/man5/rsyncd.conf.5
%attr(-,root,root) %doc tech_report.tex
%attr(-,root,root) %doc README
%attr(-,root,root) %doc COPYING

View File

@@ -1,81 +0,0 @@
Summary: Program for efficient remote updates of files.
Name: rsync
Version: PVERSION
Release: PRELEASE
Copyright: GPL
Group: Applications/Networking
Source: ftp://samba.anu.edu.au/pub/rsync/rsync-PVERSION.tar.gz
URL: http://samba.anu.edu.au/rsync/
Packager: Andrew Tridgell <tridge@samba.anu.edu.au>
BuildRoot: /tmp/rsync
%description
rsync is a replacement for rcp that has many more features.
rsync uses the "rsync algorithm" which provides a very fast method for
bringing remote files into sync. It does this by sending just the
differences in the files across the link, without requiring that both
sets of files are present at one of the ends of the link beforehand.
A technical report describing the rsync algorithm is included with
this package.
%changelog
* Mon Jan 25 1999 Stefan Hornburg <racke@linuxia.de>
quoted RPM_OPT_FLAGS for the sake of robustness
* Mon May 18 1998 Andrew Tridgell <tridge@samba.anu.edu.au>
reworked for auto-building when I release rsync (tridge@samba.anu.edu.au)
* Sat May 16 1998 John H Terpstra <jht@aquasoft.com.au>
Upgraded to Rsync 2.0.6
-new feature anonymous rsync
* Mon Apr 6 1998 Douglas N. Arnold <dna@math.psu.edu>
Upgrade to rsync version 1.7.2.
* Sun Mar 1 1998 Douglas N. Arnold <dna@math.psu.edu>
Built 1.6.9-1 based on the 1.6.3-2 spec file of John A. Martin.
Changes from 1.6.3-2 packaging: added latex and dvips commands
to create tech_report.ps.
* Mon Aug 25 1997 John A. Martin <jam@jamux.com>
Built 1.6.3-2 after finding no rsync-1.6.3-1.src.rpm although there
was an ftp://ftp.redhat.com/pub/contrib/alpha/rsync-1.6.3-1.alpha.rpm
showing no packager nor signature but giving
"Source RPM: rsync-1.6.3-1.src.rpm".
Changes from 1.6.2-1 packaging: added '$RPM_OPT_FLAGS' to make, strip
to '%build', removed '%prefix'.
* Thu Apr 10 1997 Michael De La Rue <miked@ed.ac.uk>
rsync-1.6.2-1 packaged. (This entry by jam to credit Michael for the
previous package(s).)
%prep
%setup
%build
./configure --prefix=/usr
make CFLAGS="$RPM_OPT_FLAGS"
strip rsync
%install
mkdir -p $RPM_BUILD_ROOT/usr/{bin,man/{man1,man5}}
install -m755 rsync $RPM_BUILD_ROOT/usr/bin
install -m644 rsync.1 $RPM_BUILD_ROOT/usr/man/man1
install -m644 rsyncd.conf.5 $RPM_BUILD_ROOT/usr/man/man5
%clean
rm -rf $RPM_BUILD_ROOT
%files
%attr(-,root,root) /usr/bin/rsync
%attr(-,root,root) /usr/man/man1/rsync.1
%attr(-,root,root) /usr/man/man5/rsyncd.conf.5
%attr(-,root,root) %doc tech_report.tex
%attr(-,root,root) %doc README
%attr(-,root,root) %doc COPYING

View File

@@ -0,0 +1,94 @@
#!/bin/sh
# Shell script for building Solaris package of rsync
# Author: Jens Apel <jens.apel@web.de>
# License: GPL
#
# BASEDIR is /usr/local and should be the same as the
# --prefix parameter of configure
#
# this script should be copied under
# packaging/solaris/5.8/build_pkg.sh
# Definitions start here
# you can edit this, if you like
# The Package name under which rsync will b installed
PKGNAME=SMBrsync
# Extract common info requires for the 'info' part of the package.
# This should be made generic and generated by the configure script
# but for now it is hard coded
BASEDIR=/usr/local
VERSION="2.5.5"
ARCH=`uname -p`
NAME=rsync
# Definitions end here
# Please do not edit below this line or you know what you do.
## Start by faking root install
echo "Creating install directory (fake $BASEDIR)..."
START=`pwd`
FAKE_ROOT=$START/${PKGNAME}
mkdir $FAKE_ROOT
# copy the binary and the man page to their places
mkdir $FAKE_ROOT/bin
mkdir -p $FAKE_ROOT/doc/rsync
mkdir -p $FAKE_ROOT/man/man1
mkdir -p $FAKE_ROOT/man/man5
cp ../../../rsync $FAKE_ROOT/bin/rsync
cp ../../../rsync.1 $FAKE_ROOT/man/man1/rsync.1
cp ../../../rsyncd.conf.5 $FAKE_ROOT/man/man5/rsyncd.conf.5
cp ../../../README $FAKE_ROOT/doc/rsync/README
cp ../../../COPYING $FAKE_ROOT/doc/rsync/COPYING
cp ../../../tech_report.pdf $FAKE_ROOT/doc/rsync/tech_report.pdf
cp ../../../COPYING $FAKE_ROOT/COPYING
## Build info file
echo "Building pkginfo file..."
cat > $FAKE_ROOT/pkginfo << EOF_INFO
PKG=$PKGNAME
NAME=$NAME
DESC="Program for efficient remote updates of files."
VENDOR="Samba Team URL: http://samba.anu.edu.au/rsync/"
BASEDIR=$BASEDIR
ARCH=$ARCH
VERSION=$VERSION
CATEGORY=application
CLASSES=none
EOF_INFO
## Build prototype file
cat > $FAKE_ROOT/prototype << EOFPROTO
i copyright=COPYING
i pkginfo=pkginfo
d none bin 0755 bin bin
f none bin/rsync 0755 bin bin
d none doc 0755 bin bin
d none doc/$NAME 0755 bin bin
f none doc/$NAME/README 0644 bin bin
f none doc/$NAME/COPYING 0644 bin bin
f none doc/$NAME/tech_report.pdf 0644 bin bin
d none man 0755 bin bin
d none man/man1 0755 bin bin
f none man/man1/rsync.1 0644 bin bin
d none man/man5 0755 bin bin
f none man/man5/rsyncd.conf.5 0644 bin bin
EOFPROTO
## And now build the package.
OUTPUTFILE=$PKGNAME-$VERSION-sol8-$ARCH-local.pkg
echo "Building package.."
echo FAKE_ROOT = $FAKE_ROOT
cd $FAKE_ROOT
pkgmk -d . -r . -f ./prototype -o
pkgtrans -os . $OUTPUTFILE $PKGNAME
mv $OUTPUTFILE ..
cd ..
# Comment this out if you want to see, which file structure has been created
rm -rf $FAKE_ROOT

View File

@@ -164,7 +164,7 @@ static int Continuation( char *line, int pos )
*/
{
pos--;
while( (pos >= 0) && isspace(line[pos]) )
while( (pos >= 0) && isspace(((unsigned char *)line)[pos]) )
pos--;
return( ((pos >= 0) && ('\\' == line[pos])) ? pos : -1 );
@@ -207,7 +207,7 @@ static BOOL Section( FILE *InFile, BOOL (*sfunc)(char *) )
if( i > (bSize - 2) )
{
bSize += BUFR_INC;
bufr = Realloc( bufr, bSize );
bufr = realloc_array( bufr, char, bSize );
if( NULL == bufr )
{
rprintf(FERROR, "%s Memory re-allocation failure.", func);
@@ -301,7 +301,7 @@ static BOOL Parameter( FILE *InFile, BOOL (*pfunc)(char *, char *), int c )
if( i > (bSize - 2) ) /* Ensure there's space for next char. */
{
bSize += BUFR_INC;
bufr = Realloc( bufr, bSize );
bufr = realloc_array( bufr, char, bSize );
if( NULL == bufr )
{
rprintf(FERROR, "%s Memory re-allocation failure.", func) ;
@@ -366,7 +366,7 @@ static BOOL Parameter( FILE *InFile, BOOL (*pfunc)(char *, char *), int c )
if( i > (bSize - 2) ) /* Make sure there's enough room. */
{
bSize += BUFR_INC;
bufr = Realloc( bufr, bSize );
bufr = realloc_array( bufr, char, bSize );
if( NULL == bufr )
{
rprintf(FERROR, "%s Memory re-allocation failure.", func) ;
@@ -386,7 +386,7 @@ static BOOL Parameter( FILE *InFile, BOOL (*pfunc)(char *, char *), int c )
c = 0;
else
{
for( end = i; (end >= 0) && isspace(bufr[end]); end-- )
for( end = i; (end >= 0) && isspace(((unsigned char *) bufr)[end]); end-- )
;
c = getc( InFile );
}
@@ -491,8 +491,8 @@ static FILE *OpenConfFile( char *FileName )
OpenedFile = fopen( FileName, "r" );
if( NULL == OpenedFile )
{
rprintf(FERROR,"%s Unable to open configuration file \"%s\":\n\t%s\n",
func, FileName, strerror(errno));
rsyserr(FERROR, errno, "rsync: unable to open configuration file \"%s\"",
safe_fname(FileName));
}
return( OpenedFile );
@@ -530,7 +530,7 @@ BOOL pm_process( char *FileName,
else /* If we don't have a buffer */
{ /* allocate one, then parse, */
bSize = BUFR_INC; /* then free. */
bufr = (char *)malloc( bSize );
bufr = new_array( char, bSize );
if( NULL == bufr )
{
rprintf(FERROR,"%s memory allocation failure.\n", func);

160
pipe.c Normal file
View File

@@ -0,0 +1,160 @@
/* -*- c-file-style: "linux" -*-
*
* Copyright (C) 1996-2000 by Andrew Tridgell
* Copyright (C) Paul Mackerras 1996
* Copyright (C) 2001, 2002 by Martin Pool <mbp@samba.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "rsync.h"
extern int am_sender;
extern int am_server;
extern int blocking_io;
extern int orig_umask;
extern int filesfrom_fd;
/**
* Create a child connected to use on stdin/stdout.
*
* This is derived from CVS code
*
* Note that in the child STDIN is set to blocking and STDOUT
* is set to non-blocking. This is necessary as rsh relies on stdin being blocking
* and ssh relies on stdout being non-blocking
*
* If blocking_io is set then use blocking io on both fds. That can be
* used to cope with badly broken rsh implementations like the one on
* Solaris.
**/
pid_t piped_child(char **command, int *f_in, int *f_out)
{
pid_t pid;
int to_child_pipe[2];
int from_child_pipe[2];
if (verbose >= 2) {
print_child_argv(command);
}
if (fd_pair(to_child_pipe) < 0 || fd_pair(from_child_pipe) < 0) {
rsyserr(FERROR, errno, "pipe");
exit_cleanup(RERR_IPC);
}
pid = do_fork();
if (pid == -1) {
rsyserr(FERROR, errno, "fork");
exit_cleanup(RERR_IPC);
}
if (pid == 0) {
if (dup2(to_child_pipe[0], STDIN_FILENO) < 0 ||
close(to_child_pipe[1]) < 0 ||
close(from_child_pipe[0]) < 0 ||
dup2(from_child_pipe[1], STDOUT_FILENO) < 0) {
rsyserr(FERROR, errno, "Failed to dup/close");
exit_cleanup(RERR_IPC);
}
if (to_child_pipe[0] != STDIN_FILENO)
close(to_child_pipe[0]);
if (from_child_pipe[1] != STDOUT_FILENO)
close(from_child_pipe[1]);
umask(orig_umask);
set_blocking(STDIN_FILENO);
if (blocking_io > 0)
set_blocking(STDOUT_FILENO);
execvp(command[0], command);
rsyserr(FERROR, errno, "Failed to exec %s",
safe_fname(command[0]));
exit_cleanup(RERR_IPC);
}
if (close(from_child_pipe[1]) < 0 || close(to_child_pipe[0]) < 0) {
rsyserr(FERROR, errno, "Failed to close");
exit_cleanup(RERR_IPC);
}
*f_in = from_child_pipe[0];
*f_out = to_child_pipe[1];
return pid;
}
/* This function forks a child which calls child_main(). First,
* however, it has to establish communication paths to and from the
* newborn child. It creates two socket pairs -- one for writing to
* the child (from the parent) and one for reading from the child
* (writing to the parent). Since that's four socket ends, each
* process has to close the two ends it doesn't need. The remaining
* two socket ends are retained for reading and writing. In the
* child, the STDIN and STDOUT file descriptors refer to these
* sockets. In the parent, the function arguments f_in and f_out are
* set to refer to these sockets. */
pid_t local_child(int argc, char **argv, int *f_in, int *f_out,
int (*child_main)(int, char*[]))
{
pid_t pid;
int to_child_pipe[2];
int from_child_pipe[2];
if (fd_pair(to_child_pipe) < 0 ||
fd_pair(from_child_pipe) < 0) {
rsyserr(FERROR, errno, "pipe");
exit_cleanup(RERR_IPC);
}
pid = do_fork();
if (pid == -1) {
rsyserr(FERROR, errno, "fork");
exit_cleanup(RERR_IPC);
}
if (pid == 0) {
am_sender = !am_sender;
am_server = 1;
if (!am_sender)
filesfrom_fd = -1;
if (dup2(to_child_pipe[0], STDIN_FILENO) < 0 ||
close(to_child_pipe[1]) < 0 ||
close(from_child_pipe[0]) < 0 ||
dup2(from_child_pipe[1], STDOUT_FILENO) < 0) {
rsyserr(FERROR, errno, "Failed to dup/close");
exit_cleanup(RERR_IPC);
}
if (to_child_pipe[0] != STDIN_FILENO)
close(to_child_pipe[0]);
if (from_child_pipe[1] != STDOUT_FILENO)
close(from_child_pipe[1]);
child_main(argc, argv);
}
if (!am_sender)
filesfrom_fd = -1;
if (close(from_child_pipe[1]) < 0 ||
close(to_child_pipe[0]) < 0) {
rsyserr(FERROR, errno, "Failed to close");
exit_cleanup(RERR_IPC);
}
*f_in = from_child_pipe[0];
*f_out = to_child_pipe[1];
return pid;
}

7
popt/.cvsignore Normal file
View File

@@ -0,0 +1,7 @@
ID
Makefile
config.cache
config.h
config.log
config.status
dummy

46
popt/CHANGES Normal file
View File

@@ -0,0 +1,46 @@
1.5 -> 1.6
- add ability to perform callbacks for every, not just first, match.
1.3 -> 1.5
- heavy dose of const's
- poptParseArgvString() now NULL terminates the list
1.2.3 -> 1.3
- added support for single -
- misc bug fixes
- portability improvements
1.2.2 -> 1.2.3
- fixed memset() in help message generation (Dale Hawkins)
- added extern "C" stuff to popt.h for C++ compilers (Dale Hawkins)
- const'ified poptParseArgvString (Jeff Garzik)
1.2.1 -> 1.2.2
- fixed bug in chaind alias happens which seems to have only
affected --triggers in rpm
- added POPT_ARG_VAL
- popt.3 installed by default
1.2 -> 1.2.1
- added POPT_ARG_INTL_DOMAIN (Elliot Lee)
- updated Makefile's to be more GNUish (Elliot Lee)
1.1 -> 1.2
- added popt.3 man page (Robert Lynch)
- don't use mmap anymore (its lack of portability isn't worth the
trouble)
- added test script
- added support for exec
- removed support for *_POPT_ALIASES env variable -- it was a bad
idea
- reorganized into multiple source files
- added automatic help generation, POPT_AUTOHELP
- added table callbacks
- added table inclusion
- updated man page for new features
- added test scripts
1.0 -> 1.1
- moved to autoconf (Fred Fish)
- added STRERROR replacement (Norbert Warmuth)
- added const keywords (Bruce Perens)

22
popt/COPYING Normal file
View File

@@ -0,0 +1,22 @@
Copyright (c) 1998 Red Hat Software
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of the X Consortium shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from the X Consortium.

18
popt/README Normal file
View File

@@ -0,0 +1,18 @@
This is the popt command line option parsing library. While it is similiar
to getopt(3), it contains a number of enhancements, including:
1) popt is fully reentrant
2) popt can parse arbitrary argv[] style arrays while
getopt(2) makes this quite difficult
3) popt allows users to alias command line arguments
4) popt provides convience functions for parsing strings
into argv[] style arrays
popt is used by rpm, the Red Hat install program, and many other Red Hat
utilities, all of which provide excellent examples of how to use popt.
Complete documentation on popt is available in popt.ps (included in this
tarball), which is excerpted with permission from the book "Linux
Application Development" by Michael K. Johnson and Erik Troan (availble
from Addison Wesley in May, 1998).
Comments on popt should be addressed to ewt@redhat.com.

4
popt/README.rsync Normal file
View File

@@ -0,0 +1,4 @@
This is a perfectly ordinary copy of libpopt. It is only used on platforms
that do not have a sufficiently up-to-date copy of their own. If you build
rsync on a platform which has popt, this directory should not be used. (You
can control that using the --with-included-popt configure flag.)

0
popt/dummy.in Normal file
View File

50
popt/findme.c Normal file
View File

@@ -0,0 +1,50 @@
/** \ingroup popt
* \file popt/findme.c
*/
/* (C) 1998-2000 Red Hat, Inc. -- Licensing details are in the COPYING
file accompanying popt source distributions, available from
ftp://ftp.rpm.org/pub/rpm/dist. */
#include "system.h"
#include "findme.h"
const char * findProgramPath(const char * argv0) {
char * path = getenv("PATH");
char * pathbuf;
char * start, * chptr;
char * buf;
if (argv0 == NULL) return NULL; /* XXX can't happen */
/* If there is a / in the argv[0], it has to be an absolute path */
if (strchr(argv0, '/'))
return xstrdup(argv0);
if (path == NULL) return NULL;
start = pathbuf = alloca(strlen(path) + 1);
buf = malloc(strlen(path) + strlen(argv0) + sizeof("/"));
if (buf == NULL) return NULL; /* XXX can't happen */
strcpy(pathbuf, path);
chptr = NULL;
/*@-branchstate@*/
do {
if ((chptr = strchr(start, ':')))
*chptr = '\0';
sprintf(buf, "%s/%s", start, argv0);
if (!access(buf, X_OK))
return buf;
if (chptr)
start = chptr + 1;
else
start = NULL;
} while (start && *start);
/*@=branchstate@*/
free(buf);
return NULL;
}

20
popt/findme.h Normal file
View File

@@ -0,0 +1,20 @@
/** \ingroup popt
* \file popt/findme.h
*/
/* (C) 1998-2000 Red Hat, Inc. -- Licensing details are in the COPYING
file accompanying popt source distributions, available from
ftp://ftp.rpm.org/pub/rpm/dist. */
#ifndef H_FINDME
#define H_FINDME
/**
* Return absolute path to executable by searching PATH.
* @param argv0 name of executable
* @return (malloc'd) absolute path to executable (or NULL)
*/
/*@null@*/ const char * findProgramPath(/*@null@*/ const char * argv0)
/*@*/;
#endif

1209
popt/popt.c Normal file
View File

File diff suppressed because it is too large Load Diff

446
popt/popt.h Normal file
View File

@@ -0,0 +1,446 @@
/** \file popt/popt.h
* \ingroup popt
*/
/* (C) 1998-2000 Red Hat, Inc. -- Licensing details are in the COPYING
file accompanying popt source distributions, available from
ftp://ftp.rpm.org/pub/rpm/dist. */
#ifndef H_POPT
#define H_POPT
#include <stdio.h> /* for FILE * */
#define POPT_OPTION_DEPTH 10
/** \ingroup popt
* \name Arg type identifiers
*/
/*@{*/
#define POPT_ARG_NONE 0 /*!< no arg */
#define POPT_ARG_STRING 1 /*!< arg will be saved as string */
#define POPT_ARG_INT 2 /*!< arg will be converted to int */
#define POPT_ARG_LONG 3 /*!< arg will be converted to long */
#define POPT_ARG_INCLUDE_TABLE 4 /*!< arg points to table */
#define POPT_ARG_CALLBACK 5 /*!< table-wide callback... must be
set first in table; arg points
to callback, descrip points to
callback data to pass */
#define POPT_ARG_INTL_DOMAIN 6 /*!< set the translation domain
for this table and any
included tables; arg points
to the domain string */
#define POPT_ARG_VAL 7 /*!< arg should take value val */
#define POPT_ARG_FLOAT 8 /*!< arg will be converted to float */
#define POPT_ARG_DOUBLE 9 /*!< arg will be converted to double */
#define POPT_ARG_MASK 0x0000FFFF
/*@}*/
/** \ingroup popt
* \name Arg modifiers
*/
/*@{*/
#define POPT_ARGFLAG_ONEDASH 0x80000000 /*!< allow -longoption */
#define POPT_ARGFLAG_DOC_HIDDEN 0x40000000 /*!< don't show in help/usage */
#define POPT_ARGFLAG_STRIP 0x20000000 /*!< strip this arg from argv(only applies to long args) */
#define POPT_ARGFLAG_OPTIONAL 0x10000000 /*!< arg may be missing */
#define POPT_ARGFLAG_OR 0x08000000 /*!< arg will be or'ed */
#define POPT_ARGFLAG_NOR 0x09000000 /*!< arg will be nor'ed */
#define POPT_ARGFLAG_AND 0x04000000 /*!< arg will be and'ed */
#define POPT_ARGFLAG_NAND 0x05000000 /*!< arg will be nand'ed */
#define POPT_ARGFLAG_XOR 0x02000000 /*!< arg will be xor'ed */
#define POPT_ARGFLAG_NOT 0x01000000 /*!< arg will be negated */
#define POPT_ARGFLAG_LOGICALOPS \
(POPT_ARGFLAG_OR|POPT_ARGFLAG_AND|POPT_ARGFLAG_XOR)
#define POPT_BIT_SET (POPT_ARG_VAL|POPT_ARGFLAG_OR)
/*!< set arg bit(s) */
#define POPT_BIT_CLR (POPT_ARG_VAL|POPT_ARGFLAG_NAND)
/*!< clear arg bit(s) */
#define POPT_ARGFLAG_SHOW_DEFAULT 0x00800000 /*!< show default value in --help */
/*@}*/
/** \ingroup popt
* \name Callback modifiers
*/
/*@{*/
#define POPT_CBFLAG_PRE 0x80000000 /*!< call the callback before parse */
#define POPT_CBFLAG_POST 0x40000000 /*!< call the callback after parse */
#define POPT_CBFLAG_INC_DATA 0x20000000 /*!< use data from the include line,
not the subtable */
#define POPT_CBFLAG_SKIPOPTION 0x10000000 /*!< don't callback with option */
#define POPT_CBFLAG_CONTINUE 0x08000000 /*!< continue callbacks with option */
/*@}*/
/** \ingroup popt
* \name Error return values
*/
/*@{*/
#define POPT_ERROR_NOARG -10 /*!< missing argument */
#define POPT_ERROR_BADOPT -11 /*!< unknown option */
#define POPT_ERROR_OPTSTOODEEP -13 /*!< aliases nested too deeply */
#define POPT_ERROR_BADQUOTE -15 /*!< error in paramter quoting */
#define POPT_ERROR_ERRNO -16 /*!< errno set, use strerror(errno) */
#define POPT_ERROR_BADNUMBER -17 /*!< invalid numeric value */
#define POPT_ERROR_OVERFLOW -18 /*!< number too large or too small */
#define POPT_ERROR_BADOPERATION -19 /*!< mutually exclusive logical operations requested */
#define POPT_ERROR_NULLARG -20 /*!< opt->arg should not be NULL */
#define POPT_ERROR_MALLOC -21 /*!< memory allocation failed */
/*@}*/
/** \ingroup popt
* \name poptBadOption() flags
*/
/*@{*/
#define POPT_BADOPTION_NOALIAS (1 << 0) /*!< don't go into an alias */
/*@}*/
/** \ingroup popt
* \name poptGetContext() flags
*/
/*@{*/
#define POPT_CONTEXT_NO_EXEC (1 << 0) /*!< ignore exec expansions */
#define POPT_CONTEXT_KEEP_FIRST (1 << 1) /*!< pay attention to argv[0] */
#define POPT_CONTEXT_POSIXMEHARDER (1 << 2) /*!< options can't follow args */
#define POPT_CONTEXT_ARG_OPTS (1 << 4) /*!< return args as options with value 0 */
/*@}*/
/** \ingroup popt
*/
struct poptOption {
/*@observer@*/ /*@null@*/ const char * longName; /*!< may be NULL */
char shortName; /*!< may be '\0' */
int argInfo;
/*@shared@*/ /*@null@*/ void * arg; /*!< depends on argInfo */
int val; /*!< 0 means don't return, just update flag */
/*@observer@*/ /*@null@*/ const char * descrip; /*!< description for autohelp -- may be NULL */
/*@observer@*/ /*@null@*/ const char * argDescrip; /*!< argument description for autohelp */
};
/** \ingroup popt
* A popt alias argument for poptAddAlias().
*/
struct poptAlias {
/*@owned@*/ /*@null@*/ const char * longName; /*!< may be NULL */
char shortName; /*!< may be '\0' */
int argc;
/*@owned@*/ const char ** argv; /*!< must be free()able */
};
/** \ingroup popt
* A popt alias or exec argument for poptAddItem().
*/
typedef struct poptItem_s {
struct poptOption option; /*!< alias/exec name(s) and description. */
int argc; /*!< (alias) no. of args. */
/*@owned@*/ const char ** argv; /*!< (alias) args, must be free()able. */
} * poptItem;
/** \ingroup popt
* \name Auto-generated help/usage
*/
/*@{*/
/**
* Empty table marker to enable displaying popt alias/exec options.
*/
/*@observer@*/ /*@checked@*/
extern struct poptOption poptAliasOptions[];
#define POPT_AUTOALIAS { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptAliasOptions, \
0, "Options implemented via popt alias/exec:", NULL },
/**
* Auto help table options.
*/
/*@observer@*/ /*@checked@*/
extern struct poptOption poptHelpOptions[];
#define POPT_AUTOHELP { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptHelpOptions, \
0, "Help options:", NULL },
#define POPT_TABLEEND { NULL, '\0', 0, 0, 0, NULL, NULL }
/*@}*/
/** \ingroup popt
*/
typedef /*@abstract@*/ struct poptContext_s * poptContext;
/** \ingroup popt
*/
#ifndef __cplusplus
/*@-typeuse@*/
typedef struct poptOption * poptOption;
/*@=typeuse@*/
#endif
enum poptCallbackReason { POPT_CALLBACK_REASON_PRE,
POPT_CALLBACK_REASON_POST,
POPT_CALLBACK_REASON_OPTION };
#ifdef __cplusplus
extern "C" {
#endif
/*@-type@*/
/** \ingroup popt
* Table callback prototype.
* @param con context
* @param reason reason for callback
* @param opt option that triggered callback
* @param arg @todo Document.
* @param data @todo Document.
*/
typedef void (*poptCallbackType) (poptContext con,
enum poptCallbackReason reason,
/*@null@*/ const struct poptOption * opt,
/*@null@*/ const char * arg,
/*@null@*/ const void * data)
/*@*/;
/** \ingroup popt
* Initialize popt context.
* @param name
* @param argc no. of arguments
* @param argv argument array
* @param options address of popt option table
* @param flags or'd POPT_CONTEXT_* bits
* @return initialized popt context
*/
/*@only@*/ /*@null@*/ poptContext poptGetContext(
/*@dependent@*/ /*@keep@*/ const char * name,
int argc, /*@dependent@*/ /*@keep@*/ const char ** argv,
/*@dependent@*/ /*@keep@*/ const struct poptOption * options,
int flags)
/*@*/;
/** \ingroup popt
* Reinitialize popt context.
* @param con context
*/
void poptResetContext(/*@null@*/poptContext con)
/*@modifies con @*/;
/** \ingroup popt
* Return value of next option found.
* @param con context
* @return next option val, -1 on last item, POPT_ERROR_* on error
*/
int poptGetNextOpt(/*@null@*/poptContext con)
/*@globals fileSystem@*/
/*@modifies con, fileSystem @*/;
/*@-redecl@*/
/** \ingroup popt
* Return next option argument (if any).
* @param con context
* @return option argument, NULL if no more options are available
*/
/*@observer@*/ /*@null@*/ const char * poptGetOptArg(/*@null@*/poptContext con)
/*@modifies con @*/;
/** \ingroup popt
* Return current option's argument.
* @param con context
* @return option argument, NULL if no more options are available
*/
/*@observer@*/ /*@null@*/ const char * poptGetArg(/*@null@*/poptContext con)
/*@modifies con @*/;
/** \ingroup popt
* Peek at current option's argument.
* @param con context
* @return option argument
*/
/*@observer@*/ /*@null@*/ const char * poptPeekArg(/*@null@*/poptContext con)
/*@*/;
/** \ingroup popt
* Return remaining arguments.
* @param con context
* @return argument array, terminated with NULL
*/
/*@observer@*/ /*@null@*/ const char ** poptGetArgs(/*@null@*/poptContext con)
/*@modifies con @*/;
/** \ingroup popt
* Return the option which caused the most recent error.
* @param con context
* @return offending option
*/
/*@observer@*/ const char * poptBadOption(/*@null@*/poptContext con, int flags)
/*@*/;
/*@=redecl@*/
/** \ingroup popt
* Destroy context.
* @param con context
* @return NULL always
*/
/*@null@*/ poptContext poptFreeContext( /*@only@*/ /*@null@*/ poptContext con)
/*@modifies con @*/;
/** \ingroup popt
* Add arguments to context.
* @param con context
* @param argv argument array, NULL terminated
* @return 0 on success, POPT_ERROR_OPTSTOODEEP on failure
*/
int poptStuffArgs(poptContext con, /*@keep@*/ const char ** argv)
/*@modifies con @*/;
/** \ingroup popt
* Add alias to context.
* @todo Pass alias by reference, not value.
* @deprecated Use poptAddItem instead.
* @param con context
* @param alias alias to add
* @param flags (unused)
* @return 0 on success
*/
/*@unused@*/
int poptAddAlias(poptContext con, struct poptAlias alias, int flags)
/*@modifies con @*/;
/** \ingroup popt
* Add alias/exec item to context.
* @param con context
* @param item alias/exec item to add
* @param flags 0 for alias, 1 for exec
* @return 0 on success
*/
int poptAddItem(poptContext con, poptItem newItem, int flags)
/*@modifies con @*/;
/** \ingroup popt
* Read configuration file.
* @param con context
* @param fn file name to read
* @return 0 on success, POPT_ERROR_ERRNO on failure
*/
int poptReadConfigFile(poptContext con, const char * fn)
/*@globals fileSystem@*/
/*@modifies fileSystem,
con->execs, con->numExecs @*/;
/** \ingroup popt
* Read default configuration from /etc/popt and $HOME/.popt.
* @param con context
* @param useEnv (unused)
* @return 0 on success, POPT_ERROR_ERRNO on failure
*/
int poptReadDefaultConfig(poptContext con, /*@unused@*/ int useEnv)
/*@globals fileSystem@*/
/*@modifies fileSystem,
con->execs, con->numExecs @*/;
/** \ingroup popt
* Duplicate an argument array.
* @note: The argument array is malloc'd as a single area, so only argv must
* be free'd.
*
* @param argc no. of arguments
* @param argv argument array
* @retval argcPtr address of returned no. of arguments
* @retval argvPtr address of returned argument array
* @return 0 on success, POPT_ERROR_NOARG on failure
*/
int poptDupArgv(int argc, /*@null@*/ const char **argv,
/*@null@*/ /*@out@*/ int * argcPtr,
/*@null@*/ /*@out@*/ const char *** argvPtr)
/*@modifies *argcPtr, *argvPtr @*/;
/** \ingroup popt
* Parse a string into an argument array.
* The parse allows ', ", and \ quoting, but ' is treated the same as " and
* both may include \ quotes.
* @note: The argument array is malloc'd as a single area, so only argv must
* be free'd.
*
* @param s string to parse
* @retval argcPtr address of returned no. of arguments
* @retval argvPtr address of returned argument array
*/
int poptParseArgvString(const unsigned char * s,
/*@out@*/ int * argcPtr, /*@out@*/ const char *** argvPtr)
/*@modifies *argcPtr, *argvPtr @*/;
/** \ingroup popt
* Return formatted error string for popt failure.
* @param error popt error
* @return error string
*/
/*@-redecl@*/
/*@observer@*/ const char * poptStrerror(const int error)
/*@*/;
/*@=redecl@*/
/** \ingroup popt
* Limit search for executables.
* @param con context
* @param path single path to search for executables
* @param allowAbsolute absolute paths only?
*/
void poptSetExecPath(poptContext con, const char * path, int allowAbsolute)
/*@modifies con @*/;
/** \ingroup popt
* Print detailed description of options.
* @param con context
* @param fp ouput file handle
* @param flags (unused)
*/
void poptPrintHelp(poptContext con, FILE * fp, /*@unused@*/ int flags)
/*@globals fileSystem @*/
/*@modifies *fp, fileSystem @*/;
/** \ingroup popt
* Print terse description of options.
* @param con context
* @param fp ouput file handle
* @param flags (unused)
*/
void poptPrintUsage(poptContext con, FILE * fp, /*@unused@*/ int flags)
/*@globals fileSystem @*/
/*@modifies *fp, fileSystem @*/;
/** \ingroup popt
* Provide text to replace default "[OPTION...]" in help/usage output.
* @param con context
* @param text replacement text
*/
/*@-fcnuse@*/
void poptSetOtherOptionHelp(poptContext con, const char * text)
/*@modifies con @*/;
/*@=fcnuse@*/
/** \ingroup popt
* Return argv[0] from context.
* @param con context
* @return argv[0]
*/
/*@-redecl -fcnuse@*/
/*@observer@*/ const char * poptGetInvocationName(poptContext con)
/*@*/;
/*@=redecl =fcnuse@*/
/** \ingroup popt
* Shuffle argv pointers to remove stripped args, returns new argc.
* @param con context
* @param argc no. of args
* @param argv arg vector
* @return new argc
*/
/*@-fcnuse@*/
int poptStrippedArgv(poptContext con, int argc, char ** argv)
/*@modifies *argv @*/;
/*@=fcnuse@*/
/*@=type@*/
#ifdef __cplusplus
}
#endif
#endif

184
popt/poptconfig.c Normal file
View File

@@ -0,0 +1,184 @@
/** \ingroup popt
* \file popt/poptconfig.c
*/
/* (C) 1998-2000 Red Hat, Inc. -- Licensing details are in the COPYING
file accompanying popt source distributions, available from
ftp://ftp.rpm.org/pub/rpm/dist. */
#include "system.h"
#include "poptint.h"
/*@-compmempass@*/ /* FIX: item->option.longName kept, not dependent. */
static void configLine(poptContext con, unsigned char * line)
/*@modifies con @*/
{
/*@-type@*/
int nameLength = strlen(con->appName);
/*@=type@*/
const char * entryType;
const char * opt;
poptItem item = (poptItem) alloca(sizeof(*item));
int i, j;
memset(item, 0, sizeof(*item));
/*@-type@*/
if (strncmp(line, con->appName, nameLength)) return;
/*@=type@*/
line += nameLength;
if (*line == '\0' || !isspace(*line)) return;
while (*line != '\0' && isspace(*line)) line++;
entryType = line;
while (*line == '\0' || !isspace(*line)) line++;
*line++ = '\0';
while (*line != '\0' && isspace(*line)) line++;
if (*line == '\0') return;
opt = line;
while (*line == '\0' || !isspace(*line)) line++;
*line++ = '\0';
while (*line != '\0' && isspace(*line)) line++;
if (*line == '\0') return;
/*@-temptrans@*/ /* FIX: line alias is saved */
if (opt[0] == '-' && opt[1] == '-')
item->option.longName = opt + 2;
else if (opt[0] == '-' && opt[2] == '\0')
item->option.shortName = opt[1];
/*@=temptrans@*/
if (poptParseArgvString(line, &item->argc, &item->argv)) return;
/*@-modobserver@*/
item->option.argInfo = POPT_ARGFLAG_DOC_HIDDEN;
for (i = 0, j = 0; i < item->argc; i++, j++) {
const char * f;
if (!strncmp(item->argv[i], "--POPTdesc=", sizeof("--POPTdesc=")-1)) {
f = item->argv[i] + sizeof("--POPTdesc=");
if (f[0] == '$' && f[1] == '"') f++;
item->option.descrip = f;
item->option.argInfo &= ~POPT_ARGFLAG_DOC_HIDDEN;
j--;
} else
if (!strncmp(item->argv[i], "--POPTargs=", sizeof("--POPTargs=")-1)) {
f = item->argv[i] + sizeof("--POPTargs=");
if (f[0] == '$' && f[1] == '"') f++;
item->option.argDescrip = f;
item->option.argInfo &= ~POPT_ARGFLAG_DOC_HIDDEN;
item->option.argInfo |= POPT_ARG_STRING;
j--;
} else
if (j != i)
item->argv[j] = item->argv[i];
}
if (j != i) {
item->argv[j] = NULL;
item->argc = j;
}
/*@=modobserver@*/
/*@-nullstate@*/ /* FIX: item->argv[] may be NULL */
if (!strcmp(entryType, "alias"))
(void) poptAddItem(con, item, 0);
else if (!strcmp(entryType, "exec"))
(void) poptAddItem(con, item, 1);
/*@=nullstate@*/
}
/*@=compmempass@*/
int poptReadConfigFile(poptContext con, const char * fn)
{
const unsigned char * file, * chptr, * end;
unsigned char * buf;
/*@dependent@*/ unsigned char * dst;
int fd, rc;
off_t fileLength;
fd = open(fn, O_RDONLY);
if (fd < 0)
return (errno == ENOENT ? 0 : POPT_ERROR_ERRNO);
fileLength = lseek(fd, 0, SEEK_END);
if (fileLength == -1 || lseek(fd, 0, 0) == -1) {
rc = errno;
(void) close(fd);
/*@-mods@*/
errno = rc;
/*@=mods@*/
return POPT_ERROR_ERRNO;
}
file = alloca(fileLength + 1);
if (read(fd, (char *)file, fileLength) != fileLength) {
rc = errno;
(void) close(fd);
/*@-mods@*/
errno = rc;
/*@=mods@*/
return POPT_ERROR_ERRNO;
}
if (close(fd) == -1)
return POPT_ERROR_ERRNO;
dst = buf = alloca(fileLength + 1);
chptr = file;
end = (file + fileLength);
/*@-infloops@*/ /* LCL: can't detect chptr++ */
while (chptr < end) {
switch (*chptr) {
case '\n':
*dst = '\0';
dst = buf;
while (*dst && isspace(*dst)) dst++;
if (*dst && *dst != '#')
configLine(con, dst);
chptr++;
/*@switchbreak@*/ break;
case '\\':
*dst++ = *chptr++;
if (chptr < end) {
if (*chptr == '\n')
dst--, chptr++;
/* \ at the end of a line does not insert a \n */
else
*dst++ = *chptr++;
}
/*@switchbreak@*/ break;
default:
*dst++ = *chptr++;
/*@switchbreak@*/ break;
}
}
/*@=infloops@*/
return 0;
}
int poptReadDefaultConfig(poptContext con, /*@unused@*/ UNUSED(int useEnv))
{
char * fn, * home;
int rc;
/*@-type@*/
if (!con->appName) return 0;
/*@=type@*/
rc = poptReadConfigFile(con, "/etc/popt");
if (rc) return rc;
if (getuid() != geteuid()) return 0;
if ((home = getenv("HOME"))) {
fn = alloca(strlen(home) + 20);
strcpy(fn, home);
strcat(fn, "/.popt");
rc = poptReadConfigFile(con, fn);
if (rc) return rc;
}
return 0;
}

661
popt/popthelp.c Normal file
View File

@@ -0,0 +1,661 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/*@-type@*/
/** \ingroup popt
* \file popt/popthelp.c
*/
/* (C) 1998-2000 Red Hat, Inc. -- Licensing details are in the COPYING
file accompanying popt source distributions, available from
ftp://ftp.rpm.org/pub/rpm/dist. */
#include "system.h"
#include "poptint.h"
/**
* @param con context
* @param key option(s)
*/
static void displayArgs(poptContext con,
/*@unused@*/ UNUSED(enum poptCallbackReason foo),
struct poptOption * key,
/*@unused@*/ UNUSED(const char * arg), /*@unused@*/ UNUSED(void * data))
/*@globals fileSystem@*/
/*@modifies fileSystem@*/
{
if (key->shortName == '?')
poptPrintHelp(con, stdout, 0);
else
poptPrintUsage(con, stdout, 0);
exit(0);
}
#ifdef NOTYET
/*@unchecked@*/
static int show_option_defaults = 0;
#endif
/**
* Empty table marker to enable displaying popt alias/exec options.
*/
/*@observer@*/ /*@unchecked@*/
struct poptOption poptAliasOptions[] = {
POPT_TABLEEND
};
/**
* Auto help table options.
*/
/*@-castfcnptr@*/
/*@observer@*/ /*@unchecked@*/
struct poptOption poptHelpOptions[] = {
{ NULL, '\0', POPT_ARG_CALLBACK, (void *)&displayArgs, '\0', NULL, NULL },
{ "help", '?', 0, NULL, '?', N_("Show this help message"), NULL },
{ "usage", '\0', 0, NULL, 'u', N_("Display brief usage message"), NULL },
#ifdef NOTYET
{ "defaults", '\0', POPT_ARG_NONE, &show_option_defaults, 0,
N_("Display option defaults in message"), NULL },
#endif
POPT_TABLEEND
} ;
/*@=castfcnptr@*/
/**
* @param table option(s)
*/
/*@observer@*/ /*@null@*/ static const char *
getTableTranslationDomain(/*@null@*/ const struct poptOption *table)
/*@*/
{
const struct poptOption *opt;
if (table != NULL)
for (opt = table; opt->longName || opt->shortName || opt->arg; opt++) {
if (opt->argInfo == POPT_ARG_INTL_DOMAIN)
return opt->arg;
}
return NULL;
}
/**
* @param opt option(s)
* @param translation_domain translation domain
*/
/*@observer@*/ /*@null@*/ static const char *
getArgDescrip(const struct poptOption * opt,
/*@-paramuse@*/ /* FIX: wazzup? */
/*@null@*/ UNUSED(const char * translation_domain))
/*@=paramuse@*/
/*@*/
{
if (!(opt->argInfo & POPT_ARG_MASK)) return NULL;
if (opt == (poptHelpOptions + 1) || opt == (poptHelpOptions + 2))
if (opt->argDescrip) return POPT_(opt->argDescrip);
if (opt->argDescrip) return D_(translation_domain, opt->argDescrip);
switch (opt->argInfo & POPT_ARG_MASK) {
case POPT_ARG_NONE: return POPT_("NONE");
case POPT_ARG_VAL: return POPT_("VAL");
case POPT_ARG_INT: return POPT_("INT");
case POPT_ARG_LONG: return POPT_("LONG");
case POPT_ARG_STRING: return POPT_("STRING");
case POPT_ARG_FLOAT: return POPT_("FLOAT");
case POPT_ARG_DOUBLE: return POPT_("DOUBLE");
default: return POPT_("ARG");
}
}
/**
* @param opt option(s)
* @param translation_domain translation domain
*/
static /*@only@*/ /*@null@*/ char *
singleOptionDefaultValue(int lineLength,
const struct poptOption * opt,
/*@-paramuse@*/ /* FIX: i18n macros disable with lclint */
/*@null@*/ UNUSED(const char * translation_domain))
/*@=paramuse@*/
/*@*/
{
const char * defstr = D_(translation_domain, "default");
char * le = malloc(4*lineLength + 1);
char * l = le;
if (le == NULL) return NULL; /* XXX can't happen */
*le = '\0';
*le++ = '(';
strcpy(le, defstr); le += strlen(le);
*le++ = ':';
*le++ = ' ';
if (opt->arg) /* XXX programmer error */
switch (opt->argInfo & POPT_ARG_MASK) {
case POPT_ARG_VAL:
case POPT_ARG_INT:
{ long aLong = *((int *)opt->arg);
sprintf(le, "%ld", aLong);
le += strlen(le);
} break;
case POPT_ARG_LONG:
{ long aLong = *((long *)opt->arg);
sprintf(le, "%ld", aLong);
le += strlen(le);
} break;
case POPT_ARG_FLOAT:
{ double aDouble = *((float *)opt->arg);
sprintf(le, "%g", aDouble);
le += strlen(le);
} break;
case POPT_ARG_DOUBLE:
{ double aDouble = *((double *)opt->arg);
sprintf(le, "%g", aDouble);
le += strlen(le);
} break;
case POPT_ARG_STRING:
{ const char * s = *(const char **)opt->arg;
if (s == NULL) {
strcpy(le, "null"); le += strlen(le);
} else {
size_t slen = 4*lineLength - (le - l) - sizeof("\"...\")");
*le++ = '"';
strncpy(le, s, slen); le[slen] = '\0'; le += strlen(le);
if (slen < strlen(s)) {
strcpy(le, "..."); le += strlen(le);
}
*le++ = '"';
}
} break;
case POPT_ARG_NONE:
default:
l = _free(l);
return NULL;
/*@notreached@*/ break;
}
*le++ = ')';
*le = '\0';
return l;
}
/**
* @param fp output file handle
* @param opt option(s)
* @param translation_domain translation domain
*/
static void singleOptionHelp(FILE * fp, int maxLeftCol,
const struct poptOption * opt,
/*@null@*/ const char * translation_domain)
/*@globals fileSystem @*/
/*@modifies *fp, fileSystem @*/
{
int indentLength = maxLeftCol + 5;
int lineLength = 79 - indentLength;
const unsigned char * help = D_(translation_domain, opt->descrip);
const char * argDescrip = getArgDescrip(opt, translation_domain);
int helpLength;
unsigned char * defs = NULL;
unsigned char * left;
int nb = maxLeftCol + 1;
/* Make sure there's more than enough room in target buffer. */
if (opt->longName) nb += strlen(opt->longName);
if (argDescrip) nb += strlen(argDescrip);
left = malloc(nb);
if (left == NULL) return; /* XXX can't happen */
left[0] = '\0';
left[maxLeftCol] = '\0';
if (opt->longName && opt->shortName)
sprintf(left, "-%c, %s%s", opt->shortName,
((opt->argInfo & POPT_ARGFLAG_ONEDASH) ? "-" : "--"),
opt->longName);
else if (opt->shortName != '\0')
sprintf(left, "-%c", opt->shortName);
else if (opt->longName)
sprintf(left, "%s%s",
((opt->argInfo & POPT_ARGFLAG_ONEDASH) ? "-" : "--"),
opt->longName);
if (!*left) goto out;
if (argDescrip) {
char * le = left + strlen(left);
if (opt->argInfo & POPT_ARGFLAG_OPTIONAL)
*le++ = '[';
/* Choose type of output */
/*@-branchstate@*/
if (opt->argInfo & POPT_ARGFLAG_SHOW_DEFAULT) {
defs = singleOptionDefaultValue(lineLength, opt, translation_domain);
if (defs) {
char * t = malloc((help ? strlen(help) : 0) +
strlen(defs) + sizeof(" "));
if (t) {
char * te = t;
*te = '\0';
if (help) {
strcpy(te, help); te += strlen(te);
}
*te++ = ' ';
strcpy(te, defs);
defs = _free(defs);
}
defs = t;
}
}
/*@=branchstate@*/
if (opt->argDescrip == NULL) {
switch (opt->argInfo & POPT_ARG_MASK) {
case POPT_ARG_NONE:
break;
case POPT_ARG_VAL:
{ long aLong = opt->val;
int ops = (opt->argInfo & POPT_ARGFLAG_LOGICALOPS);
int negate = (opt->argInfo & POPT_ARGFLAG_NOT);
/* Don't bother displaying typical values */
if (!ops && (aLong == 0L || aLong == 1L || aLong == -1L))
break;
*le++ = '[';
switch (ops) {
case POPT_ARGFLAG_OR:
*le++ = '|';
/*@innerbreak@*/ break;
case POPT_ARGFLAG_AND:
*le++ = '&';
/*@innerbreak@*/ break;
case POPT_ARGFLAG_XOR:
*le++ = '^';
/*@innerbreak@*/ break;
default:
/*@innerbreak@*/ break;
}
*le++ = '=';
if (negate) *le++ = '~';
/*@-formatconst@*/
sprintf(le, (ops ? "0x%lx" : "%ld"), aLong);
le += strlen(le);
/*@=formatconst@*/
*le++ = ']';
} break;
case POPT_ARG_INT:
case POPT_ARG_LONG:
case POPT_ARG_FLOAT:
case POPT_ARG_DOUBLE:
case POPT_ARG_STRING:
*le++ = '=';
strcpy(le, argDescrip); le += strlen(le);
break;
default:
break;
}
} else {
*le++ = '=';
strcpy(le, argDescrip); le += strlen(le);
}
if (opt->argInfo & POPT_ARGFLAG_OPTIONAL)
*le++ = ']';
*le = '\0';
}
if (help)
fprintf(fp," %-*s ", maxLeftCol, left);
else {
fprintf(fp," %s\n", left);
goto out;
}
left = _free(left);
if (defs) {
help = defs; defs = NULL;
}
helpLength = strlen(help);
while (helpLength > lineLength) {
const unsigned char * ch;
char format[10];
ch = help + lineLength - 1;
while (ch > help && !isspace(*ch)) ch--;
if (ch == help) break; /* give up */
while (ch > (help + 1) && isspace(*ch)) ch--;
ch++;
sprintf(format, "%%.%ds\n%%%ds", (int) (ch - help), indentLength);
/*@-formatconst@*/
fprintf(fp, format, help, " ");
/*@=formatconst@*/
help = ch;
while (isspace(*help) && *help) help++;
helpLength = strlen(help);
}
if (helpLength) fprintf(fp, "%s\n", help);
out:
/*@-dependenttrans@*/
defs = _free(defs);
/*@=dependenttrans@*/
left = _free(left);
}
/**
* @param opt option(s)
* @param translation_domain translation domain
*/
static int maxArgWidth(const struct poptOption * opt,
/*@null@*/ const char * translation_domain)
/*@*/
{
int max = 0;
int len = 0;
const char * s;
if (opt != NULL)
while (opt->longName || opt->shortName || opt->arg) {
if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) {
if (opt->arg) /* XXX program error */
len = maxArgWidth(opt->arg, translation_domain);
if (len > max) max = len;
} else if (!(opt->argInfo & POPT_ARGFLAG_DOC_HIDDEN)) {
len = sizeof(" ")-1;
if (opt->shortName != '\0') len += sizeof("-X")-1;
if (opt->shortName != '\0' && opt->longName) len += sizeof(", ")-1;
if (opt->longName) {
len += ((opt->argInfo & POPT_ARGFLAG_ONEDASH)
? sizeof("-")-1 : sizeof("--")-1);
len += strlen(opt->longName);
}
s = getArgDescrip(opt, translation_domain);
if (s)
len += sizeof("=")-1 + strlen(s);
if (opt->argInfo & POPT_ARGFLAG_OPTIONAL) len += sizeof("[]")-1;
if (len > max) max = len;
}
opt++;
}
return max;
}
/**
* Display popt alias and exec help.
* @param fp output file handle
* @param items alias/exec array
* @param nitems no. of alias/exec entries
* @param translation_domain translation domain
*/
static void itemHelp(FILE * fp,
/*@null@*/ poptItem items, int nitems, int left,
/*@null@*/ const char * translation_domain)
/*@globals fileSystem @*/
/*@modifies *fp, fileSystem @*/
{
poptItem item;
int i;
if (items != NULL)
for (i = 0, item = items; i < nitems; i++, item++) {
const struct poptOption * opt;
opt = &item->option;
if ((opt->longName || opt->shortName) &&
!(opt->argInfo & POPT_ARGFLAG_DOC_HIDDEN))
singleOptionHelp(fp, left, opt, translation_domain);
}
}
/**
* @param fp output file handle
* @param table option(s)
* @param translation_domain translation domain
*/
static void singleTableHelp(poptContext con, FILE * fp,
/*@null@*/ const struct poptOption * table, int left,
/*@null@*/ const char * translation_domain)
/*@globals fileSystem @*/
/*@modifies *fp, fileSystem @*/
{
const struct poptOption * opt;
const char *sub_transdom;
if (table == poptAliasOptions) {
itemHelp(fp, con->aliases, con->numAliases, left, NULL);
itemHelp(fp, con->execs, con->numExecs, left, NULL);
return;
}
if (table != NULL)
for (opt = table; (opt->longName || opt->shortName || opt->arg); opt++) {
if ((opt->longName || opt->shortName) &&
!(opt->argInfo & POPT_ARGFLAG_DOC_HIDDEN))
singleOptionHelp(fp, left, opt, translation_domain);
}
if (table != NULL)
for (opt = table; (opt->longName || opt->shortName || opt->arg); opt++) {
if ((opt->argInfo & POPT_ARG_MASK) != POPT_ARG_INCLUDE_TABLE)
continue;
sub_transdom = getTableTranslationDomain(opt->arg);
if (sub_transdom == NULL)
sub_transdom = translation_domain;
if (opt->descrip)
fprintf(fp, "\n%s\n", D_(sub_transdom, opt->descrip));
singleTableHelp(con, fp, opt->arg, left, sub_transdom);
}
}
/**
* @param con context
* @param fp output file handle
*/
static int showHelpIntro(poptContext con, FILE * fp)
/*@globals fileSystem @*/
/*@modifies *fp, fileSystem @*/
{
int len = 6;
const char * fn;
fprintf(fp, POPT_("Usage:"));
if (!(con->flags & POPT_CONTEXT_KEEP_FIRST)) {
/*@-nullderef@*/ /* LCL: wazzup? */
fn = con->optionStack->argv[0];
/*@=nullderef@*/
if (fn == NULL) return len;
if (strchr(fn, '/')) fn = strrchr(fn, '/') + 1;
fprintf(fp, " %s", fn);
len += strlen(fn) + 1;
}
return len;
}
void poptPrintHelp(poptContext con, FILE * fp, /*@unused@*/ UNUSED(int flags))
{
int leftColWidth;
(void) showHelpIntro(con, fp);
if (con->otherHelp)
fprintf(fp, " %s\n", con->otherHelp);
else
fprintf(fp, " %s\n", POPT_("[OPTION...]"));
leftColWidth = maxArgWidth(con->options, NULL);
singleTableHelp(con, fp, con->options, leftColWidth, NULL);
}
/**
* @param fp output file handle
* @param opt option(s)
* @param translation_domain translation domain
*/
static int singleOptionUsage(FILE * fp, int cursor,
const struct poptOption * opt,
/*@null@*/ const char *translation_domain)
/*@globals fileSystem @*/
/*@modifies *fp, fileSystem @*/
{
int len = 3;
char shortStr[2] = { '\0', '\0' };
const char * item = shortStr;
const char * argDescrip = getArgDescrip(opt, translation_domain);
if (opt->shortName!= '\0' ) {
if (!(opt->argInfo & POPT_ARG_MASK))
return cursor; /* we did these already */
len++;
shortStr[0] = opt->shortName;
shortStr[1] = '\0';
} else if (opt->longName) {
len += 1 + strlen(opt->longName);
item = opt->longName;
}
if (len == 3) return cursor;
if (argDescrip)
len += strlen(argDescrip) + 1;
if ((cursor + len) > 79) {
fprintf(fp, "\n ");
cursor = 7;
}
fprintf(fp, " [-%s%s%s%s]",
((opt->shortName || (opt->argInfo & POPT_ARGFLAG_ONEDASH)) ? "" : "-"),
item,
(argDescrip ? (opt->shortName != '\0' ? " " : "=") : ""),
(argDescrip ? argDescrip : ""));
return cursor + len + 1;
}
/**
* Display popt alias and exec usage.
* @param fp output file handle
* @param item alias/exec array
* @param nitems no. of ara/exec entries
* @param translation_domain translation domain
*/
static int itemUsage(FILE * fp, int cursor, poptItem item, int nitems,
/*@null@*/ const char * translation_domain)
/*@globals fileSystem @*/
/*@modifies *fp, fileSystem @*/
{
int i;
/*@-branchstate@*/ /* FIX: W2DO? */
if (item != NULL)
for (i = 0; i < nitems; i++, item++) {
const struct poptOption * opt;
opt = &item->option;
if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INTL_DOMAIN) {
translation_domain = (const char *)opt->arg;
} else if ((opt->longName || opt->shortName) &&
!(opt->argInfo & POPT_ARGFLAG_DOC_HIDDEN)) {
cursor = singleOptionUsage(fp, cursor, opt, translation_domain);
}
}
/*@=branchstate@*/
return cursor;
}
/**
* @param fp output file handle
* @param opt option(s)
* @param translation_domain translation domain
*/
static int singleTableUsage(poptContext con, FILE * fp,
int cursor, const struct poptOption * opt,
/*@null@*/ const char * translation_domain)
/*@globals fileSystem @*/
/*@modifies *fp, fileSystem @*/
{
/*@-branchstate@*/ /* FIX: W2DO? */
if (opt != NULL)
for (; (opt->longName || opt->shortName || opt->arg) ; opt++) {
if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INTL_DOMAIN) {
translation_domain = (const char *)opt->arg;
} else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) {
if (opt->arg) /* XXX program error */
cursor = singleTableUsage(con, fp, cursor, opt->arg,
translation_domain);
} else if ((opt->longName || opt->shortName) &&
!(opt->argInfo & POPT_ARGFLAG_DOC_HIDDEN)) {
cursor = singleOptionUsage(fp, cursor, opt, translation_domain);
}
}
/*@=branchstate@*/
return cursor;
}
/**
* Return concatenated short options for display.
* @param opt option(s)
* @param fp output file handle
* @retval str concatenation of short options
* @return length of display string
*/
static int showShortOptions(const struct poptOption * opt, FILE * fp,
/*@null@*/ char * str)
/*@globals fileSystem @*/
/*@modifies *str, *fp, fileSystem @*/
{
char * s = alloca(300); /* larger then the ascii set */
s[0] = '\0';
/*@-branchstate@*/ /* FIX: W2DO? */
if (str == NULL) {
memset(s, 0, sizeof(s));
str = s;
}
/*@=branchstate@*/
if (opt != NULL)
for (; (opt->longName || opt->shortName || opt->arg); opt++) {
if (opt->shortName && !(opt->argInfo & POPT_ARG_MASK))
str[strlen(str)] = opt->shortName;
else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE)
if (opt->arg) /* XXX program error */
(void) showShortOptions(opt->arg, fp, str);
}
if (s != str || *s != '\0')
return 0;
fprintf(fp, " [-%s]", s);
return strlen(s) + 4;
}
void poptPrintUsage(poptContext con, FILE * fp, /*@unused@*/ UNUSED(int flags))
{
int cursor;
cursor = showHelpIntro(con, fp);
cursor += showShortOptions(con->options, fp, NULL);
(void) singleTableUsage(con, fp, cursor, con->options, NULL);
(void) itemUsage(fp, cursor, con->aliases, con->numAliases, NULL);
(void) itemUsage(fp, cursor, con->execs, con->numExecs, NULL);
if (con->otherHelp) {
cursor += strlen(con->otherHelp) + 1;
if (cursor > 79) fprintf(fp, "\n ");
fprintf(fp, " %s", con->otherHelp);
}
fprintf(fp, "\n");
}
void poptSetOtherOptionHelp(poptContext con, const char * text)
{
con->otherHelp = _free(con->otherHelp);
con->otherHelp = xstrdup(text);
}
/*@=type@*/

96
popt/poptint.h Normal file
View File

@@ -0,0 +1,96 @@
/** \ingroup popt
* \file popt/poptint.h
*/
/* (C) 1998-2000 Red Hat, Inc. -- Licensing details are in the COPYING
file accompanying popt source distributions, available from
ftp://ftp.rpm.org/pub/rpm/dist. */
#ifndef H_POPTINT
#define H_POPTINT
/**
* Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
* @param p memory to free
* @retval NULL always
*/
/*@unused@*/ static inline /*@null@*/ void *
_free(/*@only@*/ /*@null@*/ const void * p)
/*@modifies p @*/
{
if (p != NULL) free((void *)p);
return NULL;
}
/* Bit mask macros. */
typedef unsigned int __pbm_bits;
#define __PBM_NBITS (8 * sizeof (__pbm_bits))
#define __PBM_IX(d) ((d) / __PBM_NBITS)
#define __PBM_MASK(d) ((__pbm_bits) 1 << (((unsigned)(d)) % __PBM_NBITS))
typedef struct {
__pbm_bits bits[1];
} pbm_set;
#define __PBM_BITS(set) ((set)->bits)
#define PBM_ALLOC(d) calloc(__PBM_IX (d) + 1, sizeof(__pbm_bits))
#define PBM_FREE(s) _free(s);
#define PBM_SET(d, s) (__PBM_BITS (s)[__PBM_IX (d)] |= __PBM_MASK (d))
#define PBM_CLR(d, s) (__PBM_BITS (s)[__PBM_IX (d)] &= ~__PBM_MASK (d))
#define PBM_ISSET(d, s) ((__PBM_BITS (s)[__PBM_IX (d)] & __PBM_MASK (d)) != 0)
struct optionStackEntry {
int argc;
/*@only@*/ /*@null@*/ const char ** argv;
/*@only@*/ /*@null@*/ pbm_set * argb;
int next;
/*@only@*/ /*@null@*/ const char * nextArg;
/*@keep@*/ /*@null@*/ const char * nextCharArg;
/*@dependent@*/ /*@null@*/ poptItem currAlias;
int stuffed;
};
struct poptContext_s {
struct optionStackEntry optionStack[POPT_OPTION_DEPTH];
/*@dependent@*/ struct optionStackEntry * os;
/*@owned@*/ /*@null@*/ const char ** leftovers;
int numLeftovers;
int nextLeftover;
/*@keep@*/ const struct poptOption * options;
int restLeftover;
/*@only@*/ /*@null@*/ const char * appName;
/*@only@*/ /*@null@*/ poptItem aliases;
int numAliases;
int flags;
/*@owned@*/ /*@null@*/ poptItem execs;
int numExecs;
/*@only@*/ /*@null@*/ const char ** finalArgv;
int finalArgvCount;
int finalArgvAlloced;
/*@dependent@*/ /*@null@*/ poptItem doExec;
/*@only@*/ const char * execPath;
int execAbsolute;
/*@only@*/ const char * otherHelp;
/*@null@*/ pbm_set * arg_strip;
};
#ifdef HAVE_LIBINTL_H
#include <libintl.h>
#endif
#if defined(HAVE_GETTEXT) && !defined(__LCLINT__)
#define _(foo) gettext(foo)
#else
#define _(foo) foo
#endif
#if defined(HAVE_DGETTEXT) && !defined(__LCLINT__)
#define D_(dom, str) dgettext(dom, str)
#define POPT_(foo) D_("popt", foo)
#else
#define D_(dom, str) str
#define POPT_(foo) foo
#endif
#define N_(foo) foo
#endif

118
popt/poptparse.c Normal file
View File

@@ -0,0 +1,118 @@
/** \ingroup popt
* \file popt/poptparse.c
*/
/* (C) 1998-2000 Red Hat, Inc. -- Licensing details are in the COPYING
file accompanying popt source distributions, available from
ftp://ftp.rpm.org/pub/rpm/dist. */
#include "system.h"
#define POPT_ARGV_ARRAY_GROW_DELTA 5
int poptDupArgv(int argc, const char **argv,
int * argcPtr, const char *** argvPtr)
{
size_t nb = (argc + 1) * sizeof(*argv);
const char ** argv2;
char * dst;
int i;
if (argc <= 0 || argv == NULL) /* XXX can't happen */
return POPT_ERROR_NOARG;
for (i = 0; i < argc; i++) {
if (argv[i] == NULL)
return POPT_ERROR_NOARG;
nb += strlen(argv[i]) + 1;
}
dst = malloc(nb);
if (dst == NULL) /* XXX can't happen */
return POPT_ERROR_MALLOC;
argv2 = (void *) dst;
dst += (argc + 1) * sizeof(*argv);
/*@-branchstate@*/
for (i = 0; i < argc; i++) {
argv2[i] = dst;
dst += strlen(strcpy(dst, argv[i])) + 1;
}
/*@=branchstate@*/
argv2[argc] = NULL;
if (argvPtr) {
*argvPtr = argv2;
} else {
free(argv2);
argv2 = NULL;
}
if (argcPtr)
*argcPtr = argc;
return 0;
}
int poptParseArgvString(const unsigned char * s, int * argcPtr, const char *** argvPtr)
{
const unsigned char * src;
unsigned char quote = '\0';
int argvAlloced = POPT_ARGV_ARRAY_GROW_DELTA;
const char ** argv = malloc(sizeof(*argv) * argvAlloced);
int argc = 0;
int buflen = strlen(s) + 1;
char * buf = memset(alloca(buflen), 0, buflen);
int rc = POPT_ERROR_MALLOC;
if (argv == NULL) return rc;
argv[argc] = buf;
for (src = s; *src != '\0'; src++) {
if (quote == *src) {
quote = '\0';
} else if (quote != '\0') {
if (*src == '\\') {
src++;
if (!*src) {
rc = POPT_ERROR_BADQUOTE;
goto exit;
}
if (*src != quote) *buf++ = '\\';
}
*buf++ = *src;
} else if (isspace(*src)) {
if (*argv[argc] != '\0') {
buf++, argc++;
if (argc == argvAlloced) {
argvAlloced += POPT_ARGV_ARRAY_GROW_DELTA;
argv = realloc(argv, sizeof(*argv) * argvAlloced);
if (argv == NULL) goto exit;
}
argv[argc] = buf;
}
} else switch (*src) {
case '"':
case '\'':
quote = *src;
/*@switchbreak@*/ break;
case '\\':
src++;
if (!*src) {
rc = POPT_ERROR_BADQUOTE;
goto exit;
}
/*@fallthrough@*/
default:
*buf++ = *src;
/*@switchbreak@*/ break;
}
}
if (strlen(argv[argc])) {
argc++, buf++;
}
rc = poptDupArgv(argc, argv, argcPtr, argvPtr);
exit:
if (argv) free(argv);
return rc;
}

82
popt/system.h Normal file
View File

@@ -0,0 +1,82 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#if HAVE_MCHECK_H
#include <mcheck.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#if !defined(__GNUC__) || defined(APPLE)
/* Apparently the OS X port of gcc gags on __attribute__.
*
* <http://www.opensource.apple.com/bugs/X/gcc/2512150.html> */
#define __attribute__(x)
#endif
#ifdef __NeXT
/* access macros are not declared in non posix mode in unistd.h -
don't try to use posix on NeXTstep 3.3 ! */
#include <libc.h>
#endif
#if defined(__LCLINT__)
/*@-declundef -incondefs -redecl@*/ /* LCL: missing annotation */
/*@only@*/ void * alloca (size_t __size)
/*@ensures MaxSet(result) == (__size - 1) @*/
/*@*/;
/*@=declundef =incondefs =redecl@*/
#endif
/* AIX requires this to be the first thing in the file. */
#ifndef __GNUC__
# if HAVE_ALLOCA_H
# include <alloca.h>
# else
# ifdef _AIX
#pragma alloca
# else
# if HAVE_ALLOCA
# ifndef alloca /* predefined by HP cc +Olibcalls */
char *alloca ();
# endif
# else
# ifdef alloca
# undef alloca
# endif
# define alloca(sz) malloc(sz) /* Kludge this for now */
# endif
# endif
# endif
#elif defined(__GNUC__) && defined(__STRICT_ANSI__)
#define alloca __builtin_alloca
#endif
/*@-redecl -redef@*/
/*@mayexit@*/ /*@only@*/ char * xstrdup (const char *str)
/*@*/;
/*@=redecl =redef@*/
#if HAVE_MCHECK_H && defined(__GNUC__)
#define vmefail() (fprintf(stderr, "virtual memory exhausted.\n"), exit(EXIT_FAILURE), NULL)
#define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail()), (_str)))
#else
#define xstrdup(_str) strdup(_str)
#endif /* HAVE_MCHECK_H && defined(__GNUC__) */
#define UNUSED(x) x __attribute__((__unused__))
#include "popt.h"

176
progress.c Normal file
View File

@@ -0,0 +1,176 @@
/* -*- c-file-style: "linux" -*-
*
* Copyright (C) 1996-2000 by Andrew Tridgell
* Copyright (C) Paul Mackerras 1996
* Copyright (C) 2001, 2002 by Martin Pool <mbp@samba.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "rsync.h"
extern struct stats stats;
extern int am_server;
#define PROGRESS_HISTORY_SECS 5
#ifdef GETPGRP_VOID
#define GETPGRP_ARG
#else
#define GETPGRP_ARG 0
#endif
struct progress_history {
struct timeval time;
OFF_T ofs;
};
static struct progress_history ph_start;
static struct progress_history ph_list[PROGRESS_HISTORY_SECS];
static int newest_hpos, oldest_hpos;
static unsigned long msdiff(struct timeval *t1, struct timeval *t2)
{
return (t2->tv_sec - t1->tv_sec) * 1000L
+ (t2->tv_usec - t1->tv_usec) / 1000;
}
/**
* @param ofs Current position in file
* @param size Total size of file
* @param is_last True if this is the last time progress will be
* printed for this file, so we should output a newline. (Not
* necessarily the same as all bytes being received.)
**/
static void rprint_progress(OFF_T ofs, OFF_T size, struct timeval *now,
int is_last)
{
char eol[256];
const char *units;
int pct = ofs == size ? 100 : (int) (100.0 * ofs / size);
unsigned long diff;
double rate, remain;
int remain_h, remain_m, remain_s;
if (is_last) {
/* Compute stats based on the starting info. */
if (!ph_start.time.tv_sec
|| !(diff = msdiff(&ph_start.time, now)))
diff = 1;
rate = (double) (ofs - ph_start.ofs) * 1000.0 / diff / 1024.0;
/* Switch to total time taken for our last update. */
remain = (double) diff / 1000.0;
} else {
/* Compute stats based on recent progress. */
if (!(diff = msdiff(&ph_list[oldest_hpos].time, now)))
diff = 1;
rate = (double) (ofs - ph_list[oldest_hpos].ofs) * 1000.0
/ diff / 1024.0;
remain = rate ? (double) (size - ofs) / rate / 1000.0 : 0.0;
}
if (rate > 1024*1024) {
rate /= 1024.0 * 1024.0;
units = "GB/s";
} else if (rate > 1024) {
rate /= 1024.0;
units = "MB/s";
} else {
units = "kB/s";
}
remain_s = (int) remain % 60;
remain_m = (int) (remain / 60.0) % 60;
remain_h = (int) (remain / 3600.0);
if (is_last) {
snprintf(eol, sizeof eol, " (%d, %.1f%% of %d)\n",
stats.num_transferred_files,
(float)((stats.current_file_index+1) * 100)
/ stats.num_files,
stats.num_files);
} else
strcpy(eol, "\r");
rprintf(FINFO, "%12.0f %3d%% %7.2f%s %4d:%02d:%02d%s",
(double) ofs, pct, rate, units,
remain_h, remain_m, remain_s, eol);
}
void end_progress(OFF_T size)
{
if (!am_server) {
struct timeval now;
gettimeofday(&now, NULL);
rprint_progress(size, size, &now, True);
}
memset(&ph_start, 0, sizeof ph_start);
}
void show_progress(OFF_T ofs, OFF_T size)
{
struct timeval now;
#if defined HAVE_GETPGRP && defined HAVE_TCGETPGRP
static pid_t pgrp = -1;
pid_t tc_pgrp;
#endif
if (am_server)
return;
#if defined HAVE_GETPGRP && defined HAVE_TCGETPGRP
if (pgrp == -1)
pgrp = getpgrp(GETPGRP_ARG);
#endif
gettimeofday(&now, NULL);
if (!ph_start.time.tv_sec) {
int i;
/* Try to guess the real starting time when the sender started
* to send us data by using the time we last received some data
* in the last file (if it was recent enough). */
if (msdiff(&ph_list[newest_hpos].time, &now) <= 1500) {
ph_start.time = ph_list[newest_hpos].time;
ph_start.ofs = 0;
} else {
ph_start.time.tv_sec = now.tv_sec;
ph_start.time.tv_usec = now.tv_usec;
ph_start.ofs = ofs;
}
for (i = 0; i < PROGRESS_HISTORY_SECS; i++)
ph_list[i] = ph_start;
}
else {
if (msdiff(&ph_list[newest_hpos].time, &now) < 1000)
return;
newest_hpos = oldest_hpos;
oldest_hpos = (oldest_hpos + 1) % PROGRESS_HISTORY_SECS;
ph_list[newest_hpos].time.tv_sec = now.tv_sec;
ph_list[newest_hpos].time.tv_usec = now.tv_usec;
ph_list[newest_hpos].ofs = ofs;
}
#if defined HAVE_GETPGRP && defined HAVE_TCGETPGRP
tc_pgrp = tcgetpgrp(STDOUT_FILENO);
if (tc_pgrp != pgrp && tc_pgrp != -1)
return;
#endif
rprint_progress(ofs, size, &now, False);
}

View File

File diff suppressed because it is too large Load Diff

320
rsync.c
View File

@@ -1,17 +1,17 @@
/*
/*
Copyright (C) Andrew Tridgell 1996
Copyright (C) Paul Mackerras 1996
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -24,13 +24,20 @@
extern int verbose;
extern int dry_run;
extern int daemon_log_format_has_i;
extern int preserve_times;
extern int omit_dir_times;
extern int am_root;
extern int am_server;
extern int am_sender;
extern int am_generator;
extern int am_starting_up;
extern int preserve_uid;
extern int preserve_gid;
extern int preserve_perms;
extern int inplace;
extern int keep_dirlinks;
extern int make_backups;
extern char *backup_suffix;
extern struct stats stats;
/*
@@ -43,185 +50,102 @@ void free_sums(struct sum_struct *s)
}
/*
* delete a file or directory. If force_delet is set then delete
* recursively
*/
int delete_file(char *fname)
{
DIR *d;
struct dirent *di;
char buf[MAXPATHLEN];
extern int force_delete;
STRUCT_STAT st;
int ret;
extern int recurse;
if (robust_unlink(fname) == 0 || errno == ENOENT) return 0;
#if SUPPORT_LINKS
ret = do_lstat(fname, &st);
#else
ret = do_stat(fname, &st);
#endif
if (ret) {
rprintf(FERROR,"stat(%s) : %s\n", fname, strerror(errno));
return -1;
}
if (!S_ISDIR(st.st_mode)) {
rprintf(FERROR,"unlink(%s) : %s\n", fname, strerror(errno));
return -1;
}
if (do_rmdir(fname) == 0 || errno == ENOENT) return 0;
if (!force_delete || !recurse ||
(errno != ENOTEMPTY && errno != EEXIST)) {
rprintf(FERROR,"rmdir(%s) : %s\n", fname, strerror(errno));
return -1;
}
/* now we do a recsursive delete on the directory ... */
d = opendir(fname);
if (!d) {
rprintf(FERROR,"opendir(%s): %s\n",
fname,strerror(errno));
return -1;
}
for (di=readdir(d); di; di=readdir(d)) {
char *dname = d_name(di);
if (strcmp(dname,".")==0 ||
strcmp(dname,"..")==0)
continue;
slprintf(buf, sizeof(buf), "%s/%s", fname, dname);
if (verbose > 0)
rprintf(FINFO,"deleting %s\n", buf);
if (delete_file(buf) != 0) {
closedir(d);
return -1;
}
}
closedir(d);
if (do_rmdir(fname) != 0) {
rprintf(FERROR,"rmdir(%s) : %s\n", fname, strerror(errno));
return -1;
}
return 0;
}
static int is_in_group(gid_t gid)
{
#ifdef GETGROUPS_T
static gid_t last_in = (gid_t) -2, last_out;
static int ngroups = -2;
static GETGROUPS_T *gidset;
int n;
if (gid == last_in)
return last_out;
if (ngroups < -1) {
/* treat failure (-1) as if not member of any group */
ngroups = getgroups(0, 0);
if (ngroups > 0) {
gidset = (GETGROUPS_T *) malloc(ngroups * sizeof(GETGROUPS_T));
ngroups = getgroups(ngroups, gidset);
}
}
last_in = gid;
last_out = 0;
for (n = 0; n < ngroups; n++) {
if (gidset[n] == gid) {
last_out = 1;
break;
}
}
return last_out;
#else
return 0;
#endif
}
int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st,
int report)
int flags)
{
int updated = 0;
STRUCT_STAT st2;
int change_uid, change_gid;
extern int am_daemon;
if (dry_run) return 0;
if (!st) {
if (link_stat(fname,&st2) != 0) {
rprintf(FERROR,"stat %s : %s\n",fname,strerror(errno));
if (dry_run)
return 1;
if (link_stat(fname, &st2, 0) < 0) {
rsyserr(FERROR, errno, "stat %s failed",
full_fname(fname));
return 0;
}
st = &st2;
}
if (preserve_times && !S_ISLNK(st->st_mode) &&
st->st_mtime != file->modtime) {
/* don't complain about not setting times on directories
because some filesystems can't do it */
if (set_modtime(fname,file->modtime) != 0 &&
!S_ISDIR(st->st_mode)) {
rprintf(FERROR,"failed to set times on %s : %s\n",
fname,strerror(errno));
if (!preserve_times || (S_ISDIR(st->st_mode) && omit_dir_times))
flags |= PERMS_SKIP_MTIME;
if (!(flags & PERMS_SKIP_MTIME)
&& cmp_modtime(st->st_mtime, file->modtime) != 0) {
int ret = set_modtime(fname, file->modtime, st->st_mode);
if (ret < 0) {
rsyserr(FERROR, errno, "failed to set times on %s",
full_fname(fname));
return 0;
} else {
updated = 1;
}
if (ret == 0) /* ret == 1 if symlink could not be set */
updated = 1;
}
change_uid = am_root && preserve_uid && st->st_uid != file->uid;
change_gid = !am_daemon && preserve_gid && file->gid != (gid_t) -1 && \
st->st_gid != file->gid;
if (change_gid && !am_root) {
/* enforce bsd-style group semantics: non-root can only
change to groups that the user is a member of */
change_gid = is_in_group(file->gid);
}
change_gid = preserve_gid && file->gid != GID_NONE
&& st->st_gid != file->gid;
#if !defined HAVE_LCHOWN && !defined CHOWN_MODIFIES_SYMLINK
if (S_ISLNK(st->st_mode))
;
else
#endif
if (change_uid || change_gid) {
if (verbose > 2) {
if (change_uid) {
rprintf(FINFO,
"set uid of %s from %ld to %ld\n",
safe_fname(fname),
(long)st->st_uid, (long)file->uid);
}
if (change_gid) {
rprintf(FINFO,
"set gid of %s from %ld to %ld\n",
safe_fname(fname),
(long)st->st_gid, (long)file->gid);
}
}
if (do_lchown(fname,
change_uid?file->uid:st->st_uid,
change_gid?file->gid:st->st_gid) != 0) {
change_uid ? file->uid : st->st_uid,
change_gid ? file->gid : st->st_gid) != 0) {
/* shouldn't have attempted to change uid or gid
unless have the privilege */
rprintf(FERROR,"chown %s : %s\n", fname,strerror(errno));
* unless have the privilege */
rsyserr(FERROR, errno, "%s %s failed",
change_uid ? "chown" : "chgrp",
full_fname(fname));
return 0;
}
/* a lchown had been done - we have to re-stat if the
* destination had the setuid or setgid bits set due
* to the side effect of the chown call */
if (st->st_mode & (S_ISUID | S_ISGID)) {
link_stat(fname, st,
keep_dirlinks && S_ISDIR(st->st_mode));
}
updated = 1;
}
#ifdef HAVE_CHMOD
if (!S_ISLNK(st->st_mode)) {
int file_mode;
if (preserve_perms)
file_mode = file->mode;
else
file_mode = file->mode & ACCESSPERMS;
if (st->st_mode != file->mode) {
updated = 1;
if (do_chmod(fname,file_mode) != 0) {
rprintf(FERROR,"failed to set permissions on %s : %s\n",
fname,strerror(errno));
return 0;
}
if ((st->st_mode & CHMOD_BITS) != (file->mode & CHMOD_BITS)) {
int ret = do_chmod(fname, file->mode);
if (ret < 0) {
rsyserr(FERROR, errno,
"failed to set permissions on %s",
full_fname(fname));
return 0;
}
if (ret == 0) /* ret == 1 if symlink could not be set */
updated = 1;
}
#endif
if (verbose > 1 && report) {
if (verbose > 1 && flags & PERMS_REPORT) {
enum logcode code = daemon_log_format_has_i || dry_run
? FCLIENT : FINFO;
if (updated)
rprintf(FINFO,"%s\n",fname);
rprintf(code, "%s\n", safe_fname(fname));
else
rprintf(FINFO,"%s is uptodate\n",fname);
rprintf(code, "%s is uptodate\n", safe_fname(fname));
}
return updated;
}
@@ -229,58 +153,62 @@ int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st,
void sig_int(void)
{
/* KLUGE: if the user hits Ctrl-C while ssh is prompting
* for a password, then our cleanup's sending of a SIGUSR1
* signal to all our children may kill ssh before it has a
* chance to restore the tty settings (i.e. turn echo back
* on). By sleeping for a short time, ssh gets a bigger
* chance to do the right thing. If child processes are
* not ssh waiting for a password, then this tiny delay
* shouldn't hurt anything. */
msleep(400);
exit_cleanup(RERR_SIGNAL);
}
int make_backup(char *fname)
{
char fnamebak[MAXPATHLEN];
if (strlen(fname) + strlen(backup_suffix) > (MAXPATHLEN-1)) {
rprintf(FERROR,"backup filename too long\n");
return 0;
}
slprintf(fnamebak,sizeof(fnamebak),"%s%s",fname,backup_suffix);
if (do_rename(fname,fnamebak) != 0) {
/* cygwin (at least version b19) reports EINVAL */
if (errno != ENOENT && errno != EINVAL) {
rprintf(FERROR,"rename %s %s : %s\n",fname,fnamebak,strerror(errno));
return 0;
}
} else if (verbose > 1) {
rprintf(FINFO,"backed up %s to %s\n",fname,fnamebak);
}
return 1;
}
/* finish off a file transfer, renaming the file and setting the permissions
and ownership */
void finish_transfer(char *fname, char *fnametmp, struct file_struct *file)
void finish_transfer(char *fname, char *fnametmp, struct file_struct *file,
int ok_to_set_time, int overwriting_basis)
{
if (make_backups && !make_backup(fname))
int ret;
if (inplace) {
if (verbose > 2)
rprintf(FINFO, "finishing %s\n", safe_fname(fname));
goto do_set_perms;
}
if (make_backups && overwriting_basis && !make_backup(fname))
return;
/* Change permissions before putting the file into place. */
set_perms(fnametmp, file, NULL, ok_to_set_time ? 0 : PERMS_SKIP_MTIME);
/* move tmp file over real file */
if (robust_rename(fnametmp,fname) != 0) {
if (errno == EXDEV) {
/* rename failed on cross-filesystem link.
Copy the file instead. */
if (copy_file(fnametmp,fname, file->mode & INITACCESSPERMS)) {
rprintf(FERROR,"copy %s -> %s : %s\n",
fnametmp,fname,strerror(errno));
} else {
set_perms(fname,file,NULL,0);
}
} else {
rprintf(FERROR,"rename %s -> %s : %s\n",
fnametmp,fname,strerror(errno));
}
do_unlink(fnametmp);
} else {
set_perms(fname,file,NULL,0);
if (verbose > 2) {
rprintf(FINFO, "renaming %s to %s\n",
safe_fname(fnametmp), safe_fname(fname));
}
ret = robust_rename(fnametmp, fname, file->mode & INITACCESSPERMS);
if (ret < 0) {
rsyserr(FERROR, errno, "%s %s -> \"%s\"",
ret == -2 ? "copy" : "rename",
full_fname(fnametmp), safe_fname(fname));
do_unlink(fnametmp);
return;
}
if (ret == 0) {
/* The file was moved into place (not copied), so it's done. */
return;
}
do_set_perms:
set_perms(fname, file, NULL, ok_to_set_time ? 0 : PERMS_SKIP_MTIME);
}
const char *who_am_i(void)
{
if (am_starting_up)
return am_server ? "server" : "client";
return am_sender ? "sender" : am_generator ? "generator" : "receiver";
}

664
rsync.h
View File

@@ -1,30 +1,34 @@
/*
Copyright (C) Andrew Tridgell 1996
/*
Copyright (C) by Andrew Tridgell 1996, 2000
Copyright (C) Paul Mackerras 1996
Copyright (C) 2001, 2002 by Martin Pool <mbp@samba.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#define False 0
#define True 1
#define BLOCK_SIZE 700
#define RSYNC_RSH_ENV "RSYNC_RSH"
#define RSYNC_RSH_IO_ENV "RSYNC_RSH_IO"
#define RSYNC_NAME "rsync"
#define RSYNCD_CONF "/etc/rsyncd.conf"
/* RSYNCD_SYSCONF is now set in config.h */
#define RSYNCD_USERCONF "rsyncd.conf"
#define DEFAULT_LOCK_FILE "/var/run/rsyncd.lock"
#define URL_PREFIX "rsync://"
@@ -35,21 +39,55 @@
incompatible with older versions :-( */
#define CHAR_OFFSET 0
/* These flags are only used during the flist transfer. */
#define FLAG_DELETE (1<<0)
#define SAME_MODE (1<<1)
#define SAME_RDEV (1<<2)
#define SAME_UID (1<<3)
#define SAME_GID (1<<4)
#define SAME_DIR (1<<5)
#define SAME_NAME SAME_DIR
#define LONG_NAME (1<<6)
#define SAME_TIME (1<<7)
#define XMIT_TOP_DIR (1<<0)
#define XMIT_SAME_MODE (1<<1)
#define XMIT_EXTENDED_FLAGS (1<<2)
#define XMIT_SAME_RDEV_pre28 XMIT_EXTENDED_FLAGS /* Only in protocols < 28 */
#define XMIT_SAME_UID (1<<3)
#define XMIT_SAME_GID (1<<4)
#define XMIT_SAME_NAME (1<<5)
#define XMIT_LONG_NAME (1<<6)
#define XMIT_SAME_TIME (1<<7)
#define XMIT_SAME_RDEV_MAJOR (1<<8)
#define XMIT_HAS_IDEV_DATA (1<<9)
#define XMIT_SAME_DEV (1<<10)
#define XMIT_RDEV_MINOR_IS_SMALL (1<<11)
/* These flags are used in the live flist data. */
#define FLAG_TOP_DIR (1<<0)
#define FLAG_HLINK_EOL (1<<1) /* receiver/generator */
#define FLAG_MOUNT_POINT (1<<2) /* sender */
#define FLAG_NO_FUZZY (1<<2) /* generator */
#define FLAG_DEL_HERE (1<<3) /* receiver/generator */
#define FLAG_SENT (1<<3) /* sender */
#define FLAG_HLINK_TOL (1<<4) /* receiver/generator */
/* update this if you make incompatible changes */
#define PROTOCOL_VERSION 20
#define MIN_PROTOCOL_VERSION 11
#define MAX_PROTOCOL_VERSION 30
#define PROTOCOL_VERSION 29
/* We refuse to interoperate with versions that are not in this range.
* Note that we assume we'll work with later versions: the onus is on
* people writing them to make sure that they don't send us anything
* we won't understand.
*
* Interoperation with old but supported protocol versions
* should cause a warning to be printed. At a future date
* the old protocol will become the minimum and
* compatibility code removed.
*
* There are two possible explanations for the limit at
* MAX_PROTOCOL_VERSION: either to allow new major-rev versions that
* do not interoperate with us, and (more likely) so that we can
* detect an attempt to connect rsync to a non-rsync server, which is
* unlikely to begin by sending a byte between MIN_PROTOCL_VERSION and
* MAX_PROTOCOL_VERSION. */
#define MIN_PROTOCOL_VERSION 20
#define OLD_PROTOCOL_VERSION 25
#define MAX_PROTOCOL_VERSION 40
#define RSYNC_PORT 873
@@ -58,59 +96,132 @@
#define CHUNK_SIZE (32*1024)
#define MAX_MAP_SIZE (256*1024)
#define IO_BUFFER_SIZE (4092)
#define MAX_READ_BUFFER (1024*1024)
#define MAX_BLOCK_SIZE ((int32)1 << 29)
#define IOERR_GENERAL (1<<0) /* For backward compatibility, this must == 1 */
#define IOERR_VANISHED (1<<1)
#define IOERR_DEL_LIMIT (1<<2)
#define MAX_ARGS 1000
#define MAX_BASIS_DIRS 20
#define MAX_SERVER_ARGS (MAX_BASIS_DIRS*2 + 100)
#define MPLEX_BASE 7
#define FERROR 1
#define FINFO 2
#define FLOG 3
#define NO_FILTERS 0
#define SERVER_FILTERS 1
#define ALL_FILTERS 2
#define XFLG_FATAL_ERRORS (1<<0)
#define XFLG_OLD_PREFIXES (1<<1)
#define XFLG_ANCHORED2ABS (1<<2)
#define PERMS_REPORT (1<<0)
#define PERMS_SKIP_MTIME (1<<1)
#define FULL_FLUSH 1
#define NORMAL_FLUSH 0
#define PDIR_CREATE 1
#define PDIR_DELETE 0
/* Note: 0x00 - 0x7F are used for basis_dir[] indexes! */
#define FNAMECMP_BASIS_DIR_LOW 0x00 /* Must remain 0! */
#define FNAMECMP_BASIS_DIR_HIGH 0x7F
#define FNAMECMP_FNAME 0x80
#define FNAMECMP_PARTIAL_DIR 0x81
#define FNAMECMP_BACKUP 0x82
#define FNAMECMP_FUZZY 0x83
/* For calling delete_file() */
#define DEL_NO_RECURSE (1<<1)
#define DEL_FORCE_RECURSE (1<<2) /* recurse even w/o --force */
#define DEL_TERSE (1<<3)
/* For use by the itemize_changes code */
#define ITEM_REPORT_CHECKSUM (1<<1)
#define ITEM_REPORT_SIZE (1<<2)
#define ITEM_REPORT_TIME (1<<3)
#define ITEM_REPORT_PERMS (1<<4)
#define ITEM_REPORT_OWNER (1<<5)
#define ITEM_REPORT_GROUP (1<<6)
#define ITEM_REPORT_XATTRS (1<<7)
#define ITEM_BASIS_TYPE_FOLLOWS (1<<11)
#define ITEM_XNAME_FOLLOWS (1<<12)
#define ITEM_IS_NEW (1<<13)
#define ITEM_LOCAL_CHANGE (1<<14)
#define ITEM_TRANSFER (1<<15)
/* These are outside the range of the transmitted flags. */
#define ITEM_NO_DEST_AND_NO_UPDATE (1<<16) /* used by itemize() */
#define ITEM_MISSING_DATA (1<<16) /* used by log_formatted() */
#define ITEM_DELETED (1<<17) /* used by log_formatted() */
#define SIGNIFICANT_ITEM_FLAGS (~(\
ITEM_BASIS_TYPE_FOLLOWS | ITEM_XNAME_FOLLOWS | ITEM_LOCAL_CHANGE))
/* Log-message categories. FLOG and FCLIENT are only used on the daemon
* side for custom logging -- they don't get sent over the socket. */
enum logcode { FERROR=1, FINFO=2, FLOG=3, FCLIENT=4 };
/* Messages types that are sent over the message channel. The logcode
* values must all be present here with identical numbers. */
enum msgcode {
MSG_DATA=0, /* raw data on the multiplexed stream */
MSG_ERROR=FERROR, MSG_INFO=FINFO, /* remote logging */
MSG_LOG=FLOG, MSG_FCLIENT=FCLIENT, /* sibling logging */
MSG_REDO=9, /* reprocess indicated flist index */
MSG_SUCCESS=100,/* successfully updated indicated flist index */
MSG_DELETED=101,/* successfully deleted a file on receiving side */
MSG_DONE=86 /* current phase is done */
};
#include "errcode.h"
#include "config.h"
#if HAVE_REMSH
#define RSYNC_RSH "remsh"
#else
#define RSYNC_RSH "rsh"
#endif
/* The default RSYNC_RSH is always set in config.h. */
#include <sys/types.h>
#ifdef HAVE_GETOPT_LONG
#include <getopt.h>
#else
#include "lib/getopt.h"
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <stdio.h>
#include <stddef.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#ifdef STDC_HEADERS
# include <stdlib.h>
# include <stddef.h>
#else
# ifdef HAVE_STDLIB_H
# include <stdlib.h>
# endif
#endif
#ifdef HAVE_STRING_H
# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
# include <memory.h>
# endif
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#if defined HAVE_MALLOC_H && (defined HAVE_MALLINFO || !defined HAVE_STDLIB_H)
#include <malloc.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
#ifdef TIME_WITH_SYS_TIME
#include <sys/time.h>
#include <time.h>
@@ -130,8 +241,6 @@
#endif
#endif
#include <sys/stat.h>
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
@@ -167,12 +276,6 @@
#endif
#endif
#ifdef HAVE_FNMATCH
#include <fnmatch.h>
#else
#include "lib/fnmatch.h"
#endif
#ifdef HAVE_GLOB_H
#include <glob.h>
#endif
@@ -188,25 +291,37 @@
#include <syslog.h>
#include <sys/file.h>
#if HAVE_DIRENT_H
#ifdef HAVE_DIRENT_H
# include <dirent.h>
#else
# define dirent direct
# if HAVE_SYS_NDIR_H
# ifdef HAVE_SYS_NDIR_H
# include <sys/ndir.h>
# endif
# if HAVE_SYS_DIR_H
# ifdef HAVE_SYS_DIR_H
# include <sys/dir.h>
# endif
# if HAVE_NDIR_H
# ifdef HAVE_NDIR_H
# include <ndir.h>
# endif
#endif
#ifdef MAJOR_IN_MKDEV
#include <sys/mkdev.h>
# if !defined makedev && (defined mkdev || defined _WIN32 || defined __WIN32__)
# define makedev mkdev
# endif
#elif defined MAJOR_IN_SYSMACROS
#include <sys/sysmacros.h>
#endif
#ifdef HAVE_COMPAT_H
#include <compat.h>
#endif
#include <assert.h>
#include "lib/pool_alloc.h"
#define BOOL int
@@ -214,56 +329,117 @@
#define uchar unsigned char
#endif
#if HAVE_UNSIGNED_CHAR
#ifdef SIGNED_CHAR_OK
#define schar signed char
#else
#define schar char
#endif
/* Find a variable that is either exactly 32-bits or longer.
* If some code depends on 32-bit truncation, it will need to
* take special action in a "#if SIZEOF_INT32 > 4" section. */
#ifndef int32
#if (SIZEOF_INT == 4)
#define int32 int
#elif (SIZEOF_LONG == 4)
#define int32 long
#elif (SIZEOF_SHORT == 4)
#define int32 short
#if SIZEOF_INT == 4
# define int32 int
# define SIZEOF_INT32 4
#elif SIZEOF_LONG == 4
# define int32 long
# define SIZEOF_INT32 4
#elif SIZEOF_SHORT == 4
# define int32 short
# define SIZEOF_INT32 4
#elif SIZEOF_INT > 4
# define int32 int
# define SIZEOF_INT32 SIZEOF_INT
#elif SIZEOF_LONG > 4
# define int32 long
# define SIZEOF_INT32 SIZEOF_LONG
#else
/* I hope this works */
#define int32 int
#define LARGE_INT32
# error Could not find a 32-bit integer variable
#endif
#else
# define SIZEOF_INT32 4
#endif
#ifndef uint32
#define uint32 unsigned int32
#endif
#if HAVE_OFF64_T
#define OFF_T off64_t
#define STRUCT_STAT struct stat64
#else
#if SIZEOF_OFF_T == 8 || !SIZEOF_OFF64_T || !defined HAVE_STRUCT_STAT64
#define OFF_T off_t
#define STRUCT_STAT struct stat
#else
#define OFF_T off64_t
#define STRUCT_STAT struct stat64
#define USE_STAT64_FUNCS 1
#endif
#if HAVE_OFF64_T
#define int64 off64_t
#elif (SIZEOF_LONG == 8)
#define int64 long
#elif (SIZEOF_INT == 8)
#define int64 int
#elif HAVE_LONGLONG
#define int64 long long
/* CAVEAT: on some systems, int64 will really be a 32-bit integer IFF
* that's the maximum size the file system can handle and there is no
* 64-bit type available. The rsync source must therefore take steps
* to ensure that any code that really requires a 64-bit integer has
* it (e.g. the checksum code uses two 32-bit integers for its 64-bit
* counter). */
#if SIZEOF_OFF64_T == 8
# define int64 off64_t
# define SIZEOF_INT64 8
#elif SIZEOF_LONG == 8
# define int64 long
# define SIZEOF_INT64 8
#elif SIZEOF_INT == 8
# define int64 int
# define SIZEOF_INT64 8
#elif SIZEOF_LONG_LONG == 8
# define int64 long long
# define SIZEOF_INT64 8
#elif SIZEOF_OFF_T == 8
# define int64 off_t
# define SIZEOF_INT64 8
#elif SIZEOF_INT > 8
# define int64 int
# define SIZEOF_INT64 SIZEOF_INT
#elif SIZEOF_LONG > 8
# define int64 long
# define SIZEOF_INT64 SIZEOF_LONG
#elif SIZEOF_LONG_LONG > 8
# define int64 long long
# define SIZEOF_INT64 SIZEOF_LONG_LONG
#else
#define int64 off_t
#define NO_INT64
/* As long as it gets... */
# define int64 off_t
# define SIZEOF_INT64 SIZEOF_OFF_T
#endif
#if HAVE_SHORT_INO_T
#define INO_T uint32
#else
#define INO_T ino_t
#endif
/* Starting from protocol version 26, we always use 64-bit
* ino_t and dev_t internally, even if this platform does not
* allow files to have 64-bit inums. That's because the
* receiver needs to find duplicate (dev,ino) tuples to detect
* hardlinks, and it might have files coming from a platform
* that has 64-bit inums.
*
* The only exception is if we're on a platform with no 64-bit type at
* all.
*
* Because we use read_longint() to get these off the wire, if you
* transfer devices or hardlinks with dev or inum > 2**32 to a machine
* with no 64-bit types then you will get an overflow error. Probably
* not many people have that combination of machines, and you can
* avoid it by not preserving hardlinks or not transferring device
* nodes. It's not clear that any other behaviour is better.
*
* Note that if you transfer devices from a 64-bit-devt machine (say,
* Solaris) to a 32-bit-devt machine (say, Linux-2.2/x86) then the
* device numbers will be truncated. But it's a kind of silly thing
* to do anyhow.
*
* FIXME: I don't think the code in flist.c has ever worked on a system
* where dev_t is a struct.
*/
struct idev {
int64 inode;
int64 dev;
};
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
@@ -280,69 +456,164 @@
/* the length of the md4 checksum */
#define MD4_SUM_LENGTH 16
#define SUM_LENGTH 16
#define SHORT_SUM_LENGTH 2
#define BLOCKSUM_BIAS 10
#ifndef MAXPATHLEN
#define MAXPATHLEN 1024
#endif
#ifndef NAME_MAX
#define NAME_MAX 255
#endif
#ifndef INADDR_NONE
#define INADDR_NONE 0xffffffff
#endif
#ifndef IN_LOOPBACKNET
#define IN_LOOPBACKNET 127
#endif
#define GID_NONE ((gid_t)-1)
#define HL_CHECK_MASTER 0
#define HL_SKIP 1
struct hlink {
int next;
int hlindex;
};
#define F_DEV link_u.idev->dev
#define F_INODE link_u.idev->inode
#define F_HLINDEX link_u.links->hlindex
#define F_NEXT link_u.links->next
struct file_struct {
unsigned flags;
time_t modtime;
union {
dev_t rdev; /* The device number, if this is a device */
char *sum; /* Only a normal file can have a checksum */
char *link; /* Points to symlink string, if a symlink */
} u;
OFF_T length;
mode_t mode;
INO_T inode;
dev_t dev;
dev_t rdev;
char *basename; /* The current item's name (AKA filename) */
char *dirname; /* The directory info inside the transfer */
union {
char *root; /* Sender-side dir info outside transfer */
int depth; /* Receiver-side directory depth info */
} dir;
union {
struct idev *idev;
struct hlink *links;
} link_u;
time_t modtime;
uid_t uid;
gid_t gid;
char *basename;
char *dirname;
char *basedir;
char *link;
char *sum;
mode_t mode;
uchar flags; /* this item MUST remain last */
};
/*
* Start the flist array at FLIST_START entries and grow it
* by doubling until FLIST_LINEAR then grow by FLIST_LINEAR
*/
#define FLIST_START (32 * 1024)
#define FLIST_LINEAR (FLIST_START * 512)
/*
* Extent size for allocation pools A minimum size of 128KB
* is needed to mmap them so that freeing will release the
* space to the OS.
*
* Larger sizes reduce leftover fragments and speed free calls
* (when they happen) Smaller sizes increase the chance of
* freed allocations freeing whole extents.
*/
#define FILE_EXTENT (256 * 1024)
#define HLINK_EXTENT (128 * 1024)
#define WITH_HLINK 1
#define WITHOUT_HLINK 0
struct file_list {
struct file_struct **files;
alloc_pool_t file_pool;
alloc_pool_t hlink_pool;
int count;
int malloced;
struct file_struct **files;
int low, high;
};
#define SUMFLG_SAME_OFFSET (1<<0)
struct sum_buf {
OFF_T offset; /* offset in file of this chunk */
int len; /* length of chunk of file */
int i; /* index of this chunk */
uint32 sum1; /* simple checksum */
char sum2[SUM_LENGTH]; /* checksum */
OFF_T offset; /**< offset in file of this chunk */
int32 len; /**< length of chunk of file */
uint32 sum1; /**< simple checksum */
short flags; /**< flag bits */
char sum2[SUM_LENGTH]; /**< checksum */
};
struct sum_struct {
OFF_T flength; /* total file length */
int count; /* how many chunks */
int remainder; /* flength % block_length */
int n; /* block_length */
struct sum_buf *sums; /* points to info for each chunk */
OFF_T flength; /**< total file length */
struct sum_buf *sums; /**< points to info for each chunk */
int32 count; /**< how many chunks */
int32 blength; /**< block_length */
int32 remainder; /**< flength % block_length */
int s2length; /**< sum2_length */
};
struct map_struct {
char *p;
int fd,p_size,p_len;
OFF_T file_size, p_offset, p_fd_offset;
OFF_T file_size; /* File size (from stat) */
OFF_T p_offset; /* Window start */
OFF_T p_fd_offset; /* offset of cursor in fd ala lseek */
char *p; /* Window pointer */
int32 p_size; /* Largest window size we allocated */
int32 p_len; /* Latest (rounded) window size */
int32 def_window_size; /* Default window size */
int fd; /* File Descriptor */
int status; /* first errno from read errors */
};
struct exclude_struct {
char *orig;
#define MATCHFLG_WILD (1<<0) /* pattern has '*', '[', and/or '?' */
#define MATCHFLG_WILD2 (1<<1) /* pattern has '**' */
#define MATCHFLG_WILD2_PREFIX (1<<2) /* pattern starts with '**' */
#define MATCHFLG_ABS_PATH (1<<3) /* path-match on absolute path */
#define MATCHFLG_INCLUDE (1<<4) /* this is an include, not an exclude */
#define MATCHFLG_DIRECTORY (1<<5) /* this matches only directories */
#define MATCHFLG_CLEAR_LIST (1<<6) /* this item is the "!" token */
#define MATCHFLG_WORD_SPLIT (1<<7) /* split rules on whitespace */
#define MATCHFLG_NO_INHERIT (1<<8) /* don't inherit these rules */
#define MATCHFLG_NO_PREFIXES (1<<9) /* parse no prefixes from patterns */
#define MATCHFLG_MERGE_FILE (1<<10)/* specifies a file to merge */
#define MATCHFLG_PERDIR_MERGE (1<<11)/* merge-file is searched per-dir */
#define MATCHFLG_EXCLUDE_SELF (1<<12)/* merge-file name should be excluded */
#define MATCHFLG_FINISH_SETUP (1<<13)/* per-dir merge file needs setup */
#define MATCHFLG_NEGATE (1<<14)/* rule matches when pattern does not */
#define MATCHFLG_CVS_IGNORE (1<<15)/* rule was -C or :C */
#define MATCHFLG_SENDER_SIDE (1<<16)/* rule applies to the sending side */
#define MATCHFLG_RECEIVER_SIDE (1<<17)/* rule applies to the receiving side */
#define MATCHFLGS_FROM_CONTAINER (MATCHFLG_ABS_PATH | MATCHFLG_INCLUDE \
| MATCHFLG_DIRECTORY | MATCHFLG_SENDER_SIDE \
| MATCHFLG_NEGATE | MATCHFLG_RECEIVER_SIDE)
struct filter_struct {
struct filter_struct *next;
char *pattern;
int regular_exp;
int fnmatch_flags;
int include;
int directory;
int local;
uint32 match_flags;
union {
int slash_cnt;
struct filter_list_struct *mergelist;
} u;
};
struct filter_list_struct {
struct filter_struct *head;
struct filter_struct *tail;
char *debug_type;
};
struct stats {
@@ -352,27 +623,44 @@ struct stats {
int64 total_read;
int64 literal_data;
int64 matched_data;
int64 flist_buildtime;
int64 flist_xfertime;
int flist_size;
int num_files;
int num_transferred_files;
int current_file_index;
};
/* we need this function because of the silly way in which duplicate
entries are handled in the file lists - we can't change this
without breaking existing versions */
static inline int flist_up(struct file_list *flist, int i)
{
while (!flist->files[i]->basename) i++;
return i;
}
#include "byteorder.h"
#include "version.h"
#include "proto.h"
#include "lib/mdfour.h"
#include "lib/wildmatch.h"
#include "lib/permstring.h"
#include "lib/addrinfo.h"
#if !HAVE_STRERROR
#include "proto.h"
/* We have replacement versions of these if they're missing. */
#ifndef HAVE_ASPRINTF
int asprintf(char **ptr, const char *format, ...);
#endif
#ifndef HAVE_VASPRINTF
int vasprintf(char **ptr, const char *format, va_list ap);
#endif
#if !defined HAVE_VSNPRINTF || !defined HAVE_C99_VSNPRINTF
#define vsnprintf rsync_vsnprintf
int vsnprintf(char *str, size_t count, const char *fmt, va_list args);
#endif
#if !defined HAVE_SNPRINTF || !defined HAVE_C99_VSNPRINTF
#define snprintf rsync_snprintf
int snprintf(char *str,size_t count,const char *fmt,...);
#endif
#ifndef HAVE_STRERROR
extern char *sys_errlist[];
#define strerror(i) sys_errlist[i]
#endif
@@ -386,11 +674,11 @@ extern char *sys_errlist[];
extern int errno;
#endif
#define SUPPORT_LINKS HAVE_READLINK
#define SUPPORT_HARD_LINKS HAVE_LINK
#ifndef HAVE_LCHOWN
#define lchown chown
#ifdef HAVE_READLINK
#define SUPPORT_LINKS 1
#endif
#ifdef HAVE_LINK
#define SUPPORT_HARD_LINKS 1
#endif
#define SIGNAL_CAST (RETSIGTYPE (*)())
@@ -411,10 +699,24 @@ extern int errno;
#define STDERR_FILENO 2
#endif
#ifndef S_IRUSR
#define S_IRUSR 0400
#endif
#ifndef S_IWUSR
#define S_IWUSR 0200
#endif
#ifndef ACCESSPERMS
#define ACCESSPERMS 0777
#endif
#ifndef S_ISVTX
#define S_ISVTX 0
#endif
#define CHMOD_BITS (S_ISUID | S_ISGID | S_ISVTX | ACCESSPERMS)
#ifndef _S_IFMT
#define _S_IFMT 0170000
#endif
@@ -459,31 +761,65 @@ extern int errno;
#define S_ISREG(mode) (((mode) & (_S_IFMT)) == (_S_IFREG))
#endif
/* work out what fcntl flag to use for non-blocking */
#ifdef O_NONBLOCK
# define NONBLOCK_FLAG O_NONBLOCK
#elif defined SYSV
# define NONBLOCK_FLAG O_NDELAY
#else
# define NONBLOCK_FLAG FNDELAY
#endif
#ifndef INADDR_LOOPBACK
#define INADDR_LOOPBACK 0x7f000001
#endif
#ifndef INADDR_NONE
#define INADDR_NONE 0xffffffff
#endif
#define IS_DEVICE(mode) (S_ISCHR(mode) || S_ISBLK(mode) || S_ISSOCK(mode) || S_ISFIFO(mode))
#ifndef ACCESSPERMS
#define ACCESSPERMS 0777
#endif
/* Initial mask on permissions given to temporary files. Mask off setuid
bits and group access because of potential race-condition security
holes, and mask other access because mode 707 is bizarre */
#define INITACCESSPERMS 0700
/* handler for null strings in printf format */
#define NS(s) ((s)?(s):"<NULL>")
#define NS(s) ((s)?safe_fname(s):"<NULL>")
#if !defined __GNUC__ || defined __APPLE__
/* Apparently the OS X port of gcc gags on __attribute__.
*
* <http://www.opensource.apple.com/bugs/X/gcc/2512150.html> */
#define __attribute__(x)
#endif
/* Convenient wrappers for malloc and realloc. Use them. */
#define new(type) ((type *)malloc(sizeof(type)))
#define new_array(type, num) ((type *)_new_array(sizeof(type), (num)))
#define realloc_array(ptr, type, num) ((type *)_realloc_array((ptr), sizeof(type), (num)))
/* use magic gcc attributes to catch format errors */
void rprintf(int , const char *, ...)
#ifdef __GNUC__
__attribute__ ((format (printf, 2, 3)))
#endif
void rprintf(enum logcode , const char *, ...)
__attribute__((format (printf, 2, 3)))
;
/* This is just like rprintf, but it also tries to print some
* representation of the error code. Normally errcode = errno. */
void rsyserr(enum logcode, int, const char *, ...)
__attribute__((format (printf, 3, 4)))
;
#ifdef REPLACE_INET_NTOA
#define inet_ntoa rep_inet_ntoa
#endif
/* Make sure that the O_BINARY flag is defined. */
#ifndef O_BINARY
#define O_BINARY 0
#endif
#ifndef HAVE_STRLCPY
size_t strlcpy(char *d, const char *s, size_t bufsize);
@@ -493,4 +829,38 @@ size_t strlcpy(char *d, const char *s, size_t bufsize);
size_t strlcat(char *d, const char *s, size_t bufsize);
#endif
#ifndef WEXITSTATUS
#define WEXITSTATUS(stat) ((int)(((stat)>>8)&0xFF))
#endif
#define exit_cleanup(code) _exit_cleanup(code, __FILE__, __LINE__)
#ifdef HAVE_GETEUID
#define MY_UID() geteuid()
#else
#define MY_UID() getuid()
#endif
#ifdef HAVE_GETEGID
#define MY_GID() getegid()
#else
#define MY_GID() getgid()
#endif
extern int verbose;
#ifndef HAVE_INET_NTOP
const char *inet_ntop(int af, const void *src, char *dst, size_t size);
#endif
#ifndef HAVE_INET_PTON
int inet_pton(int af, const char *src, void *dst);
#endif
#ifdef MAINTAINER_MODE
const char *get_panic_action(void);
#endif
#define UNUSED(x) x __attribute__((__unused__))
extern const char *io_write_phase, *io_read_phase;

2116
rsync.yo
View File

File diff suppressed because it is too large Load Diff

469
rsync3.txt Normal file
View File

@@ -0,0 +1,469 @@
-*- indented-text -*-
Notes towards a new version of rsync
Martin Pool <mbp@samba.org>, September 2001.
Good things about the current implementation:
- Widely known and adopted.
- Fast/efficient, especially for moderately small sets of files over
slow links (transoceanic or modem.)
- Fairly reliable.
- The choice of runnning over a plain TCP socket or tunneling over
ssh.
- rsync operations are idempotent: you can always run the same
command twice to make sure it worked properly without any fear.
(Are there any exceptions?)
- Small changes to files cause small deltas.
- There is a way to evolve the protocol to some extent.
- rdiff and rsync --write-batch allow generation of standalone patch
sets. rsync+ is pretty cheesy, though. xdelta seems cleaner.
- Process triangle is creative, but seems to provoke OS bugs.
- "Morning-after property": you don't need to know anything on the
local machine about the state of the remote machine, or about
transfers that have been done in the past.
- You can easily push or pull simply by switching the order of
files.
- The "modules" system has some neat features compared to
e.g. Apache's per-directory configuration. In particular, because
you can set a userid and chroot directory, there is strong
protection between different modules. I haven't seen any calls
for a more flexible system.
Bad things about the current implementation:
- Persistent and hard-to-diagnose hang bugs remain
- Protocol is sketchily documented, tied to this implementation, and
hard to modify/extend
- Both the program and the protocol assume a single non-interactive
one-way transfer
- A list of all files are held in memory for the entire transfer,
which cripples scalability to large file trees
- Opening a new socket for every operation causes problems,
especially when running over SSH with password authentication.
- Renamed files are not handled: the old file is removed, and the
new file created from scratch.
- The versioning approach assumes that future versions of the
program know about all previous versions, and will do the right
thing.
- People always get confused about ':' vs '::'
- Error messages can be cryptic.
- Default behaviour is not intuitive: in too many cases rsync will
happily do nothing. Perhaps -a should be the default?
- People get confused by trailing slashes, though it's hard to think
of another reasonable way to make this necessary distinction
between a directory and its contents.
Protocol philosophy:
*The* big difference between protocols like HTTP, FTP, and NFS is
that their fundamental operations are "read this file", "delete
this file", and "make this directory", whereas rsync is "make this
directory like this one".
Questionable features:
These are neat, but not necessarily clean or worth preserving.
- The remote rsync can be wrapped by some other program, such as in
tridge's rsync-mail scripts. The general feature of sending and
retrieving mail over rsync is good, but this is perhaps not the
right way to implement it.
Desirable features:
These don't really require architectural changes; they're just
something to keep in mind.
- Synchronize ACLs and extended attributes
- Anonymous servers should be efficient
- Code should be portable to non-UNIX systems
- Should be possible to document the protocol in RFC form
- --dry-run option
- IPv6 support. Pretty straightforward.
- Allow the basis and destination files to be different. For
example, you could use this when you have a CD-ROM and want to
download an updated image onto a hard drive.
- Efficiently interrupt and restart a transfer. We can write a
checkpoint file that says where we're up to in the filesystem.
Alternatively, as long as transfers are idempotent, we can just
restart the whole thing. [NFSv4]
- Scripting support.
- Propagate atimes and do not modify them. This is very ugly on
Unix. It might be better to try to add O_NOATIME to kernels, and
call that.
- Unicode. Probably just use UTF-8 for everything.
- Open authentication system. Can we use PAM? Is SASL an adequate
mapping of PAM to the network, or useful in some other way?
- Resume interrupted transfers without the --partial flag. We need
to leave the temporary file behind, and then know to use it. This
leaves a risk of large temporary files accumulating, which is not
good. Perhaps it should be off by default.
- tcpwrappers support. Should be trivial; can already be done
through tcpd or inetd.
- Socks support built in. It's not clear this is any better than
just linking against the socks library, though.
- When run over SSH, invoke with predictable command-line arguments,
so that people can restrict what commands sshd will run. (Is this
really required?)
- Comparison mode: give a list of which files are new, gone, or
different. Set return code depending on whether anything has
changed.
- Internationalized messages (gettext?)
- Optionally use real regexps rather than globs?
- Show overall progress. Pretty hard to do, especially if we insist
on not scanning the directory tree up front.
Regression testing:
- Support automatic testing.
- Have hard internal timeouts against hangs.
- Be deterministic.
- Measure performance.
Hard links:
At the moment, we can recreate hard links, but it's a bit
inefficient: it depends on holding a list of all files in the tree.
Every time we see a file with a linkcount >1, we need to search for
another known name that has the same (fsid,inum) tuple. We could do
that more efficiently by keeping a list of only files with
linkcount>1, and removing files from that list as all their names
become known.
Command-line options:
We have rather a lot at the moment. We might get more if the tool
becomes more flexible. Do we need a .rc or configuration file?
That wouldn't really fit with its pattern of use: cp and tar don't
have them, though ssh does.
Scripting issues:
- Perhaps support multiple scripting languages: candidates include
Perl, Python, Tcl, Scheme (guile?), sh, ...
- Simply running a subprocess and looking at its stdout/exit code
might be sufficient, though it could also be pretty slow if it's
called often.
- There are security issues about running remote code, at least if
it's not running in the users own account. So we can either
disallow it, or use some kind of sandbox system.
- Python is a good language, but the syntax is not so good for
giving small fragments on the command line.
- Tcl is broken Lisp.
- Lots of sysadmins know Perl, though Perl can give some bizarre or
confusing errors. The built in stat operators and regexps might
be useful.
- Sadly probably not enough people know Scheme.
- sh is hard to embed.
Scripting hooks:
- Whether to transfer a file
- What basis file to use
- Logging
- Whether to allow transfers (for public servers)
- Authentication
- Locking
- Cache
- Generating backup path/name.
- Post-processing of backups, e.g. to do compression.
- After transfer, before replacement: so that we can spit out a diff
of what was changed, or kick off some kind of reconciliation
process.
VFS:
Rather than talking straight to the filesystem, rsyncd talks through
an internal API. Samba has one. Is it useful?
- Could be a tidy way to implement cached signatures.
- Keep files compressed on disk?
Interactive interface:
- Something like ncFTP, or integration into GNOME-vfs. Probably
hold a single socket connection open.
- Can either call us as a separate process, or as a library.
- The standalone process needs to produce output in a form easily
digestible by a calling program, like the --emacs feature some
have. Same goes for output: rpm outputs a series of hash symbols,
which are easier for a GUI to handle than "\r30% complete"
strings.
- Yow! emacs support. (You could probably build that already, of
course.) I'd like to be able to write a simple script on a remote
machine that rsyncs it to my workstation, edits it there, then
pushes it back up.
Pie-in-the-sky features:
These might have a severe impact on the protocol, and are not
clearly in our core requirements. It looks like in many of them
having scripting hooks will allow us
- Transport over UDP multicast. The hard part is handling multiple
destinations which have different basis files. We can look at
multicast-TFTP for inspiration.
- Conflict resolution. Possibly general scripting support will be
sufficient.
- Integrate with locking. It's hard to see a good general solution,
because Unix systems have several locking mechanisms, and grabbing
the lock from programs that don't expect it could cause deadlocks,
timeouts, or other problems. Scripting support might help.
- Replicate in place, rather than to a temporary file. This is
dangerous in the case of interruption, and it also means that the
delta can't refer to blocks that have already been overwritten.
On the other hand we could semi-trivially do this at first by
simply generating a delta with no copy instructions.
- Replicate block devices. Most of the difficulties here are to do
with replication in place, though on some systems we will also
have to do I/O on block boundaries.
- Peer to peer features. Flavour of the year. Can we think about
ways for clients to smoothly and voluntarily become servers for
content they receive?
- Imagine a situation where the destination has a much faster link
to the cloud than the source. In this case, Mojo Nation downloads
interleaved blocks from several slower servers. The general
situation might be a way for a master rsync process to farm out
tasks to several subjobs. In this particular case they'd need
different sockets. This might be related to multicast.
Unlikely features:
- Allow remote source and destination. If this can be cleanly
designed into the protocol, perhaps with the remote machine acting
as a kind of echo, then it's good. It's uncommon enough that we
don't want to shape the whole protocol around it, though.
In fact, in a triangle of machines there are two possibilities:
all traffic passes from remote1 to remote2 through local, or local
just sets up the transfer and then remote1 talks to remote2. FTP
supports the second but it's not clearly good. There are some
security problems with being able to instruct one machine to open
a connection to another.
In favour of evolving the protocol:
- Keeping compatibility with existing rsync servers will help with
adoption and testing.
- We should at the very least be able to fall back to the new
protocol.
- Error handling is not so good.
In favour of using a new protocol:
- Maintaining compatibility might soak up development time that
would better go into improving a new protocol.
- If we start from scratch, it can be documented as we go, and we
can avoid design decisions that make the protocol complex or
implementation-bound.
Error handling:
- Errors should come back reliably, and be clearly associated with
the particular file that caused the problem.
- Some errors ought to cause the whole transfer to abort; some are
just warnings. If any errors have occurred, then rsync ought to
return an error.
Concurrency:
- We want to keep the CPU, filesystem, and network as full as
possible as much of the time as possible.
- We can do nonblocking network IO, but not so for disk.
- It makes sense to on the destination be generating signatures and
applying patches at the same time.
- Can structure this with nonblocking, threads, separate processes,
etc.
Uses:
- Mirroring software distributions:
- Synchronizing laptop and desktop
- NFS filesystem migration/replication. See
http://www.ietf.org/proceedings/00jul/00july-133.htm#P24510_1276764
- Sync with PDA
- Network backup systems
- CVS filemover
Conflict resolution:
- Requires application-specific knowledge. We want to provide
policy, rather than mechanism.
- Possibly allowing two-way migration across a single connection
would be useful.
Moved files: <http://rsync.samba.org/cgi-bin/rsync.fom?file=44>
- There's no trivial way to detect renamed files, especially if they
move between directories.
- If we had a picture of the remote directory from last time on
either machine, then the inode numbers might give us a hint about
files which may have been renamed.
- Files that are renamed and not modified can be detected by
examining the directory listing, looking for files with the same
size/date as the origin.
Filesystem migration:
NFSv4 probably wants to migrate file locks, but that's not really
our problem.
Atomic updates:
The NFSv4 working group wants atomic migration. Most of the
responsibility for this lies on the NFS server or OS.
If migrating a whole tree, then we could do a nearly-atomic rename
at the end. This ties in to having separate basis and destination
files.
There's no way in Unix to replace a whole set of files atomically.
However, if we get them all onto the destination machine and then do
the updates quickly it would greatly reduce the window.
Scalability:
We should aim to work well on machines in use in a year or two.
That probably means transfers of many millions of files in one
batch, and gigabytes or terabytes of data.
For argument's sake: at the low end, we want to sync ten files for a
total of 10kb across a 1kB/s link. At the high end, we want to sync
1e9 files for 1TB of data across a 1GB/s link.
On the whole CPU usage is not normally a limiting factor, if only
because running over SSH burns a lot of cycles on encryption.
Perhaps have resource throttling without relying on rlimit.
Streaming:
A big attraction of rsync is that there are few round-trip delays:
basically only one to get started, and then everything is
pipelined. This is a problem with FTP, and NFS (at least up to
v3). NFSv4 can pipeline operations, but building on that is
probably a bit complicated.
Related work:
- mirror.pl http://freshmeat.net/project/mirror/
- ProFTPd
- Apache
- http://freshmeat.net/search/?site=Freshmeat&q=mirror&section=projects
- BitTorrent -- p2p mirroring
http://bitconjurer.org/BitTorrent/

View File

@@ -1,6 +1,6 @@
mailto(rsync-bugs@samba.org)
manpage(rsyncd.conf)(5)(12 Feb 1999)()()
manpagename(rsyncd.conf)(configuration file for rsync server)
manpage(rsyncd.conf)(5)(28 Jul 2005)()()
manpagename(rsyncd.conf)(configuration file for rsync in daemon mode)
manpagesynopsis()
rsyncd.conf
@@ -8,9 +8,7 @@ rsyncd.conf
manpagedescription()
The rsyncd.conf file is the runtime configuration file for rsync when
run with the --daemon option. When run in this way rsync becomes a
rsync server listening on TCP port 873. Connections from rsync clients
are accepted for either anonymous or authenticated rsync sessions.
run as an rsync daemon.
The rsyncd.conf file controls authentication, access, logging and
available modules.
@@ -21,7 +19,7 @@ The file consists of modules and parameters. A module begins with the
name of the module in square brackets and continues until the next
module begins. Modules contain parameters of the form 'name = value'.
The file is line-based - that is, each newline-terminated line represents
The file is line-based -- that is, each newline-terminated line represents
either a comment, a module name or a parameter.
Only the first equals sign in a parameter is significant. Whitespace before
@@ -43,26 +41,32 @@ in string values.
manpagesection(LAUNCHING THE RSYNC DAEMON)
The rsync daemon is launched by specifying the --daemon option to
rsync. The daemon must run with root privileges.
The rsync daemon is launched by specifying the bf(--daemon) option to
rsync.
You can launch it either via inetd or as a stand-alone daemon. If run
as a daemon then just run the command "rsync --daemon" from a suitable
startup script.
The daemon must run with root privileges if you wish to use chroot, to
bind to a port numbered under 1024 (as is the default 873), or to set
file ownership. Otherwise, it must just have permission to read and
write the appropriate data, log, and lock files.
You can launch it either via inetd, as a stand-alone daemon, or from
an rsync client via a remote shell. If run as a stand-alone daemon then
just run the command "bf(rsync --daemon)" from a suitable startup script.
When run via inetd you should add a line like this to /etc/services:
quote(rsync 873/tcp)
verb( rsync 873/tcp)
and a single line something like this to /etc/inetd.conf:
quote(rsync stream tcp nowait root /usr/bin/rsync rsyncd --daemon)
verb( rsync stream tcp nowait root /usr/bin/rsync rsyncd --daemon)
You will then need to send inetd a HUP signal to tell it to reread its
config file.
Replace "/usr/bin/rsync" with the path to where you have rsync installed on
your system. You will then need to send inetd a HUP signal to tell it to
reread its config file.
Note that you should not send the rsync server a HUP signal to force
it to reread the tt(/etc/rsyncd.conf). The file is re-read on each client
Note that you should bf(not) send the rsync daemon a HUP signal to force
it to reread the tt(rsyncd.conf) file. The file is re-read on each client
connection.
manpagesection(GLOBAL OPTIONS)
@@ -83,19 +87,30 @@ is no motd file.
dit(bf(log file)) The "log file" option tells the rsync daemon to log
messages to that file rather than using syslog. This is particularly
useful on systems (such as AIX) where syslog() doesn't work for
chrooted programs.
chrooted programs. If the daemon fails to open to specified file, it
will fall back to using syslog and output an error about the failure.
(Note that a failure to open the specified log file used to be a fatal
error.)
dit(bf(pid file)) The "pid file" option tells the rsync daemon to write
its process id to that file.
its process ID to that file.
dit(bf(syslog facility)) The "syslog facility" option allows you to
specify the syslog facility name to use when logging messages from the
rsync server. You may use any standard syslog facility name which is
rsync daemon. You may use any standard syslog facility name which is
defined on your system. Common names are auth, authpriv, cron, daemon,
ftp, kern, lpr, mail, news, security, syslog, user, uucp, local0,
local1, local2, local3, local4, local5, local6 and local7. The default
is daemon.
dit(bf(port)) You can override the default port the daemon will listen on
by specifying this value (defaults to 873). This is ignored if the daemon
is being run by inetd, and is superseded by the bf(--port) command-line option.
dit(bf(address)) You can override the default IP address the daemon
will listen on by specifying this value. This is ignored if the daemon is
being run by inetd, and is superseded by the bf(--address) command-line option.
dit(bf(socket options)) This option can provide endless fun for people
who like to tune their systems to the utmost degree. You can set all
sorts of socket options which may make transfers faster (or
@@ -119,95 +134,150 @@ dit(bf(comment)) The "comment" option specifies a description string
that is displayed next to the module name when clients obtain a list
of available modules. The default is no comment.
dit(bf(path)) The "path" option specifies the directory in the servers
dit(bf(path)) The "path" option specifies the directory in the daemon's
filesystem to make available in this module. You must specify this option
for each module in tt(/etc/rsyncd.conf).
for each module in tt(rsyncd.conf).
dit(bf(use chroot)) If "use chroot" is true, the rsync server will chroot
dit(bf(use chroot)) If "use chroot" is true, the rsync daemon will chroot
to the "path" before starting the file transfer with the client. This has
the advantage of extra protection against possible implementation security
holes, but it has the disadvantages of requiring super-user privileges and
of not being able to follow symbolic links outside of the new root path.
The default is to use chroot.
holes, but it has the disadvantages of requiring super-user privileges,
of not being able to follow symbolic links that are either absolute or outside
of the new root path, and of complicating the preservation of usernames and groups
(see below). When "use chroot" is false, for security reasons,
symlinks may only be relative paths pointing to other files within the root
path, and leading slashes are removed from most absolute paths (options
such as bf(--backup-dir), bf(--compare-dest), etc. interpret an absolute path as
rooted in the module's "path" dir, just as if chroot was specified).
The default for "use chroot" is true.
In order to preserve usernames and groupnames, rsync needs to be able to
use the standard library functions for looking up names and IDs (i.e.
getpwuid(), getgrgid(), getpwname(), and getgrnam()). This means a
process in the chroot namespace will need to have access to the resources
used by these library functions (traditionally /etc/passwd and
/etc/group). If these resources are not available, rsync will only be
able to copy the IDs, just as if the bf(--numeric-ids) option had been
specified.
Note that you are free to setup user/group information in the chroot area
differently from your normal system. For example, you could abbreviate
the list of users and groups. Also, you can protect this information from
being downloaded/uploaded by adding an exclude rule to the rsync.conf file
(e.g. "exclude = /etc/**"). Note that having the exclusion affect uploads
is a relatively new feature in rsync, so make sure your daemon is
at least 2.6.3 to effect this. Also note that it is safest to exclude a
directory and all its contents combining the rule "/some/dir/" with the
rule "/some/dir/**" just to be sure that rsync will not allow deeper
access to some of the excluded files inside the directory (rsync tries to
do this automatically, but you might as well specify both to be extra
sure).
dit(bf(max connections)) The "max connections" option allows you to
specify the maximum number of simultaneous connections you will allow
to this module of your rsync server. Any clients connecting when the
maximum has been reached will receive a message telling them to try
later. The default is 0 which means no limit.
specify the maximum number of simultaneous connections you will allow.
Any clients connecting when the maximum has been reached will receive a
message telling them to try later. The default is 0 which means no limit.
See also the "lock file" option.
dit(bf(max verbosity)) The "max verbosity" option allows you to control
the maximum amount of verbose information that you'll allow the daemon to
generate (since the information goes into the log file). The default is 1,
which allows the client to request one level of verbosity.
dit(bf(lock file)) The "lock file" option specifies the file to use to
support the "max connections" option. The rsync server uses record
support the "max connections" option. The rsync daemon uses record
locking on this file to ensure that the max connections limit is not
exceeded. The default is tt(/var/run/rsyncd.lock).
exceeded for the modules sharing the lock file.
The default is tt(/var/run/rsyncd.lock).
dit(bf(read only)) The "read only" option determines whether clients
will be able to upload files or not. If "read only" is true then any
attempted uploads will fail. If "read only" is false then uploads will
be possible if file permissions on the server allow them. The default
be possible if file permissions on the daemon side allow them. The default
is for all modules to be read only.
dit(bf(write only)) The "write only" option determines whether clients
will be able to download files or not. If "write only" is true then any
attempted downloads will fail. If "write only" is false then downloads
will be possible if file permissions on the daemon side allow them. The
default is for this option to be disabled.
dit(bf(list)) The "list" option determines if this module should be
listed when the client asks for a listing of available modules. By
setting this to false you can create hidden modules. The default is
for modules to be listable.
dit(bf(uid)) The "uid" option specifies the user name or user id that
dit(bf(uid)) The "uid" option specifies the user name or user ID that
file transfers to and from that module should take place as when the daemon
was run as root. In combination with the "gid" option this determines what
file permissions are available. The default is the user "nobody".
file permissions are available. The default is uid -2, which is normally
the user "nobody".
dit(bf(gid)) The "gid" option specifies the group name or group id that
dit(bf(gid)) The "gid" option specifies the group name or group ID that
file transfers to and from that module should take place as when the daemon
was run as root. This complements the "uid" option. The default is the
group "nobody".
was run as root. This complements the "uid" option. The default is gid -2,
which is normally the group "nobody".
dit(bf(exclude)) The "exclude" option allows you to specify a space
separated list of patterns to add to the exclude list. This is
equivalent to the client specifying these patterns with the --exclude
option except that the exclude list is not passed to the client and
thus only apply on the server. Only one "exclude" option may be
specified, but you can use "-" and "+" before patterns to specify
exclude/include.
dit(bf(filter)) The "filter" option allows you to specify a space-separated
list of filter rules that the daemon will not allow to be read or written.
This is only superficially equivalent to the client specifying these
patterns with the bf(--filter) option. Only one "filter" option may be
specified, but it may contain as many rules as you like, including
merge-file rules. Note that per-directory merge-file rules do not provide
as much protection as global rules, but they can be used to make bf(--delete)
work better when a client downloads the daemon's files (if the per-dir
merge files are included in the transfer).
Note that this option is not designed with strong security in
mind, it is quite possible that a client may find a way to bypass this
exclude list. If you want to absolutely ensure that certain files
cannot be accessed then use the uid/gid options in combination with
file permissions.
dit(bf(exclude)) The "exclude" option allows you to specify a
space-separated list of patterns that the daemon will not allow to be read
or written. This is only superficially equivalent to the client
specifying these patterns with the bf(--exclude) option. Only one "exclude"
option may be specified, but you can use "-" and "+" before patterns to
specify exclude/include.
Because this exclude list is not passed to the client it only applies on
the daemon: that is, it excludes files received by a client when receiving
from a daemon and files deleted on a daemon when sending to a daemon, but
it doesn't exclude files from being deleted on a client when receiving
from a daemon.
dit(bf(exclude from)) The "exclude from" option specifies a filename
on the server that contains exclude patterns, one per line. This is
equivalent to the client specifying the --exclude-from option with a
equivalent file except that the resulting exclude patterns are not
passed to the client and thus only apply on the server. See also the
note about security for the exclude option above.
on the daemon that contains exclude patterns, one per line.
This is only superficially equivalent
to the client specifying the bf(--exclude-from) option with an equivalent file.
See the "exclude" option above.
dit(bf(include)) The "include" option allows you to specify a space
separated list of patterns which rsync should not exclude. This is
equivalent to the client specifying these patterns with the --include
option. This is useful as it allows you to build up quite complex
exclude/include rules. Only one "include" option may be specified, but you
can use "+" and "-" before patterns to switch include/exclude.
See the section of exclude patterns in the rsync man page for information
on the syntax of this option.
dit(bf(include)) The "include" option allows you to specify a
space-separated list of patterns which rsync should not exclude. This is
only superficially equivalent to the client specifying these patterns with
the bf(--include) option because it applies only on the daemon. This is
useful as it allows you to build up quite complex exclude/include rules.
Only one "include" option may be specified, but you can use "+" and "-"
before patterns to switch include/exclude. See the "exclude" option
above.
dit(bf(include from)) The "include from" option specifies a filename
on the server that contains include patterns, one per line. This is
equivalent to the client specifying the --include-from option with a
equivalent file.
on the daemon that contains include patterns, one per line. This is
only superficially equivalent to the client specifying the
bf(--include-from) option with a equivalent file.
See the "exclude" option above.
dit(bf(auth users)) The "auth users" option specifies a comma
and space separated list of usernames that will be allowed to connect
to this module. The usernames do not need to exist on the local
system. If "auth users" is set then the client will be challenged to
supply a username and password to connect to the module. A challenge
response authentication protocol is used for this exchange. The plain
text usernames are passwords are stored in the file specified by the
dit(bf(auth users)) The "auth users" option specifies a comma and
space-separated list of usernames that will be allowed to connect to
this module. The usernames do not need to exist on the local
system. The usernames may also contain shell wildcard characters. If
"auth users" is set then the client will be challenged to supply a
username and password to connect to the module. A challenge response
authentication protocol is used for this exchange. The plain text
usernames are passwords are stored in the file specified by the
"secrets file" option. The default is for all users to be able to
connect without a password (this is called "anonymous rsync").
See also the "CONNECTING TO AN RSYNC DAEMON OVER A REMOTE SHELL
PROGRAM" section in rsync(1) for information on how handle an
rsyncd.conf-level username that differs from the remote-shell-level
username when using a remote shell to connect to an rsync daemon.
dit(bf(secrets file)) The "secrets file" option specifies the name of
a file that contains the username:password pairs used for
authenticating this module. This file is only consulted if the "auth
@@ -219,11 +289,12 @@ limit the length of passwords that can be typed at the client end, so
you may find that passwords longer than 8 characters don't work.
There is no default for the "secrets file" option, you must choose a name
(such as tt(/etc/rsyncd.secrets)).
(such as tt(/etc/rsyncd.secrets)). The file must normally not be readable
by "other"; see "strict modes".
dit(bf(strict modes)) The "strict modes" option determines whether or not
the permissions on the secrets file will be checked. If "strict modes" is
true, then the secrets file must not be readable by any user id other
true, then the secrets file must not be readable by any user ID other
than the one that the rsync daemon is running under. If "strict modes" is
false, the check is not performed. The default is true. This option
was added to accommodate rsync running on the Windows operating system.
@@ -235,25 +306,31 @@ connection is rejected.
Each pattern can be in one of five forms:
itemize(
it() a dotted decimal IP address. In this case the incoming machines
IP address must match exactly.
it() a address/mask in the form a.b.c.d/n were n is the number of
one bits in in the netmask. All IP addresses which match the masked
IP address will be allowed in.
it() a address/mask in the form a.b.c.d/e.f.g.h where e.f.g.h is a
netmask in dotted decimal notation. All IP addresses which match the masked
IP address will be allowed in.
quote(itemize(
it() a dotted decimal IPv4 address of the form a.b.c.d, or an IPv6 address
of the form a:b:c::d:e:f. In this case the incoming machine's IP address
must match exactly.
it() an address/mask in the form ipaddr/n where ipaddr is the IP address
and n is the number of one bits in the netmask. All IP addresses which
match the masked IP address will be allowed in.
it() an address/mask in the form ipaddr/maskaddr where ipaddr is the
IP address and maskaddr is the netmask in dotted decimal notation for IPv4,
or similar for IPv6, e.g. ffff:ffff:ffff:ffff:: instead of /64. All IP
addresses which match the masked IP address will be allowed in.
it() a hostname. The hostname as determined by a reverse lookup will
be matched (case insensitive) against the pattern. Only an exact
match is allowed in.
it() a hostname pattern using wildcards. These are matched using the
same rules as normal unix filename matching. If the pattern matches
then the client is allowed in.
))
Note IPv6 link-local addresses can have a scope in the address specification:
quote(
tt( fe80::1%link1)nl()
tt( fe80::%link1/64)nl()
tt( fe80::%link1/ffff:ffff:ffff:ffff::)nl()
)
You can also combine "hosts allow" with a separate "hosts deny"
@@ -273,25 +350,52 @@ rejected. See the "hosts allow" option for more information.
The default is no "hosts deny" option, which means all hosts can connect.
dit(bf(ignore errors)) The "ignore errors" option tells rsyncd to
ignore I/O errors on the daemon when deciding whether to run the delete
phase of the transfer. Normally rsync skips the bf(--delete) step if any
I/O errors have occurred in order to prevent disastrous deletion due
to a temporary resource shortage or other I/O error. In some cases this
test is counter productive so you can use this option to turn off this
behavior.
dit(bf(ignore nonreadable)) This tells the rsync daemon to completely
ignore files that are not readable by the user. This is useful for
public archives that may have some non-readable files among the
directories, and the sysadmin doesn't want those files to be seen at all.
dit(bf(transfer logging)) The "transfer logging" option enables per-file
logging of downloads and uploads in a format somewhat similar to that
used by ftp daemons. If you want to customize the log formats look at
the log format option.
used by ftp daemons. The daemon always logs the transfer at the end, so
if a transfer is aborted, no mention will be made in the log file.
If you want to customize the log lines, see the "log format" option.
dit(bf(log format)) The "log format" option allows you to specify the
format used for logging file transfers when transfer logging is
enabled. The format is a text string containing embedded single
character escape sequences prefixed with a percent (%) character.
format used for logging file transfers when transfer logging is enabled.
The format is a text string containing embedded single-character escape
sequences prefixed with a percent (%) character. An optional numeric
field width may also be specified between the percent and the escape
letter (e.g. "%-50n %8l %07p").
The prefixes that are understood are:
The default log format is "%o %h [%a] %m (%u) %f %l", and a "%t [%p] "
is always prefixed when using the "log file" option.
(A perl script that will summarize this default log format is included
in the rsync source code distribution in the "support" subdirectory:
rsyncstats.)
itemize(
The single-character escapes that are understood are as follows:
quote(itemize(
it() %h for the remote host name
it() %a for the remote IP address
it() %l for the length of the file in bytes
it() %p for the process id of this rsync session
it() %o for the operation, which is either "send" or "recv"
it() %f for the filename
it() %p for the process ID of this rsync session
it() %o for the operation, which is "send", "recv", or "del."
(the latter includes the trailing period)
it() %f for the filename (long form on sender; no trailing "/")
it() %n for the filename (short form; trailing "/" on dir)
it() %L either the string " -> SYMLINK", or " => HARDLINK" or an
empty string (where bf(SYMLINK) or bf(HARDLINK) is a filename)
it() %P for the module path
it() %m for the module name
it() %t for the current date time
@@ -299,26 +403,41 @@ itemize(
it() %b for the number of bytes actually transferred
it() %c when sending files this gives the number of checksum bytes
received for this file
)
it() %i an itemized list of what is being updated
))
The default log format is "%o %h [%a] %m (%u) %f %l", and a "%t [%p] "
is always added to the beginning when using the "log file" option.
For a list of what the characters mean that are output by "%i", see the
bf(--itemize-changes) option in the rsync manpage.
A perl script called rsyncstats to summarize this format is included
in the rsync source code distribution.
Note that some of the logged output changes when talking with older
rsync versions. For instance, deleted files were only output as verbose
messages prior to rsync 2.6.4.
dit(bf(timeout)) The "timeout" option allows you to override the
clients choice for IO timeout for this module. Using this option you
clients choice for I/O timeout for this module. Using this option you
can ensure that rsync won't wait on a dead client forever. The timeout
is specified in seconds. A value of zero means no timeout and is the
default. A good choice for anonymous rsync servers may be 600 (giving
default. A good choice for anonymous rsync daemons may be 600 (giving
a 10 minute timeout).
dit(bf(refuse options)) The "refuse options" option allows you to
specify a space separated list of rsync command line options that will
be refused by your rsync server. The full names of the options must be
used (i.e., you must use "checksum" not "c" to disable checksumming).
When an option is refused, the server prints an error message and exits.
specify a space-separated list of rsync command line options that will
be refused by your rsync daemon.
You may specify the full option name, its one-letter abbreviation, or a
wild-card string that matches multiple options.
For example, this would refuse bf(--checksum) (bf(-c)) and all the various
delete options:
quote(tt( refuse options = c delete))
The reason the above refuses all delete options is that the options imply
bf(--delete), and implied options are refused just like explicit options.
As an additional safety feature, the refusal of "delete" also refuses
bf(remove-sent-files) when the daemon is the sender; if you want the latter
without the former, instead refuse "delete-*" -- that refuses all the
delete modes without affecting bf(--remove-sent-files).
When an option is refused, the daemon prints an error message and exits.
To prevent all compression, you can use "dont compress = *" (see below)
instead of "refuse options = compress" to avoid returning an error to a
client that requests compression.
@@ -329,11 +448,11 @@ during transfer. Compression is expensive in terms of CPU usage so it
is usually good to not try to compress files that won't compress well,
such as already compressed files.
The "dont compress" option takes a space separated list of
The "dont compress" option takes a space-separated list of
case-insensitive wildcard patterns. Any source filename matching one
of the patterns will not be compressed during transfer.
The default setting is verb(*.gz *.tgz *.zip *.z *.rpm *.deb)
The default setting is tt(*.gz *.tgz *.zip *.z *.rpm *.deb *.iso *.bz2 *.tbz)
enddit()
@@ -346,8 +465,8 @@ realize that this is not a "military strength" authentication system.
It should be good enough for most purposes but if you want really top
quality security then I recommend that you run rsync over ssh.
Also note that the rsync server protocol does not currently provide any
encryption of the data that is transferred over the link. Only
Also note that the rsync daemon protocol does not currently provide any
encryption of the data that is transferred over the connection. Only
authentication is provided. Use ssh as the transport if you want
encryption.
@@ -365,17 +484,17 @@ verb(
comment = ftp export area
)
A more sophisticated example would be:
uid = nobody nl()
gid = nobody nl()
use chroot = no nl()
max connections = 4 nl()
syslog facility = local5 nl()
pid file = /etc/rsyncd.pid
verb(
uid = nobody
gid = nobody
use chroot = no
max connections = 4
syslog facility = local5
pid file = /var/run/rsyncd.pid
verb([ftp]
[ftp]
path = /var/ftp/pub
comment = whole ftp area (approx 6.1 GB)
@@ -400,12 +519,14 @@ verb([ftp]
The /etc/rsyncd.secrets file would look something like this:
tridge:mypass nl()
susan:herpass
quote(
tt(tridge:mypass)nl()
tt(susan:herpass)nl()
)
manpagefiles()
/etc/rsyncd.conf
/etc/rsyncd.conf or rsyncd.conf
manpageseealso()
@@ -415,15 +536,12 @@ manpagediagnostics()
manpagebugs()
The rsync server does not send all types of error messages to the
client. this means a client may be mystified as to why a transfer
failed. The error will have been logged by syslog on the server.
Please report bugs! The rsync bug tracking system is online at
url(http://rsync.samba.org/)(http://rsync.samba.org/)
manpagesection(VERSION)
This man page is current for version 2.0 of rsync
This man page is current for version 2.6.6 of rsync.
manpagesection(CREDITS)
@@ -444,12 +562,13 @@ Gailly and Mark Adler.
manpagesection(THANKS)
Thanks to Warren Stanley for his original idea and patch for the rsync
server. Thanks to Karsten Thygesen for his many suggestions and
daemon. Thanks to Karsten Thygesen for his many suggestions and
documentation!
manpageauthor()
rsync was written by Andrew Tridgell and Paul Mackerras. They may be
contacted via email at tridge@samba.org and
Paul.Mackerras@cs.anu.edu.au
rsync was written by Andrew Tridgell and Paul Mackerras.
Many people have later contributed to it.
Mailing lists for support and development are available at
url(http://lists.samba.org)(lists.samba.org)

26
rsyncsh.txt Normal file
View File

@@ -0,0 +1,26 @@
rsyncsh
Copyright (C) 2001 by Martin Pool
This is a quick hack to build an interactive shell around rsync, the
same way we have the ftp, lftp and ncftp programs for the FTP
protocol. The key application for this is connecting to a public
rsync server, such as rsync.kernel.org, change down through and list
directories, and finally pull down the file you want.
rsync is somewhat ill-at-ease as an interactive operation, since every
network connection is used to carry out exactly one operation. rsync
kind of "forks across the network" passing the options and filenames
to operate upon, and the connection is closed when the transfer is
complete. (This might be fixed in the future, either by adapting the
current protocol to allow chained operations over a single socket, or
by writing a new protocol that better supports interactive use.)
So, rsyncsh runs a new rsync command and opens a new socket for every
(network-based) command you type.
This has two consequences. Firstly, there is more command latency
than is really desirable. More seriously, if the connection cannot be
done automatically, because for example it uses SSH with a password,
then you will need to enter the password every time. We might even
fix this in the future, though, by having a way to automatically feed
the password to SSH if it's entered once.

277
runtests.sh Executable file
View File

@@ -0,0 +1,277 @@
#! /bin/sh
# Copyright (C) 2001, 2002 by Martin Pool <mbp@samba.org>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version
# 2 as published by the Free Software Foundation.
#
# 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
# rsync top-level test script -- this invokes all the other more
# detailed tests in order. This script can either be called by `make
# check' or `make installcheck'. `check' runs against the copies of
# the program and other files in the build directory, and
# `installcheck' against the installed copy of the program.
# In either case we need to also be able to find the source directory,
# since we read test scripts and possibly other information from
# there.
# Whenever possible, informational messages are written to stdout and
# error messages to stderr. They're separated out by the build farm
# display scripts.
# According to the GNU autoconf manual, the only valid place to set up
# directory locations is through Make, since users are allowed to (try
# to) change their mind on the Make command line. So, Make has to
# pass in all the values we need.
# For other configured settings we read ./config.sh, which tells us
# about shell commands on this machine and similar things.
# rsync_bin gives the location of the rsync binary. This is either
# builddir/rsync if we're testing an uninstalled copy, or
# install_prefix/bin/rsync if we're testing an installed copy. On the
# build farm rsync will be installed, but into a scratch /usr.
# srcdir gives the location of the source tree, which lets us find the
# build scripts. At the moment we assume we are invoked from the
# source directory.
# This script must be invoked from the build directory.
# A scratch directory, 'testtmp', is created in the build directory to
# hold working files.
# This script also uses the $loglevel environment variable. 1 is the
# default value, and 10 the most verbose. You can set this from the
# Make command line. It's also set by the build farm to give more
# detail for failing builds.
# NOTES FOR TEST CASES:
# Each test case runs in its own shell.
# Exit codes from tests:
# 1 tests failed
# 2 error in starting tests
# 77 this test skipped (random value unlikely to happen by chance, same as
# automake)
# HOWEVER, the overall exit code to the farm is different: we return
# the *number of tests that failed*, so that it will show up nicely in
# the overall summary.
# rsync.fns contains some general setup functions and definitions.
# NOTES ON PORTABILITY:
# Both this script and the Makefile have to be pretty conservative
# about which Unix features they use.
# We cannot count on Make exporting variables to commands, unless
# they're explicitly given on the command line.
# Also, we can't count on 'cp -a' or 'mkdir -p', although they're
# pretty handy.
# I think some of the GNU documentation suggests that we shouldn't
# rely on shell functions. However, the Bash manual seems to say that
# they're in POSIX 1003.2, and since the build farm relies on them
# they're probably working on most machines we really care about.
# You cannot use "function foo {" syntax, but must instead say "foo()
# {", or it breaks on FreeBSD.
# BSD machines tend not to have "head" or "seq".
# You cannot do "export VAR=VALUE" all on one line; the export must be
# separate from the assignment. (SCO SysV)
# STILL TO DO:
# We need a good protection against tests that hang indefinitely.
# Perhaps some combination of starting them in the background, wait,
# and kill?
# Perhaps we need a common way to cleanup tests. At the moment just
# clobbering the directory when we're done should be enough.
# If any of the targets fail, then (GNU?) Make returns 2, instead of
# the return code from the failing command. This is fine, but it
# means that the build farm just shows "2" for failed tests, not the
# number of tests that actually failed. For more details we might
# need to grovel through the log files to find a line saying how many
# failed.
set -e
. "./shconfig"
RUNSHFLAGS='-e'
# for Solaris
[ -d /usr/xpg4/bin ] && PATH="/usr/xpg4/bin/:$PATH"
if [ "x$loglevel" != x ] && [ "$loglevel" -gt 8 ]; then
if set -x; then
# If it doesn't work the first time, don't keep trying.
RUNSHFLAGS="$RUNSHFLAGS -x"
fi
fi
echo "============================================================"
echo "$0 running in `pwd`"
echo " rsync_bin=$rsync_bin"
echo " srcdir=$srcdir"
if [ -f /usr/bin/whoami ]; then
testuser=`/usr/bin/whoami`
elif [ -f /usr/ucb/whoami ]; then
testuser=`/usr/ucb/whoami`
elif [ -f /bin/whoami ]; then
testuser=`/bin/whoami`
else
testuser=`id -un 2>/dev/null || echo ${LOGNAME:-${USERNAME:-${USER:-'UNKNOWN'}}}`
fi
echo " testuser=$testuser"
echo " os=`uname -a`"
# It must be "yes", not just nonnull
if [ "x$preserve_scratch" = xyes ]; then
echo " preserve_scratch=yes"
else
echo " preserve_scratch=no"
fi
if [ ! -f "$rsync_bin" ]; then
echo "rsync_bin $rsync_bin is not a file" >&2
exit 2
fi
if [ ! -d "$srcdir" ]; then
echo "srcdir $srcdir is not a directory" >&2
exit 2
fi
RSYNC="$rsync_bin"
#RSYNC="valgrind --tool=addrcheck $rsync_bin"
export rsync_bin RSYNC
skipped=0
missing=0
passed=0
failed=0
# Prefix for scratch directory. We create separate directories for
# each test case, so that they can be left behind in case of failure
# to aid investigation.
scratchbase="`pwd`"/testtmp
echo " scratchbase=$scratchbase"
suitedir="$srcdir/testsuite"
export scratchdir suitedir
prep_scratch() {
[ -d "$scratchdir" ] && rm -rf "$scratchdir"
mkdir "$scratchdir"
return 0
}
maybe_discard_scratch() {
[ x"$preserve_scratch" != xyes ] && [ -d "$scratchdir" ] && rm -rf "$scratchdir"
return 0
}
if [ "x$whichtests" = x ]; then
whichtests="*.test"
fi
for testscript in $suitedir/$whichtests
do
testbase=`echo $testscript | sed -e 's!.*/!!' -e 's/.test\$//'`
scratchdir="$scratchbase.$testbase"
prep_scratch
set +e
sh $RUNSHFLAGS "$testscript" >"$scratchdir/test.log" 2>&1
result=$?
set -e
if [ "x$always_log" = xyes -o \( $result != 0 -a $result != 77 -a $result != 78 \) ]
then
echo "----- $testbase log follows"
cat "$scratchdir/test.log"
echo "----- $testbase log ends"
if [ -f "$scratchdir/rsyncd.log" ]; then
echo "----- $testbase rsyncd.log follows"
cat "$scratchdir/rsyncd.log"
echo "----- $testbase rsyncd.log ends"
fi
fi
case $result in
0)
echo "PASS $testbase"
passed=`expr $passed + 1`
maybe_discard_scratch
;;
77)
# backticks will fill the whole file onto one line, which is a feature
whyskipped=`cat "$scratchdir/whyskipped"`
echo "SKIP $testbase ($whyskipped)"
skipped=`expr $skipped + 1`
maybe_discard_scratch
;;
78)
# It failed, but we expected that. don't dump out error logs,
# because most users won't want to see them. But do leave
# the working directory around.
echo "XFAIL $testbase"
failed=`expr $failed + 1`
;;
*)
echo "FAIL $testbase"
failed=`expr $failed + 1`
if [ "x$nopersist" = xyes ]; then
exit 1
fi
esac
done
echo '------------------------------------------------------------'
echo "----- overall results:"
echo " $passed passed"
[ "$failed" -gt 0 ] && echo " $failed failed"
[ "$skipped" -gt 0 ] && echo " $skipped skipped"
[ "$missing" -gt 0 ] && echo " $missing missing"
echo '------------------------------------------------------------'
# OK, so expr exits with 0 if the result is neither null nor zero; and
# 1 if the expression is null or zero. This is the opposite of what
# we want, and if we just call expr then this script will always fail,
# because -e is set.
result=`expr $failed + $missing || true`
echo "overall result is $result"
exit $result

429
sender.c
View File

@@ -1,17 +1,17 @@
/*
/*
Copyright (C) Andrew Tridgell 1996
Copyright (C) Paul Mackerras 1996
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -20,58 +20,94 @@
#include "rsync.h"
extern int verbose;
extern int remote_version;
extern int csum_length;
extern struct stats stats;
extern int io_error;
extern int dry_run;
extern int do_xfers;
extern int am_server;
extern int am_daemon;
extern int log_before_transfer;
extern int log_format_has_i;
extern int daemon_log_format_has_i;
extern int csum_length;
extern int append_mode;
extern int io_error;
extern int allowed_lull;
extern int protocol_version;
extern int remove_sent_files;
extern int updating_basis_file;
extern int make_backups;
extern int do_progress;
extern int inplace;
extern int batch_fd;
extern int write_batch;
extern struct stats stats;
extern struct file_list *the_file_list;
extern char *log_format;
/*
receive the checksums for a buffer
*/
/**
* @file
*
* The sender gets checksums from the generator, calculates deltas,
* and transmits them to the receiver. The sender process runs on the
* machine holding the source files.
**/
/**
* Receive the checksums for a buffer
**/
static struct sum_struct *receive_sums(int f)
{
struct sum_struct *s;
int i;
int32 i;
int lull_mod = allowed_lull * 5;
OFF_T offset = 0;
s = (struct sum_struct *)malloc(sizeof(*s));
if (!s) out_of_memory("receive_sums");
if (!(s = new(struct sum_struct)))
out_of_memory("receive_sums");
read_sum_head(f, s);
s->count = read_int(f);
s->n = read_int(f);
s->remainder = read_int(f);
s->sums = NULL;
if (verbose > 3)
rprintf(FINFO,"count=%d n=%d rem=%d\n",
s->count,s->n,s->remainder);
if (verbose > 3) {
rprintf(FINFO, "count=%.0f n=%ld rem=%ld\n",
(double)s->count, (long)s->blength, (long)s->remainder);
}
if (s->count == 0)
if (append_mode) {
s->flength = (OFF_T)s->count * s->blength;
if (s->remainder)
s->flength -= s->blength - s->remainder;
return s;
}
if (s->count == 0)
return(s);
s->sums = (struct sum_buf *)malloc(sizeof(s->sums[0])*s->count);
if (!s->sums) out_of_memory("receive_sums");
if (!(s->sums = new_array(struct sum_buf, s->count)))
out_of_memory("receive_sums");
for (i=0;i<s->count;i++) {
for (i = 0; i < s->count; i++) {
s->sums[i].sum1 = read_int(f);
read_buf(f,s->sums[i].sum2,csum_length);
read_buf(f, s->sums[i].sum2, s->s2length);
s->sums[i].offset = offset;
s->sums[i].i = i;
s->sums[i].flags = 0;
if (i == s->count-1 && s->remainder != 0) {
if (i == s->count-1 && s->remainder != 0)
s->sums[i].len = s->remainder;
} else {
s->sums[i].len = s->n;
}
else
s->sums[i].len = s->blength;
offset += s->sums[i].len;
if (verbose > 3)
rprintf(FINFO,"chunk[%d] len=%d offset=%d sum1=%08x\n",
i,s->sums[i].len,(int)s->sums[i].offset,s->sums[i].sum1);
if (allowed_lull && !(i % lull_mod))
maybe_send_keepalive();
if (verbose > 3) {
rprintf(FINFO,
"chunk[%d] len=%d offset=%.0f sum1=%08x\n",
i, s->sums[i].len, (double)s->sums[i].offset,
s->sums[i].sum1);
}
}
s->flength = offset;
@@ -79,152 +115,275 @@ static struct sum_struct *receive_sums(int f)
return s;
}
void send_files(struct file_list *flist,int f_out,int f_in)
{
int fd;
struct sum_struct *s;
struct map_struct *buf;
STRUCT_STAT st;
char fname[MAXPATHLEN];
int i;
void successful_send(int ndx)
{
char fname[MAXPATHLEN];
struct file_struct *file;
int phase = 0;
extern struct stats stats;
unsigned int offset;
if (ndx < 0 || ndx >= the_file_list->count)
return;
file = the_file_list->files[ndx];
/* The generator might tell us about symlinks we didn't send. */
if (!(file->flags & FLAG_SENT) && !S_ISLNK(file->mode))
return;
if (file->dir.root) {
offset = stringjoin(fname, sizeof fname,
file->dir.root, "/", NULL);
} else
offset = 0;
f_name_to(file, fname + offset);
if (remove_sent_files && do_unlink(fname) == 0 && verbose > 1) {
rprintf(FINFO, "sender removed %s\n",
safe_fname(fname + offset));
}
}
static void write_ndx_and_attrs(int f_out, int ndx, int iflags,
uchar fnamecmp_type, char *buf, int len)
{
write_int(f_out, ndx);
if (protocol_version < 29)
return;
write_shortint(f_out, iflags);
if (iflags & ITEM_BASIS_TYPE_FOLLOWS)
write_byte(f_out, fnamecmp_type);
if (iflags & ITEM_XNAME_FOLLOWS)
write_vstring(f_out, buf, len);
}
/* This is also used by receive.c with f_out = -1. */
int read_item_attrs(int f_in, int f_out, int ndx, uchar *type_ptr,
char *buf, int *len_ptr)
{
int len;
uchar fnamecmp_type = FNAMECMP_FNAME;
int iflags = protocol_version >= 29 ? read_shortint(f_in)
: ITEM_TRANSFER | ITEM_MISSING_DATA;
/* Handle the new keep-alive (no-op) packet. */
if (ndx == the_file_list->count && iflags == ITEM_IS_NEW)
;
else if (ndx < 0 || ndx >= the_file_list->count) {
rprintf(FERROR, "Invalid file index: %d (count=%d) [%s]\n",
ndx, the_file_list->count, who_am_i());
exit_cleanup(RERR_PROTOCOL);
} else if (iflags == ITEM_IS_NEW) {
rprintf(FERROR, "Invalid itemized flag word: %x [%s]\n",
iflags, who_am_i());
exit_cleanup(RERR_PROTOCOL);
}
if (iflags & ITEM_BASIS_TYPE_FOLLOWS)
fnamecmp_type = read_byte(f_in);
*type_ptr = fnamecmp_type;
if (iflags & ITEM_XNAME_FOLLOWS) {
if ((len = read_vstring(f_in, buf, MAXPATHLEN)) < 0)
exit_cleanup(RERR_PROTOCOL);
} else {
*buf = '\0';
len = -1;
}
*len_ptr = len;
if (iflags & ITEM_TRANSFER) {
if (!S_ISREG(the_file_list->files[ndx]->mode)) {
rprintf(FERROR,
"received request to transfer non-regular file: %d [%s]\n",
ndx, who_am_i());
exit_cleanup(RERR_PROTOCOL);
}
} else if (f_out >= 0) {
write_ndx_and_attrs(f_out, ndx, iflags,
fnamecmp_type, buf, len);
}
return iflags;
}
void send_files(struct file_list *flist, int f_out, int f_in)
{
int fd = -1;
struct sum_struct *s;
struct map_struct *mbuf = NULL;
STRUCT_STAT st;
char *fname2, fname[MAXPATHLEN];
char xname[MAXPATHLEN];
uchar fnamecmp_type;
int iflags, xlen;
struct file_struct *file;
int phase = 0, max_phase = protocol_version >= 29 ? 2 : 1;
struct stats initial_stats;
int save_make_backups = make_backups;
int itemizing = am_daemon ? daemon_log_format_has_i
: !am_server && log_format_has_i;
int f_xfer = write_batch < 0 ? batch_fd : f_out;
int i, j;
if (verbose > 2)
rprintf(FINFO,"send_files starting\n");
setup_readbuffer(f_in);
rprintf(FINFO, "send_files starting\n");
while (1) {
int offset=0;
unsigned int offset;
i = read_int(f_in);
if (i == -1) {
if (phase==0 && remote_version >= 13) {
phase++;
csum_length = SUM_LENGTH;
write_int(f_out,-1);
if (verbose > 2)
rprintf(FINFO,"send_files phase=%d\n",phase);
continue;
}
break;
if (++phase > max_phase)
break;
csum_length = SUM_LENGTH;
if (verbose > 2)
rprintf(FINFO, "send_files phase=%d\n", phase);
write_int(f_out, -1);
/* For inplace: redo phase turns off the backup
* flag so that we do a regular inplace send. */
make_backups = 0;
append_mode = 0;
continue;
}
if (i < 0 || i >= flist->count) {
rprintf(FERROR,"Invalid file index %d (count=%d)\n",
i, flist->count);
iflags = read_item_attrs(f_in, f_out, i, &fnamecmp_type,
xname, &xlen);
if (iflags == ITEM_IS_NEW) /* no-op packet */
continue;
file = flist->files[i];
if (file->dir.root) {
/* N.B. We're sure that this fits, so offset is OK. */
offset = strlcpy(fname, file->dir.root, sizeof fname);
if (!offset || fname[offset-1] != '/')
fname[offset++] = '/';
} else
offset = 0;
fname2 = f_name_to(file, fname + offset);
if (verbose > 2)
rprintf(FINFO, "send_files(%d, %s)\n", i, fname);
if (!(iflags & ITEM_TRANSFER)) {
maybe_log_item(file, iflags, itemizing, xname);
continue;
}
if (phase == 2) {
rprintf(FERROR,
"got transfer request in phase 2 [%s]\n",
who_am_i());
exit_cleanup(RERR_PROTOCOL);
}
file = flist->files[i];
updating_basis_file = inplace && (protocol_version >= 29
? fnamecmp_type == FNAMECMP_FNAME : !make_backups);
stats.current_file_index = i;
stats.num_transferred_files++;
stats.total_transferred_size += file->length;
fname[0] = 0;
if (file->basedir) {
strlcpy(fname,file->basedir,MAXPATHLEN);
if (strlen(fname) == MAXPATHLEN-1) {
io_error = 1;
rprintf(FERROR, "send_files failed on long-named directory %s\n",
fname);
return;
}
strlcat(fname,"/",MAXPATHLEN);
offset = strlen(file->basedir)+1;
}
strlcat(fname,f_name(file),MAXPATHLEN);
if (verbose > 2)
rprintf(FINFO,"send_files(%d,%s)\n",i,fname);
if (dry_run) {
if (!am_server) {
log_transfer(file, fname+offset);
}
write_int(f_out,i);
if (!do_xfers) { /* log the transfer */
if (!am_server && log_format)
log_item(file, &stats, iflags, NULL);
write_ndx_and_attrs(f_out, i, iflags, fnamecmp_type,
xname, xlen);
continue;
}
initial_stats = stats;
s = receive_sums(f_in);
if (!s) {
io_error = 1;
rprintf(FERROR,"receive_sums failed\n");
if (!(s = receive_sums(f_in))) {
io_error |= IOERR_GENERAL;
rprintf(FERROR, "receive_sums failed\n");
return;
}
fd = open(fname,O_RDONLY);
fd = do_open(fname, O_RDONLY, 0);
if (fd == -1) {
io_error = 1;
rprintf(FERROR,"send_files failed to open %s: %s\n",
fname,strerror(errno));
if (errno == ENOENT) {
enum logcode c = am_daemon
&& protocol_version < 28 ? FERROR
: FINFO;
io_error |= IOERR_VANISHED;
rprintf(c, "file has vanished: %s\n",
full_fname(fname));
} else {
io_error |= IOERR_GENERAL;
rsyserr(FERROR, errno,
"send_files failed to open %s",
full_fname(fname));
}
free_sums(s);
continue;
}
/* map the local file */
if (do_fstat(fd,&st) != 0) {
io_error = 1;
rprintf(FERROR,"fstat failed : %s\n",strerror(errno));
if (do_fstat(fd, &st) != 0) {
io_error |= IOERR_GENERAL;
rsyserr(FERROR, errno, "fstat failed");
free_sums(s);
close(fd);
return;
}
if (st.st_size > 0) {
buf = map_file(fd,st.st_size);
} else {
buf = NULL;
}
if (verbose > 2)
rprintf(FINFO,"send_files mapped %s of size %d\n",
fname,(int)st.st_size);
write_int(f_out,i);
write_int(f_out,s->count);
write_int(f_out,s->n);
write_int(f_out,s->remainder);
if (verbose > 2)
rprintf(FINFO,"calling match_sums %s\n",fname);
if (!am_server) {
log_transfer(file, fname+offset);
if (st.st_size) {
int32 read_size = MAX(s->blength * 3, MAX_MAP_SIZE);
mbuf = map_file(fd, st.st_size, read_size, s->blength);
} else
mbuf = NULL;
if (verbose > 2) {
rprintf(FINFO, "send_files mapped %s of size %.0f\n",
safe_fname(fname), (double)st.st_size);
}
write_ndx_and_attrs(f_out, i, iflags, fnamecmp_type,
xname, xlen);
write_sum_head(f_xfer, s);
if (verbose > 2) {
rprintf(FINFO, "calling match_sums %s\n",
safe_fname(fname));
}
if (log_before_transfer)
log_item(file, &initial_stats, iflags, NULL);
else if (!am_server && verbose && do_progress)
rprintf(FINFO, "%s\n", safe_fname(fname2));
set_compression(fname);
match_sums(f_out,s,buf,st.st_size);
log_send(file, &initial_stats);
if (buf) unmap_file(buf);
match_sums(f_xfer, s, mbuf, st.st_size);
if (do_progress)
end_progress(st.st_size);
if (!log_before_transfer)
log_item(file, &initial_stats, iflags, NULL);
if (mbuf) {
j = unmap_file(mbuf);
if (j) {
io_error |= IOERR_GENERAL;
rsyserr(FERROR, j,
"read errors mapping %s",
full_fname(fname));
}
}
close(fd);
free_sums(s);
if (verbose > 2)
rprintf(FINFO,"sender finished %s\n",fname);
if (verbose > 2) {
rprintf(FINFO, "sender finished %s\n",
safe_fname(fname));
}
/* Flag that we actually sent this entry. */
file->flags |= FLAG_SENT;
}
make_backups = save_make_backups;
if (verbose > 2)
rprintf(FINFO,"send files finished\n");
rprintf(FINFO, "send files finished\n");
match_report();
write_int(f_out,-1);
write_int(f_out, -1);
}

12
shconfig.in Executable file
View File

@@ -0,0 +1,12 @@
#! /bin/sh
# config.sh.in
# This file is processed by config.status to produce config.status,
# containing autoconf-determined values needed by the test scripts.
ECHO_T="@ECHO_T@"
ECHO_N="@ECHO_N@"
ECHO_C="@ECHO_C@"
export ECHO_T ECHO_N ECHO_C

805
socket.c
View File

@@ -1,178 +1,529 @@
/*
Copyright (C) Andrew Tridgell 1998
/* -*- c-file-style: "linux" -*-
rsync -- fast file replication program
Copyright (C) 1992-2001 by Andrew Tridgell <tridge@samba.org>
Copyright (C) 2001, 2002 by Martin Pool <mbp@samba.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
socket functions used in rsync
*/
/**
* @file socket.c
*
* Socket functions used in rsync.
*
* This file is now converted to use the new-style getaddrinfo()
* interface, which supports IPv6 but is also supported on recent
* IPv4-only machines. On systems that don't have that interface, we
* emulate it using the KAME implementation.
**/
#include "rsync.h"
/* open a socket to a tcp remote host with the specified port
based on code from Warren */
int open_socket_out(char *host, int port)
extern char *bind_address;
extern int default_af_hint;
/**
* Establish a proxy connection on an open socket to a web proxy by
* using the CONNECT method. If proxy_user and proxy_pass are not NULL,
* they are used to authenticate to the proxy using the "Basic"
* proxy-authorization protocol
**/
static int establish_proxy_connection(int fd, char *host, int port,
char *proxy_user, char *proxy_pass)
{
char *cp, buffer[1024];
char *authhdr, authbuf[1024];
int len;
if (proxy_user && proxy_pass) {
stringjoin(buffer, sizeof buffer,
proxy_user, ":", proxy_pass, NULL);
len = strlen(buffer);
if ((len*8 + 5) / 6 >= (int)sizeof authbuf) {
rprintf(FERROR,
"authentication information is too long\n");
return -1;
}
base64_encode(buffer, len, authbuf);
authhdr = "\r\nProxy-Authorization: Basic ";
} else {
*authbuf = '\0';
authhdr = "";
}
snprintf(buffer, sizeof buffer, "CONNECT %s:%d HTTP/1.0%s%s\r\n\r\n",
host, port, authhdr, authbuf);
len = strlen(buffer);
if (write(fd, buffer, len) != len) {
rsyserr(FERROR, errno, "failed to write to proxy");
return -1;
}
for (cp = buffer; cp < &buffer[sizeof buffer - 1]; cp++) {
if (read(fd, cp, 1) != 1) {
rsyserr(FERROR, errno, "failed to read from proxy");
return -1;
}
if (*cp == '\n')
break;
}
if (*cp != '\n')
cp++;
*cp-- = '\0';
if (*cp == '\r')
*cp = '\0';
if (strncmp(buffer, "HTTP/", 5) != 0) {
rprintf(FERROR, "bad response from proxy -- %s\n",
buffer);
return -1;
}
for (cp = &buffer[5]; isdigit(*(uchar*)cp) || *cp == '.'; cp++) {}
while (*cp == ' ')
cp++;
if (*cp != '2') {
rprintf(FERROR, "bad response from proxy -- %s\n",
buffer);
return -1;
}
/* throw away the rest of the HTTP header */
while (1) {
for (cp = buffer; cp < &buffer[sizeof buffer - 1]; cp++) {
if (read(fd, cp, 1) != 1) {
rsyserr(FERROR, errno,
"failed to read from proxy");
return -1;
}
if (*cp == '\n')
break;
}
if (cp > buffer && *cp == '\n')
cp--;
if (cp == buffer && (*cp == '\n' || *cp == '\r'))
break;
}
return 0;
}
/**
* Try to set the local address for a newly-created socket. Return -1
* if this fails.
**/
int try_bind_local(int s, int ai_family, int ai_socktype,
const char *bind_addr)
{
int error;
struct addrinfo bhints, *bres_all, *r;
memset(&bhints, 0, sizeof bhints);
bhints.ai_family = ai_family;
bhints.ai_socktype = ai_socktype;
bhints.ai_flags = AI_PASSIVE;
if ((error = getaddrinfo(bind_addr, NULL, &bhints, &bres_all))) {
rprintf(FERROR, RSYNC_NAME ": getaddrinfo %s: %s\n",
bind_addr, gai_strerror(error));
return -1;
}
for (r = bres_all; r; r = r->ai_next) {
if (bind(s, r->ai_addr, r->ai_addrlen) == -1)
continue;
freeaddrinfo(bres_all);
return s;
}
/* no error message; there might be some problem that allows
* creation of the socket but not binding, perhaps if the
* machine has no ipv6 address of this name. */
freeaddrinfo(bres_all);
return -1;
}
/**
* Open a socket to a tcp remote host with the specified port .
*
* Based on code from Warren. Proxy support by Stephen Rothwell.
* getaddrinfo() rewrite contributed by KAME.net.
*
* Now that we support IPv6 we need to look up the remote machine's
* address first, using @p af_hint to set a preference for the type
* of address. Then depending on whether it has v4 or v6 addresses we
* try to open a connection.
*
* The loop allows for machines with some addresses which may not be
* reachable, perhaps because we can't e.g. route ipv6 to that network
* but we can get ip4 packets through.
*
* @param bind_addr Local address to use. Normally NULL to bind
* the wildcard address.
*
* @param af_hint Address family, e.g. AF_INET or AF_INET6.
**/
int open_socket_out(char *host, int port, const char *bind_addr,
int af_hint)
{
int type = SOCK_STREAM;
struct sockaddr_in sock_out;
int res;
struct hostent *hp;
int error, s;
struct addrinfo hints, *res0, *res;
char portbuf[10];
char *h, *cp;
int proxied = 0;
char buffer[1024];
char *proxy_user = NULL, *proxy_pass = NULL;
res = socket(PF_INET, type, 0);
if (res == -1) {
/* if we have a RSYNC_PROXY env variable then redirect our
* connetcion via a web proxy at the given address. */
h = getenv("RSYNC_PROXY");
proxied = h != NULL && *h != '\0';
if (proxied) {
strlcpy(buffer, h, sizeof buffer);
/* Is the USER:PASS@ prefix present? */
if ((cp = strrchr(buffer, '@')) != NULL) {
*cp++ = '\0';
/* The remainder is the HOST:PORT part. */
h = cp;
if ((cp = strchr(buffer, ':')) == NULL) {
rprintf(FERROR,
"invalid proxy specification: should be USER:PASS@HOST:PORT\n");
return -1;
}
*cp++ = '\0';
proxy_user = buffer;
proxy_pass = cp;
} else {
/* The whole buffer is the HOST:PORT part. */
h = buffer;
}
if ((cp = strchr(h, ':')) == NULL) {
rprintf(FERROR,
"invalid proxy specification: should be HOST:PORT\n");
return -1;
}
*cp++ = '\0';
strlcpy(portbuf, cp, sizeof portbuf);
if (verbose >= 2) {
rprintf(FINFO, "connection via http proxy %s port %s\n",
h, portbuf);
}
} else {
snprintf(portbuf, sizeof portbuf, "%d", port);
h = host;
}
memset(&hints, 0, sizeof hints);
hints.ai_family = af_hint;
hints.ai_socktype = type;
error = getaddrinfo(h, portbuf, &hints, &res0);
if (error) {
rprintf(FERROR, RSYNC_NAME ": getaddrinfo: %s %s: %s\n",
h, portbuf, gai_strerror(error));
return -1;
}
hp = gethostbyname(host);
if (!hp) {
rprintf(FERROR,"unknown host: %s\n", host);
s = -1;
/* Try to connect to all addresses for this machine until we get
* through. It might e.g. be multi-homed, or have both IPv4 and IPv6
* addresses. We need to create a socket for each record, since the
* address record tells us what protocol to use to try to connect. */
for (res = res0; res; res = res->ai_next) {
s = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
if (s < 0)
continue;
if (bind_addr
&& try_bind_local(s, res->ai_family, type,
bind_addr) == -1) {
close(s);
s = -1;
continue;
}
if (connect(s, res->ai_addr, res->ai_addrlen) < 0) {
close(s);
s = -1;
continue;
}
if (proxied
&& establish_proxy_connection(s, host, port,
proxy_user, proxy_pass) != 0) {
close(s);
s = -1;
continue;
}
break;
}
freeaddrinfo(res0);
if (s < 0) {
rsyserr(FERROR, errno, "failed to connect to %s", h);
return -1;
}
memcpy(&sock_out.sin_addr, hp->h_addr, hp->h_length);
sock_out.sin_port = htons(port);
sock_out.sin_family = PF_INET;
if (connect(res,(struct sockaddr *)&sock_out,sizeof(sock_out))) {
close(res);
rprintf(FERROR,"failed to connect to %s - %s\n", host, strerror(errno));
return -1;
}
set_nonblocking(res);
return res;
return s;
}
/****************************************************************************
open a socket of the specified type, port and address for incoming data
****************************************************************************/
static int open_socket_in(int type, int port)
/**
* Open an outgoing socket, but allow for it to be intercepted by
* $RSYNC_CONNECT_PROG, which will execute a program across a TCP
* socketpair rather than really opening a socket.
*
* We use this primarily in testing to detect TCP flow bugs, but not
* cause security problems by really opening remote connections.
*
* This is based on the Samba LIBSMB_PROG feature.
*
* @param bind_addr Local address to use. Normally NULL to get the stack default.
**/
int open_socket_out_wrapped(char *host, int port, const char *bind_addr,
int af_hint)
{
struct hostent *hp;
struct sockaddr_in sock;
char host_name[MAXHOSTNAMELEN];
int res;
int one=1;
char *prog = getenv("RSYNC_CONNECT_PROG");
/* get my host name */
if (gethostname(host_name, sizeof(host_name)) == -1) {
rprintf(FERROR,"gethostname failed\n");
return -1;
}
/* get host info */
if ((hp = gethostbyname(host_name)) == 0) {
rprintf(FERROR,"gethostbyname: Unknown host %s\n",host_name);
return -1;
if (verbose >= 2) {
rprintf(FINFO, "%sopening tcp connection to %s port %d\n",
prog ? "Using RSYNC_CONNECT_PROG instead of " : "",
host, port);
}
memset((char *)&sock,0,sizeof(sock));
memcpy((char *)&sock.sin_addr,(char *)hp->h_addr, hp->h_length);
sock.sin_port = htons(port);
sock.sin_family = hp->h_addrtype;
sock.sin_addr.s_addr = INADDR_ANY;
res = socket(hp->h_addrtype, type, 0);
if (res == -1) {
rprintf(FERROR,"socket failed\n");
return -1;
}
setsockopt(res,SOL_SOCKET,SO_REUSEADDR,(char *)&one,sizeof(one));
/* now we've got a socket - we need to bind it */
if (bind(res, (struct sockaddr * ) &sock,sizeof(sock)) == -1) {
rprintf(FERROR,"bind failed on port %d\n", port);
close(res);
return -1;
}
return res;
if (prog)
return sock_exec(prog);
return open_socket_out(host, port, bind_addr, af_hint);
}
/****************************************************************************
determine if a file descriptor is in fact a socket
****************************************************************************/
/**
* Open one or more sockets for incoming data using the specified type,
* port, and address.
*
* The getaddrinfo() call may return several address results, e.g. for
* the machine's IPv4 and IPv6 name.
*
* We return an array of file-descriptors to the sockets, with a trailing
* -1 value to indicate the end of the list.
*
* @param bind_addr Local address to bind, or NULL to allow it to
* default.
**/
static int *open_socket_in(int type, int port, const char *bind_addr,
int af_hint)
{
int one = 1;
int s, *socks, maxs, i;
struct addrinfo hints, *all_ai, *resp;
char portbuf[10];
int error;
memset(&hints, 0, sizeof hints);
hints.ai_family = af_hint;
hints.ai_socktype = type;
hints.ai_flags = AI_PASSIVE;
snprintf(portbuf, sizeof portbuf, "%d", port);
error = getaddrinfo(bind_addr, portbuf, &hints, &all_ai);
if (error) {
rprintf(FERROR, RSYNC_NAME ": getaddrinfo: bind address %s: %s\n",
bind_addr, gai_strerror(error));
return NULL;
}
/* Count max number of sockets we might open. */
for (maxs = 0, resp = all_ai; resp; resp = resp->ai_next, maxs++) {}
if (!(socks = new_array(int, maxs + 1)))
out_of_memory("open_socket_in");
/* We may not be able to create the socket, if for example the
* machine knows about IPv6 in the C library, but not in the
* kernel. */
for (resp = all_ai, i = 0; resp; resp = resp->ai_next) {
s = socket(resp->ai_family, resp->ai_socktype,
resp->ai_protocol);
if (s == -1) {
/* See if there's another address that will work... */
continue;
}
setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
(char *)&one, sizeof one);
#ifdef IPV6_V6ONLY
if (resp->ai_family == AF_INET6) {
if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY,
(char *)&one, sizeof one) < 0
&& default_af_hint != AF_INET6) {
close(s);
continue;
}
}
#endif
/* Now we've got a socket - we need to bind it. */
if (bind(s, resp->ai_addr, resp->ai_addrlen) < 0) {
/* Nope, try another */
close(s);
continue;
}
socks[i++] = s;
}
socks[i] = -1;
if (all_ai)
freeaddrinfo(all_ai);
if (!i) {
rprintf(FERROR,
"unable to bind any inbound sockets on port %d\n",
port);
free(socks);
return NULL;
}
return socks;
}
/*
* Determine if a file descriptor is in fact a socket
*/
int is_a_socket(int fd)
{
int v,l;
l = sizeof(int);
return(getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&v, &l) == 0);
int v;
socklen_t l = sizeof (int);
/* Parameters to getsockopt, setsockopt etc are very
* unstandardized across platforms, so don't be surprised if
* there are compiler warnings on e.g. SCO OpenSwerver or AIX.
* It seems they all eventually get the right idea.
*
* Debian says: ``The fifth argument of getsockopt and
* setsockopt is in reality an int [*] (and this is what BSD
* 4.* and libc4 and libc5 have). Some POSIX confusion
* resulted in the present socklen_t. The draft standard has
* not been adopted yet, but glibc2 already follows it and
* also has socklen_t [*]. See also accept(2).''
*
* We now return to your regularly scheduled programming. */
return getsockopt(fd, SOL_SOCKET, SO_TYPE, (char *)&v, &l) == 0;
}
void start_accept_loop(int port, int (*fn)(int ))
static RETSIGTYPE sigchld_handler(UNUSED(int val))
{
int s;
#ifdef WNOHANG
while (waitpid(-1, NULL, WNOHANG) > 0) {}
#endif
signal(SIGCHLD, sigchld_handler);
}
void start_accept_loop(int port, int (*fn)(int, int))
{
fd_set deffds;
int *sp, maxfd, i;
/* open an incoming socket */
s = open_socket_in(SOCK_STREAM, port);
if (s == -1)
sp = open_socket_in(SOCK_STREAM, port, bind_address, default_af_hint);
if (sp == NULL)
exit_cleanup(RERR_SOCKETIO);
/* ready to listen */
if (listen(s, 5) == -1) {
close(s);
exit_cleanup(RERR_SOCKETIO);
FD_ZERO(&deffds);
for (i = 0, maxfd = -1; sp[i] >= 0; i++) {
if (listen(sp[i], 5) < 0) {
rsyserr(FERROR, errno, "listen() on socket failed");
#ifdef INET6
if (errno == EADDRINUSE && i > 0) {
rprintf(FINFO,
"Try using --ipv4 or --ipv6 to avoid this listen() error.\n");
}
#endif
exit_cleanup(RERR_SOCKETIO);
}
FD_SET(sp[i], &deffds);
if (maxfd < sp[i])
maxfd = sp[i];
}
/* now accept incoming connections - forking a new process
for each incoming connection */
* for each incoming connection */
while (1) {
fd_set fds;
pid_t pid;
int fd;
struct sockaddr addr;
int in_addrlen = sizeof(addr);
struct sockaddr_storage addr;
socklen_t addrlen = sizeof addr;
FD_ZERO(&fds);
FD_SET(s, &fds);
/* close log file before the potentially very long select so
* file can be trimmed by another process instead of growing
* forever */
logfile_close();
if (select(s+1, &fds, NULL, NULL, NULL) != 1) {
continue;
}
if(!FD_ISSET(s, &fds)) continue;
fd = accept(s,&addr,&in_addrlen);
if (fd == -1) continue;
signal(SIGCHLD, SIG_IGN);
/* we shouldn't have any children left hanging around
but I have had reports that on Digital Unix zombies
are produced, so this ensures that they are reaped */
#ifdef WNOHANG
waitpid(-1, NULL, WNOHANG);
#ifdef FD_COPY
FD_COPY(&deffds, &fds);
#else
fds = deffds;
#endif
if (fork()==0) {
close(s);
if (select(maxfd + 1, &fds, NULL, NULL, NULL) != 1)
continue;
set_nonblocking(fd);
_exit(fn(fd));
for (i = 0, fd = -1; sp[i] >= 0; i++) {
if (FD_ISSET(sp[i], &fds)) {
fd = accept(sp[i], (struct sockaddr *)&addr,
&addrlen);
break;
}
}
close(fd);
if (fd < 0)
continue;
signal(SIGCHLD, sigchld_handler);
if ((pid = fork()) == 0) {
int ret;
for (i = 0; sp[i] >= 0; i++)
close(sp[i]);
/* Re-open log file in child before possibly giving
* up privileges (see logfile_close() above). */
logfile_reopen();
ret = fn(fd, fd);
close_all();
_exit(ret);
} else if (pid < 0) {
rsyserr(FERROR, errno,
"could not create child server process");
close(fd);
/* This might have happened because we're
* overloaded. Sleep briefly before trying to
* accept again. */
sleep(2);
} else {
/* Parent doesn't need this fd anymore. */
close(fd);
}
}
}
@@ -219,21 +570,24 @@ struct
#endif
{NULL,0,0,0,0}};
/****************************************************************************
set user socket options
****************************************************************************/
/**
* Set user socket options
**/
void set_socket_options(int fd, char *options)
{
char *tok;
if (!options || !*options) return;
if (!options || !*options)
return;
options = strdup(options);
if (!options) out_of_memory("set_socket_options");
for (tok=strtok(options, " \t,"); tok; tok=strtok(NULL," \t,")) {
if (!options)
out_of_memory("set_socket_options");
for (tok = strtok(options, " \t,"); tok; tok = strtok(NULL," \t,")) {
int ret=0,i;
int value = 1;
char *p;
@@ -245,9 +599,10 @@ void set_socket_options(int fd, char *options)
got_value = 1;
}
for (i=0;socket_options[i].name;i++)
for (i = 0; socket_options[i].name; i++) {
if (strcmp(socket_options[i].name,tok)==0)
break;
}
if (!socket_options[i].name) {
rprintf(FERROR,"Unknown socket option %s\n",tok);
@@ -258,31 +613,35 @@ void set_socket_options(int fd, char *options)
case OPT_BOOL:
case OPT_INT:
ret = setsockopt(fd,socket_options[i].level,
socket_options[i].option,(char *)&value,sizeof(int));
socket_options[i].option,
(char *)&value, sizeof (int));
break;
case OPT_ON:
if (got_value)
rprintf(FERROR,"syntax error - %s does not take a value\n",tok);
rprintf(FERROR,"syntax error -- %s does not take a value\n",tok);
{
int on = socket_options[i].value;
ret = setsockopt(fd,socket_options[i].level,
socket_options[i].option,(char *)&on,sizeof(int));
socket_options[i].option,
(char *)&on, sizeof (int));
}
break;
break;
}
if (ret != 0) {
rsyserr(FERROR, errno,
"failed to set socket option %s", tok);
}
if (ret != 0)
rprintf(FERROR,"Failed to set socket option %s\n",tok);
}
free(options);
}
/****************************************************************************
become a daemon, discarding the controlling terminal
****************************************************************************/
/**
* Become a daemon, discarding the controlling terminal
**/
void become_daemon(void)
{
int i;
@@ -294,95 +653,129 @@ void become_daemon(void)
/* detach from the terminal */
#ifdef HAVE_SETSID
setsid();
#else
#ifdef TIOCNOTTY
#elif defined TIOCNOTTY
i = open("/dev/tty", O_RDWR);
if (i >= 0) {
ioctl(i, (int) TIOCNOTTY, (char *)0);
ioctl(i, (int)TIOCNOTTY, (char *)0);
close(i);
}
#endif /* TIOCNOTTY */
#endif
/* make sure that stdin, stdout an stderr don't stuff things
up (library functions, for example) */
for (i=0;i<3;i++) {
close(i);
* up (library functions, for example) */
for (i = 0; i < 3; i++) {
close(i);
open("/dev/null", O_RDWR);
}
}
/*******************************************************************
return the IP addr of the client as a string
******************************************************************/
char *client_addr(int fd)
/**
* This is like socketpair but uses tcp. It is used by the Samba
* regression test code.
*
* The function guarantees that nobody else can attach to the socket,
* or if they do that this function fails and the socket gets closed
* returns 0 on success, -1 on failure the resulting file descriptors
* are symmetrical.
**/
static int socketpair_tcp(int fd[2])
{
struct sockaddr sa;
struct sockaddr_in *sockin = (struct sockaddr_in *) (&sa);
int length = sizeof(sa);
static char addr_buf[100];
static int initialised;
int listener;
struct sockaddr_in sock;
struct sockaddr_in sock2;
socklen_t socklen = sizeof sock;
int connect_done = 0;
if (initialised) return addr_buf;
fd[0] = fd[1] = listener = -1;
initialised = 1;
memset(&sock, 0, sizeof sock);
if (getpeername(fd, &sa, &length)) {
exit_cleanup(RERR_SOCKETIO);
if ((listener = socket(PF_INET, SOCK_STREAM, 0)) == -1)
goto failed;
memset(&sock2, 0, sizeof sock2);
#ifdef HAVE_SOCKADDR_IN_LEN
sock2.sin_len = sizeof sock2;
#endif
sock2.sin_family = PF_INET;
bind(listener, (struct sockaddr *)&sock2, sizeof sock2);
if (listen(listener, 1) != 0)
goto failed;
if (getsockname(listener, (struct sockaddr *)&sock, &socklen) != 0)
goto failed;
if ((fd[1] = socket(PF_INET, SOCK_STREAM, 0)) == -1)
goto failed;
set_nonblocking(fd[1]);
sock.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
if (connect(fd[1], (struct sockaddr *)&sock, sizeof sock) == -1) {
if (errno != EINPROGRESS)
goto failed;
} else
connect_done = 1;
if ((fd[0] = accept(listener, (struct sockaddr *)&sock, &socklen)) == -1)
goto failed;
close(listener);
listener = -1;
set_blocking(fd[1]);
if (connect_done == 0) {
if (connect(fd[1], (struct sockaddr *)&sock, sizeof sock) != 0
&& errno != EISCONN)
goto failed;
}
strlcpy(addr_buf,(char *)inet_ntoa(sockin->sin_addr), sizeof(addr_buf));
return addr_buf;
/* all OK! */
return 0;
failed:
if (fd[0] != -1)
close(fd[0]);
if (fd[1] != -1)
close(fd[1]);
if (listener != -1)
close(listener);
return -1;
}
/*******************************************************************
return the DNS name of the client
******************************************************************/
char *client_name(int fd)
/**
* Run a program on a local tcp socket, so that we can talk to it's
* stdin and stdout. This is used to fake a connection to a daemon
* for testing -- not for the normal case of running SSH.
*
* @return a socket which is attached to a subprocess running
* "prog". stdin and stdout are attached. stderr is left attached to
* the original stderr
**/
int sock_exec(const char *prog)
{
struct sockaddr sa;
struct sockaddr_in *sockin = (struct sockaddr_in *) (&sa);
int length = sizeof(sa);
static char name_buf[100];
struct hostent *hp;
char **p;
char *def = "UNKNOWN";
static int initialised;
int fd[2];
if (initialised) return name_buf;
initialised = 1;
strcpy(name_buf,def);
if (getpeername(fd, &sa, &length)) {
exit_cleanup(RERR_SOCKETIO);
if (socketpair_tcp(fd) != 0) {
rsyserr(FERROR, errno, "socketpair_tcp failed");
return -1;
}
/* Look up the remote host name. */
if ((hp = gethostbyaddr((char *) &sockin->sin_addr,
sizeof(sockin->sin_addr),
AF_INET))) {
strlcpy(name_buf,(char *)hp->h_name,sizeof(name_buf));
if (verbose >= 2)
rprintf(FINFO, "Running socket program: \"%s\"\n", prog);
if (fork() == 0) {
close(fd[0]);
close(0);
close(1);
dup(fd[1]);
dup(fd[1]);
exit(system(prog));
}
/* do a forward lookup as well to prevent spoofing */
hp = gethostbyname(name_buf);
if (!hp) {
strcpy(name_buf,def);
rprintf(FERROR,"reverse name lookup failed\n");
} else {
for (p=hp->h_addr_list;*p;p++) {
if (memcmp(*p, &sockin->sin_addr, hp->h_length) == 0) {
break;
}
}
if (!*p) {
strcpy(name_buf,def);
rprintf(FERROR,"reverse name lookup mismatch - spoofed address?\n");
}
}
return name_buf;
close(fd[1]);
return fd[0];
}

6
support/Makefile Normal file
View File

@@ -0,0 +1,6 @@
all: savetransfer
savetransfer: savetransfer.o
clean:
rm -f *.o savetransfer

90
support/atomic-rsync Executable file
View File

@@ -0,0 +1,90 @@
#!/usr/bin/perl
#
# This script lets you update a hierarchy of files in an atomic way by
# first creating a new hierarchy using rsync's --link-dest option, and
# then swapping the hierarchy into place. **See the usage message for
# more details and some important caveats!**
use strict;
use Cwd 'abs_path';
my $RSYNC_PROG = '/usr/bin/rsync';
my $RM_PROG = '/bin/rm';
my $dest_dir = $ARGV[-1];
usage(1) if $dest_dir eq '' || $dest_dir =~ /^--/;
if (!-d $dest_dir) {
print STDERR "$dest_dir is not a directory.\n\n";
usage(1);
}
if (@_ = grep(/^--(link|compare)-dest/, @ARGV)) {
$_ = join(' or ', @_);
print STDERR "You may not use $_ as an rsync option.\n\n";
usage(1);
}
$dest_dir = abs_path($dest_dir);
if ($dest_dir eq '/') {
print STDERR 'You must not use "/" as the destination directory.', "\n\n";
usage(1);
}
my $old_dir = "$dest_dir~old~";
my $new_dir = $ARGV[-1] = "$dest_dir~new~";
system($RM_PROG, '-rf', $old_dir) if -d $old_dir;
if (system($RSYNC_PROG, "--link-dest=$dest_dir", @ARGV)) {
if ($? == -1) {
print "failed to execute $RSYNC_PROG: $!\n";
} elsif ($? & 127) {
printf "child died with signal %d, %s coredump\n",
($? & 127), ($? & 128) ? 'with' : 'without';
} else {
printf "child exited with value %d\n", $? >> 8;
}
exit $?;
}
rename($dest_dir, $old_dir) or die "Unable to rename $new_dir to $old_dir: $!";
rename($new_dir, $dest_dir) or die "Unable to rename $new_dir to $dest_dir: $!";
exit;
sub usage
{
my($ret) = @_;
my $fh = $ret ? *STDERR : *STDOUT;
print $fh <<EOT;
Usage: atomic-rsync [RSYNC-OPTIONS] HOST:/SOURCE/DIR/ /DEST/DIR/
atomic-rsync [RSYNC-OPTIONS] HOST::MOD/DIR/ /DEST/DIR/
This script lets you update a hierarchy of files in an atomic way by first
creating a new hierarchy (using hard-links to leverage the existing files),
and then swapping the new hierarchy into place. You must be pulling files
to a local directory, and that directory must already exist. For example:
atomic-rsync -av host:/remote/files/ /local/files/
This would make the transfer to the directory /local/files~new~ and then
swap out /local/files at the end of the transfer by renaming it to
/local/files~old~ and putting the new directory into its place. The
/local/files~old~ directory will be preserved until the next update, at
which point it will be deleted.
Do NOT specify this command:
atomic-rsync -av host:/remote/files /local/
... UNLESS you want the entire /local dir to be swapped out!
See the "rsync" command for its list of options. You may not use the
--link-dest or --compare-dest options (since this script uses --link-dest
to make the transfer efficient). Also, the destination directory cannot
be "/".
EOT
exit $ret;
}

64
support/cull_options Executable file
View File

@@ -0,0 +1,64 @@
#!/usr/bin/perl
# This script outputs some perl code that parses all possible options
# that the code in options.c might send to the server. This perl code
# is included in the rrsync script.
use strict;
our(%short_no_arg, %short_with_num, %long_opt);
our $last_long_opt;
open(IN, '../options.c') or die "Unable to open ../options.c: $!\n";
while (<IN>) {
if (/\Qargstr[x++]\E = '(.)'/) {
$short_no_arg{$1} = 1;
undef $last_long_opt;
} elsif (/\Qasprintf(\E[^,]+, "-([a-zA-Z0-9])\%l?[ud]"/) {
$short_with_num{$1} = 1;
undef $last_long_opt;
} elsif (/\Qargs[ac++]\E = "--([^"=]+)"/) {
$last_long_opt = $1;
$long_opt{$1} = 0;
} elsif (defined($last_long_opt)
&& /\Qargs[ac++]\E = ([^["\s]+);/ && $1 ne 'dest_option') {
$long_opt{$last_long_opt} = 2;
undef $last_long_opt;
} elsif (/dest_option = "--([^"]+)"/) {
$long_opt{$1} = 2;
undef $last_long_opt;
} elsif (/\Qasprintf(\E[^,]+, "--([^"=]+)=/ || /\Qargs[ac++]\E = "--([^"=]+)=/) {
$long_opt{$1} = 1;
undef $last_long_opt;
}
}
close IN;
my $short_no_arg = join('', sort keys %short_no_arg);
my $short_with_num = join('', sort keys %short_with_num);
print <<EOT;
# These options are the only options that rsync might send to the server,
# and only in the option format that the stock rsync produces.
# To disable a short-named option, add its letter to this string:
our \$short_disabled = '';
our \$short_no_arg = '$short_no_arg'; # DO NOT REMOVE ANY
our \$short_with_num = '$short_with_num'; # DO NOT REMOVE ANY
# To disable a long-named option, change its value to a -1. The values mean:
# 0 = the option has no arg; 1 = the arg doesn't need any checking; 2 = only
# check the arg when receiving; and 3 = always check the arg.
our \%long_opt = (
EOT
foreach my $opt (sort keys %long_opt) {
my $val = $long_opt{$opt};
$val = 1 if $opt =~ /^max-/;
$val = 3 if $opt eq 'files-from';
$val = '$ro ? -1 : ' . $val if $opt =~ /^remove-/;
print " '$opt' => $val,\n";
}
print ");\n\n";

42
support/cvs2includes Executable file
View File

@@ -0,0 +1,42 @@
#!/usr/bin/perl
#
# This script finds all CVS/Entries files in the current directory and below
# and creates a local .cvsinclude file with non-inherited rules including each
# checked-in file. Then, use this option whenever using --cvs-exclude (-C):
#
# -f ': .cvsinclude'
#
# That ensures that all checked-in files/dirs are included in the transfer.
# (You could alternately put ": .cvsinclude" into an .rsync-filter file and
# use the -F option, which is easier to type.)
#
# The downside is that you need to remember to re-run cvs2includes whenever
# You add a new file to the project.
use strict;
open(FIND, 'find . -name CVS -type d |') or die $!;
while (<FIND>) {
chomp;
s#^\./##;
my $entries = "$_/Entries";
s/CVS$/.cvsinclude/;
my $filter = $_;
open(ENTRIES, $entries) or die "Unable to open $entries: $!\n";
my @includes;
while (<ENTRIES>) {
push(@includes, $1) if m#/(.+?)/#;
}
close ENTRIES;
if (@includes) {
open(FILTER, ">$filter") or die "Unable to write $filter: $!\n";
print FILTER '+ /', join("\n+ /", @includes), "\n";
close FILTER;
print "Updated $filter\n";
} elsif (-f $filter) {
unlink($filter);
print "Removed $filter\n";
}
}
close FIND;

44
support/mnt-excl Executable file
View File

@@ -0,0 +1,44 @@
#!/usr/bin/perl -w
# This script takes a command-line arg of a source directory
# that will be passed to rsync, and generates a set of excludes
# that will exclude all mount points from the list. This is
# useful if you have "bind" mounts since the --one-file-system
# option won't notice the transition to a different spot on
# the same disk. For example:
#
# mnt-excl /dir | rsync --exclude-from=- ... /dir /dest/
# mnt-excl /dir/ | rsync --exclude-from=- ... /dir/ /dest/
# ssh host mnt-excl /dir | rsync --exclude-from=- ... host:/dir /dest/
#
# Imagine that /dir/foo is a mount point: the first invocation of
# mnt-excl would have output /dir/foo, while the second would have
# output /foo (which are the properly anchored excludes).
#
# NOTE: This script expects /proc/mounts to exist, but could be
# easily adapted to read /etc/mtab or similar.
#
# ADDENDUM: The addition of the --filter option (which has support for
# absolute-anchored excludes) has made this script less useful than it
# was. Beginning with 2.6.4, you can achieve the effect of this script
# through this command:
#
# awk '{print $2}' /proc/mounts | rsync -f 'merge,/- -' host:/dir /dest/
use strict;
use Cwd 'abs_path';
my $file = '/proc/mounts';
my $dir = shift || '/';
$dir = abs_path($dir);
$dir =~ s#([^/]*)$##;
my $trailing = $1;
$trailing = '' if $trailing eq '.' || !-d "$dir$trailing";
$trailing .= '/' if $trailing ne '';
open(IN, $file) or die "Unable to open $file: $!\n";
while (<IN>) {
$_ = (split)[1];
next unless s#^\Q$dir$trailing\E##o && $_ ne '';
print "- /$trailing$_\n";
}
close IN;

Some files were not shown because too many files have changed in this diff Show More