s3:smbd: ensure to update the File-ID in struct smb_filename
authorRalph Boehme <slow@samba.org>
Fri, 30 Aug 2019 12:48:40 +0000 (14:48 +0200)
committerRalph Boehme <slow@samba.org>
Tue, 10 Sep 2019 19:05:29 +0000 (19:05 +0000)
Initialize the File-ID in fsp->fsp_name->st, any subsequent metadata fetch on
this file-handle needs this, eg QFID SMB2 Create-Context or GETINFO SMB
requests.

It would be nice if SMB_VFS_SET_DOS_ATTRIBUTE() would do this, unfortunately it
gets a const struct smb_filename.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14121

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/smbd/open.c

index 088e8cc1716beca23594bc2c257bd177a3028be4..7797df03e4b87ce41bad114911fe1402cd7edd47 100644 (file)
@@ -3667,6 +3667,15 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
 
        if (info == FILE_WAS_CREATED) {
                smb_fname->st.st_ex_iflags &= ~ST_EX_IFLAG_CALCULATED_ITIME;
+
+               if (lp_store_dos_attributes(SNUM(conn)) &&
+                   smb_fname->st.st_ex_iflags & ST_EX_IFLAG_CALCULATED_FILE_ID)
+               {
+                       uint64_t file_id;
+
+                       file_id = make_file_id_from_itime(&smb_fname->st);
+                       update_stat_ex_file_id(&smb_fname->st, file_id);
+               }
        }
 
        if (info != FILE_WAS_OPENED) {
@@ -3819,6 +3828,14 @@ static NTSTATUS mkdir_internal(connection_struct *conn,
        smb_dname->st.st_ex_iflags &= ~ST_EX_IFLAG_CALCULATED_ITIME;
 
        if (lp_store_dos_attributes(SNUM(conn))) {
+               if (smb_dname->st.st_ex_iflags & ST_EX_IFLAG_CALCULATED_FILE_ID)
+               {
+                       uint64_t file_id;
+
+                       file_id = make_file_id_from_itime(&smb_dname->st);
+                       update_stat_ex_file_id(&smb_dname->st, file_id);
+               }
+
                if (!posix_open) {
                        file_set_dosmode(conn, smb_dname,
                                         file_attributes | FILE_ATTRIBUTE_DIRECTORY,