3367
SIVAL(pdata, 24, conn->server_info->utok.ngroups);
3368
SIVAL(pdata, 28, conn->server_info->num_sids);
3417
SIVAL(pdata, 24, conn->session_info->utok.ngroups);
3418
SIVAL(pdata, 28, conn->session_info->security_token->num_sids);
3370
3420
/* We walk the SID list twice, but this call is fairly
3371
3421
* infrequent, and I don't expect that it's performance
3372
3422
* sensitive -- jpeach
3374
3424
for (i = 0, sid_bytes = 0;
3375
i < conn->server_info->ptok->num_sids; ++i) {
3425
i < conn->session_info->security_token->num_sids; ++i) {
3376
3426
sid_bytes += ndr_size_dom_sid(
3377
&conn->server_info->ptok->user_sids[i],
3427
&conn->session_info->security_token->sids[i],
3390
for (i = 0; i < conn->server_info->utok.ngroups; ++i) {
3439
for (i = 0; i < conn->session_info->utok.ngroups; ++i) {
3391
3440
SBIG_UINT(pdata, data_len,
3392
(uint64_t)conn->server_info->utok.groups[i]);
3441
(uint64_t)conn->session_info->utok.groups[i]);
3398
i < conn->server_info->ptok->num_sids; ++i) {
3447
i < conn->session_info->security_token->num_sids; ++i) {
3399
3448
int sid_len = ndr_size_dom_sid(
3400
&conn->server_info->ptok->user_sids[i],
3449
&conn->session_info->security_token->sids[i],
3404
3452
sid_linearize(pdata + data_len, sid_len,
3405
&conn->server_info->ptok->user_sids[i]);
3453
&conn->session_info->security_token->sids[i]);
3406
3454
data_len += sid_len;
3679
3736
/* unknown_1 24 NULL bytes in pdata*/
3681
3738
/* the soft quotas 8 bytes (uint64_t)*/
3682
quotas.softlim = (uint64_t)IVAL(pdata,24);
3683
#ifdef LARGE_SMB_OFF_T
3684
quotas.softlim |= (((uint64_t)IVAL(pdata,28)) << 32);
3685
#else /* LARGE_SMB_OFF_T */
3686
if ((IVAL(pdata,28) != 0)&&
3687
((quotas.softlim != 0xFFFFFFFF)||
3688
(IVAL(pdata,28)!=0xFFFFFFFF))) {
3689
/* more than 32 bits? */
3692
NT_STATUS_INVALID_PARAMETER);
3695
#endif /* LARGE_SMB_OFF_T */
3739
quotas.softlim = BVAL(pdata,24);
3697
3741
/* the hard quotas 8 bytes (uint64_t)*/
3698
quotas.hardlim = (uint64_t)IVAL(pdata,32);
3699
#ifdef LARGE_SMB_OFF_T
3700
quotas.hardlim |= (((uint64_t)IVAL(pdata,36)) << 32);
3701
#else /* LARGE_SMB_OFF_T */
3702
if ((IVAL(pdata,36) != 0)&&
3703
((quotas.hardlim != 0xFFFFFFFF)||
3704
(IVAL(pdata,36)!=0xFFFFFFFF))) {
3705
/* more than 32 bits? */
3708
NT_STATUS_INVALID_PARAMETER);
3711
#endif /* LARGE_SMB_OFF_T */
3742
quotas.hardlim = BVAL(pdata,32);
3713
3744
/* quota_flags 2 bytes **/
3714
3745
quotas.qflags = SVAL(pdata,40);
4570
4595
SBVAL(pdata, 0x30, file_size);
4571
4596
SIVAL(pdata, 0x38, nlink);
4572
4597
SCVAL(pdata, 0x3C, delete_pending);
4573
SCVAL(pdata, 0x3D, (mode&aDIR)?1:0);
4598
SCVAL(pdata, 0x3D, (mode&FILE_ATTRIBUTE_DIRECTORY)?1:0);
4574
4599
SSVAL(pdata, 0x3E, 0); /* padding */
4575
4600
SBVAL(pdata, 0x40, file_index);
4576
4601
SIVAL(pdata, 0x48, ea_size);
5904
return hardlink_internals(ctx, conn, smb_fname_old, smb_fname_new);
5966
return hardlink_internals(ctx, conn, req, false,
5967
smb_fname_old, smb_fname_new);
5970
/****************************************************************************
5971
Deal with SMB2_FILE_RENAME_INFORMATION_INTERNAL
5972
****************************************************************************/
5974
static NTSTATUS smb2_file_rename_information(connection_struct *conn,
5975
struct smb_request *req,
5979
struct smb_filename *smb_fname_src)
5983
char *newname = NULL;
5984
struct smb_filename *smb_fname_dst = NULL;
5985
NTSTATUS status = NT_STATUS_OK;
5986
TALLOC_CTX *ctx = talloc_tos();
5989
return NT_STATUS_INVALID_HANDLE;
5992
if (total_data < 20) {
5993
return NT_STATUS_INVALID_PARAMETER;
5996
overwrite = (CVAL(pdata,0) ? True : False);
5997
len = IVAL(pdata,16);
5999
if (len > (total_data - 20) || (len == 0)) {
6000
return NT_STATUS_INVALID_PARAMETER;
6003
srvstr_get_path(ctx, pdata, req->flags2, &newname,
6004
&pdata[20], len, STR_TERMINATE,
6006
if (!NT_STATUS_IS_OK(status)) {
6010
DEBUG(10,("smb2_file_rename_information: got name |%s|\n",
6013
status = filename_convert(ctx,
6015
req->flags2 & FLAGS2_DFS_PATHNAMES,
6020
if (!NT_STATUS_IS_OK(status)) {
6024
if (fsp->base_fsp) {
6025
/* newname must be a stream name. */
6026
if (newname[0] != ':') {
6027
return NT_STATUS_NOT_SUPPORTED;
6030
/* Create an smb_fname to call rename_internals_fsp() with. */
6031
status = create_synthetic_smb_fname(talloc_tos(),
6032
fsp->base_fsp->fsp_name->base_name, newname, NULL,
6034
if (!NT_STATUS_IS_OK(status)) {
6039
* Set the original last component, since
6040
* rename_internals_fsp() requires it.
6042
smb_fname_dst->original_lcomp = talloc_strdup(smb_fname_dst,
6044
if (smb_fname_dst->original_lcomp == NULL) {
6045
status = NT_STATUS_NO_MEMORY;
6051
DEBUG(10,("smb2_file_rename_information: "
6052
"SMB_FILE_RENAME_INFORMATION (fnum %d) %s -> %s\n",
6053
fsp->fnum, fsp_str_dbg(fsp),
6054
smb_fname_str_dbg(smb_fname_dst)));
6055
status = rename_internals_fsp(conn, fsp, smb_fname_dst,
6056
(FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM),
6060
TALLOC_FREE(smb_fname_dst);
6064
static NTSTATUS smb_file_link_information(connection_struct *conn,
6065
struct smb_request *req,
6069
struct smb_filename *smb_fname_src)
6073
char *newname = NULL;
6074
struct smb_filename *smb_fname_dst = NULL;
6075
NTSTATUS status = NT_STATUS_OK;
6076
TALLOC_CTX *ctx = talloc_tos();
6079
return NT_STATUS_INVALID_HANDLE;
6082
if (total_data < 20) {
6083
return NT_STATUS_INVALID_PARAMETER;
6086
overwrite = (CVAL(pdata,0) ? true : false);
6087
len = IVAL(pdata,16);
6089
if (len > (total_data - 20) || (len == 0)) {
6090
return NT_STATUS_INVALID_PARAMETER;
6093
srvstr_get_path(ctx, pdata, req->flags2, &newname,
6094
&pdata[20], len, STR_TERMINATE,
6096
if (!NT_STATUS_IS_OK(status)) {
6100
DEBUG(10,("smb_file_link_information: got name |%s|\n",
6103
status = filename_convert(ctx,
6105
req->flags2 & FLAGS2_DFS_PATHNAMES,
6110
if (!NT_STATUS_IS_OK(status)) {
6114
if (fsp->base_fsp) {
6115
/* No stream names. */
6116
return NT_STATUS_NOT_SUPPORTED;
6119
DEBUG(10,("smb_file_link_information: "
6120
"SMB_FILE_LINK_INFORMATION (fnum %d) %s -> %s\n",
6121
fsp->fnum, fsp_str_dbg(fsp),
6122
smb_fname_str_dbg(smb_fname_dst)));
6123
status = hardlink_internals(ctx,
6130
TALLOC_FREE(smb_fname_dst);
5907
6134
/****************************************************************************
6204
6431
#endif /* HAVE_LONGLONG */
6206
6433
DEBUG(10,("smb_set_posix_lock: file %s, lock_type = %u,"
6207
"lock_pid = %u, count = %.0f, offset = %.0f\n",
6434
"smblctx = %llu, count = %.0f, offset = %.0f\n",
6208
6435
fsp_str_dbg(fsp),
6209
6436
(unsigned int)lock_type,
6210
(unsigned int)lock_pid,
6437
(unsigned long long)smblctx,
6212
6439
(double)offset ));
6214
6441
if (lock_type == UNLOCK_LOCK) {
6215
status = do_unlock(smbd_messaging_context(),
6442
status = do_unlock(req->sconn->msg_ctx,
6222
uint32 block_smbpid;
6449
uint64_t block_smblctx;
6224
struct byte_range_lock *br_lck = do_lock(smbd_messaging_context(),
6451
struct byte_range_lock *br_lck = do_lock(req->sconn->msg_ctx,
6236
6463
if (br_lck && blocking_lock && ERROR_WAS_LOCK_DENIED(status)) {