Bug 11094 - using "allinfo" in smbclient causes the file to remain openend
using "allinfo" in smbclient causes the file to remain openend
Status: RESOLVED FIXED
Product: Samba 4.1 and newer
Classification: Unclassified
Component: Tools
4.1.16
x64 Linux
: P5 normal
: ---
Assigned To: Karolin Seeger
Samba QA Contact
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2015-02-10 16:48 UTC by robin
Modified: 2015-02-22 13:15 UTC (History)
1 user (show)

See Also:


Attachments
Proposed patch for master. (696 bytes, patch)
2015-02-10 17:59 UTC, Jeremy Allison
no flags Details
git-am fix for 4.2.0 - cherry-pick from master (935 bytes, patch)
2015-02-12 20:20 UTC, Jeremy Allison
vl: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description robin 2015-02-10 16:48:14 UTC
After calling allinfo on a file using smbclient against a windows server the file remains opened and trying to delete the file results in an NT_STATUS_SHARING_VIOLATION error.

Reproduction steps: see http://pastebin.com/raw.php?i=WsPRngS7

Note that this only causes an issue with a windows smb server (tested with 2012R2) when doing the same steps with a linux samaba server the file can be deleted after calling allinfo (although that might be because linux generally allows you to delete a file thats still open)
Comment 1 Jeremy Allison 2015-02-10 17:13:24 UTC
Did you use SMB1 or SMB2 to connect ?
Comment 2 Jeremy Allison 2015-02-10 17:13:39 UTC
(Copy of reproduction steps).

smb: \test\> put a.jpg
putting file a.jpg as \test\a.jpg (43392.1 kb/s) (average 37733.0 kb/s)
smb: \test\> del a.jpg
smb: \test\> put a.jpg
putting file a.jpg as \test\a.jpg (36160.2 kb/s) (average 37407.7 kb/s)
smb: \test\> allinfo a.jpg
altname: a.jpg
create_time:    Fri Nov 14 05:12:04 PM 2014 CET
access_time:    Fri Nov 14 05:12:10 PM 2014 CET
write_time:     Fri Nov 14 05:12:10 PM 2014 CET
change_time:    Fri Nov 14 05:12:10 PM 2014 CET
attributes: A (20)
stream: [::$DATA], 222172 bytes
smb: \test\> del a.jpg
NT_STATUS_SHARING_VIOLATION deleting remote file \test\a.jpg
NT_STATUS_SHARING_VIOLATION listing \test\a.jpg
smb: \test\>
Comment 3 robin 2015-02-10 17:19:58 UTC
(In reply to Jeremy Allison from comment #1)
SMB1, when using SMB2 I cant reproduce the issue
Comment 4 Jeremy Allison 2015-02-10 17:59:06 UTC
Created attachment 10715 [details]
Proposed patch for master.

Can you test this ? I think it will fix it.
Comment 5 Jeremy Allison 2015-02-10 19:33:15 UTC
Reproduced here and confirmed the fix works.
Comment 6 Jeremy Allison 2015-02-12 20:20:46 UTC
Created attachment 10717 [details]
git-am fix for 4.2.0 - cherry-pick from master
Comment 7 Jeremy Allison 2015-02-12 20:25:17 UTC
Comment on attachment 10717 [details]
git-am fix for 4.2.0 - cherry-pick from master

Also applies cleanly to 4.1.next, 4.0.next.
Comment 8 Volker Lendecke 2015-02-12 20:51:11 UTC
Comment on attachment 10717 [details]
git-am fix for 4.2.0 - cherry-pick from master

>From dbb4bb2e7afb108e0e7eeb2f2ef843be55c5577e Mon Sep 17 00:00:00 2001
>From: Jeremy Allison <jra@samba.org>
>Date: Tue, 10 Feb 2015 09:32:11 -0800
>Subject: [PATCH] s3: smbclient: Allinfo leaves the file handle open.
>
>https://bugzilla.samba.org/show_bug.cgi?id=11094
>
>Signed-off-by: Jeremy Allison <jra@samba.org>
>Reviewed-by: Volker Lendecke <vl@samba.org>
>
>Autobuild-User(master): Volker Lendecke <vl@samba.org>
>Autobuild-Date(master): Tue Feb 10 23:28:46 CET 2015 on sn-devel-104
>
>(cherry picked from commit 080ec0f7d9735b27138deb5f91a397935f089f02)
>---
> source3/client/client.c | 1 +
> 1 file changed, 1 insertion(+)
>
>diff --git a/source3/client/client.c b/source3/client/client.c
>index 5d70897..1458cf2 100644
>--- a/source3/client/client.c
>+++ b/source3/client/client.c
>@@ -1816,6 +1816,7 @@ static int do_allinfo(const char *name)
> 	}
> 
> 	TALLOC_FREE(snapshots);
>+	cli_close(cli, fnum);
> 
> 	return 0;
> }
>-- 
>2.2.0.rc0.207.ga3a616c
>
Comment 9 Jeremy Allison 2015-02-12 20:56:16 UTC
Re-assigning to Karolin for inclusion in 4.2.0, 4.1.next. 4.0.next.
Comment 10 Karolin Seeger 2015-02-16 20:05:15 UTC
(In reply to Jeremy Allison from comment #9)
Pushed to autobuild-v4-[0|1|2].
Comment 11 Karolin Seeger 2015-02-22 13:15:18 UTC
(In reply to Karolin Seeger from comment #10)
Pushed to all branches.
Closing out bug report.

Thanks!