[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Fri Jun 4 17:35:02 UTC 2021


The branch, master has been updated
       via  9cb3e4314b0 lib: Slightly simplify server_id_set_disconnected()
       via  581ebbcc312 smbd: Simplify share_mode_entry_do()
       via  c2092cfc448 libnet: Initialize pointers
       via  b9f903fbd56 libnet: Align a few integer types
       via  5acb37fd564 nsswitch: Fix a typo
       via  7f967589ea4 rpc_server: Use correct PRIu16 for printf of a uint16
       via  8ee391bbd06 tevent: Remove single-use ev_str_list_[length|add]
       via  b6191956899 lib: Open tdb files with O_CLOEXEC
       via  87a0a20417c rpc_server: Avoid a cast
       via  d4e5ce90cf6 printing: Factor out remove_from_jobs_list()
       via  93a28a5f245 printing: Simplify pack_devicemode()
       via  4388ad2a900 lib: Fix a typo
       via  3f4d85f749c dbwrap_ctdb: Remove "tryonly" from fetch_locked_internal()
       via  a41af25ebd4 dbwrap: Remove "db_context->try_fetch_locked()" fn pointer
       via  8089f5190cb dbwrap: Remove unused dbwrap_try_fetch_locked()
      from  292abd2884b s3: smbd: Fix bug (only in master) introduced by 60ddee64f6e6c178766325591e80d63a673ad111.

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


- Log -----------------------------------------------------------------
commit 9cb3e4314b00629391919d8f74080d0dfc1aae18
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Dec 17 11:37:47 2020 +0100

    lib: Slightly simplify server_id_set_disconnected()
    
    The NULL assert is not really required, it will crash nicely if that's
    not fulfilled.
    
    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): Fri Jun  4 17:34:06 UTC 2021 on sn-devel-184

commit 581ebbcc312ba88e02a3b2d9a4776d5e6db39135
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Dec 17 12:36:42 2020 +0100

    smbd: Simplify share_mode_entry_do()
    
    Looking at the logic of "ha[d|ve]_share_mode_entry" d->modified=true
    can only happen if we remove the last share mode entry . Make this
    more explicit, avoid booleans.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit c2092cfc4489ad245ffd40bb4865e64ee37fadc2
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Dec 29 13:41:42 2020 +0100

    libnet: Initialize pointers
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit b9f903fbd564d98df32570e083c855464e8042a9
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Dec 29 13:41:24 2020 +0100

    libnet: Align a few integer types
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 5acb37fd564804cd889c37b8ec610a1c6c1ef60c
Author: Volker Lendecke <vl at samba.org>
Date:   Thu May 6 11:43:51 2021 +0200

    nsswitch: Fix a typo
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 7f967589ea4a87536c7eb9d60f5df00b29e03600
Author: Volker Lendecke <vl at samba.org>
Date:   Mon May 3 14:59:13 2021 +0200

    rpc_server: Use correct PRIu16 for printf of a uint16
    
    Don't rely on correct casting
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 8ee391bbd0610c376e914ddbf236dbd68d5f40cb
Author: Volker Lendecke <vl at samba.org>
Date:   Mon May 3 22:03:47 2021 +0200

    tevent: Remove single-use ev_str_list_[length|add]
    
    This also adds proper error checks, the previous code could (very
    theoretically) have leaked memory if an intermediate _add had failed.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit b6191956899d3a962dbddc19b39d509141774208
Author: Volker Lendecke <vl at samba.org>
Date:   Fri May 7 07:32:37 2021 +0200

    lib: Open tdb files with O_CLOEXEC
    
    After an exec() the fd's don't make sense anymore
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 87a0a20417cbefaa913e29233280908c198e9fd1
Author: Volker Lendecke <vl at samba.org>
Date:   Thu May 13 20:24:09 2021 +0200

    rpc_server: Avoid a cast
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit d4e5ce90cf6f118c32dd71210889b76c5de28d63
Author: Volker Lendecke <vl at samba.org>
Date:   Thu May 13 20:08:30 2021 +0200

    printing: Factor out remove_from_jobs_list()
    
    remove_from_jobs_changed() and remove_from_jobs_added() only differed
    by the keystr.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 93a28a5f2456bbcdd3104c251a019f1f4f354219
