[SCM] Samba Shared Repository - branch v3-2-test updated - release-3-2-0pre2-281-g065938c

Volker Lendecke vlendec at samba.org
Mon Mar 17 14:29:35 GMT 2008


The branch, v3-2-test has been updated
       via  065938ccb7bb0052746267c433637f0e05b95d85 (commit)
       via  64b1625f8e3bca43504871747bef6631e1b18f44 (commit)
       via  46e50da0d550e43de3aaf0141c64f25e1c9997c2 (commit)
       via  f5e26d28be6581149bed0b599c38b82d1a44444e (commit)
      from  64664d25cf84e5e0f4a4876b2c38c127b310dbc5 (commit)

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


- Log -----------------------------------------------------------------
commit 065938ccb7bb0052746267c433637f0e05b95d85
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Mar 17 14:45:59 2008 +0100

    In smbstatus, mark locking.tdb and sessionid.tdb as CLEAR_IF_FIRST
    
    This is needed to inform ctdb that it's not a persistent database, with the
    O_RDONLY the tdb backend ignores this.
    
    Merge from 491f902098d33f in 3-0-ctdb

commit 64b1625f8e3bca43504871747bef6631e1b18f44
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Mar 17 14:40:07 2008 +0100

    Merge leftovers of 0e1a86bc845 in 3-0-ctdb

commit 46e50da0d550e43de3aaf0141c64f25e1c9997c2
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Mar 17 14:12:10 2008 +0100

    Use right control to attach to persistent databases
    
    This is a merge of 2a8f8b26f08ab09c34dff82417e541d8eb1ec91c and
    4e6508dfee0d872a7fa42c9e58ba565137a27b3f from 3-0-ctdb

commit f5e26d28be6581149bed0b599c38b82d1a44444e
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Mar 17 13:51:50 2008 +0100

    Add "net idmap aclmapset"
    
    This is a merge from 3-0-ctdb that goes along with 1daad835, the option
    nfs4:sidmap option

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

Summary of changes:
 source/lib/ctdbd_conn.c  |    7 +++-
 source/locking/brlock.c  |    2 +-
 source/locking/locking.c |    7 ++---
 source/utils/net_idmap.c |   65 ++++++++++++++++++++++++++++++++++++++++++++++
 source/utils/status.c    |    4 +-
 5 files changed, 76 insertions(+), 9 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/lib/ctdbd_conn.c b/source/lib/ctdbd_conn.c
