[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Fri Nov 2 23:24:03 UTC 2018


The branch, master has been updated
       via  c2b9b57 lib: Make dom_sid_string_buf static
       via  7d95816 lib: Use dom_sid_str_buf
       via  ab542ed auth: Use dom_sid_str_buf
       via  74c7e3d audit_logging: Use dom_sid_str_buf
       via  7963e40 passdb: Use dom_sid_str_buf
       via  be6f45c lib: Use dom_sid_str_buf
       via  039aef7 libsmb: Use dom_sid_str_buf
       via  ce18cd2 smbd: Use dom_sid_str_buf
       via  528170e winbindd: Use dom_sid_str_buf
       via  bd1e43f winbindd: Use dom_sid_str_buf
       via  602d247 auth4: Use dom_sid_str_buf
       via  d0a56a5 audit_tests: Use dom_sid_str_buf
       via  dbc9a1a net: Use dom_sid_str_buf
       via  7154953 idmap: Use dom_sid_str_buf
       via  4c1d107 auth: Use dom_sid_str_buf
       via  4602605 dsdb: Use dom_sid_str_buf
       via  b9c590a rpc_server4: Use dom_sid_str_buf
       via  07d0520 nbt_server: Use dom_sid_str_buf
       via  3fa4590 s3:smbd: remove now unused check if fsp is NULL
       via  07eb805 s3:smbd: fix SMB2 aio cancelling
       via  e37ff8c s4:torture/smb2/read: add test for cancelling SMB aio
       via  35f9bc0 vfs_delay_inject: implement pread_send and pwrite_send
       via  a6de555 s4:libcli/smb2: reapply request endtime
       via  e7eec24 libcli: fill endtime if smbXcli_req_create() timeout is non-zero
       via  94ad5ee libcli: add smbXcli_req_endtime
      from  8b9d362 lib: Add dom_sid_str_buf

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit c2b9b574b2d5215fdf431cc5be106c58c0a4eefe
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Oct 26 14:09:32 2018 +0200

    lib: Make dom_sid_string_buf static
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Sat Nov  3 00:23:31 CET 2018 on sn-devel-144

commit 7d958162bf45fe582b1a4fe30f0e5ffba1325e97
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Oct 26 08:25:14 2018 +0200

    lib: Use dom_sid_str_buf
    
    This is the one place where we have to do another strpcy. Many of the
    sid_to_fstring calls should be replacable by dom_sid_str_buf, so this
    will get less.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit ab542ed2c9883fdfe709be4dd0b37ef8d5862695
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Oct 26 08:25:14 2018 +0200

    auth: Use dom_sid_str_buf
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 74c7e3d19a590c64e0bedbb3756f23c8d6f6369e
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Oct 26 08:25:14 2018 +0200

    audit_logging: Use dom_sid_str_buf
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 7963e409cc231922f90f57477c2414674c917bdc
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Oct 26 08:25:14 2018 +0200

    passdb: Use dom_sid_str_buf
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit be6f45ca5ed66ef5f168bafa2046f400cfbea911
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Oct 26 08:25:14 2018 +0200

    lib: Use dom_sid_str_buf
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 039aef708382ac3c09859ea28b54b195bfc19dc2
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Oct 26 08:25:14 2018 +0200

    libsmb: Use dom_sid_str_buf
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit ce18cd2a3be78ef9d3abe87539e27c6d81dbb944
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Oct 26 08:25:14 2018 +0200

    smbd: Use dom_sid_str_buf
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 528170ef6bf1dabc6aef793790dd9bd2d4018db3
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Oct 26 08:25:14 2018 +0200

    winbindd: Use dom_sid_str_buf
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit bd1e43f7cb8a3a641f064259f7c2831b83262b5a
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Oct 26 08:25:14 2018 +0200

    winbindd: Use dom_sid_str_buf
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 602d247e0ba9a69c22f087abaf44de7d12114538
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Oct 25 21:45:05 2018 +0200

    auth4: Use dom_sid_str_buf
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit d0a56a55b613ac701bd39236fc7550d87252559b
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Oct 25 21:26:38 2018 +0200

    audit_tests: Use dom_sid_str_buf
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit dbc9a1a772d36447414b68bb9a860f0b4fe4723c
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Oct 18 06:18:22 2018 +0200

    net: Use dom_sid_str_buf
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 71549537b7a91ed61ae519b07b719f539a441fc0
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Oct 18 06:08:32 2018 +0200

    idmap: Use dom_sid_str_buf
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 4c1d10760d9d0cc788eb8994b99ce238ba25bbd0
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Oct 18 06:08:19 2018 +0200

    auth: Use dom_sid_str_buf
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 4602605323e76f853320e360632d644b310dd93b
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Oct 18 05:57:26 2018 +0200

    dsdb: Use dom_sid_str_buf
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit b9c590a68ec85c2a99cf2c70d4f840235044ad0b
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Oct 18 05:55:24 2018 +0200

    rpc_server4: Use dom_sid_str_buf
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 07d052024a08e3817bda17c74731e621c8c6cd83
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Oct 18 05:55:04 2018 +0200

    nbt_server: Use dom_sid_str_buf
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 3fa45900c0ada6596daf09aa4c5054974f3394b0
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Oct 31 10:21:31 2018 +0100

    s3:smbd: remove now unused check if fsp is NULL
    
    This was used internally to mark an aio request as cancelled. As the aio
    cancellation functionality has been removed, we can now also remove this
    check.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13667
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 07eb805cde4db6ac74740e3cfbc56ab6f8e2118a
Author: Ralph Boehme <slow at samba.org>
Date:   Sun Oct 28 19:35:59 2018 +0100

    s3:smbd: fix SMB2 aio cancelling
    
    As we currently don't attempt to cancel the internal aio request, we
    must ignore the SMB2 cancel request and continue to process the SMB2
    request, cf MS-SM2 3.3.5.16:
    
      If the target request is not successfully canceled, processing of the
      target request MUST continue and no response is sent to the cancel
      request.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13667
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit e37ff8c5fe18d400e378bf2591e209b30473d9f9
Author: Ralph Boehme <slow at samba.org>
Date:   Sun Oct 28 19:29:26 2018 +0100

    s4:torture/smb2/read: add test for cancelling SMB aio
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13667
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 35f9bc06722fb07143c832442d784beb204bd367
Author: Ralph Boehme <slow at samba.org>
Date:   Sun Oct 28 19:28:42 2018 +0100

    vfs_delay_inject: implement pread_send and pwrite_send
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13667
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit a6de555c51ca34ef24ac4b4cb672cd748d3197a1
Author: Ralph Boehme <slow at samba.org>
Date:   Sun Oct 28 02:05:45 2018 +0100

    s4:libcli/smb2: reapply request endtime
    
    tevent_req_finish() removed a possible request timeout, make sure to
    reinstall it. This happened when an interim SMB2 response was received.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13667
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit e7eec24d27b8694fd7626577a2aca05e99045964
Author: Ralph Boehme <slow at samba.org>
Date:   Sun Oct 28 02:04:51 2018 +0100

    libcli: fill endtime if smbXcli_req_create() timeout is non-zero
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13667
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 94ad5ee662a5bfe1c79d8a9c3fcf51d0a1d652c7
Author: Ralph Boehme <slow at samba.org>
Date:   Sun Oct 28 02:03:28 2018 +0100

    libcli: add smbXcli_req_endtime
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13667
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

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

Summary of changes:
 auth/auth_log.c                                    |  14 +-
 lib/audit_logging/audit_logging.c                  |   8 +-
 libcli/security/dom_sid.c                          |   2 +-
 libcli/security/dom_sid.h                          |   1 -
 libcli/smb/smbXcli_base.c                          |  22 +-
 libcli/smb/smbXcli_base.h                          |   1 +
 selftest/target/Samba3.pm                          |   6 +
 source3/groupdb/mapping_tdb.c                      |  11 +-
 source3/lib/namemap_cache.c                        |  26 +-
 source3/lib/util_sid.c                             |   3 +-
 source3/libsmb/samlogon_cache.c                    |  38 +--
 source3/modules/vfs_delay_inject.c                 | 262 +++++++++++++++++++++
 source3/selftest/tests.py                          |   2 +
 source3/smbd/aio.c                                 |  28 +--
 source3/smbd/nttrans.c                             |   6 +-
 source3/utils/net_cache.c                          |   7 +-
 source3/winbindd/idmap_script.c                    |  11 +-
 source3/winbindd/wb_lookupusergroups.c             |   6 +-
 source3/winbindd/winbindd_xids_to_sids.c           |  13 +-
 source4/auth/sam.c                                 |  14 +-
 source4/dsdb/samdb/ldb_modules/operational.c       |  11 +-
 .../dsdb/samdb/ldb_modules/tests/test_audit_util.c |  20 +-
 source4/libcli/smb2/transport.c                    |  17 ++
 source4/nbt_server/dgram/netlogon.c                |  10 +-
 source4/rpc_server/samr/dcesrv_samr.c              |  11 +-
 source4/selftest/tests.py                          |   1 +
 source4/torture/smb2/read.c                        | 116 +++++++++
 source4/torture/smb2/smb2.c                        |   1 +
 28 files changed, 529 insertions(+), 139 deletions(-)


Changeset truncated at 500 lines:

diff --git a/auth/auth_log.c b/auth/auth_log.c
index 9e57b1d..2d4e33f 100644
--- a/auth/auth_log.c
+++ b/auth/auth_log.c
@@ -578,14 +578,13 @@ static void log_authentication_event_human_readable(
 	local = tsocket_address_string(ui->local_host, frame);
 
 	if (NT_STATUS_IS_OK(status)) {
-		char sid_buf[DOM_SID_STR_BUFLEN];
+		struct dom_sid_buf sid_buf;
 
-		dom_sid_string_buf(sid, sid_buf, sizeof(sid_buf));
 		logon_line = talloc_asprintf(frame,
 					     " became [%s]\\[%s] [%s].",
 					     log_escape(frame, domain_name),
 					     log_escape(frame, account_name),
-					     sid_buf);
+					     dom_sid_str_buf(sid, &sid_buf));
 	} else {
 		logon_line = talloc_asprintf(
 				frame,
@@ -690,7 +689,7 @@ static void log_successful_authz_event_human_readable(
 	const char *ts = NULL;       /* formatted current time      */
 	char *remote_str = NULL;     /* formatted remote host       */
 	char *local_str = NULL;      /* formatted local host        */
-	char sid_buf[DOM_SID_STR_BUFLEN];
+	struct dom_sid_buf sid_buf;
 
 	frame = talloc_stackframe();
 
@@ -700,10 +699,6 @@ static void log_successful_authz_event_human_readable(
 	remote_str = tsocket_address_string(remote, frame);
 	local_str = tsocket_address_string(local, frame);
 
-	dom_sid_string_buf(&session_info->security_token->sids[0],
-			   sid_buf,
-			   sizeof(sid_buf));
-
 	DEBUGC(DBGC_AUTH_AUDIT, debug_level,
 	       ("Successful AuthZ: [%s,%s] user [%s]\\[%s] [%s]"
 		" at [%s]"
@@ -713,7 +708,8 @@ static void log_successful_authz_event_human_readable(
 		auth_type,
 		log_escape(frame, session_info->info->domain_name),
 		log_escape(frame, session_info->info->account_name),
-		sid_buf,
+		dom_sid_str_buf(&session_info->security_token->sids[0],
+				&sid_buf),
 		ts,
 		remote_str,
 		local_str));
diff --git a/lib/audit_logging/audit_logging.c b/lib/audit_logging/audit_logging.c
index c274e97..acccb9f 100644
--- a/lib/audit_logging/audit_logging.c
+++ b/lib/audit_logging/audit_logging.c
@@ -826,14 +826,14 @@ int json_add_sid(struct json_object *object,
 			return ret;
 		}
 	} else {
-		char sid_buf[DOM_SID_STR_BUFLEN];
+		struct dom_sid_buf sid_buf;
 
-		dom_sid_string_buf(sid, sid_buf, sizeof(sid_buf));
-		ret = json_add_string(object, name, sid_buf);
+		ret = json_add_string(
+			object, name, dom_sid_str_buf(sid, &sid_buf));
 		if (ret != 0) {
 			DBG_ERR("Unable to add SID [%s] value [%s]\n",
 				name,
-				sid_buf);
+				sid_buf.buf);
 			return ret;
 		}
 	}
diff --git a/libcli/security/dom_sid.c b/libcli/security/dom_sid.c
index 97f719f..2a0b60c 100644
--- a/libcli/security/dom_sid.c
+++ b/libcli/security/dom_sid.c
@@ -429,7 +429,7 @@ bool dom_sid_is_valid_account_domain(const struct dom_sid *sid)
   string length. If it overflows, return the string length that would
   result (buflen needs to be +1 for the terminating 0).
 */
-int dom_sid_string_buf(const struct dom_sid *sid, char *buf, int buflen)
+static int dom_sid_string_buf(const struct dom_sid *sid, char *buf, int buflen)
 {
 	int i, ofs, ret;
 	uint64_t ia;
diff --git a/libcli/security/dom_sid.h b/libcli/security/dom_sid.h
index d132628..1effdbc 100644
--- a/libcli/security/dom_sid.h
+++ b/libcli/security/dom_sid.h
@@ -99,7 +99,6 @@ bool dom_sid_in_domain(const struct dom_sid *domain_sid,
 bool dom_sid_is_valid_account_domain(const struct dom_sid *sid);
 
 #define DOM_SID_STR_BUFLEN (15*11+25)
-int dom_sid_string_buf(const struct dom_sid *sid, char *buf, int buflen);
 char *dom_sid_string(TALLOC_CTX *mem_ctx, const struct dom_sid *sid);
 
 struct dom_sid_buf { char buf[DOM_SID_STR_BUFLEN]; };
diff --git a/libcli/smb/smbXcli_base.c b/libcli/smb/smbXcli_base.c
index d94b4d8..9edb629 100644
--- a/libcli/smb/smbXcli_base.c
+++ b/libcli/smb/smbXcli_base.c
@@ -227,6 +227,8 @@ struct smbXcli_req_state {
 
 	struct tevent_req *write_req;
 
+	struct timeval endtime;
+
 	struct {
 		/* Space for the header including the wct */
 		uint8_t hdr[HDR_VWV];
@@ -1583,10 +1585,8 @@ struct tevent_req *smb1cli_req_create(TALLOC_CTX *mem_ctx,
 	state->smb1.iov_count = iov_count + 4;
 
 	if (timeout_msec > 0) {
-		struct timeval endtime;
-
-		endtime = timeval_current_ofs_msec(timeout_msec);
-		if (!tevent_req_set_endtime(req, ev, endtime)) {
+		state->endtime = timeval_current_ofs_msec(timeout_msec);
+		if (!tevent_req_set_endtime(req, ev, state->endtime)) {
 			return req;
 		}
 	}
@@ -2892,6 +2892,14 @@ static void smb2cli_req_cancel_done(struct tevent_req *subreq)
 	TALLOC_FREE(subreq);
 }
 
+struct timeval smbXcli_req_endtime(struct tevent_req *req)
+{
+	struct smbXcli_req_state *state = tevent_req_data(
+		req, struct smbXcli_req_state);
+
+	return state->endtime;
+}
+
 struct tevent_req *smb2cli_req_create(TALLOC_CTX *mem_ctx,
 				      struct tevent_context *ev,
 				      struct smbXcli_conn *conn,
@@ -3041,10 +3049,8 @@ struct tevent_req *smb2cli_req_create(TALLOC_CTX *mem_ctx,
 	}
 
 	if (timeout_msec > 0) {
-		struct timeval endtime;
-
-		endtime = timeval_current_ofs_msec(timeout_msec);
-		if (!tevent_req_set_endtime(req, ev, endtime)) {
+		state->endtime = timeval_current_ofs_msec(timeout_msec);
+		if (!tevent_req_set_endtime(req, ev, state->endtime)) {
 			return req;
 		}
 	}
diff --git a/libcli/smb/smbXcli_base.h b/libcli/smb/smbXcli_base.h
index 20ef26e..536c7ab 100644
--- a/libcli/smb/smbXcli_base.h
+++ b/libcli/smb/smbXcli_base.h
@@ -74,6 +74,7 @@ NTSTATUS smbXcli_conn_samba_suicide(struct smbXcli_conn *conn,
 
 void smbXcli_req_unset_pending(struct tevent_req *req);
 bool smbXcli_req_set_pending(struct tevent_req *req);
+struct timeval smbXcli_req_endtime(struct tevent_req *req);
 
 uint32_t smb1cli_conn_capabilities(struct smbXcli_conn *conn);
 uint32_t smb1cli_conn_max_xmit(struct smbXcli_conn *conn);
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index f7957cf..f8fda35 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -2250,6 +2250,12 @@ sub provision($$$$$$$$$)
 	kernel oplocks = no
 	posix locking = no
 	include = $libdir/delay_inject.conf
+
+[aio_delay_inject]
+	copy = tmp
+	vfs objects = delay_inject
+	delay_inject:pread_send = 2000
+	delay_inject:pwrite_send = 2000
 	";
 	close(CONF);
 
diff --git a/source3/groupdb/mapping_tdb.c b/source3/groupdb/mapping_tdb.c
index 3561057..b5b1176 100644
--- a/source3/groupdb/mapping_tdb.c
+++ b/source3/groupdb/mapping_tdb.c
@@ -133,15 +133,10 @@ static bool init_group_mapping(void)
 
 static char *group_mapping_key(TALLOC_CTX *mem_ctx, const struct dom_sid *sid)
 {
-	char sidstr[DOM_SID_STR_BUFLEN];
-	int len;
-
-	len = dom_sid_string_buf(sid, sidstr, sizeof(sidstr));
-	if (len >= sizeof(sidstr)) {
-		return NULL;
-	}
+	struct dom_sid_buf sidstr;
 
-	return talloc_asprintf(mem_ctx, "%s%s", GROUP_PREFIX, sidstr);
+	return talloc_asprintf(
+		mem_ctx, "%s%s", GROUP_PREFIX, dom_sid_str_buf(sid, &sidstr));
 }
 
 /****************************************************************************
diff --git a/source3/lib/namemap_cache.c b/source3/lib/namemap_cache.c
index c153aa6..fa17951 100644
--- a/source3/lib/namemap_cache.c
+++ b/source3/lib/namemap_cache.c
@@ -31,8 +31,8 @@ bool namemap_cache_set_sid2name(const struct dom_sid *sid,
 				enum lsa_SidType type, time_t timeout)
 {
 	char typebuf[16];
-	char sidbuf[DOM_SID_STR_BUFLEN];
-	char keybuf[DOM_SID_STR_BUFLEN+10];
+	struct dom_sid_buf sidbuf;
+	char keybuf[sizeof(sidbuf.buf)+10];
 	char *val = NULL;
 	DATA_BLOB data;
 	int ret;
@@ -70,8 +70,8 @@ bool namemap_cache_set_sid2name(const struct dom_sid *sid,
 		goto fail;
 	}
 
-	dom_sid_string_buf(sid, sidbuf, sizeof(sidbuf));
-	snprintf(keybuf, sizeof(keybuf), "SID2NAME/%s", sidbuf);
+	dom_sid_str_buf(sid, &sidbuf);
+	snprintf(keybuf, sizeof(keybuf), "SID2NAME/%s", sidbuf.buf);
 
 	data = data_blob_const(val, talloc_get_size(val));
 
@@ -151,12 +151,12 @@ bool namemap_cache_find_sid(const struct dom_sid *sid,
 	struct namemap_cache_find_sid_state state = {
 		.fn = fn, .private_data = private_data
 	};
-	char sidbuf[DOM_SID_STR_BUFLEN];
-	char keybuf[DOM_SID_STR_BUFLEN+10];
+	struct dom_sid_buf sidbuf;
+	char keybuf[sizeof(sidbuf.buf)+10];
 	bool ok;
 
-	dom_sid_string_buf(sid, sidbuf, sizeof(sidbuf));
-	snprintf(keybuf, sizeof(keybuf), "SID2NAME/%s", sidbuf);
+	dom_sid_str_buf(sid, &sidbuf);
+	snprintf(keybuf, sizeof(keybuf), "SID2NAME/%s", sidbuf.buf);
 
 	ok = gencache_parse(keybuf, namemap_cache_find_sid_parser, &state);
 	if (!ok) {
@@ -179,7 +179,7 @@ bool namemap_cache_set_name2sid(const char *domain, const char *name,
 				time_t timeout)
 {
 	char typebuf[16];
-	char sidbuf[DOM_SID_STR_BUFLEN];
+	struct dom_sid_buf sidbuf = {{0}};
 	char *key;
 	char *key_upper;
 	char *val = NULL;
@@ -193,10 +193,8 @@ bool namemap_cache_set_name2sid(const char *domain, const char *name,
 	if (name == NULL) {
 		name = "";
 	}
-	if (type == SID_NAME_UNKNOWN) {
-		sidbuf[0] = '\0';
-	} else {
-		dom_sid_string_buf(sid, sidbuf, sizeof(sidbuf));
+	if (type != SID_NAME_UNKNOWN) {
+		dom_sid_str_buf(sid, &sidbuf);
 	}
 
 	snprintf(typebuf, sizeof(typebuf), "%d", (int)type);
@@ -212,7 +210,7 @@ bool namemap_cache_set_name2sid(const char *domain, const char *name,
 		goto fail;
 	}
 
-	ret = strv_add(key, &val, sidbuf);
+	ret = strv_add(key, &val, sidbuf.buf);
 	if (ret != 0) {
 		DBG_DEBUG("strv_add failed: %s\n", strerror(ret));
 		goto fail;
diff --git a/source3/lib/util_sid.c b/source3/lib/util_sid.c
index 4d57a92..13d5e1c 100644
--- a/source3/lib/util_sid.c
+++ b/source3/lib/util_sid.c
@@ -34,7 +34,8 @@
 
 char *sid_to_fstring(fstring sidstr_out, const struct dom_sid *sid)
 {
-	dom_sid_string_buf(sid, sidstr_out, sizeof(fstring));
+	struct dom_sid_buf buf;
+	fstrcpy(sidstr_out, dom_sid_str_buf(sid, &buf));
 	return sidstr_out;
 }
 
diff --git a/source3/libsmb/samlogon_cache.c b/source3/libsmb/samlogon_cache.c
index 9638df6..494eb10 100644
--- a/source3/libsmb/samlogon_cache.c
+++ b/source3/libsmb/samlogon_cache.c
@@ -98,7 +98,7 @@ clear:
 
 void netsamlogon_clear_cached_user(const struct dom_sid *user_sid)
 {
-	char keystr[DOM_SID_STR_BUFLEN];
+	struct dom_sid_buf keystr;
 
 	if (!netsamlogon_cache_init()) {
 		DEBUG(0,("netsamlogon_clear_cached_user: cannot open "
@@ -108,11 +108,11 @@ void netsamlogon_clear_cached_user(const struct dom_sid *user_sid)
 	}
 
 	/* Prepare key as DOMAIN-SID/USER-RID string */
-	dom_sid_string_buf(user_sid, keystr, sizeof(keystr));
+	dom_sid_str_buf(user_sid, &keystr);
 
-	DEBUG(10,("netsamlogon_clear_cached_user: SID [%s]\n", keystr));
+	DBG_DEBUG("SID [%s]\n", keystr.buf);
 
-	tdb_delete_bystring(netsamlogon_tdb, keystr);
+	tdb_delete_bystring(netsamlogon_tdb, keystr.buf);
 }
 
 /***********************************************************************
@@ -124,7 +124,7 @@ bool netsamlogon_cache_store(const char *username, struct netr_SamInfo3 *info3)
 {
 	uint8_t dummy = 0;
 	TDB_DATA data = { .dptr = &dummy, .dsize = sizeof(dummy) };
-	char keystr[DOM_SID_STR_BUFLEN];
+	struct dom_sid_buf keystr;
 	bool result = false;
 	struct dom_sid	user_sid;
 	TALLOC_CTX *tmp_ctx = talloc_stackframe();
@@ -149,22 +149,22 @@ bool netsamlogon_cache_store(const char *username, struct netr_SamInfo3 *info3)
 	 * overwriting potentially other data. We're just interested
 	 * in the existence of that record.
 	 */
-	dom_sid_string_buf(info3->base.domain_sid, keystr, sizeof(keystr));
+	dom_sid_str_buf(info3->base.domain_sid, &keystr);
 
-	ret = tdb_store_bystring(netsamlogon_tdb, keystr, data, TDB_INSERT);
+	ret = tdb_store_bystring(netsamlogon_tdb, keystr.buf, data, TDB_INSERT);
 
 	if ((ret == -1) && (tdb_error(netsamlogon_tdb) != TDB_ERR_EXISTS)) {
 		DBG_WARNING("Could not store domain marker for %s: %s\n",
-			    keystr, tdb_errorstr(netsamlogon_tdb));
+			    keystr.buf, tdb_errorstr(netsamlogon_tdb));
 		goto fail;
 	}
 
 	sid_compose(&user_sid, info3->base.domain_sid, info3->base.rid);
 
 	/* Prepare key as DOMAIN-SID/USER-RID string */
-	dom_sid_string_buf(&user_sid, keystr, sizeof(keystr));
+	dom_sid_str_buf(&user_sid, &keystr);
 
-	DEBUG(10,("netsamlogon_cache_store: SID [%s]\n", keystr));
+	DBG_DEBUG("SID [%s]\n", keystr.buf);
 
 	/* Prepare data */
 
@@ -217,7 +217,7 @@ bool netsamlogon_cache_store(const char *username, struct netr_SamInfo3 *info3)
 	data.dsize = blob.length;
 	data.dptr = blob.data;
 
-	if (tdb_store_bystring(netsamlogon_tdb, keystr, data, TDB_REPLACE) == 0) {
+	if (tdb_store_bystring(netsamlogon_tdb, keystr.buf, data, TDB_REPLACE) == 0) {
 		result = true;
 	}
 
@@ -235,7 +235,7 @@ struct netr_SamInfo3 *netsamlogon_cache_get(TALLOC_CTX *mem_ctx, const struct do
 {
 	struct netr_SamInfo3 *info3 = NULL;
 	TDB_DATA data;
-	char keystr[DOM_SID_STR_BUFLEN];
+	struct dom_sid_buf keystr;
 	enum ndr_err_code ndr_err;
 	DATA_BLOB blob;
 	struct netsamlogoncache_entry r;
@@ -247,9 +247,9 @@ struct netr_SamInfo3 *netsamlogon_cache_get(TALLOC_CTX *mem_ctx, const struct do
 	}
 
 	/* Prepare key as DOMAIN-SID/USER-RID string */
-	dom_sid_string_buf(user_sid, keystr, sizeof(keystr));
-	DEBUG(10,("netsamlogon_cache_get: SID [%s]\n", keystr));
-	data = tdb_fetch_bystring( netsamlogon_tdb, keystr );
+	dom_sid_str_buf(user_sid, &keystr);
+	DBG_DEBUG("SID [%s]\n", keystr.buf);
+	data = tdb_fetch_bystring( netsamlogon_tdb, keystr.buf );
 
 	if (!data.dptr) {
 		return NULL;
@@ -268,7 +268,7 @@ struct netr_SamInfo3 *netsamlogon_cache_get(TALLOC_CTX *mem_ctx, const struct do
 
 	if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
 		DEBUG(0,("netsamlogon_cache_get: failed to pull entry from cache\n"));
-		tdb_delete_bystring(netsamlogon_tdb, keystr);
+		tdb_delete_bystring(netsamlogon_tdb, keystr.buf);
 		TALLOC_FREE(info3);
 		goto done;
 	}
@@ -288,7 +288,7 @@ struct netr_SamInfo3 *netsamlogon_cache_get(TALLOC_CTX *mem_ctx, const struct do
 
 bool netsamlogon_cache_have(const struct dom_sid *sid)
 {
-	char keystr[DOM_SID_STR_BUFLEN];
+	struct dom_sid_buf keystr;
 	bool ok;
 
 	if (!netsamlogon_cache_init()) {
@@ -296,9 +296,9 @@ bool netsamlogon_cache_have(const struct dom_sid *sid)
 		return false;
 	}
 
-	dom_sid_string_buf(sid, keystr, sizeof(keystr));
+	dom_sid_str_buf(sid, &keystr);
 
-	ok = tdb_exists(netsamlogon_tdb, string_term_tdb_data(keystr));
+	ok = tdb_exists(netsamlogon_tdb, string_term_tdb_data(keystr.buf));
 	return ok;
 }
 
diff --git a/source3/modules/vfs_delay_inject.c b/source3/modules/vfs_delay_inject.c
index 21fea9b..d561fad 100644
--- a/source3/modules/vfs_delay_inject.c
+++ b/source3/modules/vfs_delay_inject.c
@@ -19,6 +19,7 @@
 
 #include "includes.h"
 #include "smbd/smbd.h"
+#include "lib/util/tevent_unix.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_VFS
@@ -46,8 +47,269 @@ static int vfs_delay_inject_ntimes(vfs_handle_struct *handle,
 	return SMB_VFS_NEXT_NTIMES(handle, smb_fname, ft);
 }
 
+struct vfs_delay_inject_pread_state {
+	struct tevent_context *ev;
+	struct vfs_handle_struct *handle;
+	struct files_struct *fsp;
+	void *data;
+	size_t n;
+	off_t offset;
+	ssize_t ret;
+	struct vfs_aio_state vfs_aio_state;
+};
+
+static void vfs_delay_inject_pread_wait_done(struct tevent_req *subreq);
+static void vfs_delay_inject_pread_done(struct tevent_req *subreq);
+
+static struct tevent_req *vfs_delay_inject_pread_send(
+				struct vfs_handle_struct *handle,
+				TALLOC_CTX *mem_ctx,
+				struct tevent_context *ev,
+				struct files_struct *fsp,
+				void *data,
+				size_t n,
+				off_t offset)
+{
+	struct tevent_req *req = NULL, *subreq = NULL;
+	struct vfs_delay_inject_pread_state *state = NULL;
+	int delay;
+	struct timeval delay_tv;
+
+	delay = lp_parm_int(
+		SNUM(handle->conn), "delay_inject", "pread_send", 0);
+	delay_tv = tevent_timeval_current_ofs(delay / 1000,
+					      (delay * 1000) % 1000000);
+
+	req = tevent_req_create(mem_ctx, &state,
+				struct vfs_delay_inject_pread_state);
+	if (req == NULL) {
+		return NULL;
+	}
+	*state = (struct vfs_delay_inject_pread_state) {
+		.ev = ev,
+		.handle = handle,
+		.fsp = fsp,
+		.data = data,
+		.n = n,
+		.offset = offset,
+	};
+
+	if (delay == 0) {
+		subreq = SMB_VFS_NEXT_PREAD_SEND(state,
+						 state->ev,
+						 state->handle,
+						 state->fsp,
+						 state->data,
+						 state->n,
+						 state->offset);
+		if (tevent_req_nomem(subreq, req)) {
+			return tevent_req_post(req, ev);
+		}
+		tevent_req_set_callback(subreq,
+					vfs_delay_inject_pread_done,
+					req);
+		return req;
+	}
+
+	subreq = tevent_wakeup_send(state, ev, delay_tv);


-- 
Samba Shared Repository



More information about the samba-cvs mailing list