[SCM] Samba Shared Repository - branch v3-6-test updated

Karolin Seeger kseeger at samba.org
Mon Sep 9 10:08:20 CEST 2013


The branch, v3-6-test has been updated
       via  037f9ea s3-serverid: call serverid_init_readonly() from commandline tools.
       via  11d5d3d s3-serverid: add a readonly variant of the serverid init code.
       via  ec1948d s3-serverid: restructure serverid initialization.
       via  4b8b385 s3-sessionid: move sessionid init call to the only function where it is needed.
      from  5978eab s3-sessionid: use sessionid_init_readonly() from cmdline tools.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-6-test


- Log -----------------------------------------------------------------
commit 037f9ead5fc490e7e463671b76e8e8474a8728f5
Author: Günther Deschner <gd at samba.org>
Date:   Fri Sep 6 18:08:45 2013 +0200

    s3-serverid: call serverid_init_readonly() from commandline tools.
    
    Guenther
    
    Signed-off-by: Günther Deschner <gd at samba.org>
    
    The last 4 patches are follow-up patches for bug #10127 - smbstatus stopped
    working as non-root user.

commit 11d5d3d49ecec0d2ae924ff843e97cc39fa64a16
Author: Günther Deschner <gd at samba.org>
Date:   Fri Sep 6 17:44:49 2013 +0200

    s3-serverid: add a readonly variant of the serverid init code.
    
    Guenther
    
    Signed-off-by: Günther Deschner <gd at samba.org>

commit ec1948d3a6adec3dd659abc8ab9c49a334c1e6a7
Author: Günther Deschner <gd at samba.org>
Date:   Fri Sep 6 17:43:50 2013 +0200

    s3-serverid: restructure serverid initialization.
    
    Guenther
    
    Signed-off-by: Günther Deschner <gd at samba.org>

commit 4b8b385042ace68c4ec59fea81bf8b284b34c356
Author: Günther Deschner <gd at samba.org>
Date:   Fri Sep 6 18:08:23 2013 +0200

    s3-sessionid: move sessionid init call to the only function where it is needed.
    
    Guenther
    
    Signed-off-by: Günther Deschner <gd at samba.org>

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

Summary of changes:
 source3/include/serverid.h   |    2 ++
 source3/lib/serverid.c       |   42 +++++++++++++++++++++++++++++-------------
 source3/utils/net_serverid.c |   14 +++++++++-----
 source3/utils/status.c       |    6 ++++++
 4 files changed, 46 insertions(+), 18 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/serverid.h b/source3/include/serverid.h
index 435c88b..56b7237 100644
--- a/source3/include/serverid.h
+++ b/source3/include/serverid.h
@@ -73,4 +73,6 @@ bool serverid_parent_init(TALLOC_CTX *mem_ctx);
  */
 uint64_t serverid_get_random_unique_id(void);
 
+bool serverid_init_readonly(TALLOC_CTX *mem_ctx);
+
 #endif
diff --git a/source3/lib/serverid.c b/source3/lib/serverid.c
index 00dd6c4..9a0deb3 100644
--- a/source3/lib/serverid.c
+++ b/source3/lib/serverid.c
@@ -34,37 +34,53 @@ struct serverid_data {
 	uint32_t msg_flags;
 };
 
-bool serverid_parent_init(TALLOC_CTX *mem_ctx)
+static struct db_context *db_ptr = NULL;
+
+static struct db_context *serverid_init(TALLOC_CTX *mem_ctx,
+					bool readonly)
 {
-	struct tdb_wrap *db;
+	db_ptr = db_open(mem_ctx, lock_path("serverid.tdb"),
+			 0, TDB_DEFAULT|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
+			 readonly ? O_RDONLY : O_RDWR | O_CREAT,
+			 0644);
+	return db_ptr;
+}
 
