mirror of
https://github.com/samba-team/samba.git
synced 2025-11-29 16:23:52 +03:00
selftest: add a test for shadow:fixinodes
This will fail with
Failed to open file \@GMT-2015.10.31-19.40.30\subdir\hardlink. NT_STATUS_ACCESS_DENIED
The open is failing in openat_pathref_fsp():
[2021/07/06 04:58:17.677104, 10, pid=95070, effective(1000, 1000), real(1000, 0)] ../../source3/smbd/files.c:541(openat_pathref_fsp)
openat_pathref_fsp: file [subdir/hardlink {@GMT-2015.10.31-19.40.30}] - dev/ino mismatch. Old (dev=64770, ino=3826943444). New (dev=64770, ino=1746568660).
[2021/07/06 04:58:17.677114, 10, pid=95070, effective(1000, 1000), real(1000, 0)] ../../source3/smbd/files.c:568(openat_pathref_fsp)
openat_pathref_fsp: Opening pathref for [subdir/hardlink {@GMT-2015.10.31-19.40.30}] failed: NT_STATUS_ACCESS_DENIED
The reason is subtle:
shadow_copy2 calculates inode numbers of snapshot files based on the path of the
file. The result of that when doing a path based stat() from filename_convert()
was
[2021/07/06 04:58:17.676159, 10, pid=95070, effective(1000, 1000), real(1000, 0)] ../../source3/smbd/filename.c:1945(filename_convert_internal)
filename_convert_internal: XXX smb_fname [subdir/hardlink {@GMT-2015.10.31-19.40.30}] (dev=64770, ino=3826943444).
which is the "Old" inode shown above.
Later in the open code called from openat_pathref_fsp() -> fd_openat() ->
non_widelink_open() since 4.14 we call SMB_VFS_FSTAT() where fsp->fsp_name will
be set to the new relative *basename* of the file:
[2021/07/06 04:58:17.676917, 10, pid=95070, effective(1000, 1000), real(1000, 0), class=vfs] ../../source3/modules/vfs_default.c:1302(vfswrap_fstat)
vfswrap_fstat: XXX fsp [hardlink {@GMT-2015.10.31-19.40.30}] (dev=64770, ino=3826943444)
So for stat() the hash function in called with the full path relative to the share
root:
subdir/hardlink
while for fstat() the hash function will used
hardlink
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14756
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
@@ -36,6 +36,9 @@ build_files()
|
||||
destdir=$1
|
||||
|
||||
echo "$content" > $destdir/foo
|
||||
|
||||
mkdir -p $WORKDIR/subdir/
|
||||
touch $WORKDIR/subdir/hardlink
|
||||
}
|
||||
|
||||
# build a snapshots directory
|
||||
@@ -48,6 +51,9 @@ build_snapshots()
|
||||
mkdir -p $snapdir/$SNAPSHOT
|
||||
|
||||
build_files $snapdir/$SNAPSHOT
|
||||
|
||||
mkdir -p $snapdir/$SNAPSHOT/subdir
|
||||
ln "$WORKDIR"/subdir/hardlink "$snapdir"/$SNAPSHOT/subdir/hardlink
|
||||
}
|
||||
|
||||
build_stream_on_snapshot()
|
||||
@@ -126,6 +132,24 @@ test_shadow_copy_openroot()
|
||||
failed=`expr $failed + 1`
|
||||
}
|
||||
|
||||
test_shadow_copy_fix_inodes()
|
||||
{
|
||||
local msg
|
||||
|
||||
msg=$1
|
||||
|
||||
#delete snapshots from previous tests
|
||||
find $WORKDIR -name ".snapshots" -exec rm -rf {} \; 1>/dev/null 2>&1
|
||||
build_snapshots
|
||||
|
||||
out=$($SMBCLIENT \
|
||||
-U $USERNAME%$PASSWORD \
|
||||
"//$SERVER/shadow_write" \
|
||||
-c "open $SNAPSHOT/subdir/hardlink") || failed=`expr $failed + 1`
|
||||
echo $out
|
||||
echo $out | grep "hardlink: for read/write fnum 1" || return 1
|
||||
}
|
||||
|
||||
build_files $WORKDIR
|
||||
|
||||
# test open for writing and write behaviour of snapshoted files
|
||||
@@ -135,4 +159,6 @@ test_shadow_copy_stream "reading stream of snapshotted file"
|
||||
|
||||
test_shadow_copy_openroot "opening root of shadow copy share"
|
||||
|
||||
testit "fix inodes with hardlink" test_shadow_copy_fix_inodes || failed=`expr $failed + 1`
|
||||
|
||||
exit $failed
|
||||
|
||||
Reference in New Issue
Block a user