index 18e9879..46936c5 100644
--- a/source/lib/ctdbd_conn.c
+++ b/source/lib/ctdbd_conn.c
@@ -820,13 +820,16 @@ NTSTATUS ctdbd_db_attach(struct ctdbd_connection *conn,
 	NTSTATUS status;
 	TDB_DATA data;
 	int32_t cstatus;
+	bool persistent = (tdb_flags & TDB_CLEAR_IF_FIRST) == 0;
 
 	data.dptr = (uint8_t*)name;
 	data.dsize = strlen(name)+1;
 
 	status = ctdbd_control(conn, CTDB_CURRENT_NODE,
-			       CTDB_CONTROL_DB_ATTACH, 0, data, 
-			       NULL, &data, &cstatus);
+			       persistent
+			       ? CTDB_CONTROL_DB_ATTACH_PERSISTENT
+			       : CTDB_CONTROL_DB_ATTACH,
+			       0, data, NULL, &data, &cstatus);
 	if (!NT_STATUS_IS_OK(status)) {
 		DEBUG(0, (__location__ " ctdb_control for db_attach "
 			  "failed: %s\n", nt_errstr(status)));
diff --git a/source/locking/brlock.c b/source/locking/brlock.c
index 341d00f..940dfbf 100644
--- a/source/locking/brlock.c
+++ b/source/locking/brlock.c
@@ -265,7 +265,7 @@ void brl_init(bool read_only)
 	}
 	brlock_db = db_open(NULL, lock_path("brlock.tdb"),
 			    lp_open_files_db_hash_size(),
-			    TDB_DEFAULT | TDB_CLEAR_IF_FIRST,
+			    TDB_DEFAULT|TDB_VOLATILE|TDB_CLEAR_IF_FIRST,
 			    read_only?O_RDONLY:(O_RDWR|O_CREAT), 0644 );
 	if (!brlock_db) {
 		DEBUG(0,("Failed to open byte range locking database %s\n",
diff --git a/source/locking/locking.c b/source/locking/locking.c
index 513bb31..782e10f 100644
--- a/source/locking/locking.c
+++ b/source/locking/locking.c
@@ -392,10 +392,9 @@ static bool locking_init_internal(bool read_only)
 	if (lock_db)
 		return True;
 
-	lock_db = db_open(NULL, lock_path("locking.tdb"), 0,
-			  TDB_DEFAULT
-			  |TDB_VOLATILE
-			  |(read_only?0x0:TDB_CLEAR_IF_FIRST),
+	lock_db = db_open(NULL, lock_path("locking.tdb"),
+			  lp_open_files_db_hash_size(),
+			  TDB_DEFAULT|TDB_VOLATILE|TDB_CLEAR_IF_FIRST,
 			  read_only?O_RDONLY:O_RDWR|O_CREAT, 0644);
 
 	if (!lock_db) {
diff --git a/source/utils/net_idmap.c b/source/utils/net_idmap.c
index 2a060d2..7ac2a82 100644
--- a/source/utils/net_idmap.c
+++ b/source/utils/net_idmap.c
@@ -284,6 +284,70 @@ int net_help_idmap(int argc, const char **argv)
 	return -1;
 }
 
+static int net_idmap_aclmapset(int argc, const char **argv)
+{
+	TALLOC_CTX *mem_ctx;
+	int result = -1;
+	DOM_SID src_sid, dst_sid;
+	char *src, *dst;
+	struct db_context *db;
+	struct db_record *rec;
+	NTSTATUS status;
+
+	if (argc != 3) {
+		d_fprintf(stderr, "usage: net idmap aclmapset <tdb> "
+			  "<src-sid> <dst-sid>\n");
+		return -1;
+	}
+
+	if (!(mem_ctx = talloc_init("net idmap aclmapset"))) {
+		d_fprintf(stderr, "talloc_init failed\n");
+		return -1;
+	}
+
+	if (!(db = db_open(mem_ctx, argv[0], 0, TDB_DEFAULT,
+			   O_RDWR|O_CREAT, 0600))) {
+		d_fprintf(stderr, "db_open failed: %s\n", strerror(errno));
+		goto fail;
+	}
+
+	if (!string_to_sid(&src_sid, argv[1])) {
+		d_fprintf(stderr, "%s is not a valid sid\n", argv[1]);
+		goto fail;
+	}
+
+	if (!string_to_sid(&dst_sid, argv[2])) {
+		d_fprintf(stderr, "%s is not a valid sid\n", argv[2]);
+		goto fail;
+	}
+
+	if (!(src = sid_string_talloc(mem_ctx, &src_sid))
+	    || !(dst = sid_string_talloc(mem_ctx, &dst_sid))) {
+		d_fprintf(stderr, "talloc_strdup failed\n");
+		goto fail;
+	}
+
+	if (!(rec = db->fetch_locked(
+		      db, mem_ctx, string_term_tdb_data(src)))) {
+		d_fprintf(stderr, "could not fetch db record\n");
+		goto fail;
+	}
+
+	status = rec->store(rec, string_term_tdb_data(dst), 0);
+	TALLOC_FREE(rec);
+
+	if (!NT_STATUS_IS_OK(status)) {
+		d_fprintf(stderr, "could not store record: %s\n",
+			  nt_errstr(status));
+		goto fail;
+	}
+
+	result = 0;
+fail:
+	TALLOC_FREE(mem_ctx);
+	return result;
+}
+
 /***********************************************************
  Look at the current idmap
  **********************************************************/
@@ -295,6 +359,7 @@ int net_idmap(int argc, const char **argv)
 		{"setmap", net_idmap_set },
 		{"delete", net_idmap_delete},
 		{"secret", net_idmap_secret},
+		{"aclmapset", net_idmap_aclmapset},
 		{"help", net_help_idmap},
 		{NULL, NULL}
 	};
diff --git a/source/utils/status.c b/source/utils/status.c
index a42c2a1..ffa3fbd 100644
--- a/source/utils/status.c
+++ b/source/utils/status.c
@@ -386,7 +386,7 @@ static int traverse_sessionid(struct db_record *db, void *state)
 	if ( show_processes ) {
 		struct db_context *db;
 		db = db_open(NULL, lock_path("sessionid.tdb"), 0,
-			     TDB_DEFAULT, O_RDWR, 0644);
+			     TDB_CLEAR_IF_FIRST, O_RDONLY, 0644);
 		if (!db) {
 			d_printf("sessionid.tdb not initialised\n");
 		} else {
@@ -428,7 +428,7 @@ static int traverse_sessionid(struct db_record *db, void *state)
 		int result;
 		struct db_context *db;
 		db = db_open(NULL, lock_path("locking.tdb"), 0,
-			     TDB_DEFAULT, O_RDONLY, 0);
+			     TDB_CLEAR_IF_FIRST, O_RDONLY, 0);
 
 		if (!db) {
 			d_printf("%s not initialised\n",


-- 
Samba Shared Repository


More information about the samba-cvs mailing list