[SCM] Samba Shared Repository - branch v4-11-test updated

Karolin Seeger kseeger at samba.org
Tue Apr 7 10:52:05 UTC 2020


The branch, v4-11-test has been updated
       via  f7ff511bc26 testprogs: Add 'net ads join createupn' test also verifying the keytab
       via  d9709735d5b s3:libads: Fix ads_get_upn()
       via  fa3250fdac1 smbd: let delayed update handler also update on-disk timestamps
       via  c8b5d996ec7 smbd: let mark_file_modified() always call trigger_write_time_update()
       via  8dbdba4a315 smbd: remove stat call from mark_file_modified()
       via  dbff6af0acf smbd: avoid double chdir() in chdir_current_service()
       via  0a8d442fe53 smbd: flush pending writetime update when setting timestamps file
       via  4f5a5e5d6e7 smbd: flush pending writetime update when flushing file
       via  5f4a49bd9f6 smbd: always flush pending write time update when setting filesize
      from  16d837cb233 nsswitch: fix use-after-free causing segfault in _pam_delete_cred

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-11-test


- Log -----------------------------------------------------------------
commit f7ff511bc26abf6f7a1b98cf31e461234a387892
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Apr 3 15:40:48 2020 +0200

    testprogs: Add 'net ads join createupn' test also verifying the keytab
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14336
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Mon Apr  6 19:09:53 UTC 2020 on sn-devel-184
    
    (cherry picked from commit c4be195da2845be4f64e47883e3c911dedd90e48)
    
    Autobuild-User(v4-11-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-11-test): Tue Apr  7 10:51:07 UTC 2020 on sn-devel-184

commit d9709735d5b26320a141ff686b9919539a8fa8a5
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Apr 3 15:58:28 2020 +0200

    s3:libads: Fix ads_get_upn()
    
    This adds the userPrincipalName to ads_find_machine_acct() which
    fetches the data for us.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14336
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Alexander Bokovoy <ab at samba.org>
    (cherry picked from commit ec69752cb963ae850568d3f4905d2941e485627e)

commit fa3250fdac1c8c79ffec6a4ebaf6183649b9086d
Author: Ralph Boehme <slow at samba.org>
Date:   Sun Mar 15 08:30:21 2020 +0100

    smbd: let delayed update handler also update on-disk timestamps
    
    Let delayed update handler also update on-disk timestamps by calling
    trigger_write_time_update_immediate().
    
    trigger_write_time_update_immediate() sets fsp->update_write_time_on_close to
    false which prevents updating the write-time on close if there was ever only one
    write to the file.
    
    Besides resetting fsp->update_write_time_on_close and setting the on-disk timestamps
    trigger_write_time_update_immediate() takes the same steps as the removed code.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14320
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Thu Mar 19 03:05:40 UTC 2020 on sn-devel-184
    
    (back ported from commit 81c1a14e3271aeed7ed4fe6311171b19ba963555)

commit c8b5d996ec77704835c59f4b2cd8190c31df98c2
Author: Ralph Boehme <slow at samba.org>
Date:   Sun Mar 15 08:30:21 2020 +0100

    smbd: let mark_file_modified() always call trigger_write_time_update()
    
    Preperatory change: the next commit will reset fsp->update_write_time_on_close
    in the event handler, so this change ensures it gets set again for any
    subsequent write.
    
    This will NOT always result in a write-time update because
    trigger_write_time_update() has its own only-once logic using the internal
    variable fsp->update_write_time_triggered.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14320
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 53de2da7acfc24513082190502d93306c12b7434)

commit 8dbdba4a3156e1b0caf18a55591cacebedb12369
Author: Ralph Boehme <slow at samba.org>
Date:   Sun Mar 15 15:51:18 2020 +0100

    smbd: remove stat call from mark_file_modified()
    
    This stat dates back to d03453864ab1bc5fd3b4a3abaf96176a006c102b where the call
    to trigger_write_time_update() had been to the file IO codepath. It was present
    there for other reasons: to setup the write-cache based on the file's size.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14320
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 2c19d27113036d607850f370bb9afd62856d671e)

commit dbff6af0acf36e2f377694d9f83a4a49d28b8ba6
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Jan 22 10:52:39 2020 +0100

    smbd: avoid double chdir() in chdir_current_service()
    
    Since 8e81090789e4cc3ba9e5aa792d4e52971909c894 we're doing chdir() twice, first
    into conn->connectpath, then into conn->origpath.
    
    Before commit 8e81090789e4cc3ba9e5aa792d4e52971909c894 if
    chdir(conn->connectpath) succeeded, we wouldn't do the second chdir().
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14256
    RN: smbd does a chdir() twice per request
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Thu Feb  6 11:44:07 UTC 2020 on sn-devel-184
    
    (backported from commit f705629a171c1411131164f3adff36175154c093)

