summaryrefslogtreecommitdiff
path: root/source3/nsswitch
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2006-05-04 12:37:13 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:16:43 -0500
commita0ff50efa79f08f538f0c341744572929ac5a298 (patch)
tree607c451d8cacff98a67b9b10c93b89db9483f702 /source3/nsswitch
parentd2418fbf276121eae08f05cbf3d6b3c84eb09887 (diff)
downloadsamba-a0ff50efa79f08f538f0c341744572929ac5a298.tar.gz
samba-a0ff50efa79f08f538f0c341744572929ac5a298.tar.bz2
samba-a0ff50efa79f08f538f0c341744572929ac5a298.zip
r15428: Add "smbcontrol winbind onlinestatus" for debugging purpose.
Guenther (This used to be commit 9e15b1659c105b0be846e8f71c27b20eab961bd2)
Diffstat (limited to 'source3/nsswitch')
-rw-r--r--source3/nsswitch/winbindd.c1
-rw-r--r--source3/nsswitch/winbindd_cache.c5
-rw-r--r--source3/nsswitch/winbindd_dual.c76
3 files changed, 82 insertions, 0 deletions
diff --git a/source3/nsswitch/winbindd.c b/source3/nsswitch/winbindd.c
index e6c69247f8..06b8b93543 100644
--- a/source3/nsswitch/winbindd.c
+++ b/source3/nsswitch/winbindd.c
@@ -1035,6 +1035,7 @@ int main(int argc, char **argv)
/* Handle online/offline messages. */
message_register(MSG_WINBIND_OFFLINE,winbind_msg_offline);
message_register(MSG_WINBIND_ONLINE,winbind_msg_online);
+ message_register(MSG_WINBIND_ONLINESTATUS,winbind_msg_onlinestatus);
poptFreeContext(pc);
diff --git a/source3/nsswitch/winbindd_cache.c b/source3/nsswitch/winbindd_cache.c
index bf76c7f251..6541e10877 100644
--- a/source3/nsswitch/winbindd_cache.c
+++ b/source3/nsswitch/winbindd_cache.c
@@ -2357,6 +2357,11 @@ void set_global_winbindd_state_online(void)
tdb_delete_bystring(wcache->tdb, "WINBINDD_OFFLINE");
}
+BOOL get_global_winbindd_state_online(void)
+{
+ return global_winbindd_offline_state;
+}
+
/* the cache backend methods are exposed via this structure */
struct winbindd_methods cache_methods = {
True,
diff --git a/source3/nsswitch/winbindd_dual.c b/source3/nsswitch/winbindd_dual.c
index c5d24f98c1..05b73a9ddc 100644
--- a/source3/nsswitch/winbindd_dual.c
+++ b/source3/nsswitch/winbindd_dual.c
@@ -496,6 +496,26 @@ void winbind_msg_online(int msg_type, struct process_id src, void *buf, size_t l
}
}
+/* Forward the online/offline messages to our children. */
+void winbind_msg_onlinestatus(int msg_type, struct process_id src, void *buf, size_t len)
+{
+ struct winbindd_child *child;
+
+ DEBUG(10,("winbind_msg_onlinestatus: got onlinestatus message.\n"));
+
+ for (child = children; child != NULL; child = child->next) {
+ if (child->domain && child->domain->primary) {
+ DEBUG(10,("winbind_msg_onlinestatus: "
+ "sending message to pid %u of primary domain.\n",
+ (unsigned int)child->pid));
+ message_send_pid(pid_to_procid(child->pid),
+ MSG_WINBIND_ONLINESTATUS, buf, len, False);
+ break;
+ }
+ }
+}
+
+
static void account_lockout_policy_handler(struct timed_event *te,
const struct timeval *now,
void *private_data)
@@ -582,6 +602,60 @@ static void child_msg_online(int msg_type, struct process_id src, void *buf, siz
}
}
+static const char *collect_onlinestatus(TALLOC_CTX *mem_ctx)
+{
+ struct winbindd_domain *domain;
+ char *buf = NULL;
+
+ if ((buf = talloc_asprintf(mem_ctx, "global:%s ",
+ get_global_winbindd_state_online() ?
+ "Offline":"Online")) == NULL) {
+ return NULL;
+ }
+
+ for (domain = domain_list(); domain; domain = domain->next) {
+ if ((buf = talloc_asprintf_append(buf, "%s:%s ",
+ domain->name,
+ domain->online ?
+ "Online":"Offline")) == NULL) {
+ return NULL;
+ }
+ }
+
+ buf = talloc_asprintf_append(buf, "\n");
+
+ DEBUG(5,("collect_onlinestatus: %s\n", buf));
+
+ return buf;
+}
+
+static void child_msg_onlinestatus(int msg_type, struct process_id src, void *buf, size_t len)
+{
+ TALLOC_CTX *mem_ctx;
+ const char *message;
+ struct process_id *sender;
+
+ DEBUG(5,("winbind_msg_onlinestatus received.\n"));
+
+ if (!buf) {
+ return;
+ }
+
+ sender = (struct process_id *)buf;
+
+ mem_ctx = talloc_init("winbind_msg_onlinestatus");
+ if (mem_ctx == NULL) {
+ return;
+ }
+
+ message = collect_onlinestatus(mem_ctx);
+
+ message_send_pid(*sender, MSG_WINBIND_ONLINESTATUS,
+ message, strlen(message) + 1, True);
+
+ talloc_destroy(mem_ctx);
+}
+
static BOOL fork_domain_child(struct winbindd_child *child)
{
int fdpair[2];
@@ -646,6 +720,7 @@ static BOOL fork_domain_child(struct winbindd_child *child)
message_deregister(MSG_SHUTDOWN);
message_deregister(MSG_WINBIND_OFFLINE);
message_deregister(MSG_WINBIND_ONLINE);
+ message_deregister(MSG_WINBIND_ONLINESTATUS);
/* The child is ok with online/offline messages now. */
message_unblock();
@@ -667,6 +742,7 @@ static BOOL fork_domain_child(struct winbindd_child *child)
/* Handle online/offline messages. */
message_register(MSG_WINBIND_OFFLINE,child_msg_offline);
message_register(MSG_WINBIND_ONLINE,child_msg_online);
+ message_register(MSG_WINBIND_ONLINESTATUS,child_msg_onlinestatus);
while (1) {