mirror of
https://github.com/samba-team/samba.git
synced 2025-01-03 01:18:10 +03:00
Compare commits
6 Commits
ec098fbe84
...
4d043ea5e5
Author | SHA1 | Date | |
---|---|---|---|
|
4d043ea5e5 | ||
|
af0bcf35f4 | ||
|
c121f03f59 | ||
|
f1e28919ae | ||
|
fac7288aff | ||
|
197578b4d6 |
@ -62,7 +62,10 @@
|
|||||||
</varlistentry>
|
</varlistentry>
|
||||||
</variablelist>
|
</variablelist>
|
||||||
|
|
||||||
<para>This module is stackable.</para>
|
<para> This module is not fully stackable. It can be combined with other
|
||||||
|
modules, but should be the last module in the <command>vfs objects</command>
|
||||||
|
list. It directly access the files in the OS filesystem.
|
||||||
|
</para>
|
||||||
|
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
|
@ -2525,6 +2525,7 @@ static char* winbind_upn_to_username(struct pwb_context *ctx,
|
|||||||
/* Convert the UPN to a SID */
|
/* Convert the UPN to a SID */
|
||||||
|
|
||||||
wbc_status = wbcCtxLookupName(ctx->wbc_ctx, domain, name, &sid, &type);
|
wbc_status = wbcCtxLookupName(ctx->wbc_ctx, domain, name, &sid, &type);
|
||||||
|
TALLOC_FREE(name);
|
||||||
if (!WBC_ERROR_IS_OK(wbc_status)) {
|
if (!WBC_ERROR_IS_OK(wbc_status)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -2704,6 +2704,9 @@ sub provision($$)
|
|||||||
my $recycle_shrdir="$shrdir/recycle";
|
my $recycle_shrdir="$shrdir/recycle";
|
||||||
push(@dirs,$recycle_shrdir);
|
push(@dirs,$recycle_shrdir);
|
||||||
|
|
||||||
|
my $recycle_shrdir2="$shrdir/recycle2";
|
||||||
|
push(@dirs,$recycle_shrdir2);
|
||||||
|
|
||||||
my $fakedircreatetimes_shrdir="$shrdir/fakedircreatetimes";
|
my $fakedircreatetimes_shrdir="$shrdir/fakedircreatetimes";
|
||||||
push(@dirs,$fakedircreatetimes_shrdir);
|
push(@dirs,$fakedircreatetimes_shrdir);
|
||||||
|
|
||||||
@ -3631,6 +3634,15 @@ sub provision($$)
|
|||||||
recycle : exclude = *.tmp
|
recycle : exclude = *.tmp
|
||||||
recycle : directory_mode = 755
|
recycle : directory_mode = 755
|
||||||
|
|
||||||
|
[recycle2]
|
||||||
|
copy = tmp
|
||||||
|
path = $recycle_shrdir2
|
||||||
|
vfs objects = recycle crossrename
|
||||||
|
recycle : repository = .trash
|
||||||
|
recycle : exclude = *.tmp
|
||||||
|
recycle : directory_mode = 755
|
||||||
|
wide links = yes
|
||||||
|
|
||||||
[fakedircreatetimes]
|
[fakedircreatetimes]
|
||||||
copy = tmp
|
copy = tmp
|
||||||
path = $fakedircreatetimes_shrdir
|
path = $fakedircreatetimes_shrdir
|
||||||
|
@ -54,10 +54,12 @@ static NTSTATUS copy_reg(vfs_handle_struct *handle,
|
|||||||
struct files_struct *dstfsp,
|
struct files_struct *dstfsp,
|
||||||
const struct smb_filename *dest)
|
const struct smb_filename *dest)
|
||||||
{
|
{
|
||||||
NTSTATUS status;
|
NTSTATUS status = NT_STATUS_OK;
|
||||||
struct smb_filename *full_fname_src = NULL;
|
|
||||||
struct smb_filename *full_fname_dst = NULL;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
off_t off;
|
||||||
|
int ifd = -1;
|
||||||
|
int ofd = -1;
|
||||||
|
struct timespec ts[2];
|
||||||
|
|
||||||
if (!VALID_STAT(source->st)) {
|
if (!VALID_STAT(source->st)) {
|
||||||
status = NT_STATUS_OBJECT_PATH_NOT_FOUND;
|
status = NT_STATUS_OBJECT_PATH_NOT_FOUND;
|
||||||
@ -79,64 +81,105 @@ static NTSTATUS copy_reg(vfs_handle_struct *handle,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
full_fname_src = full_path_from_dirfsp_atname(talloc_tos(),
|
|
||||||
srcfsp,
|
|
||||||
source);
|
|
||||||
if (full_fname_src == NULL) {
|
|
||||||
status = NT_STATUS_NO_MEMORY;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
full_fname_dst = full_path_from_dirfsp_atname(talloc_tos(),
|
|
||||||
dstfsp,
|
|
||||||
dest);
|
|
||||||
if (full_fname_dst == NULL) {
|
|
||||||
status = NT_STATUS_NO_MEMORY;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = SMB_VFS_NEXT_UNLINKAT(handle,
|
ret = SMB_VFS_NEXT_UNLINKAT(handle,
|
||||||
dstfsp,
|
dstfsp,
|
||||||
dest,
|
dest,
|
||||||
0);
|
0);
|
||||||
if (ret == -1) {
|
if (ret == -1 && errno != ENOENT) {
|
||||||
|
status = map_nt_error_from_unix(errno);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
ifd = openat(fsp_get_pathref_fd(srcfsp),
|
||||||
|
source->base_name,
|
||||||
|
O_RDONLY,
|
||||||
|
0);
|
||||||
|
if (ifd < 0) {
|
||||||
|
status = map_nt_error_from_unix(errno);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
ofd = openat(fsp_get_pathref_fd(dstfsp),
|
||||||
|
dest->base_name,
|
||||||
|
O_WRONLY | O_CREAT | O_TRUNC | O_NOFOLLOW,
|
||||||
|
0600);
|
||||||
|
if (ofd < 0) {
|
||||||
|
status = map_nt_error_from_unix(errno);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
off = transfer_file(ifd, ofd, source->st.st_ex_size);
|
||||||
|
if (off == -1) {
|
||||||
|
status = map_nt_error_from_unix(errno);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = fchown(ofd, source->st.st_ex_uid, source->st.st_ex_gid);
|
||||||
|
if (ret == -1 && errno != EPERM) {
|
||||||
status = map_nt_error_from_unix(errno);
|
status = map_nt_error_from_unix(errno);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* copy_internals() takes attribute values from the NTrename call.
|
* fchown turns off set[ug]id bits for non-root,
|
||||||
*
|
* so do the chmod last.
|
||||||
* From MS-CIFS:
|
|
||||||
*
|
|
||||||
* "If the attribute is 0x0000, then only normal files are renamed.
|
|
||||||
* If the system file or hidden attributes are specified, then the
|
|
||||||
* rename is inclusive of both special types."
|
|
||||||
*/
|
*/
|
||||||
status = copy_internals(talloc_tos(),
|
ret = fchmod(ofd, source->st.st_ex_mode & 07777);
|
||||||
handle->conn,
|
if (ret == -1 && errno != EPERM) {
|
||||||
NULL,
|
|
||||||
srcfsp, /* src_dirfsp */
|
|
||||||
full_fname_src,
|
|
||||||
dstfsp, /* dst_dirfsp */
|
|
||||||
full_fname_dst,
|
|
||||||
FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM);
|
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = SMB_VFS_NEXT_UNLINKAT(handle,
|
|
||||||
srcfsp,
|
|
||||||
source,
|
|
||||||
0);
|
|
||||||
if (ret == -1) {
|
|
||||||
status = map_nt_error_from_unix(errno);
|
status = map_nt_error_from_unix(errno);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
/* Try to copy the old file's modtime and access time. */
|
||||||
|
ts[0] = source->st.st_ex_atime;
|
||||||
|
ts[1] = source->st.st_ex_mtime;
|
||||||
|
ret = futimens(ofd, ts);
|
||||||
|
if (ret == -1) {
|
||||||
|
DBG_DEBUG("Updating the time stamp on destinaton '%s' failed "
|
||||||
|
"with '%s'. Rename operation can continue.\n",
|
||||||
|
dest->base_name,
|
||||||
|
strerror(errno));
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = close(ifd);
|
||||||
|
if (ret == -1) {
|
||||||
|
status = map_nt_error_from_unix(errno);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
ifd = -1;
|
||||||
|
|
||||||
|
ret = close(ofd);
|
||||||
|
if (ret == -1) {
|
||||||
|
status = map_nt_error_from_unix(errno);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
ofd = -1;
|
||||||
|
|
||||||
|
ret = SMB_VFS_NEXT_UNLINKAT(handle, srcfsp, source, 0);
|
||||||
|
if (ret == -1) {
|
||||||
|
status = map_nt_error_from_unix(errno);
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
if (ifd != -1) {
|
||||||
|
ret = close(ifd);
|
||||||
|
if (ret == -1) {
|
||||||
|
DBG_DEBUG("Failed to close %s (%d): %s.\n",
|
||||||
|
source->base_name,
|
||||||
|
ifd,
|
||||||
|
strerror(errno));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ofd != -1) {
|
||||||
|
ret = close(ofd);
|
||||||
|
if (ret == -1) {
|
||||||
|
DBG_DEBUG("Failed to close %s (%d): %s.\n",
|
||||||
|
dest->base_name,
|
||||||
|
ofd,
|
||||||
|
strerror(errno));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TALLOC_FREE(full_fname_src);
|
|
||||||
TALLOC_FREE(full_fname_dst);
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,6 +211,7 @@ static int crossrename_renameat(vfs_handle_struct *handle,
|
|||||||
smb_fname_src,
|
smb_fname_src,
|
||||||
dstfsp,
|
dstfsp,
|
||||||
smb_fname_dst);
|
smb_fname_dst);
|
||||||
|
result = 0;
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
errno = map_errno_from_nt_status(status);
|
errno = map_errno_from_nt_status(status);
|
||||||
result = -1;
|
result = -1;
|
||||||
|
@ -29,7 +29,8 @@ export SAMBA_DEPRECATED_SUPPRESS
|
|||||||
|
|
||||||
# Define the test environment/filenames.
|
# Define the test environment/filenames.
|
||||||
#
|
#
|
||||||
share_test_dir="$LOCAL_PATH"
|
share_test_dir="$LOCAL_PATH/recycle"
|
||||||
|
share_test_dir2="$LOCAL_PATH/recycle2"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Cleanup function.
|
# Cleanup function.
|
||||||
@ -43,6 +44,13 @@ do_cleanup()
|
|||||||
rm -f testfile2.tmp
|
rm -f testfile2.tmp
|
||||||
rm -rf .trash
|
rm -rf .trash
|
||||||
)
|
)
|
||||||
|
(
|
||||||
|
#subshell.
|
||||||
|
cd "$share_test_dir2" || return
|
||||||
|
rm -f testfile3
|
||||||
|
rm -f testfile4.tmp
|
||||||
|
rm -rf .trash
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -50,6 +58,25 @@ do_cleanup()
|
|||||||
#
|
#
|
||||||
do_cleanup
|
do_cleanup
|
||||||
|
|
||||||
|
# Setup .trash on a different filesystem to test crossrename
|
||||||
|
# /tmp or /dev/shm should provide tmpfs
|
||||||
|
#
|
||||||
|
for T in /tmp /dev/shm
|
||||||
|
do
|
||||||
|
if df --portability --print-type $T 2>/dev/null | grep -q tmpfs; then
|
||||||
|
TRASHDIR=$T
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z $TRASHDIR ]; then
|
||||||
|
echo "No tmpfs filesystem found."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
TRASHDIR=$(mktemp -d /$TRASHDIR/.trash_XXXXXX)
|
||||||
|
chmod 0755 $TRASHDIR
|
||||||
|
ln -s $TRASHDIR $share_test_dir2/.trash
|
||||||
|
|
||||||
test_recycle()
|
test_recycle()
|
||||||
{
|
{
|
||||||
@ -90,12 +117,61 @@ quit
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test_recycle_crossrename()
|
||||||
|
{
|
||||||
|
tmpfile=$PREFIX/smbclient_interactive_prompt_commands
|
||||||
|
echo "
|
||||||
|
put $tmpfile testfile3
|
||||||
|
put $tmpfile testfile4.tmp
|
||||||
|
del testfile3
|
||||||
|
del testfile4.tmp
|
||||||
|
quit
|
||||||
|
" > $tmpfile
|
||||||
|
cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT -U$USERNAME%$PASSWORD //$SERVER/recycle2 -I$SERVER_IP $ADDARGS < $tmpfile 2>&1'
|
||||||
|
eval echo "$cmd"
|
||||||
|
out=$(eval "$cmd")
|
||||||
|
ret=$?
|
||||||
|
rm -f "$tmpfile"
|
||||||
|
|
||||||
|
if [ $ret != 0 ]; then
|
||||||
|
printf "%s\n" "$out"
|
||||||
|
printf "failed recycle smbclient run with error %s\n" "$ret"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
test -e "$share_test_dir2/.trash/testfile3" || {
|
||||||
|
printf ".trash/testfile3 expected to exist but does NOT exist\n"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
test -e "$share_test_dir2/.trash/testfile4.tmp" && {
|
||||||
|
printf ".trash/testfile4.tmp not expected to exist but DOES exist\n"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
deviceid1=`stat -c '%d' "$share_test_dir2/"`
|
||||||
|
deviceid2=`stat -c '%d' "$share_test_dir2/.trash/"`
|
||||||
|
test "$deviceid1=" != "$deviceid2" || {
|
||||||
|
printf ".trash/ should be on a different filesystem!\n"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
perm_want=755
|
||||||
|
perm_is=`stat -c '%a' "$share_test_dir2/.trash/"`
|
||||||
|
test "$perm_is" = "$perm_want" || {
|
||||||
|
printf ".trash/ permission should be $perm_want but is $perm_is\n"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
panic_count_0=$(grep -c PANIC $SMBD_TEST_LOG)
|
panic_count_0=$(grep -c PANIC $SMBD_TEST_LOG)
|
||||||
|
|
||||||
testit "recycle" \
|
testit "recycle" \
|
||||||
test_recycle ||
|
test_recycle ||
|
||||||
failed=$((failed + 1))
|
failed=$((failed + 1))
|
||||||
|
|
||||||
|
testit "recycle_crossrename" \
|
||||||
|
test_recycle_crossrename ||
|
||||||
|
failed=$((failed + 1))
|
||||||
|
|
||||||
panic_count_1=$(grep -c PANIC $SMBD_TEST_LOG)
|
panic_count_1=$(grep -c PANIC $SMBD_TEST_LOG)
|
||||||
|
|
||||||
testit "check_panic" test $panic_count_0 -eq $panic_count_1 || failed=$(expr $failed + 1)
|
testit "check_panic" test $panic_count_0 -eq $panic_count_1 || failed=$(expr $failed + 1)
|
||||||
@ -103,5 +179,7 @@ testit "check_panic" test $panic_count_0 -eq $panic_count_1 || failed=$(expr $fa
|
|||||||
#
|
#
|
||||||
# Cleanup.
|
# Cleanup.
|
||||||
do_cleanup
|
do_cleanup
|
||||||
|
# Cleanup above only deletes a symlink, delete also /tmp/.trash_XXXXXX dir
|
||||||
|
rm -rf "$TRASHDIR"
|
||||||
|
|
||||||
testok "$0" "$failed"
|
testok "$0" "$failed"
|
||||||
|
@ -763,7 +763,7 @@ for env in ["fileserver"]:
|
|||||||
plantestsuite("samba3.blackbox.force_create_mode", env, [os.path.join(samba3srcdir, "script/tests/test_force_create_mode.sh"), '$SERVER', '$DOMAIN', '$USERNAME', '$PASSWORD', '$PREFIX', env, smbclient3])
|
plantestsuite("samba3.blackbox.force_create_mode", env, [os.path.join(samba3srcdir, "script/tests/test_force_create_mode.sh"), '$SERVER', '$DOMAIN', '$USERNAME', '$PASSWORD', '$PREFIX', env, smbclient3])
|
||||||
plantestsuite("samba3.blackbox.dropbox", env, [os.path.join(samba3srcdir, "script/tests/test_dropbox.sh"), '$SERVER', '$DOMAIN', 'gooduser', '$PASSWORD', '$PREFIX', env, smbclient3])
|
plantestsuite("samba3.blackbox.dropbox", env, [os.path.join(samba3srcdir, "script/tests/test_dropbox.sh"), '$SERVER', '$DOMAIN', 'gooduser', '$PASSWORD', '$PREFIX', env, smbclient3])
|
||||||
plantestsuite("samba3.blackbox.offline", env, [os.path.join(samba3srcdir, "script/tests/test_offline.sh"), '$SERVER', '$SERVER_IP', '$DOMAIN', '$USERNAME', '$PASSWORD', '$LOCAL_PATH/offline', smbclient3])
|
plantestsuite("samba3.blackbox.offline", env, [os.path.join(samba3srcdir, "script/tests/test_offline.sh"), '$SERVER', '$SERVER_IP', '$DOMAIN', '$USERNAME', '$PASSWORD', '$LOCAL_PATH/offline', smbclient3])
|
||||||
plantestsuite("samba3.blackbox.recycle", env, [os.path.join(samba3srcdir, "script/tests/test_recycle.sh"), '$SERVER', '$SERVER_IP', '$USERNAME', '$PASSWORD', '$LOCAL_PATH/recycle', '$PREFIX', smbclient3])
|
plantestsuite("samba3.blackbox.recycle", env, [os.path.join(samba3srcdir, "script/tests/test_recycle.sh"), '$SERVER', '$SERVER_IP', '$USERNAME', '$PASSWORD', '$LOCAL_PATH', '$PREFIX', smbclient3])
|
||||||
plantestsuite("samba3.blackbox.fakedircreatetimes", env, [os.path.join(samba3srcdir, "script/tests/test_fakedircreatetimes.sh"), '$SERVER', '$SERVER_IP', '$USERNAME', '$PASSWORD', '$LOCAL_PATH/fakedircreatetimes', '$PREFIX', smbclient3])
|
plantestsuite("samba3.blackbox.fakedircreatetimes", env, [os.path.join(samba3srcdir, "script/tests/test_fakedircreatetimes.sh"), '$SERVER', '$SERVER_IP', '$USERNAME', '$PASSWORD', '$LOCAL_PATH/fakedircreatetimes', '$PREFIX', smbclient3])
|
||||||
plantestsuite("samba3.blackbox.shadow_copy2.NT1", env + "_smb1_done", [os.path.join(samba3srcdir, "script/tests/test_shadow_copy.sh"), '$SERVER', '$SERVER_IP', '$DOMAIN', '$USERNAME', '$PASSWORD', '$LOCAL_PATH/shadow', smbclient3, '-m', 'NT1'])
|
plantestsuite("samba3.blackbox.shadow_copy2.NT1", env + "_smb1_done", [os.path.join(samba3srcdir, "script/tests/test_shadow_copy.sh"), '$SERVER', '$SERVER_IP', '$DOMAIN', '$USERNAME', '$PASSWORD', '$LOCAL_PATH/shadow', smbclient3, '-m', 'NT1'])
|
||||||
plantestsuite("samba3.blackbox.shadow_copy2.SMB3", env, [os.path.join(samba3srcdir, "script/tests/test_shadow_copy.sh"), '$SERVER', '$SERVER_IP', '$DOMAIN', '$USERNAME', '$PASSWORD', '$LOCAL_PATH/shadow', smbclient3, '-m', 'SMB3'])
|
plantestsuite("samba3.blackbox.shadow_copy2.SMB3", env, [os.path.join(samba3srcdir, "script/tests/test_shadow_copy.sh"), '$SERVER', '$SERVER_IP', '$DOMAIN', '$USERNAME', '$PASSWORD', '$LOCAL_PATH/shadow', smbclient3, '-m', 'SMB3'])
|
||||||
|
Loading…
Reference in New Issue
Block a user