commit 0a8d442fe535e0bcb69e927449cd1f4b26975fb8
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Mar 12 19:23:40 2020 +0100

    smbd: flush pending writetime update when setting timestamps file
    
    Cf the explanations in the previous commits.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14150
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (back-ported from commit 7b90fe69a865ae8648b6548eabbcf2fa8237ebd8)

commit 4f5a5e5d6e73ecf60cd11be3cff25e2bb15ddb7d
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Mar 12 19:23:40 2020 +0100

    smbd: flush pending writetime update when flushing file
    
    Cf the explanations in the previous commit.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14150
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (back-ported from commit d99d5bf2c6d0a818ef2f3920e0c93fac38761c36)

commit 5f4a49bd9f658370a9516233a63e66e241990f2e
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Mar 12 16:52:34 2020 +0100

    smbd: always flush pending write time update when setting filesize
    
    We need to flush a pending write time update even when we're setting the
    filesize to current filesize.
    
    Note that we're already doing it this way in the relevant places listed my
    dochelp at MS in
    
    https://lists.samba.org/archive/cifs-protocol/2019-December/003364.html
    
      Cleanup (= Close)
      SetBasicInfo
      SetAllocationInfo
      SetEndOfFileInfo
      SetValidDataLengthInfo
      Flush
      FSCTL_SET_ENCRYPTION
      FSCTL_OFFLOAD_WRITE
    
    Cleanup (= Close):
    
      Already implemented by update_write_time_on_close() and friends.
    
    SetBasicInfo:
    
      Currently doesn't flush pending updates. Fixed by a subsequent commit.
    
    SetAllocationInfo:
    
      smb_set_file_allocation_info() when setting a file's allocation size.
    
    SetEndOfFileInfo:
    
      Currently doesn't flush pending updates. Fixed by a subsequent commit.
    
    SetValidDataLengthInfo:
    
      Not implemented, returns NT_STATUS_NOT_SUPPORTED which seems wrong btw, as
      SetValidDataLengthInfo IS listed in MS-SMB2 2.2.39.
    
    Flush:
    
      Currently doesn't flush pending updates. Fixed by subsequent commit.
    
    FSCTL_SET_ENCRYPTION:
    
      Windows 2016 doesn't flush a pending writetime update, verified with a
      smbtorture test.
    
    FSCTL_OFFLOAD_WRITE:
    
      NT_STATUS_NOT_IMPLEMENTED
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14150
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (back-ported from commit 79d7d6b9d01b8547f16b74a62926d0b471f18c39)

-----------------------------------------------------------------------

Summary of changes:
 source3/libads/ldap.c              |  1 +
 source3/smbd/fileio.c              | 17 +++--------------
 source3/smbd/reply.c               | 11 +++++++++++
 source3/smbd/service.c             | 25 ++++++++++++++-----------
 source3/smbd/smb2_flush.c          |  7 +++++++
 source3/smbd/trans2.c              | 32 +++++++++++++++++++++++++-------
 testprogs/blackbox/test_net_ads.sh | 17 +++++++++++++++++
 7 files changed, 78 insertions(+), 32 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c
index 979192eb3ed..8ad76ed0ae9 100644
--- a/source3/libads/ldap.c
+++ b/source3/libads/ldap.c
@@ -1373,6 +1373,7 @@ char *ads_parent_dn(const char *dn)
 		"userAccountControl",
 		"DnsHostName",
 		"ServicePrincipalName",
+		"userPrincipalName",
 		"unicodePwd",
 
 		/* Additional attributes Samba checks */
diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c
index 067ce5a9ad4..36ff6344a5d 100644
--- a/source3/smbd/fileio.c
+++ b/source3/smbd/fileio.c
@@ -169,15 +169,7 @@ void fsp_flush_write_time_update(struct files_struct *fsp)
 
 	DEBUG(5, ("Update write time on %s\n", fsp_str_dbg(fsp)));
 
