mirror of
https://github.com/samba-team/samba.git
synced 2025-01-03 01:18:10 +03:00
smbd: Factor out can_delete_directory_hnd()
To be used in close.c next Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
This commit is contained in:
parent
671186d8f6
commit
cf69a9ef14
@ -1539,21 +1539,14 @@ bool opens_below_forall(struct connection_struct *conn,
|
||||
Is this directory empty ?
|
||||
*****************************************************************/
|
||||
|
||||
NTSTATUS can_delete_directory_fsp(files_struct *fsp)
|
||||
NTSTATUS can_delete_directory_hnd(struct smb_Dir *dir_hnd)
|
||||
{
|
||||
NTSTATUS status = NT_STATUS_OK;
|
||||
const char *dname = NULL;
|
||||
char *talloced = NULL;
|
||||
struct connection_struct *conn = fsp->conn;
|
||||
struct files_struct *dirfsp = dir_hnd_fetch_fsp(dir_hnd);
|
||||
struct connection_struct *conn = dirfsp->conn;
|
||||
bool delete_veto = lp_delete_veto_files(SNUM(conn));
|
||||
struct smb_Dir *dir_hnd = NULL;
|
||||
struct files_struct *dirfsp = NULL;
|
||||
|
||||
status = OpenDir_from_pathref(talloc_tos(), fsp, NULL, 0, &dir_hnd);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
return status;
|
||||
}
|
||||
dirfsp = dir_hnd_fetch_fsp(dir_hnd);
|
||||
|
||||
while ((dname = ReadDirName(dir_hnd, &talloced))) {
|
||||
struct smb_filename *direntry_fname = NULL;
|
||||
@ -1658,15 +1651,26 @@ NTSTATUS can_delete_directory_fsp(files_struct *fsp)
|
||||
}
|
||||
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
TALLOC_FREE(dir_hnd);
|
||||
return status;
|
||||
}
|
||||
|
||||
if (have_file_open_below(dirfsp)) {
|
||||
TALLOC_FREE(dir_hnd);
|
||||
return NT_STATUS_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
TALLOC_FREE(dir_hnd);
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
NTSTATUS can_delete_directory_fsp(files_struct *fsp)
|
||||
{
|
||||
struct smb_Dir *dir_hnd = NULL;
|
||||
NTSTATUS status;
|
||||
|
||||
status = OpenDir_from_pathref(talloc_tos(), fsp, NULL, 0, &dir_hnd);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
return status;
|
||||
}
|
||||
status = can_delete_directory_hnd(dir_hnd);
|
||||
TALLOC_FREE(dir_hnd);
|
||||
return status;
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
struct smb_Dir;
|
||||
struct dptr_struct;
|
||||
|
||||
NTSTATUS can_delete_directory_hnd(struct smb_Dir *dir_hnd);
|
||||
NTSTATUS can_delete_directory_fsp(files_struct *fsp);
|
||||
struct files_struct *dir_hnd_fetch_fsp(struct smb_Dir *dir_hnd);
|
||||
uint16_t dptr_attr(struct smbd_server_connection *sconn, int key);
|
||||
|
Loading…
Reference in New Issue
Block a user