LCOV - code coverage report
Current view: top level - source3/smbd - smb2_posix.c (source / functions) Hit Total Coverage
Test: coverage report for support-claim-type-attributes 6b5c566e Lines: 24 27 88.9 %
Date: 2023-11-21 12:31:41 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/CIFS implementation.
       3             :    SMB2 POSIX code.
       4             :    Copyright (C) Jeremy Allison                 2022
       5             : 
       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.
      10             : 
      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.
      15             : 
      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/>.
      18             : */
      19             : 
      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"
      26             : 
      27        1431 : 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)
      33             : {
      34        2862 :         *dst = (struct smb3_file_posix_information) {
      35        1431 :                 .end_of_file = get_file_size_stat(st),
      36        1431 :                 .allocation_size = SMB_VFS_GET_ALLOC_SIZE(conn,NULL,st),
      37        1431 :                 .inode = SMB_VFS_FS_FILE_ID(conn, st),
      38        1431 :                 .device = st->st_ex_dev,
      39        1431 :                 .creation_time = unix_timespec_to_nt_time(st->st_ex_btime),
      40        1431 :                 .last_access_time = unix_timespec_to_nt_time(st->st_ex_atime),
      41        1431 :                 .last_write_time = unix_timespec_to_nt_time(st->st_ex_mtime),
      42        1431 :                 .change_time = unix_timespec_to_nt_time(st->st_ex_ctime),
      43        1431 :                 .cc.nlinks = st->st_ex_nlink,
      44             :                 .cc.reparse_tag = reparse_tag,
      45        1431 :                 .cc.posix_perms = unix_perms_to_wire(st->st_ex_mode & ~S_IFMT),
      46             :                 .cc.owner = global_sid_NULL,
      47             :                 .cc.group = global_sid_NULL,
      48             :         };
      49             : 
      50        1431 :         if (st->st_ex_uid != (uid_t)-1) {
      51        1425 :                 uid_to_sid(&dst->cc.owner, st->st_ex_uid);
      52             :         }
      53        1431 :         if (st->st_ex_gid != (uid_t)-1) {
      54        1425 :                 gid_to_sid(&dst->cc.group, st->st_ex_gid);
      55             :         }
      56             : 
      57        1431 :         switch (st->st_ex_mode & S_IFMT) {
      58         655 :         case S_IFREG:
      59         655 :                 dst->file_attributes = dos_attributes;
      60         655 :                 break;
      61         776 :         case S_IFDIR:
      62         776 :                 dst->file_attributes = dos_attributes | FILE_ATTRIBUTE_DIRECTORY;
      63         776 :                 break;
      64           0 :         default:
      65             :                 /*
      66             :                  * All non-directory or regular files are reported
      67             :                  * as reparse points. Client may or may not be able
      68             :                  * to access these.
      69             :                  */
      70           0 :                 dst->file_attributes = FILE_ATTRIBUTE_REPARSE_POINT;
      71           0 :                 break;
      72             :         }
      73        1431 : }

Generated by: LCOV version 1.14