[PATCH] auth: Make new_server_id_task() static to auth_samba4
Volker Lendecke
Volker.Lendecke at SerNet.DE
Wed Feb 12 07:52:52 MST 2014
Hi!
Review would be appreciated!
Thanks,
Volker
--
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 at sernet.de
-------------- next part --------------
From cad471067b67b70a990ccdb34d655904f5b5fdb6 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 12 Feb 2014 14:47:26 +0000
Subject: [PATCH] auth: Make new_server_id_task() static to auth_samba4
This is not used in other parts of source3, so this patch improves
modularity and isolation of features.
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/auth/auth_samba4.c | 42 ++++++++++++++++++++++++++++++++++++++++++
source3/include/proto.h | 1 -
source3/lib/util.c | 42 ------------------------------------------
3 files changed, 42 insertions(+), 43 deletions(-)
diff --git a/source3/auth/auth_samba4.c b/source3/auth/auth_samba4.c
index 0c2beac..901acf9 100644
--- a/source3/auth/auth_samba4.c
+++ b/source3/auth/auth_samba4.c
@@ -31,6 +31,48 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_AUTH
+static struct idr_context *task_id_tree;
+
+static int free_task_id(struct server_id *server_id)
+{
+ idr_remove(task_id_tree, server_id->task_id);
+ return 0;
+}
+
+/* Return a server_id with a unique task_id element. Free the
+ * returned pointer to de-allocate the task_id via a talloc destructor
+ * (ie, use talloc_free()) */
+static struct server_id *new_server_id_task(TALLOC_CTX *mem_ctx)
+{
+ struct server_id *server_id;
+ int task_id;
+ if (!task_id_tree) {
+ task_id_tree = idr_init(NULL);
+ if (!task_id_tree) {
+ return NULL;
+ }
+ }
+
+ server_id = talloc(mem_ctx, struct server_id);
+
+ if (!server_id) {
+ return NULL;
+ }
+ *server_id = procid_self();
+
+ /* 0 is the default server_id, so we need to start with 1 */
+ task_id = idr_get_new_above(task_id_tree, server_id, 1, INT32_MAX);
+
+ if (task_id == -1) {
+ talloc_free(server_id);
+ return NULL;
+ }
+
+ talloc_set_destructor(server_id, free_task_id);
+ server_id->task_id = task_id;
+ return server_id;
+}
+
/*
* This module is not an ordinary authentication module. It is really
* a way to redirect the whole authentication and authorization stack
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 315f025..28c26a9 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -447,7 +447,6 @@ uint32 get_my_vnn(void);
void set_my_unique_id(uint64_t unique_id);
struct server_id pid_to_procid(pid_t pid);
struct server_id procid_self(void);
-struct server_id *new_server_id_task(TALLOC_CTX *mem_ctx);
#define serverid_equal(p1, p2) server_id_equal(p1,p2)
bool procid_is_me(const struct server_id *pid);
struct server_id interpret_pid(const char *pid_string);
diff --git a/source3/lib/util.c b/source3/lib/util.c
index cddb53c..374bc5d 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -1948,48 +1948,6 @@ struct server_id procid_self(void)
return pid_to_procid(getpid());
}
-static struct idr_context *task_id_tree;
-
-static int free_task_id(struct server_id *server_id)
-{
- idr_remove(task_id_tree, server_id->task_id);
- return 0;
-}
-
-/* Return a server_id with a unique task_id element. Free the
- * returned pointer to de-allocate the task_id via a talloc destructor
- * (ie, use talloc_free()) */
-struct server_id *new_server_id_task(TALLOC_CTX *mem_ctx)
-{
- struct server_id *server_id;
- int task_id;
- if (!task_id_tree) {
- task_id_tree = idr_init(NULL);
- if (!task_id_tree) {
- return NULL;
- }
- }
-
- server_id = talloc(mem_ctx, struct server_id);
-
- if (!server_id) {
- return NULL;
- }
- *server_id = procid_self();
-
- /* 0 is the default server_id, so we need to start with 1 */
- task_id = idr_get_new_above(task_id_tree, server_id, 1, INT32_MAX);
-
- if (task_id == -1) {
- talloc_free(server_id);
- return NULL;
- }
-
- talloc_set_destructor(server_id, free_task_id);
- server_id->task_id = task_id;
- return server_id;
-}
-
bool procid_is_me(const struct server_id *pid)
{
if (pid->pid != getpid())
--
1.7.9.5
More information about the samba-technical
mailing list