-	/* change the write time in the open file db. */
-	(void)set_write_time(fsp->file_id, timespec_current());
-
-	/* And notify. */
-        notify_fname(fsp->conn, NOTIFY_ACTION_MODIFIED,
-                     FILE_NOTIFY_CHANGE_LAST_WRITE, fsp->fsp_name->base_name);
-
-	/* Remove the timed event handler. */
-	TALLOC_FREE(fsp->update_write_time_event);
+	trigger_write_time_update_immediate(fsp);
 }
 
 static void update_write_time_handler(struct tevent_context *ctx,
@@ -277,17 +269,14 @@ void mark_file_modified(files_struct *fsp)
 {
 	int dosmode;
 
+	trigger_write_time_update(fsp);
+
 	if (fsp->modified) {
 		return;
 	}
 
 	fsp->modified = true;
 
-	if (SMB_VFS_FSTAT(fsp, &fsp->fsp_name->st) != 0) {
-		return;
-	}
-	trigger_write_time_update(fsp);
-
 	if (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) {
 		return;
 	}
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 65ac729c732..9736077c8ad 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -5418,6 +5418,10 @@ static struct files_struct *file_sync_one_fn(struct files_struct *fsp,
 	}
 	sync_file(conn, fsp, True /* write through */);
 
+	if (fsp->modified) {
+		trigger_write_time_update_immediate(fsp);
+	}
+
 	return NULL;
 }
 
@@ -5456,6 +5460,9 @@ void reply_flush(struct smb_request *req)
 			END_PROFILE(SMBflush);
 			return;
 		}
+		if (fsp->modified) {
+			trigger_write_time_update_immediate(fsp);
+		}
 	}
 
 	reply_outbuf(req, 0, 0);
@@ -8691,6 +8698,10 @@ void reply_setattrE(struct smb_request *req)
 		goto out;
 	}
 
