我注意到,如果您中断rsync
,一些新目录仍然具有权限drwx------
,尽管当前的 umask 是0022
.
我在调用之前启动gdb
并尝试显式调用,但它没有效果:我希望新的目录有,但他们仍然有。umask(0)
mkdir()
drwxrwxrwx
drwx------
(在较新版本的 rsync 中,它们不再是drwx------
,但仍然不受 umask 影响)
如果我将命令更改为/bin/mkdir
,呼叫umask()
开始工作。似乎rsync
在使用一些魔法。
这是一个测试脚本:(由于某种原因,断点mkdir()
仅在从 ssh 复制时有效)
(
rm -rf /tmp/3 && mkdir -p /tmp/3 && cd /tmp/3 &&
#gdb -q -nx --args /bin/mkdir foo <<EOF
gdb -q -nx --args rsync -r --include=/profile.d --exclude="*" localhost:/etc/ ./ <<'EOF'
set width 0
set height 0
set pagination no
set breakpoint pending on
b mkdir
b mkdirat
run
del
print (char*)$rdi
call umask(0)
call mkdir("test")
fin
shell ls -l
p/o umask(0)
k
EOF
)
_
Reading symbols from /usr/bin/rsync...Reading symbols from /usr/bin/rsync...(no debugging symbols found)...done.
(no debugging symbols found)...done.
Missing separate debuginfos, use: debuginfo-install rsync-3.0.9-15.el7.x86_64
(gdb) (gdb) (gdb) (gdb) (gdb) Breakpoint 1 at 0x6c70
(gdb) Function "mkdirat" not defined.
Breakpoint 2 (mkdirat) pending.
(gdb) Starting program: /usr/bin/rsync -r --include=/profile.d --exclude=\* localhost:/etc/ ./
Detaching after fork from child process 15444.
Detaching after fork from child process 15464.
Breakpoint 1, 0x00007ffff76ee720 in mkdir () from /lib64/libc.so.6
(gdb) Delete all breakpoints? (y or n) [answered Y; input not from terminal]
mkdir 参数:
(gdb) $1 = 0x7fffffff9330 "profile.d"
以前的 umask 值:
(gdb) $2 = 0
的结果mkdir("test")
(gdb) $3 = 0
_
(gdb) Run till exit from #0 0x00007ffff76ee720 in mkdir () from /lib64/libc.so.6
0x000055555556845f in recv_generator ()
(gdb) total 8
drwx------ 2 il il 4096 Jan 28 20:02 profile.d
drwx------ 2 il il 4096 Jan 28 20:02 test
(gdb) $4 = 0
(gdb) Kill the program being debugged? (y or n) [answered Y; input not from terminal]
rsync: connection unexpectedly closed (31 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(605) [sender=3.0.9]
(gdb) quit
[il@basinsrv ~]$ rsync: connection unexpectedly closed (51 bytes received so far) [receiver]
rsync error: error in rsync protocol data stream (code 12) at io.c(605) [receiver=3.0.9]