[PATCH] s4:lib/messaging: use correct path for names.tdb
Ralph Boehme
rb at sernet.de
Tue Oct 20 09:44:06 UTC 2015
Hi!
Attached is a patch for bug 11562:
<https://bugzilla.samba.org/show_bug.cgi?id=11562>
Please review and push if ok. Thanks!
-Ralph
--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de,mailto:kontakt@sernet.de
-------------- next part --------------
From bc1b84cc1aa472904a56ae96a2b0b55b95a57714 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Wed, 14 Oct 2015 12:40:03 +0200
Subject: [PATCH 1/2] s4:lib/messaging: use correct path for names.tdb
source3 messaging_init() calls server_id_db_init() (where names.tdb is
created) with lock_path. source4 imessaging_init() otoh wrongly used the
special lock_path subdirectory "msg.lock":
> find /opt/samba/ -name names.tdb
/opt/samba/var/lock/msg.lock/names.tdb
/opt/samba/var/lock/names.tdb
> tdbdump /opt/samba/var/lock/names.tdb
{
key(14) = "notify-daemon\00"
data(27) = "28609/12756565486113779780\00"
}
> tdbdump /opt/samba/var/lock/msg.lock/names.tdb
{
key(15) = "winbind_server\00"
data(8) = "28593/0\00"
}
With this patch both source3 and source4 messaging now use the same
names.tdb which is what we want:
> find /opt/samba/ -name names.tdb
/opt/samba/var/lock/names.tdb
> tdbdump /opt/samba/var/lock/names.tdb
{
key(15) = "winbind_server\00"
data(8) = "26434/0\00"
}
{
key(14) = "notify-daemon\00"
data(26) = "26452/3454520012124001687\00"
}
Bug: https://bugzilla.samba.org/show_bug.cgi?id=11562
Signed-off-by: Ralph Boehme <slow at samba.org>
---
source4/lib/messaging/messaging.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c
index d91d175..72867da 100644
--- a/source4/lib/messaging/messaging.c
+++ b/source4/lib/messaging/messaging.c
@@ -311,6 +311,7 @@ struct imessaging_context *imessaging_init(TALLOC_CTX *mem_ctx,
struct imessaging_context *msg;
bool ok;
int ret;
+ const char *lock_dir;
if (ev == NULL) {
return NULL;
@@ -323,6 +324,11 @@ struct imessaging_context *imessaging_init(TALLOC_CTX *mem_ctx,
/* create the messaging directory if needed */
+ lock_dir = lpcfg_lock_directory(lp_ctx);
+ if (lock_dir == NULL) {
+ goto fail;
+ }
+
msg->sock_dir = lpcfg_private_path(msg, lp_ctx, "msg.sock");
if (msg->sock_dir == NULL) {
goto fail;
@@ -363,7 +369,7 @@ struct imessaging_context *imessaging_init(TALLOC_CTX *mem_ctx,
msg->start_time = timeval_current();
msg->names = server_id_db_init(
- msg, server_id, msg->lock_dir, 0,
+ msg, server_id, lock_dir, 0,
TDB_INCOMPATIBLE_HASH|TDB_CLEAR_IF_FIRST|
lpcfg_tdb_flags(lp_ctx, 0));
if (msg->names == NULL) {
--
2.1.0
From 00c95f245ebe82d6c47ae341336268c665be361c Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Tue, 20 Oct 2015 11:35:23 +0200
Subject: [PATCH 2/2] s4:lib/messaging: use a helper variable for tdb flags
Small refactoring that eliminates a nested function call. These are a
pita when stepping with gdb.
Bug: https://bugzilla.samba.org/show_bug.cgi?id=11562
Signed-off-by: Ralph Boehme <slow at samba.org>
---
source4/lib/messaging/messaging.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c
index 72867da..48e2509 100644
--- a/source4/lib/messaging/messaging.c
+++ b/source4/lib/messaging/messaging.c
@@ -312,6 +312,7 @@ struct imessaging_context *imessaging_init(TALLOC_CTX *mem_ctx,
bool ok;
int ret;
const char *lock_dir;
+ int tdb_flags = TDB_INCOMPATIBLE_HASH|TDB_CLEAR_IF_FIRST;
if (ev == NULL) {
return NULL;
@@ -368,10 +369,9 @@ struct imessaging_context *imessaging_init(TALLOC_CTX *mem_ctx,
msg->start_time = timeval_current();
- msg->names = server_id_db_init(
- msg, server_id, lock_dir, 0,
- TDB_INCOMPATIBLE_HASH|TDB_CLEAR_IF_FIRST|
- lpcfg_tdb_flags(lp_ctx, 0));
+ tdb_flags |= lpcfg_tdb_flags(lp_ctx, 0);
+
+ msg->names = server_id_db_init(msg, server_id, lock_dir, 0, tdb_flags);
if (msg->names == NULL) {
goto fail;
}
--
2.1.0
More information about the samba-technical
mailing list