Author: Volker Lendecke <vl at samba.org>
Date:   Wed May 12 18:22:52 2021 +0200

    printing: Simplify pack_devicemode()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 4388ad2a900a931770756e8c3cb2e61216722c92
Author: Volker Lendecke <vl at samba.org>
Date:   Fri May 7 11:13:51 2021 +0200

    lib: Fix a typo
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 3f4d85f749cd47cd7d1372ef400acc664f1c7840
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Dec 21 15:37:21 2020 +0100

    dbwrap_ctdb: Remove "tryonly" from fetch_locked_internal()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit a41af25ebd424184ceb300a181cbfca7a9eb014c
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Dec 21 14:40:47 2020 +0100

    dbwrap: Remove "db_context->try_fetch_locked()" fn pointer
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 8089f5190cb17d519f2dee27a74eccb5b8560e8a
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Dec 21 14:37:12 2020 +0100

    dbwrap: Remove unused dbwrap_try_fetch_locked()
    
    Small simplification, this has not been used since 2014 when the
    notifyd went in. Can easily be added if needed again.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

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

Summary of changes:
 lib/audit_logging/audit_logging.c     |  2 +-
 lib/dbwrap/dbwrap.c                   | 10 -----
 lib/dbwrap/dbwrap.h                   |  3 --
 lib/dbwrap/dbwrap_private.h           |  3 --
 lib/dbwrap/dbwrap_tdb.c               | 15 --------
 lib/tdb_wrap/tdb_wrap.c               |  6 +++
 lib/tevent/tevent.c                   | 18 ++++++++-
 lib/tevent/tevent_util.c              | 30 ---------------
 lib/tevent/tevent_util.h              |  2 -
 lib/util/server_id.c                  | 14 +++----
 nsswitch/wb_common.c                  |  2 +-
 source3/lib/dbwrap/dbwrap_ctdb.c      | 34 ++---------------
 source3/libnet/libnet_dssync_passdb.c | 13 +++----
 source3/locking/share_mode_lock.c     | 20 ++++------
 source3/printing/printing.c           | 71 +++++++----------------------------
 source3/rpc_server/rpc_sock_helper.c  |  2 +-
 source3/rpc_server/srv_pipe_hnd.c     |  2 +-
 17 files changed, 63 insertions(+), 184 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/audit_logging/audit_logging.c b/lib/audit_logging/audit_logging.c
