mirror of
https://github.com/RsyncProject/rsync.git
synced 2026-05-27 00:05:36 -04:00
Compare commits
236 Commits
v3.0.0pre7
...
v3.0.3pre2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc56eb2acc | ||
|
|
88e05f8489 | ||
|
|
9ec8583ef5 | ||
|
|
e9489cd6cb | ||
|
|
f1ca7c4429 | ||
|
|
adc4ebdd76 | ||
|
|
9a30c0cc3c | ||
|
|
47f43c023b | ||
|
|
5b385336b9 | ||
|
|
c3a2d95cfa | ||
|
|
6b19df680a | ||
|
|
fdf74bede0 | ||
|
|
876ad10ccc | ||
|
|
34a2b39165 | ||
|
|
276cc45571 | ||
|
|
311676ed21 | ||
|
|
4616867b0d | ||
|
|
8a5ae84efd | ||
|
|
59d2cd5a7f | ||
|
|
1c3e6e8b26 | ||
|
|
f2681d42ff | ||
|
|
774d1c367b | ||
|
|
1b8e0e876b | ||
|
|
1502f4f58f | ||
|
|
6db1db5488 | ||
|
|
09ad90537d | ||
|
|
da9aefa6b4 | ||
|
|
8ba802f3b4 | ||
|
|
e53f49d1af | ||
|
|
0917f581bc | ||
|
|
1fe2a3533f | ||
|
|
237e9a178f | ||
|
|
0668bfe077 | ||
|
|
214af6ad83 | ||
|
|
2551c47eb7 | ||
|
|
83d22fd7f9 | ||
|
|
325c243210 | ||
|
|
4e90cfbfed | ||
|
|
6fd2c27f38 | ||
|
|
19173d224a | ||
|
|
5b83829669 | ||
|
|
8cd3c6dccf | ||
|
|
29a89172f7 | ||
|
|
2089375179 | ||
|
|
f8949e7647 | ||
|
|
84ecaa0eca | ||
|
|
3f2d8d683a | ||
|
|
fd2598022c | ||
|
|
b05c58cce6 | ||
|
|
05805cd6b7 | ||
|
|
a165be754b | ||
|
|
af3172c148 | ||
|
|
487cb52615 | ||
|
|
9793bbb364 | ||
|
|
f6f74b93ef | ||
|
|
7568ff448a | ||
|
|
56158b7e04 | ||
|
|
798a9e4e74 | ||
|
|
c202b4fa96 | ||
|
|
1df02d13d3 | ||
|
|
73cb6738b3 | ||
|
|
ba8672dfab | ||
|
|
a5e0bf3579 | ||
|
|
99ba99c74c | ||
|
|
469ff84e29 | ||
|
|
b5daf5300f | ||
|
|
f5aeb6ff9b | ||
|
|
4c74d44dab | ||
|
|
4a86fbcda0 | ||
|
|
bc267e0f57 | ||
|
|
fc05137846 | ||
|
|
c085ece623 | ||
|
|
91f625cee0 | ||
|
|
27b067f87b | ||
|
|
987a546756 | ||
|
|
4d30f17671 | ||
|
|
d48810ba5b | ||
|
|
819bfe4599 | ||
|
|
d2f6e19262 | ||
|
|
e889e0c43b | ||
|
|
6e0bf4d840 | ||
|
|
83a8ca7b14 | ||
|
|
100200d0d2 | ||
|
|
f28bf7f401 | ||
|
|
e0fd68f5ce | ||
|
|
cc12c488aa | ||
|
|
99c3e591b2 | ||
|
|
1aefb7ef73 | ||
|
|
d7b6774d82 | ||
|
|
d4c5cb2b01 | ||
|
|
df476bfcff | ||
|
|
aa0e6b9977 | ||
|
|
1ba6468f1b | ||
|
|
f490102454 | ||
|
|
18f3cb6957 | ||
|
|
7abcfd85b7 | ||
|
|
6de417d9d4 | ||
|
|
ffe8feb265 | ||
|
|
c9b62cf375 | ||
|
|
7bc595785e | ||
|
|
022dec7aba | ||
|
|
ddaef70ced | ||
|
|
2357a51e09 | ||
|
|
24ded29ff6 | ||
|
|
ddff23a7f9 | ||
|
|
53936ef935 | ||
|
|
7f9bf6b710 | ||
|
|
cfdb27b0c1 | ||
|
|
fc3ca11040 | ||
|
|
d6c9c3319b | ||
|
|
8afaef4219 | ||
|
|
11faa893ca | ||
|
|
600b56b316 | ||
|
|
ee39281d14 | ||
|
|
0607c30700 | ||
|
|
492ad04277 | ||
|
|
1ed9018e69 | ||
|
|
ff0e15804f | ||
|
|
894e6299c1 | ||
|
|
c080190365 | ||
|
|
26f0e56587 | ||
|
|
b4e6aac985 | ||
|
|
7c21776e54 | ||
|
|
d724dd186e | ||
|
|
cbbd8e2e8b | ||
|
|
af6241f7ad | ||
|
|
852e763b89 | ||
|
|
0f71592015 | ||
|
|
e63d3a29e2 | ||
|
|
38cef641a5 | ||
|
|
6226396c4a | ||
|
|
89b47d43de | ||
|
|
d1c06c2180 | ||
|
|
800a4485f3 | ||
|
|
fede378577 | ||
|
|
3bc207b9dd | ||
|
|
ebac031925 | ||
|
|
3cbe640d3c | ||
|
|
4cb6197b21 | ||
|
|
d3d07a5e86 | ||
|
|
62ca38262f | ||
|
|
d62fb8894f | ||
|
|
fc29efc38d | ||
|
|
c4c9bb944b | ||
|
|
236adddc18 | ||
|
|
5b3aa8028b | ||
|
|
16e24c2043 | ||
|
|
7869953bbf | ||
|
|
d07edfc895 | ||
|
|
85b057cccf | ||
|
|
a2c473bb59 | ||
|
|
f587061a5b | ||
|
|
d9e92804a5 | ||
|
|
46e858a631 | ||
|
|
e0fe5231c2 | ||
|
|
698bc16e87 | ||
|
|
7b4f48650c | ||
|
|
a43ff267e9 | ||
|
|
717d04669a | ||
|
|
15dbffc215 | ||
|
|
0099e42332 | ||
|
|
1ed56a05c2 | ||
|
|
28fb6365d0 | ||
|
|
8365126b8d | ||
|
|
d770837ec0 | ||
|
|
59658acfec | ||
|
|
46f800e8c7 | ||
|
|
1c65a93d03 | ||
|
|
cae7885e2f | ||
|
|
eaa28e654f | ||
|
|
beef86d0dd | ||
|
|
2fe1feea75 | ||
|
|
0b52f94da7 | ||
|
|
f96bac8468 | ||
|
|
8444a7c00d | ||
|
|
c9d3bc3fca | ||
|
|
8340aa9670 | ||
|
|
3e2c0024d5 | ||
|
|
205393a2b5 | ||
|
|
5f0f2e0894 | ||
|
|
a5bb0902b4 | ||
|
|
d348d5fd5f | ||
|
|
21897ecbed | ||
|
|
01103e1870 | ||
|
|
2d8f9b1df0 | ||
|
|
68f1e7e594 | ||
|
|
87629cf2f6 | ||
|
|
e7f642cffe | ||
|
|
3e8fe565ed | ||
|
|
e96c7777d7 | ||
|
|
71daa07fb1 | ||
|
|
287bb276d5 | ||
|
|
ddc8110dea | ||
|
|
c0f4228d66 | ||
|
|
d6e6333a02 | ||
|
|
970ce063ee | ||
|
|
dd1f0da818 | ||
|
|
38a4bd432a | ||
|
|
3eabe6aa41 | ||
|
|
f2b7b64d86 | ||
|
|
b2057d38a9 | ||
|
|
964244b90d | ||
|
|
a7c1fa0049 | ||
|
|
42a28d9d3a | ||
|
|
19284e2ef8 | ||
|
|
2268defe66 | ||
|
|
643b018cfb | ||
|
|
e35ad79b1b | ||
|
|
da01d2e843 | ||
|
|
641dc0c51e | ||
|
|
69e2b4ee3a | ||
|
|
75a01a0734 | ||
|
|
b769ad6a3e | ||
|
|
6e59b97770 | ||
|
|
4da9fcd41d | ||
|
|
68ddbaf645 | ||
|
|
555a081fe2 | ||
|
|
513d3fd806 | ||
|
|
34aa616d41 | ||
|
|
ec8637f367 | ||
|
|
62a6b8df72 | ||
|
|
dd6f31f70f | ||
|
|
a5fd4b6e6e | ||
|
|
eca151d457 | ||
|
|
f859d3ded6 | ||
|
|
5288be3af7 | ||
|
|
83235dbc54 | ||
|
|
c78cb8f349 | ||
|
|
7210dbfd2a | ||
|
|
b6800a0b32 | ||
|
|
14eaa7a53b | ||
|
|
bc065415b0 | ||
|
|
9203c8d274 | ||
|
|
9468cf796d | ||
|
|
77d4c400c2 | ||
|
|
e3915dac76 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -29,7 +29,6 @@ config.status
|
||||
/t_unsafe
|
||||
/wildtest
|
||||
/getfsdev
|
||||
/mkrounding
|
||||
/rounding.h
|
||||
/doc/rsync.pdf
|
||||
/doc/rsync.ps
|
||||
|
||||
46
Makefile.in
46
Makefile.in
@@ -59,7 +59,7 @@ CHECK_OBJS=tls.o getgroups.o getfsdev.o t_stub.o t_unsafe.o trimslash.o wildtest
|
||||
$(CC) -I. -I$(srcdir) $(CFLAGS) $(CPPFLAGS) -c $< @CC_SHOBJ_FLAG@
|
||||
@OBJ_RESTORE@
|
||||
|
||||
all: conf_stop rsync$(EXEEXT) @MAKE_MAN@
|
||||
all: conf_stop make_stop rsync$(EXEEXT) @MAKE_MAN@
|
||||
|
||||
install: all
|
||||
-mkdir -p ${DESTDIR}${bindir}
|
||||
@@ -80,13 +80,23 @@ $(CHECK_OBJS): $(HEADERS)
|
||||
|
||||
flist.o: rounding.h
|
||||
|
||||
rounding.h: mkrounding$(EXEEXT)
|
||||
./mkrounding$(EXEEXT) >rounding.h
|
||||
|
||||
mkrounding$(EXEEXT): mkrounding.c rsync.h
|
||||
@sed '1,/^struct file_struct/d; /^}/,$$d' <$(srcdir)/rsync.h >mkrounding.h
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ -I. $(srcdir)/mkrounding.c
|
||||
@rm mkrounding.h
|
||||
rounding.h: rounding.c rsync.h
|
||||
@for r in 0 1 3; do \
|
||||
if $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o rounding -DEXTRA_ROUNDING=$$r -I. $(srcdir)/rounding.c >rounding.out 2>&1; then \
|
||||
echo "#define EXTRA_ROUNDING $$r" >rounding.h; \
|
||||
if test -f "$$HOME/build_farm/build_test.fns"; then \
|
||||
echo "EXTRA_ROUNDING is $$r" >&2; \
|
||||
fi; \
|
||||
break; \
|
||||
fi; \
|
||||
done
|
||||
@rm -f rounding
|
||||
@if test -f rounding.h; then : ; else \
|
||||
cat rounding.out 1>&2; \
|
||||
echo "Failed to create rounding.h!" 1>&2; \
|
||||
exit 1; \
|
||||
fi
|
||||
@rm -f rounding.out
|
||||
|
||||
tls$(EXEEXT): $(TLS_OBJ)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(TLS_OBJ) $(LIBS)
|
||||
@@ -101,7 +111,7 @@ TRIMSLASH_OBJ = trimslash.o syscall.o lib/compat.o lib/snprintf.o
|
||||
trimslash$(EXEEXT): $(TRIMSLASH_OBJ)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(TRIMSLASH_OBJ) $(LIBS)
|
||||
|
||||
T_UNSAFE_OBJ = t_unsafe.o syscall.o util.o t_stub.o lib/compat.o lib/snprintf.o
|
||||
T_UNSAFE_OBJ = t_unsafe.o syscall.o util.o t_stub.o lib/compat.o lib/snprintf.o lib/wildmatch.o
|
||||
t_unsafe$(EXEEXT): $(T_UNSAFE_OBJ)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(T_UNSAFE_OBJ) $(LIBS)
|
||||
|
||||
@@ -119,7 +129,18 @@ configure.sh config.h.in: configure.in aclocal.m4
|
||||
autoconf -o configure.sh
|
||||
autoheader && touch config.h.in
|
||||
@echo 'Configure files changed -- perhaps run:'
|
||||
@echo ' ./config.status --recheck; ./config.status'
|
||||
@echo ' make reconfigure'
|
||||
@exit 1
|
||||
|
||||
reconfigure: configure.sh
|
||||
./config.status --recheck
|
||||
./config.status
|
||||
|
||||
make_stop: Makefile
|
||||
|
||||
Makefile: Makefile.in config.status
|
||||
@./config.status
|
||||
@echo "Makefile updated -- rerun your make command."
|
||||
@exit 1
|
||||
|
||||
proto: proto.h-tstamp
|
||||
@@ -142,7 +163,7 @@ rsyncd.conf.5: rsyncd.conf.yo
|
||||
|
||||
clean: cleantests
|
||||
rm -f *~ $(OBJS) $(CHECK_PROGS) $(CHECK_OBJS) $(CHECK_SYMLINKS) \
|
||||
mkrounding mkrounding.h rounding.h
|
||||
rounding rounding.h
|
||||
|
||||
cleantests:
|
||||
rm -rf ./testtmp*
|
||||
@@ -152,11 +173,14 @@ cleantests:
|
||||
# the source directory.
|
||||
distclean: clean
|
||||
rm -f Makefile config.h config.status
|
||||
rm -f lib/dummy popt/dummy zlib/dummy
|
||||
rm -f $(srcdir)/Makefile $(srcdir)/config.h $(srcdir)/config.status
|
||||
rm -f $(srcdir)/lib/dummy $(srcdir)/popt/dummy $(srcdir)/zlib/dummy
|
||||
rm -f config.cache config.log
|
||||
rm -f $(srcdir)/config.cache $(srcdir)/config.log
|
||||
rm -f shconfig $(srcdir)/shconfig
|
||||
rm -f $(GENFILES)
|
||||
rm -rf autom4te.cache
|
||||
|
||||
# this target is really just for my use. It only works on a limited
|
||||
# range of machines and is used to produce a list of potentially
|
||||
|
||||
298
NEWS
298
NEWS
@@ -1,293 +1,45 @@
|
||||
NEWS for rsync 3.0.0 (UNRELEASED)
|
||||
Protocol: 30 (changed)
|
||||
Changes since 2.6.9:
|
||||
|
||||
NOTABLE CHANGES IN BEHAVIOR:
|
||||
|
||||
- The handling of implied directories when using --relative has changed to
|
||||
send them as directories (e.g. no implied dir is ever sent as a symlink).
|
||||
This avoids unexpected behavior and should not adversely affect most
|
||||
people. If you're one of those rare individuals who relied upon having
|
||||
an implied dir be duplicated as a symlink, you should specify the
|
||||
transfer of the symlink and the transfer of the referent directory as
|
||||
separate args. (See also --keep-dirlinks and --no-implied-dirs.)
|
||||
|
||||
- Requesting a remote file list without specifying -r (--recursive) now
|
||||
sends the -d (--dirs) option to the remote rsync rather than sending -r
|
||||
along with an extra exclude of /*/*. If the remote rsync does not
|
||||
understand the -d option (i.e. it is 2.6.3 or older), you will need to
|
||||
either turn off -d (--no-d), or specify -r --exclude='/*/*' manually.
|
||||
|
||||
- In --dry-run mode, the last line of the verbose summary text is output
|
||||
with a "(DRY RUN)" suffix to help remind you that no updates were made.
|
||||
|
||||
- A writable rsync daemon that disables "use chroot" now defaults to a
|
||||
symlink-munging behavior designed to make symlinks safer while also
|
||||
allowing absolute symlinks to be stored and retrieved. This also has
|
||||
the effect of making symlinks unusable while they're in the daemon's
|
||||
hierarchy. See the daemon option "munge symlinks" for full details.
|
||||
NEWS for rsync 3.0.3 (UNRELEASED)
|
||||
Protocol: 30 (unchanged)
|
||||
Changes since 3.0.2:
|
||||
|
||||
BUG FIXES:
|
||||
|
||||
- A daemon with "use chroot = no" and excluded items listed in the daemon
|
||||
config file now properly checks an absolute-path arg specified for these
|
||||
options: --compare-dest, --link-dest, --copy-dest, --partial-dir,
|
||||
--backup-dir, --temp-dir, and --files-from.
|
||||
- Fixed a wildcard matching problem in the daemon when a module has
|
||||
"use chroot" enabled.
|
||||
|
||||
- Fixed the output of -ii when combined with one of the --*-dest options:
|
||||
it now itemizes all the items, not just the changed ones.
|
||||
- Fixed a crash bug in the hard-link code.
|
||||
|
||||
- Made the output of all file types consistent when using a --*-dest
|
||||
option. Prior versions would output too many creation events for
|
||||
matching items.
|
||||
- Fixed the combination of --xattrs and --backup.
|
||||
|
||||
- The code that waits for a child pid now handles being interrupted by a
|
||||
signal. This fixes a problem with the pre-xfer exec function not being
|
||||
able to get the exit status from the script.
|
||||
- The generator no longer allows a '.' dir to be excluded by a daemon-
|
||||
exclude rule.
|
||||
|
||||
- A negated filter rule (i.e. with a '!' modifier) no longer loses the
|
||||
negation when sending the filter rules to the remote rsync.
|
||||
- Fixed the conversion of spaces into dashes in the %M log escape.
|
||||
|
||||
- Fixed a problem with the --out-format (aka --log-format) option %f: it
|
||||
no longer outputs superfluous directory info for a non-daemon rsync.
|
||||
- Fixed several places in the code that were not returning the right
|
||||
errno when a function failed.
|
||||
|
||||
- Fixed a problem with -vv (double --verbose) and --stats when "pushing"
|
||||
files (which includes local copies). Version 2.6.9 would complete the
|
||||
copy, but exit with an error when the receiver output its memory stats.
|
||||
- Moved the setting of the socket options prior to the connect().
|
||||
|
||||
- If --password-file is used on a non-daemon transfer, rsync now complains
|
||||
and exits. This should help users figure out that they can't use this
|
||||
option to control a remote shell's password prompt.
|
||||
- If rsync exits in the middle of a --progress output, it now outputs a
|
||||
newline to prevent the progress line from being overwritten.
|
||||
|
||||
- Make sure that directory permissions of a newly-created destination
|
||||
directory are handled right when --perms is left off.
|
||||
- Fixed a problem with how a destination path with a trailing slash was
|
||||
compared against the daemon excludes.
|
||||
|
||||
- The itemized output of a newly-created destination directory is now
|
||||
output as a creation event, not a change event.
|
||||
|
||||
- Improved --hard-link so that more corner cases are handled correctly
|
||||
when combined with options such as --link-dest and/or --ignore-existing.
|
||||
|
||||
- The --append option no longer updates a file that has the same size.
|
||||
|
||||
- Fixed a bug when combining --backup and --backup-dir with --inplace:
|
||||
any missing backup directories are now created.
|
||||
|
||||
- Fixed a bug when using --backup and --inplace with --whole-file or
|
||||
--read-batch: backup files are actually created now.
|
||||
|
||||
- Starting up an extra copy of an rsync daemon will not clobber the pidfile
|
||||
for the running daemon -- if the pidfile exists, the new daemon will exit
|
||||
with an error.
|
||||
|
||||
- The daemon pidfile is checked and created sooner in the startup sequence.
|
||||
|
||||
- If a daemon module's "path" value is not an absolute pathname, the code
|
||||
now makes it absolute internally (making it work properly).
|
||||
|
||||
- Ensure that a temporary file always has owner-write permission while we
|
||||
are writing to it. This avoids problems with some network filesystems.
|
||||
|
||||
- Any errors output about password-file reading no longer cause an error at
|
||||
the end of the run about a partial transfer.
|
||||
|
||||
- Using --only-write-batch to a daemon receiver now work properly (older
|
||||
versions would update some files while writing the batch).
|
||||
- Use the overflow_exit() function for overflows, not out_of_memory().
|
||||
|
||||
ENHANCEMENTS:
|
||||
|
||||
- A new incremental-recursion algorithm is now used when rsync is talking
|
||||
to another 3.x version. This starts the transfer going more quickly
|
||||
(before all the files have been found), and requires much less memory.
|
||||
See the --recursive option in the manpage for some restrictions.
|
||||
- The rsyncd.conf manpage now consistently refers to the parameters in
|
||||
the daemon config file as "parameters".
|
||||
|
||||
- Lowered memory use in the non-incremental-recursion algorithm for typical
|
||||
option values (usually saving from 21-29 bytes per file).
|
||||
|
||||
- The default --delete algorithm is now --delete-during when talking to a
|
||||
3.x rsync. This is a faster scan than using --delete-before (which is
|
||||
the default when talking to older rsync versions), and is compatible with
|
||||
the new incremental recursion mode.
|
||||
|
||||
- Rsync now allows multiple remote-source args to be specified rather than
|
||||
having to rely on a special space-splitting side-effect of the remote-
|
||||
shell. Additional remote args must specify the same host or an empty one
|
||||
(e.g. empty: :file1 or ::module/file2). This means that local use of
|
||||
brace expansion now works: rsync -av host:dir/{f1,f2} .
|
||||
|
||||
- Added the --protect-args (-s) option, that tells rsync to send most of
|
||||
the command-line args at the start of the transfer rather than as args
|
||||
to the remote-shell command. This protects them from space-splitting,
|
||||
and only interprets basic wildcard special shell characters (*?[).
|
||||
|
||||
- Added the --delete-delay option, which is a more efficient way to delete
|
||||
files at the end of the transfer without needing a separate delete pass.
|
||||
|
||||
- Added the --acls (-A) option to preserve Access Control Lists. This is
|
||||
an improved version of the prior patch that was available, and it even
|
||||
supports OS X ACLs. If you need to have backward compatibility with old,
|
||||
acl-patched versions of rsync, apply the acls.diff file from the patches
|
||||
dir.
|
||||
|
||||
- Added the --xattrs (-X) option to preserver extended attributes. This is
|
||||
an improved version of the prior patch that was available, and it even
|
||||
supports OS X xattrs (which includes their resource fork data). If you
|
||||
need to have backward compatibility with old, xattr-patched versions of
|
||||
rsync, apply the xattrs.diff file from the patches dir.
|
||||
|
||||
- Added the --fake-super option that allows a non-super user to preserve
|
||||
all attributes of a file by using a special extended-attribute idiom.
|
||||
It even supports the storing of foreign ACL data on your backup server.
|
||||
There is also an analogous "fake super" option for an rsync daemon.
|
||||
|
||||
- Added the --iconv option, which allows rsync to convert filenames from
|
||||
one character-set to another during the transfer. The default is to make
|
||||
this feature available as long as your system has iconv_open(). If
|
||||
compilation fails, specify --disable-iconv to configure, and then
|
||||
rebuild. If you want rsync to perform character-set conversions by
|
||||
default, you can specify --enable-iconv=CONVERT_STRING with the default
|
||||
value for the --iconv option that you wish to use. For example,
|
||||
"--enable-iconv=." is a good choice. See the rsync manpage for an
|
||||
explanation of the --iconv option's settings.
|
||||
|
||||
- Added the --skip-compress=LIST option to override the default list of
|
||||
file suffixes that will not be compressed when using --compress.
|
||||
|
||||
- The daemon's default for "dont compress" was extended to include:
|
||||
*.7z *.mp[34] *.mov *.avi *.ogg *.jpg *.jpeg
|
||||
The matching routine was also optimized to run more quickly.
|
||||
|
||||
- The --max-delete option now outputs a warning if it skipped any file
|
||||
deletions, including a count of how many deletions were skipped. (Older
|
||||
versions just silently stopped deleting things.)
|
||||
|
||||
- You may specify --max-delete=0 to a 3.0.0 client to request that it warn
|
||||
about extraneous files without deleting anything. If you're not sure
|
||||
what version the client is, you can use the less-obvious --max-delete=-1,
|
||||
as both old and new versions will treat that as the same request (though
|
||||
older versions don't warn).
|
||||
|
||||
- The --hard-link option now uses less memory on both the sending and
|
||||
receiving side for all protocol versions. For protocol 30, the use of a
|
||||
hashtable on the sending side allows us to more efficiently convey to the
|
||||
receiver what files are linked together. This reduces the amount of data
|
||||
sent over the socket by a considerable margin (rather than adding more
|
||||
data), and limits the in-memory storage of the device+inode information
|
||||
to just the sending side for the new protocol 30, or to the receiving
|
||||
side when speaking an older protocol (note that older rsync versions kept
|
||||
the device+inode information on both sides).
|
||||
|
||||
- The filter rules now support a perishable ("p") modifier that marks rules
|
||||
that should not have an effect in a directory that is being deleted. e.g.
|
||||
-f '-p .svn/' would only affect "live" .svn directories.
|
||||
|
||||
- Rsync checks all the alternate-destination args for validity (e.g.
|
||||
--link-dest). This lets the user know when they specified a directory
|
||||
that does not exist.
|
||||
|
||||
- If we get an error setting the time on a symlink, we don't complain about
|
||||
it anymore (since some operating systems don't support that, and it's not
|
||||
that important).
|
||||
|
||||
- Protocol 30 now uses MD5 checksums instead of MD4.
|
||||
|
||||
- Changed the --append option to not checksum the existing data in the
|
||||
destination file, which speeds up file appending.
|
||||
|
||||
- Added the --append-verify option, which works like the older --append
|
||||
option (verifying the existing data in the destination file). For
|
||||
compatibility with older rsync versions, any use of --append that is
|
||||
talking protocol 29 or older will revert to the --append-verify method.
|
||||
|
||||
- Added the --contimeout=SECONDS option that lets the user specify a
|
||||
connection timeout for rsync daemon access.
|
||||
|
||||
- Documented and extended the support for the RSYNC_CONNECT_PROG variable
|
||||
that can be used to enhance the client side of a daemon connection.
|
||||
|
||||
- Improved the dashes and double-quotes in the nroff manpage output.
|
||||
|
||||
- We now support a lot more --no-OPTION override options.
|
||||
|
||||
INTERNAL:
|
||||
|
||||
- The file-list sorting algorithm now uses a sort that keeps any same-
|
||||
named items in the same order as they were specified. This allows
|
||||
rsync to always ensure that the first of the duplicates is the one
|
||||
that will be included in the copy. The new sort was also faster
|
||||
than the glibc version of qsort() and mergesort() in my testing.
|
||||
|
||||
- Rsync now supports the transfer of 64-bit timestamps (time_t values).
|
||||
|
||||
- Fixed a build problem with older (2.x) versions of gcc.
|
||||
|
||||
- Added some isType() functions that make dealing with signed characters
|
||||
easier without forcing variables via casts.
|
||||
|
||||
- Changed strcat/strcpy/sprintf function calls to use safer versions.
|
||||
|
||||
- Upgraded the included popt version to 1.10.2 and improved its use of
|
||||
string-handling functions.
|
||||
|
||||
- Added missing prototypes for compatibility functions from the lib dir.
|
||||
|
||||
- Configure determines if iconv() has a const arg, allowing us to avoid a
|
||||
compiler warning.
|
||||
|
||||
- Made the sending of some numbers more efficient for protocol 30.
|
||||
|
||||
- Make sure that a daemon process doesn't mind if the client was weird and
|
||||
omitted the --server option.
|
||||
|
||||
- There are more internal logging categories available in protocol 30 than
|
||||
the age-old FINFO and FERROR, including FERROR_XFER and FWARN. These new
|
||||
categories allow some errors and warnings to go to stderr without causing
|
||||
an erroneous end-of-run warning about some files not being able to be
|
||||
transferred.
|
||||
|
||||
- Improved the use of "const" on pointers.
|
||||
|
||||
- Improved J.W.'s pool_alloc routines to add a way of freeing older
|
||||
sections of a pool's memory.
|
||||
|
||||
- The getaddrinfo.c compatibility code in the "lib" dir was replaced with
|
||||
some new code (derived from samba, derived from PostgreSQL) that has a
|
||||
better license than the old code.
|
||||
- The description of the --inplace option was improved.
|
||||
|
||||
DEVELOPER RELATED:
|
||||
|
||||
- Rsync is now licensed under the GPLv3 or later.
|
||||
- Fixed a testcase failure if the tests are run as root and made some
|
||||
compatibility improvements.
|
||||
|
||||
- Rsync is now being maintained in a "git" repository instead of CVS
|
||||
(though the old CVS repository still exists). Several maintenance
|
||||
scripts were updated to work with git.
|
||||
|
||||
- Generated files are no longer committed into the source repository. The
|
||||
autoconf and autoheader commands are now automatically run during the
|
||||
normal use of "configure" and "make". The latest dev versions of all
|
||||
generated files can also be copied from the samba.org web site (see the
|
||||
"magic" configure script that now comes with rsync for its location).
|
||||
|
||||
- The "patches" directory of diff files is now built from branches in the
|
||||
rsync git repository (branch patch/FOO creates file patches/FOO.diff).
|
||||
|
||||
- The proto.h file is now built using a simple perl script rather than a
|
||||
complex awk script, which proved to be more widely compatible.
|
||||
|
||||
- When running the tests, we now put our per-test temp dirs into a sub-
|
||||
directory named testtmp (which is created, if missing). This allows
|
||||
someone to symlink the testtmp directory to another filesystem (which is
|
||||
useful if the build dir's filesystem does not support ACLs and xattrs,
|
||||
but another file system does).
|
||||
|
||||
- Rsync now has a way of handling protocol-version changes during the
|
||||
development of a new protocol version. This causes any out-of-sync
|
||||
versions to speak an older protocol rather than fail in a cryptic manner.
|
||||
This addition makes it safe to deploy a pre-release version that may
|
||||
interact with the public. This new exchange of sub-version info does not
|
||||
interfere with the {MIN,MAX}_PROTOCOL_VERSION checking algorithm (which
|
||||
does not have enough range to allow the main protocol number to be
|
||||
incremented for every minor tweak in that happens during development).
|
||||
|
||||
- The csprotocol.txt file was updated to mention the daemon protocol change
|
||||
in the 3.0.0 release.
|
||||
- Ensure that the early patches don't cause any generated-file hunks to
|
||||
bleed-over into patches that follow.
|
||||
|
||||
506
OLDNEWS
506
OLDNEWS
@@ -1,3 +1,504 @@
|
||||
NEWS for rsync 3.0.2 (8 Apr 2008)
|
||||
Protocol: 30 (unchanged)
|
||||
Changes since 3.0.1:
|
||||
|
||||
BUG FIXES:
|
||||
|
||||
- Fixed a potential buffer overflow in the xattr code.
|
||||
|
||||
ENHANCEMENTS:
|
||||
|
||||
- None.
|
||||
|
||||
DEVELOPER RELATED:
|
||||
|
||||
- The RPM spec file was improved to install more useful files.
|
||||
|
||||
- A few developer-oriented scripts were moved from the support dir
|
||||
to the packaging dir.
|
||||
|
||||
|
||||
NEWS for rsync 3.0.1 (3 Apr 2008)
|
||||
Protocol: 30 (unchanged)
|
||||
Changes since 3.0.0:
|
||||
|
||||
NOTABLE CHANGES IN BEHAVIOR:
|
||||
|
||||
- Added the 'c'-flag to the itemizing of non-regular files so that the
|
||||
itemized output doesn't get hidden if there were no attribute changes,
|
||||
and also so that the itemizing of a --copy-links run will distinguish
|
||||
between copying an identical non-regular file and the creation of a
|
||||
revised version with a new value (e.g. a changed symlink referent, a
|
||||
new device number, etc.).
|
||||
|
||||
BUG FIXES:
|
||||
|
||||
- Fixed a crash bug when a single-use rsync daemon (via remote shell) was
|
||||
run without specifying a --config=FILE option.
|
||||
|
||||
- Fixed a crash when backing up a directory that has a default ACL.
|
||||
|
||||
- Fixed a bug in the handling of xattr values that could cause rsync to
|
||||
not think that a file's extended attributes are up-to-date.
|
||||
|
||||
- Fixed the working of --fake-super with --link-dest and --xattrs.
|
||||
|
||||
- Fixed a hang when combining --dry-run with --remove-source-files.
|
||||
|
||||
- Fixed a bug with --iconv's handling of files that cannot be converted:
|
||||
a failed name can no longer cause a transfer failure.
|
||||
|
||||
- Fixed the building of the rounding.h file on systems that need custom
|
||||
CPPFLAGS to be used. Also improved the error reporting if the building
|
||||
of rounding.h fails.
|
||||
|
||||
- Fixed the use of the --protect-args (-s) option when talking to a daemon.
|
||||
|
||||
- Fixed the --ignore-existing option's protection of files on the receiver
|
||||
that are non-regular files on the sender (e.g. if a symlink or a dir on
|
||||
the sender is trying to replace a file on the receiver). The reverse
|
||||
protection (protecting a dir/symlink/device from being replaced by a
|
||||
file) was already working.
|
||||
|
||||
- Fixed an assert failure if --hard-links is combined with an option that
|
||||
can skip a file in a set of hard-linked files (i.e. --ignore-existing,
|
||||
--append, etc.), without skipping all the files in the set.
|
||||
|
||||
- Avoid setting the modify time on a directory that already has the right
|
||||
modify time set. This avoids tweaking the dir's ctime.
|
||||
|
||||
- Improved the daemon-exclude handling to do a better job of applying the
|
||||
exclude rules to path entries. It also sends the user an error just as
|
||||
if the files were actually missing (instead of silently ignoring the
|
||||
user's args), and avoids sending the user the filter-action messages
|
||||
for these non-user-initiated rules.
|
||||
|
||||
- Fixed some glitches with the dry-run code's missing-directory
|
||||
handling, including a problem when combined with --fuzzy.
|
||||
|
||||
- Fixed some glitches with the skipped-directory handling.
|
||||
|
||||
- Fixed the 'T'-flag itemizing of symlinks when --time isn't preserved.
|
||||
|
||||
- Fixed a glitch in the itemizing of permissions with the -E option.
|
||||
|
||||
- The --append option's restricting of transfers to those that add data no
|
||||
longer prevents the updating of non-content changes to otherwise up-to-
|
||||
date files (i.e. those with the same content but differing permissions,
|
||||
ownership, xattrs, etc.).
|
||||
|
||||
- Don't allow --fake-super to be specified with -XX (double --xattrs)
|
||||
because the options conflict. If a daemon has "fake super" enabled,
|
||||
it automatically downgrades a -XX request to -X.
|
||||
|
||||
- Fixed a couple bugs in the parsing of daemon-config excludes that could
|
||||
make a floating exclude rule get treated as matching an absolute path.
|
||||
|
||||
- A daemon doesn't try to auto-refuse the "iconv" option if iconv-support
|
||||
wasn't compiled in to the daemon (avoiding a warning in the logs).
|
||||
|
||||
- Fixed the inclusion of per-dir merge files from implied dirs.
|
||||
|
||||
- Fixed the support/rrsync script to work with the latest options that
|
||||
rsync sends (including its flag-specifying use of -e to the server).
|
||||
|
||||
ENHANCEMENTS:
|
||||
|
||||
- Added the --old-dirs (--old-d) option to make it easier for a user to
|
||||
ask for file-listings with older rsync versions (this is easier than
|
||||
having to type "-r --exclude='/*/*'" manually).
|
||||
|
||||
- When getting an error while asking an older rsync daemon for a file
|
||||
listing, rsync will try to notice if the error is a rejection of the
|
||||
--dirs (-d) option and let the user know how to work around the issue.
|
||||
|
||||
- Added a few more --no-OPTION overrides.
|
||||
|
||||
- Improved the documentation of the --append option.
|
||||
|
||||
- Improved the documentation of the filter/exclude/include daemon
|
||||
parameters.
|
||||
|
||||
INTERNAL:
|
||||
|
||||
- Fixed a couple minor bugs in the included popt library (ones which I
|
||||
sent to the official popt project for inclusion in the 1.14 release).
|
||||
|
||||
- Fixed a stat() call that should have been do_stat() so that the proper
|
||||
normal/64-bit stat() function gets called. (Was in an area that should
|
||||
not have caused problems, though.)
|
||||
|
||||
- Changed the file-glob code to do a directory scan without using the
|
||||
"glob" and "glob.h". This lets us do the globbing with less memory
|
||||
churn, and also avoid adding daemon-excluded items to the returned
|
||||
args.
|
||||
|
||||
DEVELOPER RELATED:
|
||||
|
||||
- The configure script tries to get the user's compiler to not warn about
|
||||
unused function parameters if the build is not including one or more of
|
||||
the ACL/xattrs/iconv features.
|
||||
|
||||
- The configure script now has better checks for figuring out if the
|
||||
included popt code should be used or not.
|
||||
|
||||
- Fixed two testsuite glitches: avoid a failure if someone's "cd" command
|
||||
outputs the current directory when cd-ing to a relative path, and made
|
||||
the itemized test query how rsync was built to determine if it should
|
||||
expect hard-linked symlinks or not.
|
||||
|
||||
- Updated the testsuite to verify that various bug fixes remain fixed.
|
||||
|
||||
- The RPM spec file was updated to have: (1) comments for how to use the
|
||||
rsync-patch tar file, and (2) an /etc/xinetd.d/rsync file.
|
||||
|
||||
- Updated the build scripts to work with a revised FTP directory
|
||||
structure.
|
||||
|
||||
|
||||
NEWS for rsync 3.0.0 (1 Mar 2008)
|
||||
Protocol: 30 (changed)
|
||||
Changes since 2.6.9:
|
||||
|
||||
NOTABLE CHANGES IN BEHAVIOR:
|
||||
|
||||
- The handling of implied directories when using --relative has changed to
|
||||
send them as directories (e.g. no implied dir is ever sent as a symlink).
|
||||
This avoids unexpected behavior and should not adversely affect most
|
||||
people. If you're one of those rare individuals who relied upon having
|
||||
an implied dir be duplicated as a symlink, you should specify the
|
||||
transfer of the symlink and the transfer of the referent directory as
|
||||
separate args. (See also --keep-dirlinks and --no-implied-dirs.)
|
||||
Also, exclude rules no longer have a partial effect on implied dirs.
|
||||
|
||||
- Requesting a remote file-listing without specifying -r (--recursive) now
|
||||
sends the -d (--dirs) option to the remote rsync rather than sending -r
|
||||
along with an extra exclude of /*/*. If the remote rsync does not
|
||||
understand the -d option (i.e. it is 2.6.3 or older), you will need to
|
||||
either turn off -d (--no-d), or specify -r --exclude='/*/*' manually.
|
||||
|
||||
- In --dry-run mode, the last line of the verbose summary text is output
|
||||
with a "(DRY RUN)" suffix to help remind you that no updates were made.
|
||||
Similarly, --only-write-batch outputs "(BATCH ONLY)".
|
||||
|
||||
- A writable rsync daemon with "use chroot" disabled now defaults to a
|
||||
symlink-munging behavior designed to make symlinks safer while also
|
||||
allowing absolute symlinks to be stored and retrieved. This also has
|
||||
the effect of making symlinks unusable while they're in the daemon's
|
||||
hierarchy. See the daemon's "munge symlinks" parameter for details.
|
||||
|
||||
- Starting up an extra copy of an rsync daemon will not clobber the pidfile
|
||||
for the running daemon -- if the pidfile exists, the new daemon will exit
|
||||
with an error. This means that your wrapper script that starts the rsync
|
||||
daemon should be made to handle lock-breaking (if you want any automatic
|
||||
breaking of locks to be done).
|
||||
|
||||
BUG FIXES:
|
||||
|
||||
- A daemon with "use chroot = no" and excluded items listed in the daemon
|
||||
config file now properly checks an absolute-path arg specified for these
|
||||
options: --compare-dest, --link-dest, --copy-dest, --partial-dir,
|
||||
--backup-dir, --temp-dir, and --files-from.
|
||||
|
||||
- A daemon can now be told to disable all user- and group-name translation
|
||||
on a per-module basis. This avoids a potential problem with a writable
|
||||
daemon module that has "use chroot" enabled -- if precautions weren't
|
||||
taken, a user could try to add a missing library and get rsync to use
|
||||
it. This makes rsync safer by default, and more configurable when id-
|
||||
translation is not desired. See the daemon's "numeric ids" parameter
|
||||
for full details.
|
||||
|
||||
- A chroot daemon can now indicate which part of its path should affect the
|
||||
chroot call, and which part should become an inside-chroot path for the
|
||||
module. This allows you to have outside-the-transfer paths (such as for
|
||||
libraries) even when you enable chroot protection. The idiom used in the
|
||||
rsyncd.conf file is: path = /chroot/dirs/./dirs/inside
|
||||
|
||||
- If a file's data arrived successfully on the receiving side but the
|
||||
rename of the temporary file to the destination file failed AND the
|
||||
--remove-source-files (or the deprecated --remove-sent-files) option
|
||||
was specified, rsync no longer erroneously removes the associated
|
||||
source file.
|
||||
|
||||
- Fixed the output of -ii when combined with one of the --*-dest options:
|
||||
it now itemizes all the items, not just the changed ones.
|
||||
|
||||
- Made the output of all file types consistent when using a --*-dest
|
||||
option. Prior versions would output too many creation events for
|
||||
matching items.
|
||||
|
||||
- The code that waits for a child pid now handles being interrupted by a
|
||||
signal. This fixes a problem with the pre-xfer exec function not being
|
||||
able to get the exit status from the script.
|
||||
|
||||
- A negated filter rule (i.e. with a '!' modifier) no longer loses the
|
||||
negation when sending the filter rules to the remote rsync.
|
||||
|
||||
- Fixed a problem with the --out-format (aka --log-format) option %f: it
|
||||
no longer outputs superfluous directory info for a non-daemon rsync.
|
||||
|
||||
- Fixed a problem with -vv (double --verbose) and --stats when "pushing"
|
||||
files (which includes local copies). Version 2.6.9 would complete the
|
||||
copy, but exit with an error when the receiver output its memory stats.
|
||||
|
||||
- If --password-file is used on a non-daemon transfer, rsync now complains
|
||||
and exits. This should help users figure out that they can't use this
|
||||
option to control a remote shell's password prompt.
|
||||
|
||||
- Make sure that directory permissions of a newly-created destination
|
||||
directory are handled right when --perms is left off.
|
||||
|
||||
- The itemized output of a newly-created destination directory is now
|
||||
output as a creation event, not a change event.
|
||||
|
||||
- Improved --hard-link so that more corner cases are handled correctly
|
||||
when combined with options such as --link-dest and/or --ignore-existing.
|
||||
|
||||
- The --append option no longer updates a file that has the same size.
|
||||
|
||||
- Fixed a bug when combining --backup and --backup-dir with --inplace:
|
||||
any missing backup directories are now created.
|
||||
|
||||
- Fixed a bug when using --backup and --inplace with --whole-file or
|
||||
--read-batch: backup files are actually created now.
|
||||
|
||||
- The daemon pidfile is checked and created sooner in the startup sequence.
|
||||
|
||||
- If a daemon module's "path" value is not an absolute pathname, the code
|
||||
now makes it absolute internally (making it work properly).
|
||||
|
||||
- Ensure that a temporary file always has owner-write permission while we
|
||||
are writing to it. This avoids problems with some network filesystems
|
||||
when transfering read-only files.
|
||||
|
||||
- Any errors output about password-file reading no longer cause an error at
|
||||
the end of the run about a partial transfer.
|
||||
|
||||
- The --read-batch option for protocol 30 now ensures that several more
|
||||
options are set correctly for the current batch file: --iconv, --acls,
|
||||
--xattrs, --inplace, --append, and --append-verify.
|
||||
|
||||
- Using --only-write-batch to a daemon receiver now works properly (older
|
||||
versions would update some files while writing the batch).
|
||||
|
||||
- Avoid outputting a "file has vanished" message when the file is a broken
|
||||
symlink and --copy-unsafe-links or --copy-dirlinks is used (the code
|
||||
already handled this for --copy-links).
|
||||
|
||||
- Fixed the combination of --only-write-batch and --dry-run.
|
||||
|
||||
- Fixed rsync's ability to remove files that are not writable by the file's
|
||||
owner when rsync is running as the same user.
|
||||
|
||||
ENHANCEMENTS:
|
||||
|
||||
- A new incremental-recursion algorithm is now used when rsync is talking
|
||||
to another 3.x version. This starts the transfer going more quickly
|
||||
(before all the files have been found), and requires much less memory.
|
||||
See the --recursive option in the manpage for some restrictions.
|
||||
|
||||
- Lowered memory use in the non-incremental-recursion algorithm for typical
|
||||
option values (usually saving from 21-29 bytes per file).
|
||||
|
||||
- The default --delete algorithm is now --delete-during when talking to a
|
||||
3.x rsync. This is a faster scan than using --delete-before (which is
|
||||
the default when talking to older rsync versions), and is compatible with
|
||||
the new incremental recursion mode.
|
||||
|
||||
- Rsync now allows multiple remote-source args to be specified rather than
|
||||
having to rely on a special space-splitting side-effect of the remote-
|
||||
shell. Additional remote args must specify the same host or an empty one
|
||||
(e.g. empty: :file1 or ::module/file2). For example, this means that
|
||||
local use of brace expansion now works: rsync -av host:dir/{f1,f2} .
|
||||
|
||||
- Added the --protect-args (-s) option, that tells rsync to send most of
|
||||
the command-line args at the start of the transfer rather than as args
|
||||
to the remote-shell command. This protects them from space-splitting,
|
||||
and only interprets basic wildcard special shell characters (*?[).
|
||||
|
||||
- Added the --delete-delay option, which is a more efficient way to delete
|
||||
files at the end of the transfer without needing a separate delete pass.
|
||||
|
||||
- Added the --acls (-A) option to preserve Access Control Lists. This is
|
||||
an improved version of the prior patch that was available, and it even
|
||||
supports OS X ACLs. If you need to have backward compatibility with old,
|
||||
ACL-patched versions of rsync, apply the acls.diff file from the patches
|
||||
dir.
|
||||
|
||||
- Added the --xattrs (-X) option to preserve extended attributes. This is
|
||||
an improved version of the prior patch that was available, and it even
|
||||
supports OS X xattrs (which includes their resource fork data). If you
|
||||
need to have backward compatibility with old, xattr-patched versions of
|
||||
rsync, apply the xattrs.diff file from the patches dir.
|
||||
|
||||
- Added the --fake-super option that allows a non-super user to preserve
|
||||
all attributes of a file by using a special extended-attribute idiom.
|
||||
It even supports the storing of foreign ACL data on your backup server.
|
||||
There is also an analogous "fake super" parameter for an rsync daemon.
|
||||
|
||||
- Added the --iconv option, which allows rsync to convert filenames from
|
||||
one character-set to another during the transfer. The default is to
|
||||
make this feature available as long as your system has iconv_open().
|
||||
If compilation fails, specify --disable-iconv to configure, and then
|
||||
rebuild. If you want rsync to perform character-set conversions by
|
||||
default, you can specify --enable-iconv=CONVERT_STRING with the default
|
||||
value for the --iconv option that you wish to use. For example,
|
||||
"--enable-iconv=." is a good choice. See the rsync manpage for an
|
||||
explanation of the --iconv option's settings.
|
||||
|
||||
- A new daemon config parameter, "charset", lets you control the character-
|
||||
set that is used during an --iconv transfer to/from a daemon module. You
|
||||
can also set your daemon to refuse "no-iconv" if you want to force the
|
||||
client to use an --iconv transfer (requiring an rsync 3.x client).
|
||||
|
||||
- Added the --skip-compress=LIST option to override the default list of
|
||||
file suffixes that will not be compressed when using --compress (-z).
|
||||
|
||||
- The daemon's default for "dont compress" was extended to include:
|
||||
*.7z *.mp[34] *.mov *.avi *.ogg *.jpg *.jpeg
|
||||
The name-matching routine was also optimized to run more quickly.
|
||||
|
||||
- The --max-delete option now outputs a warning if it skipped any file
|
||||
deletions, including a count of how many deletions were skipped. (Older
|
||||
versions just silently stopped deleting things.)
|
||||
|
||||
- You may specify --max-delete=0 to a 3.0.0 client to request that it warn
|
||||
about extraneous files without deleting anything. If you're not sure
|
||||
what version the client is, you can use the less-obvious --max-delete=-1,
|
||||
as both old and new versions will treat that as the same request (though
|
||||
older versions don't warn).
|
||||
|
||||
- The --hard-link option now uses less memory on both the sending and
|
||||
receiving side for all protocol versions. For protocol 30, the use of a
|
||||
hashtable on the sending side allows us to more efficiently convey to the
|
||||
receiver what files are linked together. This reduces the amount of data
|
||||
sent over the socket by a considerable margin (rather than adding more
|
||||
data), and limits the in-memory storage of the device+inode information
|
||||
to just the sending side for the new protocol 30, or to the receiving
|
||||
side when speaking an older protocol (note that older rsync versions kept
|
||||
the device+inode information on both sides).
|
||||
|
||||
- The filter rules now support a perishable ("p") modifier that marks rules
|
||||
that should not have an effect in a directory that is being deleted. e.g.
|
||||
-f '-p .svn/' would only affect "live" .svn directories.
|
||||
|
||||
- Rsync checks all the alternate-destination args for validity (e.g.
|
||||
--link-dest). This lets the user know when they specified a directory
|
||||
that does not exist.
|
||||
|
||||
- If we get an ENOSYS error setting the time on a symlink, we don't
|
||||
complain about it anymore (for those systems that even support the
|
||||
setting of the modify-time on a symlink).
|
||||
|
||||
- Protocol 30 now uses MD5 checksums instead of MD4.
|
||||
|
||||
- Changed the --append option to not checksum the existing data in the
|
||||
destination file, which speeds up file appending.
|
||||
|
||||
- Added the --append-verify option, which works like the older --append
|
||||
option (verifying the existing data in the destination file). For
|
||||
compatibility with older rsync versions, any use of --append that is
|
||||
talking protocol 29 or older will revert to the --append-verify method.
|
||||
|
||||
- Added the --contimeout=SECONDS option that lets the user specify a
|
||||
connection timeout for rsync daemon access.
|
||||
|
||||
- Documented and extended the support for the RSYNC_CONNECT_PROG variable
|
||||
that can be used to enhance the client side of a daemon connection.
|
||||
|
||||
- Improved the dashes and double-quotes in the nroff manpage output.
|
||||
|
||||
- Rsync now supports a lot more --no-OPTION override options.
|
||||
|
||||
INTERNAL:
|
||||
|
||||
- The file-list sorting algorithm now uses a sort that keeps any same-
|
||||
named items in the same order as they were specified. This allows
|
||||
rsync to always ensure that the first of the duplicates is the one
|
||||
that will be included in the copy. The new sort is also faster
|
||||
than the glibc version of qsort() and mergesort().
|
||||
|
||||
- Rsync now supports the transfer of 64-bit timestamps (time_t values).
|
||||
|
||||
- Made the file-deletion code use a little less stack when recursing
|
||||
through a directory hierarchy of extraneous files.
|
||||
|
||||
- Fixed a build problem with older (2.x) versions of gcc.
|
||||
|
||||
- Added some isType() functions that make dealing with signed characters
|
||||
easier without forcing variables via casts.
|
||||
|
||||
- Changed strcat/strcpy/sprintf function calls to use safer versions.
|
||||
|
||||
- Upgraded the included popt version to 1.10.2 and improved its use of
|
||||
string-handling functions.
|
||||
|
||||
- Added missing prototypes for compatibility functions from the lib dir.
|
||||
|
||||
- Configure determines if iconv() has a const arg, allowing us to avoid a
|
||||
compiler warning.
|
||||
|
||||
- Made the sending of some numbers more efficient for protocol 30.
|
||||
|
||||
- Make sure that a daemon process doesn't mind if the client was weird and
|
||||
omitted the --server option.
|
||||
|
||||
- There are more internal logging categories available in protocol 30 than
|
||||
the age-old FINFO and FERROR, including FERROR_XFER and FWARN. These new
|
||||
categories allow some errors and warnings to go to stderr without causing
|
||||
an erroneous end-of-run warning about some files not being able to be
|
||||
transferred.
|
||||
|
||||
- Improved the use of "const" on pointers.
|
||||
|
||||
- Improved J.W.'s pool_alloc routines to add a way of incrementally freeing
|
||||
older sections of a pool's memory.
|
||||
|
||||
- The getaddrinfo.c compatibility code in the "lib" dir was replaced with
|
||||
some new code (derived from samba, derived from PostgreSQL) that has a
|
||||
better license than the old code.
|
||||
|
||||
DEVELOPER RELATED:
|
||||
|
||||
- Rsync is now licensed under the GPLv3 or later.
|
||||
|
||||
- Rsync is now being maintained in a "git" repository instead of CVS
|
||||
(though the old CVS repository still exists for historical access).
|
||||
Several maintenance scripts were updated to work with git.
|
||||
|
||||
- Generated files are no longer committed into the source repository. The
|
||||
autoconf and autoheader commands are now automatically run during the
|
||||
normal use of "configure" and "make". The latest dev versions of all
|
||||
generated files can also be copied from the samba.org web site (see the
|
||||
prepare-source script's fetch option).
|
||||
|
||||
- The "patches" directory of diff files is now built from branches in the
|
||||
rsync git repository (branch patch/FOO creates file patches/FOO.diff).
|
||||
This directory is now distributed in a separate separate tar file named
|
||||
rsync-patches-VERSION.tar.gz instead of the main rsync-VERSION.tar.gz.
|
||||
|
||||
- The proto.h file is now built using a simple perl script rather than a
|
||||
complex awk script, which proved to be more widely compatible.
|
||||
|
||||
- When running the tests, we now put our per-test temp dirs into a sub-
|
||||
directory named testtmp (which is created, if missing). This allows
|
||||
someone to symlink the testtmp directory to another filesystem (which is
|
||||
useful if the build dir's filesystem does not support ACLs and xattrs,
|
||||
but another filesystem does).
|
||||
|
||||
- Rsync now has a way of handling protocol-version changes during the
|
||||
development of a new protocol version. This causes any out-of-sync
|
||||
versions to speak an older protocol rather than fail in a cryptic manner.
|
||||
This addition makes it safer to deploy a pre-release version that may
|
||||
interact with the public. This new exchange of sub-version info does not
|
||||
interfere with the {MIN,MAX}_PROTOCOL_VERSION checking algorithm (which
|
||||
does not have enough range to allow the main protocol number to be
|
||||
incremented for every minor tweak in that happens during development).
|
||||
|
||||
- The csprotocol.txt file was updated to mention the daemon protocol change
|
||||
in the 3.0.0 release.
|
||||
|
||||
|
||||
NEWS for rsync 2.6.9 (6 Nov 2006)
|
||||
Protocol: 29 (unchanged)
|
||||
Changes since 2.6.8:
|
||||
@@ -2244,7 +2745,10 @@ Changes since 2.4.6:
|
||||
|
||||
Partial Protocol History
|
||||
RELEASE DATE VER. DATE OF COMMIT* PROTOCOL
|
||||
?? ??? 2007 3.0.0 11 Nov 2006 30
|
||||
?? ??? 2008 3.0.3 30
|
||||
08 Apr 2008 3.0.2 30
|
||||
03 Apr 2008 3.0.1 30
|
||||
01 Mar 2008 3.0.0 11 Nov 2006 30
|
||||
06 Nov 2006 2.6.9 29
|
||||
22 Apr 2006 2.6.8 29
|
||||
11 Mar 2006 2.6.7 29
|
||||
|
||||
123
README
123
README
@@ -1,122 +1,135 @@
|
||||
WHAT IS RSYNC?
|
||||
--------------
|
||||
|
||||
rsync is a replacement for scp/rcp that has many more features.
|
||||
Rsync is a fast and extraordinarily versatile file copying tool for
|
||||
both remote and local files.
|
||||
|
||||
rsync uses the "rsync algorithm" which provides a very fast method for
|
||||
bringing remote files into sync. It does this by sending just the
|
||||
Rsync uses a delta-transfer 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.
|
||||
At first glance this may seem impossible because the calculation of
|
||||
diffs between two files normally requires local access to both
|
||||
files.
|
||||
sets of files are present at one of the ends of the link beforehand. At
|
||||
first glance this may seem impossible because the calculation of diffs
|
||||
between two files normally requires local access to both files.
|
||||
|
||||
A technical report describing the rsync algorithm is included with
|
||||
this package.
|
||||
A technical report describing the rsync algorithm is included with this
|
||||
package.
|
||||
|
||||
|
||||
USAGE
|
||||
-----
|
||||
|
||||
Basically you use rsync just like rcp, but rsync has many additional
|
||||
options. To get a complete list of supported options type
|
||||
Basically you use rsync just like scp, but rsync has many additional
|
||||
options. To get a complete list of supported options type:
|
||||
|
||||
rsync --help
|
||||
rsync --help
|
||||
|
||||
and see the manual for more information.
|
||||
See the manpage for more detailed information.
|
||||
|
||||
|
||||
SETUP
|
||||
-----
|
||||
|
||||
Rsync normally uses ssh or rsh for communication. It does not need to
|
||||
be setuid and requires no special privileges for installation. You
|
||||
must, however, have a working ssh or rsh system. Using ssh is
|
||||
recommended for its security features.
|
||||
Rsync normally uses ssh or rsh for communication with remote systems.
|
||||
It does not need to be setuid and requires no special privileges for
|
||||
installation. You must, however, have a working ssh or rsh system.
|
||||
Using ssh is recommended for its security features.
|
||||
|
||||
Alternatively, rsync can run in `daemon' mode, listening on a socket.
|
||||
This is generally used for public file distribution, although
|
||||
authentication and access control are available.
|
||||
|
||||
To install rsync, first run the "configure" script. This will create a
|
||||
Makefile and config.h appropriate for your system. Then type
|
||||
"make".
|
||||
To install rsync, first run the "configure" script. This will create a
|
||||
Makefile and config.h appropriate for your system. Then type "make".
|
||||
|
||||
Note that on some systems you will have to force configure not to use
|
||||
gcc because gcc may not support some features (such as 64 bit file
|
||||
offsets) that your system may support. Set the environment variable CC
|
||||
offsets) that your system may support. Set the environment variable CC
|
||||
to the name of your native compiler before running configure in this
|
||||
case.
|
||||
case.
|
||||
|
||||
Once built put a copy of rsync in your search path on the local and
|
||||
remote systems (or use "make install"). That's it!
|
||||
remote systems (or use "make install"). That's it!
|
||||
|
||||
|
||||
RSYNC DAEMONS
|
||||
-------------
|
||||
|
||||
rsync can also talk to "rsync daemons" which can provide anonymous or
|
||||
authenticated rsync. See the rsyncd.conf(5) man page for details on how
|
||||
to setup an rsync daemon. See the rsync(1) man page for info on how to
|
||||
Rsync can also talk to "rsync daemons" which can provide anonymous or
|
||||
authenticated rsync. See the rsyncd.conf(5) man page for details on how
|
||||
to setup an rsync daemon. See the rsync(1) man page for info on how to
|
||||
connect to an rsync daemon.
|
||||
|
||||
|
||||
MAILING LIST
|
||||
------------
|
||||
WEB SITE
|
||||
--------
|
||||
|
||||
There is a mailing list for the discussion of rsync and its
|
||||
applications. It is open to anyone to join. I will announce new
|
||||
versions on this list.
|
||||
The main rsync web site is here:
|
||||
|
||||
To join the mailing list see the web page at http://lists.samba.org/
|
||||
http://rsync.samba.org/
|
||||
|
||||
To send mail to everyone on the list send it to rsync@lists.samba.org
|
||||
You'll find a FAQ list, downloads, resources, HTML versions of the
|
||||
manpages, etc.
|
||||
|
||||
|
||||
MAILING LISTS
|
||||
-------------
|
||||
|
||||
There is a mailing list for the discussion of rsync and its applications
|
||||
that is open to anyone to join. New releases are announced on this
|
||||
list, and there is also an announcement-only mailing list for those that
|
||||
want official announcements. See the mailing-list page for full
|
||||
details:
|
||||
|
||||
http://rsync.samba.org/lists.html
|
||||
|
||||
|
||||
BUG REPORTS
|
||||
-----------
|
||||
|
||||
If you have web access then please look at
|
||||
To visit this web page for full the details on bug reporting:
|
||||
|
||||
http://rsync.samba.org/
|
||||
http://rsync.samba.org/bugzilla.html
|
||||
|
||||
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
|
||||
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/
|
||||
http://mail-archive.com/rsync@lists.samba.org/
|
||||
|
||||
To send a bug report, follow the instructions on the bug-tracking
|
||||
page of the web site.
|
||||
|
||||
If you don't have web access, email your bug report to
|
||||
rsync@lists.samba.org.
|
||||
Alternately, email your bug report to rsync@lists.samba.org .
|
||||
|
||||
|
||||
CVS TREE
|
||||
--------
|
||||
GIT REPOSITORY
|
||||
--------------
|
||||
|
||||
If you want to get the very latest version of rsync direct from the
|
||||
source code repository then you can use anonymous cvs. You will need a
|
||||
recent version of cvs then use the following commands:
|
||||
source code repository then you can use git:
|
||||
|
||||
cvs -d :pserver:cvs@pserver.samba.org:/cvsroot login
|
||||
Password: cvs
|
||||
git clone git://git.samba.org/rsync.git
|
||||
|
||||
cvs -d :pserver:cvs@pserver.samba.org:/cvsroot co rsync
|
||||
See the download page for full details on all the ways to grab the
|
||||
source, including nightly tar files, web-browsing of the git repository,
|
||||
etc.:
|
||||
|
||||
Look at the cvs documentation for more details.
|
||||
http://rsync.samba.org/download.html
|
||||
|
||||
|
||||
COPYRIGHT
|
||||
---------
|
||||
|
||||
rsync was originally written by Andrew Tridgell and has been improved
|
||||
by many developers around the world. rsync may be used, modified and
|
||||
redistributed only under the terms of the GNU General Public License,
|
||||
found in the file COPYING in this distribution, or at
|
||||
Rsync was originally written by Andrew Tridgell and is currently
|
||||
maintained by Wayne Davison. It has been improved by many developers
|
||||
from around the world.
|
||||
|
||||
http://www.fsf.org/licenses/gpl.html
|
||||
Rsync may be used, modified and redistributed only under the terms of
|
||||
the GNU General Public License, found in the file COPYING in this
|
||||
distribution, or at:
|
||||
|
||||
http://www.fsf.org/licenses/gpl.html
|
||||
|
||||
|
||||
AVAILABILITY
|
||||
|
||||
2
access.c
2
access.c
@@ -2,7 +2,7 @@
|
||||
* Routines to authenticate access to a daemon (hosts allow/deny).
|
||||
*
|
||||
* Copyright (C) 1998 Andrew Tridgell
|
||||
* Copyright (C) 2004-2007 Wayne Davison
|
||||
* Copyright (C) 2004-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
22
acls.c
22
acls.c
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (C) 1996 Andrew Tridgell
|
||||
* Copyright (C) 1996 Paul Mackerras
|
||||
* Copyright (C) 2006 Wayne Davison
|
||||
* Copyright (C) 2006-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -92,9 +92,19 @@ static item_list default_acl_list = EMPTY_ITEM_LIST;
|
||||
|
||||
static const char *str_acl_type(SMB_ACL_TYPE_T type)
|
||||
{
|
||||
return type == SMB_ACL_TYPE_ACCESS ? "SMB_ACL_TYPE_ACCESS"
|
||||
: type == SMB_ACL_TYPE_DEFAULT ? "SMB_ACL_TYPE_DEFAULT"
|
||||
: "unknown SMB_ACL_TYPE_T";
|
||||
switch (type) {
|
||||
case SMB_ACL_TYPE_ACCESS:
|
||||
#ifdef HAVE_OSX_ACLS
|
||||
return "ACL_TYPE_EXTENDED";
|
||||
#else
|
||||
return "ACL_TYPE_ACCESS";
|
||||
#endif
|
||||
case SMB_ACL_TYPE_DEFAULT:
|
||||
return "ACL_TYPE_DEFAULT";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return "unknown ACL type!";
|
||||
}
|
||||
|
||||
static int calc_sacl_entries(const rsync_acl *racl)
|
||||
@@ -556,7 +566,7 @@ static void send_ida_entries(const ida_entries *idal, int f)
|
||||
|
||||
for (ida = idal->idas; count--; ida++) {
|
||||
uint32 xbits = ida->access << 2;
|
||||
char *name;
|
||||
const char *name;
|
||||
if (ida->access & NAME_IS_USER) {
|
||||
xbits |= XFLAG_NAME_IS_USER;
|
||||
name = add_uid(ida->id);
|
||||
@@ -933,7 +943,7 @@ static int set_rsync_acl(const char *fname, acl_duo *duo_item,
|
||||
#endif
|
||||
if (sys_acl_set_file(fname, type, duo_item->sacl) < 0) {
|
||||
rsyserr(FERROR_XFER, errno, "set_acl: sys_acl_set_file(%s, %s)",
|
||||
fname, str_acl_type(type));
|
||||
fname, str_acl_type(type));
|
||||
return -1;
|
||||
}
|
||||
if (type == SMB_ACL_TYPE_ACCESS)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Support rsync daemon authentication.
|
||||
*
|
||||
* Copyright (C) 1998-2000 Andrew Tridgell
|
||||
* Copyright (C) 2002-2007 Wayne Davison
|
||||
* Copyright (C) 2002-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
78
backup.c
78
backup.c
@@ -2,7 +2,7 @@
|
||||
* Backup handling code.
|
||||
*
|
||||
* Copyright (C) 1999 Andrew Tridgell
|
||||
* Copyright (C) 2003-2007 Wayne Davison
|
||||
* Copyright (C) 2003-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -180,10 +180,19 @@ int make_bak_dir(const char *fullpath)
|
||||
/* robustly move a file, creating new directory structures if necessary */
|
||||
static int robust_move(const char *src, char *dst)
|
||||
{
|
||||
if (robust_rename(src, dst, NULL, 0755) < 0
|
||||
&& (errno != ENOENT || make_bak_dir(dst) < 0
|
||||
|| robust_rename(src, dst, NULL, 0755) < 0))
|
||||
return -1;
|
||||
if (robust_rename(src, dst, NULL, 0755) < 0) {
|
||||
int save_errno = errno ? errno : EINVAL; /* 0 paranoia */
|
||||
if (errno == ENOENT && make_bak_dir(dst) == 0) {
|
||||
if (robust_rename(src, dst, NULL, 0755) < 0)
|
||||
save_errno = errno ? errno : save_errno;
|
||||
else
|
||||
save_errno = 0;
|
||||
}
|
||||
if (save_errno) {
|
||||
errno = save_errno;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -195,6 +204,7 @@ static int keep_backup(const char *fname)
|
||||
stat_x sx;
|
||||
struct file_struct *file;
|
||||
char *buf;
|
||||
int save_preserve_xattrs = preserve_xattrs;
|
||||
int kept = 0;
|
||||
int ret_code;
|
||||
|
||||
@@ -235,14 +245,24 @@ static int keep_backup(const char *fname)
|
||||
if ((am_root && preserve_devices && IS_DEVICE(file->mode))
|
||||
|| (preserve_specials && IS_SPECIAL(file->mode))) {
|
||||
uint32 *devp = F_RDEV_P(file);
|
||||
int save_errno;
|
||||
dev_t rdev = MAKEDEV(DEV_MAJOR(devp), DEV_MINOR(devp));
|
||||
do_unlink(buf);
|
||||
if (do_mknod(buf, file->mode, rdev) < 0
|
||||
&& (errno != ENOENT || make_bak_dir(buf) < 0
|
||||
|| do_mknod(buf, file->mode, rdev) < 0)) {
|
||||
rsyserr(FERROR, errno, "mknod %s failed",
|
||||
full_fname(buf));
|
||||
} else if (verbose > 2) {
|
||||
if (do_mknod(buf, file->mode, rdev) < 0) {
|
||||
save_errno = errno ? errno : EINVAL; /* 0 paranoia */
|
||||
if (errno == ENOENT && make_bak_dir(buf) == 0) {
|
||||
if (do_mknod(buf, file->mode, rdev) < 0)
|
||||
save_errno = errno ? errno : save_errno;
|
||||
else
|
||||
save_errno = 0;
|
||||
}
|
||||
if (save_errno) {
|
||||
rsyserr(FERROR, save_errno, "mknod %s failed",
|
||||
full_fname(buf));
|
||||
}
|
||||
} else
|
||||
save_errno = 0;
|
||||
if (verbose > 2 && save_errno == 0) {
|
||||
rprintf(FINFO, "make_backup: DEVICE %s successful.\n",
|
||||
fname);
|
||||
}
|
||||
@@ -252,11 +272,18 @@ static int keep_backup(const char *fname)
|
||||
|
||||
if (!kept && S_ISDIR(file->mode)) {
|
||||
/* make an empty directory */
|
||||
if (do_mkdir(buf, file->mode) < 0
|
||||
&& (errno != ENOENT || make_bak_dir(buf) < 0
|
||||
|| do_mkdir(buf, file->mode) < 0)) {
|
||||
rsyserr(FINFO, errno, "mkdir %s failed",
|
||||
full_fname(buf));
|
||||
if (do_mkdir(buf, file->mode) < 0) {
|
||||
int save_errno = errno ? errno : EINVAL; /* 0 paranoia */
|
||||
if (errno == ENOENT && make_bak_dir(buf) == 0) {
|
||||
if (do_mkdir(buf, file->mode) < 0)
|
||||
save_errno = errno ? errno : save_errno;
|
||||
else
|
||||
save_errno = 0;
|
||||
}
|
||||
if (save_errno) {
|
||||
rsyserr(FINFO, save_errno, "mkdir %s failed",
|
||||
full_fname(buf));
|
||||
}
|
||||
}
|
||||
|
||||
ret_code = do_rmdir(fname);
|
||||
@@ -278,11 +305,18 @@ static int keep_backup(const char *fname)
|
||||
kept = 1;
|
||||
} else {
|
||||
do_unlink(buf);
|
||||
if (do_symlink(sl, buf) < 0
|
||||
&& (errno != ENOENT || make_bak_dir(buf) < 0
|
||||
|| do_symlink(sl, buf) < 0)) {
|
||||
rsyserr(FERROR, errno, "link %s -> \"%s\"",
|
||||
full_fname(buf), sl);
|
||||
if (do_symlink(sl, buf) < 0) {
|
||||
int save_errno = errno ? errno : EINVAL; /* 0 paranoia */
|
||||
if (errno == ENOENT && make_bak_dir(buf) == 0) {
|
||||
if (do_symlink(sl, buf) < 0)
|
||||
save_errno = errno ? errno : save_errno;
|
||||
else
|
||||
save_errno = 0;
|
||||
}
|
||||
if (save_errno) {
|
||||
rsyserr(FERROR, save_errno, "link %s -> \"%s\"",
|
||||
full_fname(buf), sl);
|
||||
}
|
||||
}
|
||||
do_unlink(fname);
|
||||
kept = 1;
|
||||
@@ -308,7 +342,9 @@ static int keep_backup(const char *fname)
|
||||
robust_unlink(fname); /* Just in case... */
|
||||
}
|
||||
}
|
||||
preserve_xattrs = 0;
|
||||
set_file_attrs(buf, file, NULL, fname, 0);
|
||||
preserve_xattrs = save_preserve_xattrs;
|
||||
unmake_file(file);
|
||||
|
||||
if (verbose > 1) {
|
||||
|
||||
78
batch.c
78
batch.c
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (C) 1999 Weiss
|
||||
* Copyright (C) 2004 Chris Shoemaker
|
||||
* Copyright (C) 2004-2007 Wayne Davison
|
||||
* Copyright (C) 2004-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -31,15 +31,25 @@ extern int preserve_hard_links;
|
||||
extern int preserve_devices;
|
||||
extern int preserve_uid;
|
||||
extern int preserve_gid;
|
||||
extern int preserve_acls;
|
||||
extern int preserve_xattrs;
|
||||
extern int always_checksum;
|
||||
extern int do_compression;
|
||||
extern int def_compress_level;
|
||||
extern int inplace;
|
||||
extern int append_mode;
|
||||
extern int protocol_version;
|
||||
extern char *batch_name;
|
||||
#ifdef ICONV_OPTION
|
||||
extern char *iconv_opt;
|
||||
#endif
|
||||
|
||||
extern struct filter_list_struct filter_list;
|
||||
|
||||
static int tweaked_compress_level;
|
||||
int batch_stream_flags;
|
||||
|
||||
static int tweaked_append;
|
||||
static int tweaked_append_verify;
|
||||
static int tweaked_iconv;
|
||||
|
||||
static int *flag_ptr[] = {
|
||||
&recurse, /* 0 */
|
||||
@@ -50,7 +60,13 @@ static int *flag_ptr[] = {
|
||||
&preserve_hard_links, /* 5 */
|
||||
&always_checksum, /* 6 */
|
||||
&xfer_dirs, /* 7 (protocol 29) */
|
||||
&tweaked_compress_level,/* 8 (protocol 29) */
|
||||
&do_compression, /* 8 (protocol 29) */
|
||||
&tweaked_iconv, /* 9 (protocol 30) */
|
||||
&preserve_acls, /* 10 (protocol 30) */
|
||||
&preserve_xattrs, /* 11 (protocol 30) */
|
||||
&inplace, /* 12 (protocol 30) */
|
||||
&tweaked_append, /* 13 (protocol 30) */
|
||||
&tweaked_append_verify, /* 14 (protocol 30) */
|
||||
NULL
|
||||
};
|
||||
|
||||
@@ -64,6 +80,12 @@ static char *flag_name[] = {
|
||||
"--checksum (-c)",
|
||||
"--dirs (-d)",
|
||||
"--compress (-z)",
|
||||
"--iconv",
|
||||
"--acls (-A)",
|
||||
"--xattrs (-X)",
|
||||
"--inplace",
|
||||
"--append",
|
||||
"--append-verify",
|
||||
NULL
|
||||
};
|
||||
|
||||
@@ -71,16 +93,14 @@ void write_stream_flags(int fd)
|
||||
{
|
||||
int i, flags;
|
||||
|
||||
#if Z_DEFAULT_COMPRESSION == -1
|
||||
tweaked_compress_level = do_compression ? def_compress_level + 2 : 0;
|
||||
#else
|
||||
#error internal logic error! Fix def_compress_level logic above and below too!
|
||||
tweaked_append = append_mode == 1;
|
||||
tweaked_append_verify = append_mode == 2;
|
||||
#ifdef ICONV_OPTION
|
||||
tweaked_iconv = iconv_opt != NULL;
|
||||
#endif
|
||||
|
||||
/* Start the batch file with a bitmap of data-stream-affecting
|
||||
* flags. */
|
||||
if (protocol_version < 29)
|
||||
flag_ptr[7] = NULL;
|
||||
for (i = 0, flags = 0; flag_ptr[i]; i++) {
|
||||
if (*flag_ptr[i])
|
||||
flags |= 1 << i;
|
||||
@@ -90,13 +110,31 @@ void write_stream_flags(int fd)
|
||||
|
||||
void read_stream_flags(int fd)
|
||||
{
|
||||
int i, flags;
|
||||
batch_stream_flags = read_int(fd);
|
||||
}
|
||||
|
||||
void check_batch_flags(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (protocol_version < 29)
|
||||
flag_ptr[7] = NULL;
|
||||
for (i = 0, flags = read_int(fd); flag_ptr[i]; i++) {
|
||||
int set = flags & (1 << i) ? 1 : 0;
|
||||
else if (protocol_version < 30)
|
||||
flag_ptr[9] = NULL;
|
||||
tweaked_append = append_mode == 1;
|
||||
tweaked_append_verify = append_mode == 2;
|
||||
#ifdef ICONV_OPTION
|
||||
tweaked_iconv = iconv_opt != NULL;
|
||||
#endif
|
||||
for (i = 0; flag_ptr[i]; i++) {
|
||||
int set = batch_stream_flags & (1 << i) ? 1 : 0;
|
||||
if (*flag_ptr[i] != set) {
|
||||
if (i == 9) {
|
||||
rprintf(FERROR,
|
||||
"%s specify the --iconv option to use this batch file.\n",
|
||||
set ? "Please" : "Do not");
|
||||
exit_cleanup(RERR_SYNTAX);
|
||||
}
|
||||
if (verbose) {
|
||||
rprintf(FINFO,
|
||||
"%sing the %s option to match the batchfile.\n",
|
||||
@@ -112,12 +150,10 @@ void read_stream_flags(int fd)
|
||||
xfer_dirs = 0;
|
||||
}
|
||||
|
||||
if (tweaked_compress_level == 0 || tweaked_compress_level == 2)
|
||||
do_compression = 0;
|
||||
else {
|
||||
do_compression = 1;
|
||||
def_compress_level = tweaked_compress_level - 2;
|
||||
}
|
||||
if (tweaked_append)
|
||||
append_mode = 1;
|
||||
else if (tweaked_append_verify)
|
||||
append_mode = 2;
|
||||
}
|
||||
|
||||
static void write_arg(int fd, char *arg)
|
||||
@@ -179,7 +215,7 @@ void write_batch_shell_file(int argc, char *argv[], int file_arg_cnt)
|
||||
if (fd < 0) {
|
||||
rsyserr(FERROR, errno, "Batch file %s open error",
|
||||
filename);
|
||||
exit_cleanup(1);
|
||||
exit_cleanup(RERR_FILESELECT);
|
||||
}
|
||||
|
||||
/* Write argvs info to BATCH.sh file */
|
||||
@@ -225,6 +261,6 @@ void write_batch_shell_file(int argc, char *argv[], int file_arg_cnt)
|
||||
if (write(fd, "\n", 1) != 1 || close(fd) < 0) {
|
||||
rsyserr(FERROR, errno, "Batch file %s write error",
|
||||
filename);
|
||||
exit_cleanup(1);
|
||||
exit_cleanup(RERR_FILEIO);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Simple byteorder handling.
|
||||
*
|
||||
* Copyright (C) 1992-1995 Andrew Tridgell
|
||||
* Copyright (C) 2007 Wayne Davison
|
||||
* Copyright (C) 2007-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
2
case_N.h
2
case_N.h
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* End-of-run cleanup helper code used by cleanup.c.
|
||||
*
|
||||
* Copyright (C) 2006-2007 Wayne Davison
|
||||
* Copyright (C) 2006-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (C) 1996 Andrew Tridgell
|
||||
* Copyright (C) 1996 Paul Mackerras
|
||||
* Copyright (C) 2004-2007 Wayne Davison
|
||||
* Copyright (C) 2004-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
2
chmod.c
2
chmod.c
@@ -2,7 +2,7 @@
|
||||
* Implement the core of the --chmod option.
|
||||
*
|
||||
* Copyright (C) 2002 Scott Howard
|
||||
* Copyright (C) 2005-2007 Wayne Davison
|
||||
* Copyright (C) 2005-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Copyright (C) 1996-2000 Andrew Tridgell
|
||||
* Copyright (C) 1996 Paul Mackerras
|
||||
* Copyright (C) 2002 Martin Pool
|
||||
* Copyright (C) 2003-2007 Wayne Davison
|
||||
* Copyright (C) 2003-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -27,6 +27,7 @@ extern int am_daemon;
|
||||
extern int io_error;
|
||||
extern int keep_partial;
|
||||
extern int got_xfer_error;
|
||||
extern int progress_is_active;
|
||||
extern char *partial_dir;
|
||||
extern char *logfile_name;
|
||||
|
||||
@@ -115,6 +116,9 @@ NORETURN void _exit_cleanup(int code, const char *file, int line)
|
||||
|
||||
exit_code = unmodified_code = code;
|
||||
|
||||
if (progress_is_active && exit_code && !am_server)
|
||||
rprintf(FINFO, "\n");
|
||||
|
||||
if (verbose > 3) {
|
||||
rprintf(FINFO,
|
||||
"_exit_cleanup(code=%d, file=%s, line=%d): entered\n",
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (C) 1992-2001 Andrew Tridgell <tridge@samba.org>
|
||||
* Copyright (C) 2001, 2002 Martin Pool <mbp@samba.org>
|
||||
* Copyright (C) 2002-2007 Wayne Davison
|
||||
* Copyright (C) 2002-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -266,7 +266,7 @@ int compare_addrinfo_sockaddr(const struct addrinfo *ai,
|
||||
|
||||
if (ai->ai_addrlen < sizeof (struct sockaddr_in6)) {
|
||||
rprintf(FLOG, "%s: too short sockaddr_in6; length=%d\n",
|
||||
fn, ai->ai_addrlen);
|
||||
fn, (int)ai->ai_addrlen);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
209
clientserver.c
209
clientserver.c
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (C) 1998-2001 Andrew Tridgell <tridge@samba.org>
|
||||
* Copyright (C) 2001-2002 Martin Pool <mbp@samba.org>
|
||||
* Copyright (C) 2002-2007 Wayne Davison
|
||||
* Copyright (C) 2002-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "rsync.h"
|
||||
#include "ifuncs.h"
|
||||
|
||||
extern int quiet;
|
||||
extern int verbose;
|
||||
extern int dry_run;
|
||||
extern int output_motd;
|
||||
@@ -31,10 +32,13 @@ extern int am_server;
|
||||
extern int am_daemon;
|
||||
extern int am_root;
|
||||
extern int rsync_port;
|
||||
extern int protect_args;
|
||||
extern int ignore_errors;
|
||||
extern int preserve_xattrs;
|
||||
extern int kluge_around_eof;
|
||||
extern int daemon_over_rsh;
|
||||
extern int sanitize_paths;
|
||||
extern int numeric_ids;
|
||||
extern int filesfrom_fd;
|
||||
extern int remote_protocol;
|
||||
extern int protocol_version;
|
||||
@@ -52,8 +56,12 @@ extern char *logfile_format;
|
||||
extern char *files_from;
|
||||
extern char *tmpdir;
|
||||
extern struct chmod_mode_struct *chmod_modes;
|
||||
extern struct filter_list_struct server_filter_list;
|
||||
extern struct filter_list_struct daemon_filter_list;
|
||||
extern char curr_dir[];
|
||||
#ifdef ICONV_OPTION
|
||||
extern char *iconv_opt;
|
||||
extern iconv_t ic_send, ic_recv;
|
||||
#endif
|
||||
|
||||
char *auth_user;
|
||||
int read_only = 0;
|
||||
@@ -62,7 +70,8 @@ int munge_symlinks = 0;
|
||||
struct chmod_mode_struct *daemon_chmod_modes;
|
||||
|
||||
/* module_dirlen is the length of the module_dir string when in daemon
|
||||
* mode, not chrooted, and the path is not "/"; otherwise 0. */
|
||||
* mode and module_dir is not "/"; otherwise 0. (Note that a chroot-
|
||||
* enabled module can have a non-"/" module_dir these days.) */
|
||||
char *module_dir = NULL;
|
||||
unsigned int module_dirlen = 0;
|
||||
|
||||
@@ -112,7 +121,9 @@ int start_socket_client(char *host, int remote_argc, char *remote_argv[],
|
||||
if (fd == -1)
|
||||
exit_cleanup(RERR_SOCKETIO);
|
||||
|
||||
set_socket_options(fd, sockopts);
|
||||
#ifdef ICONV_CONST
|
||||
setup_iconv();
|
||||
#endif
|
||||
|
||||
ret = start_inband_exchange(fd, fd, user, remote_argc, remote_argv);
|
||||
|
||||
@@ -201,7 +212,7 @@ int start_inband_exchange(int f_in, int f_out, const char *user, int argc, char
|
||||
int sargc = 0;
|
||||
char *p, *modname;
|
||||
|
||||
assert(argc > 0);
|
||||
assert(argc > 0 && *argv != NULL);
|
||||
|
||||
if (**argv == '/') {
|
||||
rprintf(FERROR,
|
||||
@@ -245,7 +256,7 @@ int start_inband_exchange(int f_in, int f_out, const char *user, int argc, char
|
||||
rprintf(FERROR, "internal: args[] overflowed in do_cmd()\n");
|
||||
exit_cleanup(RERR_SYNTAX);
|
||||
}
|
||||
if (list_only && strncmp(*argv, modname, modlen) == 0
|
||||
if (strncmp(*argv, modname, modlen) == 0
|
||||
&& argv[0][modlen] == '\0')
|
||||
sargs[sargc++] = modname; /* we send "modname/" */
|
||||
else
|
||||
@@ -303,6 +314,8 @@ int start_inband_exchange(int f_in, int f_out, const char *user, int argc, char
|
||||
|
||||
if (rl_nulls) {
|
||||
for (i = 0; i < sargc; i++) {
|
||||
if (!sargs[i]) /* stop at --protect-args NULL */
|
||||
break;
|
||||
write_sbuf(f_out, sargs[i]);
|
||||
write_byte(f_out, 0);
|
||||
}
|
||||
@@ -313,6 +326,9 @@ int start_inband_exchange(int f_in, int f_out, const char *user, int argc, char
|
||||
write_sbuf(f_out, "\n");
|
||||
}
|
||||
|
||||
if (protect_args)
|
||||
send_protected_args(f_out, sargs);
|
||||
|
||||
if (protocol_version < 23) {
|
||||
if (protocol_version == 22 || !am_sender)
|
||||
io_start_multiplex_in();
|
||||
@@ -324,16 +340,24 @@ int start_inband_exchange(int f_in, int f_out, const char *user, int argc, char
|
||||
}
|
||||
|
||||
static char *finish_pre_exec(pid_t pid, int fd, char *request,
|
||||
int argc, char *argv[])
|
||||
char **early_argv, char **argv)
|
||||
{
|
||||
int j, status = -1;
|
||||
int j = 0, status = -1;
|
||||
|
||||
if (!request)
|
||||
request = "(NONE)";
|
||||
|
||||
write_buf(fd, request, strlen(request)+1);
|
||||
for (j = 0; j < argc; j++)
|
||||
if (early_argv) {
|
||||
for ( ; *early_argv; early_argv++)
|
||||
write_buf(fd, *early_argv, strlen(*early_argv)+1);
|
||||
j = 1; /* Skip arg0 name in argv. */
|
||||
}
|
||||
for ( ; argv[j]; j++) {
|
||||
write_buf(fd, argv[j], strlen(argv[j])+1);
|
||||
if (argv[j][0] == '.' && argv[j][1] == '\0')
|
||||
break;
|
||||
}
|
||||
write_byte(fd, 0);
|
||||
|
||||
close(fd);
|
||||
@@ -355,8 +379,12 @@ static int read_arg_from_pipe(int fd, char *buf, int limit)
|
||||
char *bp = buf, *eob = buf + limit - 1;
|
||||
|
||||
while (1) {
|
||||
if (read(fd, bp, 1) != 1)
|
||||
int got = read(fd, bp, 1);
|
||||
if (got != 1) {
|
||||
if (got < 0 && errno == EINTR)
|
||||
continue;
|
||||
return -1;
|
||||
}
|
||||
if (*bp == '\0')
|
||||
break;
|
||||
if (bp < eob)
|
||||
@@ -369,8 +397,8 @@ static int read_arg_from_pipe(int fd, char *buf, int limit)
|
||||
|
||||
static int rsync_module(int f_in, int f_out, int i, char *addr, char *host)
|
||||
{
|
||||
int argc, opt_cnt;
|
||||
char **argv;
|
||||
int argc;
|
||||
char **argv, **orig_argv, **orig_early_argv, *chroot_path = NULL;
|
||||
char line[BIGPATHBUFLEN];
|
||||
uid_t uid = (uid_t)-2; /* canonically "nobody" */
|
||||
gid_t gid = (gid_t)-2;
|
||||
@@ -381,6 +409,13 @@ static int rsync_module(int f_in, int f_out, int i, char *addr, char *host)
|
||||
pid_t pre_exec_pid = 0;
|
||||
char *request = NULL;
|
||||
|
||||
#ifdef ICONV_OPTION
|
||||
iconv_opt = lp_charset(i);
|
||||
if (*iconv_opt)
|
||||
setup_iconv();
|
||||
iconv_opt = NULL;
|
||||
#endif
|
||||
|
||||
if (!allow_access(addr, host, lp_hosts_allow(i), lp_hosts_deny(i))) {
|
||||
rprintf(FLOG, "rsync denied on module %s from %s (%s)\n",
|
||||
name, host, addr);
|
||||
@@ -463,43 +498,57 @@ static int rsync_module(int f_in, int f_out, int i, char *addr, char *host)
|
||||
/* TODO: Perhaps take a list of gids, and make them into the
|
||||
* supplementary groups. */
|
||||
|
||||
/* We do a push_dir() without actually calling chdir() in order
|
||||
* to make sure that the module's path is absolute. After this
|
||||
* check, module_dir will be set to an absolute path. */
|
||||
module_dir = lp_path(i);
|
||||
strlcpy(line, curr_dir, sizeof line);
|
||||
if (!push_dir(module_dir, 1))
|
||||
goto chdir_failed;
|
||||
if (strcmp(curr_dir, module_dir) != 0)
|
||||
module_dir = strdup(curr_dir);
|
||||
push_dir(line, 1); /* Restore curr_dir. */
|
||||
if (use_chroot) {
|
||||
if ((p = strstr(module_dir, "/./")) != NULL) {
|
||||
*p = '\0';
|
||||
p += 2;
|
||||
} else if ((p = strdup("/")) == NULL) /* MEMORY LEAK */
|
||||
out_of_memory("rsync_module");
|
||||
}
|
||||
|
||||
if (use_chroot || (module_dirlen = strlen(module_dir)) == 1) {
|
||||
/* We do a change_dir() that doesn't actually call chdir()
|
||||
* just to make a relative path absolute. */
|
||||
strlcpy(line, curr_dir, sizeof line);
|
||||
if (!change_dir(module_dir, CD_SKIP_CHDIR))
|
||||
goto chdir_failed;
|
||||
if (strcmp(curr_dir, module_dir) != 0
|
||||
&& (module_dir = strdup(curr_dir)) == NULL)
|
||||
out_of_memory("rsync_module");
|
||||
change_dir(line, CD_SKIP_CHDIR); /* Restore curr_dir. */
|
||||
|
||||
if (use_chroot) {
|
||||
chroot_path = module_dir;
|
||||
module_dir = p; /* p is "/" or our inside-chroot path */
|
||||
}
|
||||
module_dirlen = clean_fname(module_dir, CFN_COLLAPSE_DOT_DOT_DIRS | CFN_DROP_TRAILING_DOT_DIR);
|
||||
|
||||
if (module_dirlen == 1) {
|
||||
module_dirlen = 0;
|
||||
set_filter_dir("/", 1);
|
||||
} else
|
||||
set_filter_dir(module_dir, module_dirlen);
|
||||
|
||||
p = lp_filter(i);
|
||||
parse_rule(&server_filter_list, p, MATCHFLG_WORD_SPLIT,
|
||||
XFLG_ABS_IF_SLASH);
|
||||
parse_rule(&daemon_filter_list, p, MATCHFLG_WORD_SPLIT,
|
||||
XFLG_ABS_IF_SLASH | XFLG_DIR2WILD3);
|
||||
|
||||
p = lp_include_from(i);
|
||||
parse_filter_file(&server_filter_list, p, MATCHFLG_INCLUDE,
|
||||
XFLG_ABS_IF_SLASH | XFLG_OLD_PREFIXES | XFLG_FATAL_ERRORS);
|
||||
parse_filter_file(&daemon_filter_list, p, MATCHFLG_INCLUDE,
|
||||
XFLG_ABS_IF_SLASH | XFLG_DIR2WILD3 | XFLG_OLD_PREFIXES | XFLG_FATAL_ERRORS);
|
||||
|
||||
p = lp_include(i);
|
||||
parse_rule(&server_filter_list, p,
|
||||
parse_rule(&daemon_filter_list, p,
|
||||
MATCHFLG_INCLUDE | MATCHFLG_WORD_SPLIT,
|
||||
XFLG_ABS_IF_SLASH | XFLG_OLD_PREFIXES);
|
||||
XFLG_ABS_IF_SLASH | XFLG_DIR2WILD3 | XFLG_OLD_PREFIXES);
|
||||
|
||||
p = lp_exclude_from(i);
|
||||
parse_filter_file(&server_filter_list, p, 0,
|
||||
XFLG_ABS_IF_SLASH | XFLG_OLD_PREFIXES | XFLG_FATAL_ERRORS);
|
||||
parse_filter_file(&daemon_filter_list, p, 0,
|
||||
XFLG_ABS_IF_SLASH | XFLG_DIR2WILD3 | XFLG_OLD_PREFIXES | XFLG_FATAL_ERRORS);
|
||||
|
||||
p = lp_exclude(i);
|
||||
parse_rule(&server_filter_list, p, MATCHFLG_WORD_SPLIT,
|
||||
XFLG_ABS_IF_SLASH | XFLG_OLD_PREFIXES);
|
||||
parse_rule(&daemon_filter_list, p, MATCHFLG_WORD_SPLIT,
|
||||
XFLG_ABS_IF_SLASH | XFLG_DIR2WILD3 | XFLG_OLD_PREFIXES);
|
||||
|
||||
log_init(1);
|
||||
|
||||
@@ -507,8 +556,17 @@ static int rsync_module(int f_in, int f_out, int i, char *addr, char *host)
|
||||
if (*lp_prexfer_exec(i) || *lp_postxfer_exec(i)) {
|
||||
char *modname, *modpath, *hostaddr, *hostname, *username;
|
||||
int status;
|
||||
|
||||
if (!use_chroot)
|
||||
p = module_dir;
|
||||
else if (module_dirlen) {
|
||||
pathjoin(line, sizeof line, chroot_path, module_dir+1);
|
||||
p = line;
|
||||
} else
|
||||
p = chroot_path;
|
||||
|
||||
if (asprintf(&modname, "RSYNC_MODULE_NAME=%s", name) < 0
|
||||
|| asprintf(&modpath, "RSYNC_MODULE_PATH=%s", module_dir) < 0
|
||||
|| asprintf(&modpath, "RSYNC_MODULE_PATH=%s", p) < 0
|
||||
|| asprintf(&hostaddr, "RSYNC_HOST_ADDR=%s", addr) < 0
|
||||
|| asprintf(&hostname, "RSYNC_HOST_NAME=%s", host) < 0
|
||||
|| asprintf(&username, "RSYNC_USER_NAME=%s", auth_user) < 0)
|
||||
@@ -608,15 +666,17 @@ static int rsync_module(int f_in, int f_out, int i, char *addr, char *host)
|
||||
* a warning, unless a "require chroot" flag is set,
|
||||
* in which case we fail.
|
||||
*/
|
||||
if (chroot(module_dir)) {
|
||||
rsyserr(FLOG, errno, "chroot %s failed", module_dir);
|
||||
if (chroot(chroot_path)) {
|
||||
rsyserr(FLOG, errno, "chroot %s failed", chroot_path);
|
||||
io_printf(f_out, "@ERROR: chroot failed\n");
|
||||
return -1;
|
||||
}
|
||||
if (!push_dir("/", 0))
|
||||
if (!change_dir(module_dir, CD_NORMAL))
|
||||
goto chdir_failed;
|
||||
if (module_dirlen)
|
||||
sanitize_paths = 1;
|
||||
} else {
|
||||
if (!push_dir(module_dir, 0)) {
|
||||
if (!change_dir(module_dir, CD_NORMAL)) {
|
||||
chdir_failed:
|
||||
rsyserr(FLOG, errno, "chdir %s failed\n", module_dir);
|
||||
io_printf(f_out, "@ERROR: chdir failed\n");
|
||||
@@ -626,10 +686,10 @@ static int rsync_module(int f_in, int f_out, int i, char *addr, char *host)
|
||||
}
|
||||
|
||||
if ((munge_symlinks = lp_munge_symlinks(i)) < 0)
|
||||
munge_symlinks = !use_chroot;
|
||||
munge_symlinks = !use_chroot || module_dirlen;
|
||||
if (munge_symlinks) {
|
||||
STRUCT_STAT st;
|
||||
if (stat(SYMLINK_PREFIX, &st) == 0 && S_ISDIR(st.st_mode)) {
|
||||
if (do_stat(SYMLINK_PREFIX, &st) == 0 && S_ISDIR(st.st_mode)) {
|
||||
rprintf(FLOG, "Symlink munging is unsupported when a %s directory exists.\n",
|
||||
SYMLINK_PREFIX);
|
||||
io_printf(f_out, "@ERROR: daemon security issue -- contact admin\n", name);
|
||||
@@ -684,24 +744,40 @@ static int rsync_module(int f_in, int f_out, int i, char *addr, char *host)
|
||||
|
||||
io_printf(f_out, "@RSYNCD: OK\n");
|
||||
|
||||
opt_cnt = read_args(f_in, name, line, sizeof line, rl_nulls, &argv, &argc, &request);
|
||||
read_args(f_in, name, line, sizeof line, rl_nulls, &argv, &argc, &request);
|
||||
orig_argv = argv;
|
||||
|
||||
verbose = 0; /* future verbosity is controlled by client options */
|
||||
ret = parse_arguments(&argc, (const char ***) &argv);
|
||||
if (protect_args && ret) {
|
||||
orig_early_argv = orig_argv;
|
||||
protect_args = 2;
|
||||
read_args(f_in, name, line, sizeof line, 1, &argv, &argc, &request);
|
||||
orig_argv = argv;
|
||||
ret = parse_arguments(&argc, (const char ***) &argv);
|
||||
} else
|
||||
orig_early_argv = NULL;
|
||||
|
||||
if (pre_exec_pid) {
|
||||
err_msg = finish_pre_exec(pre_exec_pid, pre_exec_fd, request,
|
||||
opt_cnt, argv);
|
||||
orig_early_argv, orig_argv);
|
||||
}
|
||||
|
||||
verbose = 0; /* future verbosity is controlled by client options */
|
||||
ret = parse_arguments(&argc, (const char ***) &argv, 0);
|
||||
if (orig_early_argv)
|
||||
free(orig_early_argv);
|
||||
|
||||
am_server = 1; /* Don't let someone try to be tricky. */
|
||||
quiet = 0;
|
||||
if (lp_ignore_errors(module_id))
|
||||
ignore_errors = 1;
|
||||
if (write_batch < 0)
|
||||
dry_run = 1;
|
||||
|
||||
if (lp_fake_super(i))
|
||||
if (lp_fake_super(i)) {
|
||||
if (preserve_xattrs > 1)
|
||||
preserve_xattrs = 1;
|
||||
am_root = -1;
|
||||
else if (am_root < 0) /* Treat --fake-super from client as --super. */
|
||||
} else if (am_root < 0) /* Treat --fake-super from client as --super. */
|
||||
am_root = 2;
|
||||
|
||||
if (filesfrom_fd == 0)
|
||||
@@ -764,6 +840,23 @@ static int rsync_module(int f_in, int f_out, int i, char *addr, char *host)
|
||||
exit_cleanup(RERR_UNSUPPORTED);
|
||||
}
|
||||
|
||||
#ifdef ICONV_OPTION
|
||||
if (!iconv_opt) {
|
||||
if (ic_send != (iconv_t)-1) {
|
||||
iconv_close(ic_send);
|
||||
ic_send = (iconv_t)-1;
|
||||
}
|
||||
if (ic_recv != (iconv_t)-1) {
|
||||
iconv_close(ic_recv);
|
||||
ic_recv = (iconv_t)-1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!numeric_ids
|
||||
&& (use_chroot ? lp_numeric_ids(i) != False : lp_numeric_ids(i) == True))
|
||||
numeric_ids = -1; /* Set --numeric-ids w/o breaking protocol. */
|
||||
|
||||
if (lp_timeout(i) && lp_timeout(i) > io_timeout)
|
||||
set_io_timeout(lp_timeout(i));
|
||||
|
||||
@@ -801,6 +894,17 @@ static void send_listing(int fd)
|
||||
io_printf(fd,"@RSYNCD: EXIT\n");
|
||||
}
|
||||
|
||||
static int load_config(int globals_only)
|
||||
{
|
||||
if (!config_file) {
|
||||
if (am_server && am_root <= 0)
|
||||
config_file = RSYNCD_USERCONF;
|
||||
else
|
||||
config_file = RSYNCD_SYSCONF;
|
||||
}
|
||||
return lp_load(config_file, globals_only);
|
||||
}
|
||||
|
||||
/* 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 */
|
||||
@@ -816,7 +920,7 @@ int start_daemon(int f_in, int f_out)
|
||||
* might cause log-file output to occur. This ensures that the
|
||||
* "log file" param gets honored for the 2 non-forked use-cases
|
||||
* (when rsync is run by init and run by a remote shell). */
|
||||
if (!lp_load(config_file, 0))
|
||||
if (!load_config(0))
|
||||
exit_cleanup(RERR_SYNTAX);
|
||||
|
||||
addr = client_addr(f_in);
|
||||
@@ -825,10 +929,6 @@ int start_daemon(int f_in, int f_out)
|
||||
|
||||
if (!am_server) {
|
||||
set_socket_options(f_in, "SO_KEEPALIVE");
|
||||
if (sockopts)
|
||||
set_socket_options(f_in, sockopts);
|
||||
else
|
||||
set_socket_options(f_in, lp_socket_options());
|
||||
set_nonblocking(f_in);
|
||||
}
|
||||
|
||||
@@ -925,13 +1025,6 @@ static void become_daemon(void)
|
||||
|
||||
int daemon_main(void)
|
||||
{
|
||||
if (!config_file) {
|
||||
if (am_server && am_root <= 0)
|
||||
config_file = RSYNCD_USERCONF;
|
||||
else
|
||||
config_file = RSYNCD_SYSCONF;
|
||||
}
|
||||
|
||||
if (is_a_socket(STDIN_FILENO)) {
|
||||
int i;
|
||||
|
||||
@@ -946,7 +1039,7 @@ int daemon_main(void)
|
||||
return start_daemon(STDIN_FILENO, STDIN_FILENO);
|
||||
}
|
||||
|
||||
if (!lp_load(config_file, 1)) {
|
||||
if (!load_config(1)) {
|
||||
fprintf(stderr, "Failed to parse config file: %s\n", config_file);
|
||||
exit_cleanup(RERR_SYNTAX);
|
||||
}
|
||||
|
||||
48
compat.c
48
compat.c
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (C) Andrew Tridgell 1996
|
||||
* Copyright (C) Paul Mackerras 1996
|
||||
* Copyright (C) 2004-2007 Wayne Davison
|
||||
* Copyright (C) 2004-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -48,7 +48,7 @@ extern int preserve_acls;
|
||||
extern int preserve_xattrs;
|
||||
extern int need_messages_from_generator;
|
||||
extern int delete_mode, delete_before, delete_during, delete_after;
|
||||
extern char *shell_cmd; /* contains VER.SUB string if client is a pre-release */
|
||||
extern char *shell_cmd;
|
||||
extern char *partial_dir;
|
||||
extern char *dest_option;
|
||||
extern char *files_from;
|
||||
@@ -62,10 +62,17 @@ extern iconv_t ic_send, ic_recv;
|
||||
/* These index values are for the file-list's extra-attribute array. */
|
||||
int uid_ndx, gid_ndx, acls_ndx, xattrs_ndx, unsort_ndx;
|
||||
|
||||
int receiver_symlink_times = 0; /* receiver can set the time on a symlink */
|
||||
|
||||
#ifdef ICONV_OPTION
|
||||
int filesfrom_convert = 0;
|
||||
#endif
|
||||
|
||||
#define CF_INC_RECURSE (1<<0)
|
||||
#define CF_SYMLINK_TIMES (1<<1)
|
||||
|
||||
static const char *client_info;
|
||||
|
||||
/* The server makes sure that if either side only supports a pre-release
|
||||
* version of a protocol, that both sides must speak a compatible version
|
||||
* of that protocol for it to be advertised as available. */
|
||||
@@ -79,8 +86,9 @@ static void check_sub_protocol(void)
|
||||
int our_sub = 0;
|
||||
#endif
|
||||
|
||||
if (!shell_cmd || !(dot = strchr(shell_cmd, '.'))
|
||||
|| !(their_protocol = atoi(shell_cmd))
|
||||
/* client_info starts with VER.SUB string if client is a pre-release. */
|
||||
if (!(their_protocol = atoi(client_info))
|
||||
|| !(dot = strchr(client_info, '.'))
|
||||
|| !(their_sub = atoi(dot+1))) {
|
||||
#if SUBPROTOCOL_VERSION != 0
|
||||
if (our_sub)
|
||||
@@ -103,6 +111,8 @@ static void check_sub_protocol(void)
|
||||
|
||||
void set_allow_inc_recurse(void)
|
||||
{
|
||||
client_info = shell_cmd ? shell_cmd : "";
|
||||
|
||||
if (!recurse || use_qsort)
|
||||
allow_inc_recurse = 0;
|
||||
else if (!am_sender
|
||||
@@ -110,7 +120,7 @@ void set_allow_inc_recurse(void)
|
||||
|| delay_updates || prune_empty_dirs))
|
||||
allow_inc_recurse = 0;
|
||||
else if (am_server && !local_server
|
||||
&& (!shell_cmd || strchr(shell_cmd, 'i') == NULL))
|
||||
&& (strchr(client_info, 'i') == NULL))
|
||||
allow_inc_recurse = 0;
|
||||
}
|
||||
|
||||
@@ -171,6 +181,8 @@ void setup_protocol(int f_out,int f_in)
|
||||
PROTOCOL_VERSION, am_server? "Server" : "Client");
|
||||
exit_cleanup(RERR_PROTOCOL);
|
||||
}
|
||||
if (read_batch)
|
||||
check_batch_flags();
|
||||
|
||||
if (protocol_version < 30) {
|
||||
if (append_mode == 1)
|
||||
@@ -231,12 +243,26 @@ void setup_protocol(int f_out,int f_in)
|
||||
exit_cleanup(RERR_PROTOCOL);
|
||||
}
|
||||
} else if (protocol_version >= 30) {
|
||||
/* The inc_recurse var MUST be set to 0 or 1. */
|
||||
int compat_flags;
|
||||
if (am_server) {
|
||||
inc_recurse = allow_inc_recurse ? 1 : 0;
|
||||
write_byte(f_out, inc_recurse);
|
||||
compat_flags = allow_inc_recurse ? CF_INC_RECURSE : 0;
|
||||
#if defined HAVE_LUTIMES && defined HAVE_UTIMES
|
||||
compat_flags |= CF_SYMLINK_TIMES;
|
||||
#endif
|
||||
write_byte(f_out, compat_flags);
|
||||
} else
|
||||
inc_recurse = read_byte(f_in) ? 1 : 0;
|
||||
compat_flags = read_byte(f_in);
|
||||
/* The inc_recurse var MUST be set to 0 or 1. */
|
||||
inc_recurse = compat_flags & CF_INC_RECURSE ? 1 : 0;
|
||||
if (am_sender) {
|
||||
receiver_symlink_times = am_server
|
||||
? strchr(client_info, 'L') != NULL
|
||||
: !!(compat_flags & CF_SYMLINK_TIMES);
|
||||
}
|
||||
#if defined HAVE_LUTIMES && defined HAVE_UTIMES
|
||||
else
|
||||
receiver_symlink_times = 1;
|
||||
#endif
|
||||
if (inc_recurse && !allow_inc_recurse) {
|
||||
/* This should only be able to happen in a batch. */
|
||||
fprintf(stderr,
|
||||
@@ -245,6 +271,10 @@ void setup_protocol(int f_out,int f_in)
|
||||
exit_cleanup(RERR_SYNTAX);
|
||||
}
|
||||
need_messages_from_generator = 1;
|
||||
#if defined HAVE_LUTIMES && defined HAVE_UTIMES
|
||||
} else if (!am_sender) {
|
||||
receiver_symlink_times = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (need_unsorted_flist && (!am_sender || inc_recurse))
|
||||
|
||||
6
configure
vendored
6
configure
vendored
@@ -9,11 +9,11 @@ realconfigure="$dir/configure.sh"
|
||||
if test ! -f "$realconfigure"; then
|
||||
if test -f "$HOME/build_farm/build_test.fns"; then
|
||||
# Allow the build farm to grab latest files via rsync.
|
||||
fetch=fetch
|
||||
actions='build fetch'
|
||||
else
|
||||
fetch=''
|
||||
actions='build'
|
||||
fi
|
||||
if "$dir/prepare-source" $fetch; then
|
||||
if "$dir/prepare-source" $actions; then
|
||||
:
|
||||
else
|
||||
echo 'Failed to build configure.sh and/or config.h.in -- giving up.' >&2
|
||||
|
||||
46
configure.in
46
configure.in
@@ -5,7 +5,7 @@ AC_CONFIG_SRCDIR([byteorder.h])
|
||||
AC_CONFIG_HEADER(config.h)
|
||||
AC_PREREQ(2.59)
|
||||
|
||||
RSYNC_VERSION=3.0.0pre7
|
||||
RSYNC_VERSION=3.0.3pre2
|
||||
AC_SUBST(RSYNC_VERSION)
|
||||
AC_MSG_NOTICE([Configuring rsync $RSYNC_VERSION])
|
||||
|
||||
@@ -311,8 +311,10 @@ AC_HEADER_SYS_WAIT
|
||||
AC_CHECK_HEADERS(sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h \
|
||||
unistd.h utime.h grp.h compat.h sys/param.h ctype.h sys/wait.h \
|
||||
sys/ioctl.h sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h \
|
||||
sys/un.h sys/attr.h glob.h mcheck.h arpa/inet.h arpa/nameser.h locale.h \
|
||||
netdb.h malloc.h float.h limits.h iconv.h libcharset.h langinfo.h)
|
||||
sys/un.h sys/attr.h mcheck.h arpa/inet.h arpa/nameser.h locale.h \
|
||||
netdb.h malloc.h float.h limits.h iconv.h libcharset.h langinfo.h \
|
||||
sys/acl.h acl/libacl.h attr/xattr.h sys/xattr.h sys/extattr.h \
|
||||
popt.h popt/popt.h)
|
||||
AC_HEADER_MAJOR
|
||||
|
||||
AC_CACHE_CHECK([if makedev takes 3 args],rsync_cv_MAKEDEV_TAKES_3_ARGS,[
|
||||
@@ -548,12 +550,17 @@ AC_FUNC_UTIME_NULL
|
||||
AC_FUNC_ALLOCA
|
||||
AC_CHECK_FUNCS(waitpid wait4 getcwd strdup chown chmod lchmod mknod mkfifo \
|
||||
fchmod fstat ftruncate strchr readlink link utime utimes lutimes strftime \
|
||||
memmove lchown vsnprintf snprintf vasprintf asprintf setsid glob strpbrk \
|
||||
memmove lchown vsnprintf snprintf vasprintf asprintf setsid strpbrk \
|
||||
strlcat strlcpy strtol mallinfo getgroups setgroups geteuid getegid \
|
||||
setlocale setmode open64 lseek64 mkstemp64 mtrace va_copy __va_copy \
|
||||
strerror putenv iconv_open locale_charset nl_langinfo getxattr \
|
||||
extattr_get_link sigaction sigprocmask setattrlist)
|
||||
|
||||
dnl cygwin iconv.h defines iconv_open as libiconv_open
|
||||
if test x"$ac_cv_func_iconv_open" != x"yes"; then
|
||||
AC_CHECK_FUNC(libiconv_open, [ac_cv_func_iconv_open=yes; AC_DEFINE(HAVE_ICONV_OPEN, 1)])
|
||||
fi
|
||||
|
||||
AC_CHECK_FUNCS(getpgrp tcgetpgrp)
|
||||
if test $ac_cv_func_getpgrp = yes; then
|
||||
AC_FUNC_GETPGRP
|
||||
@@ -649,6 +656,15 @@ fi
|
||||
if test x"$with_included_popt" != x"yes"; then
|
||||
AC_CHECK_LIB(popt, poptGetContext, , [with_included_popt=yes])
|
||||
fi
|
||||
if test x"$ac_cv_header_popt_popt_h" = x"yes"; then
|
||||
# If the system has /usr/include/popt/popt.h, we enable the
|
||||
# included popt because an attempt to "#include <popt/popt.h>"
|
||||
# would use our included header file anyway (due to -I.), and
|
||||
# might conflict with the system popt.
|
||||
with_included_popt=yes
|
||||
elif test x"$ac_cv_header_popt_h" != x"yes"; then
|
||||
with_included_popt=yes
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([whether to use included libpopt])
|
||||
if test x"$with_included_popt" = x"yes"; then
|
||||
@@ -820,7 +836,6 @@ AC_SUBST(CC_SHOBJ_FLAG)
|
||||
AC_SUBST(BUILD_POPT)
|
||||
AC_SUBST(MAKE_MAN)
|
||||
|
||||
AC_CHECK_HEADERS(sys/acl.h acl/libacl.h)
|
||||
AC_CHECK_FUNCS(_acl __acl _facl __facl)
|
||||
#################################################
|
||||
# check for ACL support
|
||||
@@ -902,10 +917,6 @@ samba_cv_HAVE_ACL_GET_PERM_NP=yes,samba_cv_HAVE_ACL_GET_PERM_NP=no)])
|
||||
esac
|
||||
fi
|
||||
|
||||
AC_CHECK_HEADERS(attr/xattr.h)
|
||||
AC_CHECK_HEADERS(sys/xattr.h)
|
||||
AC_CHECK_HEADERS(sys/extattr.h)
|
||||
|
||||
#################################################
|
||||
# check for extended attribute support
|
||||
AC_MSG_CHECKING(whether to support extended attributes)
|
||||
@@ -947,6 +958,23 @@ else
|
||||
esac
|
||||
fi
|
||||
|
||||
if test x"$enable_acl_support" = x"no" -o x"$enable_xattr_support" = x"no" -o x"$enable_iconv" = x"no"; then
|
||||
AC_MSG_CHECKING([whether $CC supports -Wno-unused-parameter])
|
||||
OLD_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS -Wno-unused-parameter"
|
||||
AC_COMPILE_IFELSE([ ], [rsync_warn_flag=yes], [rsync_warn_flag=no])
|
||||
AC_MSG_RESULT([$rsync_warn_flag])
|
||||
if test x"$rsync_warn_flag" = x"no"; then
|
||||
CFLAGS="$OLD_CFLAGS"
|
||||
fi
|
||||
fi
|
||||
|
||||
case "$CC" in
|
||||
' checker'*|checker*)
|
||||
AC_DEFINE(FORCE_FD_ZERO_MEMSET, 1, [Used to make "checker" understand that FD_ZERO() clears memory.])
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_CONFIG_FILES([Makefile lib/dummy zlib/dummy popt/dummy shconfig])
|
||||
AC_OUTPUT
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Error codes returned by rsync.
|
||||
*
|
||||
* Copyright (C) 1998-2000 Andrew Tridgell
|
||||
* Copyright (C) 2003-2007 Wayne Davison
|
||||
* Copyright (C) 2003-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
98
exclude.c
98
exclude.c
@@ -4,7 +4,7 @@
|
||||
* Copyright (C) 1996-2001 Andrew Tridgell <tridge@samba.org>
|
||||
* Copyright (C) 1996 Paul Mackerras
|
||||
* Copyright (C) 2002 Martin Pool
|
||||
* Copyright (C) 2003-2007 Wayne Davison
|
||||
* Copyright (C) 2003-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -43,7 +43,7 @@ extern unsigned int module_dirlen;
|
||||
|
||||
struct filter_list_struct filter_list = { 0, 0, "" };
|
||||
struct filter_list_struct cvs_filter_list = { 0, 0, " [global CVS]" };
|
||||
struct filter_list_struct server_filter_list = { 0, 0, " [daemon]" };
|
||||
struct filter_list_struct daemon_filter_list = { 0, 0, " [daemon]" };
|
||||
|
||||
/* Need room enough for ":MODS " prefix plus some room to grow. */
|
||||
#define MAX_RULE_PREFIX (16)
|
||||
@@ -52,6 +52,8 @@ struct filter_list_struct server_filter_list = { 0, 0, " [daemon]" };
|
||||
#define MODIFIERS_INCL_EXCL "/!Crsp"
|
||||
#define MODIFIERS_HIDE_PROTECT "/!p"
|
||||
|
||||
#define SLASH_WILD3_SUFFIX "/***"
|
||||
|
||||
/* The dirbuf is set by push_local_filters() to the current subdirectory
|
||||
* relative to curr_dir that is being processed. The path always has a
|
||||
* trailing slash appended, and the variable dirbuf_len contains the length
|
||||
@@ -119,7 +121,7 @@ static void add_rule(struct filter_list_struct *listp, const char *pat,
|
||||
{
|
||||
struct filter_struct *ret;
|
||||
const char *cp;
|
||||
unsigned int ex_len;
|
||||
unsigned int pre_len, suf_len, slash_cnt = 0;
|
||||
|
||||
if (verbose > 2) {
|
||||
rprintf(FINFO, "[%s] add_rule(%s%.*s%s)%s\n",
|
||||
@@ -145,22 +147,51 @@ static void add_rule(struct filter_list_struct *listp, const char *pat,
|
||||
if (!(ret = new0(struct filter_struct)))
|
||||
out_of_memory("add_rule");
|
||||
|
||||
if (pat_len > 1 && pat[pat_len-1] == '/') {
|
||||
pat_len--;
|
||||
mflags |= MATCHFLG_DIRECTORY;
|
||||
}
|
||||
|
||||
for (cp = pat; cp < pat + pat_len; cp++) {
|
||||
if (*cp == '/')
|
||||
slash_cnt++;
|
||||
}
|
||||
|
||||
if (!(mflags & (MATCHFLG_ABS_PATH | MATCHFLG_MERGE_FILE))
|
||||
&& ((xflags & (XFLG_ANCHORED2ABS|XFLG_ABS_IF_SLASH) && *pat == '/')
|
||||
|| (xflags & XFLG_ABS_IF_SLASH && strchr(pat, '/') != NULL))) {
|
||||
|| (xflags & XFLG_ABS_IF_SLASH && slash_cnt))) {
|
||||
mflags |= MATCHFLG_ABS_PATH;
|
||||
if (*pat == '/')
|
||||
ex_len = dirbuf_len - module_dirlen - 1;
|
||||
pre_len = dirbuf_len - module_dirlen - 1;
|
||||
else
|
||||
ex_len = 0;
|
||||
pre_len = 0;
|
||||
} else
|
||||
ex_len = 0;
|
||||
if (!(ret->pattern = new_array(char, ex_len + pat_len + 1)))
|
||||
pre_len = 0;
|
||||
|
||||
/* The daemon wants dir-exclude rules to get an appended "/" + "***". */
|
||||
if (xflags & XFLG_DIR2WILD3
|
||||
&& BITS_SETnUNSET(mflags, MATCHFLG_DIRECTORY, MATCHFLG_INCLUDE)) {
|
||||
mflags &= ~MATCHFLG_DIRECTORY;
|
||||
suf_len = sizeof SLASH_WILD3_SUFFIX - 1;
|
||||
} else
|
||||
suf_len = 0;
|
||||
|
||||
if (!(ret->pattern = new_array(char, pre_len + pat_len + suf_len + 1)))
|
||||
out_of_memory("add_rule");
|
||||
if (ex_len)
|
||||
memcpy(ret->pattern, dirbuf + module_dirlen, ex_len);
|
||||
strlcpy(ret->pattern + ex_len, pat, pat_len + 1);
|
||||
pat_len += ex_len;
|
||||
if (pre_len) {
|
||||
memcpy(ret->pattern, dirbuf + module_dirlen, pre_len);
|
||||
for (cp = ret->pattern; cp < ret->pattern + pre_len; cp++) {
|
||||
if (*cp == '/')
|
||||
slash_cnt++;
|
||||
}
|
||||
}
|
||||
strlcpy(ret->pattern + pre_len, pat, pat_len + 1);
|
||||
pat_len += pre_len;
|
||||
if (suf_len) {
|
||||
memcpy(ret->pattern + pat_len, SLASH_WILD3_SUFFIX, suf_len+1);
|
||||
pat_len += suf_len;
|
||||
slash_cnt++;
|
||||
}
|
||||
|
||||
if (strpbrk(ret->pattern, "*[?")) {
|
||||
mflags |= MATCHFLG_WILD;
|
||||
@@ -178,11 +209,6 @@ static void add_rule(struct filter_list_struct *listp, const char *pat,
|
||||
}
|
||||
}
|
||||
|
||||
if (pat_len > 1 && ret->pattern[pat_len-1] == '/') {
|
||||
ret->pattern[pat_len-1] = 0;
|
||||
mflags |= MATCHFLG_DIRECTORY;
|
||||
}
|
||||
|
||||
if (mflags & MATCHFLG_PERDIR_MERGE) {
|
||||
struct filter_list_struct *lp;
|
||||
unsigned int len;
|
||||
@@ -226,10 +252,8 @@ static void add_rule(struct filter_list_struct *listp, const char *pat,
|
||||
out_of_memory("add_rule");
|
||||
}
|
||||
mergelist_parents[mergelist_cnt++] = ret;
|
||||
} else {
|
||||
for (cp = ret->pattern; (cp = strchr(cp, '/')) != NULL; cp++)
|
||||
ret->u.slash_cnt++;
|
||||
}
|
||||
} else
|
||||
ret->u.slash_cnt = slash_cnt;
|
||||
|
||||
ret->match_flags = mflags;
|
||||
|
||||
@@ -295,7 +319,7 @@ static char *parse_merge_name(const char *merge_file, unsigned int *len_ptr,
|
||||
strlcpy(to, merge_file, *len_ptr + 1);
|
||||
merge_file = to;
|
||||
}
|
||||
if (!sanitize_path(fn, merge_file, r, dirbuf_depth)) {
|
||||
if (!sanitize_path(fn, merge_file, r, dirbuf_depth, SP_DEFAULT)) {
|
||||
rprintf(FERROR, "merge-file name overflows: %s\n",
|
||||
merge_file);
|
||||
return NULL;
|
||||
@@ -308,12 +332,13 @@ static char *parse_merge_name(const char *merge_file, unsigned int *len_ptr,
|
||||
|
||||
/* If the name isn't in buf yet, it's wasn't absolute. */
|
||||
if (fn != buf) {
|
||||
if (dirbuf_len + fn_len >= MAXPATHLEN) {
|
||||
int d_len = dirbuf_len - prefix_skip;
|
||||
if (d_len + fn_len >= MAXPATHLEN) {
|
||||
rprintf(FERROR, "merge-file name overflows: %s\n", fn);
|
||||
return NULL;
|
||||
}
|
||||
memcpy(buf, dirbuf + prefix_skip, dirbuf_len - prefix_skip);
|
||||
memcpy(buf + dirbuf_len - prefix_skip, fn, fn_len + 1);
|
||||
memcpy(buf, dirbuf + prefix_skip, d_len);
|
||||
memcpy(buf + d_len, fn, fn_len + 1);
|
||||
fn_len = clean_fname(buf, CFN_COLLAPSE_DOT_DOT_DIRS);
|
||||
}
|
||||
|
||||
@@ -517,13 +542,13 @@ void change_local_filter_dir(const char *dname, int dlen, int dir_depth)
|
||||
filt_array[cur_depth] = push_local_filters(dname, dlen);
|
||||
}
|
||||
|
||||
static int rule_matches(char *fname, struct filter_struct *ex, int name_is_dir)
|
||||
static int rule_matches(const char *fname, struct filter_struct *ex, int name_is_dir)
|
||||
{
|
||||
int slash_handling, str_cnt = 0, anchored_match = 0;
|
||||
int ret_match = ex->match_flags & MATCHFLG_NEGATE ? 0 : 1;
|
||||
char *p, *pattern = ex->pattern;
|
||||
const char *strings[16]; /* more than enough */
|
||||
char *name = fname + (*fname == '/');
|
||||
const char *name = fname + (*fname == '/');
|
||||
|
||||
if (!*name)
|
||||
return 0;
|
||||
@@ -596,7 +621,7 @@ static int rule_matches(char *fname, struct filter_struct *ex, int name_is_dir)
|
||||
}
|
||||
|
||||
|
||||
static void report_filter_result(char const *name,
|
||||
static void report_filter_result(enum logcode code, char const *name,
|
||||
struct filter_struct const *ent,
|
||||
int name_is_dir, const char *type)
|
||||
{
|
||||
@@ -608,7 +633,7 @@ static void report_filter_result(char const *name,
|
||||
static char *actions[2][2]
|
||||
= { {"show", "hid"}, {"risk", "protect"} };
|
||||
const char *w = who_am_i();
|
||||
rprintf(FINFO, "[%s] %sing %s %s because of pattern %s%s%s\n",
|
||||
rprintf(code, "[%s] %sing %s %s because of pattern %s%s%s\n",
|
||||
w, actions[*w!='s'][!(ent->match_flags&MATCHFLG_INCLUDE)],
|
||||
name_is_dir ? "directory" : "file", name, ent->pattern,
|
||||
ent->match_flags & MATCHFLG_DIRECTORY ? "/" : "", type);
|
||||
@@ -620,7 +645,8 @@ static void report_filter_result(char const *name,
|
||||
* Return -1 if file "name" is defined to be excluded by the specified
|
||||
* exclude list, 1 if it is included, and 0 if it was not matched.
|
||||
*/
|
||||
int check_filter(struct filter_list_struct *listp, char *name, int name_is_dir)
|
||||
int check_filter(struct filter_list_struct *listp, enum logcode code,
|
||||
const char *name, int name_is_dir)
|
||||
{
|
||||
struct filter_struct *ent;
|
||||
|
||||
@@ -628,22 +654,22 @@ int check_filter(struct filter_list_struct *listp, char *name, int name_is_dir)
|
||||
if (ignore_perishable && ent->match_flags & MATCHFLG_PERISHABLE)
|
||||
continue;
|
||||
if (ent->match_flags & MATCHFLG_PERDIR_MERGE) {
|
||||
int rc = check_filter(ent->u.mergelist, name,
|
||||
int rc = check_filter(ent->u.mergelist, code, name,
|
||||
name_is_dir);
|
||||
if (rc)
|
||||
return rc;
|
||||
continue;
|
||||
}
|
||||
if (ent->match_flags & MATCHFLG_CVS_IGNORE) {
|
||||
int rc = check_filter(&cvs_filter_list, name,
|
||||
int rc = check_filter(&cvs_filter_list, code, name,
|
||||
name_is_dir);
|
||||
if (rc)
|
||||
return rc;
|
||||
continue;
|
||||
}
|
||||
if (rule_matches(name, ent, name_is_dir)) {
|
||||
report_filter_result(name, ent, name_is_dir,
|
||||
listp->debug_type);
|
||||
report_filter_result(code, name, ent, name_is_dir,
|
||||
listp->debug_type);
|
||||
return ent->match_flags & MATCHFLG_INCLUDE ? 1 : -1;
|
||||
}
|
||||
}
|
||||
@@ -1009,10 +1035,10 @@ void parse_filter_file(struct filter_list_struct *listp, const char *fname,
|
||||
return;
|
||||
|
||||
if (*fname != '-' || fname[1] || am_server) {
|
||||
if (server_filter_list.head) {
|
||||
if (daemon_filter_list.head) {
|
||||
strlcpy(line, fname, sizeof line);
|
||||
clean_fname(line, CFN_COLLAPSE_DOT_DOT_DIRS);
|
||||
if (check_filter(&server_filter_list, line, 0) < 0)
|
||||
if (check_filter(&daemon_filter_list, FLOG, line, 0) < 0)
|
||||
fp = NULL;
|
||||
else
|
||||
fp = fopen(line, "rb");
|
||||
|
||||
2
fileio.c
2
fileio.c
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (C) 1998 Andrew Tridgell
|
||||
* Copyright (C) 2002 Martin Pool
|
||||
* Copyright (C) 2004-2007 Wayne Davison
|
||||
* Copyright (C) 2004-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
496
flist.c
496
flist.c
@@ -4,7 +4,7 @@
|
||||
* Copyright (C) 1996 Andrew Tridgell
|
||||
* Copyright (C) 1996 Paul Mackerras
|
||||
* Copyright (C) 2001, 2002 Martin Pool <mbp@samba.org>
|
||||
* Copyright (C) 2002-2007 Wayne Davison
|
||||
* Copyright (C) 2002-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -44,6 +44,8 @@ extern int filesfrom_fd;
|
||||
extern int one_file_system;
|
||||
extern int copy_dirlinks;
|
||||
extern int keep_dirlinks;
|
||||
extern int preserve_uid;
|
||||
extern int preserve_gid;
|
||||
extern int preserve_acls;
|
||||
extern int preserve_xattrs;
|
||||
extern int preserve_links;
|
||||
@@ -74,7 +76,7 @@ extern char curr_dir[MAXPATHLEN];
|
||||
extern struct chmod_mode_struct *chmod_modes;
|
||||
|
||||
extern struct filter_list_struct filter_list;
|
||||
extern struct filter_list_struct server_filter_list;
|
||||
extern struct filter_list_struct daemon_filter_list;
|
||||
|
||||
#ifdef ICONV_OPTION
|
||||
extern int filesfrom_convert;
|
||||
@@ -95,7 +97,7 @@ int flist_eof = 0; /* all the file-lists are now known */
|
||||
|
||||
#define NORMAL_NAME 0
|
||||
#define SLASH_ENDING_NAME 1
|
||||
#define DOT_NAME 2
|
||||
#define DOTDIR_NAME 2
|
||||
|
||||
/* 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.
|
||||
@@ -230,33 +232,57 @@ int link_stat(const char *path, STRUCT_STAT *stp, int follow_dirlinks)
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int is_daemon_excluded(const char *fname, int is_dir)
|
||||
{
|
||||
if (daemon_filter_list.head
|
||||
&& check_filter(&daemon_filter_list, FLOG, fname, is_dir) < 0) {
|
||||
errno = ENOENT;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int path_is_daemon_excluded(char *path, int ignore_filename)
|
||||
{
|
||||
if (daemon_filter_list.head) {
|
||||
char *slash = path;
|
||||
|
||||
while ((slash = strchr(slash+1, '/')) != NULL) {
|
||||
int ret;
|
||||
*slash = '\0';
|
||||
ret = check_filter(&daemon_filter_list, FLOG, path, 1);
|
||||
*slash = '/';
|
||||
if (ret < 0) {
|
||||
errno = ENOENT;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ignore_filename
|
||||
&& check_filter(&daemon_filter_list, FLOG, path, 1) < 0) {
|
||||
errno = ENOENT;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* This function is used to check if a file should be included/excluded
|
||||
* from the list of files based on its name and type etc. The value of
|
||||
* filter_level is set to either SERVER_FILTERS or ALL_FILTERS. */
|
||||
static int is_excluded(char *fname, int is_dir, int filter_level)
|
||||
static int is_excluded(const char *fname, int is_dir, int filter_level)
|
||||
{
|
||||
#if 0 /* This currently never happens, so avoid a useless compare. */
|
||||
if (filter_level == NO_FILTERS)
|
||||
return 0;
|
||||
#endif
|
||||
if (fname) {
|
||||
/* never exclude '.', even if somebody does --exclude '*' */
|
||||
if (fname[0] == '.' && !fname[1])
|
||||
return 0;
|
||||
/* Handle the -R version of the '.' dir. */
|
||||
if (fname[0] == '/') {
|
||||
int len = strlen(fname);
|
||||
if (fname[len-1] == '.' && fname[len-2] == '/')
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (server_filter_list.head
|
||||
&& check_filter(&server_filter_list, fname, is_dir) < 0)
|
||||
if (is_daemon_excluded(fname, is_dir))
|
||||
return 1;
|
||||
if (filter_level != ALL_FILTERS)
|
||||
return 0;
|
||||
if (filter_list.head
|
||||
&& check_filter(&filter_list, fname, is_dir) < 0)
|
||||
&& check_filter(&filter_list, FINFO, fname, is_dir) < 0)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
@@ -267,7 +293,6 @@ static void send_directory(int f, struct file_list *flist,
|
||||
static const char *pathname, *orig_dir;
|
||||
static int pathname_len;
|
||||
|
||||
|
||||
/* Make sure flist can hold at least flist->used + extra entries. */
|
||||
static void flist_expand(struct file_list *flist, int extra)
|
||||
{
|
||||
@@ -313,34 +338,55 @@ static void flist_done_allocating(struct file_list *flist)
|
||||
flist->pool_boundary = ptr;
|
||||
}
|
||||
|
||||
int push_pathname(const char *dir, int len)
|
||||
/* Call this with EITHER (1) "file, NULL, 0" to chdir() to the file's
|
||||
* F_PATHNAME(), or (2) "NULL, dir, dirlen" to chdir() to the supplied dir,
|
||||
* with dir == NULL taken to be the starting directory, and dirlen < 0
|
||||
* indicating that strdup(dir) should be called and then the -dirlen length
|
||||
* value checked to ensure that it is not daemon-excluded. */
|
||||
int change_pathname(struct file_struct *file, const char *dir, int dirlen)
|
||||
{
|
||||
if (dir == pathname)
|
||||
return 1;
|
||||
|
||||
if (!orig_dir)
|
||||
orig_dir = strdup(curr_dir);
|
||||
|
||||
if (pathname && !pop_dir(orig_dir)) {
|
||||
rsyserr(FERROR, errno, "pop_dir %s failed",
|
||||
full_fname(orig_dir));
|
||||
exit_cleanup(RERR_FILESELECT);
|
||||
}
|
||||
|
||||
if (dir && !push_dir(dir, 0)) {
|
||||
io_error |= IOERR_GENERAL;
|
||||
rsyserr(FERROR, errno, "push_dir %s failed in %s",
|
||||
full_fname(dir), curr_dir);
|
||||
return 0;
|
||||
if (dirlen < 0) {
|
||||
char *cpy = strdup(dir);
|
||||
if (*cpy != '/')
|
||||
change_dir(orig_dir, CD_SKIP_CHDIR);
|
||||
if (path_is_daemon_excluded(cpy, 0))
|
||||
goto chdir_error;
|
||||
dir = cpy;
|
||||
dirlen = -dirlen;
|
||||
} else {
|
||||
if (file) {
|
||||
if (pathname == F_PATHNAME(file))
|
||||
return 1;
|
||||
dir = F_PATHNAME(file);
|
||||
if (dir)
|
||||
dirlen = strlen(dir);
|
||||
} else if (pathname == dir)
|
||||
return 1;
|
||||
if (dir && *dir != '/')
|
||||
change_dir(orig_dir, CD_SKIP_CHDIR);
|
||||
}
|
||||
|
||||
pathname = dir;
|
||||
pathname_len = len >= 0 ? len : dir ? (int)strlen(dir) : 0;
|
||||
pathname_len = dirlen;
|
||||
|
||||
if (!dir)
|
||||
dir = orig_dir;
|
||||
|
||||
if (!change_dir(dir, CD_NORMAL)) {
|
||||
chdir_error:
|
||||
io_error |= IOERR_GENERAL;
|
||||
rsyserr(FERROR, errno, "change_dir %s failed", full_fname(dir));
|
||||
if (dir != orig_dir)
|
||||
change_dir(orig_dir, CD_NORMAL);
|
||||
pathname = NULL;
|
||||
pathname_len = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void send_file_entry(int f, struct file_struct *file, int ndx, int first_ndx)
|
||||
static void send_file_entry(int f, const char *fname, struct file_struct *file, int ndx, int first_ndx)
|
||||
{
|
||||
static time_t modtime;
|
||||
static mode_t mode;
|
||||
@@ -351,42 +397,12 @@ static void send_file_entry(int f, struct file_struct *file, int ndx, int first_
|
||||
static uint32 rdev_major;
|
||||
static uid_t uid;
|
||||
static gid_t gid;
|
||||
static char *user_name, *group_name;
|
||||
static const char *user_name, *group_name;
|
||||
static char lastname[MAXPATHLEN];
|
||||
char fname[MAXPATHLEN];
|
||||
int first_hlink_ndx = -1;
|
||||
int l1, l2;
|
||||
int xflags;
|
||||
|
||||
#ifdef ICONV_OPTION
|
||||
if (ic_send != (iconv_t)-1) {
|
||||
xbuf outbuf, inbuf;
|
||||
|
||||
INIT_CONST_XBUF(outbuf, fname);
|
||||
|
||||
if (file->dirname) {
|
||||
INIT_XBUF_STRLEN(inbuf, (char*)file->dirname);
|
||||
outbuf.size -= 2; /* Reserve room for '/' & 1 more char. */
|
||||
if (iconvbufs(ic_send, &inbuf, &outbuf, 0) < 0)
|
||||
goto convert_error;
|
||||
outbuf.size += 2;
|
||||
outbuf.buf[outbuf.len++] = '/';
|
||||
}
|
||||
|
||||
INIT_XBUF_STRLEN(inbuf, (char*)file->basename);
|
||||
if (iconvbufs(ic_send, &inbuf, &outbuf, 0) < 0) {
|
||||
convert_error:
|
||||
io_error |= IOERR_GENERAL;
|
||||
rprintf(FINFO,
|
||||
"[%s] cannot convert filename: %s (%s)\n",
|
||||
who_am_i(), f_name(file, fname), strerror(errno));
|
||||
return;
|
||||
}
|
||||
outbuf.buf[outbuf.len] = '\0';
|
||||
} else
|
||||
#endif
|
||||
f_name(file, fname);
|
||||
|
||||
/* Initialize starting value of xflags. */
|
||||
if (protocol_version >= 30 && S_ISDIR(file->mode)) {
|
||||
dir_count++;
|
||||
@@ -422,28 +438,24 @@ static void send_file_entry(int f, struct file_struct *file, int ndx, int first_
|
||||
}
|
||||
} else if (protocol_version < 28)
|
||||
rdev = MAKEDEV(0, 0);
|
||||
if (uid_ndx) {
|
||||
if ((uid_t)F_OWNER(file) == uid && *lastname)
|
||||
xflags |= XMIT_SAME_UID;
|
||||
else {
|
||||
uid = F_OWNER(file);
|
||||
if (uid_ndx && !numeric_ids) {
|
||||
user_name = add_uid(uid);
|
||||
if (inc_recurse && user_name)
|
||||
xflags |= XMIT_USER_NAME_FOLLOWS;
|
||||
}
|
||||
if (!preserve_uid || ((uid_t)F_OWNER(file) == uid && *lastname))
|
||||
xflags |= XMIT_SAME_UID;
|
||||
else {
|
||||
uid = F_OWNER(file);
|
||||
if (!numeric_ids) {
|
||||
user_name = add_uid(uid);
|
||||
if (inc_recurse && user_name)
|
||||
xflags |= XMIT_USER_NAME_FOLLOWS;
|
||||
}
|
||||
}
|
||||
if (gid_ndx) {
|
||||
if ((gid_t)F_GROUP(file) == gid && *lastname)
|
||||
xflags |= XMIT_SAME_GID;
|
||||
else {
|
||||
gid = F_GROUP(file);
|
||||
if (gid_ndx && !numeric_ids) {
|
||||
group_name = add_gid(gid);
|
||||
if (inc_recurse && group_name)
|
||||
xflags |= XMIT_GROUP_NAME_FOLLOWS;
|
||||
}
|
||||
if (!preserve_gid || ((gid_t)F_GROUP(file) == gid && *lastname))
|
||||
xflags |= XMIT_SAME_GID;
|
||||
else {
|
||||
gid = F_GROUP(file);
|
||||
if (!numeric_ids) {
|
||||
group_name = add_gid(gid);
|
||||
if (inc_recurse && group_name)
|
||||
xflags |= XMIT_GROUP_NAME_FOLLOWS;
|
||||
}
|
||||
}
|
||||
if (file->modtime == modtime)
|
||||
@@ -460,15 +472,14 @@ static void send_file_entry(int f, struct file_struct *file, int ndx, int first_
|
||||
np->data = (void*)(long)(first_ndx + ndx + 1);
|
||||
xflags |= XMIT_HLINK_FIRST;
|
||||
}
|
||||
xflags |= XMIT_HLINKED;
|
||||
} else {
|
||||
if (tmp_dev == dev) {
|
||||
if (protocol_version >= 28)
|
||||
xflags |= XMIT_SAME_DEV_pre30;
|
||||
} else
|
||||
dev = tmp_dev;
|
||||
xflags |= XMIT_HLINKED;
|
||||
}
|
||||
xflags |= XMIT_HLINKED;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -522,7 +533,7 @@ static void send_file_entry(int f, struct file_struct *file, int ndx, int first_
|
||||
}
|
||||
if (!(xflags & XMIT_SAME_MODE))
|
||||
write_int(f, to_wire_mode(mode));
|
||||
if (uid_ndx && !(xflags & XMIT_SAME_UID)) {
|
||||
if (preserve_uid && !(xflags & XMIT_SAME_UID)) {
|
||||
if (protocol_version < 30)
|
||||
write_int(f, uid);
|
||||
else {
|
||||
@@ -534,7 +545,7 @@ static void send_file_entry(int f, struct file_struct *file, int ndx, int first_
|
||||
}
|
||||
}
|
||||
}
|
||||
if (gid_ndx && !(xflags & XMIT_SAME_GID)) {
|
||||
if (preserve_gid && !(xflags & XMIT_SAME_GID)) {
|
||||
if (protocol_version < 30)
|
||||
write_int(f, gid);
|
||||
else {
|
||||
@@ -673,10 +684,11 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
|
||||
}
|
||||
#endif
|
||||
|
||||
clean_fname(thisname, 0);
|
||||
if (*thisname)
|
||||
clean_fname(thisname, 0);
|
||||
|
||||
if (sanitize_paths)
|
||||
sanitize_path(thisname, thisname, "", 0);
|
||||
sanitize_path(thisname, thisname, "", 0, SP_DEFAULT);
|
||||
|
||||
if ((basename = strrchr(thisname, '/')) != NULL) {
|
||||
int len = basename++ - thisname;
|
||||
@@ -706,9 +718,9 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
|
||||
file_length = F_LENGTH(first);
|
||||
modtime = first->modtime;
|
||||
mode = first->mode;
|
||||
if (uid_ndx)
|
||||
if (preserve_uid)
|
||||
uid = F_OWNER(first);
|
||||
if (gid_ndx)
|
||||
if (preserve_gid)
|
||||
gid = F_GROUP(first);
|
||||
if ((preserve_devices && IS_DEVICE(mode))
|
||||
|| (preserve_specials && IS_SPECIAL(mode))) {
|
||||
@@ -745,7 +757,7 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
|
||||
if (chmod_modes && !S_ISLNK(mode))
|
||||
mode = tweak_mode(mode, chmod_modes);
|
||||
|
||||
if (uid_ndx && !(xflags & XMIT_SAME_UID)) {
|
||||
if (preserve_uid && !(xflags & XMIT_SAME_UID)) {
|
||||
if (protocol_version < 30)
|
||||
uid = (uid_t)read_int(f);
|
||||
else {
|
||||
@@ -756,7 +768,7 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
|
||||
uid = match_uid(uid);
|
||||
}
|
||||
}
|
||||
if (gid_ndx && !(xflags & XMIT_SAME_GID)) {
|
||||
if (preserve_gid && !(xflags & XMIT_SAME_GID)) {
|
||||
if (protocol_version < 30)
|
||||
gid = (gid_t)read_int(f);
|
||||
else {
|
||||
@@ -817,9 +829,9 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
|
||||
#endif
|
||||
|
||||
#ifdef SUPPORT_ACLS
|
||||
/* We need one or two index int32s when we're preserving ACLs. */
|
||||
if (preserve_acls)
|
||||
extra_len += (S_ISDIR(mode) ? 2 : 1) * EXTRA_LEN;
|
||||
/* Directories need an extra int32 for the default ACL. */
|
||||
if (preserve_acls && S_ISDIR(mode))
|
||||
extra_len += EXTRA_LEN;
|
||||
#endif
|
||||
|
||||
if (always_checksum && S_ISREG(mode))
|
||||
@@ -852,7 +864,6 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
|
||||
bp += FILE_STRUCT_LEN;
|
||||
|
||||
memcpy(bp, basename, basename_len);
|
||||
bp += basename_len + linkname_len; /* skip space for symlink too */
|
||||
|
||||
#ifdef SUPPORT_HARD_LINKS
|
||||
if (xflags & XMIT_HLINKED)
|
||||
@@ -865,9 +876,9 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
|
||||
OPT_EXTRA(file, 0)->unum = (uint32)(file_length >> 32);
|
||||
}
|
||||
file->mode = mode;
|
||||
if (uid_ndx)
|
||||
if (preserve_uid)
|
||||
F_OWNER(file) = uid;
|
||||
if (gid_ndx) {
|
||||
if (preserve_gid) {
|
||||
F_GROUP(file) = gid;
|
||||
file->flags |= gid_flags;
|
||||
}
|
||||
@@ -917,7 +928,7 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
|
||||
|
||||
#ifdef SUPPORT_LINKS
|
||||
if (linkname_len) {
|
||||
bp = (char*)file->basename + basename_len;
|
||||
bp += basename_len;
|
||||
if (first_hlink_ndx >= flist->ndx_start) {
|
||||
struct file_struct *first = flist->files[first_hlink_ndx - flist->ndx_start];
|
||||
memcpy(bp, F_SYMLINK(first), linkname_len);
|
||||
@@ -929,7 +940,7 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
|
||||
} else {
|
||||
read_sbuf(f, bp, linkname_len - 1);
|
||||
if (sanitize_paths)
|
||||
sanitize_path(bp, bp, "", lastdir_depth);
|
||||
sanitize_path(bp, bp, "", lastdir_depth, SP_DEFAULT);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1012,6 +1023,7 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
|
||||
const char *basename;
|
||||
alloc_pool_t *pool;
|
||||
STRUCT_STAT st;
|
||||
int excl_ret;
|
||||
char *bp;
|
||||
|
||||
if (strlcpy(thisname, fname, sizeof thisname) >= sizeof thisname) {
|
||||
@@ -1020,7 +1032,7 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
|
||||
}
|
||||
clean_fname(thisname, 0);
|
||||
if (sanitize_paths)
|
||||
sanitize_path(thisname, thisname, "", 0);
|
||||
sanitize_path(thisname, thisname, "", 0, SP_DEFAULT);
|
||||
|
||||
if (stp && S_ISDIR(stp->st_mode)) {
|
||||
st = *stp; /* Needed for "symlink/." with --relative. */
|
||||
@@ -1037,9 +1049,15 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
|
||||
}
|
||||
if (save_errno == ENOENT) {
|
||||
#ifdef SUPPORT_LINKS
|
||||
/* Avoid "vanished" error if symlink points nowhere. */
|
||||
if (copy_links && x_lstat(thisname, &st, NULL) == 0
|
||||
&& S_ISLNK(st.st_mode)) {
|
||||
/* When our options tell us to follow a symlink that
|
||||
* points nowhere, tell the user about the symlink
|
||||
* instead of giving a "vanished" message. We only
|
||||
* dereference a symlink if one of the --copy*links
|
||||
* options was specified, so there's no need for the
|
||||
* extra lstat() if one of these options isn't on. */
|
||||
if ((copy_links || copy_unsafe_links || copy_dirlinks)
|
||||
&& x_lstat(thisname, &st, NULL) == 0
|
||||
&& S_ISLNK(st.st_mode)) {
|
||||
io_error |= IOERR_GENERAL;
|
||||
rprintf(FERROR_XFER, "symlink has no referent: %s\n",
|
||||
full_fname(thisname));
|
||||
@@ -1088,7 +1106,17 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
|
||||
} else
|
||||
flags &= ~FLAG_CONTENT_DIR;
|
||||
|
||||
if (is_excluded(thisname, S_ISDIR(st.st_mode) != 0, filter_level)) {
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
if (flags & FLAG_DOTDIR_NAME) {
|
||||
/* A "." fname (or "/." fname in relative mode) is
|
||||
* never excluded. No other trailing-dotdir names
|
||||
* are possible. */
|
||||
excl_ret = 0;
|
||||
} else
|
||||
excl_ret = is_excluded(thisname, 1, filter_level);
|
||||
} else
|
||||
excl_ret = is_excluded(thisname, 0, filter_level);
|
||||
if (excl_ret) {
|
||||
if (ignore_perishable)
|
||||
non_perishable_cnt++;
|
||||
return NULL;
|
||||
@@ -1115,8 +1143,14 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
|
||||
pool = dir_flist->file_pool;
|
||||
} else
|
||||
pool = flist->file_pool;
|
||||
} else
|
||||
} else {
|
||||
#ifdef SUPPORT_ACLS
|
||||
/* Directories need an extra int32 for the default ACL. */
|
||||
if (preserve_acls && S_ISDIR(st.st_mode))
|
||||
extra_len += EXTRA_LEN;
|
||||
#endif
|
||||
pool = NULL;
|
||||
}
|
||||
|
||||
if (verbose > 2) {
|
||||
rprintf(FINFO, "[%s] make_file(%s,*,%d)\n",
|
||||
@@ -1164,7 +1198,6 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
|
||||
bp += FILE_STRUCT_LEN;
|
||||
|
||||
memcpy(bp, basename, basename_len);
|
||||
bp += basename_len + linkname_len; /* skip space for symlink too */
|
||||
|
||||
#ifdef SUPPORT_HARD_LINKS
|
||||
if (preserve_hard_links && flist && flist->prev) {
|
||||
@@ -1193,25 +1226,26 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
|
||||
OPT_EXTRA(file, 0)->unum = (uint32)(st.st_size >> 32);
|
||||
}
|
||||
file->mode = st.st_mode;
|
||||
if (uid_ndx)
|
||||
if (uid_ndx) /* Check uid_ndx instead of preserve_uid for del support */
|
||||
F_OWNER(file) = st.st_uid;
|
||||
if (gid_ndx)
|
||||
if (gid_ndx) /* Check gid_ndx instead of preserve_gid for del support */
|
||||
F_GROUP(file) = st.st_gid;
|
||||
|
||||
if (basename != thisname)
|
||||
file->dirname = lastdir;
|
||||
|
||||
#ifdef SUPPORT_LINKS
|
||||
if (linkname_len) {
|
||||
bp = (char*)file->basename + basename_len;
|
||||
memcpy(bp, linkname, linkname_len);
|
||||
}
|
||||
if (linkname_len)
|
||||
memcpy(bp + basename_len, linkname, linkname_len);
|
||||
#endif
|
||||
|
||||
if (always_checksum && am_sender && S_ISREG(st.st_mode))
|
||||
file_checksum(thisname, tmp_sum, st.st_size);
|
||||
|
||||
F_PATHNAME(file) = pathname;
|
||||
if (am_sender)
|
||||
F_PATHNAME(file) = pathname;
|
||||
else if (!pool)
|
||||
F_DEPTH(file) = extra_len / EXTRA_LEN;
|
||||
|
||||
/* This code is only used by the receiver when it is building
|
||||
* a list of files for a delete pass. */
|
||||
@@ -1247,22 +1281,14 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
|
||||
/* Only called for temporary file_struct entries created by make_file(). */
|
||||
void unmake_file(struct file_struct *file)
|
||||
{
|
||||
int extra_cnt = file_extra_cnt + LEN64_BUMP(file);
|
||||
#if EXTRA_ROUNDING > 0
|
||||
if (extra_cnt & EXTRA_ROUNDING)
|
||||
extra_cnt = (extra_cnt | EXTRA_ROUNDING) + 1;
|
||||
#endif
|
||||
free(REQ_EXTRA(file, extra_cnt));
|
||||
free(REQ_EXTRA(file, F_DEPTH(file)));
|
||||
}
|
||||
|
||||
static struct file_struct *send_file_name(int f, struct file_list *flist,
|
||||
char *fname, STRUCT_STAT *stp,
|
||||
const char *fname, STRUCT_STAT *stp,
|
||||
int flags, int filter_level)
|
||||
{
|
||||
struct file_struct *file;
|
||||
#if defined SUPPORT_ACLS || defined SUPPORT_XATTRS
|
||||
stat_x sx;
|
||||
#endif
|
||||
|
||||
file = make_file(fname, flist, stp, flags, filter_level);
|
||||
if (!file)
|
||||
@@ -1271,28 +1297,59 @@ static struct file_struct *send_file_name(int f, struct file_list *flist,
|
||||
if (chmod_modes && !S_ISLNK(file->mode))
|
||||
file->mode = tweak_mode(file->mode, chmod_modes);
|
||||
|
||||
if (f >= 0) {
|
||||
char fbuf[MAXPATHLEN];
|
||||
#if defined SUPPORT_ACLS || defined SUPPORT_XATTRS
|
||||
stat_x sx;
|
||||
#endif
|
||||
|
||||
#ifdef ICONV_OPTION
|
||||
if (ic_send != (iconv_t)-1) {
|
||||
xbuf outbuf, inbuf;
|
||||
|
||||
INIT_CONST_XBUF(outbuf, fbuf);
|
||||
|
||||
if (file->dirname) {
|
||||
INIT_XBUF_STRLEN(inbuf, (char*)file->dirname);
|
||||
outbuf.size -= 2; /* Reserve room for '/' & 1 more char. */
|
||||
if (iconvbufs(ic_send, &inbuf, &outbuf, 0) < 0)
|
||||
goto convert_error;
|
||||
outbuf.size += 2;
|
||||
outbuf.buf[outbuf.len++] = '/';
|
||||
}
|
||||
|
||||
INIT_XBUF_STRLEN(inbuf, (char*)file->basename);
|
||||
if (iconvbufs(ic_send, &inbuf, &outbuf, 0) < 0) {
|
||||
convert_error:
|
||||
io_error |= IOERR_GENERAL;
|
||||
rprintf(FINFO,
|
||||
"[%s] cannot convert filename: %s (%s)\n",
|
||||
who_am_i(), f_name(file, fbuf), strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
outbuf.buf[outbuf.len] = '\0';
|
||||
} else
|
||||
#endif
|
||||
f_name(file, fbuf);
|
||||
|
||||
#ifdef SUPPORT_ACLS
|
||||
if (preserve_acls && !S_ISLNK(file->mode) && f >= 0) {
|
||||
sx.st.st_mode = file->mode;
|
||||
sx.acc_acl = sx.def_acl = NULL;
|
||||
if (get_acl(fname, &sx) < 0)
|
||||
return NULL;
|
||||
}
|
||||
if (preserve_acls && !S_ISLNK(file->mode)) {
|
||||
sx.st.st_mode = file->mode;
|
||||
sx.acc_acl = sx.def_acl = NULL;
|
||||
if (get_acl(fname, &sx) < 0)
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
#ifdef SUPPORT_XATTRS
|
||||
if (preserve_xattrs && f >= 0) {
|
||||
sx.xattr = NULL;
|
||||
if (get_xattr(fname, &sx) < 0)
|
||||
return NULL;
|
||||
}
|
||||
if (preserve_xattrs) {
|
||||
sx.xattr = NULL;
|
||||
if (get_xattr(fname, &sx) < 0)
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
maybe_emit_filelist_progress(flist->used + flist_count_offset);
|
||||
send_file_entry(f, fbuf, file, flist->used, flist->ndx_start);
|
||||
|
||||
flist_expand(flist, 1);
|
||||
flist->files[flist->used++] = file;
|
||||
if (f >= 0) {
|
||||
send_file_entry(f, file, flist->used - 1, flist->ndx_start);
|
||||
#ifdef SUPPORT_ACLS
|
||||
if (preserve_acls && !S_ISLNK(file->mode)) {
|
||||
send_acl(&sx, f);
|
||||
@@ -1306,6 +1363,12 @@ static struct file_struct *send_file_name(int f, struct file_list *flist,
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
maybe_emit_filelist_progress(flist->used + flist_count_offset);
|
||||
|
||||
flist_expand(flist, 1);
|
||||
flist->files[flist->used++] = file;
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
@@ -1513,20 +1576,20 @@ static void send_directory(int f, struct file_list *flist, char *fbuf, int len,
|
||||
}
|
||||
}
|
||||
|
||||
static char lastpath[MAXPATHLEN] = "";
|
||||
static int lastpath_len = 0;
|
||||
static struct file_struct *lastpath_struct;
|
||||
|
||||
static void send_implied_dirs(int f, struct file_list *flist, char *fname,
|
||||
char *start, char *limit, int flags, char name_type)
|
||||
{
|
||||
static char lastpath[MAXPATHLEN] = "";
|
||||
static int lastpath_len = 0;
|
||||
static struct file_struct *lastpath_struct = NULL;
|
||||
struct file_struct *file;
|
||||
item_list *relname_list;
|
||||
relnamecache **rnpp;
|
||||
char *slash;
|
||||
int len, need_new_dir;
|
||||
int len, need_new_dir, depth = 0;
|
||||
struct filter_list_struct save_filter_list = filter_list;
|
||||
|
||||
flags = (flags | FLAG_IMPLIED_DIR) & ~(FLAG_TOP_DIR | FLAG_CONTENT_DIR);
|
||||
filter_list.head = filter_list.tail = NULL; /* Don't filter implied dirs. */
|
||||
|
||||
if (inc_recurse) {
|
||||
if (lastpath_struct && F_PATHNAME(lastpath_struct) == pathname
|
||||
@@ -1535,12 +1598,31 @@ static void send_implied_dirs(int f, struct file_list *flist, char *fname,
|
||||
need_new_dir = 0;
|
||||
else
|
||||
need_new_dir = 1;
|
||||
} else
|
||||
} else {
|
||||
char *tp = fname, *lp = lastpath;
|
||||
/* Skip any initial directories in our path that we
|
||||
* have in common with lastpath. */
|
||||
assert(start == fname);
|
||||
for ( ; ; tp++, lp++) {
|
||||
if (tp == limit) {
|
||||
if (*lp == '/' || *lp == '\0')
|
||||
goto done;
|
||||
break;
|
||||
}
|
||||
if (*lp != *tp)
|
||||
break;
|
||||
if (*tp == '/') {
|
||||
start = tp;
|
||||
depth++;
|
||||
}
|
||||
}
|
||||
need_new_dir = 1;
|
||||
}
|
||||
|
||||
if (need_new_dir) {
|
||||
int save_copy_links = copy_links;
|
||||
int save_xfer_dirs = xfer_dirs;
|
||||
char *slash;
|
||||
|
||||
copy_links = xfer_dirs = 1;
|
||||
|
||||
@@ -1548,7 +1630,10 @@ static void send_implied_dirs(int f, struct file_list *flist, char *fname,
|
||||
|
||||
for (slash = start; (slash = strchr(slash+1, '/')) != NULL; ) {
|
||||
*slash = '\0';
|
||||
send_file_name(f, flist, fname, NULL, flags, ALL_FILTERS);
|
||||
file = send_file_name(f, flist, fname, NULL, flags, ALL_FILTERS);
|
||||
depth++;
|
||||
if (!inc_recurse && file && S_ISDIR(file->mode))
|
||||
change_local_filter_dir(fname, strlen(fname), depth);
|
||||
*slash = '/';
|
||||
}
|
||||
|
||||
@@ -1557,7 +1642,8 @@ static void send_implied_dirs(int f, struct file_list *flist, char *fname,
|
||||
if (file && !S_ISDIR(file->mode))
|
||||
file = NULL;
|
||||
lastpath_struct = file;
|
||||
}
|
||||
} else if (file && S_ISDIR(file->mode))
|
||||
change_local_filter_dir(fname, strlen(fname), ++depth);
|
||||
|
||||
strlcpy(lastpath, fname, sizeof lastpath);
|
||||
lastpath_len = limit - fname;
|
||||
@@ -1568,11 +1654,11 @@ static void send_implied_dirs(int f, struct file_list *flist, char *fname,
|
||||
xfer_dirs = save_xfer_dirs;
|
||||
|
||||
if (!inc_recurse)
|
||||
return;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!lastpath_struct)
|
||||
return; /* dir must have vanished */
|
||||
goto done; /* dir must have vanished */
|
||||
|
||||
len = strlen(limit+1);
|
||||
memcpy(&relname_list, F_DIR_RELNAMES_P(lastpath_struct), sizeof relname_list);
|
||||
@@ -1586,6 +1672,9 @@ static void send_implied_dirs(int f, struct file_list *flist, char *fname,
|
||||
out_of_memory("send_implied_dirs");
|
||||
(*rnpp)->name_type = name_type;
|
||||
strlcpy((*rnpp)->fname, limit+1, len + 1);
|
||||
|
||||
done:
|
||||
filter_list = save_filter_list;
|
||||
}
|
||||
|
||||
static void send1extra(int f, struct file_struct *file, struct file_list *flist)
|
||||
@@ -1598,10 +1687,8 @@ static void send1extra(int f, struct file_struct *file, struct file_list *flist)
|
||||
f_name(file, fbuf);
|
||||
dlen = strlen(fbuf);
|
||||
|
||||
if (F_PATHNAME(file) != pathname) {
|
||||
if (!push_pathname(F_PATHNAME(file), -1))
|
||||
exit_cleanup(RERR_FILESELECT);
|
||||
}
|
||||
if (!change_pathname(file, NULL, 0))
|
||||
exit_cleanup(RERR_FILESELECT);
|
||||
|
||||
change_local_filter_dir(fbuf, dlen, send_dir_depth);
|
||||
|
||||
@@ -1766,13 +1853,14 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
|
||||
int64 start_write;
|
||||
int use_ff_fd = 0;
|
||||
int disable_buffering;
|
||||
int flags = recurse ? FLAG_CONTENT_DIR : 0;
|
||||
int arg_flags, flags = recurse ? FLAG_CONTENT_DIR : 0;
|
||||
int reading_remotely = filesfrom_host != NULL;
|
||||
int rl_flags = (reading_remotely ? 0 : RL_DUMP_COMMENTS)
|
||||
#ifdef ICONV_OPTION
|
||||
| (filesfrom_convert ? RL_CONVERT : 0)
|
||||
#endif
|
||||
| (eol_nulls || reading_remotely ? RL_EOL_NULLS : 0);
|
||||
int implied_dot_dir = 0;
|
||||
|
||||
rprintf(FLOG, "building file list\n");
|
||||
if (show_filelist_p())
|
||||
@@ -1783,6 +1871,9 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
|
||||
start_write = stats.total_written;
|
||||
gettimeofday(&start_tv, NULL);
|
||||
|
||||
if (!orig_dir)
|
||||
orig_dir = strdup(curr_dir);
|
||||
|
||||
if (relative_paths && protocol_version >= 30)
|
||||
implied_dirs = 1; /* We send flagged implied dirs */
|
||||
|
||||
@@ -1800,9 +1891,9 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
|
||||
|
||||
disable_buffering = io_start_buffering_out(f);
|
||||
if (filesfrom_fd >= 0) {
|
||||
if (argv[0] && !push_dir(argv[0], 0)) {
|
||||
rsyserr(FERROR_XFER, errno, "push_dir %s failed in %s",
|
||||
full_fname(argv[0]), curr_dir);
|
||||
if (argv[0] && !change_dir(argv[0], CD_NORMAL)) {
|
||||
rsyserr(FERROR_XFER, errno, "change_dir %s failed",
|
||||
full_fname(argv[0]));
|
||||
exit_cleanup(RERR_FILESELECT);
|
||||
}
|
||||
use_ff_fd = 1;
|
||||
@@ -1814,13 +1905,13 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
|
||||
if (use_ff_fd) {
|
||||
if (read_line(filesfrom_fd, fbuf, sizeof fbuf, rl_flags) == 0)
|
||||
break;
|
||||
sanitize_path(fbuf, fbuf, "", 0);
|
||||
sanitize_path(fbuf, fbuf, "", 0, SP_KEEP_DOT_DIRS);
|
||||
} else {
|
||||
if (argc-- == 0)
|
||||
break;
|
||||
strlcpy(fbuf, *argv++, MAXPATHLEN);
|
||||
if (sanitize_paths)
|
||||
sanitize_path(fbuf, fbuf, "", 0);
|
||||
sanitize_path(fbuf, fbuf, "", 0, SP_KEEP_DOT_DIRS);
|
||||
}
|
||||
|
||||
len = strlen(fbuf);
|
||||
@@ -1830,14 +1921,14 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
|
||||
} else if (!len || fbuf[len - 1] == '/') {
|
||||
if (len == 2 && fbuf[0] == '.') {
|
||||
/* Turn "./" into just "." rather than "./." */
|
||||
fbuf[1] = '\0';
|
||||
fbuf[--len] = '\0';
|
||||
} else {
|
||||
if (len + 1 >= MAXPATHLEN)
|
||||
overflow_exit("send_file_list");
|
||||
fbuf[len++] = '.';
|
||||
fbuf[len] = '\0';
|
||||
}
|
||||
name_type = DOT_NAME;
|
||||
name_type = DOTDIR_NAME;
|
||||
} else if (len > 1 && fbuf[len-1] == '.' && fbuf[len-2] == '.'
|
||||
&& (len == 2 || fbuf[len-3] == '/')) {
|
||||
if (len + 2 >= MAXPATHLEN)
|
||||
@@ -1845,9 +1936,9 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
|
||||
fbuf[len++] = '/';
|
||||
fbuf[len++] = '.';
|
||||
fbuf[len] = '\0';
|
||||
name_type = DOT_NAME;
|
||||
name_type = DOTDIR_NAME;
|
||||
} else if (fbuf[len-1] == '.' && (len == 1 || fbuf[len-2] == '/'))
|
||||
name_type = DOT_NAME;
|
||||
name_type = DOTDIR_NAME;
|
||||
else
|
||||
name_type = NORMAL_NAME;
|
||||
|
||||
@@ -1870,8 +1961,10 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
|
||||
*p = '\0';
|
||||
if (p == fbuf)
|
||||
dir = "/";
|
||||
else
|
||||
else {
|
||||
dir = fbuf;
|
||||
clean_fname(dir, 0);
|
||||
}
|
||||
fn = p + 3;
|
||||
while (*fn == '/')
|
||||
fn++;
|
||||
@@ -1879,20 +1972,27 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
|
||||
*--fn = '\0'; /* ensure room for '.' */
|
||||
} else
|
||||
fn = fbuf;
|
||||
len = clean_fname(fn, CFN_KEEP_LEADING_DOT_DIR
|
||||
| CFN_KEEP_TRAILING_SLASH
|
||||
/* A leading ./ can be used in relative mode to affect
|
||||
* the dest dir without its name being in the path. */
|
||||
if (*fn == '.' && fn[1] == '/' && !implied_dot_dir) {
|
||||
send_file_name(f, flist, ".", NULL,
|
||||
(flags | FLAG_IMPLIED_DIR) & ~FLAG_CONTENT_DIR,
|
||||
ALL_FILTERS);
|
||||
implied_dot_dir = 1;
|
||||
}
|
||||
len = clean_fname(fn, CFN_KEEP_TRAILING_SLASH
|
||||
| CFN_DROP_TRAILING_DOT_DIR);
|
||||
if (len == 1) {
|
||||
if (fn[0] == '/') {
|
||||
fn = "/.";
|
||||
len = 2;
|
||||
name_type = DOT_NAME;
|
||||
name_type = DOTDIR_NAME;
|
||||
} else if (fn[0] == '.')
|
||||
name_type = DOT_NAME;
|
||||
name_type = DOTDIR_NAME;
|
||||
} else if (fn[len-1] == '/') {
|
||||
fn[--len] = '\0';
|
||||
if (len == 1 && *fn == '.')
|
||||
name_type = DOT_NAME;
|
||||
name_type = DOTDIR_NAME;
|
||||
else
|
||||
name_type = SLASH_ENDING_NAME;
|
||||
}
|
||||
@@ -1911,22 +2011,24 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
|
||||
if (!*fn) {
|
||||
len = 1;
|
||||
fn = ".";
|
||||
name_type = DOT_NAME;
|
||||
name_type = DOTDIR_NAME;
|
||||
}
|
||||
|
||||
dirlen = dir ? strlen(dir) : 0;
|
||||
if (dirlen != lastdir_len || memcmp(lastdir, dir, dirlen) != 0) {
|
||||
if (!push_pathname(dir ? strdup(dir) : NULL, dirlen))
|
||||
if (!change_pathname(NULL, dir, -dirlen))
|
||||
continue;
|
||||
lastdir = pathname;
|
||||
lastdir_len = pathname_len;
|
||||
} else if (!push_pathname(lastdir, lastdir_len))
|
||||
} else if (!change_pathname(NULL, lastdir, lastdir_len))
|
||||
continue;
|
||||
|
||||
if (fn != fbuf)
|
||||
memmove(fbuf, fn, len + 1);
|
||||
|
||||
if (link_stat(fbuf, &st, copy_dirlinks || name_type != NORMAL_NAME) != 0) {
|
||||
if (link_stat(fbuf, &st, copy_dirlinks || name_type != NORMAL_NAME) != 0
|
||||
|| (name_type != DOTDIR_NAME && is_daemon_excluded(fbuf, S_ISDIR(st.st_mode)))
|
||||
|| (relative_paths && path_is_daemon_excluded(fbuf, 1))) {
|
||||
io_error |= IOERR_GENERAL;
|
||||
rsyserr(FERROR_XFER, errno, "link_stat %s failed",
|
||||
full_fname(fbuf));
|
||||
@@ -1952,39 +2054,33 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
|
||||
} else if (implied_dirs && (p=strrchr(fbuf,'/')) && p != fbuf) {
|
||||
/* Send the implied directories at the start of the
|
||||
* source spec, so we get their permissions right. */
|
||||
char *lp = lastpath, *slash = fbuf;
|
||||
*p = '\0';
|
||||
/* Skip any initial directories in our path that we
|
||||
* have in common with lastpath. */
|
||||
for (fn = fbuf; *fn && *lp == *fn; lp++, fn++) {
|
||||
if (*fn == '/')
|
||||
slash = fn;
|
||||
}
|
||||
*p = '/';
|
||||
if (fn != p || (*lp && *lp != '/'))
|
||||
send_implied_dirs(f, flist, fbuf, slash, p, flags, 0);
|
||||
send_implied_dirs(f, flist, fbuf, fbuf, p, flags, 0);
|
||||
}
|
||||
|
||||
if (one_file_system)
|
||||
filesystem_dev = st.st_dev;
|
||||
|
||||
arg_flags = name_type == DOTDIR_NAME ? FLAG_DOTDIR_NAME : 0;
|
||||
|
||||
if (recurse || (xfer_dirs && name_type != NORMAL_NAME)) {
|
||||
struct file_struct *file;
|
||||
int top_flags = FLAG_TOP_DIR | FLAG_CONTENT_DIR | flags;
|
||||
arg_flags |= FLAG_TOP_DIR | FLAG_CONTENT_DIR;
|
||||
file = send_file_name(f, flist, fbuf, &st,
|
||||
top_flags, ALL_FILTERS);
|
||||
arg_flags | flags, ALL_FILTERS);
|
||||
if (!file)
|
||||
continue;
|
||||
if (inc_recurse) {
|
||||
if (name_type == DOT_NAME && file) {
|
||||
if (name_type == DOTDIR_NAME) {
|
||||
if (send_dir_depth < 0) {
|
||||
send_dir_depth = 0;
|
||||
change_local_filter_dir(fbuf, len, send_dir_depth);
|
||||
}
|
||||
send_directory(f, flist, fbuf, len, flags);
|
||||
}
|
||||
} else if (file)
|
||||
} else
|
||||
send_if_directory(f, flist, file, fbuf, len, flags);
|
||||
} else
|
||||
send_file_name(f, flist, fbuf, &st, flags, ALL_FILTERS);
|
||||
send_file_name(f, flist, fbuf, &st, arg_flags | flags, ALL_FILTERS);
|
||||
}
|
||||
|
||||
gettimeofday(&end_tv, NULL);
|
||||
@@ -2026,7 +2122,7 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
|
||||
flist_sort_and_clean(flist, 0);
|
||||
file_total += flist->used;
|
||||
|
||||
if (!numeric_ids && !inc_recurse)
|
||||
if (numeric_ids <= 0 && !inc_recurse)
|
||||
send_id_list(f);
|
||||
|
||||
/* send the io_error flag */
|
||||
|
||||
559
generator.c
559
generator.c
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@
|
||||
* `id -G` on Linux, but it's too hard to find a portable equivalent.
|
||||
*
|
||||
* Copyright (C) 2002 Martin Pool
|
||||
* Copyright (C) 2003-2007 Wayne Davison
|
||||
* Copyright (C) 2003-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 3 as
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Routines to provide a memory-efficient hashtable.
|
||||
*
|
||||
* Copyright (C) 2007 Wayne Davison
|
||||
* Copyright (C) 2007-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -24,7 +24,7 @@
|
||||
struct hashtable *hashtable_create(int size, int key64)
|
||||
{
|
||||
struct hashtable *tbl;
|
||||
int node_size = key64 ? sizeof (struct ht_int64_node )
|
||||
int node_size = key64 ? sizeof (struct ht_int64_node)
|
||||
: sizeof (struct ht_int32_node);
|
||||
|
||||
/* Pick a power of 2 that can hold the requested size. */
|
||||
@@ -41,6 +41,7 @@ struct hashtable *hashtable_create(int size, int key64)
|
||||
tbl->size = size;
|
||||
tbl->entries = 0;
|
||||
tbl->node_size = node_size;
|
||||
tbl->key64 = key64;
|
||||
|
||||
return tbl;
|
||||
}
|
||||
@@ -55,7 +56,7 @@ void hashtable_destroy(struct hashtable *tbl)
|
||||
* already existing. Returns NULL if not allocating and not found. */
|
||||
void *hashtable_find(struct hashtable *tbl, int64 key, int allocate_if_missing)
|
||||
{
|
||||
int key64 = (tbl->node_size > sizeof (struct ht_int32_node));
|
||||
int key64 = tbl->key64;
|
||||
struct ht_int32_node *node;
|
||||
uint32 ndx;
|
||||
|
||||
|
||||
124
hlink.c
124
hlink.c
@@ -4,7 +4,7 @@
|
||||
* Copyright (C) 1996 Andrew Tridgell
|
||||
* Copyright (C) 1996 Paul Mackerras
|
||||
* Copyright (C) 2002 Martin Pool <mbp@samba.org>
|
||||
* Copyright (C) 2004-2007 Wayne Davison
|
||||
* Copyright (C) 2004-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -37,7 +37,7 @@ extern int stdout_format_has_i;
|
||||
extern int maybe_ATTRS_REPORT;
|
||||
extern int unsort_ndx;
|
||||
extern char *basis_dir[];
|
||||
extern struct file_list *cur_flist;
|
||||
extern struct file_list *cur_flist, *first_flist;
|
||||
|
||||
#ifdef SUPPORT_HARD_LINKS
|
||||
|
||||
@@ -125,12 +125,16 @@ static void match_gnums(int32 *ndx_list, int ndx_count)
|
||||
prev = -1;
|
||||
} else if (CVAL(node->data, 0) == 0) {
|
||||
struct file_list *flist;
|
||||
struct file_struct *fp;
|
||||
prev = IVAL(node->data, 1);
|
||||
flist = flist_for_ndx(prev);
|
||||
assert(flist != NULL);
|
||||
fp = flist->files[prev - flist->ndx_start];
|
||||
fp->flags &= ~FLAG_HLINK_LAST;
|
||||
if (flist)
|
||||
flist->files[prev - flist->ndx_start]->flags &= ~FLAG_HLINK_LAST;
|
||||
else {
|
||||
/* We skipped all prior files in this
|
||||
* group, so mark this as a "first". */
|
||||
file->flags |= FLAG_HLINK_FIRST;
|
||||
prev = -1;
|
||||
}
|
||||
} else
|
||||
prev = -1;
|
||||
} else {
|
||||
@@ -143,7 +147,7 @@ static void match_gnums(int32 *ndx_list, int ndx_count)
|
||||
if (gnum != gnum_next)
|
||||
break;
|
||||
F_HL_PREV(file) = prev;
|
||||
/* The linked list must use raw ndx values. */
|
||||
/* The linked list uses over-the-wire ndx values. */
|
||||
if (unsort_ndx)
|
||||
prev = F_NDX(file);
|
||||
else
|
||||
@@ -240,21 +244,43 @@ static int maybe_hard_link(struct file_struct *file, int ndx,
|
||||
}
|
||||
|
||||
/* Figure out if a prior entry is still there or if we just have a
|
||||
* cached name for it. Never called with a FLAG_HLINK_FIRST entry. */
|
||||
static char *check_prior(int prev_ndx, int gnum, struct file_list **flist_p)
|
||||
* cached name for it. */
|
||||
static char *check_prior(struct file_struct *file, int gnum,
|
||||
int *prev_ndx_p, struct file_list **flist_p)
|
||||
{
|
||||
struct file_list *flist = flist_for_ndx(prev_ndx);
|
||||
struct file_struct *fp;
|
||||
struct ht_int32_node *node;
|
||||
int prev_ndx = F_HL_PREV(file);
|
||||
|
||||
if (flist) {
|
||||
*flist_p = flist;
|
||||
return NULL;
|
||||
while (1) {
|
||||
struct file_list *flist;
|
||||
if (prev_ndx < 0
|
||||
|| (flist = flist_for_ndx(prev_ndx)) == NULL)
|
||||
break;
|
||||
fp = flist->files[prev_ndx - flist->ndx_start];
|
||||
if (!(fp->flags & FLAG_SKIP_HLINK)) {
|
||||
*prev_ndx_p = prev_ndx;
|
||||
*flist_p = flist;
|
||||
return NULL;
|
||||
}
|
||||
F_HL_PREV(file) = prev_ndx = F_HL_PREV(fp);
|
||||
}
|
||||
|
||||
node = hashtable_find(prior_hlinks, gnum, 0);
|
||||
assert(node != NULL && node->data);
|
||||
assert(CVAL(node->data, 0) != 0);
|
||||
return node->data;
|
||||
if (inc_recurse
|
||||
&& (node = hashtable_find(prior_hlinks, gnum, 0)) != NULL) {
|
||||
assert(node->data != NULL);
|
||||
if (CVAL(node->data, 0) != 0) {
|
||||
*prev_ndx_p = -1;
|
||||
*flist_p = NULL;
|
||||
return node->data;
|
||||
}
|
||||
/* The prior file must have been skipped. */
|
||||
F_HL_PREV(file) = -1;
|
||||
}
|
||||
|
||||
*prev_ndx_p = -1;
|
||||
*flist_p = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Only called if FLAG_HLINKED is set and FLAG_HLINK_FIRST is not. Returns:
|
||||
@@ -268,20 +294,28 @@ int hard_link_check(struct file_struct *file, int ndx, const char *fname,
|
||||
char *realname, *prev_name;
|
||||
struct file_list *flist;
|
||||
int gnum = inc_recurse ? F_HL_GNUM(file) : -1;
|
||||
int prev_ndx = F_HL_PREV(file);
|
||||
int prev_ndx;
|
||||
|
||||
prev_name = realname = check_prior(prev_ndx, gnum, &flist);
|
||||
prev_name = realname = check_prior(file, gnum, &prev_ndx, &flist);
|
||||
|
||||
if (!prev_name) {
|
||||
struct file_struct *prev_file = flist->files[prev_ndx - flist->ndx_start];
|
||||
struct file_struct *prev_file;
|
||||
|
||||
/* Is the previous link is not complete yet? */
|
||||
if (!flist) {
|
||||
/* The previous file was skipped, so this one is
|
||||
* treated as if it were the first in its group. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
prev_file = flist->files[prev_ndx - flist->ndx_start];
|
||||
|
||||
/* Is the previous link not complete yet? */
|
||||
if (!(prev_file->flags & FLAG_HLINK_DONE)) {
|
||||
/* Is the previous link being transferred? */
|
||||
if (prev_file->flags & FLAG_FILE_SENT) {
|
||||
/* Add ourselves to the list of files that will be
|
||||
* updated when the transfer completes, and mark
|
||||
* ourself as waiting for the transfer. */
|
||||
/* Add ourselves to the list of files that will
|
||||
* be updated when the transfer completes, and
|
||||
* mark ourself as waiting for the transfer. */
|
||||
F_HL_PREV(file) = F_HL_PREV(prev_file);
|
||||
F_HL_PREV(prev_file) = ndx;
|
||||
file->flags |= FLAG_FILE_SENT;
|
||||
@@ -294,8 +328,8 @@ int hard_link_check(struct file_struct *file, int ndx, const char *fname,
|
||||
/* There is a finished file to link with! */
|
||||
if (!(prev_file->flags & FLAG_HLINK_FIRST)) {
|
||||
/* The previous previous is FIRST when prev is not. */
|
||||
prev_ndx = F_HL_PREV(prev_file);
|
||||
prev_name = realname = check_prior(prev_ndx, gnum, &flist);
|
||||
prev_name = realname = check_prior(prev_file, gnum, &prev_ndx, &flist);
|
||||
assert(prev_name != NULL || flist != NULL);
|
||||
/* Update our previous pointer to point to the FIRST. */
|
||||
F_HL_PREV(file) = prev_ndx;
|
||||
}
|
||||
@@ -393,7 +427,7 @@ int hard_link_one(struct file_struct *file, const char *fname,
|
||||
enum logcode code;
|
||||
if (terse) {
|
||||
if (!verbose)
|
||||
return -1;
|
||||
return 0;
|
||||
code = FINFO;
|
||||
} else
|
||||
code = FERROR_XFER;
|
||||
@@ -413,7 +447,7 @@ void finish_hard_link(struct file_struct *file, const char *fname, int fin_ndx,
|
||||
{
|
||||
stat_x prev_sx;
|
||||
STRUCT_STAT st;
|
||||
char alt_name[MAXPATHLEN], *prev_name;
|
||||
char prev_name[MAXPATHLEN], alt_name[MAXPATHLEN];
|
||||
const char *our_name;
|
||||
struct file_list *flist;
|
||||
int prev_statret, ndx, prev_ndx = F_HL_PREV(file);
|
||||
@@ -444,13 +478,20 @@ void finish_hard_link(struct file_struct *file, const char *fname, int fin_ndx,
|
||||
while ((ndx = prev_ndx) >= 0) {
|
||||
int val;
|
||||
flist = flist_for_ndx(ndx);
|
||||
assert(flist != NULL);
|
||||
if (flist == NULL) {
|
||||
int start1 = first_flist ? first_flist->ndx_start : 0;
|
||||
int start2 = first_flist ? first_flist->prev->ndx_start : 0;
|
||||
int used = first_flist ? first_flist->prev->used : 0;
|
||||
rprintf(FERROR,
|
||||
"File index not found: %d (%d - %d)\n",
|
||||
ndx, start1 - 1, start2 + used - 1);
|
||||
exit_cleanup(RERR_PROTOCOL);
|
||||
}
|
||||
file = flist->files[ndx - flist->ndx_start];
|
||||
file->flags = (file->flags & ~FLAG_HLINK_FIRST) | FLAG_HLINK_DONE;
|
||||
prev_ndx = F_HL_PREV(file);
|
||||
F_HL_PREV(file) = fin_ndx;
|
||||
prev_name = f_name(file, NULL);
|
||||
prev_statret = link_stat(prev_name, &prev_sx.st, 0);
|
||||
prev_statret = link_stat(f_name(file, prev_name), &prev_sx.st, 0);
|
||||
val = maybe_hard_link(file, ndx, prev_name, prev_statret, &prev_sx,
|
||||
our_name, stp, fname, itemizing, code);
|
||||
flist->in_progress--;
|
||||
@@ -474,4 +515,25 @@ void finish_hard_link(struct file_struct *file, const char *fname, int fin_ndx,
|
||||
out_of_memory("finish_hard_link");
|
||||
}
|
||||
}
|
||||
|
||||
int skip_hard_link(struct file_struct *file, struct file_list **flist_p)
|
||||
{
|
||||
struct file_list *flist;
|
||||
int prev_ndx;
|
||||
|
||||
file->flags |= FLAG_SKIP_HLINK;
|
||||
if (!(file->flags & FLAG_HLINK_LAST))
|
||||
return -1;
|
||||
|
||||
check_prior(file, F_HL_GNUM(file), &prev_ndx, &flist);
|
||||
if (prev_ndx >= 0) {
|
||||
file = flist->files[prev_ndx - flist->ndx_start];
|
||||
if (file->flags & (FLAG_HLINK_DONE|FLAG_FILE_SENT))
|
||||
return -1;
|
||||
file->flags |= FLAG_HLINK_LAST;
|
||||
*flist_p = flist;
|
||||
}
|
||||
|
||||
return prev_ndx;
|
||||
}
|
||||
#endif
|
||||
|
||||
12
ifuncs.h
12
ifuncs.h
@@ -1,6 +1,6 @@
|
||||
/* Inline functions for rsync.
|
||||
*
|
||||
* Copyright (C) 2007 Wayne Davison
|
||||
* Copyright (C) 2007-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -57,6 +57,16 @@ from_wire_mode(int mode)
|
||||
return mode;
|
||||
}
|
||||
|
||||
static inline char *
|
||||
d_name(struct dirent *di)
|
||||
{
|
||||
#ifdef HAVE_BROKEN_READDIR
|
||||
return (di->d_name - 2);
|
||||
#else
|
||||
return di->d_name;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int
|
||||
isDigit(const char *ptr)
|
||||
{
|
||||
|
||||
57
io.c
57
io.c
@@ -4,7 +4,7 @@
|
||||
* Copyright (C) 1996-2001 Andrew Tridgell
|
||||
* Copyright (C) 1996 Paul Mackerras
|
||||
* Copyright (C) 2001, 2002 Martin Pool <mbp@samba.org>
|
||||
* Copyright (C) 2003-2007 Wayne Davison
|
||||
* Copyright (C) 2003-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -45,6 +45,7 @@ extern int inc_recurse;
|
||||
extern int io_error;
|
||||
extern int eol_nulls;
|
||||
extern int flist_eof;
|
||||
extern int list_only;
|
||||
extern int read_batch;
|
||||
extern int csum_length;
|
||||
extern int protect_args;
|
||||
@@ -104,6 +105,7 @@ static int defer_forwarding_messages = 0, defer_forwarding_keep = 0;
|
||||
static int select_timeout = SELECT_TIMEOUT;
|
||||
static int active_filecnt = 0;
|
||||
static OFF_T active_bytecnt = 0;
|
||||
static int first_message = 1;
|
||||
|
||||
static char int_byte_extra[64] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* (00 - 3F)/4 */
|
||||
@@ -112,6 +114,9 @@ static char int_byte_extra[64] = {
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 5, 6, /* (C0 - FF)/4 */
|
||||
};
|
||||
|
||||
#define REMOTE_OPTION_ERROR "rsync: on remote machine: -"
|
||||
#define REMOTE_OPTION_ERROR2 ": unknown option"
|
||||
|
||||
enum festatus { FES_SUCCESS, FES_REDO, FES_NO_SEND };
|
||||
|
||||
static void readfd(int fd, char *buffer, size_t N);
|
||||
@@ -321,6 +326,36 @@ static void msg_flush(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void check_for_d_option_error(const char *msg)
|
||||
{
|
||||
static char rsync263_opts[] = "BCDHIKLPRSTWabceghlnopqrtuvxz";
|
||||
char *colon;
|
||||
int saw_d = 0;
|
||||
|
||||
if (*msg != 'r'
|
||||
|| strncmp(msg, REMOTE_OPTION_ERROR, sizeof REMOTE_OPTION_ERROR - 1) != 0)
|
||||
return;
|
||||
|
||||
msg += sizeof REMOTE_OPTION_ERROR - 1;
|
||||
if (*msg == '-' || (colon = strchr(msg, ':')) == NULL
|
||||
|| strncmp(colon, REMOTE_OPTION_ERROR2, sizeof REMOTE_OPTION_ERROR2 - 1) != 0)
|
||||
return;
|
||||
|
||||
for ( ; *msg != ':'; msg++) {
|
||||
if (*msg == 'd')
|
||||
saw_d = 1;
|
||||
else if (*msg == 'e')
|
||||
break;
|
||||
else if (strchr(rsync263_opts, *msg) == NULL)
|
||||
return;
|
||||
}
|
||||
|
||||
if (saw_d) {
|
||||
rprintf(FWARNING,
|
||||
"*** Try using \"--old-d\" if remote rsync is <= 2.6.3 ***\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* Read a message from the MSG_* fd and handle it. This is called either
|
||||
* during the early stages of being a local sender (up through the sending
|
||||
* of the file list) or when we're the generator (to fetch the messages
|
||||
@@ -838,8 +873,8 @@ int read_line(int fd, char *buf, size_t bufsiz, int flags)
|
||||
return s - buf;
|
||||
}
|
||||
|
||||
int read_args(int f_in, char *mod_name, char *buf, size_t bufsiz, int rl_nulls,
|
||||
char ***argv_p, int *argc_p, char **request_p)
|
||||
void read_args(int f_in, char *mod_name, char *buf, size_t bufsiz, int rl_nulls,
|
||||
char ***argv_p, int *argc_p, char **request_p)
|
||||
{
|
||||
int maxargs = MAX_ARGS;
|
||||
int dot_pos = 0;
|
||||
@@ -853,14 +888,14 @@ int read_args(int f_in, char *mod_name, char *buf, size_t bufsiz, int rl_nulls,
|
||||
|
||||
if (!(argv = new_array(char *, maxargs)))
|
||||
out_of_memory("read_args");
|
||||
if (mod_name)
|
||||
if (mod_name && !protect_args)
|
||||
argv[argc++] = "rsyncd";
|
||||
|
||||
while (1) {
|
||||
if (read_line(f_in, buf, bufsiz, rl_flags) == 0)
|
||||
break;
|
||||
|
||||
if (argc == maxargs) {
|
||||
if (argc == maxargs-1) {
|
||||
maxargs += MAX_ARGS;
|
||||
if (!(argv = realloc_array(argv, char *, maxargs)))
|
||||
out_of_memory("read_args");
|
||||
@@ -883,11 +918,12 @@ int read_args(int f_in, char *mod_name, char *buf, size_t bufsiz, int rl_nulls,
|
||||
dot_pos = argc;
|
||||
}
|
||||
}
|
||||
argv[argc] = NULL;
|
||||
|
||||
glob_expand(NULL, NULL, NULL, NULL);
|
||||
|
||||
*argc_p = argc;
|
||||
*argv_p = argv;
|
||||
|
||||
return dot_pos ? dot_pos : argc;
|
||||
}
|
||||
|
||||
int io_start_buffering_out(int f_out)
|
||||
@@ -1119,6 +1155,13 @@ static int readfd_unbuffered(int fd, char *buf, size_t len)
|
||||
}
|
||||
read_loop(fd, line, msg_bytes);
|
||||
rwrite((enum logcode)tag, line, msg_bytes, 1);
|
||||
if (first_message) {
|
||||
if (list_only && !am_sender && tag == 1) {
|
||||
line[msg_bytes] = '\0';
|
||||
check_for_d_option_error(line);
|
||||
}
|
||||
first_message = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
rprintf(FERROR, "unexpected tag %d [%s]\n",
|
||||
|
||||
2
io.h
2
io.h
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2007 Wayne Davison
|
||||
* Copyright (C) 2007-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* An implementation of MD4 designed for use in the SMB authentication protocol.
|
||||
*
|
||||
* Copyright (C) 1997-1998 Andrew Tridgell
|
||||
* Copyright (C) 2005-2007 Wayne Davison
|
||||
* Copyright (C) 2005-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* Unix SMB/CIFS implementation.
|
||||
* Based on the Samba ACL support code.
|
||||
* Copyright (C) Jeremy Allison 2000.
|
||||
* Copyright (C) 2007-2008 Wayne Davison
|
||||
*
|
||||
* The permission functions have been changed to get/set all bits via
|
||||
* one call. Some functions that rsync doesn't need were also removed.
|
||||
@@ -2703,6 +2704,8 @@ int sys_acl_set_info(SMB_ACL_ENTRY_T entry, SMB_ACL_TAG_T tag_type, uint32 bits,
|
||||
rc = mbr_uid_to_uuid(u_g_id, uu);
|
||||
else
|
||||
rc = mbr_gid_to_uuid(u_g_id, uu);
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
|
||||
if (acl_set_tag_type(entry, tag_type) != 0
|
||||
|| acl_set_qualifier(entry, &uu) != 0
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* Version 2.2.x
|
||||
* Portable SMB ACL interface
|
||||
* Copyright (C) Jeremy Allison 2000
|
||||
* Copyright (C) 2007-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* Extended attribute support for rsync.
|
||||
*
|
||||
* Copyright (C) 2004 Red Hat, Inc.
|
||||
* Copyright (C) 2003-2008 Wayne Davison
|
||||
* Written by Jay Fenlason.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
||||
17
loadparm.c
17
loadparm.c
@@ -124,6 +124,7 @@ static global Globals;
|
||||
typedef struct
|
||||
{
|
||||
char *auth_users;
|
||||
char *charset;
|
||||
char *comment;
|
||||
char *dont_compress;
|
||||
char *exclude;
|
||||
@@ -158,6 +159,7 @@ typedef struct
|
||||
BOOL ignore_nonreadable;
|
||||
BOOL list;
|
||||
BOOL munge_symlinks;
|
||||
BOOL numeric_ids;
|
||||
BOOL read_only;
|
||||
BOOL strict_modes;
|
||||
BOOL transfer_logging;
|
||||
@@ -173,7 +175,8 @@ typedef struct
|
||||
static service sDefault =
|
||||
{
|
||||
/* auth_users; */ NULL,
|
||||
/* comment; */ NULL,
|
||||
/* charset; */ NULL,
|
||||
/* comment; */ NULL,
|
||||
/* dont_compress; */ DEFAULT_DONT_COMPRESS,
|
||||
/* exclude; */ NULL,
|
||||
/* exclude_from; */ NULL,
|
||||
@@ -207,6 +210,7 @@ static service sDefault =
|
||||
/* ignore_nonreadable; */ False,
|
||||
/* list; */ True,
|
||||
/* munge_symlinks; */ (BOOL)-1,
|
||||
/* numeric_ids; */ (BOOL)-1,
|
||||
/* read_only; */ True,
|
||||
/* strict_modes; */ True,
|
||||
/* transfer_logging; */ False,
|
||||
@@ -301,6 +305,7 @@ static struct parm_struct parm_table[] =
|
||||
{"socket options", P_STRING, P_GLOBAL,&Globals.socket_options, NULL,0},
|
||||
|
||||
{"auth users", P_STRING, P_LOCAL, &sDefault.auth_users, NULL,0},
|
||||
{"charset", P_STRING, P_LOCAL, &sDefault.charset, NULL,0},
|
||||
{"comment", P_STRING, P_LOCAL, &sDefault.comment, NULL,0},
|
||||
{"dont compress", P_STRING, P_LOCAL, &sDefault.dont_compress, NULL,0},
|
||||
{"exclude from", P_STRING, P_LOCAL, &sDefault.exclude_from, NULL,0},
|
||||
@@ -323,6 +328,7 @@ static struct parm_struct parm_table[] =
|
||||
{"max verbosity", P_INTEGER,P_LOCAL, &sDefault.max_verbosity, NULL,0},
|
||||
{"munge symlinks", P_BOOL, P_LOCAL, &sDefault.munge_symlinks, NULL,0},
|
||||
{"name", P_STRING, P_LOCAL, &sDefault.name, NULL,0},
|
||||
{"numeric ids", P_BOOL, P_LOCAL, &sDefault.numeric_ids, NULL,0},
|
||||
{"outgoing chmod", P_STRING, P_LOCAL, &sDefault.outgoing_chmod, NULL,0},
|
||||
{"path", P_PATH, P_LOCAL, &sDefault.path, NULL,0},
|
||||
#ifdef HAVE_PUTENV
|
||||
@@ -392,6 +398,7 @@ FN_GLOBAL_STRING(lp_socket_options, &Globals.socket_options)
|
||||
FN_GLOBAL_INTEGER(lp_rsync_port, &Globals.rsync_port)
|
||||
|
||||
FN_LOCAL_STRING(lp_auth_users, auth_users)
|
||||
FN_LOCAL_STRING(lp_charset, charset)
|
||||
FN_LOCAL_STRING(lp_comment, comment)
|
||||
FN_LOCAL_STRING(lp_dont_compress, dont_compress)
|
||||
FN_LOCAL_STRING(lp_exclude, exclude)
|
||||
@@ -413,12 +420,12 @@ FN_LOCAL_STRING(lp_postxfer_exec, postxfer_exec)
|
||||
FN_LOCAL_STRING(lp_prexfer_exec, prexfer_exec)
|
||||
FN_LOCAL_STRING(lp_refuse_options, refuse_options)
|
||||
FN_LOCAL_STRING(lp_secrets_file, secrets_file)
|
||||
FN_LOCAL_INTEGER(lp_syslog_facility, syslog_facility)
|
||||
FN_LOCAL_STRING(lp_temp_dir, temp_dir)
|
||||
FN_LOCAL_STRING(lp_uid, uid)
|
||||
|
||||
FN_LOCAL_INTEGER(lp_max_connections, max_connections)
|
||||
FN_LOCAL_INTEGER(lp_max_verbosity, max_verbosity)
|
||||
FN_LOCAL_INTEGER(lp_syslog_facility, syslog_facility)
|
||||
FN_LOCAL_INTEGER(lp_timeout, timeout)
|
||||
|
||||
FN_LOCAL_BOOL(lp_fake_super, fake_super)
|
||||
@@ -426,6 +433,7 @@ FN_LOCAL_BOOL(lp_ignore_errors, ignore_errors)
|
||||
FN_LOCAL_BOOL(lp_ignore_nonreadable, ignore_nonreadable)
|
||||
FN_LOCAL_BOOL(lp_list, list)
|
||||
FN_LOCAL_BOOL(lp_munge_symlinks, munge_symlinks)
|
||||
FN_LOCAL_BOOL(lp_numeric_ids, numeric_ids)
|
||||
FN_LOCAL_BOOL(lp_read_only, read_only)
|
||||
FN_LOCAL_BOOL(lp_strict_modes, strict_modes)
|
||||
FN_LOCAL_BOOL(lp_transfer_logging, transfer_logging)
|
||||
@@ -784,6 +792,11 @@ static BOOL do_section(char *sectionname)
|
||||
return(True);
|
||||
}
|
||||
|
||||
if (strchr(sectionname, '/') != NULL) {
|
||||
rprintf(FLOG, "Warning: invalid section name in configuration file: %s\n", sectionname);
|
||||
return False;
|
||||
}
|
||||
|
||||
/* if we have a current service, tidy it up before moving on */
|
||||
bRetval = True;
|
||||
|
||||
|
||||
32
log.c
32
log.c
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (C) 1998-2001 Andrew Tridgell <tridge@samba.org>
|
||||
* Copyright (C) 2000-2001 Martin Pool <mbp@samba.org>
|
||||
* Copyright (C) 2003-2007 Wayne Davison
|
||||
* Copyright (C) 2003-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -41,6 +41,7 @@ extern int stdout_format_has_i;
|
||||
extern int stdout_format_has_o_or_i;
|
||||
extern int logfile_format_has_i;
|
||||
extern int logfile_format_has_o_or_i;
|
||||
extern int receiver_symlink_times;
|
||||
extern mode_t orig_umask;
|
||||
extern char *auth_user;
|
||||
extern char *stdout_format;
|
||||
@@ -307,7 +308,7 @@ void rwrite(enum logcode code, const char *buf, int len, int is_utf8)
|
||||
switch (code) {
|
||||
case FERROR_XFER:
|
||||
got_xfer_error = 1;
|
||||
/* CONTINUE */
|
||||
/* FALL THROUGH */
|
||||
case FERROR:
|
||||
case FWARNING:
|
||||
f = stderr;
|
||||
@@ -516,7 +517,7 @@ static void log_formatted(enum logcode code, const char *format, const char *op,
|
||||
break;
|
||||
case 'M':
|
||||
n = c = timestring(file->modtime);
|
||||
while ((c = strchr(p, ' ')) != NULL)
|
||||
while ((c = strchr(c, ' ')) != NULL)
|
||||
*c = '-';
|
||||
break;
|
||||
case 'B':
|
||||
@@ -623,7 +624,7 @@ static void log_formatted(enum logcode code, const char *format, const char *op,
|
||||
break;
|
||||
case 'i':
|
||||
if (iflags & ITEM_DELETED) {
|
||||
n = "*deleting";
|
||||
n = "*deleting ";
|
||||
break;
|
||||
}
|
||||
n = c = buf2 + MAXPATHLEN - 32;
|
||||
@@ -631,14 +632,21 @@ static void log_formatted(enum logcode code, const char *format, const char *op,
|
||||
? iflags & ITEM_XNAME_FOLLOWS ? 'h' : 'c'
|
||||
: !(iflags & ITEM_TRANSFER) ? '.'
|
||||
: !local_server && *op == 's' ? '<' : '>';
|
||||
c[1] = S_ISDIR(file->mode) ? 'd'
|
||||
: IS_SPECIAL(file->mode) ? 'S'
|
||||
: IS_DEVICE(file->mode) ? 'D'
|
||||
: S_ISLNK(file->mode) ? 'L' : 'f';
|
||||
c[2] = !(iflags & ITEM_REPORT_CHECKSUM) ? '.' : 'c';
|
||||
c[3] = !(iflags & ITEM_REPORT_SIZE) ? '.' : 's';
|
||||
c[4] = !(iflags & ITEM_REPORT_TIME) ? '.'
|
||||
: !preserve_times || S_ISLNK(file->mode) ? 'T' : 't';
|
||||
if (S_ISLNK(file->mode)) {
|
||||
c[1] = 'L';
|
||||
c[3] = '.';
|
||||
c[4] = !(iflags & ITEM_REPORT_TIME) ? '.'
|
||||
: !preserve_times || !receiver_symlink_times
|
||||
|| (iflags & ITEM_REPORT_TIMEFAIL) ? 'T' : 't';
|
||||
} else {
|
||||
c[1] = S_ISDIR(file->mode) ? 'd'
|
||||
: IS_SPECIAL(file->mode) ? 'S'
|
||||
: IS_DEVICE(file->mode) ? 'D' : 'f';
|
||||
c[3] = !(iflags & ITEM_REPORT_SIZE) ? '.' : 's';
|
||||
c[4] = !(iflags & ITEM_REPORT_TIME) ? '.'
|
||||
: !preserve_times ? 'T' : 't';
|
||||
}
|
||||
c[2] = !(iflags & ITEM_REPORT_CHANGE) ? '.' : 'c';
|
||||
c[5] = !(iflags & ITEM_REPORT_PERMS) ? '.' : 'p';
|
||||
c[6] = !(iflags & ITEM_REPORT_OWNER) ? '.' : 'o';
|
||||
c[7] = !(iflags & ITEM_REPORT_GROUP) ? '.' : 'g';
|
||||
|
||||
136
main.c
136
main.c
@@ -4,7 +4,7 @@
|
||||
* Copyright (C) 1996-2001 Andrew Tridgell <tridge@samba.org>
|
||||
* Copyright (C) 1996 Paul Mackerras
|
||||
* Copyright (C) 2001, 2002 Martin Pool <mbp@samba.org>
|
||||
* Copyright (C) 2003-2007 Wayne Davison
|
||||
* Copyright (C) 2003-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -45,6 +45,7 @@ extern int got_xfer_error;
|
||||
extern int module_id;
|
||||
extern int copy_links;
|
||||
extern int copy_dirlinks;
|
||||
extern int copy_unsafe_links;
|
||||
extern int keep_dirlinks;
|
||||
extern int preserve_hard_links;
|
||||
extern int protocol_version;
|
||||
@@ -77,11 +78,9 @@ extern char *batch_name;
|
||||
extern char *password_file;
|
||||
extern char curr_dir[MAXPATHLEN];
|
||||
extern struct file_list *first_flist;
|
||||
extern struct filter_list_struct server_filter_list;
|
||||
#ifdef ICONV_OPTION
|
||||
extern iconv_t ic_send;
|
||||
#endif
|
||||
extern struct filter_list_struct daemon_filter_list;
|
||||
|
||||
uid_t our_uid;
|
||||
int local_server = 0;
|
||||
int daemon_over_rsh = 0;
|
||||
mode_t orig_umask = 0;
|
||||
@@ -278,7 +277,7 @@ static void output_summary(void)
|
||||
rprintf(FINFO, "total size is %s speedup is %.2f%s\n",
|
||||
human_num(stats.total_size),
|
||||
(double)stats.total_size / (total_written+total_read),
|
||||
dry_run ? " (DRY RUN)" : "");
|
||||
write_batch < 0 ? " (BATCH ONLY)" : dry_run ? " (DRY RUN)" : "");
|
||||
}
|
||||
|
||||
fflush(stdout);
|
||||
@@ -332,7 +331,7 @@ static pid_t do_cmd(char *cmd, char *machine, char *user, char **remote_argv, in
|
||||
{
|
||||
int i, argc = 0;
|
||||
char *args[MAX_ARGS];
|
||||
pid_t ret;
|
||||
pid_t pid;
|
||||
int dash_l_set = 0;
|
||||
|
||||
if (!read_batch && !local_server) {
|
||||
@@ -342,7 +341,7 @@ static pid_t do_cmd(char *cmd, char *machine, char *user, char **remote_argv, in
|
||||
cmd = rsh_env;
|
||||
if (!cmd)
|
||||
cmd = RSYNC_RSH;
|
||||
cmd = strdup(cmd);
|
||||
cmd = strdup(cmd); /* MEMORY LEAK */
|
||||
if (!cmd)
|
||||
goto oom;
|
||||
|
||||
@@ -451,7 +450,7 @@ static pid_t do_cmd(char *cmd, char *machine, char *user, char **remote_argv, in
|
||||
batch_gen_fd = from_gen_pipe[0];
|
||||
*f_out_p = from_gen_pipe[1];
|
||||
*f_in_p = batch_fd;
|
||||
ret = -1; /* no child pid */
|
||||
pid = (pid_t)-1; /* no child pid */
|
||||
#ifdef ICONV_CONST
|
||||
setup_iconv();
|
||||
#endif
|
||||
@@ -461,54 +460,20 @@ static pid_t do_cmd(char *cmd, char *machine, char *user, char **remote_argv, in
|
||||
if (whole_file < 0 && !write_batch)
|
||||
whole_file = 1;
|
||||
set_allow_inc_recurse();
|
||||
ret = local_child(argc, args, f_in_p, f_out_p, child_main);
|
||||
pid = local_child(argc, args, f_in_p, f_out_p, child_main);
|
||||
#ifdef ICONV_CONST
|
||||
setup_iconv();
|
||||
#endif
|
||||
} else {
|
||||
pid = piped_child(args, f_in_p, f_out_p);
|
||||
#ifdef ICONV_CONST
|
||||
setup_iconv();
|
||||
#endif
|
||||
if (protect_args) {
|
||||
int fd;
|
||||
#ifdef ICONV_OPTION
|
||||
int convert = ic_send != (iconv_t)-1;
|
||||
xbuf outbuf, inbuf;
|
||||
|
||||
if (convert)
|
||||
alloc_xbuf(&outbuf, 1024);
|
||||
#endif
|
||||
|
||||
ret = piped_child(args, f_in_p, f_out_p);
|
||||
|
||||
for (i = 0; args[i]; i++) {} /* find first NULL */
|
||||
args[i] = "rsync"; /* set a new arg0 */
|
||||
if (verbose > 1)
|
||||
print_child_argv("protected args:", args + i + 1);
|
||||
fd = *f_out_p;
|
||||
do {
|
||||
#ifdef ICONV_OPTION
|
||||
if (convert) {
|
||||
INIT_XBUF_STRLEN(inbuf, args[i]);
|
||||
iconvbufs(ic_send, &inbuf, &outbuf,
|
||||
ICB_EXPAND_OUT | ICB_INCLUDE_BAD | ICB_INCLUDE_INCOMPLETE);
|
||||
outbuf.buf[outbuf.len] = '\0';
|
||||
write_buf(fd, outbuf.buf, outbuf.len + 1);
|
||||
outbuf.len = 0;
|
||||
} else
|
||||
#endif
|
||||
write_buf(fd, args[i], strlen(args[i]) + 1);
|
||||
} while (args[++i]);
|
||||
write_byte(fd, 0);
|
||||
#ifdef ICONV_OPTION
|
||||
if (convert)
|
||||
free(outbuf.buf);
|
||||
#endif
|
||||
} else
|
||||
ret = piped_child(args, f_in_p, f_out_p);
|
||||
if (protect_args)
|
||||
send_protected_args(*f_out_p, args);
|
||||
}
|
||||
|
||||
return ret;
|
||||
return pid;
|
||||
|
||||
oom:
|
||||
out_of_memory("do_cmd");
|
||||
@@ -542,12 +507,28 @@ static char *get_local_name(struct file_list *flist, char *dest_path)
|
||||
if (!dest_path || list_only)
|
||||
return NULL;
|
||||
|
||||
if (daemon_filter_list.head) {
|
||||
char *slash = strrchr(dest_path, '/');
|
||||
if (slash && slash[1] == '\0')
|
||||
*slash = '\0';
|
||||
else
|
||||
slash = NULL;
|
||||
if (check_filter(&daemon_filter_list, FLOG, dest_path, 0) < 0
|
||||
|| check_filter(&daemon_filter_list, FLOG, dest_path, 1) < 0) {
|
||||
rprintf(FERROR, "skipping daemon-excluded destination \"%s\"\n",
|
||||
dest_path);
|
||||
exit_cleanup(RERR_FILESELECT);
|
||||
}
|
||||
if (slash)
|
||||
*slash = '/';
|
||||
}
|
||||
|
||||
/* See what currently exists at the destination. */
|
||||
if ((statret = do_stat(dest_path, &st)) == 0) {
|
||||
/* If the destination is a dir, enter it and use mode 1. */
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
if (!push_dir(dest_path, 0)) {
|
||||
rsyserr(FERROR, errno, "push_dir#1 %s failed",
|
||||
if (!change_dir(dest_path, CD_NORMAL)) {
|
||||
rsyserr(FERROR, errno, "change_dir#1 %s failed",
|
||||
full_fname(dest_path));
|
||||
exit_cleanup(RERR_FILESELECT);
|
||||
}
|
||||
@@ -606,8 +587,8 @@ static char *get_local_name(struct file_list *flist, char *dest_path)
|
||||
dry_run++;
|
||||
}
|
||||
|
||||
if (!push_dir(dest_path, dry_run > 1)) {
|
||||
rsyserr(FERROR, errno, "push_dir#2 %s failed",
|
||||
if (!change_dir(dest_path, dry_run > 1 ? CD_SKIP_CHDIR : CD_NORMAL)) {
|
||||
rsyserr(FERROR, errno, "change_dir#2 %s failed",
|
||||
full_fname(dest_path));
|
||||
exit_cleanup(RERR_FILESELECT);
|
||||
}
|
||||
@@ -626,8 +607,8 @@ static char *get_local_name(struct file_list *flist, char *dest_path)
|
||||
dest_path = "/";
|
||||
|
||||
*cp = '\0';
|
||||
if (!push_dir(dest_path, 0)) {
|
||||
rsyserr(FERROR, errno, "push_dir#3 %s failed",
|
||||
if (!change_dir(dest_path, CD_NORMAL)) {
|
||||
rsyserr(FERROR, errno, "change_dir#3 %s failed",
|
||||
full_fname(dest_path));
|
||||
exit_cleanup(RERR_FILESELECT);
|
||||
}
|
||||
@@ -640,7 +621,7 @@ static char *get_local_name(struct file_list *flist, char *dest_path)
|
||||
* dry-run mode and the destination dir does not yet exist, we'll try to
|
||||
* tweak any dest-relative paths to make them work for a dry-run (the
|
||||
* destination dir must be in curr_dir[] when this function is called).
|
||||
* We also report if any arg that is non-existent or not a directory. */
|
||||
* We also warn about any arg that is non-existent or not a directory. */
|
||||
static void check_alt_basis_dirs(void)
|
||||
{
|
||||
STRUCT_STAT st;
|
||||
@@ -719,8 +700,8 @@ static void do_server_sender(int f_in, int f_out, int argc, char *argv[])
|
||||
}
|
||||
|
||||
if (!relative_paths) {
|
||||
if (!push_dir(dir, 0)) {
|
||||
rsyserr(FERROR, errno, "push_dir#3 %s failed",
|
||||
if (!change_dir(dir, CD_NORMAL)) {
|
||||
rsyserr(FERROR, errno, "change_dir#3 %s failed",
|
||||
full_fname(dir));
|
||||
exit_cleanup(RERR_FILESELECT);
|
||||
}
|
||||
@@ -758,7 +739,7 @@ static int do_recv(int f_in, int f_out, char *local_name)
|
||||
|
||||
/* The receiving side mustn't obey this, or an existing symlink that
|
||||
* points to an identical file won't be replaced by the referent. */
|
||||
copy_links = copy_dirlinks = 0;
|
||||
copy_links = copy_dirlinks = copy_unsafe_links = 0;
|
||||
|
||||
#ifdef SUPPORT_HARD_LINKS
|
||||
if (preserve_hard_links && !inc_recurse)
|
||||
@@ -889,8 +870,8 @@ static void do_server_recv(int f_in, int f_out, int argc, char *argv[])
|
||||
char *dir = argv[0];
|
||||
argc--;
|
||||
argv++;
|
||||
if (!am_daemon && !push_dir(dir, 0)) {
|
||||
rsyserr(FERROR, errno, "push_dir#4 %s failed",
|
||||
if (!am_daemon && !change_dir(dir, CD_NORMAL)) {
|
||||
rsyserr(FERROR, errno, "change_dir#4 %s failed",
|
||||
full_fname(dir));
|
||||
exit_cleanup(RERR_FILESELECT);
|
||||
}
|
||||
@@ -929,25 +910,25 @@ static void do_server_recv(int f_in, int f_out, int argc, char *argv[])
|
||||
if (sanitize_paths) {
|
||||
char **dir_p;
|
||||
for (dir_p = basis_dir; *dir_p; dir_p++)
|
||||
*dir_p = sanitize_path(NULL, *dir_p, NULL, curr_dir_depth);
|
||||
*dir_p = sanitize_path(NULL, *dir_p, NULL, curr_dir_depth, SP_DEFAULT);
|
||||
if (partial_dir)
|
||||
partial_dir = sanitize_path(NULL, partial_dir, NULL, curr_dir_depth);
|
||||
partial_dir = sanitize_path(NULL, partial_dir, NULL, curr_dir_depth, SP_DEFAULT);
|
||||
}
|
||||
check_alt_basis_dirs();
|
||||
|
||||
if (server_filter_list.head) {
|
||||
if (daemon_filter_list.head) {
|
||||
char **dir_p;
|
||||
struct filter_list_struct *elp = &server_filter_list;
|
||||
struct filter_list_struct *elp = &daemon_filter_list;
|
||||
|
||||
for (dir_p = basis_dir; *dir_p; dir_p++) {
|
||||
char *dir = *dir_p;
|
||||
if (*dir == '/')
|
||||
dir += module_dirlen;
|
||||
if (check_filter(elp, dir, 1) < 0)
|
||||
if (check_filter(elp, FLOG, dir, 1) < 0)
|
||||
goto options_rejected;
|
||||
}
|
||||
if (partial_dir && *partial_dir == '/'
|
||||
&& check_filter(elp, partial_dir + module_dirlen, 1) < 0) {
|
||||
&& check_filter(elp, FLOG, partial_dir + module_dirlen, 1) < 0) {
|
||||
options_rejected:
|
||||
rprintf(FERROR,
|
||||
"Your options have been rejected by the server.\n");
|
||||
@@ -1065,11 +1046,6 @@ int client_run(int f_in, int f_out, pid_t pid, int argc, char *argv[])
|
||||
io_start_multiplex_out();
|
||||
}
|
||||
|
||||
if (argc == 0) {
|
||||
list_only |= 1;
|
||||
xfer_dirs |= 1;
|
||||
}
|
||||
|
||||
send_filter_list(read_batch ? -1 : f_out);
|
||||
|
||||
if (filesfrom_fd >= 0) {
|
||||
@@ -1180,8 +1156,6 @@ static int start_client(int argc, char *argv[])
|
||||
static char *dotarg[1] = { "." };
|
||||
p = dotarg[0];
|
||||
remote_argv = dotarg;
|
||||
list_only |= 1;
|
||||
xfer_dirs |= 1;
|
||||
}
|
||||
remote_argc = 1;
|
||||
|
||||
@@ -1253,10 +1227,6 @@ static int start_client(int argc, char *argv[])
|
||||
}
|
||||
remote_argv[i] = arg;
|
||||
}
|
||||
if (argc == 0) {
|
||||
list_only |= 1;
|
||||
xfer_dirs |= 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (daemon_over_rsh < 0)
|
||||
@@ -1427,7 +1397,8 @@ int main(int argc,char *argv[])
|
||||
#endif
|
||||
|
||||
starttime = time(NULL);
|
||||
am_root = (MY_UID() == 0);
|
||||
our_uid = MY_UID();
|
||||
am_root = our_uid == 0;
|
||||
|
||||
memset(&stats, 0, sizeof(stats));
|
||||
|
||||
@@ -1444,7 +1415,7 @@ int main(int argc,char *argv[])
|
||||
setlocale(LC_CTYPE, "");
|
||||
#endif
|
||||
|
||||
if (!parse_arguments(&argc, (const char ***) &argv, 1)) {
|
||||
if (!parse_arguments(&argc, (const char ***) &argv)) {
|
||||
/* FIXME: We ought to call the same error-handling
|
||||
* code here, rather than relying on getopt. */
|
||||
option_error();
|
||||
@@ -1465,11 +1436,11 @@ int main(int argc,char *argv[])
|
||||
SIGACTION(SIGXFSZ, SIG_IGN);
|
||||
#endif
|
||||
|
||||
/* Initialize push_dir here because on some old systems getcwd
|
||||
/* Initialize change_dir() here because on some old systems getcwd
|
||||
* (implemented by forking "pwd" and reading its output) doesn't
|
||||
* work when there are other child processes. Also, on all systems
|
||||
* that implement getcwd that way "pwd" can't be found after chroot. */
|
||||
push_dir(NULL, 0);
|
||||
change_dir(NULL, CD_NORMAL);
|
||||
|
||||
init_flist();
|
||||
|
||||
@@ -1493,7 +1464,6 @@ int main(int argc,char *argv[])
|
||||
read_stream_flags(batch_fd);
|
||||
else
|
||||
write_stream_flags(batch_fd);
|
||||
|
||||
}
|
||||
if (write_batch < 0)
|
||||
dry_run = 1;
|
||||
@@ -1509,7 +1479,7 @@ int main(int argc,char *argv[])
|
||||
char buf[MAXPATHLEN];
|
||||
protect_args = 2;
|
||||
read_args(STDIN_FILENO, NULL, buf, sizeof buf, 1, &argv, &argc, NULL);
|
||||
if (!parse_arguments(&argc, (const char ***) &argv, 1)) {
|
||||
if (!parse_arguments(&argc, (const char ***) &argv)) {
|
||||
option_error();
|
||||
exit_cleanup(RERR_SYNTAX);
|
||||
}
|
||||
|
||||
2
match.c
2
match.c
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (C) 1996 Andrew Tridgell
|
||||
* Copyright (C) 1996 Paul Mackerras
|
||||
* Copyright (C) 2003-2007 Wayne Davison
|
||||
* Copyright (C) 2003-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
66
mkrounding.c
66
mkrounding.c
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* A pre-compilation helper program to aid in the creation of rounding.h.
|
||||
*
|
||||
* Copyright (C) 2007 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, visit the http://fsf.org website.
|
||||
*/
|
||||
|
||||
#include "rsync.h"
|
||||
|
||||
struct test1 {
|
||||
union file_extras extras1[1];
|
||||
struct {
|
||||
# include "mkrounding.h"
|
||||
} file;
|
||||
};
|
||||
|
||||
struct test2 {
|
||||
union file_extras extras2[2];
|
||||
struct {
|
||||
# include "mkrounding.h"
|
||||
} file;
|
||||
};
|
||||
|
||||
struct test4 {
|
||||
union file_extras extras4[4];
|
||||
struct {
|
||||
# include "mkrounding.h"
|
||||
} file;
|
||||
};
|
||||
|
||||
#define SIZE_TEST(n) (sizeof (struct test ## n) == EXTRA_LEN * n + sizeof (struct file_struct))
|
||||
|
||||
int main(UNUSED(int argc), UNUSED(char *argv[]))
|
||||
{
|
||||
int cnt;
|
||||
if (SIZE_TEST(1))
|
||||
cnt = 0;
|
||||
else if (SIZE_TEST(2))
|
||||
cnt = 1;
|
||||
else if (SIZE_TEST(4))
|
||||
cnt = 3;
|
||||
else {
|
||||
fprintf(stderr, "Unable to determine required file_extras rounding!\n");
|
||||
cnt = 3;
|
||||
}
|
||||
if (cnt)
|
||||
fprintf(stderr, "Rounding file_extras in multiples of %d", cnt + 1);
|
||||
else
|
||||
fprintf(stderr, "No rounding needed for file_extras");
|
||||
fprintf(stderr, " (EXTRA_LEN=%d, FILE_STRUCT_LEN=%d)\n",
|
||||
(int)EXTRA_LEN, (int)FILE_STRUCT_LEN);
|
||||
printf("#define EXTRA_ROUNDING %d\n", cnt);
|
||||
return 0;
|
||||
}
|
||||
167
options.c
167
options.c
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (C) 1998-2001 Andrew Tridgell <tridge@samba.org>
|
||||
* Copyright (C) 2000, 2001, 2002 Martin Pool <mbp@samba.org>
|
||||
* Copyright (C) 2002-2007 Wayne Davison
|
||||
* Copyright (C) 2002-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -25,11 +25,12 @@
|
||||
#include "zlib/zlib.h"
|
||||
|
||||
extern int module_id;
|
||||
extern int local_server;
|
||||
extern int sanitize_paths;
|
||||
extern int daemon_over_rsh;
|
||||
extern unsigned int module_dirlen;
|
||||
extern struct filter_list_struct filter_list;
|
||||
extern struct filter_list_struct server_filter_list;
|
||||
extern struct filter_list_struct daemon_filter_list;
|
||||
|
||||
int make_backups = 0;
|
||||
|
||||
@@ -202,7 +203,7 @@ static int itemize_changes = 0;
|
||||
static int refused_delete, refused_archive_part, refused_compress;
|
||||
static int refused_partial, refused_progress, refused_delete_before;
|
||||
static int refused_delete_during;
|
||||
static int refused_inplace;
|
||||
static int refused_inplace, refused_no_iconv;
|
||||
static char *max_size_arg, *min_size_arg;
|
||||
static char tmp_partialdir[] = ".~tmp~";
|
||||
|
||||
@@ -218,6 +219,7 @@ static void print_rsync_version(enum logcode f)
|
||||
char const *got_socketpair = "no ";
|
||||
char const *have_inplace = "no ";
|
||||
char const *hardlinks = "no ";
|
||||
char const *symtimes = "no ";
|
||||
char const *acls = "no ";
|
||||
char const *xattrs = "no ";
|
||||
char const *links = "no ";
|
||||
@@ -252,10 +254,13 @@ static void print_rsync_version(enum logcode f)
|
||||
#ifdef ICONV_OPTION
|
||||
iconv = "";
|
||||
#endif
|
||||
#if defined HAVE_LUTIMES && defined HAVE_UTIMES
|
||||
symtimes = "";
|
||||
#endif
|
||||
|
||||
rprintf(f, "%s version %s protocol version %d%s\n",
|
||||
RSYNC_NAME, RSYNC_VERSION, PROTOCOL_VERSION, subprotocol);
|
||||
rprintf(f, "Copyright (C) 1996-2007 by Andrew Tridgell, Wayne Davison, and others.\n");
|
||||
rprintf(f, "Copyright (C) 1996-2008 by Andrew Tridgell, Wayne Davison, and others.\n");
|
||||
rprintf(f, "Web site: http://rsync.samba.org/\n");
|
||||
rprintf(f, "Capabilities:\n");
|
||||
rprintf(f, " %d-bit files, %d-bit inums, %d-bit timestamps, %d-bit long ints,\n",
|
||||
@@ -265,8 +270,8 @@ static void print_rsync_version(enum logcode f)
|
||||
(int)(sizeof (int64) * 8));
|
||||
rprintf(f, " %ssocketpairs, %shardlinks, %ssymlinks, %sIPv6, batchfiles, %sinplace,\n",
|
||||
got_socketpair, hardlinks, links, ipv6, have_inplace);
|
||||
rprintf(f, " %sappend, %sACLs, %sxattrs, %siconv\n",
|
||||
have_inplace, acls, xattrs, iconv);
|
||||
rprintf(f, " %sappend, %sACLs, %sxattrs, %siconv, %ssymtimes\n",
|
||||
have_inplace, acls, xattrs, iconv, symtimes);
|
||||
|
||||
#ifdef MAINTAINER_MODE
|
||||
rprintf(f, "Panic Action: \"%s\"\n", get_panic_action());
|
||||
@@ -441,7 +446,7 @@ enum {OPT_VERSION = 1000, OPT_DAEMON, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
|
||||
OPT_FILTER, OPT_COMPARE_DEST, OPT_COPY_DEST, OPT_LINK_DEST, OPT_HELP,
|
||||
OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_MODIFY_WINDOW, OPT_MIN_SIZE, OPT_CHMOD,
|
||||
OPT_READ_BATCH, OPT_WRITE_BATCH, OPT_ONLY_WRITE_BATCH, OPT_MAX_SIZE,
|
||||
OPT_NO_D, OPT_APPEND,
|
||||
OPT_NO_D, OPT_APPEND, OPT_NO_ICONV,
|
||||
OPT_SERVER, OPT_REFUSED_BASE = 9000};
|
||||
|
||||
static struct poptOption long_options[] = {
|
||||
@@ -470,6 +475,8 @@ static struct poptOption long_options[] = {
|
||||
{"dirs", 'd', POPT_ARG_VAL, &xfer_dirs, 2, 0, 0 },
|
||||
{"no-dirs", 0, POPT_ARG_VAL, &xfer_dirs, 0, 0, 0 },
|
||||
{"no-d", 0, POPT_ARG_VAL, &xfer_dirs, 0, 0, 0 },
|
||||
{"old-dirs", 0, POPT_ARG_VAL, &xfer_dirs, 4, 0, 0 },
|
||||
{"old-d", 0, POPT_ARG_VAL, &xfer_dirs, 4, 0, 0 },
|
||||
{"perms", 'p', POPT_ARG_VAL, &preserve_perms, 1, 0, 0 },
|
||||
{"no-perms", 0, POPT_ARG_VAL, &preserve_perms, 0, 0, 0 },
|
||||
{"no-p", 0, POPT_ARG_VAL, &preserve_perms, 0, 0, 0 },
|
||||
@@ -524,14 +531,19 @@ static struct poptOption long_options[] = {
|
||||
{"ignore-times", 'I', POPT_ARG_NONE, &ignore_times, 0, 0, 0 },
|
||||
{"size-only", 0, POPT_ARG_NONE, &size_only, 0, 0, 0 },
|
||||
{"one-file-system", 'x', POPT_ARG_NONE, 0, 'x', 0, 0 },
|
||||
{"no-one-file-system",'x',POPT_ARG_VAL, &one_file_system, 0, 0, 0 },
|
||||
{"no-x", 'x', POPT_ARG_VAL, &one_file_system, 0, 0, 0 },
|
||||
{"update", 'u', POPT_ARG_NONE, &update_only, 0, 0, 0 },
|
||||
{"existing", 0, POPT_ARG_NONE, &ignore_non_existing, 0, 0, 0 },
|
||||
{"ignore-non-existing",0,POPT_ARG_NONE, &ignore_non_existing, 0, 0, 0 },
|
||||
{"ignore-existing", 0, POPT_ARG_NONE, &ignore_existing, 0, 0, 0 },
|
||||
{"max-size", 0, POPT_ARG_STRING, &max_size_arg, OPT_MAX_SIZE, 0, 0 },
|
||||
{"min-size", 0, POPT_ARG_STRING, &min_size_arg, OPT_MIN_SIZE, 0, 0 },
|
||||
{"sparse", 'S', POPT_ARG_NONE, &sparse_files, 0, 0, 0 },
|
||||
{"inplace", 0, POPT_ARG_NONE, &inplace, 0, 0, 0 },
|
||||
{"sparse", 'S', POPT_ARG_VAL, &sparse_files, 1, 0, 0 },
|
||||
{"no-sparse", 0, POPT_ARG_VAL, &sparse_files, 0, 0, 0 },
|
||||
{"no-S", 0, POPT_ARG_VAL, &sparse_files, 0, 0, 0 },
|
||||
{"inplace", 0, POPT_ARG_VAL, &inplace, 1, 0, 0 },
|
||||
{"no-inplace", 0, POPT_ARG_VAL, &inplace, 0, 0, 0 },
|
||||
{"append", 0, POPT_ARG_NONE, 0, OPT_APPEND, 0, 0 },
|
||||
{"append-verify", 0, POPT_ARG_VAL, &append_mode, 2, 0, 0 },
|
||||
{"no-append", 0, POPT_ARG_VAL, &append_mode, 0, 0, 0 },
|
||||
@@ -544,8 +556,10 @@ static struct poptOption long_options[] = {
|
||||
{"delete-excluded", 0, POPT_ARG_NONE, &delete_excluded, 0, 0, 0 },
|
||||
{"remove-sent-files",0, POPT_ARG_VAL, &remove_source_files, 2, 0, 0 }, /* deprecated */
|
||||
{"remove-source-files",0,POPT_ARG_VAL, &remove_source_files, 1, 0, 0 },
|
||||
{"force", 0, POPT_ARG_NONE, &force_delete, 0, 0, 0 },
|
||||
{"ignore-errors", 0, POPT_ARG_NONE, &ignore_errors, 0, 0, 0 },
|
||||
{"force", 0, POPT_ARG_VAL, &force_delete, 1, 0, 0 },
|
||||
{"no-force", 0, POPT_ARG_VAL, &force_delete, 0, 0, 0 },
|
||||
{"ignore-errors", 0, POPT_ARG_VAL, &ignore_errors, 1, 0, 0 },
|
||||
{"no-ignore-errors", 0, POPT_ARG_VAL, &ignore_errors, 0, 0, 0 },
|
||||
{"max-delete", 0, POPT_ARG_INT, &max_delete, 0, 0, 0 },
|
||||
{0, 'F', POPT_ARG_NONE, 0, 'F', 0, 0 },
|
||||
{"filter", 'f', POPT_ARG_STRING, 0, OPT_FILTER, 0, 0 },
|
||||
@@ -564,11 +578,13 @@ static struct poptOption long_options[] = {
|
||||
{"compare-dest", 0, POPT_ARG_STRING, 0, OPT_COMPARE_DEST, 0, 0 },
|
||||
{"copy-dest", 0, POPT_ARG_STRING, 0, OPT_COPY_DEST, 0, 0 },
|
||||
{"link-dest", 0, POPT_ARG_STRING, 0, OPT_LINK_DEST, 0, 0 },
|
||||
{"fuzzy", 'y', POPT_ARG_NONE, &fuzzy_basis, 0, 0, 0 },
|
||||
{"fuzzy", 'y', POPT_ARG_VAL, &fuzzy_basis, 1, 0, 0 },
|
||||
{"no-fuzzy", 0, POPT_ARG_VAL, &fuzzy_basis, 0, 0, 0 },
|
||||
{"no-y", 0, POPT_ARG_VAL, &fuzzy_basis, 0, 0, 0 },
|
||||
{"compress", 'z', POPT_ARG_NONE, 0, 'z', 0, 0 },
|
||||
{"no-compress", 0, POPT_ARG_VAL, &do_compression, 0, 0, 0 },
|
||||
{"skip-compress", 0, POPT_ARG_STRING, &skip_compress, 0, 0, 0 },
|
||||
{"no-z", 0, POPT_ARG_VAL, &do_compression, 0, 0, 0 },
|
||||
{"skip-compress", 0, POPT_ARG_STRING, &skip_compress, 0, 0, 0 },
|
||||
{"compress-level", 0, POPT_ARG_INT, &def_compress_level, 'z', 0, 0 },
|
||||
{0, 'P', POPT_ARG_NONE, 0, 'P', 0, 0 },
|
||||
{"progress", 0, POPT_ARG_VAL, &do_progress, 1, 0, 0 },
|
||||
@@ -578,7 +594,9 @@ static struct poptOption long_options[] = {
|
||||
{"partial-dir", 0, POPT_ARG_STRING, &partial_dir, 0, 0, 0 },
|
||||
{"delay-updates", 0, POPT_ARG_VAL, &delay_updates, 1, 0, 0 },
|
||||
{"no-delay-updates", 0, POPT_ARG_VAL, &delay_updates, 0, 0, 0 },
|
||||
{"prune-empty-dirs",'m', POPT_ARG_NONE, &prune_empty_dirs, 0, 0, 0 },
|
||||
{"prune-empty-dirs",'m', POPT_ARG_VAL, &prune_empty_dirs, 1, 0, 0 },
|
||||
{"no-prune-empty-dirs",0,POPT_ARG_VAL, &prune_empty_dirs, 0, 0, 0 },
|
||||
{"no-m", 0, POPT_ARG_VAL, &prune_empty_dirs, 0, 0, 0 },
|
||||
{"log-file", 0, POPT_ARG_STRING, &logfile_name, 0, 0, 0 },
|
||||
{"log-file-format", 0, POPT_ARG_STRING, &logfile_format, 0, 0, 0 },
|
||||
{"out-format", 0, POPT_ARG_STRING, &stdout_format, 0, 0, 0 },
|
||||
@@ -607,15 +625,19 @@ static struct poptOption long_options[] = {
|
||||
{"timeout", 0, POPT_ARG_INT, &io_timeout, 0, 0, 0 },
|
||||
{"no-timeout", 0, POPT_ARG_VAL, &io_timeout, 0, 0, 0 },
|
||||
{"contimeout", 0, POPT_ARG_INT, &connect_timeout, 0, 0, 0 },
|
||||
{"no-contimeout", 0, POPT_ARG_VAL, &connect_timeout, 0, 0, 0 },
|
||||
{"rsh", 'e', POPT_ARG_STRING, &shell_cmd, 0, 0, 0 },
|
||||
{"rsync-path", 0, POPT_ARG_STRING, &rsync_path, 0, 0, 0 },
|
||||
{"temp-dir", 'T', POPT_ARG_STRING, &tmpdir, 0, 0, 0 },
|
||||
#ifdef ICONV_OPTION
|
||||
{"iconv", 0, POPT_ARG_STRING, &iconv_opt, 0, 0, 0 },
|
||||
{"no-iconv", 0, POPT_ARG_NONE, 0, OPT_NO_ICONV, 0, 0 },
|
||||
#endif
|
||||
{"ipv4", '4', POPT_ARG_VAL, &default_af_hint, AF_INET, 0, 0 },
|
||||
{"ipv6", '6', POPT_ARG_VAL, &default_af_hint, AF_INET6, 0, 0 },
|
||||
{"8-bit-output", '8', POPT_ARG_NONE, &allow_8bit_chars, 0, 0, 0 },
|
||||
{"8-bit-output", '8', POPT_ARG_VAL, &allow_8bit_chars, 1, 0, 0 },
|
||||
{"no-8-bit-output", 0, POPT_ARG_VAL, &allow_8bit_chars, 0, 0, 0 },
|
||||
{"no-8", 0, POPT_ARG_VAL, &allow_8bit_chars, 0, 0, 0 },
|
||||
{"qsort", 0, POPT_ARG_NONE, &use_qsort, 0, 0, 0 },
|
||||
{"address", 0, POPT_ARG_STRING, &bind_address, 0, 0, 0 },
|
||||
{"port", 0, POPT_ARG_INT, &rsync_port, 0, 0, 0 },
|
||||
@@ -758,6 +780,8 @@ static void set_refuse_options(char *bp)
|
||||
refused_progress = op->val;
|
||||
else if (wildmatch("inplace", op->longName))
|
||||
refused_inplace = op->val;
|
||||
else if (wildmatch("no-iconv", op->longName))
|
||||
refused_no_iconv = op->val;
|
||||
break;
|
||||
}
|
||||
if (!is_wild)
|
||||
@@ -868,7 +892,7 @@ static void create_refuse_error(int which)
|
||||
*
|
||||
* @retval 0 on error, with err_buf containing an explanation
|
||||
**/
|
||||
int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
|
||||
int parse_arguments(int *argc_p, const char ***argv_p)
|
||||
{
|
||||
static poptContext pc;
|
||||
char *ref = lp_refuse_options(module_id);
|
||||
@@ -878,8 +902,13 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
|
||||
|
||||
if (ref && *ref)
|
||||
set_refuse_options(ref);
|
||||
if (am_daemon)
|
||||
if (am_daemon) {
|
||||
set_refuse_options("log-file*");
|
||||
#ifdef ICONV_OPTION
|
||||
if (!*lp_charset(module_id))
|
||||
set_refuse_options("iconv");
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ICONV_OPTION
|
||||
if (!am_daemon && !protect_args && (arg = getenv("RSYNC_ICONV")) != NULL && *arg)
|
||||
@@ -1005,8 +1034,8 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
|
||||
case OPT_INCLUDE_FROM:
|
||||
arg = poptGetOptArg(pc);
|
||||
if (sanitize_paths)
|
||||
arg = sanitize_path(NULL, arg, NULL, 0);
|
||||
if (server_filter_list.head) {
|
||||
arg = sanitize_path(NULL, arg, NULL, 0, SP_DEFAULT);
|
||||
if (daemon_filter_list.head) {
|
||||
int rej;
|
||||
char *dir, *cp = strdup(arg);
|
||||
if (!cp)
|
||||
@@ -1015,7 +1044,7 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
|
||||
goto options_rejected;
|
||||
dir = cp + (*cp == '/' ? module_dirlen : 0);
|
||||
clean_fname(dir, CFN_COLLAPSE_DOT_DOT_DIRS);
|
||||
rej = check_filter(&server_filter_list, dir, 0) < 0;
|
||||
rej = check_filter(&daemon_filter_list, FLOG, dir, 0) < 0;
|
||||
free(cp);
|
||||
if (rej)
|
||||
goto options_rejected;
|
||||
@@ -1068,8 +1097,7 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
|
||||
break;
|
||||
|
||||
case 'q':
|
||||
if (frommain)
|
||||
quiet++;
|
||||
quiet++;
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
@@ -1127,6 +1155,12 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
|
||||
read_batch = 1;
|
||||
break;
|
||||
|
||||
case OPT_NO_ICONV:
|
||||
#ifdef ICONV_OPTION
|
||||
iconv_opt = NULL;
|
||||
#endif
|
||||
break;
|
||||
|
||||
case OPT_MAX_SIZE:
|
||||
if ((max_size = parse_size_arg(&max_size_arg, 'b')) <= 0) {
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
@@ -1241,7 +1275,7 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
|
||||
}
|
||||
}
|
||||
|
||||
if (human_readable && argc == 2) {
|
||||
if (human_readable && argc == 2 && !am_server) {
|
||||
/* Allow the old meaning of 'h' (--help) on its own. */
|
||||
usage(FINFO);
|
||||
exit_cleanup(0);
|
||||
@@ -1254,14 +1288,17 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
|
||||
else
|
||||
need_unsorted_flist = 1;
|
||||
}
|
||||
if (refused_no_iconv && !iconv_opt) {
|
||||
create_refuse_error(refused_no_iconv);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (protect_args == 1) {
|
||||
if (!frommain)
|
||||
protect_args = 0;
|
||||
else if (am_server)
|
||||
return 1;
|
||||
}
|
||||
if (protect_args == 1 && am_server)
|
||||
return 1;
|
||||
|
||||
*argv_p = argv = poptGetArgs(pc);
|
||||
*argc_p = argc = count_args(argv);
|
||||
|
||||
#ifndef SUPPORT_LINKS
|
||||
if (preserve_links && !am_sender) {
|
||||
@@ -1281,7 +1318,13 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef SUPPORT_XATTRS
|
||||
#ifdef SUPPORT_XATTRS
|
||||
if (am_root < 0 && preserve_xattrs > 1) {
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"--fake-super conflicts with -XX\n");
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
if (am_root < 0) {
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"--fake-super requires an rsync with extended attributes enabled\n");
|
||||
@@ -1306,7 +1349,8 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
|
||||
batch_name = NULL;
|
||||
} else if (dry_run)
|
||||
write_batch = 0;
|
||||
}
|
||||
} else if (write_batch < 0 && dry_run)
|
||||
write_batch = 0;
|
||||
if (read_batch && files_from) {
|
||||
snprintf(err_buf, sizeof err_buf,
|
||||
"--read-batch cannot be used with --files-from\n");
|
||||
@@ -1343,8 +1387,16 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
|
||||
xfer_dirs = 1;
|
||||
}
|
||||
|
||||
if (xfer_dirs < 1)
|
||||
xfer_dirs = recurse || list_only;
|
||||
if (argc < 2 && !read_batch && !am_server)
|
||||
list_only |= 1;
|
||||
|
||||
if (xfer_dirs >= 4) {
|
||||
parse_rule(&filter_list, "- /*/*", 0, 0);
|
||||
recurse = xfer_dirs = 1;
|
||||
} else if (recurse)
|
||||
xfer_dirs = 1;
|
||||
else if (xfer_dirs < 0)
|
||||
xfer_dirs = list_only ? 1 : 0;
|
||||
|
||||
if (relative_paths < 0)
|
||||
relative_paths = files_from? 1 : 0;
|
||||
@@ -1393,27 +1445,24 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
|
||||
need_messages_from_generator = 1;
|
||||
}
|
||||
|
||||
*argv_p = argv = poptGetArgs(pc);
|
||||
*argc_p = argc = count_args(argv);
|
||||
|
||||
if (sanitize_paths) {
|
||||
int i;
|
||||
for (i = argc; i-- > 0; )
|
||||
argv[i] = sanitize_path(NULL, argv[i], "", 0);
|
||||
argv[i] = sanitize_path(NULL, argv[i], "", 0, SP_KEEP_DOT_DIRS);
|
||||
if (tmpdir)
|
||||
tmpdir = sanitize_path(NULL, tmpdir, NULL, 0);
|
||||
tmpdir = sanitize_path(NULL, tmpdir, NULL, 0, SP_DEFAULT);
|
||||
if (backup_dir)
|
||||
backup_dir = sanitize_path(NULL, backup_dir, NULL, 0);
|
||||
backup_dir = sanitize_path(NULL, backup_dir, NULL, 0, SP_DEFAULT);
|
||||
}
|
||||
if (server_filter_list.head && !am_sender) {
|
||||
struct filter_list_struct *elp = &server_filter_list;
|
||||
if (daemon_filter_list.head && !am_sender) {
|
||||
struct filter_list_struct *elp = &daemon_filter_list;
|
||||
if (tmpdir) {
|
||||
char *dir;
|
||||
if (!*tmpdir)
|
||||
goto options_rejected;
|
||||
dir = tmpdir + (*tmpdir == '/' ? module_dirlen : 0);
|
||||
clean_fname(dir, CFN_COLLAPSE_DOT_DOT_DIRS);
|
||||
if (check_filter(elp, dir, 1) < 0)
|
||||
if (check_filter(elp, FLOG, dir, 1) < 0)
|
||||
goto options_rejected;
|
||||
}
|
||||
if (backup_dir) {
|
||||
@@ -1422,7 +1471,7 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
|
||||
goto options_rejected;
|
||||
dir = backup_dir + (*backup_dir == '/' ? module_dirlen : 0);
|
||||
clean_fname(dir, CFN_COLLAPSE_DOT_DOT_DIRS);
|
||||
if (check_filter(elp, dir, 1) < 0)
|
||||
if (check_filter(elp, FLOG, dir, 1) < 0)
|
||||
goto options_rejected;
|
||||
}
|
||||
}
|
||||
@@ -1611,14 +1660,14 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
|
||||
}
|
||||
} else {
|
||||
if (sanitize_paths)
|
||||
files_from = sanitize_path(NULL, files_from, NULL, 0);
|
||||
if (server_filter_list.head) {
|
||||
files_from = sanitize_path(NULL, files_from, NULL, 0, SP_DEFAULT);
|
||||
if (daemon_filter_list.head) {
|
||||
char *dir;
|
||||
if (!*files_from)
|
||||
goto options_rejected;
|
||||
dir = files_from + (*files_from == '/' ? module_dirlen : 0);
|
||||
clean_fname(dir, CFN_COLLAPSE_DOT_DOT_DIRS);
|
||||
if (check_filter(&server_filter_list, dir, 0) < 0)
|
||||
if (check_filter(&daemon_filter_list, FLOG, dir, 0) < 0)
|
||||
goto options_rejected;
|
||||
}
|
||||
filesfrom_fd = open(files_from, O_RDONLY|O_BINARY);
|
||||
@@ -1688,8 +1737,8 @@ void server_options(char **args, int *argc_p)
|
||||
argstr[x++] = 'n';
|
||||
if (preserve_links)
|
||||
argstr[x++] = 'l';
|
||||
if ((list_only && !recurse) || xfer_dirs > 1
|
||||
|| (xfer_dirs && !recurse && delete_mode && am_sender))
|
||||
if ((xfer_dirs >= 2 && xfer_dirs < 4)
|
||||
|| (xfer_dirs && !recurse && (list_only || (delete_mode && am_sender))))
|
||||
argstr[x++] = 'd';
|
||||
if (am_sender) {
|
||||
if (keep_dirlinks)
|
||||
@@ -1760,24 +1809,24 @@ void server_options(char **args, int *argc_p)
|
||||
argstr[x++] = 'z';
|
||||
|
||||
/* We make use of the -e option to let the server know about any
|
||||
* pre-release protocol version && our allow_inc_recurse status. */
|
||||
set_allow_inc_recurse();
|
||||
* pre-release protocol version && some behavior flags. */
|
||||
argstr[x++] = 'e';
|
||||
#if SUBPROTOCOL_VERSION != 0
|
||||
if (protocol_version == PROTOCOL_VERSION) {
|
||||
x += snprintf(argstr+x, sizeof argstr - x,
|
||||
"e%d.%d%s", PROTOCOL_VERSION, SUBPROTOCOL_VERSION,
|
||||
allow_inc_recurse ? "i" : "");
|
||||
"%d.%d", PROTOCOL_VERSION, SUBPROTOCOL_VERSION);
|
||||
} else
|
||||
#endif
|
||||
if (allow_inc_recurse) {
|
||||
argstr[x++] = 'e';
|
||||
argstr[x++] = '.';
|
||||
set_allow_inc_recurse();
|
||||
if (allow_inc_recurse)
|
||||
argstr[x++] = 'i';
|
||||
}
|
||||
|
||||
#if defined HAVE_LUTIMES && defined HAVE_UTIMES
|
||||
argstr[x++] = 'L';
|
||||
#endif
|
||||
argstr[x] = '\0';
|
||||
|
||||
if (x != 1)
|
||||
args[ac++] = argstr;
|
||||
args[ac++] = argstr;
|
||||
|
||||
#ifdef ICONV_OPTION
|
||||
if (iconv_opt) {
|
||||
@@ -1792,7 +1841,7 @@ void server_options(char **args, int *argc_p)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (protect_args) /* initial args break here */
|
||||
if (protect_args && !local_server) /* unprotected args stop here */
|
||||
args[ac++] = NULL;
|
||||
|
||||
if (list_only > 1)
|
||||
|
||||
6
packaging/bin/gpg
Executable file
6
packaging/bin/gpg
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh -e
|
||||
# This script gets git to run gpg with a --passphrase-file option.
|
||||
|
||||
PATH=`echo $PATH | sed 's/^[^:]*://'`
|
||||
|
||||
gpg --batch --passphrase-file=$GPG_PASSFILE "${@}"
|
||||
@@ -4,13 +4,19 @@
|
||||
# is included in the rrsync script.
|
||||
use strict;
|
||||
|
||||
our(%short_no_arg, %short_with_num, %long_opt);
|
||||
our %short_no_arg;
|
||||
our %short_with_num;
|
||||
our %long_opt = (
|
||||
'no-i-r' => 0,
|
||||
'fake-super' => 0,
|
||||
'log-file' => 3,
|
||||
);
|
||||
our $last_long_opt;
|
||||
|
||||
open(IN, '../options.c') or die "Unable to open ../options.c: $!\n";
|
||||
|
||||
while (<IN>) {
|
||||
if (/\Qargstr[x++]\E = '(.)'/) {
|
||||
if (/\Qargstr[x++]\E = '([^.ie])'/) {
|
||||
$short_no_arg{$1} = 1;
|
||||
undef $last_long_opt;
|
||||
} elsif (/\Qasprintf(\E[^,]+, "-([a-zA-Z0-9])\%l?[ud]"/) {
|
||||
@@ -1,9 +1,12 @@
|
||||
Summary: A fast, versatile, remote (and local) file-copying tool
|
||||
Name: rsync
|
||||
Version: 3.0.0pre7
|
||||
Release: 1
|
||||
Version: 3.0.3
|
||||
%define fullversion %{version}pre2
|
||||
Release: 0.1.pre2
|
||||
%define srcdir src-previews
|
||||
Group: Applications/Internet
|
||||
Source: ftp://rsync.samba.org/pub/rsync/rsync-%{version}.tar.gz
|
||||
Source0: http://rsync.samba.org/ftp/rsync/%{srcdir}/rsync-%{fullversion}.tar.gz
|
||||
#Source1: http://rsync.samba.org/ftp/rsync/%{srcdir}/rsync-patches-%{fullversion}.tar.gz
|
||||
URL: http://rsync.samba.org/
|
||||
|
||||
Prefix: %{_prefix}
|
||||
@@ -22,9 +25,21 @@ destination. Rsync is widely used for backups and mirroring and as an
|
||||
improved copy command for everyday use.
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
# Choose one -- setup source only, or setup source + rsync-patches:
|
||||
%setup -q -n rsync-%{fullversion}
|
||||
#%setup -q -b1 -n rsync-%{fullversion}
|
||||
|
||||
# If you you used "%setup -q -b1", choose the patches you wish to apply:
|
||||
#patch -p1 <patches/acls.diff
|
||||
#patch -p1 <patches/xattrs.diff
|
||||
#patch -p1 <patches/remote-option.diff
|
||||
#patch -p1 <patches/db.diff
|
||||
|
||||
# Avoid extra perl dependencies for scripts going into doc dir.
|
||||
chmod -x support/*
|
||||
|
||||
%build
|
||||
#./prepare-source
|
||||
%configure
|
||||
|
||||
make
|
||||
@@ -34,16 +49,26 @@ rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%makeinstall
|
||||
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/xinetd.d
|
||||
install -m 644 packaging/lsb/rsync.xinetd $RPM_BUILD_ROOT/etc/xinetd.d/rsync
|
||||
|
||||
#install -p -m 755 support/rsyncdb $RPM_BUILD_ROOT/usr/bin/rsyncdb
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
%doc COPYING README tech_report.tex
|
||||
%{_prefix}/bin/rsync
|
||||
%doc COPYING NEWS OLDNEWS README support/ tech_report.tex
|
||||
%config(noreplace) /etc/xinetd.d/rsync
|
||||
%{_prefix}/bin/rsync*
|
||||
%{_mandir}/man1/rsync.1*
|
||||
%{_mandir}/man5/rsyncd.conf.5*
|
||||
|
||||
%changelog
|
||||
* Sun Dec 16 2007 Wayne Davison <wayned@samba.org>
|
||||
Released 3.0.0pre7.
|
||||
* Sat May 17 2008 Wayne Davison <wayned@samba.org>
|
||||
Released 3.0.3pre2.
|
||||
|
||||
* Fri Mar 21 2008 Wayne Davison <wayned@samba.org>
|
||||
Added installation of /etc/xinetd.d/rsync file and some commented-out
|
||||
lines that demonstrate how to use the rsync-patches tar file.
|
||||
|
||||
13
packaging/lsb/rsync.xinetd
Normal file
13
packaging/lsb/rsync.xinetd
Normal file
@@ -0,0 +1,13 @@
|
||||
# default: off
|
||||
# description: The rsync server is a good addition to an ftp server, as it
|
||||
# allows crc checksumming etc.
|
||||
service rsync
|
||||
{
|
||||
disable = yes
|
||||
socket_type = stream
|
||||
wait = no
|
||||
user = root
|
||||
server = /usr/bin/rsync
|
||||
server_args = --daemon
|
||||
log_on_failure += USERID
|
||||
}
|
||||
@@ -14,8 +14,8 @@ use strict;
|
||||
use Getopt::Long;
|
||||
use Date::Format;
|
||||
|
||||
# Where the local copy of /home/ftp/pub/rsync/nightly should be updated.
|
||||
our $dest = $ENV{HOME} . '/samba-rsync-ftp/nightly';
|
||||
# Where the local copy of /home/ftp/pub/rsync/dev/nightly should be updated.
|
||||
our $dest = $ENV{HOME} . '/samba-rsync-ftp/dev/nightly';
|
||||
our $nightly_symlink = "$dest/rsync-HEAD.tar.gz";
|
||||
|
||||
our($make_tar, $upload, $help_opt);
|
||||
@@ -41,6 +41,7 @@ if ($make_tar) {
|
||||
close IN;
|
||||
die "The checkout is not clean:\n", $status unless $status =~ /\nnothing to commit \(working directory clean\)/;
|
||||
die "The checkout is not on the master branch.\n" unless $status =~ /^# On branch master\n/;
|
||||
system "make $gen_target" and die "make $gen_target failed!\n";
|
||||
|
||||
my @extra_files;
|
||||
open(IN, '<', 'Makefile.in') or die "Couldn't open Makefile.in: $!\n";
|
||||
@@ -56,7 +57,7 @@ if ($make_tar) {
|
||||
close IN;
|
||||
|
||||
print "Creating $name.tar.gz\n";
|
||||
system "make $gen_target; rsync -a @extra_files $name/";
|
||||
system "rsync -a @extra_files $name/";
|
||||
system "git archive --format=tar --prefix=$name/ HEAD | tar xf -";
|
||||
system "support/git-set-file-times --prefix=$name/";
|
||||
system "fakeroot tar czf $dest/$name.tar.gz $name; rm -rf $name";
|
||||
@@ -103,7 +104,7 @@ if ($upload) {
|
||||
if (defined $ENV{RSYNC_PARTIAL_DIR}) {
|
||||
$opt = " -f 'R $ENV{RSYNC_PARTIAL_DIR}'";
|
||||
}
|
||||
system "rsync$opt -aviHP --delete-after . samba.org:/home/ftp/pub/rsync/nightly";
|
||||
system "rsync$opt -aviHP --delete-after . samba.org:/home/ftp/pub/rsync/dev/nightly";
|
||||
}
|
||||
|
||||
exit;
|
||||
|
||||
213
packaging/patch-update
Executable file
213
packaging/patch-update
Executable file
@@ -0,0 +1,213 @@
|
||||
#!/usr/bin/perl -w
|
||||
# This script is used to turn one or more of the "patch/*" branches
|
||||
# into one or more diffs in the "patches" directory. Pass the option
|
||||
# --gen if you want generated files in the diffs. Pass the name of
|
||||
# one or more diffs if you want to just update a subset of all the
|
||||
# diffs.
|
||||
|
||||
use strict;
|
||||
use Getopt::Long;
|
||||
|
||||
my $patches_dir = 'patches';
|
||||
my $tmp_dir = "patches.$$";
|
||||
|
||||
&Getopt::Long::Configure('bundling');
|
||||
&usage if !&GetOptions(
|
||||
'skip-check' => \( my $skip_branch_check ),
|
||||
'shell|s' => \( my $launch_shell ),
|
||||
'gen:s' => \( my $incl_generated_files ),
|
||||
'help|h' => \( my $help_opt ),
|
||||
);
|
||||
&usage if $help_opt;
|
||||
|
||||
if (defined $incl_generated_files) {
|
||||
$patches_dir = $incl_generated_files if $incl_generated_files ne '';
|
||||
$incl_generated_files = 1;
|
||||
}
|
||||
|
||||
die "No '$patches_dir' directory was found.\n" unless -d $patches_dir;
|
||||
die "No '.git' directory present in the current dir.\n" unless -d '.git';
|
||||
|
||||
my($status, $is_clean, $starting_branch) = &check_git_status;
|
||||
if (!$skip_branch_check && !$is_clean) {
|
||||
die "The checkout is not clean:\n", $status;
|
||||
}
|
||||
|
||||
my @extra_files;
|
||||
open(IN, '<', 'Makefile.in') or die "Couldn't open Makefile.in: $!\n";
|
||||
while (<IN>) {
|
||||
if (s/^GENFILES=//) {
|
||||
while (s/\\$//) {
|
||||
$_ .= <IN>;
|
||||
}
|
||||
@extra_files = split(' ', $_);
|
||||
last;
|
||||
}
|
||||
}
|
||||
close IN;
|
||||
|
||||
if ($incl_generated_files) {
|
||||
die "'$tmp_dir' must not exist in the current directory.\n" if -e $tmp_dir;
|
||||
mkdir($tmp_dir, 0700) or die "Unable to mkdir($tmp_dir): $!\n";
|
||||
system "./config.status Makefile && make gen && rsync -a @extra_files $tmp_dir/master/" and exit 1;
|
||||
}
|
||||
our $last_touch = time;
|
||||
|
||||
my(%patches, %local_patch);
|
||||
|
||||
# Start by finding all patches so that we can load all possible parents.
|
||||
open(PIPE, '-|', 'git', 'branch', '-a') or die $!;
|
||||
while (<PIPE>) {
|
||||
if (m# origin/patch/(.*)#) {
|
||||
$patches{$1} = 1;
|
||||
} elsif (m# patch/(.*)#) {
|
||||
$patches{$1} = $local_patch{$1} = 1;
|
||||
}
|
||||
}
|
||||
close PIPE;
|
||||
|
||||
my @patches = sort keys %patches;
|
||||
|
||||
my(%parent, %description);
|
||||
foreach my $patch (@patches) {
|
||||
my $branch = ($local_patch{$patch} ? '' : 'origin/') . "patch/$patch";
|
||||
my $desc = '';
|
||||
open(PIPE, '-|', 'git', 'diff', '-U1000', "master...$branch", '--', "PATCH.$patch") or die $!;
|
||||
while (<PIPE>) {
|
||||
last if /^@@ /;
|
||||
}
|
||||
while (<PIPE>) {
|
||||
next unless s/^[ +]//;
|
||||
if (m#patch -p1 <patches/(\S+)\.diff# && $1 ne $patch) {
|
||||
$parent{$patch} = $1;
|
||||
}
|
||||
$desc .= $_;
|
||||
}
|
||||
$description{$patch} = $desc;
|
||||
}
|
||||
|
||||
if (@ARGV) {
|
||||
# Limit the list of patches to actually process based on @ARGV.
|
||||
@patches = ( );
|
||||
foreach (@ARGV) {
|
||||
s{^(patches|patch|origin/patch)/} {};
|
||||
s{\.diff$} {};
|
||||
push(@patches, $_);
|
||||
}
|
||||
}
|
||||
|
||||
my %completed;
|
||||
foreach my $patch (@patches) {
|
||||
next if $completed{$patch}++;
|
||||
last unless update_patch($patch);
|
||||
}
|
||||
|
||||
if ($incl_generated_files) {
|
||||
system "rm -rf $tmp_dir";
|
||||
}
|
||||
|
||||
sleep 1 while $last_touch >= time;
|
||||
system "git checkout $starting_branch" and exit 1;
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
sub update_patch
|
||||
{
|
||||
my($patch) = @_;
|
||||
|
||||
my $parent = $parent{$patch};
|
||||
if (defined $parent) {
|
||||
unless ($completed{$parent}++) {
|
||||
update_patch($parent);
|
||||
}
|
||||
$parent = "patch/$parent";
|
||||
} else {
|
||||
$parent = 'master';
|
||||
}
|
||||
|
||||
print "======== $patch ========\n";
|
||||
|
||||
sleep 1 while $incl_generated_files && $last_touch >= time;
|
||||
if ($local_patch{$patch}) {
|
||||
system "git checkout patch/$patch" and return 0;
|
||||
} else {
|
||||
system "git checkout --track -b patch/$patch origin/patch/$patch" and return 0;
|
||||
}
|
||||
|
||||
my $ok = system("git merge $parent") == 0;
|
||||
if (!$ok || $launch_shell) {
|
||||
print qq|"git merge $parent" incomplete -- please fix.\n| if !$ok;
|
||||
$ENV{PS1} = "[$parent] patch/$patch: ";
|
||||
while (1) {
|
||||
if (system($ENV{SHELL}) != 0) {
|
||||
print "Abort? [n/y] ";
|
||||
$_ = <STDIN>;
|
||||
next unless /^y/i;
|
||||
return 0;
|
||||
}
|
||||
($status, $is_clean) = &check_git_status;
|
||||
last if $is_clean;
|
||||
print $status;
|
||||
}
|
||||
}
|
||||
|
||||
open(OUT, '>', "$patches_dir/$patch.diff") or die $!;
|
||||
print OUT $description{$patch}, "\n";
|
||||
|
||||
if ($incl_generated_files) {
|
||||
system "./config.status Makefile && make gen && rsync -a @extra_files $tmp_dir/$patch/" and exit 1;
|
||||
}
|
||||
$last_touch = time;
|
||||
|
||||
open(PIPE, '-|', 'git', 'diff', $parent) or die $!;
|
||||
DIFF: while (<PIPE>) {
|
||||
while (m{^diff --git a/PATCH}) {
|
||||
while (<PIPE>) {
|
||||
last if m{^diff --git a/};
|
||||
}
|
||||
last DIFF if !defined $_;
|
||||
}
|
||||
next if /^index /;
|
||||
print OUT $_;
|
||||
}
|
||||
close PIPE;
|
||||
|
||||
if ($incl_generated_files) {
|
||||
$parent =~ s#.*/##;
|
||||
open(PIPE, '-|', 'diff', '-up', "$tmp_dir/$parent", "$tmp_dir/$patch") or die $!;
|
||||
while (<PIPE>) {
|
||||
s#^(diff -up) $tmp_dir/[^/]+/(.*?) $tmp_dir/[^/]+/(.*)#$1 a/$2 b/$3#o;
|
||||
s#^\Q---\E $tmp_dir/[^/]+/([^\t]+)\t.*#--- a/$1#o;
|
||||
s#^\Q+++\E $tmp_dir/[^/]+/([^\t]+)\t.*#+++ b/$1#o;
|
||||
print OUT $_;
|
||||
}
|
||||
close PIPE;
|
||||
}
|
||||
|
||||
close OUT;
|
||||
|
||||
1;
|
||||
}
|
||||
|
||||
exit;
|
||||
|
||||
sub check_git_status
|
||||
{
|
||||
open(IN, '-|', 'git status') or die $!;
|
||||
my $status = join('', <IN>);
|
||||
close IN;
|
||||
my $is_clean = $status =~ /\nnothing to commit \(working directory clean\)/;
|
||||
my($starting_branch) = $status =~ /^# On branch (.+)\n/;
|
||||
($status, $is_clean, $starting_branch);
|
||||
}
|
||||
|
||||
sub usage
|
||||
{
|
||||
die <<EOT;
|
||||
Usage: patch-update [OPTIONS]
|
||||
|
||||
--gen[=DIR] Include generated files. Optional dest DIR overrides "patches".
|
||||
--skip-check Skip the check that ensures starting with a clean branch.
|
||||
EOT
|
||||
}
|
||||
@@ -7,16 +7,25 @@ use strict;
|
||||
# ~/samba-rsync-ftp dir will be ready to be rsynced to samba.org.
|
||||
|
||||
use Cwd;
|
||||
use Term::ReadKey;
|
||||
use Date::Format;
|
||||
|
||||
my $dest = $ENV{HOME} . '/samba-rsync-ftp';
|
||||
my $passfile = $ENV{HOME} . '/.rsyncpass';
|
||||
my $path = $ENV{PATH};
|
||||
|
||||
my $cl_today = time2str('* %a %b %d %Y', time);
|
||||
my $ztoday = time2str('%d %b %Y', time);
|
||||
my $now = time;
|
||||
my $cl_today = time2str('* %a %b %d %Y', $now);
|
||||
my $year = time2str('%Y', $now);
|
||||
my $ztoday = time2str('%d %b %Y', $now);
|
||||
(my $today = $ztoday) =~ s/^0//;
|
||||
|
||||
my $curdir = Cwd::cwd;
|
||||
|
||||
END {
|
||||
unlink($passfile);
|
||||
}
|
||||
|
||||
my @extra_files;
|
||||
open(IN, '<', 'Makefile.in') or die "Couldn't open Makefile.in: $!\n";
|
||||
while (<IN>) {
|
||||
@@ -49,23 +58,23 @@ close IN;
|
||||
die "The checkout is not clean:\n", $status unless $status =~ /\nnothing to commit \(working directory clean\)/;
|
||||
die "The checkout is not on the master branch.\n" unless $status =~ /^# On branch master\n/;
|
||||
|
||||
my $lastversion;
|
||||
my $confversion;
|
||||
open(IN, '<', 'configure.in') or die $!;
|
||||
while (<IN>) {
|
||||
if (/^RSYNC_VERSION=(.*)/) {
|
||||
$lastversion = $1;
|
||||
$confversion = $1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
close IN;
|
||||
if ($lastversion =~ /dev$/) {
|
||||
open(IN, '<', 'OLDNEWS') or die $!;
|
||||
$_ = <IN>;
|
||||
close IN;
|
||||
($lastversion) = /(\d+\.\d+\.\d+)/;
|
||||
}
|
||||
die "Unable to find RSYNC_VERSION in configure.in\n" unless defined $confversion;
|
||||
|
||||
my $version = $lastversion;
|
||||
open(IN, '<', 'OLDNEWS') or die $!;
|
||||
$_ = <IN>;
|
||||
close IN;
|
||||
my($lastversion) = /(\d+\.\d+\.\d+)/;
|
||||
|
||||
my $version = $confversion;
|
||||
$version =~ s/dev/pre1/ || $version =~ s/pre(\d+)/ 'pre' . ($1 + 1) /e;
|
||||
|
||||
print "Please enter the version number of this release: [$version] ";
|
||||
@@ -75,31 +84,46 @@ if ($_ eq '.') {
|
||||
} elsif ($_ ne '') {
|
||||
$version = $_;
|
||||
}
|
||||
$version =~ s/[-.]*pre[-.]*/pre/;
|
||||
die "Invalid version: `$version'\n" unless $version =~ /^[\d.]+(pre\d+)?$/;
|
||||
|
||||
if (`git tag -l v$version` ne '') {
|
||||
print "Tag v$version already exists.\n\nDelete tag or quit? [q/del] ";
|
||||
$_ = <STDIN>;
|
||||
exit 1 unless /^del/i;
|
||||
system "git tag -d v$version";
|
||||
}
|
||||
|
||||
if ($version =~ s/[-.]*pre[-.]*/pre/ && $confversion !~ /dev$/) {
|
||||
$lastversion = $confversion;
|
||||
}
|
||||
|
||||
print "Enter the previous version to produce a patch against: [$lastversion] ";
|
||||
chomp($_ = <STDIN>);
|
||||
$lastversion = $_ if $_ ne '';
|
||||
$lastversion =~ s/[-.]*pre[-.]*/pre/;
|
||||
|
||||
my $release = 1;
|
||||
my $pre = $version =~ /(pre\d+)/ ? $1 : '';
|
||||
|
||||
my $release = $pre ? '0.1' : '1';
|
||||
print "Please enter the RPM release number of this release: [$release] ";
|
||||
chomp($_ = <STDIN>);
|
||||
$release = $_ if $_ ne '';
|
||||
$release .= ".$pre" if $pre;
|
||||
|
||||
my $diffdir;
|
||||
my $skipping;
|
||||
my($srcdir,$srcdiffdir,$lastsrcdir,$skipping);
|
||||
if ($lastversion =~ /pre/) {
|
||||
if ($version !~ /pre/) {
|
||||
if (!$pre) {
|
||||
die "You should not diff a release version against a pre-release version.\n";
|
||||
}
|
||||
$diffdir = "$dest/old-previews";
|
||||
$srcdir = $srcdiffdir = $lastsrcdir = 'src-previews';
|
||||
$skipping = ' ** SKIPPING **';
|
||||
} elsif ($version =~ /pre/) {
|
||||
$diffdir = $dest;
|
||||
} elsif ($pre) {
|
||||
$srcdir = $srcdiffdir = 'src-previews';
|
||||
$lastsrcdir = 'src';
|
||||
$skipping = ' ** SKIPPING **';
|
||||
} else {
|
||||
$diffdir = "$dest/old-versions";
|
||||
$srcdir = $lastsrcdir = 'src';
|
||||
$srcdiffdir = 'src-diffs';
|
||||
$skipping = '';
|
||||
}
|
||||
|
||||
@@ -108,14 +132,16 @@ print "\n", $break, <<EOT;
|
||||
\$lastversion is "$lastversion"
|
||||
\$dest is "$dest"
|
||||
\$curdir is "$curdir"
|
||||
\$diffdir is "$diffdir"
|
||||
\$srcdir is "$srcdir"
|
||||
\$srcdiffdir is "$srcdiffdir"
|
||||
\$lastsrcdir is "$lastsrcdir"
|
||||
\$release is "$release"
|
||||
|
||||
About to:
|
||||
- make sure that SUBPROTOCOL_VERSION is 0$skipping
|
||||
- tweak the version in configure.in and the spec files
|
||||
- tweak NEWS and OLDNEWS to update the release date$skipping
|
||||
- tweak the date in the *.yo files and generate the man pages
|
||||
- tweak the date in the *.yo files and generate the manpages
|
||||
- generate configure.sh, config.h.in, and proto.h
|
||||
- page through the differences
|
||||
|
||||
@@ -123,34 +149,54 @@ EOT
|
||||
print "<Press Enter to continue> ";
|
||||
$_ = <STDIN>;
|
||||
|
||||
my @tweak_files = ( glob('packaging/*.spec'), glob('packaging/*/*.spec'),
|
||||
glob('*.yo'), qw( configure.in ) );
|
||||
(my $finalversion = $version) =~ s/pre\d+//;
|
||||
my %specvars = ( 'Version:' => $finalversion, 'Release:' => $release,
|
||||
'%define fullversion' => "\%{version}$pre", 'Released' => "$version.",
|
||||
'%define srcdir' => $srcdir );
|
||||
my @tweak_files = ( glob('packaging/*.spec'), glob('packaging/*/*.spec'), glob('*.yo'),
|
||||
qw( configure.in rsync.h NEWS OLDNEWS options.c ) );
|
||||
|
||||
if ($version !~ /pre/) {
|
||||
push(@tweak_files, qw( rsync.h NEWS OLDNEWS ));
|
||||
}
|
||||
foreach my $fn (@tweak_files) {
|
||||
open(IN, '<', $fn) or die $!;
|
||||
undef $/; $_ = <IN>; $/ = "\n";
|
||||
close IN;
|
||||
if ($fn =~ /configure/) {
|
||||
s/^RSYNC_VERSION=.*/RSYNC_VERSION=$version/m;
|
||||
s/^RSYNC_VERSION=.*/RSYNC_VERSION=$version/m
|
||||
or die "Unable to update RSYNC_VERSION in $fn\n";
|
||||
} elsif ($fn =~ /\.spec/) {
|
||||
s/^(Version:) .*/$1 $version/m;
|
||||
s/^(Release:) .*/$1 $release/m;
|
||||
s/^(Released) .*/$1 $version./m;
|
||||
s/^\* \w\w\w \w\w\w \d\d \d\d\d\d (.*)/$cl_today $1/m;
|
||||
while (my($str, $val) = each %specvars) {
|
||||
s/^\Q$str\E .*/$str $val/m
|
||||
or die "Unable to update $str in $fn\n";
|
||||
}
|
||||
s/^\* \w\w\w \w\w\w \d\d \d\d\d\d (.*)/$cl_today $1/m
|
||||
or die "Unable to update ChangeLog header in $fn\n";
|
||||
} elsif ($fn =~ /\.yo/) {
|
||||
s/^(manpage\([^)]+\)\(\d+\)\()[^)]+(\).*)/$1$today$2/m;
|
||||
s/^(This man ?page is current for version) \S+ (of rsync)/$1 $version $2/m;
|
||||
} elsif ($fn eq 'NEWS') {
|
||||
s/^(NEWS for rsync \Q$version\E) \(UNRELEASED\)\s*\n/$1 ($today)\n/mi
|
||||
or die "Couldn't update NEWS file with release date!\n";
|
||||
s/^(manpage\([^)]+\)\(\d+\)\()[^)]+(\).*)/$1$today$2/m
|
||||
or die "Unable to update date in manpage() header in $fn\n";
|
||||
s/^(This man ?page is current for version) \S+ (of rsync)/$1 $version $2/m
|
||||
or die "Unable to update current version info in $fn\n";
|
||||
} elsif ($fn eq 'rsync.h') {
|
||||
s/(#define\s+SUBPROTOCOL_VERSION)\s+\d+/$1 0/;
|
||||
s/(#define\s+SUBPROTOCOL_VERSION)\s+\d+/$1 0/
|
||||
or die "Unable to find SUBPROTOCOL_VERSION define in $fn\n";
|
||||
next if $pre;
|
||||
} elsif ($fn eq 'NEWS') {
|
||||
s/^(NEWS for rsync \Q$finalversion\E) \(UNRELEASED\)\s*\n/$1 ($today)\n/mi
|
||||
or die "The first line of $fn is not in the right format. It must be:\n"
|
||||
. "NEWS for rsync $finalversion (UNRELEASED)\n";
|
||||
next if $pre;
|
||||
} elsif ($fn eq 'OLDNEWS') {
|
||||
s/^\t\S\S\s\S\S\S\s\d\d\d\d(\t\Q$version\E)/\t$ztoday$1/m
|
||||
or die "Couldn't update OLDNEWS file with release date!\n";
|
||||
s/^\t\S\S\s\S\S\S\s\d\d\d\d(\t\Q$finalversion\E)/\t$ztoday$1/m
|
||||
or die "Unable to find \"?? ??? $year\t$finalversion\" line in $fn\n";
|
||||
next if $pre;
|
||||
} elsif ($fn eq 'options.c') {
|
||||
if (s/(Copyright \(C\) 2002-)(\d+)( Wayne Davison)/$1$year$3/
|
||||
&& $2 ne $year) {
|
||||
die "Copyright comments need to be updated to $year in all files!\n";
|
||||
}
|
||||
# Adjust the year in the --version output.
|
||||
s/(rprintf\(f, "Copyright \(C\) 1996-)(\d+)/$1$year/
|
||||
or die "Unable to find Copyright string in --version output of $fn\n";
|
||||
next if $2 eq $year;
|
||||
} else {
|
||||
die "Unrecognized file in \@tweak_files: $fn\n";
|
||||
}
|
||||
@@ -165,83 +211,89 @@ system "git diff --color | less -p '^diff .*'";
|
||||
my $srctar_name = "rsync-$version.tar.gz";
|
||||
my $pattar_name = "rsync-patches-$version.tar.gz";
|
||||
my $diff_name = "rsync-$lastversion-$version.diffs.gz";
|
||||
my $srctar_file = "$dest/$srctar_name";
|
||||
my $pattar_file = "$dest/$pattar_name";
|
||||
my $diff_file = "$dest/$diff_name";
|
||||
my $lasttar_file = "$dest/rsync-$lastversion.tar.gz";
|
||||
my $srctar_file = "$dest/$srcdir/$srctar_name";
|
||||
my $pattar_file = "$dest/$srcdir/$pattar_name";
|
||||
my $diff_file = "$dest/$srcdiffdir/$diff_name";
|
||||
my $news_file = "$dest/$srcdir/rsync-$version-NEWS";
|
||||
my $lasttar_file = "$dest/$lastsrcdir/rsync-$lastversion.tar.gz";
|
||||
|
||||
print $break, <<EOT;
|
||||
|
||||
About to:
|
||||
- commit all changes
|
||||
- tag this release as v$version
|
||||
- move the old tar/diff files into the appropriate old-* dirs
|
||||
- hard-link the moved tar/diff files on samba.org
|
||||
- create release tar, "$srctar_name"
|
||||
- create patches tar, "$pattar_name"
|
||||
- commit all version changes
|
||||
- merge the master branch into the patch/* branches
|
||||
- update the files in the "patches" dir and OPTIONALLY
|
||||
(if you type 'y') to launch a shell for each patch
|
||||
|
||||
EOT
|
||||
print "<Press Enter OR 'y' to continue> ";
|
||||
my $ans = <STDIN>;
|
||||
|
||||
system "git commit -a -m 'Preparing for release of $version'" and exit 1;
|
||||
|
||||
print "Updating files in \"patches\" dir ...\n";
|
||||
system "packaging/patch-update";
|
||||
|
||||
if ($ans =~ /^y/i) {
|
||||
print "\nVisiting all \"patch/*\" branches ...\n";
|
||||
system "packaging/patch-update --shell";
|
||||
}
|
||||
|
||||
print $break, <<EOT;
|
||||
|
||||
About to:
|
||||
- create signed tag for this release: v$version
|
||||
- create release diffs, "$diff_name"
|
||||
- update patch branches and generate patch/* files
|
||||
- update README, *NEWS, TODO, and changelog
|
||||
- update rsync*.html man pages
|
||||
- create release tar, "$srctar_name"
|
||||
- generate rsync-$version/patches/* files
|
||||
- create patches tar, "$pattar_name"
|
||||
- update top-level README, *NEWS, TODO, and ChangeLog
|
||||
- update top-level rsync*.html manpages
|
||||
- gpg-sign the release files
|
||||
- update hard-linked top-level release files$skipping
|
||||
|
||||
EOT
|
||||
print "<Press Enter to continue> ";
|
||||
$_ = <STDIN>;
|
||||
|
||||
system "git commit -a -m 'Preparing for release of $version'" and exit 1;
|
||||
system "git tag -s -m 'Version $version.' v$version" and exit 1;
|
||||
my $passphrase;
|
||||
while (1) {
|
||||
ReadMode('noecho');
|
||||
print "\nEnter your GPG pass-phrase: ";
|
||||
chomp($passphrase = <STDIN>);
|
||||
ReadMode(0);
|
||||
print "\n";
|
||||
|
||||
# Extract some files from the old tar before we do the shuffle.
|
||||
# Briefly create a temp file with the passphrase for git's tagging use.
|
||||
my $oldmask = umask 077;
|
||||
unlink($passfile);
|
||||
open(OUT, '>', $passfile) or die $!;
|
||||
print OUT $passphrase, "\n";
|
||||
close OUT;
|
||||
umask $oldmask;
|
||||
$ENV{'GPG_PASSFILE'} = $passfile;
|
||||
|
||||
# We want to use our passphrase-providing "gpg" script, so modify the PATH.
|
||||
$ENV{PATH} = "packaging/bin:$path";
|
||||
$_ = `git tag -s -m 'Version $version.' v$version 2>&1`;
|
||||
$ENV{PATH} = $path;
|
||||
unlink($passfile);
|
||||
print $_;
|
||||
next if /bad passphrase/;
|
||||
last unless /failed/;
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# Extract the generated files from the old tar.
|
||||
@_ = @extra_files;
|
||||
map { s#^#rsync-$lastversion/# } @_;
|
||||
system "tar xzf $lasttar_file @_";
|
||||
rename("rsync-$lastversion", 'a');
|
||||
|
||||
# When creating a pre-release after a normal release, there's nothing to move.
|
||||
if ($diffdir ne $dest) {
|
||||
chdir($dest) or die $!;
|
||||
|
||||
print "Shuffling old files ...\n";
|
||||
|
||||
# We need to run this regardless of $lastversion's "pre"ness.
|
||||
my @moved_files;
|
||||
foreach my $fn (glob('rsync*pre*.tar.gz*'), glob('rsync*pre*-NEWS')) {
|
||||
link($fn, "old-previews/$fn") or die $!;
|
||||
push(@moved_files, $fn);
|
||||
}
|
||||
|
||||
if ($version !~ /pre/) {
|
||||
foreach my $fn (glob('rsync*.tar.gz*'), glob('rsync*-NEWS')) {
|
||||
next if $fn =~ /^rsync.*pre/;
|
||||
link($fn, "old-versions/$fn") or die $!;
|
||||
push(@moved_files, $fn);
|
||||
}
|
||||
|
||||
foreach my $fn (glob('rsync*pre*.diffs.gz*')) {
|
||||
unlink($fn);
|
||||
}
|
||||
|
||||
foreach my $fn (glob('rsync*.diffs.gz*')) {
|
||||
link($fn, "old-patches/$fn") or die $!;
|
||||
push(@moved_files, $fn);
|
||||
}
|
||||
}
|
||||
|
||||
# Optimize our future upload (in the absence of --detect-renamed) by
|
||||
# using rsync to hard-link the above files on samba.org.
|
||||
system "rsync -avHOC --include='rsync*.gz*' --include='old-*/' --exclude='*' . samba.org:/home/ftp/pub/rsync";
|
||||
foreach (@moved_files) {
|
||||
unlink($_);
|
||||
}
|
||||
|
||||
chdir($curdir) or die $!;
|
||||
}
|
||||
|
||||
print "Creating $diff_file ...\n";
|
||||
system "make gen; rsync -a @extra_files b/";
|
||||
system "./config.status Makefile; make gen; rsync -a @extra_files b/";
|
||||
my $sed_script = 's:^((---|\+\+\+) [ab]/[^\t]+)\t.*:\1:';
|
||||
system "(git diff v$lastversion v$version; diff -up a b | sed -r '$sed_script') | gzip -9 >$diff_file";
|
||||
system "(git diff v$lastversion v$version; diff -upN a b | sed -r '$sed_script') | gzip -9 >$diff_file";
|
||||
system "rm -rf a";
|
||||
rename('b', "rsync-$version");
|
||||
|
||||
@@ -250,25 +302,44 @@ system "git archive --format=tar --prefix=rsync-$version/ v$version | tar xf -";
|
||||
system "support/git-set-file-times --prefix=rsync-$version/";
|
||||
system "fakeroot tar czf $srctar_file rsync-$version; rm -rf rsync-$version";
|
||||
|
||||
system "support/patch-update --gen";
|
||||
print "Updating files in \"rsync-$version/patches\" dir ...\n";
|
||||
mkdir("rsync-$version", 0755);
|
||||
mkdir("rsync-$version/patches", 0755);
|
||||
system "packaging/patch-update --skip-check --gen=rsync-$version/patches";
|
||||
|
||||
symlink('.', "rsync-$version");
|
||||
system "fakeroot tar czf $pattar_file rsync-$version/patches";
|
||||
unlink("rsync-$version");
|
||||
print "Creating $pattar_file ...\n";
|
||||
system "fakeroot tar chzf $pattar_file rsync-$version/patches; rm -rf rsync-$version";
|
||||
|
||||
print "Updating the other files in $dest ...\n";
|
||||
system "rsync -a README NEWS OLDNEWS TODO $dest";
|
||||
unlink("$dest/rsync-$version-NEWS");
|
||||
link("$dest/NEWS", "$dest/rsync-$version-NEWS");
|
||||
system "git log --name-status | gzip -9 >$dest/changelog.gz";
|
||||
unlink($news_file);
|
||||
link("$dest/NEWS", $news_file);
|
||||
system "git log --name-status | gzip -9 >$dest/ChangeLog.gz";
|
||||
|
||||
system "yodl2html -o $dest/rsync.html rsync.yo";
|
||||
system "yodl2html -o $dest/rsyncd.conf.html rsyncd.conf.yo";
|
||||
|
||||
chdir($dest) or die $!;
|
||||
system "gpg -ba $srctar_name; gpg -ba $pattar_name; gpg -ba $diff_name";
|
||||
print $break, <<EOT;
|
||||
foreach my $fn ($srctar_file, $pattar_file, $diff_file) {
|
||||
unlink("$fn.asc");
|
||||
open(GPG, '|-', "gpg --batch --passphrase-fd=0 -ba $fn") or die $!;
|
||||
print GPG $passphrase, "\n";
|
||||
close GPG;
|
||||
}
|
||||
|
||||
All done. Remember to announce the release on *BOTH*
|
||||
rsync-announce\@lists.samba.org and rsync\@lists.samba.org!
|
||||
if (!$pre) {
|
||||
system "rm $dest/rsync-*.gz $dest/rsync-*.asc $dest/rsync-*-NEWS $dest/src-previews/rsync-*diffs.gz*";
|
||||
|
||||
foreach my $fn ($srctar_file, "$srctar_file.asc",
|
||||
$pattar_file, "$pattar_file.asc",
|
||||
$diff_file, "$diff_file.asc", $news_file) {
|
||||
(my $top_fn = $fn) =~ s#/src(-\w+)?/#/#;
|
||||
link($fn, $top_fn);
|
||||
}
|
||||
}
|
||||
|
||||
print $break, <<'EOT';
|
||||
|
||||
Local changes are done. When you're satisfied, push the git repository
|
||||
and rsync the release files. Remember to announce the release on *BOTH*
|
||||
rsync-announce@lists.samba.org and rsync@lists.samba.org (and the web)!
|
||||
EOT
|
||||
|
||||
14
pipe.c
14
pipe.c
@@ -4,7 +4,7 @@
|
||||
* Copyright (C) 1996-2000 Andrew Tridgell
|
||||
* Copyright (C) 1996 Paul Mackerras
|
||||
* Copyright (C) 2001, 2002 Martin Pool <mbp@samba.org>
|
||||
* Copyright (C) 2004-2007 Wayne Davison
|
||||
* Copyright (C) 2004-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -133,6 +133,12 @@ pid_t local_child(int argc, char **argv, int *f_in, int *f_out,
|
||||
filesfrom_fd = -1;
|
||||
chmod_modes = NULL; /* Let the sending side handle this. */
|
||||
|
||||
/* Let the client side handle this. */
|
||||
if (logfile_name) {
|
||||
logfile_name = NULL;
|
||||
logfile_close();
|
||||
}
|
||||
|
||||
if (dup2(to_child_pipe[0], STDIN_FILENO) < 0 ||
|
||||
close(to_child_pipe[1]) < 0 ||
|
||||
close(from_child_pipe[0]) < 0 ||
|
||||
@@ -150,12 +156,6 @@ pid_t local_child(int argc, char **argv, int *f_in, int *f_out,
|
||||
child_main(argc, argv);
|
||||
}
|
||||
|
||||
/* Let the client side handle this. */
|
||||
if (logfile_name) {
|
||||
logfile_name = NULL;
|
||||
logfile_close();
|
||||
}
|
||||
|
||||
if (close(from_child_pipe[1]) < 0 ||
|
||||
close(to_child_pipe[0]) < 0) {
|
||||
rsyserr(FERROR, errno, "Failed to close");
|
||||
|
||||
@@ -809,16 +809,20 @@ int poptGetNextOpt(poptContext con)
|
||||
*oe++ = '\0';
|
||||
/* XXX longArg is mapped back to persistent storage. */
|
||||
longArg = origOptString + (oe - localOptString);
|
||||
}
|
||||
} else
|
||||
oe = NULL;
|
||||
|
||||
opt = findOption(con->options, optString, '\0', &cb, &cbData,
|
||||
singleDash);
|
||||
if (!opt && !singleDash)
|
||||
return POPT_ERROR_BADOPT;
|
||||
if (!opt && oe)
|
||||
oe[-1] = '='; /* restore overwritten '=' */
|
||||
}
|
||||
|
||||
if (!opt) {
|
||||
con->os->nextCharArg = origOptString + 1;
|
||||
longArg = NULL;
|
||||
} else {
|
||||
if (con->os == con->optionStack &&
|
||||
opt->argInfo & POPT_ARGFLAG_STRIP)
|
||||
@@ -856,7 +860,7 @@ int poptGetNextOpt(poptContext con)
|
||||
|
||||
origOptString++;
|
||||
if (*origOptString != '\0')
|
||||
con->os->nextCharArg = origOptString;
|
||||
con->os->nextCharArg = origOptString + (*origOptString == '=');
|
||||
}
|
||||
/*@=branchstate@*/
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ getArgDescrip(const struct poptOption * opt,
|
||||
if (opt->argDescrip) return D_(translation_domain, opt->argDescrip);
|
||||
|
||||
switch (opt->argInfo & POPT_ARG_MASK) {
|
||||
case POPT_ARG_NONE: return POPT_("NONE");
|
||||
/*case POPT_ARG_NONE: return POPT_("NONE");*/ /* impossible */
|
||||
#ifdef DYING
|
||||
case POPT_ARG_VAL: return POPT_("VAL");
|
||||
#else
|
||||
@@ -767,6 +767,9 @@ static int showShortOptions(const struct poptOption * opt, FILE * fp,
|
||||
char * s = (str != NULL ? str : memset(alloca(300), 0, 300));
|
||||
int len = 0;
|
||||
|
||||
if (s == NULL)
|
||||
return 0;
|
||||
|
||||
/*@-boundswrite@*/
|
||||
if (opt != NULL)
|
||||
for (; (opt->longName || opt->shortName || opt->arg); opt++) {
|
||||
|
||||
@@ -163,8 +163,10 @@ int poptConfigFileToString(FILE *fp, char ** argstrp, /*@unused@*/ UNUSED(int fl
|
||||
p++;
|
||||
|
||||
linelen = strlen(p);
|
||||
if (linelen >= maxlinelen-1)
|
||||
if (linelen >= maxlinelen-1) {
|
||||
free(argstr);
|
||||
return POPT_ERROR_OVERFLOW; /* XXX line too long */
|
||||
}
|
||||
|
||||
if (*p == '\0' || *p == '\n') continue; /* line is empty */
|
||||
if (*p == '#') continue; /* comment line */
|
||||
|
||||
@@ -1,22 +1,51 @@
|
||||
#!/bin/sh
|
||||
# Use autoconf and autoheader to create configure.sh and config.h.in.
|
||||
# If unsuccessful and the "fetch" option was provided, grab the latest
|
||||
# development versions of these files (only useful with a dev checkout).
|
||||
# Either use autoconf and autoheader to create configure.sh and config.h.in
|
||||
# or (optionally) fetch the latest development versions of generated files.
|
||||
#
|
||||
# Specify one action or more than one to provide a fall-back:
|
||||
#
|
||||
# build build the config files [the default w/no arg]
|
||||
# fetch fetch the latest dev config files
|
||||
# fetchgen fetch all the latest dev generated files
|
||||
# fetchSRC fetch the latest dev source files [NON-GENERATED FILES]
|
||||
#
|
||||
# The script stops after the first successful action.
|
||||
|
||||
dir=`dirname $0`
|
||||
if test x"$dir" != x -a x"$dir" != x.; then
|
||||
cd "$dir"
|
||||
fi
|
||||
if make -f prepare-source.mak; then
|
||||
:
|
||||
elif test x"$1" = x"fetch"; then
|
||||
if perl --version >/dev/null 2>/dev/null; then
|
||||
files='c*'
|
||||
else
|
||||
files='[cp]*'
|
||||
fi
|
||||
rsync -pvz rsync://rsync.samba.org/rsyncftp/generated-files/"$files" .
|
||||
elif test x"$1" = x"fetchall"; then
|
||||
rsync -pvz rsync://rsync.samba.org/rsyncftp/generated-files/'*' .
|
||||
else
|
||||
exit 1
|
||||
|
||||
if test $# = 0; then
|
||||
set -- build
|
||||
fi
|
||||
|
||||
for action in "${@}"; do
|
||||
case "$action" in
|
||||
build|make)
|
||||
make -f prepare-source.mak
|
||||
;;
|
||||
fetch)
|
||||
if perl --version >/dev/null 2>/dev/null; then
|
||||
files='c*'
|
||||
else
|
||||
files='[cp]*'
|
||||
fi
|
||||
rsync -pvz rsync://rsync.samba.org/rsyncftp/generated-files/"$files" .
|
||||
;;
|
||||
fetchgen)
|
||||
rsync -pvz rsync://rsync.samba.org/rsyncftp/generated-files/'*' .
|
||||
;;
|
||||
fetchSRC)
|
||||
rsync -pvrz --exclude=/.git/ rsync://rsync.samba.org/ftp/pub/unpacked/rsync/ .
|
||||
;;
|
||||
*)
|
||||
echo "Unknown action: $action"
|
||||
exit 1
|
||||
esac
|
||||
if test $? = 0; then
|
||||
exit
|
||||
fi
|
||||
done
|
||||
|
||||
exit 1
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Copyright (C) 1996-2000 Andrew Tridgell
|
||||
* Copyright (C) 1996 Paul Mackerras
|
||||
* Copyright (C) 2001, 2002 Martin Pool <mbp@samba.org>
|
||||
* Copyright (C) 2003-2007 Wayne Davison
|
||||
* Copyright (C) 2003-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -40,6 +40,8 @@ struct progress_history {
|
||||
OFF_T ofs;
|
||||
};
|
||||
|
||||
int progress_is_active = 0;
|
||||
|
||||
static struct progress_history ph_start;
|
||||
static struct progress_history ph_list[PROGRESS_HISTORY_SECS];
|
||||
static int newest_hpos, oldest_hpos;
|
||||
@@ -109,8 +111,11 @@ static void rprint_progress(OFF_T ofs, OFF_T size, struct timeval *now,
|
||||
stats.num_transferred_files,
|
||||
stats.num_files - current_file_index - 1,
|
||||
stats.num_files);
|
||||
} else
|
||||
progress_is_active = 0;
|
||||
} else {
|
||||
strlcpy(eol, "\r", sizeof eol);
|
||||
progress_is_active = 1;
|
||||
}
|
||||
rprintf(FCLIENT, "%12s %3d%% %7.2f%s %s%s",
|
||||
human_num(ofs), pct, rate, units, rembuf, eol);
|
||||
}
|
||||
|
||||
68
receiver.c
68
receiver.c
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (C) 1996-2000 Andrew Tridgell
|
||||
* Copyright (C) 1996 Paul Mackerras
|
||||
* Copyright (C) 2003-2007 Wayne Davison
|
||||
* Copyright (C) 2003-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -55,7 +55,7 @@ extern char *tmpdir;
|
||||
extern char *partial_dir;
|
||||
extern char *basis_dir[];
|
||||
extern struct file_list *cur_flist, *first_flist, *dir_flist;
|
||||
extern struct filter_list_struct server_filter_list;
|
||||
extern struct filter_list_struct daemon_filter_list;
|
||||
|
||||
static struct bitbag *delayed_bits = NULL;
|
||||
static int phase = 0, redoing = 0;
|
||||
@@ -352,10 +352,11 @@ static int get_next_gen_ndx(int fd, int next_gen_ndx, int desired_ndx)
|
||||
{
|
||||
while (next_gen_ndx < desired_ndx) {
|
||||
if (next_gen_ndx >= 0) {
|
||||
rprintf(FINFO,
|
||||
struct file_struct *file = cur_flist->files[next_gen_ndx];
|
||||
rprintf(FERROR_XFER,
|
||||
"(No batched update for%s \"%s\")\n",
|
||||
redoing ? " resend of" : "",
|
||||
f_name(cur_flist->files[next_gen_ndx], NULL));
|
||||
file->flags & FLAG_FILE_SENT ? " resend of" : "",
|
||||
f_name(file, NULL));
|
||||
}
|
||||
next_gen_ndx = read_int(fd);
|
||||
if (next_gen_ndx == -1) {
|
||||
@@ -488,8 +489,8 @@ int recv_files(int f_in, char *local_name)
|
||||
|
||||
cleanup_got_literal = 0;
|
||||
|
||||
if (server_filter_list.head
|
||||
&& check_filter(&server_filter_list, fname, 0) < 0) {
|
||||
if (daemon_filter_list.head
|
||||
&& check_filter(&daemon_filter_list, FLOG, fname, 0) < 0) {
|
||||
rprintf(FERROR, "attempt to hack rsync failed.\n");
|
||||
exit_cleanup(RERR_PROTOCOL);
|
||||
}
|
||||
@@ -501,7 +502,7 @@ int recv_files(int f_in, char *local_name)
|
||||
continue;
|
||||
}
|
||||
if (write_batch < 0) {
|
||||
log_item(FINFO, file, &stats, iflags, NULL);
|
||||
log_item(FCLIENT, file, &stats, iflags, NULL);
|
||||
if (!am_server)
|
||||
discard_receive_data(f_in, F_LENGTH(file));
|
||||
continue;
|
||||
@@ -554,8 +555,8 @@ int recv_files(int f_in, char *local_name)
|
||||
fnamecmp = fnamecmpbuf;
|
||||
break;
|
||||
}
|
||||
if (!fnamecmp || (server_filter_list.head
|
||||
&& check_filter(&server_filter_list, fname, 0) < 0)) {
|
||||
if (!fnamecmp || (daemon_filter_list.head
|
||||
&& check_filter(&daemon_filter_list, FLOG, fname, 0) < 0)) {
|
||||
fnamecmp = fname;
|
||||
fnamecmp_type = FNAMECMP_FNAME;
|
||||
}
|
||||
@@ -688,26 +689,23 @@ int recv_files(int f_in, char *local_name)
|
||||
}
|
||||
|
||||
if ((recv_ok && (!delay_updates || !partialptr)) || inplace) {
|
||||
char *temp_copy_name;
|
||||
if (partialptr == fname)
|
||||
partialptr = temp_copy_name = NULL;
|
||||
else if (*partial_dir == '/')
|
||||
temp_copy_name = NULL;
|
||||
else
|
||||
temp_copy_name = partialptr;
|
||||
finish_transfer(fname, fnametmp, fnamecmp,
|
||||
temp_copy_name, file, recv_ok, 1);
|
||||
if (fnamecmp == partialptr) {
|
||||
partialptr = NULL;
|
||||
if (!finish_transfer(fname, fnametmp, fnamecmp,
|
||||
partialptr, file, recv_ok, 1))
|
||||
recv_ok = -1;
|
||||
else if (fnamecmp == partialptr) {
|
||||
do_unlink(partialptr);
|
||||
handle_partial_dir(partialptr, PDIR_DELETE);
|
||||
}
|
||||
} else if (keep_partial && partialptr
|
||||
&& handle_partial_dir(partialptr, PDIR_CREATE)) {
|
||||
finish_transfer(partialptr, fnametmp, fnamecmp, NULL,
|
||||
file, recv_ok, !partial_dir);
|
||||
if (delay_updates && recv_ok) {
|
||||
bitbag_set_bit(delayed_bits, ndx);
|
||||
if (!finish_transfer(partialptr, fnametmp, fnamecmp, NULL,
|
||||
file, recv_ok, !partial_dir))
|
||||
recv_ok = -1;
|
||||
else if (delay_updates && recv_ok) {
|
||||
bitbag_set_bit(delayed_bits, ndx);
|
||||
recv_ok = 2;
|
||||
}
|
||||
} else {
|
||||
partialptr = NULL;
|
||||
@@ -716,13 +714,15 @@ int recv_files(int f_in, char *local_name)
|
||||
|
||||
cleanup_disable();
|
||||
|
||||
if (recv_ok > 0) {
|
||||
switch (recv_ok) {
|
||||
case 1:
|
||||
if (remove_source_files || inc_recurse
|
||||
|| (preserve_hard_links && F_IS_HLINKED(file)))
|
||||
send_msg_int(MSG_SUCCESS, ndx);
|
||||
} else if (!recv_ok) {
|
||||
enum logcode msgtype = redoing || read_batch ? FERROR : FWARNING;
|
||||
if (msgtype == FERROR || verbose) {
|
||||
break;
|
||||
case 0: {
|
||||
enum logcode msgtype = redoing ? FERROR_XFER : FWARNING;
|
||||
if (msgtype == FERROR_XFER || verbose) {
|
||||
char *errstr, *redostr, *keptstr;
|
||||
if (!(keep_partial && partialptr) && !inplace)
|
||||
keptstr = "discarded";
|
||||
@@ -730,22 +730,30 @@ int recv_files(int f_in, char *local_name)
|
||||
keptstr = "put into partial-dir";
|
||||
else
|
||||
keptstr = "retained";
|
||||
if (msgtype == FERROR) {
|
||||
if (msgtype == FERROR_XFER) {
|
||||
errstr = "ERROR";
|
||||
redostr = "";
|
||||
} else {
|
||||
errstr = "WARNING";
|
||||
redostr = " (will try again)";
|
||||
redostr = read_batch ? " (may try again)"
|
||||
: " (will try again)";
|
||||
}
|
||||
rprintf(msgtype,
|
||||
"%s: %s failed verification -- update %s%s.\n",
|
||||
errstr, fname, keptstr, redostr);
|
||||
errstr, local_name ? f_name(file, NULL) : fname,
|
||||
keptstr, redostr);
|
||||
}
|
||||
if (!redoing) {
|
||||
send_msg_int(MSG_REDO, ndx);
|
||||
file->flags |= FLAG_FILE_SENT;
|
||||
} else if (inc_recurse)
|
||||
send_msg_int(MSG_NO_SEND, ndx);
|
||||
break;
|
||||
}
|
||||
case -1:
|
||||
if (inc_recurse)
|
||||
send_msg_int(MSG_NO_SEND, ndx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (make_backups < 0)
|
||||
|
||||
38
rounding.c
Normal file
38
rounding.c
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* A pre-compilation helper program to aid in the creation of rounding.h.
|
||||
*
|
||||
* Copyright (C) 2007-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, visit the http://fsf.org website.
|
||||
*/
|
||||
|
||||
#include "rsync.h"
|
||||
|
||||
#define ARRAY_LEN (EXTRA_ROUNDING+1)
|
||||
#define SIZEOF(x) ((long int)sizeof (x))
|
||||
|
||||
struct test {
|
||||
union file_extras extras[ARRAY_LEN];
|
||||
struct file_struct file;
|
||||
};
|
||||
|
||||
#define ACTUAL_SIZE SIZEOF(struct test)
|
||||
#define EXPECTED_SIZE (SIZEOF(union file_extras) * ARRAY_LEN + SIZEOF(struct file_struct))
|
||||
|
||||
int main(UNUSED(int argc), UNUSED(char *argv[]))
|
||||
{
|
||||
static int test_array[1 - 2 * (ACTUAL_SIZE != EXPECTED_SIZE)];
|
||||
test_array[0] = 0;
|
||||
return 0;
|
||||
}
|
||||
120
rsync.c
120
rsync.c
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (C) 1996 Andrew Tridgell
|
||||
* Copyright (C) 1996 Paul Mackerras
|
||||
* Copyright (C) 2003-2007 Wayne Davison
|
||||
* Copyright (C) 2003-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -205,6 +205,42 @@ int iconvbufs(iconv_t ic, xbuf *in, xbuf *out, int flags)
|
||||
}
|
||||
#endif
|
||||
|
||||
void send_protected_args(int fd, char *args[])
|
||||
{
|
||||
int i;
|
||||
#ifdef ICONV_OPTION
|
||||
int convert = ic_send != (iconv_t)-1;
|
||||
xbuf outbuf, inbuf;
|
||||
|
||||
if (convert)
|
||||
alloc_xbuf(&outbuf, 1024);
|
||||
#endif
|
||||
|
||||
for (i = 0; args[i]; i++) {} /* find first NULL */
|
||||
args[i] = "rsync"; /* set a new arg0 */
|
||||
if (verbose > 1)
|
||||
print_child_argv("protected args:", args + i + 1);
|
||||
do {
|
||||
#ifdef ICONV_OPTION
|
||||
if (convert) {
|
||||
INIT_XBUF_STRLEN(inbuf, args[i]);
|
||||
iconvbufs(ic_send, &inbuf, &outbuf,
|
||||
ICB_EXPAND_OUT | ICB_INCLUDE_BAD | ICB_INCLUDE_INCOMPLETE);
|
||||
outbuf.buf[outbuf.len] = '\0';
|
||||
write_buf(fd, outbuf.buf, outbuf.len + 1);
|
||||
outbuf.len = 0;
|
||||
} else
|
||||
#endif
|
||||
write_buf(fd, args[i], strlen(args[i]) + 1);
|
||||
} while (args[++i]);
|
||||
write_byte(fd, 0);
|
||||
|
||||
#ifdef ICONV_OPTION
|
||||
if (convert)
|
||||
free(outbuf.buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
int read_ndx_and_attrs(int f_in, int *iflag_ptr, uchar *type_ptr,
|
||||
char *buf, int *len_ptr)
|
||||
{
|
||||
@@ -399,6 +435,8 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
|
||||
}
|
||||
if (ret == 0) /* ret == 1 if symlink could not be set */
|
||||
updated = 1;
|
||||
else
|
||||
file->flags |= FLAG_TIME_FAILED;
|
||||
}
|
||||
|
||||
change_uid = am_root && uid_ndx && sxp->st.st_uid != (uid_t)F_OWNER(file);
|
||||
@@ -422,24 +460,24 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
|
||||
fname, (unsigned)sxp->st.st_gid, F_GROUP(file));
|
||||
}
|
||||
}
|
||||
if (am_root < 0) {
|
||||
;
|
||||
} else if (do_lchown(fname,
|
||||
change_uid ? (uid_t)F_OWNER(file) : sxp->st.st_uid,
|
||||
change_gid ? (gid_t)F_GROUP(file) : sxp->st.st_gid) != 0) {
|
||||
/* shouldn't have attempted to change uid or gid
|
||||
* unless have the privilege */
|
||||
rsyserr(FERROR_XFER, errno, "%s %s failed",
|
||||
change_uid ? "chown" : "chgrp",
|
||||
full_fname(fname));
|
||||
goto cleanup;
|
||||
} else
|
||||
/* a lchown had been done - we have to re-stat if the
|
||||
* destination had the setuid or setgid bits set due
|
||||
* to the side effect of the chown call */
|
||||
if (sxp->st.st_mode & (S_ISUID | S_ISGID)) {
|
||||
link_stat(fname, &sxp->st,
|
||||
keep_dirlinks && S_ISDIR(sxp->st.st_mode));
|
||||
if (am_root >= 0) {
|
||||
if (do_lchown(fname,
|
||||
change_uid ? (uid_t)F_OWNER(file) : sxp->st.st_uid,
|
||||
change_gid ? (gid_t)F_GROUP(file) : sxp->st.st_gid) != 0) {
|
||||
/* We shouldn't have attempted to change uid
|
||||
* or gid unless have the privilege. */
|
||||
rsyserr(FERROR_XFER, errno, "%s %s failed",
|
||||
change_uid ? "chown" : "chgrp",
|
||||
full_fname(fname));
|
||||
goto cleanup;
|
||||
}
|
||||
/* A lchown had been done, so we need to re-stat if
|
||||
* the destination had the setuid or setgid bits set
|
||||
* (due to the side effect of the chown call). */
|
||||
if (sxp->st.st_mode & (S_ISUID | S_ISGID)) {
|
||||
link_stat(fname, &sxp->st,
|
||||
keep_dirlinks && S_ISDIR(sxp->st.st_mode));
|
||||
}
|
||||
}
|
||||
updated = 1;
|
||||
}
|
||||
@@ -504,15 +542,17 @@ RETSIGTYPE sig_int(UNUSED(int val))
|
||||
}
|
||||
|
||||
/* Finish off a file transfer: renaming the file and setting the file's
|
||||
* attributes (e.g. permissions, ownership, etc.). If partialptr is not
|
||||
* NULL and the robust_rename() call is forced to copy the temp file, we
|
||||
* stage the file into the partial-dir and then rename it into place. */
|
||||
void finish_transfer(const char *fname, const char *fnametmp,
|
||||
const char *fnamecmp, const char *partialptr,
|
||||
struct file_struct *file, int ok_to_set_time,
|
||||
int overwriting_basis)
|
||||
* attributes (e.g. permissions, ownership, etc.). If the robust_rename()
|
||||
* call is forced to copy the temp file and partialptr is both non-NULL and
|
||||
* not an absolute path, we stage the file into the partial-dir and then
|
||||
* rename it into place. This returns 1 on succcess or 0 on failure. */
|
||||
int finish_transfer(const char *fname, const char *fnametmp,
|
||||
const char *fnamecmp, const char *partialptr,
|
||||
struct file_struct *file, int ok_to_set_time,
|
||||
int overwriting_basis)
|
||||
{
|
||||
int ret;
|
||||
const char *temp_copy_name = partialptr && *partialptr != '/' ? partialptr : NULL;
|
||||
|
||||
if (inplace) {
|
||||
if (verbose > 2)
|
||||
@@ -521,8 +561,11 @@ void finish_transfer(const char *fname, const char *fnametmp,
|
||||
goto do_set_file_attrs;
|
||||
}
|
||||
|
||||
if (make_backups > 0 && overwriting_basis && !make_backup(fname))
|
||||
return;
|
||||
if (make_backups > 0 && overwriting_basis) {
|
||||
if (!make_backup(fname))
|
||||
return 1;
|
||||
fnamecmp = get_backup_name(fname);
|
||||
}
|
||||
|
||||
/* Change permissions before putting the file into place. */
|
||||
set_file_attrs(fnametmp, file, NULL, fnamecmp,
|
||||
@@ -531,34 +574,39 @@ void finish_transfer(const char *fname, const char *fnametmp,
|
||||
/* move tmp file over real file */
|
||||
if (verbose > 2)
|
||||
rprintf(FINFO, "renaming %s to %s\n", fnametmp, fname);
|
||||
ret = robust_rename(fnametmp, fname, partialptr,
|
||||
ret = robust_rename(fnametmp, fname, temp_copy_name,
|
||||
file->mode & INITACCESSPERMS);
|
||||
if (ret < 0) {
|
||||
rsyserr(FERROR_XFER, errno, "%s %s -> \"%s\"",
|
||||
ret == -2 ? "copy" : "rename",
|
||||
full_fname(fnametmp), fname);
|
||||
do_unlink(fnametmp);
|
||||
return;
|
||||
if (!partialptr || (ret == -2 && temp_copy_name)
|
||||
|| robust_rename(fnametmp, partialptr, NULL,
|
||||
file->mode & INITACCESSPERMS) < 0)
|
||||
do_unlink(fnametmp);
|
||||
return 0;
|
||||
}
|
||||
if (ret == 0) {
|
||||
/* The file was moved into place (not copied), so it's done. */
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
/* The file was copied, so tweak the perms of the copied file. If it
|
||||
* was copied to partialptr, move it into its final destination. */
|
||||
fnametmp = partialptr ? partialptr : fname;
|
||||
fnametmp = temp_copy_name ? temp_copy_name : fname;
|
||||
|
||||
do_set_file_attrs:
|
||||
set_file_attrs(fnametmp, file, NULL, fnamecmp,
|
||||
ok_to_set_time ? 0 : ATTRS_SKIP_MTIME);
|
||||
|
||||
if (partialptr) {
|
||||
if (temp_copy_name) {
|
||||
if (do_rename(fnametmp, fname) < 0) {
|
||||
rsyserr(FERROR_XFER, errno, "rename %s -> \"%s\"",
|
||||
full_fname(fnametmp), fname);
|
||||
} else
|
||||
handle_partial_dir(partialptr, PDIR_DELETE);
|
||||
return 0;
|
||||
}
|
||||
handle_partial_dir(temp_copy_name, PDIR_DELETE);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct file_list *flist_for_ndx(int ndx)
|
||||
|
||||
41
rsync.h
41
rsync.h
@@ -2,7 +2,7 @@
|
||||
* Copyright (C) 1996, 2000 Andrew Tridgell
|
||||
* Copyright (C) 1996 Paul Mackerras
|
||||
* Copyright (C) 2001, 2002 Martin Pool <mbp@samba.org>
|
||||
* Copyright (C) 2003-2007 Wayne Davison
|
||||
* Copyright (C) 2003-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -67,7 +67,8 @@
|
||||
#define FLAG_FILE_SENT (1<<1) /* sender/receiver/generator */
|
||||
#define FLAG_DIR_CREATED (1<<1) /* generator */
|
||||
#define FLAG_CONTENT_DIR (1<<2) /* sender/receiver/generator */
|
||||
#define FLAG_MOUNT_DIR (1<<3) /* sender/generator */
|
||||
#define FLAG_MOUNT_DIR (1<<3) /* sender/generator (dirs only) */
|
||||
#define FLAG_SKIP_HLINK (1<<3) /* receiver/generator (w/FLAG_HLINKED) */
|
||||
#define FLAG_DUPLICATE (1<<4) /* sender */
|
||||
#define FLAG_MISSING_DIR (1<<4) /* generator */
|
||||
#define FLAG_HLINKED (1<<5) /* receiver/generator (checked on all types) */
|
||||
@@ -77,10 +78,12 @@
|
||||
#define FLAG_HLINK_DONE (1<<8) /* receiver/generator (checked on all types) */
|
||||
#define FLAG_LENGTH64 (1<<9) /* sender/receiver/generator */
|
||||
#define FLAG_SKIP_GROUP (1<<10) /* receiver/generator */
|
||||
#define FLAG_TIME_FAILED (1<<11)/* generator */
|
||||
|
||||
/* These flags are passed to functions but not stored. */
|
||||
|
||||
#define FLAG_DIVERT_DIRS (1<<16)/* sender */
|
||||
#define FLAG_DOTDIR_NAME (1<<17)/* sender */
|
||||
|
||||
#define BITS_SET(val,bits) (((val) & (bits)) == (bits))
|
||||
#define BITS_SETnUNSET(val,onbits,offbits) (((val) & ((onbits)|(offbits))) == (onbits))
|
||||
@@ -93,7 +96,7 @@
|
||||
/* This is used when working on a new protocol version in CVS, and should
|
||||
* be a new non-zero value for each CVS change that affects the protocol.
|
||||
* It must ALWAYS be 0 when the protocol goes final! */
|
||||
#define SUBPROTOCOL_VERSION 16
|
||||
#define SUBPROTOCOL_VERSION 0
|
||||
|
||||
/* We refuse to interoperate with versions that are not in this range.
|
||||
* Note that we assume we'll work with later versions: the onus is on
|
||||
@@ -143,8 +146,9 @@
|
||||
|
||||
#define XFLG_FATAL_ERRORS (1<<0)
|
||||
#define XFLG_OLD_PREFIXES (1<<1)
|
||||
#define XFLG_ANCHORED2ABS (1<<2)
|
||||
#define XFLG_ABS_IF_SLASH (1<<3)
|
||||
#define XFLG_ANCHORED2ABS (1<<2) /* leading slash indicates absolute */
|
||||
#define XFLG_ABS_IF_SLASH (1<<3) /* leading or interior slash is absolute */
|
||||
#define XFLG_DIR2WILD3 (1<<4) /* dir/ match gets trailing *** added */
|
||||
|
||||
#define ATTRS_REPORT (1<<0)
|
||||
#define ATTRS_SKIP_MTIME (1<<1)
|
||||
@@ -165,8 +169,9 @@
|
||||
|
||||
/* For use by the itemize_changes code */
|
||||
#define ITEM_REPORT_ATIME (1<<0)
|
||||
#define ITEM_REPORT_CHECKSUM (1<<1)
|
||||
#define ITEM_REPORT_SIZE (1<<2)
|
||||
#define ITEM_REPORT_CHANGE (1<<1)
|
||||
#define ITEM_REPORT_SIZE (1<<2) /* regular files only */
|
||||
#define ITEM_REPORT_TIMEFAIL (1<<2) /* symlinks only */
|
||||
#define ITEM_REPORT_TIME (1<<3)
|
||||
#define ITEM_REPORT_PERMS (1<<4)
|
||||
#define ITEM_REPORT_OWNER (1<<5)
|
||||
@@ -186,11 +191,17 @@
|
||||
#define SIGNIFICANT_ITEM_FLAGS (~(\
|
||||
ITEM_BASIS_TYPE_FOLLOWS | ITEM_XNAME_FOLLOWS | ITEM_LOCAL_CHANGE))
|
||||
|
||||
#define CFN_KEEP_LEADING_DOT_DIR (1<<0)
|
||||
#define CFN_KEEP_DOT_DIRS (1<<0)
|
||||
#define CFN_KEEP_TRAILING_SLASH (1<<1)
|
||||
#define CFN_DROP_TRAILING_DOT_DIR (1<<2)
|
||||
#define CFN_COLLAPSE_DOT_DOT_DIRS (1<<3)
|
||||
|
||||
#define SP_DEFAULT 0
|
||||
#define SP_KEEP_DOT_DIRS (1<<0)
|
||||
|
||||
#define CD_NORMAL 0
|
||||
#define CD_SKIP_CHDIR 1
|
||||
|
||||
/* Log-message categories. FLOG only goes to the log file, not the client;
|
||||
* FCLIENT is the opposite. */
|
||||
enum logcode {
|
||||
@@ -330,10 +341,6 @@ enum msgcode {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GLOB_H
|
||||
#include <glob.h>
|
||||
#endif
|
||||
|
||||
/* these are needed for the uid/gid mapping code */
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
@@ -408,13 +415,13 @@ enum msgcode {
|
||||
#include "lib/pool_alloc.h"
|
||||
|
||||
#ifndef HAVE_ID_T
|
||||
typedef int id_t;
|
||||
typedef unsigned int id_t;
|
||||
#endif
|
||||
#ifndef HAVE_PID_T
|
||||
typedef int pid_t;
|
||||
#endif
|
||||
#ifndef HAVE_MODE_T
|
||||
typedef int mode_t;
|
||||
typedef unsigned int mode_t;
|
||||
#endif
|
||||
#ifndef HAVE_OFF_T
|
||||
typedef long off_t;
|
||||
@@ -540,6 +547,7 @@ struct hashtable {
|
||||
void *nodes;
|
||||
int32 size, entries;
|
||||
uint32 node_size;
|
||||
int key64;
|
||||
};
|
||||
|
||||
struct ht_int32_node {
|
||||
@@ -1103,6 +1111,11 @@ size_t strlcat(char *d, const char *s, size_t bufsize);
|
||||
#define MY_GID() getgid()
|
||||
#endif
|
||||
|
||||
#ifdef FORCE_FD_ZERO_MEMSET
|
||||
#undef FD_ZERO
|
||||
#define FD_ZERO(fdsetp) memset(fdsetp, 0, sizeof (fd_set))
|
||||
#endif
|
||||
|
||||
extern int verbose;
|
||||
|
||||
#ifndef HAVE_INET_NTOP
|
||||
|
||||
142
rsync.yo
142
rsync.yo
@@ -1,5 +1,5 @@
|
||||
mailto(rsync-bugs@samba.org)
|
||||
manpage(rsync)(1)(16 Dec 2007)()()
|
||||
manpage(rsync)(1)(17 May 2008)()()
|
||||
manpagename(rsync)(a fast, versatile, remote (and local) file-copying tool)
|
||||
manpagesynopsis()
|
||||
|
||||
@@ -528,7 +528,7 @@ either a changed size or a changed checksum are selected for transfer.
|
||||
|
||||
Note that rsync always verifies that each em(transferred) file was
|
||||
correctly reconstructed on the receiving side by checking a whole-file
|
||||
checksum that is generated when as the file is transferred, but that
|
||||
checksum that is generated as the file is transferred, but that
|
||||
automatic after-the-transfer verification has nothing to do with this
|
||||
option's before-the-transfer "Does this file need to be updated?" check.
|
||||
|
||||
@@ -697,13 +697,25 @@ date is on the objects. In other words, if the source has a directory
|
||||
where the destination has a file, the transfer would occur regardless of
|
||||
the timestamps.
|
||||
|
||||
dit(bf(--inplace)) This causes rsync not to create a new copy of the file
|
||||
and then move it into place. Instead rsync will overwrite the existing
|
||||
file, meaning that the rsync algorithm can't accomplish the full amount of
|
||||
network reduction it might be able to otherwise (since it does not yet try
|
||||
to sort data matches). One exception to this is if you combine the option
|
||||
with bf(--backup), since rsync is smart enough to use the backup file as the
|
||||
basis file for the transfer.
|
||||
dit(bf(--inplace)) This option changes how rsync transfers a file when the
|
||||
file's data needs to be updated: instead of the default method of creating
|
||||
a new copy of the file and moving it into place when it is complete, rsync
|
||||
instead writes the updated data directly to the destination file.
|
||||
|
||||
This has several effects: (1) in-use binaries cannot be updated (either the
|
||||
OS will prevent this from happening, or binaries that attempt to swap-in
|
||||
their data will misbehave or crash), (2) the file's data will be in an
|
||||
inconsistent state during the transfer, (3) a file's data may be left in an
|
||||
inconsistent state after the transfer if the transfer is interrupted or if
|
||||
an update fails, (4) a file that does not have write permissions can not be
|
||||
updated, and (5) the efficiency of rsync's delta-transfer algorithm may be
|
||||
reduced if some data in the destination file is overwritten before it can
|
||||
be copied to a position later in the file (one exception to this is if you
|
||||
combine this option with bf(--backup), since rsync is smart enough to use
|
||||
the backup file as the basis file for the transfer).
|
||||
|
||||
WARNING: you should not use this option to update files that are being
|
||||
accessed by others, so be careful when choosing to use this for a copy.
|
||||
|
||||
This option is useful for transfer of large files with block-based changes
|
||||
or appended data, and also on systems that are disk bound, not network
|
||||
@@ -714,18 +726,15 @@ the file), but conflicts with bf(--partial-dir) and bf(--delay-updates).
|
||||
Prior to rsync 2.6.4 bf(--inplace) was also incompatible with bf(--compare-dest)
|
||||
and bf(--link-dest).
|
||||
|
||||
WARNING: The file's data will be in an inconsistent state during the
|
||||
transfer (and possibly afterward if the transfer gets interrupted), so you
|
||||
should not use this option to update files that are in use. Also note that
|
||||
rsync will be unable to update a file in-place that is not writable by the
|
||||
receiving user.
|
||||
|
||||
dit(bf(--append)) This causes rsync to update a file by appending data onto
|
||||
the end of the file, which presumes that the data that already exists on
|
||||
the receiving side is identical with the start of the file on the sending
|
||||
side. Any files that are the same size or shorter on the receiving size
|
||||
are skipped. Files that do not yet exist on the receiving side are also
|
||||
sent, since they are considered to have 0 length. Implies bf(--inplace),
|
||||
side. If a file needs to be transferred and its size on the receiver is
|
||||
the same or longer than the size on the sender, the file is skipped. This
|
||||
does not interfere with the updating of a file's non-content attributes
|
||||
(e.g. permissions, ownership, etc.) when the file does not need to be
|
||||
transferred, nor does it affect the updating of any non-regular files.
|
||||
Implies bf(--inplace),
|
||||
but does not conflict with bf(--sparse) (since it is always extending a
|
||||
file's length).
|
||||
|
||||
@@ -748,11 +757,15 @@ bf(--recursive) option, rsync will skip all directories it encounters (and
|
||||
output a message to that effect for each one). If you specify both
|
||||
bf(--dirs) and bf(--recursive), bf(--recursive) takes precedence.
|
||||
|
||||
This option is implied by the bf(--list-only) option (including an implied
|
||||
The bf(--dirs) option is implied by the bf(--files-from) option
|
||||
or the bf(--list-only) option (including an implied
|
||||
bf(--list-only) usage) if bf(--recursive) wasn't specified (so that
|
||||
directories are seen in the listing). Specify bf(--no-dirs) (or bf(--no-d))
|
||||
if you want to override this. This option is also implied by
|
||||
bf(--files-from).
|
||||
if you want to turn this off.
|
||||
|
||||
There is also a backward-compatibility helper option, bf(--old-dirs) (or
|
||||
bf(--old-d)) that tells rsync to use a hack of "-r --exclude='/*/*'" to get
|
||||
an older rsync to list a single directory without recursing.
|
||||
|
||||
dit(bf(-l, --links)) When symlinks are encountered, recreate the
|
||||
symlink on the destination.
|
||||
@@ -817,11 +830,24 @@ the transfer and link together the corresponding files on the receiving
|
||||
side. Without this option, hard-linked files in the transfer are treated
|
||||
as though they were separate files.
|
||||
|
||||
Note that rsync can only detect hard links if both parts of the link
|
||||
are in the list of files being sent.
|
||||
When you are updating a non-empty destination, this option only ensures
|
||||
that files that are hard-linked together on the source are hard-linked
|
||||
together on the destination. It does NOT currently endeavor to break
|
||||
already existing hard links on the destination that do not exist between
|
||||
the source files. Note, however, that if one or more extra-linked files
|
||||
have content changes, they will become unlinked when updated (assuming you
|
||||
are not using the bf(--inplace) option).
|
||||
|
||||
Note that rsync can only detect hard links between files that are inside
|
||||
the transfer set. If rsync updates a file that has extra hard-link
|
||||
connections to files outside the transfer, that linkage will be broken. If
|
||||
you are tempted to use the bf(--inplace) option to avoid this breakage, be
|
||||
very careful that you know how your files are being updated so that you are
|
||||
certain that no unintended changes happen due to lingering hard links (and
|
||||
see the bf(--inplace) option for more caveats).
|
||||
|
||||
If incremental recursion is active (see bf(--recursive)), rsync may transfer
|
||||
a missing hard-linked file before it finds that another link for the file
|
||||
a missing hard-linked file before it finds that another link for that contents
|
||||
exists elsewhere in the hierarchy. This does not affect the accuracy of
|
||||
the transfer, just its efficiency. One way to avoid this is to disable
|
||||
incremental recursion using the bf(--no-inc-recursive) option.
|
||||
@@ -966,7 +992,7 @@ with the files and update them on the remote system. Note that if this
|
||||
option is not used, the optimization that excludes files that have not been
|
||||
modified cannot be effective; in other words, a missing bf(-t) or bf(-a) will
|
||||
cause the next transfer to behave as if it used bf(-I), causing all files to be
|
||||
updated (though the rsync algorithm will make the update fairly efficient
|
||||
updated (though rsync's delta-transfer algorithm will make the update fairly efficient
|
||||
if the files haven't actually changed, you're much better off using bf(-t)).
|
||||
|
||||
dit(bf(-O, --omit-dir-times)) This tells rsync to omit directories when
|
||||
@@ -1038,7 +1064,7 @@ the "bytes sent", "bytes received", "literal data", and "matched data"
|
||||
statistics are too small, and the "speedup" value is equivalent to a run
|
||||
where no file transfers are needed.
|
||||
|
||||
dit(bf(-W, --whole-file)) With this option the delta-transfer algorithm
|
||||
dit(bf(-W, --whole-file)) With this option rsync's delta-transfer algorithm
|
||||
is not used and the whole file is sent as-is instead. The transfer may be
|
||||
faster if this option is used when the bandwidth between the source and
|
||||
destination machines is higher than the bandwidth to disk (especially when the
|
||||
@@ -1205,7 +1231,7 @@ transferring small, junk files.
|
||||
See the bf(--max-size) option for a description of SIZE.
|
||||
|
||||
dit(bf(-B, --block-size=BLOCKSIZE)) This forces the block size used in
|
||||
the rsync algorithm to a fixed value. It is normally selected based on
|
||||
rsync's delta-transfer algorithm to a fixed value. It is normally selected based on
|
||||
the size of each file being updated. See the technical report for details.
|
||||
|
||||
dit(bf(-e, --rsh=COMMAND)) This option allows you to choose an alternative
|
||||
@@ -1293,7 +1319,10 @@ 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 bf(--filter) options on the command line as you like
|
||||
to build up the list of files to exclude.
|
||||
to build up the list of files to exclude. If the filter contains whitespace,
|
||||
be sure to quote it so that the shell gives the rule to rsync as a single
|
||||
argument. The text below also mentions that you can use an underscore to
|
||||
replace the space that separates a rule from its arg.
|
||||
|
||||
See the FILTER RULES section for detailed information on this option.
|
||||
|
||||
@@ -1406,7 +1435,7 @@ characters are not translated (such as ~, $, ;, &, etc.). Wildcards are
|
||||
expanded on the remote host by rsync (instead of the shell doing it).
|
||||
|
||||
If you use this option with bf(--iconv), the args will also be translated
|
||||
from the local to the remote character set. The translation happens before
|
||||
from the local to the remote character-set. The translation happens before
|
||||
wild-cards are expanded. See also the bf(--files-from) option.
|
||||
|
||||
dit(bf(-T, --temp-dir=DIR)) This option instructs rsync to use DIR as a
|
||||
@@ -1416,7 +1445,7 @@ file in the same directory as the associated destination file.
|
||||
|
||||
This option is most often used when the receiving disk partition does not
|
||||
have enough free space to hold a copy of the largest file in the transfer.
|
||||
In this case (i.e. when the scratch directory in on a different disk
|
||||
In this case (i.e. when the scratch directory is on a different disk
|
||||
partition), rsync will not be able to rename each received temporary file
|
||||
over the top of the associated destination file, but instead must copy it
|
||||
into place. Rsync does this by copying the file over the top of the
|
||||
@@ -1640,6 +1669,8 @@ quote(itemization(
|
||||
bf(--hard-links)).
|
||||
it() A bf(.) means that the item is not being updated (though it might
|
||||
have attributes that are being modified).
|
||||
it() A bf(*) means that the rest of the itemized-output area contains
|
||||
a message (e.g. "deleting").
|
||||
))
|
||||
|
||||
The file-types that replace the bf(X) are: bf(f) for a file, a bf(d) for a
|
||||
@@ -1656,26 +1687,29 @@ a "?" (this can happen when talking to an older rsync).
|
||||
The attribute that is associated with each letter is as follows:
|
||||
|
||||
quote(itemization(
|
||||
it() A bf(c) means the checksum of the file is different and will be
|
||||
updated by the file transfer (requires bf(--checksum)).
|
||||
it() A bf(s) means the size of the file is different and will be updated
|
||||
it() A bf(c) means either that a regular file has a different checksum
|
||||
(requires bf(--checksum)) or that a symlink, device, or special file has
|
||||
a changed value.
|
||||
Note that if you are sending files to an rsync prior to 3.0.1, this
|
||||
change flag will be present only for checksum-differing regular files.
|
||||
it() A bf(s) means the size of a regular file is different and will be updated
|
||||
by the file transfer.
|
||||
it() A bf(t) means the modification time is different and is being updated
|
||||
to the sender's value (requires bf(--times)). An alternate value of bf(T)
|
||||
means that the modification time will be set to the transfer time, which happens
|
||||
anytime a symlink is transferred, or when a regular file or device is
|
||||
transferred without bf(--times).
|
||||
when a file/symlink/device is updated without bf(--times) and when a
|
||||
symlink is changed and the receiver can't set its time.
|
||||
(Note: when using an rsync 3.0.0 client, you might see the bf(s) flag combined
|
||||
with bf(t) instead of the proper bf(T) flag for this time-setting failure.)
|
||||
it() A bf(p) means the permissions are different and are being updated to
|
||||
the sender's value (requires bf(--perms)).
|
||||
it() An bf(o) means the owner is different and is being updated to the
|
||||
sender's value (requires bf(--owner) and super-user privileges).
|
||||
it() A bf(g) means the group is different and is being updated to the
|
||||
sender's value (requires bf(--group) and the authority to set the group).
|
||||
it() The bf(u) slot is reserved for reporting update (access) time changes
|
||||
(a feature that is not yet released).
|
||||
it() The bf(u) slot is reserved for future use.
|
||||
it() The bf(a) means that the ACL information changed.
|
||||
it() The bf(x) slot is reserved for reporting extended attribute changes
|
||||
(a feature that is not yet released).
|
||||
it() The bf(x) means that the extended attribute information changed.
|
||||
))
|
||||
|
||||
One other output is possible: when deleting files, the "%i" will output
|
||||
@@ -1731,14 +1765,14 @@ For a list of the possible escape characters, see the "log format" setting
|
||||
in the rsyncd.conf manpage.
|
||||
|
||||
dit(bf(--stats)) This tells rsync to print a verbose set of statistics
|
||||
on the file transfer, allowing you to tell how effective the rsync
|
||||
on the file transfer, allowing you to tell how effective rsync's delta-transfer
|
||||
algorithm is for your data.
|
||||
|
||||
The current statistics are as follows: quote(itemization(
|
||||
it() bf(Number of files) is the count of all "files" (in the generic
|
||||
sense), which includes directories, symlinks, etc.
|
||||
it() bf(Number of files transferred) is the count of normal files that
|
||||
were updated via the rsync algorithm, which does not include created
|
||||
were updated via rsync's delta-transfer algorithm, which does not include created
|
||||
dirs, symlinks, etc.
|
||||
it() bf(Total file size) is the total sum of all file sizes in the transfer.
|
||||
This does not count any size for directories or special files, but does
|
||||
@@ -1799,7 +1833,7 @@ after it has served its purpose.
|
||||
Note that if bf(--whole-file) is specified (or implied), any partial-dir
|
||||
file that is found for a file that is being updated will simply be removed
|
||||
(since
|
||||
rsync is sending files without using the delta transfer algorithm).
|
||||
rsync is sending files without using rsync's delta-transfer algorithm).
|
||||
|
||||
Rsync will create the em(DIR) if it is missing (just the last dir -- not
|
||||
the whole path). This makes it easy to use a relative path (such as
|
||||
@@ -1917,7 +1951,7 @@ sender's file, which is being reconstructed at a rate of 110.64 kilobytes
|
||||
per second, and the transfer will finish in 4 seconds if the current rate
|
||||
is maintained until the end.
|
||||
|
||||
These statistics can be misleading if the delta transfer algorithm is
|
||||
These statistics can be misleading if rsync's delta-transfer algorithm is
|
||||
in use. For example, if the sender's file consists of the basis file
|
||||
followed by additional data, the reported rate will probably drop
|
||||
dramatically when the receiver gets to the literal data, and the transfer
|
||||
@@ -1944,6 +1978,8 @@ dit(bf(--password-file)) This option allows you to provide a password in a
|
||||
file for accessing an rsync daemon. The file must not be world readable.
|
||||
It should contain just the password as a single line.
|
||||
|
||||
This option does not supply a password to a remote shell transport such as
|
||||
ssh; to learn how to do that, consult the remote shell's documentation.
|
||||
When accessing an rsync daemon using a remote shell as the transport, this
|
||||
option only comes into effect after the remote shell finishes its
|
||||
authentication (i.e. if you have also specified a password in the daemon's
|
||||
@@ -2015,11 +2051,17 @@ dit(bf(--iconv=CONVERT_SPEC)) Rsync can convert filenames between character
|
||||
sets using this option. Using a CONVERT_SPEC of "." tells rsync to look up
|
||||
the default character-set via the locale setting. Alternately, you can
|
||||
fully specify what conversion to do by giving a local and a remote charset
|
||||
separated by a comma (local first), e.g. bf(--iconv=utf8,iso88591).
|
||||
Finally, you can specify a CONVERT_SPEC of "-" to turn off any conversion.
|
||||
separated by a comma in the order bf(--iconv=LOCAL,REMOTE), e.g.
|
||||
bf(--iconv=utf8,iso88591). This order ensures that the option
|
||||
will stay the same whether you're pushing or pulling files.
|
||||
Finally, you can specify either bf(--no-iconv) or a CONVERT_SPEC of "-"
|
||||
to turn off any conversion.
|
||||
The default setting of this option is site-specific, and can also be
|
||||
affected via the RSYNC_ICONV environment variable.
|
||||
|
||||
For a list of what charset names your local iconv library supports, you can
|
||||
run "iconv --list".
|
||||
|
||||
If you specify the bf(--protect-args) option (bf(-s)), rsync will translate
|
||||
the filenames you specify on the command-line that are being sent to the
|
||||
remote host. See also the bf(--files-from) option.
|
||||
@@ -2030,6 +2072,11 @@ specifying matching rules that can match on both sides of the transfer.
|
||||
For instance, you can specify extra include/exclude rules if there are
|
||||
filename differences on the two sides that need to be accounted for.
|
||||
|
||||
When you pass an bf(--iconv) option to an rsync daemon that allows it, the
|
||||
daemon uses the charset specified in its "charset" configuration parameter
|
||||
regardless of the remote charset you actually pass. Thus, you may feel free to
|
||||
specify just the local charset for a daemon transfer (e.g. bf(--iconv=utf8)).
|
||||
|
||||
dit(bf(-4, --ipv4) or bf(-6, --ipv6)) Tells rsync to prefer IPv4/IPv6
|
||||
when creating sockets. This only affects sockets that rsync has direct
|
||||
control over, such as the outgoing socket when directly contacting an
|
||||
@@ -2800,7 +2847,8 @@ rsync daemon. You should set RSYNC_PROXY to a hostname:port pair.
|
||||
dit(bf(RSYNC_PASSWORD)) Setting RSYNC_PASSWORD to the required
|
||||
password allows you to run authenticated rsync connections to an rsync
|
||||
daemon without user intervention. Note that this does not supply a
|
||||
password to a shell transport such as ssh.
|
||||
password to a remote shell transport such as ssh; to learn how to do that,
|
||||
consult the remote shell's documentation.
|
||||
dit(bf(USER) or bf(LOGNAME)) The USER or LOGNAME environment variables
|
||||
are used to determine the default username sent to an rsync daemon.
|
||||
If neither is set, the username defaults to "nobody".
|
||||
@@ -2834,7 +2882,7 @@ url(http://rsync.samba.org/)(http://rsync.samba.org/)
|
||||
|
||||
manpagesection(VERSION)
|
||||
|
||||
This man page is current for version 3.0.0pre7 of rsync.
|
||||
This man page is current for version 3.0.3pre2 of rsync.
|
||||
|
||||
manpagesection(INTERNAL OPTIONS)
|
||||
|
||||
|
||||
311
rsyncd.conf.yo
311
rsyncd.conf.yo
@@ -1,5 +1,5 @@
|
||||
mailto(rsync-bugs@samba.org)
|
||||
manpage(rsyncd.conf)(5)(16 Dec 2007)()()
|
||||
manpage(rsyncd.conf)(5)(17 May 2008)()()
|
||||
manpagename(rsyncd.conf)(configuration file for rsync in daemon mode)
|
||||
manpagesynopsis()
|
||||
|
||||
@@ -69,7 +69,7 @@ Note that you should bf(not) send the rsync daemon a HUP signal to force
|
||||
it to reread the tt(rsyncd.conf) file. The file is re-read on each client
|
||||
connection.
|
||||
|
||||
manpagesection(GLOBAL OPTIONS)
|
||||
manpagesection(GLOBAL PARAMETERS)
|
||||
|
||||
The first parameters in the file (before a [module] header) are the
|
||||
global parameters.
|
||||
@@ -79,12 +79,12 @@ config file in which case the supplied value will override the
|
||||
default for that parameter.
|
||||
|
||||
startdit()
|
||||
dit(bf(motd file)) The "motd file" option allows you to specify a
|
||||
dit(bf(motd file)) This parameter allows you to specify a
|
||||
"message of the day" to display to clients on each connect. This
|
||||
usually contains site information and any legal notices. The default
|
||||
is no motd file.
|
||||
|
||||
dit(bf(pid file)) The "pid file" option tells the rsync daemon to write
|
||||
dit(bf(pid file)) This parameter tells the rsync daemon to write
|
||||
its process ID to that file. If the file already exists, the rsync
|
||||
daemon will abort rather than overwrite the file.
|
||||
|
||||
@@ -96,7 +96,7 @@ dit(bf(address)) You can override the default IP address the daemon
|
||||
will listen on by specifying this value. This is ignored if the daemon is
|
||||
being run by inetd, and is superseded by the bf(--address) command-line option.
|
||||
|
||||
dit(bf(socket options)) This option can provide endless fun for people
|
||||
dit(bf(socket options)) This parameter can provide endless fun for people
|
||||
who like to tune their systems to the utmost degree. You can set all
|
||||
sorts of socket options which may make transfers faster (or
|
||||
slower!). Read the man page for the code(setsockopt()) system call for
|
||||
@@ -107,21 +107,25 @@ bf(--sockopts) command-line option.
|
||||
enddit()
|
||||
|
||||
|
||||
manpagesection(MODULE OPTIONS)
|
||||
manpagesection(MODULE PARAMETERS)
|
||||
|
||||
After the global options you should define a number of modules, each
|
||||
After the global parameters you should define a number of modules, each
|
||||
module exports a directory tree as a symbolic name. Modules are
|
||||
exported by specifying a module name in square brackets [module]
|
||||
followed by the options for that module.
|
||||
followed by the parameters for that module.
|
||||
The module name cannot contain a slash or a closing square bracket. If the
|
||||
name contains whitespace, each internal sequence of whitespace will be
|
||||
changed into a single space, while leading or trailing whitespace will be
|
||||
discarded.
|
||||
|
||||
startdit()
|
||||
|
||||
dit(bf(comment)) The "comment" option specifies a description string
|
||||
dit(bf(comment)) This parameter specifies a description string
|
||||
that is displayed next to the module name when clients obtain a list
|
||||
of available modules. The default is no comment.
|
||||
|
||||
dit(bf(path)) The "path" option specifies the directory in the daemon's
|
||||
filesystem to make available in this module. You must specify this option
|
||||
dit(bf(path)) This parameter specifies the directory in the daemon's
|
||||
filesystem to make available in this module. You must specify this parameter
|
||||
for each module in tt(rsyncd.conf).
|
||||
|
||||
dit(bf(use chroot)) If "use chroot" is true, the rsync daemon will chroot
|
||||
@@ -129,46 +133,71 @@ 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,
|
||||
of not being able to follow symbolic links that are either absolute or outside
|
||||
of the new root path, and of complicating the preservation of usernames and groups
|
||||
(see below). When "use chroot" is false, rsync will: (1) munge symlinks by
|
||||
of the new root path, and of complicating the preservation of users and groups
|
||||
by name (see below).
|
||||
|
||||
As an additional safety feature, you can specify a dot-dir in the module's
|
||||
"path" to indicate the point where the chroot should occur. This allows rsync
|
||||
to run in a chroot with a non-"/" path for the top of the transfer hierarchy.
|
||||
Doing this guards against unintended library loading (since those absolute
|
||||
paths will not be inside the transfer hierarchy unless you have used an unwise
|
||||
pathname), and lets you setup libraries for the chroot that are outside of the
|
||||
transfer. For example, specifying "/var/rsync/./module1" will chroot to the
|
||||
"/var/rsync" directory and set the inside-chroot path to "/module1". If you
|
||||
had omitted the dot-dir, the chroot would have used the whole path, and the
|
||||
inside-chroot path would have been "/".
|
||||
|
||||
When "use chroot" is false or the inside-chroot path is not "/", rsync will:
|
||||
(1) munge symlinks by
|
||||
default for security reasons (see "munge symlinks" for a way to turn this
|
||||
off, but only if you trust your users), (2) substitute leading slashes in
|
||||
absolute paths with the module's path (so that options such as
|
||||
bf(--backup-dir), bf(--compare-dest), etc. interpret an absolute path as
|
||||
rooted in the module's "path" dir), and (3) trim ".." path elements from
|
||||
args if rsync believes they would escape the chroot.
|
||||
args if rsync believes they would escape the module hierarchy.
|
||||
The default for "use chroot" is true, and is the safer choice (especially
|
||||
if the module is not read-only).
|
||||
|
||||
In order to preserve usernames and groupnames, rsync needs to be able to
|
||||
When this parameter is enabled, rsync will not attempt to map users and groups
|
||||
by name (by default), but instead copy IDs as though bf(--numeric-ids) had
|
||||
been specified. In order to enable name-mapping, rsync needs to be able to
|
||||
use the standard library functions for looking up names and IDs (i.e.
|
||||
code(getpwuid()), code(getgrgid()), code(getpwname()), and code(getgrnam())). This means a
|
||||
process in the chroot namespace will need to have access to the resources
|
||||
code(getpwuid()), code(getgrgid()), code(getpwname()), and code(getgrnam())).
|
||||
This means the rsync
|
||||
process in the chroot hierarchy will need to have access to the resources
|
||||
used by these library functions (traditionally /etc/passwd and
|
||||
/etc/group). If these resources are not available, rsync will only be
|
||||
able to copy the IDs, just as if the bf(--numeric-ids) option had been
|
||||
specified.
|
||||
/etc/group, but perhaps additional dynamic libraries as well).
|
||||
|
||||
Note that you are free to setup user/group information in the chroot area
|
||||
differently from your normal system. For example, you could abbreviate
|
||||
the list of users and groups. Also, you can protect this information from
|
||||
being downloaded/uploaded by adding an exclude rule to the rsyncd.conf file
|
||||
(e.g. "bf(exclude = /etc/**)"). Note that having the exclusion affect uploads
|
||||
is a relatively new feature in rsync, so make sure your daemon is
|
||||
at least 2.6.3 to effect this. Also note that it is safest to exclude a
|
||||
directory and all its contents combining the rule "/some/dir/" with the
|
||||
rule "/some/dir/**" just to be sure that rsync will not allow deeper
|
||||
access to some of the excluded files inside the directory (rsync tries to
|
||||
do this automatically, but you might as well specify both to be extra
|
||||
sure).
|
||||
If you copy the necessary resources into the module's chroot area, you
|
||||
should protect them through your OS's normal user/group or ACL settings (to
|
||||
prevent the rsync module's user from being able to change them), and then
|
||||
hide them from the user's view via "exclude" (see how in the discussion of
|
||||
that parameter). At that point it will be safe to enable the mapping of users
|
||||
and groups by name using the "numeric ids" daemon parameter (see below).
|
||||
|
||||
dit(bf(munge symlinks)) The "munge symlinks" option tells rsync to modify
|
||||
Note also that you are free to setup custom user/group information in the
|
||||
chroot area that is different from your normal system. For example, you
|
||||
could abbreviate the list of users and groups.
|
||||
|
||||
dit(bf(numeric ids)) Enabling this parameter disables the mapping
|
||||
of users and groups by name for the current daemon module. This prevents
|
||||
the daemon from trying to load any user/group-related files or libraries.
|
||||
This enabling makes the transfer behave as if the client had passed
|
||||
the bf(--numeric-ids) command-line option. By default, this parameter is
|
||||
enabled for chroot modules and disabled for non-chroot modules.
|
||||
|
||||
A chroot-enabled module should not have this parameter enabled unless you've
|
||||
taken steps to ensure that the module has the necessary resources it needs
|
||||
to translate names, and that it is not possible for a user to change those
|
||||
resources.
|
||||
|
||||
dit(bf(munge symlinks)) This parameter tells rsync to modify
|
||||
all incoming symlinks in a way that makes them unusable but recoverable
|
||||
(see below). This should help protect your files from user trickery when
|
||||
your daemon module is writable. The default is disabled when "use chroot"
|
||||
is on and enabled when "use chroot" is off.
|
||||
is on and the inside-chroot path is "/", otherwise it is enabled.
|
||||
|
||||
If you disable this option on a daemon that is not read-only, there
|
||||
If you disable this parameter on a daemon that is not read-only, there
|
||||
are tricks that a user can play with uploaded symlinks to access
|
||||
daemon-excluded items (if your module has any), and, if "use chroot"
|
||||
is off, rsync can even be tricked into showing or changing data that
|
||||
@@ -176,11 +205,12 @@ is outside the module's path (as access-permissions allow).
|
||||
|
||||
The way rsync disables the use of symlinks is to prefix each one with
|
||||
the string "/rsyncd-munged/". This prevents the links from being used
|
||||
as long as that directory does not exist. When this option is enabled,
|
||||
as long as that directory does not exist. When this parameter is enabled,
|
||||
rsync will refuse to run if that path is a directory or a symlink to
|
||||
a directory. When using the "munge symlinks" option in a chroot area,
|
||||
you should add this path to the exclude setting for the module so that
|
||||
the user can't try to create it.
|
||||
a directory. When using the "munge symlinks" parameter in a chroot area
|
||||
that has an inside-chroot path of "/", you should add "/rsyncd-munged/"
|
||||
to the exclude setting for the module so that
|
||||
a user can't try to create it.
|
||||
|
||||
Note: rsync makes no attempt to verify that any pre-existing symlinks in
|
||||
the hierarchy are as safe as you want them to be. If you setup an rsync
|
||||
@@ -190,20 +220,34 @@ every symlink's value. There is a perl script in the support directory
|
||||
of the source code named "munge-symlinks" that can be used to add or remove
|
||||
this prefix from your symlinks.
|
||||
|
||||
When this option is disabled on a writable module and "use chroot" is off,
|
||||
When this parameter is disabled on a writable module and "use chroot" is off
|
||||
(or the inside-chroot path is not "/"),
|
||||
incoming symlinks will be modified to drop a leading slash and to remove ".."
|
||||
path elements that rsync believes will allow a symlink to escape the module's
|
||||
hierarchy. There are tricky ways to work around this, though, so you had
|
||||
better trust your users if you choose this combination of options.
|
||||
better trust your users if you choose this combination of parameters.
|
||||
|
||||
dit(bf(max connections)) The "max connections" option allows you to
|
||||
dit(bf(charset)) This specifies the name of the character set in which the
|
||||
module's filenames are stored. If the client uses an bf(--iconv) option,
|
||||
the daemon will use the value of the "charset" parameter regardless of the
|
||||
character set the client actually passed. This allows the daemon to
|
||||
support charset conversion in a chroot module without extra files in the
|
||||
chroot area, and also ensures that name-translation is done in a consistent
|
||||
manner. If the "charset" parameter is not set, the bf(--iconv) option is
|
||||
refused, just as if "iconv" had been specified via "refuse options".
|
||||
|
||||
If you wish to force users to always use bf(--iconv) for a particular
|
||||
module, add "no-iconv" to the "refuse options" parameter. Keep in mind
|
||||
that this will restrict access to your module to very new rsync clients.
|
||||
|
||||
dit(bf(max connections)) This parameter allows you to
|
||||
specify the maximum number of simultaneous connections you will allow.
|
||||
Any clients connecting when the maximum has been reached will receive a
|
||||
message telling them to try later. The default is 0, which means no limit.
|
||||
A negative value disables the module.
|
||||
See also the "lock file" option.
|
||||
See also the "lock file" parameter.
|
||||
|
||||
dit(bf(log file)) When the "log file" option is set to a non-empty
|
||||
dit(bf(log file)) When the "log file" parameter is set to a non-empty
|
||||
string, the rsync daemon will log messages to the indicated file rather
|
||||
than using syslog. This is particularly useful on systems (such as AIX)
|
||||
where code(syslog()) doesn't work for chrooted programs. The file is
|
||||
@@ -216,7 +260,7 @@ If the daemon fails to open to specified file, it will fall back to
|
||||
using syslog and output an error about the failure. (Note that the
|
||||
failure to open the specified log file used to be a fatal error.)
|
||||
|
||||
dit(bf(syslog facility)) The "syslog facility" option allows you to
|
||||
dit(bf(syslog facility)) This parameter allows you to
|
||||
specify the syslog facility name to use when logging messages from the
|
||||
rsync daemon. You may use any standard syslog facility name which is
|
||||
defined on your system. Common names are auth, authpriv, cron, daemon,
|
||||
@@ -226,43 +270,43 @@ is daemon. This setting has no effect if the "log file" setting is a
|
||||
non-empty string (either set in the per-modules settings, or inherited
|
||||
from the global settings).
|
||||
|
||||
dit(bf(max verbosity)) The "max verbosity" option allows you to control
|
||||
dit(bf(max verbosity)) This parameter allows you to control
|
||||
the maximum amount of verbose information that you'll allow the daemon to
|
||||
generate (since the information goes into the log file). The default is 1,
|
||||
which allows the client to request one level of verbosity.
|
||||
|
||||
dit(bf(lock file)) The "lock file" option specifies the file to use to
|
||||
support the "max connections" option. The rsync daemon uses record
|
||||
dit(bf(lock file)) This parameter specifies the file to use to
|
||||
support the "max connections" parameter. The rsync daemon uses record
|
||||
locking on this file to ensure that the max connections limit is not
|
||||
exceeded for the modules sharing the lock file.
|
||||
The default is tt(/var/run/rsyncd.lock).
|
||||
|
||||
dit(bf(read only)) The "read only" option determines whether clients
|
||||
dit(bf(read only)) This parameter determines whether clients
|
||||
will be able to upload files or not. If "read only" is true then any
|
||||
attempted uploads will fail. If "read only" is false then uploads will
|
||||
be possible if file permissions on the daemon side allow them. The default
|
||||
is for all modules to be read only.
|
||||
|
||||
dit(bf(write only)) The "write only" option determines whether clients
|
||||
dit(bf(write only)) This parameter determines whether clients
|
||||
will be able to download files or not. If "write only" is true then any
|
||||
attempted downloads will fail. If "write only" is false then downloads
|
||||
will be possible if file permissions on the daemon side allow them. The
|
||||
default is for this option to be disabled.
|
||||
default is for this parameter to be disabled.
|
||||
|
||||
dit(bf(list)) The "list" option determines if this module should be
|
||||
dit(bf(list)) This parameter determines if this module should be
|
||||
listed when the client asks for a listing of available modules. By
|
||||
setting this to false you can create hidden modules. The default is
|
||||
for modules to be listable.
|
||||
|
||||
dit(bf(uid)) The "uid" option specifies the user name or user ID that
|
||||
dit(bf(uid)) This parameter specifies the user name or user ID that
|
||||
file transfers to and from that module should take place as when the daemon
|
||||
was run as root. In combination with the "gid" option this determines what
|
||||
was run as root. In combination with the "gid" parameter this determines what
|
||||
file permissions are available. The default is uid -2, which is normally
|
||||
the user "nobody".
|
||||
|
||||
dit(bf(gid)) The "gid" option specifies the group name or group ID that
|
||||
dit(bf(gid)) This parameter specifies the group name or group ID that
|
||||
file transfers to and from that module should take place as when the daemon
|
||||
was run as root. This complements the "uid" option. The default is gid -2,
|
||||
was run as root. This complements the "uid" parameter. The default is gid -2,
|
||||
which is normally the group "nobody".
|
||||
|
||||
dit(bf(fake super)) Setting "fake super = yes" for a module causes the
|
||||
@@ -270,51 +314,56 @@ daemon side to behave as if the bf(--fake-user) command-line option had
|
||||
been specified. This allows the full attributes of a file to be stored
|
||||
without having to have the daemon actually running as root.
|
||||
|
||||
dit(bf(filter)) The "filter" option allows you to specify a space-separated
|
||||
list of filter rules that the daemon will not allow to be read or written.
|
||||
This is only superficially equivalent to the client specifying these
|
||||
patterns with the bf(--filter) option. Only one "filter" option may be
|
||||
specified, but it may contain as many rules as you like, including
|
||||
merge-file rules. Note that per-directory merge-file rules do not provide
|
||||
as much protection as global rules, but they can be used to make bf(--delete)
|
||||
work better when a client downloads the daemon's files (if the per-dir
|
||||
merge files are included in the transfer).
|
||||
dit(bf(filter)) The daemon has its own filter chain that determines what files
|
||||
it will let the client access. This chain is not sent to the client and is
|
||||
independent of any filters the client may have specified. Files excluded by
|
||||
the daemon filter chain (bf(daemon-excluded) files) are treated as non-existent
|
||||
if the client tries to pull them, are skipped with an error message if the
|
||||
client tries to push them (triggering exit code 23), and are never deleted from
|
||||
the module. You can use daemon filters to prevent clients from downloading or
|
||||
tampering with private administrative files, such as files you may add to
|
||||
support uid/gid name translations.
|
||||
|
||||
dit(bf(exclude)) The "exclude" option allows you to specify a
|
||||
space-separated list of patterns that the daemon will not allow to be read
|
||||
or written. This is only superficially equivalent to the client
|
||||
specifying these patterns with the bf(--exclude) option. Only one "exclude"
|
||||
option may be specified, but you can use "-" and "+" before patterns to
|
||||
specify exclude/include.
|
||||
The daemon filter chain is built from the "filter", "include from", "include",
|
||||
"exclude from", and "exclude" parameters, in that order of priority. Anchored
|
||||
patterns are anchored at the root of the module. To prevent access to an
|
||||
entire subtree, for example, "/secret", you em(must) exclude everything in the
|
||||
subtree; the easiest way to do this is with a triple-star pattern like
|
||||
"/secret/***".
|
||||
|
||||
Because this exclude list is not passed to the client it only applies on
|
||||
the daemon: that is, it excludes files received by a client when receiving
|
||||
from a daemon and files deleted on a daemon when sending to a daemon, but
|
||||
it doesn't exclude files from being deleted on a client when receiving
|
||||
from a daemon.
|
||||
The "filter" parameter takes a space-separated list of daemon filter rules,
|
||||
though it is smart enough to know not to split a token at an internal space in
|
||||
a rule (e.g. "- /foo - /bar" is parsed as two rules). You may specify one or
|
||||
more merge-file rules using the normal syntax. Only one "filter" parameter can
|
||||
apply to a given module in the config file, so put all the rules you want in a
|
||||
single parameter. Note that per-directory merge-file rules do not provide as
|
||||
much protection as global rules, but they can be used to make bf(--delete) work
|
||||
better during a client download operation if the per-dir merge files are
|
||||
included in the transfer and the client requests that they be used.
|
||||
|
||||
dit(bf(exclude from)) The "exclude from" option specifies a filename
|
||||
on the daemon that contains exclude patterns, one per line.
|
||||
This is only superficially equivalent
|
||||
to the client specifying the bf(--exclude-from) option with an equivalent file.
|
||||
See the "exclude" option above.
|
||||
dit(bf(exclude)) This parameter takes a space-separated list of daemon
|
||||
exclude patterns. As with the client bf(--exclude) option, patterns can be
|
||||
qualified with "- " or "+ " to explicitly indicate exclude/include. Only one
|
||||
"exclude" parameter can apply to a given module. See the "filter" parameter
|
||||
for a description of how excluded files affect the daemon.
|
||||
|
||||
dit(bf(include)) The "include" option allows you to specify a
|
||||
space-separated list of patterns which rsync should not exclude. This is
|
||||
only superficially equivalent to the client specifying these patterns with
|
||||
the bf(--include) option because it applies only on the daemon. This is
|
||||
useful as it allows you to build up quite complex exclude/include rules.
|
||||
Only one "include" option may be specified, but you can use "+" and "-"
|
||||
before patterns to switch include/exclude. See the "exclude" option
|
||||
above.
|
||||
dit(bf(include)) Use an "include" to override the effects of the "exclude"
|
||||
parameter. Only one "include" parameter can apply to a given module. See the
|
||||
"filter" parameter for a description of how excluded files affect the daemon.
|
||||
|
||||
dit(bf(include from)) The "include from" option specifies a filename
|
||||
on the daemon that contains include patterns, one per line. This is
|
||||
only superficially equivalent to the client specifying the
|
||||
bf(--include-from) option with a equivalent file.
|
||||
See the "exclude" option above.
|
||||
dit(bf(exclude from)) This parameter specifies the name of a file
|
||||
on the daemon that contains daemon exclude patterns, one per line. Only one
|
||||
"exclude from" parameter can apply to a given module; if you have multiple
|
||||
exclude-from files, you can specify them as a merge file in the "filter"
|
||||
parameter. See the "filter" parameter for a description of how excluded files
|
||||
affect the daemon.
|
||||
|
||||
dit(bf(incoming chmod)) This option allows you to specify a set of
|
||||
dit(bf(include from)) Analogue of "exclude from" for a file of daemon include
|
||||
patterns. Only one "include from" parameter can apply to a given module. See
|
||||
the "filter" parameter for a description of how excluded files affect the
|
||||
daemon.
|
||||
|
||||
dit(bf(incoming chmod)) This parameter allows you to specify a set of
|
||||
comma-separated chmod strings that will affect the permissions of all
|
||||
incoming files (files that are being received by the daemon). These
|
||||
changes happen after all other permission calculations, and this will
|
||||
@@ -323,7 +372,7 @@ client does not specify bf(--perms).
|
||||
See the description of the bf(--chmod) rsync option and the bf(chmod)(1)
|
||||
manpage for information on the format of this string.
|
||||
|
||||
dit(bf(outgoing chmod)) This option allows you to specify a set of
|
||||
dit(bf(outgoing chmod)) This parameter allows you to specify a set of
|
||||
comma-separated chmod strings that will affect the permissions of all
|
||||
outgoing files (files that are being sent out from the daemon). These
|
||||
changes happen first, making the sent permissions appear to be different
|
||||
@@ -333,7 +382,7 @@ be on to the clients.
|
||||
See the description of the bf(--chmod) rsync option and the bf(chmod)(1)
|
||||
manpage for information on the format of this string.
|
||||
|
||||
dit(bf(auth users)) The "auth users" option specifies a comma and
|
||||
dit(bf(auth users)) This parameter specifies a comma and
|
||||
space-separated list of usernames that will be allowed to connect to
|
||||
this module. The usernames do not need to exist on the local
|
||||
system. The usernames may also contain shell wildcard characters. If
|
||||
@@ -341,7 +390,7 @@ system. The usernames may also contain shell wildcard characters. If
|
||||
username and password to connect to the module. A challenge response
|
||||
authentication protocol is used for this exchange. The plain text
|
||||
usernames and passwords are stored in the file specified by the
|
||||
"secrets file" option. The default is for all users to be able to
|
||||
"secrets file" parameter. The default is for all users to be able to
|
||||
connect without a password (this is called "anonymous rsync").
|
||||
|
||||
See also the "CONNECTING TO AN RSYNC DAEMON OVER A REMOTE SHELL
|
||||
@@ -349,28 +398,28 @@ PROGRAM" section in bf(rsync)(1) for information on how handle an
|
||||
rsyncd.conf-level username that differs from the remote-shell-level
|
||||
username when using a remote shell to connect to an rsync daemon.
|
||||
|
||||
dit(bf(secrets file)) The "secrets file" option specifies the name of
|
||||
dit(bf(secrets file)) This parameter 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
|
||||
users" option is specified. The file is line based and contains
|
||||
users" parameter is specified. The file is line based and contains
|
||||
username:password pairs separated by a single colon. Any line starting
|
||||
with a hash (#) is considered a comment and is skipped. The passwords
|
||||
can contain any characters but be warned that many operating systems
|
||||
limit the length of passwords that can be typed at the client end, so
|
||||
you may find that passwords longer than 8 characters don't work.
|
||||
|
||||
There is no default for the "secrets file" option, you must choose a name
|
||||
There is no default for the "secrets file" parameter, you must choose a name
|
||||
(such as tt(/etc/rsyncd.secrets)). The file must normally not be readable
|
||||
by "other"; see "strict modes".
|
||||
|
||||
dit(bf(strict modes)) The "strict modes" option determines whether or not
|
||||
dit(bf(strict modes)) This parameter determines whether or not
|
||||
the permissions on the secrets file will be checked. If "strict modes" is
|
||||
true, then the secrets file must not be readable by any user ID other
|
||||
than the one that the rsync daemon is running under. If "strict modes" is
|
||||
false, the check is not performed. The default is true. This option
|
||||
false, the check is not performed. The default is true. This parameter
|
||||
was added to accommodate rsync running on the Windows operating system.
|
||||
|
||||
dit(bf(hosts allow)) The "hosts allow" option allows you to specify a
|
||||
dit(bf(hosts allow)) This parameter allows you to specify a
|
||||
list of patterns that are matched against a connecting clients
|
||||
hostname and IP address. If none of the patterns match then the
|
||||
connection is rejected.
|
||||
@@ -405,28 +454,28 @@ tt( fe80::%link1/ffff:ffff:ffff:ffff::)nl()
|
||||
)
|
||||
|
||||
You can also combine "hosts allow" with a separate "hosts deny"
|
||||
option. If both options are specified then the "hosts allow" option s
|
||||
parameter. If both parameters are specified then the "hosts allow" parameter is
|
||||
checked first and a match results in the client being able to
|
||||
connect. The "hosts deny" option is then checked and a match means
|
||||
connect. The "hosts deny" parameter is then checked and a match means
|
||||
that the host is rejected. If the host does not match either the
|
||||
"hosts allow" or the "hosts deny" patterns then it is allowed to
|
||||
connect.
|
||||
|
||||
The default is no "hosts allow" option, which means all hosts can connect.
|
||||
The default is no "hosts allow" parameter, which means all hosts can connect.
|
||||
|
||||
dit(bf(hosts deny)) The "hosts deny" option allows you to specify a
|
||||
dit(bf(hosts deny)) This parameter allows you to specify a
|
||||
list of patterns that are matched against a connecting clients
|
||||
hostname and IP address. If the pattern matches then the connection is
|
||||
rejected. See the "hosts allow" option for more information.
|
||||
rejected. See the "hosts allow" parameter for more information.
|
||||
|
||||
The default is no "hosts deny" option, which means all hosts can connect.
|
||||
The default is no "hosts deny" parameter, which means all hosts can connect.
|
||||
|
||||
dit(bf(ignore errors)) The "ignore errors" option tells rsyncd to
|
||||
dit(bf(ignore errors)) This parameter tells rsyncd to
|
||||
ignore I/O errors on the daemon when deciding whether to run the delete
|
||||
phase of the transfer. Normally rsync skips the bf(--delete) step if any
|
||||
I/O errors have occurred in order to prevent disastrous deletion due
|
||||
to a temporary resource shortage or other I/O error. In some cases this
|
||||
test is counter productive so you can use this option to turn off this
|
||||
test is counter productive so you can use this parameter to turn off this
|
||||
behavior.
|
||||
|
||||
dit(bf(ignore nonreadable)) This tells the rsync daemon to completely
|
||||
@@ -434,14 +483,14 @@ ignore files that are not readable by the user. This is useful for
|
||||
public archives that may have some non-readable files among the
|
||||
directories, and the sysadmin doesn't want those files to be seen at all.
|
||||
|
||||
dit(bf(transfer logging)) The "transfer logging" option enables per-file
|
||||
dit(bf(transfer logging)) This parameter enables per-file
|
||||
logging of downloads and uploads in a format somewhat similar to that
|
||||
used by ftp daemons. The daemon always logs the transfer at the end, so
|
||||
if a transfer is aborted, no mention will be made in the log file.
|
||||
|
||||
If you want to customize the log lines, see the "log format" option.
|
||||
If you want to customize the log lines, see the "log format" parameter.
|
||||
|
||||
dit(bf(log format)) The "log format" option allows you to specify the
|
||||
dit(bf(log format)) This parameter allows you to specify the
|
||||
format used for logging file transfers when transfer logging is enabled.
|
||||
The format is a text string containing embedded single-character escape
|
||||
sequences prefixed with a percent (%) character. An optional numeric
|
||||
@@ -449,7 +498,7 @@ field width may also be specified between the percent and the escape
|
||||
letter (e.g. "bf(%-50n %8l %07p)").
|
||||
|
||||
The default log format is "%o %h [%a] %m (%u) %f %l", and a "%t [%p] "
|
||||
is always prefixed when using the "log file" option.
|
||||
is always prefixed when using the "log file" parameter.
|
||||
(A perl script that will summarize this default log format is included
|
||||
in the rsync source code distribution in the "support" subdirectory:
|
||||
rsyncstats.)
|
||||
@@ -485,14 +534,14 @@ Note that some of the logged output changes when talking with older
|
||||
rsync versions. For instance, deleted files were only output as verbose
|
||||
messages prior to rsync 2.6.4.
|
||||
|
||||
dit(bf(timeout)) The "timeout" option allows you to override the
|
||||
clients choice for I/O timeout for this module. Using this option you
|
||||
dit(bf(timeout)) This parameter allows you to override the
|
||||
clients choice for I/O timeout for this module. Using this parameter you
|
||||
can ensure that rsync won't wait on a dead client forever. The timeout
|
||||
is specified in seconds. A value of zero means no timeout and is the
|
||||
default. A good choice for anonymous rsync daemons may be 600 (giving
|
||||
a 10 minute timeout).
|
||||
|
||||
dit(bf(refuse options)) The "refuse options" option allows you to
|
||||
dit(bf(refuse options)) This parameter allows you to
|
||||
specify a space-separated list of rsync command line options that will
|
||||
be refused by your rsync daemon.
|
||||
You may specify the full option name, its one-letter abbreviation, or a
|
||||
@@ -505,9 +554,9 @@ quote(tt( refuse options = c delete))
|
||||
The reason the above refuses all delete options is that the options imply
|
||||
bf(--delete), and implied options are refused just like explicit options.
|
||||
As an additional safety feature, the refusal of "delete" also refuses
|
||||
bf(remove-sent-files) when the daemon is the sender; if you want the latter
|
||||
bf(remove-source-files) when the daemon is the sender; if you want the latter
|
||||
without the former, instead refuse "delete-*" -- that refuses all the
|
||||
delete modes without affecting bf(--remove-sent-files).
|
||||
delete modes without affecting bf(--remove-source-files).
|
||||
|
||||
When an option is refused, the daemon prints an error message and exits.
|
||||
To prevent all compression when serving files,
|
||||
@@ -515,21 +564,21 @@ you can use "dont compress = *" (see below)
|
||||
instead of "refuse options = compress" to avoid returning an error to a
|
||||
client that requests compression.
|
||||
|
||||
dit(bf(dont compress)) The "dont compress" option allows you to select
|
||||
dit(bf(dont compress)) This parameter allows you to select
|
||||
filenames based on wildcard patterns that should not be compressed
|
||||
when pulling files from the daemon (no analogous option exists to
|
||||
when pulling files from the daemon (no analogous parameter exists to
|
||||
govern the pushing of files to a daemon).
|
||||
Compression is expensive in terms of CPU usage, so it
|
||||
is usually good to not try to compress files that won't compress well,
|
||||
such as already compressed files.
|
||||
|
||||
The "dont compress" option takes a space-separated list of
|
||||
The "dont compress" parameter takes a space-separated list of
|
||||
case-insensitive wildcard patterns. Any source filename matching one
|
||||
of the patterns will not be compressed during transfer.
|
||||
|
||||
See the bf(--skip-compress) option in the bf(rsync)(1) manpage for the list
|
||||
See the bf(--skip-compress) parameter in the bf(rsync)(1) manpage for the list
|
||||
of file suffixes that are not compressed by default. Specifying a value
|
||||
for the bf(dont compress) option changes the default when the daemon is
|
||||
for the "dont compress" parameter changes the default when the daemon is
|
||||
the sender.
|
||||
|
||||
dit(bf(pre-xfer exec), bf(post-xfer exec)) You may specify a command to be run
|
||||
@@ -599,21 +648,21 @@ A more sophisticated example would be:
|
||||
verb(
|
||||
uid = nobody
|
||||
gid = nobody
|
||||
use chroot = no
|
||||
use chroot = yes
|
||||
max connections = 4
|
||||
syslog facility = local5
|
||||
pid file = /var/run/rsyncd.pid
|
||||
|
||||
[ftp]
|
||||
path = /var/ftp/pub
|
||||
path = /var/ftp/./pub
|
||||
comment = whole ftp area (approx 6.1 GB)
|
||||
|
||||
[sambaftp]
|
||||
path = /var/ftp/pub/samba
|
||||
path = /var/ftp/./pub/samba
|
||||
comment = Samba ftp area (approx 300 MB)
|
||||
|
||||
[rsyncftp]
|
||||
path = /var/ftp/pub/rsync
|
||||
path = /var/ftp/./pub/rsync
|
||||
comment = rsync ftp area (approx 6 MB)
|
||||
|
||||
[sambawww]
|
||||
@@ -651,7 +700,7 @@ url(http://rsync.samba.org/)(http://rsync.samba.org/)
|
||||
|
||||
manpagesection(VERSION)
|
||||
|
||||
This man page is current for version 3.0.0pre7 of rsync.
|
||||
This man page is current for version 3.0.3pre2 of rsync.
|
||||
|
||||
manpagesection(CREDITS)
|
||||
|
||||
|
||||
11
runtests.sh
11
runtests.sh
@@ -154,12 +154,21 @@ fi
|
||||
RSYNC="$rsync_bin $*"
|
||||
#RSYNC="valgrind $rsync_bin $*"
|
||||
|
||||
export POSIXLY_CORRECT TOOLDIR srcdir RSYNC
|
||||
TLS_ARGS=''
|
||||
if egrep '^#define HAVE_LUTIMES 1' "$srcdir/config.h" >/dev/null; then
|
||||
TLS_ARGS="$TLS_ARGS -l"
|
||||
fi
|
||||
if egrep '#undef CHOWN_MODIFIES_SYMLINK' "$srcdir/config.h" >/dev/null; then
|
||||
TLS_ARGS="$TLS_ARGS -L"
|
||||
fi
|
||||
|
||||
export POSIXLY_CORRECT TOOLDIR srcdir RSYNC TLS_ARGS
|
||||
|
||||
echo "============================================================"
|
||||
echo "$0 running in $TOOLDIR"
|
||||
echo " rsync_bin=$RSYNC"
|
||||
echo " srcdir=$srcdir"
|
||||
echo " TLS_ARGS=$TLS_ARGS"
|
||||
|
||||
if [ -f /usr/bin/whoami ]; then
|
||||
testuser=`/usr/bin/whoami`
|
||||
|
||||
8
sender.c
8
sender.c
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (C) 1996 Andrew Tridgell
|
||||
* Copyright (C) 1996 Paul Mackerras
|
||||
* Copyright (C) 2003-2007 Wayne Davison
|
||||
* Copyright (C) 2003-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -135,7 +135,7 @@ void successful_send(int ndx)
|
||||
}
|
||||
|
||||
file = flist->files[ndx - flist->ndx_start];
|
||||
if (!push_pathname(F_PATHNAME(file), -1))
|
||||
if (!change_pathname(file, NULL, 0))
|
||||
return;
|
||||
f_name(file, fname);
|
||||
|
||||
@@ -221,7 +221,7 @@ void send_files(int f_in, int f_out)
|
||||
} else {
|
||||
path = slash = "";
|
||||
}
|
||||
if (!push_pathname(F_PATHNAME(file), -1))
|
||||
if (!change_pathname(file, NULL, 0))
|
||||
continue;
|
||||
f_name(file, fname);
|
||||
|
||||
@@ -229,7 +229,7 @@ void send_files(int f_in, int f_out)
|
||||
rprintf(FINFO, "send_files(%d, %s%s%s)\n", ndx, path,slash,fname);
|
||||
|
||||
#ifdef SUPPORT_XATTRS
|
||||
if (preserve_xattrs && iflags & ITEM_REPORT_XATTR)
|
||||
if (preserve_xattrs && iflags & ITEM_REPORT_XATTR && !dry_run)
|
||||
recv_xattr_request(file, f_in);
|
||||
#endif
|
||||
|
||||
|
||||
8
socket.c
8
socket.c
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (C) 1992-2001 Andrew Tridgell <tridge@samba.org>
|
||||
* Copyright (C) 2001, 2002 Martin Pool <mbp@samba.org>
|
||||
* Copyright (C) 2003-2007 Wayne Davison
|
||||
* Copyright (C) 2003-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <netinet/tcp.h>
|
||||
|
||||
extern char *bind_address;
|
||||
extern char *sockopts;
|
||||
extern int default_af_hint;
|
||||
extern int connect_timeout;
|
||||
|
||||
@@ -272,6 +273,7 @@ int open_socket_out(char *host, int port, const char *bind_addr,
|
||||
alarm(connect_timeout);
|
||||
}
|
||||
|
||||
set_socket_options(s, sockopts);
|
||||
while (connect(s, res->ai_addr, res->ai_addrlen) < 0) {
|
||||
if (connect_timeout < 0)
|
||||
exit_cleanup(RERR_CONTIMEOUT);
|
||||
@@ -433,6 +435,10 @@ static int *open_socket_in(int type, int port, const char *bind_addr,
|
||||
|
||||
setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
|
||||
(char *)&one, sizeof one);
|
||||
if (sockopts)
|
||||
set_socket_options(s, sockopts);
|
||||
else
|
||||
set_socket_options(s, lp_socket_options());
|
||||
|
||||
#ifdef IPV6_V6ONLY
|
||||
if (resp->ai_family == AF_INET6) {
|
||||
|
||||
22
support/lsh
22
support/lsh
@@ -6,18 +6,30 @@
|
||||
# we get a -l USER option, we try to use "sudo -u USER" to run the
|
||||
# command.
|
||||
|
||||
user=''
|
||||
prefix=''
|
||||
|
||||
cd # Default path is home dir, just like ssh.
|
||||
do_cd=y # Default path is user's home dir, just like ssh.
|
||||
|
||||
while : ; do
|
||||
case "$1" in
|
||||
-l) shift ; prefix="sudo -u $1"; shift ;;
|
||||
-l*) prefix=`echo $1 | sed 's/-l/sudo -u /'`; shift ;;
|
||||
-l) user="$2"; shift; shift ;;
|
||||
-l*) user=`echo $1 | sed 's/^-l//'`; shift ;;
|
||||
--no-cd) do_cd=n; shift ;;
|
||||
-*) shift ;;
|
||||
localhost) shift; break ;;
|
||||
*) exit 1 ;;
|
||||
*) echo "lsh: unable to connect to host $1" 1>&2; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$user" ]; then
|
||||
prefix="sudo -H -u $user"
|
||||
if [ $do_cd = y ]; then
|
||||
home=`perl -e "print((getpwnam("$user"))[7])"`
|
||||
# Yeah, this may fail, but attempts to get sudo to cd are harder.
|
||||
cd $home
|
||||
fi
|
||||
elif [ $do_cd = y ]; then
|
||||
cd
|
||||
fi
|
||||
|
||||
eval $prefix "${@}"
|
||||
|
||||
@@ -1,148 +0,0 @@
|
||||
#!/usr/bin/perl -w
|
||||
# This script is used to turn one or more of the "patch/*" branches
|
||||
# into one or more diffs in the "patches" directory. Pass the option
|
||||
# --gen if you want generated files in the diffs. Pass the name of
|
||||
# one or more diffs if you want to just update a subset of all the
|
||||
# diffs.
|
||||
|
||||
use strict;
|
||||
|
||||
die "No 'patches' directory present in the current dir.\n" unless -d 'patches';
|
||||
die "No '.git' directory present in the current dir.\n" unless -d '.git';
|
||||
|
||||
my @extra_files;
|
||||
open(IN, '<', 'Makefile.in') or die "Couldn't open Makefile.in: $!\n";
|
||||
while (<IN>) {
|
||||
if (s/^GENFILES=//) {
|
||||
while (s/\\$//) {
|
||||
$_ .= <IN>;
|
||||
}
|
||||
@extra_files = split(' ', $_);
|
||||
last;
|
||||
}
|
||||
}
|
||||
close IN;
|
||||
|
||||
my $incl_generated_files = shift if @ARGV && $ARGV[0] eq '--gen';
|
||||
|
||||
system "git checkout master" and exit 1;
|
||||
if ($incl_generated_files) {
|
||||
die "'a' must not exist in the current directory.\n" if -e 'a';
|
||||
die "'b' must not exist in the current directory.\n" if -e 'b';
|
||||
system "make gen && rsync -a @extra_files a/" and exit 1;
|
||||
}
|
||||
my $last_touch = time;
|
||||
|
||||
my(@patches, %local_patch);
|
||||
if (@ARGV) {
|
||||
foreach (@ARGV) {
|
||||
s{^(patches|patch|origin/patch)/} {};
|
||||
s{\.diff$} {};
|
||||
push(@patches, $_);
|
||||
}
|
||||
open(PIPE, '-|', 'git', 'branch', '-l') or die $!;
|
||||
} else {
|
||||
open(PIPE, '-|', 'git', 'branch', '-a') or die $!;
|
||||
}
|
||||
while (<PIPE>) {
|
||||
if (m# origin/patch/(.*)#) {
|
||||
push(@patches, $1);
|
||||
} elsif (m# patch/(.*)#) {
|
||||
$local_patch{$1} = 1;
|
||||
}
|
||||
}
|
||||
close PIPE;
|
||||
|
||||
my(%parent, %description);
|
||||
foreach my $patch (@patches) {
|
||||
my $branch = ($local_patch{$patch} ? '' : 'origin/') . "patch/$patch";
|
||||
my $desc = '';
|
||||
open(PIPE, '-|', 'git', 'diff', '-U1000', "master...$branch", '--', "PATCH.$patch") or die $!;
|
||||
while (<PIPE>) {
|
||||
next if m{^\Q+++\E b/PATCH};
|
||||
next unless s/^[ +]//;
|
||||
if (m#patch -p1 <patches/(\S+)\.diff# && $1 ne $patch) {
|
||||
$parent{$patch} = $1;
|
||||
}
|
||||
$desc .= $_;
|
||||
}
|
||||
$description{$patch} = $desc;
|
||||
}
|
||||
|
||||
my %completed;
|
||||
foreach my $patch (@patches) {
|
||||
next if $completed{$patch}++;
|
||||
update_patch($patch);
|
||||
}
|
||||
|
||||
if ($incl_generated_files) {
|
||||
system "rm -rf a b";
|
||||
}
|
||||
|
||||
sleep 1 if $last_touch == time;
|
||||
system "git checkout master";
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
sub update_patch
|
||||
{
|
||||
my($patch) = @_;
|
||||
|
||||
my $parent = $parent{$patch};
|
||||
if (defined $parent) {
|
||||
unless ($completed{$parent}++) {
|
||||
update_patch($parent);
|
||||
}
|
||||
$parent = "patch/$parent";
|
||||
} else {
|
||||
$parent = 'master';
|
||||
}
|
||||
|
||||
print "======== $patch ========\n";
|
||||
|
||||
sleep 1 if $incl_generated_files && $last_touch == time;
|
||||
if ($local_patch{$patch}) {
|
||||
system "git checkout patch/$patch" and exit 1;
|
||||
} else {
|
||||
system "git checkout --track -b patch/$patch origin/patch/$patch" and exit 1;
|
||||
}
|
||||
|
||||
open(OUT, '>', "patches/$patch.diff") or die $!;
|
||||
print OUT $description{$patch}, "\n";
|
||||
|
||||
if (system("git rebase -m $parent") != 0) {
|
||||
print qq|"git rebase -m $parent" incomplete -- please fix.\n|;
|
||||
$ENV{PS1} = "[$parent] patch/$patch: ";
|
||||
system $ENV{SHELL} and exit 1;
|
||||
}
|
||||
|
||||
if ($incl_generated_files) {
|
||||
system "make gen && rsync -a @extra_files b/" and exit 1;
|
||||
}
|
||||
$last_touch = time;
|
||||
|
||||
open(PIPE, '-|', 'git', 'diff', $parent) or die $!;
|
||||
DIFF: while (<PIPE>) {
|
||||
while (m{^diff --git a/PATCH}) {
|
||||
while (<PIPE>) {
|
||||
last if m{^diff --git a/};
|
||||
}
|
||||
last DIFF if !defined $_;
|
||||
}
|
||||
next if /^index /;
|
||||
print OUT $_;
|
||||
}
|
||||
close PIPE;
|
||||
|
||||
if ($incl_generated_files) {
|
||||
open(PIPE, '-|', 'diff', '-up', 'a', 'b') or die $!;
|
||||
while (<PIPE>) {
|
||||
s/^((?:---|\+\+\+) [^\t]+)\t.*/$1/;
|
||||
print OUT $_;
|
||||
}
|
||||
close PIPE;
|
||||
}
|
||||
|
||||
close OUT;
|
||||
}
|
||||
@@ -39,6 +39,7 @@ die "$0: Restricted directory does not exist!\n" if $subdir ne '/' && !-d $subdi
|
||||
my $command = $ENV{SSH_ORIGINAL_COMMAND};
|
||||
die "$0: Not invoked via sshd\n$Usage" unless defined $command;
|
||||
die "$0: SSH_ORIGINAL_COMMAND='$command' is not rsync\n" unless $command =~ s/^rsync\s+//;
|
||||
die "$0: --server option is not first\n" unless $command =~ /^--server\s/;
|
||||
our $am_sender = $command =~ /^--server\s+--sender\s/; # Restrictive on purpose!
|
||||
die "$0 -ro: sending to read-only server not allowed\n" if $ro && !$am_sender;
|
||||
|
||||
@@ -65,7 +66,7 @@ our %long_opt = (
|
||||
'compress-level' => 1,
|
||||
'copy-dest' => 2,
|
||||
'copy-unsafe-links' => 0,
|
||||
'daemon' => 0,
|
||||
'daemon' => -1,
|
||||
'delay-updates' => 0,
|
||||
'delete' => 0,
|
||||
'delete-after' => 0,
|
||||
@@ -74,6 +75,7 @@ our %long_opt = (
|
||||
'delete-during' => 0,
|
||||
'delete-excluded' => 0,
|
||||
'existing' => 0,
|
||||
'fake-super' => 0,
|
||||
'files-from' => 3,
|
||||
'force' => 0,
|
||||
'from0' => 0,
|
||||
@@ -84,6 +86,7 @@ our %long_opt = (
|
||||
'inplace' => 0,
|
||||
'link-dest' => 2,
|
||||
'list-only' => 0,
|
||||
'log-file' => 3,
|
||||
'log-format' => 1,
|
||||
'max-delete' => 1,
|
||||
'max-size' => 1,
|
||||
@@ -110,6 +113,7 @@ our %long_opt = (
|
||||
'super' => 0,
|
||||
'temp-dir' => 2,
|
||||
'timeout' => 1,
|
||||
'use-qsort' => 0,
|
||||
);
|
||||
|
||||
### END of options data produced by the cull_options script. ###
|
||||
@@ -139,7 +143,7 @@ while ($command =~ /((?:[^\s\\]+|\\.[^\s\\]*)+)/g) {
|
||||
if ($_ eq '.') {
|
||||
$in_options = 0;
|
||||
} else {
|
||||
next if /^-$short_no_arg+(e\d+\.\d+)?$/o || /^-$short_with_num\d+$/o;
|
||||
next if /^-$short_no_arg+(e\d*\.\w*)?$/o || /^-$short_with_num\d+$/o;
|
||||
|
||||
my($opt,$arg) = /^--([^=]+)(?:=(.*))?$/;
|
||||
my $disabled;
|
||||
|
||||
18
syscall.c
18
syscall.c
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* Copyright (C) 1998 Andrew Tridgell
|
||||
* Copyright (C) 2002 Martin Pool
|
||||
* Copyright (C) 2003-2007 Wayne Davison
|
||||
* Copyright (C) 2003-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -34,6 +34,7 @@ extern int am_root;
|
||||
extern int read_only;
|
||||
extern int list_only;
|
||||
extern int preserve_perms;
|
||||
extern int preserve_executability;
|
||||
|
||||
#define RETURN_ERROR_IF(x,e) \
|
||||
do { \
|
||||
@@ -166,9 +167,9 @@ int do_chmod(const char *path, mode_t mode)
|
||||
code = 1;
|
||||
#endif
|
||||
} else
|
||||
code = chmod(path, mode & CHMOD_BITS);
|
||||
if (code != 0 && preserve_perms)
|
||||
return code;
|
||||
code = chmod(path, mode & CHMOD_BITS); /* DISCOURAGED FUNCTION */
|
||||
if (code != 0 && (preserve_perms || preserve_executability))
|
||||
return code;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@@ -281,12 +282,3 @@ OFF_T do_lseek(int fd, OFF_T offset, int whence)
|
||||
return lseek(fd, offset, whence);
|
||||
#endif
|
||||
}
|
||||
|
||||
char *d_name(struct dirent *di)
|
||||
{
|
||||
#ifdef HAVE_BROKEN_READDIR
|
||||
return (di->d_name - 2);
|
||||
#else
|
||||
return di->d_name;
|
||||
#endif
|
||||
}
|
||||
|
||||
14
t_stub.c
14
t_stub.c
@@ -3,7 +3,7 @@
|
||||
* functions, so that module test harnesses can run standalone.
|
||||
*
|
||||
* Copyright (C) 2001, 2002 Martin Pool <mbp@samba.org>
|
||||
* Copyright (C) 2003-2007 Wayne Davison
|
||||
* Copyright (C) 2003-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -26,10 +26,11 @@ int module_id = -1;
|
||||
int relative_paths = 0;
|
||||
int human_readable = 0;
|
||||
int module_dirlen = 0;
|
||||
int preserve_xattrs = 0;
|
||||
mode_t orig_umask = 002;
|
||||
char *partial_dir;
|
||||
char *module_dir;
|
||||
struct filter_list_struct server_filter_list;
|
||||
struct filter_list_struct daemon_filter_list;
|
||||
|
||||
void rprintf(UNUSED(enum logcode code), const char *format, ...)
|
||||
{
|
||||
@@ -56,8 +57,8 @@ struct filter_list_struct server_filter_list;
|
||||
exit(code);
|
||||
}
|
||||
|
||||
int check_filter(UNUSED(struct filter_list_struct *listp), UNUSED(char *name),
|
||||
UNUSED(int name_is_dir))
|
||||
int check_filter(UNUSED(struct filter_list_struct *listp), UNUSED(enum logcode code),
|
||||
UNUSED(const char *name), UNUSED(int name_is_dir))
|
||||
{
|
||||
/* This function doesn't really get called in this test context, so
|
||||
* just return 0. */
|
||||
@@ -69,6 +70,11 @@ struct filter_list_struct server_filter_list;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int copy_xattrs(UNUSED(const char *source), UNUSED(const char *dest))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
char *lp_name(UNUSED(int mod))
|
||||
{
|
||||
return NULL;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Test harness for unsafe_symlink(). Not linked into rsync itself.
|
||||
*
|
||||
* Copyright (C) 2002 Martin Pool
|
||||
* Copyright (C) 2003-2007 Wayne Davison
|
||||
* Copyright (C) 2003-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -29,6 +29,7 @@ int read_only = 0;
|
||||
int list_only = 0;
|
||||
int verbose = 0;
|
||||
int preserve_perms = 0;
|
||||
int preserve_executability = 0;
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
|
||||
@@ -43,7 +43,7 @@ runtest "BATCH.sh use of --read-batch" 'checkit "./BATCH.sh" "$chkdir" "$todir"'
|
||||
|
||||
rm -rf "$todir"
|
||||
mkdir "$todir" || test_fail "failed to restore empty destination directory"
|
||||
runtest "daemon recv --write-batch" 'checkit "$RSYNC -av --write-batch=BATCH \"$fromdir/\" rsync://localhost/test-to" "$chkdir" "$todir"'
|
||||
runtest "daemon recv --write-batch" 'checkit "\"$ignore23\" $RSYNC -av --write-batch=BATCH \"$fromdir/\" rsync://localhost/test-to" "$chkdir" "$todir"'
|
||||
|
||||
# The script would have aborted on error, so getting here means we pass.
|
||||
exit 0
|
||||
|
||||
@@ -17,7 +17,7 @@ case $0 in
|
||||
*fake*)
|
||||
$RSYNC --version | grep ", xattrs" >/dev/null || test_skipped "Rsync needs xattrs for fake device tests"
|
||||
RSYNC="$RSYNC --fake-super"
|
||||
TLS_ARGS=--fake-super
|
||||
TLS_ARGS="$TLS_ARGS --fake-super"
|
||||
case "`xattr 2>&1`" in
|
||||
*--list:*)
|
||||
chown() {
|
||||
|
||||
@@ -25,7 +25,7 @@ hands_setup
|
||||
# Build chkdir with a normal rsync and an --exclude.
|
||||
$RSYNC -av --exclude=foobar.baz "$fromdir/" "$chkdir/"
|
||||
|
||||
checkit "$RSYNC -avvvvz '$fromdir/' localhost::test-to/" "$chkdir" "$todir"
|
||||
checkit "'$ignore23' $RSYNC -avvvvz '$fromdir/' localhost::test-to/" "$chkdir" "$todir"
|
||||
|
||||
# The script would have aborted on error, so getting here means we've won.
|
||||
exit 0
|
||||
|
||||
@@ -24,8 +24,25 @@
|
||||
|
||||
. "$suitedir/rsync.fns"
|
||||
|
||||
SSH="src/support/lsh --no-cd"
|
||||
|
||||
build_rsyncd_conf
|
||||
|
||||
cd "$scratchdir"
|
||||
|
||||
ln -s test-rsyncd.conf rsyncd.conf
|
||||
|
||||
confopt=''
|
||||
case `id -u` in
|
||||
0)
|
||||
# Root needs to specify the config file, or it uses /etc/rsyncd.conf.
|
||||
echo "Forcing --config=$conf"
|
||||
confopt=" --config=$conf"
|
||||
;;
|
||||
esac
|
||||
|
||||
$RSYNC -ve "$SSH" --rsync-path="$RSYNC$confopt" localhost::
|
||||
|
||||
RSYNC_CONNECT_PROG="$RSYNC --config=$conf --daemon"
|
||||
export RSYNC_CONNECT_PROG
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ case $0 in
|
||||
*fake*)
|
||||
$RSYNC --version | grep ", xattrs" >/dev/null || test_skipped "Rsync needs xattrs for fake device tests"
|
||||
RSYNC="$RSYNC --fake-super"
|
||||
TLS_ARGS=--fake-super
|
||||
TLS_ARGS="$TLS_ARGS --fake-super"
|
||||
case "`xattr 2>&1`" in
|
||||
*--list:*)
|
||||
mknod() {
|
||||
@@ -81,14 +81,14 @@ touch -r "$fromdir/block" "$fromdir/block2"
|
||||
$RSYNC -ai "$fromdir/block" "$todir/block2" \
|
||||
| tee "$outfile"
|
||||
cat <<EOT >"$chkfile"
|
||||
cD+++++++++ block
|
||||
cD$all_plus block
|
||||
EOT
|
||||
diff $diffopt "$chkfile" "$outfile" || test_fail "test 1 failed"
|
||||
|
||||
$RSYNC -ai "$fromdir/block2" "$todir/block" \
|
||||
| tee "$outfile"
|
||||
cat <<EOT >"$chkfile"
|
||||
cD+++++++++ block2
|
||||
cD$all_plus block2
|
||||
EOT
|
||||
diff $diffopt "$chkfile" "$outfile" || test_fail "test 2 failed"
|
||||
|
||||
@@ -97,7 +97,7 @@ sleep 1
|
||||
$RSYNC -Di "$fromdir/block3" "$todir/block" \
|
||||
| tee "$outfile"
|
||||
cat <<EOT >"$chkfile"
|
||||
cD..T...... block3
|
||||
cDc.T.$dots block3
|
||||
EOT
|
||||
diff $diffopt "$chkfile" "$outfile" || test_fail "test 3 failed"
|
||||
|
||||
@@ -105,15 +105,15 @@ $RSYNC -aiHvv "$fromdir/" "$todir/" \
|
||||
| tee "$outfile"
|
||||
filter_outfile
|
||||
cat <<EOT >"$chkfile"
|
||||
.d..t...... ./
|
||||
cD..t...... block
|
||||
cD block2
|
||||
cD+++++++++ block3
|
||||
hD+++++++++ block2.5 => block3
|
||||
cD+++++++++ char
|
||||
cD+++++++++ char2
|
||||
cD+++++++++ char3
|
||||
cS+++++++++ fifo
|
||||
.d..t.$dots ./
|
||||
cDc.t.$dots block
|
||||
cDc...$dots block2
|
||||
cD$all_plus block3
|
||||
hD$all_plus block2.5 => block3
|
||||
cD$all_plus char
|
||||
cD$all_plus char2
|
||||
cD$all_plus char3
|
||||
cS$all_plus fifo
|
||||
EOT
|
||||
if test ! -r "$fromdir/block2.5"; then
|
||||
sed -e '/block2\.5/d' <"$chkfile" >"$chkfile.new"
|
||||
@@ -132,15 +132,15 @@ if test -b "$fromdir/block2.5"; then
|
||||
$RSYNC -aii --link-dest="$todir" "$fromdir/" "$chkdir/" \
|
||||
| tee "$outfile"
|
||||
cat <<EOT >"$chkfile"
|
||||
cd ./
|
||||
hD block
|
||||
hD block2
|
||||
hD block2.5
|
||||
hD block3
|
||||
hD char
|
||||
hD char2
|
||||
hD char3
|
||||
hS fifo
|
||||
cd$allspace ./
|
||||
hD$allspace block
|
||||
hD$allspace block2
|
||||
hD$allspace block2.5
|
||||
hD$allspace block3
|
||||
hD$allspace char
|
||||
hD$allspace char2
|
||||
hD$allspace char3
|
||||
hS$allspace fifo
|
||||
EOT
|
||||
diff $diffopt "$chkfile" "$outfile" || test_fail "test 4 failed"
|
||||
fi
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
. "$suitedir/rsync.fns"
|
||||
|
||||
SSH=support/lsh
|
||||
|
||||
outfile="$scratchdir/rsync.out"
|
||||
|
||||
# Build some hardlinks
|
||||
@@ -38,12 +40,23 @@ echo "extra extra" >>"$todir/name1"
|
||||
checkit "$RSYNC -aHivv --no-whole-file '$fromdir/' '$todir/'" "$fromdir" "$todir"
|
||||
|
||||
# Add a new link in a new subdirectory to test that we don't try to link
|
||||
# the files before the directory gets created.
|
||||
mkdir "$fromdir/subdir"
|
||||
ln "$name1" "$fromdir/subdir/new-file"
|
||||
# the files before the directory gets created. We also create a bunch of
|
||||
# extra files to ensure that an incremental-recursion transfer works across
|
||||
# distant files.
|
||||
makepath "$fromdir/subdir/down/deep"
|
||||
|
||||
files=''
|
||||
for x in a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9; do
|
||||
for y in a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9; do
|
||||
files="$files $x$y"
|
||||
done
|
||||
done
|
||||
(cd "$fromdir/subdir"; touch $files)
|
||||
|
||||
ln "$name1" "$fromdir/subdir/down/deep/new-file"
|
||||
rm "$todir/text"
|
||||
|
||||
checkit "$RSYNC -aHivv '$fromdir/' '$todir/'" "$fromdir" "$todir"
|
||||
checkit "$RSYNC -aHivve '$SSH' --rsync-path='$RSYNC' '$fromdir/' localhost:'$todir/'" "$fromdir" "$todir"
|
||||
|
||||
# Do some duplicate copies using --link-dest and --copy-dest to test that
|
||||
# we hard-link all locally-inherited items.
|
||||
|
||||
@@ -25,28 +25,42 @@ umask 0
|
||||
ln -s ../bar/baz/rsync "$fromdir/foo/sym"
|
||||
umask 022
|
||||
ln "$fromdir/foo/config1" "$fromdir/foo/extra"
|
||||
rm -f "$to2dir"
|
||||
|
||||
# Check if the OS can hard-link symlinks or not
|
||||
ln -s no-such-dir "$to2dir"
|
||||
if ln "$to2dir" "$to2dir.test" 2>/dev/null; then
|
||||
# Check if rsync is set to hard-link symlinks.
|
||||
confile=`echo "$scratchdir" | sed 's;/testtmp/itemize$;/config.h;'`
|
||||
if egrep '^#define CAN_HARDLINK_SYMLINK 1' "$confile" >/dev/null; then
|
||||
L=hL
|
||||
else
|
||||
L=cL
|
||||
fi
|
||||
rm -f "$to2dir" "$to2dir.test"
|
||||
|
||||
# Check if rsync can preserve time on symlinks
|
||||
case "$RSYNC" in
|
||||
*protocol=2*)
|
||||
T=.T
|
||||
;;
|
||||
*)
|
||||
if $RSYNC --version | grep ", symtimes" >/dev/null; then
|
||||
T=.t
|
||||
else
|
||||
T=.T
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
$RSYNC -iplr "$fromdir/" "$todir/" \
|
||||
| tee "$outfile"
|
||||
cat <<EOT >"$chkfile"
|
||||
cd+++++++++ ./
|
||||
cd+++++++++ bar/
|
||||
cd+++++++++ bar/baz/
|
||||
>f+++++++++ bar/baz/rsync
|
||||
cd+++++++++ foo/
|
||||
>f+++++++++ foo/config1
|
||||
>f+++++++++ foo/config2
|
||||
>f+++++++++ foo/extra
|
||||
cL+++++++++ foo/sym -> ../bar/baz/rsync
|
||||
cd$all_plus ./
|
||||
cd$all_plus bar/
|
||||
cd$all_plus bar/baz/
|
||||
>f$all_plus bar/baz/rsync
|
||||
cd$all_plus foo/
|
||||
>f$all_plus foo/config1
|
||||
>f$all_plus foo/config2
|
||||
>f$all_plus foo/extra
|
||||
cL$all_plus foo/sym -> ../bar/baz/rsync
|
||||
EOT
|
||||
diff $diffopt "$chkfile" "$outfile" || test_fail "test 1 failed"
|
||||
|
||||
@@ -58,10 +72,10 @@ chmod 601 "$fromdir/foo/config2"
|
||||
$RSYNC -iplrH "$fromdir/" "$todir/" \
|
||||
| tee "$outfile"
|
||||
cat <<EOT >"$chkfile"
|
||||
>f..T...... bar/baz/rsync
|
||||
>f..T...... foo/config1
|
||||
>f.sTp..... foo/config2
|
||||
hf..T...... foo/extra => foo/config1
|
||||
>f..T.$dots bar/baz/rsync
|
||||
>f..T.$dots foo/config1
|
||||
>f.sTp$dots foo/config2
|
||||
hf..T.$dots foo/extra => foo/config1
|
||||
EOT
|
||||
diff $diffopt "$chkfile" "$outfile" || test_fail "test 2 failed"
|
||||
|
||||
@@ -78,11 +92,11 @@ chmod 777 "$todir/bar/baz/rsync"
|
||||
$RSYNC -iplrtc "$fromdir/" "$todir/" \
|
||||
| tee "$outfile"
|
||||
cat <<EOT >"$chkfile"
|
||||
.f..tp..... bar/baz/rsync
|
||||
.d..t...... foo/
|
||||
.f..t...... foo/config1
|
||||
>fcstp..... foo/config2
|
||||
cL..T...... foo/sym -> ../bar/baz/rsync
|
||||
.f..tp$dots bar/baz/rsync
|
||||
.d..t.$dots foo/
|
||||
.f..t.$dots foo/config1
|
||||
>fcstp$dots foo/config2
|
||||
cLc$T.$dots foo/sym -> ../bar/baz/rsync
|
||||
EOT
|
||||
diff $diffopt "$chkfile" "$outfile" || test_fail "test 3 failed"
|
||||
|
||||
@@ -107,15 +121,15 @@ $RSYNC -ivvplrtH "$fromdir/" "$todir/" \
|
||||
| tee "$outfile"
|
||||
filter_outfile
|
||||
cat <<EOT >"$chkfile"
|
||||
.d ./
|
||||
.d bar/
|
||||
.d bar/baz/
|
||||
.f...p..... bar/baz/rsync
|
||||
.d foo/
|
||||
.f foo/config1
|
||||
>f..t...... foo/config2
|
||||
hf foo/extra
|
||||
.L foo/sym -> ../bar/baz/rsync
|
||||
.d$allspace ./
|
||||
.d$allspace bar/
|
||||
.d$allspace bar/baz/
|
||||
.f...p$dots bar/baz/rsync
|
||||
.d$allspace foo/
|
||||
.f$allspace foo/config1
|
||||
>f..t.$dots foo/config2
|
||||
hf$allspace foo/extra
|
||||
.L$allspace foo/sym -> ../bar/baz/rsync
|
||||
EOT
|
||||
diff $diffopt "$chkfile" "$outfile" || test_fail "test 5 failed"
|
||||
|
||||
@@ -134,32 +148,47 @@ touch "$todir/foo/config2"
|
||||
$RSYNC -iplrtH "$fromdir/" "$todir/" \
|
||||
| tee "$outfile"
|
||||
cat <<EOT >"$chkfile"
|
||||
.f...p..... foo/config1
|
||||
>f..t...... foo/config2
|
||||
.f...p$dots foo/config1
|
||||
>f..t.$dots foo/config2
|
||||
EOT
|
||||
diff $diffopt "$chkfile" "$outfile" || test_fail "test 7 failed"
|
||||
|
||||
$RSYNC -ivvplrtH --copy-dest=../to "$fromdir/" "$to2dir/" \
|
||||
| tee "$outfile"
|
||||
filter_outfile
|
||||
case `tail -1 "$outfile"` in
|
||||
cLc.t*)
|
||||
sym_dots="c.t.$dots"
|
||||
L_sym_dots="cL$sym_dots"
|
||||
is_uptodate='-> ../bar/baz/rsync'
|
||||
echo "cL$sym_dots foo/sym $is_uptodate" >"$chkfile.extra"
|
||||
L=cL
|
||||
;;
|
||||
*)
|
||||
sym_dots="$allspace"
|
||||
L_sym_dots=".L$allspace"
|
||||
is_uptodate='is uptodate'
|
||||
touch "$chkfile.extra"
|
||||
;;
|
||||
esac
|
||||
cat <<EOT >"$chkfile"
|
||||
cd ./
|
||||
cd bar/
|
||||
cd bar/baz/
|
||||
cf bar/baz/rsync
|
||||
cd foo/
|
||||
cf foo/config1
|
||||
cf foo/config2
|
||||
hf foo/extra => foo/config1
|
||||
cL foo/sym -> ../bar/baz/rsync
|
||||
cd$allspace ./
|
||||
cd$allspace bar/
|
||||
cd$allspace bar/baz/
|
||||
cf$allspace bar/baz/rsync
|
||||
cd$allspace foo/
|
||||
cf$allspace foo/config1
|
||||
cf$allspace foo/config2
|
||||
hf$allspace foo/extra => foo/config1
|
||||
cL$sym_dots foo/sym -> ../bar/baz/rsync
|
||||
EOT
|
||||
diff $diffopt "$chkfile" "$outfile" || test_fail "test 8 failed"
|
||||
|
||||
rm -rf "$to2dir"
|
||||
$RSYNC -iplrtH --copy-dest=../to "$fromdir/" "$to2dir/" \
|
||||
| tee "$outfile"
|
||||
cat <<EOT >"$chkfile"
|
||||
hf foo/extra => foo/config1
|
||||
cat - "$chkfile.extra" <<EOT >"$chkfile"
|
||||
hf$allspace foo/extra => foo/config1
|
||||
EOT
|
||||
diff $diffopt "$chkfile" "$outfile" || test_fail "test 9 failed"
|
||||
|
||||
@@ -176,7 +205,7 @@ foo/ is uptodate
|
||||
foo/config1 is uptodate
|
||||
foo/config2 is uptodate
|
||||
foo/extra => foo/config1
|
||||
foo/sym is uptodate
|
||||
foo/sym $is_uptodate
|
||||
EOT
|
||||
diff $diffopt "$chkfile" "$outfile" || test_fail "test 10 failed"
|
||||
|
||||
@@ -185,29 +214,29 @@ $RSYNC -ivvplrtH --link-dest="$todir" "$fromdir/" "$to2dir/" \
|
||||
| tee "$outfile"
|
||||
filter_outfile
|
||||
cat <<EOT >"$chkfile"
|
||||
cd ./
|
||||
cd bar/
|
||||
cd bar/baz/
|
||||
hf bar/baz/rsync
|
||||
cd foo/
|
||||
hf foo/config1
|
||||
hf foo/config2
|
||||
hf foo/extra => foo/config1
|
||||
$L foo/sym -> ../bar/baz/rsync
|
||||
cd$allspace ./
|
||||
cd$allspace bar/
|
||||
cd$allspace bar/baz/
|
||||
hf$allspace bar/baz/rsync
|
||||
cd$allspace foo/
|
||||
hf$allspace foo/config1
|
||||
hf$allspace foo/config2
|
||||
hf$allspace foo/extra => foo/config1
|
||||
$L$sym_dots foo/sym -> ../bar/baz/rsync
|
||||
EOT
|
||||
diff $diffopt "$chkfile" "$outfile" || test_fail "test 11 failed"
|
||||
|
||||
rm -rf "$to2dir"
|
||||
$RSYNC -iplrtH --dry-run --link-dest=../to "$fromdir/" "$to2dir/" \
|
||||
| tee "$outfile"
|
||||
cat <<EOT >"$chkfile"
|
||||
cat - "$chkfile.extra" <<EOT >"$chkfile"
|
||||
EOT
|
||||
diff $diffopt "$chkfile" "$outfile" || test_fail "test 12 failed"
|
||||
|
||||
rm -rf "$to2dir"
|
||||
$RSYNC -iplrtH --link-dest=../to "$fromdir/" "$to2dir/" \
|
||||
| tee "$outfile"
|
||||
cat <<EOT >"$chkfile"
|
||||
cat - "$chkfile.extra" <<EOT >"$chkfile"
|
||||
EOT
|
||||
diff $diffopt "$chkfile" "$outfile" || test_fail "test 13 failed"
|
||||
|
||||
@@ -224,7 +253,7 @@ foo/ is uptodate
|
||||
foo/config1 is uptodate
|
||||
foo/config2 is uptodate
|
||||
foo/extra is uptodate
|
||||
foo/sym is uptodate
|
||||
foo/sym $is_uptodate
|
||||
EOT
|
||||
diff $diffopt "$chkfile" "$outfile" || test_fail "test 14 failed"
|
||||
|
||||
@@ -233,22 +262,22 @@ $RSYNC -ivvplrtH --compare-dest="$todir" "$fromdir/" "$to2dir/" \
|
||||
| tee "$outfile"
|
||||
filter_outfile
|
||||
cat <<EOT >"$chkfile"
|
||||
cd ./
|
||||
cd bar/
|
||||
cd bar/baz/
|
||||
.f bar/baz/rsync
|
||||
cd foo/
|
||||
.f foo/config1
|
||||
.f foo/config2
|
||||
.f foo/extra
|
||||
.L foo/sym -> ../bar/baz/rsync
|
||||
cd$allspace ./
|
||||
cd$allspace bar/
|
||||
cd$allspace bar/baz/
|
||||
.f$allspace bar/baz/rsync
|
||||
cd$allspace foo/
|
||||
.f$allspace foo/config1
|
||||
.f$allspace foo/config2
|
||||
.f$allspace foo/extra
|
||||
$L_sym_dots foo/sym -> ../bar/baz/rsync
|
||||
EOT
|
||||
diff $diffopt "$chkfile" "$outfile" || test_fail "test 15 failed"
|
||||
|
||||
rm -rf "$to2dir"
|
||||
$RSYNC -iplrtH --compare-dest="$todir" "$fromdir/" "$to2dir/" \
|
||||
| tee "$outfile"
|
||||
cat <<EOT >"$chkfile"
|
||||
cat - "$chkfile.extra" <<EOT >"$chkfile"
|
||||
EOT
|
||||
diff $diffopt "$chkfile" "$outfile" || test_fail "test 16 failed"
|
||||
|
||||
@@ -265,7 +294,7 @@ foo/ is uptodate
|
||||
foo/config1 is uptodate
|
||||
foo/config2 is uptodate
|
||||
foo/extra is uptodate
|
||||
foo/sym is uptodate
|
||||
foo/sym $is_uptodate
|
||||
EOT
|
||||
diff $diffopt "$chkfile" "$outfile" || test_fail "test 17 failed"
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ $RSYNC -av --existing -f 'exclude,! */' from2/ from3/
|
||||
$RSYNC -av --existing -f 'exclude,! */' from1/ chk/
|
||||
$RSYNC -av --existing -f 'exclude,! */' from3/ chk/
|
||||
|
||||
checkit "$RSYNC -avv deep/arg-test shallow from1/ from2/ from3/ to/" chk to
|
||||
checkit "$RSYNC -avv deep/arg-test shallow from1/ from2/ from3/ to/" "$chkdir" "$todir"
|
||||
|
||||
# The script would have aborted on error, so getting here means we've won.
|
||||
exit 0
|
||||
|
||||
27
testsuite/missing.test
Normal file
27
testsuite/missing.test
Normal file
@@ -0,0 +1,27 @@
|
||||
#! /bin/sh
|
||||
|
||||
# This program is distributable under the terms of the GNU GPL (see
|
||||
# COPYING).
|
||||
|
||||
# Test three bugs fixed by my redoing of the missing_below logic.
|
||||
|
||||
. $srcdir/testsuite/rsync.fns
|
||||
|
||||
makepath "$fromdir/subdir" "$todir"
|
||||
echo data >"$fromdir/subdir/file"
|
||||
echo data >"$todir/other"
|
||||
|
||||
# Test 1: Too much "not creating new..." output on a dry run
|
||||
$RSYNC -n -r --ignore-non-existing -vv "$fromdir/" "$todir/" | tee "$scratchdir/out"
|
||||
if grep 'not creating new.*subdir/file' "$scratchdir/out" >/dev/null; then
|
||||
test_fail 'test 1 failed'
|
||||
fi
|
||||
|
||||
# Test 2: Attempt to make a fuzzy dirlist for a dir not created on a dry run
|
||||
$RSYNC -n -r -R --no-implied-dirs -y "$fromdir/./subdir/file" "$todir/" \
|
||||
|| test_fail 'test 2 failed'
|
||||
|
||||
# Test 3: --delete-after pass skipped when last dir is dry-missing
|
||||
$RSYNC -n -r --delete-after -i "$fromdir/" "$todir/" | tee "$scratchdir/out"
|
||||
grep '^\*deleting * other' "$scratchdir/out" >/dev/null \
|
||||
|| test_fail 'test 3 failed'
|
||||
@@ -23,6 +23,11 @@ fromdir="$tmpdir/from"
|
||||
todir="$tmpdir/to"
|
||||
chkdir="$tmpdir/chk"
|
||||
|
||||
# For itemized output:
|
||||
all_plus='+++++++++'
|
||||
allspace=' '
|
||||
dots='.....' # trailing dots after changes
|
||||
|
||||
# Berkley's nice.
|
||||
PATH="$PATH:/usr/ucb"
|
||||
|
||||
@@ -256,6 +261,25 @@ gid = 0
|
||||
path = $scratchdir
|
||||
read only = no
|
||||
EOF
|
||||
|
||||
# Build a helper script to ignore exit code 23
|
||||
ignore23="$scratchdir/ignore23"
|
||||
echo "building help script $ignore23"
|
||||
|
||||
cat >"$ignore23" <<'EOT'
|
||||
if "${@}"; then
|
||||
exit
|
||||
fi
|
||||
|
||||
ret=$?
|
||||
|
||||
if test $ret = 23; then
|
||||
exit
|
||||
fi
|
||||
|
||||
exit $ret
|
||||
EOT
|
||||
chmod +x "$ignore23"
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,20 +10,7 @@
|
||||
|
||||
. "$suitedir/rsync.fns"
|
||||
|
||||
SSH="$scratchdir/pretend-ssh"
|
||||
|
||||
cat >"$SSH" <<'EOT'
|
||||
while : ; do
|
||||
case "$1" in
|
||||
-*) shift ;;
|
||||
localhost) shift; break ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
eval "${@}"
|
||||
EOT
|
||||
chmod +x "$SSH"
|
||||
SSH=support/lsh
|
||||
|
||||
if test x"$rsync_enable_ssh_tests" = xyes; then
|
||||
if type ssh >/dev/null ; then
|
||||
@@ -31,7 +18,7 @@ if test x"$rsync_enable_ssh_tests" = xyes; then
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! [ "`"$SSH" -o'BatchMode yes' localhost echo yes`" = "yes" ]; then
|
||||
if ! [ "`$SSH -o'BatchMode yes' localhost echo yes`" = "yes" ]; then
|
||||
test_skipped "Skipping SSH tests because ssh conection to localhost not authorised"
|
||||
fi
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ case "`xattr 2>&1`" in
|
||||
xls() {
|
||||
xattr -l "${@}"
|
||||
}
|
||||
RUSR='rsync.nonuser'
|
||||
;;
|
||||
*)
|
||||
xset() {
|
||||
@@ -31,21 +32,23 @@ case "`xattr 2>&1`" in
|
||||
xls() {
|
||||
getfattr -d "${@}"
|
||||
}
|
||||
RUSR='user.rsync'
|
||||
;;
|
||||
esac
|
||||
|
||||
makepath "$fromdir/foo"
|
||||
makepath "$fromdir/foo/bar"
|
||||
echo now >"$fromdir/file0"
|
||||
echo something >"$fromdir/file1"
|
||||
echo else >"$fromdir/file2"
|
||||
echo deep >"$fromdir/foo/file3"
|
||||
echo normal >"$fromdir/file4"
|
||||
echo deeper >"$fromdir/foo/bar/file5"
|
||||
|
||||
makepath "$chkdir/foo"
|
||||
echo wow >"$chkdir/file1"
|
||||
cp -p "$fromdir/foo/file3" "$chkdir/foo"
|
||||
|
||||
files='foo file0 file1 file2 foo/file3 file4'
|
||||
files='foo file0 file1 file2 foo/file3 file4 foo/bar/file5'
|
||||
|
||||
cd "$fromdir"
|
||||
|
||||
@@ -61,28 +64,28 @@ xset user.foo foo file2
|
||||
xset user.bar bar file2
|
||||
xset user.long 'a long attribute for our new file that tests to ensure that this works' file2
|
||||
|
||||
xset user.foo 'new foo' foo/file3
|
||||
xset user.bar 'new bar' foo/file3
|
||||
xset user.long 'this is also a long attribute that will be truncated in the initial data send' foo/file3
|
||||
xset user.equal 'this long attribute should remain the same and not need to be transferred' foo/file3
|
||||
xset user.foo 'new foo' foo/file3 foo/bar/file5
|
||||
xset user.bar 'new bar' foo/file3 foo/bar/file5
|
||||
xset user.long 'this is also a long attribute that will be truncated in the initial data send' foo/file3 foo/bar/file5
|
||||
xset $RUSR.equal 'this long attribute should remain the same and not need to be transferred' foo/file3 foo/bar/file5
|
||||
|
||||
xset user.short 'old short' "$chkdir/file1"
|
||||
xset user.extra 'remove me' "$chkdir/file1"
|
||||
|
||||
xset user.foo 'old foo' "$chkdir/foo/file3"
|
||||
xset user.equal 'this long attribute should remain the same and not need to be transferred' "$chkdir/foo/file3"
|
||||
xset $RUSR.equal 'this long attribute should remain the same and not need to be transferred' "$chkdir/foo/file3"
|
||||
|
||||
xls $files >"$scratchdir/xattrs.txt"
|
||||
|
||||
# OK, let's try a simple xattr copy.
|
||||
checkit "$RSYNC -avX . '$chkdir/'" "$fromdir" "$chkdir"
|
||||
checkit "$RSYNC -avX --super . '$chkdir/'" "$fromdir" "$chkdir"
|
||||
|
||||
cd "$chkdir"
|
||||
xls $files | diff $diffopt "$scratchdir/xattrs.txt" -
|
||||
|
||||
cd "$fromdir"
|
||||
|
||||
checkit "$RSYNC -aiX --copy-dest=../chk . ../to" "$fromdir" "$todir"
|
||||
checkit "$RSYNC -aiX --super --copy-dest=../chk . ../to" "$fromdir" "$todir"
|
||||
|
||||
cd "$todir"
|
||||
xls $files | diff $diffopt "$scratchdir/xattrs.txt" -
|
||||
@@ -94,10 +97,17 @@ xls $files >"$scratchdir/xattrs.txt"
|
||||
|
||||
rm -rf "$todir"
|
||||
|
||||
checkit "$RSYNC -aiX --link-dest=../chk . ../to" "$chkdir" "$todir"
|
||||
checkit "$RSYNC -aiX --fake-super --link-dest=../chk . ../to" "$chkdir" "$todir"
|
||||
|
||||
cd "$todir"
|
||||
xls $files | diff $diffopt "$scratchdir/xattrs.txt" -
|
||||
|
||||
sed -n -e '/\.\/file1$/d' -e '/^[^ ][^ ]* *[^ ][^ ]* *[^ ][^ ]* *1 /p' "$scratchdir/ls-to" >"$scratchdir/ls-diff"
|
||||
if [ -s "$scratchdir/ls-diff" ]; then
|
||||
echo "Missing hard links on:"
|
||||
cat "$scratchdir/ls-diff"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# The script would have aborted on error, so getting here means we've won.
|
||||
exit 0
|
||||
|
||||
19
tls.c
19
tls.c
@@ -2,7 +2,7 @@
|
||||
* Trivial ls for comparing two directories after running an rsync.
|
||||
*
|
||||
* Copyright (C) 2001, 2002 Martin Pool <mbp@samba.org>
|
||||
* Copyright (C) 2003-2007 Wayne Davison
|
||||
* Copyright (C) 2003-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -35,7 +35,7 @@
|
||||
* change. */
|
||||
|
||||
#include "rsync.h"
|
||||
#include "popt.h"
|
||||
#include <popt.h>
|
||||
#include "lib/sysxattrs.h"
|
||||
|
||||
#define PROGRAM "tls"
|
||||
@@ -45,7 +45,10 @@ int dry_run = 0;
|
||||
int am_root = 0;
|
||||
int read_only = 1;
|
||||
int list_only = 0;
|
||||
int link_times = 0;
|
||||
int link_owner = 0;
|
||||
int preserve_perms = 0;
|
||||
int preserve_executability = 0;
|
||||
|
||||
#ifdef SUPPORT_XATTRS
|
||||
|
||||
@@ -133,12 +136,14 @@ static void list_file(const char *fname)
|
||||
|
||||
/* On some BSD platforms the mode bits of a symlink are
|
||||
* undefined. Also it tends not to be possible to reset a
|
||||
* symlink's mtime, so we have to ignore it too. */
|
||||
* symlink's mtime, so we default to ignoring it too. */
|
||||
if (S_ISLNK(buf.st_mode)) {
|
||||
int len;
|
||||
buf.st_mode &= ~0777;
|
||||
buf.st_mtime = (time_t)0;
|
||||
buf.st_uid = buf.st_gid = 0;
|
||||
if (!link_times)
|
||||
buf.st_mtime = (time_t)0;
|
||||
if (!link_owner)
|
||||
buf.st_uid = buf.st_gid = 0;
|
||||
strlcpy(linkbuf, " -> ", sizeof linkbuf);
|
||||
/* const-cast required for silly UNICOS headers */
|
||||
len = readlink((char *) fname, linkbuf+4, sizeof(linkbuf) - 4);
|
||||
@@ -183,6 +188,8 @@ static void list_file(const char *fname)
|
||||
|
||||
static struct poptOption long_options[] = {
|
||||
/* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
|
||||
{"link-times", 'l', POPT_ARG_NONE, &link_times, 0, 0, 0 },
|
||||
{"link-owner", 'L', POPT_ARG_NONE, &link_owner, 0, 0, 0 },
|
||||
#ifdef SUPPORT_XATTRS
|
||||
{"fake-super", 'f', POPT_ARG_VAL, &am_root, -1, 0, 0 },
|
||||
#endif
|
||||
@@ -196,6 +203,8 @@ static void tls_usage(int ret)
|
||||
fprintf(F,"usage: " PROGRAM " [OPTIONS] FILE ...\n");
|
||||
fprintf(F,"Trivial file listing program for portably checking rsync\n");
|
||||
fprintf(F,"\nOptions:\n");
|
||||
fprintf(F," -l, --link-times display the time on a symlink\n");
|
||||
fprintf(F," -L, --link-owner display the owner+group on a symlink\n");
|
||||
#ifdef SUPPORT_XATTRS
|
||||
fprintf(F," -f, --fake-super display attributes including fake-super xattrs\n");
|
||||
#endif
|
||||
|
||||
2
token.c
2
token.c
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (C) 1996 Andrew Tridgell
|
||||
* Copyright (C) 1996 Paul Mackerras
|
||||
* Copyright (C) 2003-2007 Wayne Davison
|
||||
* Copyright (C) 2003-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -26,6 +26,7 @@ int am_root = 0;
|
||||
int read_only = 1;
|
||||
int list_only = 0;
|
||||
int preserve_perms = 0;
|
||||
int preserve_executability = 0;
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
|
||||
34
uidlist.c
34
uidlist.c
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright (C) 1996 Andrew Tridgell
|
||||
* Copyright (C) 1996 Paul Mackerras
|
||||
* Copyright (C) 2004-2007 Wayne Davison
|
||||
* Copyright (C) 2004-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -43,7 +43,7 @@ extern int numeric_ids;
|
||||
|
||||
struct idlist {
|
||||
struct idlist *next;
|
||||
char *name;
|
||||
const char *name;
|
||||
id_t id, id2;
|
||||
uint16 flags;
|
||||
};
|
||||
@@ -51,7 +51,7 @@ struct idlist {
|
||||
static struct idlist *uidlist;
|
||||
static struct idlist *gidlist;
|
||||
|
||||
static struct idlist *add_to_list(struct idlist **root, id_t id, char *name,
|
||||
static struct idlist *add_to_list(struct idlist **root, id_t id, const char *name,
|
||||
id_t id2, uint16 flags)
|
||||
{
|
||||
struct idlist *node = new(struct idlist);
|
||||
@@ -67,7 +67,7 @@ static struct idlist *add_to_list(struct idlist **root, id_t id, char *name,
|
||||
}
|
||||
|
||||
/* turn a uid into a user name */
|
||||
static char *uid_to_name(uid_t uid)
|
||||
static const char *uid_to_name(uid_t uid)
|
||||
{
|
||||
struct passwd *pass = getpwuid(uid);
|
||||
if (pass)
|
||||
@@ -76,7 +76,7 @@ static char *uid_to_name(uid_t uid)
|
||||
}
|
||||
|
||||
/* turn a gid into a group name */
|
||||
static char *gid_to_name(gid_t gid)
|
||||
static const char *gid_to_name(gid_t gid)
|
||||
{
|
||||
struct group *grp = getgrgid(gid);
|
||||
if (grp)
|
||||
@@ -84,7 +84,7 @@ static char *gid_to_name(gid_t gid)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static uid_t map_uid(uid_t id, char *name)
|
||||
static uid_t map_uid(uid_t id, const char *name)
|
||||
{
|
||||
uid_t uid;
|
||||
if (id != 0 && name_to_uid(name, &uid))
|
||||
@@ -92,7 +92,7 @@ static uid_t map_uid(uid_t id, char *name)
|
||||
return id;
|
||||
}
|
||||
|
||||
static gid_t map_gid(gid_t id, char *name)
|
||||
static gid_t map_gid(gid_t id, const char *name)
|
||||
{
|
||||
gid_t gid;
|
||||
if (id != 0 && name_to_gid(name, &gid))
|
||||
@@ -160,7 +160,7 @@ static int is_in_group(gid_t gid)
|
||||
}
|
||||
|
||||
/* Add a uid to the list of uids. Only called on receiving side. */
|
||||
static struct idlist *recv_add_uid(uid_t id, char *name)
|
||||
static struct idlist *recv_add_uid(uid_t id, const char *name)
|
||||
{
|
||||
uid_t id2 = name ? map_uid(id, name) : id;
|
||||
struct idlist *node;
|
||||
@@ -176,7 +176,7 @@ static struct idlist *recv_add_uid(uid_t id, char *name)
|
||||
}
|
||||
|
||||
/* Add a gid to the list of gids. Only called on receiving side. */
|
||||
static struct idlist *recv_add_gid(gid_t id, char *name)
|
||||
static struct idlist *recv_add_gid(gid_t id, const char *name)
|
||||
{
|
||||
gid_t id2 = name ? map_gid(id, name) : id;
|
||||
struct idlist *node;
|
||||
@@ -237,7 +237,7 @@ gid_t match_gid(gid_t gid, uint16 *flags_ptr)
|
||||
}
|
||||
|
||||
/* Add a uid to the list of uids. Only called on sending side. */
|
||||
char *add_uid(uid_t uid)
|
||||
const char *add_uid(uid_t uid)
|
||||
{
|
||||
struct idlist *list;
|
||||
struct idlist *node;
|
||||
@@ -255,7 +255,7 @@ char *add_uid(uid_t uid)
|
||||
}
|
||||
|
||||
/* Add a gid to the list of gids. Only called on sending side. */
|
||||
char *add_gid(gid_t gid)
|
||||
const char *add_gid(gid_t gid)
|
||||
{
|
||||
struct idlist *list;
|
||||
struct idlist *node;
|
||||
@@ -316,6 +316,10 @@ uid_t recv_user_name(int f, uid_t uid)
|
||||
if (!name)
|
||||
out_of_memory("recv_user_name");
|
||||
read_sbuf(f, name, len);
|
||||
if (numeric_ids < 0) {
|
||||
free(name);
|
||||
name = NULL;
|
||||
}
|
||||
node = recv_add_uid(uid, name); /* node keeps name's memory */
|
||||
return node->id2;
|
||||
}
|
||||
@@ -328,6 +332,10 @@ gid_t recv_group_name(int f, gid_t gid, uint16 *flags_ptr)
|
||||
if (!name)
|
||||
out_of_memory("recv_group_name");
|
||||
read_sbuf(f, name, len);
|
||||
if (numeric_ids < 0) {
|
||||
free(name);
|
||||
name = NULL;
|
||||
}
|
||||
node = recv_add_gid(gid, name); /* node keeps name's memory */
|
||||
if (flags_ptr && node->flags & FLAG_SKIP_GROUP)
|
||||
*flags_ptr |= FLAG_SKIP_GROUP;
|
||||
@@ -341,13 +349,13 @@ void recv_id_list(int f, struct file_list *flist)
|
||||
id_t id;
|
||||
int i;
|
||||
|
||||
if ((preserve_uid || preserve_acls) && !numeric_ids) {
|
||||
if ((preserve_uid || preserve_acls) && numeric_ids <= 0) {
|
||||
/* read the uid list */
|
||||
while ((id = read_varint30(f)) != 0)
|
||||
recv_user_name(f, id);
|
||||
}
|
||||
|
||||
if ((preserve_gid || preserve_acls) && !numeric_ids) {
|
||||
if ((preserve_gid || preserve_acls) && numeric_ids <= 0) {
|
||||
/* read the gid list */
|
||||
while ((id = read_varint30(f)) != 0)
|
||||
recv_group_name(f, id, NULL);
|
||||
|
||||
402
util.c
402
util.c
@@ -4,7 +4,7 @@
|
||||
* Copyright (C) 1996-2000 Andrew Tridgell
|
||||
* Copyright (C) 1996 Paul Mackerras
|
||||
* Copyright (C) 2001, 2002 Martin Pool <mbp@samba.org>
|
||||
* Copyright (C) 2003-2007 Wayne Davison
|
||||
* Copyright (C) 2003-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -29,11 +29,12 @@ extern int module_id;
|
||||
extern int modify_window;
|
||||
extern int relative_paths;
|
||||
extern int human_readable;
|
||||
extern int preserve_xattrs;
|
||||
extern char *module_dir;
|
||||
extern unsigned int module_dirlen;
|
||||
extern mode_t orig_umask;
|
||||
extern char *partial_dir;
|
||||
extern struct filter_list_struct server_filter_list;
|
||||
extern struct filter_list_struct daemon_filter_list;
|
||||
|
||||
int sanitize_paths = 0;
|
||||
|
||||
@@ -147,8 +148,9 @@ int set_modtime(const char *fname, time_t modtime, mode_t mode)
|
||||
t[1].tv_usec = 0;
|
||||
# ifdef HAVE_LUTIMES
|
||||
if (S_ISLNK(mode)) {
|
||||
lutimes(fname, t);
|
||||
return 0; /* ignore errors */
|
||||
if (lutimes(fname, t) < 0)
|
||||
return errno == ENOSYS ? 1 : -1;
|
||||
return 0;
|
||||
}
|
||||
# endif
|
||||
return utimes(fname, t);
|
||||
@@ -263,6 +265,8 @@ static int safe_read(int desc, char *ptr, size_t len)
|
||||
|
||||
/* Copy a file. If ofd < 0, copy_file unlinks and opens the "dest" file.
|
||||
* Otherwise, it just writes to and closes the provided file descriptor.
|
||||
* In either case, if --xattrs are being preserved, the dest file will
|
||||
* have its xattrs set from the source file.
|
||||
*
|
||||
* This is used in conjunction with the --temp-dir, --backup, and
|
||||
* --copy-dest options. */
|
||||
@@ -274,38 +278,54 @@ int copy_file(const char *source, const char *dest, int ofd,
|
||||
int len; /* Number of bytes read into `buf'. */
|
||||
|
||||
if ((ifd = do_open(source, O_RDONLY, 0)) < 0) {
|
||||
int save_errno = errno;
|
||||
rsyserr(FERROR_XFER, errno, "open %s", full_fname(source));
|
||||
errno = save_errno;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ofd < 0) {
|
||||
if (robust_unlink(dest) && errno != ENOENT) {
|
||||
int save_errno = errno;
|
||||
rsyserr(FERROR_XFER, errno, "unlink %s", full_fname(dest));
|
||||
errno = save_errno;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((ofd = do_open(dest, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, mode)) < 0
|
||||
&& (!create_bak_dir || errno != ENOENT || make_bak_dir(dest) < 0
|
||||
|| (ofd = do_open(dest, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, mode)) < 0)) {
|
||||
rsyserr(FERROR_XFER, errno, "open %s", full_fname(dest));
|
||||
close(ifd);
|
||||
return -1;
|
||||
if ((ofd = do_open(dest, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, mode)) < 0) {
|
||||
int save_errno = errno ? errno : EINVAL; /* 0 paranoia */
|
||||
if (create_bak_dir && errno == ENOENT && make_bak_dir(dest) == 0) {
|
||||
if ((ofd = do_open(dest, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, mode)) < 0)
|
||||
save_errno = errno ? errno : save_errno;
|
||||
else
|
||||
save_errno = 0;
|
||||
}
|
||||
if (save_errno) {
|
||||
rsyserr(FERROR_XFER, save_errno, "open %s", full_fname(dest));
|
||||
close(ifd);
|
||||
errno = save_errno;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while ((len = safe_read(ifd, buf, sizeof buf)) > 0) {
|
||||
if (full_write(ofd, buf, len) < 0) {
|
||||
int save_errno = errno;
|
||||
rsyserr(FERROR_XFER, errno, "write %s", full_fname(dest));
|
||||
close(ifd);
|
||||
close(ofd);
|
||||
errno = save_errno;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (len < 0) {
|
||||
int save_errno = errno;
|
||||
rsyserr(FERROR_XFER, errno, "read %s", full_fname(source));
|
||||
close(ifd);
|
||||
close(ofd);
|
||||
errno = save_errno;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -315,11 +335,18 @@ int copy_file(const char *source, const char *dest, int ofd,
|
||||
}
|
||||
|
||||
if (close(ofd) < 0) {
|
||||
int save_errno = errno;
|
||||
rsyserr(FERROR_XFER, errno, "close failed on %s",
|
||||
full_fname(dest));
|
||||
errno = save_errno;
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_XATTRS
|
||||
if (preserve_xattrs)
|
||||
copy_xattrs(source, dest);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -400,8 +427,11 @@ int robust_rename(const char *from, const char *to, const char *partialptr,
|
||||
switch (errno) {
|
||||
#ifdef ETXTBSY
|
||||
case ETXTBSY:
|
||||
if (robust_unlink(to) != 0)
|
||||
if (robust_unlink(to) != 0) {
|
||||
errno = ETXTBSY;
|
||||
return -1;
|
||||
}
|
||||
errno = ETXTBSY;
|
||||
break;
|
||||
#endif
|
||||
case EXDEV:
|
||||
@@ -465,31 +495,27 @@ void kill_all(int sig)
|
||||
}
|
||||
|
||||
/** Turn a user name into a uid */
|
||||
int name_to_uid(const char *name, uid_t *uid)
|
||||
int name_to_uid(const char *name, uid_t *uid_p)
|
||||
{
|
||||
struct passwd *pass;
|
||||
if (!name || !*name)
|
||||
return 0;
|
||||
pass = getpwnam(name);
|
||||
if (pass) {
|
||||
*uid = pass->pw_uid;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
if (!(pass = getpwnam(name)))
|
||||
return 0;
|
||||
*uid_p = pass->pw_uid;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/** Turn a group name into a gid */
|
||||
int name_to_gid(const char *name, gid_t *gid)
|
||||
int name_to_gid(const char *name, gid_t *gid_p)
|
||||
{
|
||||
struct group *grp;
|
||||
if (!name || !*name)
|
||||
return 0;
|
||||
grp = getgrnam(name);
|
||||
if (grp) {
|
||||
*gid = grp->gr_gid;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
if (!(grp = getgrnam(name)))
|
||||
return 0;
|
||||
*gid_p = grp->gr_gid;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/** Lock a byte range in a open file */
|
||||
@@ -506,82 +532,172 @@ int lock_range(int fd, int offset, int len)
|
||||
return fcntl(fd,F_SETLK,&lock) == 0;
|
||||
}
|
||||
|
||||
static int filter_server_path(char *arg)
|
||||
{
|
||||
char *s;
|
||||
#define ENSURE_MEMSPACE(buf, type, sz, req) \
|
||||
if ((req) > sz && !(buf = realloc_array(buf, type, sz = MAX(sz * 2, req)))) \
|
||||
out_of_memory("glob_expand")
|
||||
|
||||
if (server_filter_list.head) {
|
||||
for (s = arg; (s = strchr(s, '/')) != NULL; ) {
|
||||
*s = '\0';
|
||||
if (check_filter(&server_filter_list, arg, 1) < 0) {
|
||||
/* We must leave arg truncated! */
|
||||
return 1;
|
||||
}
|
||||
*s++ = '/';
|
||||
static inline void call_glob_match(const char *name, int len, int from_glob,
|
||||
char *arg, int abpos, int fbpos);
|
||||
|
||||
static struct glob_data {
|
||||
char *arg_buf, *filt_buf, **argv;
|
||||
int absize, fbsize, maxargs, argc;
|
||||
} glob;
|
||||
|
||||
static void glob_match(char *arg, int abpos, int fbpos)
|
||||
{
|
||||
int len;
|
||||
char *slash;
|
||||
|
||||
while (*arg == '.' && arg[1] == '/') {
|
||||
if (fbpos < 0) {
|
||||
ENSURE_MEMSPACE(glob.filt_buf, char, glob.fbsize, glob.absize);
|
||||
memcpy(glob.filt_buf, glob.arg_buf, abpos + 1);
|
||||
fbpos = abpos;
|
||||
}
|
||||
ENSURE_MEMSPACE(glob.arg_buf, char, glob.absize, abpos + 3);
|
||||
glob.arg_buf[abpos++] = *arg++;
|
||||
glob.arg_buf[abpos++] = *arg++;
|
||||
glob.arg_buf[abpos] = '\0';
|
||||
}
|
||||
return 0;
|
||||
if ((slash = strchr(arg, '/')) != NULL) {
|
||||
*slash = '\0';
|
||||
len = slash - arg;
|
||||
} else
|
||||
len = strlen(arg);
|
||||
if (strpbrk(arg, "*?[")) {
|
||||
struct dirent *di;
|
||||
DIR *d;
|
||||
|
||||
if (!(d = opendir(abpos ? glob.arg_buf : ".")))
|
||||
return;
|
||||
while ((di = readdir(d)) != NULL) {
|
||||
char *dname = d_name(di);
|
||||
if (dname[0] == '.' && (dname[1] == '\0'
|
||||
|| (dname[1] == '.' && dname[2] == '\0')))
|
||||
continue;
|
||||
if (!wildmatch(arg, dname))
|
||||
continue;
|
||||
call_glob_match(dname, strlen(dname), 1,
|
||||
slash ? arg + len + 1 : NULL,
|
||||
abpos, fbpos);
|
||||
}
|
||||
closedir(d);
|
||||
} else {
|
||||
call_glob_match(arg, len, 0,
|
||||
slash ? arg + len + 1 : NULL,
|
||||
abpos, fbpos);
|
||||
}
|
||||
if (slash)
|
||||
*slash = '/';
|
||||
}
|
||||
|
||||
void glob_expand(char *s, char ***argv_ptr, int *argc_ptr, int *maxargs_ptr)
|
||||
static inline void call_glob_match(const char *name, int len, int from_glob,
|
||||
char *arg, int abpos, int fbpos)
|
||||
{
|
||||
char **argv = *argv_ptr;
|
||||
int argc = *argc_ptr;
|
||||
int maxargs = *maxargs_ptr;
|
||||
#if !defined HAVE_GLOB || !defined HAVE_GLOB_H
|
||||
if (argc == maxargs) {
|
||||
maxargs += MAX_ARGS;
|
||||
if (!(argv = realloc_array(argv, char *, maxargs)))
|
||||
out_of_memory("glob_expand");
|
||||
*argv_ptr = argv;
|
||||
*maxargs_ptr = maxargs;
|
||||
}
|
||||
if (!*s)
|
||||
s = ".";
|
||||
s = argv[argc++] = strdup(s);
|
||||
filter_server_path(s);
|
||||
#else
|
||||
glob_t globbuf;
|
||||
char *use_buf;
|
||||
|
||||
if (maxargs <= argc)
|
||||
return;
|
||||
if (!*s)
|
||||
s = ".";
|
||||
ENSURE_MEMSPACE(glob.arg_buf, char, glob.absize, abpos + len + 2);
|
||||
memcpy(glob.arg_buf + abpos, name, len);
|
||||
abpos += len;
|
||||
glob.arg_buf[abpos] = '\0';
|
||||
|
||||
if (fbpos >= 0) {
|
||||
ENSURE_MEMSPACE(glob.filt_buf, char, glob.fbsize, fbpos + len + 2);
|
||||
memcpy(glob.filt_buf + fbpos, name, len);
|
||||
fbpos += len;
|
||||
glob.filt_buf[fbpos] = '\0';
|
||||
use_buf = glob.filt_buf;
|
||||
} else
|
||||
use_buf = glob.arg_buf;
|
||||
|
||||
if (from_glob || (arg && len)) {
|
||||
STRUCT_STAT st;
|
||||
int is_dir;
|
||||
|
||||
if (do_stat(glob.arg_buf, &st) != 0)
|
||||
return;
|
||||
is_dir = S_ISDIR(st.st_mode) != 0;
|
||||
if (arg && !is_dir)
|
||||
return;
|
||||
|
||||
if (daemon_filter_list.head
|
||||
&& check_filter(&daemon_filter_list, FLOG, use_buf, is_dir) < 0)
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg) {
|
||||
glob.arg_buf[abpos++] = '/';
|
||||
glob.arg_buf[abpos] = '\0';
|
||||
if (fbpos >= 0) {
|
||||
glob.filt_buf[fbpos++] = '/';
|
||||
glob.filt_buf[fbpos] = '\0';
|
||||
}
|
||||
glob_match(arg, abpos, fbpos);
|
||||
} else {
|
||||
ENSURE_MEMSPACE(glob.argv, char *, glob.maxargs, glob.argc + 1);
|
||||
if (!(glob.argv[glob.argc++] = strdup(glob.arg_buf)))
|
||||
out_of_memory("glob_match");
|
||||
}
|
||||
}
|
||||
|
||||
/* This routine performs wild-card expansion of the pathname in "arg". Any
|
||||
* daemon-excluded files/dirs will not be matched by the wildcards. Returns 0
|
||||
* if a wild-card string is the only returned item (due to matching nothing). */
|
||||
int glob_expand(const char *arg, char ***argv_p, int *argc_p, int *maxargs_p)
|
||||
{
|
||||
int ret, save_argc;
|
||||
char *s;
|
||||
|
||||
if (!arg) {
|
||||
if (glob.filt_buf)
|
||||
free(glob.filt_buf);
|
||||
free(glob.arg_buf);
|
||||
memset(&glob, 0, sizeof glob);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (sanitize_paths)
|
||||
s = sanitize_path(NULL, s, "", 0);
|
||||
else
|
||||
s = strdup(s);
|
||||
if (!s)
|
||||
out_of_memory("glob_expand");
|
||||
|
||||
memset(&globbuf, 0, sizeof globbuf);
|
||||
if (!filter_server_path(s))
|
||||
glob(s, 0, NULL, &globbuf);
|
||||
if (MAX((int)globbuf.gl_pathc, 1) > maxargs - argc) {
|
||||
maxargs += globbuf.gl_pathc + MAX_ARGS;
|
||||
if (!(argv = realloc_array(argv, char *, maxargs)))
|
||||
out_of_memory("glob_expand");
|
||||
*argv_ptr = argv;
|
||||
*maxargs_ptr = maxargs;
|
||||
}
|
||||
if (globbuf.gl_pathc == 0)
|
||||
argv[argc++] = s;
|
||||
s = sanitize_path(NULL, arg, "", 0, SP_KEEP_DOT_DIRS);
|
||||
else {
|
||||
int i;
|
||||
free(s);
|
||||
for (i = 0; i < (int)globbuf.gl_pathc; i++) {
|
||||
if (!(argv[argc++] = strdup(globbuf.gl_pathv[i])))
|
||||
out_of_memory("glob_expand");
|
||||
}
|
||||
s = strdup(arg);
|
||||
if (!s)
|
||||
out_of_memory("glob_expand");
|
||||
clean_fname(s, CFN_KEEP_DOT_DIRS
|
||||
| CFN_KEEP_TRAILING_SLASH
|
||||
| CFN_COLLAPSE_DOT_DOT_DIRS);
|
||||
}
|
||||
globfree(&globbuf);
|
||||
#endif
|
||||
*argc_ptr = argc;
|
||||
|
||||
ENSURE_MEMSPACE(glob.arg_buf, char, glob.absize, MAXPATHLEN);
|
||||
*glob.arg_buf = '\0';
|
||||
|
||||
glob.argc = save_argc = *argc_p;
|
||||
glob.argv = *argv_p;
|
||||
glob.maxargs = *maxargs_p;
|
||||
|
||||
ENSURE_MEMSPACE(glob.argv, char *, glob.maxargs, 100);
|
||||
|
||||
glob_match(s, 0, -1);
|
||||
|
||||
/* The arg didn't match anything, so add the failed arg to the list. */
|
||||
if (glob.argc == save_argc) {
|
||||
ENSURE_MEMSPACE(glob.argv, char *, glob.maxargs, glob.argc + 1);
|
||||
glob.argv[glob.argc++] = s;
|
||||
ret = 0;
|
||||
} else {
|
||||
free(s);
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
*maxargs_p = glob.maxargs;
|
||||
*argv_p = glob.argv;
|
||||
*argc_p = glob.argc;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* This routine is only used in daemon mode. */
|
||||
void glob_expand_module(char *base1, char *arg, char ***argv_ptr, int *argc_ptr, int *maxargs_ptr)
|
||||
void glob_expand_module(char *base1, char *arg, char ***argv_p, int *argc_p, int *maxargs_p)
|
||||
{
|
||||
char *p, *s;
|
||||
char *base = base1;
|
||||
@@ -603,7 +719,7 @@ void glob_expand_module(char *base1, char *arg, char ***argv_ptr, int *argc_ptr,
|
||||
for (s = arg; *s; s = p + base_len) {
|
||||
if ((p = strstr(s, base)) != NULL)
|
||||
*p = '\0'; /* split it at this point */
|
||||
glob_expand(s, argv_ptr, argc_ptr, maxargs_ptr);
|
||||
glob_expand(s, argv_p, argc_p, maxargs_p);
|
||||
if (!p)
|
||||
break;
|
||||
}
|
||||
@@ -690,13 +806,13 @@ int count_dir_elements(const char *p)
|
||||
return cnt;
|
||||
}
|
||||
|
||||
/* Turns multiple adjacent slashes into a single slash, drops interior "."
|
||||
* elements, drops an intial "./" unless CFN_KEEP_LEADING_DOT_DIR is flagged,
|
||||
* will even drop a trailing '.' after a '/' if CFN_DROP_TRAILING_DOT_DIR is
|
||||
* flagged, removes a trailing slash (perhaps after removing the aforementioned
|
||||
* dot) unless CFN_KEEP_TRAILING_SLASH is flagged, will even collapse ".."
|
||||
* elements (except at the start of the string) if CFN_COLLAPSE_DOT_DOT_DIRS
|
||||
* is flagged. If the resulting name would be empty, we return ".". */
|
||||
/* Turns multiple adjacent slashes into a single slash, drops all leading or
|
||||
* interior "." elements unless CFN_KEEP_DOT_DIRS is flagged. Will also drop
|
||||
* a trailing '.' after a '/' if CFN_DROP_TRAILING_DOT_DIR is flagged, removes
|
||||
* a trailing slash (perhaps after removing the aforementioned dot) unless
|
||||
* CFN_KEEP_TRAILING_SLASH is flagged, and will also collapse ".." elements
|
||||
* (except at the start) if CFN_COLLAPSE_DOT_DOT_DIRS is flagged. If the
|
||||
* resulting name would be empty, returns ".". */
|
||||
unsigned int clean_fname(char *name, int flags)
|
||||
{
|
||||
char *limit = name - 1, *t = name, *f = name;
|
||||
@@ -707,7 +823,7 @@ unsigned int clean_fname(char *name, int flags)
|
||||
|
||||
if ((anchored = *f == '/') != 0)
|
||||
*t++ = *f++;
|
||||
else if (flags & CFN_KEEP_LEADING_DOT_DIR && *f == '.' && f[1] == '/') {
|
||||
else if (flags & CFN_KEEP_DOT_DIRS && *f == '.' && f[1] == '/') {
|
||||
*t++ = *f++;
|
||||
*t++ = *f++;
|
||||
}
|
||||
@@ -719,7 +835,7 @@ unsigned int clean_fname(char *name, int flags)
|
||||
}
|
||||
if (*f == '.') {
|
||||
/* discard interior "." dirs */
|
||||
if (f[1] == '/') {
|
||||
if (f[1] == '/' && !(flags & CFN_KEEP_DOT_DIRS)) {
|
||||
f += 2;
|
||||
continue;
|
||||
}
|
||||
@@ -776,10 +892,11 @@ unsigned int clean_fname(char *name, int flags)
|
||||
* ALWAYS collapses ".." elements (except for those at the start of the
|
||||
* string up to "depth" deep). If the resulting name would be empty,
|
||||
* change it into a ".". */
|
||||
char *sanitize_path(char *dest, const char *p, const char *rootdir, int depth)
|
||||
char *sanitize_path(char *dest, const char *p, const char *rootdir, int depth,
|
||||
int flags)
|
||||
{
|
||||
char *start, *sanp;
|
||||
int rlen = 0, leave_one_dotdir = relative_paths;
|
||||
int rlen = 0, drop_dot_dirs = !relative_paths || !(flags & SP_KEEP_DOT_DIRS);
|
||||
|
||||
if (dest != p) {
|
||||
int plen = strlen(p);
|
||||
@@ -802,21 +919,22 @@ char *sanitize_path(char *dest, const char *p, const char *rootdir, int depth)
|
||||
}
|
||||
}
|
||||
|
||||
if (drop_dot_dirs) {
|
||||
while (*p == '.' && p[1] == '/')
|
||||
p += 2;
|
||||
}
|
||||
|
||||
start = sanp = dest + rlen;
|
||||
/* This loop iterates once per filename component in p, pointing at
|
||||
* the start of the name (past any prior slash) for each iteration. */
|
||||
while (*p) {
|
||||
/* discard leading or extra slashes */
|
||||
if (*p == '/') {
|
||||
p++;
|
||||
continue;
|
||||
}
|
||||
/* this loop iterates once per filename component in p.
|
||||
* both p (and sanp if the original had a slash) should
|
||||
* always be left pointing after a slash
|
||||
*/
|
||||
if (*p == '.' && (p[1] == '/' || p[1] == '\0')) {
|
||||
if (leave_one_dotdir && p[1])
|
||||
leave_one_dotdir = 0;
|
||||
else {
|
||||
if (drop_dot_dirs) {
|
||||
if (*p == '.' && (p[1] == '/' || p[1] == '\0')) {
|
||||
/* skip "." component */
|
||||
p++;
|
||||
continue;
|
||||
@@ -829,10 +947,8 @@ char *sanitize_path(char *dest, const char *p, const char *rootdir, int depth)
|
||||
if (sanp != start) {
|
||||
/* back up sanp one level */
|
||||
--sanp; /* now pointing at slash */
|
||||
while (sanp > start && sanp[-1] != '/') {
|
||||
/* skip back up to slash */
|
||||
while (sanp > start && sanp[-1] != '/')
|
||||
sanp--;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -856,7 +972,7 @@ char *sanitize_path(char *dest, const char *p, const char *rootdir, int depth)
|
||||
/* Like chdir(), but it keeps track of the current directory (in the
|
||||
* global "curr_dir"), and ensures that the path size doesn't overflow.
|
||||
* Also cleans the path using the clean_fname() function. */
|
||||
int push_dir(const char *dir, int set_path_only)
|
||||
int change_dir(const char *dir, int set_path_only)
|
||||
{
|
||||
static int initialised;
|
||||
unsigned int len;
|
||||
@@ -874,21 +990,26 @@ int push_dir(const char *dir, int set_path_only)
|
||||
if (len == 1 && *dir == '.')
|
||||
return 1;
|
||||
|
||||
if ((*dir == '/' ? len : curr_dir_len + 1 + len) >= sizeof curr_dir) {
|
||||
errno = ENAMETOOLONG;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!set_path_only && chdir(dir))
|
||||
return 0;
|
||||
|
||||
if (*dir == '/') {
|
||||
if (len >= sizeof curr_dir) {
|
||||
errno = ENAMETOOLONG;
|
||||
return 0;
|
||||
}
|
||||
if (!set_path_only && chdir(dir))
|
||||
return 0;
|
||||
memcpy(curr_dir, dir, len + 1);
|
||||
curr_dir_len = len;
|
||||
} else {
|
||||
curr_dir[curr_dir_len++] = '/';
|
||||
memcpy(curr_dir + curr_dir_len, dir, len + 1);
|
||||
curr_dir_len += len;
|
||||
if (curr_dir_len + 1 + len >= sizeof curr_dir) {
|
||||
errno = ENAMETOOLONG;
|
||||
return 0;
|
||||
}
|
||||
curr_dir[curr_dir_len] = '/';
|
||||
memcpy(curr_dir + curr_dir_len + 1, dir, len + 1);
|
||||
|
||||
if (!set_path_only && chdir(curr_dir)) {
|
||||
curr_dir[curr_dir_len] = '\0';
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
curr_dir_len = clean_fname(curr_dir, CFN_COLLAPSE_DOT_DOT_DIRS);
|
||||
@@ -898,26 +1019,8 @@ int push_dir(const char *dir, int set_path_only)
|
||||
curr_dir_depth = count_dir_elements(curr_dir + module_dirlen);
|
||||
}
|
||||
|
||||
if (verbose >= 5)
|
||||
rprintf(FINFO, "[%s] dir is now %s\n", who_am_i(), curr_dir);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse a push_dir() call. You must pass in an absolute path
|
||||
* that was copied from a prior value of "curr_dir".
|
||||
**/
|
||||
int pop_dir(const char *dir)
|
||||
{
|
||||
if (chdir(dir))
|
||||
return 0;
|
||||
|
||||
curr_dir_len = strlcpy(curr_dir, dir, sizeof curr_dir);
|
||||
if (curr_dir_len >= sizeof curr_dir)
|
||||
curr_dir_len = sizeof curr_dir - 1;
|
||||
if (sanitize_paths)
|
||||
curr_dir_depth = count_dir_elements(curr_dir + module_dirlen);
|
||||
if (verbose >= 5 && !set_path_only)
|
||||
rprintf(FINFO, "[%s] change_dir(%s)\n", who_am_i(), curr_dir);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -977,13 +1080,13 @@ char *partial_dir_fname(const char *fname)
|
||||
fn = fname;
|
||||
if ((int)pathjoin(t, sz, partial_dir, fn) >= sz)
|
||||
return NULL;
|
||||
if (server_filter_list.head) {
|
||||
if (daemon_filter_list.head) {
|
||||
t = strrchr(partial_fname, '/');
|
||||
*t = '\0';
|
||||
if (check_filter(&server_filter_list, partial_fname, 1) < 0)
|
||||
if (check_filter(&daemon_filter_list, FLOG, partial_fname, 1) < 0)
|
||||
return NULL;
|
||||
*t = '/';
|
||||
if (check_filter(&server_filter_list, partial_fname, 0) < 0)
|
||||
if (check_filter(&daemon_filter_list, FLOG, partial_fname, 0) < 0)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1255,7 +1358,7 @@ void *_new_array(unsigned long num, unsigned int size, int use_calloc)
|
||||
return use_calloc ? calloc(num, size) : malloc(num * size);
|
||||
}
|
||||
|
||||
void *_realloc_array(void *ptr, unsigned int size, unsigned long num)
|
||||
void *_realloc_array(void *ptr, unsigned int size, size_t num)
|
||||
{
|
||||
if (num >= MALLOC_MAX/size)
|
||||
return NULL;
|
||||
@@ -1476,7 +1579,10 @@ void *expand_item_list(item_list *lp, size_t item_size,
|
||||
new_size += incr;
|
||||
else
|
||||
new_size *= 2;
|
||||
new_ptr = realloc_array(lp->items, char, new_size * item_size);
|
||||
if (new_size < lp->malloced)
|
||||
overflow_exit("expand_item_list");
|
||||
/* Using _realloc_array() lets us pass the size, not a type. */
|
||||
new_ptr = _realloc_array(lp->items, item_size, new_size);
|
||||
if (verbose >= 4) {
|
||||
rprintf(FINFO, "[%s] expand %s to %.0f bytes, did%s move\n",
|
||||
who_am_i(), desc, (double)new_size * item_size,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Test suite for the wildmatch code.
|
||||
*
|
||||
* Copyright (C) 2003-2007 Wayne Davison
|
||||
* Copyright (C) 2003-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
269
xattrs.c
269
xattrs.c
@@ -3,7 +3,7 @@
|
||||
* Written by Jay Fenlason, vaguely based on the ACLs patch.
|
||||
*
|
||||
* Copyright (C) 2004 Red Hat, Inc.
|
||||
* Copyright (C) 2006, 2007 Wayne Davison
|
||||
* Copyright (C) 2006-2008 Wayne Davison
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -47,7 +47,6 @@ extern int checksum_seed;
|
||||
#define XSTATE_ABBREV 0
|
||||
#define XSTATE_DONE 1
|
||||
#define XSTATE_TODO 2
|
||||
#define XSTATE_LOCAL 3
|
||||
|
||||
#define USER_PREFIX "user."
|
||||
#define UPRE_LEN ((int)sizeof USER_PREFIX - 1)
|
||||
@@ -63,13 +62,17 @@ extern int checksum_seed;
|
||||
#endif
|
||||
#define RPRE_LEN ((int)sizeof RSYNC_PREFIX - 1)
|
||||
|
||||
#define XSTAT_ATTR RSYNC_PREFIX "%stat"
|
||||
#define XACC_ACL_ATTR RSYNC_PREFIX "%aacl"
|
||||
#define XDEF_ACL_ATTR RSYNC_PREFIX "%dacl"
|
||||
#define XSTAT_SUFFIX "stat"
|
||||
#define XSTAT_ATTR RSYNC_PREFIX "%" XSTAT_SUFFIX
|
||||
#define XACC_ACL_SUFFIX "aacl"
|
||||
#define XACC_ACL_ATTR RSYNC_PREFIX "%" XACC_ACL_SUFFIX
|
||||
#define XDEF_ACL_SUFFIX "dacl"
|
||||
#define XDEF_ACL_ATTR RSYNC_PREFIX "%" XDEF_ACL_SUFFIX
|
||||
|
||||
typedef struct {
|
||||
char *datum, *name;
|
||||
size_t datum_len, name_len;
|
||||
int num;
|
||||
} rsync_xa;
|
||||
|
||||
static size_t namebuf_len = 0;
|
||||
@@ -111,6 +114,7 @@ static int rsync_xal_compare_names(const void *x1, const void *x2)
|
||||
static ssize_t get_xattr_names(const char *fname)
|
||||
{
|
||||
ssize_t list_len;
|
||||
double arg;
|
||||
|
||||
if (!namebuf) {
|
||||
namebuf_len = 1024;
|
||||
@@ -119,23 +123,26 @@ static ssize_t get_xattr_names(const char *fname)
|
||||
out_of_memory("get_xattr_names");
|
||||
}
|
||||
|
||||
/* The length returned includes all the '\0' terminators. */
|
||||
list_len = sys_llistxattr(fname, namebuf, namebuf_len);
|
||||
if (list_len > (ssize_t)namebuf_len) {
|
||||
list_len = -1;
|
||||
errno = ERANGE;
|
||||
}
|
||||
if (list_len >= 0)
|
||||
return list_len;
|
||||
if (errno == ENOTSUP)
|
||||
return 0;
|
||||
if (errno == ERANGE) {
|
||||
while (1) {
|
||||
/* The length returned includes all the '\0' terminators. */
|
||||
list_len = sys_llistxattr(fname, namebuf, namebuf_len);
|
||||
if (list_len >= 0) {
|
||||
if ((size_t)list_len <= namebuf_len)
|
||||
break;
|
||||
} else if (errno == ENOTSUP)
|
||||
return 0;
|
||||
else if (errno != ERANGE) {
|
||||
arg = (double)namebuf_len;
|
||||
got_error:
|
||||
rsyserr(FERROR_XFER, errno,
|
||||
"get_xattr_names: llistxattr(\"%s\",%.0f) failed",
|
||||
fname, arg);
|
||||
return -1;
|
||||
}
|
||||
list_len = sys_llistxattr(fname, NULL, 0);
|
||||
if (list_len < 0) {
|
||||
rsyserr(FERROR_XFER, errno,
|
||||
"get_xattr_names: llistxattr(\"%s\",0) failed",
|
||||
fname);
|
||||
return -1;
|
||||
arg = 0;
|
||||
goto got_error;
|
||||
}
|
||||
if (namebuf_len)
|
||||
free(namebuf);
|
||||
@@ -143,15 +150,9 @@ static ssize_t get_xattr_names(const char *fname)
|
||||
namebuf = new_array(char, namebuf_len);
|
||||
if (!namebuf)
|
||||
out_of_memory("get_xattr_names");
|
||||
list_len = sys_llistxattr(fname, namebuf, namebuf_len);
|
||||
if (list_len >= 0)
|
||||
return list_len;
|
||||
}
|
||||
|
||||
rsyserr(FERROR_XFER, errno,
|
||||
"get_xattr_names: llistxattr(\"%s\",%ld) failed",
|
||||
fname, (long)namebuf_len);
|
||||
return -1;
|
||||
return list_len;
|
||||
}
|
||||
|
||||
/* On entry, the *len_ptr parameter contains the size of the extra space we
|
||||
@@ -177,8 +178,9 @@ static char *get_xattr_data(const char *fname, const char *name, size_t *len_ptr
|
||||
|
||||
if (!datum_len && !extra_len)
|
||||
extra_len = 1; /* request non-zero amount of memory */
|
||||
if (datum_len + extra_len < datum_len /* checks for overflow */
|
||||
|| !(ptr = new_array(char, datum_len + extra_len)))
|
||||
if (datum_len + extra_len < datum_len)
|
||||
overflow_exit("get_xattr_data");
|
||||
if (!(ptr = new_array(char, datum_len + extra_len)))
|
||||
out_of_memory("get_xattr_data");
|
||||
|
||||
if (datum_len) {
|
||||
@@ -210,14 +212,14 @@ static int rsync_xal_get(const char *fname, item_list *xalp)
|
||||
#ifdef HAVE_LINUX_XATTRS
|
||||
int user_only = am_sender ? 0 : !am_root;
|
||||
#endif
|
||||
rsync_xa *rxa;
|
||||
int count;
|
||||
|
||||
/* This puts the name list into the "namebuf" buffer. */
|
||||
if ((list_len = get_xattr_names(fname)) < 0)
|
||||
return -1;
|
||||
|
||||
for (name = namebuf; list_len > 0; name += name_len) {
|
||||
rsync_xa *rxa;
|
||||
|
||||
name_len = strlen(name) + 1;
|
||||
list_len -= name_len;
|
||||
|
||||
@@ -233,7 +235,10 @@ static int rsync_xal_get(const char *fname, item_list *xalp)
|
||||
if (name_len > RPRE_LEN && name[RPRE_LEN] == '%'
|
||||
&& HAS_PREFIX(name, RSYNC_PREFIX)) {
|
||||
if ((am_sender && preserve_xattrs < 2)
|
||||
|| (am_root < 0 && strcmp(name, XSTAT_ATTR) == 0))
|
||||
|| (am_root < 0
|
||||
&& (strcmp(name+RPRE_LEN+1, XSTAT_SUFFIX) == 0
|
||||
|| strcmp(name+RPRE_LEN+1, XACC_ACL_SUFFIX) == 0
|
||||
|| strcmp(name+RPRE_LEN+1, XDEF_ACL_SUFFIX) == 0)))
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -255,14 +260,6 @@ static int rsync_xal_get(const char *fname, item_list *xalp)
|
||||
} else
|
||||
name_offset = datum_len;
|
||||
|
||||
#ifdef HAVE_LINUX_XATTRS
|
||||
if (am_root < 0 && name_len > RPRE_LEN && name[RPRE_LEN] != '%'
|
||||
&& HAS_PREFIX(name, RSYNC_PREFIX)) {
|
||||
name += RPRE_LEN;
|
||||
name_len -= RPRE_LEN;
|
||||
}
|
||||
#endif
|
||||
|
||||
rxa = EXPAND_ITEM_LIST(xalp, rsync_xa, RSYNC_XAL_INITIAL);
|
||||
rxa->name = ptr + name_offset;
|
||||
memcpy(rxa->name, name, name_len);
|
||||
@@ -270,8 +267,12 @@ static int rsync_xal_get(const char *fname, item_list *xalp)
|
||||
rxa->name_len = name_len;
|
||||
rxa->datum_len = datum_len;
|
||||
}
|
||||
if (xalp->count > 1)
|
||||
qsort(xalp->items, xalp->count, sizeof (rsync_xa), rsync_xal_compare_names);
|
||||
count = xalp->count;
|
||||
rxa = xalp->items;
|
||||
if (count > 1)
|
||||
qsort(rxa, count, sizeof (rsync_xa), rsync_xal_compare_names);
|
||||
for (rxa += count-1; count; count--, rxa--)
|
||||
rxa->num = count;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -287,6 +288,48 @@ int get_xattr(const char *fname, stat_x *sxp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int copy_xattrs(const char *source, const char *dest)
|
||||
{
|
||||
ssize_t list_len, name_len;
|
||||
size_t datum_len;
|
||||
char *name, *ptr;
|
||||
#ifdef HAVE_LINUX_XATTRS
|
||||
int user_only = am_sender ? 0 : !am_root;
|
||||
#endif
|
||||
|
||||
/* This puts the name list into the "namebuf" buffer. */
|
||||
if ((list_len = get_xattr_names(source)) < 0)
|
||||
return -1;
|
||||
|
||||
for (name = namebuf; list_len > 0; name += name_len) {
|
||||
name_len = strlen(name) + 1;
|
||||
list_len -= name_len;
|
||||
|
||||
#ifdef HAVE_LINUX_XATTRS
|
||||
/* We always ignore the system namespace, and non-root
|
||||
* ignores everything but the user namespace. */
|
||||
if (user_only ? !HAS_PREFIX(name, USER_PREFIX)
|
||||
: HAS_PREFIX(name, SYSTEM_PREFIX))
|
||||
continue;
|
||||
#endif
|
||||
|
||||
datum_len = 0;
|
||||
if (!(ptr = get_xattr_data(source, name, &datum_len, 0)))
|
||||
return -1;
|
||||
if (sys_lsetxattr(dest, name, ptr, datum_len) < 0) {
|
||||
int save_errno = errno ? errno : EINVAL;
|
||||
rsyserr(FERROR_XFER, errno,
|
||||
"rsync_xal_set: lsetxattr(\"%s\",\"%s\") failed",
|
||||
dest, name);
|
||||
errno = save_errno;
|
||||
return -1;
|
||||
}
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int find_matching_xattr(item_list *xalp)
|
||||
{
|
||||
size_t i, j;
|
||||
@@ -350,25 +393,32 @@ int send_xattr(stat_x *sxp, int f)
|
||||
int count = sxp->xattr->count;
|
||||
write_varint(f, count);
|
||||
for (rxa = sxp->xattr->items; count--; rxa++) {
|
||||
size_t name_len = rxa->name_len;
|
||||
const char *name = rxa->name;
|
||||
/* Strip the rsync prefix from disguised namespaces. */
|
||||
if (name_len > RPRE_LEN
|
||||
#ifdef HAVE_LINUX_XATTRS
|
||||
write_varint(f, rxa->name_len);
|
||||
write_varint(f, rxa->datum_len);
|
||||
write_buf(f, rxa->name, rxa->name_len);
|
||||
#else
|
||||
/* We strip the rsync prefix from disguised namespaces
|
||||
* and put everything else in the user namespace. */
|
||||
if (HAS_PREFIX(rxa->name, RSYNC_PREFIX)
|
||||
&& rxa->name[RPRE_LEN] != '%') {
|
||||
write_varint(f, rxa->name_len - RPRE_LEN);
|
||||
write_varint(f, rxa->datum_len);
|
||||
write_buf(f, rxa->name + RPRE_LEN, rxa->name_len - RPRE_LEN);
|
||||
} else {
|
||||
write_varint(f, rxa->name_len + UPRE_LEN);
|
||||
write_varint(f, rxa->datum_len);
|
||||
write_buf(f, USER_PREFIX, UPRE_LEN);
|
||||
write_buf(f, rxa->name, rxa->name_len);
|
||||
&& am_root < 0
|
||||
#endif
|
||||
&& name[RPRE_LEN] != '%' && HAS_PREFIX(name, RSYNC_PREFIX)) {
|
||||
name += RPRE_LEN;
|
||||
name_len -= RPRE_LEN;
|
||||
}
|
||||
#ifndef HAVE_LINUX_XATTRS
|
||||
else {
|
||||
/* Put everything else in the user namespace. */
|
||||
name_len += UPRE_LEN;
|
||||
}
|
||||
#endif
|
||||
write_varint(f, name_len);
|
||||
write_varint(f, rxa->datum_len);
|
||||
#ifndef HAVE_LINUX_XATTRS
|
||||
if (name_len > rxa->name_len) {
|
||||
write_buf(f, USER_PREFIX, UPRE_LEN);
|
||||
name_len -= UPRE_LEN;
|
||||
}
|
||||
#endif
|
||||
write_buf(f, name, name_len);
|
||||
if (rxa->datum_len > MAX_FULL_DATUM)
|
||||
write_buf(f, rxa->datum + 1, MAX_DIGEST_LEN);
|
||||
else
|
||||
@@ -459,18 +509,19 @@ int xattr_diff(struct file_struct *file, stat_x *sxp, int find_all)
|
||||
void send_xattr_request(const char *fname, struct file_struct *file, int f_out)
|
||||
{
|
||||
item_list *lst = rsync_xal_l.items;
|
||||
int j, cnt, prior_req = -1;
|
||||
int cnt, prior_req = 0;
|
||||
rsync_xa *rxa;
|
||||
|
||||
lst += F_XATTR(file);
|
||||
cnt = lst->count;
|
||||
for (rxa = lst->items, j = 0; j < cnt; rxa++, j++) {
|
||||
for (rxa = lst->items, cnt = lst->count; cnt--; rxa++) {
|
||||
if (rxa->datum_len <= MAX_FULL_DATUM)
|
||||
continue;
|
||||
switch (rxa->datum[0]) {
|
||||
case XSTATE_LOCAL:
|
||||
/* Items set locally will get cached by receiver. */
|
||||
rxa->datum[0] = XSTATE_DONE;
|
||||
case XSTATE_ABBREV:
|
||||
/* Items left abbreviated matched the sender's checksum, so
|
||||
* the receiver will cache the local data for future use. */
|
||||
if (am_generator)
|
||||
rxa->datum[0] = XSTATE_DONE;
|
||||
continue;
|
||||
case XSTATE_TODO:
|
||||
break;
|
||||
@@ -481,8 +532,8 @@ void send_xattr_request(const char *fname, struct file_struct *file, int f_out)
|
||||
/* Flag that we handled this abbreviated item. */
|
||||
rxa->datum[0] = XSTATE_DONE;
|
||||
|
||||
write_varint(f_out, j - prior_req);
|
||||
prior_req = j;
|
||||
write_varint(f_out, rxa->num - prior_req);
|
||||
prior_req = rxa->num;
|
||||
|
||||
if (fname) {
|
||||
size_t len = 0;
|
||||
@@ -504,27 +555,6 @@ void send_xattr_request(const char *fname, struct file_struct *file, int f_out)
|
||||
write_byte(f_out, 0); /* end the list */
|
||||
}
|
||||
|
||||
/* Any items set locally by the generator that the receiver doesn't
|
||||
* get told about get changed back to XSTATE_ABBREV. */
|
||||
void xattr_clear_locals(struct file_struct *file)
|
||||
{
|
||||
item_list *lst = rsync_xal_l.items;
|
||||
rsync_xa *rxa;
|
||||
int cnt;
|
||||
|
||||
if (F_XATTR(file) < 0)
|
||||
return;
|
||||
|
||||
lst += F_XATTR(file);
|
||||
cnt = lst->count;
|
||||
for (rxa = lst->items; cnt--; rxa++) {
|
||||
if (rxa->datum_len <= MAX_FULL_DATUM)
|
||||
continue;
|
||||
if (rxa->datum[0] == XSTATE_LOCAL)
|
||||
rxa->datum[0] = XSTATE_ABBREV;
|
||||
}
|
||||
}
|
||||
|
||||
/* When called by the sender, read the request from the generator and mark
|
||||
* any needed xattrs with a flag that lets us know they need to be sent to
|
||||
* the receiver. When called by the receiver, reads the sent data and
|
||||
@@ -534,7 +564,7 @@ int recv_xattr_request(struct file_struct *file, int f_in)
|
||||
item_list *lst = rsync_xal_l.items;
|
||||
char *old_datum, *name;
|
||||
rsync_xa *rxa;
|
||||
int rel_pos, cnt, got_xattr_data = 0;
|
||||
int rel_pos, cnt, num, got_xattr_data = 0;
|
||||
|
||||
if (F_XATTR(file) < 0) {
|
||||
rprintf(FERROR, "recv_xattr_request: internal data error!\n");
|
||||
@@ -544,13 +574,20 @@ int recv_xattr_request(struct file_struct *file, int f_in)
|
||||
|
||||
cnt = lst->count;
|
||||
rxa = lst->items;
|
||||
rxa -= 1;
|
||||
num = 0;
|
||||
while ((rel_pos = read_varint(f_in)) != 0) {
|
||||
rxa += rel_pos;
|
||||
cnt -= rel_pos;
|
||||
if (cnt < 0 || rxa->datum_len <= MAX_FULL_DATUM
|
||||
|| rxa->datum[0] != XSTATE_ABBREV) {
|
||||
rprintf(FERROR, "recv_xattr_request: internal abbrev error!\n");
|
||||
num += rel_pos;
|
||||
while (cnt && rxa->num < num) {
|
||||
rxa++;
|
||||
cnt--;
|
||||
}
|
||||
if (!cnt || rxa->num != num) {
|
||||
rprintf(FERROR, "[%s] could not find xattr #%d for %s\n",
|
||||
who_am_i(), num, f_name(file, NULL));
|
||||
exit_cleanup(RERR_STREAMIO);
|
||||
}
|
||||
if (rxa->datum_len <= MAX_FULL_DATUM || rxa->datum[0] != XSTATE_ABBREV) {
|
||||
rprintf(FERROR, "[%s] internal abbrev error!\n", who_am_i());
|
||||
exit_cleanup(RERR_STREAMIO);
|
||||
}
|
||||
|
||||
@@ -563,7 +600,7 @@ int recv_xattr_request(struct file_struct *file, int f_in)
|
||||
rxa->datum_len = read_varint(f_in);
|
||||
|
||||
if (rxa->name_len + rxa->datum_len < rxa->name_len)
|
||||
out_of_memory("recv_xattr_request"); /* overflow */
|
||||
overflow_exit("recv_xattr_request");
|
||||
rxa->datum = new_array(char, rxa->datum_len + rxa->name_len);
|
||||
if (!rxa->datum)
|
||||
out_of_memory("recv_xattr_request");
|
||||
@@ -584,7 +621,12 @@ int recv_xattr_request(struct file_struct *file, int f_in)
|
||||
void receive_xattr(struct file_struct *file, int f)
|
||||
{
|
||||
static item_list temp_xattr = EMPTY_ITEM_LIST;
|
||||
int count;
|
||||
int count, num;
|
||||
#ifdef HAVE_LINUX_XATTRS
|
||||
int need_sort = 0;
|
||||
#else
|
||||
int need_sort = 1;
|
||||
#endif
|
||||
int ndx = read_varint(f);
|
||||
|
||||
if (ndx < 0 || (size_t)ndx > rsync_xal_l.count) {
|
||||
@@ -603,17 +645,16 @@ void receive_xattr(struct file_struct *file, int f)
|
||||
temp_xattr.count = 0;
|
||||
}
|
||||
|
||||
while (count--) {
|
||||
for (num = 1; num <= count; num++) {
|
||||
char *ptr, *name;
|
||||
rsync_xa *rxa;
|
||||
size_t name_len = read_varint(f);
|
||||
size_t datum_len = read_varint(f);
|
||||
size_t dget_len = datum_len > MAX_FULL_DATUM ? 1 + MAX_DIGEST_LEN : datum_len;
|
||||
size_t extra_len = MIGHT_NEED_RPRE ? RPRE_LEN : 0;
|
||||
if (dget_len + extra_len < dget_len)
|
||||
out_of_memory("receive_xattr"); /* overflow */
|
||||
if (dget_len + extra_len + name_len < dget_len)
|
||||
out_of_memory("receive_xattr"); /* overflow */
|
||||
if ((dget_len + extra_len < dget_len)
|
||||
|| (dget_len + extra_len + name_len < dget_len))
|
||||
overflow_exit("receive_xattr");
|
||||
ptr = new_array(char, dget_len + extra_len + name_len);
|
||||
if (!ptr)
|
||||
out_of_memory("receive_xattr");
|
||||
@@ -627,14 +668,15 @@ void receive_xattr(struct file_struct *file, int f)
|
||||
}
|
||||
#ifdef HAVE_LINUX_XATTRS
|
||||
/* Non-root can only save the user namespace. */
|
||||
if (am_root <= 0 && !HAS_PREFIX(name, USER_PREFIX)) {
|
||||
if (!am_root) {
|
||||
free(ptr);
|
||||
continue;
|
||||
}
|
||||
name -= RPRE_LEN;
|
||||
name_len += RPRE_LEN;
|
||||
memcpy(name, RSYNC_PREFIX, RPRE_LEN);
|
||||
if (am_root <= 0 && !HAS_PREFIX(name, USER_PREFIX)) {
|
||||
if (!am_root) {
|
||||
free(ptr);
|
||||
continue;
|
||||
}
|
||||
name -= RPRE_LEN;
|
||||
name_len += RPRE_LEN;
|
||||
memcpy(name, RSYNC_PREFIX, RPRE_LEN);
|
||||
need_sort = 1;
|
||||
}
|
||||
#else
|
||||
/* This OS only has a user namespace, so we either
|
||||
@@ -663,8 +705,12 @@ void receive_xattr(struct file_struct *file, int f)
|
||||
rxa->datum = ptr;
|
||||
rxa->name_len = name_len;
|
||||
rxa->datum_len = datum_len;
|
||||
rxa->num = num;
|
||||
}
|
||||
|
||||
if (need_sort && count > 1)
|
||||
qsort(temp_xattr.items, count, sizeof (rsync_xa), rsync_xal_compare_names);
|
||||
|
||||
ndx = rsync_xal_l.count; /* pre-incremented count */
|
||||
rsync_xal_store(&temp_xattr); /* adds item to rsync_xal_l */
|
||||
|
||||
@@ -694,7 +740,8 @@ static int rsync_xal_set(const char *fname, item_list *xalp,
|
||||
ssize_t list_len;
|
||||
size_t i, len;
|
||||
char *name, *ptr, sum[MAX_DIGEST_LEN];
|
||||
int name_len, ret = 0;
|
||||
size_t name_len;
|
||||
int ret = 0;
|
||||
|
||||
/* This puts the current name list into the "namebuf" buffer. */
|
||||
if ((list_len = get_xattr_names(fname)) < 0)
|
||||
@@ -739,8 +786,6 @@ static int rsync_xal_set(const char *fname, item_list *xalp,
|
||||
sxp->st.st_mtime = (time_t)-1;
|
||||
|
||||
if (am_generator) { /* generator items stay abbreviated */
|
||||
if (rxas[i].datum[0] == XSTATE_ABBREV)
|
||||
rxas[i].datum[0] = XSTATE_LOCAL;
|
||||
free(ptr);
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user