Compare commits

...

2365 Commits

Author SHA1 Message Date
Wayne Davison
8ba802f3b4 Preparing for release of 3.0.2 2008-04-08 08:16:05 -07:00
Wayne Davison
e53f49d1af Call patch-update in its new location. 2008-04-08 08:15:39 -07:00
Wayne Davison
0917f581bc Roll over the NEWS files for the next release. 2008-04-08 08:03:20 -07:00
Wayne Davison
1fe2a3533f Fixed a potential overflow issue with realloc() that Sebastian Krahmer
pointed out.
2008-04-08 08:01:43 -07:00
Wayne Davison
237e9a178f Have the spec file put more useful stuff into the doc dir. 2008-04-05 22:46:48 -07:00
Wayne Davison
0668bfe077 Moving some files from support into packaging. 2008-04-05 22:45:12 -07:00
Wayne Davison
214af6ad83 Comment out the Source1 tar file by default in the spec file. 2008-04-04 00:27:14 -07:00
Wayne Davison
2551c47eb7 Fixed the code that removes old file versions for a final release. 2008-04-04 00:05:44 -07:00
Wayne Davison
83d22fd7f9 Bump the repository version to 3.0.2dev. 2008-04-04 00:04:58 -07:00
Wayne Davison
325c243210 Preparing for release of 3.0.1 2008-04-03 22:37:01 -07:00
Wayne Davison
4e90cfbfed A few more spec-file tweaks. 2008-04-01 20:00:08 -07:00
Wayne Davison
6fd2c27f38 Define a "srcdir" in the spec file and use it in the URLs for the
source files so that they use the unchanging src or src-preview
subdirectory location for the file.
2008-04-01 12:55:27 -07:00
Wayne Davison
19173d224a Tweaked rsync.spec to use "rsync" in place of "%{name}" in a few
places (which allows for easier creation of adjunct RPMs).
2008-03-31 14:10:07 -07:00
Wayne Davison
5b83829669 A simple change to change_pathname() to ensure that the error output
mentions the right path when dir == NULL.
2008-03-31 07:46:47 -07:00
Wayne Davison
8cd3c6dccf Preparing for release of 3.0.1pre3 2008-03-30 23:29:43 -07:00
Wayne Davison
29a89172f7 Improved the chdir() code:
- Renamed push_dir() to change_dir() and revised it a little so that it
  can chdir() to a relative path without an intervening chdir() back to
  the staring path.
- Renamed push_pathname() to change_pathname() and revised it to take
  different args and to only call path_is_daemon_excluded() on a new
  path (not a revisit of a file's already-checked path).
- Fixed change_pathname() to set the right pathname value when a chdir()
  call fails.
- Set orig_dir once outside of the change_pathname() function.
- Got rid of pop_dir().
2008-03-30 15:44:46 -07:00
Wayne Davison
2089375179 Some argc-based actions in parse_arguments() shouldn't happen on
the server side.
2008-03-30 08:05:50 -07:00
Wayne Davison
f8949e7647 Fixed a path-exclusion glitch when checking more than one arg. 2008-03-30 08:05:42 -07:00
Wayne Davison
84ecaa0eca Improved the code that protects a '.' dir from exclusion.
This fixed a glitch in the daemon-exclusion code that allowed
an exclude rule such as ".*" or "*/" to affect a '.' dir.
2008-03-29 23:06:18 -07:00
Wayne Davison
3f2d8d683a Extended a test to ensure that hard-linked distant files continues
to work in incremental-recursion mode.
2008-03-28 10:40:17 -07:00
Wayne Davison
fd2598022c Allow the file-list sending code to set XMIT_SAME_UID/XMIT_SAME_GID
when owner/group info isn't being preserved.  This helps to ensure
that the lower 8 bits of the xflags aren't 0, and is what older
rsync versions did.
2008-03-28 10:40:10 -07:00
Wayne Davison
b05c58cce6 Dump an extraneous empty line. 2008-03-28 10:30:11 -07:00
Wayne Davison
05805cd6b7 Preparing for release of 3.0.1pre2 2008-03-26 17:12:07 -07:00
Wayne Davison
a165be754b Mention two more NEWS items. 2008-03-26 17:04:29 -07:00
Wayne Davison
af3172c148 Ensure that a per-dir merge file is also loaded from implied directories
in the sender (was working in incremental mode).
2008-03-26 16:49:12 -07:00
Wayne Davison
487cb52615 Fixed the discovery of a prior finished hard-link when the entry
is old enough that it is no longer in the flist data.
2008-03-26 16:12:39 -07:00
Wayne Davison
9793bbb364 Improved a length check in parse_merge_name(). 2008-03-26 14:01:52 -07:00
Wayne Davison
f6f74b93ef Ensure that a per-dir merge file is also loaded from implied directories
in the generator (for protocol 30, at least).
2008-03-26 14:01:26 -07:00
Wayne Davison
7568ff448a Fixed the way rsync handles iconv-conversion problems in the file-list:
- If the sender cannot convert a name, the discarding of the entry now
  occurs soon enough to avoid affecting the sender's list (which was
  causing the file-list on the receiving side to be out of sync).
- If the receiver cannot convert a name, its transformation of the name
  into an empty name (which indicates that the entry should be skipped)
  is no longer thwarted by the clean_fname() call (which was changing
  the name into a ".").
2008-03-25 10:46:06 -07:00
Wayne Davison
56158b7e04 Preparing for release of 3.0.1pre1 2008-03-24 21:15:51 -07:00
Wayne Davison
798a9e4e74 Some more improvements for the packaging/release-rsync script:
- Check early if the version tag already exists, so it aborts right
  away if the release script can't do its work.
- Update the files in the "patches" dir while merging the master branch
  into the patch branches (done before creating the release patches for
  the rsync-patches tar file).
- Allow the user to ask to visit each patch when updating them.
- Pause after initial patch updating so that any extra patch changes
  can be done before the creating of the tar files.
- Ask for the GPG signing passphrase once for all signing commands.
2008-03-24 21:15:30 -07:00
Wayne Davison
c202b4fa96 Some improvements for support/patch-update:
- Added a --shell option which starts a sub-shell on each patch branch.
- Don't allow the user to exit a sub-shell if the branch is not clean.
- If the sub-shell exited with a non-zero exit status, prompt to see if
  the user wanted to abort rather than assuming that.
- Wait to start the new patch-file output until after the shell runs.
- Always return to the starting branch on exit.
2008-03-24 20:30:09 -07:00
Wayne Davison
1df02d13d3 Don't send daemon-config filter-action messages back to the user. 2008-03-24 10:14:59 -07:00
Wayne Davison
73cb6738b3 Improved --dirs/--no-dirs/--list-only option handling:
- Moved setting of list_only and xfer_dirs from main.c to options.c.
- Fixed the ability of the user to force --no-dirs.
- Added the --old-dirs/--old-d option to make it easier to interact
  in list-only mode with an older rsync.
- Suggest the use of --old-d instead of "-r --exclude='/*/*'".
2008-03-24 09:54:04 -07:00
Wayne Davison
ba8672dfab Added a couple more NEWS items. 2008-03-23 10:06:53 -07:00
Wayne Davison
a5e0bf3579 Properly handle a new patch-branch that is only available locally. 2008-03-23 09:53:15 -07:00
Wayne Davison
99ba99c74c Changed the way version numbering of pre-releases will be done in
the RPM spec file so that they order prior to the final release.
2008-03-23 00:10:12 -07:00
Wayne Davison
469ff84e29 More NEWS updates and improvements. 2008-03-22 22:33:04 -07:00
Wayne Davison
b5daf5300f Made the filename arg-parsing code skip args that have excluded path
components, returning the same errors that would occur if the path
elements didn't actually exist.  The glob_match() code was also
changed to no longer truncate an arg with an excluded path element
(it just omits excluded items from glob matching).
2008-03-22 15:33:18 -07:00
Wayne Davison
f5aeb6ff9b Added XFLG_DIR2WILD3 flag that the daemon uses to transform any
config-file dir/ exclude rule into a dir/*** rule.
2008-03-22 14:02:34 -07:00
Wayne Davison
4c74d44dab A couple fixes in add_rule() for XFLG_ABS_IF_SLASH:
- Remove the trailing slash earlier, so that it doesn't
  affect the XFLG_ABS_IF_SLASH check.
- Count the slashes earlier so that the XFLG_ABS_IF_SLASH
  can use it instead of using a strchr() all that could
  scan past the end of the input.
2008-03-22 12:30:43 -07:00
Wayne Davison
4a86fbcda0 Change ex_len to pre_len in add_rule(). 2008-03-22 12:21:41 -07:00
Wayne Davison
bc267e0f57 Improved ENSURE_MEMSPACE() macro and use it in more places in glob code. 2008-03-22 08:13:04 -07:00
Wayne Davison
fc05137846 Mention the most recent changes in the NEWS. 2008-03-21 17:50:01 -07:00
Wayne Davison
c085ece623 Some RPM spec file improvements:
- Added installation of new /etc/xinetd.d/rsync config file.
- Added commented-out lines to demonstrate how to use rsync-patches.
2008-03-21 17:11:20 -07:00
Wayne Davison
91f625cee0 Make glob_expand() return an indicator if the glob had no matches. 2008-03-21 15:00:28 -07:00
Wayne Davison
27b067f87b Changed d_name() to be a static inline function. 2008-03-21 07:26:25 -07:00
Wayne Davison
987a546756 A couple improvements to the new arg-globbing code:
- Put all the state variables into a single struct.
- Reuse the buffer memory for each glob_expand() call until a final
  call with a NULL pointer tells us to free it.
2008-03-21 07:22:34 -07:00
Wayne Davison
4d30f17671 Changed the arg-globbing routine to use a custom arg-globbing algorithm
that does not include any daemon-excluded items in the matches.  It is
also not subverted by the presence of one or more dot-dir elements in
an arg.
2008-03-20 23:30:09 -07:00
Wayne Davison
d48810ba5b Some improvements to the file-name cleaning code:
- Removed the CFN_KEEP_LEADING_DOT_DIR flag for clean_fname().
- Explicitly add an implied dot-dir to the transfer rather than keeping
  a leading a "./" prefix as a part of a relative pathname.
- Added the CFN_KEEP_DOT_DIRS flag for clean_fname().
- Added the SP_KEEP_DOT_DIRS flag for sanitize_path().
- Call clean_fname() a couple more times.
2008-03-20 22:39:29 -07:00
Wayne Davison
819bfe4599 Changed the name of the server_filter_list to be
daemon_filter_list, for improved clarity.
2008-03-20 10:42:43 -07:00
Wayne Davison
d2f6e19262 Fixed a bug in the truncating of daemon-excluded paths. 2008-03-20 10:35:53 -07:00
Wayne Davison
e889e0c43b A couple more support/rrsync tweaks:
- Die if the --server option is not first on the command-line.
- Don't allow the --daemon option by default.
2008-03-19 16:44:11 -07:00
Wayne Davison
6e0bf4d840 Some more minor changes for the skip/missing/dry_run code. 2008-03-19 08:59:44 -07:00
Matt McCutchen
83a8ca7b14 Unsnarl missing_below/dry_run logic.
The generator can skip a directory's contents altogether due to
--ignore-non-existing, a daemon exclude, or a mkdir failure.  On a
--dry-run, the generator can also note the missingness of a directory
while still scanning its contents.  These two scenarios were conflated
using a single set of missing_below/missing_dir variables in combination
with transient increments in dry_run; this caused at least three bugs.

Now recv_generator has separate variables for the two scenarios, called
skip_dir and dry_missing_dir, respectively.  For simplicity, we take the
F_DEPTH instead of having separate *_below variables.  We mark both
kinds of missing dirs with FLAG_MISSING_DIR.  (dry_run > 1) iff the
*root* of the destination does not exist; it is no longer incremented
for missing subdirs.  I added tests for the three fixed bugs in
missing.test.
2008-03-19 07:45:58 -07:00
Matt McCutchen
100200d0d2 Fix a poorly placed sentence in rsyncd.conf.yo. 2008-03-18 15:28:36 -04:00
Wayne Davison
f28bf7f401 My modified version of Matt's improvements to the sections on
the various filter parameters.
2008-03-18 11:41:00 -07:00
Wayne Davison
e0fd68f5ce Improved arg-path checking so that wildcards can't be used to
avoid a daemon-exclude.
2008-03-18 10:57:54 -07:00
Wayne Davison
cc12c488aa Use the missing_below code to make the daemon-exclusions
work better.
2008-03-18 10:10:13 -07:00
Wayne Davison
99c3e591b2 Reject a daemon-excluded destination. 2008-03-18 09:44:42 -07:00
Wayne Davison
1aefb7ef73 Output a non-existent-file error for server-excluded files instead of
silently ignoring them.
2008-03-18 09:16:24 -07:00
Matt McCutchen
d7b6774d82 More typo fixes. 2008-03-17 15:32:07 -04:00
Wayne Davison
d4c5cb2b01 A couple more changes for dealing with "checker" warnings. 2008-03-17 10:50:11 -07:00
Matt McCutchen
df476bfcff Fix typo in rsyncd.conf man page. 2008-03-17 11:30:08 -04:00
Wayne Davison
aa0e6b9977 Attempting to silence some more "checker" warnings. 2008-03-17 07:35:19 -07:00
Wayne Davison
1ba6468f1b Mention all the latest changes in the NEWS file. 2008-03-16 22:43:35 -07:00
Wayne Davison
f490102454 If we're not compiling one or more major options (ACLs, xattrs, & iconv),
try to turn off unused-parameter compiler warnings.
2008-03-16 21:51:07 -07:00
Wayne Davison
18f3cb6957 Changed stat() call to do_stat(). 2008-03-16 21:44:33 -07:00
Wayne Davison
7abcfd85b7 Moved declaration of "int i" outside the ifdef in send_protected_args(). 2008-03-16 20:39:16 -07:00
Wayne Davison
6de417d9d4 If the system's popt.h file is not found, use our provided popt code. 2008-03-16 20:35:18 -07:00
Wayne Davison
ffe8feb265 Added "const" to a couple more char * args. 2008-03-16 19:50:35 -07:00
Wayne Davison
c9b62cf375 Fixed hard-linking when some of the files can get skipped. This adds
the FLAG_SKIP_HLINK flag, which gets set on any hard-linked file that
the user wants to skip (e.g. via --ignore-existing, --append, etc.).
The code in hlink.c now deals with the skipped files instead of
triggering an assert() error.
2008-03-16 19:47:35 -07:00
Wayne Davison
7bc595785e Made the FLAG_MOUNT_DIR bit only honored on a directory. 2008-03-16 17:52:31 -07:00
Wayne Davison
022dec7aba Moved the --append check so that files that don't need to be transferred
still get their non-content attributes updated, and combining --append
with --hard-links will not prevent the discovery of unchanged files.
2008-03-16 17:50:28 -07:00
Wayne Davison
ddaef70ced Make the --ignore-existing option not overwrite a regular file with
a dir/symlink/device/special-file, just like it already refuses to
overwrite a non-regular file with a regular file.
2008-03-16 17:17:38 -07:00
Wayne Davison
2357a51e09 A daemon no longer tries to refuse the iconv option when it is not enabled. 2008-03-16 12:11:19 -07:00
Wayne Davison
24ded29ff6 Fixed a hang when using --remove-source-files in dry-run mode. 2008-03-16 06:56:26 -07:00
Wayne Davison
ddff23a7f9 Added missing $(CPPFLAGS) from the building of rounding.h. 2008-03-15 14:09:20 -07:00
Wayne Davison
53936ef935 Fixed the use of --protect-args (-s) with a daemon. 2008-03-15 11:56:18 -07:00
Wayne Davison
7f9bf6b710 Generate a helpful message when we get an option-error from a daemon
while requesting a file-listing and we suspect that the remote rsync
is complaining about the -d option.
2008-03-15 11:24:38 -07:00
Wayne Davison
cfdb27b0c1 Another optimization of "bp" adding when creating a file_struct. 2008-03-15 07:27:33 -07:00
Wayne Davison
fc3ca11040 Got rid of some useless uses of the -t option. 2008-03-15 07:26:46 -07:00
Wayne Davison
d6c9c3319b - Fixed a crash bug when backing up files with ACLs enabled and we
create a directory in the backup-path area.
- Fixed a bug where make_file() was setting F_PATHNAME() on the
  receiving side.
- A non-pool (temp-memory) file structure now stores the size of
  its extra_cnt value in the F_DEPTH() int so that unmake_file()
  can always be sure of how to free() the memory.
- The ACL-preserving code no longer allocates 4 more bytes per
  file entry than it needs.
- Got rid of a useless adding of the symlink length to "bp".
2008-03-15 00:44:53 -07:00
Wayne Davison
8afaef4219 Have configure check to see if /usr/include/popt/popt.h is around
(rather than /usr/include/popt.h), and use the included popt lib
if it is (to avoid a potential conflict due to our use of -I.).
2008-03-14 22:55:59 -07:00
Wayne Davison
11faa893ca (Matt) More itemize clarifications. 2008-03-13 17:45:13 -07:00
Wayne Davison
600b56b316 Clarify that the change/checksum itemize flag can be missing
when talking to older rsync versions.
2008-03-12 16:51:13 -07:00
Wayne Davison
ee39281d14 Fixed the 'T' itemized output for a symlink the right way this time. 2008-03-11 17:35:49 -07:00
Wayne Davison
0607c30700 - One more fix for the 'T' itemized output for a symlink when we're
the client on the receiving side of a protocol-29 connection.
2008-03-11 07:26:37 -07:00
Wayne Davison
492ad04277 (Matt) Add missing --no-y option. 2008-03-10 21:40:04 -07:00
Wayne Davison
1ed9018e69 Fixed some itemized logging failures:
- If a symlink/device/special-file changes its value without any
  attribute changes, the itemized event no longer gets dropped.
- We put a 'c' into the checksum/change field now to indicate when
  a symlink/device/special-file changes its value without changing
  its type.  This lets us properly interpret the --copy-links output
  to know which items are getting copied without changes and which
  are getting created with new content.
- Fixed the 'T' itemized output for a symlink when rsync tries to
  set the right time but fails due to lack of OS/disk support.
2008-03-10 21:39:01 -07:00
Wayne Davison
ff0e15804f Fixed the itemizing of perms with -E. 2008-03-09 19:50:51 -07:00
Wayne Davison
894e6299c1 Some popt improvements:
- Fixed a bug in short-opt parsing when an abutting arg has an '='.
- Allow a short-opt to be separated from its arg by an '='.
- Avoid an IBM-checker warning about an impossible case in a switch
  and a warning about a potential NULL-pointer dereference.
- Fixed a memory leak.
2008-03-08 11:02:40 -08:00
Wayne Davison
c080190365 Fixed the latest xattrs tests on OS X. 2008-03-07 17:13:38 -08:00
Wayne Davison
26f0e56587 Restore a long-attribute test that was temporarily disabled. 2008-03-07 16:45:26 -08:00
Wayne Davison
b4e6aac985 Fixed a syntax problem for non-HAVE_LINUX_ATTRS systems. 2008-03-07 16:41:09 -08:00
Wayne Davison
7c21776e54 Handle the very latest spot for the nightly dir. 2008-03-07 16:25:05 -08:00
Wayne Davison
d724dd186e Fixed the interaction of --fake-super with --link-dest & --xattrs.
Fixed the munging of non-user namespace xattrs w/--fake-super.
Fixed the sorting of received xattrs when name-munging occurs.
Added xattr tests to verify that these things stay fixed.
2008-03-07 16:23:21 -08:00
Wayne Davison
cbbd8e2e8b The --fake-super option conflicts with -XX (which copies internal
rsync xattrs literally).
2008-03-07 15:23:39 -08:00
Wayne Davison
af6241f7ad Simplify the description of what we're doing. 2008-03-06 09:40:46 -08:00
Wayne Davison
852e763b89 Added even more no-OPTION overrides. 2008-03-06 09:38:48 -08:00
Wayne Davison
0f71592015 Made the description of ignored symlink errors more accurate. 2008-03-06 09:37:26 -08:00
Wayne Davison
e63d3a29e2 Updated nightly-rsync and release-rsync to handle the new
ftp directory layout.
2008-03-05 00:22:55 -08:00
Wayne Davison
38cef641a5 Updated rrsync to deal with the latest 3.0.0's use of the -e option.
Added a couple more long options that might get passed.
2008-03-04 22:51:56 -08:00
Wayne Davison
6226396c4a Don't call utimes() on a dir that doesn't need its mtime changed. 2008-03-04 22:48:01 -08:00
Wayne Davison
89b47d43de - Made the itemize test check for CAN_HARDLINK_SYMLINK define instead
of running its own test using ln.
- Made the merge test call checkit with absolute paths so that some
  folk's cd command won't foul things up with extra output.
2008-03-04 21:46:27 -08:00
Wayne Davison
d1c06c2180 Fixing a problem with a NULL config_file pointer when accessing
a single-use daemon without no --config option specified.  Added
a test to ensure that this doesn't break in the future.
2008-03-03 18:33:11 -08:00
Wayne Davison
800a4485f3 Improved the error-checking when tweaking the files for a new release. 2008-03-03 12:33:15 -08:00
Wayne Davison
fede378577 Updated copyright year in --version output and improved the release
script to look for year changes in options.c and to get the version
defaults totally right in the prompts.
2008-03-03 11:19:48 -08:00
Wayne Davison
3bc207b9dd Fixed a thinko and a typo in the --append option. 2008-03-03 07:16:38 -08:00
Wayne Davison
ebac031925 Show the last compile error if we failed to create rounding.h. 2008-03-01 21:00:41 -08:00
Wayne Davison
3cbe640d3c Tweak the files to start work on the next release.
The work-in-progress version is 3.0.1dev.
2008-03-01 20:35:18 -08:00
Wayne Davison
4cb6197b21 Preparing for release of 3.0.0 2008-03-01 12:12:04 -08:00
Wayne Davison
d3d07a5e86 Include 2008 in the copyright years. 2008-03-01 12:01:41 -08:00
Wayne Davison
62ca38262f Fixed the lastversion default when changing from a pre-release
to a final release.  Ensure that newly-created "extra files"
get included in the diff.
2008-03-01 12:00:13 -08:00
Wayne Davison
d62fb8894f Mention a couple more items of note. 2008-03-01 09:48:55 -08:00
Wayne Davison
fc29efc38d Use variables to hold the constant itemized strings so
that future changes are easier to make.
2008-02-27 17:57:29 -08:00
Wayne Davison
c4c9bb944b Temporarily set uid_ndx in the delete code if the transfer is not
preserving ownership, but we want to know what the UIDs are on the
files we're deleting.  Changed the DEL_OWNED_BY_US flag to be
DEL_NO_UID_WRITE, which is only set when a file is owned by us and
we can't write to it.  Fixed a glitch in the error handling of the
--delete-delay code where it might try to enable delete-after in
incremental-transfer mode.  Made a simple (well tested) optimization
in the --delete-delay code and a few other readability changes.
2008-02-27 16:25:29 -08:00
Wayne Davison
236adddc18 Use preserve_[ug]id values for send/recv checking, which will
allow the delete code to temporarily set [ug]id_ndx during
delete processing, as needed.  Got rid of a couple duplicate
tests.
2008-02-27 16:15:14 -08:00
Wayne Davison
5b3aa8028b Added missing init_iconv() call when initiating a daemon transfer. 2008-02-27 07:19:13 -08:00
Wayne Davison
16e24c2043 Don't force the user to start from the master branch when any
clean starting branch will do.  Return to the starting branch.
2008-02-24 13:19:51 -08:00
Wayne Davison
7869953bbf Fixed the description of the 'x' in the itemized output. 2008-02-23 20:55:39 -08:00
Wayne Davison
d07edfc895 Added a default to the new switch in str_acl_type(). 2008-02-23 08:14:56 -08:00
Wayne Davison
85b057cccf Check the return code from mbr_uid_to_uuid()/mbr_gid_to_uuid() so
that the user sees the right error if they failed.
2008-02-23 07:44:55 -08:00
Wayne Davison
a2c473bb59 Tweaked the ACL type-names returned by str_acl_type()
so that error messages are a little clearer.
2008-02-23 07:33:32 -08:00
Wayne Davison
f587061a5b Cast ai->ai_addrlen to int for an rprintf() call using %d. 2008-02-22 15:15:32 -08:00
Wayne Davison
d9e92804a5 The code expects id_t and mode_t to be unsigned, so the code now defines
each one to be unsigned int (instead of int) when the type is missing.
2008-02-21 20:51:54 -08:00
Wayne Davison
46e858a631 Improved several things in the NEWS files, including some typos
that Matt fixed.
2008-02-20 10:32:35 -08:00
Wayne Davison
e0fe5231c2 Output info on what's being signed to make it clearer
what is happening.  Improved the final admonition.
2008-02-19 19:18:20 -08:00
Wayne Davison
698bc16e87 Preparing for release of 3.0.0pre10 2008-02-19 18:28:00 -08:00
Wayne Davison
7b4f48650c Make a few more char pointers const. 2008-02-19 16:35:22 -08:00
Wayne Davison
a43ff267e9 Tweaked a comparison that "checker" was complaining about. 2008-02-19 11:52:00 -08:00
Wayne Davison
717d04669a Fixed the hard-link check again, adding a comment as to
why it is coded the way it is.
2008-02-18 17:16:08 -08:00
Wayne Davison
15dbffc215 Fixed a compilation problem when iconv support is disabled. 2008-02-18 16:48:20 -08:00
Wayne Davison
0099e42332 Only set FLAG_TIME_FAILED if receiver_symlink_times is set. 2008-02-18 16:48:04 -08:00
Wayne Davison
1ed56a05c2 Extended the protocol-30 info-passing code at startup, and use it to
tell the client if the server can set the times on a symlink (both
the server->client byte and the client->server use of -e).  Make use
of this info to allow the proper output of the 't' flag when rsync
can set the time on a symlink (and we're talking protocol >= 30).
Added output of "[no] symtimes" info in the --version message.
Fixed the itemize.test so that it works when rsync believes that it
can set the time of a symlink, but it can't really do it.
2008-02-18 15:57:59 -08:00
Wayne Davison
28fb6365d0 Added --no-one-file-system and --no-x options. 2008-02-18 12:42:04 -08:00
Wayne Davison
8365126b8d Some permssion fixes:
- Changed itemized output to only report 'p' with -p or -E.
 - Fixed a duplicate output of a link-dest file with -vv but no -i.
 - Improved unchanged_attrs() to handle -E.
2008-02-18 10:20:50 -08:00
Wayne Davison
d770837ec0 Fixed a typo reported in a Debian bug report. 2008-02-18 09:59:44 -08:00
Wayne Davison
59658acfec Mention the leading '*'-char rule for itemized output. 2008-02-18 08:25:15 -08:00
Wayne Davison
46f800e8c7 Decided to pad the "*deleting" message to make the names line up. 2008-02-17 23:46:26 -08:00
Wayne Davison
1c65a93d03 The daemon no longer logs a recv entry for a file that is not
actually being updated due to the --only-write-batch option.
2008-02-17 23:44:52 -08:00
Wayne Davison
cae7885e2f Don't output a duplicate warning when the daemon-config excludes a
directory or when a directory is ignored via --ignore-non-existing.
Use a new var, is_dir, to simplify the dir code in recv_generator().
2008-02-17 22:34:08 -08:00
Wayne Davison
eaa28e654f Use the name "ChangeLog" for the ftp copy of the repository history. 2008-02-16 14:45:22 -08:00
Wayne Davison
beef86d0dd A few minor changes, including better push_dir()/pop_dir() verbosity. 2008-02-15 22:19:43 -08:00
Wayne Davison
2fe1feea75 Added a way to specify where the chroot should occur in the module's
path, which allows a daemon admin to have chroot protection and still
have files that are outside the transfer area (such as libraries).
2008-02-15 19:01:35 -08:00
Wayne Davison
0b52f94da7 Some daemon security improvements, including the new parameters
"charset" and "numeric ids".
2008-02-15 17:39:21 -08:00
Wayne Davison
f96bac8468 (Matt) Dropped a superfluous word from a sentence. 2008-02-12 17:30:02 -08:00
Wayne Davison
8444a7c00d (Matt) Needed to remove a few more files for distclean target. 2008-02-12 17:29:09 -08:00
Wayne Davison
c9d3bc3fca A few more NEWS tweaks. 2008-02-10 21:21:24 -08:00
Wayne Davison
8340aa9670 Mention a couple more items. 2008-02-10 21:02:05 -08:00
Wayne Davison
3e2c0024d5 Made reconfigure target check if configure.sh was up-to-date. 2008-02-10 20:39:31 -08:00
Wayne Davison
205393a2b5 Preparing for release of 3.0.0pre9 2008-02-10 20:16:25 -08:00
Wayne Davison
5f0f2e0894 Some improvements for --hard-links and --filter options. 2008-02-10 20:10:13 -08:00
Wayne Davison
a5bb0902b4 One more fix in set_modtime() when we get ENOSYS on a symlink. 2008-02-10 15:39:21 -08:00
Wayne Davison
d348d5fd5f Add a trailing slash to a modname arg that has no path information.
This ensures that the user gets a "skipping" message if they didn't
specify -r or -d.  (A trailing-slash was already being added to a
lone modname for --list-only transfers.)
2008-02-09 22:07:03 -08:00
Wayne Davison
21897ecbed Improved the "symlink has no referent" logic to work with all the
--copy*links options.
2008-02-09 21:41:50 -08:00
Wayne Davison
01103e1870 Make do_recv() reset copy_unsafe_links too (just like it does for
copy_links and copy_dirlinks).
2008-02-09 21:33:13 -08:00
Wayne Davison
2d8f9b1df0 Ignore exit-code 23 when we expect a daemon-excluded file to be excluded. 2008-02-09 21:30:49 -08:00
Wayne Davison
68f1e7e594 (Matt) Made a daemon-refused file an FERROR_XFER with a better message. 2008-02-07 11:24:38 -08:00
Wayne Davison
87629cf2f6 Re-indent some code in set_file_attrs() to make the flow clearer. 2008-02-07 07:24:58 -08:00
Wayne Davison
e7f642cffe Using rebase for the patches has become a failing-hunk
pain in the neck, so I'm switching to using merge.
2008-02-06 16:39:53 -08:00
Wayne Davison
3e8fe565ed A daemon needs to call setup_iconv() after parsing the options
it receives.
2008-02-06 16:13:37 -08:00
Wayne Davison
e96c7777d7 Fixed return code from hard_link_one() when not verbose. 2008-02-06 16:06:33 -08:00
Wayne Davison
71daa07fb1 Make get_xattr_names() even safer at fetching the list of attr names. 2008-02-06 07:52:00 -08:00
Wayne Davison
287bb276d5 Only check F_OWNER() if uid_ndx is non-zero. 2008-02-04 21:17:27 -08:00
Wayne Davison
ddc8110dea Fixed local_child() so that the client side really does handle
the log-file writing.
2008-02-04 12:52:41 -08:00
Wayne Davison
c0f4228d66 Don't try to use recv_xattr_request() with --dry-run. Fixes an
internal abbrev error on the sending side.
2008-02-04 12:34:02 -08:00
Wayne Davison
d6e6333a02 Store the key64 flag from hashtable_create() in the hashtable structure
so that hashtable_find() knows which hashtable is which on a 64-bit
architecture.
2008-02-04 07:29:22 -08:00
Wayne Davison
970ce063ee Fixed finding of parent's description when @ARGV doesn't mention it. 2008-02-04 00:12:01 -08:00
Wayne Davison
dd1f0da818 Improved the usage message. 2008-02-03 23:40:20 -08:00
Wayne Davison
38a4bd432a Fixed a couple DEL_OWNED_BY_US glitches. 2008-02-03 16:40:28 -08:00
Wayne Davison
3eabe6aa41 Dump delete_item()'s "replace" var to reduce recursive stack use. 2008-02-03 15:13:36 -08:00
Wayne Davison
f2b7b64d86 Fixed the diffing of generated files when creating a patch that has
a parent that is not the master branch.
2008-02-02 17:00:25 -08:00
Wayne Davison
b2057d38a9 Some extra password-clarification verbage from Matt. 2008-01-29 17:19:22 -08:00
Wayne Davison
964244b90d Fixed several glitches with failed updates and batch files:
- Correctly identify when a missing batch update is for a resend.
- Made a missing batch update an xfer error.
- Made a failed redo an xfer error.
- Identify a failed transfer file consistently when it is a solo file.
- Have --read-batch say "may try again" instead of "will try again".
2008-01-27 14:40:50 -08:00
Wayne Davison
a7c1fa0049 Moved the batch option checking until after the protocol-version
in the batch file is known.  Also simplified the do_compress
checking, which had some erroneous def_compress_level code.
2008-01-26 11:58:17 -08:00
Wayne Davison
42a28d9d3a Improved a comment. 2008-01-26 09:13:19 -08:00
Wayne Davison
19284e2ef8 When removing a file/dir that is owned by us but does not have
owner-write permission, set it before the removal.
2008-01-26 08:47:02 -08:00
Wayne Davison
2268defe66 Fix some typos and such. 2008-01-25 16:57:54 -08:00
Wayne Davison
643b018cfb Mention iconv --list. 2008-01-25 16:57:26 -08:00
Wayne Davison
e35ad79b1b Make do_chmod() report an error with -E. 2008-01-25 16:57:02 -08:00
Wayne Davison
da01d2e843 Improved option handling for protocol 30 batch files. 2008-01-19 11:21:07 -08:00
Wayne Davison
641dc0c51e Output (BATCH ONLY) rather than (DRY RUN) for --only-write-batch. 2008-01-19 11:20:42 -08:00
Wayne Davison
69e2b4ee3a Fixed the combination of --dry-run and --only-write-batch. 2008-01-19 11:20:17 -08:00
Wayne Davison
75a01a0734 Don't apply filter rules to implied directories. 2008-01-19 10:09:22 -08:00
Wayne Davison
b769ad6a3e Another xattr "internal abbrev" fix for an xattr object that is
shared by multiple files:  handle the case where one file has an
abbreviated item set correctly, but a following item does not.
Also extended testsuite/xattrs.test to verify that this works.
2008-01-12 22:16:37 -08:00
Wayne Davison
6e59b97770 Preparing for release of 3.0.0pre8 2008-01-12 10:53:10 -08:00
Wayne Davison
4da9fcd41d - Make sure the Makefile is up-to-date before running "make gen".
- The release-rsync script now creates the generated patches in a
  separate dir from the normal patches.
2008-01-12 10:52:46 -08:00
Wayne Davison
68ddbaf645 Fixed a bug with truncated xattr data requests when the receiver
needs to discard some of the items from the sender's list.
2008-01-12 09:14:56 -08:00
Wayne Davison
555a081fe2 If "make gensend" fails, abort the script. 2008-01-11 13:20:14 -08:00
Wayne Davison
513d3fd806 Improved check_for_finished_files() to be really, really sure
that we've processed all the items on the hard-linked and redo
queues before we return.
2008-01-11 13:13:15 -08:00
Wayne Davison
34aa616d41 Fixed a length problem parsing an arg of "./". 2008-01-09 11:51:44 -08:00
Wayne Davison
ec8637f367 Don't allow a slash to be specified in a module name.
Document the module-name limitations in rsyncd.conf.yo.
2008-01-09 11:41:23 -08:00
Wayne Davison
62a6b8df72 Made read_arg_from_pipe() handle EINTR. 2008-01-02 17:20:44 -08:00
Wayne Davison
dd6f31f70f Rebuild the Makefile when it is not up-to-date. 2008-01-01 10:43:55 -08:00
Wayne Davison
a5fd4b6e6e Renamed mkrounding.c to rounding.c. 2008-01-01 10:34:27 -08:00
Wayne Davison
eca151d457 Changed the creation of rounding.h to use a set of compile-time checks
similar to how configure determines the size of variables.
2008-01-01 10:27:19 -08:00
Wayne Davison
f859d3ded6 If we're cross-compiling, tell the user to run mkrounding on the
target machine to build the rounding.h file.
2008-01-01 08:59:26 -08:00
Wayne Davison
5288be3af7 Some minor tweaks:
- Improved some comments in hlink.c.
- Changed "the" to "a" in rsyncd.conf.yo.
- Improved the PATCH.name filtering loop in patch-update.
2007-12-31 20:40:51 -08:00
Wayne Davison
83235dbc54 Fixed a case where the receiver indicates a successful update when the
transfer succeeded, but the final rename failed.
2007-12-31 10:31:43 -08:00
Wayne Davison
c78cb8f349 Made some user-/group-name pointers "const". 2007-12-29 22:52:42 -08:00
Wayne Davison
7210dbfd2a Some minor tweaking to name_to_uid() and name_to_gid(). 2007-12-29 22:52:04 -08:00
Wayne Davison
b6800a0b32 Added check for libiconv_open when iconv_open isn't found. 2007-12-29 09:53:37 -08:00
Wayne Davison
14eaa7a53b Added reconfigure target to re-run configure. 2007-12-29 09:44:58 -08:00
Wayne Davison
bc065415b0 Fixed Source URL and changed from ftp to http. 2007-12-19 09:36:05 -08:00
Wayne Davison
9203c8d274 Improved prepare-source to make it more flexible. The script now
lets the user choose which actions to perform and their order.
2007-12-17 23:32:47 -08:00
Wayne Davison
9468cf796d Fixed a FALL THROUGH comment. 2007-12-16 17:51:36 -08:00
Wayne Davison
77d4c400c2 Only ignore ENOSYS error from lutimes(). 2007-12-16 17:18:01 -08:00
Wayne Davison
e3915dac76 Added the 'h' option to the tar command that creates the patches
tar file just in case the patches directory is a symlink.
2007-12-16 15:41:59 -08:00
Wayne Davison
78246d1a09 Preparing for release of 3.0.0pre7 2007-12-16 15:09:43 -08:00
Wayne Davison
4bb319c6a6 Fixed extracting files from old tar file. 2007-12-16 15:09:21 -08:00
Wayne Davison
293b11b8a5 Mention 2 more changes in the NEWS. 2007-12-16 15:04:12 -08:00
Wayne Davison
8f42da0b50 Added a "fetchall" option. 2007-12-16 15:02:42 -08:00
Wayne Davison
a10186910d Fixed the check_filter() calls that might be checking an absolute path
in "use chroot = no" mode against a daemon's exclude restriction.
2007-12-16 14:16:37 -08:00
Wayne Davison
eb7715c1eb Moved the dir_count increment into an even better spot and make sure that
send_file_name() returned a non-NULL pointer before doing any DOT_NAME
processing in inc_recurse mode.
2007-12-16 14:14:35 -08:00
Wayne Davison
a7188cbf48 Fixed a potential memory leak in make_file(). 2007-12-15 11:57:34 -08:00
Wayne Davison
f7a2ac075f Refer to delta-transfer algorithm rather than rsync algorithm. 2007-12-15 08:35:45 -08:00
Wayne Davison
ce27f36d92 Check on the alternate destination dirs and report any problems. 2007-12-15 08:19:56 -08:00
Wayne Davison
af5ed0f257 Make push_dir() output where we are when verbosity is high. 2007-12-15 07:39:33 -08:00
Wayne Davison
e6d05dcfca Move incrementing of dir_count so that it can't get incremented
for a directory that isn't going to be included in the transfer.
2007-12-13 07:00:38 -08:00
Wayne Davison
65b4e4b2a9 Updated indexing for accurate progress and improved raw ndx values.
The sending side now has a sorted file-list in iconv mode so that it
can output progress in sorted order.  Simplified the over-the-wire
index values to ensure both sides will always agree on the values.
Optimized the allocation of the dir_flist->sorted array on the
receiving side with --iconv and incremental recursion.
2007-12-08 11:39:47 -08:00
Wayne Davison
37adeae73e A few more additions of $(srcdir) to Makefile.in. 2007-11-30 19:08:54 -08:00
Wayne Davison
091b3459f6 Fixed a build problem for those building in a different dir from
the srcdir.  Also got rid of "cd" code in configure stub.
2007-11-30 19:02:50 -08:00
Wayne Davison
85cdbb6be3 Reorganize the build-farm "prepare-source" magic a little.
This makes it easier for a user to request a copy of the
configure scripts via rsync ("./prepare-source fetch").
2007-11-30 18:01:18 -08:00
Wayne Davison
fcb1068f72 Improved header-file dependency rules even more. 2007-11-30 07:42:47 -08:00
Wayne Davison
07ad305e8a Make sure that the test programs get rebuilt when a header
file changes.
2007-11-29 23:44:40 -08:00
Wayne Davison
bcfb738c93 One build-farm system needs to fetch the proto.h* files too. 2007-11-29 23:21:51 -08:00
Wayne Davison
b58f5e17ed Simplified the time_t overflow check and moved an extra_len rounding
check into the right spot in recv_file_entry().
2007-11-29 22:52:20 -08:00
Wayne Davison
87de82f2d0 Make sure that the inc_recurse value is always set to
either 0 or 1.
2007-11-29 22:46:43 -08:00
Wayne Davison
87531e6302 Get rid of some compiler warnings in the AIX sysacls code. 2007-11-29 17:12:54 -08:00
Wayne Davison
eb67a6909b Don't try to process hard-link data in list-only mode. 2007-11-29 10:27:16 -08:00
Wayne Davison
9217ce30e3 Revised release-rsync and nightly-rsync code to create a tar files
with the right timestamps.
2007-11-29 09:29:45 -08:00
Wayne Davison
d52607ecd6 Preparing for release of 3.0.0pre6 2007-11-28 01:00:37 -08:00
Wayne Davison
13e4914826 Fixed a problem with extracting the previous release's
generated files (used to create the release diff).
2007-11-28 01:00:02 -08:00
Wayne Davison
932fcfc1aa Mentioned the latest changes in the NEWS. 2007-11-28 00:40:34 -08:00
Wayne Davison
a2c770dc21 Switching over to a dynamic hash method for really large files.
This code has been reported to be better for large files than the
file-chunking code that was included in pre3.
2007-11-28 00:39:02 -08:00
Wayne Davison
ba22c9e219 Adding --contimeout=SECONDS option. 2007-11-28 00:28:26 -08:00
Wayne Davison
6a2456c501 Don't use git-FOO command to call git sub-commands. 2007-11-27 16:06:01 -08:00
Wayne Davison
ef3f14e6a7 When the new "munge symlinks" option is off, a non-chroot
daemon should sanitize its symlinks, as it used to do.
2007-11-27 13:11:49 -08:00
Wayne Davison
9585b27678 Add a new daemon security option: "munge symlinks". 2007-11-27 07:34:59 -08:00
Wayne Davison
5c77266d95 Use a non-printing command for proto.h's build-rule. 2007-11-25 15:12:06 -08:00
Wayne Davison
3db06222af Give proto.h a build rule so that make re-checks its timestamp. 2007-11-25 15:03:19 -08:00
Wayne Davison
aa6865d761 Return to the master branch at the end. 2007-11-25 14:46:33 -08:00
Wayne Davison
67b9b26ff3 Modified the discovery of the generated files & use "make gen". 2007-11-25 14:36:30 -08:00
Wayne Davison
b82ad9507f Re-run autoconf and autoheader, as needed. 2007-11-25 14:08:19 -08:00
Wayne Davison
4d7c8e6b76 We now call set_stat_xattr() before set_xattr(). 2007-11-25 13:49:41 -08:00
Wayne Davison
a685271de3 Various xattr fixes:
- Fake-super mode no longer strips the RSYNC_PREFIX from a "%name" item.
- Make various places skip the fake-super xattr when --fake-super is enabled.
- If we fail to re-read the xattr value of an xattr we are trying to un-
  abbreviate, send a zero for its length (avoiding a protocol problem).
2007-11-25 13:48:54 -08:00
Wayne Davison
613c2d4431 Improved proto.h-tstamp handling, including cleanup. 2007-11-24 11:50:41 -08:00
Wayne Davison
225787a4a4 Made the (re-)building of the proto.h file automatic in the
main Makefile rules, and the (re-)building of the man pages
automatic if yodl2man is present.
2007-11-24 10:54:35 -08:00
Wayne Davison
e107b6b122 Fixed a problem with --fake-super not getting the fully tweaked new_mode
value.  Also fixed the removal of rsync-internal xattr values on the
destination files when we aren't copying rsync-internal xattr values.
2007-11-24 10:50:45 -08:00
Wayne Davison
5223b786ca A daemon needs to set dry_run with --only-write-batch. 2007-11-22 11:19:34 -08:00
Wayne Davison
3f0211b63a New logging categories added to allow differentiation between
transfer errors, normal errors, and warnings.  New messages are
translated into old FERROR/FINFO categories for older protocols.
2007-11-22 10:05:36 -08:00
Wayne Davison
a6c6f8e650 Use FLOG instead of FERROR for config errors. 2007-11-22 09:51:21 -08:00
Wayne Davison
ee6e80c753 Fix two iconv problems that Lennart Lövstrand pointed out in bug 5075. 2007-11-22 07:57:03 -08:00
Wayne Davison
ce72de30ce Don't try to delete when list_only is set. 2007-11-21 07:09:26 -08:00
Wayne Davison
29bca53f9b Got rid of the unused symlink parameter to sanitize_path(). 2007-11-20 17:37:53 -08:00
Wayne Davison
dc2815c1fb Make sure that a failure to build configure.sh or config.h.in
doesn't leave a file lying around that could deceive us on the
next run.
2007-11-20 17:22:47 -08:00
Wayne Davison
3005a12bce Only allow the build farm to rsync the latest generated
configure files when building them fails.
2007-11-20 08:40:15 -08:00
Wayne Davison
fd913297fa Made some code that handles hard-linking of symlinks be
omitted if symlinks can't be hard-linked.
2007-11-18 17:54:35 -08:00
Wayne Davison
90c98cdc39 Adding a support script that can be used to make the checked-out
file-times of an initial clone nicer.
2007-11-17 10:29:13 -08:00
Wayne Davison
b258ebf8ac Improved F_RDEV_P() define to use DEV_EXTRA_CNT count. 2007-11-17 10:26:46 -08:00
Wayne Davison
97f0421523 Make sure we process a parent patch before a dependent patch. 2007-11-16 08:02:26 -08:00
Wayne Davison
ee8a733d6f A couple minor improvments to the tar-creation code. 2007-11-15 14:05:09 -08:00
Wayne Davison
20c7d7fd69 Updated to work with git instead of cvs. 2007-11-15 07:48:13 -08:00
Wayne Davison
49ebb358ab Handle new PATCH-$name files, improved $last_touch code,
fixed handling of dependent patches.
2007-11-12 15:10:52 -08:00
Wayne Davison
1f41d42a91 Getting rid of all .cvsignore files. 2007-11-12 13:32:10 -08:00
Wayne Davison
813d2d101a Mention the change for protocol 30. 2007-11-12 07:12:48 -08:00
Wayne Davison
86eb9f9595 Exit if something goes wrong with commit or tag. 2007-11-12 06:44:16 -08:00
Wayne Davison
18fa91296b Make sure that time has progressed when we need change branches
in order to run prepare-source.
2007-11-12 06:30:24 -08:00
Wayne Davison
8d3211447d If we start a sub-shell to let the user fix a rebase, output a
message and change the prompt.
2007-11-12 00:13:52 -08:00
Wayne Davison
805d8ac43d Updated to work with latest git repository and to package
the patches directory in a separate tar file.
2007-11-11 23:58:01 -08:00
Wayne Davison
d26c7dfdb0 This script transforms one or more patch/* branches into
one or more patches/*.diff files.
2007-11-11 23:15:40 -08:00
Wayne Davison
1e21cde315 Ignore a couple more items. 2007-11-11 22:52:25 -08:00
Wayne Davison
c5d77e9659 Including my extern-squishing script, which just found an
extraneous extern in exclude.c.
2007-11-11 22:51:50 -08:00
Wayne Davison
2909586ede This helper script exists to create the generated files that are needed
for a build.  It pretends to be a configure script so that the build
steps are still the normal sequence of ./configure, make, make install
(which is particularly helpful with the samba build farm).  Once the
generated files are ready, the configure.sh script is called to do the
real configure work.
2007-11-09 21:37:01 -08:00
Wayne Davison
c5435b56bf Switched prototype generation from awk to perl. 2007-11-09 22:57:14 +00:00
Wayne Davison
2c386ff971 Ignore generated files and dirs. 2007-11-09 19:55:00 +00:00
Wayne Davison
7f3b529367 Tweaked gensend to upload man pages too. 2007-11-09 19:31:20 +00:00
Wayne Davison
6228239894 Include the arg name for the lp_*() funtions. 2007-11-09 19:28:27 +00:00
Wayne Davison
4da09a65f8 Simplified script even more for HP-UX. 2007-11-09 19:14:51 +00:00
Wayne Davison
ab96610986 Use older open() style for compatibility with older perl versions. 2007-11-09 18:15:52 +00:00
Wayne Davison
c8dccf8fb4 Improved the manpage install rules. 2007-11-09 18:12:40 +00:00
Wayne Davison
bdc12f41de Don't fail the install if the man pages aren't there. 2007-11-09 18:04:50 +00:00
Wayne Davison
2042c63251 Clean generated files for distclean. 2007-11-09 17:56:00 +00:00
Wayne Davison
6ec47d3d01 Added gensend target. 2007-11-09 17:50:10 +00:00
Wayne Davison
0c270e48af Let's try using perl for building proto.h. 2007-11-09 17:40:56 +00:00
Wayne Davison
8aeac05d98 Improved configure bootstrap to try to build generated files
before fetching them.
2007-11-09 16:56:46 +00:00
Wayne Davison
564dc9941e This is an attempt to remove generated files from the rsync repository
while still supporting the samba build farm.  Let's see if it works.
2007-11-09 16:22:20 +00:00
Wayne Davison
732b391720 Preparing for release of 3.0.0pre5 2007-11-09 04:49:18 +00:00
Wayne Davison
879b6ad05c When performing a --dry-run, output a "(DRY RUN)" reminder on the
last line of the verbose summary text.
2007-11-09 04:48:10 +00:00
Wayne Davison
f153c9c943 Mention latest changes. 2007-11-09 04:32:58 +00:00
Wayne Davison
1b411143e5 Got rid of a compiler warning. 2007-11-08 20:30:17 +00:00
Wayne Davison
9456434688 Some fixes for SCO in new getaddrinfo() code. 2007-11-08 14:54:58 +00:00
Wayne Davison
268da8167a Use uint32, not uint32_t. 2007-11-08 01:31:58 +00:00
Wayne Davison
2213961e8f Add back a define of "struct sockaddr_storage" for systems that
don't have it.
2007-11-08 01:10:34 +00:00
Wayne Davison
d100e733db Improve the man page and --help descriptions of --dry-run. In
particular, make it clear that --dry-run turns off action without
turning on verbosity, and has some incomplete/inaccurate stats.
2007-11-08 00:06:48 +00:00
Wayne Davison
15e4d40184 Tweaked an extern. 2007-11-06 15:32:55 +00:00
Wayne Davison
f7a76b9c45 Some changes to allow an unsorted file list even if the iconv option
was disabled via configure.
2007-11-06 15:25:02 +00:00
Wayne Davison
84e1a34eaa Fixed some typos that Matt pointed out. 2007-11-05 18:33:09 +00:00
Wayne Davison
41979f2518 Make sure that get_xattr_data() never tries to malloc 0 bytes. 2007-11-05 18:15:04 +00:00
Wayne Davison
4b1553e2d4 If the xattr data is bogus in get_rsync_acl(), free the buffer. 2007-11-05 18:15:01 +00:00
Wayne Davison
e516b69ef6 Fixed get_xattr_acl() -- it needed to zero *len_p. 2007-11-05 15:02:30 +00:00
Wayne Davison
7df593f21f Got rid of a redundant mtime check. 2007-11-05 15:02:27 +00:00
Wayne Davison
cac80887a6 Conditional symlink-checking code in unchanged_attrs() should be
checking HAVE_LUTIMES.
2007-11-04 06:43:01 +00:00
Wayne Davison
45a143cd51 Have unchanged_attrs() check the mtime on items where we can
affect the time, even if unchanged_file() might have already
checked it.
2007-11-03 21:14:16 +00:00
Wayne Davison
0379c8eca1 Make sure that the user has write permissions when opening a temp file. 2007-11-03 19:27:49 +00:00
Wayne Davison
c9b16cdaba Stop password errors from getting reported as transfer errors. 2007-11-03 18:14:36 +00:00
Wayne Davison
77943e69aa - Renamed updating_basis -> updating_basis_or_equiv.
- Set updating_basis_or_equiv if we're inplace-updating a
  file using the backup file as the basis.
2007-11-03 16:57:17 +00:00
Wayne Davison
d620219dc4 A better way to count our queued workload. 2007-11-03 16:30:30 +00:00
Wayne Davison
c0685c05f8 Fixed hang when --hard-links was processing a large directory
hierarchy with no files.
2007-11-03 15:27:14 +00:00
Wayne Davison
b7386d23d4 Avoid verbose output during the forwarding of flist data (for now,
at least).
2007-11-03 07:20:09 +00:00
Wayne Davison
17a4977bef In mplex_write(), make extra sure something unexpected doesn't get
put between the split output of a long buffer.
2007-11-03 07:20:05 +00:00
Wayne Davison
4f9b139ab9 The HAVE_UTIMBUF define changed to HAVE_STRUCT_UTIMBUF. 2007-11-02 20:53:04 +00:00
Wayne Davison
9f802c7294 A new version of the getaddrinfo code from the samba source. 2007-11-02 20:52:57 +00:00
Wayne Davison
6e1fa33f67 Make use of the HAVE_NETDB_H define. 2007-11-02 20:52:52 +00:00
Wayne Davison
4021aa455b Changes to handle new getaddrinfo code. 2007-11-02 20:52:46 +00:00
Wayne Davison
6ec0f6977d Added AC_HAVE_TYPE(). 2007-11-02 20:52:33 +00:00
Wayne Davison
8c702798f6 One more SUBPROTOCOL_VERSION increase for iconv change. 2007-10-31 15:01:26 +00:00
Wayne Davison
2ad3c71777 - In --iconv mode, we can't lower the ndx_end value because dirs
aren't sorted to the end.
- Made output_flist() output from "files" instead of "sorted".
2007-10-31 14:02:51 +00:00
Wayne Davison
05bd302ab6 Increment the SUBPROTOCOL_VERSION. 2007-10-31 05:48:56 +00:00
Wayne Davison
2b4d51f2e9 Set ndx_start to 1 only for an inc-recursive transfer. 2007-10-31 05:48:25 +00:00
Wayne Davison
ee279980cc - Handle a dot-dir-containing flist using its parent_ndx value. 2007-10-31 04:43:36 +00:00
Wayne Davison
4e42173508 - Fixed a problem with merging dot dirs with non-dot-dir args
in inc-recursive mode.
- Clean up a relative name to remove interior dot dirs and extra
  slashes.
- Fixed the error output about /../ in a -R path after a /./ cut-off.
- Changed the starting ndx value to 1 so that a dot-dir flist can
  use 0 to refer to its parent (".") directory.
2007-10-31 04:43:32 +00:00
Wayne Davison
b58bfb2f20 Call clean_fname() with new flag arg. 2007-10-31 04:43:29 +00:00
Wayne Davison
6bb82fe0a8 Changed clean_fname() to take a flag int instead of a BOOL. Added
a few extra cleaning options (all off by default).
2007-10-31 04:43:25 +00:00
Wayne Davison
c73f2a3831 - Define the new CFN_* flags for clean_fname().
- Changed struct relnamecache's "is_dot_dir" member to "name_type".
2007-10-31 04:43:22 +00:00
Wayne Davison
b1eca24226 Avoid a crash if we read an index value without a valid first_flist. 2007-10-31 04:43:19 +00:00
Wayne Davison
58b7b3d668 Suggest -Z as a good popt alias letter instead of -s. 2007-10-31 00:51:48 +00:00
Wayne Davison
ce055e863d Mention that --keep-dirlinks can be dangerous if there are
untrusted symlinks in the transfer.
2007-10-30 15:00:40 +00:00
Wayne Davison
53ec55a88e Fixed --one-file-system handling when dealing with multiple
user-specified mount points in inc-recursive mode.
2007-10-30 02:24:03 +00:00
Wayne Davison
2cce75453c My version of Matt's cleanup patch from bug 5051. This makes
--copy-dest use a temp file when not in in-place mode, and has
various improvments for the code.  I have also "#if 0"ed the code
in the receiver that makes missing directories to see if we can
figure out if it is needed (and if so, what for).
2007-10-29 20:43:34 +00:00
Wayne Davison
93204ccae2 Made some more char pointers const. 2007-10-28 21:42:41 +00:00
Wayne Davison
57d617192b Don't call copy_file() for a dry-run. (Thanks, Matt!) 2007-10-28 20:03:00 +00:00
Wayne Davison
ea118be593 Fixed setting of updating_basis value. 2007-10-28 06:51:50 +00:00
Wayne Davison
6a85ee9623 Preparing for release of 3.0.0pre4 2007-10-27 05:09:06 +00:00
Wayne Davison
5851ac2dfe Fixed a problem with build_hash_table() getting called too
often when overwriting a shorter file.
2007-10-27 04:41:18 +00:00
Wayne Davison
e844a4a8a8 When listing a bare module name w/o -r, make sure we list the
contents of the module's root directory.
2007-10-27 02:19:49 +00:00
Wayne Davison
1d8638ce86 Preparing for release of 3.0.0pre3 2007-10-27 00:00:21 +00:00
Wayne Davison
4c17cdcb64 Chunk a really large file to avoid sender-side hash-table
overload.
2007-10-26 22:11:19 +00:00
Wayne Davison
c291d05759 Fixed problem with anchored filter and an absolute
source path with --relative.
2007-10-26 16:53:02 +00:00
Wayne Davison
9520ce4b65 Mention .git/ exclude. 2007-10-25 02:05:43 +00:00
Wayne Davison
0485b451ea Added .git/ to "CVS" excludes. 2007-10-25 02:05:05 +00:00
Wayne Davison
4efa11680a We need to provide iconvbufs() anytime ICONV_CONST is defined. 2007-10-25 01:40:17 +00:00
Wayne Davison
2f39f112c1 A few more improvements. 2007-10-21 22:30:49 +00:00
Wayne Davison
0438c59fd0 Improved a description. 2007-10-21 21:53:20 +00:00
Wayne Davison
1aa343e89c Make last fix even better. 2007-10-21 21:52:25 +00:00
Wayne Davison
5ed353a881 Avoid dropping a hard-linked itemized output with -ii. 2007-10-21 16:50:31 +00:00
Wayne Davison
c126e66ebd Got rid of a couple compiler warnings when SUPPORT_HARD_LINKS is not
defined.
2007-10-20 06:19:01 +00:00
Wayne Davison
97bcf138be Improved a couple entries. 2007-10-18 19:47:41 +00:00
Wayne Davison
37ce167996 We can't decrement the in_progress value for a hard-linked file until
the generator gets a chance to finish the hard links.
2007-10-18 14:04:42 +00:00
Wayne Davison
88a7426843 Typedef any missing types. 2007-10-17 14:15:22 +00:00
Wayne Davison
a1f7c8e250 Add checking for id_t, and changed some of the type checking to use
the newer, recommended method.  (Couldn't switch uid_t and gid_t.)
2007-10-17 14:15:18 +00:00
Wayne Davison
52d9a554d1 Changed a word in an error message. 2007-10-16 22:42:10 +00:00
Wayne Davison
aabb50d4e3 Tweaked set_allow_inc_recurse() a bit more. 2007-10-16 18:33:47 +00:00
Wayne Davison
03646b4910 The start of some updated "thanks". 2007-10-16 16:19:40 +00:00
Wayne Davison
11b02d927f Adding Wesley Terpstra's lchmod()-equivalent that uses setattrlist(). 2007-10-16 16:00:41 +00:00
Wayne Davison
5cefa088e2 We now report symlink mode changes if HAVE_SETATTRLIST is defined. 2007-10-16 16:00:34 +00:00
Wayne Davison
2e4e03f196 Added checks for setattrlist and sys/attr.h. 2007-10-16 16:00:31 +00:00
Wayne Davison
ea4e8cf8a1 Call set_allow_inc_recurse() for situations that don't call server_options(). 2007-10-16 15:10:17 +00:00
Wayne Davison
95def6d957 - Send an 'i' in the -e arg to the server if we can support inc_recurse.
- Got rid of some unneeded blocking_io value twiddling.
- Send --use-qsort to the server if it was specified.
2007-10-16 15:10:12 +00:00
Wayne Davison
9970bed4d9 - Moved the arg-checking relating into set_allow_inc_recurse() and
call it when the server is in setup_protocol().  The function sets
  allow_inc_recurse to 0 if some options won't allow us to support
  an incremental-recursive transfer.
- The server now checks for an 'i' in the -e option from the client
  and zeros out allow_inc_recurse if not found.
- The server reports its inc_recurse determination back to the client.
- The client sets inc_recurse based on the value it gets from the server.
2007-10-16 15:10:09 +00:00
Wayne Davison
494d049ce1 Incremented the SUBPROTOCOL_VERSION. 2007-10-16 15:10:05 +00:00
Wayne Davison
6a385e3b7e We don't need to send --no-i-r anymore. 2007-10-16 04:08:25 +00:00
Wayne Davison
71456d301f Write out the inc_recurse flag into a protocol-30 batch file. 2007-10-16 04:08:21 +00:00
Wayne Davison
dbd697b578 - Send a flag from the client to the server to indicate if the protocol
is going to run in inc_recurse mode or not.
- Verify that the options we received (as a server or as a batch-reader)
  are compatible with the requested inc_recurse mode.
2007-10-16 04:08:18 +00:00
Wayne Davison
5ca70927be Incremented the SUBPROTOCOL_VERSION. 2007-10-16 04:08:14 +00:00
Wayne Davison
2e52ba36cb Added braces to an empty "if" (to avoid any complaints from a compiler
that likes to point out an "if (...)" with a semicolon after it).
2007-10-15 00:16:12 +00:00
Wayne Davison
fd78520dca If there's no lchmod(), don't itemize permission differences for
symlinks.
2007-10-15 00:13:59 +00:00
Wayne Davison
3f655ca08d If the user told us to use a password file and we used it, there's
no need to comment if a RSYNC_PASSWORD environment variable is set.
2007-10-14 21:20:31 +00:00
Wayne Davison
76edd33498 Fixed a typo in a comment. 2007-10-14 18:55:49 +00:00
Wayne Davison
e5f35681e6 Forward MSG_IO_ERROR to the generator so that it can disable deletions. 2007-10-13 05:23:34 +00:00
Wayne Davison
32b9011ae9 Improvements surrounding --list-only and --dirs. 2007-10-13 04:32:53 +00:00
Wayne Davison
fdad5aad3f Get the version # right in the changelog. 2007-10-12 14:08:19 +00:00
Wayne Davison
90ac152deb Modify the changelog section in the .spec file for each release. 2007-10-12 14:04:29 +00:00
Wayne Davison
e9df0a6242 Fixed the day of the week. 2007-10-12 14:04:00 +00:00
Wayne Davison
4cf94b8a01 Improved the summary, the description, and the changelog. 2007-10-12 13:57:37 +00:00
Wayne Davison
a6fa5bdef3 Improved the initial description summary. 2007-10-12 13:57:15 +00:00
Wayne Davison
8f61dfdbd4 One more tweak to the synopsis. 2007-10-12 01:21:02 +00:00
Wayne Davison
ddf8c2b0b2 Improvements suggested by Matt's improved manpage. 2007-10-12 01:12:05 +00:00
Wayne Davison
44ae628c59 Preparing for release of 3.0.0pre2 2007-10-12 00:09:19 +00:00
Wayne Davison
44a7ba4587 Tweaked a couple minor things. 2007-10-12 00:07:28 +00:00
Wayne Davison
44c4492acf Conditionalize the call to setup_iconv(). 2007-10-10 19:24:35 +00:00
Wayne Davison
609e6dda6b - Use the new *_CONTENT_DIR flag names (was *_XFER_DIR).
- Check the FLAG_IMPLIED_DIR flag to find implied dirs.
- Expect flagged implied dirs for all protocol 30 transfers.
2007-10-08 18:02:11 +00:00
Wayne Davison
3f30927214 - Mark implied dirs with FLAG_IMPLIED_DIR.
- Use the new *_CONTENT_DIR flag names (was *_XFER_DIR).
- Send implied dirs with XMIT_TOP_DIR | XMIT_NO_CONTENT_DIR.
- All protocol 30 transfers send flagged implied dirs.
2007-10-08 18:02:07 +00:00
Wayne Davison
ae11e4ee2d - Added a flag for implied dirs: FLAG_IMPLIED_DIR.
- Changed the *_XFER_DIR flags to *_CONTENT_DIR flags.
- Increment SUBPROTOCOL_VERSION.
2007-10-08 18:02:03 +00:00
Wayne Davison
b61665d5b6 Reposition the call to setup_iconv() so that it gets called only once
is a local_server copy, and so that arg-parsing code doesn't interfere
with the sending of a remote charset value.
2007-10-07 20:43:49 +00:00
Wayne Davison
38943d29d3 Improved on the list-only fix and on the other similar checks that want
to ignore implied dirs that are actually present in the file list
when inc_recurse is active and --no-implied-dirs was specified.
2007-10-07 07:18:49 +00:00
Wayne Davison
ff0284ddc4 - Simplified the code in recv_file_entry() for protocol 30.
- Simplified the flag setting in send1extra since we know that
  recurse is set.
- Make sure that FLAG_XFER_DIR is unset for a non-dot-dir when
  recurse is not set.
- The --relative code wasn't setting is_dot_dir enough.
2007-10-07 07:18:45 +00:00
Wayne Davison
3f65576881 Mention how --list-only w/o -r now abandons an old kluge. 2007-10-07 04:04:57 +00:00
Wayne Davison
3caf40356d We now send -d to the server for a list-only transfer w/o -r (rather
than sending -r with a kluged exclude).
2007-10-07 03:52:28 +00:00
Wayne Davison
26bbb6aa4b Set xfer_dirs when we set list_only. 2007-10-07 03:52:24 +00:00
Wayne Davison
bf66c2da14 Got rid of some old exclude trickery for --list-only w/o -r. 2007-10-07 03:52:20 +00:00
Wayne Davison
65f6b6b0ef Got rid of a useless list_only tweak. 2007-10-07 03:52:17 +00:00
Wayne Davison
983f647c7e Fix list-only output of dirs w/--relative but w/o --recursive. 2007-10-07 03:29:04 +00:00
Wayne Davison
14dfad3873 A couple tweaks to the AIX ACL code. 2007-10-05 20:47:18 +00:00
Wayne Davison
215465713b Make sure ICONV_OPTION is unset if we didn't find iconv_open()
and iconv.h.
2007-10-05 20:40:36 +00:00
Wayne Davison
6be5ac61bd Simplified a SMB_ACL_NEED_SORT conditional because some preprocessors
couldn't handle an #if embedded in a macro.
2007-10-05 02:45:09 +00:00
Wayne Davison
90c71caeb3 The hpux_count_obj() function should have been declared with a
void return type.
2007-10-05 02:30:39 +00:00
Wayne Davison
d46b5646c6 A few more improvements and some reshuffling. 2007-10-05 02:22:51 +00:00
Wayne Davison
da564b51a1 Preparing for release of 3.0.0pre1 2007-10-05 00:45:13 +00:00
Wayne Davison
f89617f7f2 One more tweak. 2007-10-05 00:41:38 +00:00
Wayne Davison
0f8984ed78 The latest changes. 2007-10-01 06:13:16 +00:00
Wayne Davison
306847ea67 Mention that we abort if the pid file exists. 2007-10-01 02:32:54 +00:00
Wayne Davison
d4eba300c9 The lp_load() function doesn't fudge the pszFname arg anymore. 2007-10-01 02:25:58 +00:00
Wayne Davison
dd589118d0 - Set config_file to a default filename if it is NULL.
- Changed create_pid_file() to fail if the pidfile already exists,
  which makes the daemon exit with an error.
- Output errors about a failure to open the config file or the lock
  file to (a still open) stderr.
- We now notice (and complain) if fork() fails.
2007-10-01 02:25:54 +00:00
Wayne Davison
f92e15efd5 Mention the latest way to specify multiple remote args. 2007-09-30 07:46:28 +00:00
Wayne Davison
4f3c1df6c3 Made list more complete. 2007-09-30 07:34:33 +00:00
Wayne Davison
eb8f5c74e1 Got rid of some SPACE-TAB sequencs in the indentation. 2007-09-30 07:30:48 +00:00
Wayne Davison
a960239f39 Allow additional remote args to contain an identical hostname instead
of requiring it to be empty.  This allows for the easy use of braces:
rsync -av host:file{1,2} /dest/
2007-09-30 07:14:16 +00:00
Wayne Davison
5621e5105a Moved become_daemon() into clientserver.c. 2007-09-30 06:57:12 +00:00
Wayne Davison
a1d2685b08 - Moved become_daemon() here from socket.c and made it static.
- Call lp_load() before we call become_daemon().
- Output an error to stderr if we fail to open/parse the config file.
- Added a create_pid_file() static function and call it earlier in
  the startup sequence.
2007-09-30 06:57:07 +00:00
Wayne Davison
0f6b4909db Improved --acls, --xattrs, and --fake-super. 2007-09-29 17:01:01 +00:00
Wayne Davison
b0ca7d2500 Specify a better SMB_ACL_VALID_NAME_BITS value for OS X. 2007-09-29 16:06:40 +00:00
Wayne Davison
7ed6bc53b9 Added get_xattr_acl(), set_xattr_acl(), and del_def_xattr_acl(). 2007-09-29 16:06:37 +00:00
Wayne Davison
f57ab2f718 When running with --fake-super, get/put ACLs from/to an xattr and don't
range-check the incoming values.
2007-09-29 16:06:34 +00:00
Wayne Davison
5ebb7935d2 Tweaked a variable name. 2007-09-29 04:35:26 +00:00
Wayne Davison
c50a9076e1 Added support for OS X testing using chmod +a and ls. 2007-09-29 02:26:23 +00:00
Wayne Davison
d417c51669 - Added OS X ACL support.
- Simplified some of the ge/set calling sequences.
- Got rid of SMB_ACL_PERMSET_T.
2007-09-28 21:54:11 +00:00
Wayne Davison
5b934f5133 Added OS X ACL support, using slightly tweaked sys_acl_*()
functions.
2007-09-28 21:54:07 +00:00
Wayne Davison
49ea69b3ff We enable ACL compilation on OS X by default now. 2007-09-28 21:54:01 +00:00
Wayne Davison
578219bed5 Determine the previous version number in a more reasonable fashion. 2007-09-26 17:43:57 +00:00
Wayne Davison
2e4a3d17b4 Some improvements and fixes for the upcoming release. 2007-09-26 14:57:52 +00:00
Wayne Davison
b4b24520f6 Added (conditional) include of stdint.h. 2007-09-23 22:31:14 +00:00
Wayne Davison
13710874ce Changed "statx" to "stat_x" to try to work around a build problem on AIX. 2007-09-23 22:19:55 +00:00
Wayne Davison
7341ee2dfd Fixed a crash bug in get_local_name() when the file list is empty. 2007-09-23 21:54:03 +00:00
Wayne Davison
e0cfd15bcc Fixed a glitch in the sending of mount-point dirs in inc_recurse mode. 2007-09-23 21:46:51 +00:00
Wayne Davison
5a47354882 Added a stub function for make_bak_dir(). 2007-09-23 21:05:15 +00:00
Wayne Davison
f5b532b144 Added an option to copy_file() that tells it to try to make a
backup directory if the open of the dest file fails.
2007-09-23 21:03:46 +00:00
Wayne Davison
c0dba635ba The --inplace code now properly handles creating a backup when
the --whole-file and/or --read-batch options are specified.
2007-09-23 21:03:41 +00:00
Wayne Davison
e1ac7791fe Changed make_bak_dir() to take a const char *. 2007-09-23 21:03:38 +00:00
Wayne Davison
5b3f6a2730 Use make_bak_dir() if we get ENOENT while trying to open an
inplace backup file.
2007-09-23 19:45:22 +00:00
Wayne Davison
f203266889 Made make_bak_dir() global. 2007-09-23 19:45:19 +00:00
Wayne Davison
21914d8135 Made clean_flist() only duplicate *_DIR_* flags on a dropped dir
when the kept entry is also a dir.
2007-09-23 19:45:00 +00:00
Wayne Davison
200aec7db4 Avoid a checker warning about unfreed memory. 2007-09-23 19:10:10 +00:00
Wayne Davison
a15c4b38b5 Fix a glitch in the handling of the last path element in a -R path
with a trailing slash.
2007-09-23 16:02:33 +00:00
Wayne Davison
40e383765a - Don't allow -x to drop implied directories.
- Improved the code that tries to avoid scanning the same dir
  twice in a row to not drop any relnamecache entries.
2007-09-23 15:46:11 +00:00
Wayne Davison
5441088298 Added the relnamecache structure and improved some variable names. 2007-09-23 14:35:12 +00:00
Wayne Davison
d0a6cdb62e Make sure that the dirs we are merging have the same timestamps. 2007-09-23 02:18:57 +00:00
Wayne Davison
19531e1f74 Got rid of some unneeded externs. 2007-09-23 02:03:20 +00:00
Wayne Davison
6f0805f564 Moved list-only output from flist.c to generator.c so that it works
properly even in inc_recurse mode.  Got rid of double output, weird
output order, and outputting of implied dirs w/--no-implied-dirs.
2007-09-23 02:00:53 +00:00
Wayne Davison
6191429b50 Added a missing "void" to the arg-spec of setup_iconv(). 2007-09-23 01:18:03 +00:00
Wayne Davison
89b76bac1f Added a test to make sure that merging relative items continues to
work right.
2007-09-23 00:30:40 +00:00
Wayne Davison
0758b2db30 Document the change to how --releative works. 2007-09-22 22:57:50 +00:00
Wayne Davison
74db1f1498 Always send implied dirs as dirs. 2007-09-22 22:37:52 +00:00
Wayne Davison
4f802c6637 Fixed a just-introduced glitch in directory creation with --no-implied-dirs. 2007-09-22 21:51:08 +00:00
Wayne Davison
33a04593ee We now forward the --no-implied-dirs option to the receiving side,
just in case we end up talking protocol 30 in inc_recurse mode.
2007-09-22 21:43:19 +00:00
Wayne Davison
6303f9a25f The latest --relative --no-implied-dirs code in inc_recurse mode
sends us a normal sequence of dirs, and we just skip the implied
ones.
2007-09-22 21:43:15 +00:00
Wayne Davison
3932c42373 Using relative with incremental recursion now results in a normal
sequence of directories in the hierarchy, and works properly when
merging things from multiple sources.
2007-09-22 21:43:11 +00:00
Wayne Davison
bc5df0f4e6 Fixed name of PTR_EXTRA_CNT (was PTR_EXTRA_LEN). 2007-09-22 21:43:08 +00:00
Wayne Davison
4b163f00c2 - Incremented the SUBPROTOCOL_VERSION to 9.
- Fixed name of PTR_EXTRA_CNT (was PTR_EXTRA_LEN).
- Added F_DIR_RELS_P() to support --relative in inc_recurse mode.
2007-09-22 21:43:05 +00:00
Wayne Davison
f07992739a Added ifuncs.h. 2007-09-22 18:07:44 +00:00
Wayne Davison
c605c2cdbd Tweaked opening comments. 2007-09-22 18:07:17 +00:00
Wayne Davison
1b42f628f4 Moved inline functions from rsync.h into ifuncs.h. 2007-09-22 16:52:58 +00:00
Wayne Davison
5dafe360de Moving inline functions into its own .h file. 2007-09-22 16:46:49 +00:00
Wayne Davison
6619d5fcc1 Added some stub functions for compilers not smart enough to get rid
of static inline functions that are not called.
2007-09-22 14:18:32 +00:00
Wayne Davison
b960483e99 Avoid affecting the proto.h file. 2007-09-22 14:16:48 +00:00
Wayne Davison
dd4a039515 Added some stub functions for compilers not smart enough to get rid
of static inline functions that are not called.
2007-09-18 19:53:50 +00:00
Wayne Davison
229554084d Added missing "#ifdef ICONV_OPTION" conditionals. 2007-09-18 18:46:03 +00:00
Wayne Davison
4a1edb63dd If iconv_t isn't needed, define it as an "int" so that our
proto.h file can be parsed.
2007-09-18 18:45:59 +00:00
Wayne Davison
3170b20967 Mention that a negative max-connections value disables the module. 2007-09-18 14:18:45 +00:00
Wayne Davison
d34cd639fc If max-connections is < 0, disable the module. 2007-09-18 14:14:22 +00:00
Wayne Davison
236df01b15 One final tweak. 2007-09-18 14:11:25 +00:00
Wayne Davison
21cafc50cc Some minor improvements in claim_connection(). 2007-09-18 14:09:38 +00:00
Wayne Davison
de80679b67 Switching to --no-i-r from --no-ir. 2007-09-18 14:04:46 +00:00
Wayne Davison
27999abab4 Document the changed name of --no-i-r. 2007-09-18 14:03:41 +00:00
Wayne Davison
82f37486a1 Mention the --protect-args (-s) option and how it interacts with
--iconv and --files-from.
2007-09-18 01:29:36 +00:00
Wayne Davison
7820fa949f Relocated the setting of ic_ndx. 2007-09-18 01:14:33 +00:00
Wayne Davison
2ac9793064 - Added new iconvbufs() conversion function that is now used for
our --iconv support.
- Moved the setup of the ic_ndx value to compat.c.
2007-09-18 01:11:57 +00:00
Wayne Davison
a4453606cc - Improved -s support.
- Handle setup_iconv() call in parse_arguments() so it gets set early.
2007-09-18 01:11:54 +00:00
Wayne Davison
71605b0f4d - Make use of new iconvbufs() function.
- Convert protected args when -s and --iconv are active.
- Simplified the splitting of args between normal and protected.
- Relocated setup_iconv() call so that it takes effect earlier.
2007-09-18 01:11:49 +00:00
Wayne Davison
ba525f770c - Make use of new iconvbufs() function.
- Convert remote --files-from filenames when -s and --iconv are
  active.
2007-09-18 01:11:45 +00:00
Wayne Davison
2509753fd3 Make use of new iconvbufs() function. 2007-09-18 01:11:42 +00:00
Wayne Davison
5688c74d25 - Setup the ic_ndx value here with the other FOO_ndx values.
- Don't disable inc_recurse due to --no-implied-dirs.
- Set filesfrom_convert bool.
2007-09-18 01:11:35 +00:00
Wayne Davison
2ac081ff60 - Added an xbuf type for use in the --iconv and --files-from code.
- Incremented the SUBPROTOCOL_VERSION.
2007-09-18 01:11:32 +00:00
Wayne Davison
5d3e5f641d Improved -s and support cvs's -e30.8 version idiom. 2007-09-17 06:02:09 +00:00
Wayne Davison
a0f29ed824 Make sure that the hashed hard-link numbers from different file
lists can't overlap in inc_recurse mode.
2007-09-17 01:45:44 +00:00
Wayne Davison
0b515981fc Changed print_child_argv() to take its prefix message as an arg. 2007-09-16 21:41:42 +00:00
Wayne Davison
2e8259bb0b Disable -s by default. 2007-09-16 02:42:55 +00:00
Wayne Davison
d274524317 Adding knowledge of some new options. 2007-09-15 21:10:35 +00:00
Wayne Davison
71845bd2a0 That should have been -s. 2007-09-15 21:10:18 +00:00
Wayne Davison
bdd53557a8 Force knowledge the -p option, since it gets passed specially. 2007-09-15 21:08:08 +00:00
Wayne Davison
d6ca255c21 - Fixed a bug in the passing of the --max-delete option.
- Added --no-i-d as a shorter no-implied-dirs.
- Changing to --no-i-r instead of --no-ir.
2007-09-15 20:54:31 +00:00
Wayne Davison
2dc7b91dd2 Handle inheritance of SGID bit on dirs marked with FLAG_DIR_CREATED. 2007-09-15 19:58:15 +00:00
Wayne Davison
288b12eefe We set FLAG_DIR_CREATED on a dot dir that got created by
get_local_name() rather than using the (now removed)
new_root_dir global.
2007-09-15 19:58:12 +00:00
Wayne Davison
f7d6dce6c8 - Fixed an inc_recurse problem with implied dirs not getting created
with the right attributes and getting omitted from the output.
- Got rid of the directory touch-up pass in inc_recurse mode again.
  This requires us to create any missing directories early, but we
  still report on what happened in the normal course of the transfer
  sequence.
- Use the FLAG_DIR_CREATED flag instead of (the removed)
  new_root_dir global.
2007-09-15 19:58:09 +00:00
Wayne Davison
48a481c4d0 Changed FLAG_DIR_CHANGED to FLAG_DIR_CREATED. 2007-09-15 18:43:36 +00:00
Wayne Davison
8db8eacbdd - If two duplicate directories have identical outside-the-transfer
paths, we only scan one of them in inc_recurse mode.
- When unduplicating directories in inc_recurse mode, dump the
  ealier directory if it is implied.
2007-09-15 17:29:25 +00:00
Wayne Davison
e8e9e12c3a Reverting last change for a re-think. 2007-09-15 17:00:41 +00:00
Wayne Davison
6e6daf5ac6 Fixed a problem with duplicate dirs being unduplicated in the list:
in inc_recurse mode, we must keep the last dir of the duplicates.
2007-09-15 16:32:38 +00:00
Wayne Davison
e73eed8563 Added more local-network IPs to the "hosts allow" rsyncd config
so that the FreeBSD machine in the compile farm can test.
2007-09-15 15:50:59 +00:00
Wayne Davison
da1319128a - Parse hard-link info as soon as we get it in inc_recurse mode.
- Improve the chances of the generator finding a match for a
  hard-link file in inc_recurse mode.
2007-09-15 15:40:57 +00:00
Wayne Davison
f2179fd370 The server should not wait around for an extra end-of-run message. 2007-09-15 15:36:04 +00:00
Wayne Davison
969cdffbea Prevent a server from outputting an end-of-run message about its
error-code that cannot be sent successfully.
2007-09-15 15:30:45 +00:00
Wayne Davison
3b7bcaaf34 Got rid of duplicate error when push_pathname() fails. 2007-09-15 15:27:56 +00:00
Wayne Davison
4abe379c05 Added an "ndx" arg to all the finish_hard_link() calls. 2007-09-10 06:15:28 +00:00
Wayne Davison
c980db5f08 - Simplified the flist-spanning gnum logic in match_gnums().
- Don't use hlink_flist in hard_link_check().
- Made the prev_name logic in hard_link_check() better.
- Added an "ndx" arg to the finish_hard_link() call.  Also, set the
  prev value of any prior entries to the first finished item (which
  ensures that any item that follows a re-shuffled item (which was
  waiting for a transferred file to finish) can find the FIRST+DONE
  item.
2007-09-10 06:15:25 +00:00
Wayne Davison
c35d6e3522 Added --no-protect-args and --no-s. 2007-09-09 07:58:19 +00:00
Wayne Davison
044dc29307 - Made glob_expand_one() public.
- Tweaking the calling syntax for glob_expand().
2007-09-09 07:53:22 +00:00
Wayne Davison
7a4addaa74 Added the --protect-args (-s) option, and made parse_arguments()
clear out an old popt context before starting a new one.
2007-09-09 07:53:18 +00:00
Wayne Davison
f7e5068d94 - If the user specifies a source arg with a hostspec in it in a local-
source transer, complain and exit.  This can help to find option
  problems were an arg to an option turns into a local-source arg,
  and the real remote-source arg will now get rejected rather than
  attempting to find a file with a colon in its name.
- We now support the ability to specify more than one remote arg using
  the ":FILENAME" idiom for additional remote filenames.
- If the --protect-args (-s) option was specified, we send just the
  "--server -s" options to the remote rsync when it is starting, and
  then the real args are sent over the socket.
2007-09-09 07:53:15 +00:00
Wayne Davison
67b8f3dfe7 - Renamed read_line() to be read_line_old().
- Renamed read_filesfrom_line() to read_line() and added args to allow
  the caller to control how it works.
- Added a new function, read_args(), that reads args from a file
  descriptor (using read_line()) and expands any wildcards in them.
  This function has relocated daemon code (from clientserver.c) and
  is also used by the new --protect-args (-s) option.  The new code
  also got rid of an extra strdup() that wasn't needed.
2007-09-09 07:53:12 +00:00
Wayne Davison
95a44066da Call the renamed read_line() function (was read_filesfrom_line()). 2007-09-09 07:53:08 +00:00
Wayne Davison
7909e65f83 - Made start_socket_client() and start_inband_exchange() take a variable
number of remote args.
- We now exchange a "VERSION.SUBVERSION" value in the initial @RSYNCD
  message.  This is backward compatible with pre-protocol 30 rsyncs,
  and fixes a problem where rsync daemons weren't checking if they were
  speaking a compatible pre-release protocol.
- Moved the protocol-handling code (which was in two places) into a new
  function:  exchange_protocols().
- Protocol 30 now sends/receives the daemon args using NULLs as a separator
  rather than a newline.
- Moved the arg-reading code into a new function in io.c:  read_args().
2007-09-09 07:53:05 +00:00
Wayne Davison
f74a3d813b Call the renamed read_line_old() function (was read_line()). 2007-09-09 07:53:02 +00:00
Wayne Davison
ac59386027 Used a couple "#if SUBPROTOCOL_VERSION != 0" conditionals. 2007-09-09 07:52:59 +00:00
Wayne Davison
73a649b7cb Tweaked the pretend-ssh script. 2007-09-08 20:16:28 +00:00
Wayne Davison
9b49704959 Added a remote-shell substitute for use in testing and for certain
other esoteric needs.
2007-09-08 20:03:42 +00:00
Wayne Davison
ffbffc647b Improved the argv/argc variable names that are really pointers. 2007-09-08 19:42:27 +00:00
Wayne Davison
968061bb65 Clarified something in the new --hard-links text. 2007-09-04 20:10:52 +00:00
Wayne Davison
c47e3ee1b6 Fixed two flist->files[first_hlink_ndx] references. 2007-09-04 07:13:01 +00:00
Wayne Davison
549a3efbb7 Improved a sentence. 2007-09-04 06:58:19 +00:00
Wayne Davison
accf8d12bc Added a test combining -H with -c and a hard-linked file that has only
one instance inside the copy hierarchy.  (Used to fail with protocol 29
or --no-ir.)
2007-09-04 06:57:57 +00:00
Wayne Davison
0eeb9f5481 If we turn off FLAG_HLINKED, set FLAG_HLINK_DONE so that any
file-entry values affected by HLINK_BUMP() stay put.
2007-09-04 06:53:47 +00:00
Wayne Davison
7b46e30fd4 Changed HLINK_BUMP() to look for either FLAG_HLINKED or FLAG_HLINK_DONE. 2007-09-04 06:52:52 +00:00
Wayne Davison
35c8fd761f Disabled the debug messages relating to the e_fds vars. 2007-09-03 21:51:59 +00:00
Wayne Davison
ba2d43d702 - Got rid of caveat about -H not working with incremental recursion.
- Talk about how inc_recurse affects -H.
- Mention --no-inc-recursive and --no-ir options.
2007-09-03 21:32:21 +00:00
Wayne Davison
29349024c4 Improved the handling of the file-status events received by
the generator.
2007-09-03 21:21:24 +00:00
Wayne Davison
d108e04f38 We don't disable inc_recurse due to -H anymore. 2007-09-03 21:21:21 +00:00
Wayne Davison
d4d6646aae Changes to allow hard-linking to work in inc_recurse mode. 2007-09-03 21:21:17 +00:00
Wayne Davison
cf2d26656d - Changes to allow hard-linking to work in inc_recurse mode.
- Incremented SUBPROTOCOL_VERSION to 7.
2007-09-03 21:21:12 +00:00
Wayne Davison
7918f24405 Changed some instances of \" in checkit calls to '. 2007-09-03 20:43:58 +00:00
Wayne Davison
9544261a45 Added weeding of "sending incremental file list" line to filter_outfile(). 2007-09-03 19:52:35 +00:00
Wayne Davison
354c9da60d Added hashtable.o. 2007-09-03 04:59:15 +00:00
Wayne Davison
626065702f Removed the old version of the hashtable functions and updated
the code to use the structures and functions calls.
2007-09-03 04:59:12 +00:00
Wayne Davison
9863bdbc93 - Use the new hashtable structures and functions.
- Tweaked a {read,write}_varint30() call set that didn't need to be "30".
2007-09-03 04:59:09 +00:00
Wayne Davison
83135e8f6a Updated hashtable structures. 2007-09-03 04:59:05 +00:00
Wayne Davison
369233927c The hashtable routines from hlink.c modified to have more generic names,
to support 2 sizes of key (32 and 64 bits), and to have a non-allocating
option for the find routine (returning NULL for no match).
2007-09-03 04:46:57 +00:00
Wayne Davison
7e4b6b7bc4 Use new0() function instead of new() followed by memset(). 2007-09-03 04:19:11 +00:00
Wayne Davison
a2dc4d687b Tweaked _new_array() to handle new use_calloc parameter. 2007-09-03 04:19:02 +00:00
Wayne Davison
a4431563e8 Added new0() and new_array0() to allocate and zero the memory. 2007-09-03 04:18:58 +00:00
Wayne Davison
fbd91cae0c One more tweak to latest omit-dir-times code. 2007-09-02 06:25:26 +00:00
Wayne Davison
eb7a6e09cb Added --no-omit-dir-times and --no-O. 2007-09-02 06:20:42 +00:00
Wayne Davison
9889a34bf2 Don't include the checksum_seed in the full-file MD5 checksum. 2007-09-02 06:00:30 +00:00
Wayne Davison
8e1e60e98f Bump up the SUBPROTOCOL_VERSION number. 2007-09-02 06:00:27 +00:00
Wayne Davison
f9998046a3 Made omit_dir_times a static variable in options.c by encoding
all the time-preserving semantics into preserve_times.
2007-09-01 16:57:01 +00:00
Wayne Davison
07bbf8703f Document the new --append and --append-verify options. 2007-09-01 16:38:09 +00:00
Wayne Davison
77502cbade Downgrade the new --append option to --append-verify for protocols < 30. 2007-09-01 16:38:04 +00:00
Wayne Davison
936fa865e1 Handle the new --append and --append-verify options. 2007-09-01 16:38:00 +00:00
Wayne Davison
2f188c8d96 Tweaked a comment. 2007-09-01 00:59:44 +00:00
Wayne Davison
83f5394810 Make the verbose message about the file-list expansion clearer in
what is being expanded.
2007-08-29 23:10:16 +00:00
Wayne Davison
24d677fc16 Don't omit the -4/-6 options if no IPv6 support was compiled into
rsync.  Just make them a no-op.
2007-08-22 00:36:56 +00:00
Wayne Davison
65a22a5ff7 In pool_free_old(), one code path was not clearing a "next" pointer,
so the code could try to free an extent twice in certain circumstances.
2007-08-21 05:04:02 +00:00
Wayne Davison
a0f70237f5 Fix pool_create() to honor the POOL_INTERN flag.
(Thanks to Brion Vibber.)
2007-08-21 04:54:30 +00:00
Wayne Davison
4eff3051a0 Fixed a null-pointer dereference pointed out by Olivier Thauvin. 2007-08-16 01:22:46 +00:00
Wayne Davison
e208631a5b Improved the arg-checking of a daemon command. 2007-08-11 16:53:31 +00:00
Wayne Davison
b553a3dd20 Document the RSYNC_CONNECT_PROG environment variable. 2007-08-11 16:51:48 +00:00
Wayne Davison
e5f1a96ff8 Added support for a %H escape in the value of the RSYNC_CONNECT_PROG
environment variable.
2007-08-11 16:20:56 +00:00
Wayne Davison
eb7e7b2499 Get rid of the comment that --xattrs implies --perms and the
outdated text that said it was a non-standard option.
2007-08-04 22:19:49 +00:00
Wayne Davison
3caafdfd2f Make the --xattrs option not imply --perms. 2007-08-04 22:19:43 +00:00
Wayne Davison
26ac181223 Let's go with "delta transfer algorithm" (thanks, Matt). 2007-08-04 19:09:26 +00:00
Wayne Davison
7fa60281bf Avoid a crash if pop_local_filters() has some pointer gaps. 2007-08-04 19:09:21 +00:00
Wayne Davison
73f2fa8189 - Call the rsync algorithm differential rather than incremental.
- Don't refer to --files-from in the talk of incremental recursion,
  since it might make people think that --files-from disables
  incremental recursion for any recursively scanned directories.
2007-08-04 17:47:08 +00:00
Wayne Davison
75f162e46f - Use the new XMIT_NON_XFER_DIR flag.
- Make sure that non-inc-recurse mode sets FLAG_XFER_DIR on all
  the non-implied directories.
- Don't set FLAG_XFER_DIR on non-directories.
2007-08-04 17:47:02 +00:00
Wayne Davison
1d2ca00703 - Added XMIT_NON_XFER_DIR flag.
- Incremented the SUBPROTOCOL_VERSION number.
2007-08-04 17:46:59 +00:00
Wayne Davison
4d91a5f8f4 Only honor XFLAGS_HLINKED on a non-directory. 2007-08-04 16:10:37 +00:00
Wayne Davison
61cb031ca4 Changed flags variable in send_file_entry() to xflags. 2007-08-04 16:08:16 +00:00
Wayne Davison
ff0c27c926 Files with the same size should also be skipped by --append. 2007-08-01 22:47:36 +00:00
Wayne Davison
d1d0a7051f Don't output a negative time-remaining value if the file has grown. 2007-08-01 22:35:54 +00:00
Wayne Davison
444f9f7b04 Fixed the port-parsing in an rsync:// path; e.g., this now
works properly:  rsync://backup@otherbox/module/a:123:b
2007-08-01 22:25:02 +00:00
Wayne Davison
411c04f06f If readdir() gives us an empty name, reject it. 2007-08-01 22:18:46 +00:00
Wayne Davison
5d935dce63 If --no-ir is specified, pass it to the server. 2007-07-24 04:09:46 +00:00
Wayne Davison
b88f6fe7e5 Let's try using egrep instead of grep since grep on Solaris
systems was failing to work right.
2007-07-15 06:37:17 +00:00
Wayne Davison
e6109f496c Updated the --max-delete docs. 2007-07-15 06:01:27 +00:00
Wayne Davison
836ce36a4f Mention the improved --max-delete behavior. 2007-07-15 05:51:05 +00:00
Wayne Davison
35da2ec35a We don't need a compatibility check for --max-delete anymore. 2007-07-15 05:43:05 +00:00
Wayne Davison
7b9598b2d5 We now take a negative value specified to --max-delete as being
synonymous with --max-delete=0.  We also pass a request for 0
deletions to the server as --max-delete=-1.  This ensures that we
can send a backward-compatible option to old and new versions alike.
2007-07-15 05:42:30 +00:00
Wayne Davison
4a4622bbe5 Improve the description of --update with respect to symlinks and
special files.
2007-07-14 22:24:03 +00:00
Wayne Davison
c9ec460807 Make extra-verbose output of touch_up_dirs() only mention the dirs. 2007-07-14 21:58:36 +00:00
Wayne Davison
79cd0c7fa4 Using --relative with --no-implied-dirs turns off incremental recursion.
(A temporary measure until some bugs can be fixed.)
2007-07-14 21:49:11 +00:00
Wayne Davison
de8c8b28c0 - When --omit-implied-dirs is specified and the creation of a directory
fails, we must make sure that the item we're skipping has a name that
  is still inside the missing hierarchy by using a prefix matching func.
- We now handle the failure to remove a file to create a dir the same
  way as a failed mkdir() (skipping the failed dir's contents).
2007-07-14 21:25:51 +00:00
Wayne Davison
569e6f432b - Made f_name() and f_name_cmp() take const pointers.
- Added f_name_has_prefix().
2007-07-14 21:21:15 +00:00
Wayne Davison
0d585188f9 Make sure that any "dont compress" patterns that have wildcards in a
suffix match stay in the wildcard-matching list.
2007-07-14 19:36:52 +00:00
Wayne Davison
34ca58d440 The "dont compress" daemon option points to the --skip-compress option
for the default set of non-compressed file suffixes.
2007-07-14 19:32:10 +00:00
Wayne Davison
9c528e2935 Mention the latest changes. 2007-07-14 19:29:04 +00:00
Wayne Davison
2b967218eb Document --skip-compress. 2007-07-14 19:24:44 +00:00
Wayne Davison
6e058b4b60 - Added support for the new --skip-compress option.
- Optimized the matching of non-compressing file suffixes.
2007-07-14 19:24:35 +00:00
Wayne Davison
b1e436ec17 Parse the --skip-compress=LIST option and sent it to the sending side. 2007-07-14 19:24:32 +00:00
Wayne Davison
4319cc56d8 Added more suffixes to the default "dont compress" value. 2007-07-14 19:24:27 +00:00
Wayne Davison
952ae75138 Make sure that --dry-run with --del doesn't output extraneous info
when the dest directory does not exist.
2007-07-14 04:47:42 +00:00
Wayne Davison
4d745d3cf5 The delete-during code needs to skip directories that don't exist
yet in --dry-run mode to avoid outputting bogus delete details.
2007-07-14 04:20:13 +00:00
Wayne Davison
8798be8e63 Mention license change. 2007-07-14 04:06:33 +00:00
Wayne Davison
42b06481c3 Made some descriptions concerning modification times clearer. 2007-07-12 14:43:26 +00:00
Wayne Davison
dbe287b701 Needed to use ndx_end in decrement_flist_in_progress(). 2007-07-12 14:04:11 +00:00
Wayne Davison
8e3b627d07 Mention how --ignore-existing can be useful for restarting a copy
that uses --link-dest.
2007-07-10 14:49:35 +00:00
Wayne Davison
809724d7e2 - Use "filename", not "file name".
- Say "regular file" instead of "file" when itemizing a list of
  non-directory types.
- Try to avoid "file" in its generic sense, as it is hard to figure
  out when it includes dirs and when it doesn't.
2007-07-10 14:21:59 +00:00
Wayne Davison
8e41b68e8f Tweaking the license text a bit more. 2007-07-10 13:55:49 +00:00
Wayne Davison
dc77edf218 Martin gave his approval to use GPLv3 with this code. 2007-07-09 01:24:01 +00:00
Wayne Davison
65ba6af61b - Do directory touch-ups at the end, even in inc-recurse mode.
- Use the latest F_DIR_*() defines (whose names were tweaked).
2007-07-08 20:53:42 +00:00
Wayne Davison
83d5e90054 - Use the new DEV_EXTRA_CNT and DIRNODE_EXTRA_CNT defines.
- Use the latest F_DIR_*() defines (whose names were tweaked).
2007-07-08 20:53:38 +00:00
Wayne Davison
e434f0ebfe Use the latest F_DIR_*() defines (whose names were tweaked). 2007-07-08 20:53:35 +00:00
Wayne Davison
a08979d564 - Define DEV_EXTRA_CNT and DIRNODE_EXTRA_CNT.
- Define and use ACL_BUMP(), fixing a clash between -A and -x in a
  directory's data.
- Tweaked the F_DIR_*() defines to have more consistent names.
- Don't make F_SUM() return a char pointer that is const.
2007-07-08 20:53:31 +00:00
Wayne Davison
252af65bb4 Changed the spots that referred to the filter_level as filter_flags
to make the naming consistent.
2007-07-08 06:30:28 +00:00
Wayne Davison
d048c2f225 Added a test for --prune-empty-dirs. 2007-07-08 06:25:57 +00:00
Wayne Davison
9b9d5f89b3 Got rid of the output differences for protocol 30 since it is now
the same as earlier protocols.
2007-07-08 06:25:54 +00:00
Wayne Davison
e5bf3b5855 - Incremental recursion mode does not process the dirs while scanning a
file list's contents.  Instead, it handles a parent dir prior to each
  extra file list.  This makes the dir-processing order the same in
  protocol 30 as it is in earlier protocols.
- Moved the permission-fudging code for dirs into recv_generator() to
  make the new protocol-30 dir-handling logic easier.
2007-07-08 06:25:51 +00:00
Wayne Davison
6755a7d742 If we get an ndx that is 1 entry prior to an incremental flist's
start, it refers to the file list's parent dir.
2007-07-08 06:25:47 +00:00
Wayne Davison
5459e693a3 - The sending side now sets the parent_ndx value in each file list.
- Leave a 1-entry gap between incremental file lists so that we can use
  that index value to refer to the parent directory of each file list.
- Set and use the new ndx_end value in the file list.  The incremental
  recursion mode omits dirs in this value (except in the first list)
  since the generator will be using the new "gap" ndx value to process
  each parent dir.
2007-07-08 06:25:42 +00:00
Wayne Davison
24108eb854 - Increased the SUBPROTOCOL_VERSION to 4 due to the new dir-ndx logic.
- Added ndx_end value to struct file_list.
2007-07-08 06:25:36 +00:00
Wayne Davison
4635fb9995 Avoid the prune-empty-dir code when cleaning a file list created
by get_dirlist().
2007-07-07 20:43:14 +00:00
Wayne Davison
9decb4d2ef Changed "count" to "used" in struct file_list since there can
be empty items that make the count inaccurate (and the name
somewhat deceiving).
2007-07-07 20:22:05 +00:00
Wayne Davison
b3b326016a The length check in make_file() doesn't need to subtract pathname_len
anymore, as the sender code never concatenates the F_PATHNAME() value
with the dirname+basename string these days.
2007-07-07 16:01:59 +00:00
Wayne Davison
4bde45f60e Make the comment even better. 2007-07-07 15:37:56 +00:00
Wayne Davison
4fd842f98d Switching to GPL 3. 2007-07-07 05:33:14 +00:00
Wayne Davison
f92f5b166e Tweaked a comment to remove a (really old) rsync version reference. 2007-07-07 05:25:50 +00:00
Wayne Davison
9b25ef35bd Switch the checking of preserve_[ug]id var to checking [ug]id_ndx var
when the code is about to use the [ug]id_ndx value as an index (since
this saves a memory reference).
2007-07-02 22:11:23 +00:00
Wayne Davison
7c73536c25 Use module_dir instead of lp_path(). 2007-07-02 22:06:48 +00:00
Wayne Davison
33cbd577ad If a module's path is not absolute, make it absolute. 2007-07-02 22:02:14 +00:00
Wayne Davison
524eaa8245 We omit copying any user-space rsync.%FOO attributes unless the
user specified -X twice.
2007-07-02 21:35:14 +00:00
Wayne Davison
9742b386b3 Make option variables a little clearer by using separate FOO_ndx
values to index into the file-list extra-attribute array instead
of abusing the preserve_FOO variables.
2007-07-02 21:29:49 +00:00
Wayne Davison
8b498b9f1a Decided against the last change. 2007-06-06 15:43:34 +00:00
Wayne Davison
c04af69701 Allow a NULL address to be passed to pool_free_old() to indicate that
it should free all old mem and reset to an empty state.
2007-06-06 15:38:31 +00:00
Wayne Davison
f87fb190b3 Check for the setacl command for Tru64 (which doesn't have setfacl). 2007-06-02 16:44:23 +00:00
Wayne Davison
a21e72c3e6 Attempting to make the mask test compatible with Solaris 8. 2007-06-02 16:30:04 +00:00
Wayne Davison
1c4ffe64db Mention the pool_alloc changes. 2007-05-29 04:23:50 +00:00
Wayne Davison
abdcb21a7a Unified the file-list pool used in incremental recursion mode so that
we use less memory, especially in small transfers.  As file lists are
discarded, we use the new pool_boundary() and pool_free_old() functions
to discard pool extents that are no longer needed.
2007-05-29 04:19:47 +00:00
Wayne Davison
f5ba7bfbb6 - Changed FILE_EXTENT to NORMAL_EXTENT and HLINK_EXTENT to SMALL_EXTENT.
- Added a pool_boundary variable to struct file_list.
2007-05-29 04:19:44 +00:00
Wayne Davison
676e604135 Added pool_free_old() and pool_boundary() functions to add a way to
free all wholly affected extents older than a particular point in time.
2007-05-29 04:19:41 +00:00
Wayne Davison
3fac8ca8d1 Tweaked a variable and a label to make them less confusing. 2007-05-29 02:47:23 +00:00
Wayne Davison
33766a8daa Improvements to increase clarity, fix misstatements, add missing
punctuation, and fix some typos.
2007-05-29 02:46:44 +00:00
Wayne Davison
e3d27df444 - Fixed a bug where a pool_free() on the most-recently allocated pool
item was trying to make that memory available to the pool, but it
  failed to adjust the right variable.
- Fixed a bug in pool_free() where the return of the entire live
  extent back to unallocated status did not obey POOL_CLEAR.
- Use the new() and new_array() functions instead of malloc().
- Changed the sqew variable to skew.
- Some other minor formatting tweaks.
2007-05-29 00:52:08 +00:00
Wayne Davison
6aa27a7ce5 - Do less seeking when writing a sparse file.
- Don't rewrite the last byte of a file in sparse mode when the
  file didn't end with a null char.
2007-05-26 21:46:22 +00:00
Wayne Davison
47cffb77de Handle EINTR in a couple places where we handle the --file-from I/O. 2007-05-26 21:44:19 +00:00
Wayne Davison
565a340b0a Changed verbosity back from -vvvv to -vv. 2007-05-25 14:32:08 +00:00
Wayne Davison
f45b64d8dd Improved the sort comment. 2007-05-25 14:29:35 +00:00
Wayne Davison
56ce72c447 Improved a comment. 2007-05-25 14:23:05 +00:00
Wayne Davison
898fab2577 Got rid of superfluous acl_clear_perms() call that Antti Tapaninen
pointed out.
2007-05-25 14:16:57 +00:00
Wayne Davison
0e5dd89866 Mention latest improvements. 2007-05-24 23:11:33 +00:00
Wayne Davison
79028af116 Changed dup-detection code to keep the first item in the user's args.
This is more in keeping with the way cp works, and also makes the dir-
joining code (in inc_recurse mode) easier.
2007-05-24 23:08:39 +00:00
Wayne Davison
a572e12675 - Added fsort() and fsort_tmp() that implement a mergesort routine
that ensures that any identical items in the file-list stay in the
  same order as they had in the input.  It will also obey the --qsort
  option (which causes it to punt the sort to the qsort() routine).
- Changed the various places that sort the file-list to call fsort().
2007-05-24 02:50:41 +00:00
Wayne Davison
c8e8394615 If someone forces the use of qsort() via --qsort, disable incremental
recursion (at least for now).
2007-05-24 02:50:38 +00:00
Wayne Davison
8487f9cf29 - Added the --qsort option.
- Added several new --no-FOO options.
2007-05-24 02:50:35 +00:00
Wayne Davison
d750be6ad8 Make sure we don't try to output a NULL pointer in a verbose message. 2007-05-23 00:48:27 +00:00
Wayne Davison
0bb8616535 - Output a -vvv(erbose) message in the touch_up_dirs() loop.
- Made the keep-alive counter in touch_up_dirs() work better.
- Use !(N & 0xFF) instead of !(N % 200).
2007-05-23 00:42:38 +00:00
Wayne Davison
1faa1a6da9 Output a -vvv(erbose) message when receiving an incremental file list. 2007-05-23 00:42:32 +00:00
Wayne Davison
b5ae4e25c2 Added a comment to the do_chmod() to mark it as a discouraged function. 2007-05-22 05:59:02 +00:00
Wayne Davison
3d0a159d96 Added a comment to a shared iterator to avoid a warning from IBM's checker. 2007-05-22 05:58:59 +00:00
Wayne Davison
8ea07c0030 - Changed the dir_flist code on the sending side to derive its sorted
data from the sorted parent flist.  This ensures that any entries
  marked with FLAG_DUPLICATE are in the same order in the dir_flist
  (where the flags get checked) as they are in the parent flist
  (where the flags get set).
- Made the flist_expand() function static.
- Added a growth count arg to flist_expand().
- Made make_file() set a pool variable instead of tweaking flist.
- Improved the error message when a dir-number is out of bounds.
2007-05-22 05:50:47 +00:00
Wayne Davison
59fd2a5e7d Improved the error message when a dir-number is out of bounds. 2007-05-22 05:50:41 +00:00
Wayne Davison
ae87c43452 One more output_flist() call that should verify if my analysis
of the Solaris 10 host's merge-test failure is correct or not.
2007-05-22 03:58:18 +00:00
Wayne Davison
f1599b9ef2 Be more verbose so that we can debug what is going wrong on solaris. 2007-05-22 00:00:51 +00:00
Wayne Davison
ee83e1bd4d Improved the index values that output_flist() outputs when we're being
extra verbose:  they now have the list's ndx_start value added in.
2007-05-22 00:00:07 +00:00
Wayne Davison
7455467c17 One more try at silencing some checker warnings. 2007-05-21 23:45:26 +00:00
Wayne Davison
19395697b9 Let's see if we can silence some more code-checker warnings. 2007-05-21 18:39:05 +00:00
Wayne Davison
7787579ad4 Added some "FALL THROUGH" comments in the main switch. 2007-05-21 10:20:18 +00:00
Wayne Davison
58a37ed34a Get rid of compiler warning about iconv()'s second parameter. 2007-05-21 03:56:06 +00:00
Wayne Davison
fe8d61e5d5 Fixed a thinko in the calling of recv_add_gid(). 2007-05-21 03:20:39 +00:00
Wayne Davison
87b0cc726b Got rid of the temporary "set -x" that was added for debugging. 2007-05-21 03:09:25 +00:00
Wayne Davison
4504b2259f The match_gid() function needed to affect the *flags_ptr value
when re-using the last-found match.
2007-05-21 03:08:55 +00:00
Wayne Davison
cf1b4969b9 The recv_file_entry() function needed to remember the gid flags so that
it can reuse them when the gid stays the same.
2007-05-21 03:08:01 +00:00
Wayne Davison
434e77193c Set -x option to diagnose what is going wrong on FreeBSD. 2007-05-21 02:31:20 +00:00
Wayne Davison
858d45f160 Cast some F_OWNER()/F_GROUP() values to make sure that we don't get
a signed/unsigned compiler warning on some systems.
2007-05-21 02:17:48 +00:00
Wayne Davison
63186ec077 Fixed a problem in a couple OS's sys_acl_get_access_bits() functions. 2007-05-21 02:09:45 +00:00
Wayne Davison
dfcb386569 Make sure that the scratch dirs have rwx permissions before we try
a recursive rm.
2007-05-21 02:06:51 +00:00
Wayne Davison
d15f2ff0cf Tweaked a sentence in the --size-only section. 2007-05-21 01:06:16 +00:00
Wayne Davison
c395acd804 Create a symlink back to the source dir in the scratchdir of a test. 2007-05-21 01:05:36 +00:00
Wayne Davison
030820d5dc - Unified the formerly separate user & group name-lists into a single
name-list.  On POSIX systems, this list will be sorted with the user
  names first, so the code will work essentially the same way it did
  before for the currently supported OSes.  However, the code will now
  more easily support non-POSIX ACL setups such as (hopefully) the one
  used in OS X.
- Increased the (potentially) available access-bit storage for name
  elements from 3 to 31 bits.  For non-name elements, the access bits
  now have the potential to store 7 bits instead of 3.  (All the
  current POSIX implementations still error-check their values at 3
  bits, but this will allow adding non-POSIX ACL setups more easily.)
- The protocol that transmits the ACL information was changed to send
  names in a single list, and to use {read,write}_varint() functions
  instead of {read,write}_byte().  This supports sending access-bit
  values up to 32-bits (minus any bits reserved for xmit flags).
- The construction of the internal access-bit value was moved into the
  lib/sysacls.c code, so that it could be handled in an appropriate
  manner for each OS.

(Aside: the code still does not support transmitting incompatible ACL
information between systems, but I envision improving --fake-super to
store the ACL information that is received as xattr information, and
this would allow a system that supports extended attributes to backup
a source system that had an incompatible ACL method.)
2007-05-21 01:04:40 +00:00
Wayne Davison
043ef55b22 - Define what the valid access bits are for a name element and a
non-name element.
- Set a define when the OS needs the name-list sorted.
- Got rid of the permset-related defines.
- Got rid of some function prototypes that rsync doesn't need.
- Got rid of the defines for the do-nothing ACL code.
2007-05-21 01:04:37 +00:00
Wayne Davison
a30dcbc0a8 - Added a function to get/set all the access-bit values with a single
call.  This allows the per-OS compatibility code to construct the
  value with however many bits are supported by each OS.
- Removed several functions that rsync doesn't (and won't) need.
- Got rid of the do-nothing ACL code (the ACL code in rsync should be
  disabled on a system that we can't support).
2007-05-21 01:04:34 +00:00
Wayne Davison
02f0227e87 Changed SUBPROTOCOL_VERSION from 2 to 3 because of the ACL protocol changes. 2007-05-21 01:04:31 +00:00
Wayne Davison
142a5e7b8b Moved GID_NONE define from rsync.h to uidlist.c. 2007-05-20 07:40:07 +00:00
Wayne Davison
fdfc67406c - Added more users and some groups to one of the files we're copying. 2007-05-20 07:10:48 +00:00
Wayne Davison
fb7b9ddcb1 - Use F_OWNER() and F_GROUP() instead of F_UID() and F_GID(). 2007-05-20 07:10:45 +00:00
Wayne Davison
4ade505c7e - Use F_OWNER() and F_GROUP() instead of F_UID() and F_GID().
- Use the new FLAG_SKIP_GROUP define.
2007-05-20 07:10:41 +00:00
Wayne Davison
1564cd5a87 - Use F_OWNER() and F_GROUP() instead of F_UID() and F_GID().
- Made recv_file_entry() name the xmit-flags variable "xflags" to
  prevent confusion with the internal flags value we're creating.
- Added an arg to the calls of recv_group_name() and match_gid().
- Use the improved function names: send_id_list() and recv_id_list().
- Improved the display of the GID values in output_flist().
2007-05-20 07:10:37 +00:00
Wayne Davison
33233b4900 - Fixed a bug in the match_racl_ids() function's iteration.
- Fixed a bug with preserving a group ID in an ACL when running as
  a non-super user that the user is not a member of.
2007-05-20 07:10:34 +00:00
Wayne Davison
d6b422a61c - Changed id & id2 from int to id_t in the struct iflist.
- Added a uint16 flags var to struct iflist.
- We now mark a group with FLAG_SKIP_GROUP if the receiving user
  can't set a group rather than turning it into GID_NONE.  This
  allows us to keep the real group ID mapping, which is needed by
  the ACL code.
2007-05-20 07:10:31 +00:00
Wayne Davison
ff2001b91b - Added FLAG_SKIP_GROUP define.
- Removed F_UID() and F_GID() defines.
2007-05-20 07:10:28 +00:00
Wayne Davison
d858b27400 A couple more minor tweaks. 2007-05-08 17:04:05 +00:00
Wayne Davison
1874f7e2e1 Improved the documentation on the "quick check" algorithm and the
--size-only option.
2007-05-08 17:01:24 +00:00
Wayne Davison
377d22ab9f If the server is exiting with an error, delay our exit just a little
in order to give the client side a better chance of reading any error
message we just sent.
2007-05-06 19:44:26 +00:00
Wayne Davison
4f3797c7e2 Clumped some option-sending together that only happens on the sending side. 2007-05-05 18:34:37 +00:00
Wayne Davison
6b5a8f80fc Try a better way to deduce if the xattr functions we need are there. 2007-04-30 02:58:14 +00:00
Wayne Davison
bf10faa9dc Added a "sleep 1" to make certain failures more reproducible. 2007-04-29 15:01:57 +00:00
Wayne Davison
548ca46fec Use the --super option for the non-fake test, just in case a system
can chown without appearing to be root (uid 0).
2007-04-28 23:47:16 +00:00
Wayne Davison
e8c64ffdc7 If the lgetxattr() function isn't found, disable xattr support. 2007-04-28 18:40:23 +00:00
Wayne Davison
0eb05245f1 Authorize 10.0.1.2 for one of the BSD test-farm systems. 2007-04-28 17:22:53 +00:00
Wayne Davison
0156c7842d Improved the --iconv description. 2007-04-27 14:09:22 +00:00
Wayne Davison
1acb8f5119 Added the $(CHECK_SYMLINKS) var to installcheck target. 2007-04-27 13:52:07 +00:00
Wayne Davison
76e754a0fd Fixed the buildability of the file without ICONV_OPTION enabled. 2007-04-27 00:19:21 +00:00
Wayne Davison
e7f905accb Fixed the comment about --iconv. 2007-04-27 00:19:02 +00:00
Wayne Davison
a9a8bc962c Got rid of the --no-ir kluge in this test. 2007-04-26 23:15:51 +00:00
Wayne Davison
a6e7b97868 - Fixed the merging of duplicated directory hierarchies in incremental
recursion mode.
- Fixed some problems with --iconv in incremental recursion mode.
2007-04-26 23:15:47 +00:00
Wayne Davison
1befb74b13 Refer to the right sorted/unsorted file list array in touch_up_dirs(). 2007-04-26 23:15:43 +00:00
Wayne Davison
8f3335a18c The server now needs the F_NDX() data for --iconv with incremental
recursion.
2007-04-26 23:15:39 +00:00
Wayne Davison
505c0579f7 Added FLAG_DUPLICATE for the sender to mark a duplicate flist entry
(which is better on the sending side than clearing the duplicate's
data).
2007-04-26 23:15:36 +00:00
Wayne Davison
a430691df1 Prevent a hang in incremental-recursion mode when the receiver encounters
an error updating the file:  the receiver now sends MSG_NO_SEND to the
generator so that it knows when all outstanding work is completed.
2007-04-26 23:06:38 +00:00
Wayne Davison
332cf6df7c The --iconv option has now made it to the trunk. 2007-04-26 05:53:13 +00:00
Wayne Davison
3f7afe7ec1 Changed a "mkdir -p" into a makedir. 2007-04-26 05:32:38 +00:00
Wayne Davison
8fc4033ef0 Changed F_ROOTDIR() to F_PATHNAME(). 2007-04-26 00:23:52 +00:00
Wayne Davison
ef35abb2b7 - Renamed flist_dir to pathname to avoid confusion with dir_flist var.
- Renamed push_flist_dir() to push_pathname().
- Set a pool var in recv_file_ent() instead of playing games with flist.
- Simplified the top_flags computation in send_file_list().
2007-04-26 00:23:48 +00:00
Wayne Davison
0b68d6b6f4 Create symlinks for fake tests. 2007-04-24 19:33:12 +00:00
Wayne Davison
f1271537a4 Put the files down in a subdir so that we test backup's dir-
creating functionality (which had a bug until recently).
2007-04-24 19:03:54 +00:00
Wayne Davison
b13505da1d Need to call unmake_file() instead of free() on a file_struct. 2007-04-24 18:43:31 +00:00
Wayne Davison
7ea6ea98c8 Use a single makepath call with multiple args. 2007-04-24 18:21:08 +00:00
Wayne Davison
d1798a2fda Allow makepath to take multiple args. 2007-04-24 18:19:25 +00:00
Wayne Davison
e911ff75d6 Specify an arg sequence that was recently failing to work. 2007-04-24 18:18:57 +00:00
Wayne Davison
49f7162e7d Use a slightly different rsync calling syntax. 2007-04-24 18:18:29 +00:00
Wayne Davison
3bb88b4388 Fixed a directory push problem with the user specified an arg
with a subdir followed by an arg with no subdirs.
2007-04-24 17:53:54 +00:00
Wayne Davison
b3fbe3ce35 The chown script now has a --fake-super mode if the script name has
"fake" in it.  Added a symlink named chown-fake.test.
2007-04-24 17:22:01 +00:00
Wayne Davison
9557eabaa7 Made the devices.test script do a real device test when called
normally, or a fake-device test when called with "fake" in the
script name.  Added a devices-fake.test symlink.
2007-04-24 17:06:09 +00:00
Wayne Davison
acac1f5c6f Conditionalize xattr code for systems without xattr support. 2007-04-24 16:54:38 +00:00
Wayne Davison
3427355422 A little more popt tweaking. 2007-04-24 16:11:02 +00:00
Wayne Davison
cbf626fd62 Fixed build problem for tls for those using the included popt. 2007-04-24 16:06:29 +00:00
Wayne Davison
1c702303eb Moved the header info from smb_acls.h into lib/sysacls.h. 2007-04-24 08:11:02 +00:00
Wayne Davison
9a234269ed Improved the usage message. 2007-04-24 08:00:49 +00:00
Wayne Davison
db9c9e2766 Added arg-parsing to tls.c. 2007-04-24 07:52:45 +00:00
Wayne Davison
9439c0cb5a Adding the --fake-super option. 2007-04-24 07:32:44 +00:00
Wayne Davison
2ed790f354 Improved the SUBPROTOCOL_VERSION code a little, and bumped the value
to 2.
2007-04-23 19:54:07 +00:00
Wayne Davison
486f8cd1ab Changed the prerelease-protocol support to use an idiom that will not
slow down the initial version handshake between the two sides.
2007-04-23 19:03:29 +00:00
Wayne Davison
875a13b42c No need to reset quiet, since we tell parse_arguments() that it
should prevent quiet from getting set.
2007-04-23 18:40:00 +00:00
Wayne Davison
719522b9bd Tweaked --version in a few minor ways, including the mentioning of
the SUBPROTOCOL_VERSION if it is non-zero.
2007-04-21 19:46:19 +00:00
Wayne Davison
753849fdbc Batch files need to be written with the new subprotocol value
for protocol 30.
2007-04-21 19:32:46 +00:00
Wayne Davison
bb25779de7 Mention how many bits our local timestamps support. 2007-04-21 19:31:54 +00:00
Wayne Davison
348d54d6d1 Mention the latest changes that have been made. 2007-04-21 19:27:04 +00:00
Wayne Davison
4471d9e570 Added a way to exchange a protocol's sub-protocol value. This will be
0 when a protocol goes final, and non-zero for an intermediary CVS
version of a protocol that is in flux.  If we find that we're talking
to a CVS version with a different sub-protocol #, we automatically
drop back to the prior protocol that the sides have in common.
2007-04-21 18:40:42 +00:00
Wayne Davison
19d4cac996 We now allow verbose messages to be sent when forwarding incremental-recursion
file-list data from the receiver to the generator.
2007-04-20 22:40:01 +00:00
Wayne Davison
e4c877cf70 Added a message queue for the receiver->generator messages to handle the case
where the message pipe is being used to forward the file-list data.
2007-04-20 22:39:58 +00:00
Wayne Davison
f14b3ef430 Verify that the modtime value is not being truncated, and complain if it is. 2007-04-20 22:39:55 +00:00
Wayne Davison
f3c93b1761 Check the size of a time_t. 2007-04-20 21:39:08 +00:00
Wayne Davison
a72ba0cfac Call the new {read,write}_varlong30() names for the long-int
functions that are protocol sensitive.
2007-04-20 08:17:06 +00:00
Wayne Davison
ba59bd68fc - Call the new {read,write}_varlong30() names for the long-int
functions that are protocol sensitive.
- Changed the sending of the time value in protocol 30 to support
  64-bit values without bloating positive 32-bit values.
2007-04-20 08:17:03 +00:00
Wayne Davison
1c60d21947 Got rid of the NVAL*() defines. 2007-04-20 08:16:59 +00:00
Wayne Davison
473feecff3 Added {read,write}_varlong30() inline functions to use the
right long-int function based on protocol version.
2007-04-20 08:16:56 +00:00
Wayne Davison
351e23ad8e - Changed the {read,write}_longint() functions into separate
{read,write}_varlong() and {read,write}_longint() functions:
  the former handles variable-length transmissions, and the
  latter is backward-compatible with older rsync versions.
- Improved the {read,write}_var{int,long}() functions to be
  simpler and to use a different byte order.
- The {read_write}_varlong() functions also allow the caller
  to specify the minimum number of bytes to send.  This allows
  time values to be sent efficiently with a 4-byte minimum,
  while length values continue to be sent with a (more optimal
  for them) 3-byte minimum.
2007-04-20 08:16:53 +00:00
Wayne Davison
f31514adb7 Changed the *_abbbrevint() functions to *_varint(). 2007-04-20 02:17:58 +00:00
Wayne Davison
2fcc265c2f Got rid of protocol-29 check. 2007-04-18 03:30:53 +00:00
Wayne Davison
b58e40332f If ssh access is not enabled, use a shell function to test that
we can copy using a spawned rsync process.
2007-04-18 03:23:26 +00:00
Wayne Davison
a217c45359 Got rid of ACL's uid/gid iterators in favor of a single function
that converts the uids & gids in a loop.
2007-04-18 02:33:02 +00:00
Wayne Davison
764782662d Can eliminate the testtmp.* ignore rule now. 2007-04-14 07:11:32 +00:00
Wayne Davison
4b24f4a2b5 Changed scratchbase from using a "testtmp." name prefix to using a
"testtmp/" name prefix (i.e. using a subdir).  This allows me to create
a testtmp as a symlink to a different file system to assist with testing
ACLs and xattrs.
2007-04-14 07:10:52 +00:00
Wayne Davison
c64ff141b8 Improved the description of the --checksum option. 2007-04-12 02:44:41 +00:00
Wayne Davison
1b896f8d1e The check for GCC <= 2 was in the wrong part of an #ifdef sequence. 2007-04-12 02:37:31 +00:00
Wayne Davison
01894cf01f Allow a local-server copy to use -X and -A even if a --protocol-version
is forced, which makes some testing idioms easier.
2007-04-07 19:22:20 +00:00
Wayne Davison
16edf86595 The improved --xattrs option is landing on the trunk. 2007-04-07 17:22:25 +00:00
Wayne Davison
1c53e5171c Tweaked an error message and a comment. 2007-04-07 17:22:09 +00:00
Wayne Davison
63d83e9477 Improved push_dir() error reporting. 2007-03-25 17:01:48 +00:00
Wayne Davison
5463453489 The print now uses a more straight-forward map() instead of a join(). 2007-03-21 13:51:54 +00:00
Wayne Davison
108133689d Use relative directories, and note that the merge code is only
working because it is not yet using --inc-recursion.
2007-03-18 20:41:51 +00:00
Wayne Davison
46ad63b7cf Added a test of a multi-file copy from a nested directory using a
relative source path.
2007-03-18 20:40:01 +00:00
Wayne Davison
dbb20f6bc0 One more tweak. 2007-03-18 20:05:24 +00:00
Wayne Davison
25c2a6ac0e Fixed a multi-file, no-dir, relative copy, such as:
rsync -av lib/*.c /var/tmp/lib
2007-03-18 17:35:39 +00:00
Wayne Davison
161fba6903 Put the checksum seed at the end of the checksum2 buffer in md5 mode. 2007-03-18 06:28:51 +00:00
Wayne Davison
55edf18c42 Made a char* arg const. 2007-03-18 06:20:07 +00:00
Wayne Davison
a0456b9c46 Protocol 30 now uses MD5 checksums instead of MD4. 2007-03-18 06:00:53 +00:00
Wayne Davison
1a515b494b In option descriptions, the short form of --copy-dirlinks is -k, not -K. 2007-03-15 23:17:26 +00:00
Wayne Davison
33cd9ad54b I managed to duplicate the hang, so hopefully it's fixed now.
Let's restore the full test suite and find out.
2007-03-14 00:22:05 +00:00
Wayne Davison
896f046f79 Fixed more potential hang cases for incremental recursion. 2007-03-14 00:20:44 +00:00
Wayne Davison
b9d5eea5c6 Next step: allow protocol 30 to be used, but disallow the use
of incremental recursion.  If this still avoids the hanging, I
will need to try to track down how inc_recurse can deadlock.
2007-03-14 00:02:39 +00:00
Wayne Davison
5275029d11 Added an explicit option that will disallow the use of
incremental recursive mode (and an option to negate that).
2007-03-14 00:00:01 +00:00
Wayne Davison
271aeaa49e Next step: see if the hang returns with a partial restoration of
protocol 30.
2007-03-12 18:05:03 +00:00
Wayne Davison
91763a9c2f It looks like some of the compile-farm hosts are hanging on this test,
so let's try some remote-diagnostics (let's try protocol 29 first).
2007-03-12 04:56:15 +00:00
Wayne Davison
18438f0bac Changed the sending of device major/minor numbers in protocol 30 to
take fewer protocol bytes and use one less bit in the XMIT_* flags.
2007-03-12 04:33:30 +00:00
Wayne Davison
057f649fc9 When a hard-linked device is duplicating the data from the prior
device, we need to allocate 2 extra option slots for the device
numbers.
2007-03-11 22:02:26 +00:00
Wayne Davison
88467ec444 Don't enable ACLs on darwin until we figure out how they work. 2007-03-11 14:25:00 +00:00
Wayne Davison
1b897d50a9 Leave out two unneeded sys*_fd() functions due to their using
a function & struct that is not available in the rsync code.
2007-03-11 07:31:17 +00:00
Wayne Davison
d4a013edb7 We now compile on systems where ENOTSUP is not defined. 2007-03-11 07:21:07 +00:00
Wayne Davison
545584cb9a Leave SUPPORT_ACLS undefined instead of giving it a 0 value. 2007-03-11 07:13:11 +00:00
Wayne Davison
e5abce8e0d Silence a compiler warning about a printf() %d mismatch. 2007-03-11 06:50:48 +00:00
Wayne Davison
3060ca8d42 Temporarily skip this test as it is taking too long on the
compile farm at the moment.
2007-03-11 06:27:59 +00:00
Wayne Davison
ab14d01a0e Use the abbrevint30 routines in a few more places. 2007-03-11 05:59:46 +00:00
Wayne Davison
987838fd2c Make configure continue if ACL support is not found and the user
didn't explicitly ask for ACLs.
2007-03-11 05:54:21 +00:00
Wayne Davison
6d4e718f5f Moved the new static internal functions from rsync.h to io.h. 2007-03-11 05:43:55 +00:00
Wayne Davison
1c3344a105 The ACL support has arrived! This version has a brand new protocol
that makes it incompatible with all prior versions.  A patch will be
provided to allow talking with older (patched) rsync versions.
2007-03-11 00:13:34 +00:00
Wayne Davison
085e2fd588 Changed the code that cleans up the old nightly releases from
time-based to count-based (keeping the newest 10 items).
2007-03-08 02:00:48 +00:00
Wayne Davison
f41152d393 Decided that we don't really want the rule that preserves the
backup-suffix files to be perishable.
2007-03-05 17:08:00 +00:00
Wayne Davison
d0c59b0e88 A local server needs to process the auto-exclude rules since we don't
send the excludes over the socket for a local copy.
2007-03-04 14:56:22 +00:00
Wayne Davison
f49c837651 Mention the slight change to the auto-filter rules that are created
for the --backup option and the --partial-dir option.
2007-03-03 01:14:08 +00:00
Wayne Davison
c12895089c Moved a couple auto-filter rules from options.c into compat.c so
that we are sure to only apply the perishable filter modifier when
the receiving side is new enough to understand it.
2007-03-03 01:06:45 +00:00
Wayne Davison
27122338dc Make the auto-generated protect filters use the perishable flag so
that they don't stop a vanished directory from being removed.
2007-03-02 21:14:01 +00:00
Wayne Davison
d762dfe94b Mention a couple more changes. 2007-02-17 17:05:22 +00:00
Wayne Davison
c4750c2a07 Make sure that a newly-created destination directory gets the same
rules applied to it as other newly-created directories when --perms
wasn't specified.
2007-02-17 17:00:40 +00:00
Wayne Davison
3831f06319 - Moved the second send_extr_file_list() call to a better spot.
- Moved the FILECNT_LOOKAHEAD define into rsync.h.
2007-02-16 02:47:12 +00:00
Wayne Davison
be91bd81b8 Improved the incremental sending of file lists in two ways: (1)
when the sender gets an index of a file to send, we make sure to
send enough future file-list data relative to the new cur_flist
value before we send the data for the file transfer (ensuring that
the generator gets the data in a more timely manner), and (2) the
generator flushes the output socket after each file-list object
has completed its scan so that the sender knows in a more timely
manner that more list data is needed.
2007-02-16 02:35:31 +00:00
Wayne Davison
2a40b503c0 Make sure that the am_server variable is non-zero after parsing the
options we received over the socket.  (Thanks, Matt!)
2007-02-16 01:20:29 +00:00
Wayne Davison
ba2133d6ad Further modifications to the copyright comment section. 2007-02-04 14:54:58 +00:00
Wayne Davison
4f47fec04d Added a license comment to the top of the file. 2007-02-03 22:46:57 +00:00
Wayne Davison
ab3d6c6025 The "ndx" variable now holds the unique, over-the-wire value, not
a value that is relative to the cur_flist object.  This makes the
variable consistent with how the sender and the receiver use it.
2007-02-03 05:13:17 +00:00
Wayne Davison
121bfb2b4d The ndx arg passed to increment_active_files() is now the unique,
over-the-wire value, making it consistent with the ndx arg that
is passed to decrement_active_files().
2007-02-03 05:13:14 +00:00
Wayne Davison
100018b7cd Mention the year 2007 in the copyright declarations. 2007-01-31 21:46:49 +00:00
Wayne Davison
1ff66d4c68 Changed the main file-scan loop to not check for redo items when
in incremental recurse mode -- it is enough to check for them
when changing from one file-list to another.
2007-01-31 21:45:42 +00:00
Wayne Davison
87a34ce56a The code can now set cur_flist to NULL sooner than it used to, so the
flist_for_ndx() routine needs to work when cur_flist is NULL.
2007-01-30 03:57:55 +00:00
Wayne Davison
04c722d5e0 - Renamed done_cnt -> msgdone_cnt.
- Changed increment_active_files() to call check_for_finished_files()
  and to avoid calling both io_flush() and read_msg_fd() in the same
  iteration of a loop (since the former may have called the latter).
2007-01-30 03:57:52 +00:00
Wayne Davison
7730114b30 Moved the code that checks for finished file-lists, for finished "redo"
sends, and finished hard-links into check_for_finished_files(), a new
function that takes the place of check_for_finished_hlinks().  This
lets us signal the sender more rapidly when a file-list is done (which
ensures that it sends us more work to do in a timely manner), and also
avoids two potential deadlocks in the old code.
2007-01-30 03:57:48 +00:00
Wayne Davison
7a2fa0c2d3 Changed how send_extra_file_list() checks if we have enough future work. 2007-01-30 03:57:45 +00:00
Wayne Davison
4eeaa16253 Improved a sentence. 2007-01-30 03:37:47 +00:00
Wayne Davison
8dca155fca Some improvements from Matt. 2007-01-28 06:39:52 +00:00
Wayne Davison
2a5df86299 - Fixed a potential hang bug in wait_for_receiver() that could occur
if the io_flush() call happened to read the last message from the
  receiver, causing the read_msg_fd() call to deadlock.
- Fixed an error-looping problem when the server-side receiver failed
  to send a message down the error-msg pipe:  we no longer try to send
  a new error about this new failure down the same failing pipe.
- Make sure that we stop any deferring of forwarded messages in the
  generator when we are exiting with an error.
2007-01-27 16:30:33 +00:00
Wayne Davison
3ea6e0e7a1 Changed the variable "incremental" to "inc_recurse". 2007-01-27 14:56:09 +00:00
Wayne Davison
051ad69634 Improved the talk of --hard-link improvements. 2007-01-27 14:53:10 +00:00
Wayne Davison
744e63fb2a More extern tweaking. 2007-01-27 14:37:53 +00:00
Wayne Davison
cc7b86bf9b The last MSG_DONE from the receiver to the generator is now followed
by the stats.total_read value so that the generator can set its value
to that of the receiver.  This makes log_exit() log the right value
when we're on the server side.
2007-01-27 14:34:15 +00:00
Wayne Davison
8c18ebe81d Got rid of unused externs. 2007-01-27 14:26:19 +00:00
Wayne Davison
33689f4803 Added an extra paragraph to the --link-dest option to make it more
explicit that it is best used with an empty destination hierarchy.
2007-01-23 15:34:43 +00:00
Wayne Davison
424d369179 Paul's patch to silence some 64-bit compiler warnings. 2007-01-23 15:24:36 +00:00
Wayne Davison
d0221f1d2b Fixed handling of "redo" items in protocol 30. 2007-01-21 14:51:52 +00:00
Wayne Davison
3be97bf931 - Make sure that we can't write via io_flush() when msg_fd_in is
temporarily set to -1.
- Got rid of the msg2genr message cache.
2007-01-20 22:10:14 +00:00
Wayne Davison
4afab31607 We need to call msg2sndr_flush() in read_msg_fd() now. 2007-01-20 20:19:24 +00:00
Wayne Davison
be21e29c35 Make sure defer_forwarding_messages is set when msg_fd_in gets
set to -1.
2007-01-20 19:56:03 +00:00
Wayne Davison
c5b6e57a13 Fixed some typos Matt found. 2007-01-20 08:42:53 +00:00
Wayne Davison
ca947dea3e Moved the code that adds each file's length to stats.total_size
so that the delete code doesn't change the value.
2007-01-10 01:49:35 +00:00
Wayne Davison
2aea85ab54 Removed a couple items (one complete, one that we don't need). 2007-01-09 20:03:34 +00:00
Wayne Davison
05a41409b1 Mention that --prune-empty-dirs forces a non-incremental recursive scan. 2006-12-29 14:17:26 +00:00
Wayne Davison
7a28d18448 If prune_empty_dirs is set, don't set incremental. 2006-12-29 14:17:21 +00:00
Wayne Davison
1e05b590c4 Fixed a typo and improved a sentence. 2006-12-29 01:22:51 +00:00
Wayne Davison
ce5fddc3ed Added a sleep so that the --delete-delay action will always tweak
the directory time, and reveal any lack of dir-time touch-up.
2006-12-29 00:56:25 +00:00
Wayne Davison
fd3f5af2aa - Put directory retouching code into a separate function that
is now called for all our touch-up needs.
- Fixed a problem with --delete-delay interfering with the
  directory-time touch-up in incremental mode.
2006-12-29 00:55:28 +00:00
Wayne Davison
dde5b77226 - My use of readfd_unbuffered() in read_msg_fd() really needed to be
readfd() so that the buffer is never partially filled.
- Make sure that msg2genr_flush() does not flush any messages while
  the flist-forwarding is active.
- Changed io_flush() to honor its flush_it_all arg again.
2006-12-29 00:12:42 +00:00
Wayne Davison
f845ef7dec An incremental-recursion transfer can't switch from delete-delay to
delete-after.
2006-12-28 19:02:01 +00:00
Wayne Davison
9ae7a2cddb Use write_ndx() and read_ndx(). 2006-12-28 18:49:13 +00:00
Wayne Davison
8a65e0ce00 Added write_ndx() and read_ndx(), functions that allow us to transmit
fewer bytes when exchanging the file-list index values.
2006-12-28 18:49:08 +00:00
Wayne Davison
98b1689dcb Output a file-list message when verbose and using incremental recursion
mode.
2006-12-28 18:43:20 +00:00
Wayne Davison
012d1a01f5 Mention incremental recursion and change to --delete. 2006-12-28 16:40:24 +00:00
Wayne Davison
d9f46544a3 Document the incremental recursion algorithm and the change in the
--delete default.
2006-12-28 16:37:01 +00:00
Wayne Davison
42c6b13901 Restored the calling of send_file_entry() back to send_file_name()
(since the reason I had separated it no longer exists).
2006-12-28 15:43:30 +00:00
Wayne Davison
f1482c3391 Assign the owner and group using F_OWNER() and F_GROUP(). 2006-12-28 09:42:48 +00:00
Wayne Davison
5bb7348509 - Define F_OWNER() and F_GROUP() to be used for assigning the UID and GID.
- F_UID() is now defined to return a uid_t value.
- F_GID() is now defined to return a gid_t value.
2006-12-28 09:42:44 +00:00
Wayne Davison
4c9d5fef07 Repositioned a misplaced assignment. 2006-12-28 08:57:25 +00:00
Wayne Davison
5607803376 - Added a sleep to make sure that the preservation of the mtime on
implied directories is working.
2006-12-28 07:54:47 +00:00
Wayne Davison
76e0a49efe Handle slight differences in the output of protocol 30's incremental mode. 2006-12-28 07:54:44 +00:00
Wayne Davison
76a1013cc6 Use --delete-delay instead of --delete-after. 2006-12-28 07:54:41 +00:00
Wayne Davison
496c809f8c - Made match_uid(), match_gid(), recv_user_name(), and recv_group_name()
public functions.
- Made add_uid() and add_gid() return the name or NULL.
2006-12-28 07:54:37 +00:00
Wayne Davison
3ac830b9f9 A few minor tweaks to handle the newest variable names. 2006-12-28 07:54:34 +00:00
Wayne Davison
f3d6d4800b Handle the new incremental-recursion mode. 2006-12-28 07:54:31 +00:00
Wayne Davison
8ef246e0b5 - Handle the new incremental-recursion mode.
- Changed some function names to make them more consistent.
2006-12-28 07:54:27 +00:00
Wayne Davison
c7e6f84f89 New functions, variables, and file-list code to support the new
incremental-recursion mode.
2006-12-28 07:54:23 +00:00
Wayne Davison
fe04532ad2 New support function: change_local_filter_dir(). 2006-12-28 07:54:19 +00:00
Wayne Davison
e4b619b46d - Choose --delete-before or --delete-during depending on protocol version.
- Set incremental-recursion mode, if possible.
- Protocol 30 gets generator->sender messages enabled.
2006-12-28 07:54:16 +00:00
Wayne Davison
9ec3828b03 Some new defines for incremental-recursion mode. 2006-12-28 07:54:13 +00:00
Wayne Davison
e0e3203156 - Changes to handle new default of --delete-during for --delete.
- Allow -H to be repeated.
2006-12-28 07:54:10 +00:00
Wayne Davison
edb977215b Only append_mode > 0 now indicates option is enabled. 2006-12-28 07:54:07 +00:00
Wayne Davison
18233a170e Only sparse_files > 0 now indicates option is enabled. 2006-12-28 07:54:04 +00:00
Wayne Davison
283887d777 Neaten up use of uid_t/gid_t variable types. 2006-12-28 07:08:13 +00:00
Wayne Davison
c2f0e4d965 Don't include MATCHFLG_PERISHABLE in CVS-exclude handling unless
we're talking protocol 30 or above.
2006-12-28 06:27:22 +00:00
Wayne Davison
8576397c3e Fix the building of mkrounding$(EXEEXT) when building outside the
source directory (provided by Art Haas).
2006-12-27 21:40:16 +00:00
Wayne Davison
c09af06d0c Made the int_byte_cnt[] array 75% smaller. 2006-12-27 17:43:51 +00:00
Wayne Davison
ded73ed90f Ignore all conftest* items, as Matt suggested. 2006-12-27 17:36:57 +00:00
Wayne Davison
f335eb1f83 Fix usage message. 2006-12-26 05:56:38 +00:00
Wayne Davison
7afa34fd27 Test --only-write-batch option. 2006-12-26 05:29:05 +00:00
Wayne Davison
1f56188f8c Can just test ignore_errors w/o lp_ignore_errors(module_id) now. 2006-12-25 17:49:23 +00:00
Wayne Davison
3162ea6f67 Set ignore_errors variable based on lp_ignore_errors(module_id). 2006-12-25 17:49:19 +00:00
Wayne Davison
327c559aff Improved the new --pasword-file error message. 2006-12-24 06:13:08 +00:00
Wayne Davison
99effefc81 Fixed a thinko in the last news item. 2006-12-24 05:47:21 +00:00
Wayne Davison
e8dad39518 Mention checking of --password-file's use. 2006-12-24 01:30:44 +00:00
Wayne Davison
09a54c399c Make the --password-file option's summary even better. 2006-12-24 01:30:24 +00:00
Wayne Davison
9586e59370 Improved the docs for the --password-file option. 2006-12-24 00:58:30 +00:00
Wayne Davison
ce455b03e7 Improved the summary of the --password-file option. 2006-12-24 00:58:24 +00:00
Wayne Davison
a39da29ac5 If the user specified --password-file without using daemon mode,
complain and die.
2006-12-24 00:58:21 +00:00
Wayne Davison
794a0b6c25 Make use of the SHORT_SUM_LENGTH define. 2006-12-23 23:57:16 +00:00
Wayne Davison
1b81f797a2 Fixed a problem with the output of %f for non-daemon rsyncs. 2006-12-23 20:48:29 +00:00
Wayne Davison
889ae39d7a Mention the %f fix. 2006-12-23 20:46:33 +00:00
Wayne Davison
5f4e991c70 Fixed the item numbers in the regex comment. 2006-12-20 00:50:17 +00:00
Wayne Davison
c96f6eb584 Call SIGACTION() instead of signal(). 2006-12-18 07:24:24 +00:00
Wayne Davison
e10664c5e8 Moved the write_stream_flags() call from io.c into main.c so that
it gets called before the transfer starts (thus ensuring that it
can write out un-tweaked values of preserver_[ug]id vars).
2006-12-18 06:56:30 +00:00
Wayne Davison
99a957d3f4 Renamed flist_extra_cnt to file_extra_cnt. 2006-12-18 06:56:26 +00:00
Wayne Davison
658a63694b Got rid of the "tweaked" versions of the uid and gid vars. 2006-12-18 06:56:23 +00:00
Wayne Davison
30e50494bb Tweaked the output a little. 2006-12-18 06:41:00 +00:00
Wayne Davison
719985cb9c A few more minor tweaks. 2006-12-17 04:42:33 +00:00
Wayne Davison
2d2414f39e - We now define int16 and uint16.
- Make use of the [u]int{16,32,64}_t types, if they're around.
2006-12-17 02:05:11 +00:00
Wayne Davison
edb4ba5fdb We now check for these: int16_t, uint16_t, int32_t, uint32_t, and int64_t. 2006-12-17 01:59:03 +00:00
Wayne Davison
007996b40d Got rid of the code that sorted based on struct idev objects since
we always use a hardlinked group-number now.
2006-12-17 00:40:39 +00:00
Wayne Davison
dbd9ea3e5a Use F_ROOTDIR() in place of dir.root. 2006-12-17 00:40:36 +00:00
Wayne Davison
2ef0340517 Use F_DEPTH() in place of dir.depth. 2006-12-17 00:40:33 +00:00
Wayne Davison
9d737ecb7a Got rid of the hlink_pool in favor of using the new hashtable code
on the receiving side.  This allows us to always use a 32-bit number
to identify the hardlink clusters, even on a system where pointers
are 64-bits.  Also made changes to handle the use of F_ROOTDIR() and
F_DEPTH() instead of the old union that wasted space on the
receiving side when pointers are 64-bits.
2006-12-17 00:40:28 +00:00
Wayne Davison
bd6edd3fa2 - Got rid of "struct idev".
- Use just the 32-bit numbers in the file_extras union.
- Re-ordered the items in the file_struct to avoid padding
  on systems with 64-bit pointers.
- Got rid of the "dir" union in the file_struct, making the
  two items into "extras": F_DEPTH() for the receiving side,
  and F_ROOTDIR() for the sending side.
- Added PTR_EXTRA_LEN define.
- Got rid of F_HL_IDEV() define.
2006-12-17 00:40:24 +00:00
Wayne Davison
6eee13cf58 Moved the flist_extra_cnt stuff from options.c to compat.c so that
the values will be computed separately for the sender and the
receiver.
2006-12-17 00:40:21 +00:00
Wayne Davison
9602b5cfbd - Ensure that mkrouding gets rebuilt when rsync.h changes.
- Added an easy way to run the tests using protocol 29.
2006-12-17 00:40:18 +00:00
Wayne Davison
48ffc11e9c Make the error messages a little clearer. 2006-12-16 23:14:59 +00:00
Wayne Davison
5a3e9ff608 Output some info about the size of our structures. 2006-12-16 21:11:58 +00:00
Wayne Davison
aac5cab80b Changed the static file_struct var to match the changes in rsync.h. 2006-12-16 19:24:17 +00:00
Wayne Davison
a3e18c763a Use the new rounding.h file to optionally round up the count of
extra values we put at the start of the file_struct.  Also, deal
with the extras variable no longer being in the file_struct.
2006-12-16 19:24:14 +00:00
Wayne Davison
403dbc1377 Build & run mkrounding to make the rounding.h file used by flist.c.
Also, clean up the new items.
2006-12-16 19:24:11 +00:00
Wayne Davison
5b30412c68 Moved the file_extra union out of the file_struct. 2006-12-16 19:24:08 +00:00
Wayne Davison
d5833800a8 New file to figure out if a system has any rounding needs when
prepending extra values at the start of the file_struct.
2006-12-16 19:24:05 +00:00
Wayne Davison
8d3a785fa5 Added mkrounding and rounding.h. 2006-12-16 19:24:02 +00:00
Wayne Davison
3a5a7de6c9 Mention hard-link memory savings and byte-transfer savings. 2006-12-16 07:39:53 +00:00
Wayne Davison
c58c1dc446 Added a basename var to file_struct at the end, making it clearer
where the basename exists without actually changing how the data
is organized.
2006-12-16 07:18:41 +00:00
Wayne Davison
eefe189e1d Changed the test for the 2.6.8 bug to preserve owner and group. 2006-12-16 02:18:44 +00:00
Wayne Davison
f05c801194 Moved the calls to init_hard_links() into flist.c. 2006-12-15 22:31:16 +00:00
Wayne Davison
c905bf37f6 Added a simple hashtable routine for hashing st_dev and st_ino info
on the sending side, and the support routines for the receiving side
that handle using a "group number" for each hard-link cluster rather
than having to manage a pool of dev+inode data. (For protocol 30)
2006-12-15 22:31:13 +00:00
Wayne Davison
8cae71ebc3 For protocol 30, the sender uses the new idev_node() hashfile
routine to keep track of which item is the first one in a particular
hard-link cluster.  It then abbreviates the sending of any follow-on
items in the cluster, reducing transfer bytes.  It also omits the
sending of any dev+inode data to the receiver, saving even more xfer
bytes (since the receiver can associate the entries based on the the
group's index number that is sent when abbreviating an entry).
2006-12-15 22:31:10 +00:00
Wayne Davison
14d776ff0c - The XMIT_SAME_DEV define is now pre-protocol-30 specific.
- Added XMIT_HLINK_FIRST define.
- Added struct idev_node.
- Added F_HL_GNUM() for protocol 30 (used in place of F_HL_IDEV()).
2006-12-15 22:31:07 +00:00
Wayne Davison
c7565dad84 Renamed XMIT_HAS_IDEV_DATA to XMIT_HLINKED. 2006-12-14 22:38:21 +00:00
Wayne Davison
b7cfb9e2c0 Renamed the F_*HLINK* macros to make their purpose clearer. 2006-12-13 15:36:15 +00:00
Wayne Davison
0d152437df Tweaked the option-passing code's delete logic to make it cleaner. 2006-12-13 14:52:59 +00:00
Wayne Davison
6aef83c97d Cast FILE_STRUCT_LEN & EXTRA_LEN to int for rprintf(). 2006-12-12 20:42:06 +00:00
Wayne Davison
225aeca346 Use new BITS_EQUAL() define. 2006-12-12 20:17:05 +00:00
Wayne Davison
0a62f5f382 Added BITS_EQUAL() define. 2006-12-12 20:17:02 +00:00
Wayne Davison
234844915e Removed last reference to "struct hlist". 2006-12-12 15:01:57 +00:00
Wayne Davison
263d3bfb40 Neaten some function formatting. 2006-12-12 14:58:10 +00:00
Wayne Davison
bf466c0f82 Provide alternate F_LENGTH() define for systems with no 64-bit type. 2006-12-12 14:55:21 +00:00
Wayne Davison
8b58407586 Mention fix for -vv --stats. 2006-12-10 21:56:37 +00:00
Wayne Davison
64119c792d Added MSG_CLIENT to the acceptable messages the generator can
get from the receiver.
2006-12-10 14:55:44 +00:00
Wayne Davison
8388e011ae Added MSG_CLIENT to the msgcode enum. 2006-12-10 14:54:08 +00:00
Wayne Davison
0fddbd8a09 A minor format tweak. 2006-12-09 17:35:36 +00:00
Wayne Davison
badb8c24b9 Handle the new output from the hard-link code, including a fix
for a long-standing bug combinding -H with --compare-dest.
2006-12-09 00:24:11 +00:00
Wayne Davison
bfd3137246 - Added FLAG_HLINK_DONE.
- Added BITS_SET() and BITS_SETnUNSET() defines.
- Got rid of unused HL_* defines.
- Got rid of no-longer-needed struct hlist.
- Changed F_HL_LIST() to F_HL_PREV().
- Added F_NOT_HLINK_FIRST() and F_NOT_HLINK_LAST().
- Got rid of WITH_HLINK and WITHOUT_HLINK.
- Got rid of the hlink_pool in the file list.
2006-12-09 00:24:08 +00:00
Wayne Davison
6de0d06259 Got rid of the pool-destroy call since this is not around anymore. 2006-12-09 00:24:05 +00:00
Wayne Davison
89d730a098 Call the new hard-link init functions. 2006-12-09 00:24:01 +00:00
Wayne Davison
18979194cf - Use the revamped hard-link functions.
- Turned maybe_ATTRS_REPORT var into a global for use by hlink.c.
2006-12-09 00:23:58 +00:00
Wayne Davison
aadc84d359 - Revamped the hard-link algorithm to save memory.
- Improved the function names.
- Improved a few variable names.
- Got rid of the "is a hard link" message in favor of the normal status
  messages for files (e.g. --itemize-changes indicates hard-links).
- Fixed a long-standing bug when combining -H with --compare-dest.
- Made sure that code compiles when hard-linking is not available.
2006-12-09 00:23:55 +00:00
Wayne Davison
9d155ecd12 Changed the hlink_pool variable to be a global since only the main
file list ever has a pool for hard-linking.
2006-12-09 00:23:51 +00:00
Wayne Davison
60af946576 Explicitly cast the length values down to an uint32 so that some
compilers don't complain about the value getting smaller.
2006-12-08 21:02:11 +00:00
Wayne Davison
ca0e8296bc Get rid of some signed/unsigned-comparison compiler warnings. 2006-12-08 20:58:51 +00:00
Wayne Davison
c4a28da3ad Use --delete-delay instead of --delete-after. 2006-12-08 20:47:09 +00:00
Wayne Davison
20319fd9ed - The --delete-delay code now does its own output buffering. This
allows us to delay opening a temp file to hold the list of deletions
  until we overflow the buffer (and thus, it's not usually needed).
- Fall back to doing a --delete-after pass if the --delete-delay
  code has a temp-file-writing failure.
2006-12-08 20:42:45 +00:00
Wayne Davison
01d29d7b02 Fixed --delete-delay by making the fprintf() output an unsigned short
for the mode.
2006-12-08 15:10:12 +00:00
Wayne Davison
1183260426 Added missing initialization of new solo_file variable. 2006-12-07 06:22:22 +00:00
Wayne Davison
07613def0a Some minor format tweaks. 2006-12-07 03:31:44 +00:00
Wayne Davison
c2a608d9f1 - Use renamed hard-link defines: F_HL_IDEV() and F_HL_LIST(). 2006-12-07 03:31:41 +00:00
Wayne Davison
49b86442ff - Set "solo_file" bool and use that for improved clarity.
- Use the new device defines: F_RDEV_P(), DEV_MAJOR(), and DEV_MINOR().
2006-12-07 03:31:38 +00:00
Wayne Davison
4785cd43d1 - Use the new device defines: F_RDEV_P(), DEV_MAJOR(), and DEV_MINOR().
- Use renamed F_HL_IDEV() define.
2006-12-07 03:31:34 +00:00
Wayne Davison
e238c9977d Use the new device defines: F_RDEV_P(), DEV_MAJOR(), and DEV_MINOR(). 2006-12-07 03:31:31 +00:00
Wayne Davison
b37b7c9949 - Added a signed number to the flist_extras union.
- Renamed F_IDEV() to F_HL_IDEV() and F_HLIST() to F_HL_LIST().
- Changed device defines to be: F_RDEV_P(), DEV_MAJOR(), and DEV_MINOR().
2006-12-07 03:31:28 +00:00
Wayne Davison
f7d7fb381d Improved the format of the debug output for mknod(). 2006-12-07 02:37:42 +00:00
Wayne Davison
3481bdf493 Mention waitpid() fix (which helps pre-xfer exec). 2006-12-06 17:27:47 +00:00
Wayne Davison
d365e22967 The wait_process() call now handles EINTR. 2006-12-06 17:21:59 +00:00
Wayne Davison
d02363609a If the pre-xfer exec failed with -1, output the strerror()
from the waitpid() call.
2006-12-06 16:56:19 +00:00
Wayne Davison
1e1ca25343 #ifdef calls to hard-link functions. 2006-12-06 01:32:17 +00:00
Wayne Davison
a2ebbffca7 - Make some char* pointers const.
- Tweaked a couple variable names.
- Changed the #ifdefs to not define any hard-link functions
  when hard-linking is disabled.
2006-12-06 01:26:11 +00:00
Wayne Davison
0395130c06 Changed i -> ndx in several variables. 2006-12-06 00:55:33 +00:00
Wayne Davison
b8c167e804 F_SUM() needed to use HLINK_BUMP(). 2006-12-06 00:52:34 +00:00
Wayne Davison
17026f2741 Handle the FLAG_LENGTH64 flag in unmake_file(). 2006-12-05 17:45:29 +00:00
Wayne Davison
112d728f48 Use the latest F_*() accessors. 2006-12-05 15:59:58 +00:00
Wayne Davison
96293cf991 Saved 9 more bytes per file in a typical transfer by making the length
32 bits by default, by removing the basename pointer, and by making the
mode value a unsigned short.
2006-12-05 15:59:53 +00:00
Wayne Davison
f0fbf1d670 Changed flist_extra_ndx into flist_extra_cnt. 2006-12-05 15:59:49 +00:00
Wayne Davison
7a821d518b Tweaked some externs. 2006-12-05 15:59:46 +00:00
Wayne Davison
663b2857eb Use new send_msg_int() function. 2006-12-04 02:07:37 +00:00
Wayne Davison
155d9206a4 Added send_msg_int() function. 2006-12-04 02:07:30 +00:00
Wayne Davison
6b2a3d5de6 Moved an extern. 2006-12-03 07:58:12 +00:00
Wayne Davison
82ad07c418 - Typical tranfers now save 12-20 bytes per file because several vars
were moved out of file_struct into an optional member-var setup.
- Renamed and reorganized the FLAG_* defines.
- Use NDX_DONE instead of a literal -1 when sending/checking the
  end-of-phase index value.
2006-12-03 06:44:16 +00:00
Wayne Davison
d144e43bb3 Restored write_ndx_and_attrs() and made it public. 2006-12-02 16:17:11 +00:00
Wayne Davison
d2aee174e6 Moved write_ndx_and_attrs() to sender.c and made it public. 2006-12-02 16:16:54 +00:00
Wayne Davison
20f0d0f9b9 Moved write_ndx_and_attrs() too. 2006-12-02 16:13:02 +00:00
Wayne Davison
b675ba6f79 Added a couple externs. 2006-12-02 16:11:33 +00:00
Wayne Davison
d1c178dd53 Moved read_item_attrs() from sender.c to rsync.c since the function
is used by both the sender and the receiver.
2006-12-02 16:08:59 +00:00
Wayne Davison
d619ff1376 Change the format/order of the capabilities --version outputs. 2006-12-01 18:29:18 +00:00
Wayne Davison
db0f7613e1 Got rid of an incorrect comment. 2006-11-28 19:34:01 +00:00
Wayne Davison
45d8bfe09e Added some more "const" prefixes to some "char *" vars. 2006-11-28 19:31:41 +00:00
Wayne Davison
d521e1c2a1 - Use write_shortint() to send the 2 bytes in an extended flag.
- Improved a comment.
2006-11-24 20:21:13 +00:00
Wayne Davison
4ea4acf17b - Added checking of SIZEOF_INT64 to the new code in read_longint().
- Improved the SIZEOF_INT64 checking code in write_longint().
2006-11-24 18:35:00 +00:00
Wayne Davison
3a993aa4bf - Changed {read,write}_shortint() to use unsigned short.
- Added explicit char-casting to new long-int code.
2006-11-24 17:28:57 +00:00
Wayne Davison
c7871d9892 Document the latest changes. 2006-11-24 08:46:21 +00:00
Wayne Davison
482f48cca9 - Fixed a bug when sending a negative 64-bit number (which may not
be needed, but it at least works right now).
- Improved the transmission of 32-bit negative numbers on systems
  where the 32-bit type is larger than 32 bits.
- Changed the sending of 64-bit numbers for protocol 30:  we send
  them in MSB-first order with the number of bytes used in the
  transmission encoded into the earliest bits.  This lets us save
  transmitted bytes for both small and large numbers.  The new
  method sends from 3 to 9 bytes, the old sent either 4 or 12.
2006-11-24 08:38:44 +00:00
Wayne Davison
36e6594dce Added some defines for sending variable-sized MSB-first numbers. 2006-11-24 08:22:23 +00:00
Wayne Davison
e17883827b Silenced a compiler warning. 2006-11-23 04:16:48 +00:00
Wayne Davison
37a4386d2c Fix a unused-variable compiler warning. 2006-11-23 03:28:58 +00:00
Wayne Davison
fd0a130c14 Document the new --delete-delay option. 2006-11-22 20:52:51 +00:00
Wayne Davison
5e77efaf41 - Implement new --delete-delay option.
- Tweaked a variable name in delete_item().
2006-11-22 20:51:03 +00:00
Wayne Davison
b0cacef14b Added parsing for --delete-delay. 2006-11-22 20:49:23 +00:00
Wayne Davison
b20830b338 Made get_tmpname() non-static. 2006-11-22 20:48:04 +00:00
Wayne Davison
c63625d41a Switch over to testing --remove-source-files, not *-sent-*. 2006-11-22 16:34:25 +00:00
Wayne Davison
7de7b49f6c Don't define NORETURN for older gcc versions. 2006-11-21 22:29:33 +00:00
Wayne Davison
d0d0e41fd2 Mention latest changes. 2006-11-21 19:08:59 +00:00
Wayne Davison
2a28dd32fd The exclude code wasn't sending the MATCHFLG_NEGATE (!) char to the
other side.
2006-11-21 17:46:54 +00:00
Wayne Davison
65e83e097c Don't set an "rc" var that we aren't going to use. 2006-11-21 08:37:28 +00:00
Wayne Davison
4f37559232 Avoid a compiler warning about setting "len" without using it. 2006-11-21 08:37:06 +00:00
Wayne Davison
604dbf6d94 Make the file_list stats value an int64. 2006-11-21 08:36:48 +00:00
Wayne Davison
53593085cf - Use an explicit cast when a value gets stored in a smaller var.
- The msgtype var should have been an enum.
2006-11-21 08:36:31 +00:00
Wayne Davison
eb0144d79b Output the size of the file list using human_num(). 2006-11-21 08:36:15 +00:00
Wayne Davison
54b0dfa0f7 Explicitly cast the tag value in read_msg_fd() to an enum. 2006-11-21 08:36:06 +00:00
Wayne Davison
264042760b Use an explicit cast when a value gets stored in a smaller var. 2006-11-21 08:35:58 +00:00
Wayne Davison
1e999f9f1b The call to do_chmod() needed to be conditional. 2006-11-21 08:35:22 +00:00
Wayne Davison
f9b66bc464 Fixed a problem with the new iconv const check. 2006-11-20 19:12:35 +00:00
Wayne Davison
60d465dbdd Use the new ICONV_CONST definition. 2006-11-20 18:17:48 +00:00
Wayne Davison
3ebdd3c7fc Added a test to figure out if iconv() takes a const char **. 2006-11-20 18:17:17 +00:00
Wayne Davison
f0fa8c6df2 Moved the options_rejected label to avoid a compiler warning on
some systems.
2006-11-19 04:39:35 +00:00
Wayne Davison
9d33e6f7cf Use rwrite() to output the err_msg string. 2006-11-19 04:37:52 +00:00
Wayne Davison
4a19c3b254 Added "const" to appropriate char pointers. 2006-11-19 00:23:21 +00:00
Wayne Davison
4743f0f41b Some bf(...) tweaks. 2006-11-14 07:56:05 +00:00
Wayne Davison
0abe148fd9 - Use double quotes for a quoted string.
- Some bf(...) tweaks.
2006-11-14 07:55:47 +00:00
Wayne Davison
39411fa876 Added: also tweak single-/double-quotes and em-dashes. 2006-11-14 07:54:26 +00:00
Wayne Davison
662fd70b54 Changed name of tweak_manpage script. 2006-11-14 07:48:56 +00:00
Wayne Davison
cd87e2f59a Turned the char * vars flist_dir and lastdir into const char * vars. 2006-11-13 00:27:10 +00:00
Wayne Davison
2c70847654 Turned the char * args to push_dir() and pop_dir() into const char *. 2006-11-13 00:27:04 +00:00
Wayne Davison
eaf895e6ef Turned the char *dir.root var in struct file_struct into a const char *. 2006-11-13 00:27:00 +00:00
Wayne Davison
149a78e33f Ignore a time-setting error on a symlink (which is only attempted
on a system with lutimes() anyway).
2006-11-12 21:18:26 +00:00
Wayne Davison
88897638a9 Tweaked a couple comments. 2006-11-11 17:09:32 +00:00
Wayne Davison
c575f8ce87 Document the new p (perishable) filter modifier. 2006-11-11 17:01:58 +00:00
Wayne Davison
5303941021 If ignore_perishable is set, increment a count of all excluded
items found by make_file().
2006-11-11 16:44:22 +00:00
Wayne Davison
c0f1e57b51 Added the MATCHFLAG_PERISHABLE flag. 2006-11-11 16:43:13 +00:00
Wayne Davison
ccdb23bb90 - Added the 'p' (perishable) flag to the filter rules, as suggested
by Matt.
- If ignore_perishable is set, we ignore all perishable rules.
- Mark all default-cvsignore rules as perishable (e.g. excludes such
  as *.o CVS .svn/ will not prevent a directory from being deleted).
2006-11-11 16:39:57 +00:00
Wayne Davison
146c2c368c - Restored some of Matt's suggested logic that I left out, as it
is needed to get --dry-run to output appropriately.
- Got rid of DR_PINNED from the enum delret.
- Set a flag when we're deleting outside the transfer hierarchy and
  initialize a counter that flist.c will use to count excluded files.
2006-11-11 16:39:02 +00:00
Wayne Davison
60cc01a6c6 When make_file() gets a stat() error on a file, the check-for-
exclusion-before-reporting-an-error code allows a dir-specific
rule to match the unknown file, not just a non-dir rule.
2006-11-11 15:34:31 +00:00
Wayne Davison
f5761a342b - Make delete_dir_contents() use less stack by recursing directly
to itself, and then calling delete_item() w/o DEL_RECURSE.
- Fixed the return value handling of delete_dir_contents().
2006-11-11 14:45:00 +00:00
Wayne Davison
caf8299e2e Tweaked an exit_cleanup() value. 2006-11-11 08:01:40 +00:00
Wayne Davison
c6fadc0ee1 My adaptation of Matt's cleanup of the delete_item() code.
The new code splits out part of the directory deletion into
its own function, delete_dir_contents(), and it outputs more
warnings when something could not be deleted.
2006-11-11 07:03:57 +00:00
Wayne Davison
2dc3db2a3e Docment that --max-delete=0 now works. 2006-11-11 05:09:22 +00:00
Wayne Davison
771d0add8f Die if we sent --max-delete=0 to a receiving side that is too old. 2006-11-11 05:09:17 +00:00
Wayne Davison
e5e85283a9 Allow --max-delete=0 (zero used to be ignored). 2006-11-11 05:09:14 +00:00
Wayne Davison
21068d8e87 Increased the PROTOCOL_VERSION to 30. 2006-11-11 05:09:10 +00:00
Wayne Davison
4d2ea5a838 Mention another internal change. 2006-11-10 15:39:03 +00:00
Wayne Davison
9ba53f26a3 Test --del too. 2006-11-10 15:36:15 +00:00
Wayne Davison
3aeedbfd11 Fixed the hard-linking of symlinks test (we need to use a symlink
to a non-existent file for the test to work right).
2006-11-10 07:49:02 +00:00
Wayne Davison
989b0b8802 Changed how we deal with the alternate-dest directory because
some systems change the time on a directory that gets moved.
2006-11-10 07:37:51 +00:00
Wayne Davison
b2e4811db2 Changed two more references to "st" to "real_st" in the dir-handling
code.
2006-11-10 07:17:20 +00:00
Wayne Davison
b467495cd0 - Fixed a problem where the real stat struct for a newly-created
root-of-transfer directory could get overwritten by the check
  for basis dirs.
- Fixed a potential problem where the stat struct for a new dir
  could get passed uninitialized to delete_in_dir().
2006-11-10 07:13:21 +00:00
Wayne Davison
3b8ed84245 If the OS can't hard-link a symlink, tweak the expected output
when using --link-dest.
2006-11-10 06:27:35 +00:00
Wayne Davison
3a72cc2929 Mention latest bug fixes. 2006-11-10 05:07:08 +00:00
Wayne Davison
c202424a03 Changed to reflect new (more correct) output of what updating is
happening.
2006-11-10 05:07:05 +00:00
Wayne Davison
083f75ee42 Improved to test --link-dest (when hard-linking of devices works). 2006-11-10 05:07:02 +00:00
Wayne Davison
45760f5f05 Allow all itemize types to change all-dots (no changes) into spaces. 2006-11-10 05:06:59 +00:00
Wayne Davison
116a4769c1 - Improved try_dests_non() so that it works with all non-regular
files (including dirs).
- Changed the directory-creating code to call try_dests_non() when a
  --*-dest option is used.
- Revamped the device/special-files code to have the same logic as
  the symlink code, making it both simpler and more correct.
- All the above makes us output changes for all items consistently
  when a --*-dest option is used.
- Fixed an output bug in try_dests_reg() and try_dests_non() when
  -ii is enabled (we use to fail to output unchanged files).
2006-11-10 05:06:56 +00:00
Wayne Davison
1e4f5f6342 Added flag ITEM_MATCHED. 2006-11-10 05:06:53 +00:00
Wayne Davison
a19d285ae3 Changed strcat() calls to strlcat(). 2006-11-10 03:34:51 +00:00
Wayne Davison
564782ba95 Disable POPT_WCHAR_HACK for now. 2006-11-09 02:55:32 +00:00
Wayne Davison
2dc7b8bd0e Got rid of type-casting into isFOO() and toFOO() functions by
using static inline functions that take a signed char pointer.
2006-11-09 02:39:29 +00:00
Wayne Davison
e0930845ce Improved the vmefail() code. 2006-11-09 02:37:38 +00:00
Wayne Davison
cf81788366 Fixed a problem with the xstrdup() change. 2006-11-09 02:36:03 +00:00
Wayne Davison
89a0e3a927 Get rid of the last strcpy() call by using an static inline function. 2006-11-09 02:34:17 +00:00
Wayne Davison
a8facdc090 Use a new isSpace() inline function to call isspace() safely
when using a signed character pointer.
2006-11-09 02:14:38 +00:00
Wayne Davison
c5e29261f3 Need to include lib/snprintf.o when building wildtest. 2006-11-09 01:58:28 +00:00
Wayne Davison
1acb2e15b4 Changed _ABS to be defined as MY_ABS. 2006-11-09 01:55:17 +00:00
Wayne Davison
06898c80d9 Got rid of code to twiddle _ABS. 2006-11-09 01:54:59 +00:00
Wayne Davison
684576ff45 Moved definition of DBL_EPSILON. 2006-11-09 01:51:57 +00:00
Wayne Davison
574a24a2ec Try a full prototype for alloca() for those systems that need it. 2006-11-09 01:34:36 +00:00
Wayne Davison
9775d6ab66 - Define snprintf() when needed.
- Improved the compatibility of the standard includes.
2006-11-09 01:26:27 +00:00
Wayne Davison
2b916250d8 The Mac version of GCC can now handle __attribute__ . 2006-11-09 01:07:35 +00:00
Wayne Davison
2955529bb4 Rolling over the NEWS file for the next version. 2006-11-09 01:06:30 +00:00
Wayne Davison
d094b5eb3c Change the version for new CVS work. 2006-11-09 00:59:58 +00:00
Wayne Davison
bc93ee842f - Upgraded popt to version 1.10.2.
- Modified all sprintf() and strcpy() calls to use snprintf()
  and strlcpy().
2006-11-09 00:57:55 +00:00
Wayne Davison
0c6d79528a Preparing for release of 2.6.9 2006-11-07 04:41:35 +00:00
Wayne Davison
556e03a3c9 Modified to recognize FreeBSD's setfacl command. 2006-11-04 00:18:49 +00:00
Wayne Davison
e4887738bb Updated to the version dated 2006-07-02. 2006-11-02 02:01:25 +00:00
Wayne Davison
0f5c1c193a Need to include netinet/tcp.h to get TCP_NODELAY defined. 2006-10-31 19:21:57 +00:00
Wayne Davison
ab6dcad61c Mention the addition of the fake-super.diff patch. 2006-10-28 21:22:26 +00:00
Wayne Davison
b6855ddc9c Don't put backslashes before the dashes in " -- ". 2006-10-27 17:51:21 +00:00
Wayne Davison
0cbb958f34 Mention the fix for bug #4079. 2006-10-27 17:29:09 +00:00
Wayne Davison
418da6d952 Mention WIFEXITED() change. 2006-10-26 19:19:23 +00:00
Wayne Davison
51d133d686 Mention Mac OS X xattr work. 2006-10-26 17:22:15 +00:00
Wayne Davison
cbb95d3d24 Preparing for release of 2.6.9pre3 2006-10-26 17:06:41 +00:00
Wayne Davison
d9126a861f Run tweak_manpage_dashes on the man pages we generate. 2006-10-24 16:17:31 +00:00
Wayne Davison
b4768a1397 Undo temporary changes used for build-farm testing of ACL patch. 2006-10-24 15:09:57 +00:00
Wayne Davison
47b032e97f Added a define for WIFEXITED() that is used if one is missing. 2006-10-24 03:31:30 +00:00
Wayne Davison
50dfd5b4fe Document the --no-motd option. 2006-10-24 00:56:46 +00:00
Wayne Davison
1de02c273d Document the --no-motd option, with a caveat on how it can also
hide the module listing.
2006-10-24 00:36:46 +00:00
Wayne Davison
9ce7fc3887 Obey the new --no-motd option. 2006-10-24 00:36:42 +00:00
Wayne Davison
dc1f7b9ea3 Added the --no-motd option to silence just the text output at the
start of a daemon transfer.
2006-10-24 00:36:38 +00:00
Wayne Davison
ee7cf95b13 Post-process manpages with the tweak_manpage_dashes perl script. 2006-10-24 00:33:32 +00:00
Wayne Davison
492fc3536d Run patch with -t so that it doesn't ask any questions. 2006-10-24 00:24:56 +00:00
Wayne Davison
5e61bdb4d5 A perl script that does appropriate backslash escaping of '-' chars
in manpages.
2006-10-24 00:09:18 +00:00
Wayne Davison
f964ac5eee - Fixed an error-handling path in try_dests_reg().
- Added a comment.
2006-10-22 22:36:36 +00:00
Wayne Davison
c55b39afad Use "test" instead of "[ ... ]" for better portability. 2006-10-22 07:29:21 +00:00
Wayne Davison
a27463a9a2 Added missing cleanup of empty ACL files. 2006-10-22 07:18:21 +00:00
Wayne Davison
590eb6c02d Change the unpatch code for NetBSD. 2006-10-22 04:26:59 +00:00
Wayne Davison
0d7a6b4906 Temporary changes to have the build-farm configure and build
the ACL version of rsync (patched in via patches/acls.diff).
2006-10-22 03:17:45 +00:00
Wayne Davison
b4f0287197 Mention the fix that lets a push now override the partial-dir exclude. 2006-10-18 05:20:05 +00:00
Wayne Davison
8d6386809e The server should not be adding an assumed filter rule based on the
partial-dir setting (since the client is sending us the rules).
2006-10-18 05:15:35 +00:00
Wayne Davison
230328a30a Added a risk filter for the partial-dir since we use --delete-after. 2006-10-18 05:14:10 +00:00
Wayne Davison
5819d6b14a Stop disabling the RSYNC_PARTIAL_DIR environment variable now that
there is a newer rsync on samba.org.
2006-10-18 04:46:26 +00:00
Wayne Davison
7b4a40ed70 Make sure the new link_dest_used value gets zeroed on init. 2006-10-17 18:49:04 +00:00
Wayne Davison
f210dcadf4 - Fixed a compile problem ("len" not defined) in inet_ntop4().
- Replaced sprintf() with snprintf() in inet_ntop6().
2006-10-16 18:11:24 +00:00
Wayne Davison
178a1d2048 - Die if we can't edit the release date into NEWS or OLDNEWS.
- Don't remove any *pre*diff* files until the final release.
2006-10-15 21:44:15 +00:00
Wayne Davison
a4b4e0770b Improved a comment. 2006-10-15 15:57:27 +00:00
Wayne Davison
2a6e35db31 Improved a couple existing items. 2006-10-15 15:49:31 +00:00
Wayne Davison
e3794138d8 Use the new case_N.h file to make sure that our cleanup_step case
statements never get out of sequence when the code changes.
2006-10-15 15:43:26 +00:00
Wayne Davison
fdd10da6f7 A helper file for cleanup.c. 2006-10-15 15:42:01 +00:00
Wayne Davison
5f12a07bff Now that samba.org has a modern rsync, we can go back to using
hard-links on the moved files and use rsync to effect the hard-
links on the remote system (which will make a future transfer
more efficient in the absense of --detect-renamed).
2006-10-15 05:04:59 +00:00
Wayne Davison
6a4a1d0cb0 Preparing for release of 2.6.9pre2 2006-10-14 20:35:17 +00:00
Wayne Davison
434c40986d Use the MAX_RENAMES_DIGITS define in the relevant snprintf(). 2006-10-14 20:31:33 +00:00
Wayne Davison
8ee6857702 Improved the description of the code-checker work.. 2006-10-14 20:30:43 +00:00
Wayne Davison
721ddc903f Updated the news about the exit_cleanup() improvement. 2006-10-14 20:01:22 +00:00
Wayne Davison
154c345db0 Improved the _exit_cleanup() function to handle potential recursions
back to the function via the calls that it is making.  The new code
treats each recursion back into the function as an opportunity to
take up where we left off (skipping whatever step just failed).
2006-10-14 19:58:52 +00:00
Wayne Davison
25f637a334 Got rid of EXIT_OR_RETURN() macro again -- switching to a better
recursion-prevention heuristic in _exit_cleanup().
2006-10-14 18:51:21 +00:00
Wayne Davison
2356d73bb4 The cleanup code that handles moving the temp file to the partial
file needed to check that cleanup_fname was not NULL to prevent
any possibility of a recursion starting into that code again.
2006-10-14 02:29:29 +00:00
Wayne Davison
4968423e71 Mention the latest fixes and internal changes. 2006-10-14 02:02:47 +00:00
Wayne Davison
99eba67585 Got rid of the recent paranoid length check because it didn't help
to silence a code-checker warning.
2006-10-14 01:17:36 +00:00
Wayne Davison
5abe03d6e8 Restore build order back to normal. 2006-10-14 01:15:16 +00:00
Wayne Davison
83078af5b0 Changed sprintf() calls to snprintf(). 2006-10-13 23:46:32 +00:00
Wayne Davison
185aa5b0e5 Turned an sprintf() call into snprintf(). 2006-10-13 23:42:52 +00:00
Wayne Davison
cabd60fdce - Changed some sprintf() calls to snprintf() calls.
- Changed two last strcpy() calls to strlcpy() calls.
2006-10-13 23:38:14 +00:00
Wayne Davison
10944395bf Changed sprintf() calls to snprintf() calls. 2006-10-13 23:35:53 +00:00
Wayne Davison
204f4f4d09 Changed strcpy() calls into memcpy() calls. 2006-10-13 23:17:37 +00:00
Wayne Davison
c9bce0b8f8 Changed strcpy() calls into strlcpy() calls, just to be extra safe. 2006-10-13 23:17:33 +00:00
Wayne Davison
deee574b11 Added a paranoid length check. 2006-10-13 23:17:30 +00:00
Wayne Davison
55410368e5 - Changed strcpy() calls into strlcpy() calls, just to be extra safe.
- Added a default: exit_cleanup() case to a switch.
- Made the check_name() function take a buffer size arg.
2006-10-13 23:17:27 +00:00
Wayne Davison
e4fdf1debe - Use precompiler conditionals in to_wire_mode() and from_write_mode()
to get rid of code that is not needed on the current system.
- Silence a code-checker warning in send_file_entry().
- Silence a code-checker warning in make_file().
- Fixed a bug in f_name_cmp() that could compare an empty filename
  incorrectly (which might only happen if we transformed a dot-dir
  into an empty name).  (Thanks, code checker!)
2006-10-13 17:07:13 +00:00
Wayne Davison
1580899c1d More temporary name juggling to get all code analyzed. 2006-10-13 17:02:39 +00:00
Wayne Davison
f863b76300 Changed one more exit_cleanup() call into EXIT_OR_RETURN(). 2006-10-13 14:28:56 +00:00
Wayne Davison
5e1ec06f09 Temporarily reorder the OBJS line so that the IBM code checker
can analyze some of the other programs (since it runs out of
time analyzing them all).
2006-10-13 14:17:22 +00:00
Wayne Davison
36e2ea6068 Use new FNONE value when setting/comparing enum logcode vars. 2006-10-13 07:48:35 +00:00
Wayne Davison
f4164b73b4 - Use the new FNONE enum instead of a literal 0 value. 2006-10-13 07:38:21 +00:00
Wayne Davison
9ef506a2b2 If in_exit_cleanup is set, some of our functions return instead of
calling exit_cleanup() (which is a safer way to avoid an infinite
loop when the exit code uses the log functions than allowing the
_exit_cleanup() function to return back into our code).
2006-10-13 07:38:18 +00:00
Wayne Davison
b1b54199ef - When exiting, set the flag "in_exit_cleanup".
- Mark _exit_cleanup() with NORETURN.
- Don't ever return from _exit_cleanup().
2006-10-13 07:38:15 +00:00
Wayne Davison
33394b769d Mark out_of_memory() and overflow_exit() with NORETURN. 2006-10-13 07:38:11 +00:00
Wayne Davison
011e85a5e3 - Added FNONE to the "enum logcode" values.
- Added a NORETURN define to mark a function that never returns.
2006-10-13 07:38:05 +00:00
Wayne Davison
d5dcb6f775 Silence some IBM checker warnings and made a slight optimization
to get_tmpname().
2006-10-13 07:18:29 +00:00
Wayne Davison
0c25dedf31 Simplified the function-finding regex, and made it more versatile
(so we don't need to keep adding variable-type strings).
2006-10-13 06:50:56 +00:00
Wayne Davison
6105464b79 Indented the function comments with "* ". 2006-10-13 06:49:44 +00:00
Wayne Davison
4d51f0db79 Don't use a bool directly in an int comparison. 2006-10-13 06:27:59 +00:00
Wayne Davison
ff530f04a0 Function fcntl() only takes 2 args when using F_GETFL. 2006-10-13 06:26:02 +00:00
Wayne Davison
e8b21fe406 Cast pat_len to an int when using it as a field width. 2006-10-13 06:24:24 +00:00
Wayne Davison
71cb9df386 Some OSes can't chmod -t for a file, so I changed the logic of our
to to substitute a chmod that will work everywhere.
2006-10-13 04:59:53 +00:00
Wayne Davison
f97c2d4a9b - Clarified the "dont compress" option.
- Cleaned up some trailing whitespace.
2006-10-13 01:37:44 +00:00
Wayne Davison
b8a6dae038 Updated the man pages to work with version 2.x of yodl. 2006-10-13 01:24:57 +00:00
Wayne Davison
969f7ed5b7 Fixed an infinite loop in parse_rule() when a filter rule is too
longer for MAXPATHLEN.  Also fixed a couple spots nearby that were
erroneously treating pointer "cp" as a '\0'-terminated string.
2006-10-13 01:22:48 +00:00
Wayne Davison
e825409a84 Preparing for release of 2.6.9pre1 2006-10-12 03:45:53 +00:00
Wayne Davison
b8d29fd8e6 Added a line for 2.6.9. 2006-10-12 03:44:44 +00:00
Wayne Davison
200f2d98db Make sure we tweak the right RSYNC_VERSION line in configure. 2006-10-12 03:32:18 +00:00
Wayne Davison
1a7f3d99c5 Removed the changes in symlink handling in non-chroot daemon mode as
they were not yet safe (I'll consider similar changes for the next
release).
2006-10-12 03:01:18 +00:00
Wayne Davison
e80876700c Got rid of changes that aren't going to make it into 2.6.9. 2006-10-12 03:01:12 +00:00
Wayne Davison
ec55b4f2fb Changed the indent for one else ... if section. 2006-10-12 03:01:01 +00:00
Wayne Davison
798cde474f Some minor improvements to parse_merge_name(). 2006-10-12 02:14:47 +00:00
Wayne Davison
558d482c47 Renumbered tests after adding one in the middle. 2006-10-11 00:51:50 +00:00
Wayne Davison
418b6a2703 Handle the itemizing of of the "." dir when it is newly created. 2006-10-11 00:04:48 +00:00
Wayne Davison
1ef5bf3cfd If new_root_dir is set, itemize the output of the "." dir as a
directory-creation event.
2006-10-11 00:04:44 +00:00
Wayne Davison
2a94207ad6 Added a new variable, new_root_dir, that is set if we created the
destination directory.
2006-10-11 00:04:41 +00:00
Wayne Davison
ddcba3f075 Changed the fix_basis_dirs() function to only remove a single ../
prefix from each --*-dest option's path.
2006-10-10 23:44:59 +00:00
Wayne Davison
db3ae95cac Made some of the --link-dest tests use a relative destination
directory, and made one of those do a --dry-run test before
the regular test.
2006-10-09 03:06:50 +00:00
Wayne Davison
1a05de2bff - If a finished link came from a link-dest dir and --dry-run is in
effect, we now stat the link-dest file instead of the non-existent
  destination file.
- Use int32 for the index variables.
2006-10-09 03:05:19 +00:00
Wayne Davison
d9163a4cf5 If the combination of --dry-run, --link-dest, and -H finds a matching
file in on of the extra basis dirs, make a note of which basis dir
we would have used in the hard-link with the destination file.
2006-10-09 02:59:23 +00:00
Wayne Davison
44885a398f Added link_dest_used unsigned short to struct hlink and made the
other values explicitly 32-bit so that the total size can't be
larger than the other struct we're in a union with.
2006-10-09 02:57:04 +00:00
Wayne Davison
dfe1ed5e97 Another tweak to the --chmod summary. 2006-10-09 00:55:04 +00:00
Wayne Davison
242f6052c2 Mention the latest bug fix. 2006-10-08 22:17:39 +00:00
Wayne Davison
519d55a950 Make the daemon's "incoming chmod" tweaks happen last, as documented. 2006-10-08 22:02:13 +00:00
Wayne Davison
b6008dc645 Clarify the short description of --chmod. 2006-10-08 22:00:31 +00:00
Wayne Davison
6f3684ffb5 Call push_dir() with its new boolean arg. 2006-10-08 20:57:01 +00:00
Wayne Davison
615a5415c9 - Call push_dir() with its new boolean arg, including the spot in
get_local_name() where we need push_dir() to skip the chdir() because
  the destination dir does no yet exist and --dry-run was specified.
- Added fix_basis_dirs(), which will combine the dest-dir with each non-
  absolute basis_dir arg to make sure that they end up being relative to
  the right dir when --dry-run was specified and the dest dir does not
  yet exist.
2006-10-08 20:56:56 +00:00
Wayne Davison
ba081be327 Made the push_dir() function take an option to skip the actual chdir()
call.  Used when the dest-dir doesn't exist and --dry-run was specified.
2006-10-08 20:56:52 +00:00
Wayne Davison
3e88414e4e Moved some of the variable setup from "make check" into the
runtest.sh script.
2006-10-07 14:54:56 +00:00
Wayne Davison
0888952768 Moved some variable setup here from the Makefile and made it
possible to specify extra rsync options for the test.
2006-10-07 14:54:14 +00:00
Wayne Davison
5dcd9a2b70 Changed the -o to -a in the "if". 2006-10-07 14:39:01 +00:00
Wayne Davison
6ce9432d75 A bug-fix for die_on_unsafe_path() when the path doesn't exist. 2006-10-07 14:19:00 +00:00
Wayne Davison
6c8507724b Added exception-checking to a couple select() calls, as suggested
by Hugh Daschbach.
2006-09-30 22:11:20 +00:00
Wayne Davison
d04e95e968 Document that --ignore-times thwarts all --link-dest linking. 2006-09-30 15:21:25 +00:00
Wayne Davison
b06050f9ad I decided that combining --link-dest with -I doesn't make much sense
(without some kind of a post-transfer identicality check, at least)
so I'm removing the code that tried to make the two play nice.
2006-09-30 15:20:17 +00:00
Wayne Davison
ad75d18d2e Mention that the --backup-dir option is a receiver-side path. 2006-09-26 16:44:27 +00:00
Wayne Davison
ed4b8da048 Mention the latest bugfix. 2006-09-24 03:36:04 +00:00
Wayne Davison
2cd421d809 Output the who_am_i() info in out-of-memory() and overflow_exit(). 2006-09-24 03:12:24 +00:00
Wayne Davison
ea0ea357f4 Provide the who_am_i() function. 2006-09-24 03:11:41 +00:00
Wayne Davison
0480a946f5 Some more testing based on Matt's recent patch. 2006-09-23 23:49:20 +00:00
Wayne Davison
67f8a41be5 Matt tracked down a bug in the daemon option "incoming chmod" where
a newly created directory would get the chmod permissions that were
specified for a file (via the F previx).
2006-09-23 23:15:11 +00:00
Wayne Davison
5e1f082d0c Improvments by Matt for the --progress option, including updating
the examples to look like the actual output in a modern rsync.
(I did a little rewording too...)
2006-09-23 00:07:28 +00:00
Wayne Davison
a633351962 Mention the current limitation of the RSYNC_EXIT_STATUS value. 2006-09-20 14:04:19 +00:00
Wayne Davison
2edfe52230 Mention the new --remove-s*-files error. 2006-09-20 01:54:40 +00:00
Wayne Davison
acee1ad853 Complain if a --remove-s*-files option is set and we can't remove
the source file.
2006-09-20 01:53:32 +00:00
Wayne Davison
8f4ae68ca7 The [ & ] are now removed from a literal IPv6 hostname passed to the
remote shell.
2006-09-18 17:39:13 +00:00
Wayne Davison
ff1b9344c9 When parsing a literal IPv6 address in square brackets, pass the
whole string (including the brackets) to the remote shell.  (The
old code stripped the leading '[' but left the trailing ']'.)
2006-09-18 01:19:26 +00:00
Wayne Davison
a923437bc0 Added a missing '-' to the string "-rsh". 2006-09-18 01:15:19 +00:00
Wayne Davison
dde698c2e8 Mention the permission bug-fix for new files created by --inplace. 2006-09-18 00:47:56 +00:00
Wayne Davison
c2b47e31a5 Mention the adding of the --remove-source-files option. 2006-09-18 00:38:20 +00:00
Wayne Davison
4e0bf97716 Mention the --server and --sender option as being internal,
not-for use by a normal user options.  Also mention the
support/rrsync script in this context.
2006-09-18 00:19:04 +00:00
Wayne Davison
174e51b5bf Added parsing for all the latest options. 2006-09-18 00:16:31 +00:00
Wayne Davison
30cd7ec1cf The --min-size arg doesn't need to be path-checked either. 2006-09-18 00:13:50 +00:00
Wayne Davison
48459ba15c The --inplace option now notices when the basis data is not coming
from the destination file (or an identical copy) and always writes
out the data (instead of seeking when at an identical offset).
2006-09-17 23:28:19 +00:00
Wayne Davison
48ecccce2d The --delete-excluded code now also drops any merge file that was
marked as MATCHFLG_NO_PREFIXES because they can only contain
include/exclude rules.
2006-09-09 18:59:10 +00:00
Wayne Davison
a739128df9 Document the new RSYNC_PID environment variable. 2006-09-09 18:56:13 +00:00
Wayne Davison
2c1775620a Try various long, long-long, etc. types for a 64-bit integer
before trying off64_t.
2006-09-09 18:53:23 +00:00
Wayne Davison
40f910c43a Mention the latest changes. 2006-09-09 18:31:45 +00:00
Wayne Davison
503114a782 Added the RSYNC_PID environment variable for the pre-/post-xfer
commands so that the pre-xfer command has a unique ID it can
use to cache information for the post-xfer command.
2006-09-09 17:59:02 +00:00
Wayne Davison
71f9e4673e A slight simplification to the last change. 2006-09-02 20:05:08 +00:00
Wayne Davison
176e8e94c3 An even better way to un-backslash-escape the filenames from find. 2006-09-02 19:57:56 +00:00
Wayne Davison
814b340c27 Improved the --delete-excluded test based on Matt's input and
another corner case I noticed.
2006-09-01 00:43:52 +00:00
Wayne Davison
f167879035 Matt pointed out that the code was not properly dropping excludes
that were read from a per-dir merge file when --delete-excluded
is enabled.  This additional code fixes that.
2006-09-01 00:42:39 +00:00
Wayne Davison
4187572616 Fixed handling of filenames with an embedded $, @, or %. 2006-08-31 20:30:16 +00:00
Wayne Davison
ff43d8b449 Added Matt's --delete-excluded test for merge-file correctness. 2006-08-31 17:19:26 +00:00
Wayne Davison
97bf86f8ee Make sure that --delete-excluded does not elide a per-dir merge
filter file, while still dumping the .cvsignore file from -C.
2006-08-31 17:18:24 +00:00
Wayne Davison
8c449e6285 When we're cleaning up a path of "/" in relative mode, we must make
the name "/." (as it was of old) so that there is a filename for us
to send.  Fixes a problem with --delete --relative when copying from
the root (/) of the filesystem.
2006-08-26 16:02:17 +00:00
Wayne Davison
29930a9fd2 Fixed an exclude bug with --relative excluding "/". 2006-08-12 16:22:03 +00:00
Wayne Davison
c98ad3df96 Check return value of asprintf() in full_fname(), as pointed
out by Ilja van Sprundel.
2006-07-29 21:04:35 +00:00
Wayne Davison
9c3c30e5c7 Assign datarootdir=@datarootdir@ so that a modern autoconf
doesn't complain about our Makefile.in.
2006-07-21 13:58:52 +00:00
Wayne Davison
b4a09b72ee Use new MAKEDEV() macro instead of makedev() directly. 2006-07-10 04:25:53 +00:00
Wayne Davison
5a3810b463 Define MAKEDEV() based on the MAKEDEV_TAKES_3_ARGS define. 2006-07-10 04:25:10 +00:00
Wayne Davison
e8d97006e5 If makedev() takes 3 args, define MAKEDEV_TAKES_3_ARGS. 2006-07-10 04:24:07 +00:00
Wayne Davison
8adc22e362 Mention the "munge symlinks" daemon setting. 2006-07-03 22:35:41 +00:00
Wayne Davison
dcebf78fe0 Obey the new "munge symlinks" dameon setting. 2006-07-03 22:35:00 +00:00
Wayne Davison
651c8510e8 Document "munge symlinks". 2006-07-03 22:33:56 +00:00
Wayne Davison
1ed3f5ed61 Added the "munge symlinks" setting. 2006-07-03 22:33:49 +00:00
Wayne Davison
70c81b0c07 Fixed the indentation on a few lines. 2006-07-03 22:30:13 +00:00
Wayne Davison
47c1197534 Decided that I like remove-source-files better than remove-sender-files. 2006-06-30 15:52:52 +00:00
Wayne Davison
fb41a3c669 Changed --remove-sent-files into --remove-sender-files. 2006-06-30 15:42:41 +00:00
Wayne Davison
2700069d5a Added --remove-sender-files and deprecated --remove-sent-files. 2006-06-30 15:42:36 +00:00
Wayne Davison
044ccbaacf The remove_sent_files var was renamed to remove_sender_files. 2006-06-30 15:42:32 +00:00
Wayne Davison
841d943651 Handle the --remove-sender-files option by sending MSG_SUCCESS for
any file that is being hard-linked.
2006-06-30 15:42:29 +00:00
Wayne Davison
04cd8789cb Handle the --remove-sender-files option by sending MSG_SUCCESS for
any up-to-date file (non-dir).
2006-06-30 15:42:26 +00:00
Wayne Davison
9578783a71 Changed the name of the nightly symlink. 2006-06-30 14:26:01 +00:00
Wayne Davison
4cff5fa462 Make use of module_dirlen in full_fname(). 2006-06-30 14:24:25 +00:00
Wayne Davison
cc1b4f776a Allow --with-nobody-group=GROUP (patch from Olivier Thauvin). 2006-06-19 19:30:51 +00:00
Wayne Davison
72d1b262ac Mention the latest bug-fix. 2006-06-16 09:05:21 +00:00
Wayne Davison
6fb7cc38a2 Make sure that the %f escape always has the full path info when
receiving files.
2006-06-16 09:01:31 +00:00
Wayne Davison
8a7b8400e7 Updated the "use chroot" section with the latest symlink info. 2006-06-16 08:56:26 +00:00
Wayne Davison
d2ab094dec Mention the latest log-file improvements. 2006-06-07 23:06:18 +00:00
Wayne Davison
ccd2966da9 Moved the "log file" and "syslog facility" sections into the per-module
options and improved them a little.
2006-06-07 23:05:27 +00:00
Wayne Davison
6dc9b74bc6 Call log_init() with its new "restart" (0 or 1) arg. 2006-06-07 23:05:24 +00:00
Wayne Davison
04c841190f - Pass "module_id" to the two log-related settings that are no longer
global.
- Added a "restart" arg to log_init() that lets us request that logging
  be reinitialized if the log-file/syslog-facility params changed.
2006-06-07 23:05:17 +00:00
Wayne Davison
d20ce6e144 Made "log file" and "syslog facility" per-module settings. 2006-06-07 23:05:14 +00:00
Wayne Davison
a7d461fccd Improved some comments in get_local_name() and improved the
error checking a little more.
2006-06-05 22:50:52 +00:00
Wayne Davison
4c5a2da65f Mention the latest bug-fix. 2006-06-05 17:00:47 +00:00
Wayne Davison
caff33228e If we fail to create a new directory, skip trying to update
everything that is inside that dir.
2006-06-05 16:56:50 +00:00
Wayne Davison
f38f6f80b7 Added FLAG_MISSING. 2006-06-05 16:52:34 +00:00
Wayne Davison
e848e06618 Got rid of an unused extern. 2006-06-05 16:17:33 +00:00
Wayne Davison
eece5fe32c Mention the temp-file fix. 2006-06-01 08:40:55 +00:00
Wayne Davison
8590993185 Got rid of the FNAME logcode enum. 2006-06-01 08:04:50 +00:00
Wayne Davison
b64ee91a41 Changed rprintf() messages that started with a newline into two
rprintf() calls (the first of which just outputs an empty line).
2006-06-01 08:04:47 +00:00
Wayne Davison
d0133e6eba - Got rid of the FNAME logcode enum.
- rwrite() no longer supports newlines at the start of the string.
- maybe_log_item() avoids outputting a non-significant update to
  the log file if the log-file-format doesn't include %i.
2006-06-01 08:04:43 +00:00
Wayne Davison
1925c3448c - Got rid of the FNAME logcode enum.
- We no longer output " is uptodate" messages to the log file.
2006-06-01 08:04:40 +00:00
Wayne Davison
19b8587654 Fixed a typo that set stdout_format_has_i instead of logfile_format_has_i. 2006-06-01 06:49:15 +00:00
Wayne Davison
051f5df526 Mention the latest --log-* option changes. 2006-05-30 18:35:36 +00:00
Wayne Davison
e525519509 Authorize the current host in the rsyncd.conf file in addition
to localhost and 127.0.0.1 (which will hopefully fix the failing
of the daemon tests on FreeBSD).
2006-05-30 18:26:17 +00:00
Wayne Davison
4b90820d9f - Added the --log-file-format option to the daemon section.
- Updated and improved the --out-format section.
- Moved and improved the description of the non-daemon --log-file and
  --log-file-format options.
2006-05-30 17:47:20 +00:00
Wayne Davison
2873603ab5 If the user specifies --log-file-format without --log-file,
ignore the useless value.
2006-05-30 17:41:54 +00:00
Wayne Davison
ec52c3b9da Skip transfer logging if the logfile_format string is empty. 2006-05-30 17:41:04 +00:00
Wayne Davison
10ae3406ee Allow the --log-file-format=FMT option (if given when starting a daemon)
to override the "log format" setting.
2006-05-30 17:15:24 +00:00
Wayne Davison
232658d9d3 - Allow the --log-file-format option to override the "log format"
setting when starting a daemon.
- Make a daemon refuse all --log-file* options.
- Don't use refuse logic on daemon-mode options given to a daemon
  module -- reject them via their own message.
2006-05-30 17:14:17 +00:00
Wayne Davison
c000002f46 Document the new --log-file-format option and renamed --log-format to
--out-format.
2006-05-29 22:57:05 +00:00
Wayne Davison
2fedf3d596 - Use the renamed stdout_format_has_i variable.
- Call log_item() with its new arg (and call it more often).
2006-05-29 22:57:01 +00:00
Wayne Davison
887d745549 Turn off the --log-file option on the server side for a local transfer. 2006-05-29 22:56:58 +00:00
Wayne Davison
20f90d5e8a Use the renamed stdout_format_has_i variable. 2006-05-29 22:56:55 +00:00
Wayne Davison
17bda2d109 - Use the renamed stdout_format_has_i variable.
- Call log_item() with its new arg.
2006-05-29 22:56:51 +00:00
Wayne Davison
b534351058 - Use the renamed stdout_format_has_i, stdout_format_has_o_or_i, and
stdout_format variables.
- In rwrite(), make FNAME output only go to the client.
- Added an arg to log_item() that indicates what kind of output is
  desired: FNAME (stdout only),  FLOG (log file only), or FINFO (both).
2006-05-29 22:56:48 +00:00
Wayne Davison
b3e4e7ef2e - Renamed log_format -> stdout_format.
- Renamed log_format_has_i -> stdout_format_has_i.
- Renamed log_format_has_o_or_i -> stdout_format_has_o_or_i.
- Changed the --log-format to --out-format (though we still accept
  the old option, and still send it as well).
- Added the --log-file-format option (and got rid of the code that
  made --out-format sometimes affect the log-file's format).
2006-05-29 22:56:45 +00:00
Wayne Davison
a3f6dbdf5c The print_child_argv() function should be outputting FCLIENT
messages these days, not FINFO.
2006-05-29 22:33:06 +00:00
Wayne Davison
95ae5224b0 The cleanup_set() call was not getting called w/o --partial. 2006-05-18 18:53:24 +00:00
Wayne Davison
03dbc0b831 - Improved the setting of cleanup_new_fname and cleanup_fname.
- Don't try to keep a partial file if cleanup_new_fname is not set.
2006-05-18 18:52:40 +00:00
Wayne Davison
ffa8ab8eb5 Improved two lseek() error messages. 2006-05-18 17:04:40 +00:00
Wayne Davison
a17e119d8b Mention the latest fixes. 2006-05-17 06:54:11 +00:00
Wayne Davison
6bfc7b4d79 Tweaked a couple things in try_dests_reg(). 2006-05-16 22:27:26 +00:00
Wayne Davison
b3e8e7c79e Make --quiet quieter (like it used to be), but also don't allow it
to interfere with any logging of messages that is going on.
2006-05-14 00:27:33 +00:00
Wayne Davison
bdd3a4fef5 Updated the (commented out) valgrind command. 2006-05-11 23:41:18 +00:00
Wayne Davison
a00f5a371e Got rid of the .ignore kluge. 2006-05-11 23:38:10 +00:00
Wayne Davison
55c412630c Added ".bzr/" to the default CVS exclusions. 2006-05-11 07:54:33 +00:00
Wayne Davison
778ee637ee This file hasn't been needed for a while now... 2006-05-10 18:34:32 +00:00
Wayne Davison
80aff93b32 Added the updating of a symlink to the very latest nightly tar file. 2006-05-10 16:37:07 +00:00
Wayne Davison
6721973e37 Mention the --log-file option. 2006-05-09 18:44:58 +00:00
Wayne Davison
a2ed5801d3 Document the new --log-file option. 2006-05-09 18:31:24 +00:00
Wayne Davison
15ce4b24fc Output the progress message as FCLIENT instead of FINFO. 2006-05-09 18:31:19 +00:00
Wayne Davison
c5260884d6 Got rid of the call to log_exit() now that the cleanup code handles this. 2006-05-09 18:31:16 +00:00
Wayne Davison
ea124cb324 - Turned some FINFO rprintf() calls into FCLIENT calls that don't go
into a client-side log-file.
- Added a couple FLOG rprintf() calls.
2006-05-09 18:31:13 +00:00
Wayne Davison
13b597fa71 - Use the new logfile_* variables that are set by the --log-file
option instead of the old daemon_log_* variables.
- Renamed the "logfile" variable "logfile_fp".
- Enhanced the logic in rwrite() to handle client-side FLOG output.
2006-05-09 18:31:10 +00:00
Wayne Davison
ecc7623e7f Some demon_log_* variables changed into logfile_* variables that are
also used by the new --log-file option.
2006-05-09 18:31:06 +00:00
Wayne Davison
87c0f9d6b4 Added --log-file and several logfile_* support variables. 2006-05-09 18:31:03 +00:00
Wayne Davison
1cfcb8af11 Revised the logic for when to call log_exit() to handle the
new --log-file option.
2006-05-09 18:31:00 +00:00
Wayne Davison
56aaa4c44c Tweaked the comment about log-message categories. 2006-05-09 18:30:57 +00:00
Wayne Davison
4b6a7bd706 Got rid of an unused variable. 2006-05-09 18:00:15 +00:00
Wayne Davison
5bc933a285 Mention the latest bugfix and improved an old description. 2006-05-09 17:46:04 +00:00
Wayne Davison
01d124d9e2 If the --partial-dir value is an absolute path and we use a file in
it as an alternate basis file, make sure that we delete it when the
associated destination file is successfully updated.
2006-05-09 17:38:47 +00:00
Wayne Davison
58a06312a4 Improved the doc for --existing and --ignore-existing. 2006-05-05 20:41:17 +00:00
Wayne Davison
c2c8db9195 - Moved the sanitizing of the partial_dir value here from options.c.
- Call die_on_unsafe_path() in a few needed places.
- Handle the server-excluded checks for an absolute partial_dir and
  the --*-dest options.
2006-05-05 16:00:33 +00:00
Wayne Davison
d1e6b0e225 - Added some calls to die_on_unsafe_path() to the path-sanitizing code.
- Moved the sanitizing of the partial_dir value into main.c.
2006-05-05 15:58:44 +00:00
Wayne Davison
8936367695 - Added a call to die_on_unsafe_path() to handle_partial_dir().
- Fixed some strange slash handling in partial_dir_fname().
2006-05-05 15:54:20 +00:00
Wayne Davison
8517e9c10a A few minor changes to match the recent --help changes in
options.c.
2006-05-05 06:24:25 +00:00
Wayne Davison
fcecb70b1d - Don't check HAVE_LINK directly, use SUPPORT_HARD_LINKS instead.
- Updated a few items in the --help text.
2006-05-05 06:16:22 +00:00
Wayne Davison
582c1589f3 Call the new die_on_unsafe_path() function in a few places. 2006-05-05 05:57:48 +00:00
Wayne Davison
cb15269eb0 Call the new die_on_unsafe_path() function in a couple spots. 2006-05-05 05:56:37 +00:00
Wayne Davison
f47807900b Added a new function named die_on_unsafe_path(). This is used
by a non-chroot daemon to ensure that a user-supplied path does
not contain an unsafe symlink element.
2006-05-05 05:55:40 +00:00
Wayne Davison
40410a38bc - Don't check HAVE_LINK directly, use SUPPORT_HARD_LINKS instead.
- Tweaked Paul's recent change just a tad.
- Fixed the output of --compare-dest when SUPPORT_HARD_LINKS is
  not defined.
2006-05-05 05:53:36 +00:00
Wayne Davison
6b54a688cf Cast file->mode to an int when printing it via %o. 2006-05-05 05:40:17 +00:00
Paul Green
b59dc8d5ae Fix generator.c to avoid calling do_link() on systems that do not support
the link() function.  The changes test OK on SuSE Linux and on my own
Stratus VOS system, but I would be grateful if other folks could
double-check this change.  Paul G.
2006-05-04 19:00:37 +00:00
Wayne Davison
45ba206a94 A few more improvements. 2006-05-04 02:42:55 +00:00
Wayne Davison
2220ec0a69 A few minor twiddles. 2006-05-04 02:38:58 +00:00
Wayne Davison
5fdbb87df8 Added/clarified the latest bug-fix info. 2006-05-04 02:29:58 +00:00
Wayne Davison
f1c9bcd0fc Cast the enum in rwrite() when calling send_msg(). 2006-05-03 16:58:36 +00:00
Wayne Davison
3723548ded Use send_msg() when forwarding a log message, not io_multiplex_write().
This allows send_msg() to decide if the message should be sent right
away, or should be deferred.
2006-05-03 16:17:49 +00:00
Wayne Davison
12ccc73ae7 Changed read_msg_fd() to always use send_msg()/rwrite() instead of
sometimes calling io_multiplex_write()/rwrite() or msg_list_add().
This simplifies the code that does the defer_forwarding_messages
checking because it can now be done in just one place, in send_msg()
(because rwrite() also calls send_msg() now when forwarding a msg).
2006-05-03 16:17:46 +00:00
Wayne Davison
ee8d9636d1 A small optimization to the new code in msg2sndr_flush(). 2006-05-03 06:32:59 +00:00
Wayne Davison
38de2866e5 Made log_init() call timestring() instead of just localtime() prior to a
chroot (note that timestring() makes use of localtime() plus strftime()).
2006-05-03 06:11:11 +00:00
Wayne Davison
bdac7621ee Improved the last bugfix description. 2006-05-03 05:37:00 +00:00
Wayne Davison
8ac4774675 Mention the fix for the "unexpected tag 3" bug. 2006-05-03 05:22:01 +00:00
Wayne Davison
229e1950ed Fixed a bug where deferred MSG_INFO/MSG_ERROR/MSG_LOG messages were
not being forwarded from the generator to the sender using rwrite()
(and MSG_LOG messages didn't need to be deferred at all).
2006-05-03 05:19:01 +00:00
Wayne Davison
93977bca10 Added module_dirlen now that utils.o needs it. 2006-05-03 00:49:31 +00:00
Wayne Davison
c2a2147a5b - Call safe_stat() instead of do_stat() when a sanitizing daemon might
need to ensure that it doesn't follow any unsafe symlinks.
- Got rid of startdir_depth code (in favor of util.c's curr_dir_depth).
- Use the new calling syntax for sanitize_path().
2006-05-03 00:48:32 +00:00
Wayne Davison
73173af955 - Call safe_stat() instead of do_stat() when a sanitizing daemon might
need to ensure that it doesn't follow any unsafe symlinks.
- Don't sanitize the string of a symlink -- just use it verbatim.
2006-05-03 00:48:29 +00:00
Wayne Davison
a2248aea2e - Call safe_stat() instead of do_stat() when a sanitizing daemon might
need to ensure that it doesn't follow any unsafe symlinks.
- Use the new calling syntax for sanitize_path().
2006-05-03 00:48:26 +00:00
Wayne Davison
a8167c6611 - Added curr_dir_depth, a variable that keeps track of the depth past
the module root when a sanitizing daemon is running.
- Use the new calling syntax for sanitize_path().
- Updated count_dir_elements() to not count a . component.
- Improved sanitize_path() so that it can take a symlink target string
  and combine it with the symlink's name when the target is relative.
  When working with a symlink, the routine also returns NULL if any ..
  elements try to escape past the module root.
- The new routine safe_stat(), is used when sanitizing paths (i.e. when
  the daemon does not have chroot enabled).  This manually follows a
  chain of symlinks, ensuring they don't try to escape the module.
2006-05-03 00:48:23 +00:00
Wayne Davison
91f4b31fe1 Use the new calling syntax for sanitize_path(). 2006-05-03 00:48:20 +00:00
Wayne Davison
cad8f6f980 Tweaked some variable names in readlink_stat() and link_stat(). 2006-05-02 19:52:28 +00:00
Wayne Davison
d8bf7ea8e9 Mention the latest bug-fixes. 2006-05-02 17:38:34 +00:00
Wayne Davison
d8f28a663c Test the new symlink sanitizing fix by using ::test-scratchdir/to
as the destination and including a symlink with a leading "../" .
2006-05-02 17:13:11 +00:00
Wayne Davison
2ae4126a9e Tweaked our test config file to include transfer logging that
includes %i, and to have a test-scratchdir module.
2006-05-02 17:11:42 +00:00
Wayne Davison
6f1c2aab43 Moved the sanitizing of a symlink's link string here from flist.c. 2006-05-02 16:52:51 +00:00
Wayne Davison
e71c1c26df Fixed a problem in the --link-dest processing where -I (--ignore-times)
or --size-only could adversely affect our ability to find identical
files to hard-link.
2006-05-02 16:46:48 +00:00
Wayne Davison
b24498ec2c Set a new variable, startdir_depth, to indicate how deep the
destination dir is in a daemon module's path.
2006-05-02 16:42:20 +00:00
Wayne Davison
b2d4639543 Got rid of the sanitizing of a symlink's link string because it
is happening too early to work correctly (before we know what
our destination-directory's depth in the module will be).
2006-05-02 16:36:07 +00:00
Wayne Davison
d3ef985954 We can't check the --*-dest args against the server filter rules
here because we don't know what the args are going to be relative
to yet.
2006-04-28 17:34:53 +00:00
Wayne Davison
7c58c99184 We sanitize the --*-dest args here so they can be relative to the
destination directory.
2006-04-28 16:58:20 +00:00
Wayne Davison
ad77db8b71 Moved the sanitizing of the --*-dest args into main.c. 2006-04-28 16:57:39 +00:00
Wayne Davison
e7c67065c0 Updated the FSF's address to an even newer one. 2006-04-25 23:51:12 +00:00
Wayne Davison
0f78b81511 - Updated the address for the FSF in the opening comment.
- Standardized the format of the opening comment, including adding a
  brief description of what's in the file for those that lacked it.
- Added some missing copyright lines.
- Some minor whitespace tweaks (in a few of the files).
2006-04-25 20:23:34 +00:00
Wayne Davison
d051056f92 Tweaked some whitespace to match the latest version from autoconf. 2006-04-24 23:43:45 +00:00
Wayne Davison
a4a38e8df0 Incremented the version to 2.6.9cvs. 2006-04-24 22:24:40 +00:00
Wayne Davison
60ef8ed128 Rolled over the news file for the next version. 2006-04-24 22:23:56 +00:00
Wayne Davison
8aa0dc7838 Updated to the version dated 2006-02-23. 2006-04-24 22:20:10 +00:00
Wayne Davison
4177f09b83 Preparing for release of 2.6.8 2006-04-22 15:39:57 +00:00
Wayne Davison
acaadb55c1 Mention the phase-unknown changes. 2006-04-21 16:57:13 +00:00
Wayne Davison
b88c2e8ffe - Got rid of the (mostly useless) io_read_phase and io_write_phase
variables.  In the future it might be useful to get rsync to
  mention what kind of a message it was trying to write, but the
  'phase "unknown"' output was ubiquitous and confusing.
- Got rid of the completely unused write_int_named() function.
2006-04-21 16:40:19 +00:00
Wayne Davison
f4ea5f47dc Got rid of the setting of io_write_phase. 2006-04-21 16:36:30 +00:00
Wayne Davison
62ae66d43b Mention the security fix for patches/xattrs.diff. 2006-04-21 00:05:30 +00:00
Wayne Davison
8641d28740 Improved the --owner and --group sections. 2006-04-18 18:58:07 +00:00
Wayne Davison
de3438407c Twiddle the trailing output in non-live mode. 2006-04-18 06:43:17 +00:00
Wayne Davison
434764269c Fixed a typo in the new code. 2006-04-18 06:38:58 +00:00
Wayne Davison
ba212fe0b6 - Fixed --copy-dest behavior on a system where CAN_HARDLINK_SYMLINK
and/or CAN_HARDLINK_SPECIAL is not defined.
- Changed --link-dest behavior on such systems to work just like
  --copy-dest for the non-hard-linkable files.
2006-04-18 05:48:46 +00:00
Wayne Davison
5f93b4d35e A slight improvement to the logic in try_dests_non(). 2006-04-18 05:24:02 +00:00
Wayne Davison
f8db4a8ab4 Mention the latest bugfix. 2006-04-17 19:55:16 +00:00
Wayne Davison
398612ba07 Fixed a bug where special files were not getting hard-linked via
the --link-dest option.
2006-04-17 19:53:41 +00:00
Wayne Davison
77b013afb5 Don't use the -C option to make (since it's not portable). 2006-04-17 18:15:02 +00:00
Wayne Davison
08c0cd8a42 Mention the latest fixes. 2006-04-17 18:00:09 +00:00
Wayne Davison
1c6e9dfabc Use the new CAN_HARDLINK_SYMLINK and CAN_HARDLINK_SPECIAL defines
from configure instead of the old (and not quite correct) run-time
checking.
2006-04-17 17:56:10 +00:00
Wayne Davison
0037bf23fc Added two new checks: 1. Does link() hard-link symlinks (not the
referent)?  2. Does link() hard-link a fifo?
2006-04-17 17:53:47 +00:00
Wayne Davison
285edc9169 Don't use -C with make because it's not portable. 2006-04-17 17:37:13 +00:00
Wayne Davison
c4aa84ad50 Got rid of the unused REPLACE_INET_NTOA and REPLACE_INET_ATON checks. 2006-04-13 16:54:24 +00:00
Wayne Davison
b635bc92d1 Got rid of inet_ntoa -> rep_inet_ntoa tom-foolery because rsync
doesn't use inet_ntoa() anymore.
2006-04-13 16:53:15 +00:00
Wayne Davison
146d2228cc Got rid of the replacement inet_aton() and inet_ntoa() functions
because no code in rsync has used these functions since 2.4.8.
2006-04-13 16:52:15 +00:00
Wayne Davison
b2501ccf12 Improved a sentence. 2006-04-12 16:59:32 +00:00
Wayne Davison
e60bba3fbc A few minor changes to some messages and a couple variable improvements. 2006-04-12 16:35:53 +00:00
Wayne Davison
e26cfccf16 Preparing for release of 2.6.8pre1 2006-04-12 16:23:46 +00:00
Wayne Davison
74f80abce2 Moved the include of netinet/ip.h into socket.c. 2006-04-11 00:48:55 +00:00
Wayne Davison
5899b8cf3e Moved the include of netinet/ip.h here along with its apparent
prerequisite, netinet/in_systm.h .
2006-04-11 00:48:28 +00:00
Wayne Davison
08e0a62956 Tweaked a comment. 2006-04-11 00:28:02 +00:00
Wayne Davison
2bd17a51ae Include netinet/ip.h . 2006-04-09 13:51:56 +00:00
Wayne Davison
c7b9ebb598 Mention the read-position fix. 2006-04-08 16:43:21 +00:00
Wayne Davison
e3db43ffe5 Fixed the value of map->p_fd_offset when a read() fails or is
abbreviated.
2006-04-08 16:37:50 +00:00
Wayne Davison
f61ab01d96 Use --delete-after instead of --delete. 2006-04-08 16:36:57 +00:00
Wayne Davison
ceca8ccac8 We don't need log_initialised exported after all. 2006-04-08 16:04:34 +00:00
Wayne Davison
374c3e1278 Moved the calls to client_addr() and client_name() below the lp_load()
call so that their potential to output log messages can't cause the
log-file to initialize before we know what "log name" to use.
2006-04-08 16:03:16 +00:00
Wayne Davison
e09d8a304c Clarified a few items. 2006-04-06 07:54:03 +00:00
Wayne Davison
2a7d9fe9b8 A slightly better fix than the last version. 2006-04-06 07:38:54 +00:00
Wayne Davison
e63aeb6d68 Made log_initialised public. 2006-04-06 07:33:12 +00:00
Wayne Davison
077d5d4ebc There's no need for lp_load() to check am_daemon. 2006-04-06 07:28:22 +00:00
Wayne Davison
e2d774cdd7 Improved the bind()-failure message to mention what family failed. 2006-04-02 21:15:37 +00:00
Wayne Davison
415b598346 Got rid of duplicate rsync: prefix from an rsyserr() call. 2006-04-02 15:02:02 +00:00
Wayne Davison
69627d66f8 Improved a couple sentences. 2006-04-02 14:23:22 +00:00
Wayne Davison
ac98cd98e3 - Mention the logging fix for a single-use daemon.
- Mention the fatal error for when --daemon can't be honored.
2006-03-31 17:56:19 +00:00
Wayne Davison
91d324b4ea Log the connect message after calling log_init(). 2006-03-31 17:37:21 +00:00
Wayne Davison
89fb50263b - Complain if the user specified --delete without -r or -d.
- Got rid of the saw_delete_* vars.
2006-03-28 23:09:36 +00:00
Wayne Davison
e257c6c20b Use the regular delete* vars instead of the saw_delete* vars
(which are no longer around).
2006-03-28 23:09:07 +00:00
Wayne Davison
43eae40e45 Include the version number when we exit with an error or warning. 2006-03-28 18:23:24 +00:00
Wayne Davison
920240a687 - Mention two omitted --files-from bug-fixes.
- Added a place-holder release line for 2.6.8.
2006-03-28 16:49:23 +00:00
Wayne Davison
f8b9da1a2c Output the who_am_i() info in the "unknown message" error. 2006-03-28 06:12:18 +00:00
Wayne Davison
3c987ee956 Mention latest tweaks. 2006-03-22 18:26:44 +00:00
Wayne Davison
5c6d46329b If open_socket_in() fails, we now log the reasons why. 2006-03-22 17:48:59 +00:00
Wayne Davison
8b3e964d14 Mention the new support/file-attr-restore script. 2006-03-21 18:11:43 +00:00
Wayne Davison
91a93df049 A nice file-attribute maintenance script that lets you restore
permissions, ownership, and group-info on files that may be
different than the originals.
2006-03-21 18:06:26 +00:00
Wayne Davison
19826af5f0 Fixed a few things that looked like yodl macros but were not. 2006-03-21 03:45:03 +00:00
Wayne Davison
49f4cfdf39 Improved a few things that a more modern yodl complained about. 2006-03-21 03:41:00 +00:00
Wayne Davison
b3222792ad Changed where ITEM_REPORT_ATIME goes in the list. 2006-03-17 23:57:19 +00:00
Wayne Davison
0640710115 Go ahead and define upcoming ITEM_REPORT_* defines now. 2006-03-17 21:59:25 +00:00
Wayne Davison
fa65989a8b Added support for using solaris's "setfacl -s" in place of
GNU's "setfacl -k".
2006-03-16 21:37:18 +00:00
Wayne Davison
4209f079dd Make sure that the --relative test creates the implied directories
with user-write permission, and turns any symlinks in the implied
dirs into real dirs.
2006-03-16 20:02:36 +00:00
Wayne Davison
a7704777ce An extra safeguard for msg2sndr_flush(). 2006-03-16 10:08:08 +00:00
Wayne Davison
7d51b8374d Made the new msg2sndr handling even better. 2006-03-16 09:57:32 +00:00
Wayne Davison
a27042b521 Mention fix for stunnel-using rsync. 2006-03-16 03:18:16 +00:00
Wayne Davison
5b51c893c5 Optimized the reacquisition of the code value from the msg2sndr list. 2006-03-16 02:26:27 +00:00
Wayne Davison
408e69396c Fixed the reacquisition of the code value from the msg2sndr list. 2006-03-16 01:27:26 +00:00
Wayne Davison
954bbed84a - Optimized the msg_list_item structure to make the buffer an
integral part of the structure instead of pointer to a
  separately allocated buffer.
- Improved the code that was ensuring that no messages from the
  receiver could be merged into the middle of a partially written
  buffer from the generator.  The new code ensures that we never
  avoid reading the messages from the receiver (like we used to).
  This ensures that the generator will not hang when the receiver
  got a read error on the socket, sent us a message about it, but
  the socket in the generator never becomes writable for it to get
  a similar error (now we are assured of getting the receiver's
  note about their read error, and we know to shut things down).
2006-03-16 00:57:54 +00:00
Wayne Davison
7c329ec72c Mention the log-file.diff. 2006-03-15 18:47:31 +00:00
Wayne Davison
07a8a360a5 Got rid of an errant newline. 2006-03-15 16:54:13 +00:00
Wayne Davison
1618c9e6d1 Improved the regex to match syslog lines and be easier to read. 2006-03-13 16:45:24 +00:00
Wayne Davison
ba0147ac42 Changing the version to 2.6.8cvs. 2006-03-13 16:44:47 +00:00
Wayne Davison
9e88f057b4 Starting the news for 2.6.8. 2006-03-13 16:42:50 +00:00
Wayne Davison
f171bf5b8f Rolling over the NEWS from 2.6.7. 2006-03-13 16:42:33 +00:00
Wayne Davison
1b1628b90a Fixed a bug where the NEWS file got an extra newline inserted when
the release date was added.  Changed "ln -f" to "cp -p" because
samba.org doesn't allow ln to be used at the moment.
2006-03-13 16:42:08 +00:00
Wayne Davison
50cf25672e Added a test of a simple exclude when --relative is enabled. 2006-03-13 01:57:13 +00:00
Wayne Davison
b316862831 Fixed a problem when copying an absolute source path with
the --relative option enabled.
2006-03-13 01:56:19 +00:00
Wayne Davison
38a4b9c297 Block-quote the itemized list in the --stats section so that
it is indented in the manpage.
2006-03-13 00:45:07 +00:00
Wayne Davison
a058cbc410 Preparing for release of 2.6.7 2006-03-11 18:43:42 +00:00
Wayne Davison
1ef7913497 Mention solo-dir fix for a dir without S_IWUSR. 2006-03-11 17:59:37 +00:00
Wayne Davison
88a16c8b4f Don't force S_IWUSR on a solo directory transfer. 2006-03-10 15:57:03 +00:00
Wayne Davison
8030b28ff8 Make extra sure that authbuf can't overflow. 2006-03-07 08:46:29 +00:00
Wayne Davison
1c598b1db8 Mention fix for Proxy-Authorization header. 2006-03-06 18:28:06 +00:00
Wayne Davison
6854bf69a8 Call base4_encode() with "1" for its new "pad" arg so that the
Proxy-Authorization header is properly padded with trailing '='
chars.
2006-03-06 18:22:26 +00:00
Wayne Davison
293def601d The base4_encode() function now takes a "pad" arg which indicates
if the caller wants to pad the value with trailing '=' chars.
2006-03-06 18:22:20 +00:00
Wayne Davison
651dc65efc Tweaked the mode of the files in the tar file. 2006-03-04 08:21:58 +00:00
Wayne Davison
c2b2bd6a93 Since the samba.org rsync is so old that it doesn't handle
out-of-order hard-linked files, changed the script to do the
hard-linking manually.
2006-03-02 23:42:56 +00:00
Wayne Davison
e32a48d256 Preparing for release of 2.6.7pre3 2006-03-02 22:49:27 +00:00
Wayne Davison
b5cf121d70 Mention the get_local_name() change. 2006-03-02 03:56:14 +00:00
Wayne Davison
44c26bf2a1 Don't allow overwriting a non-directory with a directory (just
like cp).
2006-03-02 03:53:42 +00:00
Wayne Davison
cc8c5057fe If get_local_name() fails to stat() the destination for any
reason other than the destination does not exist, mention the
error and exit.
2006-03-02 03:40:09 +00:00
Wayne Davison
b4c7c1ca99 A couple more improvements for --list-only. 2006-03-01 01:04:57 +00:00
Wayne Davison
16d3b31b2c Improved a couple sentences. 2006-03-01 00:59:22 +00:00
Wayne Davison
89a8180c5e One more bugfix. 2006-02-28 21:48:45 +00:00
Wayne Davison
34f961bbf3 Got the order of s1 and s2 right in the debug output. 2006-02-28 21:48:15 +00:00
Wayne Davison
2384f9e1db Update for hash-table change. 2006-02-28 21:21:44 +00:00
Wayne Davison
48cce779a2 Decided to drop the dynamically sized hash table for now. This was
due to timing tests showing that the per-byte modulus calculation
slowed down regular sized files.  Kept the other improvements
because they lessened our memory use and actually sped up the code.
2006-02-28 21:20:08 +00:00
Wayne Davison
6820753732 Renamed sum_table -> hash_table. 2006-02-28 07:32:48 +00:00
Wayne Davison
fbbe9a016d Changed the name of GETTAG() to SUM2HASH(). 2006-02-28 01:00:03 +00:00
Wayne Davison
c64ca7ef58 Eliminated one variable from hash_search(). 2006-02-28 00:31:51 +00:00
Wayne Davison
900cfcb584 - Fixed a problem with the new gettag2() macro by getting rid of the
need for it.
- Fixed a really old bug in the verbose output where it would output
  the wrong sum value (off by one).
- Renamed the tag_hit variables & debug output to hash_hit.
2006-02-28 00:09:19 +00:00
Wayne Davison
beab3078d6 Added --no-H and --no-hard-links. 2006-02-27 23:35:18 +00:00
Wayne Davison
530a2199da Mention the hash table change. 2006-02-27 21:29:44 +00:00
Wayne Davison
d9bca0c32f This is Shachar Shemesh's patch for making the hash-table code
work better with large files.  I further modified it to eliminate
the extra level of indirectness (and the qsort()), which saves
memory.
2006-02-27 21:16:04 +00:00
Wayne Davison
d733de97f5 Added a "chain" item to the struct sum_buf. 2006-02-27 21:11:56 +00:00
Wayne Davison
f06c11ed40 Tweaked a sentence. 2006-02-27 20:53:35 +00:00
Wayne Davison
c638caa63e In read_sum_head(): if we read a negative checksum count, die
with an error.
2006-02-27 03:12:26 +00:00
Wayne Davison
d775372a34 Tweaked a sentence. 2006-02-24 19:50:22 +00:00
Wayne Davison
07affc3d93 Document the latest changes. 2006-02-24 17:58:24 +00:00
Wayne Davison
f2ebbebead - Document the new --copy-dirlinks option.
- Improved the docs for --no-implied-dirs and --keep-dirlinks
  (based on a patch from Matt).
- Improved a few other misc. sentences.
- Shuffled the order of a couple options.
2006-02-24 17:54:47 +00:00
Wayne Davison
a695b379b5 Make sure the receiver resets copy_dirlinks (so that it can't
affect the delete scan).
2006-02-24 17:54:41 +00:00
Wayne Davison
88c2190a7c - Got rid of unused externs.
- Added support for copy_dirlinks.
- Fixed a bug where --copy-links would not affect implied dirs
  unless --copy-unsafe-links was also specified.
2006-02-24 17:54:35 +00:00
Wayne Davison
2dbf36ef55 Added the new --copy-dirlinks (-k) option. 2006-02-24 17:54:30 +00:00
Wayne Davison
cca9208697 Got rid of unused externs. 2006-02-24 16:43:44 +00:00
Wayne Davison
aa37022ef7 A recently added stat() call needed to be do_stat(). 2006-02-24 09:35:47 +00:00
Wayne Davison
85c417579f Made create_directory_path() return -1 if it couldn't create some
portion of the filename's path.
2006-02-24 09:34:44 +00:00
Wayne Davison
baed67efc4 Need to define an orig_umask value now that utils.c uses it. 2006-02-24 01:56:29 +00:00
Wayne Davison
c5b7aa1532 The orig_umask value is now a mode_t. 2006-02-24 01:56:26 +00:00
Wayne Davison
904e5af128 The create_directory_path() function no longer takes a base_umask
arg.
2006-02-24 01:56:21 +00:00
Wayne Davison
a41d110647 - The orig_umask value is now a mode_t.
- Use CHMOD_BITS instead of 07777.
2006-02-24 01:56:18 +00:00
Wayne Davison
a92d6ff13c Moved the orig_umask variable's definition into main.c since it
has nothing to do with option settings.
2006-02-24 01:56:14 +00:00
Wayne Davison
05278935a3 - Call mkdir_defmode() instead of do_mkdir().
- Define orig_umask in this file, not options.c.
- Made orig_umask a mode_t, not an int.
2006-02-24 01:56:10 +00:00
Wayne Davison
a56cdef9b1 Call mkdir_defmode() instead of do_mkdir(). 2006-02-24 01:56:07 +00:00
Wayne Davison
e9357a2deb + Added mkdir_defmode().
+ Changed create_directory_path() to drop the (now) unneeded
  base_umask arg and to call mkdir_defmode().
2006-02-24 01:56:01 +00:00
Wayne Davison
8d94d27af0 Moved an extern into its proper place. 2006-02-24 01:39:10 +00:00
Wayne Davison
6f2a222c59 One more fuzzy tweak. 2006-02-23 20:29:55 +00:00
Wayne Davison
8470a515ef Some improved fuzzy-parent-dir logic. 2006-02-23 20:27:17 +00:00
Wayne Davison
06982ac43b Mention latest fixes. 2006-02-23 20:17:09 +00:00
Wayne Davison
865c3b5f92 The new fuzzy-dir logic once again avoids calling get_dirlist()
until a regular file is found in the current parent directory.
2006-02-23 20:00:48 +00:00
Wayne Davison
8c9e06d7b9 Fixed the creation of symlinks and devices when both --relative
and --no-implied-dirs are specified and the destination dir does
not yet exist.
2006-02-23 19:43:54 +00:00
Wayne Davison
a9cc128308 Renamed fuzzy_dirname -> parent_dirname. 2006-02-23 19:07:33 +00:00
Wayne Davison
ccb16b467b Make sure that the --fuzzy option's dir-scan doesn't generate an
I/O error when --no-relative is used and the destination dir does
not exist yet.
2006-02-23 18:58:30 +00:00
Wayne Davison
1e44aeb92a Mention the --list-arg change. 2006-02-23 00:43:17 +00:00
Wayne Davison
c897f7119a Document the revised --list-only behavior and the ability to use
rsync with one local source arg (i.e. no destination).
2006-02-23 00:40:58 +00:00
Wayne Davison
ee8e2b1547 Rsync no longer returns a usage error when used with one local
source arg and no destination: this now implies the --list-only
option, just like one remote source arg has always done.
2006-02-23 00:38:34 +00:00
Wayne Davison
5fa38cd679 - Improved the way we generate the tar file.
- The second run of verify-patches is in a better spot now.
- Made various improvements to the output.
2006-02-22 19:09:51 +00:00
Wayne Davison
65535b5482 Mentioned that the daemon now logs connections. 2006-02-21 17:19:49 +00:00
Wayne Davison
439a198d02 Log every connect to the daemon. 2006-02-21 17:09:23 +00:00
Wayne Davison
f041b02557 Added a comment. 2006-02-21 00:29:55 +00:00
Wayne Davison
4d8639eb2d A few more tweaks and fixes. 2006-02-20 19:58:06 +00:00
Wayne Davison
519c8de16f - Moved the checkout of the cvs source above the version prompting so
that we can use the version from the configure.in file to provide
  good default values for the user.
- When moving old tar/diff files into the old-* dirs, first hard-link
  them into place, then (if "live"), use rsync to update these new
  files on the server (which saves us later re-sending), and _then_
  delete the old names.
2006-02-20 19:36:56 +00:00
Wayne Davison
7f20af4674 Made the new warning more visible. 2006-02-20 18:35:41 +00:00
Wayne Davison
55d24e5fed Mention if any of the CVS files we're putting in the tar file
aren't up-to-date.
2006-02-20 18:34:27 +00:00
Wayne Davison
81f654e396 Mention a couple more bug fixes. 2006-02-20 18:03:55 +00:00
Wayne Davison
8f1dc165e2 A brief msleep() in option_error() may be helpful to ensure that
an option error always arrives intact from the remote rsync.
2006-02-20 17:58:13 +00:00
Wayne Davison
9a0cfff57f Don't try to obey bwlimit restriction until bwlimit_writemax is set.
This fixes a bug with option errors not getting reported because the
write code gets called with bwlimit != 0 and bwlimit_writemax == 0.
2006-02-20 17:50:36 +00:00
Wayne Davison
d749eb6896 When starting up a transfer, substitute the remember_children()
SIGCHLD handler in place of the minimal one that socket.c enabled.
2006-02-20 17:17:51 +00:00
Wayne Davison
6d59ac192b Made the formerly static sigchld_handler() available as a
public function named remember_children().
2006-02-20 17:16:21 +00:00
Wayne Davison
94d3725cf2 In dest_mode(), we now apply any "incoming chmod" changes from
the daemon.
2006-02-20 00:01:27 +00:00
Wayne Davison
8840ec0f49 Set a new daemon_chmod_modes pointer with the daemon's chmod
(incoming or outgoing) changes.
2006-02-20 00:00:35 +00:00
Wayne Davison
44a8e86d47 Mention the change in how "incoming chmod" works when --perms was
not specified.
2006-02-19 23:58:59 +00:00
Wayne Davison
73abdda442 Slightly tweaked the output in non-live mode. 2006-02-19 23:33:15 +00:00
Wayne Davison
15b03ab1a8 Changed parse_chmod() to return the pointer to the new items on
success.
2006-02-19 23:31:56 +00:00
Wayne Davison
dc5245679a Preparing for release of 2.6.7pre2 2006-02-19 16:21:30 +00:00
Wayne Davison
60414e5bce The tar command needed --no-recursion. 2006-02-19 16:14:39 +00:00
Wayne Davison
af40c7d667 The hide filter rule is no longer needed. 2006-02-19 16:05:08 +00:00
Wayne Davison
7eb2ecda0f Improved the description of a fix in 2.6.4. 2006-02-19 15:52:59 +00:00
Wayne Davison
6d12a859bc The perl script I use to create new rsync releases. This is an
adapted and extended version of an old shell script.
2006-02-18 21:27:54 +00:00
Wayne Davison
920071e242 A perl script I wrote to make a new "nightly" tar file and
maintain the nightly dir on samba.org.
2006-02-18 21:26:48 +00:00
Wayne Davison
2a24b4bd0c Some more refinement of the --checksum section. 2006-02-16 07:40:55 +00:00
Wayne Davison
a753502200 Don't try to help the ACKs for the --remove-sent-file option
when --delay-updates was specified.
2006-02-15 20:09:49 +00:00
Wayne Davison
8958fae362 One last change to make the --checksum distinction very clear. 2006-02-15 19:58:53 +00:00
Wayne Davison
e2d68210d7 Another attempt to make --checksum clearer. 2006-02-15 19:24:39 +00:00
Wayne Davison
99534debc8 Improved the --checksum description and mention our whole-file
checksum verification checksum is different.
2006-02-15 18:20:23 +00:00
Wayne Davison
5b98629747 Improved the while's logic in increment_active_files(). 2006-02-15 08:26:51 +00:00
Wayne Davison
42003f6af3 Mention the change to --remove-sent-files. 2006-02-15 08:16:42 +00:00
Wayne Davison
434573b226 Call increment_active_files() during the first phase of a transfer
where --remove-sent-files was specified.
2006-02-15 08:06:45 +00:00
Wayne Davison
d6081c829c Added increment_active_files() and decrement_active_files() which
allows the generator to ask us to limit the number of files that
are currently active in the transfer when --remove-sent-files is
enabled.
2006-02-15 08:05:31 +00:00
Wayne Davison
58718881ef - Changed "called" to "named".
- Fixed a filter option to have the right syntax.
- Mention --prune-empty-dirs in a couple more places.
2006-02-14 16:45:38 +00:00
Wayne Davison
ac669e8b92 Tweaked a comment. 2006-02-14 16:44:11 +00:00
Wayne Davison
567f1566a9 List more of the doc improvements, list some of the best diffs in
the patches dir, and unified the discussion of the "dest" options.
2006-02-13 18:45:04 +00:00
Wayne Davison
59a5687105 Modified the sentence about doc improvements. 2006-02-13 18:19:59 +00:00
Wayne Davison
7b13ff9704 Document what all the items in the --stats output mean. 2006-02-13 18:19:26 +00:00
Wayne Davison
5e7b826a4f Made the receiver count the size of symlinks in the total_size
value, just like the sender does.
2006-02-13 18:08:45 +00:00
Wayne Davison
cbc63b9b48 Added missing release-history lines for 2.6.6 and 2.6.7. 2006-02-12 19:15:35 +00:00
Wayne Davison
71a84cbab0 Mention the ignoring of SIGXFSZ. 2006-02-11 02:37:58 +00:00
Wayne Davison
55e54e464b We now ignore the SIGXFSZ signal (if it is defined). 2006-02-11 02:36:35 +00:00
Wayne Davison
467688dc06 More improvements for "--help", and a couple hyphenation fixes. 2006-02-11 00:02:15 +00:00
Wayne Davison
375d8f913b Added a backward-compatibility note about -h to the --help option
in the help text.
2006-02-11 00:01:22 +00:00
Wayne Davison
021849204a Fixed some typos, got rid of some extraneous spaces, got rid of
a hyphen in hard-link (since we consistently use it unhyphenated),
and refer to "unix" as "*nix".
2006-02-09 17:32:36 +00:00
Wayne Davison
b635f2e964 The -h was missing from the daemon's option summary. 2006-02-09 11:56:33 +00:00
Wayne Davison
1e2b96bbee - Improved the description of how 'D' because 'D' and 'S' for -i.
- Improved the --devices and --specials item, and moved it next to
  the --super item.
- Mention that "rsync -h" still works as before.
2006-02-09 10:25:25 +00:00
Wayne Davison
2857451ca2 Got rid of an statement that is no longer true. 2006-02-09 04:08:38 +00:00
Wayne Davison
2bc3835ee0 Preparing for release of 2.6.7pre1 2006-02-09 03:59:17 +00:00
Wayne Davison
4f417448b4 Updated the %i section. 2006-02-09 01:27:03 +00:00
Wayne Davison
503f163446 Decided against shortening the output of --itemize-changes. 2006-02-09 01:17:01 +00:00
Wayne Davison
f17e769e28 There's no need to send --size-only to a remote sender. 2006-02-09 01:15:04 +00:00
Wayne Davison
f65e6a1276 Tweaked the mention of --human-readable. 2006-02-08 17:03:00 +00:00
Wayne Davison
4c248a3615 Documented the change in the --human-readable option. 2006-02-08 16:54:10 +00:00
Wayne Davison
7794db7c0d Tweaked the --human-readable code to work with the new option parsing. 2006-02-08 16:52:51 +00:00
Wayne Davison
3ca9e5d8ad Changed -h to mean powers of 1000 when used once, and powers of 1024
when repeated.  Got rid of --si.
2006-02-08 16:52:25 +00:00
Wayne Davison
5ca8a90c24 Tweaked the name of one of dest_mode()'s args. 2006-02-08 02:34:06 +00:00
Wayne Davison
0679ac4ca9 Tweaked a comment. 2006-02-08 02:32:35 +00:00
Wayne Davison
20a0269782 Mention --dry-run doesn't force --verbose. 2006-02-07 20:08:30 +00:00
Wayne Davison
a892d905bb Don't force verbose for --dry-run; let the user decide. 2006-02-07 20:06:43 +00:00
Wayne Davison
bc880cb8d2 Don't look for $RSYNC_PARTIAL_DIR on the server side. 2006-02-07 19:12:37 +00:00
Wayne Davison
2243a9353e Clarified something in "incoming chmod". 2006-02-07 18:45:16 +00:00
Wayne Davison
10f994a52a Moved the delay-bit functions into util.c, making them more generic. 2006-02-07 18:15:51 +00:00
Wayne Davison
0f86c74eba Call renamed cmp_time() function (was cmp_modtime()). 2006-02-07 18:15:46 +00:00
Wayne Davison
c2b5407678 - Renamed cmp_modtime() -> cmp_time().
- Moved the delay-bit functions here from receiver.c and transformed
  them into some more generic "bitbag" functions.
2006-02-07 18:15:37 +00:00
Wayne Davison
350879d8d1 Only call the just-added "touch" if autoheader succeeded. 2006-02-07 17:30:35 +00:00
Wayne Davison
a6a276027c Changed --8-bit to --8-bit-output. 2006-02-06 18:51:25 +00:00
Wayne Davison
45b79c8959 Mentioned --8-bit (-8). 2006-02-06 18:45:48 +00:00
Wayne Davison
d0022dd908 Document --8-bit (-8). 2006-02-06 18:43:12 +00:00
Wayne Davison
e0f4a661be Don't setup ic_chck if --8-bit was specified. 2006-02-06 18:42:46 +00:00
Wayne Davison
507433f6ca Don't call isprint() if --8-bit was specified. 2006-02-06 18:42:02 +00:00
Wayne Davison
5974c662ff Added the --8-bit (-8) option. 2006-02-06 18:41:32 +00:00
Wayne Davison
aa0bec8a52 Ensure that the timestamp for config.h.in is changed after
running autoheader.
2006-02-06 18:27:45 +00:00
Wayne Davison
2d2f71fb27 Got rid of a newly-added trailing tab. 2006-02-06 18:00:37 +00:00
Wayne Davison
36f59b5802 Mention the new output-escaping idiom and the multibyte support. 2006-02-06 17:58:29 +00:00
Wayne Davison
7fc87d2daf Allow the iconv_open() call to fail since we can now fall-back on
isprint().  Got rid of the "646" mapping kluge too.
2006-02-06 16:55:01 +00:00
Wayne Davison
3648ab3a24 - The iconv-supporting code can now ask filtered_fwrite() to use
isprint() when iconv() could not be setup.
- Changed the output idiom for escaped chars to use \#123 instead
  of \0123 because that makes it possible for a script to know for
  sure what version of rsync did the output (and thus, what the
  unescape rules are).
2006-02-06 16:54:12 +00:00
Wayne Davison
7a9d183fc4 Have default_charset() try mapping "646" -> "ASCII" instead of "ascii". 2006-02-06 09:04:20 +00:00
Wayne Davison
2a62f5ee19 Added "const" to the default_charset() return. 2006-02-06 09:00:37 +00:00
Wayne Davison
f9cfaae952 Solaris 9 and HP-UX 11.11 need us to look for libiconv_open,
not iconv_open (perhaps because iconf.h wasn't included in
the autoconf test).
2006-02-06 08:57:16 +00:00
Wayne Davison
bd4576fe4b Check to see if we need to include the iconv library. 2006-02-06 08:35:18 +00:00
Wayne Davison
4e194bf178 Mention the prepare-source script and the changes in the patches
dir.
2006-02-06 07:57:03 +00:00
Wayne Davison
ef4e0d5e7e Added dependencies for proto.h. 2006-02-06 05:06:52 +00:00
Wayne Davison
e6d8e70925 The "proto" target now builds target "proto.h" from the new
prepare-source.mak makefile.
2006-02-06 04:54:30 +00:00
Wayne Davison
a6c5741c37 Changed the "proto" target to "proto.h". 2006-02-06 04:53:02 +00:00
Wayne Davison
3ea7fc6ccf Moved the targets "gen", "proto", and "man" to prepare-source.mak. 2006-02-06 04:09:48 +00:00
Wayne Davison
20926fbd63 An easy way to run all the commands in prepare-source.mak. 2006-02-06 04:08:14 +00:00
Wayne Davison
2a3f3ba45d Moved the rules for generating files such as configure, config.h.in,
proto.h, and the manpages into this separate makefile, allowing it to
be used without first running configure (which builds the Makefile).
2006-02-06 04:07:49 +00:00
Wayne Davison
662127e6c7 Include --no-g in the popt-alias example in --perms. 2006-02-05 15:31:31 +00:00
Wayne Davison
0be05d6038 In default_charset(): if nl_langinfo() gives us "646", return "ascii". 2006-02-05 07:20:10 +00:00
Wayne Davison
1f77038ef2 Added a missing comma. 2006-02-05 07:00:21 +00:00
Wayne Davison
77ed253c73 Some more improvements to --perms and --executability from Matt and me. 2006-02-05 06:40:18 +00:00
Wayne Davison
b988781801 Allow itemize() to flag ITEM_REPORT_PERMS anytime the permissions
change (even if -p or -E aren't set).
2006-02-05 06:13:34 +00:00
Wayne Davison
595251de24 Make sure that we don't try to use iconv() without iconv.h. 2006-02-05 04:52:11 +00:00
Wayne Davison
c85631421d Changed HAVE_ICONV to HAVE_ICONV_OPEN. 2006-02-05 04:45:23 +00:00
Wayne Davison
12c8cd02fc Switched back to checking for iconv_open() due to HP-UX. 2006-02-04 23:06:39 +00:00
Wayne Davison
9656de5d13 Call setup_iconv(). 2006-02-04 22:03:44 +00:00
Wayne Davison
9a31746b10 Use iconv() (when available) to allow us to output multibyte
characters that are legal in the current locale.
2006-02-04 22:03:39 +00:00
Wayne Davison
ceccbacc34 The new function setup_iconv() initializes the ic_chck var. 2006-02-04 22:03:33 +00:00
Wayne Davison
ff2e2ccfc1 - Changed the check for iconv_open() to just iconv().
- Got rid of the --enable-iconv option for now.
2006-02-04 22:03:21 +00:00
Wayne Davison
12bda6f710 Don't do so much memory copying in mplex_write(). 2006-02-04 21:52:32 +00:00
Wayne Davison
c53b6fd0ac In the compatibility comments: mention why we don't use grep -q. 2006-02-04 19:44:19 +00:00
Wayne Davison
b31243b472 Test directory setgid inheritence when --perms is not in effect. 2006-02-04 19:42:47 +00:00
Wayne Davison
c8d19f90a6 Added a missing '(' in the opening comments. 2006-02-04 19:29:13 +00:00
Wayne Davison
114bafe0d0 Added a special permission (o+t) to one of the files in the test. 2006-02-04 19:28:45 +00:00
Wayne Davison
5ef8c5c6d4 Tweaked a function declaraion. 2006-02-04 19:27:07 +00:00
Wayne Davison
9b499e9537 - When not preserving permissions, ensure that a newly-created
directory's inherited sgid bit is preserved.
- When not preserving permissions, ensure that newly-created
  files/dirs don't inherit any special permissions.
2006-02-04 19:09:46 +00:00
Wayne Davison
00f00f846b Ignore setfacl unless it tells us that it supports the -k option. 2006-02-04 18:41:47 +00:00
Wayne Davison
998113fedf Needed to make %G output "DEFAULT" when gid == GID_NONE. 2006-02-04 18:40:41 +00:00
Wayne Davison
ee5544112a Improved the --partial-dir section. 2006-02-03 23:50:16 +00:00
Wayne Davison
7eaabd8fac Decided to undo the last change to avoid backward compatibility
inconsistencies (it would have been the right thing to do if it
were done that way from the start, but not now).
2006-02-03 23:40:37 +00:00
Wayne Davison
4fc808dd98 Avoid adding our own exclude of the partial-dir name if the
user's filter rules already match it.
2006-02-03 23:16:46 +00:00
Wayne Davison
7cfb250c93 Made the new %M escape handle multiple spaces in the timestamp
(which can occur if the user's system doesn't have strftime()).
2006-02-03 22:41:19 +00:00
Wayne Davison
47f480b619 Removed completed items. 2006-02-03 20:49:25 +00:00
Wayne Davison
fa9e950b1a Mention who is outputting the "rsync error" or "rsync warning". 2006-02-03 20:39:58 +00:00
Wayne Davison
49f4d850ce Mention latest changes. 2006-02-03 20:32:27 +00:00
Wayne Davison
b3e15181ae Log when someone requests a module list. 2006-02-03 20:28:19 +00:00
Wayne Davison
aca5500aea Document the new "log format" options: %M (modtime), %U (uid),
%G (gid), and %B (perm bits).
2006-02-03 20:00:24 +00:00
Wayne Davison
427b6179b9 - Allow tab characters to appear in rwrite() messages.
- Added %M (modtime), %U (uid), %G (gid), and %B (perm bits) to
  log_formatted().
2006-02-03 19:59:25 +00:00
Wayne Davison
afa73c75b5 A minor optimization to timestring. 2006-02-03 19:40:16 +00:00
Wayne Davison
8261af7422 Allow sigaction() to be used even if sigprocmask() isn't around
(or was manually disabled).
2006-02-03 18:48:26 +00:00
Wayne Davison
44e604f416 Simplified the conditional prior to the SIGACTION code. 2006-02-03 18:46:38 +00:00
Wayne Davison
5173f99e68 A slight tweak to the conditionalized definition of SIGACTION(). 2006-02-03 18:34:09 +00:00
Wayne Davison
8a3d4658eb Decided I don't like "set -x". 2006-02-03 17:58:48 +00:00
Wayne Davison
6b43924848 The calls to check_perms now pass a test number arg and
don't check for failure (it will die on failure).
2006-02-03 17:55:24 +00:00
Wayne Davison
eace352b39 Improved check_perms() to work with a directory, to have better
output on error, and to call test_fail on error.
2006-02-03 17:54:18 +00:00
Wayne Davison
fdbe8989fe Moved check_perms() into rsync.fns and tweaked how it is called. 2006-02-03 17:29:43 +00:00
Wayne Davison
18d7e9f46e Added a new function: check_perms(). 2006-02-03 17:28:03 +00:00
Wayne Davison
c6fbd563d8 Matt's executability test with a few tweaks (e.g. to avoid using
"stat").
2006-02-03 06:47:26 +00:00
Wayne Davison
a5df33bb62 Scratch-dir normalization from Matt: turn off any default ACLs (if
setfacl is available) and disable any directory setgid bit to avoid
confusing some tests.
2006-02-03 06:15:46 +00:00
Wayne Davison
5cf4896050 Mention the sigaction() and sigprocmask() goodness. 2006-02-02 22:38:55 +00:00
Wayne Davison
2fb450bd99 Fixed a hang. 2006-02-02 22:34:30 +00:00
Wayne Davison
4ea58045e2 Moved the potential disabling of __attribute__ above the
relocated UNUSED() define.
2006-02-02 22:24:33 +00:00
Wayne Davison
29433538ff Tweaked a couple lines in the code that handles --version. 2006-02-02 11:40:32 +00:00
Wayne Davison
d382140904 Changed default logfile setting from /var/adm/rsyncd.log to
/var/log/rsyncd.log.
2006-02-02 10:20:13 +00:00
Wayne Davison
b8e9c234e6 Changed sig_int() to use a standard signal-handler prototype. 2006-02-02 02:39:40 +00:00
Wayne Davison
60ee01f517 - Call SIGACTION() instead of signal().
- Umask all the signals we need using sigprocmask() (if available).
2006-02-02 02:39:29 +00:00
Wayne Davison
2b28968dfb Call SIGACTION() instead of signal(). 2006-02-02 02:39:25 +00:00
Wayne Davison
90b13cf606 - Moved definition of UNUSED() above inclusion of proto.h.
- Replaced definition of SIGNAL_CAST with new SIGACTION() define,
  which will use sigaction() if it is available, else signal().
2006-02-02 02:39:19 +00:00
Wayne Davison
d81894fc21 Added checks for sigaction() and sigprocmask(). 2006-02-02 02:32:39 +00:00
Wayne Davison
f5cbae9329 Look for public functions that return RETSIGTYPE. 2006-02-02 02:29:30 +00:00
Wayne Davison
7a6653bc6c Ignore the --quiet option if someone sent it to us (which doesn't
happen when talking to a normal client).
2006-02-01 19:36:37 +00:00
Wayne Davison
72f2d1b384 When complaining about a socket-read problem, use an FSOCKERR
code instead of a normal FERROR.  The generator is the only
process that will receive this, and it uses it to close down
the multi-I/O over the socket so that it won't ever hang trying
to write an error down a dead socket.
2006-02-01 19:35:17 +00:00
Wayne Davison
b66e31bf15 Turn an FSOCKERR into a normal FERROR if it's not going to our
sibling.
2006-02-01 19:33:12 +00:00
Wayne Davison
ea26c854af Added FSOCKERR and MSG_SOCKERR (a sibling-only message). 2006-02-01 19:26:34 +00:00
Wayne Davison
ef1f62807e We should be using wait_process(), not waitpid() directly. 2006-02-01 19:25:34 +00:00
Wayne Davison
d8aeda1e50 Changed a few "ret" variables to have better names. 2006-02-01 19:24:28 +00:00
Wayne Davison
07efba8ec0 The itemize() output now mentions -E permissions changes. 2006-01-31 06:25:46 +00:00
Wayne Davison
2959fe7447 Mention the --executability option. 2006-01-31 03:40:22 +00:00
Wayne Davison
4601589720 Another help-text tweak. 2006-01-31 03:11:07 +00:00
Wayne Davison
9f8225566e Moved where --chmod was listed. 2006-01-31 03:05:24 +00:00
Wayne Davison
5e65c96705 Moved --chmod in the help output. 2006-01-31 03:04:00 +00:00
Wayne Davison
a9d6e6fcac When permissions aren't being preserved, set them via the new
dest_mode() function.
2006-01-31 02:30:09 +00:00
Wayne Davison
860dcf68ad Got rid of the orig_umask-based file->mode tweak in receive_file()
(which got moved into the dest_mode() function).
2006-01-31 02:30:05 +00:00
Wayne Davison
812848323b Added the dest_mode() function: it figures out the permissions for
a file when we aren't preserving permissions, including the honoring
of the new --executability option.
2006-01-31 02:30:02 +00:00
Wayne Davison
344f9ba7fa Added the --executability (-E) option. 2006-01-31 02:29:58 +00:00
Wayne Davison
2d5279ac9a Documented the new --executability (-E) option, with improvements
to the --perms and --chmod sections as well.
2006-01-31 02:29:55 +00:00
Wayne Davison
fa3e4a0548 Mention the chmod utility's manpage number. 2006-01-31 02:26:49 +00:00
Wayne Davison
656c20715e Mention that --chmod's work can still be masked by the receiving
end's umask when permissions are not being preserved.
2006-01-30 22:10:33 +00:00
Wayne Davison
a72885e042 Mention files-to-excludes. 2006-01-30 21:54:00 +00:00
Wayne Davison
b587adda1f This perl script automates the conversion of a list of pathnames
to a set of includes/excludes needed for rsync to copy just the
listed files.
2006-01-30 21:52:17 +00:00
Wayne Davison
50fd4832c2 Mentioned the new "outgoing chmod" daemon option. 2006-01-30 21:47:23 +00:00
Wayne Davison
c094d9320d Documented the new "outgoing chmod" daemon option. 2006-01-30 21:47:08 +00:00
Wayne Davison
aaccaa887d Added support for the new "outgoing chmod" daemon option. 2006-01-30 21:47:02 +00:00
Wayne Davison
5481e42cd6 Mentioned the early-EOF bugfix (which was fixed a while ago). 2006-01-30 20:09:46 +00:00
Wayne Davison
b3964d1d86 Improved the documentation for --force. 2006-01-30 18:46:17 +00:00
Wayne Davison
e35d9f2d6d I realized that there were instances where --force could still be
required to be combined with a delete option (if a non-dir was
overwriting a dir in a directory that was not included in the
transfer), so I extended the change I just made for --delete-after
to include all delete modes.
2006-01-30 18:45:57 +00:00
Wayne Davison
4d16780366 Allow --force to work even if --recurse was not specified. 2006-01-30 18:35:54 +00:00
Wayne Davison
1661fe9b0c Made get_dirlist() always include directories. 2006-01-30 18:32:47 +00:00
Wayne Davison
63344ad4e1 Mention the latest improvements. 2006-01-30 18:19:55 +00:00
Wayne Davison
90cf7d199f Allow a non-empty dir to be overwritten by a non-dir with all the
delete options (--delete-after used to require --force).
2006-01-30 18:14:02 +00:00
Wayne Davison
730df9d222 If the module has defined an "incoming chmod" option, call
parse_chmod() on it.
2006-01-30 17:53:38 +00:00
Wayne Davison
882d8c1cab Added the "incoming chmod" config option. 2006-01-30 17:53:32 +00:00
Wayne Davison
17af842d2d Document the new "incoming chmod" config option. 2006-01-30 17:53:27 +00:00
Wayne Davison
bbe42182df Call the parse_chmod() with its new syntax. 2006-01-30 17:53:19 +00:00
Wayne Davison
81b096feef Changed the way the parse_chmod() function is called. 2006-01-30 17:53:13 +00:00
Wayne Davison
7627e92c54 Added extern for io_write_phase. 2006-01-30 17:39:43 +00:00
Wayne Davison
f7bce90cf0 - Got rid of the externs for io_read_phase and io_write_phase.
- Added stub definition for chmod_mode_struct.
2006-01-30 17:39:34 +00:00
Wayne Davison
b33ce4c800 Moved the filter_outfile() function to rsync.fns. 2006-01-30 08:12:17 +00:00
Wayne Davison
757287d8a5 Moved the filter_outfile() function here since it was identical
in devices.test and itemize.test.
2006-01-30 08:11:50 +00:00
Wayne Davison
3ed8eafccb The robust_rename() function now takes a "partialptr" arg that, if
non-NULL, will be used if we are forced to copy the file.
2006-01-30 07:18:16 +00:00
Wayne Davison
d8b1c923ef The finish_transfer() function now takes a "partialptr" arg that, if
non-NULL, will be used if robust_rename() is forced to copy the temp
file.
2006-01-30 07:18:13 +00:00
Wayne Davison
4a4d2b1ba0 Call finish_transfer() with a valid partialptr string, when
appropriate.
2006-01-30 07:18:10 +00:00
Wayne Davison
12fa790ea0 Call finish_transfer() with its newly-added arg. 2006-01-30 07:18:06 +00:00
Wayne Davison
21955d9c92 Call robust_rename() with its newly-added arg. 2006-01-30 07:18:03 +00:00
Wayne Davison
a0d9819f8c Document the side-effect that --partial-dir can have on --temp-dir. 2006-01-30 07:18:00 +00:00
Wayne Davison
a9af5d8eba More improvements to --temp-dir. 2006-01-30 06:34:57 +00:00
Wayne Davison
65854cf91a Changed the mode arg from an int to a mode_t. 2006-01-30 00:39:59 +00:00
Wayne Davison
9ec1ef2535 Improved the --temp-dir description and a couple other sentences. 2006-01-29 20:31:59 +00:00
Wayne Davison
36119f6e2a - Renamed set_perms() to set_file_attrs().
- Use the renamed PERMS_* defines: ATTRS_*.
2006-01-29 20:30:24 +00:00
Wayne Davison
e912bd4dfb - Use the renamed PERMS_* defines: ATTRS_*.
- Call the new name of set_perms():  set_file_attrs().
2006-01-29 20:30:18 +00:00
Wayne Davison
c3ef136d41 Call the new name of set_perms(): set_file_attrs(). 2006-01-29 20:30:12 +00:00
Wayne Davison
8eda7a4bb8 Renamed the PERMS_* defines to ATTRS_* defines. 2006-01-29 20:30:07 +00:00
Wayne Davison
78d146e866 Use PERMSTRING_SIZE rather than a hard-wired "11". 2006-01-29 20:30:02 +00:00
Wayne Davison
77860bacd0 No need to send --partial when we're the receiver. 2006-01-29 19:17:13 +00:00
Wayne Davison
63cf5ae72c Made a bunch of char* args const. 2006-01-29 18:52:53 +00:00
Wayne Davison
120cde9562 Avoid forwarding the --temp-dir option to the server when we're
the receiver.
2006-01-29 07:19:38 +00:00
Wayne Davison
e6ffb966dd Made the new --prune-empty-dirs code a little more memory efficient. 2006-01-28 19:20:02 +00:00
Wayne Davison
207522aef5 Tweaked a variable name in flist_find(). 2006-01-28 08:12:16 +00:00
Wayne Davison
a1cc199b34 We enforce at least protocol 29 for --prune-empty-dirs because the
file-list's sort order can be slightly wrong in older versions.
2006-01-28 07:40:52 +00:00
Wayne Davison
c22260706c Don't add the "protect" filter rule for backup-suffix filenames
if --backup was not specified.
2006-01-28 01:55:55 +00:00
Wayne Davison
d5782b52a2 - We need to send exclude info from the client to a server-receiver
when --prune-empty-dirs was specified.
- Changed the output of debug include/exclude/show/hide/risk/protect
  messages to use the appropriate filter terminology instead of
  always using the (potentially unclear) include/exclude terms.
2006-01-28 00:14:02 +00:00
Wayne Davison
85aecef6c3 The user can now use a "protect" filter to avoid pruning one or
more empty directories when --prune-empty-dirs is in effect.
2006-01-28 00:13:59 +00:00
Wayne Davison
876c993680 Changed --skip-empty-dirs (-k) to --prune-empty-dirs (-m). 2006-01-28 00:13:55 +00:00
Wayne Davison
a272ff8c1b Changed --skip-empty-dirs (-k) to --prune-empty-dirs (-m) and
improved the docs a bit more, including documenting how "protect"
filtering affects empty dirs.
2006-01-28 00:13:52 +00:00
Wayne Davison
7402d58369 Improved flist_find()'s empty-entry handling to deal with the case
where more entries may have been removed since the last find.
2006-01-27 14:29:58 +00:00
Wayne Davison
c0b134a445 Optimized flist_find() so that we never scan a series of empty
file-list items twice (which can be very important with the new
--skip-empty-dirs option).  Also optimized the code that strips
root slashes in clean_flist().
2006-01-27 12:59:07 +00:00
Wayne Davison
a324d49bfc Mention the --skip-empty-dirs option. 2006-01-27 01:20:11 +00:00
Wayne Davison
9c000f5e7b Implement the new --skip-empty-dirs (-k) option. 2006-01-27 00:32:57 +00:00
Wayne Davison
0e887ef29a Added the --skip-empty-dirs (-k) option. 2006-01-27 00:32:53 +00:00
Wayne Davison
fb72aaba48 Document the new --skip-empty-dirs (-k) option. 2006-01-27 00:32:49 +00:00
Wayne Davison
a3869e9227 Include popt.h using <popt.h> instead of "popt.h". 2006-01-26 22:32:59 +00:00
Wayne Davison
d671ccfc8e Mention the change in the --itemize-changes output. 2006-01-26 22:32:18 +00:00
Wayne Davison
35bf8fa084 - Include popt.h using <popt.h>, not "popt.h".
- A minor twiddle in server_options().
2006-01-26 22:28:08 +00:00
Wayne Davison
f7916cbf3f Mention --sockopts and an improvement to the testsuite environment. 2006-01-26 22:10:08 +00:00
Wayne Davison
2b7dab686c The setting of HOME got moved to rsync.fns. 2006-01-26 21:23:25 +00:00
Wayne Davison
a98cad00eb Set $HOME to $scratchdir so that our tests are not affected by
anything unexpected, such as a ~/.popt file.
2006-01-26 21:22:57 +00:00
Wayne Davison
facdce2c1f Fixed two typos. 2006-01-26 12:41:52 +00:00
Wayne Davison
34937987a6 Make use of the new sockopts variable. 2006-01-26 12:31:47 +00:00
Wayne Davison
831f06a5a5 Added the --sockopts option. 2006-01-26 12:31:24 +00:00
Wayne Davison
5fe3c86f25 Mention the --sockopts option. 2006-01-26 12:31:14 +00:00
Wayne Davison
04f48837d1 Document the new --sockopts option. 2006-01-26 12:30:20 +00:00
Wayne Davison
f5b14759fb Mentioned the --super option. 2006-01-26 11:14:10 +00:00
Wayne Davison
def97ff9a9 Added the --super option. 2006-01-26 11:10:32 +00:00
Wayne Davison
d38772e06f Document the new --super option and how it affects other options. 2006-01-26 11:10:28 +00:00
Wayne Davison
351f5e2f6c Check MY_UID() directly instead of accessing am_root. 2006-01-26 11:01:00 +00:00
Wayne Davison
8778174936 Mention new --specials option and --devices change. 2006-01-26 10:50:18 +00:00
Wayne Davison
e5f6a04d15 The itemized output for the fifo changed. 2006-01-26 10:39:04 +00:00
Wayne Davison
f8d47c1cb4 Added 'S' to the itemized output for special files. 2006-01-26 10:39:01 +00:00
Wayne Davison
b5c6a6aeeb Handle separated devices and special files. 2006-01-26 10:38:58 +00:00
Wayne Davison
4e7d07c8d4 Document the new --specials option and how -D and --devices now work. 2006-01-26 10:38:54 +00:00
Wayne Davison
fc2dd77ec7 One more minor tweak. 2006-01-25 17:34:39 +00:00
Wayne Davison
7b6fa00ff8 Decided to hold off on the potential memory savings of indexed
uid/gid pairs until the next release.
2006-01-25 17:10:29 +00:00
Wayne Davison
9ac3591366 Added testing of the --itemize-changes output for devices. 2006-01-24 22:23:51 +00:00
Wayne Davison
6a819e02da Changed to handle removed 'a' slot in %i output. 2006-01-24 22:23:14 +00:00
Wayne Davison
4cff7c50db Fixed a problem in the output of %i's 'T' flag on devices and
got rid of the unused 'a' flag.
2006-01-24 22:22:17 +00:00
Wayne Davison
669302a172 Got rid of the description of 'a' in the %i flags. 2006-01-24 22:14:40 +00:00
Wayne Davison
c738605098 Got rid of some debug code. 2006-01-24 21:40:43 +00:00
Wayne Davison
90cf838b18 Dump some debug code. 2006-01-24 21:39:10 +00:00
Wayne Davison
67e4043e8c Optimized id_pair() so that clumps of IDs get handled more
efficiently.
2006-01-24 19:39:09 +00:00
Wayne Davison
5e58e3f9cf The uid & gid are now stored using an id_pair structure. 2006-01-24 19:02:55 +00:00
Wayne Davison
49140b27c6 Another small improvement to the --one-file-system option. 2006-01-24 19:02:48 +00:00
Wayne Davison
9cdadbb13a The in_del_hier code needs to use lastname instead of thisname
because the latter gets cleaned and (possibly) sanitized.
2006-01-24 17:26:24 +00:00
Wayne Davison
0ace7b2567 FERROR messages also need to leave leading newlines unmangled. 2006-01-24 01:07:19 +00:00
Wayne Davison
ccb8f5788b Tweaked the copyright message. 2006-01-23 18:48:12 +00:00
Wayne Davison
4e5baafedf More improvements to the -x option (some from Matt & some from me). 2006-01-22 21:04:21 +00:00
Wayne Davison
0e82af2d27 New -x code had some problems, so restore the old code for now
(keeping the more optimal stat() calling, though).
2006-01-22 20:37:00 +00:00
Wayne Davison
535737bf39 New -x code had some problems, so restore the old code for now. 2006-01-22 20:30:56 +00:00
Wayne Davison
6e6cc16399 Matt's disambiguation. 2006-01-21 21:02:13 +00:00
Wayne Davison
bb0d8edfad - Got rid of the filesystem_dev variable now that --one-file-system
is handled in a new way.
- Moved a stat out of delete_in_dir() into do_delete_pass() to make
  --delete-during more efficient.
- Added a missing "#ifdef SUPPORT_LINKS...#endif" block around some
  symlink code.
2006-01-21 20:59:19 +00:00
Wayne Davison
ebec5eb689 - Changed how --one-file-system works so that we can skip all mount
points (including "bind" mounts).
- The --chmod option now affects devices (only skipping symlinks).
2006-01-21 20:59:16 +00:00
Wayne Davison
5cb31dcf92 Fixed a problem with the FLAG_* defines. 2006-01-21 20:16:37 +00:00
Wayne Davison
0ccffd7c80 Disable popt aliases when we're a server so that any user-redefined
options can't cause a compatibility problem.
2006-01-21 20:15:49 +00:00
Wayne Davison
57b66a2458 A tweak to --dirs and --chmod. 2006-01-21 19:55:47 +00:00
Wayne Davison
b8a39ed58a Use the new saw_delete* variables to ensure that the server side
always reads the exclude information when it is present.
2006-01-21 19:54:14 +00:00
Wayne Davison
f5a910dd73 - We now set some saw_delete* vars to keep track of the case where
we disabled a delete option that the client sent us (since we may
  still need to await exclude information from the client in such a
  case).
- If -d and --delete are in effect without -r, we may need to send
  the -d to the server even if it was implied, and we may need to
  send --no-r to the server to ensure that we don't get into a
  protocol-corrupting situation should the remote rsync disable the
  --delete option (this works because the --no-r option was added in
  the same version as the functionality which allows --delete to
  work with -d sans -r.
2006-01-21 19:52:55 +00:00
Wayne Davison
e16adcdff3 - Allow multiple --chmod options to be specified.
- Call parse_chmod() with its new arg.
2006-01-21 09:14:42 +00:00
Wayne Davison
cf9b4794fd Tweaked parse_chmod() so that it takes a pointer to an existing list
of chmod items (or NULL) and appends the new items onto the end.
2006-01-21 09:14:39 +00:00
Wayne Davison
6d8c6bdbe5 Document the new --one-file-system behavior, with improvements to
the option's text taken from Matt's patch in bugzilla.
2006-01-21 08:10:45 +00:00
Wayne Davison
8bbe41b53b Handle the --chmod option as either the sender or the receiver so
that only the client needs to know about --chmod (but if an older
version sends the option to the server, we'll still handle it).
2006-01-21 08:03:18 +00:00
Wayne Davison
ba30fb5c3c For a local rsync, turn off the --chmod option on the receiving
side so that only the sending side does the work.
2006-01-21 07:58:35 +00:00
Wayne Davison
0938e8eee5 We don't ever need to send the --chmod option to the remote rsync. 2006-01-21 07:53:40 +00:00
Wayne Davison
3b17384631 Implemented the -xx behavior that skips mount-point dirs. 2006-01-21 01:20:03 +00:00
Wayne Davison
243c995f5f Allow the -x option to be repeated. 2006-01-21 00:36:15 +00:00
Wayne Davison
96b87581ff - Changed send_file_entry() into a static function again.
- Made send_file_entry() derive the base_flag value from *file.
- Added a flags arg to make_file().
- The flag we send to send_file_name() is a FLAG_* value, not an
  XMIT_* value.
2006-01-20 21:21:43 +00:00
Wayne Davison
3de73827d7 Call make_file() with one more arg (the base flags). 2006-01-20 21:21:36 +00:00
Wayne Davison
458aeea4a6 Mentioned the addition of -ii. 2006-01-20 19:33:24 +00:00
Wayne Davison
14cbb64539 Document the behavior of -ii. 2006-01-20 18:52:52 +00:00
Wayne Davison
a9e4762634 Handle the extra output needed when log_format_has_i > 1. 2006-01-20 18:49:38 +00:00
Wayne Davison
487094a0d7 Allow the --itemize-changes (-i) option to be repeated to indicate
that unchanged files should also be itemized.
2006-01-20 18:49:07 +00:00
Wayne Davison
f608ebb106 Got rid of unused function u_strcmp(). 2006-01-20 00:14:04 +00:00
Wayne Davison
87001ac6c2 Improved a sentence. 2006-01-19 21:21:28 +00:00
Wayne Davison
ede1f0ebc9 The code in send_file_list() needed a little more improvement to
handle --relative really well:
- We must set "is_dot_dir" when we strip off a trailing "/" or "/.".
- If a trailing "/" or "/." caused us to treat a symlink as a dir,
  we now pass our stat() info down to make_file() so that it will
  always treat the cleaned-up name as a dir too.
- We must not strip a leading "/".
- Improved the check for ".." elements in the implied dirs.
2006-01-19 21:16:44 +00:00
Wayne Davison
b435d7174c Added a new arg to the make_file() call. 2006-01-19 21:16:40 +00:00
Wayne Davison
2a59d2cc31 Another bugfix. 2006-01-19 19:05:49 +00:00
Wayne Davison
b8595e609a In delete_in_dir(), skip a directory that isn't really a directory on
the local disk (can easily happen if --dry-run was specified).
2006-01-19 18:53:48 +00:00
Wayne Davison
d37bc73a48 Mention the changes made in recent checkins. 2006-01-19 07:34:41 +00:00
Wayne Davison
1902a7652f When --relative is active, simply trim off trailing slashes and
dot dirs.  Also, reject a ".." dir if it would be sent as part
of the relative path.
2006-01-19 01:43:10 +00:00
Wayne Davison
6ab423a5b6 - Fixed the --help and --version output to avoid using embedded
newlines (which are no longer allowed in rprint()).
- Updated the Copyright info for 2006.
2006-01-17 04:26:12 +00:00
Wayne Davison
c2be690cc6 Got rid of a few empty lines. 2006-01-17 02:16:57 +00:00
Wayne Davison
f5a49d0e44 Got rid of a now-unused static variable. 2006-01-17 01:26:35 +00:00
Wayne Davison
03e23e0730 A few more items to check for, including libcharset.h, langinfo.h,
locale_charset(), and nl_langinfo().
2006-01-15 14:52:12 +00:00
Wayne Davison
eb598fac4f - Improved get_local_name() using ideas from Matt McCutchen's
version:  lots more comments, and a "local name" copy now
  does a chdir to the parent dir of the destination file.
- Moved the setlocale() call prior to the parse_arguments() call.
2006-01-15 07:11:23 +00:00
Wayne Davison
be0602ec3c - We now filter all rwrite() output when it goes out to the terminal
to make sure that it contains readable characters.
- Got rid of the buf[len] = '\0' in rwrite().
- Call f_name() with revised args (which also replaces f_name_to()).
2006-01-14 20:26:28 +00:00
Wayne Davison
6cbde57d88 Call f_name() with revised args (which also replaces f_name_to()). 2006-01-14 20:26:23 +00:00
Wayne Davison
5e4ff5f9c5 Merged f_name() with f_name_to(). 2006-01-14 20:26:20 +00:00
Wayne Davison
18e1289f27 Defined new FNAME logcode enum (only used on the client side when
logging a filename).
2006-01-14 20:26:17 +00:00
Wayne Davison
99aaa6ca25 Fixed a couple out-of-memory function-name strings in make_file(). 2006-01-14 17:19:12 +00:00
Wayne Davison
24172e4b2f If the --human-readable option is in effect, output the size of
each file in human-readable units instead of a raw byte count.
2006-01-14 17:10:52 +00:00
Wayne Davison
beaf495400 Added a "continue" missing from a recent change. 2006-01-14 00:29:50 +00:00
Wayne Davison
79f48760f3 Added --enable-iconv and cleaned up the other enable/disable options. 2006-01-13 23:05:16 +00:00
Wayne Davison
785abd4802 Got rid of the safe_fname() function and the calls to it. 2006-01-13 22:06:34 +00:00
Wayne Davison
0ee6ca9800 Got rid of calls to the (soon to vanish) safe_fname() function. 2006-01-13 22:06:31 +00:00
Wayne Davison
7543020807 Fixed a bug in the explode_mode code that was causing a crash
on BSD systems.
2006-01-13 21:40:26 +00:00
Wayne Davison
47b50b9bd0 We now use lib/compat.o when building wildtest. 2006-01-13 21:38:43 +00:00
Wayne Davison
45c49b52a4 Got rid of calls to (the soon to vanish) safe_fname() function. 2006-01-13 21:17:09 +00:00
Wayne Davison
0ee32c62d3 Improved a couple sentences. 2006-01-13 21:10:11 +00:00
Wayne Davison
70e98a4348 Changed RSYNC_ARGn to RSYNC_ARG#. 2006-01-12 19:35:54 +00:00
Wayne Davison
fddf529df9 Mention the new RSYNC_ARGn environment variables for pre-xfer exec. 2006-01-12 19:24:25 +00:00
Wayne Davison
141c62659e We now send all the option args to the pre-exec command. 2006-01-12 19:15:31 +00:00
Wayne Davison
61e16468f0 We need to call clearerr() when getc() returns EOF with errno == EINTR. 2006-01-06 22:20:07 +00:00
Wayne Davison
b74b3d538e + Changed two buffers to use BIGPATHBUFLEN instead of MAXPATHLEN+512.
+ Changed a strncpy() call into a (more appropriate) memcpy() call.
+ Made the ellipsis[] string static because some older compilers may
  not like the dynamic initialization of a character string.
+ Expanded some 1-line "case ... break;" statements onto separate
  lines.
2006-01-05 02:29:16 +00:00
Wayne Davison
d3db3eef1b Document the new "dir/***" feature. 2006-01-02 17:46:32 +00:00
Wayne Davison
90d5b12e72 Added a test for the new "dir/***" feature. 2006-01-02 17:46:27 +00:00
Wayne Davison
955a3a3ded We now test all the patterns using both a normal wildtest run and
a wildtest run with various -x and -e options.
2006-01-02 17:46:24 +00:00
Wayne Davison
aec75b037b Added -x and -e options, which are used to exercise wildmatch_array(). 2006-01-02 17:46:21 +00:00
Wayne Davison
e5daa2731a We use the new wildmatch_array() and litmatch_array() functions to
make our include/exclude code easier to read and maintain, and to
eliminate a buffer copy when handling an absolute-path pattern
(which eliminated the full_name[] buffer).  Also added handling
for the new MATCHFLG_WILD3_SUFFIX define that allows a string that
ends with "dir/***" to match the "dir" as well as its contents.
2006-01-02 17:46:18 +00:00
Wayne Davison
390621a7ab Added a new function, wildmatch_array(), that lets the caller pass
the text-string as an array of strings (with a terminating NULL
pointer at the end).  Also added litmatch_array(), which does a
literal match (no wildcards or special chars) against an array of
strings.
2006-01-02 17:46:15 +00:00
Wayne Davison
478bb47c40 The latest prototypes. 2006-01-02 17:46:12 +00:00
Wayne Davison
685517abd1 Added MATCHFLG_WILD3_SUFFIX define, shuffling a few others to put
it in a nice spot.
2006-01-02 17:46:09 +00:00
Wayne Davison
515afe7cf1 Mention dont-compress fix. 2005-12-30 07:24:17 +00:00
Wayne Davison
ec497df1a0 Optimized set_compression() to remove the per-file strdup(), strlower(),
and free() calls (it now uses iwildmatch()).
2005-12-30 07:19:16 +00:00
Wayne Davison
8e74463643 - Added a new public function, iwildmatch(), which will treat all
upper-case letters in the "text" as lower-case.
- Renamed variable "ch" -> "p_ch" and "prev" -> "prev_ch".
- Added variable "t_ch" to hold the current *text value.
- Return ABORT_ALL if we reach the end of the text string with
  more pattern to match.
2005-12-30 07:12:48 +00:00
Wayne Davison
933d1dfd0f Added a prototype for iwildmatch(). 2005-12-30 07:09:34 +00:00
Wayne Davison
0fe987e226 Fixed a bug in set_compression() where the default dont-compress
patterns (e.g. *.gz) would not match a pathname containing a slash.
2005-12-30 06:03:40 +00:00
Wayne Davison
770de8994e - Renamed match_start -> anchored_match.
- Twiddled one comment and added another.
- Twiddled the placement of two else statements.
2005-12-24 08:00:12 +00:00
Wayne Davison
37cf7b4191 Improved the usage info in the opening comment. 2005-12-19 16:57:55 +00:00
Wayne Davison
1a3ef40da9 A few extra directory-style matching tests. 2005-12-19 02:30:59 +00:00
Wayne Davison
0314302e9c Added an anchored exclude to a filter file. 2005-12-19 02:23:57 +00:00
Wayne Davison
9639c71842 + Put --existing back in the main option summary.
+ Improved the discussion of wildcard characters.
2005-12-19 02:18:16 +00:00
Wayne Davison
d2da915cd0 Made --existing the main option, with --ignore-non-existing
as its alias.
2005-12-19 01:59:00 +00:00
Wayne Davison
e725abcf4e Added a comment, improved a comment, tweaked the recursive function's
name, tweaked the arg names to wildmatch(), and tweaked the style of
the "else" statements when they follow a brace.
2005-12-18 19:40:50 +00:00
Wayne Davison
de01941274 Tweaked the name of the first arg to wildmatch(). 2005-12-18 19:38:47 +00:00
Wayne Davison
d802ea54da Fixed one config-file reference that was misspelled. 2005-12-18 15:48:00 +00:00
Wayne Davison
c81a20fb7a Tweaked the debug output for cvs_filter_list and server_filter_list. 2005-12-17 21:03:25 +00:00
Wayne Davison
6bf32edb8c Return RERR_SIGNAL1 from sigusr1_handler(). 2005-12-16 23:48:34 +00:00
Wayne Davison
4a50a2176e Added RERR_SIGNAL1's message and tweaked ERR_SIGNAL. 2005-12-16 23:48:31 +00:00
Wayne Davison
9e90555fd1 Added RERR_SIGNAL1 to separate SIGUSR1 from the rest of the
signals that return RERR_SIGNAL.
2005-12-16 23:48:28 +00:00
Wayne Davison
2067ec7342 Mentioned the auto-protect rule for --backup. 2005-12-16 17:20:22 +00:00
Wayne Davison
c2c5682c0b If the user specifies --backup with --delete (but without --backup-dir
and --delete-excluded), append a protect-filter rule onto the list of
filter rules.  We run this on both the client and server side so that
an older client talking to a newer server still gets the protection
rule.  (This rule will not cause compatibility problems with older
versions of rsync due to the graceful way that a protect rule turns
into an exclude rule if it needs to be sent to an older server.)
2005-12-16 17:18:29 +00:00
Wayne Davison
4c72f27dd9 Document the new auto-added protect filter-rule when using --backup
with --delete (but without --backup-dir and --delete-excluded).
2005-12-16 17:18:26 +00:00
Wayne Davison
36d8d1a626 - Added a comment about configure figuring out the default user
and group to use in daemon mode.
- Belatedly updated the version of popt that comes with rsync.
- Updated the Mac OS X info.
2005-12-16 16:57:26 +00:00
Wayne Davison
3447d61048 Fixed a bug in the hard-linking of a group of fifos/devices in a
transfer where the leader got hard-linked to a --link-dest item.
2005-12-16 04:02:54 +00:00
Wayne Davison
a3887c2644 Improved the RERR_SIGNAL message to include all possible signals. 2005-12-16 00:18:41 +00:00
Wayne Davison
8a1f3153b9 Mention the improvements in the comare-dest/link-dest/copy-dest handling. 2005-12-15 23:00:23 +00:00
Wayne Davison
165dd4a636 Improved the tests we run to test more output variations and to work
with the new way link-dest handles symlinks.
2005-12-15 23:00:05 +00:00
Wayne Davison
541b23d144 When compare-dest/link-dest/copy-dest are in effect, we now check
if the file we're about to hard-link to the leader is present in
one of the dest dirs -- if it is, we adjust the text we output
accordingly.
2005-12-15 23:00:02 +00:00
Wayne Davison
7987ece7cc The ITEM_NO_DEST_AND_NO_UPDATE define is no longer needed. 2005-12-15 22:59:59 +00:00
Wayne Davison
48224e4c43 Improved the compare-dest/link-dest/copy-dest code to make it more
readable, to make it output properly in double-verbose mode, and
to allow the hard-linking of symlinks and devices (if supported by
the OS).
2005-12-15 22:59:56 +00:00
Wayne Davison
6d4ecad122 - Eliminate an all-dot itemization for a locally-copied file.
- Got rid of some redundant output in maybe_log_item().
2005-12-15 22:59:53 +00:00
Wayne Davison
1578919c37 Improved an old bullet point. 2005-12-15 21:23:44 +00:00
Wayne Davison
10a1d6b4a0 Use AC_SEARCH_LIBS() instead of AC_CHECK_LIB() to figure out if
we need to include libresolv or not.
2005-12-14 22:54:54 +00:00
Wayne Davison
2b7e12924d Mention that the MD4 password protection is weaker than
previously thought.
2005-12-14 22:14:26 +00:00
Wayne Davison
82f0c63e8a Parse single- and double-quotes in the --rsh/-e option (and RSYNC_RSH). 2005-12-14 22:00:01 +00:00
Wayne Davison
5d9530fe47 Mention new quote-parsing for the --rsh/-e and RSYNC_RSH handling. 2005-12-14 21:59:11 +00:00
Wayne Davison
37f35d89d1 Made msg_list_push() static and renamed it to msg_list_flush(). 2005-12-08 21:19:22 +00:00
Wayne Davison
08c88178aa Tweaked the msg_list code so that the head and tail pointers
are contained by a structure.
2005-12-08 21:01:38 +00:00
Wayne Davison
0fb2fc4a1d Fixed a typo in a comment. 2005-12-08 16:12:25 +00:00
Wayne Davison
da2d13e3ce Improved/fixed some of the entries. 2005-11-29 15:53:18 +00:00
Wayne Davison
64318670a8 Improved the description of how --delay-updates chooses it's dir. 2005-11-16 16:12:04 +00:00
Wayne Davison
3c19f72c16 Made the parsing in parse_size_arg() a little more strict. 2005-11-15 17:49:59 +00:00
Wayne Davison
8938d67ef8 Fixed a typo in the --help output for --no-OPTION. 2005-11-15 07:05:55 +00:00
Wayne Davison
05724c07cf Changed -h to be an alias for --human-readable (getting rid of -m).
Also added backward-compatibility code so that "rsync -h" shows the
help page on stdout like it would in older versions.
2005-11-15 06:35:27 +00:00
Wayne Davison
955c3145c3 Document the change in the -h option. 2005-11-15 06:35:22 +00:00
Wayne Davison
8ea17b5098 Twiddled some brace positions and removed a superfluous ';' in a macro. 2005-11-14 21:24:30 +00:00
Wayne Davison
b20fe0e6ac Improved an error message. 2005-11-13 17:15:00 +00:00
Wayne Davison
24787acd08 Moved the DEL_* flags into generator.c. 2005-11-12 20:30:40 +00:00
Wayne Davison
d71dad3bd3 Moved the DEL_* flags from rsync.h here and got rid of DEL_NO_RECURSE. 2005-11-12 20:30:36 +00:00
Wayne Davison
889439c205 Mention the latest options. 2005-11-12 20:08:10 +00:00
Wayne Davison
bee9df73c1 Changed the parsing of suffixes for --min-size and --max-size a little. 2005-11-12 20:08:00 +00:00
Wayne Davison
60613dc896 Output the stats and the end-of-run verbose output using the new
human_num() and human_dnum() functions, which both honor the
new --human-readable option.
2005-11-12 19:53:26 +00:00
Wayne Davison
e175fb07f7 Added two new functions: human_num() and human_dnum(), which
output numbers in human-readable units if the --human-readable
option was specified.
2005-11-12 19:53:23 +00:00
Wayne Davison
4a70af6f81 Added the human_readable variable (for linking with util.o). 2005-11-12 19:53:20 +00:00
Wayne Davison
8f14cc496b Parse the new --human-readable (-m) option. 2005-11-12 19:53:17 +00:00
Wayne Davison
3b4ecc6b80 Document the new --human-readable (-m) option. 2005-11-12 19:53:12 +00:00
Wayne Davison
a7e60f0c59 Only call cleanup_set() if keep_partial is set. 2005-11-10 16:57:30 +00:00
Wayne Davison
3d7cc5710d If cleanup_set() gets passed a NULL fnametmp or fname, set
cleanup_fname to NULL.
2005-11-10 16:56:32 +00:00
Wayne Davison
86fc7e6880 Got rid of a superfluous newline. 2005-11-10 16:47:52 +00:00
Wayne Davison
acee11fc60 - Indent the "oom:" label away from column 0.
- Got rid of a superfluous newline.
2005-11-10 16:47:27 +00:00
Wayne Davison
b2e7c91313 Indent the "prepare_to_open:" and "notify_others:" labels away
from column 0.
2005-11-10 16:47:03 +00:00
Wayne Davison
97b7bff4d6 - Got rid of a superfluous empty line.
- Indent the "oom:" and "skip_filters:" labels away from column 0.
2005-11-10 16:45:00 +00:00
Wayne Davison
e16ca9ef31 Got rid of a superfluous empty line. 2005-11-10 16:44:06 +00:00
Wayne Davison
b2e6caa01e Indent the "failure:" label away from column 0. 2005-11-10 16:43:44 +00:00
Wayne Davison
2997e9f769 Indent the "oom:" label away from column 0. 2005-11-10 16:42:46 +00:00
Wayne Davison
2374023982 Mention the big improvement when --delete and --checksum were
specified.
2005-11-10 06:43:10 +00:00
Wayne Davison
902f03d101 In make_file(), only compute the checksum when we're the sender.
This stops computing useless checksums during the delete scan
when --checksum (-c) was specified.
2005-11-10 06:01:55 +00:00
Wayne Davison
cfe3978049 Use the new checksum_len value instead of recomputing the
right value for the current protocol_version over and over.
2005-11-10 03:07:18 +00:00
Wayne Davison
7752df41b7 Compute the right checksum length for the current protocol_version
only once instead of over and over again.
2005-11-10 03:00:38 +00:00
Wayne Davison
d8b108c2a1 If a partial-dir file is present but the main file is up-to-date,
just remove the partial-dir file.
2005-11-10 02:56:58 +00:00
Wayne Davison
184dd27a18 Call delete_in_dir(NULL, NULL, NULL) in do_delete_pass(). 2005-11-09 19:46:42 +00:00
Wayne Davison
0e5665d3ab Made recursively deleting extraneous directories more memory
efficient by removing the need for a MAXPATHLEN buffer on the
stack of delete_item().
2005-11-09 19:39:46 +00:00
Wayne Davison
ef3bb69ad8 Mention the new --chmod option. 2005-11-07 04:47:06 +00:00
Wayne Davison
45d41d08bd Test the --chmod option. 2005-11-07 04:28:52 +00:00
Wayne Davison
dd32e2c3d4 Added support for the new --chmod option. 2005-11-07 04:28:35 +00:00
Wayne Davison
2b7e0f33a6 Call tweak_mode() on regular files and dirs if --chmod was specified. 2005-11-07 04:28:32 +00:00
Wayne Davison
0582cdae8d Added chmod.o to OBJS2. 2005-11-07 04:28:29 +00:00
Wayne Davison
9e8ea423e2 Document the new --chmod option. 2005-11-07 04:28:23 +00:00
Wayne Davison
0c983c1fd4 New --chmod support routines. 2005-11-07 04:23:22 +00:00
Wayne Davison
3381ffa6ea Fixed a sign error in the output. 2005-11-03 19:55:30 +00:00
Wayne Davison
3b15340966 Mention the change in the output of --progress. 2005-11-03 19:46:45 +00:00
Wayne Davison
91683c434b Make the just-updated file-count status even less cryptic. 2005-11-03 19:45:59 +00:00
Wayne Davison
9e7530c414 Improved the output of the transferred-file count and the position
in the flist (which was changed to a countdown of files to check)
so that it's clearer what the numbers mean.
2005-11-03 19:38:14 +00:00
Wayne Davison
8fd30fc43c Got rid of some early-checksum code that accidentally got committed. 2005-11-02 07:22:02 +00:00
Wayne Davison
b1b04fcdd4 Mention lower stack requiements for recursion. 2005-11-01 20:13:20 +00:00
Wayne Davison
56f0c976be Decreased the amount of stack needed for each level of directory
recursion by eliminating the need for a MAXPATHLEN buffer in
send_if_directory().  Also improved a few variable names in
send_file_list().
2005-11-01 20:09:41 +00:00
Wayne Davison
9aacb4df0e Fixed a typo pointed out by Peter Strazovec. 2005-10-30 22:29:59 +00:00
Wayne Davison
0fdb1aa8ff In the device section, avoid calling unlink() if the stat() failed. 2005-10-30 22:28:11 +00:00
Wayne Davison
bad0110609 Document the new --compress-level option. 2005-10-26 16:48:44 +00:00
Wayne Davison
3cc185a088 Handle new def_compress_level setting. 2005-10-26 16:48:07 +00:00
Wayne Davison
e8a8167ad9 Obey new def_compress_level setting. 2005-10-26 16:47:49 +00:00
Wayne Davison
854a1aad35 Added --compress-level option. 2005-10-26 16:47:15 +00:00
Wayne Davison
84e6d6fdcd - Changed the "status" variables into "exit_code" variables.
- Added an error message to wait_process_with_flush() that
  reports the errno we get when waitpid() fails.
- Increased the value of MAXCHILDPROCS.
2005-10-26 15:53:04 +00:00
Wayne Davison
f14a65d94c Tweaked the error message for RERR_WAITCHILD. 2005-10-26 15:50:14 +00:00
Wayne Davison
37439b36e7 Updated the docs for pre-/post-xfer exec. 2005-10-24 21:03:53 +00:00
Wayne Davison
c95ca2a228 Enhanced the "pre-xfer exec" handling so that it gets the user's
request info and puts that into the environment as RSYNC_REQUEST.
2005-10-24 21:03:50 +00:00
Wayne Davison
97d8e7095f Changed wait_process() into a simpler, yet more versatile function,
and used it in the new wait_process_with_flush() function (the old
function's new name).  Made wait_process() public.
2005-10-24 21:03:47 +00:00
Wayne Davison
20c1926a01 Fixed a typo in a comment. 2005-10-20 18:30:33 +00:00
Wayne Davison
d030233def Get rid of some superfluous empty lines. 2005-10-19 07:49:10 +00:00
Wayne Davison
35812ea1f9 One extra tweak to the just-committed code. 2005-10-15 19:15:29 +00:00
Wayne Davison
d649b78920 Added relative_paths extern. 2005-10-15 19:11:36 +00:00
Wayne Davison
7e43da819e If we're sanitizing paths with --relative enabled, we need to
preserve the first /./ dir so that we can use its position to
trim the implied directories.
2005-10-15 19:08:31 +00:00
Wayne Davison
40aaa571b4 Document --ignore-non-existing (not --existing) and what happens
if the option is combined with --ignore-existing.
2005-10-15 16:39:31 +00:00
Wayne Davison
470319d33b Changed the --help text to mention --ignore-non-existing
instead of --existing.
2005-10-15 16:38:35 +00:00
Wayne Davison
1db954e9bc Made parse_size_arg()'s parsing a little stricter. 2005-10-15 06:53:04 +00:00
Wayne Davison
d697314b42 Mention --min-size/--max-size changes. 2005-10-14 20:40:31 +00:00
Wayne Davison
59dd678603 Documented --min-size. 2005-10-14 20:16:21 +00:00
Wayne Davison
02b5cb238b Added code to implement the --min-size logic. 2005-10-14 20:16:09 +00:00
Wayne Davison
74de13d19c Added handling of the --min-size option. 2005-10-14 20:15:18 +00:00
Wayne Davison
837d01dd5a Improved parse_size_arg() a little more. 2005-10-14 19:48:34 +00:00
Wayne Davison
926d86d1f9 Document the extended parsing of --max-size values. 2005-10-14 19:03:05 +00:00
Wayne Davison
aeb213ea0c Improved parse_size_arg() so that it can be told to use powers of
ten instead of binary K/M/G powers, and so that it can be told to
add or subtract one from the result.  We also make sure to pass
the arg to --max-size in a compatible manner with older versions.
2005-10-14 18:56:07 +00:00
Wayne Davison
7c6ea3d8c7 Fixed a typo in an option name. 2005-10-12 23:59:00 +00:00
Wayne Davison
d409c6ac9c Mention va_copy change. 2005-10-11 20:21:56 +00:00
Wayne Davison
92f0b9d6ab If va_copy is defined, use it when defining VA_COPY. 2005-10-11 20:21:03 +00:00
Wayne Davison
2c8c8bbaad Pass XFLG_ABS_IF_SLASH instead of XFLG_ANCHORED2ABS for server excludes. 2005-10-07 18:40:30 +00:00
Wayne Davison
4fc8140a60 Support new XFLG_ABS_IF_SLASH flag. 2005-10-07 18:39:40 +00:00
Wayne Davison
699f7024f1 Added XFLG_ABS_IF_SLASH. 2005-10-07 18:38:25 +00:00
Wayne Davison
ce0da32a9c Mention recent changes. 2005-10-07 18:24:35 +00:00
Wayne Davison
82360c6b17 Clarify how the fitler rule "-/" works. 2005-10-07 18:18:16 +00:00
Wayne Davison
493568465b Improved the usage comments. 2005-10-04 04:12:28 +00:00
Wayne Davison
bf485d3d6b A simple filter script to output messages from a single module. 2005-10-03 18:40:59 +00:00
Wayne Davison
e90aab4982 Changed the variable names for --existing and --ignore-existing. 2005-09-29 18:07:55 +00:00
Wayne Davison
550d4e2346 Reverted one xfer_dirs change from the last commit that should not
have gone in.
2005-09-29 17:27:11 +00:00
Wayne Davison
991daf008d Keeping silent about stat() errors is never a good idea -- it hides
files that are not up-to-date.
2005-09-29 17:07:45 +00:00
Wayne Davison
505ada146c Mention that --delete now works with --dirs. 2005-09-29 08:15:34 +00:00
Wayne Davison
75c51953f1 - When --dirs is specified w/o --recursive, avoid marking solo dirs
with the XMIT_TOP_DIR flag.
- Only set in_del_hier if --recursive is enabled.
2005-09-29 07:48:05 +00:00
Wayne Davison
8d6c1c4e97 Allow deletions to occur in directories transferred with the
--dirs option in addition to the regular --recursive behavior.
2005-09-29 07:41:50 +00:00
Wayne Davison
10a1a3f511 Fixed a poorly-worded sentence and a misspelled word. 2005-09-29 07:37:00 +00:00
Wayne Davison
40e6752fba Some systems don't define WCOREDUMP(), so #ifdef that code. 2005-09-26 17:41:14 +00:00
Wayne Davison
dbefb6b4e4 Fixed wait_process() to handle cases where waitpid() fails or
the child process did not exit cleanly.
2005-09-26 17:12:13 +00:00
Wayne Davison
6016841086 Changed RERR_CRASH to RERR_CRASHED. 2005-09-26 17:11:03 +00:00
Wayne Davison
0047f535ef Handle new RERR_CRASH AND RERR_TERMINATED exit codes. 2005-09-26 17:07:50 +00:00
Wayne Davison
90eca40d27 Defined RERR_CRASH and RERR_TERMINATED. 2005-09-26 17:06:33 +00:00
Wayne Davison
0417c34e2d Mention some chanages in the patches dir. 2005-09-26 04:47:25 +00:00
Wayne Davison
d64c2b226a Use AC_HELP_STRING() in the two AC_ARG_WITH() macros that used a
hard-wired string.
2005-09-24 17:17:30 +00:00
Wayne Davison
868676dc15 Reordered the usage lines to cover push, then pull (which has a
better visible pattern than covering push & pull for each host-type).
2005-09-21 22:39:49 +00:00
Wayne Davison
e31058d41e Cast some time values to (int), just to silence some warnings on
Stratus VOS.
2005-09-21 17:42:15 +00:00
Wayne Davison
ea8291d8f7 Include limits.h (if it exists), which defines NAME_MAX on some
systems.
2005-09-21 17:38:44 +00:00
Wayne Davison
1348267518 If we get less data than expected from a read() in map_ptr(), we
need to try to keep reading to see if we get an error or more data.
2005-09-21 17:37:41 +00:00
Wayne Davison
f0323d68eb Check for limits.h. 2005-09-21 17:35:51 +00:00
Wayne Davison
12a01be14f Tweaked the output that the mknod() tests generate. 2005-09-21 17:15:58 +00:00
Wayne Davison
e0a18ce3f7 Tweaked some comments. 2005-09-19 17:21:00 +00:00
Wayne Davison
8ad5cea371 Changed one strcpy() into a strlcpy(). 2005-09-17 21:49:24 +00:00
Wayne Davison
9059e0ac2f Improved the sDefault initialization so that the prefixed
comments exactly match the variable names (making sure that
they will sort exactly the same way as the variables).
2005-09-16 20:35:05 +00:00
Wayne Davison
29fad7a3d8 Got rid of some old command-line parsing code that was only
useful when talking to a 1.x client.
2005-09-16 16:40:30 +00:00
Wayne Davison
02efda9f01 Mention '!' fix. 2005-09-16 16:14:24 +00:00
Wayne Davison
35a388b141 Really fix '!' in a .cvsignore file this time. 2005-09-16 16:10:01 +00:00
Wayne Davison
9a4a237ede Tweaked the code a little in the always_checksum handling of the
send & receive file-list functions.
2005-09-16 05:52:54 +00:00
Wayne Davison
5efbddbadb Mention that the dir used with --delay-updates cannot be on a
different filesystem from the destination files.
2005-09-15 22:27:14 +00:00
Wayne Davison
6a94c58b00 Added a comment. 2005-09-15 22:25:55 +00:00
Wayne Davison
e3f8395360 Mention doc changes. 2005-09-15 17:19:30 +00:00
Wayne Davison
f2b4c0840e Removed conflicting ssh citation in the SETUP section. 2005-09-15 15:36:27 +00:00
Wayne Davison
08d82b84cb The --help text was outputting some incomplete information on how
SRC is expanded or word-split, so I removed that text and replaced
it with an explaination of how ':' differs from '::' & 'rsync://'.
2005-09-13 01:02:54 +00:00
Wayne Davison
fbe57fdc95 Mention the latest fix. 2005-09-09 17:07:39 +00:00
Wayne Davison
92cdc39372 When pop_dir(olddir) fails, pass the right string pointer
in the error message.
2005-09-09 16:17:01 +00:00
Wayne Davison
78be8e0fc9 Improved the -F, --exclude-from, and --include-from sections. 2005-09-09 07:27:25 +00:00
Wayne Davison
a5b786d80f Tweaked the calculation that goes into sum->count so that it cannot
overflow into a negative value (which is particularly important if
configure didn't find a real int64 type).
2005-09-06 18:12:38 +00:00
Wayne Davison
f853b777be Complicate the lseek64() function prototype because some systems
don't have off64_t.
2005-09-03 16:56:53 +00:00
Wayne Davison
fed1f3f4fe Make use of the per-module "temp dir" setting. 2005-09-03 16:50:20 +00:00
Wayne Davison
18cad44967 Added a per-module "temp dir" setting. 2005-09-03 16:24:23 +00:00
Wayne Davison
d17c9a4486 Sorted some of the data structures (using vim's "!sort" command
makes it easy).
2005-09-03 16:22:06 +00:00
Wayne Davison
b6e22a47d3 - Allow --no-v and --no-verbose in the daemon options.
- If a too-long --temp-dir is specified when starting a daemon,
  omplain to the daemon-starting user, not later to the client.
2005-08-30 16:13:54 +00:00
Wayne Davison
ec69bdbd64 Mention latest changes. 2005-08-30 05:12:49 +00:00
Wayne Davison
a8cbb57c9b Mention how --inplace conflicts with --sparse and how --append
does not.
2005-08-30 05:10:51 +00:00
Wayne Davison
b8cc35874e Allow --temp-dir to be specified with --daemon to set the default. 2005-08-30 05:00:56 +00:00
Wayne Davison
c3851185f3 Fixed a comment. 2005-08-30 02:59:30 +00:00
Wayne Davison
e7ee91defc When --append is entering the redo phase, make sure that
sparse_files is disabled (because it conflicts with an
inplace update).
2005-08-30 02:58:42 +00:00
Wayne Davison
cfce9f6dc3 Reject attempts to combine --sparse with --inplace. 2005-08-30 02:57:19 +00:00
Wayne Davison
4afcb709a7 Forgot the --no-v option. 2005-08-28 00:43:51 +00:00
Wayne Davison
a912a980ec Mention the new --no-* options. 2005-08-28 00:34:46 +00:00
Wayne Davison
2c64b25827 A small improvement to the daemon-connecting instructions. 2005-08-28 00:25:44 +00:00
Wayne Davison
38b9170c52 One more tweak to the option data. 2005-08-27 21:12:44 +00:00
Wayne Davison
f40aa6fb07 Documented the new --no-* options. 2005-08-27 21:07:27 +00:00
Wayne Davison
b616493883 Added the ability to prefix "no-" to various options, which gives the
user an easy way to override implied option switches.
2005-08-27 21:01:45 +00:00
Wayne Davison
e86e2fa173 A little more reordering of the option data. 2005-08-27 20:43:35 +00:00
Wayne Davison
11bfaf6351 Reordered some of the option data to make their grouping more logical. 2005-08-27 20:01:45 +00:00
Wayne Davison
d37d1c44ff Make the --append docs a little better. 2005-08-20 17:21:06 +00:00
Wayne Davison
c89330313e Moved a variable in glob_expand_one(). 2005-08-03 04:51:29 +00:00
Wayne Davison
c9dc1300ba Got rid of the argp var that is not needed now that argv is no
longer a literal array.
2005-08-03 04:42:56 +00:00
Wayne Davison
53cf0b8bfb Improved the --relative section a little more. 2005-08-03 01:13:15 +00:00
Wayne Davison
56961becc2 Mention the latest changes. 2005-08-01 22:18:11 +00:00
Wayne Davison
1dc42d123d Improved the --relative section, including mentioning the addition
of dot-dir path trimming.
2005-08-01 22:18:00 +00:00
Wayne Davison
d2ea5980ba Allow the user to specify a dot dir in the source path when
using --relative, making it trim the duplicated dirs.
2005-08-01 21:58:16 +00:00
Wayne Davison
15cf186b85 Don't recreate a device if just the permissions bits have changed
in the st_mode.
2005-08-01 04:09:58 +00:00
Wayne Davison
4fdb03a648 Mention hard-link fix. 2005-07-31 23:21:46 +00:00
Wayne Davison
8f5b554f0b Hard-link a device in order to test that this works properly. 2005-07-31 23:20:12 +00:00
Wayne Davison
8cd3db27b6 There is no longer a need to check file->link_u.links at the start
of hard_link_check() (because the caller has already checked it).
2005-07-31 23:19:42 +00:00
Wayne Davison
273a7ed59f Fixed the handling of hard-linked symlinks and devices. 2005-07-31 23:18:28 +00:00
Wayne Davison
23deb0bcee Export RUNSHFLAGS. 2005-07-31 23:15:38 +00:00
Wayne Davison
7ea7bebf6b Mention the --inplace new-file permissions fix. 2005-07-30 16:17:21 +00:00
Wayne Davison
97894c6473 - The combination of --update and --progress now outputs progress
information during the checksum scan of the already-sent data.
- When --inplace creates a file, give it 0600 permissions, not 0000.
2005-07-30 16:14:22 +00:00
Wayne Davison
1f86fcf5dc The combination of --update and --progress now outputs progress
information during the checksum scan of the already-sent data.
2005-07-30 16:13:19 +00:00
Wayne Davison
bb9bdba4c9 Improved the text around the last example in the USAGE section. 2005-07-29 19:52:50 +00:00
Wayne Davison
5b9cc6953a Mention the latest changes. 2005-07-29 18:48:58 +00:00
Wayne Davison
33544bf422 - Use BIGPATHBUFLEN for the length of several buffers.
- If io_printf() tries to overflow the buffer, die with
  an error instead of sending a truncated buffer.
2005-07-29 18:31:12 +00:00
Wayne Davison
20accf4d06 - Use BIGPATHBUFLEN for the length of two line buffers.
- Improved the handling of the start_glob variable.
- Made the line buffer in start_daemon() a little bigger.
2005-07-29 18:31:10 +00:00
Wayne Davison
3fac51e21e Use BIGPATHBUFLEN for the length of two line buffers. 2005-07-29 18:31:07 +00:00
Wayne Davison
d999d312c4 Use BIGPATHBUFLEN for the length of a line buffer. 2005-07-29 18:31:05 +00:00
Wayne Davison
a22ca88565 Define BIGPATHBUFLEN -- a roomy line-buffer that can hold a
MAXPATHLEN string plus a message, and it's at least 4096+1024
bytes for those systems where MAXPATHLEN is overly short.
2005-07-29 18:31:03 +00:00
Wayne Davison
9ec8bd87bb Updated to match 2.6.6 release (which occurred on a branch). 2005-07-28 20:00:43 +00:00
Wayne Davison
f11ece28ff Changed the version to 2.6.7cvs. 2005-07-28 19:49:47 +00:00
Wayne Davison
f90f71498e Updated to reflect new 2.6.7cvs status. 2005-07-28 19:49:24 +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
184 changed files with 35236 additions and 12668 deletions

View File

@@ -1,25 +0,0 @@
ID
Makefile
autom4te*.cache
confdefs.h
config.cache
config.h
config.log
config.status
conftest.c
conftest.log
dox
getgroups
gmon.out
rsync
shconfig
testdir
tests-dont-exist
testtmp
testtmp.*
tls
trimslash
t_unsafe
wildtest
getfsdev
.rsync-filter

37
.gitignore vendored Normal file
View File

@@ -0,0 +1,37 @@
*.[oa]
*~
dummy
ID
Makefile
configure.sh
config.cache
config.h
config.h.in
config.log
config.status
/proto.h
/proto.h-tstamp
/rsync.1
/rsyncd.conf.5
/autom4te*.cache
/confdefs.h
/conftest*
/dox
/getgroups
/gmon.out
/rsync
/shconfig
/testdir
/tests-dont-exist
/testtmp
/tls
/trimslash
/t_unsafe
/wildtest
/getfsdev
/rounding.h
/doc/rsync.pdf
/doc/rsync.ps
/testsuite/chown-fake.test
/testsuite/devices-fake.test
/patches

19
.ignore
View File

@@ -1,19 +0,0 @@
.#*
*.log
Makefile
config.h
*.o
CVS
.ignore
.cvsignore
*~
rsync
config.status
config.cache
TAGS
config.log
test
*.gz
rsync-*
*.dvi
*.aux

849
COPYING
View File

@@ -1,285 +1,626 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
TERMS AND CONDITIONS
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
0. Definitions.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
"This License" refers to version 3 of the GNU General Public License.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
A "covered work" means either the unmodified Program or a work based
on the Program.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
1. Source Code.
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
The Corresponding Source for a work in source code form is that
same work.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
13. Use with the GNU Affero General Public License.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
14. Revised Versions of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
NO WARRANTY
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
15. Disclaimer of Warranty.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Programs
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
@@ -287,15 +628,15 @@ free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -304,36 +645,30 @@ the "copyright" line and a pointer to where the full notice is found.
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.
along with this program. If not, see <http://www.gnu.org/licenses/>.
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:
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

23
INSTALL
View File

@@ -1,4 +1,4 @@
To build and install rsync
To build and install rsync:
$ ./configure
$ make
@@ -9,8 +9,15 @@ to ./configure. To see them, use:
$ ./configure --help
Configure tries to figure out if the local system uses group "nobody" or
"nogroup" by looking in the /etc/group file. (This is only used for the
default group of an rsync daemon, which attempts to run with "nobody"
user and group permissions.) You can change the default user and group
for the daemon by editing the NOBODY_USER and NOBODY_GROUP defines in
config.h, or just override them in your /etc/rsyncd.conf file.
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,
cut-down copy of release 1.6.4 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.
@@ -18,7 +25,6 @@ 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
---------
@@ -37,16 +43,15 @@ fails:
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.
Some versions of Mac OS X (Darwin) seem to have an IPv6 stack, but do
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.
<http://www.ipv6.org/impl/mac.html> says that Apple started to support
IPv6 in 10.2 (Jaguar). If your build fails, try again after running
configure with --disable-ipv6.
IBM AIX NOTES
-------------

View File

@@ -2,6 +2,7 @@
# Makefile
prefix=@prefix@
datarootdir=@datarootdir@
exec_prefix=@exec_prefix@
bindir=@bindir@
mandir=@mandir@
@@ -25,30 +26,32 @@ VERSION=@VERSION@
.SUFFIXES:
.SUFFIXES: .c .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/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 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
GENFILES=configure.sh config.h.in proto.h proto.h-tstamp rsync.1 rsyncd.conf.5
HEADERS=byteorder.h config.h errcode.h proto.h rsync.h ifuncs.h lib/pool_alloc.h
LIBOBJ=lib/wildmatch.o lib/compat.o lib/snprintf.o lib/mdfour.o lib/md5.o \
lib/permstring.o lib/pool_alloc.o lib/sysacls.o lib/sysxattrs.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=flist.o 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 io.o compat.o hlink.o token.o uidlist.o socket.o hashtable.o \
fileio.o batch.o clientname.o chmod.o acls.o xattrs.o
OBJS3=progress.o pipe.o
DAEMON_OBJ = params.o loadparm.o clientserver.o access.o connection.o authenticate.o
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
TLS_OBJ = tls.o syscall.o lib/compat.o lib/snprintf.o lib/permstring.o lib/sysxattrs.o @BUILD_POPT@
# 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)
CHECK_SYMLINKS = testsuite/chown-fake.test testsuite/devices-fake.test
# Objects for CHECK_PROGS to clean
CHECK_OBJS=getgroups.o getfsdev.o t_stub.o t_unsafe.o trimslash.o wildtest.o
CHECK_OBJS=tls.o 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:
@@ -56,15 +59,15 @@ CHECK_OBJS=getgroups.o getfsdev.o t_stub.o t_unsafe.o trimslash.o wildtest.o
$(CC) -I. -I$(srcdir) $(CFLAGS) $(CPPFLAGS) -c $< @CC_SHOBJ_FLAG@
@OBJ_RESTORE@
all: rsync$(EXEEXT)
all: conf_stop make_stop rsync$(EXEEXT) @MAKE_MAN@
install: all
-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
if test -f $(srcdir)/rsync.1; then ${INSTALLMAN} -m 644 $(srcdir)/rsync.1 ${DESTDIR}${mandir}/man1; fi
if test -f $(srcdir)/rsyncd.conf.5; then ${INSTALLMAN} -m 644 $(srcdir)/rsyncd.conf.5 ${DESTDIR}${mandir}/man5; fi
install-strip:
$(MAKE) INSTALL_STRIP='-s' install
@@ -73,6 +76,27 @@ rsync$(EXEEXT): $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
$(OBJS): $(HEADERS)
$(CHECK_OBJS): $(HEADERS)
flist.o: rounding.h
rounding.h: rounding.c rsync.h
@for r in 0 1 3; do \
if $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o rounding -DEXTRA_ROUNDING=$$r -I. $(srcdir)/rounding.c >rounding.out 2>&1; then \
echo "#define EXTRA_ROUNDING $$r" >rounding.h; \
if test -f "$$HOME/build_farm/build_test.fns"; then \
echo "EXTRA_ROUNDING is $$r" >&2; \
fi; \
break; \
fi; \
done
@rm -f rounding
@if test -f rounding.h; then : ; else \
cat rounding.out 1>&2; \
echo "Failed to create rounding.h!" 1>&2; \
exit 1; \
fi
@rm -f rounding.out
tls$(EXEEXT): $(TLS_OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(TLS_OBJ) $(LIBS)
@@ -87,36 +111,59 @@ 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_OBJ = t_unsafe.o syscall.o util.o t_stub.o lib/compat.o lib/snprintf.o lib/wildmatch.o
t_unsafe$(EXEEXT): $(T_UNSAFE_OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(T_UNSAFE_OBJ) $(LIBS)
gen: $(srcdir)/configure $(srcdir)/config.h.in proto man
gen: conf proto.h man
man: $(srcdir)/rsync.1 $(srcdir)/rsyncd.conf.5
gensend: gen
rsync -aivzc $(GENFILES) samba.org:/home/ftp/pub/rsync/generated-files/
$(srcdir)/configure: $(srcdir)/configure.in $(srcdir)/aclocal.m4
cd $(srcdir); autoconf
conf:
cd $(srcdir) && $(MAKE) -f prepare-source.mak conf
$(srcdir)/config.h.in: $(srcdir)/configure.in $(srcdir)/aclocal.m4
cd $(srcdir); autoheader
conf_stop: configure.sh config.h.in
$(srcdir)/rsync.1: $(srcdir)/rsync.yo
yodl2man -o $(srcdir)/rsync.1 $(srcdir)/rsync.yo
configure.sh config.h.in: configure.in aclocal.m4
autoconf -o configure.sh
autoheader && touch config.h.in
@echo 'Configure files changed -- perhaps run:'
@echo ' make reconfigure'
@exit 1
$(srcdir)/rsyncd.conf.5: $(srcdir)/rsyncd.conf.yo
yodl2man -o $(srcdir)/rsyncd.conf.5 $(srcdir)/rsyncd.conf.yo
reconfigure: configure.sh
./config.status --recheck
./config.status
proto:
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
make_stop: Makefile
Makefile: Makefile.in config.status
@./config.status
@echo "Makefile updated -- rerun your make command."
@exit 1
proto: proto.h-tstamp
proto.h: proto.h-tstamp
@echo ' ' >/dev/null
proto.h-tstamp: $(srcdir)/*.c $(srcdir)/lib/compat.c
perl $(srcdir)/mkproto.pl $(srcdir)/*.c $(srcdir)/lib/compat.c
man: rsync.1 rsyncd.conf.5
rsync.1: rsync.yo
yodl2man -o rsync.1 $(srcdir)/rsync.yo
-$(srcdir)/tweak_manpage rsync.1
rsyncd.conf.5: rsyncd.conf.yo
yodl2man -o rsyncd.conf.5 $(srcdir)/rsyncd.conf.yo
-$(srcdir)/tweak_manpage rsyncd.conf.5
clean: cleantests
rm -f *~ $(OBJS) $(TLS_OBJ) $(CHECK_PROGS) $(CHECK_OBJS)
rm -f *~ $(OBJS) $(CHECK_PROGS) $(CHECK_OBJS) $(CHECK_SYMLINKS) \
rounding rounding.h
cleantests:
rm -rf ./testtmp*
@@ -126,12 +173,14 @@ cleantests:
# the source directory.
distclean: clean
rm -f Makefile config.h config.status
rm -f lib/dummy popt/dummy zlib/dummy
rm -f $(srcdir)/Makefile $(srcdir)/config.h $(srcdir)/config.status
rm -f $(srcdir)/lib/dummy $(srcdir)/popt/dummy $(srcdir)/zlib/dummy
rm -f config.cache config.log
rm -f $(srcdir)/config.cache $(srcdir)/config.log
rm -f shconfig $(srcdir)/shconfig
rm -f $(GENFILES)
rm -rf autom4te.cache
# 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
@@ -146,7 +195,6 @@ finddead:
test: check
# There seems to be no standard way to specify some variables as
# exported from a Makefile apart from listing them like this.
@@ -157,18 +205,27 @@ test: check
# 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
check: all $(CHECK_PROGS) $(CHECK_SYMLINKS)
rsync_bin=`pwd`/rsync$(EXEEXT) $(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)
check29: all $(CHECK_PROGS) $(CHECK_SYMLINKS)
rsync_bin=`pwd`/rsync$(EXEEXT) $(srcdir)/runtests.sh --protocol=29
wildtest.o: wildtest.c lib/wildmatch.c rsync.h config.h
wildtest$(EXEEXT): wildtest.o lib/compat.o lib/snprintf.o @BUILD_POPT@
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ wildtest.o lib/compat.o lib/snprintf.o @BUILD_POPT@ $(LIBS)
testsuite/chown-fake.test:
ln -s chown.test $(srcdir)/testsuite/chown-fake.test
testsuite/devices-fake.test:
ln -s devices.test $(srcdir)/testsuite/devices-fake.test
# 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)
installcheck: $(CHECK_PROGS) $(CHECK_SYMLINKS)
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

302
NEWS
View File

@@ -1,302 +1,18 @@
NEWS for rsync 2.6.4 (UNRELEASED)
Protocol: 29 (changed)
Changes since 2.6.3:
NEWS for rsync 3.0.2 (8 Apr 2008)
Protocol: 30 (unchanged)
Changes since 3.0.1:
OUTPUT CHANGES:
- When rsync deletes a directory and outputs a verbose message about
it, it now appends a trailing slash to the name instead of (only
sometimes) outputting a preceding "directory " string.
- The --stats output will contain file-list time-statistics if both
sides are 2.6.4, or if the local side is 2.6.4 and the files are
being pushed (since the stats come from the sending side).
(Requires protocol 29 for a pull.)
- The "%o" (operation) log format now has a third value (besides "send"
and "recv"): "del." (with trailing dot to make it 4 chars). This
changes the way deletions are logged in the daemon's log file.
BUG FIXES:
- Restore the list-clearing behavior of "!" in a .cvsignore file (2.6.3
was only treating it as a special token in an rsync include/exclude
file).
- The combination of --verbose and --dry-run now mentions the full list
of changes that would be output without --dry-run.
- Avoid a mkdir warning when removing a directory in the destination
that already exists in the --backup-dir.
- An OS that has a binary mode for its files (such as cygwin) needed
setmode(fd, O_BINARY) called on the temp-file we opened with
mkstemp(). (Fix derived from the cygwin's 2.6.3 rsync package.)
- Fixed a potential hang when verbosity is high, the client side is
the sender, and the file-list is large.
- We now check if the OS doesn't support using mknod() for creating
FIFOs and sockets, and compile-in using mkfifo() and socket() when
necessary.
- Fixed an off-by-one error in the handling of --max-delete=N.
- One place in the code wasn't checking if fork() failed.
- The "ignore nonreadable" daemon parameter used to erroneously affect
symlinks that pointed to a non-existent file. This has been fixed.
- If the OS does not have lchown() and a chown() of a symlink will
affect the referent of a symlink (as it should), we no longer try
to set the user and group of a symlink.
- The generator now properly runs the hard-link loop and the dir-time
rewriting loop after we're sure that the redo phase is complete.
- When --backup was specified with --partial-dir=DIR (where DIR is a
relative path), the backup code was erroneously trying to backup a
file that was put into the partial-dir.
- One call to flush_write_file() was not being checked for an error.
- The --no-relative option was not being sent from the client to a
server sender.
- If an rsync daemon specified "dont compress = ..." for a file and the
client tried to specify --compress, the libz code was not handling a
compression level of 0 properly. This could cause a transfer failure
if the block-size for a file was large enough (e.g. rsync might have
exited with an error for large files).
- Fixed a bug that would sometimes surface when using --compress and
sending a file with a block-size larger than 64K (either manually
specified, or computed due to the file being really large). Prior
versions of rsync would sometimes fail to to decompress the data
properly, and thus the transferred file would fail its verification.
- If a daemon can't open the specified log file (i.e. syslog is not
being used), die without crashing. We also output an error about
the failure on stderr (which will only be seen if --no-detach was
specified).
- A local transfer no longer duplicates all its include/exclude options
(since the forked process already has a copy of the exclude list,
there's no need to send them a set of duplicates).
- When --progress is specified, the output of items that the generator
is creating (e.g. dirs, symlinks) is now integrated into the progress
output without overlapping it. (Requires protocol 29.)
- Fixed a potential buffer overflow in the xattr code.
ENHANCEMENTS:
- Rsync now supports popt's option aliases, which means that you can
use /etc/popt and/or ~/.popt to create your own option aliases.
- None.
- Added the --delete-during (--del) option which will delete files
from on the receiving side incrementally as each directory in the
transfer is being processed. This makes it more efficient than the
default, before-the-transfer behavior, which is now available as
--delete-before (that is still the default --delete-WHEN option that
will be chosen if --delete or --delete-excluded is specified without
a --delete-WHEN choice). All the --del* options infer --delete, so
an rsync daemon that refuses "delete" will still refuse to allow any
file-deleting options.
DEVELOPER RELATED:
- All the --delete-WHEN options are now more memory efficient:
Previously an entire duplicate set of file-list objects was created
on the receiving side for the entire destination hierarchy. The new
algorithm only creates one directory of objects at a time.
- The RPM spec file was improved to install more useful files.
- Added support for specifying multiple --compare-dest or --link-dest
options, but only of a single type. (Promoted from the patches dir
and enhanced.)
- Added the --max-size option. (Promoted from the patches dir.)
- The daemon-mode options were separated from the normal rsync options
so that they can't be mixed together. This makes it impossible to
start a daemon that had improper default option values that could
cause problems when a client connects (e.g. a hang or an abort).
- The --bwlimit option may now be used in combination with --daemon
to specify both a default value for the daemon side and a value
that cannot be exceeded by a user-specified --bwlimit option.
- Added the "port" parameter to the rsyncd.conf file. (Promoted from
the patches dir.) Also added "address". A command-line option
will take precedence over a config-file option, as expected.
- In _exit_cleanup(): when we are exiting with a partially-received
file, we now flush any data in the write-cache before closing the
partial file.
- The --inplace support was enhanced to work with --compare-dest and
--link-dest. (Requires protocol 29.)
- Added the --dirs (-d) option for an easier way to copy directories
without recursion.
- Added the --list-only option which is mainly a way for the client to
put the server into listing mode without needing to resort to any
internal option kluges (e.g. the age-old use of "-r --exclude="/*/*"
for a non-recursive listing). This option is used automatically
(behind the scenes) when a modern rsync speaks to a modern daemon,
but may also be specified manually if you want to force the use of
the --list-only option over a remote-shell connection.
- Added the --omit-dir-times (-O) option, which will avoid updating
the modified time for directories when --times was specified. This
option will avoid an extra pass through the file-list at the end of
the transfer (to tweak all the directory times), which can result in
an appreciable speedup for a really large transfer. (Promoted from
the patches dir.)
- Added the --filter (-f) option and its helper option, -F. Filter
rules are an extension to the existing include/exclude handling
that also supports nested filter files as well as per-directory
filter files (like .cvsignore, but with full filter-rule parsing).
This new option was chosen in order to ensure that all existing
include/exclude processing remained 100% compatible with older
versions. Protocol 29 is needed for full filter-rule support, but
backward-compatible rules work with earlier protocol versions.
(Promoted from the patches dir and enhanced.)
- Added the --delay-updates option that puts all updated files into
a temporary directory (by default ".~tmp~", but settable via the
--partial-dir=DIR option) until the end of the transfer. This
makes the updates a little more atomic for a large transfer.
- If rsync is put into the background, any output from --progress is
reduced.
- Documented the "max verbosity" setting for rsyncd.conf. (This
setting was added a couple releases ago, but left undocumented.)
- The sender and the generator now double-check the file-list index
they are given, and refuse to try to do a file transfer on a
non-file index (since that would indicate that something had gone
very wrong).
- Added the --itemize-changes (-i) option, which is a way to output a
more detailed list of what files changed in any way and how they
changed. The effect is the same as specifying a --log-format of
"%i %n%L" (see the rsyncd.conf manpage). Works with --dry-run too.
- Added the --fuzzy option, which attempts to find a basis file for a
file that is being created from scratch. The current algorithm
only looks in the destination directory for the created file, but
it does attempt to find a match based on size/mod-time (in case the
file was renamed with no other changes) as well as based on a fuzzy
name-matching algorithm. This option requires protocol 29 because
it needs the new file-sorting order. (Promoted from patches dir
and enhanced.)
- Added the --remove-sent-files option, which lets you move files
between systems.
- When building under windows, the default for --daemon is now to
avoid detaching, requiring the new --detach option to force rsync
to detach.
- Improved the option descriptions in the --help text.
SUPPORT FILES:
- Added atomic-rsync to the support dir: a perl script that will
transfer some files using rsync, and then move the updated files into
place all at once at the end of the transfer. Only works when
pulling, and uses --link-dest and a parallel hierarchy of files to
effect its update.
- Added mnt-excl to the support dir: a perl script that takes the
/proc/mounts file and translates it into a set of excludes that will
exclude all mount points (even mapped mounts to the same disk). The
excludes are made relative to the specified source dir and properly
anchored.
- Added savetransfer.c to the support dir: a C program that can make
a copy of all the data that flows over the wire. This lets you test
for data corruption (by saving the data on both the sending side and
the receiving side) or provides a way to help debug a protocol error.
- Added rrsync to the support dir: this is my version of Joe Smith's
restricted rsync perl script. This helps to ensure that only certain
rsync commands can be run by an ssh invocation.
INTERNAL:
- Added better checking of the checksum-header values that come over
the socket.
- Merged a variety of file-deleting functions into a single function so
that it is easier to maintain.
- Improved the type of some variables (particularly blocksize vars) for
consistency and proper size.
- Got rid of the uint64 type (which we didn't need).
- Use a slightly more compatible set of core #include directives.
- Defined int32 in a way that ensures that the build dies if we can't
find a variable with at least 32 bits.
- The daemon's "read only" config item now sets an internal read_only
variable that makes extra sure that no write/delete calls on the
read-only side can succeed.
PROTOCOL DIFFERENCES FOR VERSION 29:
- A 16-bit flag-word is transmitted after every file-list index. This
indicates what is changing between the sender and the receiver. The
generator now transmits an index and a flag-word to indicate when
dirs and symlinks have changed (instead of producing a message),
which makes the outputting of the information more consistent and
less prone to screen corruption (because either the receiver or the
sender is now outputting all the file-change info).
- If --inplace is specified, the generator flags any transfer that is
using an alternate basis file so that the sender can use the entire
file in the rsync algorithm (unlike a normal --inplace update).
- The sending of exclude names is done using filter-rule syntax. This
means that all names have a prefixed rule indicator, even excludes
(which used to be sent as a bare pattern, when possible). The -C
option will include the per-dir .cvsignore merge file in the list of
filter rules so it is positioned correctly (unlike in some older
transfer scenarios).
- Rsync sorts the filename list in a different way: it sorts the subdir
names after the non-subdir names for each dir's contents, and it
always puts a dir's contents immediately after the dir's name in the
list. (Previously an item named "foo.txt" would sort in between
directory "foo/" and "foo/bar".)
- When talking to a protocol 29 rsync daemon, a list-only request
is able to note this before the options are sent over the wire and
the new --list-only option is included in the options.
- When the --stats bytes are sent over the wire (or stored in a batch),
they now include two elapsed-time values: one for how long it took to
build the file-list, and one for how long it took to send it over the
wire (each expressed in thousandths of a second).
- When --delete-excluded is specified with some filter excludes, a
client sender will now initiate a send of the filter rules to the
receiver (older protocols used to omit the sending of excludes in
this situation since there were no receiver-specific rules that
survived --delete-excluded back then). Note that, as with all the
filter-list sending, only items that are significant to the other
side will actually be sent over the wire, so the filter-rule list
is often empty in this scenario.
- A protocol-29 batch file includes a bit for the setting of the --dirs
option. Also, the shell script created by --write-batch will use the
--filter option instead of --exclude-from to capture any filter rules.
BUILD CHANGES:
- Handle an operating system that use mkdev() in place of makedev().
- Improved configure to better handle cross-compiling.
- A few developer-oriented scripts were moved from the support dir
to the packaging dir.

1697
OLDNEWS
View File

File diff suppressed because it is too large Load Diff

13
README
View File

@@ -51,13 +51,13 @@ case.
Once built put a copy of rsync in your search path on the local and
remote systems (or use "make install"). That's it!
RSYNC SERVERS
RSYNC DAEMONS
-------------
rsync can also talk to "rsync servers" which can provide anonymous or
rsync can also talk to "rsync daemons" which can provide anonymous or
authenticated rsync. See the rsyncd.conf(5) man page for details on how
to setup a rsync server. See the rsync(1) man page for info on how to
connect to a rsync server.
to setup an rsync daemon. See the rsync(1) man page for info on how to
connect to an rsync daemon.
MAILING LIST
@@ -69,7 +69,7 @@ versions on this list.
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
To send mail to everyone on the list send it to rsync@lists.samba.org
BUG REPORTS
@@ -89,6 +89,9 @@ mailing list archives at
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
--------

152
TODO
View File

@@ -1,22 +1,17 @@
-*- 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:
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
Create more granular verbosity 2003/05/15
DOCUMENTATION --------------------------------------------------------
Keep list of open issues and todos on the web site
@@ -25,22 +20,19 @@ Perhaps redo manual as SGML
LOGGING --------------------------------------------------------------
Memory accounting
Improve error messages
Better statistics: Rasmus 2002/03/08
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
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
@@ -52,8 +44,6 @@ 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
@@ -66,17 +56,6 @@ 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 ------------------------------------------------------------
@@ -133,7 +112,7 @@ Handling IPv6 on old machines
-- --
Other IPv6 stuff:
Other IPv6 stuff
Implement suggestions from http://www.kame.net/newsletter/19980604/
and ftp://ftp.iij.ad.jp/pub/RFC/rfc2553.txt
@@ -146,14 +125,6 @@ Other IPv6 stuff:
multiple passive addresses. This might be a bit harder, because we
may need to select on all of them. Hm.
Define a syntax for IPv6 literal addresses. Since they include
colons, they tend to break most naming systems, including ours.
Based on the HTTP IPv6 syntax, I think we should use
rsync://[::1]/foo/bar [::1]::bar
which should just take a small change to the parser code.
-- --
@@ -167,15 +138,6 @@ Add ACL support 2001/12/02
-- --
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
@@ -207,35 +169,6 @@ FAT support
-- --
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,
@@ -260,7 +193,7 @@ Add daemon --no-fork option
-- --
Create more granular verbosity jw 2003/05/15
Create more granular verbosity 2003/05/15
Control output with the --report option.
@@ -330,14 +263,10 @@ Improve error messages
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
Better statistics Rasmus 2002/03/08
<Rasmus>
hey, how about an rsync option that just gives you the
@@ -363,14 +292,6 @@ Perhaps flush stdout like syslog
-- --
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
@@ -379,15 +300,6 @@ Log child death on signal
-- --
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
@@ -453,21 +365,6 @@ Use generic zlib 2002/02/25
-- --
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
@@ -480,31 +377,6 @@ Splint 2002/03/12
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
@@ -594,16 +466,6 @@ 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

View File

@@ -1,29 +1,25 @@
/*
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.
*/
/*
hosts allow/deny code for rsync
*/
* Routines to authenticate access to a daemon (hosts allow/deny).
*
* Copyright (C) 1998 Andrew Tridgell
* Copyright (C) 2004-2008 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
#include "rsync.h"
static int match_hostname(char *host, char *tok)
{
if (!host || !*host)
@@ -208,7 +204,7 @@ static int match_address(char *addr, char *tok)
ret = match_binary(a, t, mask, addrlen);
out:
out:
freeaddrinfo(resa);
freeaddrinfo(rest);
return ret;

23
aclocal.m4 vendored
View File

@@ -68,4 +68,25 @@ AC_DEFUN([TYPE_SOCKLEN_T],
#include <sys/socket.h>])
])
dnl AC_HAVE_TYPE(TYPE,INCLUDES)
AC_DEFUN([AC_HAVE_TYPE], [
AC_REQUIRE([AC_HEADER_STDC])
cv=`echo "$1" | sed 'y%./+- %__p__%'`
AC_MSG_CHECKING(for $1)
AC_CACHE_VAL([ac_cv_type_$cv],
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
AC_INCLUDES_DEFAULT
$2]],
[[$1 foo;]])],
[eval "ac_cv_type_$cv=yes"],
[eval "ac_cv_type_$cv=no"]))dnl
ac_foo=`eval echo \\$ac_cv_type_$cv`
AC_MSG_RESULT($ac_foo)
if test "$ac_foo" = yes; then
ac_tr_hdr=HAVE_`echo $1 | sed 'y%abcdefghijklmnopqrstuvwxyz./- %ABCDEFGHIJKLMNOPQRSTUVWXYZ____%'`
if false; then
AC_CHECK_TYPES($1)
fi
AC_DEFINE_UNQUOTED($ac_tr_hdr, 1, [Define if you have type `$1'])
fi
])

1092
acls.c Normal file
View File

File diff suppressed because it is too large Load Diff

View File

@@ -1,41 +1,38 @@
/* -*- c-file-style: "linux"; -*-
/*
* Support rsync daemon authentication.
*
* Copyright (C) 1998-2000 Andrew Tridgell
* Copyright (C) 2002-2008 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
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.
*/
/* 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.
***************************************************************************/
void base64_encode(char *buf, int len, char *out)
void base64_encode(const char *buf, int len, char *out, int pad)
{
char *b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
int bit_offset, byte_offset, idx, i;
unsigned char *d = (unsigned char *)buf;
const uchar *d = (const uchar *)buf;
int bytes = (len*8 + 5)/6;
memset(out, 0, bytes+1);
for (i = 0; i < bytes; i++) {
byte_offset = (i*6)/8;
bit_offset = (i*6)%8;
@@ -49,17 +46,24 @@ void base64_encode(char *buf, int len, char *out)
}
out[i] = b64[idx];
}
while (pad && (i % 4))
out[i++] = '=';
out[i] = '\0';
}
/* create a 16 byte challenge buffer */
static void gen_challenge(char *addr, char *challenge)
/* Generate a challenge buffer and return it base64-encoded. */
static void gen_challenge(const char *addr, char *challenge)
{
char input[32];
char digest[MAX_DIGEST_LEN];
struct timeval tv;
int len;
memset(input, 0, sizeof input);
strlcpy((char *)input, addr, 17);
strlcpy(input, addr, 17);
sys_gettimeofday(&tv);
SIVAL(input, 16, tv.tv_sec);
SIVAL(input, 20, tv.tv_usec);
@@ -67,18 +71,21 @@ static void gen_challenge(char *addr, char *challenge)
sum_init(0);
sum_update(input, sizeof input);
sum_end(challenge);
len = sum_end(digest);
base64_encode(digest, len, challenge, 0);
}
/* 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)
static int get_secret(int module, const char *user, char *secret, int len)
{
char *fname = lp_secrets_file(module);
const char *fname = lp_secrets_file(module);
STRUCT_STAT st;
int fd, ok = 1;
char ch, *p;
const char *p;
char ch, *s;
if (!fname || !*fname)
return 0;
@@ -87,13 +94,13 @@ static int get_secret(int module, char *user, char *secret, int len)
return 0;
if (do_stat(fname, &st) == -1) {
rsyserr(FLOG, errno, "stat(%s)", safe_fname(fname));
rsyserr(FLOG, errno, "stat(%s)", fname);
ok = 0;
} else if (lp_strict_modes(module)) {
if ((st.st_mode & 06) != 0) {
rprintf(FLOG, "secrets file must not be other-accessible (see strict modes option)\n");
ok = 0;
} else if (am_root && (st.st_uid != 0)) {
} else if (MY_UID() == 0 && st.st_uid != 0) {
rprintf(FLOG, "secrets file must be owned by root when running as root (see strict modes)\n");
ok = 0;
}
@@ -130,60 +137,57 @@ static int get_secret(int module, char *user, char *secret, int len)
}
/* Slurp the secret into the "secret" buffer. */
p = secret;
s = secret;
while (len > 0) {
if (read(fd, p, 1) != 1 || *p == '\n')
if (read(fd, s, 1) != 1 || *s == '\n')
break;
if (*p == '\r')
if (*s == '\r')
continue;
p++;
s++;
len--;
}
*p = '\0';
*s = '\0';
close(fd);
return 1;
}
static char *getpassf(char *filename)
static const char *getpassf(const char *filename)
{
STRUCT_STAT st;
char buffer[512], *p;
int fd, n, ok = 1;
char *envpw = getenv("RSYNC_PASSWORD");
const char *envpw = getenv("RSYNC_PASSWORD");
if (!filename)
return NULL;
if ((fd = open(filename,O_RDONLY)) < 0) {
rsyserr(FERROR, errno, "could not open password file \"%s\"",
safe_fname(filename));
rsyserr(FWARNING, errno, "could not open password file \"%s\"",
filename);
if (envpw)
rprintf(FERROR, "falling back to RSYNC_PASSWORD environment variable.\n");
rprintf(FINFO, "falling back to RSYNC_PASSWORD environment variable.\n");
return NULL;
}
if (do_stat(filename, &st) == -1) {
rsyserr(FERROR, errno, "stat(%s)", safe_fname(filename));
rsyserr(FWARNING, errno, "stat(%s)", filename);
ok = 0;
} else if ((st.st_mode & 06) != 0) {
rprintf(FERROR,"password file must not be other-accessible\n");
rprintf(FWARNING, "password file must not be other-accessible\n");
ok = 0;
} else if (am_root && st.st_uid != 0) {
rprintf(FERROR,"password file must be owned by root when running as root\n");
} else if (MY_UID() == 0 && st.st_uid != 0) {
rprintf(FWARNING, "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");
close(fd);
rprintf(FWARNING, "continuing without password file\n");
if (envpw)
rprintf(FINFO, "falling back to RSYNC_PASSWORD environment variable.\n");
return NULL;
}
if (envpw)
rprintf(FERROR, "RSYNC_PASSWORD environment variable ignored\n");
n = read(fd, buffer, sizeof buffer - 1);
close(fd);
if (n > 0) {
@@ -195,17 +199,19 @@ static char *getpassf(char *filename)
return NULL;
}
/* generate a 16 byte hash from a password and challenge */
static void generate_hash(char *in, char *challenge, char *out)
/* Generate an MD4 hash created from the combination of the password
* and the challenge string and return it base64-encoded. */
static void generate_hash(const char *in, const char *challenge, char *out)
{
char buf[16];
char buf[MAX_DIGEST_LEN];
int len;
sum_init(0);
sum_update(in, strlen(in));
sum_update(challenge, strlen(challenge));
sum_end(buf);
len = sum_end(buf);
base64_encode(buf, 16, out);
base64_encode(buf, len, out, 0);
}
/* Possibly negotiate authentication with the client. Use "leader" to
@@ -214,17 +220,15 @@ static void generate_hash(char *in, char *challenge, char *out)
* Return NULL if authentication failed. Return "" if anonymous access.
* Otherwise return username.
*/
char *auth_server(int f_in, int f_out, int module, char *addr, char *leader)
char *auth_server(int f_in, int f_out, int module, const char *host,
const char *addr, const char *leader)
{
char *users = lp_auth_users(module);
char challenge[16];
char b64_challenge[30];
char line[MAXPATHLEN];
static char user[100];
char secret[100];
char pass[30];
char pass2[30];
char *tok;
char challenge[MAX_DIGEST_LEN*2];
char line[BIGPATHBUFLEN];
char secret[512];
char pass2[MAX_DIGEST_LEN*2];
char *tok, *pass;
/* if no auth list then allow anyone in! */
if (!users || !*users)
@@ -232,52 +236,59 @@ char *auth_server(int f_in, int f_out, int module, char *addr, char *leader)
gen_challenge(addr, challenge);
base64_encode(challenge, 16, b64_challenge);
io_printf(f_out, "%s%s\n", leader, challenge);
io_printf(f_out, "%s%s\n", leader, b64_challenge);
if (!read_line(f_in, line, sizeof line - 1))
if (!read_line_old(f_in, line, sizeof line)
|| (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 (wildmatch(tok, user))
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);
if (!tok) {
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 (!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;
}
generate_hash(secret, challenge, pass2);
memset(secret, 0, sizeof secret);
if (strcmp(pass, pass2) == 0)
return user;
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 NULL;
return strdup(line);
}
void auth_client(int fd, char *user, char *challenge)
void auth_client(int fd, const char *user, const char *challenge)
{
char *pass;
char pass2[30];
const char *pass;
char pass2[MAX_DIGEST_LEN*2];
if (!user || !*user)
user = "nobody";
@@ -302,5 +313,3 @@ void auth_client(int fd, char *user, char *challenge)
generate_hash(pass, challenge, pass2);
io_printf(fd, "%s %s\n", user, pass2);
}

239
backup.c
View File

@@ -1,42 +1,41 @@
/*
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 */
* Backup handling code.
*
* Copyright (C) 1999 Andrew Tridgell
* Copyright (C) 2003-2008 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
#include "rsync.h"
extern int verbose;
extern int backup_suffix_len;
extern int am_root;
extern int preserve_acls;
extern int preserve_xattrs;
extern int preserve_devices;
extern int preserve_specials;
extern int preserve_links;
extern int safe_symlinks;
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)
char *get_backup_name(const char *fname)
{
if (backup_dir) {
if (stringjoin(backup_dir_buf + backup_dir_len, backup_dir_remainder,
@@ -53,10 +52,10 @@ char *get_backup_name(char *fname)
}
/* simple backup creates a backup with a suffix in the same directory */
static int make_simple_backup(char *fname)
static int make_simple_backup(const char *fname)
{
int rename_errno;
char *fnamebak = get_backup_name(fname);
const char *fnamebak = get_backup_name(fname);
if (!fnamebak)
return 0;
@@ -65,8 +64,7 @@ static int make_simple_backup(char *fname)
if (do_rename(fname, fnamebak) == 0) {
if (verbose > 1) {
rprintf(FINFO, "backed up %s to %s\n",
safe_fname(fname),
safe_fname(fnamebak));
fname, fnamebak);
}
break;
}
@@ -81,7 +79,7 @@ static int make_simple_backup(char *fname)
continue;
rsyserr(FERROR, rename_errno, "rename %s to backup %s",
safe_fname(fname), safe_fname(fnamebak));
fname, fnamebak);
errno = rename_errno;
return 0;
}
@@ -94,31 +92,37 @@ static int make_simple_backup(char *fname)
Create a directory given an absolute path, perms based upon another directory
path
****************************************************************************/
static int make_bak_dir(char *fullpath)
int make_bak_dir(const char *fullpath)
{
STRUCT_STAT st;
char *rel = fullpath + backup_dir_len;
char *end = rel + strlen(rel);
char *p = end;
char fbuf[MAXPATHLEN], *rel, *end, *p;
struct file_struct *file;
int len = backup_dir_len;
stat_x sx;
while (strncmp(fullpath, "./", 2) == 0)
while (*fullpath == '.' && fullpath[1] == '/') {
fullpath += 2;
len -= 2;
}
if (strlcpy(fbuf, fullpath, sizeof fbuf) >= sizeof fbuf)
return -1;
rel = fbuf + len;
end = p = rel + strlen(rel);
/* Try to find an existing dir, starting from the deepest dir. */
while (1) {
if (--p == fullpath) {
p += strlen(p);
goto failure;
}
if (--p == fbuf)
return -1;
if (*p == '/') {
*p = '\0';
if (do_mkdir(fullpath, 0777 & ~orig_umask) == 0)
if (mkdir_defmode(fbuf) == 0)
break;
if (errno != ENOENT) {
rsyserr(FERROR, errno,
"make_bak_dir mkdir %s failed",
full_fname(fullpath));
goto failure;
full_fname(fbuf));
return -1;
}
}
}
@@ -128,40 +132,57 @@ static int make_bak_dir(char *fullpath)
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) {
if (x_stat(rel, &sx.st, NULL) < 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);
#ifdef SUPPORT_ACLS
sx.acc_acl = sx.def_acl = NULL;
#endif
#ifdef SUPPORT_XATTRS
sx.xattr = NULL;
#endif
if (!(file = make_file(rel, NULL, NULL, 0, NO_FILTERS)))
continue;
#ifdef SUPPORT_ACLS
if (preserve_acls && !S_ISLNK(file->mode)) {
get_acl(rel, &sx);
cache_acl(file, &sx);
free_acl(&sx);
}
#endif
#ifdef SUPPORT_XATTRS
if (preserve_xattrs) {
get_xattr(rel, &sx);
cache_xattr(file, &sx);
free_xattr(&sx);
}
#endif
set_file_attrs(fbuf, file, NULL, NULL, 0);
unmake_file(file);
}
}
*p = '/';
p += strlen(p);
if (p == end)
break;
if (do_mkdir(fullpath, 0777 & ~orig_umask) < 0) {
if (mkdir_defmode(fbuf) < 0) {
rsyserr(FERROR, errno, "make_bak_dir mkdir %s failed",
full_fname(fullpath));
goto failure;
full_fname(fbuf));
return -1;
}
}
return 0;
failure:
while (p != end) {
*p = '/';
p += strlen(p);
}
return -1;
return 0;
}
/* robustly move a file, creating new directory structures if necessary */
static int robust_move(char *src, char *dst)
static int robust_move(const char *src, char *dst)
{
if (robust_rename(src, dst, 0755) < 0 && (errno != ENOENT
|| make_bak_dir(dst) < 0 || robust_rename(src, dst, 0755) < 0))
if (robust_rename(src, dst, NULL, 0755) < 0
&& (errno != ENOENT || make_bak_dir(dst) < 0
|| robust_rename(src, dst, NULL, 0755) < 0))
return -1;
return 0;
}
@@ -169,37 +190,61 @@ static int robust_move(char *src, char *dst)
/* 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)
static int keep_backup(const char *fname)
{
STRUCT_STAT st;
stat_x sx;
struct file_struct *file;
char *buf;
int kept = 0;
int ret_code;
/* return if no file to keep */
if (do_lstat(fname, &st) < 0)
if (x_lstat(fname, &sx.st, NULL) < 0)
return 1;
#ifdef SUPPORT_ACLS
sx.acc_acl = sx.def_acl = NULL;
#endif
#ifdef SUPPORT_XATTRS
sx.xattr = NULL;
#endif
if (!(file = make_file(fname, NULL, NO_FILTERS)))
if (!(file = make_file(fname, NULL, NULL, 0, NO_FILTERS)))
return 1; /* the file could have disappeared */
if (!(buf = get_backup_name(fname)))
if (!(buf = get_backup_name(fname))) {
unmake_file(file);
return 0;
}
#ifdef SUPPORT_ACLS
if (preserve_acls && !S_ISLNK(file->mode)) {
get_acl(fname, &sx);
cache_acl(file, &sx);
free_acl(&sx);
}
#endif
#ifdef SUPPORT_XATTRS
if (preserve_xattrs) {
get_xattr(fname, &sx);
cache_xattr(file, &sx);
free_xattr(&sx);
}
#endif
/* Check to see if this is a device file, or link */
if (IS_DEVICE(file->mode)) {
if (am_root && preserve_devices) {
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));
}
if ((am_root && preserve_devices && IS_DEVICE(file->mode))
|| (preserve_specials && IS_SPECIAL(file->mode))) {
uint32 *devp = F_RDEV_P(file);
dev_t rdev = MAKEDEV(DEV_MAJOR(devp), DEV_MINOR(devp));
do_unlink(buf);
if (do_mknod(buf, file->mode, rdev) < 0
&& (errno != ENOENT || make_bak_dir(buf) < 0
|| do_mknod(buf, file->mode, rdev) < 0)) {
rsyserr(FERROR, errno, "mknod %s failed",
full_fname(buf));
} else if (verbose > 2) {
rprintf(FINFO, "make_backup: DEVICE %s successful.\n",
fname);
}
kept = 1;
do_unlink(fname);
@@ -224,27 +269,31 @@ static int keep_backup(char *fname)
#ifdef SUPPORT_LINKS
if (!kept && preserve_links && S_ISLNK(file->mode)) {
if (safe_symlinks && unsafe_symlink(file->u.link, buf)) {
const char *sl = F_SYMLINK(file);
if (safe_symlinks && unsafe_symlink(sl, buf)) {
if (verbose) {
rprintf(FINFO, "ignoring unsafe symlink %s -> %s\n",
full_fname(buf), file->u.link);
full_fname(buf), sl);
}
kept = 1;
} else {
do_unlink(buf);
if (do_symlink(sl, buf) < 0
&& (errno != ENOENT || make_bak_dir(buf) < 0
|| do_symlink(sl, buf) < 0)) {
rsyserr(FERROR, errno, "link %s -> \"%s\"",
full_fname(buf), sl);
}
do_unlink(fname);
kept = 1;
}
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));
fname);
unmake_file(file);
return 1;
}
@@ -252,26 +301,26 @@ static int keep_backup(char *fname)
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) {
full_fname(fname), buf);
} else if (sx.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);
set_file_attrs(buf, file, NULL, fname, 0);
unmake_file(file);
if (verbose > 1) {
rprintf(FINFO, "backed up %s to %s\n",
safe_fname(fname), safe_fname(buf));
fname, buf);
}
return 1;
}
/* main backup switch routine */
int make_backup(char *fname)
int make_backup(const char *fname)
{
if (backup_dir)
return keep_backup(fname);

176
batch.c
View File

@@ -1,14 +1,28 @@
/* -*- c-file-style: "linux" -*-
Weiss 1/1999
Batch utilities for rsync.
*/
/*
* Support for the batch-file options.
*
* Copyright (C) 1999 Weiss
* Copyright (C) 2004 Chris Shoemaker
* Copyright (C) 2004-2008 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
#include "rsync.h"
#include "zlib/zlib.h"
#include <time.h>
extern int am_sender;
extern int eol_nulls;
extern int recurse;
extern int xfer_dirs;
@@ -17,22 +31,42 @@ extern int preserve_hard_links;
extern int preserve_devices;
extern int preserve_uid;
extern int preserve_gid;
extern int preserve_acls;
extern int preserve_xattrs;
extern int always_checksum;
extern int do_compression;
extern int inplace;
extern int append_mode;
extern int protocol_version;
extern char *batch_name;
#ifdef ICONV_OPTION
extern char *iconv_opt;
#endif
extern struct filter_list_struct filter_list;
static int fudged_recurse;
int batch_stream_flags;
static int tweaked_append;
static int tweaked_append_verify;
static int tweaked_iconv;
static int *flag_ptr[] = {
&fudged_recurse,
&preserve_uid,
&preserve_gid,
&preserve_links,
&preserve_devices,
&preserve_hard_links,
&always_checksum,
&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) */
&tweaked_iconv, /* 9 (protocol 30) */
&preserve_acls, /* 10 (protocol 30) */
&preserve_xattrs, /* 11 (protocol 30) */
&inplace, /* 12 (protocol 30) */
&tweaked_append, /* 13 (protocol 30) */
&tweaked_append_verify, /* 14 (protocol 30) */
NULL
};
@@ -45,6 +79,13 @@ static char *flag_name[] = {
"--hard-links (-H)",
"--checksum (-c)",
"--dirs (-d)",
"--compress (-z)",
"--iconv",
"--acls (-A)",
"--xattrs (-X)",
"--inplace",
"--append",
"--append-verify",
NULL
};
@@ -52,9 +93,14 @@ void write_stream_flags(int fd)
{
int i, flags;
tweaked_append = append_mode == 1;
tweaked_append_verify = append_mode == 2;
#ifdef ICONV_OPTION
tweaked_iconv = iconv_opt != NULL;
#endif
/* Start the batch file with a bitmap of data-stream-affecting
* flags. */
fudged_recurse = recurse < 0;
for (i = 0, flags = 0; flag_ptr[i]; i++) {
if (*flag_ptr[i])
flags |= 1 << i;
@@ -64,14 +110,31 @@ void write_stream_flags(int fd)
void read_stream_flags(int fd)
{
int i, flags;
batch_stream_flags = read_int(fd);
}
void check_batch_flags(void)
{
int i;
fudged_recurse = recurse < 0;
if (protocol_version < 29)
xfer_dirs = 0;
for (i = 0, flags = read_int(fd); flag_ptr[i]; i++) {
int set = flags & (1 << i) ? 1 : 0;
flag_ptr[7] = NULL;
else if (protocol_version < 30)
flag_ptr[9] = NULL;
tweaked_append = append_mode == 1;
tweaked_append_verify = append_mode == 2;
#ifdef ICONV_OPTION
tweaked_iconv = iconv_opt != NULL;
#endif
for (i = 0; flag_ptr[i]; i++) {
int set = batch_stream_flags & (1 << i) ? 1 : 0;
if (*flag_ptr[i] != set) {
if (i == 9) {
rprintf(FERROR,
"%s specify the --iconv option to use this batch file.\n",
set ? "Please" : "Do not");
exit_cleanup(RERR_SYNTAX);
}
if (verbose) {
rprintf(FINFO,
"%sing the %s option to match the batchfile.\n",
@@ -80,9 +143,17 @@ void read_stream_flags(int fd)
*flag_ptr[i] = set;
}
}
recurse = fudged_recurse ? -1 : 0;
if (protocol_version < 29)
xfer_dirs = recurse ? 1 : 0;
if (protocol_version < 29) {
if (recurse)
xfer_dirs |= 1;
else if (xfer_dirs < 2)
xfer_dirs = 0;
}
if (tweaked_append)
append_mode = 1;
else if (tweaked_append_verify)
append_mode = 2;
}
static void write_arg(int fd, char *arg)
@@ -134,7 +205,7 @@ static void write_filter_rules(int fd)
* (hopefully) work. */
void write_batch_shell_file(int argc, char *argv[], int file_arg_cnt)
{
int fd, i;
int fd, i, len;
char *p, filename[MAXPATHLEN];
stringjoin(filename, sizeof filename,
@@ -143,8 +214,8 @@ void write_batch_shell_file(int argc, char *argv[], int file_arg_cnt)
S_IRUSR | S_IWUSR | S_IEXEC);
if (fd < 0) {
rsyserr(FERROR, errno, "Batch file %s open error",
safe_fname(filename));
exit_cleanup(1);
filename);
exit_cleanup(RERR_FILESELECT);
}
/* Write argvs info to BATCH.sh file */
@@ -170,19 +241,17 @@ void write_batch_shell_file(int argc, char *argv[], int file_arg_cnt)
continue;
}
write(fd, " ", 1);
if (strncmp(p, "--write-batch", 13) == 0) {
if (strncmp(p, "--write-batch", len = 13) == 0
|| strncmp(p, "--only-write-batch", len = 18) == 0) {
write(fd, "--read-batch", 12);
if (p[13] == '=') {
if (p[len] == '=') {
write(fd, "=", 1);
write_arg(fd, p + 14);
write_arg(fd, p + len + 1);
}
} else
write_arg(fd, p);
}
if ((p = find_colon(argv[argc - 1])) != NULL) {
if (*++p == ':')
p++;
} else
if (!(p = check_for_hostspec(argv[argc - 1], &p, &i)))
p = argv[argc - 1];
write(fd, " ${1:-", 6);
write_arg(fd, p);
@@ -191,42 +260,7 @@ void write_batch_shell_file(int argc, char *argv[], int file_arg_cnt)
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);
filename);
exit_cleanup(RERR_FILEIO);
}
}
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,26 +1,27 @@
/*
simple byteorder handling
Copyright (C) Andrew Tridgell 1992-1995
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.
*/
/*
* Simple byteorder handling.
*
* Copyright (C) 1992-1995 Andrew Tridgell
* Copyright (C) 2007-2008 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
#undef CAREFUL_ALIGNMENT
/* we know that the x86 can handle misalignment and has the "right"
byteorder */
/* We know that the x86 can handle misalignment and has the same
* byte order (LSB-first) as the 32-bit numbers we transmit. */
#ifdef __i386__
#define CAREFUL_ALIGNMENT 0
#endif
@@ -30,13 +31,12 @@
#endif
#define CVAL(buf,pos) (((unsigned char *)(buf))[pos])
#define PVAL(buf,pos) ((unsigned)CVAL(buf,pos))
#define UVAL(buf,pos) ((uint32)CVAL(buf,pos))
#define SCVAL(buf,pos,val) (CVAL(buf,pos) = (val))
#if CAREFUL_ALIGNMENT
#define SVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8)
#define IVAL(buf,pos) (SVAL(buf,pos)|SVAL(buf,(pos)+2)<<16)
#define PVAL(buf,pos) (UVAL(buf,pos)|UVAL(buf,(pos)+1)<<8)
#define IVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+2)<<16)
#define SSVALX(buf,pos,val) (CVAL(buf,pos)=(val)&0xFF,CVAL(buf,pos+1)=(val)>>8)
#define SIVALX(buf,pos,val) (SSVALX(buf,pos,val&0xFFFF),SSVALX(buf,pos+2,val>>16))
#define SIVAL(buf,pos,val) SIVALX((buf),(pos),((uint32)(val)))
@@ -50,5 +50,3 @@
#define IVAL(buf,pos) (*(uint32 *)((char *)(buf) + (pos)))
#define SIVAL(buf,pos,val) IVAL(buf,pos)=((uint32)(val))
#endif

79
case_N.h Normal file
View File

@@ -0,0 +1,79 @@
/*
* End-of-run cleanup helper code used by cleanup.c.
*
* Copyright (C) 2006-2008 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
/* This is included by cleanup.c multiple times, once for every segement in
* the _exit_cleanup() code. This produces the next "case N:" statement in
* sequence and increments the cleanup_step variable by 1. This ensures that
* our case statements never get out of whack due to added/removed steps. */
#if !defined EXIT_CLEANUP_CASE_0
#define EXIT_CLEANUP_CASE_0
case 0:
#elif !defined EXIT_CLEANUP_CASE_1
#define EXIT_CLEANUP_CASE_1
case 1:
#elif !defined EXIT_CLEANUP_CASE_2
#define EXIT_CLEANUP_CASE_2
case 2:
#elif !defined EXIT_CLEANUP_CASE_3
#define EXIT_CLEANUP_CASE_3
case 3:
#elif !defined EXIT_CLEANUP_CASE_4
#define EXIT_CLEANUP_CASE_4
case 4:
#elif !defined EXIT_CLEANUP_CASE_5
#define EXIT_CLEANUP_CASE_5
case 5:
#elif !defined EXIT_CLEANUP_CASE_6
#define EXIT_CLEANUP_CASE_6
case 6:
#elif !defined EXIT_CLEANUP_CASE_7
#define EXIT_CLEANUP_CASE_7
case 7:
#elif !defined EXIT_CLEANUP_CASE_8
#define EXIT_CLEANUP_CASE_8
case 8:
#elif !defined EXIT_CLEANUP_CASE_9
#define EXIT_CLEANUP_CASE_9
case 9:
#elif !defined EXIT_CLEANUP_CASE_10
#define EXIT_CLEANUP_CASE_10
case 10:
#elif !defined EXIT_CLEANUP_CASE_11
#define EXIT_CLEANUP_CASE_11
case 11:
#elif !defined EXIT_CLEANUP_CASE_12
#define EXIT_CLEANUP_CASE_12
case 12:
#elif !defined EXIT_CLEANUP_CASE_13
#define EXIT_CLEANUP_CASE_13
case 13:
#elif !defined EXIT_CLEANUP_CASE_14
#define EXIT_CLEANUP_CASE_14
case 14:
#elif !defined EXIT_CLEANUP_CASE_15
#define EXIT_CLEANUP_CASE_15
case 15:
#elif !defined EXIT_CLEANUP_CASE_16
#define EXIT_CLEANUP_CASE_16
case 16:
#else
#error Need to add more case statements!
#endif
cleanup_step++;

View File

@@ -1,31 +1,31 @@
/*
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.
*/
* Routines to support checksumming of bytes.
*
* Copyright (C) 1996 Andrew Tridgell
* Copyright (C) 1996 Paul Mackerras
* Copyright (C) 2004-2008 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
#include "rsync.h"
int csum_length=2; /* initial value */
#define CSUM_CHUNK 64
extern int checksum_seed;
extern int protocol_version;
int csum_length = SHORT_SUM_LENGTH; /* initial value */
/*
a simple 32 bit checksum that can be upadted from either end
(inspired by Mark Adler's Adler-32 checksum)
@@ -51,54 +51,64 @@ uint32 get_checksum1(char *buf1, int32 len)
void get_checksum2(char *buf, int32 len, char *sum)
{
int32 i;
static char *buf1;
static int32 len1;
struct mdfour m;
md_context m;
if (len > len1) {
if (buf1)
free(buf1);
buf1 = new_array(char, len+4);
len1 = len;
if (!buf1)
out_of_memory("get_checksum2");
if (protocol_version >= 30) {
uchar seedbuf[4];
md5_begin(&m);
md5_update(&m, (uchar *)buf, len);
if (checksum_seed) {
SIVAL(seedbuf, 0, checksum_seed);
md5_update(&m, seedbuf, 4);
}
md5_result(&m, (uchar *)sum);
} else {
int32 i;
static char *buf1;
static int32 len1;
mdfour_begin(&m);
if (len > len1) {
if (buf1)
free(buf1);
buf1 = new_array(char, len+4);
len1 = len;
if (!buf1)
out_of_memory("get_checksum2");
}
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);
/*
* 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);
}
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);
}
/*
* 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);
}
void file_checksum(char *fname,char *sum,OFF_T size)
void file_checksum(char *fname, char *sum, OFF_T size)
{
OFF_T i;
struct map_struct *buf;
OFF_T i, len = size;
md_context m;
int32 remainder;
int fd;
OFF_T len = size;
struct mdfour m;
memset(sum,0,MD4_SUM_LENGTH);
memset(sum, 0, MAX_DIGEST_LEN);
fd = do_open(fname, O_RDONLY, 0);
if (fd == -1)
@@ -106,38 +116,57 @@ void file_checksum(char *fname,char *sum,OFF_T size)
buf = map_file(fd, size, MAX_MAP_SIZE, CSUM_CHUNK);
mdfour_begin(&m);
if (protocol_version >= 30) {
md5_begin(&m);
for(i = 0; i + CSUM_CHUNK <= len; i += CSUM_CHUNK) {
mdfour_update(&m, (uchar *)map_ptr(buf, i, CSUM_CHUNK),
CSUM_CHUNK);
for (i = 0; i + CSUM_CHUNK <= len; i += CSUM_CHUNK) {
md5_update(&m, (uchar *)map_ptr(buf, i, CSUM_CHUNK),
CSUM_CHUNK);
}
remainder = (int32)(len - i);
if (remainder > 0)
md5_update(&m, (uchar *)map_ptr(buf, i, remainder), remainder);
md5_result(&m, (uchar *)sum);
} else {
mdfour_begin(&m);
for (i = 0; i + CSUM_CHUNK <= len; i += CSUM_CHUNK) {
mdfour_update(&m, (uchar *)map_ptr(buf, i, CSUM_CHUNK),
CSUM_CHUNK);
}
/* 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. */
remainder = (int32)(len - i);
if (remainder > 0 || protocol_version >= 27)
mdfour_update(&m, (uchar *)map_ptr(buf, i, remainder), remainder);
mdfour_result(&m, (uchar *)sum);
}
/* 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);
close(fd);
unmap_file(buf);
}
static int32 sumresidue;
static char sumrbuf[CSUM_CHUNK];
static struct mdfour md;
static md_context md;
void sum_init(int seed)
{
char s[4];
mdfour_begin(&md);
sumresidue = 0;
SIVAL(s, 0, seed);
sum_update(s, 4);
if (protocol_version >= 30)
md5_begin(&md);
else {
mdfour_begin(&md);
sumresidue = 0;
SIVAL(s, 0, seed);
sum_update(s, 4);
}
}
/**
@@ -148,18 +177,23 @@ void sum_init(int seed)
* @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)
void sum_update(const char *p, int32 len)
{
if (protocol_version >= 30) {
md5_update(&md, (uchar *)p, len);
return;
}
if (len + sumresidue < CSUM_CHUNK) {
memcpy(sumrbuf + sumresidue, p, len);
memcpy(md.buffer + sumresidue, p, len);
sumresidue += len;
return;
}
if (sumresidue) {
int32 i = CSUM_CHUNK - sumresidue;
memcpy(sumrbuf + sumresidue, p, i);
mdfour_update(&md, (uchar *)sumrbuf, CSUM_CHUNK);
memcpy(md.buffer + sumresidue, p, i);
mdfour_update(&md, (uchar *)md.buffer, CSUM_CHUNK);
len -= i;
p += i;
}
@@ -172,13 +206,20 @@ void sum_update(char *p, int32 len)
sumresidue = len;
if (sumresidue)
memcpy(sumrbuf, p, sumresidue);
memcpy(md.buffer, p, sumresidue);
}
void sum_end(char *sum)
int sum_end(char *sum)
{
if (protocol_version >= 30) {
md5_result(&md, (uchar *)sum);
return MD5_DIGEST_LEN;
}
if (sumresidue || protocol_version >= 27)
mdfour_update(&md, (uchar *)sumrbuf, sumresidue);
mdfour_update(&md, (uchar *)md.buffer, sumresidue);
mdfour_result(&md, (uchar *)sum);
return MD4_DIGEST_LEN;
}

225
chmod.c Normal file
View File

@@ -0,0 +1,225 @@
/*
* Implement the core of the --chmod option.
*
* Copyright (C) 2002 Scott Howard
* Copyright (C) 2005-2008 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
#include "rsync.h"
extern mode_t orig_umask;
#define FLAG_X_KEEP (1<<0)
#define FLAG_DIRS_ONLY (1<<1)
#define FLAG_FILES_ONLY (1<<2)
struct chmod_mode_struct {
struct chmod_mode_struct *next;
int ModeAND, ModeOR;
char flags;
};
#define CHMOD_ADD 1
#define CHMOD_SUB 2
#define CHMOD_EQ 3
#define STATE_ERROR 0
#define STATE_1ST_HALF 1
#define STATE_2ND_HALF 2
/* Parse a chmod-style argument, and break it down into one or more AND/OR
* pairs in a linked list. We return a pointer to new items on succcess
* (appending the items to the specified list), or NULL on error. */
struct chmod_mode_struct *parse_chmod(const char *modestr,
struct chmod_mode_struct **root_mode_ptr)
{
int state = STATE_1ST_HALF;
int where = 0, what = 0, op = 0, topbits = 0, topoct = 0, flags = 0;
struct chmod_mode_struct *first_mode = NULL, *curr_mode = NULL,
*prev_mode = NULL;
while (state != STATE_ERROR) {
if (!*modestr || *modestr == ',') {
int bits;
if (!op) {
state = STATE_ERROR;
break;
}
prev_mode = curr_mode;
curr_mode = new_array(struct chmod_mode_struct, 1);
if (prev_mode)
prev_mode->next = curr_mode;
else
first_mode = curr_mode;
curr_mode->next = NULL;
if (where)
bits = where * what;
else {
where = 0111;
bits = (where * what) & ~orig_umask;
}
switch (op) {
case CHMOD_ADD:
curr_mode->ModeAND = CHMOD_BITS;
curr_mode->ModeOR = bits + topoct;
break;
case CHMOD_SUB:
curr_mode->ModeAND = CHMOD_BITS - bits - topoct;
curr_mode->ModeOR = 0;
break;
case CHMOD_EQ:
curr_mode->ModeAND = CHMOD_BITS - (where * 7) - (topoct ? topbits : 0);
curr_mode->ModeOR = bits + topoct;
break;
}
curr_mode->flags = flags;
if (!*modestr)
break;
modestr++;
state = STATE_1ST_HALF;
where = what = op = topoct = topbits = flags = 0;
}
if (state != STATE_2ND_HALF) {
switch (*modestr) {
case 'D':
if (flags & FLAG_FILES_ONLY)
state = STATE_ERROR;
flags |= FLAG_DIRS_ONLY;
break;
case 'F':
if (flags & FLAG_DIRS_ONLY)
state = STATE_ERROR;
flags |= FLAG_FILES_ONLY;
break;
case 'u':
where |= 0100;
topbits |= 04000;
break;
case 'g':
where |= 0010;
topbits |= 02000;
break;
case 'o':
where |= 0001;
break;
case 'a':
where |= 0111;
break;
case '+':
op = CHMOD_ADD;
state = STATE_2ND_HALF;
break;
case '-':
op = CHMOD_SUB;
state = STATE_2ND_HALF;
break;
case '=':
op = CHMOD_EQ;
state = STATE_2ND_HALF;
break;
default:
state = STATE_ERROR;
break;
}
} else {
switch (*modestr) {
case 'r':
what |= 4;
break;
case 'w':
what |= 2;
break;
case 'X':
flags |= FLAG_X_KEEP;
/* FALL THROUGH */
case 'x':
what |= 1;
break;
case 's':
if (topbits)
topoct |= topbits;
else
topoct = 04000;
break;
case 't':
topoct |= 01000;
break;
default:
state = STATE_ERROR;
break;
}
}
modestr++;
}
if (state == STATE_ERROR) {
free_chmod_mode(first_mode);
return NULL;
}
if (!(curr_mode = *root_mode_ptr))
*root_mode_ptr = first_mode;
else {
while (curr_mode->next)
curr_mode = curr_mode->next;
curr_mode->next = first_mode;
}
return first_mode;
}
/* Takes an existing file permission and a list of AND/OR changes, and
* create a new permissions. */
int tweak_mode(int mode, struct chmod_mode_struct *chmod_modes)
{
int IsX = mode & 0111;
int NonPerm = mode & ~CHMOD_BITS;
for ( ; chmod_modes; chmod_modes = chmod_modes->next) {
if ((chmod_modes->flags & FLAG_DIRS_ONLY) && !S_ISDIR(NonPerm))
continue;
if ((chmod_modes->flags & FLAG_FILES_ONLY) && S_ISDIR(NonPerm))
continue;
mode &= chmod_modes->ModeAND;
if ((chmod_modes->flags & FLAG_X_KEEP) && !IsX && !S_ISDIR(NonPerm))
mode |= chmod_modes->ModeOR & ~0111;
else
mode |= chmod_modes->ModeOR;
}
return mode | NonPerm;
}
/* Free the linked list created by parse_chmod. */
int free_chmod_mode(struct chmod_mode_struct *chmod_modes)
{
struct chmod_mode_struct *next;
while (chmod_modes) {
next = chmod_modes->next;
free(chmod_modes);
chmod_modes = next;
}
return 0;
}

220
cleanup.c
View File

@@ -1,30 +1,38 @@
/* -*- 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.
*/
/*
* End-of-run cleanup routines.
*
* Copyright (C) 1996-2000 Andrew Tridgell
* Copyright (C) 1996 Paul Mackerras
* Copyright (C) 2002 Martin Pool
* Copyright (C) 2003-2008 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
#include "rsync.h"
extern int am_server;
extern int am_daemon;
extern int io_error;
extern int keep_partial;
extern int log_got_error;
extern int got_xfer_error;
extern char *partial_dir;
extern char *logfile_name;
#ifdef HAVE_SIGACTION
static struct sigaction sigact;
#endif
/**
* Close all open sockets and files, allowing a (somewhat) graceful
@@ -70,8 +78,8 @@ void close_all(void)
**/
int cleanup_got_literal = 0;
static char *cleanup_fname;
static char *cleanup_new_fname;
static const char *cleanup_fname;
static const char *cleanup_new_fname;
static struct file_struct *cleanup_file;
static int cleanup_fd_r, cleanup_fd_w;
static pid_t cleanup_pid = 0;
@@ -83,89 +91,133 @@ pid_t cleanup_child_pid = -1;
*
* @param code one of the RERR_* codes from errcode.h.
**/
void _exit_cleanup(int code, const char *file, int line)
NORETURN void _exit_cleanup(int code, const char *file, int line)
{
int ocode = code;
static int inside_cleanup = 0;
static int cleanup_step = 0;
static int exit_code = 0;
static int unmodified_code = 0;
if (inside_cleanup > 10) {
/* prevent the occasional infinite recursion */
return;
}
inside_cleanup++;
SIGACTION(SIGUSR1, SIG_IGN);
SIGACTION(SIGUSR2, SIG_IGN);
signal(SIGUSR1, SIG_IGN);
signal(SIGUSR2, SIG_IGN);
if (exit_code) /* Preserve first error code when recursing. */
code = exit_code;
if (verbose > 3) {
rprintf(FINFO,"_exit_cleanup(code=%d, file=%s, line=%d): entered\n",
code, safe_fname(file), line);
}
/* If this is the exit at the end of the run, the server side
* should not attempt to output a message (see log.c). */
if (am_server && code == 0)
am_server = 2;
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;
/* Some of our actions might cause a recursive call back here, so we
* keep track of where we are in the cleanup and never repeat a step. */
switch (cleanup_step) {
#include "case_N.h" /* case 0: cleanup_step++; */
exit_code = unmodified_code = code;
if (verbose > 3) {
rprintf(FINFO,
"_exit_cleanup(code=%d, file=%s, line=%d): entered\n",
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);
/* FALLTHROUGH */
#include "case_N.h"
if (cleanup_child_pid != -1) {
int status;
int pid = wait_process(cleanup_child_pid, &status, WNOHANG);
if (pid == cleanup_child_pid) {
status = WEXITSTATUS(status);
if (status > code)
code = exit_code = status;
}
}
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());
/* FALLTHROUGH */
#include "case_N.h"
if (cleanup_got_literal && cleanup_fname && cleanup_new_fname
&& keep_partial && handle_partial_dir(cleanup_new_fname, PDIR_CREATE)) {
const 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, NULL, NULL,
cleanup_file, 0, !partial_dir);
}
/* FALLTHROUGH */
#include "case_N.h"
io_flush(FULL_FLUSH);
/* FALLTHROUGH */
#include "case_N.h"
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 = exit_code = RERR_DEL_LIMIT;
if (io_error & IOERR_VANISHED)
code = exit_code = RERR_VANISHED;
if (io_error & IOERR_GENERAL || got_xfer_error)
code = exit_code = RERR_PARTIAL;
}
if (code || am_daemon || (logfile_name && (am_server || !verbose)))
log_exit(code, file, line);
/* FALLTHROUGH */
#include "case_N.h"
if (verbose > 2) {
rprintf(FINFO,
"_exit_cleanup(code=%d, file=%s, line=%d): "
"about to call exit(%d)\n",
unmodified_code, file, line, code);
}
/* FALLTHROUGH */
#include "case_N.h"
if (am_server && code)
msleep(100);
close_all();
/* FALLTHROUGH */
default:
break;
}
if (code == 0) {
if ((io_error & ~IOERR_VANISHED) || log_got_error)
code = RERR_PARTIAL;
else if (io_error)
code = RERR_VANISHED;
}
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);
}
void cleanup_disable(void)
{
cleanup_fname = NULL;
cleanup_fname = cleanup_new_fname = NULL;
cleanup_got_literal = 0;
}
void cleanup_set(char *fnametmp, char *fname, struct file_struct *file,
void cleanup_set(const char *fnametmp, const char *fname, struct file_struct *file,
int fd_r, int fd_w)
{
cleanup_fname = fnametmp;
cleanup_new_fname = fname;
cleanup_new_fname = fname; /* can be NULL on a partial-dir failure */
cleanup_file = file;
cleanup_fd_r = fd_r;
cleanup_fd_w = fd_w;

View File

@@ -1,40 +1,34 @@
/* -*- 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.
*
* Copyright (C) 1992-2001 Andrew Tridgell <tridge@samba.org>
* Copyright (C) 2001, 2002 Martin Pool <mbp@samba.org>
* Copyright (C) 2002-2008 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
/*
* 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;
@@ -55,7 +49,7 @@ char *client_addr(int fd)
initialised = 1;
if (am_server) { /* daemon over --rsh mode */
strcpy(addr_buf, "0.0.0.0");
strlcpy(addr_buf, "0.0.0.0", sizeof addr_buf);
if ((ssh_info = getenv("SSH_CONNECTION")) != NULL
|| (ssh_info = getenv("SSH_CLIENT")) != NULL
|| (ssh_info = getenv("SSH2_CLIENT")) != NULL) {
@@ -104,7 +98,7 @@ char *client_name(int fd)
if (initialised)
return name_buf;
strcpy(name_buf, default_name);
strlcpy(name_buf, default_name, sizeof name_buf);
initialised = 1;
memset(&ss, 0, sizeof ss);
@@ -138,6 +132,8 @@ char *client_name(int fd)
memcpy(&ss, answer->ai_addr, ss_len);
break;
#endif
default:
exit_cleanup(RERR_SOCKETIO);
}
freeaddrinfo(answer);
} else {
@@ -147,7 +143,7 @@ char *client_name(int fd)
if (lookup_name(fd, &ss, ss_len, name_buf, sizeof name_buf,
port_buf, sizeof port_buf) == 0)
check_name(fd, &ss, name_buf);
check_name(fd, &ss, name_buf, sizeof name_buf);
return name_buf;
}
@@ -211,18 +207,18 @@ void client_sockaddr(int fd,
**/
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)
char *name_buf, size_t name_buf_size,
char *port_buf, size_t port_buf_size)
{
int name_err;
/* reverse lookup */
name_err = getnameinfo((struct sockaddr *) ss, ss_len,
name_buf, name_buf_len,
port_buf, port_buf_len,
name_buf, name_buf_size,
port_buf, port_buf_size,
NI_NAMEREQD | NI_NUMERICSERV);
if (name_err != 0) {
strcpy(name_buf, default_name);
strlcpy(name_buf, default_name, name_buf_size);
rprintf(FLOG, "name lookup failed for %s: %s\n",
client_addr(fd), gai_strerror(name_err));
return name_err;
@@ -270,7 +266,7 @@ int compare_addrinfo_sockaddr(const struct addrinfo *ai,
if (ai->ai_addrlen < sizeof (struct sockaddr_in6)) {
rprintf(FLOG, "%s: too short sockaddr_in6; length=%d\n",
fn, ai->ai_addrlen);
fn, (int)ai->ai_addrlen);
return 1;
}
@@ -303,7 +299,7 @@ int compare_addrinfo_sockaddr(const struct addrinfo *ai,
**/
int check_name(int fd,
const struct sockaddr_storage *ss,
char *name_buf)
char *name_buf, size_t name_buf_size)
{
struct addrinfo hints, *res, *res0;
int error;
@@ -317,11 +313,10 @@ int check_name(int fd,
if (error) {
rprintf(FLOG, "forward name lookup for %s failed: %s\n",
name_buf, gai_strerror(error));
strcpy(name_buf, default_name);
strlcpy(name_buf, default_name, name_buf_size);
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) {
@@ -334,13 +329,13 @@ int check_name(int fd,
* address that was the same as ss. */
rprintf(FLOG, "no known address for \"%s\": "
"spoofed address?\n", name_buf);
strcpy(name_buf, default_name);
strlcpy(name_buf, default_name, name_buf_size);
} 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);
strlcpy(name_buf, default_name, name_buf_size);
}
freeaddrinfo(res0);

View File

File diff suppressed because it is too large Load Diff

273
compat.c
View File

@@ -1,43 +1,150 @@
/*
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.
*/
/**
* @file compat.c
*
/*
* Compatibility routines for older rsync protocol versions.
**/
*
* Copyright (C) Andrew Tridgell 1996
* Copyright (C) Paul Mackerras 1996
* Copyright (C) 2004-2008 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
#include "rsync.h"
int remote_protocol = 0;
int file_extra_cnt = 0; /* count of file-list extras that everyone gets */
int inc_recurse = 0;
extern int verbose;
extern int am_server;
extern int am_sender;
extern int local_server;
extern int inplace;
extern int recurse;
extern int use_qsort;
extern int allow_inc_recurse;
extern int append_mode;
extern int fuzzy_basis;
extern int read_batch;
extern int delay_updates;
extern int checksum_seed;
extern int basis_dir_cnt;
extern int prune_empty_dirs;
extern int protocol_version;
extern int protect_args;
extern int preserve_uid;
extern int preserve_gid;
extern int preserve_acls;
extern int preserve_xattrs;
extern int need_messages_from_generator;
extern int delete_mode, delete_before, delete_during, delete_after;
extern char *shell_cmd;
extern char *partial_dir;
extern char *dest_option;
extern char *files_from;
extern char *filesfrom_host;
extern struct filter_list_struct filter_list;
extern int need_unsorted_flist;
#ifdef ICONV_OPTION
extern iconv_t ic_send, ic_recv;
#endif
/* These index values are for the file-list's extra-attribute array. */
int uid_ndx, gid_ndx, acls_ndx, xattrs_ndx, unsort_ndx;
int receiver_symlink_times = 0; /* receiver can set the time on a symlink */
#ifdef ICONV_OPTION
int filesfrom_convert = 0;
#endif
#define CF_INC_RECURSE (1<<0)
#define CF_SYMLINK_TIMES (1<<1)
static const char *client_info;
/* The server makes sure that if either side only supports a pre-release
* version of a protocol, that both sides must speak a compatible version
* of that protocol for it to be advertised as available. */
static void check_sub_protocol(void)
{
char *dot;
int their_protocol, their_sub;
#if SUBPROTOCOL_VERSION != 0
int our_sub = protocol_version < PROTOCOL_VERSION ? 0 : SUBPROTOCOL_VERSION;
#else
int our_sub = 0;
#endif
/* client_info starts with VER.SUB string if client is a pre-release. */
if (!(their_protocol = atoi(client_info))
|| !(dot = strchr(client_info, '.'))
|| !(their_sub = atoi(dot+1))) {
#if SUBPROTOCOL_VERSION != 0
if (our_sub)
protocol_version--;
#endif
return;
}
if (their_protocol < protocol_version) {
if (their_sub)
protocol_version = their_protocol - 1;
return;
}
if (their_protocol > protocol_version)
their_sub = 0; /* 0 == final version of older protocol */
if (their_sub != our_sub)
protocol_version--;
}
void set_allow_inc_recurse(void)
{
client_info = shell_cmd ? shell_cmd : "";
if (!recurse || use_qsort)
allow_inc_recurse = 0;
else if (!am_sender
&& (delete_before || delete_after
|| delay_updates || prune_empty_dirs))
allow_inc_recurse = 0;
else if (am_server && !local_server
&& (strchr(client_info, 'i') == NULL))
allow_inc_recurse = 0;
}
void setup_protocol(int f_out,int f_in)
{
if (am_sender)
file_extra_cnt += PTR_EXTRA_CNT;
else
file_extra_cnt++;
if (preserve_uid)
uid_ndx = ++file_extra_cnt;
if (preserve_gid)
gid_ndx = ++file_extra_cnt;
if (preserve_acls && !am_sender)
acls_ndx = ++file_extra_cnt;
if (preserve_xattrs)
xattrs_ndx = ++file_extra_cnt;
if (am_server)
set_allow_inc_recurse();
if (remote_protocol == 0) {
if (am_server && !local_server)
check_sub_protocol();
if (!read_batch)
write_int(f_out, protocol_version);
remote_protocol = read_int(f_in);
@@ -45,7 +152,7 @@ void setup_protocol(int f_out,int f_in)
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",
rprintf(FERROR, "The protocol version in the batch file is too new (%d > %d).\n",
remote_protocol, protocol_version);
exit_cleanup(RERR_PROTOCOL);
}
@@ -74,14 +181,122 @@ void setup_protocol(int f_out,int f_in)
PROTOCOL_VERSION, am_server? "Server" : "Client");
exit_cleanup(RERR_PROTOCOL);
}
if (read_batch)
check_batch_flags();
if (fuzzy_basis && protocol_version < 29) {
rprintf(FERROR,
"--fuzzy requres protocol 29 or higher (negotiated %d).\n",
protocol_version);
exit_cleanup(RERR_PROTOCOL);
if (protocol_version < 30) {
if (append_mode == 1)
append_mode = 2;
if (preserve_acls && !local_server) {
rprintf(FERROR,
"--acls requires protocol 30 or higher"
" (negotiated %d).\n",
protocol_version);
exit_cleanup(RERR_PROTOCOL);
}
if (preserve_xattrs && !local_server) {
rprintf(FERROR,
"--xattrs requires protocol 30 or higher"
" (negotiated %d).\n",
protocol_version);
exit_cleanup(RERR_PROTOCOL);
}
}
if (delete_mode && !(delete_before+delete_during+delete_after)) {
if (protocol_version < 30)
delete_before = 1;
else
delete_during = 1;
}
if (protocol_version < 29) {
if (fuzzy_basis) {
rprintf(FERROR,
"--fuzzy requires protocol 29 or higher"
" (negotiated %d).\n",
protocol_version);
exit_cleanup(RERR_PROTOCOL);
}
if (basis_dir_cnt && inplace) {
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) {
rprintf(FERROR,
"Using more than one %s option requires protocol"
" 29 or higher (negotiated %d).\n",
dest_option, protocol_version);
exit_cleanup(RERR_PROTOCOL);
}
if (prune_empty_dirs) {
rprintf(FERROR,
"--prune-empty-dirs requires protocol 29 or higher"
" (negotiated %d).\n",
protocol_version);
exit_cleanup(RERR_PROTOCOL);
}
} else if (protocol_version >= 30) {
int compat_flags;
if (am_server) {
compat_flags = allow_inc_recurse ? CF_INC_RECURSE : 0;
#if defined HAVE_LUTIMES && defined HAVE_UTIMES
compat_flags |= CF_SYMLINK_TIMES;
#endif
write_byte(f_out, compat_flags);
} else
compat_flags = read_byte(f_in);
/* The inc_recurse var MUST be set to 0 or 1. */
inc_recurse = compat_flags & CF_INC_RECURSE ? 1 : 0;
if (am_sender) {
receiver_symlink_times = am_server
? strchr(client_info, 'L') != NULL
: !!(compat_flags & CF_SYMLINK_TIMES);
}
#if defined HAVE_LUTIMES && defined HAVE_UTIMES
else
receiver_symlink_times = 1;
#endif
if (inc_recurse && !allow_inc_recurse) {
/* This should only be able to happen in a batch. */
fprintf(stderr,
"Incompatible options specified for inc-recursive %s.\n",
read_batch ? "batch file" : "connection");
exit_cleanup(RERR_SYNTAX);
}
need_messages_from_generator = 1;
#if defined HAVE_LUTIMES && defined HAVE_UTIMES
} else if (!am_sender) {
receiver_symlink_times = 1;
#endif
}
if (need_unsorted_flist && (!am_sender || inc_recurse))
unsort_ndx = ++file_extra_cnt;
if (partial_dir && *partial_dir != '/' && (!am_server || local_server)) {
int flags = MATCHFLG_NO_PREFIXES | MATCHFLG_DIRECTORY;
if (!am_sender || protocol_version >= 30)
flags |= MATCHFLG_PERISHABLE;
parse_rule(&filter_list, partial_dir, flags, 0);
}
#ifdef ICONV_OPTION
if (protect_args && files_from) {
if (am_sender)
filesfrom_convert = filesfrom_host && ic_send != (iconv_t)-1;
else
filesfrom_convert = !filesfrom_host && ic_recv != (iconv_t)-1;
}
#endif
if (am_server) {
if (!checksum_seed)
checksum_seed = time(NULL);

650
config.guess vendored
View File

File diff suppressed because it is too large Load Diff

206
config.sub vendored
View File

@@ -1,9 +1,10 @@
#! /bin/sh
# Configuration validation subroutine script.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
# Inc.
timestamp='2003-08-18'
timestamp='2006-07-02'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
@@ -21,14 +22,15 @@ timestamp='2003-08-18'
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
# 02110-1301, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Please send patches to <config-patches@gnu.org>. Submit a context
# diff and a properly formatted ChangeLog entry.
#
@@ -70,7 +72,7 @@ Report bugs and patches to <config-patches@gnu.org>."
version="\
GNU config.sub ($timestamp)
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
@@ -83,11 +85,11 @@ Try \`$me --help' for more information."
while test $# -gt 0 ; do
case $1 in
--time-stamp | --time* | -t )
echo "$timestamp" ; exit 0 ;;
echo "$timestamp" ; exit ;;
--version | -v )
echo "$version" ; exit 0 ;;
echo "$version" ; exit ;;
--help | --h* | -h )
echo "$usage"; exit 0 ;;
echo "$usage"; exit ;;
-- ) # Stop option processing
shift; break ;;
- ) # Use stdin as input.
@@ -99,7 +101,7 @@ while test $# -gt 0 ; do
*local*)
# First pass through any local machine types.
echo $1
exit 0;;
exit ;;
* )
break ;;
@@ -118,7 +120,9 @@ esac
# Here we must recognize all the valid KERNEL-OS combinations.
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
nto-qnx* | linux-gnu* | linux-dietlibc | kfreebsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
@@ -144,7 +148,7 @@ case $os in
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-apple | -axis)
-apple | -axis | -knuth | -cray)
os=
basic_machine=$1
;;
@@ -169,6 +173,10 @@ case $os in
-hiux*)
os=-hiuxwe2
;;
-sco6)
os=-sco5v6
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco5)
os=-sco3.2v5
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
@@ -185,6 +193,10 @@ case $os in
# Don't forget version if it is 3.2v4 or newer.
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco5v6*)
# Don't forget version if it is 3.2v4 or newer.
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco*)
os=-sco3.2v2
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
@@ -229,14 +241,16 @@ case $basic_machine in
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
| am33_2.0 \
| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
| bfin \
| c4x | clipper \
| d10v | d30v | dlx | dsp16xx \
| fr30 | frv \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| i370 | i860 | i960 | ia64 \
| ip2k | iq2000 \
| m32r | m68000 | m68k | m88k | mcore \
| m32c | m32r | m32rle | m68000 | m68k | m88k \
| maxq | mb | microblaze | mcore \
| mips | mipsbe | mipseb | mipsel | mipsle \
| mips16 \
| mips64 | mips64el \
@@ -245,6 +259,7 @@ case $basic_machine in
| mips64vr4100 | mips64vr4100el \
| mips64vr4300 | mips64vr4300el \
| mips64vr5000 | mips64vr5000el \
| mips64vr5900 | mips64vr5900el \
| mipsisa32 | mipsisa32el \
| mipsisa32r2 | mipsisa32r2el \
| mipsisa64 | mipsisa64el \
@@ -253,20 +268,23 @@ case $basic_machine in
| mipsisa64sr71k | mipsisa64sr71kel \
| mipstx39 | mipstx39el \
| mn10200 | mn10300 \
| mt \
| msp430 \
| nios | nios2 \
| ns16k | ns32k \
| openrisc | or32 \
| or32 \
| pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
| pyramid \
| sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
| sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
| sh64 | sh64le \
| sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \
| strongarm \
| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
| spu | strongarm \
| tahoe | thumb | tic4x | tic80 | tron \
| v850 | v850e \
| we32k \
| x86 | xscale | xstormy16 | xtensa \
| x86 | xscale | xscalee[bl] | xstormy16 | xtensa \
| z8k)
basic_machine=$basic_machine-unknown
;;
@@ -277,6 +295,9 @@ case $basic_machine in
;;
m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
;;
ms1)
basic_machine=mt-unknown
;;
# We use `pc' rather than `unknown'
# because (1) that's what they normally are, and
@@ -296,10 +317,10 @@ case $basic_machine in
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
| avr-* \
| bs2000-* \
| avr-* | avr32-* \
| bfin-* | bs2000-* \
| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
| clipper-* | cydra-* \
| clipper-* | craynv-* | cydra-* \
| d10v-* | d30v-* | dlx-* \
| elxsi-* \
| f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
@@ -307,9 +328,9 @@ case $basic_machine in
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
| i*86-* | i860-* | i960-* | ia64-* \
| ip2k-* | iq2000-* \
| m32r-* \
| m32c-* | m32r-* | m32rle-* \
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
| m88110-* | m88k-* | mcore-* \
| m88110-* | m88k-* | maxq-* | mcore-* \
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
| mips16-* \
| mips64-* | mips64el-* \
@@ -318,6 +339,7 @@ case $basic_machine in
| mips64vr4100-* | mips64vr4100el-* \
| mips64vr4300-* | mips64vr4300el-* \
| mips64vr5000-* | mips64vr5000el-* \
| mips64vr5900-* | mips64vr5900el-* \
| mipsisa32-* | mipsisa32el-* \
| mipsisa32r2-* | mipsisa32r2el-* \
| mipsisa64-* | mipsisa64el-* \
@@ -325,24 +347,28 @@ case $basic_machine in
| mipsisa64sb1-* | mipsisa64sb1el-* \
| mipsisa64sr71k-* | mipsisa64sr71kel-* \
| mipstx39-* | mipstx39el-* \
| mmix-* \
| mt-* \
| msp430-* \
| none-* | np1-* | nv1-* | ns16k-* | ns32k-* \
| nios-* | nios2-* \
| none-* | np1-* | ns16k-* | ns32k-* \
| orion-* \
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
| pyramid-* \
| romp-* | rs6000-* \
| sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \
| sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
| sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \
| sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
| sparclite-* \
| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
| tahoe-* | thumb-* \
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
| tron-* \
| v850-* | v850e-* | vax-* \
| we32k-* \
| x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \
| xtensa-* \
| x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \
| xstormy16-* | xtensa-* \
| ymp-* \
| z8k-*)
;;
@@ -362,6 +388,9 @@ case $basic_machine in
basic_machine=a29k-amd
os=-udi
;;
abacus)
basic_machine=abacus-unknown
;;
adobe68k)
basic_machine=m68010-adobe
os=-scout
@@ -379,6 +408,9 @@ case $basic_machine in
amd64)
basic_machine=x86_64-pc
;;
amd64-*)
basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
amdahl)
basic_machine=580-amdahl
os=-sysv
@@ -438,12 +470,27 @@ case $basic_machine in
basic_machine=j90-cray
os=-unicos
;;
craynv)
basic_machine=craynv-cray
os=-unicosmp
;;
cr16c)
basic_machine=cr16c-unknown
os=-elf
;;
crds | unos)
basic_machine=m68k-crds
;;
crisv32 | crisv32-* | etraxfs*)
basic_machine=crisv32-axis
;;
cris | cris-* | etrax*)
basic_machine=cris-axis
;;
crx)
basic_machine=crx-unknown
os=-elf
;;
da30 | da30-*)
basic_machine=m68k-da30
;;
@@ -466,6 +513,10 @@ case $basic_machine in
basic_machine=m88k-motorola
os=-sysv3
;;
djgpp)
basic_machine=i586-pc
os=-msdosdjgpp
;;
dpx20 | dpx20-*)
basic_machine=rs6000-bull
os=-bosx
@@ -644,10 +695,6 @@ case $basic_machine in
mips3*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
;;
mmix*)
basic_machine=mmix-knuth
os=-mmixware
;;
monitor)
basic_machine=m68k-rom68k
os=-coff
@@ -660,6 +707,9 @@ case $basic_machine in
basic_machine=i386-pc
os=-msdos
;;
ms1-*)
basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
;;
mvs)
basic_machine=i370-ibm
os=-mvs
@@ -728,10 +778,6 @@ case $basic_machine in
np1)
basic_machine=np1-gould
;;
nv1)
basic_machine=nv1-cray
os=-unicosmp
;;
nsr-tandem)
basic_machine=nsr-tandem
;;
@@ -739,9 +785,12 @@ case $basic_machine in
basic_machine=hppa1.1-oki
os=-proelf
;;
or32 | or32-*)
openrisc | openrisc-*)
basic_machine=or32-unknown
os=-coff
;;
os400)
basic_machine=powerpc-ibm
os=-os400
;;
OSE68000 | ose68000)
basic_machine=m68000-ericsson
@@ -768,6 +817,12 @@ case $basic_machine in
pc532 | pc532-*)
basic_machine=ns32k-pc532
;;
pc98)
basic_machine=i386-pc
;;
pc98-*)
basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentium | p5 | k5 | k6 | nexgen | viac3)
basic_machine=i586-pc
;;
@@ -824,6 +879,10 @@ case $basic_machine in
basic_machine=i586-unknown
os=-pw32
;;
rdos)
basic_machine=i386-pc
os=-rdos
;;
rom68k)
basic_machine=m68k-rom68k
os=-coff
@@ -963,6 +1022,10 @@ case $basic_machine in
tower | tower-32)
basic_machine=m68k-ncr
;;
tpf)
basic_machine=s390x-ibm
os=-tpf
;;
udi29k)
basic_machine=a29k-amd
os=-udi
@@ -1006,6 +1069,10 @@ case $basic_machine in
basic_machine=hppa1.1-winbond
os=-proelf
;;
xbox)
basic_machine=i686-pc
os=-mingw32
;;
xps | xps100)
basic_machine=xps100-honeywell
;;
@@ -1036,6 +1103,9 @@ case $basic_machine in
romp)
basic_machine=romp-ibm
;;
mmix)
basic_machine=mmix-knuth
;;
rs6000)
basic_machine=rs6000-ibm
;;
@@ -1052,13 +1122,10 @@ case $basic_machine in
we32k)
basic_machine=we32k-att
;;
sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele)
sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
basic_machine=sh-unknown
;;
sh64)
basic_machine=sh64-unknown
;;
sparc | sparcv9 | sparcv9b)
sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
basic_machine=sparc-sun
;;
cydra)
@@ -1131,19 +1198,23 @@ case $os in
| -aos* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -netbsd* | -openbsd* | -kfreebsd* | -freebsd* | -riscix* \
| -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
| -openbsd* | -solidbsd* \
| -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
| -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -chorusos* | -chorusrdb* \
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
| -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
| -uxpv* | -beos* | -mpeix* | -udk* \
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
| -powermax* | -dnix* | -nx6 | -nx7 | -sei*)
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
| -skyos* | -haiku* | -rdos* | -toppers*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)
@@ -1161,7 +1232,7 @@ case $os in
os=`echo $os | sed -e 's|nto|nto-qnx|'`
;;
-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
| -windows* | -osx | -abug | -netware* | -os9* | -beos* \
| -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
| -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
;;
-mac*)
@@ -1182,6 +1253,9 @@ case $os in
-opened*)
os=-openedition
;;
-os400*)
os=-os400
;;
-wince*)
os=-wince
;;
@@ -1203,6 +1277,9 @@ case $os in
-atheos*)
os=-atheos
;;
-syllable*)
os=-syllable
;;
-386bsd)
os=-bsd
;;
@@ -1225,6 +1302,9 @@ case $os in
-sinix*)
os=-sysv4
;;
-tpf*)
os=-tpf
;;
-triton*)
os=-sysv3
;;
@@ -1261,6 +1341,9 @@ case $os in
-kaos*)
os=-kaos
;;
-zvmoe)
os=-zvmoe
;;
-none)
;;
*)
@@ -1283,6 +1366,9 @@ else
# system, and we'll never get to this point.
case $basic_machine in
spu-*)
os=-elf
;;
*-acorn)
os=-riscix1.2
;;
@@ -1292,9 +1378,9 @@ case $basic_machine in
arm*-semi)
os=-aout
;;
c4x-* | tic4x-*)
os=-coff
;;
c4x-* | tic4x-*)
os=-coff
;;
# This must come before the *-dec entry.
pdp10-*)
os=-tops20
@@ -1338,9 +1424,15 @@ case $basic_machine in
*-be)
os=-beos
;;
*-haiku)
os=-haiku
;;
*-ibm)
os=-aix
;;
*-knuth)
os=-mmixware
;;
*-wec)
os=-proelf
;;
@@ -1473,9 +1565,15 @@ case $basic_machine in
-mvs* | -opened*)
vendor=ibm
;;
-os400*)
vendor=ibm
;;
-ptx*)
vendor=sequent
;;
-tpf*)
vendor=ibm
;;
-vxsim* | -vxworks* | -windiss*)
vendor=wrs
;;
@@ -1500,7 +1598,7 @@ case $basic_machine in
esac
echo $basic_machine$os
exit 0
exit
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)

25
configure vendored Executable file
View File

@@ -0,0 +1,25 @@
#!/bin/sh -e
# This configure script ensures that the configure.sh script exists, and
# if not, it tries to fetch rsync's generated files or build them. We
# then transfer control to the configure.sh script to do the real work.
dir=`dirname $0`
realconfigure="$dir/configure.sh"
if test ! -f "$realconfigure"; then
if test -f "$HOME/build_farm/build_test.fns"; then
# Allow the build farm to grab latest files via rsync.
actions='build fetch'
else
actions='build'
fi
if "$dir/prepare-source" $actions; then
:
else
echo 'Failed to build configure.sh and/or config.h.in -- giving up.' >&2
rm -f "$realconfigure"
exit 1
fi
fi
exec "$realconfigure" "${@}"

View File

@@ -5,7 +5,7 @@ AC_CONFIG_SRCDIR([byteorder.h])
AC_CONFIG_HEADER(config.h)
AC_PREREQ(2.59)
RSYNC_VERSION=2.6.4pre1
RSYNC_VERSION=3.0.2
AC_SUBST(RSYNC_VERSION)
AC_MSG_NOTICE([Configuring rsync $RSYNC_VERSION])
@@ -26,8 +26,7 @@ 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
if test x"$ac_cv_prog_cc_stdc" = x"no"; then
AC_MSG_WARN([rsync requires an ANSI C compiler and you don't seem to have one])
fi
@@ -38,12 +37,10 @@ fi
AC_MSG_CHECKING([whether to include debugging symbols])
AC_ARG_ENABLE(debug,
AC_HELP_STRING([--enable-debug],
[including debugging symbols and features (default yes)]),
[], [])
AC_HELP_STRING([--disable-debug],
[disable debugging symbols and features]))
if test x"$enable_debug" = x"no"
then
if test x"$enable_debug" = x"no"; then
AC_MSG_RESULT(no)
CFLAGS=${CFLAGS-"-O"}
else
@@ -54,14 +51,10 @@ else
fi
AC_ARG_ENABLE(profile,
AC_HELP_STRING([--enable-profile],
[turn on CPU profiling (default no)],
[], []))
if test x"$enable_profile" = xyes
then
[turn on CPU profiling]))
if test x"$enable_profile" = x"yes"; then
CFLAGS="$CFLAGS -pg"
fi
@@ -69,10 +62,8 @@ 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
[turn on extra debug features]))
if test x"$enable_maintainer_mode" = x"yes"; then
CFLAGS="$CFLAGS -DMAINTAINER_MODE"
fi
@@ -82,16 +73,15 @@ fi
CFLAGS="$CFLAGS -DHAVE_CONFIG_H"
# If GCC, turn on warnings.
if test x"$GCC" = x"yes"
then
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_HELP_STRING([--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)],
AC_HELP_STRING([--with-rsync-path=PATH], [set default --rsync-path to PATH (default: rsync)]),
[ RSYNC_PATH="$with_rsync_path" ],
[ RSYNC_PATH="rsync" ])
@@ -122,18 +112,43 @@ 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, [remote shell is remsh not rsh])
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
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])
# arrgh. libc in the current debian stable screws up the largefile
AC_CHECK_PROG(HAVE_YODL2MAN, yodl2man, 1, 0)
if test x$HAVE_YODL2MAN = x1; then
MAKE_MAN=man
fi
AC_ARG_WITH(nobody-group,
AC_HELP_STRING([--with-nobody-group=GROUP],
[set the default unprivileged group (default nobody or nogroup)]),
[ NOBODY_GROUP="$with_nobody_group" ])
if test x"$with_nobody_group" = x; then
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)
fi
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 some old debian version screwed up the largefile
# stuff, getting byte range locking wrong
AC_CACHE_CHECK([for broken largefile support],rsync_cv_HAVE_BROKEN_LARGEFILE,[
AC_TRY_RUN([
@@ -179,10 +194,9 @@ ipv6lib=none
ipv6trylibc=yes
AC_ARG_ENABLE(ipv6,
AC_HELP_STRING([--disable-ipv6], [don't even try to use IPv6]))
if test "x$enable_ipv6" != xno
then
AC_HELP_STRING([--disable-ipv6],
[don't even try to use IPv6]))
if test x"$enable_ipv6" != x"no"; then
AC_MSG_CHECKING([ipv6 stack type])
for i in inria kame linux-glibc linux-inet6 toshiba v6d zeta; do
case $i in
@@ -271,6 +285,16 @@ yes
AC_SEARCH_LIBS(getaddrinfo, inet6)
fi
dnl Do you want to disable use of locale functions
AC_ARG_ENABLE([locale],
AC_HELP_STRING([--disable-locale],
[disable locale features]))
AH_TEMPLATE([CONFIG_LOCALE],
[Undefine if you don't want locale features. By default this is defined.])
if test x"$enable_locale" != x"no"; then
AC_DEFINE(CONFIG_LOCALE)
fi
AC_MSG_CHECKING([whether to call shutdown on all sockets])
case $host_os in
*cygwin* ) AC_MSG_RESULT(yes)
@@ -287,26 +311,56 @@ 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 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 \
netdb.h malloc.h float.h)
sys/un.h sys/attr.h mcheck.h arpa/inet.h arpa/nameser.h locale.h \
netdb.h malloc.h float.h limits.h iconv.h libcharset.h langinfo.h \
sys/acl.h acl/libacl.h attr/xattr.h sys/xattr.h sys/extattr.h \
popt.h popt/popt.h)
AC_HEADER_MAJOR
AC_CACHE_CHECK([if makedev takes 3 args],rsync_cv_MAKEDEV_TAKES_3_ARGS,[
AC_TRY_RUN([
#include <sys/types.h>
#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
int main(void)
{
dev_t dev = makedev(0, 5, 7);
if (major(dev) != 5 || minor(dev) != 7)
exit(1);
return 0;
}
],
rsync_cv_MAKEDEV_TAKES_3_ARGS=yes,rsync_cv_MAKEDEV_TAKES_3_ARGS=no,rsync_cv_MAKEDEV_TAKES_3_ARGS=no)])
if test x"$rsync_cv_MAKEDEV_TAKES_3_ARGS" = x"yes"; then
AC_DEFINE(MAKEDEV_TAKES_3_ARGS, 1, [Define to 1 if makedev() takes 3 args])
fi
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(long long)
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(int16_t)
AC_CHECK_SIZEOF(uint16_t)
AC_CHECK_SIZEOF(int32_t)
AC_CHECK_SIZEOF(uint32_t)
AC_CHECK_SIZEOF(int64_t)
AC_CHECK_SIZEOF(off_t)
AC_CHECK_SIZEOF(off64_t)
AC_CHECK_SIZEOF(time_t)
AC_C_INLINE
AC_C_LONG_DOUBLE
AC_TYPE_SIGNAL
AC_TYPE_UID_T
AC_TYPE_MODE_T
AC_TYPE_OFF_T
AC_TYPE_SIZE_T
AC_TYPE_PID_T
AC_CHECK_TYPES([mode_t,off_t,size_t,pid_t,id_t])
AC_TYPE_GETGROUPS
AC_CHECK_MEMBERS([struct stat.st_rdev])
@@ -355,13 +409,43 @@ if test x"$ac_cv_func_connect" = x"no"; then
fi
fi
AC_CHECK_LIB(resolv, inet_ntop)
AC_SEARCH_LIBS(inet_ntop, resolv)
# Solaris and HP-UX weirdness:
# Search for libiconv_open (not iconv_open) to discover if -liconv is needed!
AC_SEARCH_LIBS(libiconv_open, iconv)
AC_MSG_CHECKING([for iconv declaration])
AC_CACHE_VAL(am_cv_proto_iconv, [
AC_TRY_COMPILE([
#include <stdlib.h>
#include <iconv.h>
extern
#ifdef __cplusplus
"C"
#endif
#if defined(__STDC__) || defined(__cplusplus)
size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
#else
size_t iconv();
#endif
], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
AC_MSG_RESULT([$]{ac_t:-
}[$]am_cv_proto_iconv)
AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
[Define as const if the declaration of iconv() needs const.])
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)])
AC_HAVE_TYPE([struct addrinfo], [#include <netdb.h>])
AC_HAVE_TYPE([struct sockaddr_storage], [#include <sys/types.h>
#include <sys/socket.h>])
# 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],
@@ -375,7 +459,7 @@ AC_CACHE_CHECK([whether defines needed by getaddrinfo exist],
#endif],
rsync_cv_HAVE_GETADDR_DEFINES=yes,
rsync_cv_HAVE_GETADDR_DEFINES=no)])
if test x"$rsync_cv_HAVE_GETADDR_DEFINES" = x"yes"; then
if test x"$rsync_cv_HAVE_GETADDR_DEFINES" = x"yes" -a x"$ac_cv_type_struct_addrinfo" = 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.
@@ -386,13 +470,11 @@ if test x"$rsync_cv_HAVE_GETADDR_DEFINES" = x"yes"; then
#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.])],
[Define to 1 if you have the "getaddrinfo" function and required types.])],
[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],
@@ -421,15 +503,6 @@ AC_CHECK_MEMBER([struct sockaddr_un.sun_len],
#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?]) ],
[],
@@ -439,8 +512,7 @@ AC_CHECK_MEMBER([struct sockaddr_in6.sin6_scope_id],
#include <netinet/in.h>
])
AC_MSG_CHECKING(struct stat64)
AC_TRY_COMPILE([#include <stdio.h>
AC_HAVE_TYPE([struct stat64], [#include <stdio.h>
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
@@ -455,10 +527,7 @@ AC_TRY_COMPILE([#include <stdio.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)
#
@@ -467,6 +536,11 @@ if test x"$ac_cv_func_strcasecmp" = x"no"; then
AC_CHECK_LIB(resolv, strcasecmp)
fi
AC_CHECK_FUNCS(aclsort)
if test x"$ac_cv_func_aclsort" = x"no"; then
AC_CHECK_LIB(sec, aclsort)
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.
@@ -474,19 +548,41 @@ 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 \
AC_CHECK_FUNCS(waitpid wait4 getcwd strdup chown chmod lchmod mknod mkfifo \
fchmod fstat ftruncate strchr readlink link utime utimes lutimes strftime \
memmove lchown vsnprintf snprintf vasprintf asprintf setsid strpbrk \
strlcat strlcpy strtol mallinfo getgroups setgroups geteuid getegid \
setmode open64 mkstemp64 va_copy __va_copy)
setlocale setmode open64 lseek64 mkstemp64 mtrace va_copy __va_copy \
strerror putenv iconv_open locale_charset nl_langinfo getxattr \
extattr_get_link sigaction sigprocmask setattrlist)
dnl cygwin iconv.h defines iconv_open as libiconv_open
if test x"$ac_cv_func_iconv_open" != x"yes"; then
AC_CHECK_FUNC(libiconv_open, [ac_cv_func_iconv_open=yes; AC_DEFINE(HAVE_ICONV_OPEN, 1)])
fi
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_ARG_ENABLE(iconv,
AC_HELP_STRING([--disable-iconv],
[disable rsync's --iconv option]),
[], [enable_iconv=$ac_cv_func_iconv_open])
AH_TEMPLATE([ICONV_OPTION],
[Define if you want the --iconv option. Specifing a value will set the
default iconv setting (a NULL means no --iconv processing by default).])
if test x"$enable_iconv" != x"no"; then
if test x"$enable_iconv" = x"yes"; then
AC_DEFINE(ICONV_OPTION, NULL)
else
AC_DEFINE_UNQUOTED(ICONV_OPTION, "$enable_iconv")
fi
AC_DEFINE(UTF8_CHARSET, "UTF-8", [String to pass to iconv() for the UTF-8 charset.])
fi
AC_CACHE_CHECK([whether chown() modifies symlinks],rsync_cv_chown_modifies_symlink,[
AC_TRY_RUN([
#if HAVE_UNISTD_H
# include <unistd.h>
@@ -497,14 +593,52 @@ AC_CACHE_CHECK([whether chown() dereferences symlinks],rsync_cv_chown_follows_sy
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);
if (chown(dangling_symlink, getuid(), getgid()) < 0 && errno == ENOENT) exit(1);
exit(0);
}],
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
rsync_cv_chown_modifies_symlink=yes,rsync_cv_chown_modifies_symlink=no,rsync_cv_chown_modifies_symlink=no)])
if test $rsync_cv_chown_modifies_symlink = yes; then
AC_DEFINE(CHOWN_MODIFIES_SYMLINK, 1, [Define to 1 if chown modifies symlinks.])
fi
AC_CACHE_CHECK([whether link() can hard-link symlinks],rsync_cv_can_hardlink_symlink,[
AC_TRY_RUN([
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <stdlib.h>
#include <errno.h>
#define FILENAME "conftest.dangle"
main() {
unlink(FILENAME);
if (symlink("conftest.no-such", FILENAME) < 0) abort();
if (link(FILENAME, FILENAME "2") < 0) exit(1);
exit(0);
}],
rsync_cv_can_hardlink_symlink=yes,rsync_cv_can_hardlink_symlink=no,rsync_cv_can_hardlink_symlink=no)])
if test $rsync_cv_can_hardlink_symlink = yes; then
AC_DEFINE(CAN_HARDLINK_SYMLINK, 1, [Define to 1 if link() can hard-link symlinks.])
fi
AC_CACHE_CHECK([whether link() can hard-link special files],rsync_cv_can_hardlink_special,[
AC_TRY_RUN([
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <stdlib.h>
#include <errno.h>
#define FILENAME "conftest.fifi"
main() {
unlink(FILENAME);
if (mkfifo(FILENAME, 0777) < 0) abort();
if (link(FILENAME, FILENAME "2") < 0) exit(1);
exit(0);
}],
rsync_cv_can_hardlink_special=yes,rsync_cv_can_hardlink_special=no,rsync_cv_can_hardlink_special=no)])
if test $rsync_cv_can_hardlink_special = yes; then
AC_DEFINE(CAN_HARDLINK_SPECIAL, 1, [Define to 1 if link() can hard-link special files.])
fi
AC_CACHE_CHECK([for working socketpair],rsync_cv_HAVE_SOCKETPAIR,[
AC_TRY_RUN([
#include <sys/types.h>
@@ -519,14 +653,21 @@ 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
if test x"$with_included_popt" != x"yes"; then
AC_CHECK_LIB(popt, poptGetContext, , [with_included_popt=yes])
fi
if test x"$ac_cv_header_popt_popt_h" = x"yes"; then
# If the system has /usr/include/popt/popt.h, we enable the
# included popt because an attempt to "#include <popt/popt.h>"
# would use our included header file anyway (due to -I.), and
# might conflict with the system popt.
with_included_popt=yes
elif test x"$ac_cv_header_popt_h" != x"yes"; then
with_included_popt=yes
fi
AC_MSG_CHECKING([whether to use included libpopt])
if test x"$with_included_popt" = x"yes"
then
if test x"$with_included_popt" = x"yes"; then
AC_MSG_RESULT($srcdir/popt)
BUILD_POPT='$(popt_OBJS)'
CFLAGS="$CFLAGS -I$srcdir/popt"
@@ -558,13 +699,13 @@ 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_CACHE_CHECK([for utimbuf],rsync_cv_HAVE_STRUCT_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])
rsync_cv_HAVE_STRUCT_UTIMBUF=yes,rsync_cv_HAVE_STRUCT_UTIMBUF=no)])
if test x"$rsync_cv_HAVE_STRUCT_UTIMBUF" = x"yes"; then
AC_DEFINE(HAVE_STRUCT_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,[
@@ -621,39 +762,20 @@ 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
AC_DEFINE(HAVE_SECURE_MKSTEMP, 1, [Define to 1 if mkstemp() is available and works right])
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>
@@ -661,7 +783,7 @@ AC_TRY_RUN([
#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;}
if (rc) {printf("(%d %d) ",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
@@ -675,7 +797,7 @@ AC_TRY_RUN([
#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;}
if (rc) {printf("(%d %d) ",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
@@ -712,25 +834,150 @@ AC_SUBST(OBJ_SAVE)
AC_SUBST(OBJ_RESTORE)
AC_SUBST(CC_SHOBJ_FLAG)
AC_SUBST(BUILD_POPT)
AC_SUBST(MAKE_MAN)
AC_CHECK_FUNCS(_acl __acl _facl __facl)
#################################################
# check for ACL support
AC_MSG_CHECKING([whether to support ACLs])
AC_ARG_ENABLE(acl-support,
AC_HELP_STRING([--disable-acl-support],
[disable ACL support]))
if test x"$enable_acl_support" = x"no"; then
AC_MSG_RESULT(no)
else
case "$host_os" in
*sysv5*)
AC_MSG_RESULT(Using UnixWare ACLs)
AC_DEFINE(HAVE_UNIXWARE_ACLS, 1, [true if you have UnixWare ACLs])
AC_DEFINE(SUPPORT_ACLS, 1, [Define to 1 to add support for ACLs])
;;
*solaris*|*cygwin*)
AC_MSG_RESULT(Using solaris ACLs)
AC_DEFINE(HAVE_SOLARIS_ACLS, 1, [true if you have solaris ACLs])
AC_DEFINE(SUPPORT_ACLS, 1)
;;
*hpux*)
AC_MSG_RESULT(Using HPUX ACLs)
AC_DEFINE(HAVE_HPUX_ACLS, 1, [true if you have HPUX ACLs])
AC_DEFINE(SUPPORT_ACLS, 1)
;;
*irix*)
AC_MSG_RESULT(Using IRIX ACLs)
AC_DEFINE(HAVE_IRIX_ACLS, 1, [true if you have IRIX ACLs])
AC_DEFINE(SUPPORT_ACLS, 1)
;;
*aix*)
AC_MSG_RESULT(Using AIX ACLs)
AC_DEFINE(HAVE_AIX_ACLS, 1, [true if you have AIX ACLs])
AC_DEFINE(SUPPORT_ACLS, 1)
;;
*osf*)
AC_MSG_RESULT(Using Tru64 ACLs)
AC_DEFINE(HAVE_TRU64_ACLS, 1, [true if you have Tru64 ACLs])
AC_DEFINE(SUPPORT_ACLS, 1)
LIBS="$LIBS -lpacl"
;;
darwin*)
AC_MSG_RESULT(Using OS X ACLs)
AC_DEFINE(HAVE_OSX_ACLS, 1, [true if you have Mac OS X ACLs])
AC_DEFINE(SUPPORT_ACLS, 1)
;;
*)
AC_MSG_RESULT(running tests:)
AC_CHECK_LIB(acl,acl_get_file)
AC_CACHE_CHECK([for ACL support],samba_cv_HAVE_POSIX_ACLS,[
AC_TRY_LINK([#include <sys/types.h>
#include <sys/acl.h>],
[ acl_t acl; int entry_id; acl_entry_t *entry_p; return acl_get_entry( acl, entry_id, entry_p);],
samba_cv_HAVE_POSIX_ACLS=yes,samba_cv_HAVE_POSIX_ACLS=no)])
AC_MSG_CHECKING(ACL test results)
if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then
AC_MSG_RESULT(Using posix ACLs)
AC_DEFINE(HAVE_POSIX_ACLS, 1, [true if you have posix ACLs])
AC_DEFINE(SUPPORT_ACLS, 1)
AC_CACHE_CHECK([for acl_get_perm_np],samba_cv_HAVE_ACL_GET_PERM_NP,[
AC_TRY_LINK([#include <sys/types.h>
#include <sys/acl.h>],
[ acl_permset_t permset_d; acl_perm_t perm; return acl_get_perm_np( permset_d, perm);],
samba_cv_HAVE_ACL_GET_PERM_NP=yes,samba_cv_HAVE_ACL_GET_PERM_NP=no)])
if test x"$samba_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
AC_DEFINE(HAVE_ACL_GET_PERM_NP, 1, [true if you have acl_get_perm_np])
fi
else
if test x"$enable_acl_support" = x"yes"; then
AC_MSG_ERROR(Failed to find ACL support)
else
AC_MSG_RESULT(No ACL support found)
fi
fi
;;
esac
fi
#################################################
# check for extended attribute support
AC_MSG_CHECKING(whether to support extended attributes)
AC_ARG_ENABLE(xattr-support,
AC_HELP_STRING([--disable-xattr-support],
[disable extended attributes]),
[], [case "$ac_cv_func_getxattr$ac_cv_func_extattr_get_link" in
*yes*) enable_xattr_support=maybe ;;
*) enable_xattr_support=no ;;
esac])
AH_TEMPLATE([SUPPORT_XATTRS],
[Define to 1 to add support for extended attributes])
if test x"$enable_xattr_support" = x"no"; then
AC_MSG_RESULT(no)
else
case "$host_os" in
*linux*)
AC_MSG_RESULT(Using Linux xattrs)
AC_DEFINE(HAVE_LINUX_XATTRS, 1, [True if you have Linux xattrs])
AC_DEFINE(SUPPORT_XATTRS, 1)
;;
darwin*)
AC_MSG_RESULT(Using OS X xattrs)
AC_DEFINE(HAVE_OSX_XATTRS, 1, [True if you have Mac OS X xattrs])
AC_DEFINE(SUPPORT_XATTRS, 1)
;;
freebsd*)
AC_MSG_RESULT(Using FreeBSD extattrs)
AC_DEFINE(HAVE_FREEBSD_XATTRS, 1, [True if you have FreeBSD xattrs])
AC_DEFINE(SUPPORT_XATTRS, 1)
;;
*)
if test x"$enable_xattr_support" = x"yes"; then
AC_MSG_ERROR(Failed to find extended attribute support)
else
AC_MSG_RESULT(No extended attribute support found)
fi
;;
esac
fi
if test x"$enable_acl_support" = x"no" -o x"$enable_xattr_support" = x"no" -o x"$enable_iconv" = x"no"; then
AC_MSG_CHECKING([whether $CC supports -Wno-unused-parameter])
OLD_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Wno-unused-parameter"
AC_COMPILE_IFELSE([ ], [rsync_warn_flag=yes], [rsync_warn_flag=no])
AC_MSG_RESULT([$rsync_warn_flag])
if test x"$rsync_warn_flag" = x"no"; then
CFLAGS="$OLD_CFLAGS"
fi
fi
case "$CC" in
' checker'*|checker*)
AC_DEFINE(FORCE_FD_ZERO_MEMSET, 1, [Used to make "checker" understand that FD_ZERO() clears memory.])
;;
esac
AC_CONFIG_FILES([Makefile lib/dummy zlib/dummy popt/dummy shconfig])
AC_OUTPUT
if test x"$with_rsh" = x; then
if test x"$HAVE_REMSH" = x1; then
rmsh1='remsh:'
rmsh2='=remsh'
else
rmsh1='rsh: '
rmsh2='=rsh '
fi
AC_MSG_RESULT()
AC_MSG_RESULT([ **********************************************************************])
AC_MSG_RESULT([ * As of v2.6.0, the default remote shell is ssh instead of rsh!! *])
AC_MSG_RESULT([ * To use previous default of $rmsh1 ./configure --with-rsh$rmsh2 *])
AC_MSG_RESULT([ **********************************************************************])
fi
AC_MSG_RESULT()
AC_MSG_RESULT([ rsync ${RSYNC_VERSION} configuration successful])
AC_MSG_RESULT()

View File

@@ -1,49 +1,46 @@
/*
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.
*/
/*
* Support the max connections option.
*
* Copyright (C) 1998 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
/* support the max connections option */
#include "rsync.h"
/****************************************************************************
simple routine to do connection counting
****************************************************************************/
int claim_connection(char *fname,int max_connections)
/* A simple routine to do connection counting. This returns 1 on success
* and 0 on failure, with errno also being set if the open() failed (errno
* will be 0 if the lock request failed). */
int claim_connection(char *fname, int max_connections)
{
int fd, i;
if (max_connections <= 0)
if (max_connections == 0)
return 1;
fd = open(fname,O_RDWR|O_CREAT, 0600);
if (fd == -1) {
if ((fd = open(fname, O_RDWR|O_CREAT, 0600)) < 0)
return 0;
/* Find a free spot. */
for (i = 0; i < max_connections; i++) {
if (lock_range(fd, i*4, 4))
return 1;
}
/* find a free spot */
for (i=0;i<max_connections;i++) {
if (lock_range(fd, i*4, 4)) return 1;
}
/* only interested in open failures */
errno = 0;
close(fd);
/* A lock failure needs to return an errno of 0. */
errno = 0;
return 0;
}

View File

@@ -3,21 +3,22 @@ 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>
@RSYNCD: <version>.<subprotocol>
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.
where <version> is the numeric version (see PROTOCOL_VERSION in rsync.h)
'.' is a literal period, and <subprotocol> is the numeric subprotocol
version (see SUBPROTOCOL_VERSION -- it will be 0 for final releases).
Protocols prior to 30 only output <version> alone. The daemon expects
to see a similar greeting back from the client. For protocols prior to
30, an absent ".<subprotocol>" value is assumed to be 0. For protocol
30, an absent value is a fatal error. The daemon then follows this line
with a free-format text message-of-the-day (if any is defined).
The server is now in the connected state. The client can either send
the command
@@ -75,8 +76,13 @@ stay tuned (or write it yourself!).
------------
Protocol version changes
25 (2001-08-20, 2.4.7pre2)
30 (2007-10-04, 3.0.0pre1)
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.
The use of a ".<subprotocol>" number was added to
@RSYNCD: <version>.<subprotocol>
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.

View File

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

View File

@@ -1,27 +1,26 @@
/* -*- 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
* Error codes returned by rsync.
*
* Copyright (C) 1998-2000 Andrew Tridgell
* Copyright (C) 2003-2008 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
/* 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 */
@@ -34,14 +33,19 @@
#define RERR_STREAMIO 12 /* error in rsync protocol data stream */
#define RERR_MESSAGEIO 13 /* errors with program diagnostics */
#define RERR_IPC 14 /* error in IPC code */
#define RERR_CRASHED 15 /* sibling crashed */
#define RERR_TERMINATED 16 /* sibling terminated abnormally */
#define RERR_SIGNAL 20 /* status returned when sent SIGUSR1, SIGINT */
#define RERR_SIGNAL1 19 /* status returned when sent SIGUSR1 */
#define RERR_SIGNAL 20 /* status returned when sent SIGINT, SIGTERM, SIGHUP */
#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 */
#define RERR_CONTIMEOUT 35 /* timeout waiting for daemon connection */
/* Although it doesn't seem to be specified anywhere,
* ssh and the shell seem to return these values:

406
exclude.c
View File

@@ -1,12 +1,14 @@
/* -*- c-file-style: "linux" -*-
/*
* The filter include/exclude routines.
*
* Copyright (C) 1996-2001 by Andrew Tridgell <tridge@samba.org>
* Copyright (C) 1996 by Paul Mackerras
* Copyright (C) 2002 by Martin Pool
* Copyright (C) 1996-2001 Andrew Tridgell <tridge@samba.org>
* Copyright (C) 1996 Paul Mackerras
* Copyright (C) 2002 Martin Pool
* Copyright (C) 2003-2008 Wayne Davison
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
@@ -14,26 +16,20 @@
* 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.
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
/* a lot of this stuff was originally derived from GNU tar, although
it has now changed so much that it is hard to tell :) */
/* include/exclude cluestick added by Martin Pool <mbp@samba.org> */
#include "rsync.h"
extern int verbose;
extern int am_server;
extern int am_sender;
extern int eol_nulls;
extern int list_only;
extern int recurse;
extern int io_error;
extern int local_server;
extern int prune_empty_dirs;
extern int ignore_perishable;
extern int delete_mode;
extern int delete_excluded;
extern int cvs_exclude;
@@ -46,15 +42,17 @@ extern unsigned int curr_dir_len;
extern unsigned int module_dirlen;
struct filter_list_struct filter_list = { 0, 0, "" };
struct filter_list_struct cvs_filter_list = { 0, 0, " [cvsignore]" };
struct filter_list_struct server_filter_list = { 0, 0, " [server]" };
struct filter_list_struct cvs_filter_list = { 0, 0, " [global CVS]" };
struct filter_list_struct daemon_filter_list = { 0, 0, " [daemon]" };
/* Need room enough for ":MODS " prefix plus some room to grow. */
#define MAX_RULE_PREFIX (16)
#define MODIFIERS_MERGE_FILE "-+Cenw"
#define MODIFIERS_INCL_EXCL "/!Crs"
#define MODIFIERS_HIDE_PROTECT "/!"
#define MODIFIERS_INCL_EXCL "/!Crsp"
#define MODIFIERS_HIDE_PROTECT "/!p"
#define SLASH_WILD3_SUFFIX "/***"
/* The dirbuf is set by push_local_filters() to the current subdirectory
* relative to curr_dir that is being processed. The path always has a
@@ -123,7 +121,7 @@ static void add_rule(struct filter_list_struct *listp, const char *pat,
{
struct filter_struct *ret;
const char *cp;
unsigned int ex_len;
unsigned int pre_len, suf_len, slash_cnt = 0;
if (verbose > 2) {
rprintf(FINFO, "[%s] add_rule(%s%.*s%s)%s\n",
@@ -133,9 +131,9 @@ static void add_rule(struct filter_list_struct *listp, const char *pat,
listp->debug_type);
}
/* This flag also indicates that we're reading a list that
/* These flags also indicate that we're reading a list that
* needs to be filtered now, not post-filtered later. */
if (xflags & XFLG_ANCHORED2ABS) {
if (xflags & (XFLG_ANCHORED2ABS|XFLG_ABS_IF_SLASH)) {
uint32 mf = mflags & (MATCHFLG_RECEIVER_SIDE|MATCHFLG_SENDER_SIDE);
if (am_sender) {
if (mf == MATCHFLG_RECEIVER_SIDE)
@@ -146,22 +144,54 @@ static void add_rule(struct filter_list_struct *listp, const char *pat,
}
}
if (!(ret = new(struct filter_struct)))
if (!(ret = new0(struct filter_struct)))
out_of_memory("add_rule");
memset(ret, 0, sizeof ret[0]);
if (xflags & XFLG_ANCHORED2ABS && *pat == '/'
&& !(mflags & (MATCHFLG_ABS_PATH | MATCHFLG_MERGE_FILE))) {
if (pat_len > 1 && pat[pat_len-1] == '/') {
pat_len--;
mflags |= MATCHFLG_DIRECTORY;
}
for (cp = pat; cp < pat + pat_len; cp++) {
if (*cp == '/')
slash_cnt++;
}
if (!(mflags & (MATCHFLG_ABS_PATH | MATCHFLG_MERGE_FILE))
&& ((xflags & (XFLG_ANCHORED2ABS|XFLG_ABS_IF_SLASH) && *pat == '/')
|| (xflags & XFLG_ABS_IF_SLASH && slash_cnt))) {
mflags |= MATCHFLG_ABS_PATH;
ex_len = dirbuf_len - module_dirlen - 1;
if (*pat == '/')
pre_len = dirbuf_len - module_dirlen - 1;
else
pre_len = 0;
} else
ex_len = 0;
if (!(ret->pattern = new_array(char, ex_len + pat_len + 1)))
pre_len = 0;
/* The daemon wants dir-exclude rules to get an appended "/" + "***". */
if (xflags & XFLG_DIR2WILD3
&& BITS_SETnUNSET(mflags, MATCHFLG_DIRECTORY, MATCHFLG_INCLUDE)) {
mflags &= ~MATCHFLG_DIRECTORY;
suf_len = sizeof SLASH_WILD3_SUFFIX - 1;
} else
suf_len = 0;
if (!(ret->pattern = new_array(char, pre_len + pat_len + suf_len + 1)))
out_of_memory("add_rule");
if (ex_len)
memcpy(ret->pattern, dirbuf + module_dirlen, ex_len);
strlcpy(ret->pattern + ex_len, pat, pat_len + 1);
pat_len += ex_len;
if (pre_len) {
memcpy(ret->pattern, dirbuf + module_dirlen, pre_len);
for (cp = ret->pattern; cp < ret->pattern + pre_len; cp++) {
if (*cp == '/')
slash_cnt++;
}
}
strlcpy(ret->pattern + pre_len, pat, pat_len + 1);
pat_len += pre_len;
if (suf_len) {
memcpy(ret->pattern + pat_len, SLASH_WILD3_SUFFIX, suf_len+1);
pat_len += suf_len;
slash_cnt++;
}
if (strpbrk(ret->pattern, "*[?")) {
mflags |= MATCHFLG_WILD;
@@ -170,14 +200,15 @@ static void add_rule(struct filter_list_struct *listp, const char *pat,
/* If the pattern starts with **, note that. */
if (cp == ret->pattern)
mflags |= MATCHFLG_WILD2_PREFIX;
/* If the pattern ends with ***, note that. */
if (pat_len >= 3
&& ret->pattern[pat_len-3] == '*'
&& ret->pattern[pat_len-2] == '*'
&& ret->pattern[pat_len-1] == '*')
mflags |= MATCHFLG_WILD3_SUFFIX;
}
}
if (pat_len > 1 && ret->pattern[pat_len-1] == '/') {
ret->pattern[pat_len-1] = 0;
mflags |= MATCHFLG_DIRECTORY;
}
if (mflags & MATCHFLG_PERDIR_MERGE) {
struct filter_list_struct *lp;
unsigned int len;
@@ -221,10 +252,8 @@ static void add_rule(struct filter_list_struct *listp, const char *pat,
out_of_memory("add_rule");
}
mergelist_parents[mergelist_cnt++] = ret;
} else {
for (cp = ret->pattern; (cp = strchr(cp, '/')) != NULL; cp++)
ret->u.slash_cnt++;
}
} else
ret->u.slash_cnt = slash_cnt;
ret->match_flags = mflags;
@@ -290,30 +319,29 @@ static char *parse_merge_name(const char *merge_file, unsigned int *len_ptr,
strlcpy(to, merge_file, *len_ptr + 1);
merge_file = to;
}
if (!sanitize_path(fn, merge_file, r, dirbuf_depth)) {
if (!sanitize_path(fn, merge_file, r, dirbuf_depth, SP_DEFAULT)) {
rprintf(FERROR, "merge-file name overflows: %s\n",
safe_fname(merge_file));
merge_file);
return NULL;
}
fn_len = strlen(fn);
} else {
strlcpy(fn, merge_file, len_ptr ? *len_ptr + 1 : MAXPATHLEN);
clean_fname(fn, 1);
fn_len = clean_fname(fn, CFN_COLLAPSE_DOT_DOT_DIRS);
}
fn_len = strlen(fn);
if (fn == buf)
goto done;
if (dirbuf_len + fn_len >= MAXPATHLEN) {
rprintf(FERROR, "merge-file name overflows: %s\n",
safe_fname(fn));
return NULL;
/* If the name isn't in buf yet, it's wasn't absolute. */
if (fn != buf) {
int d_len = dirbuf_len - prefix_skip;
if (d_len + fn_len >= MAXPATHLEN) {
rprintf(FERROR, "merge-file name overflows: %s\n", fn);
return NULL;
}
memcpy(buf, dirbuf + prefix_skip, d_len);
memcpy(buf + d_len, fn, fn_len + 1);
fn_len = clean_fname(buf, CFN_COLLAPSE_DOT_DOT_DIRS);
}
memcpy(buf, dirbuf + prefix_skip, dirbuf_len - prefix_skip);
memcpy(buf + dirbuf_len - prefix_skip, fn, fn_len + 1);
fn_len = clean_fname(buf, 1);
done:
if (len_ptr)
*len_ptr = fn_len;
return buf;
@@ -333,7 +361,7 @@ void set_filter_dir(const char *dir, unsigned int dirlen)
len = 0;
memcpy(dirbuf + len, dir, dirlen);
dirbuf[dirlen + len] = '\0';
dirbuf_len = clean_fname(dirbuf, 1);
dirbuf_len = clean_fname(dirbuf, CFN_COLLAPSE_DOT_DOT_DIRS);
if (dirbuf_len > 1 && dirbuf[dirbuf_len-1] == '.'
&& dirbuf[dirbuf_len-2] == '/')
dirbuf_len -= 2;
@@ -369,7 +397,7 @@ static BOOL setup_merge_file(struct filter_struct *ex,
else
pathjoin(buf, MAXPATHLEN, dirbuf, x);
len = clean_fname(buf, 1);
len = clean_fname(buf, CFN_COLLAPSE_DOT_DOT_DIRS);
if (len != 1 && len < MAXPATHLEN-1) {
buf[len++] = '/';
buf[len] = '\0';
@@ -486,73 +514,98 @@ void pop_local_filters(void *mem)
free(pop);
}
static int rule_matches(char *name, struct filter_struct *ex, int name_is_dir)
void change_local_filter_dir(const char *dname, int dlen, int dir_depth)
{
char *p, full_name[MAXPATHLEN];
int match_start = 0;
static int cur_depth = -1;
static void *filt_array[MAXPATHLEN/2+1];
if (!dname) {
for ( ; cur_depth >= 0; cur_depth--) {
if (filt_array[cur_depth]) {
pop_local_filters(filt_array[cur_depth]);
filt_array[cur_depth] = NULL;
}
}
return;
}
assert(dir_depth < MAXPATHLEN/2+1);
for ( ; cur_depth >= dir_depth; cur_depth--) {
if (filt_array[cur_depth]) {
pop_local_filters(filt_array[cur_depth]);
filt_array[cur_depth] = NULL;
}
}
cur_depth = dir_depth;
filt_array[cur_depth] = push_local_filters(dname, dlen);
}
static int rule_matches(const char *fname, struct filter_struct *ex, int name_is_dir)
{
int slash_handling, str_cnt = 0, anchored_match = 0;
int ret_match = ex->match_flags & MATCHFLG_NEGATE ? 0 : 1;
char *pattern = ex->pattern;
char *p, *pattern = ex->pattern;
const char *strings[16]; /* more than enough */
const char *name = fname + (*fname == '/');
if (!*name)
return 0;
/* If the pattern does not have any slashes AND it does not have
* a "**" (which could match a slash), then we just match the
* name portion of the path. */
if (!ex->u.slash_cnt && !(ex->match_flags & MATCHFLG_WILD2)) {
/* If the pattern does not have any slashes AND it does
* not have a "**" (which could match a slash), then we
* just match the name portion of the path. */
if ((p = strrchr(name,'/')) != NULL)
name = p+1;
}
else if (ex->match_flags & MATCHFLG_ABS_PATH && *name != '/'
} else if (ex->match_flags & MATCHFLG_ABS_PATH && *fname != '/'
&& curr_dir_len > module_dirlen + 1) {
pathjoin(full_name, sizeof full_name,
curr_dir + module_dirlen + 1, name);
name = full_name;
/* If we're matching against an absolute-path pattern,
* we need to prepend our full path info. */
strings[str_cnt++] = curr_dir + module_dirlen + 1;
strings[str_cnt++] = "/";
} else if (ex->match_flags & MATCHFLG_WILD2_PREFIX && *fname != '/') {
/* Allow "**"+"/" to match at the start of the string. */
strings[str_cnt++] = "/";
}
if (ex->match_flags & MATCHFLG_DIRECTORY && !name_is_dir)
strings[str_cnt++] = name;
if (name_is_dir) {
/* Allow a trailing "/"+"***" to match the directory. */
if (ex->match_flags & MATCHFLG_WILD3_SUFFIX)
strings[str_cnt++] = "/";
} else if (ex->match_flags & MATCHFLG_DIRECTORY)
return !ret_match;
strings[str_cnt] = NULL;
if (*pattern == '/') {
match_start = 1;
anchored_match = 1;
pattern++;
if (*name == '/')
name++;
}
if (!anchored_match && ex->u.slash_cnt
&& !(ex->match_flags & MATCHFLG_WILD2)) {
/* A non-anchored match with an infix slash and no "**"
* needs to match the last slash_cnt+1 name elements. */
slash_handling = ex->u.slash_cnt + 1;
} else if (!anchored_match && !(ex->match_flags & MATCHFLG_WILD2_PREFIX)
&& ex->match_flags & MATCHFLG_WILD2) {
/* A non-anchored match with an infix or trailing "**" (but not
* a prefixed "**") needs to try matching after every slash. */
slash_handling = -1;
} else {
/* The pattern matches only at the start of the path or name. */
slash_handling = 0;
}
if (ex->match_flags & MATCHFLG_WILD) {
/* A non-anchored match with an infix slash and no "**"
* needs to match the last slash_cnt+1 name elements. */
if (!match_start && ex->u.slash_cnt
&& !(ex->match_flags & MATCHFLG_WILD2)) {
int cnt = ex->u.slash_cnt + 1;
for (p = name + strlen(name) - 1; p >= name; p--) {
if (*p == '/' && !--cnt)
break;
}
name = p+1;
}
if (wildmatch(pattern, name))
if (wildmatch_array(pattern, strings, slash_handling))
return ret_match;
if (ex->match_flags & MATCHFLG_WILD2_PREFIX) {
/* If the **-prefixed pattern has a '/' as the next
* character, then try to match the rest of the
* pattern at the root. */
if (pattern[2] == '/' && wildmatch(pattern+3, name))
return ret_match;
}
else if (!match_start && ex->match_flags & MATCHFLG_WILD2) {
/* A non-anchored match with an infix or trailing "**"
* (but not a prefixed "**") needs to try matching
* after every slash. */
while ((name = strchr(name, '/')) != NULL) {
name++;
if (wildmatch(pattern, name))
return ret_match;
}
}
} else if (match_start) {
if (strcmp(name,pattern) == 0)
} else if (str_cnt > 1) {
if (litmatch_array(pattern, strings, slash_handling))
return ret_match;
} else if (anchored_match) {
if (strcmp(name, pattern) == 0)
return ret_match;
} else {
int l1 = strlen(name);
@@ -568,7 +621,7 @@ static int rule_matches(char *name, struct filter_struct *ex, int name_is_dir)
}
static void report_filter_result(char const *name,
static void report_filter_result(enum logcode code, char const *name,
struct filter_struct const *ent,
int name_is_dir, const char *type)
{
@@ -577,11 +630,13 @@ static void report_filter_result(char const *name,
* case we add it back in here. */
if (verbose >= 2) {
rprintf(FINFO, "[%s] %scluding %s %s because of pattern %s%s%s\n",
who_am_i(),
ent->match_flags & MATCHFLG_INCLUDE ? "in" : "ex",
name_is_dir ? "directory" : "file", name, ent->pattern,
ent->match_flags & MATCHFLG_DIRECTORY ? "/" : "", type);
static char *actions[2][2]
= { {"show", "hid"}, {"risk", "protect"} };
const char *w = who_am_i();
rprintf(code, "[%s] %sing %s %s because of pattern %s%s%s\n",
w, actions[*w!='s'][!(ent->match_flags&MATCHFLG_INCLUDE)],
name_is_dir ? "directory" : "file", name, ent->pattern,
ent->match_flags & MATCHFLG_DIRECTORY ? "/" : "", type);
}
}
@@ -590,28 +645,31 @@ static void report_filter_result(char const *name,
* Return -1 if file "name" is defined to be excluded by the specified
* exclude list, 1 if it is included, and 0 if it was not matched.
*/
int check_filter(struct filter_list_struct *listp, char *name, int name_is_dir)
int check_filter(struct filter_list_struct *listp, enum logcode code,
const char *name, int name_is_dir)
{
struct filter_struct *ent;
for (ent = listp->head; ent; ent = ent->next) {
if (ignore_perishable && ent->match_flags & MATCHFLG_PERISHABLE)
continue;
if (ent->match_flags & MATCHFLG_PERDIR_MERGE) {
int rc = check_filter(ent->u.mergelist, name,
int rc = check_filter(ent->u.mergelist, code, name,
name_is_dir);
if (rc)
return rc;
continue;
}
if (ent->match_flags & MATCHFLG_CVS_IGNORE) {
int rc = check_filter(&cvs_filter_list, name,
int rc = check_filter(&cvs_filter_list, code, name,
name_is_dir);
if (rc)
return rc;
continue;
}
if (rule_matches(name, ent, name_is_dir)) {
report_filter_result(name, ent, name_is_dir,
listp->debug_type);
report_filter_result(code, name, ent, name_is_dir,
listp->debug_type);
return ent->match_flags & MATCHFLG_INCLUDE ? 1 : -1;
}
}
@@ -674,8 +732,7 @@ static const char *parse_rule_tok(const char *p, uint32 mflags, int xflags,
} else if (*s == '+' && s[1] == ' ') {
new_mflags |= MATCHFLG_INCLUDE;
s += 2;
}
if (*s == '!')
} else if (*s == '!')
new_mflags |= MATCHFLG_CLEAR_LIST; /* Tentative! */
} else {
char ch = 0, *mods = "";
@@ -716,7 +773,6 @@ static const char *parse_rule_tok(const char *p, uint32 mflags, int xflags,
if ((s = RULE_STRCMP(s, "show")) != NULL)
ch = 'S';
break;
default:
ch = *s;
if (s[1] == ',')
@@ -757,7 +813,7 @@ static const char *parse_rule_tok(const char *p, uint32 mflags, int xflags,
mods = NULL;
break;
default:
rprintf(FERROR, "Unknown filter rule: %s\n", p);
rprintf(FERROR, "Unknown filter rule: `%s'\n", p);
exit_cleanup(RERR_SYNTAX);
}
while (mods && *++s && *s != ' ' && *s != '_') {
@@ -804,6 +860,9 @@ static const char *parse_rule_tok(const char *p, uint32 mflags, int xflags,
case 'n':
new_mflags |= MATCHFLG_NO_INHERIT;
break;
case 'p':
new_mflags |= MATCHFLG_PERISHABLE;
break;
case 'r':
new_mflags |= MATCHFLG_RECEIVER_SIDE;
break;
@@ -829,7 +888,8 @@ static const char *parse_rule_tok(const char *p, uint32 mflags, int xflags,
len = strlen((char*)s);
if (new_mflags & MATCHFLG_CLEAR_LIST) {
if (!(xflags & XFLG_OLD_PREFIXES) && len) {
if (!(mflags & MATCHFLG_NO_PREFIXES)
&& !(xflags & XFLG_OLD_PREFIXES) && len) {
rprintf(FERROR,
"'!' rule has trailing characters: %s\n", p);
exit_cleanup(RERR_SYNTAX);
@@ -841,13 +901,22 @@ static const char *parse_rule_tok(const char *p, uint32 mflags, int xflags,
exit_cleanup(RERR_SYNTAX);
}
/* --delete-excluded turns an un-modified include/exclude into a
* sender-side rule. We also affect per-dir merge files that take
* no prefixes as a simple optimization. */
if (delete_excluded
&& !(new_mflags & (MATCHFLG_RECEIVER_SIDE|MATCHFLG_SENDER_SIDE))
&& (!(new_mflags & MATCHFLG_PERDIR_MERGE)
|| new_mflags & MATCHFLG_NO_PREFIXES))
new_mflags |= MATCHFLG_SENDER_SIDE;
*len_ptr = len;
*mflags_ptr = new_mflags;
return (const char *)s;
}
static char default_cvsignore[] =
static char default_cvsignore[] =
/* These default ignored items come from the CVS manual. */
"RCS SCCS CVS CVS.adm RCSLOG cvslog.* tags TAGS"
" .make.state .nse_depinfo *~ #* .#* ,* _$* *$"
@@ -855,18 +924,20 @@ static char default_cvsignore[] =
" *.a *.olb *.o *.obj *.so *.exe"
" *.Z *.elc *.ln core"
/* The rest we added to suit ourself. */
" .svn/";
" .svn/ .git/ .bzr/";
static void get_cvs_excludes(uint32 mflags)
{
char *p, fname[MAXPATHLEN];
static int initialized = 0;
char *p, fname[MAXPATHLEN];
if (initialized)
return;
initialized = 1;
parse_rule(&cvs_filter_list, default_cvsignore, mflags, 0);
parse_rule(&cvs_filter_list, default_cvsignore,
mflags | (protocol_version >= 30 ? MATCHFLG_PERISHABLE : 0),
0);
p = module_id >= 0 && lp_use_chroot(module_id) ? "/" : getenv("HOME");
if (p && pathjoin(fname, MAXPATHLEN, p, ".cvsignore") < MAXPATHLEN)
@@ -892,12 +963,14 @@ void parse_rule(struct filter_list_struct *listp, const char *pattern,
&pat_len, &new_mflags);
if (!cp)
break;
pattern = cp + pat_len;
if (pat_len >= MAXPATHLEN) {
rprintf(FERROR, "discarding over-long filter: %s\n",
cp);
rprintf(FERROR, "discarding over-long filter: %.*s\n",
(int)pat_len, cp);
continue;
}
pattern = cp + pat_len;
if (new_mflags & MATCHFLG_CLEAR_LIST) {
if (verbose > 2) {
@@ -917,11 +990,9 @@ void parse_rule(struct filter_list_struct *listp, const char *pattern,
}
len = pat_len;
if (new_mflags & MATCHFLG_EXCLUDE_SELF) {
const char *name = strrchr(cp, '/');
if (name)
len -= ++name - cp;
else
name = cp;
const char *name = cp + len;
while (name > cp && name[-1] != '/') name--;
len -= name - cp;
add_rule(listp, name, len, 0, 0);
new_mflags &= ~MATCHFLG_EXCLUDE_SELF;
len = pat_len;
@@ -956,7 +1027,7 @@ void parse_filter_file(struct filter_list_struct *listp, const char *fname,
uint32 mflags, int xflags)
{
FILE *fp;
char line[MAXPATHLEN+MAX_RULE_PREFIX+1]; /* +1 for trailing slash. */
char line[BIGPATHBUFLEN];
char *eob = line + sizeof line - 1;
int word_split = mflags & MATCHFLG_WORD_SPLIT;
@@ -964,10 +1035,10 @@ void parse_filter_file(struct filter_list_struct *listp, const char *fname,
return;
if (*fname != '-' || fname[1] || am_server) {
if (server_filter_list.head) {
if (daemon_filter_list.head) {
strlcpy(line, fname, sizeof line);
clean_fname(line, 1);
if (check_filter(&server_filter_list, line, 0) < 0)
clean_fname(line, CFN_COLLAPSE_DOT_DOT_DIRS);
if (check_filter(&daemon_filter_list, FLOG, line, 0) < 0)
fp = NULL;
else
fp = fopen(line, "rb");
@@ -978,7 +1049,7 @@ void parse_filter_file(struct filter_list_struct *listp, const char *fname,
if (verbose > 2) {
rprintf(FINFO, "[%s] parse_filter_file(%s,%x,%x)%s\n",
who_am_i(), safe_fname(fname), mflags, xflags,
who_am_i(), fname, mflags, xflags,
fp ? "" : " [not found]");
}
@@ -987,7 +1058,7 @@ void parse_filter_file(struct filter_list_struct *listp, const char *fname,
rsyserr(FERROR, errno,
"failed to open %sclude file %s",
mflags & MATCHFLG_INCLUDE ? "in" : "ex",
safe_fname(fname));
fname);
exit_cleanup(RERR_FILEIO);
}
return;
@@ -999,8 +1070,10 @@ void parse_filter_file(struct filter_list_struct *listp, const char *fname,
int ch, overflow = 0;
while (1) {
if ((ch = getc(fp)) == EOF) {
if (ferror(fp) && errno == EINTR)
if (ferror(fp) && errno == EINTR) {
clearerr(fp);
continue;
}
break;
}
if (word_split && isspace(ch))
@@ -1034,7 +1107,7 @@ char *get_rule_prefix(int match_flags, const char *pat, int for_xfer,
{
static char buf[MAX_RULE_PREFIX+1];
char *op = buf;
int legal_len = for_xfer && protocol_version < 29 ? 1 : MAX_RULE_PREFIX;
int legal_len = for_xfer && protocol_version < 29 ? 1 : MAX_RULE_PREFIX-1;
if (match_flags & MATCHFLG_PERDIR_MERGE) {
if (legal_len == 1)
@@ -1048,6 +1121,8 @@ char *get_rule_prefix(int match_flags, const char *pat, int for_xfer,
else
legal_len = 0;
if (match_flags & MATCHFLG_NEGATE)
*op++ = '!';
if (match_flags & MATCHFLG_CVS_IGNORE)
*op++ = 'C';
else {
@@ -1071,10 +1146,16 @@ char *get_rule_prefix(int match_flags, const char *pat, int for_xfer,
&& (!for_xfer || protocol_version >= 29
|| (delete_excluded && am_sender)))
*op++ = 'r';
if (legal_len)
*op++ = ' ';
if (match_flags & MATCHFLG_PERISHABLE) {
if (!for_xfer || protocol_version >= 30)
*op++ = 'p';
else if (am_sender)
return NULL;
}
if (op - buf > legal_len)
return NULL;
if (legal_len)
*op++ = ' ';
*op = '\0';
if (plen_ptr)
*plen_ptr = op - buf;
@@ -1090,11 +1171,20 @@ static void send_rules(int f_out, struct filter_list_struct *flp)
int elide = 0;
char *p;
/* Note we need to check delete_excluded here in addition to
* the code in parse_rule_tok() because some rules may have
* been added before we found the --delete-excluded option.
* We must also elide any CVS merge-file rules to avoid a
* backward compatibility problem, and we elide any no-prefix
* merge files as an optimization (since they can only have
* include/exclude rules). */
if (ent->match_flags & MATCHFLG_SENDER_SIDE)
elide = am_sender ? 1 : -1;
if (ent->match_flags & MATCHFLG_RECEIVER_SIDE)
elide = elide ? 0 : am_sender ? -1 : 1;
else if (delete_excluded && !elide)
else if (delete_excluded && !elide
&& (!(ent->match_flags & MATCHFLG_PERDIR_MERGE)
|| ent->match_flags & MATCHFLG_NO_PREFIXES))
elide = am_sender ? 1 : -1;
if (elide < 0) {
if (prev)
@@ -1107,16 +1197,16 @@ static void send_rules(int f_out, struct filter_list_struct *flp)
continue;
if (ent->match_flags & MATCHFLG_CVS_IGNORE
&& !(ent->match_flags & MATCHFLG_MERGE_FILE)) {
int f = am_sender || protocol_version < 29 ? f_out : -1;
int f = am_sender || protocol_version < 29 ? f_out : -2;
send_rules(f, &cvs_filter_list);
if (f >= 0)
if (f == f_out)
continue;
}
p = get_rule_prefix(ent->match_flags, ent->pattern, 1, &plen);
if (!p) {
rprintf(FERROR,
"filter rules are too modern for remote rsync.\n");
exit_cleanup(RERR_SYNTAX);
exit_cleanup(RERR_PROTOCOL);
}
if (f_out < 0)
continue;
@@ -1137,8 +1227,8 @@ static void send_rules(int f_out, struct filter_list_struct *flp)
/* This is only called by the client. */
void send_filter_list(int f_out)
{
int receiver_wants_list = delete_mode
&& (!delete_excluded || protocol_version >= 29);
int receiver_wants_list = prune_empty_dirs
|| (delete_mode && (!delete_excluded || protocol_version >= 29));
if (local_server || (am_sender && !receiver_wants_list))
f_out = -1;
@@ -1148,11 +1238,6 @@ void send_filter_list(int f_out)
parse_rule(&filter_list, "-C", 0, 0);
}
/* This is a complete hack - blame Rusty. FIXME!
* Remove this hack when older rsyncs (below 2.6.4) are gone. */
if (list_only == 1 && !recurse)
parse_rule(&filter_list, "/*/*", MATCHFLG_NO_PREFIXES, 0);
send_rules(f_out, &filter_list);
if (f_out >= 0)
@@ -1169,16 +1254,17 @@ void send_filter_list(int f_out)
/* This is only called by the server. */
void recv_filter_list(int f_in)
{
char line[MAXPATHLEN+MAX_RULE_PREFIX+1]; /* +1 for trailing slash. */
char line[BIGPATHBUFLEN];
int xflags = protocol_version >= 29 ? 0 : XFLG_OLD_PREFIXES;
int receiver_wants_list = delete_mode
&& (!delete_excluded || protocol_version >= 29);
int receiver_wants_list = prune_empty_dirs
|| (delete_mode
&& (!delete_excluded || protocol_version >= 29));
unsigned int len;
if (!local_server && (am_sender || receiver_wants_list)) {
while ((len = read_int(f_in)) != 0) {
if (len >= sizeof line)
overflow("recv_rules");
overflow_exit("recv_rules");
read_sbuf(f_in, line, len);
parse_rule(&filter_list, line, 0, xflags);
}

148
fileio.c
View File

@@ -1,71 +1,82 @@
/*
Copyright (C) Andrew Tridgell 1998
Copyright (C) 2002 by Martin Pool
* File IO utilities used in rsync.
*
* Copyright (C) 1998 Andrew Tridgell
* Copyright (C) 2002 Martin Pool
* Copyright (C) 2004-2008 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
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
*/
#include "rsync.h"
#ifndef ENODATA
#define ENODATA EAGAIN
#endif
extern int sparse_files;
static char last_byte;
static int last_sparse;
static size_t sparse_seek = 0;
int sparse_end(int f)
{
if (last_sparse) {
do_lseek(f,-1,SEEK_CUR);
return (write(f,&last_byte,1) == 1 ? 0 : -1);
}
last_sparse = 0;
return 0;
int ret;
if (!sparse_seek)
return 0;
do_lseek(f, sparse_seek-1, SEEK_CUR);
sparse_seek = 0;
do {
ret = write(f, "", 1);
} while (ret < 0 && errno == EINTR);
return ret <= 0 ? -1 : 0;
}
static int write_sparse(int f,char *buf,size_t len)
static int write_sparse(int f, char *buf, size_t len)
{
size_t 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++) {}
/* XXX Riddle me this: why does this function SLOW DOWN when I
* remove the following (unneeded) line?? Core Duo weirdness? */
last_byte = buf[len-1];
if (l1 == len || l2 > 0)
last_sparse=1;
if (l1 > 0) {
do_lseek(f,l1,SEEK_CUR);
}
sparse_seek += l1;
if (l1 == len)
return len;
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 (sparse_seek)
do_lseek(f, sparse_seek, SEEK_CUR);
sparse_seek = l2;
if (l2 > 0)
do_lseek(f,l2,SEEK_CUR);
while ((ret = write(f, buf + l1, len - (l1+l2))) <= 0) {
if (ret < 0 && errno == EINTR)
continue;
return ret;
}
if (ret != (int)(len - (l1+l2)))
return l1+ret;
return len;
}
@@ -103,7 +114,7 @@ int write_file(int f,char *buf,size_t len)
while (len > 0) {
int r1;
if (sparse_files) {
if (sparse_files > 0) {
int len1 = MIN(len, SPARSE_WRITE_SIZE);
r1 = write_sparse(f, buf, len1);
} else {
@@ -148,13 +159,12 @@ struct map_struct *map_file(int fd, OFF_T len, int32 read_size,
{
struct map_struct *map;
if (!(map = new(struct map_struct)))
if (!(map = new0(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->def_window_size = read_size;
@@ -186,7 +196,7 @@ char *map_ptr(struct map_struct *map, OFF_T offset, int32 len)
window_start = offset;
window_size = map->def_window_size;
if (window_start + window_size > map->file_size)
window_size = map->file_size - window_start;
window_size = (int32)(map->file_size - window_start);
if (len > window_size)
window_size = len;
@@ -204,7 +214,7 @@ char *map_ptr(struct map_struct *map, OFF_T offset, int32 len)
window_start < map->p_offset + map->p_len &&
window_start + window_size >= map->p_offset + map->p_len) {
read_start = map->p_offset + map->p_len;
read_offset = read_start - window_start;
read_offset = (int32)(read_start - window_start);
read_size = window_size - read_offset;
memmove(map->p, map->p + (map->p_len - read_offset), read_offset);
} else {
@@ -217,31 +227,35 @@ char *map_ptr(struct map_struct *map, OFF_T offset, int32 len)
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");
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 (!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);
}
map->p_fd_offset += nread;
}
if (map->p_fd_offset != read_start) {
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;
}
map->p_offset = window_start;
map->p_len = window_size;
while (read_size > 0) {
nread = read(map->fd, map->p + read_offset, read_size);
if (nread <= 0) {
if (!map->status)
map->status = nread ? errno : ENODATA;
/* The best we can do is zero the buffer -- the file
* has changed mid transfer! */
memset(map->p + read_offset, 0, read_size);
break;
}
map->p_fd_offset += nread;
read_offset += nread;
read_size -= nread;
}
return map->p;
}

3149
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

View File

@@ -1,28 +1,22 @@
/*
* Copyright (C) 2002 by Martin Pool
*
* 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.
*
* Copyright (C) 2002 Martin Pool
* Copyright (C) 2003-2008 Wayne Davison
*
* 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.
*
* it under the terms of the GNU General Public License version 3 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 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.
**/
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
#include "rsync.h"
@@ -63,6 +57,6 @@ main(UNUSED(int argc), UNUSED(char *argv[]))
if (!gid_in_list)
printf("%lu", (unsigned long)gid);
printf("\n");
return 0;
}

146
hashtable.c Normal file
View File

@@ -0,0 +1,146 @@
/*
* Routines to provide a memory-efficient hashtable.
*
* Copyright (C) 2007-2008 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
#include "rsync.h"
#define HASH_LOAD_LIMIT(size) ((size)*3/4)
struct hashtable *hashtable_create(int size, int key64)
{
struct hashtable *tbl;
int node_size = key64 ? sizeof (struct ht_int64_node)
: sizeof (struct ht_int32_node);
/* Pick a power of 2 that can hold the requested size. */
if (size & (size-1) || size < 16) {
int req = size;
size = 16;
while (size < req)
size *= 2;
}
if (!(tbl = new(struct hashtable))
|| !(tbl->nodes = new_array0(char, size * node_size)))
out_of_memory("hashtable_create");
tbl->size = size;
tbl->entries = 0;
tbl->node_size = node_size;
tbl->key64 = key64;
return tbl;
}
void hashtable_destroy(struct hashtable *tbl)
{
free(tbl->nodes);
free(tbl);
}
/* This returns the node for the indicated key, either newly created or
* already existing. Returns NULL if not allocating and not found. */
void *hashtable_find(struct hashtable *tbl, int64 key, int allocate_if_missing)
{
int key64 = tbl->key64;
struct ht_int32_node *node;
uint32 ndx;
if (allocate_if_missing && tbl->entries > HASH_LOAD_LIMIT(tbl->size)) {
void *old_nodes = tbl->nodes;
int size = tbl->size * 2;
int i;
if (!(tbl->nodes = new_array0(char, size * tbl->node_size)))
out_of_memory("hashtable_node");
tbl->size = size;
tbl->entries = 0;
for (i = size / 2; i-- > 0; ) {
struct ht_int32_node *move_node = HT_NODE(tbl, old_nodes, i);
int64 move_key = HT_KEY(move_node, key64);
if (move_key == 0)
continue;
node = hashtable_find(tbl, move_key, 1);
node->data = move_node->data;
}
free(old_nodes);
}
if (!key64) {
/* Based on Jenkins One-at-a-time hash. */
uchar buf[4], *keyp = buf;
int i;
SIVAL(buf, 0, key);
for (ndx = 0, i = 0; i < 4; i++) {
ndx += keyp[i];
ndx += (ndx << 10);
ndx ^= (ndx >> 6);
}
ndx += (ndx << 3);
ndx ^= (ndx >> 11);
ndx += (ndx << 15);
} else {
/* Based on Jenkins hashword() from lookup3.c. */
uint32 a, b, c;
/* Set up the internal state */
a = b = c = 0xdeadbeef + (8 << 2);
#define rot(x,k) (((x)<<(k)) ^ ((x)>>(32-(k))))
b += (uint32)(key >> 32);
a += (uint32)key;
c ^= b; c -= rot(b, 14);
a ^= c; a -= rot(c, 11);
b ^= a; b -= rot(a, 25);
c ^= b; c -= rot(b, 16);
a ^= c; a -= rot(c, 4);
b ^= a; b -= rot(a, 14);
c ^= b; c -= rot(b, 24);
#undef rot
ndx = c;
}
/* If it already exists, return the node. If we're not
* allocating, return NULL if the key is not found. */
while (1) {
int64 nkey;
ndx &= tbl->size - 1;
node = HT_NODE(tbl, tbl->nodes, ndx);
nkey = HT_KEY(node, key64);
if (nkey == key)
return node;
if (nkey == 0) {
if (!allocate_if_missing)
return NULL;
break;
}
ndx++;
}
/* Take over this empty spot and then return the node. */
if (key64)
((struct ht_int64_node*)node)->key = key;
else
node->key = key;
tbl->entries++;
return node;
}

691
hlink.c
View File

@@ -1,212 +1,531 @@
/*
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.
*/
* Routines to support hard-linking.
*
* Copyright (C) 1996 Andrew Tridgell
* Copyright (C) 1996 Paul Mackerras
* Copyright (C) 2002 Martin Pool <mbp@samba.org>
* Copyright (C) 2004-2008 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
#include "rsync.h"
extern int dry_run;
extern int verbose;
extern int dry_run;
extern int list_only;
extern int am_sender;
extern int inc_recurse;
extern int do_xfers;
extern int link_dest;
extern int preserve_acls;
extern int make_backups;
extern int protocol_version;
extern int remove_source_files;
extern int stdout_format_has_i;
extern int maybe_ATTRS_REPORT;
extern int unsort_ndx;
extern char *basis_dir[];
extern struct file_list *cur_flist;
#ifdef SUPPORT_HARD_LINKS
static int hlink_compare(struct file_struct **file1, struct file_struct **file2)
/* Starting with protocol 30, we use a simple hashtable on the sending side
* for hashing the st_dev and st_ino info. The receiving side gets told
* (via flags and a "group index") which items are hard-linked together, so
* we can avoid the pool of dev+inode data. For incremental recursion mode,
* the receiver will use a ndx hash to remember old pathnames. */
static struct hashtable *dev_tbl;
static struct hashtable *prior_hlinks;
static struct file_list *hlink_flist;
void init_hard_links(void)
{
struct file_struct *f1 = *file1;
struct file_struct *f2 = *file2;
if (f1->F_DEV != f2->F_DEV)
return (int) (f1->F_DEV > f2->F_DEV ? 1 : -1);
if (f1->F_INODE != f2->F_INODE)
return (int) (f1->F_INODE > f2->F_INODE ? 1 : -1);
return f_name_cmp(f1, f2);
if (am_sender || protocol_version < 30)
dev_tbl = hashtable_create(16, SIZEOF_INT64 == 8);
else if (inc_recurse)
prior_hlinks = hashtable_create(1024, 0);
}
static struct file_struct **hlink_list;
static int hlink_count;
#define LINKED(p1,p2) ((p1)->F_DEV == (p2)->F_DEV \
&& (p1)->F_INODE == (p2)->F_INODE)
/* 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(struct file_list *flist)
struct ht_int64_node *idev_find(int64 dev, int64 ino)
{
struct file_struct *head;
int from, to, start;
static struct ht_int64_node *dev_node = NULL;
struct hashtable *tbl;
alloc_pool_t hlink_pool;
alloc_pool_t idev_pool = flist->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;
head = hlink_list[start];
while (from < hlink_count-1
&& LINKED(hlink_list[from], hlink_list[from+1])) {
pool_free(idev_pool, 0, hlink_list[from]->link_u.idev);
hlink_list[from]->link_u.links = pool_talloc(hlink_pool,
struct hlink, 1, "hlink_list");
hlink_list[from]->F_HLINDEX = to;
hlink_list[from]->F_NEXT = hlink_list[from+1];
from++;
}
if (from > start) {
pool_free(idev_pool, 0, hlink_list[from]->link_u.idev);
hlink_list[from]->link_u.links = pool_talloc(hlink_pool,
struct hlink, 1, "hlink_list");
hlink_list[from]->F_HLINDEX = to;
hlink_list[from]->F_NEXT = head;
hlink_list[from]->flags |= FLAG_HLINK_EOL;
hlink_list[to++] = head;
} else {
pool_free(idev_pool, 0, head->link_u.idev);
head->link_u.idev = NULL;
}
}
if (!to) {
free(hlink_list);
hlink_list = NULL;
pool_destroy(hlink_pool);
hlink_pool = NULL;
} else {
hlink_count = to;
if (!(hlink_list = realloc_array(hlink_list,
struct file_struct *, hlink_count)))
out_of_memory("init_hard_links");
}
flist->hlink_pool = hlink_pool;
pool_destroy(idev_pool);
}
#endif
void init_hard_links(struct file_list *flist)
{
#ifdef SUPPORT_HARD_LINKS
int i;
if (flist->count < 2)
return;
if (hlink_list)
free(hlink_list);
if (!(hlink_list = new_array(struct file_struct *, flist->count)))
out_of_memory("init_hard_links");
hlink_count = 0;
for (i = 0; i < flist->count; i++) {
if (flist->files[i]->link_u.idev)
hlink_list[hlink_count++] = flist->files[i];
}
qsort(hlink_list, hlink_count,
sizeof hlink_list[0], (int (*)()) hlink_compare);
if (!hlink_count) {
free(hlink_list);
hlink_list = NULL;
if (!dev_node || dev_node->key != dev) {
/* We keep a separate hash table of inodes for every device. */
dev_node = hashtable_find(dev_tbl, dev, 1);
if (!(tbl = dev_node->data))
tbl = dev_node->data = hashtable_create(512, SIZEOF_INT64 == 8);
} else
link_idev_data(flist);
#endif
tbl = dev_node->data;
return hashtable_find(tbl, ino, 1);
}
int hard_link_check(struct file_struct *file, int skip)
void idev_destroy(void)
{
#ifdef SUPPORT_HARD_LINKS
if (!hlink_list || !file->link_u.links)
return 0;
if (skip && !(file->flags & FLAG_HLINK_EOL))
hlink_list[file->F_HLINDEX] = file->F_NEXT;
if (hlink_list[file->F_HLINDEX] != file) {
if (verbose > 1) {
rprintf(FINFO, "\"%s\" is a hard link\n",
safe_fname(f_name(file)));
}
return 1;
}
#endif
return 0;
}
#ifdef SUPPORT_HARD_LINKS
static void hard_link_one(char *hlink1, char *hlink2)
{
if (do_link(hlink1, hlink2)) {
if (verbose) {
rsyserr(FINFO, errno, "link %s => %s failed",
full_fname(hlink2), safe_fname(hlink1));
}
}
else if (verbose)
rprintf(FINFO, "%s => %s\n", safe_fname(hlink2), safe_fname(hlink1));
}
#endif
/**
* Create any hard links in the global hlink_list. They were put
* there by running init_hard_links on the filelist.
**/
void do_hard_links(void)
{
#ifdef SUPPORT_HARD_LINKS
struct file_struct *file, *first;
char hlink1[MAXPATHLEN];
char *hlink2;
STRUCT_STAT st1, st2;
int i;
if (!hlink_list)
return;
for (i = 0; i < dev_tbl->size; i++) {
struct ht_int32_node *node = HT_NODE(dev_tbl, dev_tbl->nodes, i);
if (node->data)
hashtable_destroy(node->data);
}
for (i = 0; i < hlink_count; i++) {
first = file = hlink_list[i];
if (link_stat(f_name_to(first, hlink1), &st1, 0) < 0)
hashtable_destroy(dev_tbl);
}
static int hlink_compare_gnum(int *int1, int *int2)
{
struct file_struct *f1 = hlink_flist->sorted[*int1];
struct file_struct *f2 = hlink_flist->sorted[*int2];
int32 gnum1 = F_HL_GNUM(f1);
int32 gnum2 = F_HL_GNUM(f2);
if (gnum1 != gnum2)
return gnum1 > gnum2 ? 1 : -1;
return *int1 > *int2 ? 1 : -1;
}
static void match_gnums(int32 *ndx_list, int ndx_count)
{
int32 from, prev;
struct file_struct *file, *file_next;
struct ht_int32_node *node = NULL;
int32 gnum, gnum_next;
qsort(ndx_list, ndx_count, sizeof ndx_list[0],
(int (*)()) hlink_compare_gnum);
for (from = 0; from < ndx_count; from++) {
file = hlink_flist->sorted[ndx_list[from]];
gnum = F_HL_GNUM(file);
if (inc_recurse) {
node = hashtable_find(prior_hlinks, gnum, 1);
if (!node->data) {
node->data = new_array0(char, 5);
assert(gnum >= hlink_flist->ndx_start);
file->flags |= FLAG_HLINK_FIRST;
prev = -1;
} else if (CVAL(node->data, 0) == 0) {
struct file_list *flist;
prev = IVAL(node->data, 1);
flist = flist_for_ndx(prev);
if (flist)
flist->files[prev - flist->ndx_start]->flags &= ~FLAG_HLINK_LAST;
else {
/* We skipped all prior files in this
* group, so mark this as a "first". */
file->flags |= FLAG_HLINK_FIRST;
prev = -1;
}
} else
prev = -1;
} else {
file->flags |= FLAG_HLINK_FIRST;
prev = -1;
}
for ( ; from < ndx_count-1; file = file_next, gnum = gnum_next, from++) { /*SHARED ITERATOR*/
file_next = hlink_flist->sorted[ndx_list[from+1]];
gnum_next = F_HL_GNUM(file_next);
if (gnum != gnum_next)
break;
F_HL_PREV(file) = prev;
/* The linked list uses over-the-wire ndx values. */
if (unsort_ndx)
prev = F_NDX(file);
else
prev = ndx_list[from] + hlink_flist->ndx_start;
}
if (prev < 0 && !inc_recurse) {
/* Disable hard-link bit and set DONE so that
* HLINK_BUMP()-dependent values are unaffected. */
file->flags &= ~(FLAG_HLINKED | FLAG_HLINK_FIRST);
file->flags |= FLAG_HLINK_DONE;
continue;
while ((file = file->F_NEXT) != first) {
hlink2 = f_name(file);
if (link_stat(hlink2, &st2, 0) == 0) {
if (st2.st_dev == st1.st_dev
&& st2.st_ino == st1.st_ino)
continue;
if (make_backups) {
if (!make_backup(hlink2))
continue;
} else if (robust_unlink(hlink2)) {
if (verbose > 0) {
rsyserr(FINFO, errno,
"unlink %s failed",
full_fname(hlink2));
}
}
file->flags |= FLAG_HLINK_LAST;
F_HL_PREV(file) = prev;
if (inc_recurse && CVAL(node->data, 0) == 0) {
if (unsort_ndx)
prev = F_NDX(file);
else
prev = ndx_list[from] + hlink_flist->ndx_start;
SIVAL(node->data, 1, prev);
}
}
}
/* Analyze the hard-links in the file-list by creating a list of all the
* items that have hlink data, sorting them, and matching up identical
* values into clusters. These will be a single linked list from last
* to first when we're done. */
void match_hard_links(struct file_list *flist)
{
if (!list_only) {
int i, ndx_count = 0;
int32 *ndx_list;
if (!(ndx_list = new_array(int32, flist->used)))
out_of_memory("match_hard_links");
for (i = 0; i < flist->used; i++) {
if (F_IS_HLINKED(flist->sorted[i]))
ndx_list[ndx_count++] = i;
}
hlink_flist = flist;
if (ndx_count)
match_gnums(ndx_list, ndx_count);
free(ndx_list);
}
if (protocol_version < 30)
idev_destroy();
}
static int maybe_hard_link(struct file_struct *file, int ndx,
const char *fname, int statret, stat_x *sxp,
const char *oldname, STRUCT_STAT *old_stp,
const char *realname, int itemizing, enum logcode code)
{
if (statret == 0) {
if (sxp->st.st_dev == old_stp->st_dev
&& sxp->st.st_ino == old_stp->st_ino) {
if (itemizing) {
itemize(fname, file, ndx, statret, sxp,
ITEM_LOCAL_CHANGE | ITEM_XNAME_FOLLOWS,
0, "");
}
if (verbose > 1 && maybe_ATTRS_REPORT)
rprintf(FCLIENT, "%s is uptodate\n", fname);
file->flags |= FLAG_HLINK_DONE;
return 0;
}
if (make_backups > 0) {
if (!make_backup(fname))
return -1;
} else if (robust_unlink(fname)) {
rsyserr(FERROR_XFER, errno, "unlink %s failed",
full_fname(fname));
return -1;
}
}
if (hard_link_one(file, fname, oldname, 0)) {
if (itemizing) {
itemize(fname, file, ndx, statret, sxp,
ITEM_LOCAL_CHANGE | ITEM_XNAME_FOLLOWS, 0,
realname);
}
if (code != FNONE && verbose)
rprintf(code, "%s => %s\n", fname, realname);
return 0;
}
return -1;
}
/* Figure out if a prior entry is still there or if we just have a
* cached name for it. */
static char *check_prior(struct file_struct *file, int gnum,
int *prev_ndx_p, struct file_list **flist_p)
{
struct file_struct *fp;
struct ht_int32_node *node;
int prev_ndx = F_HL_PREV(file);
while (1) {
struct file_list *flist;
if (prev_ndx < 0
|| (flist = flist_for_ndx(prev_ndx)) == NULL)
break;
fp = flist->files[prev_ndx - flist->ndx_start];
if (!(fp->flags & FLAG_SKIP_HLINK)) {
*prev_ndx_p = prev_ndx;
*flist_p = flist;
return NULL;
}
F_HL_PREV(file) = prev_ndx = F_HL_PREV(fp);
}
if ((node = hashtable_find(prior_hlinks, gnum, 0)) != NULL) {
assert(node->data != NULL);
if (CVAL(node->data, 0) != 0) {
*prev_ndx_p = -1;
*flist_p = NULL;
return node->data;
}
/* The prior file must have been skipped. */
F_HL_PREV(file) = -1;
}
*prev_ndx_p = -1;
*flist_p = NULL;
return NULL;
}
/* Only called if FLAG_HLINKED is set and FLAG_HLINK_FIRST is not. Returns:
* 0 = process the file, 1 = skip the file, -1 = error occurred. */
int hard_link_check(struct file_struct *file, int ndx, const char *fname,
int statret, stat_x *sxp, int itemizing,
enum logcode code)
{
STRUCT_STAT prev_st;
char namebuf[MAXPATHLEN], altbuf[MAXPATHLEN];
char *realname, *prev_name;
struct file_list *flist;
int gnum = inc_recurse ? F_HL_GNUM(file) : -1;
int prev_ndx;
prev_name = realname = check_prior(file, gnum, &prev_ndx, &flist);
if (!prev_name) {
struct file_struct *prev_file;
if (!flist) {
/* The previous file was skipped, so this one is
* treated as if it were the first in its group. */
return 0;
}
prev_file = flist->files[prev_ndx - flist->ndx_start];
/* Is the previous link not complete yet? */
if (!(prev_file->flags & FLAG_HLINK_DONE)) {
/* Is the previous link being transferred? */
if (prev_file->flags & FLAG_FILE_SENT) {
/* Add ourselves to the list of files that will
* be updated when the transfer completes, and
* mark ourself as waiting for the transfer. */
F_HL_PREV(file) = F_HL_PREV(prev_file);
F_HL_PREV(prev_file) = ndx;
file->flags |= FLAG_FILE_SENT;
cur_flist->in_progress++;
return 1;
}
return 0;
}
/* There is a finished file to link with! */
if (!(prev_file->flags & FLAG_HLINK_FIRST)) {
/* The previous previous is FIRST when prev is not. */
prev_name = realname = check_prior(prev_file, gnum, &prev_ndx, &flist);
assert(prev_name != NULL || flist != NULL);
/* Update our previous pointer to point to the FIRST. */
F_HL_PREV(file) = prev_ndx;
}
if (!prev_name) {
int alt_dest;
prev_file = flist->files[prev_ndx - flist->ndx_start];
/* F_HL_PREV() is alt_dest value when DONE && FIRST. */
alt_dest = F_HL_PREV(prev_file);
if (alt_dest >= 0 && dry_run) {
pathjoin(namebuf, MAXPATHLEN, basis_dir[alt_dest],
f_name(prev_file, NULL));
prev_name = namebuf;
realname = f_name(prev_file, altbuf);
} else {
prev_name = f_name(prev_file, namebuf);
realname = prev_name;
}
}
}
if (link_stat(prev_name, &prev_st, 0) < 0) {
rsyserr(FERROR_XFER, errno, "stat %s failed",
full_fname(prev_name));
return -1;
}
if (statret < 0 && basis_dir[0] != NULL) {
/* If we match an alt-dest item, we don't output this as a change. */
char cmpbuf[MAXPATHLEN];
stat_x alt_sx;
int j = 0;
#ifdef SUPPORT_ACLS
alt_sx.acc_acl = alt_sx.def_acl = NULL;
#endif
do {
pathjoin(cmpbuf, MAXPATHLEN, basis_dir[j], fname);
if (link_stat(cmpbuf, &alt_sx.st, 0) < 0)
continue;
if (link_dest) {
if (prev_st.st_dev != alt_sx.st.st_dev
|| prev_st.st_ino != alt_sx.st.st_ino)
continue;
statret = 1;
if (stdout_format_has_i == 0
|| (verbose < 2 && stdout_format_has_i < 2)) {
itemizing = 0;
code = FNONE;
if (verbose > 1 && maybe_ATTRS_REPORT)
rprintf(FCLIENT, "%s is uptodate\n", fname);
}
break;
}
if (!unchanged_file(cmpbuf, file, &alt_sx.st))
continue;
statret = 1;
if (unchanged_attrs(cmpbuf, file, &alt_sx))
break;
} while (basis_dir[++j] != NULL);
if (statret == 1) {
sxp->st = alt_sx.st;
#ifdef SUPPORT_ACLS
if (preserve_acls && !S_ISLNK(file->mode)) {
if (!ACL_READY(*sxp))
get_acl(cmpbuf, sxp);
else {
sxp->acc_acl = alt_sx.acc_acl;
sxp->def_acl = alt_sx.def_acl;
}
}
hard_link_one(hlink1, hlink2);
}
}
#endif
}
#ifdef SUPPORT_ACLS
else if (preserve_acls)
free_acl(&alt_sx);
#endif
}
if (maybe_hard_link(file, ndx, fname, statret, sxp, prev_name, &prev_st,
realname, itemizing, code) < 0)
return -1;
if (remove_source_files == 1 && do_xfers)
send_msg_int(MSG_SUCCESS, ndx);
return 1;
}
int hard_link_one(struct file_struct *file, const char *fname,
const char *oldname, int terse)
{
if (do_link(oldname, fname) < 0) {
enum logcode code;
if (terse) {
if (!verbose)
return 0;
code = FINFO;
} else
code = FERROR_XFER;
rsyserr(code, errno, "link %s => %s failed",
full_fname(fname), oldname);
return 0;
}
file->flags |= FLAG_HLINK_DONE;
return 1;
}
void finish_hard_link(struct file_struct *file, const char *fname, int fin_ndx,
STRUCT_STAT *stp, int itemizing, enum logcode code,
int alt_dest)
{
stat_x prev_sx;
STRUCT_STAT st;
char alt_name[MAXPATHLEN], *prev_name;
const char *our_name;
struct file_list *flist;
int prev_statret, ndx, prev_ndx = F_HL_PREV(file);
if (stp == NULL && prev_ndx >= 0) {
if (link_stat(fname, &st, 0) < 0) {
rsyserr(FERROR_XFER, errno, "stat %s failed",
full_fname(fname));
return;
}
stp = &st;
}
/* FIRST combined with DONE means we were the first to get done. */
file->flags |= FLAG_HLINK_FIRST | FLAG_HLINK_DONE;
F_HL_PREV(file) = alt_dest;
if (alt_dest >= 0 && dry_run) {
pathjoin(alt_name, MAXPATHLEN, basis_dir[alt_dest],
f_name(file, NULL));
our_name = alt_name;
} else
our_name = fname;
#ifdef SUPPORT_ACLS
prev_sx.acc_acl = prev_sx.def_acl = NULL;
#endif
while ((ndx = prev_ndx) >= 0) {
int val;
flist = flist_for_ndx(ndx);
assert(flist != NULL);
file = flist->files[ndx - flist->ndx_start];
file->flags = (file->flags & ~FLAG_HLINK_FIRST) | FLAG_HLINK_DONE;
prev_ndx = F_HL_PREV(file);
F_HL_PREV(file) = fin_ndx;
prev_name = f_name(file, NULL);
prev_statret = link_stat(prev_name, &prev_sx.st, 0);
val = maybe_hard_link(file, ndx, prev_name, prev_statret, &prev_sx,
our_name, stp, fname, itemizing, code);
flist->in_progress--;
#ifdef SUPPORT_ACLS
if (preserve_acls)
free_acl(&prev_sx);
#endif
if (val < 0)
continue;
if (remove_source_files == 1 && do_xfers)
send_msg_int(MSG_SUCCESS, ndx);
}
if (inc_recurse) {
int gnum = F_HL_GNUM(file);
struct ht_int32_node *node = hashtable_find(prior_hlinks, gnum, 0);
assert(node != NULL && node->data != NULL);
assert(CVAL(node->data, 0) == 0);
free(node->data);
if (!(node->data = strdup(our_name)))
out_of_memory("finish_hard_link");
}
}
int skip_hard_link(struct file_struct *file, struct file_list **flist_p)
{
struct file_list *flist;
int prev_ndx;
file->flags |= FLAG_SKIP_HLINK;
if (!(file->flags & FLAG_HLINK_LAST))
return -1;
check_prior(file, F_HL_GNUM(file), &prev_ndx, &flist);
if (prev_ndx >= 0) {
file = flist->files[prev_ndx - flist->ndx_start];
if (file->flags & (FLAG_HLINK_DONE|FLAG_FILE_SENT))
return -1;
file->flags |= FLAG_HLINK_LAST;
*flist_p = flist;
}
return prev_ndx;
}
#endif

110
ifuncs.h Normal file
View File

@@ -0,0 +1,110 @@
/* Inline functions for rsync.
*
* Copyright (C) 2007-2008 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
static inline void
alloc_xbuf(xbuf *xb, size_t sz)
{
if (!(xb->buf = new_array(char, sz)))
out_of_memory("alloc_xbuf");
xb->size = sz;
xb->len = xb->pos = 0;
}
static inline void
realloc_xbuf(xbuf *xb, size_t sz)
{
char *bf = realloc_array(xb->buf, char, sz);
if (!bf)
out_of_memory("realloc_xbuf");
xb->buf = bf;
xb->size = sz;
}
static inline int
to_wire_mode(mode_t mode)
{
#ifdef SUPPORT_LINKS
#if _S_IFLNK != 0120000
if (S_ISLNK(mode))
return (mode & ~(_S_IFMT)) | 0120000;
#endif
#endif
return mode;
}
static inline mode_t
from_wire_mode(int mode)
{
#if _S_IFLNK != 0120000
if ((mode & (_S_IFMT)) == 0120000)
return (mode & ~(_S_IFMT)) | _S_IFLNK;
#endif
return mode;
}
static inline char *
d_name(struct dirent *di)
{
#ifdef HAVE_BROKEN_READDIR
return (di->d_name - 2);
#else
return di->d_name;
#endif
}
static inline int
isDigit(const char *ptr)
{
return isdigit(*(unsigned char *)ptr);
}
static inline int
isPrint(const char *ptr)
{
return isprint(*(unsigned char *)ptr);
}
static inline int
isSpace(const char *ptr)
{
return isspace(*(unsigned char *)ptr);
}
static inline int
isLower(const char *ptr)
{
return islower(*(unsigned char *)ptr);
}
static inline int
isUpper(const char *ptr)
{
return isupper(*(unsigned char *)ptr);
}
static inline int
toLower(const char *ptr)
{
return tolower(*(unsigned char *)ptr);
}
static inline int
toUpper(const char *ptr)
{
return toupper(*(unsigned char *)ptr);
}

1624
io.c
View File

File diff suppressed because it is too large Load Diff

52
io.h Normal file
View File

@@ -0,0 +1,52 @@
/*
* Copyright (C) 2007-2008 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
extern int protocol_version;
static inline int32
read_varint30(int f)
{
if (protocol_version < 30)
return read_int(f);
return read_varint(f);
}
static inline int64
read_varlong30(int f, uchar min_bytes)
{
if (protocol_version < 30)
return read_longint(f);
return read_varlong(f, min_bytes);
}
static inline void
write_varint30(int f, int32 x)
{
if (protocol_version < 30)
write_int(f, x);
else
write_varint(f, x);
}
static inline void
write_varlong30(int f, int64 x, uchar min_bytes)
{
if (protocol_version < 30)
write_longint(f, x);
else
write_varlong(f, x, min_bytes);
}

View File

@@ -1 +0,0 @@
dummy

180
lib/addrinfo.h Normal file
View File

@@ -0,0 +1,180 @@
/*
PostgreSQL Database Management System
(formerly known as Postgres, then as Postgres95)
Portions Copyright (c) 1996-2005, The PostgreSQL Global Development Group
Portions Copyright (c) 1994, The Regents of the University of California
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose, without fee, and without a written agreement
is hereby granted, provided that the above copyright notice and this paragraph
and the following two paragraphs appear in all copies.
IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS
TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*/
/*-------------------------------------------------------------------------
*
* getaddrinfo.h
* Support getaddrinfo() on platforms that don't have it.
*
* Note: we use our own routines on platforms that don't HAVE_STRUCT_ADDRINFO,
* whether or not the library routine getaddrinfo() can be found. This
* policy is needed because on some platforms a manually installed libbind.a
* may provide getaddrinfo(), yet the system headers may not provide the
* struct definitions needed to call it. To avoid conflict with the libbind
* definition in such cases, we rename our routines to pg_xxx() via macros.
*
* This code will also work on platforms where struct addrinfo is defined
* in the system headers but no getaddrinfo() can be located.
*
* Copyright (c) 2003-2007, PostgreSQL Global Development Group
*
*-------------------------------------------------------------------------
*/
#ifndef ADDRINFO_H
#define ADDRINFO_H
/* Various macros that ought to be in <netdb.h>, but might not be */
#ifndef EAI_FAIL
#define EAI_BADFLAGS (-1)
#define EAI_NONAME (-2)
#define EAI_AGAIN (-3)
#define EAI_FAIL (-4)
#define EAI_FAMILY (-6)
#define EAI_SOCKTYPE (-7)
#define EAI_SERVICE (-8)
#define EAI_MEMORY (-10)
#define EAI_SYSTEM (-11)
#endif /* !EAI_FAIL */
#ifndef AI_PASSIVE
#define AI_PASSIVE 0x0001
#endif
#ifndef AI_NUMERICHOST
/*
* some platforms don't support AI_NUMERICHOST; define as zero if using
* the system version of getaddrinfo...
*/
#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
#define AI_NUMERICHOST 0
#else
#define AI_NUMERICHOST 0x0004
#endif
#endif
#ifndef AI_CANONNAME
#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
#define AI_CANONNAME 0
#else
#define AI_CANONNAME 0x0008
#endif
#endif
#ifndef AI_NUMERICSERV
#if defined(HAVE_STRUCT_ADDRINFO) && defined(HAVE_GETADDRINFO)
#define AI_NUMERICSERV 0
#else
#define AI_NUMERICSERV 0x0010
#endif
#endif
#ifndef NI_NUMERICHOST
#define NI_NUMERICHOST 1
#endif
#ifndef NI_NUMERICSERV
#define NI_NUMERICSERV 2
#endif
#ifndef NI_NOFQDN
#define NI_NOFQDN 4
#endif
#ifndef NI_NAMEREQD
#define NI_NAMEREQD 8
#endif
#ifndef NI_DGRAM
#define NI_DGRAM 16
#endif
#ifndef NI_MAXHOST
#define NI_MAXHOST 1025
#endif
#ifndef NI_MAXSERV
#define NI_MAXSERV 32
#endif
#ifndef HAVE_STRUCT_ADDRINFO
struct addrinfo
{
int ai_flags;
int ai_family;
int ai_socktype;
int ai_protocol;
size_t ai_addrlen;
struct sockaddr *ai_addr;
char *ai_canonname;
struct addrinfo *ai_next;
};
#endif /* !HAVE_STRUCT_ADDRINFO */
#ifndef HAVE_STRUCT_SOCKADDR_STORAGE
struct sockaddr_storage {
unsigned short ss_family;
unsigned long ss_align;
char ss_padding[128 - sizeof (unsigned long)];
};
#endif /* !HAVE_STRUCT_SOCKADDR_STORAGE */
#ifndef HAVE_GETADDRINFO
/* Rename private copies per comments above */
#ifdef getaddrinfo
#undef getaddrinfo
#endif
#define getaddrinfo pg_getaddrinfo
#ifdef freeaddrinfo
#undef freeaddrinfo
#endif
#define freeaddrinfo pg_freeaddrinfo
#ifdef gai_strerror
#undef gai_strerror
#endif
#define gai_strerror pg_gai_strerror
#ifdef getnameinfo
#undef getnameinfo
#endif
#define getnameinfo pg_getnameinfo
extern int getaddrinfo(const char *node, const char *service,
const struct addrinfo * hints, struct addrinfo ** res);
extern void freeaddrinfo(struct addrinfo * res);
extern const char *gai_strerror(int errcode);
extern int getnameinfo(const struct sockaddr * sa, socklen_t salen,
char *node, size_t nodelen,
char *service, size_t servicelen, int flags);
#endif /* !HAVE_GETADDRINFO */
#endif /* ADDRINFO_H */

View File

@@ -1,42 +1,34 @@
/*
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 compat.c
/*
* Reimplementations of standard functions for platforms that don't have them.
*
* Reimplementations of standard functions for platforms that don't
* have them.
**/
* Copyright (C) 1998 Andrew Tridgell
* Copyright (C) 2002 Martin Pool
* Copyright (C) 2004, 2005, 2006 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
#include "rsync.h"
#ifndef HAVE_STRDUP
char *strdup(char *s)
{
int l = strlen(s) + 1;
char *ret = (char *)malloc(l);
if (ret)
strcpy(ret,s);
return ret;
int len = strlen(s) + 1;
char *ret = (char *)malloc(len);
if (ret)
memcpy(ret, s, len);
return ret;
}
#endif
@@ -86,7 +78,7 @@
/**
* Find the first ocurrence in @p s of any character in @p accept.
*
* Derived from glibc
* Derived from glibc
**/
char *strpbrk(const char *s, const char *accept)
{
@@ -105,7 +97,7 @@
#ifndef HAVE_STRLCPY
/**
* Like strncpy but does not 0 fill the buffer and always null
* Like strncpy but does not 0 fill the buffer and always null
* terminates.
*
* @param bufsize is the size of the destination buffer.
@@ -128,7 +120,7 @@
#ifndef HAVE_STRLCAT
/**
* Like strncat() but does not 0 fill the buffer and always null
* 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
@@ -150,49 +142,6 @@
}
#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)
{

508
lib/getaddrinfo.c Normal file
View File

@@ -0,0 +1,508 @@
/*
PostgreSQL Database Management System
(formerly known as Postgres, then as Postgres95)
Portions Copyright (c) 1996-2005, The PostgreSQL Global Development Group
Portions Copyright (c) 1994, The Regents of the University of California
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose, without fee, and without a written agreement
is hereby granted, provided that the above copyright notice and this paragraph
and the following two paragraphs appear in all copies.
IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS
TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*/
/*-------------------------------------------------------------------------
*
* getaddrinfo.c
* Support getaddrinfo() on platforms that don't have it.
*
* We also supply getnameinfo() here, assuming that the platform will have
* it if and only if it has getaddrinfo(). If this proves false on some
* platform, we'll need to split this file and provide a separate configure
* test for getnameinfo().
*
* Copyright (c) 2003-2007, PostgreSQL Global Development Group
*
* Copyright (C) 2007 Jeremy Allison.
* Modified to return multiple IPv4 addresses for Samba.
*
*-------------------------------------------------------------------------
*/
#include "rsync.h"
#ifndef SMB_MALLOC
#define SMB_MALLOC(s) malloc(s)
#endif
#ifndef SMB_STRDUP
#define SMB_STRDUP(s) strdup(s)
#endif
#ifndef HOST_NAME_MAX
#define HOST_NAME_MAX 255
#endif
static int check_hostent_err(struct hostent *hp)
{
#ifndef INET6
extern int h_errno;
#endif
if (!hp) {
switch (h_errno) {
case HOST_NOT_FOUND:
case NO_DATA:
return EAI_NONAME;
case TRY_AGAIN:
return EAI_AGAIN;
case NO_RECOVERY:
default:
return EAI_FAIL;
}
}
if (!hp->h_name || hp->h_addrtype != AF_INET) {
return EAI_FAIL;
}
return 0;
}
static char *canon_name_from_hostent(struct hostent *hp,
int *perr)
{
char *ret = NULL;
*perr = check_hostent_err(hp);
if (*perr) {
return NULL;
}
ret = SMB_STRDUP(hp->h_name);
if (!ret) {
*perr = EAI_MEMORY;
}
return ret;
}
static char *get_my_canon_name(int *perr)
{
char name[HOST_NAME_MAX+1];
if (gethostname(name, HOST_NAME_MAX) == -1) {
*perr = EAI_FAIL;
return NULL;
}
/* Ensure null termination. */
name[HOST_NAME_MAX] = '\0';
return canon_name_from_hostent(gethostbyname(name), perr);
}
static char *get_canon_name_from_addr(struct in_addr ip,
int *perr)
{
return canon_name_from_hostent(
gethostbyaddr((void *)&ip, sizeof ip, AF_INET),
perr);
}
static struct addrinfo *alloc_entry(const struct addrinfo *hints,
struct in_addr ip,
unsigned short port)
{
struct sockaddr_in *psin = NULL;
struct addrinfo *ai = SMB_MALLOC(sizeof(*ai));
if (!ai) {
return NULL;
}
memset(ai, '\0', sizeof(*ai));
psin = SMB_MALLOC(sizeof(*psin));
if (!psin) {
free(ai);
return NULL;
}
memset(psin, '\0', sizeof(*psin));
psin->sin_family = AF_INET;
psin->sin_port = htons(port);
psin->sin_addr = ip;
ai->ai_flags = 0;
ai->ai_family = AF_INET;
ai->ai_socktype = hints->ai_socktype;
ai->ai_protocol = hints->ai_protocol;
ai->ai_addrlen = sizeof(*psin);
ai->ai_addr = (struct sockaddr *) psin;
ai->ai_canonname = NULL;
ai->ai_next = NULL;
return ai;
}
/*
* get address info for a single ipv4 address.
*
* Bugs: - servname can only be a number, not text.
*/
static int getaddr_info_single_addr(const char *service,
uint32 addr,
const struct addrinfo *hints,
struct addrinfo **res)
{
struct addrinfo *ai = NULL;
struct in_addr ip;
unsigned short port = 0;
if (service) {
port = (unsigned short)atoi(service);
}
ip.s_addr = htonl(addr);
ai = alloc_entry(hints, ip, port);
if (!ai) {
return EAI_MEMORY;
}
/* If we're asked for the canonical name,
* make sure it returns correctly. */
if (!(hints->ai_flags & AI_NUMERICSERV) &&
hints->ai_flags & AI_CANONNAME) {
int err;
if (addr == INADDR_LOOPBACK || addr == INADDR_ANY) {
ai->ai_canonname = get_my_canon_name(&err);
} else {
ai->ai_canonname =
get_canon_name_from_addr(ip,&err);
}
if (ai->ai_canonname == NULL) {
freeaddrinfo(ai);
return err;
}
}
*res = ai;
return 0;
}
/*
* get address info for multiple ipv4 addresses.
*
* Bugs: - servname can only be a number, not text.
*/
static int getaddr_info_name(const char *node,
const char *service,
const struct addrinfo *hints,
struct addrinfo **res)
{
struct addrinfo *listp = NULL, *prevp = NULL;
char **pptr = NULL;
int err;
struct hostent *hp = NULL;
unsigned short port = 0;
if (service) {
port = (unsigned short)atoi(service);
}
hp = gethostbyname(node);
err = check_hostent_err(hp);
if (err) {
return err;
}
for(pptr = hp->h_addr_list; *pptr; pptr++) {
struct in_addr ip = *(struct in_addr *)*pptr;
struct addrinfo *ai = alloc_entry(hints, ip, port);
if (!ai) {
freeaddrinfo(listp);
return EAI_MEMORY;
}
if (!listp) {
listp = ai;
prevp = ai;
ai->ai_canonname = SMB_STRDUP(hp->h_name);
if (!ai->ai_canonname) {
freeaddrinfo(listp);
return EAI_MEMORY;
}
} else {
prevp->ai_next = ai;
prevp = ai;
}
}
*res = listp;
return 0;
}
/*
* get address info for ipv4 sockets.
*
* Bugs: - servname can only be a number, not text.
*/
int getaddrinfo(const char *node,
const char *service,
const struct addrinfo * hintp,
struct addrinfo ** res)
{
struct addrinfo hints;
/* Setup the hints struct. */
if (hintp == NULL) {
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
} else {
memcpy(&hints, hintp, sizeof(hints));
}
if (hints.ai_family != AF_INET && hints.ai_family != AF_UNSPEC) {
return EAI_FAMILY;
}
if (hints.ai_socktype == 0) {
hints.ai_socktype = SOCK_STREAM;
}
if (!node && !service) {
return EAI_NONAME;
}
if (node) {
if (node[0] == '\0') {
return getaddr_info_single_addr(service,
INADDR_ANY,
&hints,
res);
} else if (hints.ai_flags & AI_NUMERICHOST) {
struct in_addr ip;
if (!inet_aton(node, &ip)) {
return EAI_FAIL;
}
return getaddr_info_single_addr(service,
ntohl(ip.s_addr),
&hints,
res);
} else {
return getaddr_info_name(node,
service,
&hints,
res);
}
} else if (hints.ai_flags & AI_PASSIVE) {
return getaddr_info_single_addr(service,
INADDR_ANY,
&hints,
res);
}
return getaddr_info_single_addr(service,
INADDR_LOOPBACK,
&hints,
res);
}
void freeaddrinfo(struct addrinfo *res)
{
struct addrinfo *next = NULL;
for (;res; res = next) {
next = res->ai_next;
if (res->ai_canonname) {
free(res->ai_canonname);
}
if (res->ai_addr) {
free(res->ai_addr);
}
free(res);
}
}
const char *gai_strerror(int errcode)
{
#ifdef HAVE_HSTRERROR
int hcode;
switch (errcode)
{
case EAI_NONAME:
hcode = HOST_NOT_FOUND;
break;
case EAI_AGAIN:
hcode = TRY_AGAIN;
break;
case EAI_FAIL:
default:
hcode = NO_RECOVERY;
break;
}
return hstrerror(hcode);
#else /* !HAVE_HSTRERROR */
switch (errcode)
{
case EAI_NONAME:
return "Unknown host";
case EAI_AGAIN:
return "Host name lookup failure";
#ifdef EAI_BADFLAGS
case EAI_BADFLAGS:
return "Invalid argument";
#endif
#ifdef EAI_FAMILY
case EAI_FAMILY:
return "Address family not supported";
#endif
#ifdef EAI_MEMORY
case EAI_MEMORY:
return "Not enough memory";
#endif
#ifdef EAI_NODATA
case EAI_NODATA:
return "No host data of that type was found";
#endif
#ifdef EAI_SERVICE
case EAI_SERVICE:
return "Class type not found";
#endif
#ifdef EAI_SOCKTYPE
case EAI_SOCKTYPE:
return "Socket type not supported";
#endif
default:
return "Unknown server error";
}
#endif /* HAVE_HSTRERROR */
}
static int gethostnameinfo(const struct sockaddr *sa,
char *node,
size_t nodelen,
int flags)
{
int ret = -1;
char *p = NULL;
if (!(flags & NI_NUMERICHOST)) {
struct hostent *hp = gethostbyaddr(
(void *)&((struct sockaddr_in *)sa)->sin_addr,
sizeof (struct in_addr),
sa->sa_family);
ret = check_hostent_err(hp);
if (ret == 0) {
/* Name looked up successfully. */
ret = snprintf(node, nodelen, "%s", hp->h_name);
if (ret < 0 || (size_t)ret >= nodelen) {
return EAI_MEMORY;
}
if (flags & NI_NOFQDN) {
p = strchr(node,'.');
if (p) {
*p = '\0';
}
}
return 0;
}
if (flags & NI_NAMEREQD) {
/* If we require a name and didn't get one,
* automatically fail. */
return ret;
}
/* Otherwise just fall into the numeric host code... */
}
p = inet_ntoa(((struct sockaddr_in *)sa)->sin_addr);
ret = snprintf(node, nodelen, "%s", p);
if (ret < 0 || (size_t)ret >= nodelen) {
return EAI_MEMORY;
}
return 0;
}
static int getservicenameinfo(const struct sockaddr *sa,
char *service,
size_t servicelen,
int flags)
{
int ret = -1;
int port = ntohs(((struct sockaddr_in *)sa)->sin_port);
if (!(flags & NI_NUMERICSERV)) {
struct servent *se = getservbyport(
port,
(flags & NI_DGRAM) ? "udp" : "tcp");
if (se && se->s_name) {
/* Service name looked up successfully. */
ret = snprintf(service, servicelen, "%s", se->s_name);
if (ret < 0 || (size_t)ret >= servicelen) {
return EAI_MEMORY;
}
return 0;
}
/* Otherwise just fall into the numeric service code... */
}
ret = snprintf(service, servicelen, "%d", port);
if (ret < 0 || (size_t)ret >= servicelen) {
return EAI_MEMORY;
}
return 0;
}
/*
* Convert an ipv4 address to a hostname.
*
* Bugs: - No IPv6 support.
*/
int getnameinfo(const struct sockaddr *sa, socklen_t salen,
char *node, size_t nodelen,
char *service, size_t servicelen, int flags)
{
/* Invalid arguments. */
if (sa == NULL || (node == NULL && service == NULL)) {
return EAI_FAIL;
}
if (sa->sa_family != AF_INET) {
return EAI_FAIL;
}
if (salen < (socklen_t)sizeof (struct sockaddr_in)) {
return EAI_FAIL;
}
/* We don't support those. */
if ((node && !(flags & NI_NUMERICHOST))
|| (service && !(flags & NI_NUMERICSERV)))
return EAI_FAIL;
if (node) {
return gethostnameinfo(sa, node, nodelen, flags);
}
if (service) {
return getservicenameinfo(sa, service, servicelen, flags);
}
return 0;
}

View File

@@ -75,13 +75,14 @@ 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"];
size_t len;
if ((size_t)sprintf(tmp, fmt, src[0], src[1], src[2], src[3]) >= size)
{
len = snprintf(tmp, sizeof tmp, fmt, src[0], src[1], src[2], src[3]);
if (len >= size) {
errno = ENOSPC;
return (NULL);
}
strcpy(dst, tmp);
memcpy(dst, tmp, len + 1);
return (dst);
}
@@ -106,7 +107,7 @@ inet_ntop6(const unsigned char *src, char *dst, size_t size)
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;
int i, inc;
/*
* Preprocess:
@@ -157,13 +158,14 @@ inet_ntop6(const unsigned char *src, char *dst, size_t size)
/* 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)))
if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp)))
return (NULL);
tp += strlen(tp);
break;
}
tp += sprintf(tp, "%x", words[i]);
inc = snprintf(tp, 5, "%x", words[i]);
assert(inc < 5);
tp += inc;
}
/* Was it a trailing run of 0x00's? */
if (best.base != -1 && (best.base + best.len) ==
@@ -178,7 +180,7 @@ inet_ntop6(const unsigned char *src, char *dst, size_t size)
errno = ENOSPC;
return (NULL);
}
strcpy(dst, tmp);
memcpy(dst, tmp, tp - tmp);
return (dst);
}
#endif /* AF_INET6 */

304
lib/md5.c Normal file
View File

@@ -0,0 +1,304 @@
/*
* RFC 1321 compliant MD5 implementation
*
* Copyright (C) 2001-2003 Christophe Devine
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
#include "rsync.h"
void md5_begin(md_context *ctx)
{
ctx->A = 0x67452301;
ctx->B = 0xEFCDAB89;
ctx->C = 0x98BADCFE;
ctx->D = 0x10325476;
ctx->totalN = ctx->totalN2 = 0;
}
static void md5_process(md_context *ctx, const uchar data[CSUM_CHUNK])
{
uint32 X[16], A, B, C, D;
A = ctx->A;
B = ctx->B;
C = ctx->C;
D = ctx->D;
X[0] = IVAL(data, 0);
X[1] = IVAL(data, 4);
X[2] = IVAL(data, 8);
X[3] = IVAL(data, 12);
X[4] = IVAL(data, 16);
X[5] = IVAL(data, 20);
X[6] = IVAL(data, 24);
X[7] = IVAL(data, 28);
X[8] = IVAL(data, 32);
X[9] = IVAL(data, 36);
X[10] = IVAL(data, 40);
X[11] = IVAL(data, 44);
X[12] = IVAL(data, 48);
X[13] = IVAL(data, 52);
X[14] = IVAL(data, 56);
X[15] = IVAL(data, 60);
#define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n)))
#define P(a,b,c,d,k,s,t) a += F(b,c,d) + X[k] + t, a = S(a,s) + b
#define F(x,y,z) (z ^ (x & (y ^ z)))
P(A, B, C, D, 0, 7, 0xD76AA478);
P(D, A, B, C, 1, 12, 0xE8C7B756);
P(C, D, A, B, 2, 17, 0x242070DB);
P(B, C, D, A, 3, 22, 0xC1BDCEEE);
P(A, B, C, D, 4, 7, 0xF57C0FAF);
P(D, A, B, C, 5, 12, 0x4787C62A);
P(C, D, A, B, 6, 17, 0xA8304613);
P(B, C, D, A, 7, 22, 0xFD469501);
P(A, B, C, D, 8, 7, 0x698098D8);
P(D, A, B, C, 9, 12, 0x8B44F7AF);
P(C, D, A, B, 10, 17, 0xFFFF5BB1);
P(B, C, D, A, 11, 22, 0x895CD7BE);
P(A, B, C, D, 12, 7, 0x6B901122);
P(D, A, B, C, 13, 12, 0xFD987193);
P(C, D, A, B, 14, 17, 0xA679438E);
P(B, C, D, A, 15, 22, 0x49B40821);
#undef F
#define F(x,y,z) (y ^ (z & (x ^ y)))
P(A, B, C, D, 1, 5, 0xF61E2562);
P(D, A, B, C, 6, 9, 0xC040B340);
P(C, D, A, B, 11, 14, 0x265E5A51);
P(B, C, D, A, 0, 20, 0xE9B6C7AA);
P(A, B, C, D, 5, 5, 0xD62F105D);
P(D, A, B, C, 10, 9, 0x02441453);
P(C, D, A, B, 15, 14, 0xD8A1E681);
P(B, C, D, A, 4, 20, 0xE7D3FBC8);
P(A, B, C, D, 9, 5, 0x21E1CDE6);
P(D, A, B, C, 14, 9, 0xC33707D6);
P(C, D, A, B, 3, 14, 0xF4D50D87);
P(B, C, D, A, 8, 20, 0x455A14ED);
P(A, B, C, D, 13, 5, 0xA9E3E905);
P(D, A, B, C, 2, 9, 0xFCEFA3F8);
P(C, D, A, B, 7, 14, 0x676F02D9);
P(B, C, D, A, 12, 20, 0x8D2A4C8A);
#undef F
#define F(x,y,z) (x ^ y ^ z)
P(A, B, C, D, 5, 4, 0xFFFA3942);
P(D, A, B, C, 8, 11, 0x8771F681);
P(C, D, A, B, 11, 16, 0x6D9D6122);
P(B, C, D, A, 14, 23, 0xFDE5380C);
P(A, B, C, D, 1, 4, 0xA4BEEA44);
P(D, A, B, C, 4, 11, 0x4BDECFA9);
P(C, D, A, B, 7, 16, 0xF6BB4B60);
P(B, C, D, A, 10, 23, 0xBEBFBC70);
P(A, B, C, D, 13, 4, 0x289B7EC6);
P(D, A, B, C, 0, 11, 0xEAA127FA);
P(C, D, A, B, 3, 16, 0xD4EF3085);
P(B, C, D, A, 6, 23, 0x04881D05);
P(A, B, C, D, 9, 4, 0xD9D4D039);
P(D, A, B, C, 12, 11, 0xE6DB99E5);
P(C, D, A, B, 15, 16, 0x1FA27CF8);
P(B, C, D, A, 2, 23, 0xC4AC5665);
#undef F
#define F(x,y,z) (y ^ (x | ~z))
P(A, B, C, D, 0, 6, 0xF4292244);
P(D, A, B, C, 7, 10, 0x432AFF97);
P(C, D, A, B, 14, 15, 0xAB9423A7);
P(B, C, D, A, 5, 21, 0xFC93A039);
P(A, B, C, D, 12, 6, 0x655B59C3);
P(D, A, B, C, 3, 10, 0x8F0CCC92);
P(C, D, A, B, 10, 15, 0xFFEFF47D);
P(B, C, D, A, 1, 21, 0x85845DD1);
P(A, B, C, D, 8, 6, 0x6FA87E4F);
P(D, A, B, C, 15, 10, 0xFE2CE6E0);
P(C, D, A, B, 6, 15, 0xA3014314);
P(B, C, D, A, 13, 21, 0x4E0811A1);
P(A, B, C, D, 4, 6, 0xF7537E82);
P(D, A, B, C, 11, 10, 0xBD3AF235);
P(C, D, A, B, 2, 15, 0x2AD7D2BB);
P(B, C, D, A, 9, 21, 0xEB86D391);
#undef F
ctx->A += A;
ctx->B += B;
ctx->C += C;
ctx->D += D;
}
void md5_update(md_context *ctx, const uchar *input, uint32 length)
{
uint32 left, fill;
if (!length)
return;
left = ctx->totalN & 0x3F;
fill = CSUM_CHUNK - left;
ctx->totalN += length;
ctx->totalN &= 0xFFFFFFFF;
if (ctx->totalN < length)
ctx->totalN2++;
if (left && length >= fill) {
memcpy(ctx->buffer + left, input, fill);
md5_process(ctx, ctx->buffer);
length -= fill;
input += fill;
left = 0;
}
while (length >= CSUM_CHUNK) {
md5_process(ctx, input);
length -= CSUM_CHUNK;
input += CSUM_CHUNK;
}
if (length)
memcpy(ctx->buffer + left, input, length);
}
static uchar md5_padding[CSUM_CHUNK] = { 0x80 };
void md5_result(md_context *ctx, uchar digest[MD5_DIGEST_LEN])
{
uint32 last, padn;
uint32 high, low;
uchar msglen[8];
high = (ctx->totalN >> 29)
| (ctx->totalN2 << 3);
low = (ctx->totalN << 3);
SIVAL(msglen, 0, low);
SIVAL(msglen, 4, high);
last = ctx->totalN & 0x3F;
padn = last < 56 ? 56 - last : 120 - last;
md5_update(ctx, md5_padding, padn);
md5_update(ctx, msglen, 8);
SIVAL(digest, 0, ctx->A);
SIVAL(digest, 4, ctx->B);
SIVAL(digest, 8, ctx->C);
SIVAL(digest, 12, ctx->D);
}
void get_md5(uchar *out, const uchar *input, int n)
{
md_context ctx;
md5_begin(&ctx);
md5_update(&ctx, input, n);
md5_result(&ctx, out);
}
#ifdef TEST_MD5
#include <stdlib.h>
#include <stdio.h>
/*
* those are the standard RFC 1321 test vectors
*/
static struct {
char *str, *md5;
} tests[] = {
{ "",
"d41d8cd98f00b204e9800998ecf8427e" },
{ "a",
"0cc175b9c0f1b6a831c399e269772661" },
{ "abc",
"900150983cd24fb0d6963f7d28e17f72" },
{ "message digest",
"f96b697d7cb7938d525a2f31aaf161d0" },
{ "abcdefghijklmnopqrstuvwxyz",
"c3fcd3d76192e4007dfb496cca67e13b" },
{ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
"d174ab98d277d9f5a5611c2c9f419d9f" },
{ "12345678901234567890123456789012345678901234567890123456789012345678901234567890",
"57edf4a22be3c955ac49da2e2107b67a" },
{ NULL, NULL }
};
int main(int argc, char *argv[])
{
FILE *f;
int i, j;
char output[33];
md_context ctx;
uchar buf[1000];
uchar md5sum[MD5_DIGEST_LEN];
if (argc < 2) {
printf("\nMD5 Validation Tests:\n\n");
for (i = 0; tests[i].str; i++) {
char *str = tests[i].str;
char *chk = tests[i].md5;
printf(" Test %d ", i + 1);
get_md5(md5sum, str, strlen(str));
for (j = 0; j < MD5_DIGEST_LEN; j++)
sprintf(output + j * 2, "%02x", md5sum[j]);
if (memcmp(output, chk, 32)) {
printf("failed!\n");
return 1;
}
printf("passed.\n");
}
printf("\n");
return 0;
}
while (--argc) {
if (!(f = fopen(*++argv, "rb"))) {
perror("fopen");
return 1;
}
md5_begin(&ctx);
while ((i = fread(buf, 1, sizeof buf, f)) > 0)
md5_update(&ctx, buf, i);
md5_result(&ctx, md5sum);
for (j = 0; j < MD5_DIGEST_LEN; j++)
printf("%02x", md5sum[j]);
printf(" %s\n", *argv);
}
return 0;
}
#endif

View File

@@ -1,32 +1,32 @@
/*
Unix SMB/Netbios implementation.
Version 1.9.
a implementation of MD4 designed for use in the SMB authentication protocol
Copyright (C) Andrew Tridgell 1997-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.
*/
* Unix SMB/Netbios implementation.
* Version 1.9.
* An implementation of MD4 designed for use in the SMB authentication protocol.
*
* Copyright (C) 1997-1998 Andrew Tridgell
* Copyright (C) 2005-2008 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
#include "rsync.h"
/* NOTE: This code makes no attempt to be fast!
*
* It assumes that a int is at least 32 bits long. */
It assumes that a int is at least 32 bits long
*/
static struct mdfour *m;
static md_context *m;
#define MASK32 (0xffffffff)
@@ -48,32 +48,31 @@ static void mdfour64(uint32 *M)
A = m->A; B = m->B; C = m->C; D = m->D;
AA = A; BB = B; CC = C; DD = D;
ROUND1(A,B,C,D, 0, 3); ROUND1(D,A,B,C, 1, 7);
ROUND1(A,B,C,D, 0, 3); ROUND1(D,A,B,C, 1, 7);
ROUND1(C,D,A,B, 2, 11); ROUND1(B,C,D,A, 3, 19);
ROUND1(A,B,C,D, 4, 3); ROUND1(D,A,B,C, 5, 7);
ROUND1(A,B,C,D, 4, 3); ROUND1(D,A,B,C, 5, 7);
ROUND1(C,D,A,B, 6, 11); ROUND1(B,C,D,A, 7, 19);
ROUND1(A,B,C,D, 8, 3); ROUND1(D,A,B,C, 9, 7);
ROUND1(A,B,C,D, 8, 3); ROUND1(D,A,B,C, 9, 7);
ROUND1(C,D,A,B, 10, 11); ROUND1(B,C,D,A, 11, 19);
ROUND1(A,B,C,D, 12, 3); ROUND1(D,A,B,C, 13, 7);
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(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);
ROUND2(A,B,C,D, 1, 3); ROUND2(D,A,B,C, 5, 5);
ROUND2(C,D,A,B, 9, 9); ROUND2(B,C,D,A, 13, 13);
ROUND2(A,B,C,D, 2, 3); ROUND2(D,A,B,C, 6, 5);
ROUND2(A,B,C,D, 2, 3); ROUND2(D,A,B,C, 6, 5);
ROUND2(C,D,A,B, 10, 9); ROUND2(B,C,D,A, 14, 13);
ROUND2(A,B,C,D, 3, 3); ROUND2(D,A,B,C, 7, 5);
ROUND2(A,B,C,D, 3, 3); ROUND2(D,A,B,C, 7, 5);
ROUND2(C,D,A,B, 11, 9); ROUND2(B,C,D,A, 15, 13);
ROUND3(A,B,C,D, 0, 3); ROUND3(D,A,B,C, 8, 9);
ROUND3(C,D,A,B, 4, 11); ROUND3(B,C,D,A, 12, 15);
ROUND3(A,B,C,D, 2, 3); ROUND3(D,A,B,C, 10, 9);
ROUND3(A,B,C,D, 2, 3); ROUND3(D,A,B,C, 10, 9);
ROUND3(C,D,A,B, 6, 11); ROUND3(B,C,D,A, 14, 15);
ROUND3(A,B,C,D, 1, 3); ROUND3(D,A,B,C, 9, 9);
ROUND3(A,B,C,D, 1, 3); ROUND3(D,A,B,C, 9, 9);
ROUND3(C,D,A,B, 5, 11); ROUND3(B,C,D,A, 13, 15);
ROUND3(A,B,C,D, 3, 3); ROUND3(D,A,B,C, 11, 9);
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;
@@ -85,16 +84,17 @@ static void mdfour64(uint32 *M)
m->A = A; m->B = B; m->C = C; m->D = D;
}
static void copy64(uint32 *M, unsigned char *in)
static void copy64(uint32 *M, const uchar *in)
{
int i;
for (i=0;i<16;i++)
M[i] = (in[i*4+3]<<24) | (in[i*4+2]<<16) |
(in[i*4+1]<<8) | (in[i*4+0]<<0);
for (i = 0; i < MD4_DIGEST_LEN; i++) {
M[i] = (in[i*4+3] << 24) | (in[i*4+2] << 16)
| (in[i*4+1] << 8) | (in[i*4+0] << 0);
}
}
static void copy4(unsigned char *out,uint32 x)
static void copy4(uchar *out,uint32 x)
{
out[0] = x&0xFF;
out[1] = (x>>8)&0xFF;
@@ -102,7 +102,7 @@ static void copy4(unsigned char *out,uint32 x)
out[3] = (x>>24)&0xFF;
}
void mdfour_begin(struct mdfour *md)
void mdfour_begin(md_context *md)
{
md->A = 0x67452301;
md->B = 0xefcdab89;
@@ -112,27 +112,26 @@ void mdfour_begin(struct mdfour *md)
md->totalN2 = 0;
}
static void mdfour_tail(unsigned char *in, uint32 n)
static void mdfour_tail(const uchar *in, uint32 length)
{
unsigned char buf[128];
uchar buf[128];
uint32 M[16];
extern int protocol_version;
/*
* Count total number of bits, modulo 2^64
*/
m->totalN += n << 3;
if (m->totalN < (n << 3)) {
m->totalN += length << 3;
if (m->totalN < (length << 3))
m->totalN2++;
}
m->totalN2 += n >> 29;
m->totalN2 += length >> 29;
memset(buf, 0, 128);
if (n) memcpy(buf, in, n);
buf[n] = 0x80;
if (length)
memcpy(buf, in, length);
buf[length] = 0x80;
if (n <= 55) {
if (length <= 55) {
copy4(buf+56, m->totalN);
/*
* Prior to protocol version 27 only the number of bits
@@ -140,9 +139,8 @@ static void mdfour_tail(unsigned char *in, uint32 n)
* of bits modulo 2^64, which was fixed starting with
* protocol version 27.
*/
if (protocol_version >= 27) {
if (protocol_version >= 27)
copy4(buf+60, m->totalN2);
}
copy64(M, buf);
mdfour64(M);
} else {
@@ -153,9 +151,8 @@ static void mdfour_tail(unsigned char *in, uint32 n)
* of bits modulo 2^64, which was fixed starting with
* protocol version 27.
*/
if (protocol_version >= 27) {
if (protocol_version >= 27)
copy4(buf+124, m->totalN2);
}
copy64(M, buf);
mdfour64(M);
copy64(M, buf+64);
@@ -163,46 +160,45 @@ static void mdfour_tail(unsigned char *in, uint32 n)
}
}
void mdfour_update(struct mdfour *md, unsigned char *in, uint32 n)
void mdfour_update(md_context *md, const uchar *in, uint32 length)
{
uint32 M[16];
m = md;
if (n == 0) mdfour_tail(in, n);
if (length == 0)
mdfour_tail(in, length);
while (n >= 64) {
while (length >= 64) {
copy64(M, in);
mdfour64(M);
in += 64;
n -= 64;
length -= 64;
m->totalN += 64 << 3;
if (m->totalN < 64 << 3) {
if (m->totalN < 64 << 3)
m->totalN2++;
}
}
if (n) mdfour_tail(in, n);
if (length)
mdfour_tail(in, length);
}
void mdfour_result(struct mdfour *md, unsigned char *out)
void mdfour_result(md_context *md, uchar digest[MD4_DIGEST_LEN])
{
m = md;
copy4(out, m->A);
copy4(out+4, m->B);
copy4(out+8, m->C);
copy4(out+12, m->D);
copy4(digest, m->A);
copy4(digest+4, m->B);
copy4(digest+8, m->C);
copy4(digest+12, m->D);
}
void mdfour(unsigned char *out, unsigned char *in, int n)
void mdfour(uchar digest[MD4_DIGEST_LEN], uchar *in, int length)
{
struct mdfour md;
md_context md;
mdfour_begin(&md);
mdfour_update(&md, in, n);
mdfour_result(&md, out);
mdfour_update(&md, in, length);
mdfour_result(&md, digest);
}
#ifdef TEST_MDFOUR
@@ -211,8 +207,8 @@ int protocol_version = 28;
static void file_checksum1(char *fname)
{
int fd, i, was_multiple_of_64 = 1;
struct mdfour md;
unsigned char buf[64*1024], sum[16];
md_context md;
uchar buf[64*1024], sum[MD4_DIGEST_LEN];
fd = open(fname,O_RDONLY);
if (fd == -1) {
@@ -223,7 +219,7 @@ static void file_checksum1(char *fname)
mdfour_begin(&md);
while (1) {
int n = read(fd, buf, sizeof(buf));
int n = read(fd, buf, sizeof buf);
if (n <= 0)
break;
was_multiple_of_64 = !(n % 64);
@@ -236,54 +232,15 @@ static void file_checksum1(char *fname)
mdfour_result(&md, sum);
for (i=0;i<16;i++)
for (i = 0; i < MD4_DIGEST_LEN; i++)
printf("%02X", sum[i]);
printf("\n");
}
#if 0
#include "../md4.h"
static void file_checksum2(char *fname)
{
int fd, i;
MDstruct md;
unsigned char buf[64], sum[16];
fd = open(fname,O_RDONLY);
if (fd == -1) {
perror("fname");
exit(1);
}
MDbegin(&md);
while (1) {
int n = read(fd, buf, sizeof(buf));
if (n <= 0) break;
MDupdate(&md, buf, n*8);
}
if (!md.done) {
MDupdate(&md, buf, 0);
}
close(fd);
memcpy(sum, md.buffer, 16);
for (i=0;i<16;i++)
printf("%02X", sum[i]);
printf("\n");
}
#endif
int main(int argc, char *argv[])
{
file_checksum1(argv[1]);
#if 0
file_checksum2(argv[1]);
#endif
while (--argc)
file_checksum1(*++argv);
return 0;
}
#endif

View File

@@ -1,35 +0,0 @@
/*
Unix SMB/Netbios implementation.
Version 1.9.
a implementation of MD4 designed for use in the SMB authentication protocol
Copyright (C) Andrew Tridgell 1997-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.
*/
struct mdfour {
uint32 A, B, C, D;
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, uint32 n);
void mdfour_result(struct mdfour *md, unsigned char *out);
void mdfour(unsigned char *out, unsigned char *in, int n);

26
lib/mdigest.h Normal file
View File

@@ -0,0 +1,26 @@
/* The include file for both the MD4 and MD5 routines. */
#define MD4_DIGEST_LEN 16
#define MD5_DIGEST_LEN 16
#define MAX_DIGEST_LEN MD5_DIGEST_LEN
#define CSUM_CHUNK 64
typedef struct {
uint32 A, B, C, D;
uint32 totalN; /* bit count, lower 32 bits */
uint32 totalN2; /* bit count, upper 32 bits */
uchar buffer[CSUM_CHUNK];
} md_context;
void mdfour_begin(md_context *md);
void mdfour_update(md_context *md, const uchar *in, uint32 length);
void mdfour_result(md_context *md, uchar digest[MD4_DIGEST_LEN]);
void get_mdfour(uchar digest[MD4_DIGEST_LEN], const uchar *in, int length);
void md5_begin(md_context *ctx);
void md5_update(md_context *ctx, const uchar *input, uint32 length);
void md5_result(md_context *ctx, uchar digest[MD5_DIGEST_LEN]);
void get_md5(uchar digest[MD5_DIGEST_LEN], const uchar *input, int n);

View File

@@ -1,41 +1,39 @@
/*
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.
*/
/*
* A single utility routine.
*
* Copyright (C) 1996 Andrew Tridgell
* Copyright (C) 1996 Paul Mackerras
* Copyright (C) 2001 Martin Pool <mbp@samba.org>
* Copyright (C) 2003, 2006 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
#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)
/* Produce a string representation of Unix mode bits like that used by ls(1).
* The "buf" buffer must be at least 11 characters. */
void permstring(char *perms, mode_t 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];
strlcpy(perms, "----------", 11);
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
@@ -46,18 +44,22 @@ void permstring(char *perms,
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';
}
if (S_ISDIR(mode))
perms[0] = 'd';
else if (S_ISLNK(mode))
perms[0] = 'l';
else if (S_ISBLK(mode))
perms[0] = 'b';
else if (S_ISCHR(mode))
perms[0] = 'c';
else if (S_ISSOCK(mode))
perms[0] = 's';
else if (S_ISFIFO(mode))
perms[0] = 'p';
}

View File

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

View File

@@ -28,7 +28,7 @@ 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
pool_alloc, pool_free, pool_free_old, pool_talloc, pool_tfree, pool_create, pool_destroy, pool_boundary
\- Allocate and free memory in managed allocation pools.
.SH SYNOPSIS
.B #include "pool_alloc.h"
@@ -39,42 +39,45 @@ pool_alloc, pool_free, pool_talloc, pool_tfree, pool_create, pool_destroy
\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_free(struct alloc_pool *\fIpool\fB, size_t \fIsize\fB, void *\fIaddr\fB);
\fBvoid pool_free_old(struct alloc_pool *\fIpool\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);
\fBvoid pool_boundary(struct alloc_pool *\fIpool\fB, sise_t \fIsize\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()
What allocation pools do is cause memory within a given pool
to be allocated in large contiguous blocks
(called extents) that will be reusable when freed. Unlike
.BR malloc() ,
the allocations are not managed individually.
Instead each extent tracks the total free memory within the
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.
allocation request, the current extent ceases to be used
for allocation. See also the
.B pool_boundary()
function.
.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
underlying allocations are done in large contiguous extents,
when an extent is freed, it can release a large enough
contiguous block of memory to allow the memory to be returned
to the OS for use by whatever program needs it.
You can allocate from one or more memory pools and/or
.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.
all at the same time without interfering with how pools work.
.P
.B pool_create()
Creates an allocation pool for subsequent calls to the pool
@@ -90,22 +93,32 @@ Specifying
.B 0
for
.I quantum
Will produce a quantum that should meet maximal allignment
will produce a quantum that should meet maximal alignment
on most platforms.
If the
If
.B POOL_QALIGN
.I flag
is set allocations will be aligned to addresses that are a
is set in the
.IR flags ,
allocations will be aligned to addresses that are a
multiple of
.IR quantum .
If the
If
.B POOL_CLEAR
.I flag
is set all allocations from the pool will be zero filled.
is set in the
.IR flags ,
all allocations from the pool will be initialized to zeros.
You may specify a
.B NULL
for the
.I bomb
function pointer if you don't wish to use it. (See the
.B pool_alloc()
function for how it is used.)
.P
.B pool_destroy()
destroys an allocation pool and frees all memory allocated
in that pool.
destroys an allocation
.I pool
and frees all its associated memory.
.P
.B pool_alloc()
allocates
@@ -115,57 +128,97 @@ bytes from the specified
If
.I size
is
.B 0
.BR 0 ,
.I quantum
bytes will be freed.
If the requested memory cannot be allocated
.B pool_alloc()
will call
bytes will be allocated.
If the pool has been created with
.BR POOL_QALIGN ,
every chunk of memory that is returned will be suitably aligned.
You can use this with the default
.I quantum
size to ensure that all memory can store a variable of any type.
If the requested memory cannot be allocated, the
.I bomb()
function, if defined, with
function will be called with
.I msg
as it's sole argument and
as its sole argument (if the function was defined at the time
the pool was created), and then a
.B NULL
will be returned.
address is returned (assuming that the bomb function didn't exit).
.P
.B pool_free()
frees
.I size
bytes pointed to by
bytes pointed to by an
.I addr
previously allocated in the specified
that was 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
.BR 0 ,
.I quantum
bytes will be freed.
The memory freed within an extent will not be reusable until
all of the memory in that extent has been freed with one
exception: the most recent pool allocation may be freed back
into the pool prior to making any further allocations.
If enough free calls are made to indicate that an extent has no
remaining allocated objects (as computed by the total freed size for
an extent), its memory will be completely freed back to the system.
If
.I addr
is
.B 0
no memory will be freed but subsequent allocations will come
.BR 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
.B pool_free_old()
takes a boundary
.I addr
value that was returned by
.B pool_boundary()
and frees up any extents in the
.I pool
that have data allocated from that point backward in time.
NOTE: you must NOT mix calls to both
.B pool_free
and
.B pool_free_old
on the same pool!
.P
.B pool_boundary()
asks for a boundary value that can be sent to
.B pool_free_old()
at a later time to free up all memory allocated prior to a particular
moment in time.
If the extent that holds the boundary point has allocations from after the
boundary point, it will not be freed until a future
.B pool_free_old()
call encompasses the entirety of the extent's data.
If
.I len
is non-zero, the call will also check if the active extent has at least
that much free memory available in it, and if not, it will mark the
extent as inactive, forcing a new extent to be used for future allocations.
(You can specify -1 for
.I len
if you want to force a new extent to start.)
.P
.B pool_talloc()
is a macro that takes a
.I type
and a
.I count
instead of
.I size
and will cast the return value to the correct type.
instead of a
.IR size .
It casts the return value to the correct pointer type.
.P
.B pool_tfree
is a macro to free memory previously allocated in the
specified
.IR pool .
is a macro that calls
.B pool_free
on memory that was allocated by
.BR pool_talloc() .
.SH RETURN VALUE
.B pool_create()
returns a pointer to
@@ -176,9 +229,6 @@ 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
@@ -186,7 +236,12 @@ will normally require casting to the desired type but
will returns a pointer of the requested
.IR type .
.P
.B pool_boundary()
returns a pointer that should only be used in a call to
.BR pool_free_old() .
.P
.BR pool_free() ,
.BR pool_free_old() ,
.B pool_tfree()
and
.B pool_destroy()

View File

@@ -6,11 +6,8 @@ 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
struct pool_extent *extents; /* top extent is "live" */
void (*bomb)(); /* function to call if
* malloc fails */
int flags;
@@ -33,8 +30,8 @@ struct pool_extent
};
struct align_test {
void *foo;
int64 bar;
void *foo;
int64 bar;
};
#define MINALIGN offsetof(struct align_test, bar)
@@ -44,20 +41,18 @@ struct align_test {
#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)
pool_create(size_t size, size_t quantum, void (*bomb)(const char *), int flags)
{
struct alloc_pool *pool;
if (!(pool = (struct alloc_pool*) malloc(sizeof (struct alloc_pool))))
if (!(pool = new(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)
{
if (flags & POOL_INTERN) {
pool->size -= sizeof (struct pool_extent);
flags |= POOL_APPEND;
}
@@ -77,15 +72,7 @@ pool_destroy(alloc_pool_t p)
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)
{
for (cur = pool->extents; cur; cur = next) {
next = cur->next;
free(cur->start);
if (!(pool->flags & POOL_APPEND))
@@ -95,7 +82,7 @@ pool_destroy(alloc_pool_t p)
}
void *
pool_alloc(alloc_pool_t p, size_t len, char *bomb)
pool_alloc(alloc_pool_t p, size_t len, const char *bomb_msg)
{
struct alloc_pool *pool = (struct alloc_pool *) p;
if (!pool)
@@ -107,21 +94,15 @@ pool_alloc(alloc_pool_t p, size_t len, char *bomb)
len += pool->quantum - len % pool->quantum;
if (len > pool->size)
goto bomb;
goto bomb_out;
if (!pool->live || len > pool->live->free)
{
if (!pool->extents || len > pool->extents->free) {
void *start;
size_t free;
size_t bound;
size_t sqew;
size_t skew;
size_t asize;
if (pool->live)
{
pool->live->next = pool->free;
pool->free = pool->live;
}
struct pool_extent *ext;
free = pool->size;
bound = 0;
@@ -130,30 +111,26 @@ pool_alloc(alloc_pool_t p, size_t len, char *bomb)
if (pool->flags & POOL_APPEND)
asize += sizeof (struct pool_extent);
if (!(start = (void *) malloc(asize)))
goto bomb;
if (!(start = new_array(char, asize)))
goto bomb_out;
if (pool->flags & POOL_CLEAR)
memset(start, 0, pool->size);
memset(start, 0, free);
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;
}
ext = PTR_ADD(start, free);
else if (!(ext = new(struct pool_extent)))
goto bomb_out;
if (pool->flags & POOL_QALIGN && pool->quantum > 1
&& (sqew = (size_t)PTR_ADD(start, free) % pool->quantum))
{
bound += sqew;
free -= sqew;
&& (skew = (size_t)PTR_ADD(start, free) % pool->quantum)) {
bound += skew;
free -= skew;
}
pool->live->start = start;
pool->live->free = free;
pool->live->bound = bound;
pool->live->next = NULL;
ext->start = start;
ext->free = free;
ext->bound = bound;
ext->next = pool->extents;
pool->extents = ext;
pool->e_created++;
}
@@ -161,22 +138,24 @@ pool_alloc(alloc_pool_t p, size_t len, char *bomb)
pool->n_allocated++;
pool->b_allocated += len;
pool->live->free -= len;
pool->extents->free -= len;
return PTR_ADD(pool->live->start, pool->live->free);
return PTR_ADD(pool->extents->start, pool->extents->free);
bomb:
bomb_out:
if (pool->bomb)
(*pool->bomb)(bomb);
(*pool->bomb)(bomb_msg);
return NULL;
}
/* This function allows you to declare memory in the pool that you are done
* using. If you free all the memory in a pool's extent, that extent will
* be freed. */
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;
struct alloc_pool *pool = (struct alloc_pool *)p;
struct pool_extent *cur, *prev;
if (!pool)
return;
@@ -186,46 +165,10 @@ pool_free(alloc_pool_t p, size_t len, void *addr)
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)
{
for (prev = NULL, cur = pool->extents; cur; prev = cur, cur = cur->next) {
if (addr >= cur->start
&& addr < PTR_ADD(cur->start, pool->size))
break;
@@ -233,32 +176,130 @@ pool_free(alloc_pool_t p, size_t len, void *addr)
if (!cur)
return;
if (prev)
{
prev->next = cur->next;
cur->next = pool->free;
pool->free = cur;
if (!prev) {
/* The "live" extent is kept ready for more allocations. */
if (cur->free + cur->bound + len >= pool->size) {
size_t skew;
if (pool->flags & POOL_CLEAR) {
memset(PTR_ADD(cur->start, cur->free), 0,
pool->size - cur->free);
}
cur->free = pool->size;
cur->bound = 0;
if (pool->flags & POOL_QALIGN && pool->quantum > 1
&& (skew = (size_t)PTR_ADD(cur->start, cur->free) % pool->quantum)) {
cur->bound += skew;
cur->free -= skew;
}
} else if (addr == PTR_ADD(cur->start, cur->free)) {
if (pool->flags & POOL_CLEAR)
memset(addr, 0, len);
cur->free += len;
} else
cur->bound += len;
} else {
cur->bound += len;
if (cur->free + cur->bound >= pool->size) {
prev->next = cur->next;
free(cur->start);
if (!(pool->flags & POOL_APPEND))
free(cur);
pool->e_freed++;
} else if (prev != pool->extents) {
/* Move the extent to be the first non-live extent. */
prev->next = cur->next;
cur->next = pool->extents->next;
pool->extents->next = cur;
}
}
cur->bound += len;
}
if (cur->free + cur->bound >= pool->size)
{
pool->free = cur->next;
/* This allows you to declare that the given address marks the edge of some
* pool memory that is no longer needed. Any extents that hold only data
* older than the boundary address are freed. NOTE: You MUST NOT USE BOTH
* pool_free() and pool_free_old() on the same pool!! */
void
pool_free_old(alloc_pool_t p, void *addr)
{
struct alloc_pool *pool = (struct alloc_pool *)p;
struct pool_extent *cur, *prev, *next;
if (!pool || !addr)
return;
for (prev = NULL, cur = pool->extents; cur; prev = cur, cur = cur->next) {
if (addr >= cur->start
&& addr < PTR_ADD(cur->start, pool->size))
break;
}
if (!cur)
return;
if (addr == PTR_ADD(cur->start, cur->free)) {
if (prev) {
prev->next = NULL;
next = cur;
} else {
size_t skew;
/* The most recent live extent can just be reset. */
if (pool->flags & POOL_CLEAR)
memset(addr, 0, pool->size - cur->free);
cur->free = pool->size;
cur->bound = 0;
if (pool->flags & POOL_QALIGN && pool->quantum > 1
&& (skew = (size_t)PTR_ADD(cur->start, cur->free) % pool->quantum)) {
cur->bound += skew;
cur->free -= skew;
}
next = cur->next;
cur->next = NULL;
}
} else {
next = cur->next;
cur->next = NULL;
}
while ((cur = next) != NULL) {
next = cur->next;
free(cur->start);
if (!(pool->flags & POOL_APPEND))
free(cur);
pool->e_freed++;
}
return;
}
/* If the current extent doesn't have "len" free space in it, mark it as full
* so that the next alloc will start a new extent. If len is (size_t)-1, this
* bump will always occur. The function returns a boundary address that can
* be used with pool_free_old(), or a NULL if no memory is allocated. */
void *
pool_boundary(alloc_pool_t p, size_t len)
{
struct alloc_pool *pool = (struct alloc_pool *)p;
struct pool_extent *cur;
if (!pool || !pool->extents)
return NULL;
cur = pool->extents;
if (cur->free < len) {
cur->bound += cur->free;
cur->free = 0;
}
return PTR_ADD(cur->start, cur->free);
}
#define FDPRINT(label, value) \
snprintf(buf, BUFSIZ, label, value), \
write(fd, buf, strlen(buf));
snprintf(buf, sizeof buf, label, value), \
write(fd, buf, strlen(buf))
#define FDEXTSTAT(ext) \
snprintf(buf, BUFSIZ, " %12ld %5ld\n", \
snprintf(buf, sizeof buf, " %12ld %5ld\n", \
(long) ext->free, \
(long) ext->bound), \
write(fd, buf, strlen(buf))
@@ -279,26 +320,17 @@ pool_stats(alloc_pool_t p, int fd, int summarize)
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);
FDPRINT(" Bytes allocated: %12.0f\n", (double) pool->b_allocated);
FDPRINT(" Bytes freed: %12.0f\n", (double) pool->b_freed);
if (summarize)
return;
if (!pool->live && !pool->free)
if (!pool->extents)
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)
{
for (cur = pool->extents; cur; cur = cur->next)
FDEXTSTAT(cur);
}
}

View File

@@ -7,14 +7,15 @@
typedef void *alloc_pool_t;
alloc_pool_t pool_create(size_t size, size_t quantum, void (*bomb)(char *), int flags);
alloc_pool_t pool_create(size_t size, size_t quantum, void (*bomb)(const char *), int flags);
void pool_destroy(alloc_pool_t pool);
void *pool_alloc(alloc_pool_t pool, size_t size, char *bomb);
void *pool_alloc(alloc_pool_t pool, size_t size, const char *bomb_msg);
void pool_free(alloc_pool_t pool, size_t size, void *addr);
void pool_free_old(alloc_pool_t pool, void *addr);
void *pool_boundary(alloc_pool_t pool, size_t size);
#define pool_talloc(pool, type, count, bomb) \
((type *)pool_alloc(pool, sizeof(type) * count, bomb))
#define pool_talloc(pool, type, count, bomb_msg) \
((type *)pool_alloc(pool, sizeof(type) * count, bomb_msg))
#define pool_tfree(pool, type, count, addr) \
(pool_free(pool, sizeof(type) * count, addr))

View File

@@ -146,7 +146,7 @@
#endif
#ifndef VA_COPY
#ifdef HAVE_VA_COPY
#if defined HAVE_VA_COPY || defined va_copy
#define VA_COPY(dest, src) va_copy(dest, src)
#else
#ifdef HAVE___VA_COPY

2783
lib/sysacls.c Normal file
View File

File diff suppressed because it is too large Load Diff

305
lib/sysacls.h Normal file
View File

@@ -0,0 +1,305 @@
/*
* Unix SMB/Netbios implementation.
* Version 2.2.x
* Portable SMB ACL interface
* Copyright (C) Jeremy Allison 2000
* Copyright (C) 2007-2008 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* with this program; if not, visit the http://fsf.org website.
*/
#ifdef SUPPORT_ACLS
#ifdef HAVE_SYS_ACL_H
#include <sys/acl.h>
#endif
#ifdef HAVE_ACL_LIBACL_H
#include <acl/libacl.h>
#endif
#define SMB_MALLOC(cnt) new_array(char, cnt)
#define SMB_MALLOC_P(obj) new_array(obj, 1)
#define SMB_MALLOC_ARRAY(obj, cnt) new_array(obj, cnt)
#define SMB_REALLOC(mem, cnt) realloc_array(mem, char, cnt)
#define slprintf snprintf
#if defined HAVE_POSIX_ACLS /*-----------------------------------------------*/
/* This is an identity mapping (just remove the SMB_). */
#define SMB_ACL_TAG_T acl_tag_t
#define SMB_ACL_TYPE_T acl_type_t
/* Types of ACLs. */
#define SMB_ACL_USER ACL_USER
#define SMB_ACL_USER_OBJ ACL_USER_OBJ
#define SMB_ACL_GROUP ACL_GROUP
#define SMB_ACL_GROUP_OBJ ACL_GROUP_OBJ
#define SMB_ACL_OTHER ACL_OTHER
#define SMB_ACL_MASK ACL_MASK
#define SMB_ACL_T acl_t
#define SMB_ACL_ENTRY_T acl_entry_t
#define SMB_ACL_FIRST_ENTRY ACL_FIRST_ENTRY
#define SMB_ACL_NEXT_ENTRY ACL_NEXT_ENTRY
#define SMB_ACL_TYPE_ACCESS ACL_TYPE_ACCESS
#define SMB_ACL_TYPE_DEFAULT ACL_TYPE_DEFAULT
#define SMB_ACL_VALID_NAME_BITS (4 | 2 | 1)
#define SMB_ACL_VALID_OBJ_BITS (4 | 2 | 1)
#define SMB_ACL_NEED_SORT
#elif defined HAVE_TRU64_ACLS /*---------------------------------------------*/
/* This is for DEC/Compaq Tru64 UNIX */
#define SMB_ACL_TAG_T acl_tag_t
#define SMB_ACL_TYPE_T acl_type_t
/* Types of ACLs. */
#define SMB_ACL_USER ACL_USER
#define SMB_ACL_USER_OBJ ACL_USER_OBJ
#define SMB_ACL_GROUP ACL_GROUP
#define SMB_ACL_GROUP_OBJ ACL_GROUP_OBJ
#define SMB_ACL_OTHER ACL_OTHER
#define SMB_ACL_MASK ACL_MASK
#define SMB_ACL_T acl_t
#define SMB_ACL_ENTRY_T acl_entry_t
#define SMB_ACL_FIRST_ENTRY 0
#define SMB_ACL_NEXT_ENTRY 1
#define SMB_ACL_TYPE_ACCESS ACL_TYPE_ACCESS
#define SMB_ACL_TYPE_DEFAULT ACL_TYPE_DEFAULT
#define SMB_ACL_VALID_NAME_BITS (4 | 2 | 1)
#define SMB_ACL_VALID_OBJ_BITS (4 | 2 | 1)
#define SMB_ACL_NEED_SORT
#elif defined HAVE_UNIXWARE_ACLS || defined HAVE_SOLARIS_ACLS /*-------------*/
/* Donated by Michael Davidson <md@sco.COM> for UnixWare / OpenUNIX.
* Modified by Toomas Soome <tsoome@ut.ee> for Solaris. */
/* SVR4.2 ES/MP ACLs */
typedef int SMB_ACL_TAG_T;
typedef int SMB_ACL_TYPE_T;
/* Types of ACLs. */
#define SMB_ACL_USER USER
#define SMB_ACL_USER_OBJ USER_OBJ
#define SMB_ACL_GROUP GROUP
#define SMB_ACL_GROUP_OBJ GROUP_OBJ
#define SMB_ACL_OTHER OTHER_OBJ
#define SMB_ACL_MASK CLASS_OBJ
typedef struct SMB_ACL_T {
int size;
int count;
int next;
struct acl acl[1];
} *SMB_ACL_T;
typedef struct acl *SMB_ACL_ENTRY_T;
#define SMB_ACL_FIRST_ENTRY 0
#define SMB_ACL_NEXT_ENTRY 1
#define SMB_ACL_TYPE_ACCESS 0
#define SMB_ACL_TYPE_DEFAULT 1
#define SMB_ACL_VALID_NAME_BITS (4 | 2 | 1)
#define SMB_ACL_VALID_OBJ_BITS (4 | 2 | 1)
#define SMB_ACL_NEED_SORT
#ifdef __CYGWIN__
#define SMB_ACL_LOSES_SPECIAL_MODE_BITS
#endif
#elif defined HAVE_HPUX_ACLS /*----------------------------------------------*/
/* Based on the Solaris & UnixWare code. */
#undef GROUP
#include <sys/aclv.h>
/* SVR4.2 ES/MP ACLs */
typedef int SMB_ACL_TAG_T;
typedef int SMB_ACL_TYPE_T;
/* Types of ACLs. */
#define SMB_ACL_USER USER
#define SMB_ACL_USER_OBJ USER_OBJ
#define SMB_ACL_GROUP GROUP
#define SMB_ACL_GROUP_OBJ GROUP_OBJ
#define SMB_ACL_OTHER OTHER_OBJ
#define SMB_ACL_MASK CLASS_OBJ
typedef struct SMB_ACL_T {
int size;
int count;
int next;
struct acl acl[1];
} *SMB_ACL_T;
typedef struct acl *SMB_ACL_ENTRY_T;
#define SMB_ACL_FIRST_ENTRY 0
#define SMB_ACL_NEXT_ENTRY 1
#define SMB_ACL_TYPE_ACCESS 0
#define SMB_ACL_TYPE_DEFAULT 1
#define SMB_ACL_VALID_NAME_BITS (4 | 2 | 1)
#define SMB_ACL_VALID_OBJ_BITS (4 | 2 | 1)
#define SMB_ACL_NEED_SORT
#elif defined HAVE_IRIX_ACLS /*----------------------------------------------*/
/* IRIX ACLs */
#define SMB_ACL_TAG_T acl_tag_t
#define SMB_ACL_TYPE_T acl_type_t
/* Types of ACLs. */
#define SMB_ACL_USER ACL_USER
#define SMB_ACL_USER_OBJ ACL_USER_OBJ
#define SMB_ACL_GROUP ACL_GROUP
#define SMB_ACL_GROUP_OBJ ACL_GROUP_OBJ
#define SMB_ACL_OTHER ACL_OTHER_OBJ
#define SMB_ACL_MASK ACL_MASK
typedef struct SMB_ACL_T {
int next;
BOOL freeaclp;
struct acl *aclp;
} *SMB_ACL_T;
#define SMB_ACL_ENTRY_T acl_entry_t
#define SMB_ACL_FIRST_ENTRY 0
#define SMB_ACL_NEXT_ENTRY 1
#define SMB_ACL_TYPE_ACCESS ACL_TYPE_ACCESS
#define SMB_ACL_TYPE_DEFAULT ACL_TYPE_DEFAULT
#define SMB_ACL_VALID_NAME_BITS (4 | 2 | 1)
#define SMB_ACL_VALID_OBJ_BITS (4 | 2 | 1)
#define SMB_ACL_NEED_SORT
#elif defined HAVE_AIX_ACLS /*-----------------------------------------------*/
/* Donated by Medha Date, mdate@austin.ibm.com, for IBM */
#include "/usr/include/acl.h"
struct acl_entry_link{
struct acl_entry_link *prevp;
struct new_acl_entry *entryp;
struct acl_entry_link *nextp;
int count;
};
struct new_acl_entry{
unsigned short ace_len;
unsigned short ace_type;
unsigned int ace_access;
struct ace_id ace_id[1];
};
#define SMB_ACL_ENTRY_T struct new_acl_entry*
#define SMB_ACL_T struct acl_entry_link*
#define SMB_ACL_TAG_T unsigned short
#define SMB_ACL_TYPE_T int
/* Types of ACLs. */
#define SMB_ACL_USER ACEID_USER
#define SMB_ACL_USER_OBJ 3
#define SMB_ACL_GROUP ACEID_GROUP
#define SMB_ACL_GROUP_OBJ 4
#define SMB_ACL_OTHER 5
#define SMB_ACL_MASK 6
#define SMB_ACL_FIRST_ENTRY 1
#define SMB_ACL_NEXT_ENTRY 2
#define SMB_ACL_TYPE_ACCESS 0
#define SMB_ACL_TYPE_DEFAULT 1
#define SMB_ACL_VALID_NAME_BITS (4 | 2 | 1)
#define SMB_ACL_VALID_OBJ_BITS (4 | 2 | 1)
#define SMB_ACL_NEED_SORT
#elif defined(HAVE_OSX_ACLS) /*----------------------------------------------*/
/* Special handling for OS X ACLs */
#define SMB_ACL_TAG_T acl_tag_t
#define SMB_ACL_TYPE_T acl_type_t
#define SMB_ACL_T acl_t
#define SMB_ACL_ENTRY_T acl_entry_t
#define SMB_ACL_USER 1
#define SMB_ACL_GROUP 2
#define SMB_ACL_FIRST_ENTRY ACL_FIRST_ENTRY
#define SMB_ACL_NEXT_ENTRY ACL_NEXT_ENTRY
#define SMB_ACL_TYPE_ACCESS ACL_TYPE_EXTENDED
#define SMB_ACL_TYPE_DEFAULT ACL_TYPE_DEFAULT
#define SMB_ACL_VALID_NAME_BITS ((1<<25)-1)
#define SMB_ACL_VALID_OBJ_BITS 0
/*#undef SMB_ACL_NEED_SORT*/
#else /*---------------------------------------------------------------------*/
/* Unknown platform. */
#error Cannot handle ACLs on this platform!
#endif
int sys_acl_get_entry(SMB_ACL_T the_acl, int entry_id, SMB_ACL_ENTRY_T *entry_p);
int sys_acl_get_tag_type(SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *tag_type_p);
int sys_acl_get_info(SMB_ACL_ENTRY_T entry, SMB_ACL_TAG_T *tag_type_p, uint32 *bits_p, id_t *u_g_id_p);
SMB_ACL_T sys_acl_get_file(const char *path_p, SMB_ACL_TYPE_T type);
SMB_ACL_T sys_acl_get_fd(int fd);
SMB_ACL_T sys_acl_init(int count);
int sys_acl_create_entry(SMB_ACL_T *pacl, SMB_ACL_ENTRY_T *pentry);
int sys_acl_set_info(SMB_ACL_ENTRY_T entry, SMB_ACL_TAG_T tagtype, uint32 bits, id_t u_g_id);
int sys_acl_set_access_bits(SMB_ACL_ENTRY_T entry, uint32 bits);
int sys_acl_valid(SMB_ACL_T theacl);
int sys_acl_set_file(const char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl);
int sys_acl_set_fd(int fd, SMB_ACL_T theacl);
int sys_acl_delete_def_file(const char *name);
int sys_acl_free_acl(SMB_ACL_T the_acl);
int no_acl_syscall_error(int err);
#endif /* SUPPORT_ACLS */

135
lib/sysxattrs.c Normal file
View File

@@ -0,0 +1,135 @@
/*
* Extended attribute support for rsync.
*
* Copyright (C) 2004 Red Hat, Inc.
* Copyright (C) 2003-2008 Wayne Davison
* Written by Jay Fenlason.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
#include "rsync.h"
#include "sysxattrs.h"
#ifdef SUPPORT_XATTRS
#if defined HAVE_LINUX_XATTRS
ssize_t sys_lgetxattr(const char *path, const char *name, void *value, size_t size)
{
return lgetxattr(path, name, value, size);
}
ssize_t sys_fgetxattr(int filedes, const char *name, void *value, size_t size)
{
return fgetxattr(filedes, name, value, size);
}
int sys_lsetxattr(const char *path, const char *name, const void *value, size_t size)
{
return lsetxattr(path, name, value, size, 0);
}
int sys_lremovexattr(const char *path, const char *name)
{
return lremovexattr(path, name);
}
ssize_t sys_llistxattr(const char *path, char *list, size_t size)
{
return llistxattr(path, list, size);
}
#elif HAVE_OSX_XATTRS
ssize_t sys_lgetxattr(const char *path, const char *name, void *value, size_t size)
{
return getxattr(path, name, value, size, 0, XATTR_NOFOLLOW);
}
ssize_t sys_fgetxattr(int filedes, const char *name, void *value, size_t size)
{
return fgetxattr(filedes, name, value, size, 0, 0);
}
int sys_lsetxattr(const char *path, const char *name, const void *value, size_t size)
{
return setxattr(path, name, value, size, 0, XATTR_NOFOLLOW);
}
int sys_lremovexattr(const char *path, const char *name)
{
return removexattr(path, name, XATTR_NOFOLLOW);
}
ssize_t sys_llistxattr(const char *path, char *list, size_t size)
{
return listxattr(path, list, size, XATTR_NOFOLLOW);
}
#elif HAVE_FREEBSD_XATTRS
ssize_t sys_lgetxattr(const char *path, const char *name, void *value, size_t size)
{
return extattr_get_link(path, EXTATTR_NAMESPACE_USER, name, value, size);
}
ssize_t sys_fgetxattr(int filedes, const char *name, void *value, size_t size)
{
return extattr_get_fd(filedes, EXTATTR_NAMESPACE_USER, name, value, size);
}
int sys_lsetxattr(const char *path, const char *name, const void *value, size_t size)
{
return extattr_set_link(path, EXTATTR_NAMESPACE_USER, name, value, size);
}
int sys_lremovexattr(const char *path, const char *name)
{
return extattr_delete_link(path, EXTATTR_NAMESPACE_USER, name);
}
ssize_t sys_llistxattr(const char *path, char *list, size_t size)
{
unsigned char keylen;
ssize_t off, len = extattr_list_link(path, EXTATTR_NAMESPACE_USER, list, size);
if (len <= 0 || (size_t)len > size)
return len;
/* FreeBSD puts a single-byte length before each string, with no '\0'
* terminator. We need to change this into a series of null-terminted
* strings. Since the size is the same, we can simply transform the
* output in place. */
for (off = 0; off < len; off += keylen + 1) {
keylen = ((unsigned char*)list)[off];
if (off + keylen >= len) {
/* Should be impossible, but kernel bugs happen! */
errno = EINVAL;
return -1;
}
memmove(list+off, list+off+1, keylen);
list[off+keylen] = '\0';
}
return len;
}
#else
#error You need to create xattr compatibility functions.
#endif
#endif /* SUPPORT_XATTRS */

26
lib/sysxattrs.h Normal file
View File

@@ -0,0 +1,26 @@
#ifdef SUPPORT_XATTRS
#if defined HAVE_ATTR_XATTR_H
#include <attr/xattr.h>
#elif defined HAVE_SYS_XATTR_H
#include <sys/xattr.h>
#elif defined HAVE_SYS_EXTATTR_H
#include <sys/extattr.h>
#endif
/* Linux 2.4 does not define this as a distinct errno value: */
#ifndef ENOATTR
#define ENOATTR ENODATA
#endif
ssize_t sys_lgetxattr(const char *path, const char *name, void *value, size_t size);
ssize_t sys_fgetxattr(int filedes, const char *name, void *value, size_t size);
int sys_lsetxattr(const char *path, const char *name, const void *value, size_t size);
int sys_lremovexattr(const char *path, const char *name);
ssize_t sys_llistxattr(const char *path, char *list, size_t size);
#else
/* No xattrs available */
#endif

View File

@@ -57,173 +57,312 @@
int wildmatch_iteration_count;
#endif
static int domatch(const uchar *p, const uchar *text)
static int force_lower_case = 0;
/* Match pattern "p" against the a virtually-joined string consisting
* of "text" and any strings in array "a". */
static int dowild(const uchar *p, const uchar *text, const uchar*const *a)
{
int matched, special;
uchar ch, prev;
uchar p_ch;
#ifdef WILD_TEST_ITERATIONS
wildmatch_iteration_count++;
#endif
for ( ; (ch = *p) != '\0'; text++, p++) {
if (*text == '\0' && ch != '*')
return FALSE;
switch (ch) {
for ( ; (p_ch = *p) != '\0'; text++, p++) {
int matched, special;
uchar t_ch, prev_ch;
while ((t_ch = *text) == '\0') {
if (*a == NULL) {
if (p_ch != '*')
return ABORT_ALL;
break;
}
text = *a++;
}
if (force_lower_case && ISUPPER(t_ch))
t_ch = tolower(t_ch);
switch (p_ch) {
case '\\':
/* Literal match with following character. Note that the test
* in "default" handles the p[1] == '\0' failure case. */
ch = *++p;
p_ch = *++p;
/* FALLTHROUGH */
default:
if (*text != ch)
if (t_ch != p_ch)
return FALSE;
continue;
case '?':
/* Match anything but '/'. */
if (*text == '/')
if (t_ch == '/')
return FALSE;
continue;
case '*':
if (*++p == '*') {
while (*++p == '*') {}
special = TRUE;
}
else
} 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;
if (!special) {
do {
if (strchr((char*)text, '/') != NULL)
return FALSE;
} while ((text = *a++) != NULL);
}
return TRUE;
}
for ( ; *text; text++) {
if ((matched = domatch(p, text)) != FALSE) {
while (1) {
if (t_ch == '\0') {
if ((text = *a++) == NULL)
break;
t_ch = *text;
continue;
}
if ((matched = dowild(p, text, a)) != FALSE) {
if (!special || matched != ABORT_TO_STARSTAR)
return matched;
}
else if (!special && *text == '/')
} else if (!special && t_ch == '/')
return ABORT_TO_STARSTAR;
t_ch = *++text;
}
return ABORT_ALL;
case '[':
ch = *++p;
p_ch = *++p;
#ifdef NEGATE_CLASS2
if (ch == NEGATE_CLASS2)
ch = NEGATE_CLASS;
if (p_ch == NEGATE_CLASS2)
p_ch = NEGATE_CLASS;
#endif
/* Assign literal TRUE/FALSE because of "matched" comparison. */
special = ch == NEGATE_CLASS? TRUE : FALSE;
special = p_ch == NEGATE_CLASS? TRUE : FALSE;
if (special) {
/* Inverted character class. */
ch = *++p;
p_ch = *++p;
}
prev = 0;
prev_ch = 0;
matched = FALSE;
do {
if (!ch)
if (!p_ch)
return ABORT_ALL;
if (ch == '\\') {
ch = *++p;
if (!ch)
if (p_ch == '\\') {
p_ch = *++p;
if (!p_ch)
return ABORT_ALL;
if (*text == ch)
if (t_ch == p_ch)
matched = TRUE;
}
else if (ch == '-' && prev && p[1] && p[1] != ']') {
ch = *++p;
if (ch == '\\') {
ch = *++p;
if (!ch)
} else if (p_ch == '-' && prev_ch && p[1] && p[1] != ']') {
p_ch = *++p;
if (p_ch == '\\') {
p_ch = *++p;
if (!p_ch)
return ABORT_ALL;
}
if (*text <= ch && *text >= prev)
if (t_ch <= p_ch && t_ch >= prev_ch)
matched = TRUE;
ch = 0; /* This makes "prev" get set to 0. */
}
else if (ch == '[' && p[1] == ':') {
p_ch = 0; /* This makes "prev_ch" get set to 0. */
} else if (p_ch == '[' && p[1] == ':') {
const uchar *s;
int i;
for (s = p += 2; (ch = *p) && ch != ']'; p++) {}
if (!ch)
for (s = p += 2; (p_ch = *p) && p_ch != ']'; p++) {} /*SHARED ITERATOR*/
if (!p_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)
p_ch = '[';
if (t_ch == p_ch)
matched = TRUE;
continue;
}
if (CC_EQ(s,i, "alnum")) {
if (ISALNUM(*text))
if (ISALNUM(t_ch))
matched = TRUE;
}
else if (CC_EQ(s,i, "alpha")) {
if (ISALPHA(*text))
} else if (CC_EQ(s,i, "alpha")) {
if (ISALPHA(t_ch))
matched = TRUE;
}
else if (CC_EQ(s,i, "blank")) {
if (ISBLANK(*text))
} else if (CC_EQ(s,i, "blank")) {
if (ISBLANK(t_ch))
matched = TRUE;
}
else if (CC_EQ(s,i, "cntrl")) {
if (ISCNTRL(*text))
} else if (CC_EQ(s,i, "cntrl")) {
if (ISCNTRL(t_ch))
matched = TRUE;
}
else if (CC_EQ(s,i, "digit")) {
if (ISDIGIT(*text))
} else if (CC_EQ(s,i, "digit")) {
if (ISDIGIT(t_ch))
matched = TRUE;
}
else if (CC_EQ(s,i, "graph")) {
if (ISGRAPH(*text))
} else if (CC_EQ(s,i, "graph")) {
if (ISGRAPH(t_ch))
matched = TRUE;
}
else if (CC_EQ(s,i, "lower")) {
if (ISLOWER(*text))
} else if (CC_EQ(s,i, "lower")) {
if (ISLOWER(t_ch))
matched = TRUE;
}
else if (CC_EQ(s,i, "print")) {
if (ISPRINT(*text))
} else if (CC_EQ(s,i, "print")) {
if (ISPRINT(t_ch))
matched = TRUE;
}
else if (CC_EQ(s,i, "punct")) {
if (ISPUNCT(*text))
} else if (CC_EQ(s,i, "punct")) {
if (ISPUNCT(t_ch))
matched = TRUE;
}
else if (CC_EQ(s,i, "space")) {
if (ISSPACE(*text))
} else if (CC_EQ(s,i, "space")) {
if (ISSPACE(t_ch))
matched = TRUE;
}
else if (CC_EQ(s,i, "upper")) {
if (ISUPPER(*text))
} else if (CC_EQ(s,i, "upper")) {
if (ISUPPER(t_ch))
matched = TRUE;
}
else if (CC_EQ(s,i, "xdigit")) {
if (ISXDIGIT(*text))
} else if (CC_EQ(s,i, "xdigit")) {
if (ISXDIGIT(t_ch))
matched = TRUE;
}
else /* malformed [:class:] string */
} else /* malformed [:class:] string */
return ABORT_ALL;
ch = 0; /* This makes "prev" get set to 0. */
}
else if (*text == ch)
p_ch = 0; /* This makes "prev_ch" get set to 0. */
} else if (t_ch == p_ch)
matched = TRUE;
} while (prev = ch, (ch = *++p) != ']');
if (matched == special || *text == '/')
} while (prev_ch = p_ch, (p_ch = *++p) != ']');
if (matched == special || t_ch == '/')
return FALSE;
continue;
}
}
return *text == '\0';
do {
if (*text)
return FALSE;
} while ((text = *a++) != NULL);
return TRUE;
}
/* Find the pattern (p) in the text string (t). */
int wildmatch(const char *p, const char *t)
/* Match literal string "s" against the a virtually-joined string consisting
* of "text" and any strings in array "a". */
static int doliteral(const uchar *s, const uchar *text, const uchar*const *a)
{
for ( ; *s != '\0'; text++, s++) {
while (*text == '\0') {
if ((text = *a++) == NULL)
return FALSE;
}
if (*text != *s)
return FALSE;
}
do {
if (*text)
return FALSE;
} while ((text = *a++) != NULL);
return TRUE;
}
/* Return the last "count" path elements from the concatenated string.
* We return a string pointer to the start of the string, and update the
* array pointer-pointer to point to any remaining string elements. */
static const uchar *trailing_N_elements(const uchar*const **a_ptr, int count)
{
const uchar*const *a = *a_ptr;
const uchar*const *first_a = a;
while (*a)
a++;
while (a != first_a) {
const uchar *s = *--a;
s += strlen((char*)s);
while (--s >= *a) {
if (*s == '/' && !--count) {
*a_ptr = a+1;
return s+1;
}
}
}
if (count == 1) {
*a_ptr = a+1;
return *a;
}
return NULL;
}
/* Match the "pattern" against the "text" string. */
int wildmatch(const char *pattern, const char *text)
{
static const uchar *nomore[1]; /* A NULL pointer. */
#ifdef WILD_TEST_ITERATIONS
wildmatch_iteration_count = 0;
#endif
return domatch((const uchar*)p, (const uchar*)t) == TRUE;
return dowild((const uchar*)pattern, (const uchar*)text, nomore) == TRUE;
}
/* Match the "pattern" against the forced-to-lower-case "text" string. */
int iwildmatch(const char *pattern, const char *text)
{
static const uchar *nomore[1]; /* A NULL pointer. */
int ret;
#ifdef WILD_TEST_ITERATIONS
wildmatch_iteration_count = 0;
#endif
force_lower_case = 1;
ret = dowild((const uchar*)pattern, (const uchar*)text, nomore) == TRUE;
force_lower_case = 0;
return ret;
}
/* Match pattern "p" against the a virtually-joined string consisting
* of all the pointers in array "texts" (which has a NULL pointer at the
* end). The int "where" can be 0 (normal matching), > 0 (match only
* the trailing N slash-separated filename components of "texts"), or < 0
* (match the "pattern" at the start or after any slash in "texts"). */
int wildmatch_array(const char *pattern, const char*const *texts, int where)
{
const uchar *p = (const uchar*)pattern;
const uchar*const *a = (const uchar*const*)texts;
const uchar *text;
int matched;
#ifdef WILD_TEST_ITERATIONS
wildmatch_iteration_count = 0;
#endif
if (where > 0)
text = trailing_N_elements(&a, where);
else
text = *a++;
if (!text)
return FALSE;
if ((matched = dowild(p, text, a)) != TRUE && where < 0
&& matched != ABORT_ALL) {
while (1) {
if (*text == '\0') {
if ((text = (uchar*)*a++) == NULL)
return FALSE;
continue;
}
if (*text++ == '/' && (matched = dowild(p, text, a)) != FALSE
&& matched != ABORT_TO_STARSTAR)
break;
}
}
return matched == TRUE;
}
/* Match literal string "s" against the a virtually-joined string consisting
* of all the pointers in array "texts" (which has a NULL pointer at the
* end). The int "where" can be 0 (normal matching), or > 0 (match
* only the trailing N slash-separated filename components of "texts"). */
int litmatch_array(const char *string, const char*const *texts, int where)
{
const uchar *s = (const uchar*)string;
const uchar*const *a = (const uchar* const*)texts;
const uchar *text;
if (where > 0)
text = trailing_N_elements(&a, where);
else
text = *a++;
if (!text)
return FALSE;
return doliteral(s, text, a) == TRUE;
}

View File

@@ -1,3 +1,6 @@
/* wildmatch.h */
int wildmatch(const char *p, const char *text);
int wildmatch(const char *pattern, const char *text);
int iwildmatch(const char *pattern, const char *text);
int wildmatch_array(const char *pattern, const char*const *texts, int where);
int litmatch_array(const char *string, const char*const *texts, int where);

View File

@@ -1,26 +1,25 @@
/* This is based on loadparm.c from Samba, written by Andrew Tridgell
and Karl Auer */
/* some fixes
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2001, 2002 by Martin Pool <mbp@samba.org>
* 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, visit the http://fsf.org website.
*/
/*
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.
*/
/* some fixes
*
* Copyright (C) 2001, 2002 Martin Pool <mbp@samba.org>
*/
/*
* Load parameters.
@@ -51,12 +50,20 @@
/* TODO: Parameter to set debug level on server. */
#include "rsync.h"
#include "ifuncs.h"
#define PTR_DIFF(p1,p2) ((ptrdiff_t)(((char *)(p1)) - (char *)(p2)))
#define strequal(a,b) (strcasecmp(a,b)==0)
#define BOOLSTR(b) ((b) ? "Yes" : "No")
typedef char pstring[1024];
#define pstrcpy(a,b) strlcpy(a,b,sizeof(pstring))
#ifndef LOG_DAEMON
#define LOG_DAEMON 0
#endif
#define DEFAULT_DONT_COMPRESS "*.gz *.zip *.z *.rpm *.deb *.iso *.bz2" \
" *.t[gb]z *.7z *.mp[34] *.mov *.avi *.ogg *.jpg *.jpeg"
/* the following are used by loadparm for option lists */
typedef enum
{
@@ -98,13 +105,11 @@ struct parm_struct
*/
typedef struct
{
char *bind_address;
char *motd_file;
char *log_file;
char *pid_file;
char *socket_options;
char *bind_address;
int syslog_facility;
int max_verbosity;
int rsync_port;
} global;
@@ -112,81 +117,105 @@ static global Globals;
/*
* This structure describes a single service.
* This structure describes a single service. Their order must match the
* initializers below, which you can accomplish by keeping each sub-section
* sorted. (e.g. in vim, just visually select each subsection and use !sort.)
*/
typedef struct
{
char *name;
char *path;
char *auth_users;
char *charset;
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 *dont_compress;
char *exclude;
char *exclude_from;
char *filter;
char *gid;
char *hosts_allow;
char *hosts_deny;
char *auth_users;
char *secrets_file;
BOOL strict_modes;
char *filter;
char *exclude;
char *exclude_from;
char *include;
char *include_from;
char *incoming_chmod;
char *lock_file;
char *log_file;
char *log_format;
char *name;
char *outgoing_chmod;
char *path;
char *postxfer_exec;
char *prexfer_exec;
char *refuse_options;
char *dont_compress;
int timeout;
char *secrets_file;
char *temp_dir;
char *uid;
int max_connections;
int max_verbosity;
int syslog_facility;
int timeout;
BOOL fake_super;
BOOL ignore_errors;
BOOL ignore_nonreadable;
BOOL list;
BOOL munge_symlinks;
BOOL numeric_ids;
BOOL read_only;
BOOL strict_modes;
BOOL transfer_logging;
BOOL use_chroot;
BOOL write_only;
} service;
/* This is a default service used to prime a services structure */
/* This is a default service used to prime a services structure. In order
* to make these easy to keep sorted in the same way as the variables
* above, use the variable name in the leading comment, including a
* trailing ';' (to avoid a sorting problem with trailing digits). */
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 */
False, /* ignore errors */
"nobody",/* uid */
/* auth_users; */ NULL,
/* charset; */ NULL,
/* comment; */ NULL,
/* dont_compress; */ DEFAULT_DONT_COMPRESS,
/* exclude; */ NULL,
/* exclude_from; */ NULL,
/* filter; */ NULL,
/* gid; */ NOBODY_GROUP,
/* hosts_allow; */ NULL,
/* hosts_deny; */ NULL,
/* include; */ NULL,
/* include_from; */ NULL,
/* incoming_chmod; */ NULL,
/* lock_file; */ DEFAULT_LOCK_FILE,
/* log_file; */ NULL,
/* log_format; */ "%o %h [%a] %m (%u) %f %l",
/* name; */ NULL,
/* outgoing_chmod; */ NULL,
/* path; */ NULL,
/* postxfer_exec; */ NULL,
/* prexfer_exec; */ NULL,
/* refuse_options; */ NULL,
/* secrets_file; */ NULL,
/* temp_dir; */ NULL,
/* uid; */ NOBODY_USER,
/* TODO: This causes problems on Debian, where it is called
* "nogroup". Debian patch this in their version of the
* package, but it would be nice to be consistent. Possibly
* other systems are different again.
*
* What is the best behaviour? Perhaps always using (gid_t)
* -2? */
"nobody",/* gid */
/* max_connections; */ 0,
/* max_verbosity; */ 1,
/* syslog_facility; */ LOG_DAEMON,
/* timeout; */ 0,
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 *.iso *.bz2 *.tbz", /* dont compress */
0, /* timeout */
0, /* max connections */
False /* ignore nonreadable */
/* fake_super; */ False,
/* ignore_errors; */ False,
/* ignore_nonreadable; */ False,
/* list; */ True,
/* munge_symlinks; */ (BOOL)-1,
/* numeric_ids; */ (BOOL)-1,
/* read_only; */ True,
/* strict_modes; */ True,
/* transfer_logging; */ False,
/* use_chroot; */ True,
/* write_only; */ False,
};
@@ -269,61 +298,68 @@ static struct enum_list enum_facilities[] = {
/* note that we do not initialise the defaults union - it is not allowed in ANSI C */
static struct parm_struct parm_table[] =
{
{"motd file", P_STRING, P_GLOBAL, &Globals.motd_file, NULL, 0},
{"syslog facility", P_ENUM, P_GLOBAL, &Globals.syslog_facility, enum_facilities,0},
{"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},
{"max verbosity", P_INTEGER, P_GLOBAL, &Globals.max_verbosity, NULL, 0},
{"port", P_INTEGER, P_GLOBAL, &Globals.rsync_port, NULL, 0},
{"address", P_STRING, P_GLOBAL, &Globals.bind_address, NULL, 0},
{"address", P_STRING, P_GLOBAL,&Globals.bind_address, NULL,0},
{"motd file", P_STRING, P_GLOBAL,&Globals.motd_file, NULL,0},
{"pid file", P_STRING, P_GLOBAL,&Globals.pid_file, NULL,0},
{"port", P_INTEGER,P_GLOBAL,&Globals.rsync_port, NULL,0},
{"socket options", P_STRING, P_GLOBAL,&Globals.socket_options, NULL,0},
{"timeout", P_INTEGER, P_LOCAL, &sDefault.timeout, NULL, 0},
{"max connections", P_INTEGER, P_LOCAL, &sDefault.max_connections,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_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},
{"hosts deny", P_STRING, P_LOCAL, &sDefault.hosts_deny, NULL, 0},
{"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},
{NULL, P_BOOL, P_NONE, NULL, NULL, 0}
{"auth users", P_STRING, P_LOCAL, &sDefault.auth_users, NULL,0},
{"charset", P_STRING, P_LOCAL, &sDefault.charset, NULL,0},
{"comment", P_STRING, P_LOCAL, &sDefault.comment, NULL,0},
{"dont compress", P_STRING, P_LOCAL, &sDefault.dont_compress, NULL,0},
{"exclude from", P_STRING, P_LOCAL, &sDefault.exclude_from, NULL,0},
{"exclude", P_STRING, P_LOCAL, &sDefault.exclude, NULL,0},
{"fake super", P_BOOL, P_LOCAL, &sDefault.fake_super, NULL,0},
{"filter", P_STRING, P_LOCAL, &sDefault.filter, NULL,0},
{"gid", P_STRING, P_LOCAL, &sDefault.gid, NULL,0},
{"hosts allow", P_STRING, P_LOCAL, &sDefault.hosts_allow, NULL,0},
{"hosts deny", P_STRING, P_LOCAL, &sDefault.hosts_deny, NULL,0},
{"ignore errors", P_BOOL, P_LOCAL, &sDefault.ignore_errors, NULL,0},
{"ignore nonreadable",P_BOOL, P_LOCAL, &sDefault.ignore_nonreadable,NULL,0},
{"include from", P_STRING, P_LOCAL, &sDefault.include_from, NULL,0},
{"include", P_STRING, P_LOCAL, &sDefault.include, NULL,0},
{"incoming chmod", P_STRING, P_LOCAL, &sDefault.incoming_chmod, NULL,0},
{"list", P_BOOL, P_LOCAL, &sDefault.list, NULL,0},
{"lock file", P_STRING, P_LOCAL, &sDefault.lock_file, NULL,0},
{"log file", P_STRING, P_LOCAL, &sDefault.log_file, NULL,0},
{"log format", P_STRING, P_LOCAL, &sDefault.log_format, NULL,0},
{"max connections", P_INTEGER,P_LOCAL, &sDefault.max_connections, NULL,0},
{"max verbosity", P_INTEGER,P_LOCAL, &sDefault.max_verbosity, NULL,0},
{"munge symlinks", P_BOOL, P_LOCAL, &sDefault.munge_symlinks, NULL,0},
{"name", P_STRING, P_LOCAL, &sDefault.name, NULL,0},
{"numeric ids", P_BOOL, P_LOCAL, &sDefault.numeric_ids, NULL,0},
{"outgoing chmod", P_STRING, P_LOCAL, &sDefault.outgoing_chmod, NULL,0},
{"path", P_PATH, P_LOCAL, &sDefault.path, NULL,0},
#ifdef HAVE_PUTENV
{"post-xfer exec", P_STRING, P_LOCAL, &sDefault.postxfer_exec, NULL,0},
{"pre-xfer exec", P_STRING, P_LOCAL, &sDefault.prexfer_exec, NULL,0},
#endif
{"read only", P_BOOL, P_LOCAL, &sDefault.read_only, NULL,0},
{"refuse options", P_STRING, P_LOCAL, &sDefault.refuse_options, NULL,0},
{"secrets file", P_STRING, P_LOCAL, &sDefault.secrets_file, NULL,0},
{"strict modes", P_BOOL, P_LOCAL, &sDefault.strict_modes, NULL,0},
{"syslog facility", P_ENUM, P_LOCAL, &sDefault.syslog_facility,enum_facilities,0},
{"temp dir", P_PATH, P_LOCAL, &sDefault.temp_dir, NULL,0},
{"timeout", P_INTEGER,P_LOCAL, &sDefault.timeout, NULL,0},
{"transfer logging", P_BOOL, P_LOCAL, &sDefault.transfer_logging, NULL,0},
{"uid", P_STRING, P_LOCAL, &sDefault.uid, NULL,0},
{"use chroot", P_BOOL, P_LOCAL, &sDefault.use_chroot, NULL,0},
{"write only", P_BOOL, P_LOCAL, &sDefault.write_only, NULL,0},
{NULL, P_BOOL, P_NONE, NULL, NULL,0}
};
/***************************************************************************
Initialise the global parameter structure.
* Initialise the global parameter structure.
***************************************************************************/
static void init_globals(void)
{
memset(&Globals, 0, sizeof Globals);
#ifdef LOG_DAEMON
Globals.syslog_facility = LOG_DAEMON;
#endif
Globals.max_verbosity = 1;
}
/***************************************************************************
Initialise the sDefault parameter structure.
* Initialise the sDefault parameter structure.
***************************************************************************/
static void init_locals(void)
{
@@ -354,43 +390,55 @@ static void init_locals(void)
int fn_name(int i) {return(LP_SNUM_OK(i)? pSERVICE(i)->val : sDefault.val);}
FN_GLOBAL_STRING(lp_bind_address, &Globals.bind_address)
FN_GLOBAL_STRING(lp_motd_file, &Globals.motd_file)
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_max_verbosity, &Globals.max_verbosity)
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_GLOBAL_INTEGER(lp_rsync_port, &Globals.rsync_port)
FN_LOCAL_STRING(lp_auth_users, auth_users)
FN_LOCAL_STRING(lp_charset, charset)
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_dont_compress, dont_compress)
FN_LOCAL_STRING(lp_exclude, exclude)
FN_LOCAL_STRING(lp_exclude_from, exclude_from)
FN_LOCAL_STRING(lp_filter, filter)
FN_LOCAL_STRING(lp_gid, gid)
FN_LOCAL_STRING(lp_hosts_allow, hosts_allow)
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)
FN_LOCAL_STRING(lp_include_from, include_from)
FN_LOCAL_STRING(lp_incoming_chmod, incoming_chmod)
FN_LOCAL_STRING(lp_lock_file, lock_file)
FN_LOCAL_STRING(lp_log_file, log_file)
FN_LOCAL_STRING(lp_log_format, log_format)
FN_LOCAL_STRING(lp_name, name)
FN_LOCAL_STRING(lp_outgoing_chmod, outgoing_chmod)
FN_LOCAL_STRING(lp_path, path)
FN_LOCAL_STRING(lp_postxfer_exec, postxfer_exec)
FN_LOCAL_STRING(lp_prexfer_exec, prexfer_exec)
FN_LOCAL_STRING(lp_refuse_options, refuse_options)
FN_LOCAL_STRING(lp_dont_compress, dont_compress)
FN_LOCAL_INTEGER(lp_timeout, timeout)
FN_LOCAL_STRING(lp_secrets_file, secrets_file)
FN_LOCAL_STRING(lp_temp_dir, temp_dir)
FN_LOCAL_STRING(lp_uid, uid)
FN_LOCAL_INTEGER(lp_max_connections, max_connections)
FN_LOCAL_INTEGER(lp_max_verbosity, max_verbosity)
FN_LOCAL_INTEGER(lp_syslog_facility, syslog_facility)
FN_LOCAL_INTEGER(lp_timeout, timeout)
FN_LOCAL_BOOL(lp_fake_super, fake_super)
FN_LOCAL_BOOL(lp_ignore_errors, ignore_errors)
FN_LOCAL_BOOL(lp_ignore_nonreadable, ignore_nonreadable)
FN_LOCAL_BOOL(lp_list, list)
FN_LOCAL_BOOL(lp_munge_symlinks, munge_symlinks)
FN_LOCAL_BOOL(lp_numeric_ids, numeric_ids)
FN_LOCAL_BOOL(lp_read_only, read_only)
FN_LOCAL_BOOL(lp_strict_modes, strict_modes)
FN_LOCAL_BOOL(lp_transfer_logging, transfer_logging)
FN_LOCAL_BOOL(lp_use_chroot, use_chroot)
FN_LOCAL_BOOL(lp_write_only, write_only)
/* local prototypes */
static int strwicmp(char *psz1, char *psz2);
@@ -403,7 +451,7 @@ static BOOL do_section(char *sectionname);
/***************************************************************************
initialise a service to the defaults
* initialise a service to the defaults
***************************************************************************/
static void init_service(service *pservice)
{
@@ -437,8 +485,8 @@ static void string_set(char **s, const char *v)
/***************************************************************************
add a new service to the services array initialising it with the given
service
* add a new service to the services array initialising it with the given
* service
***************************************************************************/
static int add_a_service(service *pservice, char *name)
{
@@ -477,7 +525,7 @@ static int add_a_service(service *pservice, char *name)
}
/***************************************************************************
Do a case-insensitive, whitespace-ignoring string compare.
* Do a case-insensitive, whitespace-ignoring string compare.
***************************************************************************/
static int strwicmp(char *psz1, char *psz2)
{
@@ -495,12 +543,11 @@ static int strwicmp(char *psz1, char *psz2)
/* sync the strings on first non-whitespace */
while (1)
{
while (isspace(* (unsigned char *) psz1))
while (isSpace(psz1))
psz1++;
while (isspace(* (unsigned char *) psz2))
while (isSpace(psz2))
psz2++;
if (toupper(* (unsigned char *) psz1) != toupper(* (unsigned char *) psz2)
|| *psz1 == '\0' || *psz2 == '\0')
if (toUpper(psz1) != toUpper(psz2) || *psz1 == '\0' || *psz2 == '\0')
break;
psz1++;
psz2++;
@@ -509,8 +556,8 @@ static int strwicmp(char *psz1, char *psz2)
}
/***************************************************************************
Map a parameter's string representation to something we can use.
Returns False if the parameter string is not recognised, else TRUE.
* 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)
{
@@ -523,15 +570,15 @@ static int map_parameter(char *parmname)
if (strwicmp(parm_table[iIndex].label, parmname) == 0)
return(iIndex);
rprintf(FERROR, "Unknown Parameter encountered: \"%s\"\n", parmname);
rprintf(FLOG, "Unknown Parameter encountered: \"%s\"\n", parmname);
return(-1);
}
/***************************************************************************
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
represent a boolean.
* 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
* represent a boolean.
***************************************************************************/
static BOOL set_boolean(BOOL *pb, char *parmvalue)
{
@@ -549,7 +596,7 @@ static BOOL set_boolean(BOOL *pb, char *parmvalue)
*pb = False;
else
{
rprintf(FERROR, "Badly formed boolean in configuration file: \"%s\".\n",
rprintf(FLOG, "Badly formed boolean in configuration file: \"%s\".\n",
parmvalue);
bRetval = False;
}
@@ -557,7 +604,7 @@ static BOOL set_boolean(BOOL *pb, char *parmvalue)
}
/***************************************************************************
Find a service by name. Otherwise works like get_service.
* Find a service by name. Otherwise works like get_service.
***************************************************************************/
static int getservicebyname(char *name, service *pserviceDest)
{
@@ -577,8 +624,7 @@ static int getservicebyname(char *name, service *pserviceDest)
/***************************************************************************
Copy a service structure to another
* Copy a service structure to another
***************************************************************************/
static void copy_service(service *pserviceDest,
service *pserviceSource)
@@ -623,8 +669,8 @@ static void copy_service(service *pserviceDest,
/***************************************************************************
Process a parameter for a particular service number. If snum < 0
then assume we are in the globals
* Process a parameter for a particular service number. If snum < 0
* then assume we are in the globals
***************************************************************************/
static BOOL lp_do_parameter(int snum, char *parmname, char *parmvalue)
{
@@ -637,7 +683,7 @@ static BOOL lp_do_parameter(int snum, char *parmname, char *parmvalue)
if (parmnum < 0)
{
rprintf(FERROR, "IGNORING unknown parameter \"%s\"\n", parmname);
rprintf(FLOG, "IGNORING unknown parameter \"%s\"\n", parmname);
return(True);
}
@@ -648,7 +694,7 @@ static BOOL lp_do_parameter(int snum, char *parmname, char *parmvalue)
parm_ptr = def_ptr;
} else {
if (parm_table[parmnum].class == P_GLOBAL) {
rprintf(FERROR, "Global parameter %s found in service section!\n",parmname);
rprintf(FLOG, "Global parameter %s found in service section!\n",parmname);
return(True);
}
parm_ptr = ((char *)pSERVICE(snum)) + PTR_DIFF(def_ptr,&sDefault);
@@ -715,7 +761,7 @@ static BOOL lp_do_parameter(int snum, char *parmname, char *parmvalue)
}
/***************************************************************************
Process a parameter.
* Process a parameter.
***************************************************************************/
static BOOL do_parameter(char *parmname, char *parmvalue)
{
@@ -723,9 +769,9 @@ static BOOL do_parameter(char *parmname, char *parmvalue)
}
/***************************************************************************
Process a new section (service). At this stage all sections are services.
Later we'll have special sections that permit server parameters to be set.
Returns True on success, False on failure.
* Process a new section (service). At this stage all sections are services.
* Later we'll have special sections that permit server parameters to be set.
* Returns True on success, False on failure.
***************************************************************************/
static BOOL do_section(char *sectionname)
{
@@ -746,6 +792,11 @@ static BOOL do_section(char *sectionname)
return(True);
}
if (strchr(sectionname, '/') != NULL) {
rprintf(FLOG, "Warning: invalid section name in configuration file: %s\n", sectionname);
return False;
}
/* if we have a current service, tidy it up before moving on */
bRetval = True;
@@ -760,7 +811,7 @@ static BOOL do_section(char *sectionname)
if ((iServiceIndex=add_a_service(&sDefault,sectionname)) < 0)
{
rprintf(FERROR,"Failed to add a new service\n");
rprintf(FLOG, "Failed to add a new service\n");
return(False);
}
}
@@ -770,14 +821,11 @@ static BOOL do_section(char *sectionname)
/***************************************************************************
Load the services array from the services file. Return True on success,
False on failure.
* 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;
@@ -787,12 +835,7 @@ BOOL lp_load(char *pszFname, int globals_only)
init_globals();
if (pszFname)
pstrcpy(n2,pszFname);
else if (am_server && am_daemon && !am_root)
pstrcpy(n2,RSYNCD_USERCONF);
else
pstrcpy(n2,RSYNCD_SYSCONF);
pstrcpy(n2, pszFname);
/* We get sections first, so have to start 'behind' to make up */
iServiceIndex = -1;
@@ -803,7 +846,7 @@ BOOL lp_load(char *pszFname, int globals_only)
/***************************************************************************
return the max number of services
* return the max number of services
***************************************************************************/
int lp_numservices(void)
{
@@ -811,10 +854,10 @@ int lp_numservices(void)
}
/***************************************************************************
Return the number of the service with the given name, or -1 if it doesn't
exist. Note that this is a DIFFERENT ANIMAL from the internal function
getservicebyname()! This works ONLY if all services have been loaded, and
does not copy the found service.
* Return the number of the service with the given name, or -1 if it doesn't
* exist. Note that this is a DIFFERENT ANIMAL from the internal function
* getservicebyname()! This works ONLY if all services have been loaded, and
* does not copy the found service.
***************************************************************************/
int lp_number(char *name)
{

761
log.c
View File

File diff suppressed because it is too large Load Diff

1178
main.c
View File

File diff suppressed because it is too large Load Diff

219
match.c
View File

@@ -1,88 +1,89 @@
/*
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.
*/
* Block matching used by the file-transfer code.
*
* Copyright (C) 1996 Andrew Tridgell
* Copyright (C) 1996 Paul Mackerras
* Copyright (C) 2003-2008 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
#include "rsync.h"
extern int verbose;
extern int am_server;
extern int do_progress;
extern int checksum_seed;
extern int append_mode;
int updating_basis_file;
typedef unsigned short tag;
#define TABLESIZE (1<<16)
#define NULL_TAG (-1)
static int false_alarms;
static int tag_hits;
static int hash_hits;
static int matches;
static int64 data_transfer;
static int total_false_alarms;
static int total_tag_hits;
static int total_hash_hits;
static int total_matches;
extern struct stats stats;
struct target {
tag t;
int32 i;
};
#define TRADITIONAL_TABLESIZE (1<<16)
static struct target *targets;
static uint32 tablesize;
static int32 *hash_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;
}
#define SUM2HASH2(s1,s2) (((s1) + (s2)) & 0xFFFF)
#define SUM2HASH(sum) SUM2HASH2((sum)&0xFFFF,(sum)>>16)
#define BIG_SUM2HASH(sum) ((sum)%tablesize)
static void build_hash_table(struct sum_struct *s)
{
static uint32 alloc_size;
int32 i;
if (!tag_table)
tag_table = new_array(int32, TABLESIZE);
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);
/* Dynamically calculate the hash table size so that the hash load
* for big files is about 80%. A number greater than the traditional
* size must be odd or s2 will not be able to span the entire set. */
tablesize = (uint32)(s->count/8) * 10 + 11;
if (tablesize < TRADITIONAL_TABLESIZE)
tablesize = TRADITIONAL_TABLESIZE;
if (tablesize > alloc_size || tablesize < alloc_size - 16*1024) {
if (hash_table)
free(hash_table);
hash_table = new_array(int32, tablesize);
if (!hash_table)
out_of_memory("build_hash_table");
alloc_size = tablesize;
}
qsort(targets,s->count,sizeof(targets[0]),(int (*)())compare_targets);
memset(hash_table, 0xFF, tablesize * sizeof hash_table[0]);
for (i = 0; i < TABLESIZE; i++)
tag_table[i] = NULL_TAG;
for (i = s->count; i-- > 0; )
tag_table[targets[i].t] = i;
if (tablesize == TRADITIONAL_TABLESIZE) {
for (i = 0; i < s->count; i++) {
uint32 t = SUM2HASH(s->sums[i].sum1);
s->sums[i].chain = hash_table[t];
hash_table[t] = i;
}
} else {
for (i = 0; i < s->count; i++) {
uint32 t = BIG_SUM2HASH(s->sums[i].sum1);
s->sums[i].chain = hash_table[t];
hash_table[t] = i;
}
}
}
@@ -104,7 +105,7 @@ static OFF_T last_match;
static void matched(int f, struct sum_struct *s, struct map_struct *buf,
OFF_T offset, int32 i)
{
int32 n = offset - last_match; /* max value: block_size (int32) */
int32 n = (int32)(offset - last_match); /* max value: block_size (int32) */
int32 j;
if (verbose > 2 && i >= 0) {
@@ -127,26 +128,21 @@ static void matched(int f, struct sum_struct *s, struct map_struct *buf,
sum_update(map_ptr(buf, last_match + j, n1), n1);
}
if (i >= 0)
last_match = offset + s->sums[i].len;
else
last_match = offset;
if (buf && do_progress) {
if (buf && do_progress)
show_progress(last_match, buf->file_size);
if (i == -1)
end_progress(buf->file_size);
}
}
static void hash_search(int f,struct sum_struct *s,
struct map_struct *buf, OFF_T len)
{
OFF_T offset, end, backup;
int32 k, want_i;
OFF_T offset, end;
int32 k, want_i, backup;
char sum2[SUM_LENGTH];
uint32 s1, s2, sum;
int more;
@@ -181,20 +177,27 @@ static void hash_search(int f,struct sum_struct *s,
}
do {
tag t = gettag2(s1,s2);
int done_csum2 = 0;
int32 j = tag_table[t];
int32 i;
if (verbose > 4)
rprintf(FINFO,"offset=%.0f sum=%08x\n",(double)offset,sum);
if (verbose > 4) {
rprintf(FINFO, "offset=%.0f sum=%04x%04x\n",
(double)offset, s2 & 0xFFFF, s1 & 0xFFFF);
}
if (j == NULL_TAG)
goto null_tag;
if (tablesize == TRADITIONAL_TABLESIZE) {
if ((i = hash_table[SUM2HASH2(s1,s2)]) < 0)
goto null_hash;
sum = (s1 & 0xffff) | (s2 << 16);
} else {
sum = (s1 & 0xffff) | (s2 << 16);
if ((i = hash_table[BIG_SUM2HASH(sum)]) < 0)
goto null_hash;
}
sum = (s1 & 0xffff) | (s2 << 16);
tag_hits++;
hash_hits++;
do {
int32 l, i = targets[j].i;
int32 l;
if (sum != s->sums[i].sum1)
continue;
@@ -210,9 +213,11 @@ static void hash_search(int f,struct sum_struct *s,
&& !(s->sums[i].flags & SUMFLG_SAME_OFFSET))
continue;
if (verbose > 3)
rprintf(FINFO,"potential match at %.0f target=%.0f %.0f sum=%08x\n",
(double)offset,(double)j,(double)i,sum);
if (verbose > 3) {
rprintf(FINFO,
"potential match at %.0f i=%ld sum=%08x\n",
(double)offset, (long)i, sum);
}
if (!done_csum2) {
map = (schar *)map_ptr(buf,offset,l);
@@ -229,8 +234,8 @@ static void hash_search(int f,struct sum_struct *s,
* 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;
int32 i2;
for (i2 = i; i2 >= 0; i2 = s->sums[i2].chain) {
if (s->sums[i2].offset != offset)
continue;
if (i2 != i) {
@@ -245,7 +250,7 @@ static void hash_search(int f,struct sum_struct *s,
* 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);
}
}
/* we've found a match, but now check to see
@@ -271,10 +276,10 @@ static void hash_search(int f,struct sum_struct *s,
s2 = sum >> 16;
matches++;
break;
} while (++j < s->count && targets[j].t == t);
} while ((i = s->sums[i].chain) >= 0);
null_tag:
backup = offset - last_match;
null_hash:
backup = (int32)(offset - last_match);
/* We sometimes read 1 byte prior to last_match... */
if (backup < 0)
backup = 0;
@@ -324,53 +329,70 @@ static void hash_search(int f,struct sum_struct *s,
**/
void match_sums(int f, struct sum_struct *s, struct map_struct *buf, OFF_T len)
{
char file_sum[MD4_SUM_LENGTH];
char file_sum[MAX_DIGEST_LEN];
int sum_len;
last_match = 0;
false_alarms = 0;
tag_hits = 0;
hash_hits = 0;
matches = 0;
data_transfer = 0;
sum_init(checksum_seed);
if (append_mode > 0) {
if (append_mode == 2) {
OFF_T j = 0;
for (j = CHUNK_SIZE; j < s->flength; j += CHUNK_SIZE) {
if (buf && do_progress)
show_progress(last_match, buf->file_size);
sum_update(map_ptr(buf, last_match, CHUNK_SIZE),
CHUNK_SIZE);
last_match = j;
}
if (last_match < s->flength) {
int32 n = (int32)(s->flength - last_match);
if (buf && do_progress)
show_progress(last_match, buf->file_size);
sum_update(map_ptr(buf, last_match, n), n);
}
}
last_match = s->flength;
s->count = 0;
}
if (len > 0 && s->count > 0) {
build_hash_table(s);
if (verbose > 2)
rprintf(FINFO,"built hash table\n");
hash_search(f,s,buf,len);
hash_search(f, s, buf, len);
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 = CHUNK_SIZE; j < len; j += CHUNK_SIZE)
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);
sum_len = sum_end(file_sum);
/* If we had a read error, send a bad checksum. */
if (buf && buf->status != 0)
file_sum[0]++;
if (verbose > 2)
rprintf(FINFO,"sending file_sum\n");
write_buf(f,file_sum,MD4_SUM_LENGTH);
if (targets) {
free(targets);
targets=NULL;
}
write_buf(f, file_sum, sum_len);
if (verbose > 2)
rprintf(FINFO, "false_alarms=%d tag_hits=%d matches=%d\n",
false_alarms, tag_hits, matches);
rprintf(FINFO, "false_alarms=%d hash_hits=%d matches=%d\n",
false_alarms, hash_hits, matches);
total_tag_hits += tag_hits;
total_hash_hits += hash_hits;
total_false_alarms += false_alarms;
total_matches += matches;
stats.literal_data += data_transfer;
@@ -382,8 +404,7 @@ void match_report(void)
return;
rprintf(FINFO,
"total: matches=%d tag_hits=%d false_alarms=%d data=%.0f\n",
total_matches,total_tag_hits,
total_false_alarms,
"total: matches=%d hash_hits=%d false_alarms=%d data=%.0f\n",
total_matches, total_hash_hits, total_false_alarms,
(double)stats.literal_data);
}

View File

@@ -1,76 +0,0 @@
# generate prototypes for Samba C code
# tridge, June 1996
BEGIN {
inheader=0;
print "/* This file is automatically generated with \"make proto\". DO NOT EDIT */"
print ""
}
{
if (inheader) {
if (match($0,"[)][ \t]*$")) {
inheader = 0;
printf "%s;\n",$0;
} else {
printf "%s\n",$0;
}
next;
}
}
/^FN_LOCAL_BOOL/ {
split($0,a,"[,()]")
printf "BOOL %s(int );\n", a[2]
}
/^FN_LOCAL_STRING/ {
split($0,a,"[,()]")
printf "char *%s(int );\n", a[2]
}
/^FN_LOCAL_INT/ {
split($0,a,"[,()]")
printf "int %s(int );\n", a[2]
}
/^FN_LOCAL_CHAR/ {
split($0,a,"[,()]")
printf "char %s(int );\n", a[2]
}
/^FN_GLOBAL_BOOL/ {
split($0,a,"[,()]")
printf "BOOL %s(void);\n", a[2]
}
/^FN_GLOBAL_STRING/ {
split($0,a,"[,()]")
printf "char *%s(void);\n", a[2]
}
/^FN_GLOBAL_INT/ {
split($0,a,"[,()]")
printf "int %s(void);\n", a[2]
}
/^static|^extern/ || !/^[a-zA-Z]/ || /[;]/ {
next;
}
!/^OFF_T|^size_t|^off_t|^pid_t|^unsigned|^mode_t|^DIR|^user|^int|^char|^uint|^uchar|^short|^struct|^BOOL|^void|^time|^const/ {
next;
}
/[(].*[)][ \t]*$/ {
printf "%s;\n",$0;
next;
}
/[(]/ {
inheader=1;
printf "%s\n",$0;
next;
}

48
mkproto.pl Normal file
View File

@@ -0,0 +1,48 @@
# generate prototypes for rsync
$old_protos = '';
if (open(IN, 'proto.h')) {
$old_protos = join('', <IN>);
close IN;
}
%FN_MAP = (
BOOL => 'BOOL ',
CHAR => 'char ',
INTEGER => 'int ',
STRING => 'char *',
);
$inheader = 0;
$protos = qq|/* This file is automatically generated with "make proto". DO NOT EDIT */\n\n|;
while (<>) {
if ($inheader) {
if (/[)][ \t]*$/) {
$inheader = 0;
s/$/;/;
}
$protos .= $_;
} elsif (/^FN_(LOCAL|GLOBAL)_([^(]+)\(([^,()]+)/) {
$ret = $FN_MAP{$2};
$func = $3;
$arg = $1 eq 'LOCAL' ? 'int module_id' : 'void';
$protos .= "$ret$func($arg);\n";
} elsif (/^static|^extern/ || /[;]/ || !/^[A-Za-z][A-Za-z0-9_]* /) {
;
} elsif (/[(].*[)][ \t]*$/) {
s/$/;/;
$protos .= $_;
} elsif (/[(]/) {
$inheader = 1;
$protos .= $_;
}
}
if ($old_protos ne $protos) {
open(OUT, '>proto.h') or die $!;
print OUT $protos;
close OUT;
}
open(OUT, '>proto.h-tstamp') and close OUT;

1580
options.c
View File

File diff suppressed because it is too large Load Diff

6
packaging/bin/gpg Executable file
View File

@@ -0,0 +1,6 @@
#!/bin/sh -e
# This script gets git to run gpg with a --passphrase-file option.
PATH=`echo $PATH | sed 's/^[^:]*://'`
gpg --batch --passphrase-file=$GPG_PASSFILE "${@}"

70
packaging/cull_options Executable file
View File

@@ -0,0 +1,70 @@
#!/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;
our %short_with_num;
our %long_opt = (
'no-i-r' => 0,
'fake-super' => 0,
'log-file' => 3,
);
our $last_long_opt;
open(IN, '../options.c') or die "Unable to open ../options.c: $!\n";
while (<IN>) {
if (/\Qargstr[x++]\E = '([^.ie])'/) {
$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 = 's';
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-|min-)/;
$val = 3 if $opt eq 'files-from';
$val = '$ro ? -1 : ' . $val if $opt =~ /^remove-/;
print " '$opt' => $val,\n";
}
print ");\n\n";

18
packaging/extern-squish Executable file
View File

@@ -0,0 +1,18 @@
#!/usr/bin/perl
# This script finds extraneous "extern" variables in the *.c files.
# Run it from inside the main rsync directory.
use strict;
my @files = glob('*.c');
foreach my $fn (@files) {
open(IN, '<', $fn) or die;
undef $/; $_ = <IN>; $/ = "\n";
close IN;
my @externs = /^extern .*?([^[\s(*;&.]+)(?:\[.*?\])?;/mg;
foreach my $find (@externs) {
my @matches = /(?<!\sstruct )\b(\Q$find\E)\b/g;
print $fn, ': ', $find, "\n" if @matches == 1;
}
}

View File

@@ -1,93 +1,74 @@
Summary: Program for efficient remote updates of files.
Summary: A fast, versatile, remote (and local) file-copying tool
Name: rsync
Version: 2.6.4pre1
Version: 3.0.2
%define fullversion %{version}
Release: 1
Copyright: GPL
Group: Applications/Networking
Source: ftp://samba.anu.edu.au/pub/rsync/rsync-%{version}.tar.gz
URL: http://samba.anu.edu.au/rsync/
Packager: Andrew Tridgell <tridge@samba.anu.edu.au>
BuildRoot: /tmp/rsync
%define srcdir src
Group: Applications/Internet
Source0: http://rsync.samba.org/ftp/rsync/%{srcdir}/rsync-%{fullversion}.tar.gz
#Source1: http://rsync.samba.org/ftp/rsync/%{srcdir}/rsync-patches-%{fullversion}.tar.gz
URL: http://rsync.samba.org/
Prefix: %{_prefix}
BuildRoot: /var/tmp/%{name}-root
License: GPL
%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
* 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).)
Rsync is a fast and extraordinarily versatile file copying tool. It can
copy locally, to/from another host over any remote shell, or to/from a
remote rsync daemon. It offers a large number of options that control
every aspect of its behavior and permit very flexible specification of the
set of files to be copied. It is famous for its delta-transfer algorithm,
which reduces the amount of data sent over the network by sending only the
differences between the source files and the existing files in the
destination. Rsync is widely used for backups and mirroring and as an
improved copy command for everyday use.
%prep
%setup
# Choose one -- setup source only, or setup source + rsync-patches:
%setup -q -n rsync-%{fullversion}
#%setup -q -b1 -n rsync-%{fullversion}
# If you you used "%setup -q -b1", choose the patches you wish to apply:
#patch -p1 <patches/acls.diff
#patch -p1 <patches/xattrs.diff
#patch -p1 <patches/remote-option.diff
#patch -p1 <patches/db.diff
# Avoid extra perl dependencies for scripts going into doc dir.
chmod -x support/*
%build
./configure --prefix=/usr --mandir=%{_mandir}
make CFLAGS="$RPM_OPT_FLAGS"
strip rsync
#./prepare-source
%configure
make
%install
mkdir -p $RPM_BUILD_ROOT/usr/bin
mkdir -p $RPM_BUILD_ROOT/%{_mandir}/man{1,5}
install -m755 rsync $RPM_BUILD_ROOT/usr/bin
install -m644 rsync.1 $RPM_BUILD_ROOT/%{_mandir}/man1
install -m644 rsyncd.conf.5 $RPM_BUILD_ROOT/%{_mandir}/man5
rm -rf $RPM_BUILD_ROOT
%makeinstall
mkdir -p $RPM_BUILD_ROOT/etc/xinetd.d
install -m 644 packaging/lsb/rsync.xinetd $RPM_BUILD_ROOT/etc/xinetd.d/rsync
#install -p -m 755 support/rsyncdb $RPM_BUILD_ROOT/usr/bin/rsyncdb
%clean
rm -rf $RPM_BUILD_ROOT
%files
%attr(-,root,root) /usr/bin/rsync
%attr(-,root,root) %{_mandir}/man1/rsync.1*
%attr(-,root,root) %{_mandir}/man5/rsyncd.conf.5*
%attr(-,root,root) %doc tech_report.tex
%attr(-,root,root) %doc README
%attr(-,root,root) %doc COPYING
%attr(-,root,root) %doc doc/README-SGML doc/rsync.sgml
%defattr(-,root,root)
%doc COPYING NEWS OLDNEWS README support/ tech_report.tex
%config(noreplace) /etc/xinetd.d/rsync
%{_prefix}/bin/rsync*
%{_mandir}/man1/rsync.1*
%{_mandir}/man5/rsyncd.conf.5*
%changelog
* Tue Apr 08 2008 Wayne Davison <wayned@samba.org>
Released 3.0.2.
* Fri Mar 21 2008 Wayne Davison <wayned@samba.org>
Added installation of /etc/xinetd.d/rsync file and some commented-out
lines that demonstrate how to use the rsync-patches tar file.

View File

@@ -0,0 +1,13 @@
# default: off
# description: The rsync server is a good addition to an ftp server, as it
# allows crc checksumming etc.
service rsync
{
disable = yes
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}

121
packaging/nightly-rsync Executable file
View File

@@ -0,0 +1,121 @@
#!/usr/bin/perl
use strict;
# This script expects the directory ~/samba-rsync-ftp to exist and to be a
# copy of the /home/ftp/pub/rsync dir on samba.org. It also requires a
# pristine CVS checkout of rsync (don't use your normal rsync build dir
# unless you're 100% sure that there are not unchecked-in changes).
#
# If this is run with -ctu, it will make an updated "nightly" tar file in
# the nightly dir. It will also remove any old tar files, regenerate the
# HTML man pages in the nightly dir, and then rsync the changes to the
# samba.org server.
use Getopt::Long;
use Date::Format;
# Where the local copy of /home/ftp/pub/rsync/dev/nightly should be updated.
our $dest = $ENV{HOME} . '/samba-rsync-ftp/dev/nightly';
our $nightly_symlink = "$dest/rsync-HEAD.tar.gz";
our($make_tar, $upload, $help_opt);
&Getopt::Long::Configure('bundling');
&usage if !&GetOptions(
'make-tar|t' => \$make_tar,
'upload|u' => \$upload,
'help|h' => \$help_opt,
) || $help_opt;
our $name = time2str('rsync-HEAD-%Y%m%d-%H%M%Z', time, 'GMT');
our $ztoday = time2str('%d %b %Y', time);
our $today = $ztoday;
our $gen_target = $upload ? 'gensend' : 'gen';
die "$dest does not exist\n" unless -d $dest;
die "There is no .git dir in the current directory.\n" unless -d '.git';
die "There is no rsync checkout in the current directory.\n" unless -f 'rsyncd.conf.yo';
if ($make_tar) {
open(IN, '-|', 'git status') or die $!;
my $status = join('', <IN>);
close IN;
die "The checkout is not clean:\n", $status unless $status =~ /\nnothing to commit \(working directory clean\)/;
die "The checkout is not on the master branch.\n" unless $status =~ /^# On branch master\n/;
system "make $gen_target" and die "make $gen_target failed!\n";
my @extra_files;
open(IN, '<', 'Makefile.in') or die "Couldn't open Makefile.in: $!\n";
while (<IN>) {
if (s/^GENFILES=//) {
while (s/\\$//) {
$_ .= <IN>;
}
@extra_files = split(' ', $_);
last;
}
}
close IN;
print "Creating $name.tar.gz\n";
system "rsync -a @extra_files $name/";
system "git archive --format=tar --prefix=$name/ HEAD | tar xf -";
system "support/git-set-file-times --prefix=$name/";
system "fakeroot tar czf $dest/$name.tar.gz $name; rm -rf $name";
unlink($nightly_symlink);
symlink("$name.tar.gz", $nightly_symlink);
}
foreach my $fn (qw( rsync.yo rsyncd.conf.yo )) {
my $yo_tmp = "$dest/$fn";
(my $html_fn = "$dest/$fn") =~ s/\.yo/.html/;
open(IN, '<', $fn) or die $!;
undef $/; $_ = <IN>; $/ = "\n";
close IN;
s/^(manpage\([^)]+\)\(\d+\)\()[^)]+(\).*)/$1$today$2/m;
#s/^(This man ?page is current for version) \S+ (of rsync)/$1 $version $2/m;
open(OUT, '>', $yo_tmp) or die $!;
print OUT $_;
close OUT;
system 'yodl2html', '-o', $html_fn, $yo_tmp;
unlink($yo_tmp);
}
chdir($dest) or die $!;
my $cnt = 0;
open(PIPE, '-|', 'ls -1t rsync-HEAD-*') or die $!;
while (<PIPE>) {
chomp;
next if $cnt++ < 10;
unlink($_);
}
close PIPE;
system 'ls -ltr';
if ($upload) {
my $opt = '';
if (defined $ENV{RSYNC_PARTIAL_DIR}) {
$opt = " -f 'R $ENV{RSYNC_PARTIAL_DIR}'";
}
system "rsync$opt -aviHP --delete-after . samba.org:/home/ftp/pub/rsync/dev/nightly";
}
exit;
sub usage
{
die <<EOT;
Usage: nightly-rsync [OPTIONS]
-t, --make-tar create a new tar file in $dest
-u, --upload upload the revised nightly dir to samba.org
-h, --help display this help
EOT
}

213
packaging/patch-update Executable file
View File

@@ -0,0 +1,213 @@
#!/usr/bin/perl -w
# This script is used to turn one or more of the "patch/*" branches
# into one or more diffs in the "patches" directory. Pass the option
# --gen if you want generated files in the diffs. Pass the name of
# one or more diffs if you want to just update a subset of all the
# diffs.
use strict;
use Getopt::Long;
my $patches_dir = 'patches';
my $tmp_dir = "patches.$$";
&Getopt::Long::Configure('bundling');
&usage if !&GetOptions(
'skip-check' => \( my $skip_branch_check ),
'shell|s' => \( my $launch_shell ),
'gen:s' => \( my $incl_generated_files ),
'help|h' => \( my $help_opt ),
);
&usage if $help_opt;
if (defined $incl_generated_files) {
$patches_dir = $incl_generated_files if $incl_generated_files ne '';
$incl_generated_files = 1;
}
die "No '$patches_dir' directory was found.\n" unless -d $patches_dir;
die "No '.git' directory present in the current dir.\n" unless -d '.git';
my($status, $is_clean, $starting_branch) = &check_git_status;
if (!$skip_branch_check && !$is_clean) {
die "The checkout is not clean:\n", $status;
}
my @extra_files;
open(IN, '<', 'Makefile.in') or die "Couldn't open Makefile.in: $!\n";
while (<IN>) {
if (s/^GENFILES=//) {
while (s/\\$//) {
$_ .= <IN>;
}
@extra_files = split(' ', $_);
last;
}
}
close IN;
if ($incl_generated_files) {
die "'$tmp_dir' must not exist in the current directory.\n" if -e $tmp_dir;
mkdir($tmp_dir, 0700) or die "Unable to mkdir($tmp_dir): $!\n";
system "./config.status Makefile && make gen && rsync -a @extra_files $tmp_dir/master/" and exit 1;
}
my $last_touch = time;
my(%patches, %local_patch);
# Start by finding all patches so that we can load all possible parents.
open(PIPE, '-|', 'git', 'branch', '-a') or die $!;
while (<PIPE>) {
if (m# origin/patch/(.*)#) {
$patches{$1} = 1;
} elsif (m# patch/(.*)#) {
$patches{$1} = $local_patch{$1} = 1;
}
}
close PIPE;
my @patches = sort keys %patches;
my(%parent, %description);
foreach my $patch (@patches) {
my $branch = ($local_patch{$patch} ? '' : 'origin/') . "patch/$patch";
my $desc = '';
open(PIPE, '-|', 'git', 'diff', '-U1000', "master...$branch", '--', "PATCH.$patch") or die $!;
while (<PIPE>) {
last if /^@@ /;
}
while (<PIPE>) {
next unless s/^[ +]//;
if (m#patch -p1 <patches/(\S+)\.diff# && $1 ne $patch) {
$parent{$patch} = $1;
}
$desc .= $_;
}
$description{$patch} = $desc;
}
if (@ARGV) {
# Limit the list of patches to actually process based on @ARGV.
@patches = ( );
foreach (@ARGV) {
s{^(patches|patch|origin/patch)/} {};
s{\.diff$} {};
push(@patches, $_);
}
}
my %completed;
foreach my $patch (@patches) {
next if $completed{$patch}++;
last unless update_patch($patch);
}
if ($incl_generated_files) {
system "rm -rf $tmp_dir";
}
sleep 1 if $last_touch == time;
system "git checkout $starting_branch" and exit 1;
exit;
sub update_patch
{
my($patch) = @_;
my $parent = $parent{$patch};
if (defined $parent) {
unless ($completed{$parent}++) {
update_patch($parent);
}
$parent = "patch/$parent";
} else {
$parent = 'master';
}
print "======== $patch ========\n";
sleep 1 if $incl_generated_files && $last_touch == time;
if ($local_patch{$patch}) {
system "git checkout patch/$patch" and return 0;
} else {
system "git checkout --track -b patch/$patch origin/patch/$patch" and return 0;
}
my $ok = system("git merge $parent") == 0;
if (!$ok || $launch_shell) {
print qq|"git merge $parent" incomplete -- please fix.\n| if !$ok;
$ENV{PS1} = "[$parent] patch/$patch: ";
while (1) {
if (system($ENV{SHELL}) != 0) {
print "Abort? [n/y] ";
$_ = <STDIN>;
next unless /^y/i;
return 0;
}
($status, $is_clean) = &check_git_status;
last if $is_clean;
print $status;
}
}
open(OUT, '>', "$patches_dir/$patch.diff") or die $!;
print OUT $description{$patch}, "\n";
if ($incl_generated_files) {
system "./config.status Makefile && make gen && rsync -a @extra_files $tmp_dir/$patch/";
}
$last_touch = time;
open(PIPE, '-|', 'git', 'diff', $parent) or die $!;
DIFF: while (<PIPE>) {
while (m{^diff --git a/PATCH}) {
while (<PIPE>) {
last if m{^diff --git a/};
}
last DIFF if !defined $_;
}
next if /^index /;
print OUT $_;
}
close PIPE;
if ($incl_generated_files) {
$parent =~ s#.*/##;
open(PIPE, '-|', 'diff', '-up', "$tmp_dir/$parent", "$tmp_dir/$patch") or die $!;
while (<PIPE>) {
s#^(diff -up) $tmp_dir/[^/]+/(.*?) $tmp_dir/[^/]+/(.*)#$1 a/$2 b/$3#o;
s#^\Q---\E $tmp_dir/[^/]+/([^\t]+)\t.*#--- a/$1#o;
s#^\Q+++\E $tmp_dir/[^/]+/([^\t]+)\t.*#+++ b/$1#o;
print OUT $_;
}
close PIPE;
}
close OUT;
1;
}
exit;
sub check_git_status
{
open(IN, '-|', 'git status') or die $!;
my $status = join('', <IN>);
close IN;
my $is_clean = $status =~ /\nnothing to commit \(working directory clean\)/;
my($starting_branch) = $status =~ /^# On branch (.+)\n/;
($status, $is_clean, $starting_branch);
}
sub usage
{
die <<EOT;
Usage: patch-update [OPTIONS]
--gen[=DIR] Include generated files. Optional dest DIR overrides "patches".
--skip-check Skip the check that ensures starting with a clean branch.
EOT
}

345
packaging/release-rsync Executable file
View File

@@ -0,0 +1,345 @@
#!/usr/bin/perl
use strict;
# This script expects the directory ~/samba-rsync-ftp to exist and to be a
# copy of the /home/ftp/pub/rsync dir on samba.org. When the script is done,
# the git repository in the current directory will be updated, and the local
# ~/samba-rsync-ftp dir will be ready to be rsynced to samba.org.
use Cwd;
use Term::ReadKey;
use Date::Format;
my $dest = $ENV{HOME} . '/samba-rsync-ftp';
my $passfile = $ENV{HOME} . '/.rsyncpass';
my $path = $ENV{PATH};
my $now = time;
my $cl_today = time2str('* %a %b %d %Y', $now);
my $year = time2str('%Y', $now);
my $ztoday = time2str('%d %b %Y', $now);
(my $today = $ztoday) =~ s/^0//;
my $curdir = Cwd::cwd;
END {
unlink($passfile);
}
my @extra_files;
open(IN, '<', 'Makefile.in') or die "Couldn't open Makefile.in: $!\n";
while (<IN>) {
if (s/^GENFILES=//) {
while (s/\\$//) {
$_ .= <IN>;
}
@extra_files = split(' ', $_);
last;
}
}
close IN;
my $break = <<EOT;
==========================================================================
EOT
print $break, <<EOT, $break, "\n";
== This will release a new version of rsync onto an unsuspecting world. ==
EOT
die "$dest does not exist\n" unless -d $dest;
die "There is no .git dir in the current directory.\n" unless -d '.git';
die "'a' must not exist in the current directory.\n" if -e 'a';
die "'b' must not exist in the current directory.\n" if -e 'b';
open(IN, '-|', 'git status') or die $!;
my $status = join('', <IN>);
close IN;
die "The checkout is not clean:\n", $status unless $status =~ /\nnothing to commit \(working directory clean\)/;
die "The checkout is not on the master branch.\n" unless $status =~ /^# On branch master\n/;
my $confversion;
open(IN, '<', 'configure.in') or die $!;
while (<IN>) {
if (/^RSYNC_VERSION=(.*)/) {
$confversion = $1;
last;
}
}
close IN;
die "Unable to find RSYNC_VERSION in configure.in\n" unless defined $confversion;
open(IN, '<', 'OLDNEWS') or die $!;
$_ = <IN>;
close IN;
my($lastversion) = /(\d+\.\d+\.\d+)/;
my $version = $confversion;
$version =~ s/dev/pre1/ || $version =~ s/pre(\d+)/ 'pre' . ($1 + 1) /e;
print "Please enter the version number of this release: [$version] ";
chomp($_ = <STDIN>);
if ($_ eq '.') {
$version =~ s/pre\d+//;
} elsif ($_ ne '') {
$version = $_;
}
die "Invalid version: `$version'\n" unless $version =~ /^[\d.]+(pre\d+)?$/;
if (`git tag -l v$version` ne '') {
print "Tag v$version already exists.\n\nDelete tag or quit? [q/del] ";
$_ = <STDIN>;
exit 1 unless /^del/i;
system "git tag -d v$version";
}
if ($version =~ s/[-.]*pre[-.]*/pre/ && $confversion !~ /dev$/) {
$lastversion = $confversion;
}
print "Enter the previous version to produce a patch against: [$lastversion] ";
chomp($_ = <STDIN>);
$lastversion = $_ if $_ ne '';
$lastversion =~ s/[-.]*pre[-.]*/pre/;
my $pre = $version =~ /(pre\d+)/ ? $1 : '';
my $release = $pre ? '0.1' : '1';
print "Please enter the RPM release number of this release: [$release] ";
chomp($_ = <STDIN>);
$release = $_ if $_ ne '';
$release .= ".$pre" if $pre;
my($srcdir,$srcdiffdir,$lastsrcdir,$skipping);
if ($lastversion =~ /pre/) {
if (!$pre) {
die "You should not diff a release version against a pre-release version.\n";
}
$srcdir = $srcdiffdir = $lastsrcdir = 'src-previews';
$skipping = ' ** SKIPPING **';
} elsif ($pre) {
$srcdir = $srcdiffdir = 'src-previews';
$lastsrcdir = 'src';
$skipping = ' ** SKIPPING **';
} else {
$srcdir = $lastsrcdir = 'src';
$srcdiffdir = 'src-diffs';
$skipping = '';
}
print "\n", $break, <<EOT;
\$version is "$version"
\$lastversion is "$lastversion"
\$dest is "$dest"
\$curdir is "$curdir"
\$srcdir is "$srcdir"
\$srcdiffdir is "$srcdiffdir"
\$lastsrcdir is "$lastsrcdir"
\$release is "$release"
About to:
- make sure that SUBPROTOCOL_VERSION is 0$skipping
- tweak the version in configure.in and the spec files
- tweak NEWS and OLDNEWS to update the release date$skipping
- tweak the date in the *.yo files and generate the manpages
- generate configure.sh, config.h.in, and proto.h
- page through the differences
EOT
print "<Press Enter to continue> ";
$_ = <STDIN>;
(my $finalversion = $version) =~ s/pre\d+//;
my %specvars = ( 'Version:' => $finalversion, 'Release:' => $release,
'%define fullversion' => "\%{version}$pre", 'Released' => "$version.",
'%define srcdir' => $srcdir );
my @tweak_files = ( glob('packaging/*.spec'), glob('packaging/*/*.spec'), glob('*.yo'),
qw( configure.in rsync.h NEWS OLDNEWS options.c ) );
foreach my $fn (@tweak_files) {
open(IN, '<', $fn) or die $!;
undef $/; $_ = <IN>; $/ = "\n";
close IN;
if ($fn =~ /configure/) {
s/^RSYNC_VERSION=.*/RSYNC_VERSION=$version/m
or die "Unable to update RSYNC_VERSION in $fn\n";
} elsif ($fn =~ /\.spec/) {
while (my($str, $val) = each %specvars) {
s/^\Q$str\E .*/$str $val/m
or die "Unable to update $str in $fn\n";
}
s/^\* \w\w\w \w\w\w \d\d \d\d\d\d (.*)/$cl_today $1/m
or die "Unable to update ChangeLog header in $fn\n";
} elsif ($fn =~ /\.yo/) {
s/^(manpage\([^)]+\)\(\d+\)\()[^)]+(\).*)/$1$today$2/m
or die "Unable to update date in manpage() header in $fn\n";
s/^(This man ?page is current for version) \S+ (of rsync)/$1 $version $2/m
or die "Unable to update current version info in $fn\n";
} elsif ($fn eq 'rsync.h') {
s/(#define\s+SUBPROTOCOL_VERSION)\s+\d+/$1 0/
or die "Unable to find SUBPROTOCOL_VERSION define in $fn\n";
next if $pre;
} elsif ($fn eq 'NEWS') {
s/^(NEWS for rsync \Q$finalversion\E) \(UNRELEASED\)\s*\n/$1 ($today)\n/mi
or die "The first line of $fn is not in the right format. It must be:\n"
. "NEWS for rsync $finalversion (UNRELEASED)\n";
next if $pre;
} elsif ($fn eq 'OLDNEWS') {
s/^\t\S\S\s\S\S\S\s\d\d\d\d(\t\Q$finalversion\E)/\t$ztoday$1/m
or die "Unable to find \"?? ??? $year\t$finalversion\" line in $fn\n";
next if $pre;
} elsif ($fn eq 'options.c') {
if (s/(Copyright \(C\) 2002-)(\d+)( Wayne Davison)/$1$year$3/
&& $2 ne $year) {
die "Copyright comments need to be updated to $year in all files!\n";
}
# Adjust the year in the --version output.
s/(rprintf\(f, "Copyright \(C\) 1996-)(\d+)/$1$year/
or die "Unable to find Copyright string in --version output of $fn\n";
next if $2 eq $year;
} else {
die "Unrecognized file in \@tweak_files: $fn\n";
}
open(OUT, '>', $fn) or die $!;
print OUT $_;
close OUT;
}
print $break;
system "git diff --color | less -p '^diff .*'";
my $srctar_name = "rsync-$version.tar.gz";
my $pattar_name = "rsync-patches-$version.tar.gz";
my $diff_name = "rsync-$lastversion-$version.diffs.gz";
my $srctar_file = "$dest/$srcdir/$srctar_name";
my $pattar_file = "$dest/$srcdir/$pattar_name";
my $diff_file = "$dest/$srcdiffdir/$diff_name";
my $news_file = "$dest/$srcdir/rsync-$version-NEWS";
my $lasttar_file = "$dest/$lastsrcdir/rsync-$lastversion.tar.gz";
print $break, <<EOT;
About to:
- commit all version changes
- merge the master branch into the patch/* branches
- update the files in the "patches" dir and OPTIONALLY
(if you type 'y') to launch a shell for each patch
EOT
print "<Press Enter OR 'y' to continue> ";
my $ans = <STDIN>;
system "git commit -a -m 'Preparing for release of $version'" and exit 1;
print "Updating files in \"patches\" dir ...\n";
system "packaging/patch-update";
if ($ans =~ /^y/i) {
print "\nVisiting all \"patch/*\" branches ...\n";
system "packaging/patch-update --shell";
}
print $break, <<EOT;
About to:
- create signed tag for this release: v$version
- create release diffs, "$diff_name"
- create release tar, "$srctar_name"
- generate rsync-$version/patches/* files
- create patches tar, "$pattar_name"
- update top-level README, *NEWS, TODO, and ChangeLog
- update top-level rsync*.html manpages
- gpg-sign the release files
- update hard-linked top-level release files$skipping
EOT
print "<Press Enter to continue> ";
$_ = <STDIN>;
my $passphrase;
while (1) {
ReadMode('noecho');
print "\nEnter your GPG pass-phrase: ";
chomp($passphrase = <STDIN>);
ReadMode(0);
print "\n";
# Briefly create a temp file with the passphrase for git's tagging use.
my $oldmask = umask 077;
unlink($passfile);
open(OUT, '>', $passfile) or die $!;
print OUT $passphrase, "\n";
close OUT;
umask $oldmask;
$ENV{'GPG_PASSFILE'} = $passfile;
# We want to use our passphrase-providing "gpg" script, so modify the PATH.
$ENV{PATH} = "packaging/bin:$path";
$_ = `git tag -s -m 'Version $version.' v$version 2>&1`;
$ENV{PATH} = $path;
unlink($passfile);
print $_;
next if /bad passphrase/;
last unless /failed/;
exit 1;
}
# Extract the generated files from the old tar.
@_ = @extra_files;
map { s#^#rsync-$lastversion/# } @_;
system "tar xzf $lasttar_file @_";
rename("rsync-$lastversion", 'a');
print "Creating $diff_file ...\n";
system "./config.status Makefile; make gen; rsync -a @extra_files b/";
my $sed_script = 's:^((---|\+\+\+) [ab]/[^\t]+)\t.*:\1:';
system "(git diff v$lastversion v$version; diff -upN a b | sed -r '$sed_script') | gzip -9 >$diff_file";
system "rm -rf a";
rename('b', "rsync-$version");
print "Creating $srctar_file ...\n";
system "git archive --format=tar --prefix=rsync-$version/ v$version | tar xf -";
system "support/git-set-file-times --prefix=rsync-$version/";
system "fakeroot tar czf $srctar_file rsync-$version; rm -rf rsync-$version";
print "Updating files in \"rsync-$version/patches\" dir ...\n";
mkdir("rsync-$version", 0755);
mkdir("rsync-$version/patches", 0755);
system "packaging/patch-update --skip-check --gen=rsync-$version/patches";
print "Creating $pattar_file ...\n";
system "fakeroot tar chzf $pattar_file rsync-$version/patches; rm -rf rsync-$version";
print "Updating the other files in $dest ...\n";
system "rsync -a README NEWS OLDNEWS TODO $dest";
unlink($news_file);
link("$dest/NEWS", $news_file);
system "git log --name-status | gzip -9 >$dest/ChangeLog.gz";
system "yodl2html -o $dest/rsync.html rsync.yo";
system "yodl2html -o $dest/rsyncd.conf.html rsyncd.conf.yo";
foreach my $fn ($srctar_file, $pattar_file, $diff_file) {
unlink("$fn.asc");
open(GPG, '|-', "gpg --batch --passphrase-fd=0 -ba $fn") or die $!;
print GPG $passphrase, "\n";
close GPG;
}
if (!$pre) {
system "rm $dest/rsync-*.gz $dest/rsync-*.asc $dest/rsync-*-NEWS $dest/src-previews/rsync-*diffs.gz*";
foreach my $fn ($srctar_file, "$srctar_file.asc",
$pattar_file, "$pattar_file.asc",
$diff_file, "$diff_file.asc", $news_file) {
(my $top_fn = $fn) =~ s#/src(-\w+)?/#/#;
link($fn, $top_fn);
}
}
print $break, <<'EOT';
Local changes are done. When you're satisfied, push the git repository
and rsync the release files. Remember to announce the release on *BOTH*
rsync-announce@lists.samba.org and rsync@lists.samba.org (and the web)!
EOT

View File

@@ -1,10 +1,10 @@
/*
This modules is based on the params.c module from Samba, written by Karl Auer
and much modifed by Christopher Hertel.
/* This modules is based on the params.c module from Samba, written by Karl Auer
and much modifed by Christopher Hertel. */
/*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
@@ -12,11 +12,11 @@
* 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.
*
* -------------------------------------------------------------------------- **
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
/* -------------------------------------------------------------------------- **
*
* Module name: params
*
@@ -74,6 +74,7 @@
*/
#include "rsync.h"
#include "ifuncs.h"
/* -------------------------------------------------------------------------- **
* Constants...
@@ -164,7 +165,7 @@ static int Continuation( char *line, int pos )
*/
{
pos--;
while( (pos >= 0) && isspace(((unsigned char *)line)[pos]) )
while( pos >= 0 && isSpace(line + pos) )
pos--;
return( ((pos >= 0) && ('\\' == line[pos])) ? pos : -1 );
@@ -210,7 +211,7 @@ static BOOL Section( FILE *InFile, BOOL (*sfunc)(char *) )
bufr = realloc_array( bufr, char, bSize );
if( NULL == bufr )
{
rprintf(FERROR, "%s Memory re-allocation failure.", func);
rprintf(FLOG, "%s Memory re-allocation failure.", func);
return( False );
}
}
@@ -222,7 +223,7 @@ static BOOL Section( FILE *InFile, BOOL (*sfunc)(char *) )
bufr[end] = '\0';
if( 0 == end ) /* Don't allow an empty name. */
{
rprintf(FERROR, "%s Empty section name in configuration file.\n", func );
rprintf(FLOG, "%s Empty section name in configuration file.\n", func );
return( False );
}
if( !sfunc( bufr ) ) /* Got a valid name. Deal with it. */
@@ -235,7 +236,7 @@ static BOOL Section( FILE *InFile, BOOL (*sfunc)(char *) )
if( i < 0 )
{
bufr[end] = '\0';
rprintf(FERROR, "%s Badly formed line in configuration file: %s\n",
rprintf(FLOG, "%s Badly formed line in configuration file: %s\n",
func, bufr );
return( False );
}
@@ -260,7 +261,7 @@ static BOOL Section( FILE *InFile, BOOL (*sfunc)(char *) )
}
/* We arrive here if we've met the EOF before the closing bracket. */
rprintf(FERROR, "%s Unexpected EOF in the configuration file: %s\n", func, bufr );
rprintf(FLOG, "%s Unexpected EOF in the configuration file: %s\n", func, bufr );
return( False );
} /* Section */
@@ -304,7 +305,7 @@ static BOOL Parameter( FILE *InFile, BOOL (*pfunc)(char *, char *), int c )
bufr = realloc_array( bufr, char, bSize );
if( NULL == bufr )
{
rprintf(FERROR, "%s Memory re-allocation failure.", func) ;
rprintf(FLOG, "%s Memory re-allocation failure.", func) ;
return( False );
}
}
@@ -314,7 +315,7 @@ static BOOL Parameter( FILE *InFile, BOOL (*pfunc)(char *, char *), int c )
case '=': /* Equal sign marks end of param name. */
if( 0 == end ) /* Don't allow an empty name. */
{
rprintf(FERROR, "%s Invalid parameter name in config. file.\n", func );
rprintf(FLOG, "%s Invalid parameter name in config. file.\n", func );
return( False );
}
bufr[end++] = '\0'; /* Mark end of string & advance. */
@@ -328,7 +329,7 @@ static BOOL Parameter( FILE *InFile, BOOL (*pfunc)(char *, char *), int c )
if( i < 0 )
{
bufr[end] = '\0';
rprintf(FERROR, "%s Ignoring badly formed line in configuration file: %s\n",
rprintf(FLOG, "%s Ignoring badly formed line in configuration file: %s\n",
func, bufr );
return( True );
}
@@ -339,7 +340,7 @@ static BOOL Parameter( FILE *InFile, BOOL (*pfunc)(char *, char *), int c )
case '\0': /* Shouldn't have EOF within param name. */
case EOF:
bufr[i] = '\0';
rprintf(FERROR, "%s Unexpected end-of-file at: %s\n", func, bufr );
rprintf(FLOG, "%s Unexpected end-of-file at: %s\n", func, bufr );
return( True );
default:
@@ -369,7 +370,7 @@ static BOOL Parameter( FILE *InFile, BOOL (*pfunc)(char *, char *), int c )
bufr = realloc_array( bufr, char, bSize );
if( NULL == bufr )
{
rprintf(FERROR, "%s Memory re-allocation failure.", func) ;
rprintf(FLOG, "%s Memory re-allocation failure.", func) ;
return( False );
}
}
@@ -386,7 +387,7 @@ static BOOL Parameter( FILE *InFile, BOOL (*pfunc)(char *, char *), int c )
c = 0;
else
{
for( end = i; (end >= 0) && isspace(((unsigned char *) bufr)[end]); end-- )
for( end = i; end >= 0 && isSpace(bufr + end); end-- )
;
c = getc( InFile );
}
@@ -484,15 +485,15 @@ static FILE *OpenConfFile( char *FileName )
if( NULL == FileName || 0 == *FileName )
{
rprintf(FERROR,"%s No configuration filename specified.\n", func);
rprintf(FLOG, "%s No configuration filename specified.\n", func);
return( NULL );
}
OpenedFile = fopen( FileName, "r" );
if( NULL == OpenedFile )
{
rsyserr(FERROR, errno, "rsync: unable to open configuration file \"%s\"",
safe_fname(FileName));
rsyserr(FLOG, errno, "unable to open configuration file \"%s\"",
FileName);
}
return( OpenedFile );
@@ -533,7 +534,7 @@ BOOL pm_process( char *FileName,
bufr = new_array( char, bSize );
if( NULL == bufr )
{
rprintf(FERROR,"%s memory allocation failure.\n", func);
rprintf(FLOG, "%s memory allocation failure.\n", func);
fclose(InFile);
return( False );
}
@@ -547,7 +548,7 @@ BOOL pm_process( char *FileName,
if( !result ) /* Generic failure. */
{
rprintf(FERROR,"%s Failed. Error returned from params.c:parse().\n", func);
rprintf(FLOG, "%s Failed. Error returned from params.c:parse().\n", func);
return( False );
}

56
pipe.c
View File

@@ -1,12 +1,14 @@
/* -*- c-file-style: "linux" -*-
/*
* Routines used to setup various kinds of inter-process pipes.
*
* Copyright (C) 1996-2000 by Andrew Tridgell
* Copyright (C) Paul Mackerras 1996
* Copyright (C) 2001, 2002 by Martin Pool <mbp@samba.org>
* Copyright (C) 1996-2000 Andrew Tridgell
* Copyright (C) 1996 Paul Mackerras
* Copyright (C) 2001, 2002 Martin Pool <mbp@samba.org>
* Copyright (C) 2004-2008 Wayne Davison
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
@@ -14,9 +16,8 @@
* 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.
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
#include "rsync.h"
@@ -24,12 +25,13 @@
extern int am_sender;
extern int am_server;
extern int blocking_io;
extern int orig_umask;
extern int write_batch;
extern int filesfrom_fd;
extern mode_t orig_umask;
extern char *logfile_name;
extern struct chmod_mode_struct *chmod_modes;
/**
* Create a child connected to use on stdin/stdout.
* Create a child connected to us via its stdin/stdout.
*
* This is derived from CVS code
*
@@ -47,9 +49,8 @@ pid_t piped_child(char **command, int *f_in, int *f_out)
int to_child_pipe[2];
int from_child_pipe[2];
if (verbose >= 2) {
print_child_argv(command);
}
if (verbose >= 2)
print_child_argv("opening connection using:", command);
if (fd_pair(to_child_pipe) < 0 || fd_pair(from_child_pipe) < 0) {
rsyserr(FERROR, errno, "pipe");
@@ -79,8 +80,7 @@ pid_t piped_child(char **command, int *f_in, int *f_out)
if (blocking_io > 0)
set_blocking(STDOUT_FILENO);
execvp(command[0], command);
rsyserr(FERROR, errno, "Failed to exec %s",
safe_fname(command[0]));
rsyserr(FERROR, errno, "Failed to exec %s", command[0]);
exit_cleanup(RERR_IPC);
}
@@ -112,6 +112,9 @@ pid_t local_child(int argc, char **argv, int *f_in, int *f_out,
int to_child_pipe[2];
int from_child_pipe[2];
/* The parent process is always the sender for a local rsync. */
assert(am_sender);
if (fd_pair(to_child_pipe) < 0 ||
fd_pair(from_child_pipe) < 0) {
rsyserr(FERROR, errno, "pipe");
@@ -125,15 +128,16 @@ pid_t local_child(int argc, char **argv, int *f_in, int *f_out,
}
if (pid == 0) {
am_sender = !am_sender;
am_sender = 0;
am_server = 1;
filesfrom_fd = -1;
chmod_modes = NULL; /* Let the sending side handle this. */
/* The server side never writes the batch, even if it
* is local (it makes the logic easier elsewhere). */
write_batch = 0;
if (!am_sender)
filesfrom_fd = -1;
/* Let the client side handle this. */
if (logfile_name) {
logfile_name = NULL;
logfile_close();
}
if (dup2(to_child_pipe[0], STDIN_FILENO) < 0 ||
close(to_child_pipe[1]) < 0 ||
@@ -146,12 +150,12 @@ pid_t local_child(int argc, char **argv, int *f_in, int *f_out,
close(to_child_pipe[0]);
if (from_child_pipe[1] != STDOUT_FILENO)
close(from_child_pipe[1]);
#ifdef ICONV_CONST
setup_iconv();
#endif
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");

View File

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

View File

@@ -2,18 +2,20 @@
* \file popt/findme.c
*/
/* (C) 1998-2000 Red Hat, Inc. -- Licensing details are in the COPYING
/* (C) 1998-2002 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) {
const char * findProgramPath(const char * argv0)
{
char * path = getenv("PATH");
char * pathbuf;
char * start, * chptr;
char * buf;
size_t bufsize;
if (argv0 == NULL) return NULL; /* XXX can't happen */
/* If there is a / in the argv[0], it has to be an absolute path */
@@ -22,17 +24,20 @@ const char * findProgramPath(const char * argv0) {
if (path == NULL) return NULL;
start = pathbuf = alloca(strlen(path) + 1);
buf = malloc(strlen(path) + strlen(argv0) + sizeof("/"));
bufsize = strlen(path) + 1;
start = pathbuf = alloca(bufsize);
if (pathbuf == NULL) return NULL; /* XXX can't happen */
strlcpy(pathbuf, path, bufsize);
bufsize += sizeof "/" - 1 + strlen(argv0);
buf = malloc(bufsize);
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);
snprintf(buf, bufsize, "%s/%s", start, argv0);
if (!access(buf, X_OK))
return buf;

View File

@@ -2,7 +2,7 @@
* \file popt/popt.c
*/
/* (C) 19982000 Red Hat, Inc. -- Licensing details are in the COPYING
/* (C) 1998-2002 Red Hat, Inc. -- Licensing details are in the COPYING
file accompanying popt source distributions, available from
ftp://ftp.rpm.org/pub/rpm/dist */
@@ -18,8 +18,18 @@
#include "findme.h"
#include "poptint.h"
#ifndef HAVE_STRERROR
static char * strerror(int errno) {
#ifndef DBL_EPSILON
#define DBL_EPSILON 2.2204460492503131e-16
#endif
#ifdef MYDEBUG
/*@unchecked@*/
int _popt_debug = 0;
#endif
#if !defined(HAVE_STRERROR) && !defined(__LCLINT__)
static char * strerror(int errno)
{
extern int sys_nerr;
extern char * sys_errlist[];
@@ -31,7 +41,8 @@ static char * strerror(int errno) {
#endif
#ifdef MYDEBUG
/*@unused@*/ static void prtcon(const char *msg, poptContext con)
/*@unused@*/
static void prtcon(const char *msg, poptContext con)
{
if (msg) fprintf(stderr, "%s", msg);
fprintf(stderr, "\tcon %p os %p nextCharArg \"%s\" nextArg \"%s\" argv[%d] \"%s\"\n",
@@ -49,7 +60,7 @@ void poptSetExecPath(poptContext con, const char * path, int allowAbsolute)
con->execPath = _free(con->execPath);
con->execPath = xstrdup(path);
con->execAbsolute = allowAbsolute;
/*@-nullstate@*/ /* LCL: con->execPath can be NULL? */
/*@-nullstate@*/ /* LCL: con->execPath not NULL */
return;
/*@=nullstate@*/
}
@@ -62,17 +73,22 @@ static void invokeCallbacksPRE(poptContext con, const struct poptOption * opt)
for (; opt->longName || opt->shortName || opt->arg; opt++) {
if (opt->arg == NULL) continue; /* XXX program error. */
if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) {
void * arg = opt->arg;
/*@-branchstate@*/
/* XXX sick hack to preserve pretense of ABI. */
if (arg == poptHelpOptions) arg = poptHelpOptionsI18N;
/*@=branchstate@*/
/* Recurse on included sub-tables. */
invokeCallbacksPRE(con, opt->arg);
invokeCallbacksPRE(con, arg);
} else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_CALLBACK &&
(opt->argInfo & POPT_CBFLAG_PRE))
{ /*@-castfcnptr@*/
poptCallbackType cb = (poptCallbackType)opt->arg;
/*@=castfcnptr@*/
/* Perform callback. */
/*@-moduncon -noeffectuncon @*/
/*@-noeffectuncon @*/
cb(con, POPT_CALLBACK_REASON_PRE, NULL, NULL, opt->descrip);
/*@=moduncon =noeffectuncon @*/
/*@=noeffectuncon @*/
}
}
}
@@ -85,17 +101,22 @@ static void invokeCallbacksPOST(poptContext con, const struct poptOption * opt)
for (; opt->longName || opt->shortName || opt->arg; opt++) {
if (opt->arg == NULL) continue; /* XXX program error. */
if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) {
void * arg = opt->arg;
/*@-branchstate@*/
/* XXX sick hack to preserve pretense of ABI. */
if (arg == poptHelpOptions) arg = poptHelpOptionsI18N;
/*@=branchstate@*/
/* Recurse on included sub-tables. */
invokeCallbacksPOST(con, opt->arg);
invokeCallbacksPOST(con, arg);
} else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_CALLBACK &&
(opt->argInfo & POPT_CBFLAG_POST))
{ /*@-castfcnptr@*/
poptCallbackType cb = (poptCallbackType)opt->arg;
/*@=castfcnptr@*/
/* Perform callback. */
/*@-moduncon -noeffectuncon @*/
/*@-noeffectuncon @*/
cb(con, POPT_CALLBACK_REASON_POST, NULL, NULL, opt->descrip);
/*@=moduncon =noeffectuncon @*/
/*@=noeffectuncon @*/
}
}
}
@@ -112,6 +133,11 @@ static void invokeCallbacksOPTION(poptContext con,
if (opt != NULL)
for (; opt->longName || opt->shortName || opt->arg; opt++) {
if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) {
void * arg = opt->arg;
/*@-branchstate@*/
/* XXX sick hack to preserve pretense of ABI. */
if (arg == poptHelpOptions) arg = poptHelpOptionsI18N;
/*@=branchstate@*/
/* Recurse on included sub-tables. */
if (opt->arg != NULL) /* XXX program error */
invokeCallbacksOPTION(con, opt->arg, myOpt, myData, shorty);
@@ -133,10 +159,10 @@ static void invokeCallbacksOPTION(poptContext con,
const void * cbData = (cbopt->descrip ? cbopt->descrip : myData);
/* Perform callback. */
if (cb != NULL) { /* XXX program error */
/*@-moduncon -noeffectuncon @*/
/*@-noeffectuncon @*/
cb(con, POPT_CALLBACK_REASON_OPTION, myOpt,
con->os->nextArg, cbData);
/*@=moduncon =noeffectuncon @*/
/*@=noeffectuncon @*/
}
/* Terminate (unless explcitly continuing). */
if (!(cbopt->argInfo & POPT_CBFLAG_CONTINUE))
@@ -181,8 +207,12 @@ poptContext poptGetContext(const char * name, int argc, const char ** argv,
con->flags |= POPT_CONTEXT_POSIXMEHARDER;
if (name) {
char * t = malloc(strlen(name) + 1);
if (t) con->appName = strcpy(t, name);
size_t bufsize = strlen(name) + 1;
char * t = malloc(bufsize);
if (t) {
strlcpy(t, name, bufsize);
con->appName = t;
}
}
/*@-internalglobs@*/
@@ -202,6 +232,7 @@ static void cleanOSE(/*@special@*/ struct optionStackEntry *os)
os->argb = PBM_FREE(os->argb);
}
/*@-boundswrite@*/
void poptResetContext(poptContext con)
{
int i;
@@ -222,10 +253,11 @@ void poptResetContext(poptContext con)
con->doExec = NULL;
if (con->finalArgv != NULL)
for (i = 0; i < con->finalArgvCount; i++)
for (i = 0; i < con->finalArgvCount; i++) {
/*@-unqualifiedtrans@*/ /* FIX: typedef double indirection. */
con->finalArgv[i] = _free(con->finalArgv[i]);
/*@=unqualifiedtrans@*/
}
con->finalArgvCount = 0;
con->arg_strip = PBM_FREE(con->arg_strip);
@@ -233,8 +265,10 @@ void poptResetContext(poptContext con)
return;
/*@=nullstate@*/
}
/*@=boundswrite@*/
/* Only one of longName, shortName should be set, not both. */
/*@-boundswrite@*/
static int handleExec(/*@special@*/ poptContext con,
/*@null@*/ const char * longName, char shortName)
/*@uses con->execs, con->numExecs, con->flags, con->doExec,
@@ -277,12 +311,13 @@ static int handleExec(/*@special@*/ poptContext con,
i = con->finalArgvCount++;
if (con->finalArgv != NULL) /* XXX can't happen */
{ char *s = malloc((longName ? strlen(longName) : 0) + 3);
{ size_t bufsize = (longName ? strlen(longName) : 0) + 3;
char *s = malloc(bufsize);
if (s != NULL) { /* XXX can't happen */
if (longName)
sprintf(s, "--%s", longName);
snprintf(s, bufsize, "--%s", longName);
else
sprintf(s, "-%c", shortName);
snprintf(s, bufsize, "-%c", shortName);
con->finalArgv[i] = s;
} else
con->finalArgv[i] = NULL;
@@ -292,11 +327,12 @@ static int handleExec(/*@special@*/ poptContext con,
return 1;
/*@=nullstate@*/
}
/*@=boundswrite@*/
/* Only one of longName, shortName may be set at a time */
static int handleAlias(/*@special@*/ poptContext con,
/*@null@*/ const char * longName, char shortName,
/*@keep@*/ /*@null@*/ const char * nextCharArg)
/*@exposed@*/ /*@null@*/ const char * nextCharArg)
/*@uses con->aliases, con->numAliases, con->optionStack, con->os,
con->os->currAlias, con->os->currAlias->option.longName @*/
/*@modifies con @*/
@@ -330,8 +366,10 @@ static int handleAlias(/*@special@*/ poptContext con,
if ((con->os - con->optionStack + 1) == POPT_OPTION_DEPTH)
return POPT_ERROR_OPTSTOODEEP;
/*@-boundsread@*/
if (nextCharArg && *nextCharArg)
con->os->nextCharArg = nextCharArg;
/*@=boundsread@*/
con->os++;
con->os->next = 0;
@@ -346,13 +384,14 @@ static int handleAlias(/*@special@*/ poptContext con,
return (rc ? rc : 1);
}
/*@-bounds -boundswrite @*/
static int execCommand(poptContext con)
/*@*/
/*@globals internalState @*/
/*@modifies internalState @*/
{
poptItem item = con->doExec;
const char ** argv;
int argc = 0;
int rc;
if (item == NULL) /*XXX can't happen*/
return POPT_ERROR_NOARG;
@@ -363,15 +402,15 @@ static int execCommand(poptContext con)
argv = malloc(sizeof(*argv) *
(6 + item->argc + con->numLeftovers + con->finalArgvCount));
if (argv == NULL) return POPT_ERROR_MALLOC; /* XXX can't happen */
if (argv == NULL) return POPT_ERROR_MALLOC;
if (!strchr(item->argv[0], '/') && con->execPath) {
char *s = alloca(strlen(con->execPath) + strlen(item->argv[0]) + sizeof("/"));
sprintf(s, "%s/%s", con->execPath, item->argv[0]);
if (!strchr(item->argv[0], '/') && con->execPath != NULL) {
size_t bufsize = strlen(con->execPath) + strlen(item->argv[0]) + sizeof "/";
char *s = alloca(bufsize);
snprintf(s, bufsize, "%s/%s", con->execPath, item->argv[0]);
argv[argc] = s;
} else {
} else
argv[argc] = findProgramPath(item->argv[0]);
}
if (argv[argc++] == NULL) return POPT_ERROR_NOARG;
if (item->argc > 1) {
@@ -386,16 +425,16 @@ static int execCommand(poptContext con)
}
if (con->leftovers != NULL && con->numLeftovers > 0) {
#if 0
argv[argc++] = "--";
#endif
memcpy(argv + argc, con->leftovers, sizeof(*argv) * con->numLeftovers);
argc += con->numLeftovers;
}
argv[argc] = NULL;
{
#ifdef __hpux
int rc = setresgid(getgid(), getgid(),-1);
if (rc) return POPT_ERROR_ERRNO;
rc = setresuid(getuid(), getuid(),-1);
if (rc) return POPT_ERROR_ERRNO;
#else
@@ -405,19 +444,26 @@ static int execCommand(poptContext con)
* XXX from Norbert Warmuth <nwarmuth@privat.circular.de>
*/
#if defined(HAVE_SETUID)
int rc = setgid(getgid());
if (rc) return POPT_ERROR_ERRNO;
rc = setuid(getuid());
if (rc) return POPT_ERROR_ERRNO;
#elif defined (HAVE_SETREUID)
rc = setreuid(getuid(), getuid()); /*hlauer: not portable to hpux9.01 */
int rc = setregid(getgid(), getgid());
if (rc) return POPT_ERROR_ERRNO;
rc = setreuid(getuid(), getuid());
if (rc) return POPT_ERROR_ERRNO;
#else
; /* Can't drop privileges */
#endif
#endif
}
if (argv[0] == NULL)
return POPT_ERROR_NOARG;
#ifdef MYDEBUG
#ifdef MYDEBUG
if (_popt_debug)
{ const char ** avp;
fprintf(stderr, "==> execvp(%s) argv[%d]:", argv[0], argc);
for (avp = argv; *avp; avp++)
@@ -426,10 +472,13 @@ static int execCommand(poptContext con)
}
#endif
rc = execvp(argv[0], (char *const *)argv);
execvp(argv[0], (char *const *)argv);
return POPT_ERROR_ERRNO;
}
/*@=bounds =boundswrite @*/
/*@-boundswrite@*/
/*@observer@*/ /*@null@*/ static const struct poptOption *
findOption(const struct poptOption * opt, /*@null@*/ const char * longName,
char shortName,
@@ -448,10 +497,15 @@ findOption(const struct poptOption * opt, /*@null@*/ const char * longName,
if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) {
const struct poptOption * opt2;
void * arg = opt->arg;
/*@-branchstate@*/
/* XXX sick hack to preserve pretense of ABI. */
if (arg == poptHelpOptions) arg = poptHelpOptionsI18N;
/*@=branchstate@*/
/* Recurse on included sub-tables. */
if (opt->arg == NULL) continue; /* XXX program error */
opt2 = findOption(opt->arg, longName, shortName, callback,
if (arg == NULL) continue; /* XXX program error */
opt2 = findOption(arg, longName, shortName, callback,
callbackData, singleDash);
if (opt2 == NULL) continue;
/* Sub-table data will be inheirited if no data yet. */
@@ -496,6 +550,7 @@ findOption(const struct poptOption * opt, /*@null@*/ const char * longName,
return opt;
}
/*@=boundswrite@*/
static const char * findNextArg(/*@special@*/ poptContext con,
unsigned argx, int delete_arg)
@@ -534,6 +589,7 @@ static const char * findNextArg(/*@special@*/ poptContext con,
return arg;
}
/*@-boundswrite@*/
static /*@only@*/ /*@null@*/ const char *
expandNextArg(/*@special@*/ poptContext con, const char * s)
/*@uses con->optionStack, con->os,
@@ -541,7 +597,7 @@ expandNextArg(/*@special@*/ poptContext con, const char * s)
/*@modifies con @*/
{
const char * a = NULL;
size_t alen;
size_t alen, pos;
char *t, *te;
size_t tn = strlen(s) + 1;
char c;
@@ -567,9 +623,9 @@ expandNextArg(/*@special@*/ poptContext con, const char * s)
alen = strlen(a);
tn += alen;
*te = '\0';
pos = te - t;
t = realloc(t, tn);
te = t + strlen(t);
te = t + pos;
strncpy(te, a, alen); te += alen;
continue;
/*@notreached@*/ /*@switchbreak@*/ break;
@@ -582,6 +638,7 @@ expandNextArg(/*@special@*/ poptContext con, const char * s)
t = realloc(t, strlen(t) + 1); /* XXX memory leak, hard to plug */
return t;
}
/*@=boundswrite@*/
static void poptStripArg(/*@special@*/ poptContext con, int which)
/*@uses con->arg_strip, con->optionStack @*/
@@ -599,26 +656,26 @@ static void poptStripArg(/*@special@*/ poptContext con, int which)
/*@=compdef@*/
}
static int poptSaveLong(const struct poptOption * opt, long aLong)
/*@modifies opt->arg @*/
int poptSaveLong(long * arg, int argInfo, long aLong)
{
if (opt->arg == NULL)
/* XXX Check alignment, may fail on funky platforms. */
if (arg == NULL || (((unsigned long)arg) & (sizeof(*arg)-1)))
return POPT_ERROR_NULLARG;
if (opt->argInfo & POPT_ARGFLAG_NOT)
if (argInfo & POPT_ARGFLAG_NOT)
aLong = ~aLong;
switch (opt->argInfo & POPT_ARGFLAG_LOGICALOPS) {
switch (argInfo & POPT_ARGFLAG_LOGICALOPS) {
case 0:
*((long *) opt->arg) = aLong;
*arg = aLong;
break;
case POPT_ARGFLAG_OR:
*((long *) opt->arg) |= aLong;
*arg |= aLong;
break;
case POPT_ARGFLAG_AND:
*((long *) opt->arg) &= aLong;
*arg &= aLong;
break;
case POPT_ARGFLAG_XOR:
*((long *) opt->arg) ^= aLong;
*arg ^= aLong;
break;
default:
return POPT_ERROR_BADOPERATION;
@@ -627,26 +684,26 @@ static int poptSaveLong(const struct poptOption * opt, long aLong)
return 0;
}
static int poptSaveInt(const struct poptOption * opt, long aLong)
/*@modifies opt->arg @*/
int poptSaveInt(/*@null@*/ int * arg, int argInfo, long aLong)
{
if (opt->arg == NULL)
/* XXX Check alignment, may fail on funky platforms. */
if (arg == NULL || (((unsigned long)arg) & (sizeof(*arg)-1)))
return POPT_ERROR_NULLARG;
if (opt->argInfo & POPT_ARGFLAG_NOT)
if (argInfo & POPT_ARGFLAG_NOT)
aLong = ~aLong;
switch (opt->argInfo & POPT_ARGFLAG_LOGICALOPS) {
switch (argInfo & POPT_ARGFLAG_LOGICALOPS) {
case 0:
*((int *) opt->arg) = aLong;
*arg = aLong;
break;
case POPT_ARGFLAG_OR:
*((int *) opt->arg) |= aLong;
*arg |= aLong;
break;
case POPT_ARGFLAG_AND:
*((int *) opt->arg) &= aLong;
*arg &= aLong;
break;
case POPT_ARGFLAG_XOR:
*((int *) opt->arg) ^= aLong;
*arg ^= aLong;
break;
default:
return POPT_ERROR_BADOPERATION;
@@ -655,6 +712,7 @@ static int poptSaveInt(const struct poptOption * opt, long aLong)
return 0;
}
/*@-boundswrite@*/
/* returns 'val' element, -1 on last item, POPT_ERROR_* on error */
int poptGetNextOpt(poptContext con)
{
@@ -714,8 +772,12 @@ int poptGetNextOpt(poptContext con)
}
/* Make a copy we can hack at */
localOptString = optString =
strcpy(alloca(strlen(origOptString) + 1), origOptString);
{ size_t bufsize = strlen(origOptString) + 1;
localOptString = optString = alloca(bufsize);
if (optString == NULL) /* XXX can't happen */
return POPT_ERROR_BADOPT;
strlcpy(optString, origOptString, bufsize);
}
if (optString[0] == '\0')
return POPT_ERROR_BADOPT;
@@ -747,16 +809,20 @@ int poptGetNextOpt(poptContext con)
*oe++ = '\0';
/* XXX longArg is mapped back to persistent storage. */
longArg = origOptString + (oe - localOptString);
}
} else
oe = NULL;
opt = findOption(con->options, optString, '\0', &cb, &cbData,
singleDash);
if (!opt && !singleDash)
return POPT_ERROR_BADOPT;
if (!opt && oe)
oe[-1] = '='; /* restore overwritten '=' */
}
if (!opt) {
con->os->nextCharArg = origOptString + 1;
longArg = NULL;
} else {
if (con->os == con->optionStack &&
opt->argInfo & POPT_ARGFLAG_STRIP)
@@ -794,17 +860,17 @@ int poptGetNextOpt(poptContext con)
origOptString++;
if (*origOptString != '\0')
con->os->nextCharArg = origOptString;
con->os->nextCharArg = origOptString + (*origOptString == '=');
}
/*@=branchstate@*/
if (opt == NULL) return POPT_ERROR_BADOPT; /* XXX can't happen */
if (opt->arg && (opt->argInfo & POPT_ARG_MASK) == POPT_ARG_NONE) {
if (poptSaveInt(opt, 1L))
if (poptSaveInt((int *)opt->arg, opt->argInfo, 1L))
return POPT_ERROR_BADOPERATION;
} else if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_VAL) {
if (opt->arg) {
if (poptSaveInt(opt, (long)opt->val))
if (poptSaveInt((int *)opt->arg, opt->argInfo, (long)opt->val))
return POPT_ERROR_BADOPERATION;
}
} else if ((opt->argInfo & POPT_ARG_MASK) != POPT_ARG_NONE) {
@@ -873,12 +939,12 @@ int poptGetNextOpt(poptContext con)
if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_LONG) {
if (aLong == LONG_MIN || aLong == LONG_MAX)
return POPT_ERROR_OVERFLOW;
if (poptSaveLong(opt, aLong))
if (poptSaveLong((long *)opt->arg, opt->argInfo, aLong))
return POPT_ERROR_BADOPERATION;
} else {
if (aLong > INT_MAX || aLong < INT_MIN)
return POPT_ERROR_OVERFLOW;
if (poptSaveInt(opt, aLong))
if (poptSaveInt((int *)opt->arg, opt->argInfo, aLong))
return POPT_ERROR_BADOPERATION;
}
} /*@switchbreak@*/ break;
@@ -904,9 +970,6 @@ int poptGetNextOpt(poptContext con)
if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_DOUBLE) {
*((double *) opt->arg) = aDouble;
} else {
#ifndef DBL_EPSILON
#define DBL_EPSILON 2.2204460492503131e-16
#endif
#define MY_ABS(a) ((((a) - 0.0) < DBL_EPSILON) ? -(a) : (a))
if ((MY_ABS(aDouble) - FLT_MAX) > DBL_EPSILON)
return POPT_ERROR_OVERFLOW;
@@ -939,14 +1002,15 @@ int poptGetNextOpt(poptContext con)
}
if (con->finalArgv != NULL)
{ char *s = malloc((opt->longName ? strlen(opt->longName) : 0) + 3);
{ ssize_t bufsize = (opt->longName ? strlen(opt->longName) : 0) + 3;
char *s = malloc(bufsize);
if (s != NULL) { /* XXX can't happen */
if (opt->longName)
sprintf(s, "%s%s",
snprintf(s, bufsize, "%s%s",
((opt->argInfo & POPT_ARGFLAG_ONEDASH) ? "-" : "--"),
opt->longName);
else
sprintf(s, "-%c", opt->shortName);
snprintf(s, bufsize, "-%c", opt->shortName);
con->finalArgv[con->finalArgvCount++] = s;
} else
con->finalArgv[con->finalArgvCount++] = NULL;
@@ -967,6 +1031,7 @@ int poptGetNextOpt(poptContext con)
return (opt ? opt->val : -1); /* XXX can't happen */
}
/*@=boundswrite@*/
const char * poptGetOptArg(poptContext con)
{
@@ -996,6 +1061,7 @@ const char * poptPeekArg(poptContext con)
return ret;
}
/*@-boundswrite@*/
const char ** poptGetArgs(poptContext con)
{
if (con == NULL ||
@@ -1009,6 +1075,7 @@ const char ** poptGetArgs(poptContext con)
return (con->leftovers + con->nextLeftover);
/*@=nullret =nullstate @*/
}
/*@=boundswrite@*/
poptContext poptFreeContext(poptContext con)
{
@@ -1071,6 +1138,7 @@ int poptAddAlias(poptContext con, struct poptAlias alias,
return poptAddItem(con, item, 0);
}
/*@-boundswrite@*/
/*@-mustmod@*/ /* LCL: con not modified? */
int poptAddItem(poptContext con, poptItem newItem, int flags)
{
@@ -1115,6 +1183,7 @@ int poptAddItem(poptContext con, poptItem newItem, int flags)
return 0;
}
/*@=mustmod@*/
/*@=boundswrite@*/
const char * poptBadOption(poptContext con, int flags)
{
@@ -1184,6 +1253,7 @@ const char * poptGetInvocationName(poptContext con)
return (con->os->argv ? con->os->argv[0] : "");
}
/*@-boundswrite@*/
int poptStrippedArgv(poptContext con, int argc, char ** argv)
{
int numargs = argc;
@@ -1207,3 +1277,4 @@ int poptStrippedArgv(poptContext con, int argc, char ** argv)
return numargs;
}
/*@=boundswrite@*/

View File

@@ -112,33 +112,42 @@
/** \ingroup popt
*/
struct poptOption {
/*@observer@*/ /*@null@*/ const char * longName; /*!< may be NULL */
char shortName; /*!< may be '\0' */
/*@observer@*/ /*@null@*/
const char * longName; /*!< may be NULL */
char shortName; /*!< may be NUL */
int argInfo;
/*@shared@*/ /*@null@*/ void * arg; /*!< depends on 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 */
/*@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' */
/*@owned@*/ /*@null@*/
const char * longName; /*!< may be NULL */
char shortName; /*!< may be NUL */
int argc;
/*@owned@*/ const char ** argv; /*!< must be free()able */
/*@owned@*/
const char ** argv; /*!< must be free()able */
};
/** \ingroup popt
* A popt alias or exec argument for poptAddItem().
*/
/*@-exporttype@*/
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. */
/*@owned@*/
const char ** argv; /*!< (alias) args, must be free()able. */
} * poptItem;
/*@=exporttype@*/
/** \ingroup popt
* \name Auto-generated help/usage
@@ -148,16 +157,26 @@ typedef struct poptItem_s {
/**
* Empty table marker to enable displaying popt alias/exec options.
*/
/*@observer@*/ /*@checked@*/
/*@-exportvar@*/
/*@unchecked@*/ /*@observer@*/
extern struct poptOption poptAliasOptions[];
/*@=exportvar@*/
#define POPT_AUTOALIAS { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptAliasOptions, \
0, "Options implemented via popt alias/exec:", NULL },
/**
* Auto help table options.
*/
/*@observer@*/ /*@checked@*/
/*@-exportvar@*/
/*@unchecked@*/ /*@observer@*/
extern struct poptOption poptHelpOptions[];
/*@=exportvar@*/
/*@-exportvar@*/
/*@unchecked@*/ /*@observer@*/
extern struct poptOption * poptHelpOptionsI18N;
/*@=exportvar@*/
#define POPT_AUTOHELP { NULL, '\0', POPT_ARG_INCLUDE_TABLE, poptHelpOptions, \
0, "Help options:", NULL },
@@ -166,19 +185,25 @@ extern struct poptOption poptHelpOptions[];
/** \ingroup popt
*/
/*@-exporttype@*/
typedef /*@abstract@*/ struct poptContext_s * poptContext;
/*@=exporttype@*/
/** \ingroup popt
*/
#ifndef __cplusplus
/*@-typeuse@*/
/*@-exporttype -typeuse@*/
typedef struct poptOption * poptOption;
/*@=typeuse@*/
/*@=exporttype =typeuse@*/
#endif
enum poptCallbackReason { POPT_CALLBACK_REASON_PRE,
POPT_CALLBACK_REASON_POST,
POPT_CALLBACK_REASON_OPTION };
/*@-exportconst@*/
enum poptCallbackReason {
POPT_CALLBACK_REASON_PRE = 0,
POPT_CALLBACK_REASON_POST = 1,
POPT_CALLBACK_REASON_OPTION = 2
};
/*@=exportconst@*/
#ifdef __cplusplus
extern "C" {
@@ -198,18 +223,20 @@ typedef void (*poptCallbackType) (poptContext con,
/*@null@*/ const struct poptOption * opt,
/*@null@*/ const char * arg,
/*@null@*/ const void * data)
/*@*/;
/*@globals internalState @*/
/*@modifies internalState @*/;
/** \ingroup popt
* Initialize popt context.
* @param name
* @param name context name (usually argv[0] program 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(
/*@only@*/ /*@null@*/
poptContext poptGetContext(
/*@dependent@*/ /*@keep@*/ const char * name,
int argc, /*@dependent@*/ /*@keep@*/ const char ** argv,
/*@dependent@*/ /*@keep@*/ const struct poptOption * options,
@@ -220,6 +247,7 @@ typedef void (*poptCallbackType) (poptContext con,
* Reinitialize popt context.
* @param con context
*/
/*@unused@*/
void poptResetContext(/*@null@*/poptContext con)
/*@modifies con @*/;
@@ -229,57 +257,62 @@ void poptResetContext(/*@null@*/poptContext con)
* @return next option val, -1 on last item, POPT_ERROR_* on error
*/
int poptGetNextOpt(/*@null@*/poptContext con)
/*@globals fileSystem@*/
/*@modifies con, fileSystem @*/;
/*@globals fileSystem, internalState @*/
/*@modifies con, fileSystem, internalState @*/;
/*@-redecl@*/
/** \ingroup popt
* Return next option argument (if any).
* @param con context
* @return option argument, NULL if no more options are available
* @return option argument, NULL if no argument is available
*/
/*@observer@*/ /*@null@*/ const char * poptGetOptArg(/*@null@*/poptContext con)
/*@observer@*/ /*@null@*/ /*@unused@*/
const char * poptGetOptArg(/*@null@*/poptContext con)
/*@modifies con @*/;
/** \ingroup popt
* Return current option's argument.
* Return next argument.
* @param con context
* @return option argument, NULL if no more options are available
* @return next argument, NULL if no argument is available
*/
/*@observer@*/ /*@null@*/ const char * poptGetArg(/*@null@*/poptContext con)
/*@observer@*/ /*@null@*/ /*@unused@*/
const char * poptGetArg(/*@null@*/poptContext con)
/*@modifies con @*/;
/** \ingroup popt
* Peek at current option's argument.
* Peek at current argument.
* @param con context
* @return option argument
* @return current argument, NULL if no argument is available
*/
/*@observer@*/ /*@null@*/ const char * poptPeekArg(/*@null@*/poptContext con)
/*@observer@*/ /*@null@*/ /*@unused@*/
const char * poptPeekArg(/*@null@*/poptContext con)
/*@*/;
/** \ingroup popt
* Return remaining arguments.
* @param con context
* @return argument array, terminated with NULL
* @return argument array, NULL terminated
*/
/*@observer@*/ /*@null@*/ const char ** poptGetArgs(/*@null@*/poptContext con)
/*@observer@*/ /*@null@*/
const char ** poptGetArgs(/*@null@*/poptContext con)
/*@modifies con @*/;
/** \ingroup popt
* Return the option which caused the most recent error.
* @param con context
* @param flags
* @return offending option
*/
/*@observer@*/ const char * poptBadOption(/*@null@*/poptContext con, int flags)
/*@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)
/*@null@*/
poptContext poptFreeContext( /*@only@*/ /*@null@*/ poptContext con)
/*@modifies con @*/;
/** \ingroup popt
@@ -288,6 +321,7 @@ int poptGetNextOpt(/*@null@*/poptContext con)
* @param argv argument array, NULL terminated
* @return 0 on success, POPT_ERROR_OPTSTOODEEP on failure
*/
/*@unused@*/
int poptStuffArgs(poptContext con, /*@keep@*/ const char ** argv)
/*@modifies con @*/;
@@ -307,7 +341,7 @@ int poptAddAlias(poptContext con, struct poptAlias alias, int flags)
/** \ingroup popt
* Add alias/exec item to context.
* @param con context
* @param item alias/exec item to add
* @param newItem alias/exec item to add
* @param flags 0 for alias, 1 for exec
* @return 0 on success
*/
@@ -321,9 +355,9 @@ int poptAddItem(poptContext con, poptItem newItem, int flags)
* @return 0 on success, POPT_ERROR_ERRNO on failure
*/
int poptReadConfigFile(poptContext con, const char * fn)
/*@globals fileSystem@*/
/*@modifies fileSystem,
con->execs, con->numExecs @*/;
/*@globals errno, fileSystem, internalState @*/
/*@modifies con->execs, con->numExecs,
errno, fileSystem, internalState @*/;
/** \ingroup popt
* Read default configuration from /etc/popt and $HOME/.popt.
@@ -331,10 +365,11 @@ int poptReadConfigFile(poptContext con, const char * fn)
* @param useEnv (unused)
* @return 0 on success, POPT_ERROR_ERRNO on failure
*/
/*@unused@*/
int poptReadDefaultConfig(poptContext con, /*@unused@*/ int useEnv)
/*@globals fileSystem@*/
/*@modifies fileSystem,
con->execs, con->numExecs @*/;
/*@globals fileSystem, internalState @*/
/*@modifies con->execs, con->numExecs,
fileSystem, internalState @*/;
/** \ingroup popt
* Duplicate an argument array.
@@ -363,19 +398,70 @@ int poptDupArgv(int argc, /*@null@*/ const char **argv,
* @retval argcPtr address of returned no. of arguments
* @retval argvPtr address of returned argument array
*/
int poptParseArgvString(const unsigned char * s,
int poptParseArgvString(const char * s,
/*@out@*/ int * argcPtr, /*@out@*/ const char *** argvPtr)
/*@modifies *argcPtr, *argvPtr @*/;
/** \ingroup popt
* Parses an input configuration file and returns an string that is a
* command line. For use with popt. You must free the return value when done.
*
* Given the file:
\verbatim
# this line is ignored
# this one too
aaa
bbb
ccc
bla=bla
this_is = fdsafdas
bad_line=
reall bad line
reall bad line = again
5555= 55555
test = with lots of spaces
\endverbatim
*
* The result is:
\verbatim
--aaa --bbb --ccc --bla="bla" --this_is="fdsafdas" --5555="55555" --test="with lots of spaces"
\endverbatim
*
* Passing this to poptParseArgvString() yields an argv of:
\verbatim
'--aaa'
'--bbb'
'--ccc'
'--bla=bla'
'--this_is=fdsafdas'
'--5555=55555'
'--test=with lots of spaces'
\endverbatim
*
* @bug NULL is returned if file line is too long.
* @bug Silently ignores invalid lines.
*
* @param fp file handle to read
* @param *argstrp return string of options (malloc'd)
* @param flags unused
* @return 0 on success
* @see poptParseArgvString
*/
/*@-fcnuse@*/
int poptConfigFileToString(FILE *fp, /*@out@*/ char ** argstrp, int flags)
/*@globals fileSystem @*/
/*@modifies *fp, *argstrp, fileSystem @*/;
/*@=fcnuse@*/
/** \ingroup popt
* Return formatted error string for popt failure.
* @param error popt error
* @return error string
*/
/*@-redecl@*/
/*@observer@*/ const char * poptStrerror(const int error)
/*@observer@*/
const char * poptStrerror(const int error)
/*@*/;
/*@=redecl@*/
/** \ingroup popt
* Limit search for executables.
@@ -383,6 +469,7 @@ int poptParseArgvString(const unsigned char * s,
* @param path single path to search for executables
* @param allowAbsolute absolute paths only?
*/
/*@unused@*/
void poptSetExecPath(poptContext con, const char * path, int allowAbsolute)
/*@modifies con @*/;
@@ -421,10 +508,11 @@ void poptSetOtherOptionHelp(poptContext con, const char * text)
* @param con context
* @return argv[0]
*/
/*@-redecl -fcnuse@*/
/*@observer@*/ const char * poptGetInvocationName(poptContext con)
/*@-fcnuse@*/
/*@observer@*/
const char * poptGetInvocationName(poptContext con)
/*@*/;
/*@=redecl =fcnuse@*/
/*@=fcnuse@*/
/** \ingroup popt
* Shuffle argv pointers to remove stripped args, returns new argc.
@@ -438,6 +526,36 @@ int poptStrippedArgv(poptContext con, int argc, char ** argv)
/*@modifies *argv @*/;
/*@=fcnuse@*/
/**
* Save a long, performing logical operation with value.
* @warning Alignment check may be too strict on certain platorms.
* @param arg integer pointer, aligned on int boundary.
* @param argInfo logical operation (see POPT_ARGFLAG_*)
* @param aLong value to use
* @return 0 on success, POPT_ERROR_NULLARG/POPT_ERROR_BADOPERATION
*/
/*@-incondefs@*/
/*@unused@*/
int poptSaveLong(/*@null@*/ long * arg, int argInfo, long aLong)
/*@modifies *arg @*/
/*@requires maxSet(arg) >= 0 /\ maxRead(arg) == 0 @*/;
/*@=incondefs@*/
/**
* Save an integer, performing logical operation with value.
* @warning Alignment check may be too strict on certain platorms.
* @param arg integer pointer, aligned on int boundary.
* @param argInfo logical operation (see POPT_ARGFLAG_*)
* @param aLong value to use
* @return 0 on success, POPT_ERROR_NULLARG/POPT_ERROR_BADOPERATION
*/
/*@-incondefs@*/
/*@unused@*/
int poptSaveInt(/*@null@*/ int * arg, int argInfo, long aLong)
/*@modifies *arg @*/
/*@requires maxSet(arg) >= 0 /\ maxRead(arg) == 0 @*/;
/*@=incondefs@*/
/*@=type@*/
#ifdef __cplusplus
}

View File

@@ -2,46 +2,48 @@
* \file popt/poptconfig.c
*/
/* (C) 1998-2000 Red Hat, Inc. -- Licensing details are in the COPYING
/* (C) 1998-2002 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"
/*@access poptContext @*/
/*@-compmempass@*/ /* FIX: item->option.longName kept, not dependent. */
static void configLine(poptContext con, unsigned char * line)
static void configLine(poptContext con, char * line)
/*@modifies con @*/
{
/*@-type@*/
int nameLength = strlen(con->appName);
/*@=type@*/
size_t nameLength;
const char * entryType;
const char * opt;
poptItem item = (poptItem) alloca(sizeof(*item));
int i, j;
if (con->appName == NULL)
return;
nameLength = strlen(con->appName);
/*@-boundswrite@*/
memset(item, 0, sizeof(*item));
/*@-type@*/
if (strncmp(line, con->appName, nameLength)) return;
/*@=type@*/
line += nameLength;
if (*line == '\0' || !isspace(*line)) return;
if (*line == '\0' || !isSpace(line)) return;
while (*line != '\0' && isspace(*line)) line++;
while (*line != '\0' && isSpace(line)) line++;
entryType = line;
while (*line == '\0' || !isspace(*line)) line++;
while (*line == '\0' || !isSpace(line)) line++;
*line++ = '\0';
while (*line != '\0' && isspace(*line)) line++;
while (*line != '\0' && isSpace(line)) line++;
if (*line == '\0') return;
opt = line;
while (*line == '\0' || !isspace(*line)) line++;
while (*line == '\0' || !isSpace(line)) line++;
*line++ = '\0';
while (*line != '\0' && isspace(*line)) line++;
while (*line != '\0' && isSpace(line)) line++;
if (*line == '\0') return;
/*@-temptrans@*/ /* FIX: line alias is saved */
@@ -80,6 +82,7 @@ static void configLine(poptContext con, unsigned char * line)
item->argc = j;
}
/*@=modobserver@*/
/*@=boundswrite@*/
/*@-nullstate@*/ /* FIX: item->argv[] may be NULL */
if (!strcmp(entryType, "alias"))
@@ -92,9 +95,9 @@ static void configLine(poptContext con, unsigned char * line)
int poptReadConfigFile(poptContext con, const char * fn)
{
const unsigned char * file, * chptr, * end;
unsigned char * buf;
/*@dependent@*/ unsigned char * dst;
const char * file, * chptr, * end;
char * buf;
/*@dependent@*/ char * dst;
int fd, rc;
off_t fileLength;
@@ -106,9 +109,7 @@ int poptReadConfigFile(poptContext con, const char * fn)
if (fileLength == -1 || lseek(fd, 0, 0) == -1) {
rc = errno;
(void) close(fd);
/*@-mods@*/
errno = rc;
/*@=mods@*/
return POPT_ERROR_ERRNO;
}
@@ -116,14 +117,13 @@ int poptReadConfigFile(poptContext con, const char * fn)
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;
/*@-boundswrite@*/
dst = buf = alloca(fileLength + 1);
chptr = file;
@@ -134,7 +134,7 @@ int poptReadConfigFile(poptContext con, const char * fn)
case '\n':
*dst = '\0';
dst = buf;
while (*dst && isspace(*dst)) dst++;
while (*dst && isSpace(dst)) dst++;
if (*dst && *dst != '#')
configLine(con, dst);
chptr++;
@@ -155,6 +155,7 @@ int poptReadConfigFile(poptContext con, const char * fn)
}
}
/*@=infloops@*/
/*@=boundswrite@*/
return 0;
}
@@ -164,18 +165,16 @@ int poptReadDefaultConfig(poptContext con, /*@unused@*/ UNUSED(int useEnv))
char * fn, * home;
int rc;
/*@-type@*/
if (!con->appName) return 0;
/*@=type@*/
if (con->appName == NULL) return 0;
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");
size_t bufsize = strlen(home) + 20;
fn = alloca(bufsize);
if (fn == NULL) return 0;
snprintf(fn, bufsize, "%s/.popt", home);
rc = poptReadConfigFile(con, fn);
if (rc) return rc;
}

View File

@@ -1,20 +1,31 @@
/* -*- 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
/* (C) 1998-2002 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_WCHAR_HACK*/
#ifdef POPT_WCHAR_HACK
#include <wchar.h> /* for mbsrtowcs */
/*@access mbstate_t @*/
#endif
#include "poptint.h"
/*@access poptContext@*/
/**
* Display arguments.
* @param con context
* @param foo (unused)
* @param key option(s)
* @param arg (unused)
* @param data (unused)
*/
static void displayArgs(poptContext con,
/*@unused@*/ UNUSED(enum poptCallbackReason foo),
@@ -49,6 +60,17 @@ struct poptOption poptAliasOptions[] = {
/*@-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 },
POPT_TABLEEND
} ;
/*@observer@*/ /*@unchecked@*/
static struct poptOption poptHelpOptions2[] = {
/*@-readonlytrans@*/
{ NULL, '\0', POPT_ARG_INTL_DOMAIN, PACKAGE, 0, NULL, NULL},
/*@=readonlytrans@*/
{ 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 },
@@ -58,6 +80,9 @@ struct poptOption poptHelpOptions[] = {
#endif
POPT_TABLEEND
} ;
/*@observer@*/ /*@unchecked@*/
struct poptOption * poptHelpOptionsI18N = poptHelpOptions2;
/*@=castfcnptr@*/
/**
@@ -83,7 +108,7 @@ getTableTranslationDomain(/*@null@*/ const struct poptOption *table)
*/
/*@observer@*/ /*@null@*/ static const char *
getArgDescrip(const struct poptOption * opt,
/*@-paramuse@*/ /* FIX: wazzup? */
/*@-paramuse@*/ /* FIX: i18n macros disabled with lclint */
/*@null@*/ UNUSED(const char * translation_domain))
/*@=paramuse@*/
/*@*/
@@ -96,8 +121,12 @@ getArgDescrip(const struct poptOption * opt,
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_NONE: return POPT_("NONE");*/ /* impossible */
#ifdef DYING
case POPT_ARG_VAL: return POPT_("VAL");
#else
case POPT_ARG_VAL: return NULL;
#endif
case POPT_ARG_INT: return POPT_("INT");
case POPT_ARG_LONG: return POPT_("LONG");
case POPT_ARG_STRING: return POPT_("STRING");
@@ -108,61 +137,65 @@ getArgDescrip(const struct poptOption * opt,
}
/**
* Display default value for an option.
* @param lineLength display positions remaining
* @param opt option(s)
* @param translation_domain translation domain
* @return
*/
static /*@only@*/ /*@null@*/ char *
singleOptionDefaultValue(int lineLength,
singleOptionDefaultValue(size_t lineLength,
const struct poptOption * opt,
/*@-paramuse@*/ /* FIX: i18n macros disable with lclint */
/*@-paramuse@*/ /* FIX: i18n macros disabled with lclint */
/*@null@*/ UNUSED(const char * translation_domain))
/*@=paramuse@*/
/*@*/
{
const char * defstr = D_(translation_domain, "default");
char * le = malloc(4*lineLength + 1);
size_t limit, bufsize = 4*lineLength + 1;
char * le = malloc(bufsize);
char * l = le;
if (le == NULL) return NULL; /* XXX can't happen */
*le = '\0';
/*@-boundswrite@*/
*le++ = '(';
strcpy(le, defstr); le += strlen(le);
le += strlcpy(le, defstr, bufsize - 3);
*le++ = ':';
*le++ = ' ';
limit = bufsize - (le - l) - 1; /* -1 for closing paren */
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);
le += snprintf(le, limit, "%ld", aLong);
} break;
case POPT_ARG_LONG:
{ long aLong = *((long *)opt->arg);
sprintf(le, "%ld", aLong);
le += strlen(le);
le += snprintf(le, limit, "%ld", aLong);
} break;
case POPT_ARG_FLOAT:
{ double aDouble = *((float *)opt->arg);
sprintf(le, "%g", aDouble);
le += strlen(le);
le += snprintf(le, limit, "%g", aDouble);
} break;
case POPT_ARG_DOUBLE:
{ double aDouble = *((double *)opt->arg);
sprintf(le, "%g", aDouble);
le += strlen(le);
le += snprintf(le, limit, "%g", aDouble);
} break;
case POPT_ARG_STRING:
{ const char * s = *(const char **)opt->arg;
if (s == NULL) {
strcpy(le, "null"); le += strlen(le);
le += strlcpy(le, "null", limit);
} else {
size_t slen = 4*lineLength - (le - l) - sizeof("\"...\")");
size_t len;
limit -= 2; /* make room for quotes */
*le++ = '"';
strncpy(le, s, slen); le[slen] = '\0'; le += strlen(le);
if (slen < strlen(s)) {
strcpy(le, "..."); le += strlen(le);
}
len = strlcpy(le, s, limit);
if (len >= limit) {
le += limit - 3 - 1;
*le++ = '.'; *le++ = '.'; *le++ = '.';
} else
le += len;
*le++ = '"';
}
} break;
@@ -174,50 +207,57 @@ singleOptionDefaultValue(int lineLength,
}
*le++ = ')';
*le = '\0';
/*@=boundswrite@*/
return l;
}
/**
* Display help text for an option.
* @param fp output file handle
* @param maxLeftCol largest argument display width
* @param opt option(s)
* @param translation_domain translation domain
*/
static void singleOptionHelp(FILE * fp, int maxLeftCol,
static void singleOptionHelp(FILE * fp, size_t maxLeftCol,
const struct poptOption * opt,
/*@null@*/ const char * translation_domain)
/*@null@*/ UNUSED(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);
size_t indentLength = maxLeftCol + 5;
size_t lineLength = 79 - indentLength;
const 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;
size_t helpLength;
char * defs = NULL;
char * left;
size_t lelen, limit;
size_t nb = maxLeftCol + 1;
int displaypad = 0;
/* Make sure there's more than enough room in target buffer. */
if (opt->longName) nb += strlen(opt->longName);
if (argDescrip) nb += strlen(argDescrip);
/*@-boundswrite@*/
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,
snprintf(left, nb, "-%c, %s%s", opt->shortName,
((opt->argInfo & POPT_ARGFLAG_ONEDASH) ? "-" : "--"),
opt->longName);
else if (opt->shortName != '\0')
sprintf(left, "-%c", opt->shortName);
snprintf(left, nb, "-%c", opt->shortName);
else if (opt->longName)
sprintf(left, "%s%s",
snprintf(left, nb, "%s%s",
((opt->argInfo & POPT_ARGFLAG_ONEDASH) ? "-" : "--"),
opt->longName);
if (!*left) goto out;
if (argDescrip) {
char * le = left + strlen(left);
@@ -229,16 +269,10 @@ static void singleOptionHelp(FILE * fp, int maxLeftCol,
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(" "));
size_t bufsize = (help ? strlen(help) : 0) + sizeof " " + strlen(defs);
char * t = malloc(bufsize);
if (t) {
char * te = t;
*te = '\0';
if (help) {
strcpy(te, help); te += strlen(te);
}
*te++ = ' ';
strcpy(te, defs);
snprintf(t, bufsize, "%s %s", help ? help : "", defs);
defs = _free(defs);
}
defs = t;
@@ -251,6 +285,7 @@ static void singleOptionHelp(FILE * fp, int maxLeftCol,
case POPT_ARG_NONE:
break;
case POPT_ARG_VAL:
#ifdef NOTNOW /* XXX pug ugly nerdy output */
{ long aLong = opt->val;
int ops = (opt->argInfo & POPT_ARGFLAG_LOGICALOPS);
int negate = (opt->argInfo & POPT_ARGFLAG_NOT);
@@ -272,65 +307,94 @@ static void singleOptionHelp(FILE * fp, int maxLeftCol,
default:
/*@innerbreak@*/ break;
}
*le++ = '=';
*le++ = (opt->longName != NULL ? '=' : ' ');
if (negate) *le++ = '~';
/*@-formatconst@*/
sprintf(le, (ops ? "0x%lx" : "%ld"), aLong);
le += strlen(le);
limit = nb - (le - left);
lelen = snprintf(le, limit, (ops ? "0x%lx" : "%ld"), aLong);
le += lelen >= limit ? limit - 1 : lelen;
/*@=formatconst@*/
*le++ = ']';
} break;
}
#endif
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);
*le++ = (opt->longName != NULL ? '=' : ' ');
limit = nb - (le - left);
lelen = strlcpy(le, argDescrip, limit);
le += lelen >= limit ? limit - 1 : lelen;
break;
default:
break;
}
} else {
*le++ = '=';
strcpy(le, argDescrip); le += strlen(le);
limit = nb - (le - left);
lelen = strlcpy(le, argDescrip, limit);
if (lelen >= limit)
lelen = limit - 1;
le += lelen;
#ifdef POPT_WCHAR_HACK
{ const char * scopy = argDescrip;
mbstate_t t;
size_t n;
memset ((void *)&t, '\0', sizeof (t)); /* In initial state. */
/* Determine number of characters. */
n = mbsrtowcs (NULL, &scopy, strlen(scopy), &t);
displaypad = (int) (lelen-n);
}
#endif
}
if (opt->argInfo & POPT_ARGFLAG_OPTIONAL)
*le++ = ']';
*le = '\0';
}
/*@=boundswrite@*/
if (help)
fprintf(fp," %-*s ", maxLeftCol, left);
fprintf(fp," %-*s ", (int)maxLeftCol+displaypad, left);
else {
fprintf(fp," %s\n", left);
goto out;
}
left = _free(left);
/*@-branchstate@*/
if (defs) {
help = defs; defs = NULL;
help = defs;
defs = NULL;
}
/*@=branchstate@*/
helpLength = strlen(help);
/*@-boundsread@*/
while (helpLength > lineLength) {
const unsigned char * ch;
char format[10];
const char * ch;
char format[16];
ch = help + lineLength - 1;
while (ch > help && !isspace(*ch)) ch--;
while (ch > help && !isSpace(ch)) ch--;
if (ch == help) break; /* give up */
while (ch > (help + 1) && isspace(*ch)) ch--;
while (ch > (help + 1) && isSpace(ch)) ch--;
ch++;
sprintf(format, "%%.%ds\n%%%ds", (int) (ch - help), indentLength);
snprintf(format, sizeof format, "%%.%ds\n%%%ds", (int) (ch - help), (int) indentLength);
/*@-formatconst@*/
fprintf(fp, format, help, " ");
/*@=formatconst@*/
help = ch;
while (isspace(*help) && *help) help++;
while (isSpace(help) && *help) help++;
helpLength = strlen(help);
}
/*@=boundsread@*/
if (helpLength) fprintf(fp, "%s\n", help);
@@ -342,15 +406,17 @@ out:
}
/**
* Find display width for longest argument string.
* @param opt option(s)
* @param translation_domain translation domain
* @return display width
*/
static int maxArgWidth(const struct poptOption * opt,
/*@null@*/ const char * translation_domain)
static size_t maxArgWidth(const struct poptOption * opt,
/*@null@*/ UNUSED(const char * translation_domain))
/*@*/
{
int max = 0;
int len = 0;
size_t max = 0;
size_t len = 0;
const char * s;
if (opt != NULL)
@@ -370,8 +436,26 @@ static int maxArgWidth(const struct poptOption * opt,
}
s = getArgDescrip(opt, translation_domain);
#ifdef POPT_WCHAR_HACK
/* XXX Calculate no. of display characters. */
if (s) {
const char * scopy = s;
mbstate_t t;
size_t n;
/*@-boundswrite@*/
memset ((void *)&t, '\0', sizeof (t)); /* In initial state. */
/*@=boundswrite@*/
/* Determine number of characters. */
n = mbsrtowcs (NULL, &scopy, strlen(scopy), &t);
len += sizeof("=")-1 + n;
}
#else
if (s)
len += sizeof("=")-1 + strlen(s);
#endif
if (opt->argInfo & POPT_ARGFLAG_OPTIONAL) len += sizeof("[]")-1;
if (len > max) max = len;
}
@@ -387,11 +471,12 @@ static int maxArgWidth(const struct poptOption * opt,
* @param fp output file handle
* @param items alias/exec array
* @param nitems no. of alias/exec entries
* @param left largest argument display width
* @param translation_domain translation domain
*/
static void itemHelp(FILE * fp,
/*@null@*/ poptItem items, int nitems, int left,
/*@null@*/ const char * translation_domain)
/*@null@*/ poptItem items, int nitems, size_t left,
/*@null@*/ UNUSED(const char * translation_domain))
/*@globals fileSystem @*/
/*@modifies *fp, fileSystem @*/
{
@@ -409,13 +494,16 @@ static void itemHelp(FILE * fp,
}
/**
* Display help text for a table of options.
* @param con context
* @param fp output file handle
* @param table option(s)
* @param left largest argument display width
* @param translation_domain translation domain
*/
static void singleTableHelp(poptContext con, FILE * fp,
/*@null@*/ const struct poptOption * table, int left,
/*@null@*/ const char * translation_domain)
/*@null@*/ const struct poptOption * table, size_t left,
/*@null@*/ UNUSED(const char * translation_domain))
/*@globals fileSystem @*/
/*@modifies *fp, fileSystem @*/
{
@@ -463,9 +551,11 @@ static int showHelpIntro(poptContext con, FILE * fp)
fprintf(fp, POPT_("Usage:"));
if (!(con->flags & POPT_CONTEXT_KEEP_FIRST)) {
/*@-nullderef@*/ /* LCL: wazzup? */
/*@-boundsread@*/
/*@-nullderef -type@*/ /* LCL: wazzup? */
fn = con->optionStack->argv[0];
/*@=nullderef@*/
/*@=nullderef =type@*/
/*@=boundsread@*/
if (fn == NULL) return len;
if (strchr(fn, '/')) fn = strrchr(fn, '/') + 1;
fprintf(fp, " %s", fn);
@@ -477,7 +567,7 @@ static int showHelpIntro(poptContext con, FILE * fp)
void poptPrintHelp(poptContext con, FILE * fp, /*@unused@*/ UNUSED(int flags))
{
int leftColWidth;
size_t leftColWidth;
(void) showHelpIntro(con, fp);
if (con->otherHelp)
@@ -490,47 +580,76 @@ void poptPrintHelp(poptContext con, FILE * fp, /*@unused@*/ UNUSED(int flags))
}
/**
* Display usage text for an option.
* @param fp output file handle
* @param cursor current display position
* @param opt option(s)
* @param translation_domain translation domain
*/
static int singleOptionUsage(FILE * fp, int cursor,
static size_t singleOptionUsage(FILE * fp, size_t cursor,
const struct poptOption * opt,
/*@null@*/ const char *translation_domain)
/*@globals fileSystem @*/
/*@modifies *fp, fileSystem @*/
{
int len = 3;
size_t len = 4;
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 */
if (opt->shortName != '\0' && opt->longName != NULL) {
len += 2;
if (!(opt->argInfo & POPT_ARGFLAG_ONEDASH)) len++;
len += strlen(opt->longName);
} else if (opt->shortName != '\0') {
len++;
shortStr[0] = opt->shortName;
shortStr[1] = '\0';
} else if (opt->longName) {
len += 1 + strlen(opt->longName);
len += strlen(opt->longName);
if (!(opt->argInfo & POPT_ARGFLAG_ONEDASH)) len++;
item = opt->longName;
}
if (len == 3) return cursor;
if (len == 4) return cursor;
#ifdef POPT_WCHAR_HACK
/* XXX Calculate no. of display characters. */
if (argDescrip) {
const char * scopy = argDescrip;
mbstate_t t;
size_t n;
/*@-boundswrite@*/
memset ((void *)&t, '\0', sizeof (t)); /* In initial state. */
/*@=boundswrite@*/
/* Determine number of characters. */
n = mbsrtowcs (NULL, &scopy, strlen(scopy), &t);
len += sizeof("=")-1 + n;
}
#else
if (argDescrip)
len += strlen(argDescrip) + 1;
len += sizeof("=")-1 + strlen(argDescrip);
#endif
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 : ""));
if (opt->longName && opt->shortName) {
fprintf(fp, " [-%c|-%s%s%s%s]",
opt->shortName, ((opt->argInfo & POPT_ARGFLAG_ONEDASH) ? "" : "-"),
opt->longName,
(argDescrip ? " " : ""),
(argDescrip ? argDescrip : ""));
} else {
fprintf(fp, " [-%s%s%s%s]",
((opt->shortName || (opt->argInfo & POPT_ARGFLAG_ONEDASH)) ? "" : "-"),
item,
(argDescrip ? (opt->shortName != '\0' ? " " : "=") : ""),
(argDescrip ? argDescrip : ""));
}
return cursor + len + 1;
}
@@ -538,12 +657,14 @@ static int singleOptionUsage(FILE * fp, int cursor,
/**
* Display popt alias and exec usage.
* @param fp output file handle
* @param cursor current display position
* @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)
static size_t itemUsage(FILE * fp, size_t cursor,
/*@null@*/ poptItem item, int nitems,
/*@null@*/ UNUSED(const char * translation_domain))
/*@globals fileSystem @*/
/*@modifies *fp, fileSystem @*/
{
@@ -567,15 +688,30 @@ static int itemUsage(FILE * fp, int cursor, poptItem item, int nitems,
}
/**
* Keep track of option tables already processed.
*/
typedef struct poptDone_s {
int nopts;
int maxopts;
const void ** opts;
} * poptDone;
/**
* Display usage text for a table of options.
* @param con context
* @param fp output file handle
* @param cursor current display position
* @param opt option(s)
* @param translation_domain translation domain
* @param done tables already processed
* @return
*/
static int singleTableUsage(poptContext con, FILE * fp,
int cursor, const struct poptOption * opt,
/*@null@*/ const char * translation_domain)
static size_t singleTableUsage(poptContext con, FILE * fp, size_t cursor,
/*@null@*/ const struct poptOption * opt,
/*@null@*/ UNUSED(const char * translation_domain),
/*@null@*/ poptDone done)
/*@globals fileSystem @*/
/*@modifies *fp, fileSystem @*/
/*@modifies *fp, done, fileSystem @*/
{
/*@-branchstate@*/ /* FIX: W2DO? */
if (opt != NULL)
@@ -583,9 +719,26 @@ static int singleTableUsage(poptContext con, FILE * fp,
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 */
if (done) {
int i = 0;
for (i = 0; i < done->nopts; i++) {
/*@-boundsread@*/
const void * that = done->opts[i];
/*@=boundsread@*/
if (that == NULL || that != opt->arg)
/*@innercontinue@*/ continue;
/*@innerbreak@*/ break;
}
/* Skip if this table has already been processed. */
if (opt->arg == NULL || i < done->nopts)
continue;
/*@-boundswrite@*/
if (done->nopts < done->maxopts)
done->opts[done->nopts++] = (const void *) opt->arg;
/*@=boundswrite@*/
}
cursor = singleTableUsage(con, fp, cursor, opt->arg,
translation_domain);
translation_domain, done);
} else if ((opt->longName || opt->shortName) &&
!(opt->argInfo & POPT_ARGFLAG_DOC_HIDDEN)) {
cursor = singleOptionUsage(fp, cursor, opt, translation_domain);
@@ -598,6 +751,7 @@ static int singleTableUsage(poptContext con, FILE * fp,
/**
* Return concatenated short options for display.
* @todo Sub-tables should be recursed.
* @param opt option(s)
* @param fp output file handle
* @retval str concatenation of short options
@@ -607,42 +761,54 @@ static int showShortOptions(const struct poptOption * opt, FILE * fp,
/*@null@*/ char * str)
/*@globals fileSystem @*/
/*@modifies *str, *fp, fileSystem @*/
/*@requires maxRead(str) >= 0 @*/
{
char * s = alloca(300); /* larger then the ascii set */
/* bufsize larger then the ascii set, lazy alloca on top level call. */
char * s = (str != NULL ? str : memset(alloca(300), 0, 300));
int len = 0;
s[0] = '\0';
/*@-branchstate@*/ /* FIX: W2DO? */
if (str == NULL) {
memset(s, 0, sizeof(s));
str = s;
}
/*@=branchstate@*/
if (s == NULL)
return 0;
/*@-boundswrite@*/
if (opt != NULL)
for (; (opt->longName || opt->shortName || opt->arg); opt++) {
if (opt->shortName && !(opt->argInfo & POPT_ARG_MASK))
str[strlen(str)] = opt->shortName;
s[strlen(s)] = 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);
len = showShortOptions(opt->arg, fp, s);
}
/*@=boundswrite@*/
if (s != str || *s != '\0')
return 0;
fprintf(fp, " [-%s]", s);
return strlen(s) + 4;
/* On return to top level, print the short options, return print length. */
if (s == str && *s != '\0') {
fprintf(fp, " [-%s]", s);
len = strlen(s) + sizeof(" [-]")-1;
}
return len;
}
void poptPrintUsage(poptContext con, FILE * fp, /*@unused@*/ UNUSED(int flags))
{
int cursor;
poptDone done = memset(alloca(sizeof(*done)), 0, sizeof(*done));
size_t cursor;
done->nopts = 0;
done->maxopts = 64;
cursor = done->maxopts * sizeof(*done->opts);
/*@-boundswrite@*/
done->opts = memset(alloca(cursor), 0, cursor);
/*@-keeptrans@*/
done->opts[done->nopts++] = (const void *) con->options;
/*@=keeptrans@*/
/*@=boundswrite@*/
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);
cursor = singleTableUsage(con, fp, cursor, con->options, NULL, done);
cursor = itemUsage(fp, cursor, con->aliases, con->numAliases, NULL);
cursor = itemUsage(fp, cursor, con->execs, con->numExecs, NULL);
if (con->otherHelp) {
cursor += strlen(con->otherHelp) + 1;
@@ -658,4 +824,3 @@ void poptSetOtherOptionHelp(poptContext con, const char * text)
con->otherHelp = _free(con->otherHelp);
con->otherHelp = xstrdup(text);
}
/*@=type@*/

View File

@@ -22,14 +22,24 @@ _free(/*@only@*/ /*@null@*/ const void * p)
return NULL;
}
static inline int
isSpace(const char *ptr)
{
return isspace(*(unsigned char *)ptr);
}
/* Bit mask macros. */
/*@-exporttype -redef @*/
typedef unsigned int __pbm_bits;
/*@=exporttype =redef @*/
#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))
/*@-exporttype -redef @*/
typedef struct {
__pbm_bits bits[1];
} pbm_set;
/*@=exporttype =redef @*/
#define __PBM_BITS(set) ((set)->bits)
#define PBM_ALLOC(d) calloc(__PBM_IX (d) + 1, sizeof(__pbm_bits))
@@ -40,37 +50,53 @@ typedef struct {
struct optionStackEntry {
int argc;
/*@only@*/ /*@null@*/ const char ** argv;
/*@only@*/ /*@null@*/ pbm_set * argb;
/*@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;
/*@only@*/ /*@null@*/
const char * nextArg;
/*@observer@*/ /*@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;
/*@dependent@*/
struct optionStackEntry * os;
/*@owned@*/ /*@null@*/
const char ** leftovers;
int numLeftovers;
int nextLeftover;
/*@keep@*/ const struct poptOption * options;
/*@keep@*/
const struct poptOption * options;
int restLeftover;
/*@only@*/ /*@null@*/ const char * appName;
/*@only@*/ /*@null@*/ poptItem aliases;
/*@only@*/ /*@null@*/
const char * appName;
/*@only@*/ /*@null@*/
poptItem aliases;
int numAliases;
int flags;
/*@owned@*/ /*@null@*/ poptItem execs;
/*@owned@*/ /*@null@*/
poptItem execs;
int numExecs;
/*@only@*/ /*@null@*/ const char ** finalArgv;
/*@only@*/ /*@null@*/
const char ** finalArgv;
int finalArgvCount;
int finalArgvAlloced;
/*@dependent@*/ /*@null@*/ poptItem doExec;
/*@only@*/ const char * execPath;
/*@dependent@*/ /*@null@*/
poptItem doExec;
/*@only@*/
const char * execPath;
int execAbsolute;
/*@only@*/ const char * otherHelp;
/*@null@*/ pbm_set * arg_strip;
/*@only@*/ /*@relnull@*/
const char * otherHelp;
/*@null@*/
pbm_set * arg_strip;
};
#ifdef HAVE_LIBINTL_H
@@ -83,7 +109,7 @@ struct poptContext_s {
#define _(foo) foo
#endif
#if defined(HAVE_DGETTEXT) && !defined(__LCLINT__)
#if defined(HAVE_DCGETTEXT) && !defined(__LCLINT__)
#define D_(dom, str) dgettext(dom, str)
#define POPT_(foo) D_("popt", foo)
#else

View File

@@ -2,14 +2,17 @@
* \file popt/poptparse.c
*/
/* (C) 1998-2000 Red Hat, Inc. -- Licensing details are in the COPYING
/* (C) 1998-2002 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"
#define POPT_ARGV_ARRAY_GROW_DELTA 5
/*@-boundswrite@*/
int poptDupArgv(int argc, const char **argv,
int * argcPtr, const char *** argvPtr)
{
@@ -35,7 +38,7 @@ int poptDupArgv(int argc, const char **argv,
/*@-branchstate@*/
for (i = 0; i < argc; i++) {
argv2[i] = dst;
dst += strlen(strcpy(dst, argv[i])) + 1;
dst += strlcpy(dst, argv[i], nb) + 1;
}
/*@=branchstate@*/
argv2[argc] = NULL;
@@ -50,11 +53,13 @@ int poptDupArgv(int argc, const char **argv,
*argcPtr = argc;
return 0;
}
/*@=boundswrite@*/
int poptParseArgvString(const unsigned char * s, int * argcPtr, const char *** argvPtr)
/*@-bounds@*/
int poptParseArgvString(const char * s, int * argcPtr, const char *** argvPtr)
{
const unsigned char * src;
unsigned char quote = '\0';
const char * src;
char quote = '\0';
int argvAlloced = POPT_ARGV_ARRAY_GROW_DELTA;
const char ** argv = malloc(sizeof(*argv) * argvAlloced);
int argc = 0;
@@ -78,7 +83,7 @@ int poptParseArgvString(const unsigned char * s, int * argcPtr, const char *** a
if (*src != quote) *buf++ = '\\';
}
*buf++ = *src;
} else if (isspace(*src)) {
} else if (isSpace(src)) {
if (*argv[argc] != '\0') {
buf++, argc++;
if (argc == argvAlloced) {
@@ -116,3 +121,111 @@ exit:
if (argv) free(argv);
return rc;
}
/*@=bounds@*/
/* still in the dev stage.
* return values, perhaps 1== file erro
* 2== line to long
* 3== umm.... more?
*/
int poptConfigFileToString(FILE *fp, char ** argstrp, /*@unused@*/ UNUSED(int flags))
{
char line[999];
char * argstr;
char * p;
char * q;
char * x;
int t;
int argvlen = 0;
size_t maxlinelen = sizeof(line);
size_t linelen;
int maxargvlen = 480;
int linenum = 0;
*argstrp = NULL;
/* | this_is = our_line
* p q x
*/
if (fp == NULL)
return POPT_ERROR_NULLARG;
argstr = calloc(maxargvlen, sizeof(*argstr));
if (argstr == NULL) return POPT_ERROR_MALLOC;
while (fgets(line, (int)maxlinelen, fp) != NULL) {
linenum++;
p = line;
/* loop until first non-space char or EOL */
while( *p != '\0' && isSpace(p) )
p++;
linelen = strlen(p);
if (linelen >= maxlinelen-1) {
free(argstr);
return POPT_ERROR_OVERFLOW; /* XXX line too long */
}
if (*p == '\0' || *p == '\n') continue; /* line is empty */
if (*p == '#') continue; /* comment line */
q = p;
while (*q != '\0' && (!isSpace(q)) && *q != '=')
q++;
if (isSpace(q)) {
/* a space after the name, find next non space */
*q++='\0';
while( *q != '\0' && isSpace(q) ) q++;
}
if (*q == '\0') {
/* single command line option (ie, no name=val, just name) */
q[-1] = '\0'; /* kill off newline from fgets() call */
argvlen += (t = q - p) + (sizeof(" --")-1);
if (argvlen >= maxargvlen) {
maxargvlen = (t > maxargvlen) ? t*2 : maxargvlen*2;
argstr = realloc(argstr, maxargvlen);
if (argstr == NULL) return POPT_ERROR_MALLOC;
}
strlcat(argstr, " --", maxargvlen);
strlcat(argstr, p, maxargvlen);
continue;
}
if (*q != '=')
continue; /* XXX for now, silently ignore bogus line */
/* *q is an equal sign. */
*q++ = '\0';
/* find next non-space letter of value */
while (*q != '\0' && isSpace(q))
q++;
if (*q == '\0')
continue; /* XXX silently ignore missing value */
/* now, loop and strip all ending whitespace */
x = p + linelen;
while (isSpace(--x))
*x = 0; /* null out last char if space (including fgets() NL) */
/* rest of line accept */
t = x - p;
argvlen += t + (sizeof("' --='")-1);
if (argvlen >= maxargvlen) {
maxargvlen = (t > maxargvlen) ? t*2 : maxargvlen*2;
argstr = realloc(argstr, maxargvlen);
if (argstr == NULL) return POPT_ERROR_MALLOC;
}
strlcat(argstr, " --", maxargvlen);
strlcat(argstr, p, maxargvlen);
strlcat(argstr, "=\"", maxargvlen);
strlcat(argstr, q, maxargvlen);
strlcat(argstr, "\"", maxargvlen);
}
*argstrp = argstr;
return 0;
}

View File

@@ -2,7 +2,17 @@
#include "config.h"
#endif
#if defined (__GLIBC__) && defined(__LCLINT__)
/*@-declundef@*/
/*@unchecked@*/
extern __const __int32_t *__ctype_tolower;
/*@unchecked@*/
extern __const __int32_t *__ctype_toupper;
/*@=declundef@*/
#endif
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
@@ -12,19 +22,32 @@
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.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
#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> */
#ifndef __GNUC__
#define __attribute__(x)
#endif
#ifdef __NeXT
@@ -34,11 +57,12 @@
#endif
#if defined(__LCLINT__)
/*@-declundef -incondefs -redecl@*/ /* LCL: missing annotation */
/*@only@*/ void * alloca (size_t __size)
/*@-declundef -incondefs @*/ /* LCL: missing annotation */
/*@only@*/ /*@out@*/
void * alloca (size_t __size)
/*@ensures MaxSet(result) == (__size - 1) @*/
/*@*/;
/*@=declundef =incondefs =redecl@*/
/*@=declundef =incondefs @*/
#endif
/* AIX requires this to be the first thing in the file. */
@@ -49,9 +73,9 @@
# ifdef _AIX
#pragma alloca
# else
# if HAVE_ALLOCA
# ifdef HAVE_ALLOCA
# ifndef alloca /* predefined by HP cc +Olibcalls */
char *alloca ();
char *alloca(size_t size);
# endif
# else
# ifdef alloca
@@ -65,18 +89,42 @@ char *alloca ();
#define alloca __builtin_alloca
#endif
/*@-redecl -redef@*/
/*@mayexit@*/ /*@only@*/ char * xstrdup (const char *str)
/*@*/;
/*@=redecl =redef@*/
#ifndef HAVE_STRLCPY
size_t strlcpy(char *d, const char *s, size_t bufsize);
#endif
#ifndef HAVE_STRLCAT
size_t strlcat(char *d, const char *s, size_t bufsize);
#endif
#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)))
static inline char *
xstrdup(const char *s)
{
size_t memsize = strlen(s) + 1;
char *ptr = malloc(memsize);
if (!ptr) {
fprintf(stderr, "virtual memory exhausted.\n");
exit(EXIT_FAILURE);
}
strlcpy(ptr, s, memsize);
return ptr;
}
#else
#define xstrdup(_str) strdup(_str)
#endif /* HAVE_MCHECK_H && defined(__GNUC__) */
#if HAVE___SECURE_GETENV && !defined(__LCLINT__)
#define getenv(_s) __secure_getenv(_s)
#endif
#if !defined HAVE_SNPRINTF || !defined HAVE_C99_VSNPRINTF
#define snprintf rsync_snprintf
int snprintf(char *str,size_t count,const char *fmt,...);
#endif
#define UNUSED(x) x __attribute__((__unused__))
#define PACKAGE "rsync"
#include "popt.h"

51
prepare-source Executable file
View File

@@ -0,0 +1,51 @@
#!/bin/sh
# Either use autoconf and autoheader to create configure.sh and config.h.in
# or (optionally) fetch the latest development versions of generated files.
#
# Specify one action or more than one to provide a fall-back:
#
# build build the config files [the default w/no arg]
# fetch fetch the latest dev config files
# fetchgen fetch all the latest dev generated files
# fetchSRC fetch the latest dev source files [NON-GENERATED FILES]
#
# The script stops after the first successful action.
dir=`dirname $0`
if test x"$dir" != x -a x"$dir" != x.; then
cd "$dir"
fi
if test $# = 0; then
set -- build
fi
for action in "${@}"; do
case "$action" in
build|make)
make -f prepare-source.mak
;;
fetch)
if perl --version >/dev/null 2>/dev/null; then
files='c*'
else
files='[cp]*'
fi
rsync -pvz rsync://rsync.samba.org/rsyncftp/generated-files/"$files" .
;;
fetchgen)
rsync -pvz rsync://rsync.samba.org/rsyncftp/generated-files/'*' .
;;
fetchSRC)
rsync -pvrz --exclude=/.git/ rsync://rsync.samba.org/ftp/pub/unpacked/rsync/ .
;;
*)
echo "Unknown action: $action"
exit 1
esac
if test $? = 0; then
exit
fi
done
exit 1

7
prepare-source.mak Normal file
View File

@@ -0,0 +1,7 @@
conf: configure.sh config.h.in
configure.sh: configure.in aclocal.m4
autoconf -o configure.sh
config.h.in: configure.in aclocal.m4
autoheader && touch config.h.in

View File

@@ -1,12 +1,14 @@
/* -*- c-file-style: "linux" -*-
/*
* Routines to output progress information during a file transfer.
*
* Copyright (C) 1996-2000 by Andrew Tridgell
* Copyright (C) Paul Mackerras 1996
* Copyright (C) 2001, 2002 by Martin Pool <mbp@samba.org>
* Copyright (C) 1996-2000 Andrew Tridgell
* Copyright (C) 1996 Paul Mackerras
* Copyright (C) 2001, 2002 Martin Pool <mbp@samba.org>
* Copyright (C) 2003-2008 Wayne Davison
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
@@ -14,15 +16,16 @@
* 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.
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
#include "rsync.h"
extern struct stats stats;
extern int am_server;
extern int need_unsorted_flist;
extern struct stats stats;
extern struct file_list *cur_flist;
#define PROGRESS_HISTORY_SECS 5
@@ -40,6 +43,7 @@ struct progress_history {
static struct progress_history ph_start;
static struct progress_history ph_list[PROGRESS_HISTORY_SECS];
static int newest_hpos, oldest_hpos;
static int current_file_index;
static unsigned long msdiff(struct timeval *t1, struct timeval *t2)
{
@@ -58,26 +62,26 @@ static unsigned long msdiff(struct timeval *t1, struct timeval *t2)
static void rprint_progress(OFF_T ofs, OFF_T size, struct timeval *now,
int is_last)
{
char eol[256];
char rembuf[64], eol[128];
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. */
diff = msdiff(&ph_start.time, now);
if (!diff)
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. */
diff = msdiff(&ph_list[oldest_hpos].time, now);
rate = diff ? (double) (ofs - ph_list[oldest_hpos].ofs) * 1000.0
/ diff / 1024.0 : 0;
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;
}
@@ -91,21 +95,33 @@ static void rprint_progress(OFF_T ofs, OFF_T size, struct timeval *now,
units = "kB/s";
}
remain_s = (int) remain % 60;
remain_m = (int) (remain / 60.0) % 60;
remain_h = (int) (remain / 3600.0);
if (remain < 0)
strlcpy(rembuf, " ??:??:??", sizeof rembuf);
else {
snprintf(rembuf, sizeof rembuf, "%4d:%02d:%02d",
(int) (remain / 3600.0),
(int) (remain / 60.0) % 60,
(int) remain % 60);
}
if (is_last) {
snprintf(eol, sizeof eol, " (%d, %.1f%% of %d)\n",
snprintf(eol, sizeof eol, " (xfer#%d, to-check=%d/%d)\n",
stats.num_transferred_files,
(float)((stats.current_file_index+1) * 100)
/ stats.num_files,
stats.num_files - current_file_index - 1,
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);
strlcpy(eol, "\r", sizeof eol);
rprintf(FCLIENT, "%12s %3d%% %7.2f%s %s%s",
human_num(ofs), pct, rate, units, rembuf, eol);
}
void set_current_file_index(struct file_struct *file, int ndx)
{
if (need_unsorted_flist)
current_file_index = flist_find(cur_flist, file) + cur_flist->ndx_start;
else
current_file_index = ndx;
current_file_index -= cur_flist->flist_num;
}
void end_progress(OFF_T size)

View File

File diff suppressed because it is too large Load Diff

38
rounding.c Normal file
View File

@@ -0,0 +1,38 @@
/*
* A pre-compilation helper program to aid in the creation of rounding.h.
*
* Copyright (C) 2007-2008 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
#include "rsync.h"
#define ARRAY_LEN (EXTRA_ROUNDING+1)
#define SIZEOF(x) ((long int)sizeof (x))
struct test {
union file_extras extras[ARRAY_LEN];
struct file_struct file;
};
#define ACTUAL_SIZE SIZEOF(struct test)
#define EXPECTED_SIZE (SIZEOF(union file_extras) * ARRAY_LEN + SIZEOF(struct file_struct))
int main(UNUSED(int argc), UNUSED(char *argv[]))
{
static int test_array[1 - 2 * (ACTUAL_SIZE != EXPECTED_SIZE)];
test_array[0] = 0;
return 0;
}

637
rsync.c
View File

@@ -1,44 +1,342 @@
/*
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.
*/
/* this file contains code used by more than one part of the rsync
process */
* Routines common to more than one of the rsync processes.
*
* Copyright (C) 1996 Andrew Tridgell
* Copyright (C) 1996 Paul Mackerras
* Copyright (C) 2003-2008 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
#include "rsync.h"
#include "ifuncs.h"
#if defined HAVE_LIBCHARSET_H && defined HAVE_LOCALE_CHARSET
#include <libcharset.h>
#elif defined HAVE_LANGINFO_H && defined HAVE_NL_LANGINFO
#include <langinfo.h>
#endif
extern int verbose;
extern int dry_run;
extern int daemon_log_format_has_i;
extern int preserve_acls;
extern int preserve_xattrs;
extern int preserve_perms;
extern int preserve_executability;
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 preserve_uid;
extern int preserve_gid;
extern int am_starting_up;
extern int allow_8bit_chars;
extern int protocol_version;
extern int uid_ndx;
extern int gid_ndx;
extern int inc_recurse;
extern int inplace;
extern int recurse;
extern int flist_eof;
extern int keep_dirlinks;
extern int make_backups;
extern struct stats stats;
extern struct file_list *cur_flist, *first_flist, *dir_flist;
extern struct chmod_mode_struct *daemon_chmod_modes;
#ifdef ICONV_OPTION
extern char *iconv_opt;
#endif
#ifdef ICONV_CONST
iconv_t ic_chck = (iconv_t)-1;
# ifdef ICONV_OPTION
iconv_t ic_send = (iconv_t)-1, ic_recv = (iconv_t)-1;
# endif
static const char *default_charset(void)
{
# if defined HAVE_LIBCHARSET_H && defined HAVE_LOCALE_CHARSET
return locale_charset();
# elif defined HAVE_LANGINFO_H && defined HAVE_NL_LANGINFO
return nl_langinfo(CODESET);
# else
return ""; /* Works with (at the very least) gnu iconv... */
# endif
}
void setup_iconv(void)
{
const char *defset = default_charset();
# ifdef ICONV_OPTION
const char *charset;
char *cp;
# endif
if (!am_server && !allow_8bit_chars) {
/* It's OK if this fails... */
ic_chck = iconv_open(defset, defset);
if (verbose > 3) {
if (ic_chck == (iconv_t)-1) {
rprintf(FINFO,
"note: iconv_open(\"%s\", \"%s\") failed (%d)"
" -- using isprint() instead of iconv().\n",
defset, defset, errno);
} else {
rprintf(FINFO,
"note: iconv_open(\"%s\", \"%s\") succeeded.\n",
defset, defset);
}
}
}
# ifdef ICONV_OPTION
if (!iconv_opt)
return;
if ((cp = strchr(iconv_opt, ',')) != NULL) {
if (am_server) /* A local transfer needs this. */
iconv_opt = cp + 1;
else
*cp = '\0';
}
if (!*iconv_opt || (*iconv_opt == '.' && iconv_opt[1] == '\0'))
charset = defset;
else
charset = iconv_opt;
if ((ic_send = iconv_open(UTF8_CHARSET, charset)) == (iconv_t)-1) {
rprintf(FERROR, "iconv_open(\"%s\", \"%s\") failed\n",
UTF8_CHARSET, charset);
exit_cleanup(RERR_UNSUPPORTED);
}
if ((ic_recv = iconv_open(charset, UTF8_CHARSET)) == (iconv_t)-1) {
rprintf(FERROR, "iconv_open(\"%s\", \"%s\") failed\n",
charset, UTF8_CHARSET);
exit_cleanup(RERR_UNSUPPORTED);
}
if (verbose > 1) {
rprintf(FINFO, "%s charset: %s\n",
am_server ? "server" : "client",
*charset ? charset : "[LOCALE]");
}
# endif
}
/* This function converts the characters in the "in" xbuf into characters
* in the "out" xbuf. The "len" of the "in" xbuf is used starting from its
* "pos". The "size" of the "out" xbuf restricts how many characters can be
* stored, starting at its "pos+len" position. Note that the last byte of
* the buffer is never used, which reserves space for a terminating '\0'.
* We return a 0 on success or a -1 on error. An error also sets errno to
* E2BIG, EILSEQ, or EINVAL (see below); otherwise errno will be set to 0.
* The "in" xbuf is altered to update "pos" and "len". The "out" xbuf has
* data appended, and its "len" incremented. If ICB_EXPAND_OUT is set in
* "flags", the "out" xbuf will also be allocated if empty, and expanded if
* too small (so E2BIG will not be returned). If ICB_INCLUDE_BAD is set in
* "flags", any badly-encoded chars are included verbatim in the "out" xbuf,
* so EILSEQ will not be returned. Likewise for ICB_INCLUDE_INCOMPLETE with
* respect to an incomplete multi-byte char at the end, which ensures that
* EINVAL is not returned. Anytime "in.pos" is 0 we will reset the iconv()
* state prior to processing the characters. */
int iconvbufs(iconv_t ic, xbuf *in, xbuf *out, int flags)
{
ICONV_CONST char *ibuf;
size_t icnt, ocnt;
char *obuf;
if (!out->size && flags & ICB_EXPAND_OUT)
alloc_xbuf(out, 1024);
if (!in->pos)
iconv(ic, NULL, 0, NULL, 0);
ibuf = in->buf + in->pos;
icnt = in->len;
obuf = out->buf + (out->pos + out->len);
ocnt = out->size - (out->pos + out->len) - 1;
while (icnt) {
while (iconv(ic, &ibuf, &icnt, &obuf, &ocnt) == (size_t)-1) {
if (errno == EINTR)
continue;
if (errno == EINVAL) {
if (!(flags & ICB_INCLUDE_INCOMPLETE))
goto finish;
} else if (errno == EILSEQ) {
if (!(flags & ICB_INCLUDE_BAD))
goto finish;
} else {
size_t opos = obuf - out->buf;
if (!(flags & ICB_EXPAND_OUT)) {
errno = E2BIG;
goto finish;
}
realloc_xbuf(out, out->size + 1024);
obuf = out->buf + opos;
ocnt += 1024;
continue;
}
*obuf++ = *ibuf++;
ocnt--, icnt--;
}
}
errno = 0;
finish:
in->len = icnt;
in->pos = ibuf - in->buf;
out->len = obuf - out->buf - out->pos;
return errno ? -1 : 0;
}
#endif
void send_protected_args(int fd, char *args[])
{
int i;
#ifdef ICONV_OPTION
int convert = ic_send != (iconv_t)-1;
xbuf outbuf, inbuf;
if (convert)
alloc_xbuf(&outbuf, 1024);
#endif
for (i = 0; args[i]; i++) {} /* find first NULL */
args[i] = "rsync"; /* set a new arg0 */
if (verbose > 1)
print_child_argv("protected args:", args + i + 1);
do {
#ifdef ICONV_OPTION
if (convert) {
INIT_XBUF_STRLEN(inbuf, args[i]);
iconvbufs(ic_send, &inbuf, &outbuf,
ICB_EXPAND_OUT | ICB_INCLUDE_BAD | ICB_INCLUDE_INCOMPLETE);
outbuf.buf[outbuf.len] = '\0';
write_buf(fd, outbuf.buf, outbuf.len + 1);
outbuf.len = 0;
} else
#endif
write_buf(fd, args[i], strlen(args[i]) + 1);
} while (args[++i]);
write_byte(fd, 0);
#ifdef ICONV_OPTION
if (convert)
free(outbuf.buf);
#endif
}
int read_ndx_and_attrs(int f_in, int *iflag_ptr, uchar *type_ptr,
char *buf, int *len_ptr)
{
int len, iflags = 0;
struct file_list *flist;
uchar fnamecmp_type = FNAMECMP_FNAME;
int ndx, save_verbose = verbose;
read_loop:
while (1) {
ndx = read_ndx(f_in);
if (ndx >= 0)
break;
if (ndx == NDX_DONE)
return ndx;
if (!inc_recurse || am_sender)
goto invalid_ndx;
if (ndx == NDX_FLIST_EOF) {
flist_eof = 1;
send_msg(MSG_FLIST_EOF, "", 0, 0);
continue;
}
ndx = NDX_FLIST_OFFSET - ndx;
if (ndx < 0 || ndx >= dir_flist->used) {
ndx = NDX_FLIST_OFFSET - ndx;
rprintf(FERROR,
"[%s] Invalid dir index: %d (%d - %d)\n",
who_am_i(), ndx, NDX_FLIST_OFFSET,
NDX_FLIST_OFFSET - dir_flist->used + 1);
exit_cleanup(RERR_PROTOCOL);
}
/* Send everything read from f_in to msg_fd_out. */
if (verbose > 3) {
rprintf(FINFO, "[%s] receiving flist for dir %d\n",
who_am_i(), ndx);
}
verbose = 0;
send_msg_int(MSG_FLIST, ndx);
start_flist_forward(f_in);
flist = recv_file_list(f_in);
flist->parent_ndx = ndx;
stop_flist_forward();
verbose = save_verbose;
}
iflags = protocol_version >= 29 ? read_shortint(f_in)
: ITEM_TRANSFER | ITEM_MISSING_DATA;
/* Honor the old-style keep-alive indicator. */
if (protocol_version < 30
&& ndx == cur_flist->used && iflags == ITEM_IS_NEW) {
if (am_sender)
maybe_send_keepalive();
goto read_loop;
}
if (!(flist = flist_for_ndx(ndx))) {
int start, used;
invalid_ndx:
start = first_flist ? first_flist->ndx_start : 0;
used = first_flist ? first_flist->used : 0;
rprintf(FERROR,
"Invalid file index: %d (%d - %d) with iflags %x [%s]\n",
ndx, start - 1, start + used -1, iflags, who_am_i());
exit_cleanup(RERR_PROTOCOL);
}
cur_flist = flist;
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) {
int i = ndx - cur_flist->ndx_start;
if (i < 0 || !S_ISREG(cur_flist->files[i]->mode)) {
rprintf(FERROR,
"received request to transfer non-regular file: %d [%s]\n",
ndx, who_am_i());
exit_cleanup(RERR_PROTOCOL);
}
}
*iflag_ptr = iflags;
return ndx;
}
/*
free a sums struct
@@ -49,107 +347,187 @@ void free_sums(struct sum_struct *s)
free(s);
}
/* This is only called when we aren't preserving permissions. Figure out what
* the permissions should be and return them merged back into the mode. */
mode_t dest_mode(mode_t flist_mode, mode_t stat_mode, int dflt_perms,
int exists)
{
int new_mode;
/* If the file already exists, we'll return the local permissions,
* possibly tweaked by the --executability option. */
if (exists) {
new_mode = (flist_mode & ~CHMOD_BITS) | (stat_mode & CHMOD_BITS);
if (preserve_executability && S_ISREG(flist_mode)) {
/* If the source file is executable, grant execute
* rights to everyone who can read, but ONLY if the
* file isn't already executable. */
if (!(flist_mode & 0111))
new_mode &= ~0111;
else if (!(stat_mode & 0111))
new_mode |= (new_mode & 0444) >> 2;
}
} else {
/* Apply destination default permissions and turn
* off special permissions. */
new_mode = flist_mode & (~CHMOD_BITS | dflt_perms);
}
return new_mode;
}
int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st,
int flags)
int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
const char *fnamecmp, int flags)
{
int updated = 0;
STRUCT_STAT st2;
stat_x sx2;
int change_uid, change_gid;
mode_t new_mode = file->mode;
int inherit;
if (!st) {
if (!sxp) {
if (dry_run)
return 1;
if (link_stat(fname, &st2, 0) < 0) {
rsyserr(FERROR, errno, "stat %s failed",
if (link_stat(fname, &sx2.st, 0) < 0) {
rsyserr(FERROR_XFER, errno, "stat %s failed",
full_fname(fname));
return 0;
}
st = &st2;
#ifdef SUPPORT_ACLS
sx2.acc_acl = sx2.def_acl = NULL;
#endif
#ifdef SUPPORT_XATTRS
sx2.xattr = NULL;
#endif
sxp = &sx2;
inherit = !preserve_perms;
} else
inherit = !preserve_perms && file->flags & FLAG_DIR_CREATED;
if (inherit && S_ISDIR(new_mode) && sxp->st.st_mode & S_ISGID) {
/* We just created this directory and its setgid
* bit is on, so make sure it stays on. */
new_mode |= S_ISGID;
}
if (!preserve_times || S_ISLNK(st->st_mode)
|| (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) {
if (set_modtime(fname,file->modtime) != 0) {
rsyserr(FERROR, errno, "failed to set times on %s",
if (daemon_chmod_modes && !S_ISLNK(new_mode))
new_mode = tweak_mode(new_mode, daemon_chmod_modes);
#ifdef SUPPORT_ACLS
if (preserve_acls && !S_ISLNK(file->mode) && !ACL_READY(*sxp))
get_acl(fname, sxp);
#endif
#ifdef SUPPORT_XATTRS
if (am_root < 0)
set_stat_xattr(fname, file, new_mode);
if (preserve_xattrs && fnamecmp)
set_xattr(fname, file, fnamecmp, sxp);
#endif
if (!preserve_times || (S_ISDIR(sxp->st.st_mode) && preserve_times == 1))
flags |= ATTRS_SKIP_MTIME;
if (!(flags & ATTRS_SKIP_MTIME)
&& cmp_time(sxp->st.st_mtime, file->modtime) != 0) {
int ret = set_modtime(fname, file->modtime, sxp->st.st_mode);
if (ret < 0) {
rsyserr(FERROR_XFER, errno, "failed to set times on %s",
full_fname(fname));
return 0;
goto cleanup;
}
updated = 1;
if (ret == 0) /* ret == 1 if symlink could not be set */
updated = 1;
else
file->flags |= FLAG_TIME_FAILED;
}
change_uid = am_root && preserve_uid && st->st_uid != file->uid;
change_gid = preserve_gid && file->gid != GID_NONE
&& st->st_gid != file->gid;
change_uid = am_root && uid_ndx && sxp->st.st_uid != (uid_t)F_OWNER(file);
change_gid = gid_ndx && !(file->flags & FLAG_SKIP_GROUP)
&& sxp->st.st_gid != (gid_t)F_GROUP(file);
#if !defined HAVE_LCHOWN && !defined CHOWN_MODIFIES_SYMLINK
if (S_ISLNK(st->st_mode))
if (S_ISLNK(sxp->st.st_mode)) {
;
else
} 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);
"set uid of %s from %u to %u\n",
fname, (unsigned)sxp->st.st_uid, F_OWNER(file));
}
if (change_gid) {
rprintf(FINFO,
"set gid of %s from %ld to %ld\n",
safe_fname(fname),
(long)st->st_gid, (long)file->gid);
"set gid of %s from %u to %u\n",
fname, (unsigned)sxp->st.st_gid, F_GROUP(file));
}
}
if (do_lchown(fname,
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 */
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));
if (am_root >= 0) {
if (do_lchown(fname,
change_uid ? (uid_t)F_OWNER(file) : sxp->st.st_uid,
change_gid ? (gid_t)F_GROUP(file) : sxp->st.st_gid) != 0) {
/* We shouldn't have attempted to change uid
* or gid unless have the privilege. */
rsyserr(FERROR_XFER, errno, "%s %s failed",
change_uid ? "chown" : "chgrp",
full_fname(fname));
goto cleanup;
}
/* A lchown had been done, so we need to re-stat if
* the destination had the setuid or setgid bits set
* (due to the side effect of the chown call). */
if (sxp->st.st_mode & (S_ISUID | S_ISGID)) {
link_stat(fname, &sxp->st,
keep_dirlinks && S_ISDIR(sxp->st.st_mode));
}
}
updated = 1;
}
#ifdef SUPPORT_ACLS
/* It's OK to call set_acl() now, even for a dir, as the generator
* will enable owner-writability using chmod, if necessary.
*
* If set_acl() changes permission bits in the process of setting
* an access ACL, it changes sxp->st.st_mode so we know whether we
* need to chmod(). */
if (preserve_acls && !S_ISLNK(new_mode) && set_acl(fname, file, sxp) == 0)
updated = 1;
#endif
#ifdef HAVE_CHMOD
if (!S_ISLNK(st->st_mode)) {
if ((st->st_mode & CHMOD_BITS) != (file->mode & CHMOD_BITS)) {
updated = 1;
if (do_chmod(fname,(file->mode & CHMOD_BITS)) != 0) {
rsyserr(FERROR, errno, "failed to set permissions on %s",
full_fname(fname));
return 0;
}
if (!BITS_EQUAL(sxp->st.st_mode, new_mode, CHMOD_BITS)) {
int ret = am_root < 0 ? 0 : do_chmod(fname, new_mode);
if (ret < 0) {
rsyserr(FERROR_XFER, errno,
"failed to set permissions on %s",
full_fname(fname));
goto cleanup;
}
if (ret == 0) /* ret == 1 if symlink could not be set */
updated = 1;
}
#endif
if (verbose > 1 && flags & PERMS_REPORT) {
enum logcode code = daemon_log_format_has_i || dry_run
? FCLIENT : FINFO;
if (verbose > 1 && flags & ATTRS_REPORT) {
if (updated)
rprintf(code, "%s\n", safe_fname(fname));
rprintf(FCLIENT, "%s\n", fname);
else
rprintf(code, "%s is uptodate\n", safe_fname(fname));
rprintf(FCLIENT, "%s is uptodate\n", fname);
}
cleanup:
if (sxp == &sx2) {
#ifdef SUPPORT_ACLS
if (preserve_acls)
free_acl(&sx2);
#endif
#ifdef SUPPORT_XATTRS
if (preserve_xattrs)
free_xattr(&sx2);
#endif
}
return updated;
}
void sig_int(void)
RETSIGTYPE sig_int(UNUSED(int val))
{
/* KLUGE: if the user hits Ctrl-C while ssh is prompting
* for a password, then our cleanup's sending of a SIGUSR1
@@ -163,50 +541,93 @@ void sig_int(void)
exit_cleanup(RERR_SIGNAL);
}
/* 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,
int ok_to_set_time, int overwriting_basis)
/* Finish off a file transfer: renaming the file and setting the file's
* attributes (e.g. permissions, ownership, etc.). If the robust_rename()
* call is forced to copy the temp file and partialptr is both non-NULL and
* not an absolute path, we stage the file into the partial-dir and then
* rename it into place. This returns 1 on succcess or 0 on failure. */
int finish_transfer(const char *fname, const char *fnametmp,
const char *fnamecmp, const char *partialptr,
struct file_struct *file, int ok_to_set_time,
int overwriting_basis)
{
int ret;
const char *temp_copy_name = partialptr && *partialptr != '/' ? partialptr : NULL;
if (inplace) {
if (verbose > 2)
rprintf(FINFO, "finishing %s\n", safe_fname(fname));
goto do_set_perms;
rprintf(FINFO, "finishing %s\n", fname);
fnametmp = fname;
goto do_set_file_attrs;
}
if (make_backups && overwriting_basis && !make_backup(fname))
return;
if (make_backups > 0 && overwriting_basis && !make_backup(fname))
return 1;
/* Change permissions before putting the file into place. */
set_perms(fnametmp, file, NULL, ok_to_set_time ? 0 : PERMS_SKIP_MTIME);
set_file_attrs(fnametmp, file, NULL, fnamecmp,
ok_to_set_time ? 0 : ATTRS_SKIP_MTIME);
/* move tmp file over real file */
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 (verbose > 2)
rprintf(FINFO, "renaming %s to %s\n", fnametmp, fname);
ret = robust_rename(fnametmp, fname, temp_copy_name,
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;
rsyserr(FERROR_XFER, errno, "%s %s -> \"%s\"",
ret == -2 ? "copy" : "rename",
full_fname(fnametmp), fname);
if (!partialptr || (ret == -2 && temp_copy_name)
|| robust_rename(fnametmp, partialptr, NULL,
file->mode & INITACCESSPERMS) < 0)
do_unlink(fnametmp);
return 0;
}
if (ret == 0) {
/* The file was moved into place (not copied), so it's done. */
return;
return 1;
}
do_set_perms:
set_perms(fname, file, NULL, ok_to_set_time ? 0 : PERMS_SKIP_MTIME);
/* The file was copied, so tweak the perms of the copied file. If it
* was copied to partialptr, move it into its final destination. */
fnametmp = temp_copy_name ? temp_copy_name : fname;
do_set_file_attrs:
set_file_attrs(fnametmp, file, NULL, fnamecmp,
ok_to_set_time ? 0 : ATTRS_SKIP_MTIME);
if (temp_copy_name) {
if (do_rename(fnametmp, fname) < 0) {
rsyserr(FERROR_XFER, errno, "rename %s -> \"%s\"",
full_fname(fnametmp), fname);
return 0;
}
handle_partial_dir(temp_copy_name, PDIR_DELETE);
}
return 1;
}
struct file_list *flist_for_ndx(int ndx)
{
struct file_list *flist = cur_flist;
if (!flist && !(flist = first_flist))
return NULL;
while (ndx < flist->ndx_start-1) {
if (flist == first_flist)
return NULL;
flist = flist->prev;
}
while (ndx >= flist->ndx_start + flist->used) {
if (!(flist = flist->next))
return NULL;
}
return flist;
}
const char *who_am_i(void)
{
if (am_sender < 0)
if (am_starting_up)
return am_server ? "server" : "client";
return am_sender ? "sender" : am_generator ? "generator" : "receiver";
}

623
rsync.h
View File

@@ -1,23 +1,22 @@
/*
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.
*/
* Copyright (C) 1996, 2000 Andrew Tridgell
* Copyright (C) 1996 Paul Mackerras
* Copyright (C) 2001, 2002 Martin Pool <mbp@samba.org>
* Copyright (C) 2003-2008 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
#define False 0
#define True 1
@@ -33,6 +32,9 @@
#define DEFAULT_LOCK_FILE "/var/run/rsyncd.lock"
#define URL_PREFIX "rsync://"
#define SYMLINK_PREFIX "/rsyncd-munged/"
#define SYMLINK_PREFIX_LEN ((int)sizeof SYMLINK_PREFIX - 1)
#define BACKUP_SUFFIX "~"
/* a non-zero CHAR_OFFSET makes the rolling sum stronger, but is
@@ -43,29 +45,58 @@
#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_RDEV_pre28 (1<<2) /* protocols 20 - 27 */
#define XMIT_EXTENDED_FLAGS (1<<2) /* protocols 28 - now */
#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)
#define XMIT_SAME_RDEV_MAJOR (1<<8) /* protocols 28 - now (devices only) */
#define XMIT_NO_CONTENT_DIR (1<<8) /* protocols 30 - now (dirs only) */
#define XMIT_HLINKED (1<<9) /* protocols 28 - now */
#define XMIT_SAME_DEV_pre30 (1<<10) /* protocols 28 - 29 */
#define XMIT_USER_NAME_FOLLOWS (1<<10) /* protocols 30 - now */
#define XMIT_RDEV_MINOR_8_pre30 (1<<11) /* protocols 28 - 29 */
#define XMIT_GROUP_NAME_FOLLOWS (1<<11) /* protocols 30 - now */
#define XMIT_HLINK_FIRST (1<<12) /* protocols 30 - now (HLINKED files only) */
/* These flags are used in the live flist data. */
#define FLAG_TOP_DIR (1<<0)
#define FLAG_HLINK_EOL (1<<1) /* generator only */
#define FLAG_MOUNT_POINT (1<<2) /* sender only */
#define FLAG_NO_FUZZY (1<<2) /* generator only */
#define FLAG_DEL_HERE (1<<3) /* receiver/generator */
#define FLAG_SENT (1<<3) /* sender only */
#define FLAG_TOP_DIR (1<<0) /* sender/receiver/generator */
#define FLAG_FILE_SENT (1<<1) /* sender/receiver/generator */
#define FLAG_DIR_CREATED (1<<1) /* generator */
#define FLAG_CONTENT_DIR (1<<2) /* sender/receiver/generator */
#define FLAG_MOUNT_DIR (1<<3) /* sender/generator (dirs only) */
#define FLAG_SKIP_HLINK (1<<3) /* receiver/generator (w/FLAG_HLINKED) */
#define FLAG_DUPLICATE (1<<4) /* sender */
#define FLAG_MISSING_DIR (1<<4) /* generator */
#define FLAG_HLINKED (1<<5) /* receiver/generator (checked on all types) */
#define FLAG_HLINK_FIRST (1<<6) /* receiver/generator (w/FLAG_HLINKED) */
#define FLAG_IMPLIED_DIR (1<<6) /* sender/receiver/generator (dirs only) */
#define FLAG_HLINK_LAST (1<<7) /* receiver/generator */
#define FLAG_HLINK_DONE (1<<8) /* receiver/generator (checked on all types) */
#define FLAG_LENGTH64 (1<<9) /* sender/receiver/generator */
#define FLAG_SKIP_GROUP (1<<10) /* receiver/generator */
#define FLAG_TIME_FAILED (1<<11)/* generator */
/* These flags are passed to functions but not stored. */
#define FLAG_DIVERT_DIRS (1<<16)/* sender */
#define FLAG_DOTDIR_NAME (1<<17)/* sender */
#define BITS_SET(val,bits) (((val) & (bits)) == (bits))
#define BITS_SETnUNSET(val,onbits,offbits) (((val) & ((onbits)|(offbits))) == (onbits))
#define BITS_EQUAL(b1,b2,mask) (((unsigned)(b1) & (unsigned)(mask)) \
== ((unsigned)(b2) & (unsigned)(mask)))
/* update this if you make incompatible changes */
#define PROTOCOL_VERSION 29
#define PROTOCOL_VERSION 30
/* This is used when working on a new protocol version in CVS, and should
* be a new non-zero value for each CVS change that affects the protocol.
* It must ALWAYS be 0 when the protocol goes final! */
#define SUBPROTOCOL_VERSION 0
/* 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
@@ -88,6 +119,8 @@
#define OLD_PROTOCOL_VERSION 25
#define MAX_PROTOCOL_VERSION 40
#define FILECNT_LOOKAHEAD 1000
#define RSYNC_PORT 873
#define SPARSE_WRITE_SIZE (1024)
@@ -95,14 +128,15 @@
#define CHUNK_SIZE (32*1024)
#define MAX_MAP_SIZE (256*1024)
#define IO_BUFFER_SIZE (4092)
#define MAX_BLOCK_SIZE ((int32)1 << 29)
#define MAX_BLOCK_SIZE ((int32)1 << 17)
#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
@@ -112,10 +146,12 @@
#define XFLG_FATAL_ERRORS (1<<0)
#define XFLG_OLD_PREFIXES (1<<1)
#define XFLG_ANCHORED2ABS (1<<2)
#define XFLG_ANCHORED2ABS (1<<2) /* leading slash indicates absolute */
#define XFLG_ABS_IF_SLASH (1<<3) /* leading or interior slash is absolute */
#define XFLG_DIR2WILD3 (1<<4) /* dir/ match gets trailing *** added */
#define PERMS_REPORT (1<<0)
#define PERMS_SKIP_MTIME (1<<1)
#define ATTRS_REPORT (1<<0)
#define ATTRS_SKIP_MTIME (1<<1)
#define FULL_FLUSH 1
#define NORMAL_FLUSH 0
@@ -131,41 +167,74 @@
#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_UPDATING (1<<0)
#define ITEM_REPORT_CHECKSUM (1<<1)
#define ITEM_REPORT_SIZE (1<<2)
#define ITEM_REPORT_ATIME (1<<0)
#define ITEM_REPORT_CHANGE (1<<1)
#define ITEM_REPORT_SIZE (1<<2) /* regular files only */
#define ITEM_REPORT_TIMEFAIL (1<<2) /* symlinks only */
#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_IS_NEW (1<<7)
#define ITEM_USING_ALT_BASIS (1<<8)
#define ITEM_REPORT_ACL (1<<7)
#define ITEM_REPORT_XATTR (1<<8)
#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_MISSING_DATA (1<<16) /* used by log_formatted() */
#define ITEM_DELETED (1<<17) /* used by log_formatted() */
#define ITEM_MATCHED (1<<18) /* used by itemize() */
#define ITEM_MISSING_DATA (1<<16) /* these are outside the transmitted flags */
#define ITEM_DELETED (1<<17)
#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 };
#define CFN_KEEP_DOT_DIRS (1<<0)
#define CFN_KEEP_TRAILING_SLASH (1<<1)
#define CFN_DROP_TRAILING_DOT_DIR (1<<2)
#define CFN_COLLAPSE_DOT_DOT_DIRS (1<<3)
#define SP_DEFAULT 0
#define SP_KEEP_DOT_DIRS (1<<0)
#define CD_NORMAL 0
#define CD_SKIP_CHDIR 1
/* Log-message categories. FLOG only goes to the log file, not the client;
* FCLIENT is the opposite. */
enum logcode {
FNONE=0, /* never sent */
FERROR_XFER=1, FINFO=2, /* sent over socket for any protocol */
FERROR=3, FWARNING=4, /* sent over socket for protocols >= 30 */
FERROR_SOCKET=5, FLOG=6, /* only sent via receiver -> generator pipe */
FCLIENT=7 /* never transmitted (e.g. server converts to FINFO) */
};
/* 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_ERROR_XFER=FERROR_XFER, MSG_INFO=FINFO, /* remote logging */
MSG_ERROR=FERROR, MSG_WARNING=FWARNING, /* protocol-30 remote logging */
MSG_ERROR_SOCKET=FERROR_SOCKET, /* sibling logging */
MSG_LOG=FLOG, MSG_CLIENT=FCLIENT, /* sibling logging */
MSG_REDO=9, /* reprocess indicated flist index */
MSG_FLIST=20, /* extra file list over sibling socket */
MSG_FLIST_EOF=21,/* we've transmitted all the file lists */
MSG_IO_ERROR=22,/* the sending side had an I/O error */
MSG_NOOP=42, /* a do-nothing message */
MSG_SUCCESS=100,/* successfully updated indicated flist index */
MSG_DELETED=101,/* successfully deleted a file on receiving side */
MSG_NO_SEND=102,/* sender failed to open a file we wanted */
MSG_DONE=86 /* current phase is done */
};
#define NDX_DONE -1
#define NDX_FLIST_EOF -2
#define NDX_FLIST_OFFSET -101
#include "errcode.h"
#include "config.h"
@@ -196,6 +265,12 @@ enum msgcode {
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#ifdef HAVE_INTTYPES_H
# include <inttypes.h>
#endif
#ifdef HAVE_STDINT_H
# include <stdint.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
@@ -266,10 +341,6 @@ enum msgcode {
#endif
#endif
#ifdef HAVE_GLOB_H
#include <glob.h>
#endif
/* these are needed for the uid/gid mapping code */
#include <pwd.h>
#include <grp.h>
@@ -277,7 +348,9 @@ enum msgcode {
#include <stdarg.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif
#include <syslog.h>
#include <sys/file.h>
@@ -305,14 +378,58 @@ enum msgcode {
#include <sys/sysmacros.h>
#endif
#ifdef MAKEDEV_TAKES_3_ARGS
#define MAKEDEV(devmajor,devminor) makedev(0,devmajor,devminor)
#else
#define MAKEDEV(devmajor,devminor) makedev(devmajor,devminor)
#endif
#ifdef HAVE_COMPAT_H
#include <compat.h>
#endif
#ifdef HAVE_LIMITS_H
# include <limits.h>
#endif
#if defined HAVE_ICONV_OPEN && defined HAVE_ICONV_H
#include <iconv.h>
#ifndef ICONV_CONST
#define ICONV_CONST
#endif
#else
#ifdef ICONV_CONST
#undef ICONV_CONST
#endif
#ifdef ICONV_OPTION
#undef ICONV_OPTION
#endif
#ifdef iconv_t
#undef iconv_t
#endif
#define iconv_t int
#endif
#include <assert.h>
#include "lib/pool_alloc.h"
#ifndef HAVE_ID_T
typedef unsigned int id_t;
#endif
#ifndef HAVE_PID_T
typedef int pid_t;
#endif
#ifndef HAVE_MODE_T
typedef unsigned int mode_t;
#endif
#ifndef HAVE_OFF_T
typedef long off_t;
#endif
#ifndef HAVE_SIZE_T
typedef unsigned int size_t;
#endif
#define BOOL int
#ifndef uchar
@@ -325,11 +442,30 @@ enum msgcode {
#define schar char
#endif
#ifndef int16
#if SIZEOF_INT16_T == 2
# define int16 int16_t
#else
# define int16 short
#endif
#endif
#ifndef uint16
#if SIZEOF_UINT16_T == 2
# define uint16 uint16_t
#else
# define uint16 unsigned int16
#endif
#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
#if SIZEOF_INT32_T == 4
# define int32 int32_t
# define SIZEOF_INT32 4
#elif SIZEOF_INT == 4
# define int32 int
# define SIZEOF_INT32 4
#elif SIZEOF_LONG == 4
@@ -352,7 +488,11 @@ enum msgcode {
#endif
#ifndef uint32
#define uint32 unsigned int32
#if SIZEOF_UINT32_T == 4
# define uint32 uint32_t
#else
# define uint32 unsigned int32
#endif
#endif
#if SIZEOF_OFF_T == 8 || !SIZEOF_OFF64_T || !defined HAVE_STRUCT_STAT64
@@ -370,8 +510,8 @@ enum msgcode {
* 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
#if SIZEOF_INT64_T == 8
# define int64 int64_t
# define SIZEOF_INT64 8
#elif SIZEOF_LONG == 8
# define int64 long
@@ -382,6 +522,9 @@ enum msgcode {
#elif SIZEOF_LONG_LONG == 8
# define int64 long long
# define SIZEOF_INT64 8
#elif SIZEOF_OFF64_T == 8
# define int64 off64_t
# define SIZEOF_INT64 8
#elif SIZEOF_OFF_T == 8
# define int64 off_t
# define SIZEOF_INT64 8
@@ -400,37 +543,27 @@ enum msgcode {
# define SIZEOF_INT64 SIZEOF_OFF_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;
struct hashtable {
void *nodes;
int32 size, entries;
uint32 node_size;
int key64;
};
struct ht_int32_node {
void *data;
int32 key;
};
struct ht_int64_node {
void *data;
int64 key;
};
#define HT_NODE(tbl, bkts, i) ((void*)((char*)(bkts) + (i)*(tbl)->node_size))
#define HT_KEY(node, k64) ((k64)? ((struct ht_int64_node*)(node))->key \
: (int64)((struct ht_int32_node*)(node))->key)
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
#endif
@@ -443,8 +576,6 @@ struct idev {
#define MAXHOSTNAMELEN 256
#endif
/* the length of the md4 checksum */
#define MD4_SUM_LENGTH 16
#define SUM_LENGTH 16
#define SHORT_SUM_LENGTH 2
#define BLOCKSUM_BIAS 10
@@ -453,6 +584,14 @@ struct idev {
#define MAXPATHLEN 1024
#endif
/* We want a roomy line buffer that can hold more than MAXPATHLEN,
* and significantly more than an overly short MAXPATHLEN. */
#if MAXPATHLEN < 4096
#define BIGPATHBUFLEN (4096+1024)
#else
#define BIGPATHBUFLEN (MAXPATHLEN+1024)
#endif
#ifndef NAME_MAX
#define NAME_MAX 255
#endif
@@ -465,46 +604,104 @@ struct idev {
#define IN_LOOPBACKNET 127
#endif
#define GID_NONE ((gid_t)-1)
#if HAVE_UNIXWARE_ACLS|HAVE_SOLARIS_ACLS|HAVE_HPUX_ACLS
#define ACLS_NEED_MASK 1
#endif
#define HL_CHECK_MASTER 0
#define HL_SKIP 1
struct hlink {
struct file_struct *next;
int hlindex;
union file_extras {
int32 num;
uint32 unum;
};
#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 {
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;
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;
mode_t mode;
uchar flags; /* this item MUST remain last */
const char *dirname; /* The dir info inside the transfer */
time_t modtime; /* When the item was last modified */
uint32 len32; /* Lowest 32 bits of the file's length */
uint16 mode; /* The item's type and permissions */
uint16 flags; /* The FLAG_* bits for this item */
const char basename[1]; /* The basename (AKA filename) follows */
};
extern int file_extra_cnt;
extern int inc_recurse;
extern int uid_ndx;
extern int gid_ndx;
extern int acls_ndx;
extern int xattrs_ndx;
#define FILE_STRUCT_LEN (offsetof(struct file_struct, basename))
#define EXTRA_LEN (sizeof (union file_extras))
#define PTR_EXTRA_CNT ((sizeof (char *) + EXTRA_LEN - 1) / EXTRA_LEN)
#define DEV_EXTRA_CNT 2
#define DIRNODE_EXTRA_CNT 3
#define SUM_EXTRA_CNT ((MAX_DIGEST_LEN + EXTRA_LEN - 1) / EXTRA_LEN)
#define REQ_EXTRA(f,ndx) ((union file_extras*)(f) - (ndx))
#define OPT_EXTRA(f,bump) ((union file_extras*)(f) - file_extra_cnt - 1 - (bump))
#define LEN64_BUMP(f) ((f)->flags & FLAG_LENGTH64 ? 1 : 0)
#define HLINK_BUMP(f) ((f)->flags & (FLAG_HLINKED|FLAG_HLINK_DONE) ? inc_recurse+1 : 0)
#define ACL_BUMP(f) (acls_ndx ? 1 : 0)
/* The length applies to all items. */
#if SIZEOF_INT64 < 8
#define F_LENGTH(f) ((int64)(f)->len32)
#else
#define F_LENGTH(f) ((int64)(f)->len32 + ((f)->flags & FLAG_LENGTH64 \
? (int64)OPT_EXTRA(f, 0)->unum << 32 : 0))
#endif
/* If there is a symlink string, it is always right after the basename */
#define F_SYMLINK(f) ((f)->basename + strlen((f)->basename) + 1)
/* The sending side always has this available: */
#define F_PATHNAME(f) (*(const char**)REQ_EXTRA(f, PTR_EXTRA_CNT))
/* The receiving side always has this available: */
#define F_DEPTH(f) REQ_EXTRA(f, 1)->num
/* When the associated option is on, all entries will have these present: */
#define F_OWNER(f) REQ_EXTRA(f, uid_ndx)->unum
#define F_GROUP(f) REQ_EXTRA(f, gid_ndx)->unum
#define F_ACL(f) REQ_EXTRA(f, acls_ndx)->num
#define F_XATTR(f) REQ_EXTRA(f, xattrs_ndx)->num
#define F_NDX(f) REQ_EXTRA(f, unsort_ndx)->num
/* These items are per-entry optional: */
#define F_HL_GNUM(f) OPT_EXTRA(f, LEN64_BUMP(f))->num /* non-dirs */
#define F_HL_PREV(f) OPT_EXTRA(f, LEN64_BUMP(f)+inc_recurse)->num /* non-dirs */
#define F_DIR_NODE_P(f) (&OPT_EXTRA(f, LEN64_BUMP(f) \
+ DIRNODE_EXTRA_CNT - 1)->num) /* sender dirs */
#define F_DIR_RELNAMES_P(f) (&OPT_EXTRA(f, LEN64_BUMP(f) + DIRNODE_EXTRA_CNT \
+ PTR_EXTRA_CNT - 1)->num) /* sender dirs */
#define F_DIR_DEFACL(f) OPT_EXTRA(f, LEN64_BUMP(f))->unum /* receiver dirs */
#define F_DIR_DEV_P(f) (&OPT_EXTRA(f, LEN64_BUMP(f) + ACL_BUMP(f) \
+ DEV_EXTRA_CNT - 1)->unum) /* receiver dirs */
/* This optional item might follow an F_HL_*() item.
* (Note: a device doesn't need to check LEN64_BUMP(f).) */
#define F_RDEV_P(f) (&OPT_EXTRA(f, HLINK_BUMP(f) + DEV_EXTRA_CNT - 1)->unum)
/* The sum is only present on regular files. */
#define F_SUM(f) ((char*)OPT_EXTRA(f, LEN64_BUMP(f) + HLINK_BUMP(f) \
+ SUM_EXTRA_CNT - 1))
/* Some utility defines: */
#define F_IS_ACTIVE(f) (f)->basename[0]
#define F_IS_HLINKED(f) ((f)->flags & FLAG_HLINKED)
#define F_HLINK_NOT_FIRST(f) BITS_SETnUNSET((f)->flags, FLAG_HLINKED, FLAG_HLINK_FIRST)
#define F_HLINK_NOT_LAST(f) BITS_SETnUNSET((f)->flags, FLAG_HLINKED, FLAG_HLINK_LAST)
/* These access the F_DIR_DEV_P() and F_RDEV_P() values: */
#define DEV_MAJOR(a) (a)[0]
#define DEV_MINOR(a) (a)[1]
/* These access the F_DIRS_NODE_P() values: */
#define DIR_PARENT(a) (a)[0]
#define DIR_FIRST_CHILD(a) (a)[1]
#define DIR_NEXT_SIBLING(a) (a)[2]
/*
* Start the flist array at FLIST_START entries and grow it
* by doubling until FLIST_LINEAR then grow by FLIST_LINEAR
@@ -513,27 +710,30 @@ struct file_struct {
#define FLIST_LINEAR (FLIST_START * 512)
/*
* Extent size for allocation pools A minimum size of 128KB
* 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
* (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 NORMAL_EXTENT (256 * 1024)
#define SMALL_EXTENT (128 * 1024)
#define WITH_HLINK 1
#define WITHOUT_HLINK 0
#define FLIST_TEMP (1<<1)
struct file_list {
struct file_struct **files;
struct file_list *next, *prev;
struct file_struct **files, **sorted;
alloc_pool_t file_pool;
alloc_pool_t hlink_pool;
int count;
int malloced;
int low, high;
void *pool_boundary;
int used, malloced;
int low, high; /* 0-relative index values excluding empties */
int ndx_start; /* the start offset for inc_recurse mode */
int flist_num; /* 1-relative file_list number or 0 */
int parent_ndx; /* dir_flist index of parent directory */
int in_progress, to_redo;
};
#define SUMFLG_SAME_OFFSET (1<<0)
@@ -542,6 +742,7 @@ struct sum_buf {
OFF_T offset; /**< offset in file of this chunk */
int32 len; /**< length of chunk of file */
uint32 sum1; /**< simple checksum */
int32 chain; /**< next hash-table collision */
short flags; /**< flag bits */
char sum2[SUM_LENGTH]; /**< checksum */
};
@@ -569,11 +770,11 @@ struct map_struct {
#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_WILD2_PREFIX (1<<2) /* pattern starts with "**" */
#define MATCHFLG_WILD3_SUFFIX (1<<3) /* pattern ends with "***" */
#define MATCHFLG_ABS_PATH (1<<4) /* path-match on absolute path */
#define MATCHFLG_INCLUDE (1<<5) /* this is an include, not an exclude */
#define MATCHFLG_DIRECTORY (1<<6) /* this matches only directories */
#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 */
@@ -585,10 +786,13 @@ struct map_struct {
#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 MATCHFLG_CLEAR_LIST (1<<18)/* this item is the "!" token */
#define MATCHFLG_PERISHABLE (1<<19)/* perishable if parent dir goes away */
#define MATCHFLGS_FROM_CONTAINER (MATCHFLG_ABS_PATH | MATCHFLG_INCLUDE \
| MATCHFLG_DIRECTORY | MATCHFLG_SENDER_SIDE \
| MATCHFLG_NEGATE | MATCHFLG_RECEIVER_SIDE)
| MATCHFLG_NEGATE | MATCHFLG_RECEIVER_SIDE \
| MATCHFLG_PERISHABLE)
struct filter_struct {
struct filter_struct *next;
@@ -615,21 +819,92 @@ struct stats {
int64 matched_data;
int64 flist_buildtime;
int64 flist_xfertime;
int flist_size;
int64 flist_size;
int num_files;
int num_transferred_files;
int current_file_index;
};
struct chmod_mode_struct;
#define EMPTY_ITEM_LIST {NULL, 0, 0}
typedef struct {
void *items;
size_t count;
size_t malloced;
} item_list;
#define EXPAND_ITEM_LIST(lp, type, incr) \
(type*)expand_item_list(lp, sizeof (type), #type, incr)
#define EMPTY_XBUF {NULL, 0, 0, 0}
typedef struct {
char *buf;
size_t pos; /* pos = read pos in the buf */
size_t len; /* len = chars following pos */
size_t size; /* size = total space in buf */
} xbuf;
#define INIT_XBUF(xb, str, ln, sz) (xb).buf = (str), (xb).len = (ln), (xb).size = (sz), (xb).pos = 0
#define INIT_XBUF_STRLEN(xb, str) (xb).buf = (str), (xb).len = strlen((xb).buf), (xb).size = (-1), (xb).pos = 0
/* This one is used to make an output xbuf based on a char[] buffer: */
#define INIT_CONST_XBUF(xb, bf) (xb).buf = (bf), (xb).size = sizeof (bf), (xb).len = (xb).pos = 0
#define ICB_EXPAND_OUT (1<<0)
#define ICB_INCLUDE_BAD (1<<1)
#define ICB_INCLUDE_INCOMPLETE (1<<2)
#define RL_EOL_NULLS (1<<0)
#define RL_DUMP_COMMENTS (1<<1)
#define RL_CONVERT (1<<2)
typedef struct {
char name_type;
char fname[1]; /* has variable size */
} relnamecache;
#include "byteorder.h"
#include "lib/mdfour.h"
#include "lib/mdigest.h"
#include "lib/wildmatch.h"
#include "lib/permstring.h"
#include "lib/addrinfo.h"
#ifndef __GNUC__
#define __attribute__(x)
#else
# if __GNUC__ <= 2
# define NORETURN
# endif
#endif
#define UNUSED(x) x __attribute__((__unused__))
#ifndef NORETURN
#define NORETURN __attribute__((__noreturn__))
#endif
typedef struct {
STRUCT_STAT st;
#ifdef SUPPORT_ACLS
struct rsync_acl *acc_acl; /* access ACL */
struct rsync_acl *def_acl; /* default ACL */
#endif
#ifdef SUPPORT_XATTRS
item_list *xattr;
#endif
} stat_x;
#define ACL_READY(sx) ((sx).acc_acl != NULL)
#define XATTR_READY(sx) ((sx).xattr != NULL)
#include "proto.h"
#ifndef SUPPORT_XATTRS
#define x_stat(fn,fst,xst) do_stat(fn,fst)
#define x_lstat(fn,fst,xst) do_lstat(fn,fst)
#define x_fstat(fd,fst,xst) do_fstat(fd,fst)
#endif
/* We have replacement versions of these if they're missing. */
#ifndef HAVE_ASPRINTF
int asprintf(char **ptr, const char *format, ...);
@@ -646,7 +921,7 @@ int vsnprintf(char *str, size_t count, const char *fmt, va_list args);
#if !defined HAVE_SNPRINTF || !defined HAVE_C99_VSNPRINTF
#define snprintf rsync_snprintf
int snprintf(char *str,size_t count,const char *fmt,...);
int snprintf(char *str, size_t count, const char *fmt,...);
#endif
@@ -664,10 +939,19 @@ extern char *sys_errlist[];
extern int errno;
#endif
#define SUPPORT_LINKS HAVE_READLINK
#define SUPPORT_HARD_LINKS HAVE_LINK
#ifdef HAVE_READLINK
#define SUPPORT_LINKS 1
#endif
#ifdef HAVE_LINK
#define SUPPORT_HARD_LINKS 1
#endif
#define SIGNAL_CAST (RETSIGTYPE (*)())
#ifdef HAVE_SIGACTION
#define SIGACTION(n,h) sigact.sa_handler=(h), sigaction((n),&sigact,NULL)
#define signal(n,h) we_need_to_call_SIGACTION_not_signal(n,h)
#else
#define SIGACTION(n,h) signal(n,h)
#endif
#ifndef EWOULDBLOCK
#define EWOULDBLOCK EAGAIN
@@ -764,7 +1048,8 @@ extern int errno;
#define INADDR_NONE 0xffffffff
#endif
#define IS_DEVICE(mode) (S_ISCHR(mode) || S_ISBLK(mode) || S_ISSOCK(mode) || S_ISFIFO(mode))
#define IS_SPECIAL(mode) (S_ISSOCK(mode) || S_ISFIFO(mode))
#define IS_DEVICE(mode) (S_ISCHR(mode) || S_ISBLK(mode))
/* Initial mask on permissions given to temporary files. Mask off setuid
bits and group access because of potential race-condition security
@@ -772,20 +1057,14 @@ extern int errno;
#define INITACCESSPERMS 0700
/* handler for null strings in printf format */
#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
#define NS(s) ((s)?(s):"<NULL>")
/* 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)))
#define new(type) ((type*)malloc(sizeof (type)))
#define new0(type) ((type*)calloc(1, sizeof (type)))
#define new_array(type, num) ((type*)_new_array((num), sizeof (type), 0))
#define new_array0(type, num) ((type*)_new_array((num), sizeof (type), 1))
#define realloc_array(ptr, type, num) ((type*)_realloc_array((ptr), sizeof(type), (num)))
/* use magic gcc attributes to catch format errors */
void rprintf(enum logcode , const char *, ...)
@@ -798,10 +1077,6 @@ 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
@@ -818,6 +1093,9 @@ size_t strlcat(char *d, const char *s, size_t bufsize);
#ifndef WEXITSTATUS
#define WEXITSTATUS(stat) ((int)(((stat)>>8)&0xFF))
#endif
#ifndef WIFEXITED
#define WIFEXITED(stat) ((int)((stat)&0xFF) == 0)
#endif
#define exit_cleanup(code) _exit_cleanup(code, __FILE__, __LINE__)
@@ -833,6 +1111,11 @@ size_t strlcat(char *d, const char *s, size_t bufsize);
#define MY_GID() getgid()
#endif
#ifdef FORCE_FD_ZERO_MEMSET
#undef FD_ZERO
#define FD_ZERO(fdsetp) memset(fdsetp, 0, sizeof (fd_set))
#endif
extern int verbose;
#ifndef HAVE_INET_NTOP
@@ -846,7 +1129,3 @@ int inet_pton(int af, const char *src, void *dst);
#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;

1929
rsync.yo
View File

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
mailto(rsync-bugs@samba.org)
manpage(rsyncd.conf)(5)(22 Feb 2005)()()
manpagename(rsyncd.conf)(configuration file for rsync server)
manpage(rsyncd.conf)(5)(8 Apr 2008)()()
manpagename(rsyncd.conf)(configuration file for rsync in daemon mode)
manpagesynopsis()
rsyncd.conf
@@ -8,27 +8,27 @@ rsyncd.conf
manpagedescription()
The rsyncd.conf file is the runtime configuration file for rsync when
run as an rsync server.
run as an rsync daemon.
The rsyncd.conf file controls authentication, access, logging and
available modules.
manpagesection(FILE FORMAT)
The file consists of modules and parameters. A module begins with the
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'.
module begins. Modules contain parameters of the form "name = value".
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
Only the first equals sign in a parameter is significant. Whitespace before
or after the first equals sign is discarded. Leading, trailing and internal
whitespace in module and parameter names is irrelevant. Leading and
trailing whitespace in a parameter value is discarded. Internal whitespace
within a parameter value is retained verbatim.
Any line beginning with a hash (#) is ignored, as are lines containing
Any line beginning with a hash (#) is ignored, as are lines containing
only whitespace.
Any line ending in a \ is "continued" on the next line in the
@@ -37,12 +37,12 @@ customary UNIX fashion.
The values following the equals sign in parameters are all either a string
(no quotes needed) or a boolean, which may be given as yes/no, 0/1 or
true/false. Case is not significant in boolean values, but is preserved
in string values.
in string values.
manpagesection(LAUNCHING THE RSYNC DAEMON)
The rsync daemon is launched by specifying the bf(--daemon) option to
rsync.
rsync.
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
@@ -52,30 +52,27 @@ 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.
If run from an rsync client via a remote shell (by specifying both the
bf(--rsh) (bf(-e)) option and server mode with "::" or "rsync://"), the bf(--daemon)
option is automatically passed to the remote side.
When run via inetd you should add a line like this to /etc/services:
verb( rsync 873/tcp)
and a single line something like this to /etc/inetd.conf:
verb( rsync stream tcp nowait root /usr/bin/rsync rsyncd --daemon)
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
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.
connection.
manpagesection(GLOBAL OPTIONS)
The first parameters in the file (before a [module] header) are the
global parameters.
global parameters.
You may also include any module parameters in the global part of the
config file in which case the supplied value will override the
@@ -87,28 +84,25 @@ dit(bf(motd file)) The "motd file" option allows you to specify a
usually contains site information and any legal notices. The default
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.
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. If the file already exists, the rsync
daemon will abort rather than overwrite the 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
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
slower!). Read the man page for the setsockopt() system call for
slower!). Read the man page for the code(setsockopt()) system call for
details on some of the options you may be able to set. By default no
special socket options are set.
special socket options are set. These settings are superseded by the
bf(--sockopts) command-line option.
enddit()
@@ -119,6 +113,10 @@ After the global options you should define a number of modules, each
module exports a directory tree as a symbolic name. Modules are
exported by specifying a module name in square brackets [module]
followed by the options for that module.
The module name cannot contain a slash or a closing square bracket. If the
name contains whitespace, each internal sequence of whitespace will be
changed into a single space, while leading or trailing whitespace will be
discarded.
startdit()
@@ -126,75 +124,173 @@ 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(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,
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.
of the new root path, and of complicating the preservation of users and groups
by name (see below).
In order to preserve usernames and groupnames, rsync needs to be able to
As an additional safety feature, you can specify a dot-dir in the module's
"path" to indicate the point where the chroot should occur. This allows rsync
to run in a chroot with a non-"/" path for the top of the transfer hierarchy.
Doing this guards against unintended library loading (since those absolute
paths will not be inside the transfer hierarchy unless you have used an unwise
pathname), and lets you setup libraries for the chroot that are outside of the
transfer. For example, specifying "/var/rsync/./module1" will chroot to the
"/var/rsync" directory and set the inside-chroot path to "/module1". If you
had omitted the dot-dir, the chroot would have used the whole path, and the
inside-chroot path would have been "/".
When "use chroot" is false or the inside-chroot path is not "/", rsync will:
(1) munge symlinks by
default for security reasons (see "munge symlinks" for a way to turn this
off, but only if you trust your users), (2) substitute leading slashes in
absolute paths with the module's path (so that options such as
bf(--backup-dir), bf(--compare-dest), etc. interpret an absolute path as
rooted in the module's "path" dir), and (3) trim ".." path elements from
args if rsync believes they would escape the module hierarchy.
The default for "use chroot" is true, and is the safer choice (especially
if the module is not read-only).
When this option is enabled, rsync will not attempt to map users and groups
by name (by default), but instead copy IDs as though bf(--numeric-ids) had
been specified. In order to enable name-mapping, 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
code(getpwuid()), code(getgrgid()), code(getpwname()), and code(getgrnam())).
This means the rsync
process in the chroot hierarchy 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.
/etc/group, but perhaps additional dynamic libraries as well).
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 server is running
at least 2.6.3 to effect this.
If you copy the necessary resources into the module's chroot area, you
should protect them through your OS's normal user/group or ACL settings (to
prevent the rsync module's user from being able to change them), and then
hide them from the user's view via "exclude" (see how in the discussion of
that option). At that point it will be safe to enable the mapping of users
and groups by name using the "numeric ids" daemon option (see below).
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.
Note also that you are free to setup custom user/group information in the
chroot area that is different from your normal system. For example, you
could abbreviate the list of users and groups.
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(numeric ids)) Enabling the "numeric ids" option disables the mapping
of users and groups by name for the current daemon module. This prevents
the daemon from trying to load any user/group-related files or libraries.
Enabling this option makes the transfer behave as if the client had passed
the bf(--numeric-ids) command-line option. By default, this parameter is
enabled for chroot modules and disabled for non-chroot modules.
A chroot-enabled module should not have this option enabled unless you've
taken steps to ensure that the module has the necessary resources it needs
to translate names, and that it is not possible for a user to change those
resources.
dit(bf(munge symlinks)) The "munge symlinks" option tells rsync to modify
all incoming symlinks in a way that makes them unusable but recoverable
(see below). This should help protect your files from user trickery when
your daemon module is writable. The default is disabled when "use chroot"
is on and the inside-chroot path is "/", otherwise it is enabled.
If you disable this option on a daemon that is not read-only, there
are tricks that a user can play with uploaded symlinks to access
daemon-excluded items (if your module has any), and, if "use chroot"
is off, rsync can even be tricked into showing or changing data that
is outside the module's path (as access-permissions allow).
The way rsync disables the use of symlinks is to prefix each one with
the string "/rsyncd-munged/". This prevents the links from being used
as long as that directory does not exist. When this option is enabled,
rsync will refuse to run if that path is a directory or a symlink to
a directory. When using the "munge symlinks" option in a chroot area
that has an inside-chroot path of "/", you should add "/rsyncd-munged/"
to the exclude setting for the module so that
a user can't try to create it.
Note: rsync makes no attempt to verify that any pre-existing symlinks in
the hierarchy are as safe as you want them to be. If you setup an rsync
daemon on a new area or locally add symlinks, you can manually protect your
symlinks from being abused by prefixing "/rsyncd-munged/" to the start of
every symlink's value. There is a perl script in the support directory
of the source code named "munge-symlinks" that can be used to add or remove
this prefix from your symlinks.
When this option is disabled on a writable module and "use chroot" is off
(or the inside-chroot path is not "/"),
incoming symlinks will be modified to drop a leading slash and to remove ".."
path elements that rsync believes will allow a symlink to escape the module's
hierarchy. There are tricky ways to work around this, though, so you had
better trust your users if you choose this combination of options.
dit(bf(charset)) This specifies the name of the character set in which the
module's filenames are stored. If the client uses an bf(--iconv) option,
the daemon will use the value of the "charset" parameter regardless of the
character set the client actually passed. This allows the daemon to
support charset conversion in a chroot module without extra files in the
chroot area, and also ensures that name-translation is done in a consistent
manner. If the "charset" parameter is not set, the bf(--iconv) option is
refused, just as if "iconv" had been specified via "refuse options".
If you wish to force users to always use bf(--iconv) for a particular
module, add "no-iconv" to the "refuse options" parameter. Keep in mind
that this will restrict access to your module to very new rsync clients.
dit(bf(max connections)) The "max connections" option allows you to
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.
message telling them to try later. The default is 0, which means no limit.
A negative value disables the module.
See also the "lock file" option.
dit(bf(log file)) When the "log file" option is set to a non-empty
string, the rsync daemon will log messages to the indicated file rather
than using syslog. This is particularly useful on systems (such as AIX)
where code(syslog()) doesn't work for chrooted programs. The file is
opened before code(chroot()) is called, allowing it to be placed outside
the transfer. If this value is set on a per-module basis instead of
globally, the global log will still contain any authorization failures
or config-file error messages.
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 the
failure to open the specified log file used to be a fatal error.)
dit(bf(syslog facility)) The "syslog facility" option allows you to
specify the syslog facility name to use when logging messages from the
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. This setting has no effect if the "log file" setting is a
non-empty string (either set in the per-modules settings, or inherited
from the global settings).
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 for the modules sharing the lock file.
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 server allow them. The
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
@@ -213,49 +309,78 @@ 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 gid -2,
which is normally the group "nobody".
dit(bf(filter)) The "filter" option allows you to specify a space-separated
list of filter rules that the server 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 server's files (if the per-dir
merge files are included in the transfer).
dit(bf(fake super)) Setting "fake super = yes" for a module causes the
daemon side to behave as if the bf(--fake-user) command-line option had
been specified. This allows the full attributes of a file to be stored
without having to have the daemon actually running as root.
dit(bf(exclude)) The "exclude" option allows you to specify a
space-separated list of patterns that the server 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.
dit(bf(filter)) The daemon has its own filter chain that determines what files
it will let the client access. This chain is not sent to the client and is
independent of any filters the client may have specified. Files excluded by
the daemon filter chain (bf(daemon-excluded) files) are treated as non-existent
if the client tries to pull them, are skipped with an error message if the
client tries to push them (triggering exit code 23), and are never deleted from
the module. You can use daemon filters to prevent clients from downloading or
tampering with private administrative files, such as files you may add to
support uid/gid name translations.
Because this exclude list is not passed to the client it only applies on
the server: that is, it excludes files received by a client when receiving
from a server and files deleted on a server when sending to a server, but
it doesn't exclude files from being deleted on a client when receiving
from a server.
The daemon filter chain is built from the "filter", "include from", "include",
"exclude from", and "exclude" parameters, in that order of priority. Anchored
patterns are anchored at the root of the module. To prevent access to an
entire subtree, for example, "/secret", you em(must) exclude everything in the
subtree; the easiest way to do this is with a triple-star pattern like
"/secret/***".
dit(bf(exclude from)) The "exclude from" option specifies a filename
on the server 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.
The "filter" parameter takes a space-separated list of daemon filter rules,
though it is smart enough to know not to split a token at an internal space in
a rule (e.g. "- /foo - /bar" is parsed as two rules). You may specify one or
more merge-file rules using the normal syntax. Only one "filter" parameter can
apply to a given module in the config file, so put all the rules you want in a
single parameter. 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 during a client download operation if the per-dir merge files are
included in the transfer and the client requests that they be used.
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 server. 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(exclude)) The "exclude" parameter takes a space-separated list of daemon
exclude patterns. As with the client bf(--exclude) option, patterns can be
qualified with "- " or "+ " to explicitly indicate exclude/include. Only one
"exclude" parameter can apply to a given module. See the "filter" parameter
for a description of how excluded files affect the daemon.
dit(bf(include from)) The "include from" option specifies a filename
on the server 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(include)) Use an "include" to override the effects of the "exclude"
parameter. Only one "include" parameter can apply to a given module. See the
"filter" parameter for a description of how excluded files affect the daemon.
dit(bf(exclude from)) The "exclude from" parameter specifies the name of a file
on the daemon that contains daemon exclude patterns, one per line. Only one
"exclude from" parameter can apply to a given module; if you have multiple
exclude-from files, you can specify them as a merge file in the "filter"
parameter. See the "filter" parameter for a description of how excluded files
affect the daemon.
dit(bf(include from)) Analogue of "exclude from" for a file of daemon include
patterns. Only one "include from" parameter can apply to a given module. See
the "filter" parameter for a description of how excluded files affect the
daemon.
dit(bf(incoming chmod)) This option allows you to specify a set of
comma-separated chmod strings that will affect the permissions of all
incoming files (files that are being received by the daemon). These
changes happen after all other permission calculations, and this will
even override destination-default and/or existing permissions when the
client does not specify bf(--perms).
See the description of the bf(--chmod) rsync option and the bf(chmod)(1)
manpage for information on the format of this string.
dit(bf(outgoing chmod)) This option allows you to specify a set of
comma-separated chmod strings that will affect the permissions of all
outgoing files (files that are being sent out from the daemon). These
changes happen first, making the sent permissions appear to be different
than those stored in the filesystem itself. For instance, you could
disable group write permissions on the server while having it appear to
be on to the clients.
See the description of the bf(--chmod) rsync option and the bf(chmod)(1)
manpage for information on the format of this string.
dit(bf(auth users)) The "auth users" option specifies a comma and
space-separated list of usernames that will be allowed to connect to
@@ -264,14 +389,14 @@ 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
usernames and 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 bf(CONNECTING TO AN RSYNC SERVER OVER A REMOTE SHELL
PROGRAM) section in rsync(1) for information on how handle an
See also the "CONNECTING TO AN RSYNC DAEMON OVER A REMOTE SHELL
PROGRAM" section in bf(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 server.
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
@@ -281,13 +406,13 @@ username:password pairs separated by a single colon. Any line starting
with a hash (#) is considered a comment and is skipped. The passwords
can contain any characters but be warned that many operating systems
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.
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)). The file must normally not be readable
by "other"; see "strict modes".
dit(bf(strict modes)) The "strict modes" option determines whether or not
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
than the one that the rsync daemon is running under. If "strict modes" is
@@ -301,7 +426,7 @@ connection is rejected.
Each pattern can be in one of five forms:
quote(itemize(
quote(itemization(
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.
@@ -329,10 +454,10 @@ tt( fe80::%link1/ffff:ffff:ffff:ffff::)nl()
)
You can also combine "hosts allow" with a separate "hosts deny"
option. If both options are specified then the "hosts allow" option s
option. If both options are specified then the "hosts allow" option is
checked first and a match results in the client being able to
connect. The "hosts deny" option is then checked and a match means
that the host is rejected. If the host does not match either the
that the host is rejected. If the host does not match either the
"hosts allow" or the "hosts deny" patterns then it is allowed to
connect.
@@ -346,110 +471,79 @@ 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 server when deciding whether to run the delete
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.
behavior.
dit(bf(ignore nonreadable)) This tells the rsync server to completely
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
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. The server always logs the transfer at the end, so
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.
The prefixes that are understood are:
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 "send", "recv", or "del."
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 "" if not a symlink
it() %P for the module path
it() %m for the module name
it() %t for the current date time
it() %u for the authenticated username (or the null string)
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
))
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. "bf(%-50n %8l %07p)").
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.)
A perl script called rsyncstats to summarize this format is included
in the rsync source code distribution in the "support" subdirectory.
The single-character escapes that are understood are as follows:
The %i format is a set of cryptic characters that are output as follows:
quote(tt( =Xcstpog ITEM_NAME))
The bf(=) is output as either a bf(<) (receive) or a bf(>) (send) if the
item is being transferred, a bf(.) if only the attributes are being
updated, or a bf(=) if the items are identical. Note that when a symlink
or a device gets its value changed, that is considered to be a transfer (as
opposed to a change in permissions or ownership).
The bf(X) will be replaced by one of the following: an "f" for a file, a
"d" for a dir, an "L" for a symlink, or a "D" for a device.
The rest of the letters in the string above are the actual letters that
will be output if the associated attribute for the item is being updated or
a "." for no change. Three exceptions to this are: (1) a newly created
item replaces each letter with a "+", (2) an identical item replaces each
letter with a space, and (3) an unknown attribute replaces each letter with
a "?" (this happens when talking to an older rsync).
The attribute that is associated with each letter is as follows:
quote(itemize(
it() A bf(c) means the checksum of the file is different and will be
updated by the file transfer (requries bf(--checksum)).
it() A bf(s) means the size of the file is different and will be updated
by the file transfer.
it() A bf(t) means the modified time is different and is being updated to
the server's value (requires bf(--times)). An alternate value of bf(T)
means that the time will be set to the transfer time, which happens
anytime a symlink is transferred, or when a file or device is transferred
without bf(--times).
it() A bf(p) means the permissions are different and are being updated to
the server's value (requires bf(--perms)).
it() An bf(o) means the owner is being updated (requires bf(--owner) and
root privileges).
it() A bf(g) means the group is being updated (requires bf(--group) and
the authority to set the requested group).
quote(itemization(
it() %a the remote IP address
it() %b the number of bytes actually transferred
it() %B the permission bits of the file (e.g. rwxrwxrwt)
it() %c the checksum bytes received for this file (only when sending)
it() %f the filename (long form on sender; no trailing "/")
it() %G the gid of the file (decimal) or "DEFAULT"
it() %h the remote host name
it() %i an itemized list of what is being updated
it() %l the length of the file in bytes
it() %L the string " -> SYMLINK", " => HARDLINK", or "" (where bf(SYMLINK) or bf(HARDLINK) is a filename)
it() %m the module name
it() %M the last-modified time of the file
it() %n the filename (short form; trailing "/" on dir)
it() %o the operation, which is "send", "recv", or "del." (the latter includes the trailing period)
it() %p the process ID of this rsync session
it() %P the module path
it() %t the current date time
it() %u the authenticated username or an empty string
it() %U the uid of the file (decimal)
))
One other output is possible: when deleting files, each deleted file will
be logged with the "%i" taking on a value of "deleting".
For a list of what the characters mean that are output by "%i", see the
bf(--itemize-changes) option in the rsync manpage.
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 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.
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
@@ -460,39 +554,77 @@ 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
bf(remove-source-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).
delete modes without affecting bf(--remove-source-files).
When an option is refused, the server prints an error message and exits.
To prevent all compression, you can use "dont compress = *" (see below)
When an option is refused, the daemon prints an error message and exits.
To prevent all compression when serving files,
you can use "dont compress = *" (see below)
instead of "refuse options = compress" to avoid returning an error to a
client that requests compression.
dit(bf(dont compress)) The "dont compress" option allows you to select
filenames based on wildcard patterns that should not be compressed
during transfer. Compression is expensive in terms of CPU usage so it
when pulling files from the daemon (no analogous option exists to
govern the pushing of files to a daemon).
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.
such as already compressed files.
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 tt(*.gz *.tgz *.zip *.z *.rpm *.deb *.iso *.bz2 *.tbz)
See the bf(--skip-compress) option in the bf(rsync)(1) manpage for the list
of file suffixes that are not compressed by default. Specifying a value
for the "dont compress" option changes the default when the daemon is
the sender.
dit(bf(pre-xfer exec), bf(post-xfer exec)) You may specify a command to be run
before and/or after the transfer. If the bf(pre-xfer exec) command fails, the
transfer is aborted before it begins.
The following environment variables will be set, though some are
specific to the pre-xfer or the post-xfer environment:
quote(itemization(
it() bf(RSYNC_MODULE_NAME): The name of the module being accessed.
it() bf(RSYNC_MODULE_PATH): The path configured for the module.
it() bf(RSYNC_HOST_ADDR): The accessing host's IP address.
it() bf(RSYNC_HOST_NAME): The accessing host's name.
it() bf(RSYNC_USER_NAME): The accessing user's name (empty if no user).
it() bf(RSYNC_PID): A unique number for this transfer.
it() bf(RSYNC_REQUEST): (pre-xfer only) The module/path info specified
by the user (note that the user can specify multiple source files,
so the request can be something like "mod/path1 mod/path2", etc.).
it() bf(RSYNC_ARG#): (pre-xfer only) The pre-request arguments are set
in these numbered values. RSYNC_ARG0 is always "rsyncd", and the last
value contains a single period.
it() bf(RSYNC_EXIT_STATUS): (post-xfer only) the server side's exit value.
This will be 0 for a successful run, a positive value for an error that the
server generated, or a -1 if rsync failed to exit properly. Note that an
error that occurs on the client side does not currently get sent to the
server side, so this is not the final exit status for the whole transfer.
it() bf(RSYNC_RAW_STATUS): (post-xfer only) the raw exit value from code(waitpid()).
))
Even though the commands can be associated with a particular module, they
are run using the permissions of the user that started the daemon (not the
module's uid/gid setting) without any chroot restrictions.
enddit()
manpagesection(AUTHENTICATION STRENGTH)
The authentication protocol used in rsync is a 128 bit MD4 based
challenge response system. Although I believe that no one has ever
demonstrated a brute-force break of this sort of system you should
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.
challenge response system. This is fairly weak protection, though (with
at least one brute-force hash-finding algorithm publicly available), so
if you want really top-quality security, then I recommend that you run
rsync over ssh. (Yes, a future version of rsync will switch over to a
stronger hashing method.)
Also note that the rsync server protocol does not currently provide any
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.
@@ -500,32 +632,6 @@ encryption.
Future versions of rsync may support SSL for better authentication and
encryption, but that is still being investigated.
manpagesection(RUNNING AN RSYNC SERVER OVER A REMOTE SHELL PROGRAM)
If rsync is run with both the bf(--daemon) and bf(--rsh) (bf(-e)) options, it will
spawn an rsync daemon using a remote shell connection. Several
configuration options will not be available unless the remote user is
root (e.g. chroot, setuid/setgid, etc.). There is no need to configure
inetd or the services map to include the rsync server port if you run an
rsync server only via a remote shell program.
ADVANCED: To run an rsync server out of a single-use ssh key, use the
"command=em(COMMAND)" syntax in the remote user's authorized_keys entry,
where command would be
quote(tt(rsync --server --daemon .))
NOTE: rsync's argument parsing expects the trailing ".", so make sure
that it's there. If you want to use an rsyncd.conf(5)-style
configuration file other than the default, you can added a
bf(--config) option to the em(command):
quote(tt(rsync --server --daemon --config=em(file) .))
Note that the "--server" here is the internal option that rsync uses to
run the remote version of rsync that it communicates with, and thus you
should not be using the bf(--server) option under normal circumstances.
manpagesection(EXAMPLES)
A simple rsyncd.conf file that allow anonymous rsync to a ftp area at
@@ -542,23 +648,23 @@ A more sophisticated example would be:
verb(
uid = nobody
gid = nobody
use chroot = no
use chroot = yes
max connections = 4
syslog facility = local5
pid file = /var/run/rsyncd.pid
[ftp]
path = /var/ftp/pub
path = /var/ftp/./pub
comment = whole ftp area (approx 6.1 GB)
[sambaftp]
path = /var/ftp/pub/samba
path = /var/ftp/./pub/samba
comment = Samba ftp area (approx 300 MB)
[rsyncftp]
path = /var/ftp/pub/rsync
path = /var/ftp/./pub/rsync
comment = rsync ftp area (approx 6 MB)
[sambawww]
path = /public_html/samba
comment = Samba WWW pages (approx 240 MB)
@@ -583,21 +689,18 @@ manpagefiles()
manpageseealso()
rsync(1)
bf(rsync)(1)
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.x of rsync.
This man page is current for version 3.0.2 of rsync.
manpagesection(CREDITS)
@@ -618,8 +721,8 @@ 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
documentation!
daemon. Thanks to Karsten Thygesen for his many suggestions and
documentation!
manpageauthor()
@@ -627,4 +730,4 @@ 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)
url(http://lists.samba.org)(lists.samba.org)

View File

@@ -1,6 +1,7 @@
#! /bin/sh
# Copyright (C) 2001, 2002 by Martin Pool <mbp@samba.org>
# Copyright (C) 2003, 2004, 2005, 2006 Wayne Davison
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version
@@ -13,8 +14,7 @@
#
# 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.
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# rsync top-level test script -- this invokes all the other more
# detailed tests in order. This script can either be called by `make
@@ -49,8 +49,8 @@
# This script must be invoked from the build directory.
# A scratch directory, 'testtmp', is created in the build directory to
# hold working files.
# A scratch directory, 'testtmp', is used in the build directory to
# hold per-test subdirectories.
# This script also uses the $loglevel environment variable. 1 is the
# default value, and 10 the most verbose. You can set this from the
@@ -85,7 +85,7 @@
# they're explicitly given on the command line.
# Also, we can't count on 'cp -a' or 'mkdir -p', although they're
# pretty handy.
# pretty handy (see function makepath for the latter).
# I think some of the GNU documentation suggests that we shouldn't
# rely on shell functions. However, the Bash manual seems to say that
@@ -100,6 +100,8 @@
# You cannot do "export VAR=VALUE" all on one line; the export must be
# separate from the assignment. (SCO SysV)
# Don't rely on grep -q, as that doesn't work everywhere -- just redirect
# stdout to /dev/null to keep it quiet.
# STILL TO DO:
@@ -124,6 +126,7 @@ set -e
. "./shconfig"
RUNSHFLAGS='-e'
export RUNSHFLAGS
# for Solaris
[ -d /usr/xpg4/bin ] && PATH="/usr/xpg4/bin/:$PATH"
@@ -135,9 +138,27 @@ if [ "x$loglevel" != x ] && [ "$loglevel" -gt 8 ]; then
fi
fi
POSIXLY_CORRECT=1
if test x"$TOOLDIR" = x; then
TOOLDIR=`pwd`
fi
srcdir=`dirname $0`
if test x"$srcdir" = x -o x"$srcdir" = x.; then
srcdir="$TOOLDIR"
fi
if test x"$rsync_bin" = x; then
rsync_bin="$TOOLDIR/rsync"
fi
# This allows the user to specify extra rsync options -- use carefully!
RSYNC="$rsync_bin $*"
#RSYNC="valgrind $rsync_bin $*"
export POSIXLY_CORRECT TOOLDIR srcdir RSYNC
echo "============================================================"
echo "$0 running in `pwd`"
echo " rsync_bin=$rsync_bin"
echo "$0 running in $TOOLDIR"
echo " rsync_bin=$RSYNC"
echo " srcdir=$srcdir"
if [ -f /usr/bin/whoami ]; then
@@ -160,6 +181,19 @@ else
echo " preserve_scratch=no"
fi
# Check if setacl/setfacl is around and if it supports the -k or -s option.
if setacl -k u::7,g::5,o:5 testsuite 2>/dev/null; then
setfacl_nodef='setacl -k'
elif setfacl --help 2>&1 | grep ' -k,\|\[-[a-z]*k' >/dev/null; then
setfacl_nodef='setfacl -k'
elif setfacl -s u::7,g::5,o:5 testsuite 2>/dev/null; then
setfacl_nodef='setfacl -s u::7,g::5,o:5'
else
# The "true" command runs successfully, but does nothing.
setfacl_nodef=true
fi
export setfacl_nodef
if [ ! -f "$rsync_bin" ]; then
echo "rsync_bin $rsync_bin is not a file" >&2
@@ -171,29 +205,31 @@ if [ ! -d "$srcdir" ]; then
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
# Directory that holds the other test subdirs. We create separate dirs
# inside for each test case, so that they can be left behind in case of
# failure to aid investigation. We don't remove the testtmp subdir at
# the end so that it can be configured as a symlink to a filesystem that
# has ACLs and xattr support enabled (if desired).
scratchbase="$TOOLDIR"/testtmp
echo " scratchbase=$scratchbase"
[ -d "$scratchbase" ] || mkdir "$scratchbase"
suitedir="$srcdir/testsuite"
export scratchdir suitedir
prep_scratch() {
[ -d "$scratchdir" ] && rm -rf "$scratchdir"
[ -d "$scratchdir" ] && chmod -R u+rwX "$scratchdir" && rm -rf "$scratchdir"
mkdir "$scratchdir"
# Get rid of default ACLs and dir-setgid to avoid confusing some tests.
$setfacl_nodef "$scratchdir" || true
chmod g-s "$scratchdir"
ln -s "$srcdir" "$scratchdir/src"
return 0
}
@@ -209,7 +245,7 @@ fi
for testscript in $suitedir/$whichtests
do
testbase=`echo $testscript | sed -e 's!.*/!!' -e 's/.test\$//'`
scratchdir="$scratchbase.$testbase"
scratchdir="$scratchbase/$testbase"
prep_scratch

328
sender.c
View File

@@ -1,42 +1,50 @@
/*
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.
*/
* Routines only used by the sending process.
*
* Copyright (C) 1996 Andrew Tridgell
* Copyright (C) 1996 Paul Mackerras
* Copyright (C) 2003-2008 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, visit the http://fsf.org website.
*/
#include "rsync.h"
extern int verbose;
extern int dry_run;
extern int do_xfers;
extern int am_server;
extern int am_daemon;
extern int inc_recurse;
extern int log_before_transfer;
extern int log_format_has_i;
extern int daemon_log_format_has_i;
extern int stdout_format_has_i;
extern int logfile_format_has_i;
extern int csum_length;
extern int append_mode;
extern int io_error;
extern int allowed_lull;
extern int preserve_xattrs;
extern int protocol_version;
extern int remove_sent_files;
extern int remove_source_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 char *log_format;
extern struct file_list *cur_flist, *first_flist, *dir_flist;
/**
* @file
@@ -53,6 +61,7 @@ static struct sum_struct *receive_sums(int f)
{
struct sum_struct *s;
int32 i;
int lull_mod = allowed_lull * 5;
OFF_T offset = 0;
if (!(s = new(struct sum_struct)))
@@ -67,6 +76,13 @@ static struct sum_struct *receive_sums(int f)
(double)s->count, (long)s->blength, (long)s->remainder);
}
if (append_mode > 0) {
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);
@@ -86,6 +102,9 @@ static struct sum_struct *receive_sums(int f)
s->sums[i].len = s->blength;
offset += s->sums[i].len;
if (allowed_lull && !(i % lull_mod))
maybe_send_keepalive();
if (verbose > 3) {
rprintf(FINFO,
"chunk[%d] len=%d offset=%.0f sum1=%08x\n",
@@ -99,131 +118,162 @@ static struct sum_struct *receive_sums(int f)
return s;
}
static struct file_list *the_flist;
void successful_send(int i)
void successful_send(int ndx)
{
char fname[MAXPATHLEN];
struct file_struct *file;
unsigned int offset;
struct file_list *flist;
if (!the_flist || i < 0 || i >= the_flist->count)
if (!remove_source_files)
return;
file = the_flist->files[i];
/* The generator might tell us about symlinks we didn't send. */
if (!(file->flags & FLAG_SENT) && !S_ISLNK(file->mode))
if (!(flist = flist_for_ndx(ndx))) {
rprintf(FERROR,
"INTERNAL ERROR: unable to find flist for item %d\n",
ndx);
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));
}
file = flist->files[ndx - flist->ndx_start];
if (!change_pathname(file, NULL, 0))
return;
f_name(file, fname);
if (do_unlink(fname) == 0) {
if (verbose > 1)
rprintf(FINFO, "sender removed %s\n", fname);
} else
rsyserr(FERROR, errno, "sender failed to remove %s", fname);
}
void send_files(struct file_list *flist, int f_out, int f_in)
static void write_ndx_and_attrs(int f_out, int ndx, int iflags,
const char *fname, struct file_struct *file,
uchar fnamecmp_type, char *buf, int len)
{
write_ndx(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);
#ifdef SUPPORT_XATTRS
if (preserve_xattrs && iflags & ITEM_REPORT_XATTR && !dry_run)
send_xattr_request(fname, file, f_out);
#endif
}
void send_files(int f_in, int f_out)
{
int fd = -1;
struct sum_struct *s;
struct map_struct *mbuf = NULL;
STRUCT_STAT st;
char *fname2, fname[MAXPATHLEN];
int iflags;
char fname[MAXPATHLEN], xname[MAXPATHLEN];
const char *path, *slash;
uchar fnamecmp_type;
int iflags, xlen;
struct file_struct *file;
int phase = 0;
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 i, j;
int itemizing = am_server ? logfile_format_has_i : stdout_format_has_i;
enum logcode log_code = log_before_transfer ? FLOG : FINFO;
int f_xfer = write_batch < 0 ? batch_fd : f_out;
int ndx, j;
if (verbose > 2)
rprintf(FINFO, "send_files starting\n");
the_flist = flist;
while (1) {
unsigned int offset;
if (inc_recurse)
send_extra_file_list(f_out, FILECNT_LOOKAHEAD);
i = read_int(f_in);
if (i == -1) {
if (phase == 0) {
phase++;
csum_length = SUM_LENGTH;
write_int(f_out, -1);
if (verbose > 2)
rprintf(FINFO, "send_files phase=%d\n", phase);
/* For inplace: redo phase turns off the backup
* flag so that we do a regular inplace send. */
make_backups = 0;
continue;
/* This call also sets cur_flist. */
ndx = read_ndx_and_attrs(f_in, &iflags, &fnamecmp_type,
xname, &xlen);
if (ndx == NDX_DONE) {
if (inc_recurse && first_flist) {
flist_free(first_flist);
if (first_flist) {
write_ndx(f_out, NDX_DONE);
continue;
}
}
break;
if (++phase > max_phase)
break;
if (verbose > 2)
rprintf(FINFO, "send_files phase=%d\n", phase);
write_ndx(f_out, NDX_DONE);
continue;
}
if (i < 0 || i >= flist->count) {
rprintf(FERROR, "Invalid file index %d (count=%d)\n",
i, flist->count);
exit_cleanup(RERR_PROTOCOL);
}
if (inc_recurse)
send_extra_file_list(f_out, FILECNT_LOOKAHEAD);
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 (ndx - cur_flist->ndx_start >= 0)
file = cur_flist->files[ndx - cur_flist->ndx_start];
else
file = dir_flist->files[cur_flist->parent_ndx];
if (F_PATHNAME(file)) {
path = F_PATHNAME(file);
slash = "/";
} else {
path = slash = "";
}
if (!change_pathname(file, NULL, 0))
continue;
f_name(file, fname);
if (verbose > 2)
rprintf(FINFO, "send_files(%d, %s)\n", i, fname);
rprintf(FINFO, "send_files(%d, %s%s%s)\n", ndx, path,slash,fname);
if (protocol_version >= 29) {
iflags = read_shortint(f_in);
if (!(iflags & ITEM_UPDATING) || !S_ISREG(file->mode)) {
int see_item = itemizing && (iflags || verbose > 1);
write_int(f_out, i);
write_shortint(f_out, iflags);
if (am_server) {
if (am_daemon && !dry_run && see_item)
log_send(file, &stats, iflags);
} else if (see_item || iflags & ITEM_UPDATING
|| (S_ISDIR(file->mode)
&& iflags & ITEM_REPORT_TIME))
log_send(file, &stats, iflags);
continue;
}
} else
iflags = ITEM_UPDATING | ITEM_MISSING_DATA;
#ifdef SUPPORT_XATTRS
if (preserve_xattrs && iflags & ITEM_REPORT_XATTR && !dry_run)
recv_xattr_request(file, f_in);
#endif
if (inplace && protocol_version >= 29) {
updating_basis_file = !(iflags & ITEM_USING_ALT_BASIS);
} else
updating_basis_file = inplace && !make_backups;
if (!S_ISREG(file->mode)) {
rprintf(FERROR, "[%s] got index of non-regular file: %d\n",
who_am_i(), i);
if (!(iflags & ITEM_TRANSFER)) {
maybe_log_item(file, iflags, itemizing, xname);
write_ndx_and_attrs(f_out, ndx, iflags, fname, file,
fnamecmp_type, xname, xlen);
continue;
}
if (phase == 2) {
rprintf(FERROR,
"got transfer request in phase 2 [%s]\n",
who_am_i());
exit_cleanup(RERR_PROTOCOL);
}
stats.current_file_index = i;
stats.num_transferred_files++;
stats.total_transferred_size += file->length;
if (file->flags & FLAG_FILE_SENT) {
if (csum_length == SHORT_SUM_LENGTH) {
/* For inplace: redo phase turns off the backup
* flag so that we do a regular inplace send. */
make_backups = -make_backups;
append_mode = -append_mode;
csum_length = SUM_LENGTH;
}
} else {
if (csum_length != SHORT_SUM_LENGTH) {
make_backups = -make_backups;
append_mode = -append_mode;
csum_length = SHORT_SUM_LENGTH;
}
}
if (dry_run) { /* log the transfer */
if (!am_server && log_format)
log_send(file, &stats, iflags);
write_int(f_out, i);
if (protocol_version >= 29)
write_shortint(f_out, iflags);
updating_basis_file = inplace && (protocol_version >= 29
? fnamecmp_type == FNAMECMP_FNAME : make_backups <= 0);
if (!am_server && do_progress)
set_current_file_index(file, ndx);
stats.num_transferred_files++;
stats.total_transferred_size += F_LENGTH(file);
if (!do_xfers) { /* log the transfer */
log_item(FCLIENT, file, &stats, iflags, NULL);
write_ndx_and_attrs(f_out, ndx, iflags, fname, file,
fnamecmp_type, xname, xlen);
continue;
}
@@ -232,7 +282,7 @@ void send_files(struct file_list *flist, int f_out, int f_in)
if (!(s = receive_sums(f_in))) {
io_error |= IOERR_GENERAL;
rprintf(FERROR, "receive_sums failed\n");
return;
exit_cleanup(RERR_PROTOCOL);
}
fd = do_open(fname, O_RDONLY, 0);
@@ -240,17 +290,19 @@ void send_files(struct file_list *flist, int f_out, int f_in)
if (errno == ENOENT) {
enum logcode c = am_daemon
&& protocol_version < 28 ? FERROR
: FINFO;
: FWARNING;
io_error |= IOERR_VANISHED;
rprintf(c, "file has vanished: %s\n",
full_fname(fname));
} else {
io_error |= IOERR_GENERAL;
rsyserr(FERROR, errno,
rsyserr(FERROR_XFER, errno,
"send_files failed to open %s",
full_fname(fname));
}
free_sums(s);
if (protocol_version >= 30)
send_msg_int(MSG_NO_SEND, ndx);
continue;
}
@@ -260,7 +312,7 @@ void send_files(struct file_list *flist, int f_out, int f_in)
rsyserr(FERROR, errno, "fstat failed");
free_sums(s);
close(fd);
return;
exit_cleanup(RERR_PROTOCOL);
}
if (st.st_size) {
@@ -270,36 +322,35 @@ void send_files(struct file_list *flist, int f_out, int f_in)
mbuf = NULL;
if (verbose > 2) {
rprintf(FINFO, "send_files mapped %s of size %.0f\n",
safe_fname(fname), (double)st.st_size);
rprintf(FINFO, "send_files mapped %s%s%s of size %.0f\n",
path,slash,fname, (double)st.st_size);
}
write_int(f_out, i);
if (protocol_version >= 29)
write_shortint(f_out, iflags);
write_sum_head(f_out, s);
write_ndx_and_attrs(f_out, ndx, iflags, fname, file,
fnamecmp_type, xname, xlen);
write_sum_head(f_xfer, s);
if (verbose > 2) {
rprintf(FINFO, "calling match_sums %s\n",
safe_fname(fname));
}
if (verbose > 2)
rprintf(FINFO, "calling match_sums %s%s%s\n", path,slash,fname);
if (log_before_transfer)
log_send(file, &initial_stats, iflags);
log_item(FCLIENT, file, &initial_stats, iflags, NULL);
else if (!am_server && verbose && do_progress)
rprintf(FINFO, "%s\n", safe_fname(fname2));
rprintf(FCLIENT, "%s\n", fname);
set_compression(fname);
match_sums(f_out, s, mbuf, st.st_size);
if (!log_before_transfer)
log_send(file, &initial_stats, iflags);
match_sums(f_xfer, s, mbuf, st.st_size);
if (do_progress)
end_progress(st.st_size);
log_item(log_code, file, &initial_stats, iflags, NULL);
if (mbuf) {
j = unmap_file(mbuf);
if (j) {
io_error |= IOERR_GENERAL;
rsyserr(FERROR, j,
rsyserr(FERROR_XFER, j,
"read errors mapping %s",
full_fname(fname));
}
@@ -308,20 +359,19 @@ void send_files(struct file_list *flist, int f_out, int f_in)
free_sums(s);
if (verbose > 2) {
rprintf(FINFO, "sender finished %s\n",
safe_fname(fname));
}
if (verbose > 2)
rprintf(FINFO, "sender finished %s%s%s\n", path,slash,fname);
/* Flag that we actually sent this entry. */
file->flags |= FLAG_SENT;
file->flags |= FLAG_FILE_SENT;
}
make_backups = save_make_backups;
if (make_backups < 0)
make_backups = -make_backups;
if (verbose > 2)
rprintf(FINFO, "send files finished\n");
match_report();
write_int(f_out, -1);
write_ndx(f_out, NDX_DONE);
}

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