[PATCH] Streamline winbind sync functions
Volker Lendecke
Volker.Lendecke at SerNet.DE
Wed May 16 14:26:21 UTC 2018
Hi!
This is required for further development in my pipeline. Metze has
already reviewed those. If nobody objects, I'll push tomorrow.
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 25da4e06e57803837cff6a557dd5778359d7f8fa Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 2 May 2018 15:26:05 +0200
Subject: [PATCH 01/16] winbindd: Introduce "bool_dispatch_table"
This is meant to replace the synchronous "dispatch_table".
The current dispatch_table assumes that every synchronous function does
the request_ok or request_error itself. This mixes two concerns: Doing
the work and shipping the reply to the winbind client. This new dispatch
table will make it possible to centralize shipping the reply to the
client. At a later stage this will enable easier statistics on how long
request processing took precisely.
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
---
source3/winbindd/winbindd.c | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index 76d644b1ba6..f9bea96bf97 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -554,6 +554,13 @@ static struct winbindd_dispatch_table {
{ WINBINDD_NUM_CMDS, NULL, "NONE" }
};
+static struct winbindd_bool_dispatch_table {
+ enum winbindd_cmd cmd;
+ bool (*fn)(struct winbindd_cli_state *state);
+ const char *cmd_name;
+} bool_dispatch_table[] = {
+};
+
struct winbindd_async_dispatch_table {
enum winbindd_cmd cmd;
const char *cmd_name;
@@ -658,6 +665,8 @@ static void process_request(struct winbindd_cli_state *state)
{
struct winbindd_dispatch_table *table = dispatch_table;
struct winbindd_async_dispatch_table *atable;
+ size_t i;
+ bool ok;
state->mem_ctx = talloc_named(state, 0, "winbind request");
if (state->mem_ctx == NULL)
@@ -725,14 +734,32 @@ static void process_request(struct winbindd_cli_state *state)
table->winbindd_cmd_name ));
state->cmd_name = table->winbindd_cmd_name;
table->fn(state);
+ return;
+ }
+ }
+
+ for (i=0; i<ARRAY_SIZE(bool_dispatch_table); i++) {
+ if (bool_dispatch_table[i].cmd == state->request->cmd) {
break;
}
}
- if (!table->fn) {
+ if (i == ARRAY_SIZE(bool_dispatch_table)) {
DEBUG(10,("process_request: unknown request fn number %d\n",
(int)state->request->cmd ));
request_error(state);
+ return;
+ }
+
+ DBG_DEBUG("process_request: request fn %s\n",
+ bool_dispatch_table[i].cmd_name);
+
+ ok = bool_dispatch_table[i].fn(state);
+
+ if (ok) {
+ request_ok(state);
+ } else {
+ request_error(state);
}
}
--
2.11.0
From 521e58e3ec208879c24dc96c08f81fac14a387ee Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 2 May 2018 15:26:55 +0200
Subject: [PATCH 02/16] winbindd: winbindd_interface_version() ->
bool_dispatch_table
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
---
source3/winbindd/winbindd.c | 5 +++--
source3/winbindd/winbindd_misc.c | 4 ++--
source3/winbindd/winbindd_proto.h | 2 +-
3 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index f9bea96bf97..d658d8a6ac3 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -536,8 +536,6 @@ static struct winbindd_dispatch_table {
{ WINBINDD_INFO, winbindd_info, "INFO" },
{ WINBINDD_PING, winbindd_ping, "PING" },
- { WINBINDD_INTERFACE_VERSION, winbindd_interface_version,
- "INTERFACE_VERSION" },
{ WINBINDD_DOMAIN_NAME, winbindd_domain_name, "DOMAIN_NAME" },
{ WINBINDD_DOMAIN_INFO, winbindd_domain_info, "DOMAIN_INFO" },
{ WINBINDD_DC_INFO, winbindd_dc_info, "DC_INFO" },
@@ -559,6 +557,9 @@ static struct winbindd_bool_dispatch_table {
bool (*fn)(struct winbindd_cli_state *state);
const char *cmd_name;
} bool_dispatch_table[] = {
+ { WINBINDD_INTERFACE_VERSION,
+ winbindd_interface_version,
+ "INTERFACE_VERSION" },
};
struct winbindd_async_dispatch_table {
diff --git a/source3/winbindd/winbindd_misc.c b/source3/winbindd/winbindd_misc.c
index c101269e93a..d6efce2d684 100644
--- a/source3/winbindd/winbindd_misc.c
+++ b/source3/winbindd/winbindd_misc.c
@@ -522,13 +522,13 @@ void winbindd_info(struct winbindd_cli_state *state)
/* Tell the client the current interface version */
-void winbindd_interface_version(struct winbindd_cli_state *state)
+bool winbindd_interface_version(struct winbindd_cli_state *state)
{
DEBUG(3, ("[%5lu]: request interface version (version = %d)\n",
(unsigned long)state->pid, WINBIND_INTERFACE_VERSION));
state->response->data.interface_version = WINBIND_INTERFACE_VERSION;
- request_ok(state);
+ return true;
}
/* What domain are we a member of? */
diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h
index 9b3fadf4c98..b5e4ecfe5c0 100644
--- a/source3/winbindd/winbindd_proto.h
+++ b/source3/winbindd/winbindd_proto.h
@@ -389,7 +389,7 @@ void winbindd_domain_info(struct winbindd_cli_state *state);
void winbindd_dc_info(struct winbindd_cli_state *state);
void winbindd_ping(struct winbindd_cli_state *state);
void winbindd_info(struct winbindd_cli_state *state);
-void winbindd_interface_version(struct winbindd_cli_state *state);
+bool winbindd_interface_version(struct winbindd_cli_state *state);
void winbindd_domain_name(struct winbindd_cli_state *state);
void winbindd_netbios_name(struct winbindd_cli_state *state);
void winbindd_priv_pipe_dir(struct winbindd_cli_state *state);
--
2.11.0
From 1aa7398dfeb9546c10dac949ca251d55ecb6097e Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 2 May 2018 16:36:49 +0200
Subject: [PATCH 03/16] winbindd: winbindd_info() -> bool_dispatch_table
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
---
source3/winbindd/winbindd.c | 4 +++-
source3/winbindd/winbindd_misc.c | 4 ++--
source3/winbindd/winbindd_proto.h | 2 +-
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index d658d8a6ac3..a89962add92 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -534,7 +534,6 @@ static struct winbindd_dispatch_table {
/* Miscellaneous */
- { WINBINDD_INFO, winbindd_info, "INFO" },
{ WINBINDD_PING, winbindd_ping, "PING" },
{ WINBINDD_DOMAIN_NAME, winbindd_domain_name, "DOMAIN_NAME" },
{ WINBINDD_DOMAIN_INFO, winbindd_domain_info, "DOMAIN_INFO" },
@@ -560,6 +559,9 @@ static struct winbindd_bool_dispatch_table {
{ WINBINDD_INTERFACE_VERSION,
winbindd_interface_version,
"INTERFACE_VERSION" },
+ { WINBINDD_INFO,
+ winbindd_info,
+ "INFO" },
};
struct winbindd_async_dispatch_table {
diff --git a/source3/winbindd/winbindd_misc.c b/source3/winbindd/winbindd_misc.c
index d6efce2d684..315b0a3fcd3 100644
--- a/source3/winbindd/winbindd_misc.c
+++ b/source3/winbindd/winbindd_misc.c
@@ -510,14 +510,14 @@ void winbindd_ping(struct winbindd_cli_state *state)
/* List various tidbits of information */
-void winbindd_info(struct winbindd_cli_state *state)
+bool winbindd_info(struct winbindd_cli_state *state)
{
DEBUG(3, ("[%5lu]: request misc info\n", (unsigned long)state->pid));
state->response->data.info.winbind_separator = *lp_winbind_separator();
fstrcpy(state->response->data.info.samba_version, samba_version_string());
- request_ok(state);
+ return true;
}
/* Tell the client the current interface version */
diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h
index b5e4ecfe5c0..90565333e1a 100644
--- a/source3/winbindd/winbindd_proto.h
+++ b/source3/winbindd/winbindd_proto.h
@@ -388,7 +388,7 @@ void winbindd_show_sequence(struct winbindd_cli_state *state);
void winbindd_domain_info(struct winbindd_cli_state *state);
void winbindd_dc_info(struct winbindd_cli_state *state);
void winbindd_ping(struct winbindd_cli_state *state);
-void winbindd_info(struct winbindd_cli_state *state);
+bool winbindd_info(struct winbindd_cli_state *state);
bool winbindd_interface_version(struct winbindd_cli_state *state);
void winbindd_domain_name(struct winbindd_cli_state *state);
void winbindd_netbios_name(struct winbindd_cli_state *state);
--
2.11.0
From 86e7d1ba615643ef047a8716630ef0497cea4428 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 2 May 2018 16:38:14 +0200
Subject: [PATCH 04/16] winbindd: winbindd_ping() -> bool_dispatch_table
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
---
source3/winbindd/winbindd.c | 4 +++-
source3/winbindd/winbindd_misc.c | 4 ++--
source3/winbindd/winbindd_proto.h | 2 +-
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index a89962add92..62944037be5 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -534,7 +534,6 @@ static struct winbindd_dispatch_table {
/* Miscellaneous */
- { WINBINDD_PING, winbindd_ping, "PING" },
{ WINBINDD_DOMAIN_NAME, winbindd_domain_name, "DOMAIN_NAME" },
{ WINBINDD_DOMAIN_INFO, winbindd_domain_info, "DOMAIN_INFO" },
{ WINBINDD_DC_INFO, winbindd_dc_info, "DC_INFO" },
@@ -562,6 +561,9 @@ static struct winbindd_bool_dispatch_table {
{ WINBINDD_INFO,
winbindd_info,
"INFO" },
+ { WINBINDD_PING,
+ winbindd_ping,
+ "PING" },
};
struct winbindd_async_dispatch_table {
diff --git a/source3/winbindd/winbindd_misc.c b/source3/winbindd/winbindd_misc.c
index 315b0a3fcd3..99aed9c1a3f 100644
--- a/source3/winbindd/winbindd_misc.c
+++ b/source3/winbindd/winbindd_misc.c
@@ -502,10 +502,10 @@ void winbindd_dc_info(struct winbindd_cli_state *cli)
request_ok(cli);
}
-void winbindd_ping(struct winbindd_cli_state *state)
+bool winbindd_ping(struct winbindd_cli_state *state)
{
DEBUG(3, ("[%5lu]: ping\n", (unsigned long)state->pid));
- request_ok(state);
+ return true;
}
/* List various tidbits of information */
diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h
index 90565333e1a..b947baa08d5 100644
--- a/source3/winbindd/winbindd_proto.h
+++ b/source3/winbindd/winbindd_proto.h
@@ -387,7 +387,7 @@ enum winbindd_result winbindd_dual_list_trusted_domains(struct winbindd_domain *
void winbindd_show_sequence(struct winbindd_cli_state *state);
void winbindd_domain_info(struct winbindd_cli_state *state);
void winbindd_dc_info(struct winbindd_cli_state *state);
-void winbindd_ping(struct winbindd_cli_state *state);
+bool winbindd_ping(struct winbindd_cli_state *state);
bool winbindd_info(struct winbindd_cli_state *state);
bool winbindd_interface_version(struct winbindd_cli_state *state);
void winbindd_domain_name(struct winbindd_cli_state *state);
--
2.11.0
From c54dd9321d46ca6e544406e5f2ba36fc3f8bd74a Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 2 May 2018 16:39:20 +0200
Subject: [PATCH 05/16] winbindd: winbindd_domain_name() -> bool_dispatch_table
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
---
source3/winbindd/winbindd.c | 4 +++-
source3/winbindd/winbindd_misc.c | 4 ++--
source3/winbindd/winbindd_proto.h | 2 +-
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index 62944037be5..1d820f26d7b 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -534,7 +534,6 @@ static struct winbindd_dispatch_table {
/* Miscellaneous */
- { WINBINDD_DOMAIN_NAME, winbindd_domain_name, "DOMAIN_NAME" },
{ WINBINDD_DOMAIN_INFO, winbindd_domain_info, "DOMAIN_INFO" },
{ WINBINDD_DC_INFO, winbindd_dc_info, "DC_INFO" },
{ WINBINDD_NETBIOS_NAME, winbindd_netbios_name, "NETBIOS_NAME" },
@@ -564,6 +563,9 @@ static struct winbindd_bool_dispatch_table {
{ WINBINDD_PING,
winbindd_ping,
"PING" },
+ { WINBINDD_DOMAIN_NAME,
+ winbindd_domain_name,
+ "DOMAIN_NAME" },
};
struct winbindd_async_dispatch_table {
diff --git a/source3/winbindd/winbindd_misc.c b/source3/winbindd/winbindd_misc.c
index 99aed9c1a3f..45dabc3843b 100644
--- a/source3/winbindd/winbindd_misc.c
+++ b/source3/winbindd/winbindd_misc.c
@@ -533,12 +533,12 @@ bool winbindd_interface_version(struct winbindd_cli_state *state)
/* What domain are we a member of? */
-void winbindd_domain_name(struct winbindd_cli_state *state)
+bool winbindd_domain_name(struct winbindd_cli_state *state)
{
DEBUG(3, ("[%5lu]: request domain name\n", (unsigned long)state->pid));
fstrcpy(state->response->data.domain_name, lp_workgroup());
- request_ok(state);
+ return true;
}
/* What's my name again? */
diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h
index b947baa08d5..cc1677e622f 100644
--- a/source3/winbindd/winbindd_proto.h
+++ b/source3/winbindd/winbindd_proto.h
@@ -390,7 +390,7 @@ void winbindd_dc_info(struct winbindd_cli_state *state);
bool winbindd_ping(struct winbindd_cli_state *state);
bool winbindd_info(struct winbindd_cli_state *state);
bool winbindd_interface_version(struct winbindd_cli_state *state);
-void winbindd_domain_name(struct winbindd_cli_state *state);
+bool winbindd_domain_name(struct winbindd_cli_state *state);
void winbindd_netbios_name(struct winbindd_cli_state *state);
void winbindd_priv_pipe_dir(struct winbindd_cli_state *state);
--
2.11.0
From ab270506ce9eb27d02d84c7da8cb433b31dcc21e Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 2 May 2018 18:25:00 +0200
Subject: [PATCH 06/16] winbindd: winbindd_netbios_name() ->
bool_dispatch_table
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
---
source3/winbindd/winbindd.c | 4 +++-
source3/winbindd/winbindd_misc.c | 4 ++--
source3/winbindd/winbindd_proto.h | 2 +-
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index 1d820f26d7b..714663b7c9f 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -536,7 +536,6 @@ static struct winbindd_dispatch_table {
{ WINBINDD_DOMAIN_INFO, winbindd_domain_info, "DOMAIN_INFO" },
{ WINBINDD_DC_INFO, winbindd_dc_info, "DC_INFO" },
- { WINBINDD_NETBIOS_NAME, winbindd_netbios_name, "NETBIOS_NAME" },
{ WINBINDD_PRIV_PIPE_DIR, winbindd_priv_pipe_dir,
"WINBINDD_PRIV_PIPE_DIR" },
@@ -566,6 +565,9 @@ static struct winbindd_bool_dispatch_table {
{ WINBINDD_DOMAIN_NAME,
winbindd_domain_name,
"DOMAIN_NAME" },
+ { WINBINDD_NETBIOS_NAME,
+ winbindd_netbios_name,
+ "NETBIOS_NAME" },
};
struct winbindd_async_dispatch_table {
diff --git a/source3/winbindd/winbindd_misc.c b/source3/winbindd/winbindd_misc.c
index 45dabc3843b..db73784bff8 100644
--- a/source3/winbindd/winbindd_misc.c
+++ b/source3/winbindd/winbindd_misc.c
@@ -543,13 +543,13 @@ bool winbindd_domain_name(struct winbindd_cli_state *state)
/* What's my name again? */
-void winbindd_netbios_name(struct winbindd_cli_state *state)
+bool winbindd_netbios_name(struct winbindd_cli_state *state)
{
DEBUG(3, ("[%5lu]: request netbios name\n",
(unsigned long)state->pid));
fstrcpy(state->response->data.netbios_name, lp_netbios_name());
- request_ok(state);
+ return true;
}
/* Where can I find the privileged pipe? */
diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h
index cc1677e622f..e6ffee1bacb 100644
--- a/source3/winbindd/winbindd_proto.h
+++ b/source3/winbindd/winbindd_proto.h
@@ -391,7 +391,7 @@ bool winbindd_ping(struct winbindd_cli_state *state);
bool winbindd_info(struct winbindd_cli_state *state);
bool winbindd_interface_version(struct winbindd_cli_state *state);
bool winbindd_domain_name(struct winbindd_cli_state *state);
-void winbindd_netbios_name(struct winbindd_cli_state *state);
+bool winbindd_netbios_name(struct winbindd_cli_state *state);
void winbindd_priv_pipe_dir(struct winbindd_cli_state *state);
/* The following definitions come from winbindd/winbindd_ndr.c */
--
2.11.0
From 5582bd9426e2cae3e3571dce1c2d0d3f89ceef1c Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 2 May 2018 18:27:23 +0200
Subject: [PATCH 07/16] winbindd: winbindd_dc_info() -> bool_dispatch_table
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
---
source3/winbindd/winbindd.c | 4 +++-
source3/winbindd/winbindd_misc.c | 13 +++++--------
source3/winbindd/winbindd_proto.h | 2 +-
3 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index 714663b7c9f..1608a14974c 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -535,7 +535,6 @@ static struct winbindd_dispatch_table {
/* Miscellaneous */
{ WINBINDD_DOMAIN_INFO, winbindd_domain_info, "DOMAIN_INFO" },
- { WINBINDD_DC_INFO, winbindd_dc_info, "DC_INFO" },
{ WINBINDD_PRIV_PIPE_DIR, winbindd_priv_pipe_dir,
"WINBINDD_PRIV_PIPE_DIR" },
@@ -568,6 +567,9 @@ static struct winbindd_bool_dispatch_table {
{ WINBINDD_NETBIOS_NAME,
winbindd_netbios_name,
"NETBIOS_NAME" },
+ { WINBINDD_DC_INFO,
+ winbindd_dc_info,
+ "DC_INFO" },
};
struct winbindd_async_dispatch_table {
diff --git a/source3/winbindd/winbindd_misc.c b/source3/winbindd/winbindd_misc.c
index db73784bff8..e55fc4ef874 100644
--- a/source3/winbindd/winbindd_misc.c
+++ b/source3/winbindd/winbindd_misc.c
@@ -452,7 +452,7 @@ static void domain_info_done(struct tevent_req *req)
request_ok(state->cli);
}
-void winbindd_dc_info(struct winbindd_cli_state *cli)
+bool winbindd_dc_info(struct winbindd_cli_state *cli)
{
struct winbindd_domain *domain;
char *dc_name, *dc_ip;
@@ -468,8 +468,7 @@ void winbindd_dc_info(struct winbindd_cli_state *cli)
if (domain == NULL) {
DEBUG(10, ("Could not find domain %s\n",
cli->request->domain_name));
- request_error(cli);
- return;
+ return false;
}
} else {
domain = find_our_domain();
@@ -479,8 +478,7 @@ void winbindd_dc_info(struct winbindd_cli_state *cli)
talloc_tos(), domain->name, &dc_name, &dc_ip)) {
DEBUG(10, ("fetch_current_dc_from_gencache(%s) failed\n",
domain->name));
- request_error(cli);
- return;
+ return false;
}
cli->response->data.num_entries = 1;
@@ -491,15 +489,14 @@ void winbindd_dc_info(struct winbindd_cli_state *cli)
TALLOC_FREE(dc_ip);
if (cli->response->extra_data.data == NULL) {
- request_error(cli);
- return;
+ return false;
}
/* must add one to length to copy the 0 for string termination */
cli->response->length +=
strlen((char *)cli->response->extra_data.data) + 1;
- request_ok(cli);
+ return true;
}
bool winbindd_ping(struct winbindd_cli_state *state)
diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h
index e6ffee1bacb..ea8225256bc 100644
--- a/source3/winbindd/winbindd_proto.h
+++ b/source3/winbindd/winbindd_proto.h
@@ -386,7 +386,7 @@ enum winbindd_result winbindd_dual_list_trusted_domains(struct winbindd_domain *
struct winbindd_cli_state *state);
void winbindd_show_sequence(struct winbindd_cli_state *state);
void winbindd_domain_info(struct winbindd_cli_state *state);
-void winbindd_dc_info(struct winbindd_cli_state *state);
+bool winbindd_dc_info(struct winbindd_cli_state *state);
bool winbindd_ping(struct winbindd_cli_state *state);
bool winbindd_info(struct winbindd_cli_state *state);
bool winbindd_interface_version(struct winbindd_cli_state *state);
--
2.11.0
From cd6cc6b8a70f4f3bc16f7355efaf4e818c69246f Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 2 May 2018 20:23:54 +0200
Subject: [PATCH 08/16] winbindd: winbindd_ccache_ntlm_auth() ->
bool_dispatch_table
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
---
source3/winbindd/winbindd.c | 4 +++-
source3/winbindd/winbindd_ccache_access.c | 17 +++++------------
source3/winbindd/winbindd_proto.h | 2 +-
3 files changed, 9 insertions(+), 14 deletions(-)
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index 1608a14974c..acccd61128a 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -539,7 +539,6 @@ static struct winbindd_dispatch_table {
"WINBINDD_PRIV_PIPE_DIR" },
/* Credential cache access */
- { WINBINDD_CCACHE_NTLMAUTH, winbindd_ccache_ntlm_auth, "NTLMAUTH" },
{ WINBINDD_CCACHE_SAVE, winbindd_ccache_save, "CCACHE_SAVE" },
/* End of list */
@@ -570,6 +569,9 @@ static struct winbindd_bool_dispatch_table {
{ WINBINDD_DC_INFO,
winbindd_dc_info,
"DC_INFO" },
+ { WINBINDD_CCACHE_NTLMAUTH,
+ winbindd_ccache_ntlm_auth,
+ "NTLMAUTH" },
};
struct winbindd_async_dispatch_table {
diff --git a/source3/winbindd/winbindd_ccache_access.c b/source3/winbindd/winbindd_ccache_access.c
index ddeaf1d9940..7b558660cc9 100644
--- a/source3/winbindd/winbindd_ccache_access.c
+++ b/source3/winbindd/winbindd_ccache_access.c
@@ -180,7 +180,7 @@ static bool check_client_uid(struct winbindd_cli_state *state, uid_t uid)
return True;
}
-void winbindd_ccache_ntlm_auth(struct winbindd_cli_state *state)
+bool winbindd_ccache_ntlm_auth(struct winbindd_cli_state *state)
{
struct winbindd_domain *domain;
fstring name_namespace, name_domain, name_user;
@@ -206,8 +206,7 @@ void winbindd_ccache_ntlm_auth(struct winbindd_cli_state *state)
if (!ok) {
DEBUG(5,("winbindd_ccache_ntlm_auth: cannot parse domain and user from name [%s]\n",
state->request->data.ccache_ntlm_auth.user));
- request_error(state);
- return;
+ return false;
}
domain = find_auth_domain(state->request->flags, name_domain);
@@ -215,13 +214,11 @@ void winbindd_ccache_ntlm_auth(struct winbindd_cli_state *state)
if (domain == NULL) {
DEBUG(5,("winbindd_ccache_ntlm_auth: can't get domain [%s]\n",
name_domain));
- request_error(state);
- return;
+ return false;
}
if (!check_client_uid(state, state->request->data.ccache_ntlm_auth.uid)) {
- request_error(state);
- return;
+ return false;
}
/* validate blob lengths */
@@ -309,11 +306,7 @@ void winbindd_ccache_ntlm_auth(struct winbindd_cli_state *state)
data_blob_free(&auth);
process_result:
- if (!NT_STATUS_IS_OK(result)) {
- request_error(state);
- return;
- }
- request_ok(state);
+ return NT_STATUS_IS_OK(result);
}
void winbindd_ccache_save(struct winbindd_cli_state *state)
diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h
index ea8225256bc..0ffaf803e83 100644
--- a/source3/winbindd/winbindd_proto.h
+++ b/source3/winbindd/winbindd_proto.h
@@ -173,7 +173,7 @@ void wcache_store_ndr(struct winbindd_domain *domain, uint32_t opnum,
/* The following definitions come from winbindd/winbindd_ccache_access.c */
-void winbindd_ccache_ntlm_auth(struct winbindd_cli_state *state);
+bool winbindd_ccache_ntlm_auth(struct winbindd_cli_state *state);
enum winbindd_result winbindd_dual_ccache_ntlm_auth(struct winbindd_domain *domain,
struct winbindd_cli_state *state);
void winbindd_ccache_save(struct winbindd_cli_state *state);
--
2.11.0
From 6fbdad77a534a0196247d48d34f1580da9ab8d59 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 2 May 2018 20:26:19 +0200
Subject: [PATCH 09/16] winbindd: winbindd_ccache_save() -> bool_dispatch_table
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
---
source3/winbindd/winbindd.c | 4 +++-
source3/winbindd/winbindd_ccache_access.c | 16 ++++++----------
source3/winbindd/winbindd_proto.h | 2 +-
3 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index acccd61128a..03b44bc9a51 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -539,7 +539,6 @@ static struct winbindd_dispatch_table {
"WINBINDD_PRIV_PIPE_DIR" },
/* Credential cache access */
- { WINBINDD_CCACHE_SAVE, winbindd_ccache_save, "CCACHE_SAVE" },
/* End of list */
@@ -572,6 +571,9 @@ static struct winbindd_bool_dispatch_table {
{ WINBINDD_CCACHE_NTLMAUTH,
winbindd_ccache_ntlm_auth,
"NTLMAUTH" },
+ { WINBINDD_CCACHE_SAVE,
+ winbindd_ccache_save,
+ "CCACHE_SAVE" },
};
struct winbindd_async_dispatch_table {
diff --git a/source3/winbindd/winbindd_ccache_access.c b/source3/winbindd/winbindd_ccache_access.c
index 7b558660cc9..b3a8c89d7be 100644
--- a/source3/winbindd/winbindd_ccache_access.c
+++ b/source3/winbindd/winbindd_ccache_access.c
@@ -309,7 +309,7 @@ bool winbindd_ccache_ntlm_auth(struct winbindd_cli_state *state)
return NT_STATUS_IS_OK(result);
}
-void winbindd_ccache_save(struct winbindd_cli_state *state)
+bool winbindd_ccache_save(struct winbindd_cli_state *state)
{
struct winbindd_domain *domain;
fstring name_namespace, name_domain, name_user;
@@ -336,8 +336,7 @@ void winbindd_ccache_save(struct winbindd_cli_state *state)
DEBUG(5,("winbindd_ccache_save: cannot parse domain and user "
"from name [%s]\n",
state->request->data.ccache_save.user));
- request_error(state);
- return;
+ return false;
}
/*
@@ -353,13 +352,11 @@ void winbindd_ccache_save(struct winbindd_cli_state *state)
if (domain == NULL) {
DEBUG(5, ("winbindd_ccache_save: can't get domain [%s]\n",
name_domain));
- request_error(state);
- return;
+ return false;
}
if (!check_client_uid(state, state->request->data.ccache_save.uid)) {
- request_error(state);
- return;
+ return false;
}
status = winbindd_add_memory_creds(
@@ -370,8 +367,7 @@ void winbindd_ccache_save(struct winbindd_cli_state *state)
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("winbindd_add_memory_creds failed %s\n",
nt_errstr(status)));
- request_error(state);
- return;
+ return false;
}
- request_ok(state);
+ return true;
}
diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h
index 0ffaf803e83..2005730be33 100644
--- a/source3/winbindd/winbindd_proto.h
+++ b/source3/winbindd/winbindd_proto.h
@@ -176,7 +176,7 @@ void wcache_store_ndr(struct winbindd_domain *domain, uint32_t opnum,
bool winbindd_ccache_ntlm_auth(struct winbindd_cli_state *state);
enum winbindd_result winbindd_dual_ccache_ntlm_auth(struct winbindd_domain *domain,
struct winbindd_cli_state *state);
-void winbindd_ccache_save(struct winbindd_cli_state *state);
+bool winbindd_ccache_save(struct winbindd_cli_state *state);
/* The following definitions come from winbindd/winbindd_cm.c */
void winbind_msg_domain_offline(struct messaging_context *msg_ctx,
--
2.11.0
From 4dfe44c1623d1811395bf0962001874c8eea7190 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 2 May 2018 20:27:43 +0200
Subject: [PATCH 10/16] winbindd: winbindd_priv_pipe_dir() ->
bool_dispatch_table
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
---
source3/winbindd/winbindd.c | 6 +++---
source3/winbindd/winbindd_misc.c | 4 ++--
source3/winbindd/winbindd_proto.h | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index 03b44bc9a51..8e4071ac3f9 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -535,9 +535,6 @@ static struct winbindd_dispatch_table {
/* Miscellaneous */
{ WINBINDD_DOMAIN_INFO, winbindd_domain_info, "DOMAIN_INFO" },
- { WINBINDD_PRIV_PIPE_DIR, winbindd_priv_pipe_dir,
- "WINBINDD_PRIV_PIPE_DIR" },
-
/* Credential cache access */
/* End of list */
@@ -574,6 +571,9 @@ static struct winbindd_bool_dispatch_table {
{ WINBINDD_CCACHE_SAVE,
winbindd_ccache_save,
"CCACHE_SAVE" },
+ { WINBINDD_PRIV_PIPE_DIR,
+ winbindd_priv_pipe_dir,
+ "WINBINDD_PRIV_PIPE_DIR" },
};
struct winbindd_async_dispatch_table {
diff --git a/source3/winbindd/winbindd_misc.c b/source3/winbindd/winbindd_misc.c
index e55fc4ef874..f919f1c9324 100644
--- a/source3/winbindd/winbindd_misc.c
+++ b/source3/winbindd/winbindd_misc.c
@@ -551,7 +551,7 @@ bool winbindd_netbios_name(struct winbindd_cli_state *state)
/* Where can I find the privileged pipe? */
-void winbindd_priv_pipe_dir(struct winbindd_cli_state *state)
+bool winbindd_priv_pipe_dir(struct winbindd_cli_state *state)
{
char *priv_dir;
DEBUG(3, ("[%5lu]: request location of privileged pipe\n",
@@ -565,6 +565,6 @@ void winbindd_priv_pipe_dir(struct winbindd_cli_state *state)
state->response->length +=
strlen((char *)state->response->extra_data.data) + 1;
- request_ok(state);
+ return true;
}
diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h
index 2005730be33..6231997ae32 100644
--- a/source3/winbindd/winbindd_proto.h
+++ b/source3/winbindd/winbindd_proto.h
@@ -392,7 +392,7 @@ bool winbindd_info(struct winbindd_cli_state *state);
bool winbindd_interface_version(struct winbindd_cli_state *state);
bool winbindd_domain_name(struct winbindd_cli_state *state);
bool winbindd_netbios_name(struct winbindd_cli_state *state);
-void winbindd_priv_pipe_dir(struct winbindd_cli_state *state);
+bool winbindd_priv_pipe_dir(struct winbindd_cli_state *state);
/* The following definitions come from winbindd/winbindd_ndr.c */
struct ndr_print;
--
2.11.0
From c1dae4d390549cdee71f5dce45e92a901511172d Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 4 May 2018 21:19:06 +0200
Subject: [PATCH 11/16] winbindd: winbindd_list_trusted_domains() ->
bool_dispatch_table
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
---
source3/winbindd/winbindd.c | 5 +++--
source3/winbindd/winbindd_misc.c | 8 ++++----
source3/winbindd/winbindd_proto.h | 2 +-
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index 8e4071ac3f9..28f048c2f26 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -529,8 +529,6 @@ static struct winbindd_dispatch_table {
/* Enumeration functions */
- { WINBINDD_LIST_TRUSTDOM, winbindd_list_trusted_domains,
- "LIST_TRUSTDOM" },
/* Miscellaneous */
@@ -574,6 +572,9 @@ static struct winbindd_bool_dispatch_table {
{ WINBINDD_PRIV_PIPE_DIR,
winbindd_priv_pipe_dir,
"WINBINDD_PRIV_PIPE_DIR" },
+ { WINBINDD_LIST_TRUSTDOM,
+ winbindd_list_trusted_domains,
+ "LIST_TRUSTDOM" },
};
struct winbindd_async_dispatch_table {
diff --git a/source3/winbindd/winbindd_misc.c b/source3/winbindd/winbindd_misc.c
index f919f1c9324..c8b778db727 100644
--- a/source3/winbindd/winbindd_misc.c
+++ b/source3/winbindd/winbindd_misc.c
@@ -203,25 +203,24 @@ static bool trust_is_transitive(struct winbindd_tdc_domain *domain)
return transitive;
}
-void winbindd_list_trusted_domains(struct winbindd_cli_state *state)
+bool winbindd_list_trusted_domains(struct winbindd_cli_state *state)
{
struct winbindd_tdc_domain *dom_list = NULL;
size_t num_domains = 0;
int extra_data_len = 0;
char *extra_data = NULL;
int i = 0;
+ bool ret = false;
DEBUG(3, ("[%5lu]: list trusted domains\n",
(unsigned long)state->pid));
if( !wcache_tdc_fetch_list( &dom_list, &num_domains )) {
- request_error(state);
goto done;
}
extra_data = talloc_strdup(state->mem_ctx, "");
if (extra_data == NULL) {
- request_error(state);
goto done;
}
@@ -269,9 +268,10 @@ void winbindd_list_trusted_domains(struct winbindd_cli_state *state)
state->response->length += extra_data_len;
}
- request_ok(state);
+ ret = true;
done:
TALLOC_FREE( dom_list );
+ return ret;
}
enum winbindd_result winbindd_dual_list_trusted_domains(struct winbindd_domain *domain,
diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h
index 6231997ae32..7eb92fb6c9c 100644
--- a/source3/winbindd/winbindd_proto.h
+++ b/source3/winbindd/winbindd_proto.h
@@ -381,7 +381,7 @@ struct dcerpc_binding_handle *locator_child_handle(void);
/* The following definitions come from winbindd/winbindd_misc.c */
-void winbindd_list_trusted_domains(struct winbindd_cli_state *state);
+bool winbindd_list_trusted_domains(struct winbindd_cli_state *state);
enum winbindd_result winbindd_dual_list_trusted_domains(struct winbindd_domain *domain,
struct winbindd_cli_state *state);
void winbindd_show_sequence(struct winbindd_cli_state *state);
--
2.11.0
From 4c0f24879d2d4526c108dd5154ec61c62bcd0969 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 2 May 2018 20:47:49 +0200
Subject: [PATCH 12/16] winbindd: Make DOMAIN_INFO a proper async request
This has an async code path hidden inside. Expose that properly.
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
---
source3/winbindd/winbindd.c | 5 +-
source3/winbindd/winbindd_domain_info.c | 129 ++++++++++++++++++++++++++++++++
source3/winbindd/winbindd_misc.c | 106 --------------------------
source3/winbindd/winbindd_proto.h | 9 ++-
source3/winbindd/wscript_build | 1 +
5 files changed, 139 insertions(+), 111 deletions(-)
create mode 100644 source3/winbindd/winbindd_domain_info.c
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index 28f048c2f26..1542edb6cb0 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -532,9 +532,6 @@ static struct winbindd_dispatch_table {
/* Miscellaneous */
- { WINBINDD_DOMAIN_INFO, winbindd_domain_info, "DOMAIN_INFO" },
- /* Credential cache access */
-
/* End of list */
{ WINBINDD_NUM_CMDS, NULL, "NONE" }
@@ -658,6 +655,8 @@ static struct winbindd_async_dispatch_table async_nonpriv_table[] = {
winbindd_wins_byip_send, winbindd_wins_byip_recv },
{ WINBINDD_WINS_BYNAME, "WINS_BYNAME",
winbindd_wins_byname_send, winbindd_wins_byname_recv },
+ { WINBINDD_DOMAIN_INFO, "DOMAIN_INFO",
+ winbindd_domain_info_send, winbindd_domain_info_recv },
{ 0, NULL, NULL, NULL }
};
diff --git a/source3/winbindd/winbindd_domain_info.c b/source3/winbindd/winbindd_domain_info.c
new file mode 100644
index 00000000000..126691a893e
--- /dev/null
+++ b/source3/winbindd/winbindd_domain_info.c
@@ -0,0 +1,129 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * async implementation of WINBINDD_DOMAIN_INFO
+ * Copyright (C) Volker Lendecke 2018
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "includes.h"
+#include "winbindd.h"
+
+struct winbindd_domain_info_state {
+ struct winbindd_domain *domain;
+ struct winbindd_request ping_request;
+};
+
+static void winbindd_domain_info_done(struct tevent_req *subreq);
+
+struct tevent_req *winbindd_domain_info_send(
+ TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct winbindd_cli_state *cli,
+ struct winbindd_request *request)
+{
+ struct tevent_req *req, *subreq;
+ struct winbindd_domain_info_state *state;
+
+ req = tevent_req_create(mem_ctx, &state,
+ struct winbindd_domain_info_state);
+ if (req == NULL) {
+ return NULL;
+ }
+
+ DEBUG(3, ("[%5lu]: domain_info [%s]\n", (unsigned long)cli->pid,
+ cli->request->domain_name));
+
+ state->domain = find_domain_from_name_noinit(
+ cli->request->domain_name);
+
+ if (state->domain == NULL) {
+ DEBUG(3, ("Did not find domain [%s]\n",
+ cli->request->domain_name));
+ tevent_req_nterror(req, NT_STATUS_NO_SUCH_DOMAIN);
+ return tevent_req_post(req, ev);
+ }
+
+ if (state->domain->initialized) {
+ tevent_req_done(req);
+ return tevent_req_post(req, ev);
+ }
+
+ state->ping_request.cmd = WINBINDD_PING;
+
+ /*
+ * Send a ping down. This implicitly initializes the domain.
+ */
+
+ subreq = wb_domain_request_send(state, server_event_context(),
+ state->domain, &state->ping_request);
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
+ }
+ tevent_req_set_callback(subreq, winbindd_domain_info_done, req);
+
+ return req;
+}
+
+static void winbindd_domain_info_done(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct winbindd_domain_info_state *state = tevent_req_data(
+ req, struct winbindd_domain_info_state);
+ struct winbindd_response *response;
+ int ret, err;
+
+ ret = wb_domain_request_recv(subreq, state, &response, &err);
+ TALLOC_FREE(subreq);
+ if (ret == -1) {
+ DBG_DEBUG("wb_domain_request failed: %s\n", strerror(err));
+ tevent_req_nterror(req, map_nt_error_from_unix(err));
+ return;
+ }
+
+ if (!state->domain->initialized) {
+ DBG_INFO("wb_domain_request did not initialize domain %s\n",
+ state->domain->name);
+ tevent_req_nterror(req, NT_STATUS_INTERNAL_ERROR);
+ return;
+ }
+
+ tevent_req_done(req);
+}
+
+NTSTATUS winbindd_domain_info_recv(struct tevent_req *req,
+ struct winbindd_response *response)
+{
+ struct winbindd_domain_info_state *state = tevent_req_data(
+ req, struct winbindd_domain_info_state);
+ struct winbindd_domain *domain = state->domain;
+ NTSTATUS status;
+
+ if (tevent_req_is_nterror(req, &status)) {
+ DBG_DEBUG("winbindd_domain_info failed: %s\n",
+ nt_errstr(status));
+ return status;
+ }
+
+ fstrcpy(response->data.domain_info.name, domain->name);
+ fstrcpy(response->data.domain_info.alt_name, domain->alt_name);
+ sid_to_fstring(response->data.domain_info.sid, &domain->sid);
+
+ response->data.domain_info.native_mode = domain->native_mode;
+ response->data.domain_info.active_directory = domain->active_directory;
+ response->data.domain_info.primary = domain->primary;
+
+ return NT_STATUS_OK;
+}
diff --git a/source3/winbindd/winbindd_misc.c b/source3/winbindd/winbindd_misc.c
index c8b778db727..46273a99a1a 100644
--- a/source3/winbindd/winbindd_misc.c
+++ b/source3/winbindd/winbindd_misc.c
@@ -346,112 +346,6 @@ enum winbindd_result winbindd_dual_list_trusted_domains(struct winbindd_domain *
return WINBINDD_OK;
}
-struct domain_info_state {
- struct winbindd_domain *domain;
- struct winbindd_cli_state *cli;
- struct winbindd_request ping_request;
-};
-
-static void domain_info_done(struct tevent_req *req);
-
-void winbindd_domain_info(struct winbindd_cli_state *cli)
-{
- struct domain_info_state *state;
- struct winbindd_domain *domain;
- struct tevent_req *req;
-
- DEBUG(3, ("[%5lu]: domain_info [%s]\n", (unsigned long)cli->pid,
- cli->request->domain_name));
-
- domain = find_domain_from_name_noinit(cli->request->domain_name);
-
- if (domain == NULL) {
- DEBUG(3, ("Did not find domain [%s]\n",
- cli->request->domain_name));
- request_error(cli);
- return;
- }
-
- if (domain->initialized) {
- fstrcpy(cli->response->data.domain_info.name,
- domain->name);
- fstrcpy(cli->response->data.domain_info.alt_name,
- domain->alt_name);
- sid_to_fstring(cli->response->data.domain_info.sid,
- &domain->sid);
- cli->response->data.domain_info.native_mode =
- domain->native_mode;
- cli->response->data.domain_info.active_directory =
- domain->active_directory;
- cli->response->data.domain_info.primary =
- domain->primary;
- request_ok(cli);
- return;
- }
-
- state = talloc_zero(cli->mem_ctx, struct domain_info_state);
- if (state == NULL) {
- DEBUG(0, ("talloc failed\n"));
- request_error(cli);
- return;
- }
-
- state->cli = cli;
- state->domain = domain;
- state->ping_request.cmd = WINBINDD_PING;
-
- /*
- * Send a ping down. This implicitly initializes the domain.
- */
-
- req = wb_domain_request_send(state, server_event_context(),
- domain, &state->ping_request);
- if (req == NULL) {
- DEBUG(3, ("wb_domain_request_send failed\n"));
- request_error(cli);
- return;
- }
- tevent_req_set_callback(req, domain_info_done, state);
-}
-
-static void domain_info_done(struct tevent_req *req)
-{
- struct domain_info_state *state = tevent_req_callback_data(
- req, struct domain_info_state);
- struct winbindd_response *response;
- int ret, err;
-
- ret = wb_domain_request_recv(req, req, &response, &err);
- TALLOC_FREE(req);
- if (ret == -1) {
- DEBUG(10, ("wb_domain_request failed: %s\n", strerror(errno)));
- request_error(state->cli);
- return;
- }
- if (!state->domain->initialized) {
- DEBUG(5, ("wb_domain_request did not initialize domain %s\n",
- state->domain->name));
- request_error(state->cli);
- return;
- }
-
- fstrcpy(state->cli->response->data.domain_info.name,
- state->domain->name);
- fstrcpy(state->cli->response->data.domain_info.alt_name,
- state->domain->alt_name);
- sid_to_fstring(state->cli->response->data.domain_info.sid,
- &state->domain->sid);
-
- state->cli->response->data.domain_info.native_mode =
- state->domain->native_mode;
- state->cli->response->data.domain_info.active_directory =
- state->domain->active_directory;
- state->cli->response->data.domain_info.primary =
- state->domain->primary;
-
- request_ok(state->cli);
-}
-
bool winbindd_dc_info(struct winbindd_cli_state *cli)
{
struct winbindd_domain *domain;
diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h
index 7eb92fb6c9c..3b5423e48e2 100644
--- a/source3/winbindd/winbindd_proto.h
+++ b/source3/winbindd/winbindd_proto.h
@@ -385,7 +385,6 @@ bool winbindd_list_trusted_domains(struct winbindd_cli_state *state);
enum winbindd_result winbindd_dual_list_trusted_domains(struct winbindd_domain *domain,
struct winbindd_cli_state *state);
void winbindd_show_sequence(struct winbindd_cli_state *state);
-void winbindd_domain_info(struct winbindd_cli_state *state);
bool winbindd_dc_info(struct winbindd_cli_state *state);
bool winbindd_ping(struct winbindd_cli_state *state);
bool winbindd_info(struct winbindd_cli_state *state);
@@ -941,7 +940,13 @@ struct tevent_req *winbindd_wins_byname_send(TALLOC_CTX *mem_ctx,
struct winbindd_request *request);
NTSTATUS winbindd_wins_byname_recv(struct tevent_req *req,
struct winbindd_response *presp);
-
+struct tevent_req *winbindd_domain_info_send(
+ TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct winbindd_cli_state *cli,
+ struct winbindd_request *request);
+NTSTATUS winbindd_domain_info_recv(struct tevent_req *req,
+ struct winbindd_response *response);
/* The following definitions come from winbindd/winbindd_samr.c */
diff --git a/source3/winbindd/wscript_build b/source3/winbindd/wscript_build
index 0adbe9cbba1..a23c44566ed 100644
--- a/source3/winbindd/wscript_build
+++ b/source3/winbindd/wscript_build
@@ -249,6 +249,7 @@ bld.SAMBA3_BINARY('winbindd',
winbindd_change_machine_acct.c
winbindd_irpc.c
winbindd_ping_dc.c
+ winbindd_domain_info.c
winbindd_pam_auth.c
winbindd_pam_logoff.c
winbindd_pam_chauthtok.c
--
2.11.0
From 5bd5bca5d1f97bfa87663e59de39dffa96270e3f Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 2 May 2018 21:20:58 +0200
Subject: [PATCH 13/16] winbindd: Remove the "old" non-bool dispatch table
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
---
source3/winbindd/winbindd.c | 27 ---------------------------
1 file changed, 27 deletions(-)
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index 1542edb6cb0..8ad16b8ca58 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -521,22 +521,6 @@ static void winbind_msg_validate_cache(struct messaging_context *msg_ctx,
_exit(0);
}
-static struct winbindd_dispatch_table {
- enum winbindd_cmd cmd;
- void (*fn)(struct winbindd_cli_state *state);
- const char *winbindd_cmd_name;
-} dispatch_table[] = {
-
- /* Enumeration functions */
-
-
- /* Miscellaneous */
-
- /* End of list */
-
- { WINBINDD_NUM_CMDS, NULL, "NONE" }
-};
-
static struct winbindd_bool_dispatch_table {
enum winbindd_cmd cmd;
bool (*fn)(struct winbindd_cli_state *state);
@@ -678,7 +662,6 @@ static void wb_request_done(struct tevent_req *req);
static void process_request(struct winbindd_cli_state *state)
{
- struct winbindd_dispatch_table *table = dispatch_table;
struct winbindd_async_dispatch_table *atable;
size_t i;
bool ok;
@@ -743,16 +726,6 @@ static void process_request(struct winbindd_cli_state *state)
state->response->result = WINBINDD_PENDING;
state->response->length = sizeof(struct winbindd_response);
- for (table = dispatch_table; table->fn; table++) {
- if (state->request->cmd == table->cmd) {
- DEBUG(10,("process_request: request fn %s\n",
- table->winbindd_cmd_name ));
- state->cmd_name = table->winbindd_cmd_name;
- table->fn(state);
- return;
- }
- }
-
for (i=0; i<ARRAY_SIZE(bool_dispatch_table); i++) {
if (bool_dispatch_table[i].cmd == state->request->cmd) {
break;
--
2.11.0
From 7d7b1edb26508e18ba39441d30255753ab5d503a Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 2 May 2018 21:22:45 +0200
Subject: [PATCH 14/16] winbindd: Make "request_ok()" static to winbindd.c
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
---
source3/winbindd/winbindd.c | 3 ++-
source3/winbindd/winbindd_proto.h | 1 -
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index 8ad16b8ca58..d38d1d4fd02 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -54,6 +54,7 @@
static bool client_is_idle(struct winbindd_cli_state *state);
static void remove_client(struct winbindd_cli_state *state);
static void winbindd_setup_max_fds(void);
+static void request_ok(struct winbindd_cli_state *state);
static bool opt_nocache = False;
static bool interactive = False;
@@ -864,7 +865,7 @@ void request_error(struct winbindd_cli_state *state)
request_finished(state);
}
-void request_ok(struct winbindd_cli_state *state)
+static void request_ok(struct winbindd_cli_state *state)
{
SMB_ASSERT(state->response->result == WINBINDD_PENDING);
state->response->result = WINBINDD_OK;
diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h
index 3b5423e48e2..0bc99fc3bbc 100644
--- a/source3/winbindd/winbindd_proto.h
+++ b/source3/winbindd/winbindd_proto.h
@@ -26,7 +26,6 @@
/* The following definitions come from winbindd/winbindd.c */
struct imessaging_context *winbind_imessaging_context(void);
void request_error(struct winbindd_cli_state *state);
-void request_ok(struct winbindd_cli_state *state);
bool winbindd_setup_sig_term_handler(bool parent);
bool winbindd_setup_stdin_handler(bool parent, bool foreground);
bool winbindd_setup_sig_hup_handler(const char *lfile);
--
2.11.0
From 1c1b95d4659da406e6a46ed84508c9a9697d52c3 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 2 May 2018 21:23:49 +0200
Subject: [PATCH 15/16] winbindd: Make "request_error()" static to winbindd.c
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
---
source3/winbindd/winbindd.c | 3 ++-
source3/winbindd/winbindd_proto.h | 1 -
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index d38d1d4fd02..34607ca653e 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -55,6 +55,7 @@ static bool client_is_idle(struct winbindd_cli_state *state);
static void remove_client(struct winbindd_cli_state *state);
static void winbindd_setup_max_fds(void);
static void request_ok(struct winbindd_cli_state *state);
+static void request_error(struct winbindd_cli_state *state);
static bool opt_nocache = False;
static bool interactive = False;
@@ -858,7 +859,7 @@ static void winbind_client_response_written(struct tevent_req *req)
state->io_req = req;
}
-void request_error(struct winbindd_cli_state *state)
+static void request_error(struct winbindd_cli_state *state)
{
SMB_ASSERT(state->response->result == WINBINDD_PENDING);
state->response->result = WINBINDD_ERROR;
diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h
index 0bc99fc3bbc..58ec3e2eaa6 100644
--- a/source3/winbindd/winbindd_proto.h
+++ b/source3/winbindd/winbindd_proto.h
@@ -25,7 +25,6 @@
/* The following definitions come from winbindd/winbindd.c */
struct imessaging_context *winbind_imessaging_context(void);
-void request_error(struct winbindd_cli_state *state);
bool winbindd_setup_sig_term_handler(bool parent);
bool winbindd_setup_stdin_handler(bool parent, bool foreground);
bool winbindd_setup_sig_hup_handler(const char *lfile);
--
2.11.0
From b509db65bf773d710e5dc5fba8407d11a58314c5 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Wed, 2 May 2018 21:19:08 +0200
Subject: [PATCH 16/16] winbindd: Remove an unused function prototype
This has been moved to async in 2009
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
---
source3/winbindd/winbindd_proto.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h
index 58ec3e2eaa6..1c8cfc3889c 100644
--- a/source3/winbindd/winbindd_proto.h
+++ b/source3/winbindd/winbindd_proto.h
@@ -382,7 +382,6 @@ struct dcerpc_binding_handle *locator_child_handle(void);
bool winbindd_list_trusted_domains(struct winbindd_cli_state *state);
enum winbindd_result winbindd_dual_list_trusted_domains(struct winbindd_domain *domain,
struct winbindd_cli_state *state);
-void winbindd_show_sequence(struct winbindd_cli_state *state);
bool winbindd_dc_info(struct winbindd_cli_state *state);
bool winbindd_ping(struct winbindd_cli_state *state);
bool winbindd_info(struct winbindd_cli_state *state);
--
2.11.0
More information about the samba-technical
mailing list