Compare commits

...

715 Commits

Author SHA1 Message Date
Wayne Davison
c1456d83a7 Tweaked the date. 2004-01-01 19:00:11 +00:00
Wayne Davison
1cbbaea957 Preparing for release of 2.6.0 2004-01-01 11:36:16 +00:00
Wayne Davison
f6aeaa74d1 One more tweak to --modify-window verbage. 2003-12-30 18:17:16 +00:00
Wayne Davison
6839140eb5 Shorten some of the lines in the --help output. 2003-12-30 18:16:25 +00:00
Wayne Davison
915dd20705 Shortened a few lines, plus a couple minor tweaks. 2003-12-30 17:44:01 +00:00
Wayne Davison
c53217a2b8 Changed the VERSION section to refer to 2.x instead of 2.0. 2003-12-29 09:58:06 +00:00
Wayne Davison
b2ac00eb16 Preparing for release of 2.6.0pre2 2003-12-28 21:11:38 +00:00
Wayne Davison
45ddbf6204 Make the upper copyright year "2004". 2003-12-28 20:48:06 +00:00
Wayne Davison
276877cf77 Aged news from NEWS to OLDNEWS. 2003-12-27 00:14:21 +00:00
Wayne Davison
6b45fcf160 Undid previous change. 2003-12-26 23:04:01 +00:00
Wayne Davison
49c24eccd4 A change that wasn't needed. 2003-12-26 22:59:53 +00:00
Wayne Davison
0d7d3763f2 Use %{version} to refer to the current version. 2003-12-24 17:48:25 +00:00
Wayne Davison
241dc65eee Getting rid of klunky *.tmpl files. 2003-12-24 17:46:46 +00:00
Wayne Davison
860bdd4571 Mention the new-backup-dir mode change. 2003-12-24 01:46:38 +00:00
Wayne Davison
55bf051bbc Getting rid of an extra newline that accidentally crept into the code. 2003-12-24 01:46:07 +00:00
Wayne Davison
423dba8ea1 Simplified an internal function's name to remove a potentially
cryptic suffix.
2003-12-24 01:14:16 +00:00
Wayne Davison
517c7b4dee Updated the copyright year. 2003-12-20 18:00:13 +00:00
Wayne Davison
18ced14631 Output a warning about the new remote-shell default if the --with-rsh
option wasn't used.
2003-12-20 17:57:47 +00:00
Wayne Davison
ce67256218 Output a newline before the heap statistics. 2003-12-20 16:57:24 +00:00
Wayne Davison
9e83fa99fe - Mention the extra newlines in the verbose/stats output.
- Made some spelling corrections.
2003-12-20 16:56:51 +00:00
Wayne Davison
256a9e376c Added a couple missing items from John Van Essen. 2003-12-20 16:51:13 +00:00
Wayne Davison
ef5075e092 Quiet a compiler warning. 2003-12-19 22:19:54 +00:00
Wayne Davison
65653a6596 Mention the change we made to help ssh cleanup the tty on Ctrl-C. 2003-12-19 20:21:17 +00:00
Wayne Davison
d5a0b48379 Do a small msleep() in the sig_int() handler before shutting down.
This kluge allows things like SIGINT to find our children before
we go throwing around SIGUSR1's at them.
2003-12-19 06:52:02 +00:00
Wayne Davison
314a74d731 Got rid of the RSYNC_RSH_IO stuff for now. 2003-12-17 09:29:35 +00:00
Wayne Davison
90e22f4b51 Backed out the RSYNC_RSH_IO support for now. 2003-12-17 09:28:45 +00:00
J.W. Schultz
ab304c268c Removed hardlink reporting bug from TODO list -- seems to be
fixed.
2003-12-17 00:52:01 +00:00
J.W. Schultz
16a3fec02d Added keword base reporting to TODO features list. 2003-12-17 00:49:50 +00:00
J.W. Schultz
abb0b532f8 Reorganized and cleaned up TODO list. 2003-12-17 00:47:39 +00:00
Wayne Davison
43cd760fc1 - Changed the places that talked about rsh being the default shell.
- Document the new RSYNC_RSH_IO environment variable.
2003-12-16 23:07:19 +00:00
Wayne Davison
9af87151ec We now support an environment variable named RSYNC_RSH_IO which lets the
user set the blocking-IO value for the shell specified by RSYNC_RSH.
2003-12-16 23:06:25 +00:00
Wayne Davison
8dd99390f5 Added RSYNC_RSH_IO_ENV. 2003-12-16 23:04:59 +00:00
Wayne Davison
e636af6b23 Mention change to ssh. 2003-12-16 19:48:25 +00:00
Wayne Davison
e3217f1448 Tweaked an obsolete comment. 2003-12-16 18:02:15 +00:00
Wayne Davison
66b711633f Improved the default-blocking-I/O code to discern rsh from ssh
properly.
2003-12-16 18:02:03 +00:00
Wayne Davison
f40f2fc8ce Made the default remote-shell be "ssh" (override with --with-rsh=FOO). 2003-12-16 18:01:06 +00:00
Wayne Davison
e6f9e388cf Moved the information on the single-use ssh key so that the --server
option wasn't being mentioned early in the rsync manpage (which has
confused at least one user trying to figure out the --daemon mode
command-line syntax).
2003-12-15 20:10:21 +00:00
Wayne Davison
3c1e2ad956 Document new error code 24. 2003-12-15 19:49:38 +00:00
Wayne Davison
e6d2799170 Updated version. 2003-12-15 19:04:04 +00:00
Wayne Davison
2cfbf4bc0e Changed the version to 2.6.0pre1. 2003-12-15 19:00:20 +00:00
Wayne Davison
f7731f1fc2 Removed some obsolete items. 2003-12-15 18:45:27 +00:00
Wayne Davison
7d3f8ae2df Make sure we only use blocking-I/O if blocking_io is > 0. 2003-12-15 18:45:07 +00:00
Wayne Davison
a60fdd63f4 Changed version to 2.6.0. 2003-12-15 18:25:10 +00:00
Wayne Davison
3a7dec59bc Changed version to 2.6.0 in preparation for new release. 2003-12-15 18:22:12 +00:00
Wayne Davison
880ae34190 Got rid of setgroups() caveat for OSX -- we fixed that a while back. 2003-12-15 18:20:06 +00:00
Wayne Davison
d00daf1f3f Mentioned the vanished-file warning enhancement. 2003-12-15 08:44:55 +00:00
Wayne Davison
17fadf7d40 Twiddled some whitespace and multi-line comments. 2003-12-15 08:14:27 +00:00
Wayne Davison
06c28400fa New "io_error" variable handling for RERR_VANISHED support. 2003-12-15 08:10:31 +00:00
Wayne Davison
6e35c72fdb Return new RERR_VANISHED code, as appropriate. 2003-12-15 08:08:44 +00:00
Wayne Davison
e2d22fee53 Added new IOERR_* defines. 2003-12-15 08:07:38 +00:00
Wayne Davison
1bca1de6cc Handle new RERR_VANISHED error. 2003-12-15 08:06:52 +00:00
Wayne Davison
e0ed4e4087 Added RERR_VANISHED. 2003-12-15 08:04:14 +00:00
Wayne Davison
4a7319be12 Neatened up some whitespace issues and made multi-line comments more
consistent.
2003-12-15 01:45:01 +00:00
Wayne Davison
55d5937dd6 Simplified the setting of the reading_remotely variable in function
read_filesfrom_line() now that remote_filesfrom_file is set more
often.
2003-12-15 00:54:44 +00:00
Wayne Davison
63596e1c4a If we're the server and --files-from is "-", set remote_filesfrom_file
to "-" as well (since the data is coming over the socket from the remote
side).
2003-12-15 00:53:07 +00:00
Wayne Davison
603e6b05c7 Neatened up the indentation. 2003-12-12 17:13:22 +00:00
J.W. Schultz
dfad66a838 Sanity check s2length on recept. 2003-12-06 21:35:34 +00:00
Wayne Davison
58cadc8608 Merged in the security fixes from 2.5.7. 2003-12-06 21:07:27 +00:00
J.W. Schultz
b11b50bcd0 Added reminder to update rsync.yo manpage when adding to
exit codes.
2003-10-25 20:02:45 +00:00
Wayne Davison
a73de5f3ba Added exit code 0. 2003-10-25 17:53:57 +00:00
Wayne Davison
84c3645cea Updated exit codes as Jon Jensen and J.W. suggested. 2003-10-25 16:21:41 +00:00
Wayne Davison
2a88a8cd30 Fixed an operator-precedence problem in the batch-mode code. 2003-10-13 23:46:08 +00:00
Wayne Davison
8a97fc2e1b Tried to improve the documentation surrounding a trailing-slash
source-dir transfer.
2003-10-07 20:33:08 +00:00
Wayne Davison
7a2fd68b96 Tweaked the just-added error message to use my new full_fname()
function.  Also removed some trailing whitespace from lines.
2003-09-16 05:33:09 +00:00
J.W. Schultz
6a7cc46cb2 Detect and report when open or opendir succeed but read and
readdir fail caused by network filesystems issues and
truncated files.
			Thanks to David Norwood and Michael Brown
2003-09-16 02:49:59 +00:00
Wayne Davison
aa6dc37ccb Mention my recent changes. 2003-09-11 05:00:52 +00:00
Wayne Davison
ea42541fe0 Improved file-related error messages by using the new
full_fname() function.
2003-09-11 04:53:05 +00:00
Wayne Davison
b7b2741f3a Tweaked an error message. 2003-09-11 04:53:01 +00:00
Wayne Davison
eb61be192d Added a new function, full_fname(), that makes a filename more complete
for error messages.  If the path is in a module, we ensure that the
"path" setting (from the config file) is not revealed, while still
reminding the user that the path is relative to the module's root.
2003-09-11 04:48:15 +00:00
Wayne Davison
9b9114e8cd Include a few new stubs to handle the new full_fname() function. 2003-09-11 04:48:13 +00:00
Wayne Davison
857e38bb45 Got rid of some "/* dw */" comments and fixed some line's indentation. 2003-09-11 04:48:09 +00:00
Wayne Davison
4ea812445d Got rid of some "/* dw */" comments. 2003-09-11 04:48:07 +00:00
Wayne Davison
e80a765412 If lp_path() returns "/", set exclude_path_prefix to "" (because the
exclude code doesn't want any trailing slashes).
2003-09-11 04:00:19 +00:00
Wayne Davison
15089022d4 Make sure that the new slash-stripping P_PATH code doesn't turn
a "/" into an empty string.
2003-09-11 03:49:53 +00:00
Wayne Davison
f69204adad Changed main() definition to avoid an extra prototype being put
into the proto.h file.
2003-09-10 08:27:34 +00:00
Wayne Davison
459a83c9cc Make sure that the "path" value has any trailing slashes removed. 2003-09-10 08:08:14 +00:00
Wayne Davison
6464bdbe13 Got rid of trailing whitespace. 2003-09-10 07:31:58 +00:00
Wayne Davison
4f3e9a0fba Added the new --protocol option. 2003-09-09 15:58:56 +00:00
Wayne Davison
8a9709dee5 Changed most instances of "remote_version" to "protocol_version", and
others to "remote_protocol".  Downgrade the protocol_version if the
remote_protocol" is lower.  Output the protocol values if the verbose
level is large enough.  Exit if the user tried to force a protocol
value that is not within the range that we can handle.  Fixed the
output of the "very old version of rsync" message to output the right
Client/Server string.
2003-09-09 15:58:53 +00:00
Wayne Davison
daa598df11 Changed most instances of "remote_version" to "protocol_version", and
others to "remote_protocol".  Downgrade the protocol_version if the
remote_protocol is lower.
2003-09-09 15:58:50 +00:00
Wayne Davison
d04e9c51b4 Changed "remote_version" to "protocol_version". 2003-09-09 15:58:48 +00:00
J.W. Schultz
d89a3a313a *** empty log message *** 2003-09-04 05:54:20 +00:00
J.W. Schultz
350e4e4dec Allow non-dir special files to be replaced with regular
files and fix error that caused directories in link-dest or
compare-dest to prevent the creation of files of same path.
2003-09-04 05:49:50 +00:00
Wayne Davison
c95dcb3935 Cast various s->blength references inside of MIN() macros to OFF_T
so that compilers don't warn about signed/unsigned comparisons.
2003-08-22 21:26:08 +00:00
Wayne Davison
1e4f48d6c4 Whitespace tweaks. 2003-08-22 05:51:42 +00:00
Wayne Davison
fb55e28d83 Fixed the multiplying of blength*blength so that it can't overflow
before it gets cast to a uint64.
2003-08-22 05:42:13 +00:00
Wayne Davison
067669dac7 Made the UNUSED(parameter) macro calls read a little nicer. 2003-08-22 05:04:13 +00:00
Wayne Davison
24c906d3f7 Mark unused vars. 2003-08-22 00:31:46 +00:00
Wayne Davison
14820f635d Make extra backup dirs mode 0700, not 0755. 2003-08-22 00:30:46 +00:00
Wayne Davison
59192f5650 Got rid of a duplicate include for malloc.h and improved the "do we
need malloc.h" logic a bit more.  (Trying to prevent #warning and
#error problems on *BSD systems.)
2003-08-21 23:54:20 +00:00
Wayne Davison
365346ca30 Got rid of signed/unsigned-comparison warning if st_rdev is signed. 2003-08-21 23:46:10 +00:00
Wayne Davison
d01350a881 Got rid of signed/unsigned-comparison warning if st_dev is signed. 2003-08-21 23:45:49 +00:00
Wayne Davison
38b02c13d0 Let's try only including malloc.h if stdlib.h isn't around (and it
exists).
2003-08-21 23:32:35 +00:00
Wayne Davison
b017ec4e13 Silenced a couple compiler warnings. 2003-08-21 23:28:24 +00:00
Wayne Davison
2c873122b3 Mention some more bug fixes. 2003-08-20 23:36:45 +00:00
Wayne Davison
6969ebcfcf Call setgroups(1, &gid) after setting the gid (rather than calling
setgroups(0, NULL) before).
2003-08-20 23:25:52 +00:00
Wayne Davison
1dbb94cadf Use the AVAIL_OUT_SIZE() macro in a few more places to ensure
that the avail_out buffer is big enough to uncompress all the
compressed data.
2003-08-20 10:37:53 +00:00
Wayne Davison
8a78bb963d Fixed a couple option-name typos (that had '_' instead of '-'). 2003-08-18 23:52:43 +00:00
Wayne Davison
6931c13800 - Made special exclusion-handling of '.' work in -R mode (so that we
can't accidentally lose the '.' dir and not transfer anything at all).
- Add a trailing '.' onto all '/'-trailing names, even '/' (fixes
  skipped deletions in -R mode from '/').
- Fixed loss of FLAG_DELETE on user-specified dir when unduplicating '.'
  (could happen on "./." or similar).
2003-08-17 21:29:11 +00:00
J.W. Schultz
e6e3f12ffc Whitespace and indentation cleanup. There is a lot of deep
indentation mostly due to read_batch but at least it is now
consistant.
2003-08-15 00:57:27 +00:00
J.W. Schultz
e2559dbedc Make --progress imply --verbose without incrementing verbosity. 2003-08-06 06:45:14 +00:00
Wayne Davison
1f3d6cdd86 Got rid of unused OPT_* enums. 2003-08-05 17:56:54 +00:00
Wayne Davison
4a7ee79d4d Improved the mkstemp error message. 2003-08-04 21:03:07 +00:00
Wayne Davison
0c2ef5f42d Make sure that the error message for mkstemp() includes the full
path of where we're trying to create the temp file.
2003-08-04 21:00:57 +00:00
Wayne Davison
ca20c7fd62 Instead of ignoring SIG_CHLD, reap zombies in the signal handler. 2003-08-04 18:27:27 +00:00
Wayne Davison
191e40da17 Change the way we pass the --suffix option to the remote process so
that a string that starts with ~ doesn't get modified.
2003-08-01 20:19:51 +00:00
Wayne Davison
80ddadb7e8 Complain if the --suffix value contains slashes (which is all too easy
to accidentally have happen if you try to specify "~" with --backup-dir).
2003-08-01 19:40:31 +00:00
Wayne Davison
31f3b68a97 We should bump the deletion_count for backed-up deleted files too. 2003-08-01 08:20:53 +00:00
Wayne Davison
d594399c6a Mention the --backup fix. 2003-08-01 08:01:15 +00:00
Wayne Davison
d74a2e3ed5 Properly handle the backup_suffix/backup_dir settings when deleting
files.  Also optimized the code that calls delete_one().  Don't
neglect to mention a file being deleted with --backup set.
2003-08-01 07:58:47 +00:00
Wayne Davison
d175d7e13e Got rid of suffix_specified and instead set backup_suffix to the
correct default value for the current backup_dir mode.  Added two
new values: backup_suffix_len and backup_dir_len.  Improved some
error-message code to not output duplicate errors.
2003-08-01 07:58:44 +00:00
Wayne Davison
daa8ce838b Use the new backup_suffix_len and backup_dir_len variables. Got rid
of the suffix_specified kludge.
2003-08-01 07:58:41 +00:00
Wayne Davison
b19fd07c02 Clarify some --backup/--backup-dir/--suffix issues. 2003-08-01 00:50:23 +00:00
J.W. Schultz
47d6a60c2f Whitespace and indentation fixes. 2003-07-31 09:32:15 +00:00
Wayne Davison
980821ebab No longer needed (replaced by wildmatch). 2003-07-30 06:13:47 +00:00
Wayne Davison
592f4696dc Updated the exclude/include section to mention the "**" vs "*" change. 2003-07-30 06:12:41 +00:00
Wayne Davison
8a7846f97e Changed the "**" description to reflect its no-longer-buggy behavior. 2003-07-30 06:12:33 +00:00
Wayne Davison
87f18b6289 Include "lib/wildmatch.h", not "lib/fnmatch.h" or <fnmatch.h>. 2003-07-30 06:12:31 +00:00
Wayne Davison
28063ba5b2 Got rid of test for fnmatch. 2003-07-30 06:12:29 +00:00
Wayne Davison
fe332038c6 Call wildmatch(), not fnmatch(). 2003-07-30 06:12:27 +00:00
Wayne Davison
3c0b1ebf78 Changed lib/fnmatch.o to lib/wildmatch.o. 2003-07-30 06:12:25 +00:00
Wayne Davison
f2fe4903c9 Made the list of exclude/include changes more prominent and clear. 2003-07-26 18:13:38 +00:00
Wayne Davison
3151cbae89 Some superficial tweaks I made while reading through the io.c code. 2003-07-26 17:55:07 +00:00
Wayne Davison
3c30b99059 Added one more test. 2003-07-14 15:46:34 +00:00
Wayne Davison
a7735ba085 Updated for latest character-class change. 2003-07-14 15:13:31 +00:00
Wayne Davison
d811b68901 Make sure that no character class can match a '/'. 2003-07-14 15:12:59 +00:00
Wayne Davison
1c8162a921 Optimized show_progress() to reduce the calls to gettimeofday() when
am_server is set.  No need to check do_progress here anymore, since
we aren't called if do_progress isn't set.
2003-07-08 16:54:53 +00:00
Wayne Davison
16417f8b9d Only call show_progress() and end_progress() if do_progress is set. 2003-07-08 16:49:10 +00:00
Wayne Davison
b49d381d05 Changed "./0123456789" to just ".0123456789". 2003-07-07 19:37:58 +00:00
Wayne Davison
7da9a16d10 I decided to go with the slightly simpler logic Thorild Selen suggested
in a subsequent email.
2003-07-07 18:37:38 +00:00
Wayne Davison
32f60a6e7b Improved deficiencies in the hostname-vs-address check (reintroduced in the
last revision) based on the suggestions of Thorild Selen.
2003-07-07 18:25:01 +00:00
Wayne Davison
b7db090661 Commented-out a test that wasn't consistent across all platforms. 2003-07-07 07:28:02 +00:00
Wayne Davison
136c5c5ec3 Silence some compiler warnings on HP-UX. 2003-07-07 07:22:08 +00:00
Wayne Davison
85b80fbc73 A few more tests. 2003-07-07 07:10:40 +00:00
Wayne Davison
16859cdbdc Improved the summary output to use correct English for all counts. 2003-07-07 07:08:24 +00:00
Wayne Davison
fc96552d26 Don't treat "[:" as the start of a named set if there's no ":]". 2003-07-07 07:07:16 +00:00
Wayne Davison
15bb997d0a Added a few more items to the tests. 2003-07-06 18:54:08 +00:00
Wayne Davison
b6b42c892c Improve the format of the --iterations output. 2003-07-06 18:29:24 +00:00
Wayne Davison
5bb920003e - Return ABORT_ALL for a syntax error in the pattern (not FALSE).
- Abort if the [:class:] name is not known.
2003-07-06 18:26:34 +00:00
Wayne Davison
37ff0e344d Added match for new "no errors" line from wildtest. 2003-07-06 17:41:37 +00:00
Wayne Davison
97d53f8c75 Switch to using an input file so that backslashes are specified
normally, and so that test additions and changes are easier.
2003-07-06 17:41:01 +00:00
Wayne Davison
f2ac84c36d Added some portability code for the ctype functions. 2003-07-06 16:29:32 +00:00
Wayne Davison
c21eeef5bc Updated for latest wildmatch.c changes. 2003-07-06 04:34:19 +00:00
Wayne Davison
e11c425119 - Added [:class:] handling to the character-class code.
- Use explicit unsigned characters for proper set checks.
- Made the character-class code honor backslash escapes.
- Accept '^' as a class-negation character in addition to '!'.
2003-07-06 04:33:54 +00:00
Wayne Davison
84229c7ac9 We now figure out if diff accepts -u and we'll use it instead of -c,
if possible.
2003-07-05 22:57:08 +00:00
Wayne Davison
c9a59880f0 Simplified the character-class code a bit. 2003-07-05 22:40:27 +00:00
Wayne Davison
9a17dddbc5 Fixed the output of popt errors and changed our one option to be
--iterations (-i).
2003-07-05 19:21:41 +00:00
Wayne Davison
277d99e8c9 A wildtest change to handle someone using the included popt lib. 2003-07-05 19:14:10 +00:00
Wayne Davison
2a1874cc82 Added dependencies for wildtest.o. 2003-07-05 19:06:49 +00:00
Wayne Davison
d5c973ccb7 Changed some names since "depth" wasn't really the right term. 2003-07-05 19:03:42 +00:00
Wayne Davison
37f3ce61bb Another change to the wildtest rule to make it more portable. 2003-07-05 18:55:09 +00:00
Wayne Davison
076f60eed0 Added a --depth option to report recursion depth values. 2003-07-05 18:49:38 +00:00
Wayne Davison
20b2e9cef7 Improved the ABORT logic to allow aborting consecutive "*" wildcards
back to a "**" wildcard.  Added optional debug code for recursion stats.
2003-07-05 18:48:34 +00:00
Wayne Davison
e37d8229f5 Changed the build rule for wildtest. 2003-07-05 18:46:02 +00:00
Wayne Davison
710faea9a4 Added in the ABORT optimization logic from a newer wildmat release,
adapted for our code that distinguishes "**" from "*".
2003-07-05 17:30:53 +00:00
Wayne Davison
70a6051cf1 Restored an isdigit() check in the match_address() function, but check
the last character in the hostname, not the first.
2003-07-05 07:39:57 +00:00
Wayne Davison
7a1f46b6ac A couple comment tweaks. 2003-07-05 07:22:13 +00:00
Wayne Davison
7ca9250db0 Changed "diff -u" back to "diff -c" (for portability). 2003-07-05 07:09:31 +00:00
Wayne Davison
af7086c63f Change most SAME-AS-FNMATCH "false" values to "true" (since we _should_
work the same as fnmatch in most cases, if fnmatch was actually working
right).
2003-07-05 07:03:56 +00:00
Wayne Davison
8808589277 Get rid of a couple compiler warnings. 2003-07-05 06:56:16 +00:00
Wayne Davison
6cd5096063 Don't define COMPARE_WITH_FNMATCH by default. 2003-07-05 06:53:41 +00:00
Wayne Davison
677cd34acd Include lib/wildmatch.h directly for now (until we make rsync.h include
it for us).
2003-07-05 00:13:38 +00:00
Wayne Davison
08c5385e65 Test the new wildmatch() routine using the wildtest executable. 2003-07-05 00:08:11 +00:00
Wayne Davison
d7bf70f196 Build "wildtest" for "make check". 2003-07-05 00:07:35 +00:00
Wayne Davison
6f3cff41dd Ignore "wildtest". 2003-07-05 00:05:33 +00:00
Wayne Davison
5de45bcadc A testbed to stress the new wildmatch() routine. 2003-07-05 00:05:02 +00:00
Wayne Davison
446ee5b110 A new wildcard-matching routine to replace the fnmatch code. 2003-07-05 00:03:36 +00:00
Wayne Davison
d3e6fd3910 Changed "diff -c" to "diff -u". 2003-07-04 23:56:59 +00:00
Wayne Davison
6813fa7eac Attempting to fix the snprintf() conflict on a gcc-using HPUX 11.11. 2003-07-04 15:36:39 +00:00
Wayne Davison
0f5a04e3ff Use "return" at the end of main() to silence some compilers. 2003-07-04 15:11:46 +00:00
Wayne Davison
8801138b47 Made rprintf() of size_t value portable. 2003-07-04 15:11:44 +00:00
Wayne Davison
2473391971 Improved upon my last patch to make it clearer and cleaner. 2003-07-04 07:47:09 +00:00
Wayne Davison
7d6879328a Changed the syntax of a comment. 2003-07-03 18:33:53 +00:00
Wayne Davison
900454132e Mention the compression (-z) fix. 2003-07-03 17:41:08 +00:00
Wayne Davison
92b8abfe80 Fixed a problem where we might not have enough room to compress
unsent tokens into the obuf in a single call.
2003-07-03 17:38:12 +00:00
Wayne Davison
52e628a861 Mention the exclude changes. 2003-07-01 22:01:48 +00:00
Wayne Davison
4791825d49 Modified the glob_expand_one() function to check the args against the
server's config-specified exclude list.  This prevents the user from
going around directory exclusions.  Fixed push_dir() to not append
"/." onto the end of the current path if it is called with "." as the
"dir" arg.  Made curr_dir[] exported so the exclude code can use it
(for the daemon-config absolute-path excludes).
2003-07-01 21:45:31 +00:00
Wayne Davison
d542c20c5f New stubs to get the test setup to compile with the exclude changes. 2003-07-01 21:45:29 +00:00
Wayne Davison
4762db4fc9 Added some defines for the various exclude-function arg literals.
Added MATCHFLG_ABS_PATH flag for absolute-path patterns.
2003-07-01 21:45:27 +00:00
Wayne Davison
8645af1d8c Changed add_exclude*() calls to use the revised arg syntax. 2003-07-01 21:45:23 +00:00
Wayne Davison
429f98283f Modifications to handle the new server_exclude_list, and to use the
revised calling syntax and new defines for the various exclude
functions.
2003-07-01 21:45:18 +00:00
Wayne Davison
5be7fa93fc Made make_exclude() store anchored config-file excludes with the full
path (clear to the root).  Changed several functions to make the args
more general (to support separated lists), more consistent, and easier
to understand.
2003-07-01 21:45:16 +00:00
Wayne Davison
837cbad97f We now put the excludes from the config file into a "server_exclude_list"
using the revised add_exclude_line() arg syntax.
2003-07-01 21:45:13 +00:00
Wayne Davison
af1d91c562 Call make_file() using the revised arg syntax and new defines. 2003-07-01 21:45:07 +00:00
Martin Pool
908f5a9f9f Add a comment about using getpassphrase() or readpassphrase() rather
than getpass().  No code change.
2003-06-17 04:46:32 +00:00
J.W. Schultz
9b74643315 Credit where due. 2003-06-10 00:21:34 +00:00
J.W. Schultz
986066873e Clarified EXCLUDE PATTERNS to enforce the relativity of
paths.  Replaced undefined "base dir" with a defined "top
dir".
2003-06-10 00:11:24 +00:00
J.W. Schultz
9533e15a79 Changed write file to cope with partial writes by looping
until complete or errno is set.
					(John Van Essen)
2003-05-22 23:24:44 +00:00
Wayne Davison
8dc74608a3 Updated the long description for the --perms option. 2003-05-16 04:23:34 +00:00
J.W. Schultz
3e85237e5f Added AIX and OSX build workaround notes. 2003-05-14 12:54:15 +00:00
Wayne Davison
9d0523ef4c Another MD4 fix for protocol 27 (from Christoph Bartelmus). 2003-05-12 20:38:07 +00:00
Wayne Davison
4a7144ee7e Cleaned up whitespace/indentation. 2003-05-10 08:33:08 +00:00
Wayne Davison
c120ff37f5 Optimized away 3 calls to strcmp(). 2003-05-10 00:56:08 +00:00
J.W. Schultz
83fd337d8e Modified the (in|ex)clude [from] option descriptions to
better highlight the non-equivalence with client-side
--exclude.
2003-05-09 12:04:24 +00:00
Jos Backus
707c1a3085 Remove generated file config.log. 2003-05-04 19:59:47 +00:00
J.W. Schultz
8294b00c11 Added --link-dest to the --help output. 2003-05-02 23:36:10 +00:00
Wayne Davison
da2bcdd1c2 Exclude/include bug fixes. 2003-05-01 19:39:20 +00:00
Wayne Davison
093acc5dad Changed the expected results to match the new bug-fixed behavior. 2003-05-01 19:34:01 +00:00
Wayne Davison
fd73b94d31 Tweaked the exclude_struct for our improved matching code. 2003-05-01 19:33:59 +00:00
Wayne Davison
38499c1a49 Mention that a pattern with "**" is matched against the entire path, even
if the pattern doesn't contain a slash.
2003-05-01 19:33:57 +00:00
Wayne Davison
170381c052 Fixed some matching bugs; made the logic of the matching code a little
clearer by using defined flags; added several comments; optimized the
matching of an anchored literal string.
2003-05-01 19:33:54 +00:00
Wayne Davison
8113a033dd Mention the improved trailing-slash-in-destination handling. 2003-04-24 16:26:53 +00:00
Wayne Davison
87cc45e136 Made my last change a little better. 2003-04-24 16:26:09 +00:00
Wayne Davison
f6b8d591f7 If the user specifies a trailing slash on the destination, make sure
that we treat it as a directory reference.
2003-04-24 16:14:33 +00:00
J.W. Schultz
d31c09c872 Copy relative path caviat from --compare-dest to
--link-dest.
2003-04-23 23:17:41 +00:00
Wayne Davison
337a1a86a7 Changed one part of the exclude-test setup to test the --existing
option.  Also tweaked a few comment lines.
2003-04-23 02:15:59 +00:00
Wayne Davison
b7dc46c0f6 Fixed a typo and added a couple clarifying phrases to the exclude
descriptions.
2003-04-22 18:09:22 +00:00
Wayne Davison
ff57065957 Test various exclude/include patterns. 2003-04-22 17:53:53 +00:00
Wayne Davison
0406a3a7a4 Changed test_xfail to test_fail. 2003-04-22 16:45:24 +00:00
Wayne Davison
bc3b5b2558 Fixed a problem with the test code and enabled it (since rsync's
duplicate-elimination code is now fixed).
2003-04-22 00:25:05 +00:00
J.W. Schultz
d1cce1dd92 Make explicit that (in|ex)clude patterns are for relative
paths and that the leading / is the equivalent of ^ in
regex.
2003-04-21 08:44:25 +00:00
Wayne Davison
7bb7058e8d Made a slight tweak to the previous --stats change. 2003-04-18 20:03:41 +00:00
Wayne Davison
727fa3688f Mention the change to the --stats output. 2003-04-17 23:46:01 +00:00
Wayne Davison
577ab12ce5 Only display the malloc stats if we're at least double-verbose (and
--stats was specified, of course).  Also made the output of the short
(2-line) transfer summary get prefixed with an empty line in all
cases (not just with --stats).
2003-04-17 23:44:25 +00:00
Wayne Davison
0f2ac85576 Some whitespace/indentation cleanup. 2003-04-17 01:44:33 +00:00
J.W. Schultz
fab1f8898e document bug fix for --link-dest and lack of -pgo. 2003-04-11 03:15:53 +00:00
restrict
f63d68be97 (Really mbp)
Test commit from restricted CVS account.  No changes.
2003-04-10 04:35:12 +00:00
Wayne Davison
58665d23b4 Fixed a weird line corruption in the last check-in and tweaked the
format to be the same as in older releases.
2003-04-10 03:06:28 +00:00
J.W. Schultz
195bd906a2 - Per-file dynamic block size is now sqrt(file length).
-	The per-file checksum size is determined according
	to an algorythm provided by Donovan Baarda which
	reduces the probability of rsync algorithm
	corrupting data and falling back using the whole md4
	checksums.
2003-04-10 02:04:58 +00:00
J.W. Schultz
fc1ae6582f - for protocol version >= 27, mdfour_tail() is called when the block size
(including checksum_seed) is a multiple of 64.  Previously it was not
   called, giving the wrong MD4 checksum.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Doc.

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

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

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

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

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

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

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

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

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

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

 3) otherwise use rsh

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

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

View File

@@ -1,9 +1,15 @@
ID
Makefile
autom4te.cache
confdefs.h
config.cache
config.h
config.log
config.status
conftest.c
conftest.log
dox
getgroups
gmon.out
rsync
shconfig
@@ -12,7 +18,7 @@ tests-dont-exist
testtmp
testtmp.*
tls
trimslash
t_unsafe
wildtest
zlib/dummy
confdefs.h
conftest.c
conftest.log

187
Doxyfile Normal file
View File

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

20
INSTALL
View File

@@ -11,11 +11,21 @@ to ./configure. To see them, use:
As of 2.4.7, rsync uses Eric Troan's popt option-parsing library. A
cut-down copy of release 1.5 is included in the rsync distribution,
and will be used it there is no popt library on your build host, or if
and will be used if there is no popt library on your build host, or if
the --with-included-popt option is passed to ./configure.
If you configure using --enable-maintainer-mode, then rsync will try
to pop up an xterm on DISPLAY=:0 if it crashes. You might find this
useful, but it should be turned off for production builds.
RPM NOTES
---------
Under packaging you will find .spec files for several distributions.
The .spec file in packaging/lsb can be used for Linux systems that
adhere to the Linux Standards Base (e.g., RedHat and others).
HP-UX NOTES
-----------
@@ -38,5 +48,11 @@ completely implement the "New Sockets" API.
<http://www.ipv6.org/impl/mac.html> says that Apple do not support
IPv6 yet. If your build fails, try again with --disable-ipv6.
IBM AIX NOTES
-------------
IBM AIX has a largefile problem with mkstemp. See IBM PR-51921.
The workaround is to append the below to config.h
#ifdef _LARGE_FILES
#undef HAVE_SECURE_MKSTEMP
#endif

View File

@@ -9,9 +9,12 @@ mandir=@mandir@
LIBS=@LIBS@
CC=@CC@
CFLAGS=@CFLAGS@
CPPFLAGS=@CPPFLAGS@
EXEEXT=@EXEEXT@
LDFLAGS=@LDFLAGS@
INSTALLCMD=@INSTALL@
INSTALLMAN=@INSTALL@
srcdir=@srcdir@
VPATH=$(srcdir)
@@ -22,78 +25,109 @@ VERSION=@VERSION@
.SUFFIXES:
.SUFFIXES: .c .o
LIBOBJ=lib/fnmatch.o lib/compat.o lib/snprintf.o lib/mdfour.o \
lib/permstring.o \
@LIBOBJS@
HEADERS=byteorder.h config.h errcode.h proto.h rsync.h
LIBOBJ=lib/wildmatch.o lib/compat.o lib/snprintf.o lib/mdfour.o \
lib/permstring.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
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
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) $(DAEMON_OBJ) $(LIBOBJ) $(ZLIBOBJ) @BUILD_POPT@
OBJS=$(OBJS1) $(OBJS2) $(OBJS3) $(DAEMON_OBJ) $(LIBOBJ) $(ZLIBOBJ) @BUILD_POPT@
tls_OBJ = tls.o syscall.o lib/permstring.o
TLS_OBJ = tls.o syscall.o lib/permstring.o
# Programs we must have to run the test cases
CHECK_PROGS = rsync tls
CHECK_PROGS = rsync$(EXEEXT) tls$(EXEEXT) getgroups$(EXEEXT) \
trimslash$(EXEEXT) t_unsafe$(EXEEXT) wildtest$(EXEEXT)
# Objects for CHECK_PROGS to clean
CHECK_OBJS=getgroups.o t_stub.o t_unsafe.o trimslash.o wildtest.o
# note that the -I. is needed to handle config.h when using VPATH
.c.o:
@OBJ_SAVE@
$(CC) -I. -I$(srcdir) $(CFLAGS) -c $< @CC_SHOBJ_FLAG@
$(CC) -I. -I$(srcdir) $(CFLAGS) $(CPPFLAGS) -c $< @CC_SHOBJ_FLAG@
@OBJ_RESTORE@
all: rsync
all: rsync$(EXEEXT)
man: rsync.1 rsyncd.conf.5
install: all
-mkdir -p ${bindir}
${INSTALLCMD} -m 755 rsync ${bindir}
-mkdir -p ${mandir}/man1
-mkdir -p ${mandir}/man5
${INSTALLCMD} -m 644 $(srcdir)/rsync.1 ${mandir}/man1
${INSTALLCMD} -m 644 $(srcdir)/rsyncd.conf.5 ${mandir}/man5
-mkdir -p ${DESTDIR}${bindir}
${INSTALLCMD} ${STRIP} -m 755 rsync$(EXEEXT) ${DESTDIR}${bindir}
-mkdir -p ${DESTDIR}${mandir}/man1
-mkdir -p ${DESTDIR}${mandir}/man5
${INSTALLMAN} -m 644 $(srcdir)/rsync.1 ${DESTDIR}${mandir}/man1
${INSTALLMAN} -m 644 $(srcdir)/rsyncd.conf.5 ${DESTDIR}${mandir}/man5
install-strip:
$(MAKE) INSTALLCMD='$(INSTALLCMD) -s' install
$(MAKE) STRIP='-s' install
rsync: $(OBJS)
@echo "Please ignore warnings below about mktemp -- it is used in a safe way"
$(CC) $(CFLAGS) $(LDFLAGS) -o rsync $(OBJS) $(LIBS)
rsync$(EXEEXT): $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
$(OBJS): config.h
$(OBJS): $(HEADERS)
tls: $(tls_OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(tls_OBJ) $(LIBS)
tls$(EXEEXT): $(TLS_OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(TLS_OBJ) $(LIBS)
Makefile: Makefile.in configure config.status
echo "WARNING: You need to run ./config.status --recheck"
getgroups$(EXEEXT): getgroups.o
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ getgroups.o $(LIBS)
TRIMSLASH_OBJ = trimslash.o syscall.o
trimslash$(EXEEXT): $(TRIMSLASH_OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(TRIMSLASH_OBJ) $(LIBS)
T_UNSAFE_OBJ = t_unsafe.o syscall.o util.o t_stub.o lib/compat.o lib/snprintf.o
t_unsafe$(EXEEXT): $(T_UNSAFE_OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(T_UNSAFE_OBJ) $(LIBS)
# I don't like these rules because CVS can skew the timestamps and
# produce spurious warnings, and also make "make install" fail if the
# source directory can no longer be found. Since we don't rebuild
# automatically they're kind of lame anyhow.
#Makefile: Makefile.in configure config.status
# echo "WARNING: You need to run ./config.status --recheck"
# don't actually run autoconf, just issue a warning
configure: configure.in
echo "WARNING: you need to rerun autoconf"
#configure: configure.in
# echo "WARNING: you need to rerun autoconf"
rsync.1: rsync.yo
yodl2man -o rsync.1 rsync.yo
$(srcdir)/rsync.1: $(srcdir)/rsync.yo
yodl2man -o $(srcdir)/rsync.1 $(srcdir)/rsync.yo
rsyncd.conf.5: rsyncd.conf.yo
yodl2man -o rsyncd.conf.5 rsyncd.conf.yo
$(srcdir)/rsyncd.conf.5: $(srcdir)/rsyncd.conf.yo
yodl2man -o $(srcdir)/rsyncd.conf.5 $(srcdir)/rsyncd.conf.yo
proto:
cat *.c lib/compat.c | awk -f mkproto.awk > proto.h
cat $(srcdir)/*.c $(srcdir)/lib/compat.c | awk -f $(srcdir)/mkproto.awk > $(srcdir)/proto.h
clean:
rm -f *~ $(OBJS) rsync $(TLS_OBJ) tls
rm -rf ./testtmp
rm -f config.cache
clean: cleantests
rm -f *~ $(OBJS) $(TLS_OBJ) $(CHECK_PROGS) $(CHECK_OBJS)
cleantests:
rm -rf ./testtmp*
# We try to delete built files from both the source and build
# directories, just in case somebody previously configured things in
# the source directory.
distclean: clean
rm -f Makefile config.h config.status
rm -f $(srcdir)/Makefile $(srcdir)/config.h $(srcdir)/config.status
rm -f config.cache config.log
rm -f $(srcdir)/config.cache $(srcdir)/config.log
rm -f shconfig $(srcdir)/shconfig
# this target is really just for my use. It only works on a limited
# range of machines and is used to produce a list of potentially
@@ -101,7 +135,7 @@ distclean: clean
finddead:
nm *.o */*.o |grep 'U ' | awk '{print $$2}' | sort -u > nmused.txt
nm *.o */*.o |grep 'T ' | awk '{print $$3}' | sort -u > nmfns.txt
comm -13 nmused.txt nmfns.txt
comm -13 nmused.txt nmfns.txt
# 'check' is the GNU name, 'test' is the name for everybody else :-)
.PHONY: check test
@@ -123,13 +157,41 @@ test: check
# might lose in the future where POSIX diverges from old sh.
check: all $(CHECK_PROGS)
POSIXLY_CORRECT=1 TLS=`pwd`/tls rsync_bin=`pwd`/rsync srcdir="$(srcdir)" $(srcdir)/runtests.sh
POSIXLY_CORRECT=1 TOOLDIR=`pwd` rsync_bin=`pwd`/rsync$(EXEEXT) srcdir="$(srcdir)" $(srcdir)/runtests.sh
wildtest.o: wildtest.c lib/wildmatch.c rsync.h
wildtest$(EXEEXT): wildtest.o
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ wildtest.o @BUILD_POPT@ $(LIBS)
# This does *not* depend on building or installing: you can use it to
# check a version installed from a binary or some other source tree,
# if you want.
installcheck: $(CHECK_PROGS)
POSIXLY_CORRECT=1 TLS=`pwd`/tls rsync_bin="$(bindir)/rsync" srcdir="$(srcdir)" $(srcdir)/runtests.sh
POSIXLY_CORRECT=1 TOOLDIR=`pwd` rsync_bin="$(bindir)/rsync$(EXEEXT)" srcdir="$(srcdir)" $(srcdir)/runtests.sh
# TODO: Add 'dist' target; need to know which files will be included
# Run the SPLINT (Secure Programming Lint) tool. <www.splint.org>
.PHONY: splint
splint:
splint +unixlib +gnuextensions -weak rsync.c
rsync.dvi: doc/rsync.texinfo
texi2dvi -o $@ $<
rsync.ps: rsync.dvi
dvips -ta4 -o $@ $<
rsync.pdf: doc/rsync.texinfo
texi2dvi -o $@ --pdf $<
doxygen:
cd $(srcdir) && rm dox/html/* && doxygen
# for maintainers only
doxygen-upload:
rsync -avzv $(srcdir)/dox/html/ --delete \
samba.org:/home/httpd/html/rsync/doxygen/head/

156
NEWS
View File

@@ -1,34 +1,134 @@
rsync 2.5.2 (???)
SECURITY FIXES:
* Signedness security patch from Sebastian Krahmer
<krahmer@suse.de> -- in some cases we were not sufficiently
careful about reading integers from the network.
BUG FIXES:
* Fix possible string mangling in log files.
* Fix for setting local address of outgoing sockets.
* Better handling of hardlinks and devices on platforms with
64-bit dev_t or ino_t.
* Name resolution on machines supporting IPv6 is improved.
NEWS for rsync 2.6.0 (1 Jan 2004)
Protocol: 27 (changed)
Changes since 2.5.7:
ENHANCEMENTS:
* With -v, rsync now shows the command used to initiate an ssh/rsh
connection.
* "ssh" is now the default remote shell for rsync. If you want to
change this, configure like this: "./configure --with-rsh=rsh".
* --statistics now shows memory heap usage on platforms that
support mallinfo().
* Added --files-from, --no-relative, --no-implied-dirs, and --from0.
Note that --from0 affects the line-ending character for all the
files read by the --*-from options. (Wayne Davison)
* "The Ted T'so school of program optimization": make progress
visible and people will think it's faster. (With --progress,
rsync will show you how many files it has seen as it builds the
file_list, giving some indication that it has not hung.)
* Length of csum2 is now per-file starting with protocol version
27. (J.W. Schultz)
* Improvements to batch mode support. This is still experimental
but testing would be welcome. (Jos Backus)
* Per-file dynamic block size is now sqrt(file length). The
per-file checksum size is determined according to an algorithm
provided by Donovan Baarda which reduces the probability of rsync
algorithm corrupting data and falling back using the whole md4
checksums. (J.W. Schultz, Donovan Baarda)
* The --stats option no longer includes the (debug) malloc summary
unless the verbose option was specified at least twice.
* Added a new error/warning code for when files vanish from the
sending side. Made vanished source files not interfere with the
file-deletion pass when --delete-after was specified.
* Various trailing-info sections are now preceded by a newline.
BUG FIXES:
* Fixed several exclude/include matching bugs when using wild-cards.
This has a several user-visible effects, all of which make the
matching more consistent and intuitive. This should hopefully not
cause anyone problems since it makes the matching work more like
what people are expecting. (Wayne Davison)
- A pattern with a "**" no longer causes a "*" to match slashes.
For example, with "/*/foo/**", "foo" must be 2 levels deep.
- "**/foo" now matches at the base of the transfer (i.e. /foo).
- An non-anchored wildcard term floats to match beyond the base of
the transfer. E.g. "CVS/R*" matches at the end of the path,
just like the non-wildcard term "CVS/Root" does.
- Including a "**" in the match term causes it to be matched
against the entire path, not just the name portion, even if
there aren't any interior slashes in the term. E.g. "foo**bar"
would exclude "/path/foo-bar" (just like before) as well as
"/foo-path/baz-bar" (unlike before).
* The exclude list specified in the daemon's config file is now
properly applied to the pulled items no matter how deep the
user's file-args are in the source tree. (Wayne Davison)
* For protocol version >= 27, mdfour_tail() is called when the
block size (including checksum_seed) is a multiple of 64.
Previously it was not called, giving the wrong MD4 checksum.
(Craig Barratt)
* For protocol version >= 27, a 64 bit bit counter is used in
mdfour.c as required by the RFC. Previously only a 32 bit bit
counter was used, causing incorrect MD4 file checksums for
file sizes >= 512MB - 4. (Craig Barratt)
* Fixed a crash bug when interacting with older rsync versions and
multiple files of the same name are destined for the same dir.
(Wayne Davison)
* Keep tmp names from overflowing MAXPATHLEN.
* Make --link-dest honor the absence of -p, -o, and -g.
* Made rsync treat a trailing slash in the destination in a more
consistent manner.
* Fixed file I/O error detection. (John Van Essen)
* Fixed bogus "malformed address {hostname}" message in rsyncd log
when checking IP address against hostnames from "hosts allow"
and "hosts deny" parameters in config file.
* Print heap statistics when verbose >= 2 instead of when >= 1.
* Fixed a compression (-z) bug when syncing a mostly-matching file
that contains already-compressed data. (Yasuoka Masahiko and
Wayne Davison)
* Fixed a bug in the --backup code that could cause deleted files
to not get backed up.
* When the backup code makes new directories, create them with mode
0700 instead of 0755 (since the directory permissions in the
backup tree are not yet copied from the main tree).
* Call setgroups() in a more portable manner.
* Improved file-related error messages to better indicate exactly
what pathname failed. (Wayne Davison)
* Fixed some bugs in the handling of --delete and --exclude when
using the --relative (-R) option. (Wayne Davison)
* Fixed bug that prevented regular files from replacing
special files and caused a directory in --link-dest or
--compare-dest to block the creation of a file with the
same path. A directory still cannot be replaced by a
regular file unless --delete specified. (J.W. Schultz)
* Detect and report when open or opendir succeed but read and
readdir fail caused by network filesystems issues and truncated
files. (David Norwood, Michael Brown, J.W. Schultz)
* Added a fix that should give ssh time to restore the tty settings
if the user presses Ctrl-C at an ssh password prompt.
INTERNAL:
* Eliminated vestigial support for old versions that we stopped
supporting. (J.W. Schultz)
* Simplified some of the option-parsing code. (Wayne Davison)
* Some cleanup made to the exclude code, as well as some new
defines added to enhance readability. (Wayne Davison)
* Changed the protocol-version code so that it can interact at a
lower protocol level than the maximum supported by both sides.
Added an undocumented option, --protocol=N, to force the value
we advertise to the other side (primarily for testing purposes).
(Wayne Davison)

329
OLDNEWS
View File

@@ -1,7 +1,266 @@
rsync 2.5.1 (2002-01-03)
NEWS for rsync 2.5.7 (4 Dec 2003)
Protocol: 26 (unchanged)
Changes since 2.5.6:
SECURITY FIXES:
* Fix buffer handling bugs. (Andrew Tridgell, Martin Pool, Paul
Russell, Andrea Barisani)
NEWS for rsync 2.5.6, aka "the dwd-between-jobs release" (26 Jan 2003)
Protocol: 26 (unchanged)
Changes since 2.5.5:
ENHANCEMENTS:
* The --delete-after option now implies --delete. (Wayne Davison)
* The --suffix option can now be used with --backup-dir. (Michael
Zimmerman)
* Combining "::" syntax with the -rsh/-e option now uses the
specified remote-shell as a transport to talk to a (newly-spawned)
server-daemon. This allows someone to use daemon features, such
as modules, over a secure protocol, such as ssh. (JD Paul)
* The rsync:// syntax for daemon connections is now accepted in the
destination field.
* If the file name given to --include-from or --exclude-from is "-",
rsync will read from standard input. (J.W. Schultz)
* New option --link-dest which is like --compare-dest except that
unchanged files are hard-linked in to the destination directory.
(J.W. Schultz)
* Don't report an error if an excluded file disappears during an
rsync run. (Eugene Chupriyanov and Bo Kersey)
* Added .svn to --cvs-exclude list to support subversion. (Jon
Middleton)
* Properly support IPv6 addresses in the rsyncd.conf "hosts allow"
and "hosts deny" fields. (Hideaki Yoshifuji)
* Changed exclude file handling to permit DOS or MAC style line
terminations. (J.W. Schultz)
* Ignore errors from chmod when -p/-a/--preserve-perms is not set.
(Dave Dykstra)
BUG FIXES:
* Fix "forward name lookup failed" errors on AIX 4.3.3. (John
L. Allen, Martin Pool)
* Generate each file's rolling-checksum data as we send it, not
in a separate (memory-eating) pass before hand. This prevents
timeout errors on really large files. (Stefan Nehlsen)
* Fix compilation on Tru64. (Albert Chin, Zoong Pham)
* Better handling of some client-server errors. (Martin Pool)
* Fixed a crash that would occur when sending a list of files that
contains a duplicate name (if it sorts to the end of the file
list) and using --delete. (Wayne Davison)
* Fixed the file-name duplicate-removal code when dealing with multiple
dups in a row. (Wayne Davison)
* Fixed a bug that caused rsync to lose the exit status of its child
processes and sometimes return an exit code of 0 instead of showing
an error. (David R. Staples, Dave Dykstra)
* Fixed bug in --copy-unsafe-links that caused it to be completely
broken. (Dave Dykstra)
* Prevent infinite recursion in cleanup code under certain circumstances.
(Sviatoslav Sviridov and Marc Espie)
* Fixed a bug that prevented rsync from creating intervening directories
when --relative-paths/-R is set. (Craig Barratt)
* Prevent "Connection reset by peer" messages from Cygwin. (Randy O'Meara)
INTERNAL:
* Many code cleanups and improved internal documentation. (Martin
Pool, Nelson Beebe)
* Portability fixes. (Dave Dykstra and Wayne Davison)
* More test cases. (Martin Pool)
* Some test-case fixes. (Brian Poole, Wayne Davison)
* Updated included popt to the latest vendor drop, version 1.6.4.
(Jos Backus)
* Updated config.guess and config.sub to latest versions; this
means rsync should build on more platforms. (Paul Green)
NEWS for rsync 2.5.5, aka Snowy River (2 Apr 2002)
Protocol: 26 (unchanged)
Changes since 2.5.4:
ENHANCEMENTS:
* With --progress, when a transfer is complete show the time taken;
otherwise show expected time to complete. (Cameron Simpson)
* Make "make install-strip" works properly, and "make install"
accepts a DESTDIR variable for help in building binary packages.
(Peter Breitenlohner, Greg Louis)
* If configured with --enable-maintainer-mode, then on receipt of
a fatal signal rsync will try to open an xterm running gdb,
similarly to Samba's "panic action" or GNOME's bug-buddy.
(Martin Pool)
BUG FIXES:
* Fix situation where failure to fork (e.g. because out of process
slots) would cause rsync to kill all processes owned by the
current user. Yes, really! (Paul Haas, Martin Pool)
* Fix test suite on Solaris. (Jos Backus, Martin Pool)
* Fix minor memory leak in socket code. (Dave Dykstra, Martin
Pool.)
* Fix --whole-file problem that caused it to be the default even
for remote connections. (Martin Pool, Frank Schulz)
* Work around bug in Mac OS X mkdir(2), which cannot handle
trailing slashes.
<http://www.opensource.apple.com/bugs/X/BSD%20Kernel/2734739.html>
(Martin Pool)
* Improved network error handling. (Greg A. Woods)
NEWS for rsync 2.5.4, aka "Imitation lizard skin" (13 Mar 2002)
Protocol: 26 (unchanged)
Changes since 2.5.3:
BUG FIXES:
* Additional fix for zlib double-free bug. (Martin Pool, Andrew
Tridgell) (CVE CAN-2002-0059)
ENHANCEMENTS:
* Merge in changes from zlib 1.1.3 to zlib 1.1.4. (Jos Backus)
(Note that rsync still uses a custom version of zlib; you can
not just link against a system library. See zlib/README.rsync)
* Additional test cases for --compress. (Martin Pool)
NEWS for rsync 2.5.3, aka "Happy 26" (11 Mar 2002)
Protocol: 26 (unchanged)
Changes since 2.5.2:
SECURITY FIXES:
* Make sure that supplementary groups are removed from a server
process after changing uid and gid. (Ethan Benson) (Debian bug
#132272, CVE CAN-2002-0080)
BUG FIXES:
* Fix zlib double-free bug. (Owen Taylor, Mark J Cox) (CVE
CAN-2002-0059)
* Fixed problem that in many cases caused the error message
unexpected read size of 0 in map_ptr
and resulted in the wrong data being copied.
* Fixed compilation errors on some systems caused by the use of
"unsigned int64" in rsync.h.
* Fixed problem on systems such as Sunos4 that do not support realloc
on a NULL pointer; error was "out of memory in flist_expand".
* Fix for rsync server processes hanging around after the client
unexpectedly disconnects. (Colin Walters) (Debian bug #128632)
* Cope with BSD systems on which mkdir() will not accept a trailing
slash.
ENHANCEMENTS:
* Merge in changes from zlib 1.1.2 to zlib 1.1.3. (Note that
rsync still uses a custom version of zlib; you can not just link
against a system library. See zlib/README.rsync)
* Command to initiate connections is only shown with -vv, rather
than -v as in 2.5.2. Output from plain -v is more similar to
what was historically used so as not to break scripts that try
to parse the output.
* Added --no-whole-file and --no-blocking-io options (Dave Dykstra)
* Made the --write-batch and --read-batch options actually work
and added documentation in the man page (Jos Backus)
* If the daemon is unable to fork a child to accept a connection,
print an error message. (Colin Walters)
NEWS for rsync 2.5.2 (26 Jan 2002)
Protocol: 26 (changed)
Changes since 2.5.1:
SECURITY FIXES:
* Signedness security patch from Sebastian Krahmer
<krahmer@suse.de> -- in some cases we were not sufficiently
careful about reading integers from the network.
BUG FIXES:
* Fix possible string mangling in log files.
* Fix for setting local address of outgoing sockets.
* Better handling of hardlinks and devices on platforms with
64-bit dev_t or ino_t.
* Name resolution on machines supporting IPv6 is improved.
* Fix for device nodes. (dann frazier) (Debian #129135)
ENHANCEMENTS:
* With -v, rsync now shows the command used to initiate an ssh/rsh
connection.
* --statistics now shows memory heap usage on platforms that
support mallinfo().
* "The Ted T'so school of program optimization": make progress
visible and people will think it's faster. (With --progress,
rsync will show you how many files it has seen as it builds the
file_list, giving some indication that it has not hung.)
* Improvements to batch mode support. This is still experimental
but testing would be welcome. (Jos Backus)
* New --ignore-existing option, patch previously distributed with
Vipul's Razor. (Debian #124286)
NEWS for rsync 2.5.1 (3 Jan 2002)
Protocol: 25 (unchanged)
Changes since 2.5.0:
BUG FIXES:
BUG FIXES:
* Fix for segfault in --daemon mode configuration parser. (Paul
Mackerras)
@@ -23,16 +282,19 @@ rsync 2.5.1 (2002-01-03)
ENHANCEMENTS:
* --progress and -P now show estimated data transfer rate (in a
multiple of bytes/s) and estimated time to completion. (Rik
Faith)
multiple of bytes/s) and estimated time to completion. (Rik
Faith)
* --no-detach option, required to run as a W32 service and also
useful when running on Unix under daemontools, AIX's SRC, or a
debugger. (Max Bowsher, Jos Backus)
useful when running on Unix under daemontools, AIX's SRC, or a
debugger. (Max Bowsher, Jos Backus)
* Clearer error messages for some conditions.
rsync 2.5.0 (2001-11-30)
NEWS for rsync 2.5.0 (30 Nov 2001)
Protocol: 25 (changed)
Changes since 2.4.6:
ANNOUNCEMENTS
@@ -94,7 +356,7 @@ rsync 2.5.0 (2001-11-30)
* Attempt to fix error handling lockup bug.
* Give a non-0 exit code if *any* of the files we have been asked
to transfer fail to transfer
to transfer fail to transfer.
* For log messages containing ridiculously long strings that might
overflow a buffer rsync no longer aborts, but rather prints an
@@ -105,7 +367,7 @@ rsync 2.5.0 (2001-11-30)
* Improved support for UNICOS (tested on Cray T3E and Cray SV1)
* autoconf2.52 (or later) is now required to rebuild the autoconf
scripts. It is not required to simply build rsync.
scripts. It is not required to simply build rsync.
* Platforms thought to work in this release:
@@ -146,3 +408,48 @@ rsync 2.5.0 (2001-11-30)
* The existing test.sh script by Phil Hands has been merged into a
test framework that works from both "make check" and the Samba
build farm.
Partial Protocol History
RELEASE DATE VER. DATE OF COMMIT PROTOCOL
01 Jan 2004 2.6.0 10 Apr 2003 27 (MAX=40)
04 Dec 2003 2.5.7 26
26 Jan 2003 2.5.6 26
02 Apr 2002 2.5.5 26
13 Mar 2002 2.5.4 26
11 Mar 2002 2.5.3 26
26 Jan 2002 2.5.2 11 Jan 2002 26
03 Jan 2002 2.5.1 25
30 Nov 2001 2.5.0 23 Aug 2001 25
06 Sep 2000 2.4.6 24
19 Aug 2000 2.4.5 24
29 Jul 2000 2.4.4 24
09 Apr 2000 2.4.3 24
30 Mar 2000 2.4.2 24
30 Jan 2000 2.4.1 29 Jan 2000 24
29 Jan 2000 2.4.0 28 Jan 2000 23
25 Jan 2000 2.3.3 23 Jan 2000 22
08 Nov 1999 2.3.2 26 Jun 1999 21
06 Apr 1999 2.3.1 20
15 Mar 1999 2.3.0 15 Mar 1999 20
25 Nov 1998 2.2.1 19
03 Nov 1998 2.2.0 19
09 Sep 1998 2.1.1 19
20 Jul 1998 2.1.0 19
17 Jul 1998 2.0.19 19
18 Jun 1998 2.0.17 19
01 Jun 1998 2.0.16 19
27 May 1998 2.0.13 27 May 1998 19
26 May 1998 2.0.12 18
22 May 1998 2.0.11 18
18 May 1998 2.0.9 18 May 1998 18
17 May 1998 2.0.8 17
15 May 1998 2.0.1 17
14 May 1998 2.0.0 17
17 Apr 1998 1.7.4 17
13 Apr 1998 1.7.3 17
05 Apr 1998 1.7.2 17
26 Mar 1998 1.7.1 17
26 Mar 1998 1.7.0 26 Mar 1998 17 (MAX=30)
13 Jan 1998 1.6.9 13 Jan 1998 15 (MAX=20)
* DATE OF COMMIT is the date the protocol change was committed to CVS.

85
README
View File

@@ -18,73 +18,12 @@ this package.
USAGE
-----
Basically you use rsync just like rcp, but rsync has many additional options.
Basically you use rsync just like rcp, but rsync has many additional
options. To get a complete list of supported options type
Here is a brief description of rsync usage:
Usage: rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST
or rsync [OPTION]... [USER@]HOST:SRC DEST
or rsync [OPTION]... SRC [SRC]... DEST
or rsync [OPTION]... [USER@]HOST::SRC [DEST]
or rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST
or rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]
SRC on single-colon remote HOST will be expanded by remote shell
SRC on server remote HOST may contain shell wildcards or multiple
sources separated by space as long as they have same top-level
Options
-v, --verbose increase verbosity
-q, --quiet decrease verbosity
-c, --checksum always checksum
-a, --archive archive mode
-r, --recursive recurse into directories
-R, --relative use relative path names
-b, --backup make backups (default ~ suffix)
--suffix=SUFFIX override backup suffix
-u, --update update only (don't overwrite newer files)
-l, --links preserve soft links
-L, --copy-links treat soft links like regular files
--copy-unsafe-links copy links outside the source tree
--safe-links ignore links outside the destination tree
-H, --hard-links preserve hard links
-p, --perms preserve permissions
-o, --owner preserve owner (root only)
-g, --group preserve group
-D, --devices preserve devices (root only)
-t, --times preserve times
-S, --sparse handle sparse files efficiently
-n, --dry-run show what would have been transferred
-W, --whole-file copy whole files, no incremental checks
-x, --one-file-system don't cross filesystem boundaries
-B, --block-size=SIZE checksum blocking size (default 700)
-e, --rsh=COMMAND specify rsh replacement
--rsync-path=PATH specify path to rsync on the remote machine
-C, --cvs-exclude auto ignore files in the same way CVS does
--delete delete files that don't exist on the sending side
--delete-excluded also delete excluded files on the receiving side
--partial keep partially transferred files
--force force deletion of directories even if not empty
--numeric-ids don't map uid/gid values by user/group name
--timeout=TIME set IO timeout in seconds
-I, --ignore-times don't exclude files that match length and time
--size-only only use file size when determining if a file should be transferred
-T --temp-dir=DIR create temporary files in directory DIR
--compare-dest=DIR also compare destination files relative to DIR
-z, --compress compress file data
--exclude=PATTERN exclude files matching PATTERN
--exclude-from=FILE exclude patterns listed in FILE
--include=PATTERN don't exclude files matching PATTERN
--include-from=FILE don't exclude patterns listed in FILE
--version print version number
--daemon run as a rsync daemon
--config=FILE specify alternate rsyncd.conf file
--port=PORT specify alternate rsyncd port number
--stats give some file transfer stats
--progress show progress during transfer
--log-format=FORMAT log file transfers using specified format
--password-file=FILE get password from FILE
-h, --help show this help screen
rsync --help
and see the manual for more information.
SETUP
@@ -137,13 +76,19 @@ BUG REPORTS
-----------
If you have web access then please look at
http://rsync.samba.org/rsync/
This will give you access to the bug tracking system used by the
developers of rsync and will allow you to look at other bug reports or
submit a new bug report.
http://rsync.samba.org
If you don't have web access then mail bug reports to rsync@samba.org.
That page contains links to the current bug list, and information on
how to report a bug well. You might also like to try searching the
internet for the error message you've received, or looking in the
mailing list archives at
http://mail-archive.com/rsync@lists.samba.org/
Please send bug reports to
rsync@lists.samba.org
CVS TREE

887
TODO
View File

@@ -1,22 +1,168 @@
-*- indented-text -*-
URGENT ---------------------------------------------------------------
BUGS ---------------------------------------------------------------
Fix progress indicator to not corrupt log
lchmod question
Do not rely on having a group called "nobody"
Incorrect timestamps (Debian #100295)
Win32
FEATURES ------------------------------------------------------------
server-imposed bandwidth limits
rsyncd over ssh
Use chroot only if supported
Allow supplementary groups in rsyncd.conf 2002/04/09
Handling IPv6 on old machines
Other IPv6 stuff:
Add ACL support 2001/12/02
Lazy directory creation
Conditional -z for old protocols
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-detach and --no-fork options
Create more granular verbosity jw 2003/05/15
DOCUMENTATION --------------------------------------------------------
Update README
Keep list of open issues and todos on the web site
Update web site from CVS
Perhaps redo manual as SGML
LOGGING --------------------------------------------------------------
Make dry run list all updates 2002/04/03
Memory accounting
Improve error messages
Better statistics: Rasmus 2002/03/08
Perhaps flush stdout like syslog
Log deamon sessions that just list modules
Log child death on signal
Keep stderr and stdout properly separated (Debian #23626)
Log errors with function that reports process of origin
verbose output David Stein 2001/12/20
Add reason for transfer to file logging
debugging of daemon 2002/04/08
internationalization
DEVELOPMENT --------------------------------------------------------
Handling duplicate names
Use generic zlib 2002/02/25
TDB: 2002/03/12
Splint 2002/03/12
Memory debugger
Create release script
Add machines to build farm
PERFORMANCE ----------------------------------------------------------
File list structure in memory
Traverse just one directory at a time
Hard-link handling
Allow skipping MD4 file_sum 2002/04/08
Accelerate MD4
String area code
TESTING --------------------------------------------------------------
Torture test
Cross-test versions 2001/08/22
Test on kernel source
Test large files
Create mutator program for testing
Create configure option to enable dangerous tests
If tests are skipped, say why.
Test daemon feature to disallow particular options.
Create pipe program for testing
Create test makefile target for some tests
Test "refuse options" works
RELATED PROJECTS -----------------------------------------------------
rsyncsh
http://rsync.samba.org/rsync-and-debian/
rsyncable gzip patch
rsyncsplit as alternative to real integration with gzip?
reverse rsync over HTTP Range
IMPORTANT ------------------------------------------------------------
Cross-test versions
BUGS ---------------------------------------------------------------
Part of the regression suite should be making sure that we don't
break backwards compatibility: old clients vs new servers and so
on. Ideally we would test the cross product of versions.
Fix progress indicator to not corrupt log
It might be sufficient to test downloads from well-known public
rsync servers running different versions of rsync. This will give
some testing and also be the most common case for having different
versions and not being able to upgrade.
Progress indicator can produce corrupt output when transferring directories:
use chroot
main/binary-arm/
main/binary-arm/admin/
main/binary-arm/base/
main/binary-arm/comm/8.56kB/s 0:00:52
main/binary-arm/devel/
main/binary-arm/doc/
main/binary-arm/editors/
main/binary-arm/electronics/s 0:00:53
main/binary-arm/games/
main/binary-arm/graphics/
main/binary-arm/hamradio/
main/binary-arm/interpreters/
main/binary-arm/libs/6.61kB/s 0:00:54
main/binary-arm/mail/
main/binary-arm/math/
main/binary-arm/misc/
-- --
lchmod question
I don't think we handle this properly on systems that don't have the
call. Are there any such?
-- --
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"
-- --
Incorrect timestamps (Debian #100295)
A bit hard to believe, but apparently it happens.
-- --
Win32
Don't detach, because this messes up --srvany.
http://sources.redhat.com/ml/cygwin/2001-08/msg00234.html
-- --
FEATURES ------------------------------------------------------------
server-imposed bandwidth limits
-- --
rsyncd over ssh
There are already some patches to do this.
BitKeeper uses a server whose login shell is set to bkd. That's
probably a reasonable approach.
-- --
Use chroot only if supported
If the platform doesn't support it, then don't even try.
@@ -26,22 +172,379 @@ use chroot
http://lists.samba.org/pipermail/rsync/2001-August/thread.html
http://lists.samba.org/pipermail/rsync/2001-September/thread.html
--files-from
Avoids traversal. Better option than a pile of --include statements
for people who want to generate the file list using a find(1)
command or a script.
-- --
Performance
Allow supplementary groups in rsyncd.conf 2002/04/09
Traverse just one directory at a time. Tridge says it's possible.
Perhaps allow supplementary groups to be specified in rsyncd.conf;
then make the first one the primary gid and all the rest be
supplementary gids.
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.
-- --
Handling IPv6 on old machines
The KAME IPv6 patch is nice in theory but has proved a bit of a
nightmare in practice. The basic idea of their patch is that rsync
is rewritten to use the new getaddrinfo()/getnameinfo() interface,
rather than gethostbyname()/gethostbyaddr() as in rsync 2.4.6.
Systems that don't have the new interface are handled by providing
our own implementation in lib/, which is selectively linked in.
The problem with this is that it is really hard to get right on
platforms that have a half-working implementation, so redefining
these functions clashes with system headers, and leaving them out
breaks. This affects at least OSF/1, RedHat 5, and Cobalt, which
are moderately improtant.
Perhaps the simplest solution would be to have two different files
implementing the same interface, and choose either the new or the
old API. This is probably necessary for systems that e.g. have
IPv6, but gethostbyaddr() can't handle it. The Linux manpage claims
this is currently the case.
In fact, our internal sockets interface (things like
open_socket_out(), etc) is much narrower than the getaddrinfo()
interface, and so probably simpler to get right. In addition, the
old code is known to work well on old machines.
We could drop the rather large lib/getaddrinfo files.
-- --
Other IPv6 stuff:
Implement suggestions from http://www.kame.net/newsletter/19980604/
and ftp://ftp.iij.ad.jp/pub/RFC/rfc2553.txt
If a host has multiple addresses, then listen try to connect to all
in order until we get through. (getaddrinfo may return multiple
addresses.) This is kind of implemented already.
Possibly also when starting as a server we may need to listen on
multiple passive addresses. This might be a bit harder, because we
may need to select on all of them. Hm.
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.
-- --
Add ACL support 2001/12/02
Transfer ACLs. Need to think of a standard representation.
Probably better not to even try to convert between NT and POSIX.
Possibly can share some code with Samba.
-- --
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.
-- --
Conditional -z for old protocols
After we get the @RSYNCD greeting from the server, we know it's
version but we have not yet sent the command line, so we could just
remove the -z option if the server is too old.
For ssh invocation it's not so simple, because we actually use the
command line to start the remote process. However, we only actually
do compression in token.c, and we could therefore once we discover
the remote version emit an error if it's too old. I'm not sure if
that's a good tradeoff or not.
-- --
proxy authentication 2002/01/23
Allow RSYNC_PROXY to be http://user:pass@proxy.foo:3128/, and do
HTTP Basic Proxy-Authentication.
Multiple schemes are possible, up to and including the insanity that
is NTLM, but Basic probably covers most cases.
-- --
SOCKS 2002/01/23
Add --with-socks, and then perhaps a command-line option to put them
on or off. This might be more reliable than LD_PRELOAD hacks.
-- --
FAT support
rsync to a FAT partition on a Unix machine doesn't work very well at
the moment. I think we get errors about invalid filenames and
perhaps also trying to do atomic renames.
I guess the code to do this is currently #ifdef'd on Windows;
perhaps we ought to intelligently fall back to it on Unix too.
-- --
Allow forcing arbitrary permissions 2002/03/12
On 12 Mar 2002, Dave Dykstra <dwd@bell-labs.com> wrote:
> If we would add an option to do that functionality, I
> would vote for one that was more general which could mask
> off any set of permission bits and possibly add any set of
> bits. Perhaps a chmod-like syntax if it could be
> implemented simply.
I think that would be good too. For example, people uploading files
to a web server might like to say
rsync -avzP --chmod a+rX ./ sourcefrog.net:/home/www/sourcefrog/
Ideally the patch would implement as many of the gnu chmod semantics
as possible. I think the mode parser should be a separate function
that passes back something like (mask,set) description to the rest
of the program. For bonus points there would be a test case for the
parser.
Possibly also --chown
(Debian #23628)
-- --
--diff david.e.sewell 2002/03/15
Allow people to specify the diff command. (Might want to use wdiff,
gnudiff, etc.)
Just diff the temporary file with the destination file, and delete
the tmp file rather than moving it into place.
Interaction with --partial.
Security interactions with daemon mode?
-- --
Add daemon --no-detach and --no-fork options
Very useful for debugging. Also good when running under a
daemon-monitoring process that tries to restart the service when the
parent exits.
-- --
Create more granular verbosity jw 2003/05/15
Control output with the --report option.
The option takes as a single argument (no whitespace) a
comma delimited lists of keywords.
This would separate debugging from "logging" as well as
fine grained selection of statistical reporting and what
actions are logged.
http://lists.samba.org/archive/rsync/2003-May/006059.html
-- --
DOCUMENTATION --------------------------------------------------------
Update README
-- --
Keep list of open issues and todos on the web site
-- --
Update web site from CVS
-- --
Perhaps redo manual as SGML
The man page is getting rather large, and there is more information
that ought to be added.
TexInfo source is probably a dying format.
Linuxdoc looks like the most likely contender. I know DocBook is
favoured by some people, but it's so bloody verbose, even with emacs
support.
-- --
LOGGING --------------------------------------------------------------
Make dry run list all updates 2002/04/03
--dry-run is too dry
Mark Santcroos points out that -n fails to list files which have
only metadata changes, though it probably should.
There may be a Debian bug about this as well.
-- --
Memory accounting
At exit, show how much memory was used for the file list, etc.
Also we do a wierd exponential-growth allocation in flist.c. I'm
not sure this makes sense with modern mallocs. At any rate it will
make us allocate a huge amount of memory for large file lists.
-- --
Improve error messages
If we hang or get SIGINT, then explain where we were up to. Perhaps
have a static buffer that contains the current function name, or
some kind of description of what we were trying to do. This is a
little easier on people than needing to run strace/truss.
"The dungeon collapses! You are killed." Rather than "unexpected
eof" give a message that is more detailed if possible and also more
helpful.
If we get an error writing to a socket, then we should perhaps
continue trying to read to see if an error message comes across
explaining why the socket is closed. I'm not sure if this would
work, but it would certainly make our messages more helpful.
What happens if a directory is missing -x attributes. Do we lose
our load? (Debian #28416) Probably fixed now, but a test case would
be good.
-- --
Better statistics: Rasmus 2002/03/08
<Rasmus>
hey, how about an rsync option that just gives you the
summary without the list of files? And perhaps gives
more information like the number of new files, number
of changed, deleted, etc. ?
<mbp>
nice idea there is --stats but at the moment it's very
tridge-oriented rather than user-friendly it would be
nice to improve it that would also work well with
--dryrun
-- --
Perhaps flush stdout like syslog
Perhaps flush stdout after each filename, so that people trying to
monitor progress in a log file can do so more easily. See
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=48108
-- --
Log deamon sessions that just list modules
At the connections that just get a list of modules are not logged,
but they should be.
-- --
Log child death on signal
If a child of the rsync daemon dies with a signal, we should notice
that when we reap it and log a message.
-- --
Keep stderr and stdout properly separated (Debian #23626)
-- --
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
Indicate whether files are new, updated, or deleted
At end of transfer, show how many files were or were not transferred
correctly.
-- --
Add reason for transfer to file logging
Explain *why* every file is transferred or not (e.g. "local mtime
123123 newer than 1283198")
-- --
debugging of daemon 2002/04/08
Add an rsyncd.conf parameter to turn on debugging on the server.
-- --
internationalization
Change to using gettext(). Probably need to ship this for platforms
that don't have it.
Solicit translations.
Does anyone care? Before we bother modifying the code, we ought to
get the manual translated first, because that's possibly more useful
and at any rate demonstrates desire.
-- --
DEVELOPMENT --------------------------------------------------------
Handling duplicate names
We need to be careful of duplicate names getting into the file list.
@@ -52,7 +555,7 @@ Handling duplicate names
through the pipeline at the same time. For example we might have
updated the first occurrence after reading the checksums for the
second. So possibly we just need to make sure that we don't have
both in the pipeline at the same time.
both in the pipeline at the same time.
Possibly if we did one directory at a time that would be sufficient.
@@ -85,23 +588,130 @@ Handling duplicate names
incompatibility, so we need to be able to accept the old format as
well.
-- --
Memory accounting
At exit, show how much memory was used for the file list, etc.
Use generic zlib 2002/02/25
Also we do a wierd exponential-growth allocation in flist.c. I'm
not sure this makes sense with modern mallocs. At any rate it will
make us allocate a huge amount of memory for large file lists.
Perhaps don't use our own zlib.
We can try using the GNU/SVID/XPG mallinfo() function to get some
heap statistics.
Advantages:
- will automatically be up to date with bugfixes in zlib
- can leave it out for small rsync on e.g. recovery disks
- can use a shared library
- avoids people breaking rsync by trying to do this themselves and
messing up
Should we ship zlib for systems that don't have it, or require
people to install it separately?
Apparently this will make us incompatible with versions of rsync
that use the patched version of rsync. Probably the simplest way to
do this is to just disable gzip (with a warning) when talking to old
versions.
-- --
TDB: 2002/03/12
Rather than storing the file list in memory, store it in a TDB.
This *might* make memory usage lower while building the file list.
Hashtable lookup will mean files are not transmitted in order,
though... hm.
This would neatly eliminate one of the major post-fork shared data
structures.
-- --
Splint 2002/03/12
Build rsync with SPLINT to try to find security holes. Add
annotations as necessary. Keep track of the number of warnings
found initially, and see how many of them are real bugs, or real
security bugs. Knowing the percentage of likely hits would be
really interesting for other projects.
-- --
Memory debugger
jra recommends Valgrind:
http://devel-home.kde.org/~sewardj/
-- --
Create release script
Script would:
Update spec files
Build tar file; upload
Send announcement to mailing list and c.o.l.a.
Make freshmeat announcement
Update web site
-- --
Add machines to build farm
Cygwin (on different versions of Win32?)
HP-UX variants (via HP?)
SCO
-- --
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.
-- --
Hard-link handling
At the moment hardlink handling is very expensive, so it's off by
default. It does not need to be so.
default. It does not need to be so.
Since most of the solutions are rather intertwined with the file
list it is probably better to fix that first, although fixing
@@ -115,7 +725,7 @@ Hard-link handling
but I have not seen them.
When trying to reproduce hard links, we only need to worry about
files that have more than one name (nlinks>1 && !S_ISDIR).
files that have more than one name (nlinks>1 && !S_ISDIR).
The basic point of this is to discover alternate names that refer to
the same file. All operations, including creating the file and
@@ -165,140 +775,152 @@ Hard-link handling
might need a little program to check whether several names refer to
the same file.
IPv6
-- --
Implement suggestions from http://www.kame.net/newsletter/19980604/
and ftp://ftp.iij.ad.jp/pub/RFC/rfc2553.txt
If a host has multiple addresses, then listen try to connect to all
in order until we get through. (getaddrinfo may return multiple
addresses.) This is kind of implemented already.
Allow skipping MD4 file_sum 2002/04/08
Possibly also when starting as a server we may need to listen on
multiple passive addresses. This might be a bit harder, because we
may need to select on all of them. Hm.
If we're doing a local transfer, or using -W, then perhaps don't
send the file checksum. If we're doing a local transfer, then
calculating MD4 checksums uses 90% of CPU and is unlikely to be
useful.
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
Indeed for transfers over zlib or ssh we can also rely on the
transport to have quite strong protection against corruption.
which should just take a small change to the parser code.
Perhaps we should have an option to disable this,
analogous to --whole-file, although it would default to
disabled. The file checksum takes up a definite space in
the protocol -- we can either set it to 0, or perhaps just
leave it out.
Errors
-- --
If we hang or get SIGINT, then explain where we were up to. Perhaps
have a static buffer that contains the current function name, or
some kind of description of what we were trying to do. This is a
little easier on people than needing to run strace/truss.
"The dungeon collapses! You are killed." Rather than "unexpected
eof" give a message that is more detailed if possible and also more
helpful.
Accelerate MD4
File attributes
Perhaps borrow an assembler MD4 from someone?
Device major/minor numbers should be at least 32 bits each. See
http://lists.samba.org/pipermail/rsync/2001-November/005357.html
Make sure we call MD4 with properly-sized blocks whenever possible
to avoid copying into the residue region?
Transfer ACLs. Need to think of a standard representation.
Probably better not to even try to convert between NT and POSIX.
Possibly can share some code with Samba.
-- --
Empty directories
With the current common --include '*/' --exclude '*' pattern, people
can end up with many empty directories. We might avoid this by
lazily creating such directories.
String area code
zlib
Test whether this is actually faster than just using malloc(). If
it's not (anymore), throw it out.
Perhaps don't use our own zlib. Will we actually be incompatible,
or just be slightly less efficient?
-- --
logging
TESTING --------------------------------------------------------------
Perhaps flush stdout after each filename, so that people trying to
monitor progress in a log file can do so more easily. See
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=48108
Torture test
At the connections that just get a list of modules are not logged,
but they should be.
Something that just keeps running rsync continuously over a data set
likely to generate problems.
rsyncd over ssh
-- --
There are already some patches to do this.
proxy authentication
Cross-test versions 2001/08/22
Allow RSYNC_PROXY to be http://user:pass@proxy.foo:3128/, and do
HTTP Basic Proxy-Authentication.
Part of the regression suite should be making sure that we
don't break backwards compatibility: old clients vs new
servers and so on. Ideally we would test both up and down
from the current release to all old versions.
Multiple schemes are possible, up to and including the insanity that
is NTLM, but Basic probably covers most cases.
Run current rsync versions against significant past releases.
SOCKS
We might need to omit broken old versions, or versions in which
particular functionality is broken
Add --with-socks, and then perhaps a command-line option to put them
on or off. This might be more reliable than LD_PRELOAD hacks.
It might be sufficient to test downloads from well-known public
rsync servers running different versions of rsync. This will give
some testing and also be the most common case for having different
versions and not being able to upgrade.
PLATFORMS ------------------------------------------------------------
The new --protocol option may help in this.
Win32
-- --
Don't detach, because this messes up --srvany.
http://sources.redhat.com/ml/cygwin/2001-08/msg00234.html
Test on kernel source
According to "Effective TCP/IP Programming" (??) close() on a socket
has incorrect behaviour on Windows -- it sends a RST packet to the
other side, which gives a "connection reset by peer" error. On that
platform we should probably do shutdown() instead. However, on Unix
we are correct to call close(), because shutdown() discards
untransmitted data.
Download all versions of kernel; unpack, sync between them. Also
sync between uncompressed tarballs. Compare directories after
transfer.
DOCUMENTATION --------------------------------------------------------
Use local mode; ssh; daemon; --whole-file and --no-whole-file.
Update README
Use awk to pull out the 'speedup' number for each transfer. Make
sure it is >= x.
BUILD FARM -----------------------------------------------------------
-- --
Add machines
AMDAHL UTS (Dave Dykstra)
Test large files
Cygwin (on different versions of Win32?)
Sparse and non-sparse
HP-UX variants (via HP?)
-- --
SCO
NICE -----------------------------------------------------------------
Create mutator program for testing
--no-detach and --no-fork options
Insert bytes, delete bytes, swap blocks, ...
Very useful for debugging. Also good when running under a
daemon-monitoring process that tries to restart the service when the
parent exits.
-- --
hang/timeout friendliness
verbose output
Indicate whether files are new, updated, or deleted
Create configure option to enable dangerous tests
internationalization
-- --
Change to using gettext(). Probably need to ship this for platforms
that don't have it.
Solicit translations.
If tests are skipped, say why.
Does anyone care?
-- --
rsyncsh
Test daemon feature to disallow particular options.
-- --
Create pipe program for testing
Create pipe program that makes slow/jerky connections for
testing Versions of read() and write() that corrupt the
stream, or abruptly fail
-- --
Create test makefile target for some tests
Separate makefile target to run rough tests -- or perhaps
just run them every time?
-- --
Test "refuse options" works
What about for --recursive?
If you specify an unrecognized option here, you should get an error.
We need a test case for this...
Was this broken when we changed to popt?
-- --
RELATED PROJECTS -----------------------------------------------------
rsyncsh
Write a small emulation of interactive ftp as a Pythonn program
that calls rsync. Commands such as "cd", "ls", "ls *.c" etc map
@@ -306,4 +928,33 @@ rsyncsh
current host, directory and so on. We can probably even do
completion of remote filenames.
%K%
-- --
http://rsync.samba.org/rsync-and-debian/
-- --
rsyncable gzip patch
Exhaustive, tortuous testing
Cleanups?
-- --
rsyncsplit as alternative to real integration with gzip?
-- --
reverse rsync over HTTP Range
Goswin Brederlow suggested this on Debian; I think tridge and I
talked about it previous in relation to rproxy.
-- --

194
access.c
View File

@@ -27,57 +27,185 @@
static int match_hostname(char *host, char *tok)
{
if (!host || !*host) return 0;
return (fnmatch(tok, host, 0) == 0);
return wildmatch(tok, host);
}
static int match_binary(char *b1, char *b2, char *mask, int addrlen)
{
int i;
for (i=0; i<addrlen; i++) {
if ((b1[i]^b2[i])&mask[i]) {
return 0;
}
}
return 1;
}
static void make_mask(char *mask, int plen, int addrlen) {
int w, b;
w = plen >> 3;
b = plen & 0x7;
if (w)
memset(mask, 0xff, w);
if (w < addrlen)
mask[w] = 0xff & (0xff<<(8-b));
if (w+1 < addrlen)
memset(mask+w+1, 0, addrlen-w-1);
return;
}
static int match_address(char *addr, char *tok)
{
char *p;
unsigned long a, t, mask = (unsigned long)~0;
struct addrinfo hints, *resa, *rest;
int gai;
int ret = 0;
int addrlen = 0;
#ifdef HAVE_STRTOL
long int bits;
#else
int bits;
#endif
char mask[16];
char *a = NULL, *t = NULL;
unsigned int len;
if (!addr || !*addr) return 0;
if (!isdigit(tok[0])) return 0;
p = strchr(tok,'/');
if (p) *p = 0;
a = inet_addr(addr);
t = inet_addr(tok);
if (p) {
*p = '/';
*p = '\0';
len = p - tok;
}
else
len = strlen(tok);
if (t == INADDR_NONE) {
rprintf(FERROR,"malformed address %s\n", tok);
/* Fail quietly if tok is a hostname (not an address) */
if (strspn(tok, ".0123456789") != len
#ifdef INET6
&& !strchr(tok, ':')
#endif
) return 0;
memset(&hints, 0, sizeof(hints));
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
#ifdef AI_NUMERICHOST
hints.ai_flags = AI_NUMERICHOST;
#endif
gai = getaddrinfo(addr, NULL, &hints, &resa);
if (gai) return 0;
gai = getaddrinfo(tok, NULL, &hints, &rest);
if (p)
*p++ = '/';
if (gai) {
rprintf(FERROR,
"error matching address %s: %s\n",
tok,
gai_strerror(gai));
freeaddrinfo(resa);
return 0;
}
a = ntohl(a);
t = ntohl(t);
if (p) {
if (strchr(p+1,'.')) {
mask = inet_addr(p+1);
if (mask == INADDR_NONE) {
rprintf(FERROR,"malformed mask in %s\n", tok);
return 0;
}
mask = ntohl(mask);
} else {
int bits = atoi(p+1);
if (bits == 0) return 1;
if (bits <= 0 || bits > 32) {
rprintf(FERROR,"malformed mask in %s\n", tok);
return 0;
}
mask &= (mask << (32-bits));
}
if (rest->ai_family != resa->ai_family) {
ret = 0;
goto out;
}
return ((a&mask) == (t&mask));
switch(resa->ai_family) {
case PF_INET:
a = (char *)&((struct sockaddr_in *)resa->ai_addr)->sin_addr;
t = (char *)&((struct sockaddr_in *)rest->ai_addr)->sin_addr;
addrlen = 4;
break;
#ifdef INET6
case PF_INET6:
{
struct sockaddr_in6 *sin6a, *sin6t;
sin6a = (struct sockaddr_in6 *)resa->ai_addr;
sin6t = (struct sockaddr_in6 *)rest->ai_addr;
a = (char *)&sin6a->sin6_addr;
t = (char *)&sin6t->sin6_addr;
addrlen = 16;
#ifdef HAVE_SOCKADDR_IN6_SCOPE_ID
if (sin6t->sin6_scope_id &&
sin6a->sin6_scope_id != sin6t->sin6_scope_id) {
ret = 0;
goto out;
}
#endif
break;
}
#endif
default:
rprintf(FERROR,"unknown family %u\n", rest->ai_family);
ret = 0;
goto out;
}
bits = -1;
if (p) {
if (inet_pton(resa->ai_addr->sa_family, p, mask) <= 0) {
#ifdef HAVE_STRTOL
char *ep = NULL;
#else
unsigned char *pp;
#endif
#ifdef HAVE_STRTOL
bits = strtol(p, &ep, 10);
if (!*p || *ep) {
rprintf(FERROR,"malformed mask in %s\n", tok);
ret = 0;
goto out;
}
#else
for (pp = (unsigned char *)p; *pp; pp++) {
if (!isascii(*pp) || !isdigit(*pp)) {
rprintf(FERROR,"malformed mask in %s\n", tok);
ret = 0;
goto out;
}
}
bits = atoi(p);
#endif
if (bits == 0) {
ret = 1;
goto out;
}
if (bits < 0 || bits > (addrlen << 3)) {
rprintf(FERROR,"malformed mask in %s\n", tok);
ret = 0;
goto out;
}
}
} else {
bits = 128;
}
if (bits >= 0)
make_mask(mask, bits, addrlen);
ret = match_binary(a, t, mask, addrlen);
out:
freeaddrinfo(resa);
freeaddrinfo(rest);
return ret;
}
static int access_match(char *list, char *addr, char *host)

View File

@@ -7,4 +7,5 @@
#undef HAVE_GETTIMEOFDAY_TZ
#undef ENABLE_IPV6
#undef HAVE_SOCKADDR_LEN
#undef HAVE_SOCKADDR_IN6_SCOPE_ID
#undef HAVE_SOCKETPAIR

View File

@@ -203,7 +203,7 @@ static void generate_hash(char *in, char *challenge, char *out)
otherwise return username
*/
char *auth_server(int fd, int module, char *addr, char *leader)
char *auth_server(int f_in, int f_out, int module, char *addr, char *leader)
{
char *users = lp_auth_users(module);
char challenge[16];
@@ -222,9 +222,9 @@ char *auth_server(int fd, int module, char *addr, char *leader)
base64_encode(challenge, 16, b64_challenge);
io_printf(fd,"%s%s\n", leader, b64_challenge);
io_printf(f_out, "%s%s\n", leader, b64_challenge);
if (!read_line(fd, line, sizeof(line)-1)) {
if (!read_line(f_in, line, sizeof(line)-1)) {
return NULL;
}
@@ -239,7 +239,7 @@ char *auth_server(int fd, int module, char *addr, char *leader)
if (!users) return NULL;
for (tok=strtok(users," ,\t"); tok; tok = strtok(NULL," ,\t")) {
if (fnmatch(tok, user, 0) == 0) break;
if (wildmatch(tok, user)) break;
}
free(users);
@@ -273,8 +273,14 @@ void auth_client(int fd, char *user, char *challenge)
if (!(pass=getpassf(password_file)) && !(pass=getenv("RSYNC_PASSWORD"))) {
/* XXX: cyeoh says that getpass is deprecated, because
it may return a truncated password on some systems,
and it is not in the LSB. */
* it may return a truncated password on some systems,
* and it is not in the LSB.
*
* Andrew Klein says that getpassphrase() is present
* on Solaris and reads up to 256 characters.
*
* OpenBSD has a readpassphrase() that might be more suitable.
*/
pass = getpass("Password: ");
}

222
backup.c
View File

@@ -21,10 +21,11 @@
#include "rsync.h"
extern int verbose;
extern int backup_suffix_len;
extern int backup_dir_len;
extern char *backup_suffix;
extern char *backup_dir;
extern int am_root;
extern int preserve_devices;
extern int preserve_links;
@@ -34,20 +35,20 @@ extern int preserve_hard_links;
static int make_simple_backup(char *fname)
{
char fnamebak[MAXPATHLEN];
if (strlen(fname) + strlen(backup_suffix) > (MAXPATHLEN-1)) {
rprintf(FERROR,"backup filename too long\n");
if (strlen(fname) + backup_suffix_len > MAXPATHLEN-1) {
rprintf(FERROR, "backup filename too long\n");
return 0;
}
snprintf(fnamebak,sizeof(fnamebak),"%s%s",fname,backup_suffix);
if (do_rename(fname,fnamebak) != 0) {
snprintf(fnamebak, sizeof(fnamebak), "%s%s", fname, backup_suffix);
if (do_rename(fname, fnamebak) != 0) {
/* cygwin (at least version b19) reports EINVAL */
if (errno != ENOENT && errno != EINVAL) {
rsyserr(FERROR, errno, "rename %s to backup %s", fname, fnamebak);
return 0;
}
} else if (verbose > 1) {
rprintf(FINFO,"backed up %s to %s\n",fname,fnamebak);
rprintf(FINFO, "backed up %s to %s\n", fname, fnamebak);
}
return 1;
}
@@ -80,50 +81,53 @@ static int make_dir(char *name, int mask)
Create a directory given an absolute path, perms based upon another directory
path
****************************************************************************/
static int make_bak_dir(char *fname,char *bak_path)
static int make_bak_dir(char *fname, char *bak_path)
{
STRUCT_STAT st;
STRUCT_STAT *st2;
char fullpath[MAXPATHLEN];
extern int orig_umask;
char *p;
char *q;
STRUCT_STAT st;
STRUCT_STAT *st2;
char fullpath[MAXPATHLEN];
extern int orig_umask;
char *p;
char *q;
while(strncmp(bak_path,"./",2)==0) bak_path += 2;
while(strncmp(bak_path, "./", 2) == 0) bak_path += 2;
if(bak_path[strlen(bak_path)-1]!='/') {
snprintf(fullpath,sizeof(fullpath),"%s/",bak_path);
} else {
snprintf(fullpath,sizeof(fullpath),"%s",bak_path);
}
p=fullpath;
q=&fullpath[strlen(fullpath)]; /* End of bak_path string */
strcat(fullpath,fname);
if(bak_path[strlen(bak_path)-1] != '/') {
snprintf(fullpath, sizeof(fullpath), "%s/", bak_path);
} else {
snprintf(fullpath, sizeof(fullpath), "%s", bak_path);
}
p = fullpath;
q = &fullpath[strlen(fullpath)]; /* End of bak_path string */
strcat(fullpath, fname);
/* Make the directories */
while ((p=strchr(p,'/'))) {
*p = 0;
if(do_lstat(fullpath,&st)!=0) {
do_mkdir(fullpath,0777 & ~orig_umask);
if(p>q) {
if(do_lstat(q,&st)!=0) {
rprintf(FERROR,"make_bak_dir stat %s : %s\n",fullpath,strerror(errno));
} else {
st2=&st;
set_modtime(fullpath,st2->st_mtime);
if(do_lchown(fullpath,st2->st_uid,st2->st_gid)!=0) {
rprintf(FERROR,"make_bak_dir chown %s : %s\n",fullpath,strerror(errno));
};
if(do_chmod(fullpath,st2->st_mode)!=0) {
rprintf(FERROR,"make_bak_dir failed to set permissions on %s : %s\n",fullpath,strerror(errno));
};
};
}
};
*p = '/';
p++;
}
return 0;
/* Make the directories */
while ((p = strchr(p, '/'))) {
*p = 0;
if(do_lstat(fullpath, &st) != 0) {
do_mkdir(fullpath, 0777 & ~orig_umask);
if(p>q) {
if(do_lstat(q, &st) != 0) {
rprintf(FERROR, "make_bak_dir stat %s failed: %s\n",
full_fname(fullpath), strerror(errno));
} else {
st2 = &st;
set_modtime(fullpath, st2->st_mtime);
if(do_lchown(fullpath, st2->st_uid, st2->st_gid) != 0) {
rprintf(FERROR, "make_bak_dir chown %s failed: %s\n",
full_fname(fullpath), strerror(errno));
}
if(do_chmod(fullpath, st2->st_mode) != 0) {
rprintf(FERROR, "make_bak_dir failed to set permissions on %s: %s\n",
full_fname(fullpath), strerror(errno));
}
}
}
}
*p = '/';
p++;
}
return 0;
}
/* robustly move a file, creating new directory structures if necessary */
@@ -146,7 +150,7 @@ static int robust_move(char *src, char *dst)
if (failed) {
if (verbose > 2)
rprintf (FERROR, "robust_move failed: %s(%d)\n",
strerror (errno), errno);
strerror (errno), errno);
switch (errno) {
/* external filesystem */
case EXDEV:
@@ -155,7 +159,7 @@ static int robust_move(char *src, char *dst)
break;
/* no directory to write to */
case ENOENT:
make_dir (dst, 0755);
make_dir(dst, 0700);
keep_trying--;
break;
default:
@@ -179,12 +183,12 @@ static int keep_backup(char *fname)
STRUCT_STAT st;
struct file_struct *file;
int kept=0;
int kept = 0;
int ret_code;
if (!initialised) {
if (backup_dir[strlen(backup_dir) - 1] == '/')
backup_dir[strlen(backup_dir) - 1] = 0;
if (backup_dir_len && backup_dir[backup_dir_len - 1] == '/')
backup_dir[--backup_dir_len] = '\0';
if (verbose > 0)
rprintf (FINFO, "backup_dir is %s\n", backup_dir);
initialised = 1;
@@ -197,79 +201,86 @@ static int keep_backup(char *fname)
if (do_stat (fname, &st)) return 1;
#endif
file = make_file(-1, fname, NULL, 1);
file = make_file(fname, NULL, NO_EXCLUDES);
/* the file could have disappeared */
if (!file) return 1;
/* make a complete pathname for backup file */
if (strlen(backup_dir) + strlen(fname) > (MAXPATHLEN - 1)) {
rprintf (FERROR, "keep_backup filename too long\n");
return 0;
}
snprintf(keep_name, sizeof (keep_name), "%s/%s", backup_dir, fname);
/* make a complete pathname for backup file */
if (backup_dir_len+strlen(fname)+backup_suffix_len > MAXPATHLEN-1) {
rprintf (FERROR, "keep_backup filename too long\n");
return 0;
}
snprintf(keep_name, sizeof (keep_name), "%s/%s%s",
backup_dir, fname, backup_suffix);
#ifdef HAVE_MKNOD
/* Check to see if this is a device file, or link */
if(IS_DEVICE(file->mode)) {
if(am_root && preserve_devices) {
make_bak_dir(fname,backup_dir);
if(do_mknod(keep_name,file->mode,file->rdev)!=0) {
rprintf(FERROR,"mknod %s : %s\n",keep_name,strerror(errno));
} else {
if(verbose>2)
rprintf(FINFO,"make_backup : DEVICE %s successful.\n",fname);
};
};
kept=1;
do_unlink(fname);
};
if(IS_DEVICE(file->mode)) {
if(am_root && preserve_devices) {
make_bak_dir(fname, backup_dir);
if(do_mknod(keep_name, file->mode, file->rdev) != 0) {
rprintf(FERROR, "mknod %s failed: %s\n",
full_fname(keep_name), strerror(errno));
} else if(verbose>2) {
rprintf(FINFO, "make_backup: DEVICE %s successful.\n", fname);
}
}
kept = 1;
do_unlink(fname);
}
#endif
if(!kept && S_ISDIR(file->mode)) {
/* make an empty directory */
make_bak_dir(fname,backup_dir);
do_mkdir(keep_name,file->mode);
ret_code=do_rmdir(fname);
if(verbose>2)
rprintf(FINFO,"make_backup : RMDIR %s returns %i\n",fname,ret_code);
kept=1;
};
make_bak_dir(fname, backup_dir);
do_mkdir(keep_name, file->mode);
ret_code = do_rmdir(fname);
if(verbose>2) {
rprintf(FINFO, "make_backup: RMDIR %s returns %i\n",
full_fname(fname), ret_code);
}
kept = 1;
}
#if SUPPORT_LINKS
if(!kept && preserve_links && S_ISLNK(file->mode)) {
extern int safe_symlinks;
if (safe_symlinks && unsafe_symlink(file->link, keep_name)) {
if (verbose) {
rprintf(FINFO,"ignoring unsafe symlink %s -> %s\n",
keep_name,file->link);
}
kept=1;
}
make_bak_dir(fname,backup_dir);
if(do_symlink(file->link,keep_name) != 0) {
rprintf(FERROR,"link %s -> %s : %s\n",keep_name,file->link,strerror(errno));
};
do_unlink(fname);
kept=1;
};
if(!kept && preserve_links && S_ISLNK(file->mode)) {
extern int safe_symlinks;
if (safe_symlinks && unsafe_symlink(file->link, keep_name)) {
if (verbose) {
rprintf(FINFO, "ignoring unsafe symlink %s -> %s\n",
full_fname(keep_name), file->link);
}
kept = 1;
}
make_bak_dir(fname, backup_dir);
if(do_symlink(file->link, keep_name) != 0) {
rprintf(FERROR, "link %s -> %s : %s\n",
full_fname(keep_name), file->link, strerror(errno));
}
do_unlink(fname);
kept = 1;
}
#endif
if(!kept && preserve_hard_links && check_hard_link(file)) {
if(verbose > 1) rprintf(FINFO,"%s is a hard link\n",f_name(file));
};
if(!kept && preserve_hard_links && check_hard_link(file)) {
if(verbose > 1)
rprintf(FINFO, "%s is a hard link\n", f_name(file));
}
if(!kept && !S_ISREG(file->mode)) {
rprintf(FINFO,"make_bak: skipping non-regular file %s\n",fname);
}
if(!kept && !S_ISREG(file->mode)) {
rprintf(FINFO, "make_bak: skipping non-regular file %s\n",
fname);
}
/* move to keep tree if a file */
if(!kept) {
if (!robust_move (fname, keep_name))
rprintf(FERROR, "keep_backup failed %s -> %s : %s\n",
fname, keep_name, strerror(errno));
};
if (!robust_move (fname, keep_name)) {
rprintf(FERROR, "keep_backup failed: %s -> \"%s\": %s\n",
full_fname(fname), keep_name, strerror(errno));
}
}
set_perms (keep_name, file, NULL, 0);
free_file (file);
free (file);
@@ -288,4 +299,3 @@ int make_backup(char *fname)
else
return (make_simple_backup(fname));
}

266
batch.c
View File

@@ -8,55 +8,38 @@
#include "rsync.h"
#include <time.h>
char rsync_flist_file[27] = "rsync_flist.";
char rsync_csums_file[27] = "rsync_csums.";
char rsync_delta_file[27] = "rsync_delta.";
char rsync_argvs_file[27] = "rsync_argvs.";
char batch_file_ext[15];
int fdb;
int fdb_delta;
int fdb_open;
int fdb_close;
extern char *batch_prefix;
struct file_list *batch_flist;
void create_batch_file_ext()
{
struct tm *timeptr;
time_t elapsed_seconds;
static char rsync_flist_file[] = ".rsync_flist";
static char rsync_csums_file[] = ".rsync_csums";
static char rsync_delta_file[] = ".rsync_delta";
static char rsync_argvs_file[] = ".rsync_argvs";
/* Save run date and time to use for batch file extensions */
time(&elapsed_seconds);
timeptr = localtime(&elapsed_seconds);
sprintf(batch_file_ext, "%4d%02d%02d%02d%02d%02d",
timeptr->tm_year + 1900, timeptr->tm_mon + 1,
timeptr->tm_mday, timeptr->tm_hour, timeptr->tm_min,
timeptr->tm_sec);
rprintf(FINFO,"batch file extension: %s\n", batch_file_ext);
}
void set_batch_file_ext(char *ext)
{
strcpy(batch_file_ext, ext);
}
static int fdb;
static int fdb_delta;
static int fdb_open;
static int fdb_close;
void write_batch_flist_file(char *buff, int bytes_to_write)
{
char filename[MAXPATHLEN];
if (fdb_open) {
/* Set up file extension */
strcat(rsync_flist_file, batch_file_ext);
strlcpy(filename, batch_prefix, sizeof(filename));
strlcat(filename, rsync_flist_file, sizeof(filename));
/* Open batch flist file for writing; create it if it doesn't exist */
fdb =
do_open(rsync_flist_file, O_WRONLY | O_CREAT | O_TRUNC,
/*
* Open batch flist file for writing;
* create it if it doesn't exist
*/
fdb = do_open(filename, O_WRONLY | O_CREAT | O_TRUNC,
S_IREAD | S_IWRITE);
if (fdb == -1) {
rprintf(FERROR, "Batch file %s open error: %s\n",
rsync_flist_file, strerror(errno));
filename, strerror(errno));
close(fdb);
exit_cleanup(1);
}
@@ -67,12 +50,11 @@ void write_batch_flist_file(char *buff, int bytes_to_write)
if (write(fdb, buff, bytes_to_write) == -1) {
rprintf(FERROR, "Batch file %s write error: %s\n",
rsync_flist_file, strerror(errno));
filename, strerror(errno));
close(fdb);
exit_cleanup(1);
}
if (fdb_close) {
close(fdb);
}
@@ -110,7 +92,6 @@ void write_batch_flist_info(int flist_count, struct file_struct **fptr)
}
write_char_bufs(fptr[i]->sum);
}
}
void write_char_bufs(char *buf)
@@ -118,11 +99,8 @@ void write_char_bufs(char *buf)
/* Write the size of the string which will follow */
char b[4];
if (buf != NULL)
SIVAL(b, 0, strlen(buf));
else {
SIVAL(b, 0, 0);
}
SIVAL(b, 0, buf != NULL ? strlen(buf) : 0);
write_batch_flist_file(b, sizeof(int));
@@ -137,36 +115,52 @@ void write_batch_argvs_file(int argc, char *argv[])
{
int fdb;
int i;
char buff[256];
char buff[256]; /* XXX */
char buff2[MAXPATHLEN + 6];
char filename[MAXPATHLEN];
strcat(rsync_argvs_file, batch_file_ext);
/* Set up file extension */
strlcpy(filename, batch_prefix, sizeof(filename));
strlcat(filename, rsync_argvs_file, sizeof(filename));
/* Open batch argvs file for writing; create it if it doesn't exist */
fdb = do_open(rsync_argvs_file, O_WRONLY | O_CREAT | O_TRUNC,
/*
* Open batch argvs file for writing;
* create it if it doesn't exist
*/
fdb = do_open(filename, O_WRONLY | O_CREAT | O_TRUNC,
S_IREAD | S_IWRITE | S_IEXEC);
if (fdb == -1) {
rprintf(FERROR, "Batch file %s open error: %s\n",
rsync_argvs_file, strerror(errno));
filename, strerror(errno));
close(fdb);
exit_cleanup(1);
}
buff[0] = '\0';
/* Write argvs info to batch file */
for (i = 0; i < argc; ++i) {
if (i == argc - 2)
if (i == argc - 2) /* Skip source directory on cmdline */
continue;
/*
* FIXME:
* I think directly manipulating argv[] is probably bogus
*/
if (!strcmp(argv[i], "--write-batch")) {
if (!strncmp(argv[i], "--write-batch",
strlen("--write-batch"))) {
/* Safer to change it here than script */
/* Change to --read-batch + ext * to get ready for remote */
strlcat(buff, "--read-batch ", sizeof(buff));
strlcat(buff, batch_file_ext, sizeof(buff));
} else {
/*
* Change to --read-batch=prefix
* to get ready for remote
*/
strlcat(buff, "--read-batch=", sizeof(buff));
strlcat(buff, batch_prefix, sizeof(buff));
} else
if (i == argc - 1) {
snprintf(buff2, sizeof(buff2), "${1:-%s}", argv[i]);
strlcat(buff, buff2, sizeof(buff));
}
else {
strlcat(buff, argv[i], sizeof(buff));
}
@@ -177,31 +171,30 @@ void write_batch_argvs_file(int argc, char *argv[])
strlcat(buff, "\n", sizeof(buff));
if (!write(fdb, buff, strlen(buff))) {
rprintf(FERROR, "Batch file %s write error: %s\n",
rsync_argvs_file, strerror(errno));
filename, strerror(errno));
close(fdb);
exit_cleanup(1);
}
close(fdb);
}
struct file_list *create_flist_from_batch()
struct file_list *create_flist_from_batch(void)
{
unsigned char flags;
fdb_open = 1;
fdb_close = 0;
batch_flist = (struct file_list *) malloc(sizeof(batch_flist[0]));
batch_flist = new(struct file_list);
if (!batch_flist) {
out_of_memory("create_flist_from_batch");
}
batch_flist->count = 0;
batch_flist->malloced = 1000;
batch_flist->files =
(struct file_struct **) malloc(sizeof(batch_flist->files[0]) *
batch_flist->malloced);
batch_flist->files = new_array(struct file_struct *,
batch_flist->malloced);
if (!batch_flist->files) {
out_of_memory("create_flist_from_batch"); /* dw -- will exit */
out_of_memory("create_flist_from_batch");
}
for (flags = read_batch_flags(); flags; flags = read_batch_flags()) {
@@ -213,14 +206,10 @@ struct file_list *create_flist_from_batch()
batch_flist->malloced += 1000;
else
batch_flist->malloced *= 2;
batch_flist->files =
(struct file_struct **) realloc(batch_flist->
files,
sizeof
(batch_flist->
files[0]) *
batch_flist->
malloced);
batch_flist->files
= realloc_array(batch_flist->files,
struct file_struct *,
batch_flist->malloced);
if (!batch_flist->files)
out_of_memory("create_flist_from_batch");
}
@@ -231,23 +220,23 @@ struct file_list *create_flist_from_batch()
}
return batch_flist;
}
int read_batch_flist_file(char *buff, int len)
{
int bytes_read;
char filename[MAXPATHLEN];
if (fdb_open) {
/* Set up file extension */
strcat(rsync_flist_file, batch_file_ext);
/* Set up file extension */
strlcpy(filename, batch_prefix, sizeof(filename));
strlcat(filename, rsync_flist_file, sizeof(filename));
/* Open batch flist file for reading */
fdb = do_open(rsync_flist_file, O_RDONLY, 0);
fdb = do_open(filename, O_RDONLY, 0);
if (fdb == -1) {
rprintf(FERROR, "Batch file %s open error: %s\n",
rsync_flist_file, strerror(errno));
filename, strerror(errno));
close(fdb);
exit_cleanup(1);
}
@@ -256,21 +245,21 @@ int read_batch_flist_file(char *buff, int len)
/* Read flist batch file */
bytes_read = read(fdb, buff, len);
if (bytes_read == -1) {
switch (bytes_read = read(fdb, buff, len)) {
case -1:
rprintf(FERROR, "Batch file %s read error: %s\n",
rsync_flist_file, strerror(errno));
filename, strerror(errno));
close(fdb);
exit_cleanup(1);
}
if (bytes_read == 0) { /* EOF */
break;
case 0: /* EOF */
close(fdb);
}
return bytes_read;
}
unsigned char read_batch_flags()
unsigned char read_batch_flags(void)
{
int flags;
@@ -288,13 +277,17 @@ void read_batch_flist_info(struct file_struct **fptr)
char buff[256];
struct file_struct *file;
file = (struct file_struct *) malloc(sizeof(*file));
file = new(struct file_struct);
if (!file)
out_of_memory("read_batch_flist_info");
memset((char *) file, 0, sizeof(*file));
(*fptr) = file;
*fptr = file;
/*
* Keep these in sync with bytes_to_write assignment
* in write_batch_flist_info()
*/
read_batch_flist_file((char *) &file->modtime, sizeof(time_t));
read_batch_flist_file((char *) &file->length, sizeof(OFF_T));
read_batch_flist_file((char *) &file->mode, sizeof(mode_t));
@@ -356,20 +349,23 @@ void read_batch_flist_info(struct file_struct **fptr)
void write_batch_csums_file(void *buff, int bytes_to_write)
{
static int fdb_open = 1;
char filename[MAXPATHLEN];
if (fdb_open) {
/* Set up file extension */
strcat(rsync_csums_file, batch_file_ext);
strlcpy(filename, batch_prefix, sizeof(filename));
strlcat(filename, rsync_csums_file, sizeof(filename));
/* Open batch csums file for writing; create it if it doesn't exist */
fdb =
do_open(rsync_csums_file, O_WRONLY | O_CREAT | O_TRUNC,
/*
* Open batch csums file for writing;
* create it if it doesn't exist
*/
fdb = do_open(filename, O_WRONLY | O_CREAT | O_TRUNC,
S_IREAD | S_IWRITE);
if (fdb == -1) {
rprintf(FERROR, "Batch file %s open error: %s\n",
rsync_csums_file, strerror(errno));
filename, strerror(errno));
close(fdb);
exit_cleanup(1);
}
@@ -380,35 +376,38 @@ void write_batch_csums_file(void *buff, int bytes_to_write)
if (write(fdb, buff, bytes_to_write) == -1) {
rprintf(FERROR, "Batch file %s write error: %s\n",
rsync_csums_file, strerror(errno));
filename, strerror(errno));
close(fdb);
exit_cleanup(1);
}
}
void close_batch_csums_file()
void close_batch_csums_file(void)
{
close(fdb);
}
/**
* Write csum info to batch file
*
* @todo This will break if s->count is ever larger than maxint. The
* batch code should probably be changed to consistently use the
* variable-length integer routines, which is probably a compatible
* change.
**/
void write_batch_csum_info(int *flist_entry, int flist_count,
struct sum_struct *s)
{
size_t i;
unsigned int int_zero = 0;
int int_count;
extern int csum_length;
fdb_open = 1;
/* Write csum info to batch file */
/* FIXME: This will break if s->count is ever not exactly an int. */
write_batch_csums_file(flist_entry, sizeof(int));
if (s)
write_batch_csums_file(&s->count, sizeof(int));
else
write_batch_csums_file(&int_zero, sizeof (int));
int_count = s ? (int) s->count : 0;
write_batch_csums_file(&int_count, sizeof int_count);
if (s) {
for (i = 0; i < s->count; i++) {
@@ -417,8 +416,7 @@ void write_batch_csum_info(int *flist_entry, int flist_count,
&& (i == s->count - 1)) {
fdb_close = 1;
}
write_batch_csums_file(s->sums[i].sum2,
csum_length);
write_batch_csums_file(s->sums[i].sum2, csum_length);
}
}
}
@@ -427,17 +425,18 @@ int read_batch_csums_file(char *buff, int len)
{
static int fdb_open = 1;
int bytes_read;
char filename[MAXPATHLEN];
if (fdb_open) {
/* Set up file extension */
strcat(rsync_csums_file, batch_file_ext);
/* Set up file extension */
strlcpy(filename, batch_prefix, sizeof(filename));
strlcat(filename, rsync_csums_file, sizeof(filename));
/* Open batch flist file for reading */
fdb = do_open(rsync_csums_file, O_RDONLY, 0);
fdb = do_open(filename, O_RDONLY, 0);
if (fdb == -1) {
rprintf(FERROR, "Batch file %s open error: %s\n",
rsync_csums_file, strerror(errno));
filename, strerror(errno));
close(fdb);
exit_cleanup(1);
}
@@ -450,14 +449,14 @@ int read_batch_csums_file(char *buff, int len)
if (bytes_read == -1) {
rprintf(FERROR, "Batch file %s read error: %s\n",
rsync_csums_file, strerror(errno));
filename, strerror(errno));
close(fdb);
exit_cleanup(1);
}
return bytes_read;
}
void read_batch_csum_info(int flist_entry, struct sum_struct *s,
int *checksums_match)
{
@@ -468,11 +467,9 @@ void read_batch_csum_info(int flist_entry, struct sum_struct *s,
char file_sum2[SUM_LENGTH];
extern int csum_length;
read_batch_csums_file((char *) &file_flist_entry, sizeof(int));
if (file_flist_entry != flist_entry) {
rprintf(FINFO, "file_list_entry NE flist_entry\n");
rprintf(FINFO, "file_flist_entry = %d flist_entry = %d\n",
rprintf(FINFO, "file_flist_entry (%d) != flist_entry (%d)\n",
file_flist_entry, flist_entry);
close(fdb);
exit_cleanup(1);
@@ -488,31 +485,33 @@ void read_batch_csum_info(int flist_entry, struct sum_struct *s,
read_batch_csums_file(file_sum2, csum_length);
if ((s->sums[i].sum1 != file_sum1) ||
(memcmp
(s->sums[i].sum2, file_sum2,
csum_length) != 0)) {
(memcmp(s->sums[i].sum2, file_sum2, csum_length)
!= 0)) {
*checksums_match = 0;
}
} /* end for */
}
}
void write_batch_delta_file(char *buff, int bytes_to_write)
{
static int fdb_delta_open = 1;
char filename[MAXPATHLEN];
if (fdb_delta_open) {
/* Set up file extension */
strcat(rsync_delta_file, batch_file_ext);
strlcpy(filename, batch_prefix, sizeof(filename));
strlcat(filename, rsync_delta_file, sizeof(filename));
/* Open batch delta file for writing; create it if it doesn't exist */
fdb_delta =
do_open(rsync_delta_file, O_WRONLY | O_CREAT | O_TRUNC,
/*
* Open batch delta file for writing;
* create it if it doesn't exist
*/
fdb_delta = do_open(filename, O_WRONLY | O_CREAT | O_TRUNC,
S_IREAD | S_IWRITE);
if (fdb_delta == -1) {
rprintf(FERROR, "Batch file %s open error: %s\n",
rsync_delta_file, strerror(errno));
filename, strerror(errno));
close(fdb_delta);
exit_cleanup(1);
}
@@ -523,32 +522,33 @@ void write_batch_delta_file(char *buff, int bytes_to_write)
if (write(fdb_delta, buff, bytes_to_write) == -1) {
rprintf(FERROR, "Batch file %s write error: %s\n",
rsync_delta_file, strerror(errno));
filename, strerror(errno));
close(fdb_delta);
exit_cleanup(1);
}
}
void close_batch_delta_file()
void close_batch_delta_file(void)
{
close(fdb_delta);
}
int read_batch_delta_file(char *buff, int len)
{
static int fdb_delta_open = 1;
int bytes_read;
char filename[MAXPATHLEN];
if (fdb_delta_open) {
/* Set up file extension */
strcat(rsync_delta_file, batch_file_ext);
/* Set up file extension */
strlcpy(filename, batch_prefix, sizeof(filename));
strlcat(filename, rsync_delta_file, sizeof(filename));
/* Open batch flist file for reading */
fdb_delta = do_open(rsync_delta_file, O_RDONLY, 0);
fdb_delta = do_open(filename, O_RDONLY, 0);
if (fdb_delta == -1) {
rprintf(FERROR, "Batch file %s open error: %s\n",
rsync_delta_file, strerror(errno));
filename, strerror(errno));
close(fdb_delta);
exit_cleanup(1);
}
@@ -561,14 +561,14 @@ int read_batch_delta_file(char *buff, int len)
if (bytes_read == -1) {
rprintf(FERROR, "Batch file %s read error: %s\n",
rsync_delta_file, strerror(errno));
filename, strerror(errno));
close(fdb_delta);
exit_cleanup(1);
}
return bytes_read;
}
void show_flist(int index, struct file_struct **fptr)
{
/* for debugging show_flist(flist->count, flist->files * */

View File

@@ -24,7 +24,7 @@ int csum_length=2; /* initial value */
#define CSUM_CHUNK 64
int checksum_seed = 0;
extern int remote_version;
extern int protocol_version;
/*
a simple 32 bit checksum that can be upadted from either end
@@ -58,7 +58,7 @@ void get_checksum2(char *buf,int len,char *sum)
if (len > len1) {
if (buf1) free(buf1);
buf1 = (char *)malloc(len+4);
buf1 = new_array(char, len+4);
len1 = len;
if (!buf1) out_of_memory("get_checksum2");
}
@@ -74,7 +74,13 @@ void get_checksum2(char *buf,int len,char *sum)
for(i = 0; i + CSUM_CHUNK <= len; i += CSUM_CHUNK) {
mdfour_update(&m, (uchar *)(buf1+i), CSUM_CHUNK);
}
if (len - i > 0) {
/*
* Prior to version 27 an incorrect MD4 checksum was computed
* by failing to call mdfour_tail() for block sizes that
* are multiples of 64. This is fixed by calling mdfour_update()
* even when there are no more bytes.
*/
if (len - i > 0 || protocol_version >= 27) {
mdfour_update(&m, (uchar *)(buf1+i), (len-i));
}
@@ -105,8 +111,16 @@ void file_checksum(char *fname,char *sum,OFF_T size)
mdfour_update(&m, (uchar *)tmpchunk, 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) {
memcpy(tmpchunk, map_ptr(buf,i,len-i), len-i);
}
if (len - i > 0 || protocol_version >= 27) {
mdfour_update(&m, (uchar *)tmpchunk, (len-i));
}
@@ -117,16 +131,6 @@ void file_checksum(char *fname,char *sum,OFF_T size)
}
void checksum_init(void)
{
if (remote_version >= 14)
csum_length = 2; /* adaptive */
else
csum_length = SUM_LENGTH;
}
static int sumresidue;
static char sumrbuf[CSUM_CHUNK];
static struct mdfour md;
@@ -140,7 +144,15 @@ void sum_init(void)
sum_update(s,4);
}
void sum_update(char *p,int len)
/**
* Feed data into an MD4 accumulator, md. The results may be
* retrieved using sum_end(). md is used for different purposes at
* different points during execution.
*
* @todo Perhaps get rid of md and just pass in the address each time.
* Very slightly clearer and slower.
**/
void sum_update(char *p, int len)
{
int i;
if (len + sumresidue < CSUM_CHUNK) {
@@ -172,7 +184,7 @@ void sum_update(char *p,int len)
void sum_end(char *sum)
{
if (sumresidue) {
if (sumresidue || protocol_version >= 27) {
mdfour_update(&md, (uchar *)sumrbuf, sumresidue);
}

View File

@@ -2,6 +2,7 @@
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
@@ -20,9 +21,50 @@
#include "rsync.h"
/* handling the cleanup when a transfer is interrupted is tricky when
--partial is selected. We need to ensure that the partial file is
kept if any real data has been transferred */
/**
* Close all open sockets and files, allowing a (somewhat) graceful
* shutdown() of socket connections. This eliminates the abortive
* TCP RST sent by a Winsock-based system when the close() occurs.
**/
void close_all(void)
{
#ifdef SHUTDOWN_ALL_SOCKETS
int max_fd;
int fd;
int ret;
struct stat st;
max_fd = sysconf(_SC_OPEN_MAX) - 1;
for (fd = max_fd; fd >= 0; fd--) {
ret = fstat(fd,&st);
if (fstat(fd,&st) == 0) {
if (is_a_socket(fd)) {
ret = shutdown(fd, 2);
}
ret = close(fd);
}
}
#endif
}
/**
* @file cleanup.c
*
* Code for handling interrupted transfers. Depending on the @c
* --partial option, we may either delete the temporary file, or go
* ahead and overwrite the destination. This second behaviour only
* occurs if we've sent literal data and therefore hopefully made
* progress on the transfer.
**/
/**
* Set to True once literal data has been sent across the link for the
* current file. (????)
*
* Handling the cleanup when a transfer is interrupted is tricky when
* --partial is selected. We need to ensure that the partial file is
* kept if any real data has been transferred.
**/
int cleanup_got_literal=0;
static char *cleanup_fname;
@@ -35,17 +77,31 @@ extern int io_error;
pid_t cleanup_child_pid = -1;
/*
* Code is one of the RERR_* codes from errcode.h.
*/
/**
* Eventually calls exit(), passing @p code, therefore does not return.
*
* @param code one of the RERR_* codes from errcode.h.
**/
void _exit_cleanup(int code, const char *file, int line)
{
int ocode = code;
extern int keep_partial;
extern int log_got_error;
static int inside_cleanup = 0;
if (inside_cleanup > 10) {
/* prevent the occasional infinite recursion */
return;
}
inside_cleanup++;
signal(SIGUSR1, SIG_IGN);
signal(SIGUSR2, SIG_IGN);
if (verbose > 3)
rprintf(FINFO,"_exit_cleanup(code=%d, file=%s, line=%d): entered\n",
code, file, line);
if (cleanup_child_pid != -1) {
int status;
if (waitpid(cleanup_child_pid, &status, WNOHANG) == cleanup_child_pid) {
@@ -75,12 +131,20 @@ void _exit_cleanup(int code, const char *file, int line)
}
}
if (code == 0 && (io_error || log_got_error)) {
code = RERR_PARTIAL;
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, file, line, code);
close_all();
exit(code);
}

View File

@@ -34,6 +34,8 @@
#include "rsync.h"
static const char default_name[] = "UNKNOWN";
extern int am_daemon;
extern int am_server;
/**
@@ -43,6 +45,8 @@ char *client_addr(int fd)
{
struct sockaddr_storage ss;
socklen_t length = sizeof ss;
char *ssh_client, *p;
int len;
static char addr_buf[100];
static int initialised;
@@ -50,11 +54,25 @@ char *client_addr(int fd)
initialised = 1;
client_sockaddr(fd, &ss, &length);
if (am_server) {
/* daemon over --rsh mode */
strcpy(addr_buf, "0.0.0.0");
if ((ssh_client = getenv("SSH_CLIENT")) != NULL) {
/* truncate SSH_CLIENT to just IP address */
p = strchr(ssh_client, ' ');
if (p) {
len = MIN((unsigned int) (p - ssh_client),
sizeof(addr_buf) - 1);
strncpy(addr_buf, ssh_client, len);
*(addr_buf + len) = '\0';
}
}
} else {
client_sockaddr(fd, &ss, &length);
getnameinfo((struct sockaddr *)&ss, length,
addr_buf, sizeof addr_buf, NULL, 0, NI_NUMERICHOST);
}
getnameinfo((struct sockaddr *)&ss, length,
addr_buf, sizeof(addr_buf), NULL, 0, NI_NUMERICHOST);
return addr_buf;
}
@@ -74,24 +92,67 @@ static int get_sockaddr_family(const struct sockaddr_storage *ss)
* If anything goes wrong, including the name->addr->name check, then
* we just use "UNKNOWN", so you can use that value in hosts allow
* lines.
*
* After translation from sockaddr to name we do a forward lookup to
* make sure nobody is spoofing PTR records.
**/
char *client_name(int fd)
{
struct sockaddr_storage ss;
socklen_t ss_len = sizeof ss;
static char name_buf[100];
static char port_buf[100];
static int initialised;
struct sockaddr_storage ss, *ssp;
struct sockaddr_in sin;
#ifdef INET6
struct sockaddr_in6 sin6;
#endif
socklen_t ss_len;
if (initialised) return name_buf;
strcpy(name_buf, default_name);
initialised = 1;
client_sockaddr(fd, &ss, &ss_len);
if (am_server) {
/* daemon over --rsh mode */
if (!lookup_name(fd, &ss, ss_len, name_buf, sizeof name_buf, port_buf, sizeof port_buf))
check_name(fd, &ss, ss_len, name_buf, port_buf);
char *addr = client_addr(fd);
#ifdef INET6
int dots = 0;
char *p;
for (p = addr; *p && (dots <= 3); p++) {
if (*p == '.')
dots++;
}
if (dots > 3) {
/* more than 4 parts to IP address, must be ipv6 */
ssp = (struct sockaddr_storage *) &sin6;
ss_len = sizeof sin6;
memset(ssp, 0, ss_len);
inet_pton(AF_INET6, addr, &sin6.sin6_addr);
sin6.sin6_family = AF_INET6;
} else
#endif
{
ssp = (struct sockaddr_storage *) &sin;
ss_len = sizeof sin;
memset(ssp, 0, ss_len);
inet_pton(AF_INET, addr, &sin.sin_addr);
sin.sin_family = AF_INET;
}
} else {
ss_len = sizeof ss;
ssp = &ss;
client_sockaddr(fd, &ss, &ss_len);
}
if (!lookup_name(fd, ssp, ss_len, name_buf, sizeof name_buf,
port_buf, sizeof port_buf))
check_name(fd, ssp, name_buf);
return name_buf;
}
@@ -108,6 +169,8 @@ void client_sockaddr(int fd,
struct sockaddr_storage *ss,
socklen_t *ss_len)
{
memset(ss, 0, sizeof(*ss));
if (getpeername(fd, (struct sockaddr *) ss, ss_len)) {
/* FIXME: Can we really not continue? */
rprintf(FERROR, RSYNC_NAME ": getpeername on fd%d failed: %s\n",
@@ -149,6 +212,8 @@ void client_sockaddr(int fd,
/**
* Look up a name from @p ss into @p name_buf.
*
* @param fd file descriptor for client socket.
**/
int lookup_name(int fd, const struct sockaddr_storage *ss,
socklen_t ss_len,
@@ -209,9 +274,23 @@ int compare_addrinfo_sockaddr(const struct addrinfo *ai,
sin1 = (const struct sockaddr_in6 *) ss;
sin2 = (const struct sockaddr_in6 *) ai->ai_addr;
return memcmp(&sin1->sin6_addr, &sin2->sin6_addr,
sizeof sin1->sin6_addr);
if (ai->ai_addrlen < sizeof(struct sockaddr_in6)) {
rprintf(FERROR,
"%s: too short sockaddr_in6; length=%d\n",
fn, ai->ai_addrlen);
return 1;
}
if (memcmp(&sin1->sin6_addr, &sin2->sin6_addr,
sizeof sin1->sin6_addr))
return 1;
#ifdef HAVE_SOCKADDR_IN6_SCOPE_ID
if (sin1->sin6_scope_id != sin2->sin6_scope_id)
return 1;
#endif
return 0;
}
#endif /* INET6 */
else {
@@ -226,12 +305,14 @@ int compare_addrinfo_sockaddr(const struct addrinfo *ai,
* @p ss -- otherwise we may be being spoofed. If we suspect we are,
* then we don't abort the connection but just emit a warning, and
* change @p name_buf to be "UNKNOWN".
*
* We don't do anything with the service when checking the name,
* because it doesn't seem that it could be spoofed in any way, and
* getaddrinfo on random service names seems to cause problems on AIX.
**/
int check_name(int fd,
const struct sockaddr_storage *ss,
socklen_t ss_len,
char *name_buf,
const char *port_buf)
char *name_buf)
{
struct addrinfo hints, *res, *res0;
int error;
@@ -241,7 +322,7 @@ int check_name(int fd,
hints.ai_family = ss_family;
hints.ai_flags = AI_CANONNAME;
hints.ai_socktype = SOCK_STREAM;
error = getaddrinfo(name_buf, port_buf, &hints, &res0);
error = getaddrinfo(name_buf, NULL, &hints, &res0);
if (error) {
rprintf(FERROR,
RSYNC_NAME ": forward name lookup for %s failed: %s\n",

View File

@@ -1,24 +1,29 @@
/* -*- c-file-style: "linux"; -*-
Copyright (C) 1998-2001 by Andrew Tridgell <tridge@samba.org>
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.
*/
*
* Copyright (C) 1998-2001 by Andrew Tridgell <tridge@samba.org>
* Copyright (C) 2001-2002 by Martin Pool <mbp@samba.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* the socket based protocol for setting up a connection with rsyncd */
/**
* @file
*
* The socket based protocol for setting up a connection with
* rsyncd.
**/
#include "rsync.h"
@@ -27,43 +32,37 @@ extern int read_only;
extern int verbose;
extern int rsync_port;
char *auth_user;
int sanitize_paths = 0;
extern int sanitize_paths;
extern int filesfrom_fd;
extern int remote_protocol;
extern int protocol_version;
extern struct exclude_struct **server_exclude_list;
extern char *exclude_path_prefix;
/*
/**
* Run a client connected to an rsyncd. The alternative to this
* function for remote-shell connections is do_cmd.
*/
* function for remote-shell connections is do_cmd().
*
* After negotiating which module to use and reading the server's
* motd, this hands over to client_run(). Telling the server the
* module will cause it to chroot/setuid/etc.
*
* Instead of doing a transfer, the client may at this stage instead
* get a listing of remote modules and exit.
*
* @return -1 for error in startup, or the result of client_run().
* Either way, it eventually gets passed to exit_cleanup().
**/
int start_socket_client(char *host, char *path, int argc, char *argv[])
{
int fd, i;
char *sargs[MAX_ARGS];
int sargc=0;
char line[MAXPATHLEN];
int fd, ret;
char *p, *user=NULL;
extern int remote_version;
extern int am_sender;
extern char *shell_cmd;
extern int kludge_around_eof;
extern char *bind_address;
extern int default_af_hint;
if (argc == 0 && !am_sender) {
extern int list_only;
list_only = 1;
}
/* This is just a friendliness enhancement: if the connection
* is to an rsyncd then there is no point specifying the -e option.
* Note that this is only set if the -e was explicitly specified,
* not if the environment variable just happens to be set.
* See http://lists.samba.org/pipermail/rsync/2000-September/002744.html
*/
if (shell_cmd) {
rprintf(FERROR, "WARNING: --rsh or -e option ignored when "
"connecting to rsync daemon\n");
/* continue */
}
/* this is redundant with code in start_inband_exchange(), but
* this short-circuits a problem before we open a socket, and
* the extra check won't hurt */
if (*path == '/') {
rprintf(FERROR,"ERROR: The remote path must start with a module name not a /\n");
return -1;
@@ -76,77 +75,133 @@ int start_socket_client(char *host, char *path, int argc, char *argv[])
*p = 0;
}
if (!user) user = getenv("USER");
if (!user) user = getenv("LOGNAME");
fd = open_socket_out_wrapped (host, rsync_port, bind_address,
default_af_hint);
if (verbose >= 2) {
/* FIXME: If we're going to use a socket program for
* testing, then this message is wrong. We need to
* say something like "(except really using %s)" */
rprintf(FINFO, "opening tcp connection to %s port %d\n",
host, rsync_port);
}
fd = open_socket_out_wrapped(host, rsync_port, bind_address,
default_af_hint);
if (fd == -1) {
exit_cleanup(RERR_SOCKETIO);
}
server_options(sargs,&sargc);
ret = start_inband_exchange(user, path, fd, fd, argc);
return ret < 0? ret : client_run(fd, fd, -1, argc, argv);
}
int start_inband_exchange(char *user, char *path, int f_in, int f_out, int argc)
{
int i;
char *sargs[MAX_ARGS];
int sargc = 0;
char line[MAXPATHLEN];
char *p;
extern int kludge_around_eof;
extern int am_sender;
extern int daemon_over_rsh;
extern int list_only;
if (argc == 0 && !am_sender)
list_only = 1;
if (*path == '/') {
rprintf(FERROR, "ERROR: The remote path must start with a module name\n");
return -1;
}
if (!user) user = getenv("USER");
if (!user) user = getenv("LOGNAME");
/* set daemon_over_rsh to false since we need to build the
* true set of args passed through the rsh/ssh connection;
* this is a no-op for direct-socket-connection mode */
daemon_over_rsh = 0;
server_options(sargs, &sargc);
sargs[sargc++] = ".";
if (path && *path)
if (path && *path)
sargs[sargc++] = path;
sargs[sargc] = NULL;
io_printf(fd,"@RSYNCD: %d\n", PROTOCOL_VERSION);
io_printf(f_out, "@RSYNCD: %d\n", PROTOCOL_VERSION);
if (!read_line(fd, line, sizeof(line)-1)) {
if (!read_line(f_in, line, sizeof(line)-1)) {
rprintf(FERROR, "rsync: did not see server greeting\n");
return -1;
}
if (sscanf(line,"@RSYNCD: %d", &remote_version) != 1) {
if (sscanf(line,"@RSYNCD: %d", &remote_protocol) != 1) {
/* note that read_line strips of \n or \r */
rprintf(FERROR, "rsync: server sent \"%s\" rather than greeting\n",
line);
return -1;
}
if (protocol_version > remote_protocol)
protocol_version = remote_protocol;
p = strchr(path,'/');
if (p) *p = 0;
io_printf(fd,"%s\n",path);
io_printf(f_out, "%s\n", path);
if (p) *p = '/';
/* Old servers may just drop the connection here,
rather than sending a proper EXIT command. Yuck. */
kludge_around_eof = remote_version < 25;
kludge_around_eof = list_only && (protocol_version < 25);
while (1) {
if (!read_line(fd, line, sizeof(line)-1)) {
if (!read_line(f_in, line, sizeof(line)-1)) {
rprintf(FERROR, "rsync: didn't get server startup line\n");
return -1;
}
if (strncmp(line,"@RSYNCD: AUTHREQD ",18) == 0) {
auth_client(fd, user, line+18);
auth_client(f_out, user, line+18);
continue;
}
if (strcmp(line,"@RSYNCD: OK") == 0) break;
if (strcmp(line,"@RSYNCD: EXIT") == 0) exit(0);
if (strcmp(line,"@RSYNCD: EXIT") == 0) {
/* This is sent by recent versions of the
* server to terminate the listing of modules.
* We don't want to go on and transfer
* anything; just exit. */
exit(0);
}
rprintf(FINFO,"%s\n", line);
if (strncmp(line, "@ERROR", 6) == 0) {
rprintf(FERROR,"%s\n", line);
/* This is always fatal; the server will now
* close the socket. */
return RERR_STARTCLIENT;
} else {
rprintf(FINFO,"%s\n", line);
}
}
kludge_around_eof = False;
for (i=0;i<sargc;i++) {
io_printf(fd,"%s\n", sargs[i]);
for (i = 0; i < sargc; i++) {
io_printf(f_out, "%s\n", sargs[i]);
}
io_printf(fd,"\n");
io_printf(f_out, "\n");
if (remote_version < 23) {
if (remote_version == 22 || (remote_version > 17 && !am_sender))
io_start_multiplex_in(fd);
if (protocol_version < 23) {
if (protocol_version == 22 || (protocol_version > 17 && !am_sender))
io_start_multiplex_in(f_in);
}
return client_run(fd, fd, -1, argc, argv);
return 0;
}
static int rsync_module(int fd, int i)
static int rsync_module(int f_in, int f_out, int i)
{
int argc=0;
char *argv[MAX_ARGS];
@@ -155,47 +210,54 @@ static int rsync_module(int fd, int i)
uid_t uid = (uid_t)-2; /* canonically "nobody" */
gid_t gid = (gid_t)-2;
char *p;
char *addr = client_addr(fd);
char *host = client_name(fd);
char *addr = client_addr(f_in);
char *host = client_name(f_in);
char *name = lp_name(i);
int use_chroot = lp_use_chroot(i);
int start_glob=0;
int ret;
char *request=NULL;
extern int am_sender;
extern int remote_version;
extern int am_server;
extern int am_daemon;
extern int am_root;
if (!allow_access(addr, host, lp_hosts_allow(i), lp_hosts_deny(i))) {
rprintf(FERROR,"rsync denied on module %s from %s (%s)\n",
name, host, addr);
io_printf(fd,"@ERROR: access denied to %s from %s (%s)\n",
io_printf(f_out, "@ERROR: access denied to %s from %s (%s)\n",
name, host, addr);
return -1;
}
if (am_daemon && am_server) {
rprintf(FINFO, "rsync allowed access on module %s from %s (%s)\n",
name, host, addr);
}
if (!claim_connection(lp_lock_file(i), lp_max_connections(i))) {
if (errno) {
rprintf(FERROR,"failed to open lock file %s : %s\n",
lp_lock_file(i), strerror(errno));
io_printf(fd,"@ERROR: failed to open lock file %s : %s\n",
io_printf(f_out, "@ERROR: failed to open lock file %s : %s\n",
lp_lock_file(i), strerror(errno));
} else {
rprintf(FERROR,"max connections (%d) reached\n",
lp_max_connections(i));
io_printf(fd,"@ERROR: max connections (%d) reached - try again later\n", lp_max_connections(i));
io_printf(f_out, "@ERROR: max connections (%d) reached - try again later\n",
lp_max_connections(i));
}
return -1;
}
auth_user = auth_server(fd, i, addr, "@RSYNCD: AUTHREQD ");
auth_user = auth_server(f_in, f_out, i, addr, "@RSYNCD: AUTHREQD ");
if (!auth_user) {
rprintf(FERROR,"auth failed on module %s from %s (%s)\n",
name, client_name(fd), client_addr(fd));
io_printf(fd,"@ERROR: auth failed on module %s\n",name);
return -1;
name, host, addr);
io_printf(f_out, "@ERROR: auth failed on module %s\n", name);
return -1;
}
module_id = i;
@@ -205,43 +267,49 @@ static int rsync_module(int fd, int i)
if (am_root) {
p = lp_uid(i);
if (!name_to_uid(p, &uid)) {
if (!isdigit(*p)) {
if (!isdigit(* (unsigned char *) p)) {
rprintf(FERROR,"Invalid uid %s\n", p);
io_printf(fd,"@ERROR: invalid uid %s\n", p);
io_printf(f_out, "@ERROR: invalid uid %s\n", p);
return -1;
}
}
uid = atoi(p);
}
p = lp_gid(i);
if (!name_to_gid(p, &gid)) {
if (!isdigit(*p)) {
if (!isdigit(* (unsigned char *) p)) {
rprintf(FERROR,"Invalid gid %s\n", p);
io_printf(fd,"@ERROR: invalid gid %s\n", p);
io_printf(f_out, "@ERROR: invalid gid %s\n", p);
return -1;
}
}
gid = atoi(p);
}
}
/* TODO: If we're not root, but the configuration requests
* that we change to some uid other than the current one, then
* log a warning. */
/* TODO: Perhaps take a list of gids, and make them into the
* supplementary groups. */
/* TODO: If we're not root, but the configuration requests
* that we change to some uid other than the current one, then
* log a warning. */
/* TODO: Perhaps take a list of gids, and make them into the
* supplementary groups. */
exclude_path_prefix = use_chroot? "" : lp_path(i);
if (*exclude_path_prefix == '/' && !exclude_path_prefix[1])
exclude_path_prefix = "";
p = lp_include_from(i);
add_exclude_file(p, 1, 1);
add_exclude_file(&server_exclude_list, p, MISSING_FATAL, ADD_INCLUDE);
p = lp_include(i);
add_include_line(p);
add_exclude_line(&server_exclude_list, p, ADD_INCLUDE);
p = lp_exclude_from(i);
add_exclude_file(p, 1, 0);
add_exclude_file(&server_exclude_list, p, MISSING_FATAL, ADD_EXCLUDE);
p = lp_exclude(i);
add_exclude_line(p);
add_exclude_line(&server_exclude_list, p, ADD_EXCLUDE);
exclude_path_prefix = NULL;
log_init();
@@ -260,47 +328,66 @@ static int rsync_module(int fd, int i)
*/
if (chroot(lp_path(i))) {
rsyserr(FERROR, errno, "chroot %s failed", lp_path(i));
io_printf(fd,"@ERROR: chroot failed\n");
io_printf(f_out, "@ERROR: chroot failed\n");
return -1;
}
if (!push_dir("/", 0)) {
rsyserr(FERROR, errno, "chdir %s failed\n", lp_path(i));
io_printf(fd,"@ERROR: chdir failed\n");
rsyserr(FERROR, errno, "chdir %s failed\n", lp_path(i));
io_printf(f_out, "@ERROR: chdir failed\n");
return -1;
}
} else {
if (!push_dir(lp_path(i), 0)) {
rsyserr(FERROR, errno, "chdir %s failed\n", lp_path(i));
io_printf(fd,"@ERROR: chdir failed\n");
io_printf(f_out, "@ERROR: chdir failed\n");
return -1;
}
sanitize_paths = 1;
}
if (am_root) {
/* XXXX: You could argue that if the daemon is started
* by a non-root user and they explicitly specify a
* gid, then we should try to change to that gid --
* this could be possible if it's already in their
* supplementary groups. */
/* TODO: Perhaps we need to document that if rsyncd is
* started by somebody other than root it will inherit
* all their supplementary groups. */
if (setgid(gid)) {
rsyserr(FERROR, errno, "setgid %d failed", (int) gid);
io_printf(fd,"@ERROR: setgid failed\n");
io_printf(f_out, "@ERROR: setgid failed\n");
return -1;
}
#ifdef HAVE_SETGROUPS
/* Get rid of any supplementary groups this process
* might have inheristed. */
if (setgroups(1, &gid)) {
rsyserr(FERROR, errno, "setgroups failed");
io_printf(f_out, "@ERROR: setgroups failed\n");
return -1;
}
#endif
if (setuid(uid)) {
rsyserr(FERROR, errno, "setuid %d failed", (int) uid);
io_printf(fd,"@ERROR: setuid failed\n");
io_printf(f_out, "@ERROR: setuid failed\n");
return -1;
}
am_root = (getuid() == 0);
}
io_printf(fd,"@RSYNCD: OK\n");
io_printf(f_out, "@RSYNCD: OK\n");
argv[argc++] = "rsyncd";
while (1) {
if (!read_line(fd, line, sizeof(line)-1)) {
if (!read_line(f_in, line, sizeof(line)-1)) {
return -1;
}
@@ -345,9 +432,12 @@ static int rsync_module(int fd, int i)
}
}
argp = argv;
argp = argv;
ret = parse_arguments(&argc, (const char ***) &argp, 0);
if (filesfrom_fd == 0)
filesfrom_fd = f_in;
if (request) {
if (*auth_user) {
rprintf(FINFO,"rsync %s %s from %s@%s (%s)\n",
@@ -366,22 +456,22 @@ static int rsync_module(int fd, int i)
if (verbose > 1) verbose = 1;
#endif
if (remote_version < 23) {
if (remote_version == 22 || (remote_version > 17 && am_sender))
io_start_multiplex_out(fd);
if (protocol_version < 23) {
if (protocol_version == 22 || (protocol_version > 17 && am_sender))
io_start_multiplex_out(f_out);
}
/* For later protocol versions, we don't start multiplexing
* until we've configured nonblocking in start_server. That
* means we're in a sticky situation now: there's no way to
* convey errors to the client. */
/* FIXME: Hold off on reporting option processing errors until
* we've set up nonblocking and multiplexed IO and can get the
* message back to them. */
/* For later protocol versions, we don't start multiplexing
* until we've configured nonblocking in start_server. That
* means we're in a sticky situation now: there's no way to
* convey errors to the client. */
/* FIXME: Hold off on reporting option processing errors until
* we've set up nonblocking and multiplexed IO and can get the
* message back to them. */
if (!ret) {
option_error();
exit_cleanup(RERR_UNSUPPORTED);
option_error();
exit_cleanup(RERR_UNSUPPORTED);
}
if (lp_timeout(i)) {
@@ -389,7 +479,7 @@ static int rsync_module(int fd, int i)
io_timeout = lp_timeout(i);
}
start_server(fd, fd, argc, argp);
start_server(f_in, f_out, argc, argp);
return 0;
}
@@ -400,36 +490,39 @@ static void send_listing(int fd)
{
int n = lp_numservices();
int i;
extern int remote_version;
for (i=0;i<n;i++)
if (lp_list(i))
io_printf(fd, "%-15s\t%s\n", lp_name(i), lp_comment(i));
io_printf(fd, "%-15s\t%s\n", lp_name(i), lp_comment(i));
if (remote_version >= 25)
if (protocol_version >= 25)
io_printf(fd,"@RSYNCD: EXIT\n");
}
/* this is called when a socket connection is established to a client
/* this is called when a connection is established to a client
and we want to start talking. The setup of the system is done from
here */
static int start_daemon(int fd)
int start_daemon(int f_in, int f_out)
{
char line[200];
char *motd;
int i = -1;
extern char *config_file;
extern int remote_version;
extern int am_server;
if (!lp_load(config_file, 0)) {
exit_cleanup(RERR_SYNTAX);
}
set_socket_options(fd,"SO_KEEPALIVE");
set_socket_options(fd,lp_socket_options());
set_nonblocking(fd);
log_init();
io_printf(fd,"@RSYNCD: %d\n", PROTOCOL_VERSION);
if (!am_server) {
set_socket_options(f_in, "SO_KEEPALIVE");
set_socket_options(f_in, lp_socket_options());
set_nonblocking(f_in);
}
io_printf(f_out, "@RSYNCD: %d\n", PROTOCOL_VERSION);
motd = lp_motd_file();
if (motd && *motd) {
@@ -438,47 +531,49 @@ static int start_daemon(int fd)
int len = fread(line, 1, sizeof(line)-1, f);
if (len > 0) {
line[len] = 0;
io_printf(fd,"%s", line);
io_printf(f_out, "%s", line);
}
}
if (f) fclose(f);
io_printf(fd,"\n");
io_printf(f_out, "\n");
}
if (!read_line(fd, line, sizeof(line)-1)) {
if (!read_line(f_in, line, sizeof(line)-1)) {
return -1;
}
if (sscanf(line,"@RSYNCD: %d", &remote_version) != 1) {
io_printf(fd,"@ERROR: protocol startup error\n");
if (sscanf(line,"@RSYNCD: %d", &remote_protocol) != 1) {
io_printf(f_out, "@ERROR: protocol startup error\n");
return -1;
}
}
if (protocol_version > remote_protocol)
protocol_version = remote_protocol;
while (i == -1) {
line[0] = 0;
if (!read_line(fd, line, sizeof(line)-1)) {
if (!read_line(f_in, line, sizeof(line)-1)) {
return -1;
}
if (!*line || strcmp(line,"#list")==0) {
send_listing(fd);
send_listing(f_out);
return -1;
}
}
if (*line == '#') {
/* it's some sort of command that I don't understand */
io_printf(fd,"@ERROR: Unknown command '%s'\n", line);
io_printf(f_out, "@ERROR: Unknown command '%s'\n", line);
return -1;
}
i = lp_number(line);
if (i == -1) {
io_printf(fd,"@ERROR: Unknown module '%s'\n", line);
io_printf(f_out, "@ERROR: Unknown module '%s'\n", line);
return -1;
}
}
return rsync_module(fd, i);
return rsync_module(f_in, f_out, i);
}
@@ -493,18 +588,18 @@ int daemon_main(void)
int i;
/* we are running via inetd - close off stdout and
stderr so that library functions (and getopt) don't
try to use them. Redirect them to /dev/null */
* stderr so that library functions (and getopt) don't
* try to use them. Redirect them to /dev/null */
for (i=1;i<3;i++) {
close(i);
close(i);
open("/dev/null", O_RDWR);
}
return start_daemon(STDIN_FILENO);
return start_daemon(STDIN_FILENO, STDIN_FILENO);
}
if (!no_detach)
become_daemon();
become_daemon();
if (!lp_load(config_file, 1)) {
exit_cleanup(RERR_SYNTAX);
@@ -513,11 +608,10 @@ int daemon_main(void)
log_init();
rprintf(FINFO, "rsyncd version %s starting, listening on port %d\n",
RSYNC_VERSION,
rsync_port);
/* TODO: If listening on a particular address, then show that
* address too. In fact, why not just do inet_ntop on the
* local address??? */
RSYNC_VERSION, rsync_port);
/* TODO: If listening on a particular address, then show that
* address too. In fact, why not just do inet_ntop on the
* local address??? */
if (((pid_file = lp_pid_file()) != NULL) && (*pid_file != '\0')) {
char pidbuf[16];
@@ -526,9 +620,9 @@ int daemon_main(void)
cleanup_set_pid(pid);
if ((fd = do_open(lp_pid_file(), O_WRONLY|O_CREAT|O_TRUNC,
0666 & ~orig_umask)) == -1) {
cleanup_set_pid(0);
rsyserr(FLOG, errno, "failed to create pid file %s", pid_file);
exit_cleanup(RERR_FILEIO);
cleanup_set_pid(0);
rsyserr(FLOG, errno, "failed to create pid file %s", pid_file);
exit_cleanup(RERR_FILEIO);
}
snprintf(pidbuf, sizeof(pidbuf), "%d\n", pid);
write(fd, pidbuf, strlen(pidbuf));
@@ -538,4 +632,3 @@ int daemon_main(void)
start_accept_loop(rsync_port, start_daemon);
return -1;
}

View File

@@ -17,10 +17,16 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* compatability routines for older rsync protocol versions */
/**
* @file compat.c
*
* Compatibility routines for older rsync protocol versions.
**/
#include "rsync.h"
int remote_protocol = 0;
extern int am_server;
extern int preserve_links;
@@ -33,43 +39,58 @@ extern int always_checksum;
extern int checksum_seed;
extern int remote_version;
extern int protocol_version;
extern int verbose;
extern int read_batch; /* dw */
extern int write_batch; /* dw */
extern int read_batch;
extern int write_batch;
void setup_protocol(int f_out,int f_in)
{
if (remote_version == 0) {
if (remote_protocol == 0) {
if (am_server) {
remote_version = read_int(f_in);
write_int(f_out,PROTOCOL_VERSION);
remote_protocol = read_int(f_in);
write_int(f_out, protocol_version);
} else {
write_int(f_out,PROTOCOL_VERSION);
remote_version = read_int(f_in);
write_int(f_out, protocol_version);
remote_protocol = read_int(f_in);
}
if (protocol_version > remote_protocol)
protocol_version = remote_protocol;
}
if (remote_version < MIN_PROTOCOL_VERSION ||
remote_version > MAX_PROTOCOL_VERSION) {
if (verbose > 3) {
rprintf(FINFO, "(%s) Protocol versions: remote=%d, negotiated=%d\n",
am_server? "Server" : "Client", remote_protocol, protocol_version);
}
if (remote_protocol < MIN_PROTOCOL_VERSION
|| remote_protocol > MAX_PROTOCOL_VERSION) {
rprintf(FERROR,"protocol version mismatch - is your shell clean?\n");
rprintf(FERROR,"(see the rsync man page for an explanation)\n");
exit_cleanup(RERR_PROTOCOL);
}
if (remote_version >= 12) {
if (am_server) {
if (read_batch || write_batch) /* dw */
checksum_seed = 32761;
else
checksum_seed = time(NULL);
write_int(f_out,checksum_seed);
} else {
checksum_seed = read_int(f_in);
}
}
checksum_init();
}
if (remote_protocol < OLD_PROTOCOL_VERSION) {
rprintf(FINFO,"%s is very old version of rsync, upgrade recommended.\n",
am_server? "Client" : "Server");
}
if (protocol_version < MIN_PROTOCOL_VERSION) {
rprintf(FERROR, "--protocol must be at least %d on the %s.\n",
MIN_PROTOCOL_VERSION, am_server? "Server" : "Client");
exit_cleanup(RERR_PROTOCOL);
}
if (protocol_version > PROTOCOL_VERSION) {
rprintf(FERROR, "--protocol must be no more than %d on the %s.\n",
PROTOCOL_VERSION, am_server? "Server" : "Client");
exit_cleanup(RERR_PROTOCOL);
}
if (am_server) {
if (read_batch || write_batch)
checksum_seed = 32761;
else
checksum_seed = time(NULL);
write_int(f_out,checksum_seed);
} else {
checksum_seed = read_int(f_in);
}
}

458
config.guess vendored
View File

@@ -1,9 +1,9 @@
#! /bin/sh
# Attempt to guess a canonical system name.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
# Free Software Foundation, Inc.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
timestamp='2001-07-19'
timestamp='2003-01-10'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@@ -24,8 +24,9 @@ timestamp='2001-07-19'
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Written by Per Bothner <bothner@cygnus.com>.
# Please send patches to <config-patches@gnu.org>.
# Originally written by Per Bothner <per@bothner.com>.
# Please send patches to <config-patches@gnu.org>. Submit a context
# diff and a properly formatted ChangeLog entry.
#
# This script attempts to guess a canonical system name similar to
# config.sub. If it succeeds, it prints the system name on stdout, and
@@ -87,30 +88,41 @@ if test $# != 0; then
exit 1
fi
trap 'exit 1' 1 2 15
dummy=dummy-$$
trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15
# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
# compiler to aid in system detection is discouraged as it requires
# temporary files to be created and, as you can see below, it is a
# headache to deal with in a portable fashion.
# CC_FOR_BUILD -- compiler used by this script.
# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
# use `HOST_CC' if defined, but it is deprecated.
set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in
,,) echo "int dummy(){}" > $dummy.c ;
for c in cc gcc c89 ; do
($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ;
if test $? = 0 ; then
# Portable tmp directory creation inspired by the Autoconf team.
set_cc_for_build='
trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
: ${TMPDIR=/tmp} ;
{ tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
{ test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
{ echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
dummy=$tmp/dummy ;
tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
case $CC_FOR_BUILD,$HOST_CC,$CC in
,,) echo "int x;" > $dummy.c ;
for c in cc gcc c89 c99 ; do
if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
CC_FOR_BUILD="$c"; break ;
fi ;
done ;
rm -f $dummy.c $dummy.o $dummy.rel ;
if test x"$CC_FOR_BUILD" = x ; then
CC_FOR_BUILD=no_compiler_found ;
fi
;;
,,*) CC_FOR_BUILD=$CC ;;
,*,*) CC_FOR_BUILD=$HOST_CC ;;
esac'
esac ;'
# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
# (ghazi@noc.rutgers.edu 1994-08-24)
@@ -127,29 +139,30 @@ UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
*:NetBSD:*:*)
# Netbsd (nbsd) targets should (where applicable) match one or
# NetBSD (nbsd) targets should (where applicable) match one or
# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
# *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
# switched to ELF, *-*-netbsd* would select the old
# object file format. This provides both forward
# compatibility and a consistent mechanism for selecting the
# object file format.
# Determine the machine/vendor (is the vendor relevant).
case "${UNAME_MACHINE}" in
amiga) machine=m68k-unknown ;;
arm32) machine=arm-unknown ;;
atari*) machine=m68k-atari ;;
sun3*) machine=m68k-sun ;;
mac68k) machine=m68k-apple ;;
macppc) machine=powerpc-apple ;;
hp3[0-9][05]) machine=m68k-hp ;;
ibmrt|romp-ibm) machine=romp-ibm ;;
*) machine=${UNAME_MACHINE}-unknown ;;
#
# Note: NetBSD doesn't particularly care about the vendor
# portion of the name. We always set it to "unknown".
sysctl="sysctl -n hw.machine_arch"
UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
/usr/sbin/$sysctl 2>/dev/null || echo unknown)`
case "${UNAME_MACHINE_ARCH}" in
armeb) machine=armeb-unknown ;;
arm*) machine=arm-unknown ;;
sh3el) machine=shl-unknown ;;
sh3eb) machine=sh-unknown ;;
*) machine=${UNAME_MACHINE_ARCH}-unknown ;;
esac
# The Operating System including object format, if it has switched
# to ELF recently, or will in the future.
case "${UNAME_MACHINE}" in
i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k)
case "${UNAME_MACHINE_ARCH}" in
arm*|i386|m68k|ns32k|sh3*|sparc|vax)
eval $set_cc_for_build
if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep __ELF__ >/dev/null
@@ -166,12 +179,65 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
;;
esac
# The OS release
release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
# Debian GNU/NetBSD machines have a different userland, and
# thus, need a distinct triplet. However, they do not need
# kernel version information, so it can be replaced with a
# suitable tag, in the style of linux-gnu.
case "${UNAME_VERSION}" in
Debian*)
release='-gnu'
;;
*)
release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
;;
esac
# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
# contains redundant information, the shorter form:
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
echo "${machine}-${os}${release}"
exit 0 ;;
amiga:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
arc:OpenBSD:*:*)
echo mipsel-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
hp300:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mac68k:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
macppc:OpenBSD:*:*)
echo powerpc-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mvme68k:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mvme88k:OpenBSD:*:*)
echo m88k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mvmeppc:OpenBSD:*:*)
echo powerpc-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
pmax:OpenBSD:*:*)
echo mipsel-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
sgi:OpenBSD:*:*)
echo mipseb-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
sun3:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
wgrisc:OpenBSD:*:*)
echo mipsel-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
*:OpenBSD:*:*)
echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
*:MicroBSD:*:*)
echo ${UNAME_MACHINE}-unknown-microbsd${UNAME_RELEASE}
exit 0 ;;
alpha:OSF1:*:*)
if test $UNAME_RELEASE = "V4.0"; then
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
@@ -180,6 +246,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# A Tn.n version is a released field test version.
# A Xn.n version is an unreleased experimental baselevel.
# 1.2 uses "1.2" for uname -r.
eval $set_cc_for_build
cat <<EOF >$dummy.s
.data
\$Lformat:
@@ -205,10 +272,9 @@ main:
jsr \$26,exit
.end main
EOF
eval $set_cc_for_build
$CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
$CC_FOR_BUILD -o $dummy $dummy.s 2>/dev/null
if test "$?" = 0 ; then
case `./$dummy` in
case `$dummy` in
0-0)
UNAME_MACHINE="alpha"
;;
@@ -227,9 +293,14 @@ EOF
2-307)
UNAME_MACHINE="alphaev67"
;;
2-1307)
UNAME_MACHINE="alphaev68"
;;
3-1307)
UNAME_MACHINE="alphaev7"
;;
esac
fi
rm -f $dummy.s $dummy
echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
exit 0 ;;
Alpha\ *:Windows_NT*:*)
@@ -244,29 +315,11 @@ EOF
Amiga*:UNIX_System_V:4.0:*)
echo m68k-unknown-sysv4
exit 0;;
amiga:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
*:[Aa]miga[Oo][Ss]:*:*)
echo ${UNAME_MACHINE}-unknown-amigaos
exit 0 ;;
arc64:OpenBSD:*:*)
echo mips64el-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
arc:OpenBSD:*:*)
echo mipsel-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
hkmips:OpenBSD:*:*)
echo mips-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
pmax:OpenBSD:*:*)
echo mipsel-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
sgi:OpenBSD:*:*)
echo mips-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
wgrisc:OpenBSD:*:*)
echo mipsel-unknown-openbsd${UNAME_RELEASE}
*:[Mm]orph[Oo][Ss]:*:*)
echo ${UNAME_MACHINE}-unknown-morphos
exit 0 ;;
*:OS/390:*:*)
echo i370-ibm-openedition
@@ -288,6 +341,10 @@ EOF
NILE*:*:*:dcosx)
echo pyramid-pyramid-svr4
exit 0 ;;
DRS?6000:UNIX_SV:4.2*:7*)
case `/usr/bin/uname -p` in
sparc) echo sparc-icl-nx7 && exit 0 ;;
esac ;;
sun4H:SunOS:5.*:*)
echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit 0 ;;
@@ -316,7 +373,7 @@ EOF
echo m68k-sun-sunos${UNAME_RELEASE}
exit 0 ;;
sun*:*:4.2BSD:*)
UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
case "`/bin/arch`" in
sun3)
@@ -330,9 +387,6 @@ EOF
aushp:SunOS:*:*)
echo sparc-auspex-sunos${UNAME_RELEASE}
exit 0 ;;
atari*:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
# The situation for MiNT is a little confusing. The machine name
# can be virtually everything (everything which is not
# "atarist" or "atariste" at least should have a processor
@@ -359,18 +413,6 @@ EOF
*:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
echo m68k-unknown-mint${UNAME_RELEASE}
exit 0 ;;
sun3*:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mac68k:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mvme68k:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mvme88k:OpenBSD:*:*)
echo m88k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
powerpc:machten:*:*)
echo powerpc-apple-machten${UNAME_RELEASE}
exit 0 ;;
@@ -387,6 +429,7 @@ EOF
echo clipper-intergraph-clix${UNAME_RELEASE}
exit 0 ;;
mips:*:*:UMIPS | mips:*:*:RISCos)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#ifdef __cplusplus
#include <stdio.h> /* for printf() prototype */
@@ -408,16 +451,20 @@ EOF
exit (-1);
}
EOF
eval $set_cc_for_build
$CC_FOR_BUILD $dummy.c -o $dummy \
&& ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
&& rm -f $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
$CC_FOR_BUILD -o $dummy $dummy.c \
&& $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
&& exit 0
echo mips-mips-riscos${UNAME_RELEASE}
exit 0 ;;
Motorola:PowerMAX_OS:*:*)
echo powerpc-motorola-powermax
exit 0 ;;
Motorola:*:4.3:PL8-*)
echo powerpc-harris-powermax
exit 0 ;;
Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
echo powerpc-harris-powermax
exit 0 ;;
Night_Hawk:Power_UNIX:*:*)
echo powerpc-harris-powerunix
exit 0 ;;
@@ -478,6 +525,7 @@ EOF
exit 0 ;;
*:AIX:2:3)
if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#include <sys/systemcfg.h>
@@ -489,9 +537,7 @@ EOF
exit(0);
}
EOF
eval $set_cc_for_build
$CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
$CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0
echo rs6000-ibm-aix3.2.5
elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
echo rs6000-ibm-aix3.2.4
@@ -500,7 +546,7 @@ EOF
fi
exit 0 ;;
*:AIX:*:[45])
IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'`
IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
IBM_ARCH=rs6000
else
@@ -540,10 +586,8 @@ EOF
9000/31? ) HP_ARCH=m68000 ;;
9000/[34]?? ) HP_ARCH=m68k ;;
9000/[678][0-9][0-9])
case "${HPUX_REV}" in
11.[0-9][0-9])
if [ -x /usr/bin/getconf ]; then
sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
if [ -x /usr/bin/getconf ]; then
sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
case "${sc_cpu_version}" in
523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
@@ -552,12 +596,13 @@ EOF
case "${sc_kernel_bits}" in
32) HP_ARCH="hppa2.0n" ;;
64) HP_ARCH="hppa2.0w" ;;
'') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
esac ;;
esac
fi ;;
esac
if [ "${HP_ARCH}" = "" ]; then
sed 's/^ //' << EOF >$dummy.c
fi
if [ "${HP_ARCH}" = "" ]; then
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#define _HPUX_SOURCE
#include <stdlib.h>
@@ -590,12 +635,21 @@ EOF
exit (0);
}
EOF
eval $set_cc_for_build
(CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy`
if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi
rm -f $dummy.c $dummy
fi ;;
(CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
test -z "$HP_ARCH" && HP_ARCH=hppa
fi ;;
esac
if [ ${HP_ARCH} = "hppa2.0w" ]
then
# avoid double evaluation of $set_cc_for_build
test -n "$CC_FOR_BUILD" || eval $set_cc_for_build
if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null
then
HP_ARCH="hppa2.0w"
else
HP_ARCH="hppa64"
fi
fi
echo ${HP_ARCH}-hp-hpux${HPUX_REV}
exit 0 ;;
ia64:HP-UX:*:*)
@@ -603,6 +657,7 @@ EOF
echo ia64-hp-hpux${HPUX_REV}
exit 0 ;;
3050*:HI-UX:*:*)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#include <unistd.h>
int
@@ -628,9 +683,7 @@ EOF
exit (0);
}
EOF
eval $set_cc_for_build
$CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
$CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0
echo unknown-hitachi-hiuxwe2
exit 0 ;;
9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
@@ -658,9 +711,6 @@ EOF
parisc*:Lites*:*:*)
echo hppa1.1-hp-lites
exit 0 ;;
hppa*:OpenBSD:*:*)
echo hppa-unknown-openbsd
exit 0 ;;
C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
echo c1-convex-bsd
exit 0 ;;
@@ -679,9 +729,6 @@ EOF
C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
echo c4-convex-bsd
exit 0 ;;
CRAY*X-MP:*:*:*)
echo xmp-cray-unicos
exit 0 ;;
CRAY*Y-MP:*:*:*)
echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;;
@@ -694,27 +741,21 @@ EOF
CRAY*TS:*:*:*)
echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;;
CRAY*T3D:*:*:*)
echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;;
CRAY*T3E:*:*:*)
echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;;
CRAY*SV1:*:*:*)
echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;;
CRAY-2:*:*:*)
echo cray2-cray-unicos
exit 0 ;;
*:UNICOS/mp:*:*)
echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;;
F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit 0 ;;
hp300:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
exit 0 ;;
@@ -725,10 +766,18 @@ EOF
echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
exit 0 ;;
*:FreeBSD:*:*)
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
exit 0 ;;
*:OpenBSD:*:*)
echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
# Determine whether the default compiler uses glibc.
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#include <features.h>
#if __GLIBC__ >= 2
LIBC=gnu
#else
LIBC=
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC}
exit 0 ;;
i*:CYGWIN*:*)
echo ${UNAME_MACHINE}-pc-cygwin
@@ -739,11 +788,17 @@ EOF
i*:PW*:*)
echo ${UNAME_MACHINE}-pc-pw32
exit 0 ;;
x86:Interix*:3*)
echo i586-pc-interix3
exit 0 ;;
[345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
echo i${UNAME_MACHINE}-pc-mks
exit 0 ;;
i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
# How do we know it's Interix rather than the generic POSIX subsystem?
# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
# UNAME_MACHINE based on the output of uname instead of i386?
echo i386-pc-interix
echo i586-pc-interix
exit 0 ;;
i*:UWIN*:*)
echo ${UNAME_MACHINE}-pc-uwin
@@ -764,16 +819,48 @@ EOF
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit 0 ;;
ia64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit 0 ;;
m68*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit 0 ;;
mips:Linux:*:*)
case `sed -n '/^byte/s/^.*: \(.*\) endian/\1/p' < /proc/cpuinfo` in
big) echo mips-unknown-linux-gnu && exit 0 ;;
little) echo mipsel-unknown-linux-gnu && exit 0 ;;
esac
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#undef CPU
#undef mips
#undef mipsel
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
CPU=mipsel
#else
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
CPU=mips
#else
CPU=
#endif
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0
;;
mips64:Linux:*:*)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#undef CPU
#undef mips64
#undef mips64el
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
CPU=mips64el
#else
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
CPU=mips64
#else
CPU=
#endif
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0
;;
ppc:Linux:*:*)
echo powerpc-unknown-linux-gnu
@@ -789,7 +876,7 @@ EOF
PCA57) UNAME_MACHINE=alphapca56 ;;
EV6) UNAME_MACHINE=alphaev6 ;;
EV67) UNAME_MACHINE=alphaev67 ;;
EV68*) UNAME_MACHINE=alphaev67 ;;
EV68*) UNAME_MACHINE=alphaev68 ;;
esac
objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
@@ -822,7 +909,8 @@ EOF
# The BFD linker knows what the default object file format is, so
# first see if it will tell us. cd to the root directory to prevent
# problems with other programs or directories called `ld' in the path.
ld_supported_targets=`cd /; ld --help 2>&1 \
# Set LC_ALL=C to ensure ld outputs messages in English.
ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
| sed -ne '/supported targets:/!d
s/[ ][ ]*/ /g
s/.*supported targets: *//
@@ -834,7 +922,7 @@ EOF
;;
a.out-i386-linux)
echo "${UNAME_MACHINE}-pc-linux-gnuaout"
exit 0 ;;
exit 0 ;;
coff-i386)
echo "${UNAME_MACHINE}-pc-linux-gnucoff"
exit 0 ;;
@@ -845,33 +933,29 @@ EOF
exit 0 ;;
esac
# Determine whether the default compiler is a.out or elf
cat >$dummy.c <<EOF
#include <features.h>
#ifdef __cplusplus
#include <stdio.h> /* for printf() prototype */
int main (int argc, char *argv[]) {
#else
int main (argc, argv) int argc; char *argv[]; {
#endif
#ifdef __ELF__
# ifdef __GLIBC__
# if __GLIBC__ >= 2
printf ("%s-pc-linux-gnu\n", argv[1]);
# else
printf ("%s-pc-linux-gnulibc1\n", argv[1]);
# endif
# else
printf ("%s-pc-linux-gnulibc1\n", argv[1]);
# endif
#else
printf ("%s-pc-linux-gnuaout\n", argv[1]);
#endif
return 0;
}
EOF
eval $set_cc_for_build
$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
sed 's/^ //' << EOF >$dummy.c
#include <features.h>
#ifdef __ELF__
# ifdef __GLIBC__
# if __GLIBC__ >= 2
LIBC=gnu
# else
LIBC=gnulibc1
# endif
# else
LIBC=gnulibc1
# endif
#else
#ifdef __INTEL_COMPILER
LIBC=gnu
#else
LIBC=gnuaout
#endif
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0
test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
;;
i*86:DYNIX/ptx:4*:*)
@@ -888,6 +972,23 @@ EOF
# Use sysv4.2uw... so that sysv4* matches it.
echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
exit 0 ;;
i*86:OS/2:*:*)
# If we were able to find `uname', then EMX Unix compatibility
# is probably installed.
echo ${UNAME_MACHINE}-pc-os2-emx
exit 0 ;;
i*86:XTS-300:*:STOP)
echo ${UNAME_MACHINE}-unknown-stop
exit 0 ;;
i*86:atheos:*:*)
echo ${UNAME_MACHINE}-unknown-atheos
exit 0 ;;
i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
echo i386-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
i*86:*DOS:*:*)
echo ${UNAME_MACHINE}-pc-msdosdjgpp
exit 0 ;;
i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
@@ -909,22 +1010,19 @@ EOF
UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
elif /bin/uname -X 2>/dev/null >/dev/null ; then
UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
(/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
(/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
&& UNAME_MACHINE=i586
(/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \
(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
&& UNAME_MACHINE=i686
(/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \
(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
&& UNAME_MACHINE=i686
echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
else
echo ${UNAME_MACHINE}-pc-sysv32
fi
exit 0 ;;
i*86:*DOS:*:*)
echo ${UNAME_MACHINE}-pc-msdosdjgpp
exit 0 ;;
pc:*:*:*)
# Left here for compatibility:
# uname -m prints for DJGPP always 'pc', but it prints nothing about
@@ -948,9 +1046,15 @@ EOF
# "miniframe"
echo m68010-convergent-sysv
exit 0 ;;
mc68k:UNIX:SYSTEM5:3.51m)
echo m68k-convergent-sysv
exit 0 ;;
M680?0:D-NIX:5.3:*)
echo m68k-diab-dnix
exit 0 ;;
M68*:*:R3V[567]*:*)
test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0)
OS_REL=''
test -r /etc/.relid \
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
@@ -967,9 +1071,6 @@ EOF
mc68030:UNIX_System_V:4.*:*)
echo m68k-atari-sysv4
exit 0 ;;
i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
echo i386-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
TSUNAMI:LynxOS:2.*:*)
echo sparc-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
@@ -996,8 +1097,8 @@ EOF
echo ns32k-sni-sysv
fi
exit 0 ;;
PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
# says <Richard.M.Bartel@ccMail.Census.GOV>
PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
# says <Richard.M.Bartel@ccMail.Census.GOV>
echo i586-unisys-sysv4
exit 0 ;;
*:UNIX_System_V:4*:FTX*)
@@ -1009,6 +1110,10 @@ EOF
# From seanf@swdc.stratus.com.
echo i860-stratus-sysv4
exit 0 ;;
*:VOS:*:*)
# From Paul.Green@stratus.com.
echo hppa1.1-stratus-vos
exit 0 ;;
mc68*:A/UX:*:*)
echo m68k-apple-aux${UNAME_RELEASE}
exit 0 ;;
@@ -1037,6 +1142,9 @@ EOF
SX-5:SUPER-UX:*:*)
echo sx5-nec-superux${UNAME_RELEASE}
exit 0 ;;
SX-6:SUPER-UX:*:*)
echo sx6-nec-superux${UNAME_RELEASE}
exit 0 ;;
Power*:Rhapsody:*:*)
echo powerpc-apple-rhapsody${UNAME_RELEASE}
exit 0 ;;
@@ -1044,18 +1152,24 @@ EOF
echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
exit 0 ;;
*:Darwin:*:*)
echo `uname -p`-apple-darwin${UNAME_RELEASE}
case `uname -p` in
*86) UNAME_PROCESSOR=i686 ;;
powerpc) UNAME_PROCESSOR=powerpc ;;
esac
echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
exit 0 ;;
*:procnto*:*:* | *:QNX:[0123456789]*:*)
if test "${UNAME_MACHINE}" = "x86pc"; then
UNAME_PROCESSOR=`uname -p`
if test "$UNAME_PROCESSOR" = "x86"; then
UNAME_PROCESSOR=i386
UNAME_MACHINE=pc
fi
echo `uname -p`-${UNAME_MACHINE}-nto-qnx
echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
exit 0 ;;
*:QNX:*:4*)
echo i386-pc-qnx
exit 0 ;;
NSR-[KW]:NONSTOP_KERNEL:*:*)
NSR-[DGKLNPTVW]:NONSTOP_KERNEL:*:*)
echo nsr-tandem-nsk${UNAME_RELEASE}
exit 0 ;;
*:NonStop-UX:*:*)
@@ -1078,11 +1192,6 @@ EOF
fi
echo ${UNAME_MACHINE}-unknown-plan9
exit 0 ;;
i*86:OS/2:*:*)
# If we were able to find `uname', then EMX Unix compatibility
# is probably installed.
echo ${UNAME_MACHINE}-pc-os2-emx
exit 0 ;;
*:TOPS-10:*:*)
echo pdp10-unknown-tops10
exit 0 ;;
@@ -1106,6 +1215,7 @@ esac
#echo '(No uname command or uname output not recognized.)' 1>&2
#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
eval $set_cc_for_build
cat >$dummy.c <<EOF
#ifdef _SEQUENT_
# include <sys/types.h>
@@ -1220,9 +1330,7 @@ main ()
}
EOF
eval $set_cc_for_build
$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0
# Apollos put the system type in the environment.

325
config.sub vendored
View File

@@ -1,9 +1,9 @@
#! /bin/sh
# Configuration validation subroutine script.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
# Free Software Foundation, Inc.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
timestamp='2001-06-08'
timestamp='2003-01-22'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
@@ -29,7 +29,8 @@ timestamp='2001-06-08'
# 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>.
# Please send patches to <config-patches@gnu.org>. Submit a context
# diff and a properly formatted ChangeLog entry.
#
# Configuration subroutine to validate and canonicalize a configuration type.
# Supply the specified configuration type as an argument.
@@ -117,7 +118,7 @@ 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* | storm-chaos* | os2-emx* | windows32-*)
nto-qnx* | linux-gnu* | freebsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
@@ -223,26 +224,48 @@ esac
case $basic_machine in
# Recognize the basic CPU types without company name.
# Some are omitted here because they have special meanings below.
tahoe | i860 | ia64 | m32r | m68k | m68000 | m88k | ns32k | arc \
| arm | arme[lb] | arm[bl]e | armv[2345] | armv[345][lb] | strongarm | xscale \
| pyramid | mn10200 | mn10300 | tron | a29k \
| 580 | i960 | h8300 \
| x86 | ppcbe | mipsbe | mipsle | shbe | shle \
| hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \
| hppa64 \
| alpha | alphaev[4-8] | alphaev56 | alphapca5[67] \
| alphaev6[78] \
| we32k | ns16k | clipper | i370 | sh | sh[34] \
| powerpc | powerpcle \
| 1750a | dsp16xx | pdp10 | pdp11 \
| mips16 | mips64 | mipsel | mips64el \
| mips64orion | mips64orionel | mipstx39 | mipstx39el \
| mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \
| mips64vr5000 | mips64vr5000el | mcore | s390 | s390x \
| sparc | sparclet | sparclite | sparc64 | sparcv9 | sparcv9b \
| v850 | c4x \
| thumb | d10v | d30v | fr30 | avr | openrisc | tic80 \
| pj | pjl | h8500 | z8k)
1750a | 580 \
| a29k \
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
| clipper \
| d10v | d30v | dlx | dsp16xx \
| fr30 | frv \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| i370 | i860 | i960 | ia64 \
| ip2k \
| m32r | m68000 | m68k | m88k | mcore \
| mips | mipsbe | mipseb | mipsel | mipsle \
| mips16 \
| mips64 | mips64el \
| mips64vr | mips64vrel \
| mips64orion | mips64orionel \
| mips64vr4100 | mips64vr4100el \
| mips64vr4300 | mips64vr4300el \
| mips64vr5000 | mips64vr5000el \
| mipsisa32 | mipsisa32el \
| mipsisa32r2 | mipsisa32r2el \
| mipsisa64 | mipsisa64el \
| mipsisa64sb1 | mipsisa64sb1el \
| mipsisa64sr71k | mipsisa64sr71kel \
| mipstx39 | mipstx39el \
| mn10200 | mn10300 \
| msp430 \
| ns16k | ns32k \
| openrisc | or32 \
| pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
| pyramid \
| sh | sh[1234] | sh3e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
| sh64 | sh64le \
| sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \
| strongarm \
| tahoe | thumb | tic80 | tron \
| v850 | v850e \
| we32k \
| x86 | xscale | xstormy16 | xtensa \
| z8k)
basic_machine=$basic_machine-unknown
;;
m6811 | m68hc11 | m6812 | m68hc12)
@@ -265,31 +288,58 @@ case $basic_machine in
exit 1
;;
# Recognize the basic CPU types with company name.
# FIXME: clean up the formatting here.
vax-* | tahoe-* | i*86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \
| m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | c[123]* \
| arm-* | armbe-* | armle-* | armv*-* | strongarm-* | xscale-* \
| mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
| power-* | none-* | 580-* | cray2-* | h8300-* | h8500-* | i960-* \
| xmp-* | ymp-* \
| x86-* | ppcbe-* | mipsbe-* | mipsle-* | shbe-* | shle-* \
| hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* \
| hppa2.0n-* | hppa64-* \
| alpha-* | alphaev[4-8]-* | alphaev56-* | alphapca5[67]-* \
| alphaev6[78]-* \
| we32k-* | cydra-* | ns16k-* | pn-* | np1-* | xps100-* \
| clipper-* | orion-* \
| sparclite-* | pdp10-* | pdp11-* | sh-* | sh[34]-* | sh[34]eb-* \
| powerpc-* | powerpcle-* | sparc64-* | sparcv9-* | sparcv9b-* | sparc86x-* \
| mips16-* | mips64-* | mipsel-* \
| mips64el-* | mips64orion-* | mips64orionel-* \
| mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \
| mipstx39-* | mipstx39el-* | mcore-* \
| f30[01]-* | f700-* | s390-* | s390x-* | sv1-* | t3e-* \
| [cjt]90-* \
| m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \
| thumb-* | v850-* | d30v-* | tic30-* | tic80-* | c30-* | fr30-* \
| bs2000-* | tic54x-* | c54x-* | x86_64-* | pj-* | pjl-*)
580-* \
| a29k-* \
| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
| avr-* \
| bs2000-* \
| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* \
| clipper-* | cydra-* \
| d10v-* | d30v-* | dlx-* \
| elxsi-* \
| f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
| h8300-* | h8500-* \
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
| i*86-* | i860-* | i960-* | ia64-* \
| ip2k-* \
| m32r-* \
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
| m88110-* | m88k-* | mcore-* \
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
| mips16-* \
| mips64-* | mips64el-* \
| mips64vr-* | mips64vrel-* \
| mips64orion-* | mips64orionel-* \
| mips64vr4100-* | mips64vr4100el-* \
| mips64vr4300-* | mips64vr4300el-* \
| mips64vr5000-* | mips64vr5000el-* \
| mipsisa32-* | mipsisa32el-* \
| mipsisa32r2-* | mipsisa32r2el-* \
| mipsisa64-* | mipsisa64el-* \
| mipsisa64sb1-* | mipsisa64sb1el-* \
| mipsisa64sr71k-* | mipsisa64sr71kel-* \
| mipstx39-* | mipstx39el-* \
| msp430-* \
| none-* | np1-* | nv1-* | ns16k-* | ns32k-* \
| orion-* \
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
| pyramid-* \
| romp-* | rs6000-* \
| sh-* | sh[1234]-* | sh3e-* | sh[34]eb-* | shbe-* \
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
| sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \
| sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
| tahoe-* | thumb-* | tic30-* | tic4x-* | tic54x-* | tic80-* | tron-* \
| v850-* | v850e-* | vax-* \
| we32k-* \
| x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \
| xtensa-* \
| ymp-* \
| z8k-*)
;;
# Recognize the various machine names and aliases which stand
# for a CPU type and a company and sometimes even an OS.
@@ -352,6 +402,10 @@ case $basic_machine in
basic_machine=ns32k-sequent
os=-dynix
;;
c90)
basic_machine=c90-cray
os=-unicos
;;
convex-c1)
basic_machine=c1-convex
os=-bsd
@@ -372,16 +426,8 @@ case $basic_machine in
basic_machine=c38-convex
os=-bsd
;;
cray | ymp)
basic_machine=ymp-cray
os=-unicos
;;
cray2)
basic_machine=cray2-cray
os=-unicos
;;
[cjt]90)
basic_machine=${basic_machine}-cray
cray | j90)
basic_machine=j90-cray
os=-unicos
;;
crds | unos)
@@ -396,6 +442,14 @@ case $basic_machine in
decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
basic_machine=mips-dec
;;
decsystem10* | dec10*)
basic_machine=pdp10-dec
os=-tops10
;;
decsystem20* | dec20*)
basic_machine=pdp10-dec
os=-tops20
;;
delta | 3300 | motorola-3300 | motorola-delta \
| 3300-motorola | delta-motorola)
basic_machine=m68k-motorola
@@ -576,14 +630,6 @@ case $basic_machine in
basic_machine=m68k-atari
os=-mint
;;
mipsel*-linux*)
basic_machine=mipsel-unknown
os=-linux-gnu
;;
mips*-linux*)
basic_machine=mips-unknown
os=-linux-gnu
;;
mips3*-*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
;;
@@ -598,6 +644,10 @@ case $basic_machine in
basic_machine=m68k-rom68k
os=-coff
;;
morphos)
basic_machine=powerpc-unknown
os=-morphos
;;
msdos)
basic_machine=i386-pc
os=-msdos
@@ -670,6 +720,10 @@ case $basic_machine in
np1)
basic_machine=np1-gould
;;
nv1)
basic_machine=nv1-cray
os=-unicosmp
;;
nsr-tandem)
basic_machine=nsr-tandem
;;
@@ -677,6 +731,10 @@ case $basic_machine in
basic_machine=hppa1.1-oki
os=-proelf
;;
or32 | or32-*)
basic_machine=or32-unknown
os=-coff
;;
OSE68000 | ose68000)
basic_machine=m68000-ericsson
os=-ose
@@ -699,19 +757,19 @@ case $basic_machine in
pbb)
basic_machine=m68k-tti
;;
pc532 | pc532-*)
pc532 | pc532-*)
basic_machine=ns32k-pc532
;;
pentium | p5 | k5 | k6 | nexgen)
pentium | p5 | k5 | k6 | nexgen | viac3)
basic_machine=i586-pc
;;
pentiumpro | p6 | 6x86 | athlon)
pentiumpro | p6 | 6x86 | athlon | athlon_*)
basic_machine=i686-pc
;;
pentiumii | pentium2)
basic_machine=i686-pc
;;
pentium-* | p5-* | k5-* | k6-* | nexgen-*)
pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentiumpro-* | p6-* | 6x86-* | athlon-*)
@@ -726,15 +784,25 @@ case $basic_machine in
power) basic_machine=power-ibm
;;
ppc) basic_machine=powerpc-unknown
;;
;;
ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppcle | powerpclittle | ppc-le | powerpc-little)
basic_machine=powerpcle-unknown
;;
;;
ppcle-* | powerpclittle-*)
basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppc64) basic_machine=powerpc64-unknown
;;
ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppc64le | powerpc64little | ppc64-le | powerpc64-little)
basic_machine=powerpc64le-unknown
;;
ppc64le-* | powerpc64little-*)
basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ps2)
basic_machine=i386-ibm
;;
@@ -752,10 +820,22 @@ case $basic_machine in
rtpc | rtpc-*)
basic_machine=romp-ibm
;;
s390 | s390-*)
basic_machine=s390-ibm
;;
s390x | s390x-*)
basic_machine=s390x-ibm
;;
sa29200)
basic_machine=a29k-amd
os=-udi
;;
sb1)
basic_machine=mipsisa64sb1-unknown
;;
sb1el)
basic_machine=mipsisa64sb1el-unknown
;;
sequent)
basic_machine=i386-sequent
;;
@@ -763,7 +843,7 @@ case $basic_machine in
basic_machine=sh-hitachi
os=-hms
;;
sparclite-wrs)
sparclite-wrs | simso-wrs)
basic_machine=sparclite-wrs
os=-vxworks
;;
@@ -830,9 +910,17 @@ case $basic_machine in
os=-dynix
;;
t3e)
basic_machine=t3e-cray
basic_machine=alphaev5-cray
os=-unicos
;;
t90)
basic_machine=t90-cray
os=-unicos
;;
tic4x | c4x*)
basic_machine=tic4x-unknown
os=-coff
;;
tic54x | c54x*)
basic_machine=tic54x-unknown
os=-coff
@@ -843,6 +931,10 @@ case $basic_machine in
tx39el)
basic_machine=mipstx39el-unknown
;;
toad1)
basic_machine=pdp10-xkl
os=-tops20
;;
tower | tower-32)
basic_machine=m68k-ncr
;;
@@ -867,8 +959,8 @@ case $basic_machine in
os=-vms
;;
vpp*|vx|vx-*)
basic_machine=f301-fujitsu
;;
basic_machine=f301-fujitsu
;;
vxworks960)
basic_machine=i960-wrs
os=-vxworks
@@ -889,17 +981,13 @@ case $basic_machine in
basic_machine=hppa1.1-winbond
os=-proelf
;;
windows32)
basic_machine=i386-pc
os=-windows32-msvcrt
;;
xmp)
basic_machine=xmp-cray
os=-unicos
;;
xps | xps100)
xps | xps100)
basic_machine=xps100-honeywell
;;
ymp)
basic_machine=ymp-cray
os=-unicos
;;
z8k-*-coff)
basic_machine=z8k-unknown
os=-sim
@@ -920,13 +1008,6 @@ case $basic_machine in
op60c)
basic_machine=hppa1.1-oki
;;
mips)
if [ x$os = x-linux-gnu ]; then
basic_machine=mips-unknown
else
basic_machine=mips-mips
fi
;;
romp)
basic_machine=romp-ibm
;;
@@ -946,13 +1027,16 @@ case $basic_machine in
we32k)
basic_machine=we32k-att
;;
sh3 | sh4)
sh3 | sh4 | sh3eb | sh4eb | sh[1234]le | sh3ele)
basic_machine=sh-unknown
;;
sh64)
basic_machine=sh64-unknown
;;
sparc | sparcv9 | sparcv9b)
basic_machine=sparc-sun
;;
cydra)
cydra)
basic_machine=cydra-cydrome
;;
orion)
@@ -967,10 +1051,6 @@ case $basic_machine in
pmac | pmac-mpw)
basic_machine=powerpc-apple
;;
c4x*)
basic_machine=c4x-none
os=-coff
;;
*-unknown)
# Make sure to match an already-canonicalized machine name.
;;
@@ -1033,9 +1113,12 @@ case $os in
| -chorusos* | -chorusrdb* \
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
| -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* | -os2*)
| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
| -powermax* | -dnix* | -microbsd*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)
@@ -1047,8 +1130,10 @@ case $os in
;;
esac
;;
-nto-qnx*)
;;
-nto*)
os=-nto-qnx
os=`echo $os | sed -e 's|nto|nto-qnx|'`
;;
-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
| -windows* | -osx | -abug | -netware* | -os9* | -beos* \
@@ -1087,14 +1172,20 @@ case $os in
-acis*)
os=-aos
;;
-atheos*)
os=-atheos
;;
-386bsd)
os=-bsd
;;
-ctix* | -uts*)
os=-sysv
;;
-nova*)
os=-rtmk-nova
;;
-ns2 )
os=-nextstep2
os=-nextstep2
;;
-nsk*)
os=-nsk
@@ -1133,8 +1224,11 @@ case $os in
-xenix)
os=-xenix
;;
-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
os=-mint
-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
os=-mint
;;
-aros*)
os=-aros
;;
-none)
;;
@@ -1167,10 +1261,11 @@ case $basic_machine in
arm*-semi)
os=-aout
;;
# This must come before the *-dec entry.
pdp10-*)
os=-tops20
;;
pdp11-*)
pdp11-*)
os=-none
;;
*-dec | vax-*)
@@ -1197,6 +1292,9 @@ case $basic_machine in
mips*-*)
os=-elf
;;
or32-*)
os=-coff
;;
*-tti) # must be before sparc entry or we get the wrong os.
os=-sysv3
;;
@@ -1260,19 +1358,19 @@ case $basic_machine in
*-next)
os=-nextstep3
;;
*-gould)
*-gould)
os=-sysv
;;
*-highlevel)
*-highlevel)
os=-bsd
;;
*-encore)
os=-bsd
;;
*-sgi)
*-sgi)
os=-irix
;;
*-siemens)
*-siemens)
os=-sysv4
;;
*-masscomp)
@@ -1344,7 +1442,7 @@ case $basic_machine in
-ptx*)
vendor=sequent
;;
-vxsim* | -vxworks*)
-vxsim* | -vxworks* | -windiss*)
vendor=wrs
;;
-aux*)
@@ -1359,6 +1457,9 @@ case $basic_machine in
-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
vendor=atari
;;
-vos*)
vendor=stratus
;;
esac
basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
;;

View File

@@ -5,7 +5,7 @@ AC_CONFIG_SRCDIR([byteorder.h])
AC_CONFIG_HEADER(config.h)
AC_PREREQ(2.52)
RSYNC_VERSION=2.5.2pre3
RSYNC_VERSION=2.6.0
AC_SUBST(RSYNC_VERSION)
AC_MSG_NOTICE([Configuring rsync $RSYNC_VERSION])
@@ -25,7 +25,7 @@ AC_SUBST(SHELL)
AC_DEFINE([_GNU_SOURCE], 1,
[Define _GNU_SOURCE so that we get all necessary prototypes])
if test "$xac_cv_prog_cc_stdc" = xno
if test "x$ac_cv_prog_cc_stdc" = xno
then
AC_MSG_WARN([rsync requires an ANSI C compiler and you don't seem to have one])
fi
@@ -65,6 +65,17 @@ then
fi
# Specifically, this turns on panic_action handling.
AC_ARG_ENABLE(maintainer-mode,
AC_HELP_STRING([--enable-maintainer-mode],
[turn on extra debug features],
[], []))
if test x"$enable_maintainer_mode" = xyes
then
CFLAGS="$CFLAGS -DMAINTAINER_MODE"
fi
# This is needed for our included version of popt. Kind of silly, but
# I don't want our version too far out of sync.
CFLAGS="$CFLAGS -DHAVE_CONFIG_H"
@@ -79,14 +90,26 @@ AC_ARG_WITH(included-popt,
[ --with-included-popt use bundled popt library, not from system])
AC_ARG_WITH(rsync-path,
[ --with-rsync-path=PATH set default --rsync-path to PATH (default: \"rsync\")],
[ --with-rsync-path=PATH set default --rsync-path to PATH (default: rsync)],
[ RSYNC_PATH="$with_rsync_path" ],
[ RSYNC_PATH="rsync" ])
AC_DEFINE_UNQUOTED(RSYNC_PATH, "$RSYNC_PATH", [ ])
AC_DEFINE_UNQUOTED(RSYNC_PATH, "$RSYNC_PATH", [location of rsync on remote machine])
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, [ ])
AC_DEFINE_UNQUOTED(HAVE_REMSH, $HAVE_REMSH, [remote shell is remsh not rsh])
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
# stuff, getting byte range locking wrong
@@ -221,16 +244,26 @@ yes
AC_SEARCH_LIBS(getaddrinfo, inet6)
fi
AC_MSG_CHECKING([whether to call shutdown on all sockets])
case $host_os in
*cygwin* ) AC_MSG_RESULT(yes)
AC_DEFINE(SHUTDOWN_ALL_SOCKETS, 1,
[Define if sockets need to be shutdown])
;;
* ) AC_MSG_RESULT(no);;
esac
AC_C_BIGENDIAN
AC_HEADER_DIRENT
AC_HEADER_TIME
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h unistd.h utime.h grp.h)
AC_CHECK_HEADERS(compat.h sys/param.h ctype.h sys/wait.h sys/ioctl.h)
AC_CHECK_HEADERS(sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h)
AC_CHECK_HEADERS(glob.h alloca.h mcheck.h sys/sysctl.h arpa/inet.h arpa/nameser.h)
AC_CHECK_HEADERS(sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h sys/un.h)
AC_CHECK_HEADERS(glob.h mcheck.h sys/sysctl.h arpa/inet.h arpa/nameser.h)
AC_CHECK_HEADERS(netdb.h)
AC_CHECK_HEADERS(malloc.h)
AC_CHECK_HEADERS(float.h)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
@@ -300,8 +333,39 @@ 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_CHECK_FUNCS(getaddrinfo, , AC_LIBOBJ(lib/getaddrinfo))
AC_CHECK_FUNCS(getnameinfo, , AC_LIBOBJ(lib/getnameinfo))
# Irix 6.5 has getaddrinfo but not the corresponding defines, so use
# builtin getaddrinfo if one of the defines don't exist
AC_CACHE_CHECK([whether defines needed by getaddrinfo exist],
rsync_cv_HAVE_GETADDR_DEFINES,[
AC_EGREP_CPP(yes, [
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#ifdef AI_PASSIVE
yes
#endif],
rsync_cv_HAVE_GETADDR_DEFINES=yes,
rsync_cv_HAVE_GETADDR_DEFINES=no)])
if test x"$rsync_cv_HAVE_GETADDR_DEFINES" = x"yes"; then
# Tru64 UNIX has getaddrinfo() but has it renamed in libc as
# something else so we must include <netdb.h> to get the
# redefinition.
AC_CHECK_FUNCS(getaddrinfo, ,
[AC_MSG_CHECKING([for getaddrinfo by including <netdb.h>])
AC_TRY_LINK([#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>],[getaddrinfo(NULL, NULL, NULL, NULL);],
[AC_MSG_RESULT([yes])
AC_DEFINE(HAVE_GETADDRINFO, 1,
[Define if you have the `getaddrinfo' function.])],
[AC_MSG_RESULT([no])
AC_LIBOBJ(lib/getaddrinfo)])])
AC_CHECK_FUNCS(getnameinfo, , AC_LIBOBJ(lib/getnameinfo))
else
AC_LIBOBJ(lib/getaddrinfo)
AC_LIBOBJ(lib/getnameinfo)
fi
AC_CHECK_MEMBER([struct sockaddr.sa_len],
[ AC_DEFINE(HAVE_SOCKADDR_LEN) ],
@@ -320,6 +384,15 @@ AC_TRY_COMPILE([#include <sys/types.h>
[Define if you have strct sockaddr_storage.] ),
AC_MSG_RESULT(no))
AC_CHECK_MEMBER([struct sockaddr_in6.sin6_scope_id],
[ AC_DEFINE(HAVE_SOCKADDR_IN6_SCOPE_ID) ],
[],
[
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
])
# if we can't find strcasecmp, look in -lresolv (for Unixware at least)
#
AC_CHECK_FUNCS(strcasecmp)
@@ -333,10 +406,11 @@ dnl every platform has a memcmp that can do at least that.
dnl AC_FUNC_MEMCMP
AC_FUNC_UTIME_NULL
AC_CHECK_FUNCS(waitpid wait4 getcwd strdup strerror chown chmod mknod)
AC_FUNC_ALLOCA
AC_CHECK_FUNCS(waitpid wait4 getcwd strdup strerror chown chmod mknod mkfifo)
AC_CHECK_FUNCS(fchmod fstat strchr readlink link utime utimes strftime)
AC_CHECK_FUNCS(memmove lchown vsnprintf snprintf asprintf setsid glob strpbrk)
AC_CHECK_FUNCS(strlcat strlcpy mtrace mallinfo)
AC_CHECK_FUNCS(strlcat strlcpy strtol mtrace mallinfo setgroups)
AC_CACHE_CHECK([for working socketpair],rsync_cv_HAVE_SOCKETPAIR,[
AC_TRY_RUN([
@@ -352,15 +426,6 @@ if test x"$rsync_cv_HAVE_SOCKETPAIR" = x"yes"; then
AC_DEFINE(HAVE_SOCKETPAIR, 1, [ ])
fi
AC_CACHE_CHECK([for working fnmatch],rsync_cv_HAVE_FNMATCH,[
AC_TRY_RUN([#include <fnmatch.h>
main() { exit((fnmatch("*.o", "x.o", FNM_PATHNAME) == 0 &&
fnmatch("a/b/*", "a/b/c/d", FNM_PATHNAME) != 0) ? 0: 1); }],
rsync_cv_HAVE_FNMATCH=yes,rsync_cv_HAVE_FNMATCH=no,rsync_cv_HAVE_FNMATCH=cross)])
if test x"$rsync_cv_HAVE_FNMATCH" = x"yes"; then
AC_DEFINE(HAVE_FNMATCH, 1, [ ])
fi
if test x"$with_included_popt" != x"yes"
then
AC_CHECK_LIB(popt, poptGetContext, , [with_included_popt=yes])
@@ -372,6 +437,12 @@ then
AC_MSG_RESULT($srcdir/popt)
BUILD_POPT='$(popt_OBJS)'
CFLAGS="$CFLAGS -I$srcdir/popt"
if test x"$ALLOCA" != x
then
# this can be removed when/if we add an included alloca.c;
# see autoconf documentation on AC_FUNC_ALLOCA
AC_MSG_WARN([included libpopt will use malloc, not alloca (which wastes a small amount of memory)])
fi
else
AC_MSG_RESULT(no)
fi
@@ -553,6 +624,21 @@ AC_SUBST(BUILD_POPT)
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()

2
doc/.cvsignore Normal file
View File

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

20
doc/README-SGML Normal file
View File

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

42
doc/profile.txt Normal file
View File

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

351
doc/rsync.sgml Normal file
View File

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

View File

@@ -19,13 +19,15 @@
/*
* error codes returned by rsync. If you change these, please also update the
* string mappings in log.c
* string mappings in log.c and the EXIT VALUES in rsync.yo
*/
#define RERR_OK 0
#define RERR_SYNTAX 1 /* syntax or usage error */
#define RERR_PROTOCOL 2 /* protocol incompatibility */
#define RERR_FILESELECT 3 /* errors selecting input/output files, dirs */
#define RERR_UNSUPPORTED 4 /* requested action not supported */
#define RERR_UNSUPPORTED 4 /* requested action not supported */
#define RERR_STARTCLIENT 5 /* error starting client-server protocol */
#define RERR_SOCKETIO 10 /* error in socket IO */
#define RERR_FILEIO 11 /* error in file IO */
@@ -37,6 +39,7 @@
#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_TIMEOUT 30 /* timeout in data send/receive */

434
exclude.c
View File

@@ -1,22 +1,23 @@
/* -*- c-file-style: "linux" -*-
Copyright (C) 1996-2001 by Andrew Tridgell <tridge@samba.org>
Copyright (C) 1996 by Paul Mackerras
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-2001 by Andrew Tridgell <tridge@samba.org>
* Copyright (C) 1996 by Paul Mackerras
* 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.
*/
/* a lot of this stuff was originally derived from GNU tar, although
it has now changed so much that it is hard to tell :) */
@@ -26,16 +27,20 @@
#include "rsync.h"
extern int verbose;
extern int delete_mode;
static struct exclude_struct **exclude_list;
struct exclude_struct **exclude_list;
struct exclude_struct **local_exclude_list;
struct exclude_struct **server_exclude_list;
char *exclude_path_prefix = NULL;
/* build an exclude structure given a exclude pattern */
/** Build an exclude structure given a exclude pattern */
static struct exclude_struct *make_exclude(const char *pattern, int include)
{
struct exclude_struct *ret;
char *cp;
int pat_len;
ret = (struct exclude_struct *)malloc(sizeof(*ret));
ret = new(struct exclude_struct);
if (!ret) out_of_memory("make_exclude");
memset(ret, 0, sizeof(*ret));
@@ -49,33 +54,37 @@ static struct exclude_struct *make_exclude(const char *pattern, int include)
ret->include = include;
}
ret->pattern = strdup(pattern);
if (!ret->pattern) out_of_memory("make_exclude");
if (strpbrk(pattern, "*[?")) {
ret->regular_exp = 1;
ret->fnmatch_flags = FNM_PATHNAME;
if (strstr(pattern, "**")) {
static int tested;
if (!tested) {
tested = 1;
if (fnmatch("a/b/*", "a/b/c/d", FNM_PATHNAME)==0) {
rprintf(FERROR,"WARNING: fnmatch FNM_PATHNAME is broken on your system\n");
}
}
ret->fnmatch_flags = 0;
}
if (exclude_path_prefix)
ret->match_flags |= MATCHFLG_ABS_PATH;
if (exclude_path_prefix && *pattern == '/') {
ret->pattern = new_array(char,
strlen(exclude_path_prefix) + strlen(pattern) + 1);
if (!ret->pattern) out_of_memory("make_exclude");
sprintf(ret->pattern, "%s%s", exclude_path_prefix, pattern);
}
else {
ret->pattern = strdup(pattern);
if (!ret->pattern) out_of_memory("make_exclude");
}
if (strlen(pattern) > 1 && pattern[strlen(pattern)-1] == '/') {
ret->pattern[strlen(pattern)-1] = 0;
if (strpbrk(pattern, "*[?")) {
ret->match_flags |= MATCHFLG_WILD;
if (strstr(pattern, "**")) {
ret->match_flags |= MATCHFLG_WILD2;
/* If the pattern starts with **, note that. */
if (*pattern == '*' && pattern[1] == '*')
ret->match_flags |= MATCHFLG_WILD2_PREFIX;
}
}
pat_len = strlen(ret->pattern);
if (pat_len > 1 && ret->pattern[pat_len-1] == '/') {
ret->pattern[pat_len-1] = 0;
ret->directory = 1;
}
if (!strchr(ret->pattern,'/')) {
ret->local = 1;
}
for (cp = ret->pattern; (cp = strchr(cp, '/')) != NULL; cp++)
ret->slash_cnt++;
return ret;
}
@@ -87,35 +96,98 @@ static void free_exclude(struct exclude_struct *ex)
free(ex);
}
void free_exclude_list(struct exclude_struct ***listp)
{
struct exclude_struct **list = *listp;
if (verbose > 2)
rprintf(FINFO,"clearing exclude list\n");
if (!list)
return;
while (*list)
free_exclude(*list++);
free(*listp);
*listp = NULL;
}
static int check_one_exclude(char *name, struct exclude_struct *ex,
STRUCT_STAT *st)
int name_is_dir)
{
char *p;
int match_start=0;
int match_start = 0;
char *pattern = ex->pattern;
if (ex->local && (p=strrchr(name,'/')))
name = p+1;
/* 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->slash_cnt && !(ex->match_flags & MATCHFLG_WILD2)) {
if ((p = strrchr(name,'/')) != NULL)
name = p+1;
}
else if ((ex->match_flags & MATCHFLG_ABS_PATH) && *name != '/') {
static char full_name[MAXPATHLEN];
extern char curr_dir[];
int plus = curr_dir[1] == '\0'? 1 : 0;
snprintf(full_name, sizeof full_name,
"%s/%s", curr_dir+plus, name);
name = full_name;
}
if (!name[0]) return 0;
if (ex->directory && !S_ISDIR(st->st_mode)) return 0;
if (ex->directory && !name_is_dir) return 0;
if (*pattern == '/' && *name != '/') {
if (*pattern == '/') {
match_start = 1;
pattern++;
if (*name == '/')
name++;
}
if (ex->regular_exp) {
if (fnmatch(pattern, name, ex->fnmatch_flags) == 0) {
return 1;
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->slash_cnt &&
!(ex->match_flags & MATCHFLG_WILD2)) {
int cnt = ex->slash_cnt + 1;
for (p = name + strlen(name) - 1; p >= name; p--) {
if (*p == '/' && !--cnt)
break;
}
name = p+1;
}
if (wildmatch(pattern, name))
return 1;
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 1;
}
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 1;
}
}
} else if (match_start) {
if (strcmp(name,pattern) == 0)
return 1;
} else {
int l1 = strlen(name);
int l2 = strlen(pattern);
if (l2 <= l1 &&
if (l2 <= l1 &&
strcmp(name+(l1-l2),pattern) == 0 &&
(l1==l2 || (!match_start && name[l1-(l2+1)] == '/'))) {
(l1==l2 || name[l1-(l2+1)] == '/')) {
return 1;
}
}
@@ -126,18 +198,18 @@ static int check_one_exclude(char *name, struct exclude_struct *ex,
static void report_exclude_result(char const *name,
struct exclude_struct const *ent,
STRUCT_STAT const *st)
int name_is_dir)
{
/* If a trailing slash is present to match only directories,
* then it is stripped out by make_exclude. So as a special
* case we add it back in here. */
if (verbose >= 2)
rprintf(FINFO, "%s %s %s because of pattern %s%s\n",
ent->include ? "including" : "excluding",
S_ISDIR(st->st_mode) ? "directory" : "file",
name, ent->pattern,
ent->directory ? "/" : "");
/* If a trailing slash is present to match only directories,
* then it is stripped out by make_exclude. So as a special
* case we add it back in here. */
if (verbose >= 2)
rprintf(FINFO, "%s %s %s because of pattern %s%s\n",
ent->include ? "including" : "excluding",
name_is_dir ? "directory" : "file",
name, ent->pattern,
ent->directory ? "/" : "");
}
@@ -145,125 +217,114 @@ static void report_exclude_result(char const *name,
* Return true if file NAME is defined to be excluded by either
* LOCAL_EXCLUDE_LIST or the globals EXCLUDE_LIST.
*/
int check_exclude(char *name, struct exclude_struct **local_exclude_list,
STRUCT_STAT *st)
int check_exclude(struct exclude_struct **list, char *name, int name_is_dir)
{
int n;
struct exclude_struct *ent;
struct exclude_struct *ent;
if (name && (name[0] == '.') && !name[1])
/* never exclude '.', even if somebody does --exclude '*' */
return 0;
if (exclude_list) {
for (n=0; exclude_list[n]; n++) {
ent = exclude_list[n];
if (check_one_exclude(name, ent, st)) {
report_exclude_result(name, ent, st);
return !ent->include;
}
}
}
if (local_exclude_list) {
for (n=0; local_exclude_list[n]; n++) {
ent = local_exclude_list[n];
if (check_one_exclude(name, ent, st)) {
report_exclude_result(name, ent, st);
return !ent->include;
}
}
while ((ent = *list++) != NULL) {
if (check_one_exclude(name, ent, name_is_dir)) {
report_exclude_result(name, ent, name_is_dir);
return !ent->include;
}
}
return 0;
}
void add_exclude_list(const char *pattern, struct exclude_struct ***list, int include)
void add_exclude(struct exclude_struct ***listp, const char *pattern, int include)
{
int len=0;
if (list && *list)
for (; (*list)[len]; len++) ;
struct exclude_struct **list = *listp;
int len = 0;
if (strcmp(pattern,"!") == 0) {
if (verbose > 2)
rprintf(FINFO,"clearing exclude list\n");
while ((len)--) {
free_exclude((*list)[len]);
if (*pattern == '!' && !pattern[1]) {
free_exclude_list(listp);
return;
}
if (list)
for (; list[len]; len++) {}
list = *listp = realloc_array(list, struct exclude_struct *, len+2);
if (!list || !(list[len] = make_exclude(pattern, include)))
out_of_memory("add_exclude");
if (verbose > 2) {
rprintf(FINFO,"add_exclude(%s,%s)\n",pattern,
include ? "include" : "exclude");
}
list[len+1] = NULL;
}
void add_exclude_file(struct exclude_struct ***listp, const char *fname,
int fatal, int include)
{
int fd;
char line[MAXPATHLEN];
char *eob = line + MAXPATHLEN - 1;
extern int eol_nulls;
if (!fname || !*fname)
return;
if (*fname != '-' || fname[1])
fd = open(fname, O_RDONLY|O_BINARY);
else
fd = 0;
if (fd < 0) {
if (fatal) {
rsyserr(FERROR, errno,
"failed to open %s file %s",
include ? "include" : "exclude",
fname);
exit_cleanup(RERR_FILEIO);
}
free((*list));
*list = NULL;
return;
}
*list = (struct exclude_struct **)Realloc(*list,sizeof(struct exclude_struct *)*(len+2));
if (!*list || !((*list)[len] = make_exclude(pattern, include)))
out_of_memory("add_exclude");
if (verbose > 2)
rprintf(FINFO,"add_exclude(%s)\n",pattern);
(*list)[len+1] = NULL;
}
void add_exclude(const char *pattern, int include)
{
add_exclude_list(pattern,&exclude_list, include);
}
struct exclude_struct **make_exclude_list(const char *fname,
struct exclude_struct **list1,
int fatal, int include)
{
struct exclude_struct **list=list1;
FILE *f = fopen(fname,"r");
char line[MAXPATHLEN];
if (!f) {
if (fatal) {
rsyserr(FERROR, errno,
"failed to open %s file %s",
include ? "include" : "exclude",
fname);
exit_cleanup(RERR_FILEIO);
while (1) {
char ch, *s = line;
int cnt;
while (1) {
if ((cnt = read(fd, &ch, 1)) <= 0) {
if (cnt < 0 && errno == EINTR)
continue;
break;
}
if (eol_nulls? !ch : (ch == '\n' || ch == '\r'))
break;
if (s < eob)
*s++ = ch;
}
return list;
}
while (fgets(line,MAXPATHLEN,f)) {
int l = strlen(line);
if (l && line[l-1] == '\n') l--;
line[l] = 0;
if (line[0] && (line[0] != ';') && (line[0] != '#')) {
*s = '\0';
if (*line && *line != ';' && *line != '#') {
/* Skip lines starting with semicolon or pound.
It probably wouldn't cause any harm to not skip
them but there's no need to save them. */
add_exclude_list(line,&list,include);
* It probably wouldn't cause any harm to not skip
* them but there's no need to save them. */
add_exclude(listp, line, include);
}
if (cnt <= 0)
break;
}
fclose(f);
return list;
}
void add_exclude_file(const char *fname, int fatal, int include)
{
if (!fname || !*fname) return;
exclude_list = make_exclude_list(fname,exclude_list,fatal,include);
close(fd);
}
void send_exclude_list(int f)
{
int i;
extern int remote_version;
extern int protocol_version;
extern int list_only, recurse;
/* this is a complete hack - blame Rusty */
if (list_only && !recurse) {
add_exclude("/*/*", 0);
}
/* This is a complete hack - blame Rusty.
*
* FIXME: This pattern shows up in the output of
* report_exclude_result(), which is not ideal. */
if (list_only && !recurse)
add_exclude(&exclude_list, "/*/*", ADD_EXCLUDE);
if (!exclude_list) {
write_int(f,0);
@@ -274,13 +335,13 @@ void send_exclude_list(int f)
int l;
char pattern[MAXPATHLEN];
strlcpy(pattern,exclude_list[i]->pattern,sizeof(pattern));
strlcpy(pattern,exclude_list[i]->pattern,sizeof(pattern));
if (exclude_list[i]->directory) strlcat(pattern,"/", sizeof(pattern));
l = strlen(pattern);
if (l == 0) continue;
if (exclude_list[i]->include) {
if (remote_version < 19) {
if (protocol_version < 19) {
rprintf(FERROR,"remote rsync does not support include syntax - aborting\n");
exit_cleanup(RERR_UNSUPPORTED);
}
@@ -290,7 +351,7 @@ void send_exclude_list(int f)
write_int(f,l);
}
write_buf(f,pattern,l);
}
}
write_int(f,0);
}
@@ -304,7 +365,7 @@ void recv_exclude_list(int f)
while ((l=read_int(f))) {
if (l >= MAXPATHLEN) overflow("recv_exclude_list");
read_sbuf(f,line,l);
add_exclude(line,0);
add_exclude(&exclude_list, line, ADD_EXCLUDE);
}
}
@@ -329,7 +390,7 @@ char *get_exclude_tok(char *p)
return(NULL);
/* Skip over any initial spaces */
while(isspace(*s))
while (isspace(* (unsigned char *) s))
s++;
/* Are we at the end of the string? */
@@ -340,9 +401,9 @@ char *get_exclude_tok(char *p)
/* Is this a '+' or '-' followed by a space (not whitespace)? */
if ((*s=='+' || *s=='-') && *(s+1)==' ')
s+=2;
/* Skip to the next space or the end of the string */
while(!isspace(*s) && *s!='\0')
while (!isspace(* (unsigned char *) s) && *s != '\0')
s++;
} else {
t=NULL;
@@ -356,37 +417,26 @@ char *get_exclude_tok(char *p)
return(t);
}
void add_exclude_line(char *p)
{
char *tok;
if (!p || !*p) return;
p = strdup(p);
if (!p) out_of_memory("add_exclude_line");
for (tok=get_exclude_tok(p); tok; tok=get_exclude_tok(NULL))
add_exclude(tok, 0);
free(p);
}
void add_include_line(char *p)
void add_exclude_line(struct exclude_struct ***listp,
const char *line, int include)
{
char *tok;
if (!p || !*p) return;
p = strdup(p);
if (!p) out_of_memory("add_include_line");
char *tok, *p;
if (!line || !*line) return;
p = strdup(line);
if (!p) out_of_memory("add_exclude_line");
for (tok=get_exclude_tok(p); tok; tok=get_exclude_tok(NULL))
add_exclude(tok, 1);
add_exclude(listp, tok, include);
free(p);
}
static char *cvs_ignore_list[] = {
"RCS","SCCS","CVS","CVS.adm","RCSLOG","cvslog.*",
"tags","TAGS",".make.state",".nse_depinfo",
"*~", "#*", ".#*", ",*", "*.old", "*.bak", "*.BAK", "*.orig",
"RCS/", "SCCS/", "CVS/", ".svn/", "CVS.adm", "RCSLOG", "cvslog.*",
"tags", "TAGS", ".make.state", ".nse_depinfo",
"*~", "#*", ".#*", ", *", "*.old", "*.bak", "*.BAK", "*.orig",
"*.rej", ".del-*", "*.a", "*.o", "*.obj", "*.so", "*.Z", "*.elc", "*.ln",
"core",NULL};
"core", NULL};
void add_cvs_excludes(void)
@@ -394,14 +444,14 @@ void add_cvs_excludes(void)
char fname[MAXPATHLEN];
char *p;
int i;
for (i=0; cvs_ignore_list[i]; i++)
add_exclude(cvs_ignore_list[i], 0);
add_exclude(&exclude_list, cvs_ignore_list[i], ADD_EXCLUDE);
if ((p=getenv("HOME")) && strlen(p) < (MAXPATHLEN-12)) {
snprintf(fname,sizeof(fname), "%s/.cvsignore",p);
add_exclude_file(fname,0,0);
add_exclude_file(&exclude_list,fname,MISSING_OK,ADD_EXCLUDE);
}
add_exclude_line(getenv("CVSIGNORE"));
add_exclude_line(&exclude_list, getenv("CVSIGNORE"), ADD_EXCLUDE);
}

View File

@@ -1,5 +1,6 @@
/*
Copyright (C) Andrew Tridgell 1998
Copyright (C) 2002 by Martin Pool
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -38,7 +39,7 @@ int sparse_end(int f)
static int write_sparse(int f,char *buf,size_t len)
{
int l1=0,l2=0;
size_t l1=0, l2=0;
int ret;
for (l1=0;l1<len && buf[l1]==0;l1++) ;
@@ -56,10 +57,11 @@ static int write_sparse(int f,char *buf,size_t len)
if (l1 == len)
return len;
if ((ret=write(f,buf+l1,len-(l1+l2))) != len-(l1+l2)) {
if (ret == -1 || ret == 0) return ret;
ret = write(f, buf + l1, len - (l1+l2));
if (ret == -1 || ret == 0)
return ret;
else if (ret != (int) (len - (l1+l2)))
return (l1+ret);
}
if (l2 > 0)
do_lseek(f,l2,SEEK_CUR);
@@ -67,19 +69,22 @@ static int write_sparse(int f,char *buf,size_t len)
return len;
}
/*
* write_file does not allow incomplete writes. It loops internally
* until len bytes are written or errno is set.
*/
int write_file(int f,char *buf,size_t len)
{
int ret = 0;
if (!sparse_files) {
return write(f,buf,len);
}
while (len>0) {
int len1 = MIN(len, SPARSE_WRITE_SIZE);
int r1 = write_sparse(f, buf, len1);
int r1;
if (sparse_files) {
int len1 = MIN(len, SPARSE_WRITE_SIZE);
r1 = write_sparse(f, buf, len1);
} else {
r1 = write(f, buf, len);
}
if (r1 <= 0) {
if (ret > 0) return ret;
return r1;
@@ -100,7 +105,7 @@ int write_file(int f,char *buf,size_t len)
struct map_struct *map_file(int fd,OFF_T len)
{
struct map_struct *map;
map = (struct map_struct *)malloc(sizeof(*map));
map = new(struct map_struct);
if (!map) out_of_memory("map_file");
map->fd = fd;
@@ -110,6 +115,7 @@ struct map_struct *map_file(int fd,OFF_T len)
map->p_offset = 0;
map->p_fd_offset = 0;
map->p_len = 0;
map->status = 0;
return map;
}
@@ -154,7 +160,7 @@ char *map_ptr(struct map_struct *map,OFF_T offset,int len)
/* make sure we have allocated enough memory for the window */
if (window_size > map->p_size) {
map->p = (char *)Realloc(map->p, window_size);
map->p = realloc_array(map->p, char, window_size);
if (!map->p) out_of_memory("map_ptr");
map->p_size = window_size;
}
@@ -186,7 +192,11 @@ char *map_ptr(struct map_struct *map,OFF_T offset,int len)
}
if ((nread=read(map->fd,map->p + read_offset,read_size)) != read_size) {
if (nread < 0) nread = 0;
if (nread < 0) {
nread = 0;
if (!map->status)
map->status = errno;
}
/* the best we can do is zero the buffer - the file
has changed mid transfer! */
memset(map->p+read_offset+nread, 0, read_size - nread);
@@ -201,13 +211,18 @@ char *map_ptr(struct map_struct *map,OFF_T offset,int len)
}
void unmap_file(struct map_struct *map)
int unmap_file(struct map_struct *map)
{
int ret;
if (map->p) {
free(map->p);
map->p = NULL;
}
ret = map->status;
memset(map, 0, sizeof(*map));
free(map);
return ret;
}

1120
flist.c
View File

File diff suppressed because it is too large Load Diff

View File

@@ -1,21 +1,21 @@
/* -*- c-file-style: "linux" -*-
rsync -- fast file replication program
Copyright (C) 1996-2000 by Andrew Tridgell
Copyright (C) 1996-2000 by Andrew Tridgell
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.
@@ -31,16 +31,16 @@ extern int am_root;
extern int preserve_devices;
extern int preserve_hard_links;
extern int update_only;
extern int whole_file;
extern int block_size;
extern int opt_ignore_existing;
extern int csum_length;
extern int ignore_times;
extern int size_only;
extern int io_timeout;
extern int remote_version;
extern int protocol_version;
extern int always_checksum;
extern int modify_window;
extern char *compare_dest;
extern int link_dest;
/* choose whether to skip a particular file */
@@ -50,8 +50,23 @@ static int skip_file(char *fname,
if (st->st_size != file->length) {
return 0;
}
/* if always checksum is set then we use the checksum instead
if (link_dest) {
extern int preserve_perms;
extern int preserve_uid;
extern int preserve_gid;
if(preserve_perms
&& (st->st_mode & ~_S_IFMT) != (file->mode & ~_S_IFMT))
return 0;
if (preserve_uid && st->st_uid != file->uid)
return 0;
if (preserve_gid && st->st_gid != file->gid)
return 0;
}
/* if always checksum is set then we use the checksum instead
of the file time to determine whether to sync */
if (always_checksum && S_ISREG(st->st_mode)) {
char sum[MD4_SUM_LENGTH];
@@ -60,12 +75,12 @@ static int skip_file(char *fname,
if (compare_dest != NULL) {
if (access(fname, 0) != 0) {
snprintf(fnamecmpdest,MAXPATHLEN,"%s/%s",
compare_dest,fname);
compare_dest,fname);
fname = fnamecmpdest;
}
}
file_checksum(fname,sum,st->st_size);
if (remote_version < 21) {
if (protocol_version < 21) {
return (memcmp(sum,file->sum,2) == 0);
} else {
return (memcmp(sum,file->sum,MD4_SUM_LENGTH) == 0);
@@ -84,122 +99,179 @@ static int skip_file(char *fname,
}
/* use a larger block size for really big files */
static int adapt_block_size(struct file_struct *file, int bsize)
/*
* NULL sum_struct means we have no checksums
*/
void write_sum_head(int f, struct sum_struct *sum)
{
int ret;
static struct sum_struct null_sum;
if (bsize != BLOCK_SIZE) return bsize;
if (sum == (struct sum_struct *)NULL)
sum = &null_sum;
ret = file->length / (10000); /* rough heuristic */
ret = ret & ~15; /* multiple of 16 */
if (ret < bsize) ret = bsize;
if (ret > CHUNK_SIZE/2) ret = CHUNK_SIZE/2;
return ret;
write_int(f, sum->count);
write_int(f, sum->blength);
if (protocol_version >= 27)
write_int(f, sum->s2length);
write_int(f, sum->remainder);
}
/*
* set (initialize) the size entries in the per-file sum_struct
* calulating dynamic block ans checksum sizes.
*
* This is only called from generate_and_send_sums() but is a seperate
* function to encapsulate the logic.
*
* The block size is a rounded square root of file length.
*
* The checksum size is determined according to:
* blocksum_bits = BLOCKSUM_EXP + 2*log2(file_len) - log2(block_len)
* provided by Donovan Baarda which gives a probability of rsync
* algorithm corrupting data and falling back using the whole md4
* checksums.
*
* This might be made one of several selectable heuristics.
*/
/*
send a sums struct down a fd
*/
static void send_sums(struct sum_struct *s, int f_out)
static void sum_sizes_sqroot(struct sum_struct *sum, uint64 len)
{
if (s) {
size_t i;
extern int block_size;
int blength, s2length, b;
uint32 c;
uint64 l;
/* tell the other guy how many we are going to be
doing and how many bytes there are in the last
chunk */
write_int(f_out, s->count);
write_int(f_out, s->n);
write_int(f_out, s->remainder);
for (i = 0; i < s->count; i++) {
write_int(f_out, s->sums[i].sum1);
write_buf(f_out, s->sums[i].sum2, csum_length);
}
if (block_size) {
blength = block_size;
} else if (len <= BLOCK_SIZE * BLOCK_SIZE) {
blength = BLOCK_SIZE;
} else {
/* we don't have checksums */
write_int(f_out, 0);
write_int(f_out, block_size);
write_int(f_out, 0);
l = len;
c = 1;
while (l >>= 2) {
c <<= 1;
}
blength = 0;
do {
blength |= c;
if (len < (uint64)blength * blength)
blength &= ~c;
c >>= 1;
} while (c >= 8); /* round to multiple of 8 */
blength = MAX(blength, BLOCK_SIZE);
}
if (protocol_version < 27) {
s2length = csum_length;
} else if (csum_length == SUM_LENGTH) {
s2length = SUM_LENGTH;
} else {
b = BLOCKSUM_BIAS;
l = len;
while (l >>= 1) {
b += 2;
}
c = blength;
while (c >>= 1 && b) {
b--;
}
s2length = (b + 1 - 32 + 7) / 8; /* add a bit,
* subtract rollsum,
* round up
* --optimize in compiler--
*/
s2length = MAX(s2length, csum_length);
s2length = MIN(s2length, SUM_LENGTH);
}
sum->flength = len;
sum->blength = blength;
sum->s2length = s2length;
sum->count = (len + (blength - 1)) / blength;
sum->remainder = (len % blength);
if (sum->count && verbose > 2) {
rprintf(FINFO, "count=%ld rem=%ld blength=%ld s2length=%ld flength=%.0f\n",
(long) sum->count, (long) sum->remainder,
(long) sum->blength, (long) sum->s2length,
(double) sum->flength);
}
}
/*
generate a stream of signatures/checksums that describe a buffer
generate approximately one checksum every n bytes
*/
static struct sum_struct *generate_sums(struct map_struct *buf,OFF_T len,int n)
/**
* Perhaps we want to just send an empty checksum set for this file,
* which will force the whole thing to be literally transferred.
*
* When do we do this? If the user's explicitly said they
* want the whole thing, or if { they haven't explicitly
* requested a delta, and it's local but not batch mode.}
*
* Whew. */
static BOOL disable_deltas_p(void)
{
int i;
struct sum_struct *s;
int count;
int block_len = n;
int remainder = (len%block_len);
extern int whole_file;
extern int local_server;
extern int write_batch;
if (whole_file > 0)
return True;
if (whole_file == 0 || write_batch)
return False;
return local_server;
}
/*
* Generate and send a stream of signatures/checksums that describe a buffer
*
* Generate approximately one checksum every block_len bytes.
*/
static void generate_and_send_sums(struct map_struct *buf, OFF_T len, int f_out)
{
size_t i;
struct sum_struct sum;
OFF_T offset = 0;
count = (len+(block_len-1))/block_len;
sum_sizes_sqroot(&sum, len);
s = (struct sum_struct *)malloc(sizeof(*s));
if (!s) out_of_memory("generate_sums");
write_sum_head(f_out, &sum);
s->count = count;
s->remainder = remainder;
s->n = n;
s->flength = len;
for (i = 0; i < sum.count; i++) {
int n1 = MIN(len, sum.blength);
char *map = map_ptr(buf, offset, n1);
uint32 sum1 = get_checksum1(map, n1);
char sum2[SUM_LENGTH];
if (count==0) {
s->sums = NULL;
return s;
}
if (verbose > 3)
rprintf(FINFO,"count=%d rem=%d n=%d flength=%.0f\n",
s->count,s->remainder,s->n,(double)s->flength);
s->sums = (struct sum_buf *)malloc(sizeof(s->sums[0])*s->count);
if (!s->sums) out_of_memory("generate_sums");
for (i=0;i<count;i++) {
int n1 = MIN(len,n);
char *map = map_ptr(buf,offset,n1);
s->sums[i].sum1 = get_checksum1(map,n1);
get_checksum2(map,n1,s->sums[i].sum2);
s->sums[i].offset = offset;
s->sums[i].len = n1;
s->sums[i].i = i;
if (verbose > 3)
rprintf(FINFO,"chunk[%d] offset=%.0f len=%d sum1=%08x\n",
i,(double)s->sums[i].offset,s->sums[i].len,s->sums[i].sum1);
get_checksum2(map, n1, sum2);
if (verbose > 3) {
rprintf(FINFO,
"chunk[%ld] offset=%.0f len=%d sum1=%08lx\n",
(long)i,(double)offset,n1,(unsigned long)sum1);
}
write_int(f_out, sum1);
write_buf(f_out, sum2, sum.s2length);
len -= n1;
offset += n1;
}
return s;
}
/*
* Acts on file number I from FLIST, whose name is fname.
/**
* Acts on file number @p i from @p flist, whose name is @p fname.
*
* First fixes up permissions, then generates checksums for the file.
*
* (This comment was added later by mbp who was trying to work it out;
* it might be wrong.)
*/
void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
{
* @note This comment was added later by mbp who was trying to work it
* out. It might be wrong.
**/
void recv_generator(char *fname, struct file_list *flist, int i, int f_out)
{
int fd;
STRUCT_STAT st;
struct map_struct *buf;
struct sum_struct *s;
int statret;
struct file_struct *file = flist->files[i];
char *fnamecmp;
@@ -208,6 +280,7 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
extern int list_only;
extern int preserve_perms;
extern int only_existing;
extern int orig_umask;
if (list_only) return;
@@ -218,48 +291,47 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
if (only_existing && statret == -1 && errno == ENOENT) {
/* we only want to update existing files */
if (verbose > 1) rprintf(FINFO, RSYNC_NAME
": not creating new file \"%s\"\n",fname);
if (verbose > 1) rprintf(FINFO, "not creating new file \"%s\"\n",fname);
return;
}
if (statret == 0 &&
!preserve_perms &&
if (statret == 0 &&
!preserve_perms &&
(S_ISDIR(st.st_mode) == S_ISDIR(file->mode))) {
/* if the file exists already and we aren't perserving
presmissions then act as though the remote end sent
us the file permissions we already have */
* permissions then act as though the remote end sent
* us the file permissions we already have */
file->mode = (file->mode & _S_IFMT) | (st.st_mode & ~_S_IFMT);
}
if (S_ISDIR(file->mode)) {
/* The file to be received is a directory, so we need
* to prepare appropriately. If there is already a
* file of that name and it is *not* a directory, then
* we need to delete it. If it doesn't exist, then
* recursively create it. */
/* The file to be received is a directory, so we need
* to prepare appropriately. If there is already a
* file of that name and it is *not* a directory, then
* we need to delete it. If it doesn't exist, then
* recursively create it. */
if (dry_run) return; /* XXXX -- might cause inaccuracies?? -- mbp */
if (statret == 0 && !S_ISDIR(st.st_mode)) {
if (robust_unlink(fname) != 0) {
rprintf(FERROR, RSYNC_NAME
": recv_generator: unlink \"%s\" to make room for directory: %s\n",
fname,strerror(errno));
rprintf(FERROR,
"recv_generator: unlink %s to make room for directory: %s\n",
full_fname(fname), strerror(errno));
return;
}
statret = -1;
}
if (statret != 0 && do_mkdir(fname,file->mode) != 0 && errno != EEXIST) {
if (!(relative_paths && errno==ENOENT &&
create_directory_path(fname)==0 &&
if (!(relative_paths && errno==ENOENT &&
create_directory_path(fname, orig_umask)==0 &&
do_mkdir(fname,file->mode)==0)) {
rprintf(FERROR, RSYNC_NAME ": recv_generator: mkdir \"%s\": %s (2)\n",
fname,strerror(errno));
rprintf(FERROR, "recv_generator: mkdir %s failed: %s\n",
full_fname(fname), strerror(errno));
}
}
/* f_out is set to -1 when doing final directory
/* f_out is set to -1 when doing final directory
permission and modification time repair */
if (set_perms(fname,file,NULL,0) && verbose && (f_out != -1))
if (set_perms(fname,file,NULL,0) && verbose && (f_out != -1))
rprintf(FINFO,"%s/\n",fname);
return;
}
@@ -272,8 +344,8 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
if (safe_symlinks && unsafe_symlink(file->link, fname)) {
if (verbose) {
rprintf(FINFO,RSYNC_NAME ": ignoring unsafe symlink \"%s\" -> \"%s\"\n",
fname,file->link);
rprintf(FINFO, "ignoring unsafe symlink %s -> \"%s\"\n",
full_fname(fname), file->link);
}
return;
}
@@ -288,20 +360,19 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
set_perms(fname,file,&st,1);
return;
}
}
}
/* Not a symlink, so delete whatever's
* already there and put a new symlink
* in place. */
* in place. */
delete_file(fname);
}
if (do_symlink(file->link,fname) != 0) {
rprintf(FERROR,RSYNC_NAME": symlink \"%s\" -> \"%s\": %s\n",
fname,file->link,strerror(errno));
rprintf(FERROR, "symlink %s -> \"%s\" failed: %s\n",
full_fname(fname), file->link, strerror(errno));
} else {
set_perms(fname,file,NULL,0);
if (verbose) {
rprintf(FINFO,RSYNC_NAME": %s -> %s\n",
fname,file->link);
rprintf(FINFO,"%s -> %s\n", fname,file->link);
}
}
#endif
@@ -310,15 +381,16 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
#ifdef HAVE_MKNOD
if (am_root && preserve_devices && IS_DEVICE(file->mode)) {
if (statret != 0 ||
if (statret != 0 ||
st.st_mode != file->mode ||
st.st_rdev != file->rdev) {
(DEV64_T)st.st_rdev != file->rdev) {
delete_file(fname);
if (verbose > 2)
rprintf(FINFO,"mknod(%s,0%o,0x%x)\n",
fname,(int)file->mode,(int)file->rdev);
if (do_mknod(fname,file->mode,file->rdev) != 0) {
rprintf(FERROR,"mknod %s : %s\n",fname,strerror(errno));
rprintf(FERROR, "mknod %s failed: %s\n",
full_fname(fname), strerror(errno));
} else {
set_perms(fname,file,NULL,0);
if (verbose)
@@ -333,14 +405,12 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
if (preserve_hard_links && check_hard_link(file)) {
if (verbose > 1)
rprintf(FINFO, RSYNC_NAME
": \"%s\" is a hard link\n",f_name(file));
rprintf(FINFO, "recv_generator: \"%s\" is a hard link\n",f_name(file));
return;
}
if (!S_ISREG(file->mode)) {
rprintf(FINFO, RSYNC_NAME
": skipping non-regular file \"%s\"\n",fname);
rprintf(FINFO, "skipping non-regular file \"%s\"\n",fname);
return;
}
@@ -355,6 +425,18 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
statret = -1;
if (statret == -1)
errno = saveerrno;
#if HAVE_LINK
else if (link_dest && !dry_run) {
if (do_link(fnamecmpbuf, fname) != 0) {
if (verbose > 0)
rprintf(FINFO,"link %s => %s : %s\n",
fnamecmpbuf,
fname,
strerror(errno));
}
fnamecmp = fnamecmpbuf;
}
#endif
else
fnamecmp = fnamecmpbuf;
}
@@ -362,12 +444,11 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
if (statret == -1) {
if (errno == ENOENT) {
write_int(f_out,i);
if (!dry_run) send_sums(NULL,f_out);
} else {
if (verbose > 1)
rprintf(FERROR, RSYNC_NAME
": recv_generator failed to open \"%s\": %s\n",
fname, strerror(errno));
if (!dry_run) write_sum_head(f_out, NULL);
} else if (verbose > 1) {
rprintf(FERROR,
"recv_generator: failed to open %s: %s\n",
full_fname(fname), strerror(errno));
}
return;
}
@@ -379,7 +460,13 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
/* now pretend the file didn't exist */
write_int(f_out,i);
if (!dry_run) send_sums(NULL,f_out);
if (!dry_run) write_sum_head(f_out, NULL);
return;
}
if (opt_ignore_existing && fnamecmp == fname) {
if (verbose > 1)
rprintf(FINFO,"%s exists\n",fname);
return;
}
@@ -400,20 +487,21 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
return;
}
if (whole_file) {
if (disable_deltas_p()) {
write_int(f_out,i);
send_sums(NULL,f_out);
write_sum_head(f_out, NULL);
return;
}
/* open the file */
/* open the file */
fd = do_open(fnamecmp, O_RDONLY, 0);
if (fd == -1) {
rprintf(FERROR,RSYNC_NAME": failed to open \"%s\", continuing : %s\n",fnamecmp,strerror(errno));
rprintf(FERROR, "failed to open %s, continuing: %s\n",
full_fname(fnamecmp), strerror(errno));
/* pretend the file didn't exist */
write_int(f_out,i);
send_sums(NULL,f_out);
write_sum_head(f_out, NULL);
return;
}
@@ -426,18 +514,14 @@ void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
if (verbose > 3)
rprintf(FINFO,"gen mapped %s of size %.0f\n",fnamecmp,(double)st.st_size);
s = generate_sums(buf,st.st_size,adapt_block_size(file, block_size));
if (verbose > 2)
rprintf(FINFO,"sending sums for %d\n",i);
rprintf(FINFO, "generating and sending sums for %d\n", i);
write_int(f_out,i);
send_sums(s,f_out);
generate_and_send_sums(buf, st.st_size, f_out);
close(fd);
if (buf) unmap_file(buf);
free_sums(s);
}
@@ -451,6 +535,13 @@ void generate_files(int f,struct file_list *flist,char *local_name,int f_recv)
rprintf(FINFO,"generator starting pid=%d count=%d\n",
(int)getpid(),flist->count);
if (verbose >= 2) {
rprintf(FINFO,
disable_deltas_p()
? "delta-transmission disabled for local transfer or --whole-file\n"
: "delta transmission enabled\n");
}
/* we expect to just sit around now, so don't exit on a
timeout. If we really get a timeout then the other process should
exit */
@@ -466,12 +557,11 @@ void generate_files(int f,struct file_list *flist,char *local_name,int f_recv)
them. This is then fixed after the files are transferred */
if (!am_root && S_ISDIR(file->mode)) {
file->mode |= S_IWUSR; /* user write */
/* XXX: Could this be causing a problem on SCO? Perhaps their
* handling of permissions is strange? */
/* XXX: Could this be causing a problem on SCO? Perhaps their
* handling of permissions is strange? */
}
recv_generator(local_name?local_name:f_name(file),
flist,i,f);
recv_generator(local_name?local_name:f_name(file), flist,i,f);
file->mode = saved_mode;
}
@@ -485,19 +575,16 @@ void generate_files(int f,struct file_list *flist,char *local_name,int f_recv)
write_int(f,-1);
if (remote_version >= 13) {
/* in newer versions of the protocol the files can cycle through
the system more than once to catch initial checksum errors */
for (i=read_int(f_recv); i != -1; i=read_int(f_recv)) {
struct file_struct *file = flist->files[i];
recv_generator(local_name?local_name:f_name(file),
flist,i,f);
}
phase++;
if (verbose > 2)
rprintf(FINFO,"generate_files phase=%d\n",phase);
write_int(f,-1);
/* files can cycle through the system more than once
* to catch initial checksum errors */
for (i=read_int(f_recv); i != -1; i=read_int(f_recv)) {
struct file_struct *file = flist->files[i];
recv_generator(local_name?local_name:f_name(file), flist,i,f);
}
phase++;
if (verbose > 2)
rprintf(FINFO,"generate_files phase=%d\n",phase);
write_int(f,-1);
}

50
getgroups.c Normal file
View File

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

13
hlink.c
View File

@@ -57,9 +57,7 @@ void init_hard_links(struct file_list *flist)
if (hlink_list)
free(hlink_list);
if (!(hlink_list =
(struct file_struct *) malloc(sizeof(hlink_list[0]) *
flist->count)))
if (!(hlink_list = new_array(struct file_struct, flist->count)))
out_of_memory("init_hard_links");
for (i = 0; i < flist->count; i++)
@@ -97,14 +95,21 @@ int check_hard_link(struct file_struct *file)
low = mid + 1;
}
/* XXX: To me this looks kind of dodgy -- why do we use [low]
* here and [low-1] below? -- mbp */
if (hlink_compare(&hlink_list[low], file) != 0)
return 0;
if (low > 0 &&
S_ISREG(hlink_list[low - 1].mode) &&
file->dev == hlink_list[low - 1].dev &&
file->inode == hlink_list[low - 1].inode)
file->inode == hlink_list[low - 1].inode) {
if (verbose >= 2) {
rprintf(FINFO, "check_hard_link: \"%s\" is a hard link to file %d, \"%s\"\n",
f_name(file), low-1, f_name(&hlink_list[low-1]));
}
return 1;
}
#endif
return 0;

View File

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

472
io.c
View File

@@ -1,32 +1,42 @@
/* -*- c-file-style: "linux" -*-
Copyright (C) 1996-2001 by Andrew Tridgell
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.
*/
*
* Copyright (C) 1996-2001 by Andrew Tridgell
* Copyright (C) Paul Mackerras 1996
* Copyright (C) 2001, 2002 by Martin Pool <mbp@samba.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
socket and pipe IO utilities used in rsync
/**
* @file io.c
*
* Socket and pipe IO utilities used in rsync.
*
* rsync provides its own multiplexing system, which is used to send
* stderr and stdout over a single socket. We need this because
* stdout normally carries the binary data stream, and stderr all our
* error messages.
*
* For historical reasons this is off during the start of the
* connection, but it's switched on quite early using
* io_start_multiplex_out() and io_start_multiplex_in().
**/
tridge, June 1996
*/
#include "rsync.h"
/* if no timeout is specified then use a 60 second select timeout */
/** If no timeout is specified then use a 60 second select timeout */
#define SELECT_TIMEOUT 60
static int io_multiplexing_out;
@@ -42,12 +52,36 @@ extern int io_timeout;
extern struct stats stats;
const char phase_unknown[] = "unknown";
/**
* The connection might be dropped at some point; perhaps because the
* remote instance crashed. Just giving the offset on the stream is
* not very helpful. So instead we try to make io_phase_name point to
* something useful.
*
* For buffered/multiplexed IO these names will be somewhat
* approximate; perhaps for ease of support we would rather make the
* buffer always flush when a single application-level IO finishes.
*
* @todo Perhaps we want some simple stack functionality, but there's
* no need to overdo it.
**/
const char *io_write_phase = phase_unknown;
const char *io_read_phase = phase_unknown;
/** Ignore EOF errors while reading a module listing if the remote
version is 24 or less. */
int kludge_around_eof = False;
static int io_error_fd = -1;
static int io_filesfrom_f_in = -1;
static int io_filesfrom_f_out = -1;
static char io_filesfrom_buf[2048];
static char *io_filesfrom_bp;
static char io_filesfrom_lastchar;
static int io_filesfrom_buflen;
static void read_loop(int fd, char *buf, size_t len);
@@ -57,7 +91,7 @@ static void check_timeout(void)
time_t t;
err_list_push();
if (!io_timeout) return;
if (!last_io) {
@@ -76,13 +110,13 @@ static void check_timeout(void)
}
}
/* setup the fd used to propogate errors */
/** Setup the fd used to propagate errors */
void io_set_error_fd(int fd)
{
io_error_fd = fd;
}
/* read some data from the error fd and write it to the write log code */
/** Read some data from the error fd and write it to the write log code */
static void read_error_fd(void)
{
char buf[200];
@@ -90,8 +124,8 @@ static void read_error_fd(void)
int fd = io_error_fd;
int tag, len;
/* io_error_fd is temporarily disabled -- is this meant to
* prevent indefinite recursion? */
/* io_error_fd is temporarily disabled -- is this meant to
* prevent indefinite recursion? */
io_error_fd = -1;
read_loop(fd, buf, 4);
@@ -103,8 +137,8 @@ static void read_error_fd(void)
while (len) {
n = len;
if (n > (sizeof(buf)-1))
n = sizeof(buf)-1;
if (n > (sizeof buf - 1))
n = sizeof buf - 1;
read_loop(fd, buf, n);
rwrite((enum logcode)tag, buf, n);
len -= n;
@@ -113,47 +147,62 @@ static void read_error_fd(void)
io_error_fd = fd;
}
static void whine_about_eof (void)
/**
* When we're the receiver and we have a local --files-from list of names
* that needs to be sent over the socket to the sender, we have to do two
* things at the same time: send the sender a list of what files we're
* processing and read the incoming file+info list from the sender. We do
* this by augmenting the read_timeout() function to copy this data. It
* uses the io_filesfrom_buf to read a block of data from f_in (when it is
* ready, since it might be a pipe) and then blast it out f_out (when it
* is ready to receive more data).
*/
void io_set_filesfrom_fds(int f_in, int f_out)
{
/**
It's almost always an error to get an EOF when we're trying
to read from the network, because the protocol is
self-terminating.
However, there is one unfortunate cases where it is not,
which is rsync <2.4.6 sending a list of modules on a
server, since the list is terminated by closing the socket.
So, for the section of the program where that is a problem
(start_socket_client), kludge_around_eof is True and we
just exit.
*/
io_filesfrom_f_in = f_in;
io_filesfrom_f_out = f_out;
io_filesfrom_bp = io_filesfrom_buf;
io_filesfrom_lastchar = '\0';
io_filesfrom_buflen = 0;
}
/**
* It's almost always an error to get an EOF when we're trying to read
* from the network, because the protocol is self-terminating.
*
* However, there is one unfortunate cases where it is not, which is
* rsync <2.4.6 sending a list of modules on a server, since the list
* is terminated by closing the socket. So, for the section of the
* program where that is a problem (start_socket_client),
* kludge_around_eof is True and we just exit.
*/
static void whine_about_eof(void)
{
if (kludge_around_eof)
exit_cleanup (0);
exit_cleanup(0);
else {
rprintf (FERROR,
"%s: connection unexpectedly closed "
"(%.0f bytes read so far)\n",
RSYNC_NAME, (double)stats.total_read);
exit_cleanup (RERR_STREAMIO);
rprintf(FERROR,
"%s: connection unexpectedly closed "
"(%.0f bytes read so far)\n",
RSYNC_NAME, (double)stats.total_read);
exit_cleanup(RERR_STREAMIO);
}
}
static void die_from_readerr (int err)
static void die_from_readerr(int err)
{
/* this prevents us trying to write errors on a dead socket */
io_multiplexing_close();
rprintf(FERROR, "%s: read error: %s\n",
RSYNC_NAME, strerror (err));
RSYNC_NAME, strerror(err));
exit_cleanup(RERR_STREAMIO);
}
/*!
/**
* Read from a socket with IO timeout. return the number of bytes
* read. If no bytes can be read then exit, never return a number <= 0.
*
@@ -164,7 +213,7 @@ static void die_from_readerr (int err)
* give a better explanation. We can tell whether the connection has
* started by looking e.g. at whether the remote version is known yet.
*/
static int read_timeout (int fd, char *buf, size_t len)
static int read_timeout(int fd, char *buf, size_t len)
{
int n, ret=0;
@@ -172,16 +221,33 @@ static int read_timeout (int fd, char *buf, size_t len)
while (ret == 0) {
/* until we manage to read *something* */
fd_set fds;
fd_set r_fds, w_fds;
struct timeval tv;
int fd_count = fd+1;
int count;
FD_ZERO(&fds);
FD_SET(fd, &fds);
FD_ZERO(&r_fds);
FD_SET(fd, &r_fds);
if (io_error_fd != -1) {
FD_SET(io_error_fd, &fds);
if (io_error_fd > fd) fd_count = io_error_fd+1;
FD_SET(io_error_fd, &r_fds);
if (io_error_fd >= fd_count) fd_count = io_error_fd+1;
}
if (io_filesfrom_f_out != -1) {
int new_fd;
if (io_filesfrom_buflen == 0) {
if (io_filesfrom_f_in != -1) {
FD_SET(io_filesfrom_f_in, &r_fds);
new_fd = io_filesfrom_f_in;
} else {
io_filesfrom_f_out = -1;
new_fd = -1;
}
} else {
FD_ZERO(&w_fds);
FD_SET(io_filesfrom_f_out, &w_fds);
new_fd = io_filesfrom_f_out;
}
if (new_fd >= fd_count) fd_count = new_fd+1;
}
tv.tv_sec = io_timeout?io_timeout:SELECT_TIMEOUT;
@@ -189,7 +255,9 @@ static int read_timeout (int fd, char *buf, size_t len)
errno = 0;
count = select(fd_count, &fds, NULL, NULL, &tv);
count = select(fd_count, &r_fds,
io_filesfrom_buflen? &w_fds : NULL,
NULL, &tv);
if (count == 0) {
check_timeout();
@@ -202,11 +270,75 @@ static int read_timeout (int fd, char *buf, size_t len)
continue;
}
if (io_error_fd != -1 && FD_ISSET(io_error_fd, &fds)) {
if (io_error_fd != -1 && FD_ISSET(io_error_fd, &r_fds)) {
read_error_fd();
}
if (!FD_ISSET(fd, &fds)) continue;
if (io_filesfrom_f_out != -1) {
if (io_filesfrom_buflen) {
if (FD_ISSET(io_filesfrom_f_out, &w_fds)) {
int l = write(io_filesfrom_f_out,
io_filesfrom_bp,
io_filesfrom_buflen);
if (l > 0) {
if (!(io_filesfrom_buflen -= l))
io_filesfrom_bp = io_filesfrom_buf;
else
io_filesfrom_bp += l;
} else {
/* XXX should we complain? */
io_filesfrom_f_out = -1;
}
}
} else if (io_filesfrom_f_in != -1) {
if (FD_ISSET(io_filesfrom_f_in, &r_fds)) {
int l = read(io_filesfrom_f_in,
io_filesfrom_buf,
sizeof io_filesfrom_buf);
if (l <= 0) {
/* Send end-of-file marker */
io_filesfrom_buf[0] = '\0';
io_filesfrom_buf[1] = '\0';
io_filesfrom_buflen = io_filesfrom_lastchar? 2 : 1;
io_filesfrom_f_in = -1;
} else {
extern int eol_nulls;
if (!eol_nulls) {
char *s = io_filesfrom_buf + l;
/* Transform CR and/or LF into '\0' */
while (s-- > io_filesfrom_buf) {
if (*s == '\n' || *s == '\r')
*s = '\0';
}
}
if (!io_filesfrom_lastchar) {
/* Last buf ended with a '\0', so don't
* let this buf start with one. */
while (l && !*io_filesfrom_bp)
io_filesfrom_bp++, l--;
}
if (!l)
io_filesfrom_bp = io_filesfrom_buf;
else {
char *f = io_filesfrom_bp;
char *t = f;
char *eob = f + l;
/* Eliminate any multi-'\0' runs. */
while (f != eob) {
if (!(*t++ = *f++)) {
while (f != eob && !*f)
f++, l--;
}
}
io_filesfrom_lastchar = f[-1];
}
io_filesfrom_buflen = l;
}
}
}
}
if (!FD_ISSET(fd, &r_fds)) continue;
n = read(fd, buf, len);
@@ -218,26 +350,75 @@ static int read_timeout (int fd, char *buf, size_t len)
last_io = time(NULL);
continue;
} else if (n == 0) {
whine_about_eof ();
whine_about_eof();
return -1; /* doesn't return */
} else if (n == -1) {
if (errno == EINTR || errno == EWOULDBLOCK ||
errno == EAGAIN)
continue;
else
die_from_readerr (errno);
die_from_readerr(errno);
}
}
return ret;
}
/**
* Read a line into the "fname" buffer (which must be at least MAXPATHLEN
* characters long).
*/
int read_filesfrom_line(int fd, char *fname)
{
char ch, *s, *eob = fname + MAXPATHLEN - 1;
int cnt;
extern int io_timeout;
extern int eol_nulls;
extern char *remote_filesfrom_file;
int reading_remotely = remote_filesfrom_file != NULL;
int nulls = eol_nulls || reading_remotely;
start:
s = fname;
while (1) {
cnt = read(fd, &ch, 1);
if (cnt < 0 && (errno == EWOULDBLOCK
|| errno == EINTR || errno == EAGAIN)) {
struct timeval tv;
fd_set fds;
FD_ZERO(&fds);
FD_SET(fd, &fds);
tv.tv_sec = io_timeout? io_timeout : SELECT_TIMEOUT;
tv.tv_usec = 0;
if (!select(fd+1, &fds, NULL, NULL, &tv))
check_timeout();
continue;
}
if (cnt != 1)
break;
if (nulls? !ch : (ch == '\r' || ch == '\n')) {
/* Skip empty lines if reading locally. */
if (!reading_remotely && s == fname)
continue;
break;
}
if (s < eob)
*s++ = ch;
}
*s = '\0';
/* Dump comments. */
if (*fname == '#' || *fname == ';')
goto start;
return s - fname;
}
/*! Continue trying to read len bytes - don't return until len has
been read. */
static void read_loop (int fd, char *buf, size_t len)
/**
* Continue trying to read len bytes - don't return until len has been
* read.
**/
static void read_loop(int fd, char *buf, size_t len)
{
while (len) {
int n = read_timeout(fd, buf, len);
@@ -288,9 +469,9 @@ static int read_unbuffered(int fd, char *buf, size_t len)
exit_cleanup(RERR_STREAMIO);
}
if (remaining > sizeof(line) - 1) {
rprintf(FERROR, "multiplexing overflow %d\n\n",
remaining);
if (remaining > sizeof line - 1) {
rprintf(FERROR, "multiplexing overflow %ld\n\n",
(long)remaining);
exit_cleanup(RERR_STREAMIO);
}
@@ -306,17 +487,20 @@ static int read_unbuffered(int fd, char *buf, size_t len)
/* do a buffered read from fd. don't return until all N bytes
have been read. If all N can't be read then exit with an error */
static void readfd (int fd, char *buffer, size_t N)
/**
* Do a buffered read from @p fd. Don't return until all @p n bytes
* have been read. If all @p n can't be read then exit with an
* error.
**/
static void readfd(int fd, char *buffer, size_t N)
{
int ret;
size_t total=0;
while (total < N) {
io_flush();
ret = read_unbuffered (fd, buffer + total, N-total);
ret = read_unbuffered(fd, buffer + total, N-total);
total += ret;
}
@@ -337,7 +521,6 @@ int32 read_int(int f)
int64 read_longint(int f)
{
extern int remote_version;
int64 ret;
char b[8];
ret = read_int(f);
@@ -350,10 +533,8 @@ int64 read_longint(int f)
rprintf(FERROR,"Integer overflow - attempted 64 bit offset\n");
exit_cleanup(RERR_UNSUPPORTED);
#else
if (remote_version >= 16) {
readfd(f,b,8);
ret = IVAL(b,0) | (((int64)IVAL(b,4))<<32);
}
readfd(f,b,8);
ret = IVAL(b,0) | (((int64)IVAL(b,4))<<32);
#endif
return ret;
@@ -366,18 +547,51 @@ void read_buf(int f,char *buf,size_t len)
void read_sbuf(int f,char *buf,size_t len)
{
read_buf (f,buf,len);
read_buf(f,buf,len);
buf[len] = 0;
}
unsigned char read_byte(int f)
{
unsigned char c;
read_buf (f, (char *)&c, 1);
read_buf(f, (char *)&c, 1);
return c;
}
/* write len bytes to fd */
/**
* Sleep after writing to limit I/O bandwidth usage.
*
* @todo Rather than sleeping after each write, it might be better to
* use some kind of averaging. The current algorithm seems to always
* use a bit less bandwidth than specified, because it doesn't make up
* for slow periods. But arguably this is a feature. In addition, we
* ought to take the time used to write the data into account.
**/
static void sleep_for_bwlimit(int bytes_written)
{
struct timeval tv;
if (!bwlimit)
return;
assert(bytes_written > 0);
assert(bwlimit > 0);
tv.tv_usec = bytes_written * 1000 / bwlimit;
tv.tv_sec = tv.tv_usec / 1000000;
tv.tv_usec = tv.tv_usec % 1000000;
select(0, NULL, NULL, NULL, &tv);
}
/**
* Write len bytes to the file descriptor @p fd.
*
* This function underlies the multiplexing system. The body of the
* application never calls this function directly.
**/
static void writefd_unbuffered(int fd,char *buf,size_t len)
{
size_t total = 0;
@@ -391,11 +605,11 @@ static void writefd_unbuffered(int fd,char *buf,size_t len)
while (total < len) {
FD_ZERO(&w_fds);
FD_ZERO(&r_fds);
FD_SET(fd,&w_fds);
fd_count = fd;
if (io_error_fd != -1) {
FD_ZERO(&r_fds);
FD_SET(io_error_fd,&r_fds);
if (io_error_fd > fd_count)
fd_count = io_error_fd;
@@ -442,25 +656,17 @@ static void writefd_unbuffered(int fd,char *buf,size_t len)
}
if (ret <= 0) {
rprintf(FERROR,
"error writing %d unbuffered bytes"
" - exiting: %s\n", len,
/* Don't try to write errors back
* across the stream */
io_multiplexing_close();
rprintf(FERROR, RSYNC_NAME
": writefd_unbuffered failed to write %ld bytes: phase \"%s\": %s\n",
(long) len, io_write_phase,
strerror(errno));
exit_cleanup(RERR_STREAMIO);
}
/* Sleep after writing to limit I/O bandwidth */
if (bwlimit)
{
tv.tv_sec = 0;
tv.tv_usec = ret * 1000 / bwlimit;
while (tv.tv_usec > 1000000)
{
tv.tv_sec++;
tv.tv_usec -= 1000000;
}
select(0, NULL, NULL, NULL, &tv);
}
sleep_for_bwlimit(ret);
total += ret;
@@ -480,13 +686,15 @@ void io_start_buffering(int fd)
{
if (io_buffer) return;
multiplex_out_fd = fd;
io_buffer = (char *)malloc(IO_BUFFER_SIZE);
io_buffer = new_array(char, IO_BUFFER_SIZE);
if (!io_buffer) out_of_memory("writefd");
io_buffer_count = 0;
}
/* write an message to a multiplexed stream. If this fails then rsync
exits */
/**
* Write an message to a multiplexed stream. If this fails then rsync
* exits.
**/
static void mplex_write(int fd, enum logcode code, char *buf, size_t len)
{
char buffer[4096];
@@ -494,8 +702,8 @@ static void mplex_write(int fd, enum logcode code, char *buf, size_t len)
SIVAL(buffer, 0, ((MPLEX_BASE + (int)code)<<24) + len);
if (n > (sizeof(buffer)-4)) {
n = sizeof(buffer)-4;
if (n > (sizeof buffer - 4)) {
n = sizeof buffer - 4;
}
memcpy(&buffer[4], buf, n);
@@ -527,8 +735,7 @@ void io_flush(void)
}
/* XXX: fd is ignored, which seems a little strange. */
void io_end_buffering(int fd)
void io_end_buffering(void)
{
io_flush();
if (!io_multiplexing_out) {
@@ -549,14 +756,14 @@ static void writefd(int fd,char *buf,size_t len)
}
while (len) {
int n = MIN(len, IO_BUFFER_SIZE-io_buffer_count);
int n = MIN((int) len, IO_BUFFER_SIZE-io_buffer_count);
if (n > 0) {
memcpy(io_buffer+io_buffer_count, buf, n);
buf += n;
len -= n;
io_buffer_count += n;
}
if (io_buffer_count == IO_BUFFER_SIZE) io_flush();
}
}
@@ -570,25 +777,37 @@ void write_int(int f,int32 x)
}
void write_int_named(int f, int32 x, const char *phase)
{
io_write_phase = phase;
write_int(f, x);
io_write_phase = phase_unknown;
}
/*
* Note: int64 may actually be a 32-bit type if ./configure couldn't find any
* 64-bit types on this platform.
*/
void write_longint(int f, int64 x)
{
extern int remote_version;
char b[8];
if (remote_version < 16 || x <= 0x7FFFFFFF) {
if (x <= 0x7FFFFFFF) {
write_int(f, (int)x);
return;
}
#ifdef NO_INT64
rprintf(FERROR,"Integer overflow - attempted 64 bit offset\n");
exit_cleanup(RERR_UNSUPPORTED);
#else
write_int(f, (int32)0xFFFFFFFF);
SIVAL(b,0,(x&0xFFFFFFFF));
SIVAL(b,4,((x>>32)&0xFFFFFFFF));
writefd(f,b,8);
#endif
}
void write_buf(int f,char *buf,size_t len)
@@ -596,7 +815,7 @@ void write_buf(int f,char *buf,size_t len)
writefd(f,buf,len);
}
/* write a string to the connection */
/** Write a string to the connection */
static void write_sbuf(int f,char *buf)
{
write_buf(f, buf, strlen(buf));
@@ -610,12 +829,19 @@ void write_byte(int f,unsigned char c)
/**
* Read a line of up to @p maxlen characters into @p buf. Does not
* contain a trailing newline or carriage return.
*
* @return 1 for success; 0 for io error or truncation.
**/
int read_line(int f, char *buf, size_t maxlen)
{
while (maxlen) {
buf[0] = 0;
read_buf(f, buf, 1);
if (buf[0] == 0) return 0;
if (buf[0] == 0)
return 0;
if (buf[0] == '\n') {
buf[0] = 0;
break;
@@ -639,9 +865,9 @@ void io_printf(int fd, const char *format, ...)
va_list ap;
char buf[1024];
int len;
va_start(ap, format);
len = vsnprintf(buf, sizeof(buf), format, ap);
len = vsnprintf(buf, sizeof buf, format, ap);
va_end(ap);
if (len < 0) exit_cleanup(RERR_STREAMIO);
@@ -650,7 +876,7 @@ void io_printf(int fd, const char *format, ...)
}
/* setup for multiplexing an error stream with the data stream */
/** Setup for multiplexing an error stream with the data stream */
void io_start_multiplex_out(int fd)
{
multiplex_out_fd = fd;
@@ -659,7 +885,7 @@ void io_start_multiplex_out(int fd)
io_multiplexing_out = 1;
}
/* setup for multiplexing an error stream with the data stream */
/** Setup for multiplexing an error stream with the data stream */
void io_start_multiplex_in(int fd)
{
multiplex_in_fd = fd;
@@ -667,7 +893,7 @@ void io_start_multiplex_in(int fd)
io_multiplexing_in = 1;
}
/* write an message to the multiplexed error stream */
/** Write an message to the multiplexed error stream */
int io_multiplex_write(enum logcode code, char *buf, size_t len)
{
if (!io_multiplexing_out) return 0;
@@ -678,7 +904,7 @@ int io_multiplex_write(enum logcode code, char *buf, size_t len)
return 1;
}
/* stop output multiplexing */
/** Stop output multiplexing */
void io_multiplexing_close(void)
{
io_multiplexing_out = 0;

View File

@@ -1,5 +1,6 @@
/*
Copyright (C) Andrew Tridgell 1998
Copyright (C) 2002 by Martin Pool
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -16,11 +17,15 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
compatibility functions - replacing functions for platforms that don't
have them.
/**
* @file compat.c
*
* Reimplementations of standard functions for platforms that don't
* have them.
**/
*/
#include "rsync.h"
@@ -78,9 +83,11 @@
#endif
#ifndef HAVE_STRPBRK
/* Find the first ocurrence in S of any character in ACCEPT.
derived from glibc
*/
/**
* Find the first ocurrence in @p s of any character in @p accept.
*
* Derived from glibc
**/
char *strpbrk(const char *s, const char *accept)
{
while (*s != '\0') {
@@ -97,10 +104,14 @@
#ifndef HAVE_STRLCPY
/* Like strncpy but does not 0 fill the buffer and always null
* terminates. bufsize is the size of the destination buffer.
/**
* Like strncpy but does not 0 fill the buffer and always null
* terminates.
*
* Returns the index of the terminating byte. */
* @param bufsize is the size of the destination buffer.
*
* @return index of the terminating byte.
**/
size_t strlcpy(char *d, const char *s, size_t bufsize)
{
size_t len = strlen(s);
@@ -114,9 +125,13 @@
#endif
#ifndef HAVE_STRLCAT
/* like strncat but does not 0 fill the buffer and always null
terminates. bufsize is the length of the buffer, which should
be one more than the maximum resulting string length */
/**
* Like strncat() but does not 0 fill the buffer and always null
* terminates.
*
* @param bufsize length of the buffer, which should be one more than
* the maximum resulting string length.
**/
size_t strlcat(char *d, const char *s, size_t bufsize)
{
size_t len1 = strlen(d);

View File

@@ -1,482 +0,0 @@
#include "../rsync.h"
#ifndef HAVE_FNMATCH
/* ----- THE FOLLOWING UP TO 'END' is glibc-2.1.2 posix/fnmatch.c
except for the parts with '#if 0' */
/* Copyright (C) 1991, 92, 93, 96, 97, 98, 99 Free Software Foundation, Inc.
This file is part of the GNU C Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#if 0 /* header files included better by ../rsync.h */
#if HAVE_CONFIG_H
# include <config.h>
#endif
/* Enable GNU extensions in fnmatch.h. */
#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
#endif
#include <errno.h>
#include <fnmatch.h>
#include <ctype.h>
#if HAVE_STRING_H || defined _LIBC
# include <string.h>
#else
# include <strings.h>
#endif
#if defined STDC_HEADERS || defined _LIBC
# include <stdlib.h>
#endif
#endif /* 0 */
/* For platform which support the ISO C amendement 1 functionality we
support user defined character classes. */
#if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)
/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. */
# include <wchar.h>
# include <wctype.h>
#endif
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C
Library, but also included in many other GNU distributions. Compiling
and linking in this code is a waste when using the GNU C library
(especially if it is a shared library). Rather than having every GNU
program understand `configure --with-gnu-libc' and omit the object files,
it is simpler to just do this in the source for each such file. */
#if 1
# if defined STDC_HEADERS || !defined isascii
# define ISASCII(c) 1
# else
# define ISASCII(c) isascii(c)
# endif
#ifdef isblank
# define ISBLANK(c) (ISASCII (c) && isblank (c))
#else
# define ISBLANK(c) ((c) == ' ' || (c) == '\t')
#endif
#ifdef isgraph
# define ISGRAPH(c) (ISASCII (c) && isgraph (c))
#else
# define ISGRAPH(c) (ISASCII (c) && isprint (c) && !isspace (c))
#endif
#define ISPRINT(c) (ISASCII (c) && isprint (c))
#define ISDIGIT(c) (ISASCII (c) && isdigit (c))
#define ISALNUM(c) (ISASCII (c) && isalnum (c))
#define ISALPHA(c) (ISASCII (c) && isalpha (c))
#define ISCNTRL(c) (ISASCII (c) && iscntrl (c))
#define ISLOWER(c) (ISASCII (c) && islower (c))
#define ISPUNCT(c) (ISASCII (c) && ispunct (c))
#define ISSPACE(c) (ISASCII (c) && isspace (c))
#define ISUPPER(c) (ISASCII (c) && isupper (c))
#define ISXDIGIT(c) (ISASCII (c) && isxdigit (c))
# define STREQ(s1, s2) ((strcmp (s1, s2) == 0))
# if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)
/* The GNU C library provides support for user-defined character classes
and the functions from ISO C amendement 1. */
# ifdef CHARCLASS_NAME_MAX
# define CHAR_CLASS_MAX_LENGTH CHARCLASS_NAME_MAX
# else
/* This shouldn't happen but some implementation might still have this
problem. Use a reasonable default value. */
# define CHAR_CLASS_MAX_LENGTH 256
# endif
# ifdef _LIBC
# define IS_CHAR_CLASS(string) __wctype (string)
# else
# define IS_CHAR_CLASS(string) wctype (string)
# endif
# else
# define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */
# define IS_CHAR_CLASS(string) \
(STREQ (string, "alpha") || STREQ (string, "upper") \
|| STREQ (string, "lower") || STREQ (string, "digit") \
|| STREQ (string, "alnum") || STREQ (string, "xdigit") \
|| STREQ (string, "space") || STREQ (string, "print") \
|| STREQ (string, "punct") || STREQ (string, "graph") \
|| STREQ (string, "cntrl") || STREQ (string, "blank"))
# endif
/* Avoid depending on library functions or files
whose names are inconsistent. */
# if !defined _LIBC && !defined getenv
extern char *getenv ();
# endif
# ifndef errno
extern int errno;
# endif
/* Match STRING against the filename pattern PATTERN, returning zero if
it matches, nonzero if not. */
static int
#ifdef _LIBC
internal_function
#endif
internal_fnmatch (const char *pattern, const char *string,
int no_leading_period, int flags)
{
register const char *p = pattern, *n = string;
register unsigned char c;
/* Note that this evaluates C many times. */
# ifdef _LIBC
# define FOLD(c) ((flags & FNM_CASEFOLD) ? tolower (c) : (c))
# else
# define FOLD(c) ((flags & FNM_CASEFOLD) && ISUPPER (c) ? tolower (c) : (c))
# endif
while ((c = *p++) != '\0')
{
c = FOLD (c);
switch (c)
{
case '?':
if (*n == '\0')
return FNM_NOMATCH;
else if (*n == '/' && (flags & FNM_FILE_NAME))
return FNM_NOMATCH;
else if (*n == '.' && no_leading_period
&& (n == string
|| (n[-1] == '/' && (flags & FNM_FILE_NAME))))
return FNM_NOMATCH;
break;
case '\\':
if (!(flags & FNM_NOESCAPE))
{
c = *p++;
if (c == '\0')
/* Trailing \ loses. */
return FNM_NOMATCH;
c = FOLD (c);
}
if (FOLD ((unsigned char) *n) != c)
return FNM_NOMATCH;
break;
case '*':
if (*n == '.' && no_leading_period
&& (n == string
|| (n[-1] == '/' && (flags & FNM_FILE_NAME))))
return FNM_NOMATCH;
for (c = *p++; c == '?' || c == '*'; c = *p++)
{
if (*n == '/' && (flags & FNM_FILE_NAME))
/* A slash does not match a wildcard under FNM_FILE_NAME. */
return FNM_NOMATCH;
else if (c == '?')
{
/* A ? needs to match one character. */
if (*n == '\0')
/* There isn't another character; no match. */
return FNM_NOMATCH;
else
/* One character of the string is consumed in matching
this ? wildcard, so *??? won't match if there are
less than three characters. */
++n;
}
}
if (c == '\0')
/* The wildcard(s) is/are the last element of the pattern.
If the name is a file name and contains another slash
this does mean it cannot match. */
return ((flags & FNM_FILE_NAME) && strchr (n, '/') != NULL
? FNM_NOMATCH : 0);
else
{
const char *endp;
#if 0
endp = __strchrnul (n, (flags & FNM_FILE_NAME) ? '/' : '\0');
#else
/* replace call to internal glibc function with equivalent */
if (!(flags & FNM_FILE_NAME) || ((endp = strchr(n, '/')) == NULL))
endp = n + strlen(n);
#endif
if (c == '[')
{
int flags2 = ((flags & FNM_FILE_NAME)
? flags : (flags & ~FNM_PERIOD));
for (--p; n < endp; ++n)
if (internal_fnmatch (p, n,
(no_leading_period
&& (n == string
|| (n[-1] == '/'
&& (flags
& FNM_FILE_NAME)))),
flags2)
== 0)
return 0;
}
else if (c == '/' && (flags & FNM_FILE_NAME))
{
while (*n != '\0' && *n != '/')
++n;
if (*n == '/'
&& (internal_fnmatch (p, n + 1, flags & FNM_PERIOD,
flags) == 0))
return 0;
}
else
{
int flags2 = ((flags & FNM_FILE_NAME)
? flags : (flags & ~FNM_PERIOD));
if (c == '\\' && !(flags & FNM_NOESCAPE))
c = *p;
c = FOLD (c);
for (--p; n < endp; ++n)
if (FOLD ((unsigned char) *n) == c
&& (internal_fnmatch (p, n,
(no_leading_period
&& (n == string
|| (n[-1] == '/'
&& (flags
& FNM_FILE_NAME)))),
flags2) == 0))
return 0;
}
}
/* If we come here no match is possible with the wildcard. */
return FNM_NOMATCH;
case '[':
{
/* Nonzero if the sense of the character class is inverted. */
static int posixly_correct;
register int not;
char cold;
if (posixly_correct == 0)
posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1;
if (*n == '\0')
return FNM_NOMATCH;
if (*n == '.' && no_leading_period && (n == string
|| (n[-1] == '/'
&& (flags
& FNM_FILE_NAME))))
return FNM_NOMATCH;
if (*n == '/' && (flags & FNM_FILE_NAME))
/* `/' cannot be matched. */
return FNM_NOMATCH;
not = (*p == '!' || (posixly_correct < 0 && *p == '^'));
if (not)
++p;
c = *p++;
for (;;)
{
unsigned char fn = FOLD ((unsigned char) *n);
if (!(flags & FNM_NOESCAPE) && c == '\\')
{
if (*p == '\0')
return FNM_NOMATCH;
c = FOLD ((unsigned char) *p);
++p;
if (c == fn)
goto matched;
}
else if (c == '[' && *p == ':')
{
/* Leave room for the null. */
char str[CHAR_CLASS_MAX_LENGTH + 1];
size_t c1 = 0;
# if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)
wctype_t wt;
# endif
const char *startp = p;
for (;;)
{
if (c1 == CHAR_CLASS_MAX_LENGTH)
/* The name is too long and therefore the pattern
is ill-formed. */
return FNM_NOMATCH;
c = *++p;
if (c == ':' && p[1] == ']')
{
p += 2;
break;
}
if (c < 'a' || c >= 'z')
{
/* This cannot possibly be a character class name.
Match it as a normal range. */
p = startp;
c = '[';
goto normal_bracket;
}
str[c1++] = c;
}
str[c1] = '\0';
# if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)
wt = IS_CHAR_CLASS (str);
if (wt == 0)
/* Invalid character class name. */
return FNM_NOMATCH;
if (__iswctype (__btowc ((unsigned char) *n), wt))
goto matched;
# else
if ((STREQ (str, "alnum") && ISALNUM ((unsigned char) *n))
|| (STREQ (str, "alpha") && ISALPHA ((unsigned char) *n))
|| (STREQ (str, "blank") && ISBLANK ((unsigned char) *n))
|| (STREQ (str, "cntrl") && ISCNTRL ((unsigned char) *n))
|| (STREQ (str, "digit") && ISDIGIT ((unsigned char) *n))
|| (STREQ (str, "graph") && ISGRAPH ((unsigned char) *n))
|| (STREQ (str, "lower") && ISLOWER ((unsigned char) *n))
|| (STREQ (str, "print") && ISPRINT ((unsigned char) *n))
|| (STREQ (str, "punct") && ISPUNCT ((unsigned char) *n))
|| (STREQ (str, "space") && ISSPACE ((unsigned char) *n))
|| (STREQ (str, "upper") && ISUPPER ((unsigned char) *n))
|| (STREQ (str, "xdigit") && ISXDIGIT ((unsigned char) *n)))
goto matched;
# endif
}
else if (c == '\0')
/* [ (unterminated) loses. */
return FNM_NOMATCH;
else
{
normal_bracket:
if (FOLD (c) == fn)
goto matched;
cold = c;
c = *p++;
if (c == '-' && *p != ']')
{
/* It is a range. */
unsigned char cend = *p++;
if (!(flags & FNM_NOESCAPE) && cend == '\\')
cend = *p++;
if (cend == '\0')
return FNM_NOMATCH;
if (cold <= fn && fn <= FOLD (cend))
goto matched;
c = *p++;
}
}
if (c == ']')
break;
}
if (!not)
return FNM_NOMATCH;
break;
matched:
/* Skip the rest of the [...] that already matched. */
while (c != ']')
{
if (c == '\0')
/* [... (unterminated) loses. */
return FNM_NOMATCH;
c = *p++;
if (!(flags & FNM_NOESCAPE) && c == '\\')
{
if (*p == '\0')
return FNM_NOMATCH;
/* XXX 1003.2d11 is unclear if this is right. */
++p;
}
else if (c == '[' && *p == ':')
{
do
if (*++p == '\0')
return FNM_NOMATCH;
while (*p != ':' || p[1] == ']');
p += 2;
c = *p;
}
}
if (not)
return FNM_NOMATCH;
}
break;
default:
if (c != FOLD ((unsigned char) *n))
return FNM_NOMATCH;
}
++n;
}
if (*n == '\0')
return 0;
if ((flags & FNM_LEADING_DIR) && *n == '/')
/* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz". */
return 0;
return FNM_NOMATCH;
# undef FOLD
}
int
fnmatch (pattern, string, flags)
const char *pattern;
const char *string;
int flags;
{
return internal_fnmatch (pattern, string, flags & FNM_PERIOD, flags);
}
#endif /* _LIBC or not __GNU_LIBRARY__. */
/* ----- END glibc-2.1.2 posix/fnmatch.c */
#else /* HAVE_FNMATCH */
void fnmatch_dummy(void) {}
#endif

View File

@@ -1,88 +0,0 @@
/* Copyright (C) 1991, 92, 93, 96, 97, 98 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifndef _FNMATCH_H
#define _FNMATCH_H 1
#ifdef __cplusplus
extern "C" {
#endif
#if defined __cplusplus || (defined __STDC__ && __STDC__) || defined WINDOWS32
# if !defined __GLIBC__ || !defined __P
# undef __P
# define __P(protos) protos
# endif
#else /* Not C++ or ANSI C. */
# undef __P
# define __P(protos) ()
/* We can get away without defining `const' here only because in this file
it is used only inside the prototype for `fnmatch', which is elided in
non-ANSI C where `const' is problematical. */
#endif /* C++ or ANSI C. */
#ifndef const
# if (defined __STDC__ && __STDC__) || defined __cplusplus
# define __const const
# else
# define __const
# endif
#endif
/* We #undef these before defining them because some losing systems
(HP-UX A.08.07 for example) define these in <unistd.h>. */
#undef FNM_PATHNAME
#undef FNM_NOESCAPE
#undef FNM_PERIOD
/* Bits set in the FLAGS argument to `fnmatch'. */
#define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */
#define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */
#define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */
#ifndef FNM_FILE_NAME
# define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */
#endif
#ifndef FNM_LEADING_DIR
# define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */
#endif
#ifndef FNM_CASEFOLD
# define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */
#endif
/* Value returned by `fnmatch' if STRING does not match PATTERN. */
#define FNM_NOMATCH 1
/* This value is returned if the implementation does not support
`fnmatch'. Since this is not the case here it will never be
returned but the conformance test suites still require the symbol
to be defined. */
#ifdef _XOPEN_SOURCE
# define FNM_NOSYS (-1)
#endif
/* Match STRING against the filename pattern PATTERN,
returning zero if it matches, FNM_NOMATCH if not. */
extern int fnmatch __P ((__const char *__pattern, __const char *__string,
int __flags));
#ifdef __cplusplus
}
#endif
#endif /* fnmatch.h */

View File

@@ -27,10 +27,12 @@
*/
static int inet_pton4(const char *src, unsigned char *dst);
#ifdef INET6
static int inet_pton6(const char *src, unsigned char *dst);
#endif
/* int
* isc_net_pton(af, src, dst)
* inet_pton(af, src, dst)
* convert from presentation format (which usually means ASCII printable)
* to network format (which is usually some kind of binary format).
* return:

View File

@@ -109,29 +109,53 @@ void mdfour_begin(struct mdfour *md)
md->C = 0x98badcfe;
md->D = 0x10325476;
md->totalN = 0;
md->totalN2 = 0;
}
static void mdfour_tail(unsigned char *in, int n)
static void mdfour_tail(unsigned char *in, uint32 n)
{
unsigned char buf[128];
uint32 M[16];
uint32 b;
extern int protocol_version;
m->totalN += n;
b = m->totalN * 8;
/*
* Count total number of bits, modulo 2^64
*/
m->totalN += n << 3;
if (m->totalN < (n << 3)) {
m->totalN2++;
}
m->totalN2 += n >> 29;
memset(buf, 0, 128);
if (n) memcpy(buf, in, n);
buf[n] = 0x80;
if (n <= 55) {
copy4(buf+56, b);
copy4(buf+56, m->totalN);
/*
* Prior to protocol version 27 only the number of bits
* modulo 2^32 was included. MD4 requires the number
* of bits modulo 2^64, which was fixed starting with
* protocol version 27.
*/
if (protocol_version >= 27) {
copy4(buf+60, m->totalN2);
}
copy64(M, buf);
mdfour64(M);
} else {
copy4(buf+120, b);
copy4(buf+120, m->totalN);
/*
* Prior to protocol version 27 only the number of bits
* modulo 2^32 was included. MD4 requires the number
* of bits modulo 2^64, which was fixed starting with
* protocol version 27.
*/
if (protocol_version >= 27) {
copy4(buf+124, m->totalN2);
}
copy64(M, buf);
mdfour64(M);
copy64(M, buf+64);
@@ -139,20 +163,23 @@ static void mdfour_tail(unsigned char *in, int n)
}
}
void mdfour_update(struct mdfour *md, unsigned char *in, int n)
void mdfour_update(struct mdfour *md, unsigned char *in, uint32 n)
{
uint32 M[16];
if (n == 0) mdfour_tail(in, n);
m = md;
if (n == 0) mdfour_tail(in, n);
while (n >= 64) {
copy64(M, in);
mdfour64(M);
in += 64;
n -= 64;
m->totalN += 64;
m->totalN += 64 << 3;
if (m->totalN < 64 << 3) {
m->totalN2++;
}
}
if (n) mdfour_tail(in, n);

View File

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

View File

@@ -47,8 +47,10 @@ 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';

View File

@@ -53,6 +53,9 @@
* got rid of fcvt code (twas buggy and made testing harder)
* added C99 semantics
*
* Paul Green (paulg@samba.org) April 9, 2003
* fixed handling of %f when converting fractions with leading zeros.
* (e.g., 0.025).
**************************************************************/
#ifndef NO_CONFIG_H /* for some tests */
@@ -725,15 +728,15 @@ static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
if (max > 0) {
dopr_outch (buffer, currlen, maxlen, '.');
while (zpadlen > 0) {
dopr_outch (buffer, currlen, maxlen, '0');
--zpadlen;
}
while (fplace > 0)
dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]);
}
while (zpadlen > 0) {
dopr_outch (buffer, currlen, maxlen, '0');
--zpadlen;
}
while (padlen < 0) {
dopr_outch (buffer, currlen, maxlen, ' ');
++padlen;
@@ -749,13 +752,15 @@ static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c)
}
#if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
int vsnprintf (char *str, size_t count, const char *fmt, va_list args)
#define vsnprintf rsync_vsnprintf
int vsnprintf(char *str, size_t count, const char *fmt, va_list args)
{
return dopr(str, count, fmt, args);
}
#endif
#if !defined(HAVE_SNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
#define snprintf rsync_snprintf
int snprintf(char *str,size_t count,const char *fmt,...)
{
size_t ret;

229
lib/wildmatch.c Normal file
View File

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

3
lib/wildmatch.h Normal file
View File

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

View File

@@ -3,20 +3,20 @@
/* some fixes
*
* Copyright (C) 2001 by Martin Pool <mbp@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.
@@ -36,7 +36,7 @@
* 3) add it to the list of available functions (eg: using FN_GLOBAL_STRING())
* 4) If it's a global then initialise it in init_globals. If a local
* (ie. service) parameter then initialise it in the sDefault structure
*
*
*
* Notes:
* The configuration file is processed sequentially for speed. It is NOT
@@ -48,6 +48,8 @@
*
*/
/* TODO: Parameter to set debug level on server. */
#include "rsync.h"
#define PTR_DIFF(p1,p2) ((ptrdiff_t)(((char *)(p1)) - (char *)(p2)))
#define strequal(a,b) (strcasecmp(a,b)==0)
@@ -59,7 +61,7 @@ typedef char pstring[1024];
typedef enum
{
P_BOOL,P_BOOLREV,P_CHAR,P_INTEGER,P_OCTAL,
P_STRING,P_GSTRING,P_ENUM,P_SEP
P_PATH,P_STRING,P_GSTRING,P_ENUM,P_SEP
} parm_type;
typedef enum
@@ -91,7 +93,7 @@ struct parm_struct
#define iSERVICE(i) (*pSERVICE(i))
#define LP_SNUM_OK(iService) (((iService) >= 0) && ((iService) < iNumServices))
/*
/*
* This structure describes global (ie., server-wide) parameters.
*/
typedef struct
@@ -107,8 +109,8 @@ static global Globals;
/*
* This structure describes a single service.
/*
* This structure describes a single service.
*/
typedef struct
{
@@ -142,7 +144,7 @@ typedef struct
/* This is a default service used to prime a services structure */
static service sDefault =
static service sDefault =
{
NULL, /* name */
NULL, /* path */
@@ -154,7 +156,16 @@ static service sDefault =
False, /* transfer logging */
False, /* ignore errors */
"nobody",/* uid */
/* 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 */
NULL, /* hosts allow */
NULL, /* hosts deny */
NULL, /* auth users */
@@ -211,7 +222,7 @@ static struct enum_list enum_facilities[] = {
{ LOG_NEWS, "news" },
#endif
#ifdef LOG_AUTH
{ LOG_AUTH, "security" },
{ LOG_AUTH, "security" },
#endif
#ifdef LOG_SYSLOG
{ LOG_SYSLOG, "syslog" },
@@ -263,7 +274,7 @@ static struct parm_struct parm_table[] =
{"name", P_STRING, P_LOCAL, &sDefault.name, NULL, 0},
{"comment", P_STRING, P_LOCAL, &sDefault.comment, NULL, 0},
{"lock file", P_STRING, P_LOCAL, &sDefault.lock_file, NULL, 0},
{"path", P_STRING, P_LOCAL, &sDefault.path, NULL, 0},
{"path", P_PATH, P_LOCAL, &sDefault.path, NULL, 0},
{"read only", P_BOOL, P_LOCAL, &sDefault.read_only, NULL, 0},
{"list", P_BOOL, P_LOCAL, &sDefault.list, NULL, 0},
{"use chroot", P_BOOL, P_LOCAL, &sDefault.use_chroot, NULL, 0},
@@ -308,8 +319,8 @@ static void init_locals(void)
/*
In this section all the functions that are used to access the
parameters from the rest of the program are defined
In this section all the functions that are used to access the
parameters from the rest of the program are defined
*/
#define FN_GLOBAL_STRING(fn_name,ptr) \
@@ -365,12 +376,11 @@ FN_LOCAL_INTEGER(lp_timeout, timeout)
FN_LOCAL_INTEGER(lp_max_connections, max_connections)
/* local prototypes */
static int strwicmp( char *psz1, char *psz2 );
static int map_parameter( char *parmname);
static BOOL set_boolean( BOOL *pb, char *parmvalue );
static int strwicmp(char *psz1, char *psz2);
static int map_parameter(char *parmname);
static BOOL set_boolean(BOOL *pb, char *parmvalue);
static int getservicebyname(char *name, service *pserviceDest);
static void copy_service( service *pserviceDest,
service *pserviceSource);
static void copy_service(service *pserviceDest, service *pserviceSource);
static BOOL do_parameter(char *parmname, char *parmvalue);
static BOOL do_section(char *sectionname);
@@ -410,7 +420,7 @@ static void string_set(char **s, const char *v)
/***************************************************************************
add a new service to the services array initialising it with the given
add a new service to the services array initialising it with the given
service
***************************************************************************/
static int add_a_service(service *pservice, char *name)
@@ -422,7 +432,7 @@ static int add_a_service(service *pservice, char *name)
tservice = *pservice;
/* it might already exist */
if (name)
if (name)
{
i = getservicebyname(name,NULL);
if (i >= 0)
@@ -431,10 +441,10 @@ static int add_a_service(service *pservice, char *name)
i = iNumServices;
ServicePtrs = (service **)Realloc(ServicePtrs,sizeof(service *)*num_to_alloc);
ServicePtrs = realloc_array(ServicePtrs, service *, num_to_alloc);
if (ServicePtrs)
pSERVICE(iNumServices) = (service *)malloc(sizeof(service));
pSERVICE(iNumServices) = new(service);
if (!ServicePtrs || !pSERVICE(iNumServices))
return(-1);
@@ -444,7 +454,7 @@ static int add_a_service(service *pservice, char *name)
init_service(pSERVICE(i));
copy_service(pSERVICE(i),&tservice);
if (name)
string_set(&iSERVICE(i).name,name);
string_set(&iSERVICE(i).name,name);
return(i);
}
@@ -468,11 +478,12 @@ static int strwicmp(char *psz1, char *psz2)
/* sync the strings on first non-whitespace */
while (1)
{
while (isspace(*psz1))
while (isspace(* (unsigned char *) psz1))
psz1++;
while (isspace(*psz2))
while (isspace(* (unsigned char *) psz2))
psz2++;
if (toupper(*psz1) != toupper(*psz2) || *psz1 == '\0' || *psz2 == '\0')
if (toupper(* (unsigned char *) psz1) != toupper(* (unsigned char *) psz2)
|| *psz1 == '\0' || *psz2 == '\0')
break;
psz1++;
psz2++;
@@ -481,7 +492,7 @@ static int strwicmp(char *psz1, char *psz2)
}
/***************************************************************************
Map a parameter's string representation to something we can use.
Map a parameter's string representation to something we can use.
Returns False if the parameter string is not recognised, else TRUE.
***************************************************************************/
static int map_parameter(char *parmname)
@@ -491,7 +502,7 @@ static int map_parameter(char *parmname)
if (*parmname == '-')
return(-1);
for (iIndex = 0; parm_table[iIndex].label; iIndex++)
for (iIndex = 0; parm_table[iIndex].label; iIndex++)
if (strwicmp(parm_table[iIndex].label, parmname) == 0)
return(iIndex);
@@ -502,7 +513,7 @@ static int map_parameter(char *parmname)
/***************************************************************************
Set a boolean variable from the text value stored in the passed string.
Returns True in success, False if the passed string does not correctly
Returns True in success, False if the passed string does not correctly
represent a boolean.
***************************************************************************/
static BOOL set_boolean(BOOL *pb, char *parmvalue)
@@ -536,7 +547,7 @@ static int getservicebyname(char *name, service *pserviceDest)
int iService;
for (iService = iNumServices - 1; iService >= 0; iService--)
if (strwicmp(iSERVICE(iService).name, name) == 0)
if (strwicmp(iSERVICE(iService).name, name) == 0)
{
if (pserviceDest != NULL)
copy_service(pserviceDest, pSERVICE(iService));
@@ -552,7 +563,7 @@ static int getservicebyname(char *name, service *pserviceDest)
Copy a service structure to another
***************************************************************************/
static void copy_service(service *pserviceDest,
static void copy_service(service *pserviceDest,
service *pserviceSource)
{
int i;
@@ -560,9 +571,9 @@ static void copy_service(service *pserviceDest,
for (i=0;parm_table[i].label;i++)
if (parm_table[i].ptr && parm_table[i].class == P_LOCAL) {
void *def_ptr = parm_table[i].ptr;
void *src_ptr =
void *src_ptr =
((char *)pserviceSource) + PTR_DIFF(def_ptr,&sDefault);
void *dest_ptr =
void *dest_ptr =
((char *)pserviceDest) + PTR_DIFF(def_ptr,&sDefault);
switch (parm_table[i].type)
@@ -582,6 +593,7 @@ static void copy_service(service *pserviceDest,
*(char *)dest_ptr = *(char *)src_ptr;
break;
case P_PATH:
case P_STRING:
string_set(dest_ptr,*(char **)src_ptr);
break;
@@ -602,6 +614,7 @@ static BOOL lp_do_parameter(int snum, char *parmname, char *parmvalue)
int parmnum, i;
void *parm_ptr=NULL; /* where we are going to store the result */
void *def_ptr=NULL;
char *cp;
parmnum = map_parameter(parmname);
@@ -648,6 +661,15 @@ static BOOL lp_do_parameter(int snum, char *parmname, char *parmvalue)
sscanf(parmvalue,"%o",(int *)parm_ptr);
break;
case P_PATH:
string_set(parm_ptr,parmvalue);
if ((cp = *(char**)parm_ptr) != NULL) {
int len = strlen(cp);
while (len > 1 && cp[len-1] == '/') len--;
cp[len] = '\0';
}
break;
case P_STRING:
string_set(parm_ptr,parmvalue);
break;
@@ -699,7 +721,7 @@ static BOOL do_section(char *sectionname)
init_locals();
/* if we've just struck a global section, note the fact. */
bInGlobalSection = isglobal;
bInGlobalSection = isglobal;
/* check for multiple global sections */
if (bInGlobalSection)
@@ -731,26 +753,34 @@ static BOOL do_section(char *sectionname)
/***************************************************************************
Load the services array from the services file. Return True on success,
Load the services array from the services file. Return True on success,
False on failure.
***************************************************************************/
BOOL lp_load(char *pszFname, int globals_only)
{
extern int am_server;
extern int am_daemon;
extern int am_root;
pstring n2;
BOOL bRetval;
bRetval = False;
bInGlobalSection = True;
init_globals();
pstrcpy(n2,pszFname);
if (pszFname)
pstrcpy(n2,pszFname);
else if (am_server && am_daemon && !am_root)
pstrcpy(n2,RSYNCD_USERCONF);
else
pstrcpy(n2,RSYNCD_SYSCONF);
/* We get sections first, so have to start 'behind' to make up */
iServiceIndex = -1;
bRetval = pm_process(n2, globals_only?NULL:do_section, do_parameter);
return (bRetval);
}
@@ -774,7 +804,7 @@ int lp_number(char *name)
int iService;
for (iService = iNumServices - 1; iService >= 0; iService--)
if (strequal(lp_name(iService), name))
if (strequal(lp_name(iService), name))
break;
return (iService);

216
log.c
View File

@@ -1,18 +1,18 @@
/* -*- c-file-style: "linux"; -*-
Copyright (C) 1998-2001 by Andrew Tridgell <tridge@samba.org>
Copyright (C) 2000-2001 by Martin Pool <mbp@samba.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -27,9 +27,11 @@
*/
#include "rsync.h"
static int log_initialised;
static char *logfname;
static FILE *logfile;
static int log_error_fd = -1;
struct stats stats;
int log_got_error=0;
@@ -37,25 +39,27 @@ struct {
int code;
char const *name;
} const rerr_names[] = {
{ RERR_SYNTAX , "syntax or usage error" },
{ RERR_PROTOCOL , "protocol incompatibility" },
{ RERR_FILESELECT , "errors selecting input/output files, dirs" },
{ RERR_UNSUPPORTED, "requested action not supported" },
{ RERR_SOCKETIO , "error in socket IO" },
{ RERR_FILEIO , "error in file IO" },
{ RERR_STREAMIO , "error in rsync protocol data stream" },
{ RERR_MESSAGEIO , "errors with program diagnostics" },
{ RERR_IPC , "error in IPC code" },
{ RERR_SIGNAL , "received SIGUSR1 or SIGINT" },
{ RERR_WAITCHILD , "some error returned by waitpid()" },
{ RERR_MALLOC , "error allocating core memory buffers" },
{ RERR_PARTIAL , "partial transfer" },
{ RERR_TIMEOUT , "timeout in data send/receive" },
{ RERR_SYNTAX , "syntax or usage error" },
{ RERR_PROTOCOL , "protocol incompatibility" },
{ RERR_FILESELECT , "errors selecting input/output files, dirs" },
{ RERR_UNSUPPORTED, "requested action not supported" },
{ RERR_STARTCLIENT, "error starting client-server protocol" },
{ RERR_SOCKETIO , "error in socket IO" },
{ RERR_FILEIO , "error in file IO" },
{ RERR_STREAMIO , "error in rsync protocol data stream" },
{ RERR_MESSAGEIO , "errors with program diagnostics" },
{ RERR_IPC , "error in IPC code" },
{ RERR_SIGNAL , "received SIGUSR1 or SIGINT" },
{ RERR_WAITCHILD , "some error returned by waitpid()" },
{ RERR_MALLOC , "error allocating core memory buffers" },
{ RERR_PARTIAL , "some files could not be transferred" },
{ RERR_VANISHED , "some files vanished before they could be transfered" },
{ RERR_TIMEOUT , "timeout in data send/receive" },
{ RERR_CMD_FAILED , "remote shell failed" },
{ RERR_CMD_KILLED , "remote shell killed" },
{ RERR_CMD_RUN, "remote command could not be run" },
{ RERR_CMD_NOTFOUND, "remote command not found" },
{ 0, NULL }
{ RERR_CMD_NOTFOUND, "remote command not found" },
{ 0, NULL }
};
@@ -65,12 +69,12 @@ struct {
*/
static char const *rerr_name(int code)
{
int i;
for (i = 0; rerr_names[i].name; i++) {
if (rerr_names[i].code == code)
return rerr_names[i].name;
}
return NULL;
int i;
for (i = 0; rerr_names[i].name; i++) {
if (rerr_names[i].code == code)
return rerr_names[i].name;
}
return NULL;
}
struct err_list {
@@ -87,10 +91,10 @@ static struct err_list *err_list_tail;
static void err_list_add(int code, char *buf, int len)
{
struct err_list *el;
el = (struct err_list *)malloc(sizeof(*el));
el = new(struct err_list);
if (!el) exit_cleanup(RERR_MALLOC);
el->next = NULL;
el->buf = malloc(len+4);
el->buf = new_array(char, len+4);
if (!el->buf) exit_cleanup(RERR_MALLOC);
memcpy(el->buf+4, buf, len);
SIVAL(el->buf, 0, ((code+MPLEX_BASE)<<24) | len);
@@ -114,7 +118,7 @@ void err_list_push(void)
struct err_list *el = err_list_head;
int n = write(log_error_fd, el->buf+el->written, el->len - el->written);
/* don't check for an error if the best way of handling the error is
to ignore it */
* to ignore it */
if (n == -1) break;
if (n > 0) {
el->written += n;
@@ -134,7 +138,7 @@ static void logit(int priority, char *buf)
if (logfname) {
if (!logfile)
log_open();
fprintf(logfile,"%s [%d] %s",
fprintf(logfile,"%s [%d] %s",
timestring(time(NULL)), (int)getpid(), buf);
fflush(logfile);
} else {
@@ -144,16 +148,15 @@ static void logit(int priority, char *buf)
void log_init(void)
{
static int initialised;
int options = LOG_PID;
time_t t;
if (initialised) return;
initialised = 1;
if (log_initialised) return;
log_initialised = 1;
/* this looks pointless, but it is needed in order for the
C library on some systems to fetch the timezone info
before the chroot */
* C library on some systems to fetch the timezone info
* before the chroot */
t = time(NULL);
localtime(&t);
@@ -182,7 +185,7 @@ void log_init(void)
#endif
}
void log_open()
void log_open(void)
{
if (logfname && !logfile) {
extern int orig_umask;
@@ -192,7 +195,7 @@ void log_open()
}
}
void log_close()
void log_close(void)
{
if (logfile) {
fclose(logfile);
@@ -201,7 +204,7 @@ void log_close()
}
/* setup the error file descriptor - used when we are a server
that is receiving files */
* that is receiving files */
void set_error_fd(int fd)
{
log_error_fd = fd;
@@ -209,7 +212,7 @@ void set_error_fd(int fd)
}
/* this is the underlying (unformatted) rsync debugging function. Call
it with FINFO, FERROR or FLOG */
* it with FINFO, FERROR or FLOG */
void rwrite(enum logcode code, char *buf, int len)
{
FILE *f=NULL;
@@ -236,12 +239,22 @@ void rwrite(enum logcode code, char *buf, int len)
return;
}
/* if that fails, try to pass it to the other end */
/* next, if we are a server and multiplexing is enabled,
* pass it to the other side. */
if (am_server && io_multiplex_write(code, buf, len)) {
return;
}
if (am_daemon) {
/* otherwise, if in daemon mode and either we are not a server
* (that is, we are not running --daemon over a remote shell) or
* the log has already been initialised, log the message on this
* side because we don't want the client to see most errors for
* security reasons. We do want early messages when running daemon
* mode over a remote shell to go to the remote side; those will
* fall through to the next case.
* Note that this is only for the time before multiplexing is enabled.
*/
if (am_daemon && (!am_server || log_initialised)) {
static int depth;
int priority = LOG_INFO;
if (code == FERROR) priority = LOG_WARNING;
@@ -260,14 +273,14 @@ void rwrite(enum logcode code, char *buf, int len)
if (code == FERROR) {
log_got_error = 1;
f = stderr;
}
}
if (code == FINFO) {
if (am_server)
if (am_server)
f = stderr;
else
f = stdout;
}
}
if (!f) exit_cleanup(RERR_MESSAGEIO);
@@ -281,7 +294,7 @@ void rwrite(enum logcode code, char *buf, int len)
* FLOG. */
void rprintf(enum logcode code, const char *format, ...)
{
va_list ap;
va_list ap;
char buf[1024];
int len;
@@ -330,31 +343,33 @@ void rprintf(enum logcode code, const char *format, ...)
* message catalog we need to call it once before chroot-ing. */
void rsyserr(enum logcode code, int errcode, const char *format, ...)
{
va_list ap;
va_list ap;
char buf[1024];
int len;
size_t sys_len;
char *sysmsg;
char *sysmsg;
va_start(ap, format);
/* Note: might return <0 */
len = vsnprintf(buf, sizeof(buf), format, ap);
va_end(ap);
/* TODO: Put in RSYNC_NAME at the start. */
if ((size_t) len > sizeof(buf)-1)
exit_cleanup(RERR_MESSAGEIO);
sysmsg = strerror(errcode);
sys_len = strlen(sysmsg);
if ((size_t) len + 3 + sys_len > sizeof(buf) - 1)
exit_cleanup(RERR_MESSAGEIO);
sysmsg = strerror(errcode);
sys_len = strlen(sysmsg);
if ((size_t) len + 3 + sys_len > sizeof(buf) - 1)
exit_cleanup(RERR_MESSAGEIO);
strcpy(buf + len, ": ");
len += 2;
strcpy(buf + len, sysmsg);
len += sys_len;
strcpy(buf + len, "\n");
len++;
strcpy(buf + len, ": ");
len += 2;
strcpy(buf + len, sysmsg);
len += sys_len;
strcpy(buf + len, "\n");
len++;
rwrite(code, buf, len);
}
@@ -372,19 +387,19 @@ void rflush(enum logcode code)
if (code == FLOG) {
return;
}
}
if (code == FERROR) {
f = stderr;
}
}
if (code == FINFO) {
extern int am_server;
if (am_server)
if (am_server)
f = stderr;
else
f = stdout;
}
}
if (!f) exit_cleanup(RERR_MESSAGEIO);
fflush(f);
@@ -393,7 +408,7 @@ void rflush(enum logcode code)
/* a generic logging routine for send/recv, with parameter
substitiution */
* substitiution */
static void log_formatted(enum logcode code,
char *format, char *op, struct file_struct *file,
struct stats *initial_stats)
@@ -417,57 +432,56 @@ static void log_formatted(enum logcode code,
memset(buf, 0, sizeof buf);
strlcpy(buf, format, sizeof(buf));
for (s=&buf[0];
s && (p=strchr(s,'%')); ) {
for (s = &buf[0]; s && (p = strchr(s,'%')); ) {
n = NULL;
s = p + 1;
switch (p[1]) {
case 'h': if (am_daemon) n = client_name(0); break;
case 'a': if (am_daemon) n = client_addr(0); break;
case 'l':
snprintf(buf2,sizeof(buf2),"%.0f",
(double)file->length);
case 'l':
snprintf(buf2,sizeof(buf2),"%.0f",
(double)file->length);
n = buf2;
break;
case 'p':
snprintf(buf2,sizeof(buf2),"%d",
(int)getpid());
case 'p':
snprintf(buf2,sizeof(buf2),"%d",
(int)getpid());
n = buf2;
break;
case 'o': n = op; break;
case 'f':
snprintf(buf2, sizeof(buf2), "%s/%s",
file->basedir?file->basedir:"",
case 'f':
snprintf(buf2, sizeof(buf2), "%s/%s",
file->basedir?file->basedir:"",
f_name(file));
clean_fname(buf2);
n = buf2;
n = buf2;
if (*n == '/') n++;
break;
case 'm': n = lp_name(module_id); break;
case 't': n = timestring(time(NULL)); break;
case 'P': n = lp_path(module_id); break;
case 'u': n = auth_user; break;
case 'b':
case 'b':
if (am_sender) {
b = stats.total_written -
b = stats.total_written -
initial_stats->total_written;
} else {
b = stats.total_read -
b = stats.total_read -
initial_stats->total_read;
}
snprintf(buf2,sizeof(buf2),"%.0f", (double)b);
snprintf(buf2,sizeof(buf2),"%.0f", (double)b);
n = buf2;
break;
case 'c':
case 'c':
if (!am_sender) {
b = stats.total_written -
b = stats.total_written -
initial_stats->total_written;
} else {
b = stats.total_read -
b = stats.total_read -
initial_stats->total_read;
}
snprintf(buf2,sizeof(buf2),"%.0f", (double)b);
snprintf(buf2,sizeof(buf2),"%.0f", (double)b);
n = buf2;
break;
}
@@ -548,31 +562,19 @@ void log_exit(int code, const char *file, int line)
(double)stats.total_read,
(double)stats.total_size);
} else {
const char *name;
const char *name;
name = rerr_name(code);
if (!name)
name = "unexplained error";
rprintf(FERROR,"rsync error: %s (code %d) at %s(%d)\n",
name, code, file, line);
name = rerr_name(code);
if (!name)
name = "unexplained error";
/* VANISHED is not an error, only a warning */
if (code == RERR_VANISHED) {
rprintf(FINFO, "rsync warning: %s (code %d) at %s(%d)\n",
name, code, file, line);
} else {
rprintf(FERROR, "rsync error: %s (code %d) at %s(%d)\n",
name, code, file, line);
}
}
}
/* log the incoming transfer of a file for interactive use, this
will be called at the end where the client was run
it i called when a file starts to be transferred
*/
void log_transfer(struct file_struct *file, const char *fname)
{
extern int verbose;
if (!verbose) return;
rprintf(FINFO,"%s\n", fname);
}

642
main.c
View File

File diff suppressed because it is too large Load Diff

186
match.c
View File

@@ -1,17 +1,17 @@
/*
/*
Copyright (C) Andrew Tridgell 1996
Copyright (C) Paul Mackerras 1996
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -19,12 +19,9 @@
#include "rsync.h"
extern int csum_length;
extern int verbose;
extern int am_server;
extern int remote_version;
extern int do_progress;
typedef unsigned short tag;
@@ -43,8 +40,8 @@ static int total_matches;
extern struct stats stats;
struct target {
tag t;
int i;
tag t;
int i;
};
static struct target *targets;
@@ -56,40 +53,51 @@ static int *tag_table;
static int compare_targets(struct target *t1,struct target *t2)
{
return((int)t1->t - (int)t2->t);
return (int)t1->t - (int)t2->t;
}
static void build_hash_table(struct sum_struct *s)
{
int i;
int i;
if (!tag_table)
tag_table = (int *)malloc(sizeof(tag_table[0])*TABLESIZE);
if (!tag_table)
tag_table = new_array(int, TABLESIZE);
targets = (struct target *)malloc(sizeof(targets[0])*s->count);
if (!tag_table || !targets)
out_of_memory("build_hash_table");
targets = new_array(struct target, s->count);
if (!tag_table || !targets)
out_of_memory("build_hash_table");
for (i=0;i<s->count;i++) {
targets[i].i = i;
targets[i].t = gettag(s->sums[i].sum1);
}
for (i = 0; i < (int)s->count; i++) {
targets[i].i = i;
targets[i].t = gettag(s->sums[i].sum1);
}
qsort(targets,s->count,sizeof(targets[0]),(int (*)())compare_targets);
qsort(targets,s->count,sizeof(targets[0]),(int (*)())compare_targets);
for (i=0;i<TABLESIZE;i++)
tag_table[i] = NULL_TAG;
for (i = 0; i < TABLESIZE; i++)
tag_table[i] = NULL_TAG;
for (i=s->count-1;i>=0;i--) {
tag_table[targets[i].t] = i;
}
for (i = s->count-1; i >= 0; i--)
tag_table[targets[i].t] = i;
}
static OFF_T last_match;
/**
* Transmit a literal and/or match token.
*
* This delightfully-named function is called either when we find a
* match and need to transmit all the unmatched data leading up to it,
* or when we get bored of accumulating literal data and just need to
* transmit it. As a result of this second case, it is called even if
* we have not matched at all!
*
* @param i If >0, the number of a matched token. If 0, indicates we
* have only literal data.
**/
static void matched(int f,struct sum_struct *s,struct map_struct *buf,
OFF_T offset,int i)
{
@@ -107,8 +115,8 @@ static void matched(int f,struct sum_struct *s,struct map_struct *buf,
stats.matched_data += s->sums[i].len;
n += s->sums[i].len;
}
for (j=0;j<n;j+=CHUNK_SIZE) {
for (j = 0; j < n; j += CHUNK_SIZE) {
int n1 = MIN(CHUNK_SIZE,n-j);
sum_update(map_ptr(buf,last_match+j,n1),n1);
}
@@ -119,7 +127,7 @@ static void matched(int f,struct sum_struct *s,struct map_struct *buf,
else
last_match = offset;
if (buf) {
if (buf && do_progress) {
show_progress(last_match, buf->file_size);
if (i == -1) end_progress(buf->file_size);
@@ -133,7 +141,7 @@ static void hash_search(int f,struct sum_struct *s,
OFF_T offset, end;
int j,k, last_i;
char sum2[SUM_LENGTH];
uint32 s1, s2, sum;
uint32 s1, s2, sum;
schar *map;
/* last_i is used to encourage adjacent matches, allowing the RLL coding of the
@@ -141,83 +149,84 @@ static void hash_search(int f,struct sum_struct *s,
last_i = -1;
if (verbose > 2)
rprintf(FINFO,"hash search b=%d len=%.0f\n",s->n,(double)len);
rprintf(FINFO,"hash search b=%ld len=%.0f\n",
(long) s->blength, (double)len);
k = MIN(len, (OFF_T)s->blength);
k = MIN(len, s->n);
map = (schar *)map_ptr(buf,0,k);
sum = get_checksum1((char *)map, k);
s1 = sum & 0xFFFF;
s2 = sum >> 16;
if (verbose > 3)
rprintf(FINFO, "sum=%.8x k=%d\n", sum, k);
offset = 0;
end = len + 1 - s->sums[s->count-1].len;
if (verbose > 3)
rprintf(FINFO,"hash search s->n=%d len=%.0f count=%d\n",
s->n,(double)len,s->count);
rprintf(FINFO, "hash search s->blength=%ld len=%.0f count=%ld\n",
(long) s->blength, (double) len, (long) s->count);
do {
tag t = gettag2(s1,s2);
int done_csum2 = 0;
j = tag_table[t];
if (verbose > 4)
rprintf(FINFO,"offset=%.0f sum=%08x\n",(double)offset,sum);
if (j == NULL_TAG) {
goto null_tag;
}
sum = (s1 & 0xffff) | (s2 << 16);
tag_hits++;
for (; j<s->count && targets[j].t == t; j++) {
for (; j < (int) s->count && targets[j].t == t; j++) {
int l, i = targets[j].i;
if (sum != s->sums[i].sum1) continue;
/* also make sure the two blocks are the same length */
l = MIN(s->n,len-offset);
if (l != s->sums[i].len) continue;
l = MIN((OFF_T)s->blength, len-offset);
if (l != s->sums[i].len) continue;
if (verbose > 3)
rprintf(FINFO,"potential match at %.0f target=%d %d sum=%08x\n",
(double)offset,j,i,sum);
if (!done_csum2) {
map = (schar *)map_ptr(buf,offset,l);
get_checksum2((char *)map,l,sum2);
done_csum2 = 1;
}
if (memcmp(sum2,s->sums[i].sum2,csum_length) != 0) {
if (memcmp(sum2,s->sums[i].sum2,s->s2length) != 0) {
false_alarms++;
continue;
}
/* we've found a match, but now check to see
if last_i can hint at a better match */
for (j++; j<s->count && targets[j].t == t; j++) {
* if last_i can hint at a better match */
for (j++; j < (int) s->count && targets[j].t == t; j++) {
int i2 = targets[j].i;
if (i2 == last_i + 1) {
if (sum != s->sums[i2].sum1) break;
if (memcmp(sum2,s->sums[i2].sum2,csum_length) != 0) break;
/* we've found an adjacent match - the RLL coder
will be happy */
if (memcmp(sum2,s->sums[i2].sum2,s->s2length) != 0) break;
/* we've found an adjacent match - the RLL coder
* will be happy */
i = i2;
break;
}
}
last_i = i;
matched(f,s,buf,offset,i);
offset += s->sums[i].len - 1;
k = MIN((len-offset), s->n);
k = MIN((OFF_T)s->blength, len-offset);
map = (schar *)map_ptr(buf,offset,k);
sum = get_checksum1((char *)map, k);
s1 = sum & 0xFFFF;
@@ -225,13 +234,13 @@ static void hash_search(int f,struct sum_struct *s,
matches++;
break;
}
null_tag:
/* Trim off the first byte from the checksum */
map = (schar *)map_ptr(buf,offset,k+1);
s1 -= map[0] + CHAR_OFFSET;
s2 -= k * (map[0]+CHAR_OFFSET);
/* Add on the next byte (if there is one) to the checksum */
if (k < (len-offset)) {
s1 += (map[k]+CHAR_OFFSET);
@@ -246,18 +255,33 @@ static void hash_search(int f,struct sum_struct *s,
match. The 3 reads are caused by the
running match, the checksum update and the
literal send. */
if (offset-last_match >= CHUNK_SIZE+s->n &&
(end-offset > CHUNK_SIZE)) {
matched(f,s,buf,offset - s->n, -2);
if (offset > last_match
&& offset-last_match >= CHUNK_SIZE+s->blength
&& end-offset > CHUNK_SIZE) {
matched(f,s,buf,offset - s->blength, -2);
}
} while (++offset < end);
matched(f,s,buf,len,-1);
map_ptr(buf,len-1,1);
}
void match_sums(int f,struct sum_struct *s,struct map_struct *buf,OFF_T len)
/**
* Scan through a origin file, looking for sections that match
* checksums from the generator, and transmit either literal or token
* data.
*
* Also calculates the MD4 checksum of the whole file, using the md
* accumulator. This is transmitted with the file as protection
* against corruption on the wire.
*
* @param s Checksums received from the generator. If <tt>s->count ==
* 0</tt>, then there are actually no checksums for this file.
*
* @param len Length of the file to send.
**/
void match_sums(int f, struct sum_struct *s, struct map_struct *buf, OFF_T len)
{
char file_sum[MD4_SUM_LENGTH];
extern int write_batch; /* dw */
@@ -265,25 +289,25 @@ void match_sums(int f,struct sum_struct *s,struct map_struct *buf,OFF_T len)
last_match = 0;
false_alarms = 0;
tag_hits = 0;
matches=0;
data_transfer=0;
matches = 0;
data_transfer = 0;
sum_init();
if (len > 0 && s->count>0) {
build_hash_table(s);
if (verbose > 2)
if (verbose > 2)
rprintf(FINFO,"built hash table\n");
hash_search(f,s,buf,len);
if (verbose > 2)
if (verbose > 2)
rprintf(FINFO,"done hash search\n");
} else {
OFF_T j;
/* by doing this in pieces we avoid too many seeks */
for (j=0;j<(len-CHUNK_SIZE);j+=CHUNK_SIZE) {
for (j = 0; j < len-CHUNK_SIZE; j += CHUNK_SIZE) {
int n1 = MIN(CHUNK_SIZE,(len-CHUNK_SIZE)-j);
matched(f,s,buf,j+n1,-2);
}
@@ -292,23 +316,21 @@ void match_sums(int f,struct sum_struct *s,struct map_struct *buf,OFF_T len)
sum_end(file_sum);
if (remote_version >= 14) {
if (verbose > 2)
rprintf(FINFO,"sending file_sum\n");
write_buf(f,file_sum,MD4_SUM_LENGTH);
if (write_batch) /* dw */
write_batch_delta_file(file_sum, MD4_SUM_LENGTH);
}
if (verbose > 2)
rprintf(FINFO,"sending file_sum\n");
write_buf(f,file_sum,MD4_SUM_LENGTH);
if (write_batch) /* dw */
write_batch_delta_file(file_sum, MD4_SUM_LENGTH);
if (targets) {
free(targets);
targets=NULL;
}
if (verbose > 2)
rprintf(FINFO, "false_alarms=%d tag_hits=%d matches=%d\n",
false_alarms, tag_hits, matches);
total_tag_hits += tag_hits;
total_false_alarms += false_alarms;
total_matches += matches;

703
options.c
View File

File diff suppressed because it is too large Load Diff

View File

@@ -1,10 +1,10 @@
Summary: Program for efficient remote updates of files.
Name: rsync
Version: 2.5.1
Version: 2.6.0
Release: 1
Copyright: GPL
Group: Applications/Networking
Source: ftp://samba.anu.edu.au/pub/rsync/rsync-2.5.1.tar.gz
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
@@ -21,11 +21,18 @@ A technical report describing the rsync algorithm is included with
this package.
%changelog
* Mon Sept 11 2000 John H Terpstra <jht@turbolinux.com>
* 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
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)
@@ -62,23 +69,25 @@ previous package(s).)
%setup
%build
./configure --prefix=/usr --mandir=/usr/share/man
./configure --prefix=/usr --mandir=%{_mandir}
make CFLAGS="$RPM_OPT_FLAGS"
strip rsync
%install
mkdir -p $RPM_BUILD_ROOT/usr/{bin,share/man/{man1,man5}}
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/usr/share/man/man1
install -m644 rsyncd.conf.5 $RPM_BUILD_ROOT/usr/share/man/man5
install -m644 rsync.1 $RPM_BUILD_ROOT/%{_mandir}/man1
install -m644 rsyncd.conf.5 $RPM_BUILD_ROOT/%{_mandir}/man5
%clean
rm -rf $RPM_BUILD_ROOT
%files
%attr(-,root,root) /usr/bin/rsync
%attr(-,root,root) /usr/share/man/man1/rsync.1
%attr(-,root,root) /usr/share/man/man5/rsyncd.conf.5
%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

View File

@@ -1,84 +0,0 @@
Summary: Program for efficient remote updates of files.
Name: rsync
Version: PVERSION
Release: PRELEASE
Copyright: GPL
Group: Applications/Networking
Source: ftp://samba.anu.edu.au/pub/rsync/rsync-PVERSION.tar.gz
URL: http://samba.anu.edu.au/rsync/
Packager: Andrew Tridgell <tridge@samba.anu.edu.au>
BuildRoot: /tmp/rsync
%description
rsync is a replacement for rcp that has many more features.
rsync uses the "rsync algorithm" which provides a very fast method for
bringing remote files into sync. It does this by sending just the
differences in the files across the link, without requiring that both
sets of files are present at one of the ends of the link beforehand.
A technical report describing the rsync algorithm is included with
this package.
%changelog
* Mon Sept 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).)
%prep
%setup
%build
./configure --prefix=/usr --mandir=/usr/share/man
make CFLAGS="$RPM_OPT_FLAGS"
strip rsync
%install
mkdir -p $RPM_BUILD_ROOT/usr/{bin,share/man/{man1,man5}}
install -m755 rsync $RPM_BUILD_ROOT/usr/bin
install -m644 rsync.1 $RPM_BUILD_ROOT/usr/share/man/man1
install -m644 rsyncd.conf.5 $RPM_BUILD_ROOT/usr/share/man/man5
%clean
rm -rf $RPM_BUILD_ROOT
%files
%attr(-,root,root) /usr/bin/rsync
%attr(-,root,root) /usr/share/man/man1/rsync.1
%attr(-,root,root) /usr/share/man/man5/rsyncd.conf.5
%attr(-,root,root) %doc tech_report.tex
%attr(-,root,root) %doc README
%attr(-,root,root) %doc COPYING

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

151
pipe.c Normal file
View File

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

View File

@@ -1,4 +1,7 @@
1.3 ->
1.5 -> 1.6
- add ability to perform callbacks for every, not just first, match.
1.3 -> 1.5
- heavy dose of const's
- poptParseArgvString() now NULL terminates the list

View File

@@ -5,7 +5,7 @@ to getopt(3), it contains a number of enhancements, including:
2) popt can parse arbitrary argv[] style arrays while
getopt(2) makes this quite difficult
3) popt allows users to alias command line arguments
4) popt provides convience functions for parsting strings
4) popt provides convience functions for parsing strings
into argv[] style arrays
popt is used by rpm, the Red Hat install program, and many other Red Hat

4
popt/README.rsync Normal file
View File

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

View File

@@ -1,104 +0,0 @@
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
configure:592: checking host system type
configure:613: checking target system type
configure:631: checking build system type
configure:665: checking for a BSD compatible install
configure:718: checking whether build environment is sane
configure:775: checking whether make sets ${MAKE}
configure:821: checking for working aclocal
configure:834: checking for working autoconf
configure:847: checking for working automake
configure:860: checking for working autoheader
configure:873: checking for working makeinfo
configure:891: checking for gcc
configure:1004: checking whether the C compiler (gcc ) works
configure:1020: gcc -o conftest conftest.c 1>&5
configure:1046: checking whether the C compiler (gcc ) is a cross-compiler
configure:1051: checking whether we are using GNU C
configure:1079: checking whether gcc accepts -g
configure:1111: checking for POSIXized ISC
configure:1135: checking for gcc
configure:1248: checking whether the C compiler (gcc -g -O2 ) works
configure:1264: gcc -o conftest -g -O2 conftest.c 1>&5
configure:1290: checking whether the C compiler (gcc -g -O2 ) is a cross-compiler
configure:1295: checking whether we are using GNU C
configure:1323: checking whether gcc accepts -g
configure:1355: checking how to run the C preprocessor
configure:1436: checking whether gcc needs -traditional
configure:1485: checking for gcc option to accept ANSI C
configure:1564: checking for function prototypes
configure:1795: checking for ranlib
configure:1834: checking for ld used by GCC
configure:1896: checking if the linker (/usr/bin/ld) is GNU ld
configure:1912: checking for BSD-compatible nm
configure:1948: checking whether ln -s works
ltconfig:603: checking for object suffix
ltconfig:604: gcc -c -g -O2 conftest.c 1>&5
ltconfig:629: checking for executable suffix
ltconfig:630: gcc -o conftest -g -O2 conftest.c 1>&5
ltconfig:776: checking if gcc PIC flag -fPIC works
ltconfig:777: gcc -c -g -O2 -fPIC -DPIC conftest.c 1>&5
ltconfig:829: checking if gcc supports -c -o file.o
ltconfig:830: gcc -c -g -O2 -o out/conftest2.o conftest.c 1>&5
ltconfig:862: checking if gcc supports -c -o file.lo
ltconfig:863: gcc -c -g -O2 -c -o conftest.lo conftest.c 1>&5
ltconfig:914: checking if gcc supports -fno-rtti -fno-exceptions
ltconfig:915: gcc -c -g -O2 -fno-rtti -fno-exceptions -c conftest.c conftest.c 1>&5
ltconfig:958: checking if gcc static flag -static works
ltconfig:959: gcc -o conftest -g -O2 -static conftest.c 1>&5
GNU ld version 2.10.91 (with BFD 2.10.91.0.2)
ltconfig:1635: checking if global_symbol_pipe works
ltconfig:1636: gcc -c -g -O2 conftest.c 1>&5
ltconfig:1639: eval "/usr/bin/nm -B conftest.o | sed -n -e 's/^.*[ ]\([ABCDGISTW]\)[ ][ ]*\(\)\([_A-Za-z][_A-Za-z0-9]*\)$/\1 \2\3 \3/p' > conftest.nm"
ltconfig:1691: gcc -o conftest -g -O2 -fno-builtin -fno-rtti -fno-exceptions conftest.c conftstm.o 1>&5
configure:2150: checking for a BSD compatible install
configure:2231: checking for alloca.h
configure:2231: checking for libintl.h
configure:2231: checking for mcheck.h
configure:2231: checking for unistd.h
configure:2268: checking for /usr/ucblib in LIBS
configure:2284: checking for GNU xgettext
configure:2294: checking for strerror
configure:2294: checking for mtrace
configure:2347: checking for setreuid
configure:2438: checking for working const
configure:2513: checking for inline
configure:2553: checking for off_t
configure:2586: checking for size_t
configure:2621: checking for working alloca.h
configure:2654: checking for alloca
configure:2856: checking for unistd.h
configure:2895: checking for getpagesize
configure:2948: checking for working mmap
configure:3124: checking for argz.h
configure:3124: checking for limits.h
configure:3124: checking for locale.h
configure:3124: checking for nl_types.h
configure:3124: checking for malloc.h
configure:3124: checking for string.h
configure:3124: checking for unistd.h
configure:3124: checking for sys/param.h
configure:3164: checking for getcwd
configure:3164: checking for munmap
configure:3164: checking for putenv
configure:3164: checking for setenv
configure:3164: checking for setlocale
configure:3164: checking for strchr
configure:3164: checking for strcasecmp
configure:3164: checking for strdup
configure:3164: checking for __argz_count
configure:3164: checking for __argz_stringify
configure:3164: checking for __argz_next
configure:3283: checking for LC_MESSAGES
configure:3316: checking whether NLS is requested
configure:3336: checking whether included gettext is requested
configure:3355: checking for libintl.h
configure:3382: checking for gettext in libc
configure:3508: checking for msgfmt
configure:3542: checking for dcgettext
configure:3597: checking for gmsgfmt
configure:3633: checking for xgettext
configure:3673: gcc -o conftest -Wall -g -O2 conftest.c 1>&5
configure:4131: checking for catalogs to be installed

View File

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

View File

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

View File

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,6 +1,10 @@
/* (C) 1998 Red Hat Software, Inc. -- Licensing details are in the COPYING
/** \ingroup popt
* \file popt/poptparse.c
*/
/* (C) 1998-2000 Red Hat, Inc. -- Licensing details are in the COPYING
file accompanying popt source distributions, available from
ftp://ftp.redhat.com/pub/code/popt */
ftp://ftp.rpm.org/pub/rpm/dist. */
#include "system.h"
@@ -14,6 +18,8 @@ int poptDupArgv(int argc, const char **argv,
char * dst;
int i;
if (argc <= 0 || argv == NULL) /* XXX can't happen */
return POPT_ERROR_NOARG;
for (i = 0; i < argc; i++) {
if (argv[i] == NULL)
return POPT_ERROR_NOARG;
@@ -21,17 +27,27 @@ int poptDupArgv(int argc, const char **argv,
}
dst = malloc(nb);
if (dst == NULL) /* XXX can't happen */
return POPT_ERROR_MALLOC;
argv2 = (void *) dst;
dst += (argc + 1) * sizeof(*argv);
/*@-branchstate@*/
for (i = 0; i < argc; i++) {
argv2[i] = dst;
dst += strlen(strcpy(dst, argv[i])) + 1;
}
/*@=branchstate@*/
argv2[argc] = NULL;
*argvPtr = argv2;
*argcPtr = argc;
if (argvPtr) {
*argvPtr = argv2;
} else {
free(argv2);
argv2 = NULL;
}
if (argcPtr)
*argcPtr = argc;
return 0;
}
@@ -43,31 +59,32 @@ int poptParseArgvString(const char * s, int * argcPtr, const char *** argvPtr)
const char ** argv = malloc(sizeof(*argv) * argvAlloced);
int argc = 0;
int buflen = strlen(s) + 1;
char *buf0 = calloc(buflen, 1);
char *buf = buf0;
char * buf = memset(alloca(buflen), 0, buflen);
int rc = POPT_ERROR_MALLOC;
if (argv == NULL) return rc;
argv[argc] = buf;
for (src = s; *src; src++) {
for (src = s; *src != '\0'; src++) {
if (quote == *src) {
quote = '\0';
} else if (quote) {
} else if (quote != '\0') {
if (*src == '\\') {
src++;
if (!*src) {
free(argv);
free(buf0);
return POPT_ERROR_BADQUOTE;
rc = POPT_ERROR_BADQUOTE;
goto exit;
}
if (*src != quote) *buf++ = '\\';
}
*buf++ = *src;
} else if (isspace(*src)) {
if (*argv[argc]) {
if (*argv[argc] != '\0') {
buf++, argc++;
if (argc == argvAlloced) {
argvAlloced += POPT_ARGV_ARRAY_GROW_DELTA;
argv = realloc(argv, sizeof(*argv) * argvAlloced);
if (argv == NULL) goto exit;
}
argv[argc] = buf;
}
@@ -75,18 +92,17 @@ int poptParseArgvString(const char * s, int * argcPtr, const char *** argvPtr)
case '"':
case '\'':
quote = *src;
break;
/*@switchbreak@*/ break;
case '\\':
src++;
if (!*src) {
free(argv);
free(buf0);
return POPT_ERROR_BADQUOTE;
rc = POPT_ERROR_BADQUOTE;
goto exit;
}
/*@fallthrough@*/
default:
*buf++ = *src;
break;
/*@switchbreak@*/ break;
}
}
@@ -94,9 +110,9 @@ int poptParseArgvString(const char * s, int * argcPtr, const char *** argvPtr)
argc++, buf++;
}
(void) poptDupArgv(argc, argv, argcPtr, argvPtr);
rc = poptDupArgv(argc, argv, argcPtr, argvPtr);
free(argv);
free(buf0);
return 0;
exit:
if (argv) free(argv);
return rc;
}

View File

@@ -25,6 +25,14 @@
#include <libc.h>
#endif
#if defined(__LCLINT__)
/*@-declundef -incondefs -redecl@*/ /* LCL: missing annotation */
/*@only@*/ void * alloca (size_t __size)
/*@ensures MaxSet(result) == (__size - 1) @*/
/*@*/;
/*@=declundef =incondefs =redecl@*/
#endif
/* AIX requires this to be the first thing in the file. */
#ifndef __GNUC__
# if HAVE_ALLOCA_H
@@ -33,8 +41,15 @@
# ifdef _AIX
#pragma alloca
# else
# ifndef alloca /* predefined by HP cc +Olibcalls */
# if HAVE_ALLOCA
# ifndef alloca /* predefined by HP cc +Olibcalls */
char *alloca ();
# endif
# else
# ifdef alloca
# undef alloca
# endif
# define alloca(sz) malloc(sz) /* Kludge this for now */
# endif
# endif
# endif
@@ -42,7 +57,10 @@ char *alloca ();
#define alloca __builtin_alloca
#endif
/*@only@*/ char * xstrdup (const char *str);
/*@-redecl -redef@*/
/*@mayexit@*/ /*@only@*/ char * xstrdup (const char *str)
/*@*/;
/*@=redecl =redef@*/
#if HAVE_MCHECK_H && defined(__GNUC__)
#define vmefail() (fprintf(stderr, "virtual memory exhausted.\n"), exit(EXIT_FAILURE), NULL)

119
progress.c Normal file
View File

@@ -0,0 +1,119 @@
/* -*- c-file-style: "linux" -*-
*
* Copyright (C) 1996-2000 by Andrew Tridgell
* Copyright (C) Paul Mackerras 1996
* Copyright (C) 2001, 2002 by Martin Pool <mbp@samba.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "rsync.h"
static OFF_T last_ofs;
static struct timeval print_time;
static struct timeval start_time;
static OFF_T start_ofs;
static unsigned long msdiff(struct timeval *t1, struct timeval *t2)
{
return (t2->tv_sec - t1->tv_sec) * 1000
+ (t2->tv_usec - t1->tv_usec) / 1000;
}
/**
* @param ofs Current position in file
* @param size Total size of file
* @param is_last True if this is the last time progress will be
* printed for this file, so we should output a newline. (Not
* necessarily the same as all bytes being received.)
**/
static void rprint_progress(OFF_T ofs, OFF_T size, struct timeval *now,
int is_last)
{
int pct = (ofs == size) ? 100 : (int)((100.0*ofs)/size);
unsigned long diff = msdiff(&start_time, now);
double rate = diff ? (double) (ofs-start_ofs) * 1000.0 / diff / 1024.0 : 0;
const char *units;
/* If we've finished transferring this file, show the time taken;
* otherwise show expected time to complete. That's kind of
* inconsistent, but people can probably cope. Hopefully we'll
* get more consistent and complete progress reporting soon. --
* mbp */
double remain = is_last ? (double) diff / 1000.0
: rate ? (double) (size-ofs) / rate / 1000.0 : 0.0;
int remain_h, remain_m, remain_s;
if (rate > 1024*1024) {
rate /= 1024.0 * 1024.0;
units = "GB/s";
} else if (rate > 1024) {
rate /= 1024.0;
units = "MB/s";
} else {
units = "kB/s";
}
remain_s = (int) remain % 60;
remain_m = (int) (remain / 60.0) % 60;
remain_h = (int) (remain / 3600.0);
rprintf(FINFO, "%12.0f %3d%% %7.2f%s %4d:%02d:%02d%s",
(double) ofs, pct, rate, units,
remain_h, remain_m, remain_s,
is_last ? "\n" : "\r");
}
void end_progress(OFF_T size)
{
extern int am_server;
if (!am_server) {
struct timeval now;
gettimeofday(&now, NULL);
rprint_progress(size, size, &now, True);
}
last_ofs = 0;
start_ofs = 0;
print_time.tv_sec = print_time.tv_usec = 0;
start_time.tv_sec = start_time.tv_usec = 0;
}
void show_progress(OFF_T ofs, OFF_T size)
{
extern int am_server;
struct timeval now;
if (!start_time.tv_sec) {
gettimeofday(&now, NULL);
start_time.tv_sec = now.tv_sec;
start_time.tv_usec = now.tv_usec;
start_ofs = ofs;
if (am_server)
return;
}
else {
if (am_server)
return;
gettimeofday(&now, NULL);
}
if (ofs > last_ofs + 1000 && msdiff(&print_time, &now) > 250) {
rprint_progress(ofs, size, &now, False);
last_ofs = ofs;
print_time.tv_sec = now.tv_sec;
print_time.tv_usec = now.tv_usec;
}
}

View File

@@ -1,18 +1,18 @@
/* -*- c-file-style: "linux" -*-
Copyright (C) 1996-2000 by Andrew Tridgell
Copyright (C) Paul Mackerras 1996
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -23,7 +23,7 @@
extern int verbose;
extern int recurse;
extern int delete_mode;
extern int remote_version;
extern int protocol_version;
extern int csum_length;
extern struct stats stats;
extern int dry_run;
@@ -35,7 +35,10 @@ extern int io_error;
extern char *tmpdir;
extern char *compare_dest;
extern int make_backups;
extern int do_progress;
extern char *backup_dir;
extern char *backup_suffix;
extern int backup_suffix_len;
static struct delete_list {
DEV64_T dev;
@@ -44,9 +47,9 @@ static struct delete_list {
static int dlist_len, dlist_alloc_len;
/* yuck! This function wouldn't have been necessary if I had the sorting
algorithm right. Unfortunately fixing the sorting algorithm would introduce
a backward incompatibility as file list indexes are sent over the link.
*/
* algorithm right. Unfortunately fixing the sorting algorithm would introduce
* a backward incompatibility as file list indexes are sent over the link.
*/
static int delete_already_done(struct file_list *flist,int j)
{
int i;
@@ -54,9 +57,9 @@ static int delete_already_done(struct file_list *flist,int j)
if (link_stat(f_name(flist->files[j]), &st)) return 1;
for (i=0;i<dlist_len;i++) {
for (i = 0; i < dlist_len; i++) {
if (st.st_ino == delete_list[i].inode &&
st.st_dev == delete_list[i].dev)
(DEV64_T)st.st_dev == delete_list[i].dev)
return 1;
}
@@ -67,7 +70,8 @@ static void add_delete_entry(struct file_struct *file)
{
if (dlist_len == dlist_alloc_len) {
dlist_alloc_len += 1024;
delete_list = (struct delete_list *)Realloc(delete_list, sizeof(delete_list[0])*dlist_alloc_len);
delete_list = realloc_array(delete_list, struct delete_list,
dlist_alloc_len);
if (!delete_list) out_of_memory("add_delete_entry");
}
@@ -79,31 +83,38 @@ static void add_delete_entry(struct file_struct *file)
rprintf(FINFO,"added %s to delete list\n", f_name(file));
}
static void delete_one(struct file_struct *f)
static void delete_one(char *fn, int is_dir)
{
if (!S_ISDIR(f->mode)) {
if (robust_unlink(f_name(f)) != 0) {
rprintf(FERROR,"delete_one: unlink %s: %s\n",f_name(f),strerror(errno));
if (!is_dir) {
if (robust_unlink(fn) != 0) {
rprintf(FERROR, "delete_one: unlink %s failed: %s\n",
full_fname(fn), strerror(errno));
} else if (verbose) {
rprintf(FINFO,"deleting %s\n",f_name(f));
rprintf(FINFO, "deleting %s\n", fn);
}
} else {
if (do_rmdir(f_name(f)) != 0) {
if (errno != ENOTEMPTY && errno != EEXIST)
rprintf(FERROR,"delete_one: rmdir %s: %s\n",
f_name(f), strerror(errno));
} else {
if (do_rmdir(fn) != 0) {
if (errno != ENOTEMPTY && errno != EEXIST) {
rprintf(FERROR, "delete_one: rmdir %s failed: %s\n",
full_fname(fn), strerror(errno));
}
} else if (verbose) {
rprintf(FINFO,"deleting directory %s\n",f_name(f));
rprintf(FINFO, "deleting directory %s\n", fn);
}
}
}
static int is_backup_file(char *fn)
{
int k = strlen(fn) - backup_suffix_len;
return k > 0 && strcmp(fn+k, backup_suffix) == 0;
}
/* this deletes any files on the receiving side that are not present
on the sending side. For version 1.6.4 I have changed the behaviour
to match more closely what most people seem to expect of this option */
* on the sending side. For version 1.6.4 I have changed the behaviour
* to match more closely what most people seem to expect of this option */
void delete_files(struct file_list *flist)
{
struct file_list *local_file_list;
@@ -123,10 +134,10 @@ void delete_files(struct file_list *flist)
}
for (j=0;j<flist->count;j++) {
if (!S_ISDIR(flist->files[j]->mode) ||
if (!S_ISDIR(flist->files[j]->mode) ||
!(flist->files[j]->flags & FLAG_DELETE)) continue;
if (remote_version < 19 &&
if (protocol_version < 19 &&
delete_already_done(flist, j)) continue;
name = strdup(f_name(flist->files[j]));
@@ -142,20 +153,20 @@ void delete_files(struct file_list *flist)
for (i=local_file_list->count-1;i>=0;i--) {
if (max_delete && deletion_count > max_delete) break;
if (!local_file_list->files[i]->basename) continue;
if (remote_version < 19 &&
if (protocol_version < 19 &&
S_ISDIR(local_file_list->files[i]->mode))
add_delete_entry(local_file_list->files[i]);
if (-1 == flist_find(flist,local_file_list->files[i])) {
char *f = f_name(local_file_list->files[i]);
int k = strlen(f) - strlen(backup_suffix);
/* Hi Andrew, do we really need to play with backup_suffix here? */
if (make_backups && ((k <= 0) ||
(strcmp(f+k,backup_suffix) != 0))) {
if (make_backups && (backup_dir || !is_backup_file(f))) {
(void) make_backup(f);
if (verbose)
rprintf(FINFO, "deleting %s\n", f);
} else {
deletion_count++;
delete_one(local_file_list->files[i]);
int mode = local_file_list->files[i]->mode;
delete_one(f, S_ISDIR(mode) != 0);
}
deletion_count++;
}
}
flist_free(local_file_list);
@@ -164,40 +175,63 @@ void delete_files(struct file_list *flist)
}
/*
* get_tmpname() - create a tmp filename for a given filename
*
* If a tmpdir is defined, use that as the directory to
* put it in. Otherwise, the tmp filename is in the same
* directory as the given name. Note that there may be no
* directory at all in the given name!
*
* The tmp filename is basically the given filename with a
* dot prepended, and .XXXXXX appended (for mkstemp() to
* put its unique gunk in). Take care to not exceed
* either the MAXPATHLEN or NAME_MAX, esp. the last, as
* the basename basically becomes 8 chars longer. In that
* case, the original name is shortened sufficiently to
* make it all fit.
*
* Of course, there's no real reason for the tmp name to
* look like the original, except to satisfy us humans.
* As long as it's unique, rsync will work.
*/
static int get_tmpname(char *fnametmp, char *fname)
{
char *f;
int length = 0;
int maxname;
/* open tmp file */
if (tmpdir) {
f = strrchr(fname,'/');
if (f == NULL)
f = fname;
else
f++;
if (strlen(tmpdir)+strlen(f)+10 > MAXPATHLEN) {
rprintf(FERROR,"filename too long\n");
return 0;
strlcpy(fnametmp, tmpdir, MAXPATHLEN - 2);
length = strlen(fnametmp);
fnametmp[length++] = '/';
fnametmp[length] = '\0'; /* always NULL terminated */
}
if ((f = strrchr(fname, '/')) != NULL) {
++f;
if (!tmpdir) {
length = f - fname;
/* copy up to and including the slash */
strlcpy(fnametmp, fname, length + 1);
}
snprintf(fnametmp,MAXPATHLEN, "%s/.%s.XXXXXX",tmpdir,f);
return 1;
}
} else {
f = fname;
}
fnametmp[length++] = '.';
fnametmp[length] = '\0'; /* always NULL terminated */
f = strrchr(fname,'/');
maxname = MIN(MAXPATHLEN - 7 - length, NAME_MAX - 8);
if (strlen(fname)+9 > MAXPATHLEN) {
rprintf(FERROR,"filename too long\n");
if (maxname < 1) {
rprintf(FERROR, "temporary filename too long: %s\n", fname);
fnametmp[0] = '\0';
return 0;
}
if (f) {
*f = 0;
snprintf(fnametmp,MAXPATHLEN,"%s/.%s.XXXXXX",
fname,f+1);
*f = '/';
} else {
snprintf(fnametmp,MAXPATHLEN,".%s.XXXXXX",fname);
}
strlcpy(fnametmp + length, f, maxname);
strcat(fnametmp + length, ".XXXXXX");
return 1;
}
@@ -207,23 +241,22 @@ static int receive_data(int f_in,struct map_struct *buf,int fd,char *fname,
OFF_T total_size)
{
int i;
unsigned int n,remainder,len,count;
struct sum_struct sum;
unsigned int len;
OFF_T offset = 0;
OFF_T offset2;
char *data;
static char file_sum1[MD4_SUM_LENGTH];
static char file_sum2[MD4_SUM_LENGTH];
char *map=NULL;
count = read_int(f_in);
n = read_int(f_in);
remainder = read_int(f_in);
sum_init();
for (i=recv_token(f_in,&data); i != 0; i=recv_token(f_in,&data)) {
show_progress(offset, total_size);
read_sum_head(f_in, &sum);
sum_init();
for (i=recv_token(f_in,&data); i != 0; i=recv_token(f_in,&data)) {
if (do_progress)
show_progress(offset, total_size);
if (i > 0) {
extern int cleanup_got_literal;
@@ -235,73 +268,73 @@ static int receive_data(int f_in,struct map_struct *buf,int fd,char *fname,
stats.literal_data += i;
cleanup_got_literal = 1;
sum_update(data,i);
if (fd != -1 && write_file(fd,data,i) != i) {
rprintf(FERROR,"write failed on %s : %s\n",fname,strerror(errno));
rprintf(FERROR, "write failed on %s: %s\n",
full_fname(fname), strerror(errno));
exit_cleanup(RERR_FILEIO);
}
offset += i;
continue;
}
}
i = -(i+1);
offset2 = i*(OFF_T)n;
len = n;
if (i == count-1 && remainder != 0)
len = remainder;
offset2 = i*(OFF_T)sum.blength;
len = sum.blength;
if (i == (int) sum.count-1 && sum.remainder != 0)
len = sum.remainder;
stats.matched_data += len;
if (verbose > 3)
rprintf(FINFO,"chunk[%d] of size %d at %.0f offset=%.0f\n",
i,len,(double)offset2,(double)offset);
if (buf) {
map = map_ptr(buf,offset2,len);
see_token(map, len);
sum_update(map,len);
}
if (fd != -1 && write_file(fd,map,len) != len) {
rprintf(FERROR,"write failed on %s : %s\n",
fname,strerror(errno));
if (fd != -1 && write_file(fd,map,len) != (int) len) {
rprintf(FERROR, "write failed on %s: %s\n",
full_fname(fname), strerror(errno));
exit_cleanup(RERR_FILEIO);
}
offset += len;
}
end_progress(total_size);
if (do_progress)
end_progress(total_size);
if (fd != -1 && offset > 0 && sparse_end(fd) != 0) {
rprintf(FERROR,"write failed on %s : %s\n",
fname,strerror(errno));
rprintf(FERROR, "write failed on %s: %s\n",
full_fname(fname), strerror(errno));
exit_cleanup(RERR_FILEIO);
}
sum_end(file_sum1);
if (remote_version >= 14) {
read_buf(f_in,file_sum2,MD4_SUM_LENGTH);
if (verbose > 2) {
rprintf(FINFO,"got file_sum\n");
}
if (fd != -1 &&
memcmp(file_sum1,file_sum2,MD4_SUM_LENGTH) != 0) {
return 0;
}
read_buf(f_in,file_sum2,MD4_SUM_LENGTH);
if (verbose > 2) {
rprintf(FINFO,"got file_sum\n");
}
if (fd != -1 && memcmp(file_sum1,file_sum2,MD4_SUM_LENGTH) != 0) {
return 0;
}
return 1;
}
/* main routine for receiver process. Receiver process runs on the
same host as the generator process. */
/**
* main routine for receiver process.
*
* Receiver process runs on the same host as the generator process. */
int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
{
{
int fd1,fd2;
STRUCT_STAT st;
char *fname;
@@ -314,21 +347,22 @@ int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
struct file_struct *file;
int phase=0;
int recv_ok;
extern struct stats stats;
extern struct stats stats;
extern int preserve_perms;
extern int delete_after;
extern int orig_umask;
struct stats initial_stats;
if (verbose > 2) {
rprintf(FINFO,"recv_files(%d) starting\n",flist->count);
}
while (1) {
while (1) {
cleanup_disable();
i = read_int(f_in);
if (i == -1) {
if (phase==0 && remote_version >= 13) {
if (phase==0) {
phase++;
csum_length = SUM_LENGTH;
if (verbose > 2)
@@ -340,7 +374,7 @@ int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
}
if (i < 0 || i >= flist->count) {
rprintf(FERROR,"Invalid file index %d in recv_files (count=%d)\n",
rprintf(FERROR,"Invalid file index %d in recv_files (count=%d)\n",
i, flist->count);
exit_cleanup(RERR_PROTOCOL);
}
@@ -355,8 +389,8 @@ int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
fname = local_name;
if (dry_run) {
if (!am_server) {
log_transfer(file, fname);
if (!am_server && verbose) { /* log transfer */
rprintf(FINFO, "%s\n", fname);
}
continue;
}
@@ -368,7 +402,7 @@ int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
fnamecmp = fname;
/* open the file */
/* open the file */
fd1 = do_open(fnamecmp, O_RDONLY, 0);
if ((fd1 == -1) && (compare_dest != NULL)) {
@@ -380,23 +414,36 @@ int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
}
if (fd1 != -1 && do_fstat(fd1,&st) != 0) {
rprintf(FERROR,"fstat %s : %s\n",fnamecmp,strerror(errno));
rprintf(FERROR, "fstat %s failed: %s\n",
full_fname(fnamecmp), strerror(errno));
receive_data(f_in,NULL,-1,NULL,file->length);
close(fd1);
continue;
}
if (fd1 != -1 && S_ISDIR(st.st_mode) && fnamecmp == fname) {
/* this special handling for directories
* wouldn't be necessary if robust_rename()
* and the underlying robust_unlink could cope
* with directories
*/
rprintf(FERROR,"recv_files: %s is a directory\n",
full_fname(fnamecmp));
receive_data(f_in, NULL, -1, NULL, file->length);
close(fd1);
continue;
}
if (fd1 != -1 && !S_ISREG(st.st_mode)) {
rprintf(FERROR,"%s : not a regular file (recv_files)\n",fnamecmp);
receive_data(f_in,NULL,-1,NULL,file->length);
close(fd1);
continue;
fd1 = -1;
buf = NULL;
}
if (fd1 != -1 && !preserve_perms) {
/* if the file exists already and we aren't perserving
presmissions then act as though the remote end sent
us the file permissions we already have */
/* if the file exists already and we aren't preserving
* permissions then act as though the remote end sent
* us the file permissions we already have */
file->mode = st.st_mode;
}
@@ -417,52 +464,47 @@ int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
strlcpy(template, fnametmp, sizeof(template));
/* we initially set the perms without the
setuid/setgid bits to ensure that there is no race
condition. They are then correctly updated after
the lchown. Thanks to snabb@epipe.fi for pointing
this out. We also set it initially without group
access because of a similar race condition. */
* setuid/setgid bits to ensure that there is no race
* condition. They are then correctly updated after
* the lchown. Thanks to snabb@epipe.fi for pointing
* this out. We also set it initially without group
* access because of a similar race condition. */
fd2 = do_mkstemp(fnametmp, file->mode & INITACCESSPERMS);
if (fd2 == -1) {
rprintf(FERROR,"mkstemp %s failed\n",fnametmp);
receive_data(f_in,buf,-1,NULL,file->length);
if (buf) unmap_file(buf);
continue;
}
/* in most cases parent directories will already exist
because their information should have been previously
transferred, but that may not be the case with -R */
if (fd2 == -1 && relative_paths && errno == ENOENT &&
create_directory_path(fnametmp) == 0) {
* because their information should have been previously
* transferred, but that may not be the case with -R */
if (fd2 == -1 && relative_paths && errno == ENOENT &&
create_directory_path(fnametmp, orig_umask) == 0) {
strlcpy(fnametmp, template, sizeof(fnametmp));
fd2 = do_mkstemp(fnametmp, file->mode & INITACCESSPERMS);
}
if (fd2 == -1) {
rprintf(FERROR,"cannot create %s : %s\n",fnametmp,strerror(errno));
rprintf(FERROR, "mkstemp %s failed: %s\n",
full_fname(fnametmp), strerror(errno));
receive_data(f_in,buf,-1,NULL,file->length);
if (buf) unmap_file(buf);
if (fd1 != -1) close(fd1);
continue;
}
cleanup_set(fnametmp, fname, file, buf, fd1, fd2);
if (!am_server) {
log_transfer(file, fname);
if (!am_server && verbose) { /* log transfer */
rprintf(FINFO, "%s\n", fname);
}
/* recv file data */
recv_ok = receive_data(f_in,buf,fd2,fname,file->length);
log_recv(file, &initial_stats);
if (buf) unmap_file(buf);
if (fd1 != -1) {
close(fd1);
}
close(fd2);
if (verbose > 2)
rprintf(FINFO,"renaming %s to %s\n",fnametmp,fname);
@@ -473,7 +515,7 @@ int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
if (!recv_ok) {
if (csum_length == SUM_LENGTH) {
rprintf(FERROR,"ERROR: file corruption in %s. File changed during transfer?\n",
fname);
full_fname(fname));
} else {
if (verbose > 1)
rprintf(FINFO,"redoing %s(%d)\n",fname,i);
@@ -491,8 +533,8 @@ int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
if (preserve_hard_links)
do_hard_links();
/* now we need to fix any directory permissions that were
modified during the transfer */
/* now we need to fix any directory permissions that were
* modified during the transfer */
for (i = 0; i < flist->count; i++) {
file = flist->files[i];
if (!file->basename || !S_ISDIR(file->mode)) continue;
@@ -501,7 +543,7 @@ int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
if (verbose > 2)
rprintf(FINFO,"recv_files finished\n");
return 0;
}

87
rsync.c
View File

@@ -1,17 +1,17 @@
/*
/*
Copyright (C) Andrew Tridgell 1996
Copyright (C) Paul Mackerras 1996
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -43,8 +43,8 @@ void free_sums(struct sum_struct *s)
/*
* delete a file or directory. If force_delete is set then delete
* recursively
* delete a file or directory. If force_delete is set then delete
* recursively
*/
int delete_file(char *fname)
{
@@ -67,29 +67,31 @@ int delete_file(char *fname)
if (!S_ISDIR(st.st_mode)) {
if (robust_unlink(fname) == 0 || errno == ENOENT) return 0;
rprintf(FERROR,"delete_file: unlink(%s) : %s\n", fname, strerror(errno));
rprintf(FERROR, "delete_file: unlink %s failed: %s\n",
full_fname(fname), strerror(errno));
return -1;
}
if (do_rmdir(fname) == 0 || errno == ENOENT) return 0;
if (!force_delete || !recurse ||
if (!force_delete || !recurse ||
(errno != ENOTEMPTY && errno != EEXIST)) {
rprintf(FERROR,"delete_file: rmdir(%s) : %s\n", fname, strerror(errno));
rprintf(FERROR, "delete_file: rmdir %s failed: %s\n",
full_fname(fname), strerror(errno));
return -1;
}
/* now we do a recsursive delete on the directory ... */
d = opendir(fname);
if (!d) {
rprintf(FERROR,"delete_file: opendir(%s): %s\n",
fname,strerror(errno));
rprintf(FERROR, "delete_file: opendir %s failed: %s\n",
full_fname(fname), strerror(errno));
return -1;
}
for (di=readdir(d); di; di=readdir(d)) {
for (errno = 0, di = readdir(d); di; errno = 0, di = readdir(d)) {
char *dname = d_name(di);
if (strcmp(dname,".")==0 ||
strcmp(dname,"..")==0)
if (strcmp(dname,".") == 0
|| strcmp(dname,"..") == 0)
continue;
snprintf(buf, sizeof(buf), "%s/%s", fname, dname);
if (verbose > 0)
@@ -98,12 +100,19 @@ int delete_file(char *fname)
closedir(d);
return -1;
}
}
}
if (errno) {
rprintf(FERROR, "delete_file: readdir %s failed: %s\n",
full_fname(fname), strerror(errno));
closedir(d);
return -1;
}
closedir(d);
if (do_rmdir(fname) != 0) {
rprintf(FERROR,"delete_file: rmdir(%s) : %s\n", fname, strerror(errno));
rprintf(FERROR, "delete_file: rmdir %s failed: %s\n",
full_fname(fname), strerror(errno));
return -1;
}
@@ -124,7 +133,7 @@ static int is_in_group(gid_t gid)
/* treat failure (-1) as if not member of any group */
ngroups = getgroups(0, 0);
if (ngroups > 0) {
gidset = (GETGROUPS_T *) malloc(ngroups * sizeof(GETGROUPS_T));
gidset = new_array(GETGROUPS_T, ngroups);
ngroups = getgroups(ngroups, gidset);
}
}
@@ -145,7 +154,7 @@ static int is_in_group(gid_t gid)
}
int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st,
int report)
int report)
{
int updated = 0;
STRUCT_STAT st2;
@@ -155,7 +164,8 @@ int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st,
if (!st) {
if (link_stat(fname,&st2) != 0) {
rprintf(FERROR,"stat %s : %s\n",fname,strerror(errno));
rprintf(FERROR, "stat %s failed: %s\n",
full_fname(fname), strerror(errno));
return 0;
}
st = &st2;
@@ -167,8 +177,8 @@ int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st,
because some filesystems can't do it */
if (set_modtime(fname,file->modtime) != 0 &&
!S_ISDIR(st->st_mode)) {
rprintf(FERROR,"failed to set times on %s : %s\n",
fname,strerror(errno));
rprintf(FERROR, "failed to set times on %s: %s\n",
full_fname(fname), strerror(errno));
return 0;
} else {
updated = 1;
@@ -189,7 +199,8 @@ int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st,
change_gid?file->gid:st->st_gid) != 0) {
/* shouldn't have attempted to change uid or gid
unless have the privilege */
rprintf(FERROR,"chown %s : %s\n", fname,strerror(errno));
rprintf(FERROR, "chown %s failed: %s\n",
full_fname(fname), strerror(errno));
return 0;
}
/* a lchown had been done - we have to re-stat if the
@@ -203,17 +214,17 @@ int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st,
#ifdef HAVE_CHMOD
if (!S_ISLNK(st->st_mode)) {
if (st->st_mode != file->mode) {
if ((st->st_mode & CHMOD_BITS) != (file->mode & CHMOD_BITS)) {
updated = 1;
if (do_chmod(fname,file->mode) != 0) {
rprintf(FERROR,"failed to set permissions on %s : %s\n",
fname,strerror(errno));
if (do_chmod(fname,(file->mode & CHMOD_BITS)) != 0) {
rprintf(FERROR, "failed to set permissions on %s: %s\n",
full_fname(fname), strerror(errno));
return 0;
}
}
}
#endif
if (verbose > 1 && report) {
if (updated)
rprintf(FINFO,"%s\n",fname);
@@ -226,6 +237,15 @@ int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st,
void sig_int(void)
{
/* KLUGE: if the user hits Ctrl-C while ssh is prompting
* for a password, then our cleanup's sending of a SIGUSR1
* signal to all our children may kill ssh before it has a
* chance to restore the tty settings (i.e. turn echo back
* on). By sleeping for a short time, ssh gets a bigger
* chance to do the right thing. If child processes are
* not ssh waiting for a password, then this tiny delay
* shouldn't hurt anything. */
msleep(400);
exit_cleanup(RERR_SIGNAL);
}
@@ -240,17 +260,18 @@ void finish_transfer(char *fname, char *fnametmp, struct file_struct *file)
/* move tmp file over real file */
if (robust_rename(fnametmp,fname) != 0) {
if (errno == EXDEV) {
/* rename failed on cross-filesystem link.
/* rename failed on cross-filesystem link.
Copy the file instead. */
if (copy_file(fnametmp,fname, file->mode & INITACCESSPERMS)) {
rprintf(FERROR,"copy %s -> %s : %s\n",
fnametmp,fname,strerror(errno));
rprintf(FERROR, "copy %s -> \"%s\": %s\n",
full_fname(fnametmp), fname,
strerror(errno));
} else {
set_perms(fname,file,NULL,0);
}
} else {
rprintf(FERROR,"rename %s -> %s : %s\n",
fnametmp,fname,strerror(errno));
rprintf(FERROR,"rename %s -> \"%s\": %s\n",
full_fname(fnametmp), fname, strerror(errno));
}
do_unlink(fnametmp);
} else {

196
rsync.h
View File

@@ -24,9 +24,11 @@
#define BLOCK_SIZE 700
#define RSYNC_RSH_ENV "RSYNC_RSH"
#define RSYNC_RSH_IO_ENV "RSYNC_RSH_IO"
#define RSYNC_NAME "rsync"
#define RSYNCD_CONF "/etc/rsyncd.conf"
#define RSYNCD_SYSCONF "/etc/rsyncd.conf"
#define RSYNCD_USERCONF "rsyncd.conf"
#define DEFAULT_LOCK_FILE "/var/run/rsyncd.lock"
#define URL_PREFIX "rsync://"
@@ -49,20 +51,28 @@
#define SAME_TIME (1<<7)
/* update this if you make incompatible changes */
#define PROTOCOL_VERSION 26
#define PROTOCOL_VERSION 27
/* We refuse to interoperate with versions that are not in this range.
* Note that we assume we'll work with later versions: the onus is on
* people writing them to make sure that they don't send us anything
* we won't understand.
*
* There are two possible explanations for the limit at thirty: either
* to allow new major-rev versions that do not interoperate with us,
* and (more likely) so that we can detect an attempt to connect rsync
* to a non-rsync server, which is unlikely to begin by sending a byte
* between 15 and 30. */
#define MIN_PROTOCOL_VERSION 15
#define MAX_PROTOCOL_VERSION 30
* Interoperation with old but supported protocol versions
* should cause a warning to be printed. At a future date
* the old protocol will become the minimum and
* compatibility code removed.
*
* There are two possible explanations for the limit at
* MAX_PROTOCOL_VERSION: either to allow new major-rev versions that
* do not interoperate with us, and (more likely) so that we can
* detect an attempt to connect rsync to a non-rsync server, which is
* unlikely to begin by sending a byte between MIN_PROTOCL_VERSION and
* MAX_PROTOCOL_VERSION. */
#define MIN_PROTOCOL_VERSION 17
#define OLD_PROTOCOL_VERSION 20
#define MAX_PROTOCOL_VERSION 40
#define RSYNC_PORT 873
@@ -72,10 +82,23 @@
#define MAX_MAP_SIZE (256*1024)
#define IO_BUFFER_SIZE (4092)
#define IOERR_GENERAL (1<<0) /* For backward compatibility, this must == 1 */
#define IOERR_VANISHED (1<<1)
#define MAX_ARGS 1000
#define MPLEX_BASE 7
#define NO_EXCLUDES 0
#define SERVER_EXCLUDES 1
#define ALL_EXCLUDES 2
#define MISSING_OK 0
#define MISSING_FATAL 1
#define ADD_INCLUDE 1
#define ADD_EXCLUDE 0
/* Log values. I *think* what these mean is: FLOG goes to the server
* logfile; FERROR and FINFO try to end up on the client, with
* different levels of filtering. */
@@ -85,11 +108,7 @@ enum logcode {FNONE=0, FERROR=1, FINFO=2, FLOG=3 };
#include "config.h"
#if HAVE_REMSH
#define RSYNC_RSH "remsh"
#else
#define RSYNC_RSH "rsh"
#endif
/* The default RSYNC_RSH is always set in config.h. */
#include <sys/types.h>
@@ -107,6 +126,10 @@ enum logcode {FNONE=0, FERROR=1, FINFO=2, FLOG=3 };
#include <stdlib.h>
#endif
#if defined(HAVE_MALLOC_H) && (defined(HAVE_MALLINFO) || !defined(HAVE_STDLIB_H))
#include <malloc.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
@@ -115,10 +138,6 @@ enum logcode {FNONE=0, FERROR=1, FINFO=2, FLOG=3 };
#include <string.h>
#endif
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
#ifdef TIME_WITH_SYS_TIME
#include <sys/time.h>
#include <time.h>
@@ -175,20 +194,10 @@ enum logcode {FNONE=0, FERROR=1, FINFO=2, FLOG=3 };
#endif
#endif
#ifdef HAVE_FNMATCH
#include <fnmatch.h>
#else
#include "lib/fnmatch.h"
#endif
#ifdef HAVE_GLOB_H
#include <glob.h>
#endif
#ifdef HAVE_MALLOC_H
# include <malloc.h>
#endif
/* these are needed for the uid/gid mapping code */
#include <pwd.h>
#include <grp.h>
@@ -219,6 +228,8 @@ enum logcode {FNONE=0, FERROR=1, FINFO=2, FLOG=3 };
#include <compat.h>
#endif
#include <assert.h>
#define BOOL int
@@ -272,6 +283,17 @@ enum logcode {FNONE=0, FERROR=1, FINFO=2, FLOG=3 };
#define NO_INT64
#endif
#if (SIZEOF_LONG == 8)
#define uint64 unsigned long
#elif (SIZEOF_INT == 8)
#define uint64 unsigned int
#elif HAVE_LONGLONG
#define uint64 unsigned long long
#else
/* As long as it gets... */
#define uint64 unsigned 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
@@ -303,8 +325,8 @@ enum logcode {FNONE=0, FERROR=1, FINFO=2, FLOG=3 };
* cope with platforms on which this is an unsigned int or even a
* struct. Later.
*/
#define INO64_T int64
#define DEV64_T int64
#define INO64_T uint64
#define DEV64_T uint64
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
@@ -321,15 +343,25 @@ enum logcode {FNONE=0, FERROR=1, FINFO=2, FLOG=3 };
/* the length of the md4 checksum */
#define MD4_SUM_LENGTH 16
#define SUM_LENGTH 16
#define SHORT_SUM_LENGTH 2
#define BLOCKSUM_BIAS 10
#ifndef MAXPATHLEN
#define MAXPATHLEN 1024
#endif
#ifndef NAME_MAX
#define NAME_MAX 255
#endif
#ifndef INADDR_NONE
#define INADDR_NONE 0xffffffff
#endif
#ifndef IN_LOOPBACKNET
#define IN_LOOPBACKNET 127
#endif
struct file_struct {
unsigned flags;
time_t modtime;
@@ -369,34 +401,46 @@ struct file_list {
};
struct sum_buf {
OFF_T offset; /* offset in file of this chunk */
int len; /* length of chunk of file */
int i; /* index of this chunk */
uint32 sum1; /* simple checksum */
char sum2[SUM_LENGTH]; /* checksum */
OFF_T offset; /**< offset in file of this chunk */
int len; /**< length of chunk of file */
int i; /**< index of this chunk */
uint32 sum1; /**< simple checksum */
char sum2[SUM_LENGTH]; /**< checksum */
};
struct sum_struct {
OFF_T flength; /* total file length */
size_t count; /* how many chunks */
size_t remainder; /* flength % block_length */
size_t n; /* block_length */
struct sum_buf *sums; /* points to info for each chunk */
OFF_T flength; /**< total file length */
size_t count; /**< how many chunks */
size_t remainder; /**< flength % block_length */
size_t blength; /**< block_length */
size_t s2length; /**< sum2_length */
struct sum_buf *sums; /**< points to info for each chunk */
};
struct map_struct {
char *p;
int fd,p_size,p_len;
OFF_T file_size, p_offset, p_fd_offset;
char *p; /* Window pointer */
int fd; /* File Descriptor */
int p_size; /* Window size at allocation */
int p_len; /* Window size after fill */
/* p_size and p_len could be
* consolodated by using a local
* variable in map_ptr() */
int status; /* first errno from read errors */
OFF_T file_size; /* File size (from stat) */
OFF_T p_offset; /* Window start */
OFF_T p_fd_offset; /* offset of cursor in fd ala lseek */
};
#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 */
struct exclude_struct {
char *pattern;
int regular_exp;
int fnmatch_flags;
int match_flags;
int include;
int directory;
int local;
int slash_cnt;
};
struct stats {
@@ -423,6 +467,7 @@ static inline int flist_up(struct file_list *flist, int i)
#include "byteorder.h"
#include "lib/mdfour.h"
#include "lib/wildmatch.h"
#include "lib/permstring.h"
#include "lib/addrinfo.h"
@@ -437,11 +482,13 @@ int asprintf(char **ptr, const char *format, ...);
int vasprintf(char **ptr, const char *format, va_list ap);
#endif
#if !defined(HAVE_VSNPRINTF) && !defined(HAVE_C99_VSNPRINTF)
int vsnprintf (char *str, size_t count, const char *fmt, va_list args);
#if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
#define vsnprintf rsync_vsnprintf
int vsnprintf(char *str, size_t count, const char *fmt, va_list args);
#endif
#if !defined(HAVE_SNPRINTF) && !defined(HAVE_C99_VSNPRINTF)
#if !defined(HAVE_SNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
#define snprintf rsync_snprintf
int snprintf(char *str,size_t count,const char *fmt,...);
#endif
@@ -463,6 +510,9 @@ extern int errno;
#define SUPPORT_LINKS HAVE_READLINK
#define SUPPORT_HARD_LINKS HAVE_LINK
/* This could be bad on systems which have no lchown and where chown
* follows symbollic links. On such systems it might be better not to
* try to chown symlinks at all. */
#ifndef HAVE_LCHOWN
#define lchown chown
#endif
@@ -489,6 +539,16 @@ extern int errno;
#define S_IWUSR 0200
#endif
#ifndef ACCESSPERMS
#define ACCESSPERMS 0777
#endif
#ifndef S_ISVTX
#define S_ISVTX 0
#endif
#define CHMOD_BITS (S_ISUID | S_ISGID | S_ISVTX | ACCESSPERMS)
#ifndef _S_IFMT
#define _S_IFMT 0170000
#endif
@@ -552,9 +612,6 @@ extern int errno;
#define IS_DEVICE(mode) (S_ISCHR(mode) || S_ISBLK(mode) || S_ISSOCK(mode) || S_ISFIFO(mode))
#ifndef ACCESSPERMS
#define ACCESSPERMS 0777
#endif
/* Initial mask on permissions given to temporary files. Mask off setuid
bits and group access because of potential race-condition security
holes, and mask other access because mode 707 is bizarre */
@@ -563,25 +620,38 @@ extern int errno;
/* handler for null strings in printf format */
#define NS(s) ((s)?(s):"<NULL>")
#if !defined(__GNUC__) || defined(APPLE)
/* Apparently the OS X port of gcc gags on __attribute__.
*
* <http://www.opensource.apple.com/bugs/X/gcc/2512150.html> */
#define __attribute__(x)
#endif
/* Convenient wrappers for malloc and realloc. Use them. */
#define new(type) ((type *)malloc(sizeof(type)))
#define new_array(type, num) ((type *)_new_array(sizeof(type), (num)))
#define realloc_array(ptr, type, num) ((type *)_realloc_array((ptr), sizeof(type), (num)))
/* use magic gcc attributes to catch format errors */
void rprintf(enum logcode , const char *, ...)
#ifdef __GNUC__
__attribute__ ((format (printf, 2, 3)))
#endif
__attribute__((format (printf, 2, 3)))
;
/* This is just like rprintf, but it also tries to print some
* representation of the error code. Normally errcode = errno. */
void rsyserr(enum logcode, int, const char *, ...)
#ifdef __GNUC__
__attribute__ ((format (printf, 3, 4)))
#endif
__attribute__((format (printf, 3, 4)))
;
#ifdef REPLACE_INET_NTOA
#define inet_ntoa rep_inet_ntoa
#endif
/* Make sure that the O_BINARY flag is defined. */
#ifndef O_BINARY
#define O_BINARY 0
#endif
#ifndef HAVE_STRLCPY
size_t strlcpy(char *d, const char *s, size_t bufsize);
@@ -606,5 +676,13 @@ inet_ntop(int af, const void *src, char *dst, size_t size);
#endif /* !HAVE_INET_NTOP */
#ifndef HAVE_INET_PTON
int isc_net_pton(int af, const char *src, void *dst);
int inet_pton(int af, const char *src, void *dst);
#endif
#ifdef MAINTAINER_MODE
const char *get_panic_action(void);
#endif
#define UNUSED(x) x __attribute__((__unused__))
extern const char *io_write_phase, *io_read_phase;

595
rsync.yo
View File

@@ -1,5 +1,5 @@
mailto(rsync-bugs@samba.org)
manpage(rsync)(1)(14 Dec 2001)()()
manpage(rsync)(1)(1 Jan 2004)()()
manpagename(rsync)(faster, flexible replacement for rcp)
manpagesynopsis()
@@ -15,6 +15,8 @@ rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST
rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]
rsync [OPTION]... SRC [SRC]... rsync://[USER@]HOST[:PORT]/DEST
manpagedescription()
rsync is a program that behaves in much the same way that rcp does,
@@ -23,7 +25,7 @@ greatly speed up file transfers when the destination file already
exists.
The rsync remote-update protocol allows rsync to transfer just the
differences between two sets of files across the network link, using
differences between two sets of files across the network connection, using
an efficient checksum-search algorithm described in the technical
report that accompanies this package.
@@ -33,7 +35,7 @@ itemize(
it() support for copying links, devices, owners, groups and permissions
it() exclude and exclude-from options similar to GNU tar
it() a CVS exclude mode for ignoring the same files that CVS would ignore
it() can use any transparent remote shell, including rsh or ssh
it() can use any transparent remote shell, including ssh or rsh
it() does not require root privileges
it() pipelining of file transfers to minimize latency costs
it() support for anonymous or authenticated rsync servers (ideal for
@@ -42,15 +44,15 @@ itemize(
manpagesection(GENERAL)
There are six different ways of using rsync. They are:
There are eight different ways of using rsync. They are:
itemize(
it() for copying local files. This is invoked when neither
source nor destination path contains a : separator
it() for copying from the local machine to a remote machine using
a remote shell program as the transport (such as rsh or
ssh). This is invoked when the destination path contains a
a remote shell program as the transport (such as ssh or
rsh). This is invoked when the destination path contains a
single : separator.
it() for copying from a remote machine to the local machine
@@ -63,7 +65,19 @@ itemize(
it() for copying from the local machine to a remote rsync
server. This is invoked when the destination path contains a ::
separator.
separator or a rsync:// URL.
it() for copying from a remote machine using a remote shell
program as the transport, using rsync server on the remote
machine. This is invoked when the source path contains a ::
separator and the --rsh=COMMAND (aka "-e COMMAND") option is
also provided.
it() for copying from the local machine to a remote machine
using a remote shell program as the transport, using rsync
server on the remote machine. This is invoked when the
destination path contains a :: separator and the
--rsh=COMMMAND option is also provided.
it() for listing files on a remote machine. This is done the
same way as rsync transfers except that you leave off the
@@ -77,11 +91,13 @@ manpagesection(SETUP)
See the file README for installation instructions.
Once installed you can use rsync to any machine that you can use rsh
to. rsync uses rsh for its communications, unless both the source and
destination are local.
Once installed, you can use rsync to any machine that you can access via
a remote shell (as well as some that you can access using the rsync
daemon-mode protocol). For remote transfers, a modern rsync uses ssh
for its communications, but it may have been configured to use a
different remote shell by default, such as rsh or remsh.
You can also specify an alternative to rsh, either by using the -e
You can also specify any remote shell you like, either by using the -e
command line option, or by setting the RSYNC_RSH environment variable.
One common substitute is to use ssh, which offers a high degree of
@@ -99,7 +115,7 @@ Perhaps the best way to explain the syntax is some examples:
quote(rsync *.c foo:src/)
this would transfer all files matching the pattern *.c from the
This would transfer all files matching the pattern *.c from the
current directory to the directory src on the machine foo. If any of
the files already exist on the remote system then the rsync
remote-update protocol is used to update the file by sending only the
@@ -107,7 +123,7 @@ differences. See the tech report for details.
quote(rsync -avz foo:src/bar /data/tmp)
this would recursively transfer all files from the directory src/bar on the
This would recursively transfer all files from the directory src/bar on the
machine foo into the /data/tmp/bar directory on the local machine. The
files are transferred in "archive" mode, which ensures that symbolic
links, devices, attributes, permissions, ownerships etc are preserved
@@ -116,12 +132,17 @@ size of data portions of the transfer.
quote(rsync -avz foo:src/bar/ /data/tmp)
a trailing slash on the source changes this behavior to transfer
all files from the directory src/bar on the machine foo into the
/data/tmp/. A trailing / on a source name means "copy the
contents of this directory". Without a trailing slash it means "copy
the directory". This difference becomes particularly important when
using the --delete option.
A trailing slash on the source changes this behavior to avoid creating an
additional directory level at the destination. You can think of a trailing
/ on a source as meaning "copy the contents of this directory" as opposed
to "copy the directory by name", but in both cases the attributes of the
containing directory are transferred to the containing directory on the
destination. In other words, each of the following commands copies the
files in the same way, including their setting of the attributes of
/dest/foo:
quote(rsync -avz /src/foo /dest)
quote(rsync -avz /src/foo/ /dest/foo)
You can also use rsync in local-only mode, where both the source and
destination don't have a ':' in the name. In this case it behaves like
@@ -129,13 +150,13 @@ an improved copy command.
quote(rsync somehost.mydomain.com::)
this would list all the anonymous rsync modules available on the host
This would list all the anonymous rsync modules available on the host
somehost.mydomain.com. (See the following section for more details.)
manpagesection(CONNECTING TO AN RSYNC SERVER)
It is also possible to use rsync without using rsh or ssh as the
It is also possible to use rsync without a remote shell as the
transport. In this case you will connect to a remote rsync server
running on TCP port 873.
@@ -144,12 +165,12 @@ environment variable RSYNC_PROXY to a hostname:port pair pointing to
your web proxy. Note that your web proxy's configuration must allow
proxying to port 873.
Using rsync in this way is the same as using it with rsh or ssh except
Using rsync in this way is the same as using it with a remote shell except
that:
itemize(
it() you use a double colon :: instead of a single colon to
separate the hostname from the path.
separate the hostname from the path or a rsync:// URL.
it() the remote server may print a message of the day when you
connect.
@@ -170,11 +191,51 @@ may be useful when scripting rsync.
WARNING: On some systems environment variables are visible to all
users. On those systems using --password-file is recommended.
manpagesection(CONNECTING TO AN RSYNC SERVER OVER A REMOTE SHELL PROGRAM)
It is sometimes useful to be able to set up file transfers using rsync
server capabilities on the remote machine, while still using ssh or
rsh for transport. This is especially useful when you want to connect
to a remote machine via ssh (for encryption or to get through a
firewall), but you still want to have access to the rsync server
features (see RUNNING AN RSYNC SERVER OVER A REMOTE SHELL PROGRAM,
below).
From the user's perspective, using rsync in this way is the same as
using it to connect to an rsync server, except that you must
explicitly set the remote shell program on the command line with
--rsh=COMMAND. (Setting RSYNC_RSH in the environment will not turn on
this functionality.)
In order to distinguish between the remote-shell user and the rsync
server user, you can use '-l user' on your remote-shell command:
quote(rsync -av --rsh="ssh -l ssh-user" rsync-user@host::module[/path] local-path)
The "ssh-user" will be used at the ssh level; the "rsync-user" will be
used to check against the rsyncd.conf on the remote host.
manpagesection(RUNNING AN RSYNC SERVER)
An rsync server is configured using a config file which by default is
called /etc/rsyncd.conf. Please see the rsyncd.conf(5) man page for more
information.
An rsync server is configured using a config file. Please see the
rsyncd.conf(5) man page for more information. By default the configuration
file is called /etc/rsyncd.conf, unless rsync is running over a remote
shell program and is not running as root; in that case, the default name
is rsyncd.conf in the current directory on the remote computer
(typically $HOME).
manpagesection(RUNNING AN RSYNC SERVER OVER A REMOTE SHELL PROGRAM)
See the rsyncd.conf(5) man page for full information on the rsync
server configuration file.
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.
To run an rsync server out of a single-use ssh key, see this section
in the rsyncd.conf(5) man page.
manpagesection(EXAMPLES)
@@ -185,7 +246,7 @@ files and mail folders, I use a cron job that runs
quote(rsync -Cavz . arvidsjaur:backup)
each night over a PPP link to a duplicate directory on my machine
each night over a PPP connection to a duplicate directory on my machine
"arvidsjaur".
To synchronize my samba source trees I use the following Makefile
@@ -200,7 +261,7 @@ quote( get:nl()
sync: get put)
this allows me to sync with a CVS directory at the other end of the
link. I then do cvs operations on the remote machine, which saves a
connection. I then do cvs operations on the remote machine, which saves a
lot of time as the remote cvs protocol isn't very efficient.
I mirror a directory between my "old" and "new" ftp sites with the
@@ -219,12 +280,14 @@ verb(
-v, --verbose increase verbosity
-q, --quiet decrease verbosity
-c, --checksum always checksum
-a, --archive archive mode
-a, --archive archive mode, equivalent to -rlptgoD
-r, --recursive recurse into directories
-R, --relative use relative path names
-b, --backup make backups (default ~ suffix)
--no-relative turn off --relative
--no-implied-dirs don't send implied dirs with -R
-b, --backup make backups (see --suffix & --backup-dir)
--backup-dir make backups into this directory
--suffix=SUFFIX override backup suffix
--suffix=SUFFIX backup suffix (default ~ w/o --backup-dir)
-u, --update update only (don't overwrite newer files)
-l, --links copy symlinks as symlinks
-L, --copy-links copy the referent of symlinks
@@ -239,32 +302,37 @@ verb(
-S, --sparse handle sparse files efficiently
-n, --dry-run show what would have been transferred
-W, --whole-file copy whole files, no incremental checks
--no-whole-file turn off --whole-file
-x, --one-file-system don't cross filesystem boundaries
-B, --block-size=SIZE checksum blocking size (default 700)
-e, --rsh=COMMAND specify rsh replacement
-e, --rsh=COMMAND specify the remote shell
--rsync-path=PATH specify path to rsync on the remote machine
-C, --cvs-exclude auto ignore files in the same way CVS does
--existing only update files that already exist
--delete delete files that don't exist on the sending side
--delete-excluded also delete excluded files on the receiving side
--ignore-existing ignore files that already exist on receiver
--delete delete files that don't exist on sender
--delete-excluded also delete excluded files on receiver
--delete-after delete after transferring, not before
--ignore-errors delete even if there are IO errors
--max-delete=NUM don't delete more than NUM files
--partial keep partially transferred files
--force force deletion of directories even if not empty
--force force deletion of dirs even if not empty
--numeric-ids don't map uid/gid values by user/group name
--timeout=TIME set IO timeout in seconds
-I, --ignore-times don't exclude files that match length and time
--size-only only use file size when determining if a file should be transferred
--modify-window=NUM Timestamp window (seconds) for file match (default=0)
-I, --ignore-times turn off mod time & file size quick check
--size-only ignore mod time for quick check (use size)
--modify-window=NUM compare mod times with reduced accuracy
-T --temp-dir=DIR create temporary files in directory DIR
--compare-dest=DIR also compare destination files relative to DIR
--compare-dest=DIR also compare received files relative to DIR
--link-dest=DIR create hardlinks to DIR for unchanged files
-P equivalent to --partial --progress
-z, --compress compress file data
-C, --cvs-exclude auto ignore files in the same way CVS does
--exclude=PATTERN exclude files matching PATTERN
--exclude-from=FILE exclude patterns listed in FILE
--include=PATTERN don't exclude files matching PATTERN
--include-from=FILE don't exclude patterns listed in FILE
--files-from=FILE read FILE for list of source-file names
-0 --from0 all file lists are delimited by nulls
--version print version number
--daemon run as a rsync daemon
--no-detach do not detach from the parent
@@ -272,13 +340,14 @@ verb(
--config=FILE specify alternate rsyncd.conf file
--port=PORT specify alternate rsyncd port number
--blocking-io use blocking IO for the remote shell
--no-blocking-io turn off --blocking-io
--stats give some file transfer stats
--progress show progress during transfer
--log-format=FORMAT log file transfers using specified format
--password-file=FILE get password from FILE
--bwlimit=KBPS limit I/O bandwidth, KBytes per second
--read-batch=FILE read batch file
--write-batch write batch file
--write-batch=PREFIX write batch fileset starting with PREFIX
--read-batch=PREFIX read batch fileset starting with PREFIX
-h, --help show this help screen
@@ -312,11 +381,11 @@ from the remote server. This flag is useful when invoking rsync from
cron.
dit(bf(-I, --ignore-times)) Normally rsync will skip any files that are
already the same length and have the same time-stamp. This option turns
off this behavior.
already the same size and have the same modification time-stamp.
This option turns off this "quick check" behavior.
dit(bf(--size-only)) Normally rsync will skip any files that are
already the same length and have the same time-stamp. With the
already the same size and have the same modification time-stamp. With the
--size-only option files will be skipped if they have the same size,
regardless of timestamp. This is useful when starting to use rsync
after using another mirroring system which may not preserve timestamps
@@ -326,8 +395,8 @@ dit(bf(--modify-window)) When comparing two timestamps rsync treats
the timestamps as being equal if they are within the value of
modify_window. This is normally zero, but you may find it useful to
set this to a larger value in some situations. In particular, when
transferring to/from FAT filesystems which cannot represent times with
a 1 second resolution this option is useful.
transferring to Windows FAT filesystems which cannot represent times
with a 1 second resolution --modify-window=1 is useful.
dit(bf(-c, --checksum)) This forces the sender to checksum all files using
a 128-bit MD4 checksum before transfer. The checksum is then
@@ -361,18 +430,38 @@ machine. If instead you used
verb(rsync -R foo/bar/foo.c remote:/tmp/)
then a file called /tmp/foo/bar/foo.c would be created on the remote
machine. The full path name is preserved.
machine -- the full path name is preserved.
dit(bf(-b, --backup)) With this option preexisting destination files are
renamed with a ~ extension as each file is transferred. You can
control the backup suffix using the --suffix option.
dit(bf(--no-relative)) Turn off the --relative option. This is only
needed if you want to use --files-from without its implied --relative
file processing.
dit(bf(--no-implied-dirs)) When combined with the --relative option, the
implied directories in each path are not explicitly duplicated as part
of the transfer. This makes the transfer more optimal and also allows
the two sides to have non-matching symlinks in the implied part of the
path. For instance, if you transfer the file "/path/foo/file" with -R,
the default is for rsync to ensure that "/path" and "/path/foo" on the
destination exactly match the directories/symlinks of the source. Using
the --no-implied-dirs option would omit both of these implied dirs,
which means that if "/path" was a real directory on one machine and a
symlink of the other machine, rsync would not try to change this.
dit(bf(-b, --backup)) With this option, preexisting destination files are
renamed as each file is transferred or deleted. You can control where the
backup file goes and what (if any) suffix gets appended using the
--backup-dir and --suffix options.
dit(bf(--backup-dir=DIR)) In combination with the --backup option, this
tells rsync to store all backups in the specified directory. This is
very useful for incremental backups.
very useful for incremental backups. You can additionally
specify a backup suffix using the --suffix option
(otherwise the files backed up in the specified directory
will keep their original filenames).
dit(bf(--suffix=SUFFIX)) This option allows you to override the default
backup suffix used with the -b option. The default is a ~.
backup suffix used with the --backup (-b) option. The default suffix is a ~
if no --backup-dir was specified, otherwise it is an empty string.
dit(bf(-u, --update)) This forces rsync to skip any files for which the
destination file already exists and has a date later than the source
@@ -410,12 +499,22 @@ target machines is higher than the bandwidth to disk (especially when the
"disk" is actually a networked file system). This is the default when both
the source and target are on the local machine.
dit(bf(-p, --perms)) This option causes rsync to update the remote
permissions to be the same as the local permissions.
dit(bf(--no-whole-file)) Turn off --whole-file, for use when it is the
default.
dit(bf(-p, --perms)) This option causes rsync to set the destination
permissions to be the same as the source permissions.
Without this option, each new file gets its permissions set based on the
source file's permissions and the umask at the receiving end, while all
other files (including updated files) retain their existing permissions
(which is the same behavior as other file-copy utilities, such as cp).
dit(bf(-o, --owner)) This option causes rsync to set the owner of the
destination file to be the same as the source file. On most systems,
only the super-user can set file ownership.
only the super-user can set file ownership. Note that if the remote system
is a daemon using chroot, the --numeric-ids option is implied because the
remote system cannot get access to the usernames from /etc/passwd.
dit(bf(-g, --group)) This option causes rsync to set the group of the
destination file to be the same as the source file. If the receiving
@@ -452,6 +551,10 @@ contents of only one filesystem.
dit(bf(--existing)) This tells rsync not to create any new files -
only update files that already exist on the destination.
dit(bf(--ignore-existing))
This tells rsync not to update files that already exist on
the destination.
dit(bf(--max-delete=NUM)) This tells rsync not to delete more than NUM
files or directories. This is useful when mirroring very large trees
to prevent disasters.
@@ -475,33 +578,46 @@ destination. You can override this with the --ignore-errors option.
dit(bf(--delete-excluded)) In addition to deleting the files on the
receiving side that are not on the sending side, this tells rsync to also
delete any files on the receiving side that are excluded (see --exclude).
Implies --delete.
dit(bf(--delete-after)) By default rsync does file deletions before
transferring files to try to ensure that there is sufficient space on
the receiving filesystem. If you want to delete after transferring
then use the --delete-after switch.
then use the --delete-after switch. Implies --delete.
dit(bf(--ignore-errors)) Tells --delete to go ahead and delete files
even when there are IO errors.
dit(bf(--force)) This options tells rsync to delete directories even if
they are not empty. This applies to both the --delete option and to
cases where rsync tries to copy a normal file but the destination
contains a directory of the same name.
Since this option was added, deletions were reordered to be done depth-first
so it is hardly ever needed anymore except in very obscure cases.
they are not empty when they are to be replaced by non-directories. This
is only relevant without --delete because deletions are now done depth-first.
Requires the --recursive option (which is implied by -a) to have any effect.
dit(bf(-B , --block-size=BLOCKSIZE)) This controls the block size used in
the rsync algorithm. See the technical report for details.
dit(bf(-e, --rsh=COMMAND)) This option allows you to choose an alternative
remote shell program to use for communication between the local and
remote copies of rsync. By default, rsync will use rsh, but you may
like to instead use ssh because of its high security.
remote copies of rsync. Typically, rsync is configured to use ssh by
default, but you may prefer to use rsh on a local network.
If this option is used with bf([user@]host::module/path), then the
remote shell em(COMMMAND) will be used to run an rsync server on the
remote host, and all data will be transmitted through that remote
shell connection, rather than through a direct socket connection to a
running rsync server on the remote host. See the section "CONNECTING
TO AN RSYNC SERVER OVER A REMOTE SHELL PROGRAM" above.
Command-line arguments are permitted in COMMAND provided that COMMAND is
presented to rsync as a single argument. For example:
quote(-e "ssh -p 2234")
(Note that ssh users can alternately customize site-specific connect
options in their .ssh/config file.)
You can also choose the remote shell program using the RSYNC_RSH
environment variable.
environment variable, which accepts the same range of values as -e.
See also the --blocking-io option which is affected by this option.
@@ -510,31 +626,6 @@ rsync on the remote machine. Useful when it's not in your path. Note
that this is the full path to the binary, not just the directory that
the binary is in.
dit(bf(--exclude=PATTERN)) This option allows you to selectively exclude
certain files from the list of files to be transferred. This is most
useful in combination with a recursive transfer.
You may use as many --exclude options on the command line as you like
to build up the list of files to exclude.
See the section on exclude patterns for information on the syntax of
this option.
dit(bf(--exclude-from=FILE)) This option is similar to the --exclude
option, but instead it adds all exclude patterns listed in the file
FILE to the exclude list. Blank lines in FILE and lines starting with
';' or '#' are ignored.
dit(bf(--include=PATTERN)) This option tells rsync to not exclude the
specified pattern of filenames. This is useful as it allows you to
build up quite complex exclude/include rules.
See the section of exclude patterns for information on the syntax of
this option.
dit(bf(--include-from=FILE)) This specifies a list of include patterns
from a file.
dit(bf(-C, --cvs-exclude)) This is a useful shorthand for excluding a
broad range of files that you often don't want to transfer between
systems. It uses the same algorithm that CVS uses to determine if
@@ -542,7 +633,7 @@ a file should be ignored.
The exclude list is initialized to:
quote(RCS SCCS CVS CVS.adm RCSLOG cvslog.* tags TAGS .make.state
quote(RCS/ SCCS/ CVS/ .svn/ CVS.adm RCSLOG cvslog.* tags TAGS .make.state
.nse_depinfo *~ #* .#* ,* *.old *.bak *.BAK *.orig *.rej .del-*
*.a *.o *.obj *.so *.Z *.elc *.ln core)
@@ -553,24 +644,73 @@ Finally, any file is ignored if it is in the same directory as a
.cvsignore file and matches one of the patterns listed therein. See
the bf(cvs(1)) manual for more information.
dit(bf(--csum-length=LENGTH)) By default the primary checksum used in
rsync is a very strong 16 byte MD4 checksum. In most cases you will
find that a truncated version of this checksum is quite efficient, and
this will decrease the size of the checksum data sent over the link,
making things faster.
dit(bf(--exclude=PATTERN)) This option allows you to selectively exclude
certain files from the list of files to be transferred. This is most
useful in combination with a recursive transfer.
You can choose the number of bytes in the truncated checksum using the
--csum-length option. Any value less than or equal to 16 is valid.
You may use as many --exclude options on the command line as you like
to build up the list of files to exclude.
Note that if you use this option then you run the risk of ending up
with an incorrect target file. The risk with a value of 16 is
microscopic and can be safely ignored (the universe will probably end
before it fails) but with smaller values the risk is higher.
See the EXCLUDE PATTERNS section for information on the syntax of
this option.
Current versions of rsync actually use an adaptive algorithm for the
checksum length by default, using a 16 byte file checksum to determine
if a 2nd pass is required with a longer block checksum. Only use this
option if you have read the source code and know what you are doing.
dit(bf(--exclude-from=FILE)) This option is similar to the --exclude
option, but instead it adds all exclude patterns listed in the file
FILE to the exclude list. Blank lines in FILE and lines starting with
';' or '#' are ignored.
If em(FILE) is bf(-) the list will be read from standard input.
dit(bf(--include=PATTERN)) This option tells rsync to not exclude the
specified pattern of filenames. This is useful as it allows you to
build up quite complex exclude/include rules.
See the EXCLUDE PATTERNS section for information on the syntax of
this option.
dit(bf(--include-from=FILE)) This specifies a list of include patterns
from a file.
If em(FILE) is bf(-) the list will be read from standard input.
dit(bf(--files-from=FILE)) Using this option allows you to specify the
exact list of files to transfer (as read from the specified FILE or "-"
for stdin). It also tweaks the default behavior of rsync to make
transferring just the specified files and directories easier. For
instance, the --relative option is enabled by default when this option
is used (use --no-relative if you want to turn that off), all
directories specified in the list are created on the destination (rather
than being noisily skipped without -r), and the -a (--archive) option's
behavior does not imply -r (--recursive) -- specify it explicitly, if
you want it.
The file names that are read from the FILE are all relative to the
source dir -- any leading slashes are removed and no ".." references are
allowed to go higher than the source dir. For example, take this
command:
quote(rsync -a --files-from=/tmp/foo /usr remote:/backup)
If /tmp/foo contains the string "bin" (or even "/bin"), the /usr/bin
directory will be created as /backup/bin on the remote host (but the
contents of the /usr/bin dir would not be sent unless you specified -r
or the names were explicitly listed in /tmp/foo). Also keep in mind
that the effect of the (enabled by default) --relative option is to
duplicate only the path info that is read from the file -- it does not
force the duplication of the source-spec path (/usr in this case).
In addition, the --files-from file can be read from the remote host
instead of the local host if you specify a "host:" in front of the file
(the host must match one end of the transfer). As a short-cut, you can
specify just a prefix of ":" to mean "use the remote end of the
transfer". For example:
quote(rsync -a --files-from=:/path/file-list src:/ /tmp/copy)
This would copy all the files specified in the /path/file-list file that
was located on the remote "src" host.
dit(bf(-0, --from0)) This tells rsync that the filenames it reads from a
file are terminated by a null ('\0') character, not a NL, CR, or CR+LF.
This affects --exclude-from, --include-from, and --files-from.
dit(bf(-T, --temp-dir=DIR)) This option instructs rsync to use DIR as a
scratch directory when creating temporary copies of the files
@@ -579,19 +719,27 @@ the temporary files in the receiving directory.
dit(bf(--compare-dest=DIR)) This option instructs rsync to use DIR on
the destination machine as an additional directory to compare destination
files against when doing transfers. This is useful for doing transfers to
a new destination while leaving existing files intact, and then doing a
files against when doing transfers if the files are missing in the
destination directory. This is useful for doing transfers to a new
destination while leaving existing files intact, and then doing a
flash-cutover when all files have been successfully transferred (for
example by moving directories around and removing the old directory,
although this requires also doing the transfer with -I to avoid skipping
files that haven't changed). This option increases the usefulness of
--partial because partially transferred files will remain in the new
temporary destination until they have a chance to be completed. If DIR is
a relative path, it is relative to the destination directory.
although this skips files that haven't changed; see also --link-dest).
This option increases the usefulness of --partial because partially
transferred files will remain in the new temporary destination until they
have a chance to be completed. If DIR is a relative path, it is relative
to the destination directory.
dit(bf(--link-dest=DIR)) This option behaves like bf(--compare-dest) but
also will create hard links from em(DIR) to the destination directory for
unchanged files. Files with changed ownership or permissions will not be
linked.
Like bf(--compare-dest) if DIR is a relative path, it is relative
to the destination directory.
dit(bf(-z, --compress)) With this option, rsync compresses any data from
the files that it sends to the destination machine. This
option is useful on slow links. The compression method used is the
option is useful on slow connections. The compression method used is the
same method that gzip uses.
Note this this option typically achieves better compression ratios
@@ -623,7 +771,7 @@ bf(rsync://host/module/) syntax.
If standard input is a socket then rsync will assume that it is being
run via inetd, otherwise it will detach from the current terminal and
become a background daemon. The daemon will read the config file
(/etc/rsyncd.conf) on each connect made by a client and respond to
(rsyncd.conf) on each connect made by a client and respond to
requests accordingly. See the rsyncd.conf(5) man page for more
details.
@@ -643,17 +791,22 @@ address (or hostname) to bind to. This makes virtual hosting possible
in conjunction with the --config option.
dit(bf(--config=FILE)) This specifies an alternate config file than
the default /etc/rsyncd.conf. This is only relevant when --daemon is
specified.
the default. This is only relevant when --daemon is specified.
The default is /etc/rsyncd.conf unless the daemon is running over
a remote shell program and the remote user is not root; in that case
the default is rsyncd.conf in the current directory (typically $HOME).
dit(bf(--port=PORT)) This specifies an alternate TCP port number to use
rather than the default port 873.
dit(bf(--blocking-io)) This tells rsync to use blocking IO when launching
a remote shell transport. If -e or --rsh are not specified or are set to
the default "rsh", this defaults to blocking IO, otherwise it defaults to
non-blocking IO. You may find the --blocking-io option is needed for some
remote shells that can't handle non-blocking IO. Ssh prefers blocking IO.
a remote shell transport. If the remote shell is either rsh or remsh,
rsync defaults to using
blocking IO, otherwise it defaults to using non-blocking IO. (Note that
ssh prefers non-blocking IO.)
dit(bf(--no-blocking-io)) Turn off --blocking-io, for use when it is the
default.
dit(bf(--log-format=FORMAT)) This allows you to specify exactly what the
rsync client logs to stdout on a per-file basis. The log format is
@@ -673,9 +826,7 @@ make a subsequent transfer of the rest of the file much faster.
dit(bf(--progress)) This option tells rsync to print information
showing the progress of the transfer. This gives a bored user
something to watch.
This option is normally combined with -v. Using this option without
the -v option will produce weird results on your display.
Implies --verbose without incrementing verbosity.
dit(bf(-P)) The -P option is equivalent to --partial --progress. I
found myself typing that combination quite often so I created an
@@ -696,10 +847,13 @@ transfer was too fast, it will wait before sending the next data block. The
result is an average transfer rate equalling the specified limit. A value
of zero specifies no limit.
dit(bf(--read-batch)) Apply a previously generated change batch.
dit(bf(--write-batch=PREFIX)) Generate a set of files that can be
transferred as a batch update. Each filename in the set starts with
PREFIX. See the "BATCH MODE" section for details.
dit(bf(--write-batch)) Generate a set of files that can be transferred
as a batch update.
dit(bf(--read-batch=PREFIX)) Apply a previously generated change batch,
using the fileset whose filenames start with PREFIX. See the "BATCH
MODE" section for details.
enddit()
@@ -709,13 +863,20 @@ The exclude and include patterns specified to rsync allow for flexible
selection of which files to transfer and which files to skip.
rsync builds an ordered list of include/exclude options as specified on
the command line. When a filename is encountered, rsync checks the
the command line. Rsync checks each file and directory
name against each exclude/include pattern in turn. The first matching
pattern is acted on. If it is an exclude pattern, then that file is
skipped. If it is an include pattern then that filename is not
skipped. If no matching include/exclude pattern is found then the
filename is not skipped.
The filenames matched against the exclude/include patterns
are relative to the destination directory, or "top
directory", so patterns should not include the path elements
of the source or destination directories. The only way in
which a pattern will match the absolute path of a file or
directory is if the source path is the root directory.
Note that when used with -r (which is implied by -a), every subcomponent of
every path is visited from top down, so include/exclude patterns get
applied recursively to each subcomponent.
@@ -727,13 +888,18 @@ each. To add multiple patterns use the --include-from and
The patterns can take several forms. The rules are:
itemize(
it() if the pattern starts with a / then it is matched against the
start of the filename, otherwise it is matched against the end of
the filename. Thus "/foo" would match a file called "foo" at the base of
the tree. On the other hand, "foo" would match any file called "foo"
the filename.
This is the equivalent of a leading ^ in regular expressions.
Thus "/foo" would match a file called "foo" at the top of the
transferred tree.
On the other hand, "foo" would match any file called "foo"
anywhere in the tree because the algorithm is applied recursively from
top down; it behaves as if each path component gets a turn at being the
end of the file name.
The leading / does not make the pattern an absolute pathname.
it() if the pattern ends with a / then it will only match a
directory, not a file, link or device.
@@ -742,15 +908,15 @@ itemize(
*?[ then expression matching is applied using the shell filename
matching rules. Otherwise a simple string match is used.
it() if the pattern includes a double asterisk "**" then all wildcards in
the pattern will match slashes, otherwise they will stop at slashes.
it() the double asterisk pattern "**" will match slashes while a
single asterisk pattern "*" will stop at slashes.
it() if the pattern contains a / (not counting a trailing /) then it
is matched against the full filename, including any leading
directory. If the pattern doesn't contain a / then it is matched
only against the final component of the filename. Again, remember
that the algorithm is applied recursively so "full filename" can
actually be any portion of a path.
it() if the pattern contains a / (not counting a trailing /) or a "**"
then it is matched against the full filename, including any leading
directory. If the pattern doesn't contain a / or a "**", then it is
matched only against the final component of the filename. Again,
remember that the algorithm is applied recursively so "full filename" can
actually be any portion of a path below the starting directory.
it() if the pattern starts with "+ " (a plus followed by a space)
then it is always considered an include pattern, even if specified as
@@ -764,8 +930,9 @@ itemize(
include/exclude list is reset, removing all previously defined patterns.
)
The +/- rules are most useful in exclude lists, allowing you to have a
single exclude list that contains both include and exclude options.
The +/- rules are most useful in a list that was read from a file, allowing
you to have a single exclude list that contains both include and exclude
options.
If you end an exclude list with --exclude '*', note that since the
algorithm is applied recursively that unless you explicitly include
@@ -778,12 +945,12 @@ Here are some exclude/include examples:
itemize(
it() --exclude "*.o" would exclude all filenames matching *.o
it() --exclude "/foo" would exclude a file in the base directory called foo
it() --exclude "/foo" would exclude a file called foo in the top directory
it() --exclude "foo/" would exclude any directory called foo
it() --exclude "/foo/*/bar" would exclude any file called bar two
levels below a base directory called foo
levels below a directory called foo in the top directory
it() --exclude "/foo/**/bar" would exclude any file called bar two
or more levels below a base directory called foo
or more levels below a directory called foo in the top directory
it() --include "*/" --include "*.c" --exclude "*" would include all
directories and C source files
it() --include "foo/" --include "foo/bar.c" --exclude "*" would include
@@ -794,26 +961,83 @@ itemize(
manpagesection(BATCH MODE)
bf(Note:) Batch mode should be considered experimental in this version
of rsync. The interface or behaviour may change before it stabilizes.
of rsync. The interface or behaviour may change before it stabilizes.
The following call generates 4 files that encapsulate the information
for synchronizing the contents of bf(target_dir) with the updates found in
bf(src_dir)
Batch mode can be used to apply the same set of updates to many
identical systems. Suppose one has a tree which is replicated on a
number of hosts. Now suppose some changes have been made to this
source tree and those changes need to be propagated to the other
hosts. In order to do this using batch mode, rsync is run with the
write-batch option to apply the changes made to the source tree to one
of the destination trees. The write-batch option causes the rsync
client to store the information needed to repeat this operation against
other destination trees in a batch update fileset (see below). The
filename of each file in the fileset starts with a prefix specified by
the user as an argument to the write-batch option. This fileset is
then copied to each remote host, where rsync is run with the read-batch
option, again specifying the same prefix, and the destination tree.
Rsync updates the destination tree using the information stored in the
batch update fileset.
quote(
$ rsync --write-batch [other rsync options here] \nl()
/somewhere/src_dir /somewhere/target_dir
)
The generated files are labeled with a common timestamp:
The fileset consists of 4 files:
itemize(
it() bf(rsync_argvs.<timestamp>) command-line arguments
it() bf(rsync_flist.<timestamp>) rsync internal file metadata
it() bf(rsync_csums.<timestamp>) rsync checksums
it() bf(rsync_delta.<timestamp>) data blocks for file update & change
it() bf(<prefix>.rsync_argvs) command-line arguments
it() bf(<prefix>.rsync_flist) rsync internal file metadata
it() bf(<prefix>.rsync_csums) rsync checksums
it() bf(<prefix>.rsync_delta) data blocks for file update & change
)
The .rsync_argvs file contains a command-line suitable for updating a
destination tree using that batch update fileset. It can be executed
using a Bourne(-like) shell, optionally passing in an alternate
destination tree pathname which is then used instead of the original
path. This is useful when the destination tree path differs from the
original destination tree path.
Generating the batch update fileset once saves having to perform the
file status, checksum and data block generation more than once when
updating multiple destination trees. Multicast transport protocols can
be used to transfer the batch update files in parallel to many hosts at
once, instead of sending the same data to every host individually.
Example:
verb(
$ rsync --write-batch=pfx -a /source/dir/ /adest/dir/
$ rcp pfx.rsync_* remote:
$ ssh remote rsync --read-batch=pfx -a /bdest/dir/
# or alternatively
$ ssh remote ./pfx.rsync_argvs /bdest/dir/
)
In this example, rsync is used to update /adest/dir/ with /source/dir/
and the information to repeat this operation is stored in the files
pfx.rsync_*. These files are then copied to the machine named "remote".
Rsync is then invoked on "remote" to update /bdest/dir/ the same way as
/adest/dir/. The last line shows the rsync_argvs file being used to
invoke rsync.
Caveats:
The read-batch option expects the destination tree it is meant to update
to be identical to the destination tree that was used to create the
batch update fileset. When a difference between the destination trees
is encountered the update will fail at that point, leaving the
destination tree in a partially updated state. In that case, rsync can
be used in its regular (non-batch) mode of operation to fix up the
destination tree.
The rsync version used on all destinations should be identical to the
one used on the original destination.
The -z/--compress option does not work in batch mode and yields a usage
error. A separate compression tool can be used instead to reduce the
size of the batch update files for transport to the destination.
The -n/--dryrun option does not work in batch mode and yields a runtime
error.
See bf(http://www.ils.unc.edu/i2dsi/unc_rsync+.html) for papers and technical
reports.
@@ -840,6 +1064,10 @@ bf(--copy-unsafe-links) will cause any links to be copied as the file
they point to on the destination. Using bf(--safe-links) will cause
unsafe links to be ommitted altogether.
Symbolic links are considered unsafe if they are absolute symlinks
(start with bf(/)), empty, or if they contain enough bf("..")
components to ascend from the directory being copied.
manpagesection(DIAGNOSTICS)
rsync occasionally produces error messages that may seem a little
@@ -852,7 +1080,7 @@ for its transport. The way to diagnose this problem is to run your
remote shell like this:
verb(
rsh remotehost /bin/true > out.dat
ssh remotehost /bin/true > out.dat
)
then look at out.dat. If everything is working correctly then out.dat
@@ -870,24 +1098,26 @@ show why each individual file is included or excluded.
manpagesection(EXIT VALUES)
startdit()
dit(bf(RERR_SYNTAX 1)) Syntax or usage error
dit(bf(RERR_PROTOCOL 2)) Protocol incompatibility
dit(bf(RERR_FILESELECT 3)) Errors selecting input/output files, dirs
dit(bf(RERR_UNSUPPORTED 4)) Requested action not supported: an attempt
dit(bf(0)) Success
dit(bf(1)) Syntax or usage error
dit(bf(2)) Protocol incompatibility
dit(bf(3)) Errors selecting input/output files, dirs
dit(bf(4)) Requested action not supported: an attempt
was made to manipulate 64-bit files on a platform that cannot support
them; or an option was speciifed that is supported by the client and
not by the server.
dit(bf(RERR_SOCKETIO 10)) Error in socket IO
dit(bf(RERR_FILEIO 11)) Error in file IO
dit(bf(RERR_STREAMIO 12)) Error in rsync protocol data stream
dit(bf(RERR_MESSAGEIO 13)) Errors with program diagnostics
dit(bf(RERR_IPC 14)) Error in IPC code
dit(bf(RERR_SIGNAL 20)) Received SIGUSR1 or SIGINT
dit(bf(RERR_WAITCHILD 21)) Some error returned by waitpid()
dit(bf(RERR_MALLOC 22)) Error allocating core memory buffers
dit(bf(RERR_TIMEOUT 30)) Timeout in data send/receive
dit(bf(5)) Error starting client-server protocol
dit(bf(10)) Error in socket IO
dit(bf(11)) Error in file IO
dit(bf(12)) Error in rsync protocol data stream
dit(bf(13)) Errors with program diagnostics
dit(bf(14)) Error in IPC code
dit(bf(20)) Received SIGUSR1 or SIGINT
dit(bf(21)) Some error returned by waitpid()
dit(bf(22)) Error allocating core memory buffers
dit(bf(23)) Partial transfer due to error
dit(bf(24)) Partial transfer due to vanished source files
dit(bf(30)) Timeout in data send/receive
enddit()
manpagesection(ENVIRONMENT VARIABLES)
@@ -899,8 +1129,8 @@ ignore patterns in .cvsignore files. See the --cvs-exclude option for
more details.
dit(bf(RSYNC_RSH)) The RSYNC_RSH environment variable allows you to
override the default shell used as the transport for rsync. This can
be used instead of the -e option.
override the default shell used as the transport for rsync. Command line
options are permitted after the command name, just as in the -e option.
dit(bf(RSYNC_PROXY)) The RSYNC_PROXY environment variable allows you to
redirect your rsync client to use a web proxy when connecting to a
@@ -921,7 +1151,7 @@ enddit()
manpagefiles()
/etc/rsyncd.conf
/etc/rsyncd.conf or rsyncd.conf
manpageseealso()
@@ -933,16 +1163,17 @@ manpagebugs()
times are transferred as unix time_t values
When transferring to FAT filesystmes rsync may resync
unmodified files.
See the comments on the --modify-window option.
file permissions, devices etc are transferred as native numerical
values
see also the comments on the --delete option
Please report bugs! The rsync bug tracking system is online at
url(http://rsync.samba.org/rsync/)(http://rsync.samba.org/rsync/)
manpagesection(VERSION)
This man page is current for version 2.0 of rsync
Please report bugs! See the website at
url(http://rsync.samba.org/)(http://rsync.samba.org/)
manpagesection(CREDITS)

View File

@@ -1,5 +1,5 @@
mailto(rsync-bugs@samba.org)
manpage(rsyncd.conf)(5)(12 Feb 1999)()()
manpage(rsyncd.conf)(5)(1 Jan 2004)()()
manpagename(rsyncd.conf)(configuration file for rsync server)
manpagesynopsis()
@@ -8,9 +8,7 @@ rsyncd.conf
manpagedescription()
The rsyncd.conf file is the runtime configuration file for rsync when
run with the --daemon option. When run in this way rsync becomes a
rsync server listening on TCP port 873. Connections from rsync clients
are accepted for either anonymous or authenticated rsync sessions.
run as an rsync server.
The rsyncd.conf file controls authentication, access, logging and
available modules.
@@ -51,9 +49,12 @@ bind to a port numbered under 1024 (as is the default 873), or to set
file ownership. Otherwise, it must just have permission to read and
write the appropriate data, log, and lock files.
You can launch it either via inetd or as a stand-alone daemon. If run
as a daemon then just run the command "rsync --daemon" from a suitable
startup script.
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 "rsync --daemon" from a suitable startup script.
If run from an rsync client via a remote shell (by specifying both the
"-e/--rsh" option and server mode with "::" or "rsync://"), the --daemon
option is automatically passed to the remote side.
When run via inetd you should add a line like this to /etc/services:
@@ -68,7 +69,7 @@ your system. You will then need to send inetd a HUP signal to tell it to
reread its config file.
Note that you should not send the rsync server a HUP signal to force
it to reread the tt(/etc/rsyncd.conf). The file is re-read on each client
it to reread the tt(rsyncd.conf) file. The file is re-read on each client
connection.
manpagesection(GLOBAL OPTIONS)
@@ -127,28 +128,30 @@ of available modules. The default is no comment.
dit(bf(path)) The "path" option specifies the directory in the servers
filesystem to make available in this module. You must specify this option
for each module in tt(/etc/rsyncd.conf).
for each module in tt(rsyncd.conf).
dit(bf(use chroot)) If "use chroot" is true, the rsync server will chroot
to the "path" before starting the file transfer with the client. This has
the advantage of extra protection against possible implementation security
holes, but it has the disadvantages of requiring super-user privileges and
holes, but it has the disadvantages of requiring super-user privileges,
of not being able to follow symbolic links outside of the new root path
when reading. 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 absolute paths. The
default for "use chroot" is true.
when reading, and of implying the --numeric-ids option because /etc/passwd
becomes inaccessible. 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 absolute paths. The default for
"use chroot" is true.
dit(bf(max connections)) The "max connections" option allows you to
specify the maximum number of simultaneous connections you will allow
to this module of your rsync server. Any clients connecting when the
maximum has been reached will receive a message telling them to try
later. The default is 0 which means no limit.
specify the maximum number of simultaneous connections you will allow.
Any clients connecting when the maximum has been reached will receive a
message telling them to try later. The default is 0 which means no limit.
See also the "lock file" option.
dit(bf(lock file)) The "lock file" option specifies the file to use to
support the "max connections" option. The rsync server uses record
locking on this file to ensure that the max connections limit is not
exceeded. The default is tt(/var/run/rsyncd.lock).
exceeded for the modules sharing the lock file.
The default is tt(/var/run/rsyncd.lock).
dit(bf(read only)) The "read only" option determines whether clients
will be able to upload files or not. If "read only" is true then any
@@ -173,12 +176,17 @@ was run as root. This complements the "uid" option. The default is gid -2,
which is normally the group "nobody".
dit(bf(exclude)) The "exclude" option allows you to specify a space
separated list of patterns to add to the exclude list. This is
equivalent to the client specifying these patterns with the --exclude
option except that the exclude list is not passed to the client and
thus only apply on the server. Only one "exclude" option may be
specified, but you can use "-" and "+" before patterns to specify
exclude/include.
separated list of patterns to add to the exclude list.
This is only superficially equivalent
to the client specifying these patterns with the --exclude option.
Only one "exclude" option may be specified, but
you can use "-" and "+" before patterns to specify exclude/include.
Because this exclude list is not passed to the client it only applies on
the 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 sent from a client when sending to a server or
files deleted on a client when receiving from a server.
Note that this option is not designed with strong security in
mind, it is quite possible that a client may find a way to bypass this
@@ -187,26 +195,25 @@ cannot be accessed then use the uid/gid options in combination with
file permissions.
dit(bf(exclude from)) The "exclude from" option specifies a filename
on the server that contains exclude patterns, one per line. This is
equivalent to the client specifying the --exclude-from option with a
equivalent file except that the resulting exclude patterns are not
passed to the client and thus only apply on the server. See also the
note about security for the exclude option above.
on the server that contains exclude patterns, one per line.
This is only superficially equivalent
to the client specifying the --exclude-from option with an equivalent file.
See the "exclude" option above.
dit(bf(include)) The "include" option allows you to specify a space
separated list of patterns which rsync should not exclude. This is
equivalent to the client specifying these patterns with the --include
option. This is useful as it allows you to build up quite complex
exclude/include rules. Only one "include" option may be specified, but you
can use "+" and "-" before patterns to switch include/exclude.
See the section of exclude patterns in the rsync man page for information
on the syntax of this option.
only superficially equivalent to the client specifying these patterns
with the --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(include from)) The "include from" option specifies a filename
on the server that contains include patterns, one per line. This is
equivalent to the client specifying the --include-from option with a
equivalent file.
only superficially equivalent to the client specifying the
--include-from option with a equivalent file.
See the "exclude" option above.
dit(bf(auth users)) The "auth users" option specifies a comma and
space separated list of usernames that will be allowed to connect to
@@ -219,6 +226,11 @@ usernames are passwords are stored in the file specified by the
"secrets file" option. The default is for all users to be able to
connect without a password (this is called "anonymous rsync").
See also the bf(CONNECTING TO AN RSYNC SERVER OVER A REMOTE SHELL
PROGRAM) section in rsync(1) for information on how handle an
rsyncd.conf-level username that differs from the remote-shell-level
username when using a remote shell to connect to a rsync server.
dit(bf(secrets file)) The "secrets file" option specifies the name of
a file that contains the username:password pairs used for
authenticating this module. This file is only consulted if the "auth
@@ -248,16 +260,18 @@ connection is rejected.
Each pattern can be in one of five forms:
itemize(
it() a dotted decimal IP address. In this case the incoming machines
IP address must match exactly.
it() a dotted decimal IPv4 address of the form a.b.c.d, or an IPv6 address
of the form a:b:c::d:e:f. In this case the incoming machine's IP address
must match exactly.
it() a address/mask in the form a.b.c.d/n were n is the number of
one bits in in the netmask. All IP addresses which match the masked
IP address will be allowed in.
it() an address/mask in the form ipaddr/n where ipaddr is the IP address
and n is the number of one bits in the netmask. All IP addresses which
match the masked IP address will be allowed in.
it() a address/mask in the form a.b.c.d/e.f.g.h where e.f.g.h is a
netmask in dotted decimal notation. All IP addresses which match the masked
IP address will be allowed in.
it() an address/mask in the form ipaddr/maskaddr where ipaddr is the
IP address and maskaddr is the netmask in dotted decimal notation for IPv4,
or similar for IPv6, e.g. ffff:ffff:ffff:ffff:: instead of /64. All IP
addresses which match the masked IP address will be allowed in.
it() a hostname. The hostname as determined by a reverse lookup will
be matched (case insensitive) against the pattern. Only an exact
@@ -268,6 +282,12 @@ itemize(
then the client is allowed in.
)
Note IPv6 link-local addresses can have a scope in the address specification:
quote(fe80::1%link1)
quote(fe80::%link1/64)
quote(fe80::%link1/ffff:ffff:ffff:ffff::)
You can also combine "hosts allow" with a separate "hosts deny"
option. If both options are specified then the "hosts allow" option s
checked first and a match results in the client being able to
@@ -372,13 +392,39 @@ It should be good enough for most purposes but if you want really top
quality security then I recommend that you run rsync over ssh.
Also note that the rsync server protocol does not currently provide any
encryption of the data that is transferred over the link. Only
encryption of the data that is transferred over the connection. Only
authentication is provided. Use ssh as the transport if you want
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 --daemon and --rsh (-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(rsync --server --daemon .)
NOTE: rsync's argument parsing expects the trailing ".", so make sure
that it's there. If you want to use a rsyncd.conf(5)-style
configuration file other than the default, you can added a
--config option to the em(command):
quote(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 --server option under normal circumstances.
manpagesection(EXAMPLES)
A simple rsyncd.conf file that allow anonymous rsync to a ftp area at
@@ -430,7 +476,7 @@ susan:herpass
manpagefiles()
/etc/rsyncd.conf
/etc/rsyncd.conf or rsyncd.conf
manpageseealso()
@@ -448,7 +494,7 @@ Please report bugs! The rsync bug tracking system is online at
url(http://rsync.samba.org/)(http://rsync.samba.org/)
manpagesection(VERSION)
This man page is current for version 2.0 of rsync
This man page is current for version 2.x of rsync.
manpagesection(CREDITS)

View File

@@ -125,6 +125,9 @@ set -e
RUNSHFLAGS='-e'
# for Solaris
PATH="/usr/xpg4/bin/:$PATH"
if [ -n "$loglevel" ] && [ "$loglevel" -gt 8 ]
then
if set -x
@@ -139,6 +142,20 @@ echo "$0 running in `pwd`"
echo " rsync_bin=$rsync_bin"
echo " srcdir=$srcdir"
testuser=`whoami || echo UNKNOWN`
echo " testuser=$testuser"
echo " os=`uname -a`"
# It must be "yes", not just nonnull
if test "x$preserve_scratch" = xyes
then
echo " preserve_scratch=yes"
else
echo " preserve_scratch=no"
fi
if test ! -f $rsync_bin
then
echo "rsync_bin $rsync_bin is not a file" >&2
@@ -176,8 +193,8 @@ prep_scratch() {
return 0
}
discard_scratch() {
[ -d "$scratchdir" ] && rm -rf "$scratchdir"
maybe_discard_scratch() {
[ x"$preserve_scratch" != xyes ] && [ -d "$scratchdir" ] && rm -rf "$scratchdir"
return 0
}
@@ -198,16 +215,25 @@ do
result=$?
set -e
if [ "x$always_log" = xyes -o \( $result != 0 -a $result != 77 -a $result != 78 \) ]
then
echo "----- $testbase log follows"
cat "$scratchdir/test.log"
echo "----- $testbase log ends"
fi
case $result in
0)
echo "PASS $testbase"
passed=`expr $passed + 1`
discard_scratch
maybe_discard_scratch
;;
77)
echo "SKIP $testbase"
# backticks will fill the whole file onto one line, which is a feature
whyskipped=`cat "$scratchdir/whyskipped"`
echo "SKIP $testbase ($whyskipped)"
skipped=`expr $skipped + 1`
discard_scratch
maybe_discard_scratch
;;
78)
# It failed, but we expected that. don't dump out error logs,
@@ -218,9 +244,6 @@ do
;;
*)
echo "FAIL $testbase"
echo "----- $testbase failed: log follows"
cat "$scratchdir/test.log"
echo "----- $testbase log ends"
failed=`expr $failed + 1`
if [ "x$nopersist" = "xyes" ]
then

287
sender.c
View File

@@ -1,17 +1,17 @@
/*
/*
Copyright (C) Andrew Tridgell 1996
Copyright (C) Paul Mackerras 1996
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -20,7 +20,6 @@
#include "rsync.h"
extern int verbose;
extern int remote_version;
extern int csum_length;
extern struct stats stats;
extern int io_error;
@@ -28,50 +27,78 @@ extern int dry_run;
extern int am_server;
/*
receive the checksums for a buffer
*/
/**
* @file
*
* The sender gets checksums from the generator, calculates deltas,
* and transmits them to the receiver. The sender process runs on the
* machine holding the source files.
**/
void read_sum_head(int f, struct sum_struct *sum)
{
extern int protocol_version;
sum->count = read_int(f);
sum->blength = read_int(f);
if (protocol_version < 27) {
sum->s2length = csum_length;
} else {
sum->s2length = read_int(f);
if (sum->s2length > MD4_SUM_LENGTH) {
rprintf(FERROR, "Invalid checksum length %ld\n",
(long)sum->s2length);
exit_cleanup(RERR_PROTOCOL);
}
}
sum->remainder = read_int(f);
}
/**
* Receive the checksums for a buffer
**/
static struct sum_struct *receive_sums(int f)
{
struct sum_struct *s;
int i;
OFF_T offset = 0;
s = (struct sum_struct *)malloc(sizeof(*s));
s = new(struct sum_struct);
if (!s) out_of_memory("receive_sums");
s->count = read_int(f);
s->n = read_int(f);
s->remainder = read_int(f);
read_sum_head(f, s);
s->sums = NULL;
if (verbose > 3)
rprintf(FINFO,"count=%d n=%d rem=%d\n",
s->count,s->n,s->remainder);
rprintf(FINFO, "count=%ld n=%ld rem=%ld\n",
(long) s->count, (long) s->blength,
(long) s->remainder);
if (s->count == 0)
if (s->count == 0)
return(s);
s->sums = (struct sum_buf *)malloc(sizeof(s->sums[0])*s->count);
s->sums = new_array(struct sum_buf, s->count);
if (!s->sums) out_of_memory("receive_sums");
for (i=0;i<s->count;i++) {
for (i = 0; i < (int) s->count; i++) {
s->sums[i].sum1 = read_int(f);
read_buf(f,s->sums[i].sum2,csum_length);
read_buf(f, s->sums[i].sum2, s->s2length);
s->sums[i].offset = offset;
s->sums[i].i = i;
if (i == s->count-1 && s->remainder != 0) {
if (i == (int) s->count-1 && s->remainder != 0) {
s->sums[i].len = s->remainder;
} else {
s->sums[i].len = s->n;
s->sums[i].len = s->blength;
}
offset += s->sums[i].len;
if (verbose > 3)
rprintf(FINFO,"chunk[%d] len=%d offset=%.0f sum1=%08x\n",
i,s->sums[i].len,(double)s->sums[i].offset,s->sums[i].sum1);
rprintf(FINFO, "chunk[%d] len=%d offset=%.0f sum1=%08x\n",
i, s->sums[i].len, (double)s->sums[i].offset, s->sums[i].sum1);
}
s->flength = offset;
@@ -81,17 +108,17 @@ static struct sum_struct *receive_sums(int f)
void send_files(struct file_list *flist,int f_out,int f_in)
{
void send_files(struct file_list *flist, int f_out, int f_in)
{
int fd = -1;
struct sum_struct *s;
struct map_struct *buf = NULL;
STRUCT_STAT st;
char fname[MAXPATHLEN];
char fname[MAXPATHLEN];
int i;
struct file_struct *file;
int phase = 0;
extern struct stats stats;
extern struct stats stats;
struct stats initial_stats;
extern int write_batch; /* dw */
extern int read_batch; /* dw */
@@ -102,26 +129,26 @@ void send_files(struct file_list *flist,int f_out,int f_in)
int done; /* dw */
if (verbose > 2)
rprintf(FINFO,"send_files starting\n");
rprintf(FINFO, "send_files starting\n");
while (1) {
int offset=0;
int offset = 0;
i = read_int(f_in);
if (i == -1) {
if (phase==0 && remote_version >= 13) {
if (phase == 0) {
phase++;
csum_length = SUM_LENGTH;
write_int(f_out,-1);
write_int(f_out, -1);
if (verbose > 2)
rprintf(FINFO,"send_files phase=%d\n",phase);
rprintf(FINFO, "send_files phase=%d\n", phase);
continue;
}
break;
}
if (i < 0 || i >= flist->count) {
rprintf(FERROR,"Invalid file index %d (count=%d)\n",
rprintf(FERROR, "Invalid file index %d (count=%d)\n",
i, flist->count);
exit_cleanup(RERR_PROTOCOL);
}
@@ -133,26 +160,26 @@ void send_files(struct file_list *flist,int f_out,int f_in)
fname[0] = 0;
if (file->basedir) {
strlcpy(fname,file->basedir,MAXPATHLEN);
strlcpy(fname, file->basedir, MAXPATHLEN);
if (strlen(fname) == MAXPATHLEN-1) {
io_error = 1;
io_error |= IOERR_GENERAL;
rprintf(FERROR, "send_files failed on long-named directory %s\n",
fname);
full_fname(fname));
return;
}
strlcat(fname,"/",MAXPATHLEN);
strlcat(fname, "/", MAXPATHLEN);
offset = strlen(file->basedir)+1;
}
strlcat(fname,f_name(file),MAXPATHLEN);
if (verbose > 2)
rprintf(FINFO,"send_files(%d,%s)\n",i,fname);
if (dry_run) {
if (!am_server) {
log_transfer(file, fname+offset);
strlcat(fname, f_name(file), MAXPATHLEN);
if (verbose > 2)
rprintf(FINFO, "send_files(%d, %s)\n", i, fname);
if (dry_run) {
if (!am_server && verbose) { /* log transfer */
rprintf(FINFO, "%s\n", fname+offset);
}
write_int(f_out,i);
write_int(f_out, i);
continue;
}
@@ -160,129 +187,135 @@ void send_files(struct file_list *flist,int f_out,int f_in)
s = receive_sums(f_in);
if (!s) {
io_error = 1;
rprintf(FERROR,"receive_sums failed\n");
io_error |= IOERR_GENERAL;
rprintf(FERROR, "receive_sums failed\n");
return;
}
if (write_batch)
write_batch_csum_info(&i,flist->count,s);
write_batch_csum_info(&i, flist->count, s);
if (!read_batch) {
fd = do_open(fname, O_RDONLY, 0);
if (fd == -1) {
io_error = 1;
rprintf(FERROR,"send_files failed to open %s: %s\n",
fname,strerror(errno));
if (errno == ENOENT) {
io_error |= IOERR_VANISHED;
rprintf(FINFO, "file has vanished: %s\n",
full_fname(fname));
} else {
io_error |= IOERR_GENERAL;
rprintf(FERROR, "send_files failed to open %s: %s\n",
full_fname(fname), strerror(errno));
}
free_sums(s);
continue;
}
/* map the local file */
if (do_fstat(fd,&st) != 0) {
io_error = 1;
rprintf(FERROR,"fstat failed : %s\n",strerror(errno));
if (do_fstat(fd, &st) != 0) {
io_error |= IOERR_GENERAL;
rprintf(FERROR, "fstat failed: %s\n", strerror(errno));
free_sums(s);
close(fd);
return;
}
if (st.st_size > 0) {
buf = map_file(fd,st.st_size);
buf = map_file(fd, st.st_size);
} else {
buf = NULL;
}
if (verbose > 2)
rprintf(FINFO,"send_files mapped %s of size %.0f\n",
fname,(double)st.st_size);
rprintf(FINFO, "send_files mapped %s of size %.0f\n",
fname, (double)st.st_size);
write_int(f_out, i);
write_int(f_out,i);
if (write_batch)
write_batch_delta_file((char *)&i,sizeof(i));
write_batch_delta_file((char *)&i, sizeof(i));
write_int(f_out,s->count);
write_int(f_out,s->n);
write_int(f_out,s->remainder);
write_sum_head(f_out, s);
}
if (verbose > 2)
if (!read_batch)
rprintf(FINFO,"calling match_sums %s\n",fname);
if (!am_server) {
log_transfer(file, fname+offset);
if (verbose > 2 && !read_batch)
rprintf(FINFO, "calling match_sums %s\n", fname);
if (!am_server && verbose) { /* log transfer */
rprintf(FINFO, "%s\n", fname+offset);
}
set_compression(fname);
if (read_batch) { /* dw */
/* read checksums originally computed on sender side */
read_batch_csum_info(i, s, &checksums_match);
if (checksums_match) {
read_batch_delta_file( (char *) &j, sizeof(int) );
if (j != i) { /* if flist index entries don't match*/
rprintf(FINFO,"index mismatch in send_files\n");
rprintf(FINFO,"read index = %d flist ndx = %d\n",j,i);
close_batch_delta_file();
close_batch_csums_file();
exit_cleanup(1);
}
else {
write_int(f_out,j);
write_int(f_out,s->count);
write_int(f_out,s->n);
write_int(f_out,s->remainder);
done=0;
while (!done) {
read_batch_delta_file( (char *) &buff_len, sizeof(int) );
write_int(f_out,buff_len);
if (buff_len == 0) {
done = 1;
}
else {
if (buff_len > 0) {
read_batch_delta_file(buff, buff_len);
write_buf(f_out,buff,buff_len);
}
}
} /* end while */
read_batch_delta_file( buff, MD4_SUM_LENGTH);
write_buf(f_out, buff, MD4_SUM_LENGTH);
if (read_batch) { /* dw */
/* read checksums originally computed on sender side */
read_batch_csum_info(i, s, &checksums_match);
if (checksums_match) {
read_batch_delta_file( (char *) &j, sizeof(int) );
if (j != i) { /* if flist index entries don't match*/
rprintf(FINFO, "index mismatch in send_files\n");
rprintf(FINFO, "read index = %d flist ndx = %d\n", j, i);
close_batch_delta_file();
close_batch_csums_file();
exit_cleanup(1);
} else {
write_int(f_out, j);
write_sum_head(f_out, s);
done = 0;
while (!done) {
read_batch_delta_file( (char *) &buff_len, sizeof(int) );
write_int(f_out, buff_len);
if (buff_len == 0) {
done = 1;
} else {
if (buff_len > 0) {
read_batch_delta_file(buff, buff_len);
write_buf(f_out, buff, buff_len);
}
}
} /* end while */
read_batch_delta_file( buff, MD4_SUM_LENGTH);
write_buf(f_out, buff, MD4_SUM_LENGTH);
} /* j=i */
} else { /* not checksum match */
rprintf (FINFO,"readbatch & checksums don't match\n");
rprintf (FINFO,"filename=%s is being skipped\n",
fname);
continue;
}
} else {
match_sums(f_out,s,buf,st.st_size);
log_send(file, &initial_stats);
}
} /* j=i */
} else { /* not checksum match */
rprintf (FINFO, "readbatch & checksums don't match\n");
rprintf (FINFO, "filename=%s is being skipped\n", fname);
continue;
}
} else {
match_sums(f_out, s, buf, st.st_size);
log_send(file, &initial_stats);
}
if (!read_batch) { /* dw */
if (buf) unmap_file(buf);
close(fd);
if (buf) {
j = unmap_file(buf);
if (j) {
io_error |= IOERR_GENERAL;
rprintf(FERROR,
"read errors mapping %s: (%d) %s\n",
full_fname(fname), j, strerror(j));
}
}
close(fd);
}
free_sums(s);
if (verbose > 2)
rprintf(FINFO,"sender finished %s\n",fname);
rprintf(FINFO, "sender finished %s\n", fname);
}
if (verbose > 2)
rprintf(FINFO,"send files finished\n");
rprintf(FINFO, "send files finished\n");
match_report();
write_int(f_out,-1);
write_int(f_out, -1);
if (write_batch || read_batch) { /* dw */
close_batch_csums_file();
close_batch_delta_file();
close_batch_csums_file();
close_batch_delta_file();
}
}

View File

@@ -34,8 +34,10 @@
#include "rsync.h"
/* Establish a proxy connection on an open socket to a web roxy by
* using the CONNECT method. */
/**
* Establish a proxy connection on an open socket to a web proxy by
* using the HTTP CONNECT method.
**/
static int establish_proxy_connection(int fd, char *host, int port)
{
char buffer[1024];
@@ -68,7 +70,7 @@ static int establish_proxy_connection(int fd, char *host, int port)
buffer);
return -1;
}
for (cp = &buffer[5]; isdigit(*cp) || (*cp == '.'); cp++)
for (cp = &buffer[5]; isdigit(* (unsigned char *) cp) || (*cp == '.'); cp++)
;
while (*cp == ' ')
cp++;
@@ -122,12 +124,14 @@ int try_bind_local(int s,
for (r = bres_all; r; r = r->ai_next) {
if (bind(s, r->ai_addr, r->ai_addrlen) == -1)
continue;
freeaddrinfo(bres_all);
return s;
}
/* no error message; there might be some problem that allows
* creation of the socket but not binding, perhaps if the
* machine has no ipv6 address of this name. */
freeaddrinfo(bres_all);
return -1;
}
@@ -182,6 +186,10 @@ int open_socket_out(char *host, int port, const char *bind_address,
*cp++ = '\0';
strcpy(portbuf, cp);
h = buffer;
if (verbose >= 2) {
rprintf(FINFO, "connection via http proxy %s port %s\n",
h, portbuf);
}
} else {
snprintf(portbuf, sizeof(portbuf), "%d", port);
h = host;
@@ -325,7 +333,8 @@ static int open_socket_in(int type, int port, const char *bind_address,
close(s);
continue;
}
freeaddrinfo(all_ai);
return s;
}
@@ -365,7 +374,16 @@ int is_a_socket(int fd)
}
void start_accept_loop(int port, int (*fn)(int ))
static RETSIGTYPE sigchld_handler(UNUSED(int val))
{
signal(SIGCHLD, sigchld_handler);
#ifdef WNOHANG
while (waitpid(-1, NULL, WNOHANG) > 0) {}
#endif
}
void start_accept_loop(int port, int (*fn)(int, int))
{
int s;
extern char *bind_address;
@@ -387,6 +405,7 @@ void start_accept_loop(int port, int (*fn)(int ))
for each incoming connection */
while (1) {
fd_set fds;
pid_t pid;
int fd;
struct sockaddr_storage addr;
socklen_t addrlen = sizeof addr;
@@ -409,24 +428,31 @@ void start_accept_loop(int port, int (*fn)(int ))
if (fd == -1) continue;
signal(SIGCHLD, SIG_IGN);
signal(SIGCHLD, sigchld_handler);
/* we shouldn't have any children left hanging around
but I have had reports that on Digital Unix zombies
are produced, so this ensures that they are reaped */
#ifdef WNOHANG
while (waitpid(-1, NULL, WNOHANG) > 0);
#endif
if (fork()==0) {
if ((pid = fork()) == 0) {
int ret;
close(s);
/* open log file in child before possibly giving
up privileges */
log_open();
_exit(fn(fd));
ret = fn(fd, fd);
close_all();
_exit(ret);
} else if (pid < 0) {
rprintf(FERROR,
RSYNC_NAME
": could not create child server process: %s\n",
strerror(errno));
close(fd);
/* This might have happened because we're
* overloaded. Sleep briefly before trying to
* accept again. */
sleep(2);
} else {
/* Parent doesn't need this fd anymore. */
close(fd);
}
close(fd);
}
}
@@ -475,9 +501,9 @@ struct
/****************************************************************************
set user socket options
****************************************************************************/
/**
* Set user socket options
**/
void set_socket_options(int fd, char *options)
{
char *tok;
@@ -535,9 +561,9 @@ void set_socket_options(int fd, char *options)
free(options);
}
/****************************************************************************
become a daemon, discarding the controlling terminal
****************************************************************************/
/**
* Become a daemon, discarding the controlling terminal
**/
void become_daemon(void)
{
int i;
@@ -567,14 +593,15 @@ void become_daemon(void)
}
/*******************************************************************
this is like socketpair but uses tcp. It is used by the Samba
regression test code
The function guarantees that nobody else can attach to the socket,
or if they do that this function fails and the socket gets closed
returns 0 on success, -1 on failure
the resulting file descriptors are symmetrical
******************************************************************/
/**
* This is like socketpair but uses tcp. It is used by the Samba
* regression test code.
*
* The function guarantees that nobody else can attach to the socket,
* or if they do that this function fails and the socket gets closed
* returns 0 on success, -1 on failure the resulting file descriptors
* are symmetrical.
**/
static int socketpair_tcp(int fd[2])
{
int listener;
@@ -590,7 +617,7 @@ static int socketpair_tcp(int fd[2])
if ((listener = socket(PF_INET, SOCK_STREAM, 0)) == -1) goto failed;
memset(&sock2, 0, sizeof(sock2));
#ifdef HAVE_SOCK_SIN_LEN
#ifdef HAVE_SOCKADDR_LEN
sock2.sin_len = sizeof(sock2);
#endif
sock2.sin_family = PF_INET;

View File

@@ -1,5 +1,6 @@
/*
Copyright (C) Andrew Tridgell 1998
Copyright (C) 2002 by Martin Pool
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -16,15 +17,19 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
syscall wrappers to ensure that nothing gets done in dry_run mode
*/
/**
* @file syscall.c
*
* Syscall wrappers to ensure that nothing gets done in dry_run mode
* and to handle system peculiarities.
**/
#include "rsync.h"
extern int dry_run;
extern int read_only;
extern int list_only;
extern int preserve_perms;
#define CHECK_RO if (read_only || list_only) {errno = EROFS; return -1;}
@@ -80,22 +85,22 @@ int do_open(char *pathname, int flags, mode_t mode)
if (dry_run) return -1;
CHECK_RO
}
#ifdef O_BINARY
/* for Windows */
flags |= O_BINARY;
#endif
/* some systems can't handle a double / */
if (pathname[0] == '/' && pathname[1] == '/') pathname++;
return open(pathname, flags, mode);
return open(pathname, flags | O_BINARY, mode);
}
#if HAVE_CHMOD
int do_chmod(const char *path, mode_t mode)
{
int code;
if (dry_run) return 0;
CHECK_RO
return chmod(path, mode);
code = chmod(path, mode);
if ((code != 0) && preserve_perms)
return code;
return 0;
}
#endif
@@ -106,13 +111,36 @@ int do_rename(char *fname1, char *fname2)
return rename(fname1, fname2);
}
void trim_trailing_slashes(char *name)
{
int l;
/* Some BSD systems cannot make a directory if the name
* contains a trailing slash.
* <http://www.opensource.apple.com/bugs/X/BSD%20Kernel/2734739.html> */
/* Don't change empty string; and also we can't improve on
* "/" */
l = strlen(name);
while (l > 1) {
if (name[--l] != '/')
break;
name[l] = '\0';
}
}
int do_mkdir(char *fname, mode_t mode)
{
if (dry_run) return 0;
CHECK_RO
if (dry_run)
return 0;
CHECK_RO;
trim_trailing_slashes(fname);
return mkdir(fname, mode);
}
/* like mkstemp but forces permissions */
int do_mkstemp(char *template, mode_t perms)
{
@@ -123,7 +151,7 @@ int do_mkstemp(char *template, mode_t perms)
{
int fd = mkstemp(template);
if (fd == -1) return -1;
if (fchmod(fd, perms) != 0) {
if ((fchmod(fd, perms) != 0) && preserve_perms) {
close(fd);
unlink(template);
return -1;

70
t_stub.c Normal file
View File

@@ -0,0 +1,70 @@
/* -*- c-file-style: "linux" -*-
*
* Copyright (C) 2001, 2002 by Martin Pool <mbp@samba.org>
*
* This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "rsync.h"
/**
* @file t_stub.c
*
* This file contains really simple implementations for rsync global
* functions, so that module test harnesses can run standalone.
**/
int modify_window = 0;
int module_id = -1;
struct exclude_struct **server_exclude_list;
void rprintf(UNUSED(enum logcode code), const char *format, ...)
{
va_list ap;
va_start(ap, format);
vfprintf(stderr, format, ap);
va_end(ap);
}
void _exit_cleanup(int code, const char *file, int line)
{
fprintf(stderr, "exit(%d): %s(%d)\n",
code, file, line);
exit(code);
}
int check_exclude(UNUSED(struct exclude_struct **list), UNUSED(char *name),
UNUSED(int name_is_dir))
{
/* This function doesn't really get called in this test context, so
* just return 0. */
return 0;
}
char *lp_name(UNUSED(int mod))
{
return NULL;
}
BOOL lp_use_chroot(UNUSED(int mod))
{
return 0;
}
char *lp_path(UNUSED(int mod))
{
return NULL;
}

46
t_unsafe.c Normal file
View File

@@ -0,0 +1,46 @@
/*
* 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
*
* Test harness for unsafe_symlink(). Not linked into @c rsync itself.
*
* Prints either "safe" or "unsafe" depending on the two arguments.
* Always returns 0 unless something extraordinary happens.
**/
#include "rsync.h"
int dry_run, read_only, list_only, verbose;
int preserve_perms = 0;
int
main(int argc, char **argv)
{
if (argc != 3) {
fprintf(stderr, "usage: t_unsafe LINKDEST SRCDIR\n");
return 1;
}
printf("%s\n",
unsafe_symlink(argv[1], argv[2]) ? "unsafe" : "safe");
return 0;
}

133
testhelp/maketree.py Normal file
View File

@@ -0,0 +1,133 @@
#! /usr/bin/python2.2
# 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 version
# 2 as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
# Populate a tree with pseudo-randomly distributed files to test
# rsync.
from __future__ import generators
import random, string, os, os.path
nfiles = 10000
depth = 5
n_children = 20
n_files = 20
n_symlinks = 10
name_chars = string.digits + string.letters
abuffer = 'a' * 1024
def random_name_chars():
a = ""
for i in range(10):
a = a + random.choice(name_chars)
return a
def generate_names():
n = 0
while 1:
yield "%05d_%s" % (n, random_name_chars())
n += 1
class TreeBuilder:
def __init__(self):
self.n_children = 20
self.n_files = 100
self.total_entries = 100000 # long(1e8)
self.actual_size = 0
self.name_gen = generate_names()
self.all_files = []
self.all_dirs = []
self.all_symlinks = []
def random_size(self):
return random.lognormvariate(4, 4)
def random_symlink_target(self):
what = random.choice(['directory', 'file', 'symlink', 'none'])
try:
if what == 'directory':
return random.choice(self.all_dirs)
elif what == 'file':
return random.choice(self.all_files)
elif what == 'symlink':
return random.choice(self.all_symlinks)
elif what == 'none':
return self.name_gen.next()
except IndexError:
return self.name_gen.next()
def can_continue(self):
self.total_entries -= 1
return self.total_entries > 0
def build_tree(self, prefix, depth):
"""Generate a breadth-first tree"""
for count, function in [[n_files, self.make_file],
[n_children, self.make_child_recurse],
[n_symlinks, self.make_symlink]]:
for i in range(count):
if not self.can_continue():
return
name = os.path.join(prefix, self.name_gen.next())
function(name, depth)
def print_summary(self):
print "total bytes: %d" % self.actual_size
def make_child_recurse(self, dname, depth):
if depth > 1:
self.make_dir(dname)
self.build_tree(dname, depth-1)
def make_dir(self, dname, depth='ignore'):
print "%s/" % (dname)
os.mkdir(dname)
self.all_dirs.append(dname)
def make_symlink(self, lname, depth='ignore'):
print "%s -> %s" % (lname, self.random_symlink_target())
def make_file(self, fname, depth='ignore'):
size = long(self.random_size())
print "%-70s %d" % (fname, size)
f = open(fname, 'w')
f.truncate(size)
self.fill_file(f, size)
self.all_files.append(fname)
self.actual_size += size
def fill_file(self, f, size):
while size > 0:
f.write(abuffer[:size])
size -= len(abuffer)
tb = TreeBuilder()
tb.build_tree('/tmp/foo', 3)
tb.print_summary()

View File

@@ -2,4 +2,4 @@
echo $0 running
"$rsync_bin" --version || exit 1
$RSYNC --version || exit 1

View File

@@ -1,7 +0,0 @@
This directory contains automatic test cases for rsync. You can run
them yourself if you want, preferably by doing "make check" in the
top-level source directory. (Not implemented yet.)
They also run automatically on the build farm, and you can see the
results on http://build.samba.org/. That's controlled by the file
./runlist.

View File

@@ -0,0 +1,30 @@
automatic testsuite for rsync -*- text -*-
We're trying to develop some more substantial tests to prevent rsync
regressions. Ideally, all code changes or bug reports would come with
an appropriate test suite.
You can run these tests by typing "make check" in the build directory.
The tests will run using the rsync binary in the build directory, so
you do not need to do "make install" first. Indeed, you probably
should not install rsync before running the tests.
If you instead type "make installcheck" then the suite will test the
rsync binary from its installed location (e.g. /usr/local/bin/rsync).
You can use this to test a distribution build, or perhaps to run a new
test suite against an old version of rsync. Note that in accordance
with the GNU Standards, installcheck does not look for rsync on the
path.
If the tests pass, you should see a report to that effect. Some tests
require being root or some other precondition, and so will normally be
checked -- look at the test scripts for more information.
If the tests fail, you will see rather more output. The scratch
directory will remain in the build directory. It would be useful if
you could include the log messages when reporting a failure.
These tests also run automatically on the build farm, and you can see
the results on http://build.samba.org/.

38
testsuite/chgrp.test Normal file
View File

@@ -0,0 +1,38 @@
#! /bin/sh
# Copyright (C) 2002 by Martin Pool <mbp@samba.org>
# This program is distributable under the terms of the GNU GPL (see
# COPYING).
# Test that rsync with -gr will preserve groups when the user running
# the test is a member of them. Hopefully they're in at least one
# test.
. $srcdir/testsuite/rsync.fns
set -x
# Build some hardlinks
fromdir="$scratchdir/from"
todir="$scratchdir/to"
# TODO: I guess some systems will not have 'id', and therefore we have
# to ship or emulate it.
mygrps="`rsync_getgroups`" || fail "Can't get groups"
mkdir "$fromdir"
for g in $mygrps
do
name="$fromdir/foo-$g"
date > "$name"
chgrp "$g" "$name" || fail "Can't chgrp"
done
sleep 2
checkit "$RSYNC -rtgvvv \"$fromdir/\" \"$todir/\"" "$fromdir" "$todir"
exit 0
# last [] may have failed but if we get here then we've won

38
testsuite/chown.test Normal file
View File

@@ -0,0 +1,38 @@
#! /bin/sh
# Copyright (C) 2002 by Martin Pool <mbp@samba.org>
# This program is distributable under the terms of the GNU GPL (see
# COPYING).
# Test that when rsync is running as root and has -a it correctly sets
# the ownership of the destination.
# We don't know what users will be present on this system, so we just
# use random numeric uids and gids.
. $srcdir/testsuite/rsync.fns
set -x
# Build some hardlinks
fromdir="$scratchdir/from"
todir="$scratchdir/to"
mkdir "$fromdir"
name1="$fromdir/name1"
name2="$fromdir/name2"
echo "This is the file" > "$name1"
echo "This is the other file" > "$name2"
chown 5000 "$name1" || test_skipped "Can't chown (probably need root)"
chown 5001 "$name2" || test_skipped "Can't chown (probably need root)"
chgrp 5002 "$name1" || test_skipped "Can't chgrp (probably need root)"
chgrp 5003 "$name2" || test_skipped "Can't chgrp (probably need root)"
checkit "$RSYNC -aHvv \"$fromdir/\" \"$todir/\"" "$fromdir" "$todir"
exit 0
# last [] may have failed but if we get here then we've won

View File

@@ -0,0 +1,31 @@
#!/bin/sh
# Copyright (C) 2001, 2002 by Martin Pool <mbp@samba.org>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License 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 test tries to download a tree over a compressed connection from
# the server. This ought to exercise (exorcise?) a bug in 2.5.3.
. "$suitedir/rsync.fns"
build_rsyncd_conf
RSYNC_CONNECT_PROG="$RSYNC --config=$conf --daemon"
export RSYNC_CONNECT_PROG
hands_setup
checkit "$RSYNC -avvz localhost::test-from/ \"$TO/\"" "$FROM" "$TO"

View File

@@ -0,0 +1,25 @@
#!/bin/sh
# Copyright (C) 2001, 2002 by Martin Pool <mbp@samba.org>
# This program is distributable under the terms of the GNU GPL (see
# COPYING)
# We don't really want to start the server listening, because that
# might interfere with the security or operation of the test machine.
# Instead we use the fake-connect feature to dynamically assign a pair
# of ports.
# This test tries to upload a file over a compressed connection to the
# server. This ought to exercise (exorcise?) a bug in 2.5.3.
. "$suitedir/rsync.fns"
build_rsyncd_conf
RSYNC_CONNECT_PROG="$RSYNC --config=$conf --daemon"
export RSYNC_CONNECT_PROG
hands_setup
checkit "$RSYNC -avvz \"$FROM/\" localhost::test-to/" "$FROM" "$TO"

View File

@@ -26,7 +26,7 @@
build_rsyncd_conf
RSYNC_CONNECT_PROG="$rsync_bin --config=$conf --daemon"
RSYNC_CONNECT_PROG="$RSYNC --config=$conf --daemon"
export RSYNC_CONNECT_PROG
$rsync_bin -v localhost::
$RSYNC -v localhost::

29
testsuite/devices.test Normal file
View File

@@ -0,0 +1,29 @@
#! /bin/sh
# Copyright (C) 2002 by Martin Pool <mbp@samba.org>
# This program is distributable under the terms of the GNU GPL (see
# COPYING).
# Test rsync handling of devices. This can only run if you're root.
. $srcdir/testsuite/rsync.fns
set -x
# Build some hardlinks
fromdir="$scratchdir/from"
todir="$scratchdir/to"
# TODO: Need to test whether hardlinks are possible on this OS/filesystem
mkdir "$fromdir"
mknod "$fromdir/char" c 42 69 || test_skipped "Can't create char device node unless root"
mknod "$fromdir/block" b 42 69 || test_skipped "Can't create block device node unless root"
checkit "$RSYNC -aHvv \"$fromdir/\" \"$todir/\"" "$fromdir" "$todir"
exit 0
# last [] may have failed but if we get here then we've won

View File

@@ -21,9 +21,6 @@
. $srcdir/testsuite/rsync.fns
echo "SKIP THIS FOR NOW; It's a known bug"
exit 77
set -x
# Build some hardlinks
@@ -39,19 +36,18 @@ ln -s "$name1" "$name2" || fail "can't create symlink"
outfile="$scratchdir/rsync.out"
checkit "rsync -avv \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$todir/\"" "$fromdir" "$todir" \
checkit "$RSYNC -avv \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$fromdir/\" \"$todir/\"" "$fromdir" "$todir" \
| tee "$outfile"
# Make sure each file was only copied once...
if [ `grep -c '^name1$' "$outfile"` != 1 ]
then
test_xfail "name1 was not copied exactly once"
test_fail "name1 was not copied exactly once"
fi
if [ `grep -c '^name2$' "$outfile"` != 1 ]
if [ `grep -c '^name2 -> ' "$outfile"` != 1 ]
then
test_xfail "name2 was not copied exactly once"
test_fail "name2 was not copied exactly once"
fi
exit 0
# last [] may have failed but if we get here then we've won

75
testsuite/exclude.test Normal file
View File

@@ -0,0 +1,75 @@
#! /bin/sh
# Copyright (C) 2003 by Wayne Davison <wayned@samba.org>
# This program is distributable under the terms of the GNU GPL see
# COPYING).
# Test rsync handling of exclude/include directives.
# Test some of the more obscure wildcard handling of exclude/include
# processing.
. $srcdir/testsuite/rsync.fns
set -x
# Build some files/dirs/links to copy
fromdir="$scratchdir/from"
todir="$scratchdir/to"
chkdir="$scratchdir/chk"
makepath "$fromdir/foo/down/to/you"
makepath "$fromdir/bar/down/to/foo/too"
makepath "$fromdir/mid/for/foo/and/that/is/who"
echo kept >"$fromdir/foo/file1"
echo removed >"$fromdir/foo/file2"
echo keeper >"$fromdir/bar/down/to/foo/file1"
echo gone >"$fromdir/bar/down/to/foo/file3"
echo lost >"$fromdir/bar/down/to/foo/file4"
echo smashed >"$fromdir/bar/down/to/foo/to"
echo expunged >"$fromdir/mid/for/foo/extra"
echo retained >"$fromdir/mid/for/foo/keep"
ln -s too "$fromdir/bar/down/to/foo/sym"
# Setup our test exclude/include file.
excl="$scratchdir/exclude-from"
cat >"$excl" <<EOF
# If the second line of these two lines does anything, it's a bug.
+ **/bar
- /bar
# This should match against the whole path, not just the name.
+ foo**too
# This should float at the end of the path.
- foo/*/
# Test some normal excludes. Competing lines are paired.
+ t[o]/
- to
+ file4
- file[2-9]
- /mid/for/foo/extra
EOF
# Create the chk dir with what we expect to be excluded
checkit "$RSYNC -avv \"$fromdir/\" \"$chkdir/\"" "$fromdir" "$chkdir"
sleep 1 # Ensures that the rm commands will tweak the directory times.
rm -r "$chkdir"/foo/down
rm -r "$chkdir"/mid/for/foo/and
rm "$chkdir"/foo/file[235-9]
rm "$chkdir"/bar/down/to/foo/to "$chkdir"/bar/down/to/foo/file[235-9]
rm "$chkdir"/mid/for/foo/extra
# Un-tweak the directory times in our first (weak) exclude test (though
# it's a good test of the --existing option).
$RSYNC -av --existing --include='*/' --exclude='*' "$fromdir/" "$chkdir/"
# Now, test if rsync excludes the same files.
checkit "$RSYNC -avv --exclude-from=$excl \"$fromdir/\" \"$todir/\"" "$chkdir" "$todir"
exit 0

View File

@@ -1,7 +1,7 @@
#!/bin/sh
# Copyright (C) 1998,1999 Philip Hands <phil@hands.com>
# Copyright (C) 2001 by Martin Pool <mbp@samba.org>
# Copyright (C) 1998, 1999 by Philip Hands <phil@hands.com>
# Copyright (C) 2001, 2002 by Martin Pool <mbp@samba.org>
#
# This program is distributable under the terms of the GNU GPL (see COPYING)
@@ -25,6 +25,4 @@ runtest "extra data" 'checkit "$RSYNC -avH ${FROM}/ ${TO}" ${FROM}/ ${TO}'
cp ${FROM}/text ${TO}/ThisShouldGo
runtest " --delete" 'checkit "$RSYNC --delete -avH ${FROM}/ ${TO}" ${FROM}/ ${TO}'
checkforlogs ${LOG}.?
hands_cleanup
exit 0

View File

@@ -31,7 +31,7 @@ ln "$name1" "$name2" || fail "Can't create hardlink"
ln "$name2" "$name3" || fail "Can't create hardlink"
cp "$name2" "$name4" || fail "Can't copy file"
checkit "rsync -aHvv \"$fromdir/\" \"$todir/\"" "$fromdir" "$todir"
checkit "$RSYNC -aHvv \"$fromdir/\" \"$todir/\"" "$fromdir" "$todir"
exit 0
# last [] may have failed but if we get here then we've won

View File

@@ -11,9 +11,11 @@
hands_setup
LONGDIR=${FROM}/This-is-a-directory-with-a-stupidly-long-name-created-in-an-attempt-to-provoke-an-error-found-in-2.0.11-that-should-hopefully-never-appear-again-if-this-test-does-its-job/This-is-a-directory-with-a-stupidly-long-name-created-in-an-attempt-to-provoke-an-error-found-in-2.0.11-that-should-hopefully-never-appear-again-if-this-test-does-its-job/This-is-a-directory-with-a-stupidly-long-name-created-in-an-attempt-to-provoke-an-error-found-in-2.0.11-that-should-hopefully-never-appear-again-if-this-test-does-its-job
LONGNAME=This-is-a-directory-with-a-stupidly-long-name-created-in-an-attempt-to-provoke-an-error-found-in-2.0.11-that-should-hopefully-never-appear-again-if-this-test-does-its-job
LONGDIR=$FROM/$LONGNAME/$LONGNAME/$LONGNAME
makepath ${LONGDIR}
makepath $LONGDIR || test_skipped "unable to create long directory"
touch $LONGDIR/1 || test_skipped "unable to create files in long directory"
date > ${LONGDIR}/1
ls -la / > ${LONGDIR}/2
checkit "$RSYNC --delete -avH ${FROM}/ ${TO}" ${FROM}/ ${TO}

View File

@@ -24,6 +24,15 @@ TO=${TMP}/to
LOG=${TMP}/log
RSYNC="$rsync_bin"
# Berkley's nice.
PATH="$PATH:/usr/ucb"
if diff -u $srcdir/testsuite/rsync.fns $srcdir/testsuite/rsync.fns >/dev/null 2>&1; then
diffopt="-u"
else
diffopt="-c"
fi
runtest() {
echo $ECHO_N "Test $1: $ECHO_C"
if eval "$2"
@@ -42,7 +51,11 @@ printmsg() {
rsync_ls_lR() {
find "$@" -print | sort | xargs $TLS
find "$@" -print | sort | xargs "$TOOLDIR/tls"
}
rsync_getgroups() {
"$TOOLDIR/getgroups"
}
@@ -95,13 +108,6 @@ hands_setup() {
}
hands_cleanup() {
rm -r "$TMP"
}
####################
# Many machines do not have "mkdir -p", so we have to build up long paths.
# How boring.
@@ -134,6 +140,11 @@ makepath () {
# Run a test (in '$1') then compare directories $2 and $3 to see if
# there are any difference. If there are, explain them.
# So normally basically $1 should be an rsync command, and $2 and $3
# the source and destination directories. This is only good when you
# expect to transfer the whole directory exactly as is. If some files
# should be excluded, you might need to use something else.
checkit() {
failed=
@@ -150,13 +161,17 @@ checkit() {
echo "-------------"
echo "check how the files compare with diff:"
echo ""
diff -cr $2 $3 || failed=YES
for f in `cd "$2"; find . -type f -print `
do
diff $diffopt "$2"/"$f" "$3"/"$f" || failed=YES
done
echo "-------------"
echo "check how the directory listings compare with diff:"
echo ""
( cd "$2" && rsync_ls_lR . ) > ${TMP}/ls-from
( cd "$3" && rsync_ls_lR . ) > ${TMP}/ls-to
diff -c ${TMP}/ls-from ${TMP}/ls-to || failed=YES
diff $diffopt ${TMP}/ls-from ${TMP}/ls-to || failed=YES
if [ -z "${failed}" ] ; then
return 0
else
@@ -165,21 +180,6 @@ checkit() {
}
# In fact, we need a more general feature of capturing all stderr/log files,
# and dumping them if something goes wrong.
checkforlogs() {
# skip it if we're under debian-test
if test -n "${Debian}" ; then return 0 ; fi
if [ -f $1 -a -s $1 ] ; then
echo "Failures have occurred. $1 follows:" >&2
cat $1 >&2
exit 1
fi
}
build_rsyncd_conf() {
# Build an appropriate configuration file
conf="$scratchdir/test-rsyncd.conf"
@@ -197,10 +197,15 @@ use chroot = no
hosts allow = localhost, 127.0.0.1
log file = $logfile
[test-from] = $scratchdir/daemon-from/
uid = 0
gid = 0
[test-from]
path = $FROM
read only = yes
[test-to] = $scratchdir/daemon-to/
[test-to]
path = $TO
read only = no
EOF
}
@@ -222,6 +227,12 @@ test_fail() {
exit 1
}
test_skipped() {
echo "$@" >&2
echo "$@" > "$TMP/whyskipped"
exit 77
}
# It failed, but we expected that. don't dump out error logs,
# because most users won't want to see them. But do leave
# the working directory around.
@@ -230,5 +241,44 @@ test_xfail() {
exit 78
}
# be reproducible
umask 077
# Determine what shell command will appropriately test for links.
ln -s foo "$scratchdir/testlink"
for cmd in test /bin/test /usr/bin/test /usr/ucb/bin/test /usr/ucb/test
do
for switch in -h -L
do
if $cmd $switch "$scratchdir/testlink" 2>/dev/null
then
# how nice
TEST_SYMLINK_CMD="$cmd $switch"
# i wonder if break 2 is portable?
break 2
fi
done
done
# ok, now get rid of it
rm "$scratchdir/testlink"
if [ "x$TEST_SYMLINK_CMD" = 'x' ]
then
test_fail "Couldn't determine how to test for symlinks"
else
echo "Testing for symlinks using '$TEST_SYMLINK_CMD'"
fi
# Test whether something is a link, allowing for shell peculiarities
is_a_link() {
# note the variable contains the first option and therefore is not quoted
$TEST_SYMLINK_CMD "$1"
}
# We need to set the umask to be reproducible. Note also that when we
# do some daemon tests as root, we will setuid() and therefore the
# directory has to be writable by the nobody user in some cases. The
# best thing is probably to explicitly chmod those directories after
# creation.
umask 022

View File

@@ -12,22 +12,32 @@
if [ "x$rsync_enable_ssh_tests" != xyes ]
then
echo "Skipping SSH tests because \$rsync_enable_ssh_tests is not set"
exit 77
test_skipped "Skipping SSH tests because \$rsync_enable_ssh_tests is not set"
fi
if ! type ssh >/dev/null ; then
echo "Skipping SSH tests because ssh is not in the path"
exit 77
test_skipped "Skipping SSH tests because ssh is not in the path"
fi
if ! [ "`ssh -o'BatchMode yes' localhost echo yes`" = "yes" ]; then
echo "Skipping SSH tests because ssh conection to localhost not authorised"
exit 77
test_skipped "Skipping SSH tests because ssh conection to localhost not authorised"
fi
# Added by Steve Bonds Feb 2 2003
# Without this, there are no files in the ${FROM} directory, so rsync has
# nothing to do.
hands_setup
runtest "ssh: basic test" 'checkit "$RSYNC -avH -e ssh --rsync-path=$RSYNC ${FROM}/ localhost:${TO}" ${FROM}/ ${TO}'
# Added by Steve Bonds Feb 2 2003
# I assumed that "F1" was intended to hold a single file for testing if
# rsync could detect a renamed file over ssh. Without this line below
# it was unset so the "mv" tried to move a parent directory into a
# subdirectory of itself. There is probably a better way of pulling out
# a sample file to rename.
F1=`ls ${TO} | head -5 | tail -1`
mv ${TO}/${F1} ${TO}/ThisShouldGo
runtest "ssh: renamed file" 'checkit "$RSYNC --delete -avH -e ssh --rsync-path=$RSYNC ${FROM}/ localhost:${TO}" ${FROM}/ ${TO}'

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