+bool serverid_parent_init(TALLOC_CTX *mem_ctx)
+{
 	/*
 	 * Open the tdb in the parent process (smbd) so that our
 	 * CLEAR_IF_FIRST optimization in tdb_reopen_all can properly
 	 * work.
 	 */
 
-	db = tdb_wrap_open(mem_ctx, lock_path("serverid.tdb"),
-			   0, TDB_DEFAULT|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, O_RDWR|O_CREAT,
-			   0644);
-	if (db == NULL) {
+	if (serverid_init(mem_ctx, false) == NULL) {
 		DEBUG(1, ("could not open serverid.tdb: %s\n",
 			  strerror(errno)));
 		return false;
 	}
+
 	return true;
 }
 
-static struct db_context *serverid_db(void)
+bool serverid_init_readonly(TALLOC_CTX *mem_ctx)
 {
-	static struct db_context *db;
+	if (serverid_init(mem_ctx, true) == NULL) {
+		DEBUG(1, ("could not open serverid.tdb: %s\n",
+			  strerror(errno)));
+		return false;
+	}
 
-	if (db != NULL) {
-		return db;
+	return true;
+}
+
+static struct db_context *serverid_db(void)
+{
+	if (db_ptr != NULL) {
+		return db_ptr;
 	}
-	db = db_open(NULL, lock_path("serverid.tdb"), 0,
-		     TDB_DEFAULT|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH, O_RDWR|O_CREAT, 0644);
-	return db;
+
+	return serverid_init(NULL, false);
 }
 
 static void serverid_fill_key(const struct server_id *id,
diff --git a/source3/utils/net_serverid.c b/source3/utils/net_serverid.c
index 01109b9..5e61f11 100644
--- a/source3/utils/net_serverid.c
+++ b/source3/utils/net_serverid.c
@@ -36,6 +36,10 @@ static int net_serverid_list_fn(const struct server_id *id,
 static int net_serverid_list(struct net_context *c, int argc,
 			     const char **argv)
 {
+	if (!serverid_init_readonly(c)) {
+		d_printf("failed to open serverid.tdb\n");
+		return -1;
+	}
 	d_printf("pid unique_id msg_flags\n");
 	return serverid_traverse_read(net_serverid_list_fn, NULL) ? 0 : -1;
 }
@@ -113,6 +117,11 @@ static int net_serverid_wipedbs_sessionid(struct db_record *rec,
 static int net_serverid_wipedbs(struct net_context *c, int argc,
 				const char **argv)
 {
+	if (!sessionid_init()) {
+		d_printf("failed to open sessionid.tdb\n");
+		return -1;
+	};
+
 	connections_forall(net_serverid_wipedbs_conn, NULL);
 	sessionid_traverse(net_serverid_wipedbs_sessionid, NULL);
 	return 0;
@@ -150,10 +159,5 @@ int net_serverid(struct net_context *c, int argc, const char **argv)
 		{NULL, NULL, 0, NULL, NULL}
 	};
 
-	if (!sessionid_init()) {
-		d_printf("failed to open sessionid.tdb\n");
-		return -1;
-	};
-
 	return net_run_function(c, argc, argv, "net serverid", func);
 }
diff --git a/source3/utils/status.c b/source3/utils/status.c
index dc05096..b89a779 100644
--- a/source3/utils/status.c
+++ b/source3/utils/status.c
@@ -38,6 +38,7 @@
 #include "session.h"
 #include "locking/proto.h"
 #include "messages.h"
+#include "serverid.h"
 
 #define SMB_MAXPIDS		2048
 static uid_t 		Ucrit_uid = 0;               /* added by OH */
@@ -476,6 +477,11 @@ static int traverse_sessionid(const char *key, struct sessionid *session,
 			goto done;
 		}
 
+		if (!serverid_init_readonly(frame)) {
+			d_printf("Can't initialise serverid tdb - exiting\n");
+			ret = 1;
+			goto done;
+		}
 		result = share_mode_forall(print_share_mode, NULL);
 
 		if (result == 0) {


-- 
Samba Shared Repository


More information about the samba-cvs mailing list