diff options
author | Volker Lendecke <vl@samba.org> | 2014-10-04 10:58:15 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2015-02-13 23:32:06 +0100 |
commit | a3efb70c87b489967fbf0a0b6873325a6a49bfea (patch) | |
tree | a7247aacebedd1e4eb4379c43dc425d72ab92f3b /source3/lib/messages.c | |
parent | 293a602b33f07ecf75f1ea4956c012261a6f2ae5 (diff) | |
download | samba-a3efb70c87b489967fbf0a0b6873325a6a49bfea.tar.gz samba-a3efb70c87b489967fbf0a0b6873325a6a49bfea.tar.xz samba-a3efb70c87b489967fbf0a0b6873325a6a49bfea.zip |
messages_dgm: Move directory handling up
When we want to use messages_dgm in source4, we need to find better
places for the lock and socket directories. Source4 does not have the
concept of a cache directory. So I chose "private dir"/sock and "lock
dir"/msg as subdirectories.
This moves directory creation from messages_dgm.c to messages.c,
source4/lib/messaging will have its own way of doing this.
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source3/lib/messages.c')
-rw-r--r-- | source3/lib/messages.c | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/source3/lib/messages.c b/source3/lib/messages.c index f14d14961c..cdd6b05357 100644 --- a/source3/lib/messages.c +++ b/source3/lib/messages.c @@ -291,12 +291,20 @@ static int messaging_context_destructor(struct messaging_context *ctx) return 0; } +static const char *private_path(const char *name) +{ + return talloc_asprintf(talloc_tos(), "%s/%s", lp_private_dir(), name); +} + struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev) { struct messaging_context *ctx; NTSTATUS status; int ret; + const char *lck_path; + const char *priv_path; + bool ok; if (!(ctx = talloc_zero(mem_ctx, struct messaging_context))) { return NULL; @@ -307,8 +315,34 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx, sec_init(); + lck_path = lock_path("msg"); + if (lck_path == NULL) { + TALLOC_FREE(ctx); + return NULL; + } + + ok = directory_create_or_exist_strict(lck_path, sec_initial_uid(), + 0755); + if (!ok) { + DEBUG(10, ("%s: Could not create lock directory: %s\n", + __func__, strerror(errno))); + TALLOC_FREE(ctx); + return NULL; + } + + priv_path = private_path("sock"); + + ok = directory_create_or_exist_strict(priv_path, sec_initial_uid(), + 0700); + if (!ok) { + DEBUG(10, ("%s: Could not create msg directory: %s\n", + __func__, strerror(errno))); + TALLOC_FREE(ctx); + return NULL; + } + ret = messaging_dgm_init(ctx->event_ctx, ctx->id.unique_id, - lp_cache_directory(), sec_initial_uid(), + priv_path, lck_path, messaging_recv_cb, ctx); if (ret != 0) { @@ -369,7 +403,7 @@ NTSTATUS messaging_reinit(struct messaging_context *msg_ctx) msg_ctx->id = procid_self(); ret = messaging_dgm_init(msg_ctx->event_ctx, msg_ctx->id.unique_id, - lp_cache_directory(), sec_initial_uid(), + private_path("sock"), lock_path("msg"), messaging_recv_cb, msg_ctx); if (ret != 0) { DEBUG(0, ("messaging_dgm_init failed: %s\n", strerror(errno))); |