CVE-2023-3961:s3:torture: Add test SMB2-INVALID-PIPENAME to show we allow bad pipenam...
[Samba.git] / source3 / smbd / smb2_posix.c
blob1cd76e2222294c8469e60aa2e12f27d9187c8c98
1 /*
2 Unix SMB/CIFS implementation.
3 SMB2 POSIX code.
4 Copyright (C) Jeremy Allison 2022
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "includes.h"
21 #include "smbd/smbd.h"
22 #include "passdb/lookup_sid.h"
23 #include "librpc/gen_ndr/ndr_security.h"
24 #include "librpc/gen_ndr/smb3posix.h"
25 #include "libcli/security/security.h"
27 void smb3_file_posix_information_init(
28 connection_struct *conn,
29 const struct stat_ex *st,
30 uint32_t reparse_tag,
31 uint32_t dos_attributes,
32 struct smb3_file_posix_information *dst)
34 *dst = (struct smb3_file_posix_information) {
35 .end_of_file = get_file_size_stat(st),
36 .allocation_size = SMB_VFS_GET_ALLOC_SIZE(conn,NULL,st),
37 .device = st->st_ex_dev,
38 .creation_time = unix_timespec_to_nt_time(st->st_ex_btime),
39 .last_access_time = unix_timespec_to_nt_time(st->st_ex_atime),
40 .last_write_time = unix_timespec_to_nt_time(st->st_ex_mtime),
41 .change_time = unix_timespec_to_nt_time(st->st_ex_ctime),
42 .cc.reparse_tag = reparse_tag,
43 .cc.posix_perms = unix_perms_to_wire(st->st_ex_mode & ~S_IFMT),
44 .cc.owner = global_sid_NULL,
45 .cc.group = global_sid_NULL,
48 if (st->st_ex_uid != (uid_t)-1) {
49 uid_to_sid(&dst->cc.owner, st->st_ex_uid);
51 if (st->st_ex_gid != (uid_t)-1) {
52 uid_to_sid(&dst->cc.owner, st->st_ex_gid);
55 switch (st->st_ex_mode & S_IFMT) {
56 case S_IFREG:
57 dst->file_attributes = dos_attributes;
58 break;
59 case S_IFDIR:
60 dst->file_attributes = dos_attributes | FILE_ATTRIBUTE_DIRECTORY;
61 break;
62 default:
64 * All non-directory or regular files are reported
65 * as reparse points. Client may or may not be able
66 * to access these.
68 dst->file_attributes = FILE_ATTRIBUTE_REPARSE_POINT;
69 break;