1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-25 17:57:42 +03:00

smbd: Move handling smb_set_posix_lock() to smb1_trans2.c

Most of this is direct cut&paste without reformatting.

Don't pass SMB_SET_POSIX_LOCK through smbd_do_setfilepathinfo(),
directly handle it in call_trans2setfileinfo() where we know we have a
fsp.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
Volker Lendecke 2022-12-29 10:59:45 +01:00 committed by Ralph Boehme
parent 2cef6fcd6d
commit 765f9bcf66
3 changed files with 36 additions and 22 deletions

View File

@ -280,11 +280,11 @@ static void send_trans2_replies(connection_struct *conn,
static void smb_set_posix_lock_done(struct tevent_req *subreq);
NTSTATUS smb_set_posix_lock(connection_struct *conn,
struct smb_request *req,
const char *pdata,
int total_data,
files_struct *fsp)
static NTSTATUS smb_set_posix_lock(connection_struct *conn,
struct smb_request *req,
const char *pdata,
int total_data,
files_struct *fsp)
{
struct tevent_req *subreq = NULL;
struct smbd_lock_element *lck = NULL;
@ -296,6 +296,10 @@ NTSTATUS smb_set_posix_lock(connection_struct *conn,
NTSTATUS status = NT_STATUS_OK;
if (!CAN_WRITE(conn)) {
return NT_STATUS_DOS(ERRSRV, ERRaccess);
}
if (fsp == NULL ||
fsp->fsp_flags.is_pathref ||
fsp_get_io_fd(fsp) == -1)
@ -3405,6 +3409,7 @@ static void call_trans2setfileinfo(
struct files_struct *fsp = NULL;
char *params = *pparams;
int data_return_size = 0;
bool info_level_handled;
NTSTATUS status;
int ret;
@ -3497,6 +3502,32 @@ static void call_trans2setfileinfo(
}
}
info_level_handled = true; /* Untouched in switch cases below */
switch (info_level) {
default:
info_level_handled = false;
break;
case SMB_SET_POSIX_LOCK:
status = smb_set_posix_lock(
conn, req, *ppdata, total_data, fsp);
break;
}
if (info_level_handled) {
handle_trans2setfilepathinfo_result(
conn,
req,
info_level,
status,
*ppdata,
data_return_size,
max_data_bytes);
return;
}
status = smbd_do_setfilepathinfo(
conn,
req,

View File

@ -23,10 +23,5 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
NTSTATUS smb_set_posix_lock(connection_struct *conn,
struct smb_request *req,
const char *pdata,
int total_data,
files_struct *fsp);
void reply_trans2(struct smb_request *req);
void reply_transs2(struct smb_request *req);

View File

@ -6231,18 +6231,6 @@ static NTSTATUS smbd_do_posix_setfilepathinfo(struct connection_struct *conn,
}
#endif
#if defined(WITH_SMB1SERVER)
case SMB_SET_POSIX_LOCK:
{
if (fsp == NULL) {
return NT_STATUS_INVALID_LEVEL;
}
status = smb_set_posix_lock(conn, req,
pdata, total_data, fsp);
break;
}
#endif
default:
return NT_STATUS_INVALID_LEVEL;
}