summaryrefslogtreecommitdiff
path: root/source3/nsswitch/winbindd_cm.c
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2001-11-14 06:18:13 +0000
committerTim Potter <tpot@samba.org>2001-11-14 06:18:13 +0000
commitb7f6113c2dcadef6a9cc123ce719171523f54d23 (patch)
treee137ba266488c261815cb846aebf08206e8b2a93 /source3/nsswitch/winbindd_cm.c
parent68893d4a2faa04f8b0b90dfc03466e1105d087a7 (diff)
downloadsamba-b7f6113c2dcadef6a9cc123ce719171523f54d23.tar.gz
samba-b7f6113c2dcadef6a9cc123ce719171523f54d23.tar.bz2
samba-b7f6113c2dcadef6a9cc123ce719171523f54d23.zip
Random connection robustness related fixes. Display some debugs about
the currently open connections when winbindd receives a USR1 signal. Hmm - I've just realised this will conflict with the messaging code but we don't use that yet. (This used to be commit caef54e40081477609a824185949ddf6db6ba363)
Diffstat (limited to 'source3/nsswitch/winbindd_cm.c')
-rw-r--r--source3/nsswitch/winbindd_cm.c129
1 files changed, 109 insertions, 20 deletions
diff --git a/source3/nsswitch/winbindd_cm.c b/source3/nsswitch/winbindd_cm.c
index c41ed5ac62..a94476a0bc 100644
--- a/source3/nsswitch/winbindd_cm.c
+++ b/source3/nsswitch/winbindd_cm.c
@@ -74,6 +74,36 @@ enum sam_pipe_type {
SAM_PIPE_GROUP /* A handle on a group */
};
+/* Return a string description of a SAM pipe type */
+
+static char *pipe_type(enum sam_pipe_type pt)
+{
+ char *msg;
+
+ switch (pt) {
+ case SAM_PIPE_BASIC:
+ msg = "BASIC";
+ break;
+ case SAM_PIPE_DOM:
+ msg = "DOMAIN";
+ break;
+ case SAM_PIPE_USER:
+ msg = "USER";
+ break;
+ case SAM_PIPE_GROUP:
+ msg = "GROUP";
+ break;
+ default:
+ msg = "??";
+ break;
+ }
+
+ return msg;
+}
+
+/* Global list of connections. Initially a DLIST but can become a hash
+ table or whatever later. */
+
struct winbindd_cm_conn {
struct winbindd_cm_conn *prev, *next;
fstring domain;
@@ -82,15 +112,16 @@ struct winbindd_cm_conn {
struct cli_state *cli;
POLICY_HND pol;
- /* Specific pipe stuff - move into a union? */
+ /* Pipe-specific properties for this instance */
- enum sam_pipe_type sam_pipe_type; /* Domain, user, group etc */
- uint32 user_rid, group_rid;
+ union {
+ struct {
+ enum sam_pipe_type pipe_type;
+ uint32 rid;
+ } samr;
+ } pipe_data;
};
-/* Global list of connections. Initially a DLIST but can become a hash
- table or whatever later. */
-
struct winbindd_cm_conn *cm_conns = NULL;
/* Get a domain controller name */
@@ -260,7 +291,7 @@ CLI_POLICY_HND *cm_get_sam_handle(char *domain)
for (conn = cm_conns; conn; conn = conn->next) {
if (strequal(conn->domain, domain) &&
strequal(conn->pipe_name, PIPE_SAMR) &&
- conn->sam_pipe_type == SAM_PIPE_BASIC) {
+ conn->pipe_data.samr.pipe_type == SAM_PIPE_BASIC) {
if (!connection_ok(conn))
return NULL;
@@ -314,7 +345,7 @@ CLI_POLICY_HND *cm_get_sam_dom_handle(char *domain, DOM_SID *domain_sid)
for (conn = cm_conns; conn; conn = conn->next) {
if (strequal(conn->domain, domain) &&
strequal(conn->pipe_name, PIPE_SAMR) &&
- conn->sam_pipe_type == SAM_PIPE_DOM) {
+ conn->pipe_data.samr.pipe_type == SAM_PIPE_DOM) {
if (!connection_ok(conn))
return NULL;
@@ -331,7 +362,7 @@ CLI_POLICY_HND *cm_get_sam_dom_handle(char *domain, DOM_SID *domain_sid)
for (conn = cm_conns; conn; conn = conn->next) {
if (strequal(conn->domain, domain) &&
strequal(conn->pipe_name, PIPE_SAMR) &&
- conn->sam_pipe_type == SAM_PIPE_BASIC)
+ conn->pipe_data.samr.pipe_type == SAM_PIPE_BASIC)
basic_conn = conn;
}
@@ -345,7 +376,7 @@ CLI_POLICY_HND *cm_get_sam_dom_handle(char *domain, DOM_SID *domain_sid)
fstrcpy(conn->controller, basic_conn->controller);
fstrcpy(conn->pipe_name, basic_conn->pipe_name);
- conn->sam_pipe_type = SAM_PIPE_DOM;
+ conn->pipe_data.samr.pipe_type = SAM_PIPE_DOM;
conn->cli = basic_conn->cli;
result = cli_samr_open_domain(conn->cli, conn->cli->mem_ctx,
@@ -381,8 +412,8 @@ CLI_POLICY_HND *cm_get_sam_user_handle(char *domain, DOM_SID *domain_sid,
for (conn = cm_conns; conn; conn = conn->next) {
if (strequal(conn->domain, domain) &&
strequal(conn->pipe_name, PIPE_SAMR) &&
- conn->sam_pipe_type == SAM_PIPE_USER &&
- conn->user_rid == user_rid) {
+ conn->pipe_data.samr.pipe_type == SAM_PIPE_USER &&
+ conn->pipe_data.samr.rid == user_rid) {
if (!connection_ok(conn))
return NULL;
@@ -399,7 +430,7 @@ CLI_POLICY_HND *cm_get_sam_user_handle(char *domain, DOM_SID *domain_sid,
for (conn = cm_conns; conn; conn = conn->next) {
if (strequal(conn->domain, domain) &&
strequal(conn->pipe_name, PIPE_SAMR) &&
- conn->sam_pipe_type == SAM_PIPE_DOM)
+ conn->pipe_data.samr.pipe_type == SAM_PIPE_DOM)
basic_conn = conn;
}
@@ -418,9 +449,9 @@ CLI_POLICY_HND *cm_get_sam_user_handle(char *domain, DOM_SID *domain_sid,
fstrcpy(conn->controller, basic_conn->controller);
fstrcpy(conn->pipe_name, basic_conn->pipe_name);
- conn->sam_pipe_type = SAM_PIPE_USER;
+ conn->pipe_data.samr.pipe_type = SAM_PIPE_USER;
conn->cli = basic_conn->cli;
- conn->user_rid = user_rid;
+ conn->pipe_data.samr.rid = user_rid;
result = cli_samr_open_user(conn->cli, conn->cli->mem_ctx,
&basic_conn->pol, des_access, user_rid,
@@ -455,8 +486,8 @@ CLI_POLICY_HND *cm_get_sam_group_handle(char *domain, DOM_SID *domain_sid,
for (conn = cm_conns; conn; conn = conn->next) {
if (strequal(conn->domain, domain) &&
strequal(conn->pipe_name, PIPE_SAMR) &&
- conn->sam_pipe_type == SAM_PIPE_GROUP &&
- conn->group_rid == group_rid) {
+ conn->pipe_data.samr.pipe_type == SAM_PIPE_GROUP &&
+ conn->pipe_data.samr.rid == group_rid) {
if (!connection_ok(conn))
return NULL;
@@ -473,7 +504,7 @@ CLI_POLICY_HND *cm_get_sam_group_handle(char *domain, DOM_SID *domain_sid,
for (conn = cm_conns; conn; conn = conn->next) {
if (strequal(conn->domain, domain) &&
strequal(conn->pipe_name, PIPE_SAMR) &&
- conn->sam_pipe_type == SAM_PIPE_DOM)
+ conn->pipe_data.samr.pipe_type == SAM_PIPE_DOM)
basic_conn = conn;
}
@@ -492,9 +523,9 @@ CLI_POLICY_HND *cm_get_sam_group_handle(char *domain, DOM_SID *domain_sid,
fstrcpy(conn->controller, basic_conn->controller);
fstrcpy(conn->pipe_name, basic_conn->pipe_name);
- conn->sam_pipe_type = SAM_PIPE_GROUP;
+ conn->pipe_data.samr.pipe_type = SAM_PIPE_GROUP;
conn->cli = basic_conn->cli;
- conn->group_rid = group_rid;
+ conn->pipe_data.samr.rid = group_rid;
result = cli_samr_open_group(conn->cli, conn->cli->mem_ctx,
&basic_conn->pol, des_access, group_rid,
@@ -543,3 +574,61 @@ struct cli_state *cm_get_netlogon_cli(char *domain, unsigned char *trust_passwd)
return conn.cli;
}
+
+/* Dump the current connection status */
+
+static void dump_conn_list(void)
+{
+ struct winbindd_cm_conn *con;
+
+ DEBUG(0, ("\tDomain Controller Pipe\n"));
+
+ for(con = cm_conns; con; con = con->next) {
+ char *msg;
+
+ /* Display pipe info */
+
+ asprintf(&msg, "\t%-15s %-15s %-16s", con->domain,
+ con->controller, con->pipe_name);
+
+ /* Display sam specific info */
+
+ if (strequal(con->pipe_name, PIPE_SAMR)) {
+ char *msg2;
+
+ asprintf(&msg2, "%s %-7s", msg,
+ pipe_type(con->pipe_data.samr.pipe_type));
+
+ free(msg);
+ msg = msg2;
+ }
+
+ if (strequal(con->pipe_name, PIPE_SAMR) &&
+ (con->pipe_data.samr.pipe_type == SAM_PIPE_USER ||
+ con->pipe_data.samr.pipe_type == SAM_PIPE_GROUP)) {
+ char *msg2;
+
+ asprintf(&msg2, "%s %4xh", msg,
+ con->pipe_data.samr.rid);
+
+ free(msg);
+ msg = msg2;
+ }
+
+ DEBUG(0, ("%s\n", msg));
+ free(msg);
+ }
+}
+
+void winbindd_cm_status(void)
+{
+ /* List open connections */
+
+ DEBUG(0, ("winbindd connection manager status:\n"));
+
+ if (cm_conns)
+ dump_conn_list();
+ else
+ DEBUG(0, ("\tNo active connections\n"));
+
+}