Line data Source code
1 : /* 2 : * Unix SMB/CIFS implementation. 3 : * 4 : * SMB2 Posix context handling 5 : * 6 : * Copyright (C) Jeremy Allison 2019 7 : * 8 : * This program is free software; you can redistribute it and/or modify 9 : * it under the terms of the GNU General Public License as published by 10 : * the Free Software Foundation; either version 3 of the License, or 11 : * (at your option) any later version. 12 : * 13 : * This program is distributed in the hope that it will be useful, 14 : * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 : * GNU General Public License for more details. 17 : * 18 : * You should have received a copy of the GNU General Public License 19 : * along with this program. If not, see <http://www.gnu.org/licenses/>. 20 : */ 21 : 22 : #include "replace.h" 23 : #include "libcli/smb/smb2_posix.h" 24 : #include "libcli/smb/smb2_constants.h" 25 : #include "lib/util/byteorder.h" 26 : 27 554 : NTSTATUS make_smb2_posix_create_ctx( 28 : TALLOC_CTX *mem_ctx, 29 : struct smb2_create_blobs **crb, 30 : mode_t mode) 31 : { 32 554 : struct smb2_create_blobs *cblobs = NULL; 33 0 : uint8_t linear_mode[4]; 34 554 : DATA_BLOB blob = { .data=linear_mode, .length=sizeof(linear_mode) }; 35 0 : NTSTATUS status; 36 : 37 554 : cblobs = talloc_zero(mem_ctx, struct smb2_create_blobs); 38 554 : if (cblobs == NULL) { 39 0 : return NT_STATUS_NO_MEMORY; 40 : } 41 554 : SIVAL(&linear_mode,0, unix_perms_to_wire(mode & ~S_IFMT)); 42 : 43 554 : status = smb2_create_blob_add( 44 : cblobs, cblobs, SMB2_CREATE_TAG_POSIX, blob); 45 554 : if (!NT_STATUS_IS_OK(status)) { 46 0 : TALLOC_FREE(cblobs); 47 0 : return status; 48 : } 49 554 : *crb = cblobs; 50 554 : return NT_STATUS_OK; 51 : }