index e21582a91d1..9fe2d3ba45d 100644
--- a/lib/audit_logging/audit_logging.c
+++ b/lib/audit_logging/audit_logging.c
@@ -908,7 +908,7 @@ int json_add_guid(struct json_object *object,
 /*
  * @brief Convert a JSON object into a string
  *
- * Convert the jsom object into a string suitable for printing on a log line,
+ * Convert the json object into a string suitable for printing on a log line,
  * i.e. with no embedded line breaks.
  *
  * If the object is invalid it logs an error and returns NULL.
diff --git a/lib/dbwrap/dbwrap.c b/lib/dbwrap/dbwrap.c
index 735ed169690..cc685a2fa69 100644
--- a/lib/dbwrap/dbwrap.c
+++ b/lib/dbwrap/dbwrap.c
@@ -266,16 +266,6 @@ struct db_record *dbwrap_fetch_locked(struct db_context *db,
 					    db->fetch_locked);
 }
 
-struct db_record *dbwrap_try_fetch_locked(struct db_context *db,
-				      TALLOC_CTX *mem_ctx,
-				      TDB_DATA key)
-{
-	return dbwrap_fetch_locked_internal(
-		db, mem_ctx, key,
-		db->try_fetch_locked
-		? db->try_fetch_locked : db->fetch_locked);
-}
-
 struct db_context *dbwrap_record_get_db(struct db_record *rec)
 {
 	return rec->db;
diff --git a/lib/dbwrap/dbwrap.h b/lib/dbwrap/dbwrap.h
index 0069353fae5..9b8bf811ca6 100644
--- a/lib/dbwrap/dbwrap.h
+++ b/lib/dbwrap/dbwrap.h
@@ -74,9 +74,6 @@ NTSTATUS dbwrap_record_delete(struct db_record *rec);
 struct db_record *dbwrap_fetch_locked(struct db_context *db,
 				      TALLOC_CTX *mem_ctx,
 				      TDB_DATA key);
-struct db_record *dbwrap_try_fetch_locked(struct db_context *db,
-					  TALLOC_CTX *mem_ctx,
-					  TDB_DATA key);
 struct db_context *dbwrap_record_get_db(struct db_record *rec);
 
 void dbwrap_lock_order_lock(const char *db_name,
diff --git a/lib/dbwrap/dbwrap_private.h b/lib/dbwrap/dbwrap_private.h
index 8a1f03c7bec..3ac5ebf97a1 100644
--- a/lib/dbwrap/dbwrap_private.h
+++ b/lib/dbwrap/dbwrap_private.h
@@ -40,9 +40,6 @@ struct db_context {
 	struct db_record *(*fetch_locked)(struct db_context *db,
 					  TALLOC_CTX *mem_ctx,
 					  TDB_DATA key);
-	struct db_record *(*try_fetch_locked)(struct db_context *db,
-					      TALLOC_CTX *mem_ctx,
-					      TDB_DATA key);
 	int (*traverse)(struct db_context *db,
 			int (*f)(struct db_record *rec,
 				 void *private_data),
diff --git a/lib/dbwrap/dbwrap_tdb.c b/lib/dbwrap/dbwrap_tdb.c
index 74b895a7736..6cd95fa25ad 100644
--- a/lib/dbwrap/dbwrap_tdb.c
+++ b/lib/dbwrap/dbwrap_tdb.c
@@ -169,20 +169,6 @@ static struct db_record *db_tdb_fetch_locked(
 	return db_tdb_fetch_locked_internal(db, ctx, mem_ctx, key);
 }
 
-static struct db_record *db_tdb_try_fetch_locked(
-	struct db_context *db, TALLOC_CTX *mem_ctx, TDB_DATA key)
-{
-	struct db_tdb_ctx *ctx = talloc_get_type_abort(db->private_data,
-						       struct db_tdb_ctx);
-
-	db_tdb_log_key("Trying to lock", key);
-	if (tdb_chainlock_nonblock(ctx->wtdb->tdb, key) != 0) {
-		DEBUG(3, ("tdb_chainlock_nonblock failed\n"));
-		return NULL;
-	}
-	return db_tdb_fetch_locked_internal(db, ctx, mem_ctx, key);
-}
-
 static NTSTATUS db_tdb_do_locked(struct db_context *db, TDB_DATA key,
 				 void (*fn)(struct db_record *rec,
 					    TDB_DATA value,
@@ -509,7 +495,6 @@ struct db_context *db_open_tdb(TALLOC_CTX *mem_ctx,
 	db_tdb->id.ino = st.st_ino;
 
 	result->fetch_locked = db_tdb_fetch_locked;
-	result->try_fetch_locked = db_tdb_try_fetch_locked;
 	result->do_locked = db_tdb_do_locked;
 	result->traverse = db_tdb_traverse;
 	result->traverse_read = db_tdb_traverse_read;
diff --git a/lib/tdb_wrap/tdb_wrap.c b/lib/tdb_wrap/tdb_wrap.c
index 864656f2047..49585aa0b9f 100644
--- a/lib/tdb_wrap/tdb_wrap.c
+++ b/lib/tdb_wrap/tdb_wrap.c
@@ -20,6 +20,7 @@
 */
 
 #include "replace.h"
+#include "system/filesys.h"
 #include "lib/util/dlinklist.h"
 #include "lib/util/debug.h"
 #include "tdb_wrap.h"
@@ -100,6 +101,11 @@ static struct tdb_wrap_private *tdb_wrap_private_open(TALLOC_CTX *mem_ctx,
 	/* Doesn't fail, see talloc_pooled_object */
 	result->name = talloc_strdup(result, name);
 
+	/*
+	 * TDB files don't make sense after execve()
+	 */
+	open_flags |= O_CLOEXEC;
+
 	result->tdb = tdb_open_ex(name, hash_size, tdb_flags,
 				  open_flags, mode, &lctx, NULL);
 	if (result->tdb == NULL) {
diff --git a/lib/tevent/tevent.c b/lib/tevent/tevent.c
index dbec1821e41..a94bb440b9b 100644
--- a/lib/tevent/tevent.c
+++ b/lib/tevent/tevent.c
@@ -166,14 +166,28 @@ const char **tevent_backend_list(TALLOC_CTX *mem_ctx)
 {
 	const char **list = NULL;
 	struct tevent_ops_list *e;
+	size_t idx = 0;
 
 	tevent_backend_init();
 
 	for (e=tevent_backends;e;e=e->next) {
-		list = ev_str_list_add(list, e->name);
+		idx += 1;
 	}
 
-	talloc_steal(mem_ctx, list);
+	list = talloc_zero_array(mem_ctx, const char *, idx+1);
+	if (list == NULL) {
+		return NULL;
+	}
+
+	idx = 0;
+	for (e=tevent_backends;e;e=e->next) {
+		list[idx] = talloc_strdup(list, e->name);
+		if (list[idx] == NULL) {
+			TALLOC_FREE(list);
+			return NULL;
+		}
+		idx += 1;
+	}
 
 	return list;
 }
diff --git a/lib/tevent/tevent_util.c b/lib/tevent/tevent_util.c
index 16af8f3b908..7519e118ab9 100644
--- a/lib/tevent/tevent_util.c
+++ b/lib/tevent/tevent_util.c
@@ -29,36 +29,6 @@
 #include "tevent_util.h"
 #include <fcntl.h>
 
-/**
-  return the number of elements in a string list
-*/
-size_t ev_str_list_length(const char **list)
-{
-	size_t ret;
-	for (ret=0;list && list[ret];ret++) /* noop */ ;
-	return ret;
-}
-
-/**
-  add an entry to a string list
-*/
-const char **ev_str_list_add(const char **list, const char *s)
-{
-	size_t len = ev_str_list_length(list);
-	const char **ret;
-
-	ret = talloc_realloc(NULL, list, const char *, len+2);
-	if (ret == NULL) return NULL;
-
-	ret[len] = talloc_strdup(ret, s);
-	if (ret[len] == NULL) return NULL;
-
-	ret[len+1] = NULL;
-
-	return ret;
-}
-
-
 /**
  Set a fd into blocking/nonblocking mode. Uses POSIX O_NONBLOCK if available,
  else
diff --git a/lib/tevent/tevent_util.h b/lib/tevent/tevent_util.h
index eef4a00f98b..128c231e25c 100644
--- a/lib/tevent/tevent_util.h
+++ b/lib/tevent/tevent_util.h
@@ -173,9 +173,7 @@ do { \
 
 #endif /* _DLINKLIST_H */
 
-const char **ev_str_list_add(const char **list, const char *s);
 int ev_set_blocking(int fd, bool set);
-size_t ev_str_list_length(const char **list);
 bool ev_set_close_on_exec(int fd);
 
 /* Defined here so we can build against older talloc versions that don't
diff --git a/lib/util/server_id.c b/lib/util/server_id.c
index e66c9791007..690b9ddfbdc 100644
--- a/lib/util/server_id.c
+++ b/lib/util/server_id.c
@@ -187,14 +187,12 @@ struct server_id server_id_from_string(uint32_t local_vnn,
  */
 void server_id_set_disconnected(struct server_id *id)
 {
-	SMB_ASSERT(id != NULL);
-
-	id->pid = UINT64_MAX;
-	id->task_id = UINT32_MAX;
-	id->vnn = NONCLUSTER_VNN;
-	id->unique_id = SERVERID_UNIQUE_ID_NOT_TO_VERIFY;
-
-	return;
+	*id = (struct server_id) {
+		.pid = UINT64_MAX,
+		.task_id = UINT32_MAX,
+		.vnn = NONCLUSTER_VNN,
+		.unique_id = SERVERID_UNIQUE_ID_NOT_TO_VERIFY,
+	};
 }
 
 /**
diff --git a/nsswitch/wb_common.c b/nsswitch/wb_common.c
index 151c666cf53..45c1969acc2 100644
--- a/nsswitch/wb_common.c
+++ b/nsswitch/wb_common.c
@@ -259,7 +259,7 @@ static int make_safe_fd(int fd)
 /**
  * @internal
  *
- * @brief Check if we talk to the priviliged pipe which should be owned by root.
+ * @brief Check if we talk to the privileged pipe which should be owned by root.
  *
  * This checks if we have uid_wrapper running and if this is the case it will
  * allow one to connect to the winbind privileged pipe even it is not owned by root.
diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c
index 9c9e05b9d77..0907089164a 100644
--- a/source3/lib/dbwrap/dbwrap_ctdb.c
+++ b/source3/lib/dbwrap/dbwrap_ctdb.c
@@ -1071,8 +1071,7 @@ static bool db_ctdb_can_use_local_copy(TDB_DATA ctdb_data, uint32_t my_vnn,
 
 static struct db_record *fetch_locked_internal(struct db_ctdb_ctx *ctx,
 					       TALLOC_CTX *mem_ctx,
-					       TDB_DATA key,
-					       bool tryonly)
+					       TDB_DATA key)
 {
 	struct db_record *result;
 	struct db_ctdb_rec *crec;
@@ -1129,9 +1128,7 @@ again:
 	}
 
 	GetTimeOfDay(&chainlock_start);
-	lockret = tryonly
-		? tdb_chainlock_nonblock(ctx->wtdb->tdb, key)
-		: tdb_chainlock(ctx->wtdb->tdb, key);
+	lockret = tdb_chainlock(ctx->wtdb->tdb, key);
 	chainlock_time += timeval_elapsed(&chainlock_start);
 
 	if (lockret != 0) {
@@ -1156,12 +1153,6 @@ again:
 		tdb_chainunlock(ctx->wtdb->tdb, key);
 		talloc_set_destructor(result, NULL);
 
-		if (tryonly && (migrate_attempts != 0)) {
-			DEBUG(5, ("record migrated away again\n"));
-			TALLOC_FREE(result);
-			return NULL;
-		}
-
 		migrate_attempts += 1;
 
 		DEBUG(10, ("ctdb_data.dptr = %p, dmaster = %"PRIu32" "
@@ -1261,25 +1252,7 @@ static struct db_record *db_ctdb_fetch_locked(struct db_context *db,
 		return db_ctdb_fetch_locked_persistent(ctx, mem_ctx, key);
 	}
 
-	return fetch_locked_internal(ctx, mem_ctx, key, false);
-}
-
-static struct db_record *db_ctdb_try_fetch_locked(struct db_context *db,
-						  TALLOC_CTX *mem_ctx,
-						  TDB_DATA key)
-{
-	struct db_ctdb_ctx *ctx = talloc_get_type_abort(db->private_data,
-							struct db_ctdb_ctx);
-
-	if (ctx->transaction != NULL) {
-		return db_ctdb_fetch_locked_transaction(ctx, mem_ctx, key);
-	}
-
-	if (db->persistent) {
-		return db_ctdb_fetch_locked_persistent(ctx, mem_ctx, key);
-	}
-
-	return fetch_locked_internal(ctx, mem_ctx, key, true);
+	return fetch_locked_internal(ctx, mem_ctx, key);
 }
 
 struct db_ctdb_parse_record_state {
@@ -1988,7 +1961,6 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
 
 	result->private_data = (void *)db_ctdb;
 	result->fetch_locked = db_ctdb_fetch_locked;
-	result->try_fetch_locked = db_ctdb_try_fetch_locked;
 	result->parse_record = db_ctdb_parse_record;
 	result->parse_record_send = db_ctdb_parse_record_send;
 	result->parse_record_recv = db_ctdb_parse_record_recv;
diff --git a/source3/libnet/libnet_dssync_passdb.c b/source3/libnet/libnet_dssync_passdb.c
index 4472a9c4b5f..7d5ef64e8f4 100644
--- a/source3/libnet/libnet_dssync_passdb.c
+++ b/source3/libnet/libnet_dssync_passdb.c
@@ -722,7 +722,7 @@ static struct drsuapi_DsReplicaAttribute *find_drsuapi_attr(
 			const struct drsuapi_DsReplicaObjectListItemEx *cur,
 			uint32_t attid)
 {
-	int i = 0;
+	uint32_t i = 0;
 
 	for (i = 0; i < cur->object.attribute_ctr.num_attributes; i++) {
 		struct drsuapi_DsReplicaAttribute *attr;
@@ -1780,10 +1780,9 @@ static NTSTATUS parse_object(struct dssync_passdb *pctx,
 			     struct drsuapi_DsReplicaObjectListItemEx *cur)
 {
 	NTSTATUS status = NT_STATUS_OK;
-	DATA_BLOB *blob;
-	int i = 0;
-	int a = 0;
-	struct drsuapi_DsReplicaAttribute *attr;
+	DATA_BLOB *blob = NULL;
+	uint32_t i = 0;
+	size_t a = 0;
 
 	char *name = NULL;
 	uint32_t sam_type = 0;
@@ -1791,8 +1790,8 @@ static NTSTATUS parse_object(struct dssync_passdb *pctx,
 	DEBUG(3, ("parsing object '%s'\n", cur->object.identifier->dn));
 
 	for (i=0; i < cur->object.attribute_ctr.num_attributes; i++) {
-
-		attr = &cur->object.attribute_ctr.attributes[i];
+		struct drsuapi_DsReplicaAttribute *attr =
+			&cur->object.attribute_ctr.attributes[i];
 
 		if (attr->value_ctr.num_values != 1) {
 			continue;
diff --git a/source3/locking/share_mode_lock.c b/source3/locking/share_mode_lock.c
index d8c5222d70a..7a091637c74 100644
--- a/source3/locking/share_mode_lock.c
+++ b/source3/locking/share_mode_lock.c
@@ -2170,7 +2170,6 @@ static bool share_mode_entry_do(
 	bool modified = false;
 	struct share_mode_entry e;
 	uint8_t *e_ptr = NULL;
-	bool had_share_entries, have_share_entries;
 	NTSTATUS status;
 	bool ret = false;
 
@@ -2182,8 +2181,6 @@ static bool share_mode_entry_do(
 	}
 	DBG_DEBUG("num_share_modes=%zu\n", ltdb->num_share_entries);
 
-	had_share_entries = (ltdb->num_share_entries != 0);
-
 	idx = share_mode_entry_find(
 		ltdb->share_entries,
 		ltdb->num_share_entries,
@@ -2229,6 +2226,14 @@ static bool share_mode_entry_do(
 		}
 		ltdb->num_share_entries -= 1;
 
+		if (ltdb->num_share_entries == 0) {
+			/*
+			 * Tell share_mode_lock_destructor() to delete
+			 * the whole record
+			 */
+			d->modified = true;
+		}
+
 		if (DEBUGLEVEL>=10) {
 			DBG_DEBUG("share_mode_entry:\n");
 			NDR_PRINT_DEBUG(share_mode_entry, &e);
@@ -2260,15 +2265,6 @@ static bool share_mode_entry_do(
 		goto done;
 	}
 
-	have_share_entries = (ltdb->num_share_entries != 0);
-	if (had_share_entries != have_share_entries) {
-		/*
-		 * Make share_mode_data_store do the right thing wrt
-		 * possibly deleting the locking.tdb record
-		 */
-		d->modified = true;
-	}
-
 	ret = true;
 done:
 	TALLOC_FREE(ltdb);
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index 982eb4f9cdd..499334df03f 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -168,7 +168,7 @@ static TDB_DATA print_key(uint32_t jobid, uint32_t *tmp)
 static int pack_devicemode(struct spoolss_DeviceMode *devmode, uint8_t *buf, int buflen)
 {
 	enum ndr_err_code ndr_err;
-	DATA_BLOB blob;
+	DATA_BLOB blob = { .data = NULL };
 	int len = 0;
 
 	if (devmode) {
@@ -181,8 +181,6 @@ static int pack_devicemode(struct spoolss_DeviceMode *devmode, uint8_t *buf, int
 				   "error encoding spoolss_DeviceMode\n"));
 			goto done;
 		}
-	} else {
-		ZERO_STRUCT(blob);
 	}
 
 	len = tdb_pack(buf, buflen, "B", blob.length, blob.data);
@@ -522,7 +520,8 @@ static bool add_to_jobs_list(
  Remove a jobid from the 'jobs changed' list.
 ***************************************************************************/
 
-static bool remove_from_jobs_changed(const char* sharename, uint32_t jobid)
+static bool remove_from_jobs_list(
+	const char *keystr, const char *sharename, uint32_t jobid)
 {
 	struct tdb_print_db *pdb = get_print_db_byname(sharename);
 	TDB_DATA data, key;
@@ -536,7 +535,7 @@ static bool remove_from_jobs_changed(const char* sharename, uint32_t jobid)
 
 	ZERO_STRUCT(data);
 
-	key = string_tdb_data("INFO/jobs_changed");
+	key = string_tdb_data(keystr);
 
 	if (tdb_chainlock_with_timeout(pdb->tdb, key, 5) != 0)
 		goto out;
@@ -571,9 +570,16 @@ static bool remove_from_jobs_changed(const char* sharename, uint32_t jobid)
 	SAFE_FREE(data.dptr);
 	release_print_db(pdb);
 	if (ret)
-		DEBUG(10,("remove_from_jobs_changed: removed jobid %u\n", (unsigned int)jobid ));
+		DBG_DEBUG("removed jobid %"PRIu32"\n", jobid);
 	else
-		DEBUG(10,("remove_from_jobs_changed: Failed to remove jobid %u\n", (unsigned int)jobid ));
+		DBG_DEBUG("Failed to remove jobid %"PRIu32"\n", jobid);
+	return ret;
+}
+
+static bool remove_from_jobs_changed(const char* sharename, uint32_t jobid)
+{
+	bool ret = remove_from_jobs_list(
+		"INFO/jobs_changed", sharename, jobid);
 	return ret;
 }
 
@@ -1952,56 +1958,7 @@ bool print_job_get_name(TALLOC_CTX *mem_ctx, const char *sharename, uint32_t job
 
 static bool remove_from_jobs_added(const char* sharename, uint32_t jobid)
 {
-	struct tdb_print_db *pdb = get_print_db_byname(sharename);
-	TDB_DATA data, key;
-	size_t job_count, i;
-	bool ret = False;
-	bool gotlock = False;
-
-	if (!pdb) {
-		return False;
-	}
-
-	ZERO_STRUCT(data);
-
-	key = string_tdb_data("INFO/jobs_added");
-
-	if (tdb_chainlock_with_timeout(pdb->tdb, key, 5) != 0)
-		goto out;
-
-	gotlock = True;
-
-	data = tdb_fetch(pdb->tdb, key);
-
-	if (data.dptr == NULL || data.dsize == 0 || (data.dsize % 4 != 0))
-		goto out;
-
-	job_count = data.dsize / 4;
-	for (i = 0; i < job_count; i++) {


-- 
Samba Shared Repository



More information about the samba-cvs mailing list