+	if (fsp->modified) {
+		trigger_write_time_update_immediate(fsp);
+	}
+
 	DEBUG( 3, ( "reply_setattrE %s actime=%u modtime=%u "
 	       " createtime=%u\n",
 		fsp_fnum_dbg(fsp),
diff --git a/source3/smbd/service.c b/source3/smbd/service.c
index fd23d1a2d60..a4f7f898526 100644
--- a/source3/smbd/service.c
+++ b/source3/smbd/service.c
@@ -146,27 +146,30 @@ bool chdir_current_service(connection_struct *conn)
 	const struct smb_filename origpath_fname = {
 		.base_name = conn->origpath,
 	};
+	int saved_errno = 0;
 	int ret;
 
 	conn->lastused_count++;
 
 	ret = vfs_ChDir(conn, &connectpath_fname);
-	if (ret != 0) {
-		DEBUG(((errno!=EACCES)?0:3),
-		      ("chdir (%s) failed, reason: %s\n",
-		       conn->connectpath, strerror(errno)));
-		return false;
+	if (ret == 0) {
+		return true;
 	}
+	saved_errno = errno;
+	DEBUG(((errno!=EACCES)?0:3),
+	      ("chdir (%s) failed, reason: %s\n",
+	       conn->connectpath, strerror(errno)));
 
 	ret = vfs_ChDir(conn, &origpath_fname);
-	if (ret != 0) {
-		DEBUG(((errno!=EACCES)?0:3),
-			("chdir (%s) failed, reason: %s\n",
-			conn->origpath, strerror(errno)));
-		return false;
+	if (ret == 0) {
+		return true;
 	}
+	DEBUG(((errno!=EACCES)?0:3),
+	      ("chdir (%s) failed, reason: %s\n",
+	       conn->origpath, strerror(errno)));
 
-	return true;
+	errno = saved_errno;
+	return false;
 }
 
 /****************************************************************************
diff --git a/source3/smbd/smb2_flush.c b/source3/smbd/smb2_flush.c
index 470a8df4944..86dd14844e6 100644
--- a/source3/smbd/smb2_flush.c
+++ b/source3/smbd/smb2_flush.c
@@ -112,6 +112,7 @@ static void smbd_smb2_request_flush_done(struct tevent_req *subreq)
 
 struct smbd_smb2_flush_state {
 	struct smbd_smb2_request *smb2req;
+	struct files_struct *fsp;
 };
 
 static void smbd_smb2_flush_done(struct tevent_req *subreq);
@@ -133,6 +134,7 @@ static struct tevent_req *smbd_smb2_flush_send(TALLOC_CTX *mem_ctx,
 		return NULL;
 	}
 	state->smb2req = smb2req;
+	state->fsp = fsp;
 
 	DEBUG(10,("smbd_smb2_flush: %s - %s\n",
 		  fsp_str_dbg(fsp), fsp_fnum_dbg(fsp)));
@@ -214,6 +216,8 @@ static void smbd_smb2_flush_done(struct tevent_req *subreq)
 {
 	struct tevent_req *req = tevent_req_callback_data(
 		subreq, struct tevent_req);
+	struct smbd_smb2_flush_state *state = tevent_req_data(
+		req, struct smbd_smb2_flush_state);
 	int ret;
 	struct vfs_aio_state vfs_aio_state;
 
@@ -223,6 +227,9 @@ static void smbd_smb2_flush_done(struct tevent_req *subreq)
 		tevent_req_nterror(req, map_nt_error_from_unix(vfs_aio_state.error));
 		return;
 	}
+	if (state->fsp->modified) {
+		trigger_write_time_update_immediate(state->fsp);
+	}
 	tevent_req_done(req);
 }
 
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 8164c8fd213..78dabc016ed 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -6567,6 +6567,13 @@ static NTSTATUS smb_set_file_size(connection_struct *conn,
 		 get_file_size_stat(psbuf));
 
 	if (size == get_file_size_stat(psbuf)) {
+		if (fsp == NULL) {
+			return NT_STATUS_OK;
+		}
+		if (!fsp->modified) {
+			return NT_STATUS_OK;
+		}
+		trigger_write_time_update_immediate(fsp);
 		return NT_STATUS_OK;
 	}
 
@@ -7704,8 +7711,15 @@ static NTSTATUS smb_set_file_basic_info(connection_struct *conn,
 	DEBUG(10, ("smb_set_file_basic_info: file %s\n",
 		   smb_fname_str_dbg(smb_fname)));
 
-	return smb_set_file_time(conn, fsp, smb_fname, &ft,
-				 true);
+	status = smb_set_file_time(conn, fsp, smb_fname, &ft, true);
+	if (!NT_STATUS_IS_OK(status)) {
+		return status;
+	}
+
+	if (fsp != NULL && fsp->modified) {
+		trigger_write_time_update_immediate(fsp);
+	}
+	return NT_STATUS_OK;
 }
 
 /****************************************************************************
@@ -7742,11 +7756,15 @@ static NTSTATUS smb_set_info_standard(connection_struct *conn,
 		return status;
 	}
 
-        return smb_set_file_time(conn,
-                                fsp,
-				smb_fname,
-				&ft,
-                                true);
+	status = smb_set_file_time(conn, fsp, smb_fname, &ft, true);
+	if (!NT_STATUS_IS_OK(status)) {
+		return status;
+	}
+
+	if (fsp != NULL && fsp->modified) {
+		trigger_write_time_update_immediate(fsp);
+	}
+	return NT_STATUS_OK;
 }
 
 /****************************************************************************
diff --git a/testprogs/blackbox/test_net_ads.sh b/testprogs/blackbox/test_net_ads.sh
index 8bcff006b8e..95c0cf76f90 100755
--- a/testprogs/blackbox/test_net_ads.sh
+++ b/testprogs/blackbox/test_net_ads.sh
@@ -237,6 +237,23 @@ testit "leave+createcomputer" $VALGRIND $net_tool ads leave -U$DC_USERNAME%$DC_P
 
 testit "Remove OU=Servers" $VALGRIND $ldbdel -U$DC_USERNAME%$DC_PASSWORD -H ldap://$SERVER "OU=Servers,$base_dn"
 
+#
+# Test createupn option of 'net ads join'
+#
+testit "join+createupn" $VALGRIND $net_tool ads join -U$DC_USERNAME%$DC_PASSWORD createupn="host/test-$HOSTNAME@$REALM" || failed=`expr $failed + 1`
+
+testit_grep "checkupn" "userPrincipalName: host/test-$HOSTNAME@$REALM" $ldbsearch -U$DC_USERNAME%$DC_PASSWORD -H ldap://$SERVER.$REALM -s base -b "CN=$HOSTNAME,CN=Computers,$base_dn" || failed=`expr $failed + 1`
+
+dedicated_keytab_file="$PREFIX_ABS/test_net_create_dedicated_krb5.keytab"
+
+testit "create_keytab" $VALGRIND $net_tool ads keytab create --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" || failed=`expr $failed + 1`
+
+testit_grep "checkupn+keytab" "host/test-$HOSTNAME@$REALM" $net_tool ads keytab list --option="kerberosmethod=dedicatedkeytab" --option="dedicatedkeytabfile=$dedicated_keytab_file" || failed=`expr $failed + 1`
+
+rm -f $dedicated_keytab_file
+
+testit "leave+createupn" $VALGRIND $net_tool ads leave -U$DC_USERNAME%$DC_PASSWORD || failed=`expr $failed + 1`
+
 rm -rf $BASEDIR/$WORKDIR
 
 exit $failed


-- 
Samba Shared Repository



More information about the samba-cvs mailing list