summaryrefslogtreecommitdiff
path: root/source3/nsswitch
diff options
context:
space:
mode:
Diffstat (limited to 'source3/nsswitch')
-rw-r--r--source3/nsswitch/winbindd.c13
-rw-r--r--source3/nsswitch/winbindd_cache.c2
-rw-r--r--source3/nsswitch/winbindd_cm.c129
-rw-r--r--source3/nsswitch/winbindd_idmap.c4
-rw-r--r--source3/nsswitch/winbindd_proto.h5
5 files changed, 122 insertions, 31 deletions
diff --git a/source3/nsswitch/winbindd.c b/source3/nsswitch/winbindd.c
index 5231c840ba..b37fdb1a4f 100644
--- a/source3/nsswitch/winbindd.c
+++ b/source3/nsswitch/winbindd.c
@@ -55,17 +55,17 @@ static BOOL reload_services_file(BOOL test)
return(ret);
}
-static void winbindd_dump_status(void)
+static void winbindd_status(void)
{
struct winbindd_cli_state *tmp;
- DEBUG(0, ("Global status for winbindd:\n"));
+ DEBUG(0, ("winbindd status:\n"));
/* Print client state information */
DEBUG(0, ("\t%d clients currently active\n", num_clients));
- if (DEBUGLEVEL >= 2) {
+ if (DEBUGLEVEL >= 2 && num_clients) {
DEBUG(2, ("\tclient list:\n"));
for(tmp = client_list; tmp; tmp = tmp->next) {
DEBUG(2, ("\t\tpid %d, sock %d, rbl %d, wbl %d\n",
@@ -79,9 +79,10 @@ static void winbindd_dump_status(void)
static void do_print_winbindd_status(void)
{
- winbindd_dump_status();
- winbindd_idmap_dump_status();
- winbindd_cache_dump_status();
+ winbindd_status();
+ winbindd_idmap_status();
+ winbindd_cache_status();
+ winbindd_cm_status();
}
/* Flush client cache */
diff --git a/source3/nsswitch/winbindd_cache.c b/source3/nsswitch/winbindd_cache.c
index 1dc9f06050..00e1905d76 100644
--- a/source3/nsswitch/winbindd_cache.c
+++ b/source3/nsswitch/winbindd_cache.c
@@ -572,6 +572,6 @@ void winbindd_flush_cache(void)
/* Print cache status information */
-void winbindd_cache_dump_status(void)
+void winbindd_cache_status(void)
{
}
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"));
+
+}
diff --git a/source3/nsswitch/winbindd_idmap.c b/source3/nsswitch/winbindd_idmap.c
index 8925e947b9..a96111a608 100644
--- a/source3/nsswitch/winbindd_idmap.c
+++ b/source3/nsswitch/winbindd_idmap.c
@@ -251,11 +251,11 @@ BOOL winbindd_idmap_init(void)
#define DUMP_INFO 0
-void winbindd_idmap_dump_status(void)
+void winbindd_idmap_status(void)
{
int user_hwm, group_hwm;
- DEBUG(0, ("Status for winbindd idmap:\n"));
+ DEBUG(0, ("winbindd idmap status:\n"));
/* Get current high water marks */
diff --git a/source3/nsswitch/winbindd_proto.h b/source3/nsswitch/winbindd_proto.h
index 682bf81a54..fbce00989a 100644
--- a/source3/nsswitch/winbindd_proto.h
+++ b/source3/nsswitch/winbindd_proto.h
@@ -43,7 +43,7 @@ BOOL winbindd_fetch_gid_cache_entry(struct winbindd_domain *domain, gid_t gid,
struct winbindd_gr *gr,
void **extra_data, int *extra_data_len);
void winbindd_flush_cache(void);
-void winbindd_cache_dump_status(void);
+void winbindd_cache_status(void);
/* The following definitions come from nsswitch/winbindd_cm.c */
@@ -56,6 +56,7 @@ CLI_POLICY_HND *cm_get_sam_user_handle(char *domain, DOM_SID *domain_sid,
CLI_POLICY_HND *cm_get_sam_group_handle(char *domain, DOM_SID *domain_sid,
uint32 group_rid);
struct cli_state *cm_get_netlogon_cli(char *domain, unsigned char *trust_passwd);
+void winbindd_cm_status(void);
/* The following definitions come from nsswitch/winbindd_group.c */
@@ -82,7 +83,7 @@ BOOL winbindd_idmap_get_rid_from_uid(uid_t uid, uint32 *user_rid,
BOOL winbindd_idmap_get_rid_from_gid(gid_t gid, uint32 *group_rid,
struct winbindd_domain **domain);
BOOL winbindd_idmap_init(void);
-void winbindd_idmap_dump_status(void);
+void winbindd_idmap_status(void);
/* The following definitions come from nsswitch/winbindd_misc.c */