Folder can be renamed with an open file inside the same folder from different client

Volker Lendecke Volker.Lendecke at SerNet.DE
Tue Oct 1 12:56:40 MDT 2013


On Tue, Oct 01, 2013 at 04:46:31PM +0530, Shilpa K wrote:
> Hello,
> 
> Renaming a folder succeeds in the following scenario when it should
> actually fail:
> 
> 1.      Client 1 has opened the file temp.doc which is present in the
> directory TESTDIR
> 
> 2.      Client 2 tries to rename the directory TESTDIR to DIR1 and it
> succeeds.
> 
> On the other hand, if the windows client tries to rename a directory from
> client 2 wherein client 1 has opened a file under that directory, the
> operation results in access denied. Samba also sends access denied error
> when we try to rename the directory from the same client where the file is
> opened under it. In this case, the following code takes care of returning
> the appropriate error:
> 
>                 /* If no pathnames are open below this
> 
>                    directory, allow the rename. */
> 
>                 if (file_find_subpath(fsp)) {
> 
>                        return NT_STATUS_ACCESS_DENIED;
> 
>                 }
> 
> file_find_subpath() goes through the connection list for that particular
> client and if a directory has file open under it, it returns access denied.
> The reason this code is not working in case of multiple clients is because
> the connection list is specific to a particular SMBD process and not
> visible to other SMBD processes. As for as I understand, the only way the
> other SMBD processes can know if the file in a directory is open is through
> locking.tdb. But traversing locking.tdb to find an open file under a
> particular directory can be a tedious operation. Is there a simpler way by
> which we can find out if the file is open under a directory when we try to
> rename it?

No, unfortunately at this moment that's the way it is. Right
now I'm working on the open and oplock code again, and there
a similar requirement (probably the same) also pops up. We
have to break a handle lease (and probably a batch oplock)
if the containing directory of an open file is being
renamed.

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de

*****************************************************************
visit us on it-sa:IT security exhibitions in Nürnberg, Germany
October 8th - 10th 2013, hall 12, booth 333
free tickets available via code 270691 on: www.it-sa.de/gutschein
******************************************************************


More information about the samba-technical mailing list