The branch, v3-2-test has been updated
       via  54ad97bd8364c393de2c9471a4c14ca5b880b318 (commit)
       via  4389e4dadbf07c176d9102b74c06e62ecfc242be (commit)
       via  10fa43f2840899c0854763e55b9174827c522a5b (commit)
      from  37b95450518419e2153e9930b63f894b68096d3d (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test


- Log -----------------------------------------------------------------
commit 54ad97bd8364c393de2c9471a4c14ca5b880b318
Author: Günther Deschner <[EMAIL PROTECTED]>
Date:   Thu Jan 24 16:19:58 2008 +0100

    Add winbind_msg_dump_domain_list to winbindd.
    
    Guenther

commit 4389e4dadbf07c176d9102b74c06e62ecfc242be
Author: Günther Deschner <[EMAIL PROTECTED]>
Date:   Thu Jan 24 16:10:18 2008 +0100

    Add winbindd debugging ndr_print helpers.
    
    Guenther

commit 10fa43f2840899c0854763e55b9174827c522a5b
Author: Günther Deschner <[EMAIL PROTECTED]>
Date:   Thu Jan 24 16:09:20 2008 +0100

    Add dump-domain-list command for debugging winbindd's domain_list.
    
    Guenther

-----------------------------------------------------------------------

Summary of changes:
 source/Makefile.in              |    1 +
 source/include/messages.h       |    1 +
 source/utils/smbcontrol.c       |   57 +++++++++++++++
 source/winbindd/winbindd.c      |    4 +
 source/winbindd/winbindd_dual.c |   84 ++++++++++++++++++++++
 source/winbindd/winbindd_ndr.c  |  149 +++++++++++++++++++++++++++++++++++++++
 6 files changed, 296 insertions(+), 0 deletions(-)
 create mode 100644 source/winbindd/winbindd_ndr.c


Changeset truncated at 500 lines:

diff --git a/source/Makefile.in b/source/Makefile.in
index 5b408a5..4de96a8 100644
--- a/source/Makefile.in
+++ b/source/Makefile.in
@@ -944,6 +944,7 @@ WINBINDD_OBJ1 = \
                winbindd/winbindd_domain.o \
                winbindd/winbindd_idmap.o \
                winbindd/winbindd_locator.o \
+               winbindd/winbindd_ndr.o \
                auth/token_util.o
 
 WINBINDD_OBJ = \
diff --git a/source/include/messages.h b/source/include/messages.h
index 8de41ca..c97ad98 100644
--- a/source/include/messages.h
+++ b/source/include/messages.h
@@ -97,6 +97,7 @@
 #define MSG_WINBIND_TRY_TO_GO_ONLINE   0x0406
 #define MSG_WINBIND_FAILED_TO_GO_ONLINE 0x0407
 #define MSG_WINBIND_VALIDATE_CACHE     0x0408
+#define MSG_WINBIND_DUMP_DOMAIN_LIST   0x0409
 
 /* event messages */
 #define MSG_DUMP_EVENT_LIST            0x0500
diff --git a/source/utils/smbcontrol.c b/source/utils/smbcontrol.c
index fe0c229..76036bf 100644
--- a/source/utils/smbcontrol.c
+++ b/source/utils/smbcontrol.c
@@ -1008,6 +1008,62 @@ static bool do_dump_event_list(struct messaging_context 
*msg_ctx,
        return send_message(msg_ctx, pid, MSG_DUMP_EVENT_LIST, NULL, 0);
 }
 
+static bool do_winbind_dump_domain_list(struct messaging_context *msg_ctx,
+                                       const struct server_id pid,
+                                       const int argc, const char **argv)
+{
+       const char *domain = NULL;
+       int domain_len = 0;
+       struct server_id myid;
+       uint8_t *buf = NULL;
+       int buf_len = 0;
+
+       myid = pid_to_procid(sys_getpid());
+
+       if (argc < 1 || argc > 2) {
+               fprintf(stderr, "Usage: smbcontrol <dest> dump_domain_list "
+                       "<domain>\n");
+               return false;
+       }
+
+       if (argc == 2) {
+               domain = argv[1];
+               domain_len = strlen(argv[1]) + 1;
+       }
+
+       messaging_register(msg_ctx, NULL, MSG_WINBIND_DUMP_DOMAIN_LIST,
+                          print_pid_string_cb);
+
+       buf_len = sizeof(myid)+domain_len;
+       buf = SMB_MALLOC(buf_len);
+       if (!buf) {
+               return false;
+       }
+
+       memcpy(buf, &myid, sizeof(myid));
+       memcpy(&buf[sizeof(myid)], domain, domain_len);
+
+       if (!send_message(msg_ctx, pid, MSG_WINBIND_DUMP_DOMAIN_LIST,
+                         buf, buf_len))
+       {
+               SAFE_FREE(buf);
+               return false;
+       }
+
+       wait_replies(msg_ctx, procid_to_pid(&pid) == 0);
+
+       /* No replies were received within the timeout period */
+
+       SAFE_FREE(buf);
+       if (num_replies == 0) {
+               printf("No replies received\n");
+       }
+
+       messaging_deregister(msg_ctx, MSG_WINBIND_DUMP_DOMAIN_LIST, NULL);
+
+       return num_replies;
+}
+
 static void winbind_validate_cache_cb(struct messaging_context *msg,
                                      void *private_data,
                                      uint32_t msg_type,
@@ -1150,6 +1206,7 @@ static const struct {
        { "dump-event-list", do_dump_event_list, "Dump event list"},
        { "validate-cache" , do_winbind_validate_cache,
          "Validate winbind's credential cache" },
+       { "dump-domain-list", do_winbind_dump_domain_list, "Dump winbind domain 
list"},
        { "noop", do_noop, "Do nothing" },
        { NULL }
 };
diff --git a/source/winbindd/winbindd.c b/source/winbindd/winbindd.c
index 5e9900d..615f4a9 100644
--- a/source/winbindd/winbindd.c
+++ b/source/winbindd/winbindd.c
@@ -1227,6 +1227,10 @@ int main(int argc, char **argv, char **envp)
                           MSG_WINBIND_VALIDATE_CACHE,
                           winbind_msg_validate_cache);
 
+       messaging_register(winbind_messaging_context(), NULL,
+                          MSG_WINBIND_DUMP_DOMAIN_LIST,
+                          winbind_msg_dump_domain_list);
+
        netsamlogon_cache_init(); /* Non-critical */
        
        /* clear the cached list of trusted domains */
diff --git a/source/winbindd/winbindd_dual.c b/source/winbindd/winbindd_dual.c
index e215246..a9786d1 100644
--- a/source/winbindd/winbindd_dual.c
+++ b/source/winbindd/winbindd_dual.c
@@ -676,6 +676,88 @@ void winbind_msg_dump_event_list(struct messaging_context 
*msg_ctx,
 
 }
 
+void winbind_msg_dump_domain_list(struct messaging_context *msg_ctx,
+                                 void *private_data,
+                                 uint32_t msg_type,
+                                 struct server_id server_id,
+                                 DATA_BLOB *data)
+{
+       TALLOC_CTX *mem_ctx;
+       const char *message = NULL;
+       struct server_id *sender = NULL;
+       const char *domain = NULL;
+       char *s = NULL;
+       NTSTATUS status;
+       struct winbindd_domain *dom = NULL;
+
+       DEBUG(5,("winbind_msg_dump_domain_list received.\n"));
+
+       if (!data || !data->data) {
+               return;
+       }
+
+       if (data->length < sizeof(struct server_id)) {
+               return;
+       }
+
+       mem_ctx = talloc_init("winbind_msg_dump_domain_list");
+       if (!mem_ctx) {
+               return;
+       }
+
+       sender = (struct server_id *)data->data;
+       if (data->length > sizeof(struct server_id)) {
+               domain = (const char *)data->data+sizeof(struct server_id);
+       }
+
+       if (domain) {
+
+               DEBUG(5,("winbind_msg_dump_domain_list for domain: %s\n",
+                       domain));
+
+               message = NDR_PRINT_STRUCT_STRING(mem_ctx, winbindd_domain,
+                                                 
find_domain_from_name_noinit(domain));
+               if (!message) {
+                       talloc_destroy(mem_ctx);
+                       return;
+               }
+
+               messaging_send_buf(msg_ctx, *sender,
+                                  MSG_WINBIND_DUMP_DOMAIN_LIST,
+                                  (uint8_t *)message, strlen(message) + 1);
+
+               talloc_destroy(mem_ctx);
+
+               return;
+       }
+
+       DEBUG(5,("winbind_msg_dump_domain_list all domains\n"));
+
+       for (dom = domain_list(); dom; dom=dom->next) {
+               message = NDR_PRINT_STRUCT_STRING(mem_ctx, winbindd_domain, 
dom);
+               if (!message) {
+                       talloc_destroy(mem_ctx);
+                       return;
+               }
+
+               s = talloc_asprintf_append(s, "%s\n", message);
+               if (!s) {
+                       talloc_destroy(mem_ctx);
+                       return;
+               }
+       }
+
+       status = messaging_send_buf(msg_ctx, *sender,
+                                   MSG_WINBIND_DUMP_DOMAIN_LIST,
+                                   (uint8_t *)s, strlen(s) + 1);
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(0,("failed to send message: %s\n",
+               nt_errstr(status)));
+       }
+
+       talloc_destroy(mem_ctx);
+}
+
 static void account_lockout_policy_handler(struct event_context *ctx,
                                           struct timed_event *te,
                                           const struct timeval *now,
@@ -946,6 +1028,8 @@ static bool fork_domain_child(struct winbindd_child *child)
                             MSG_WINBIND_ONLINESTATUS, NULL);
        messaging_deregister(winbind_messaging_context(),
                             MSG_DUMP_EVENT_LIST, NULL);
+       messaging_deregister(winbind_messaging_context(),
+                            MSG_WINBIND_DUMP_DOMAIN_LIST, NULL);
 
        /* Handle online/offline messages. */
        messaging_register(winbind_messaging_context(), NULL,
diff --git a/source/winbindd/winbindd_ndr.c b/source/winbindd/winbindd_ndr.c
new file mode 100644
index 0000000..145d119
--- /dev/null
+++ b/source/winbindd/winbindd_ndr.c
@@ -0,0 +1,149 @@
+/*
+ *  Unix SMB/CIFS implementation.
+ *  winbindd debug helper
+ *  Copyright (C) Guenther Deschner 2008
+ *
+ *  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"
+
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_WINBIND
+
+/****************************************************************
+****************************************************************/
+
+void ndr_print_winbindd_child(struct ndr_print *ndr,
+                             const char *name,
+                             const struct winbindd_child *r)
+{
+       ndr_print_struct(ndr, name, "winbindd_child");
+       ndr->depth++;
+       ndr_print_ptr(ndr, "next", r->next);
+       ndr_print_ptr(ndr, "prev", r->prev);
+       ndr_print_uint32(ndr, "pid", (uint32_t)r->pid);
+#if 0
+       ndr_print_winbindd_domain(ndr, "domain", r->domain);
+#else
+       ndr_print_ptr(ndr, "domain", r->domain);
+#endif
+       ndr_print_string(ndr, "logfilename", r->logfilename);
+       /* struct fd_event event; */
+       ndr_print_ptr(ndr, "lockout_policy_event", r->lockout_policy_event);
+       ndr_print_ptr(ndr, "requests", r->requests);
+       ndr_print_ptr(ndr, "table", r->table);
+       ndr->depth--;
+}
+
+/****************************************************************
+****************************************************************/
+
+void ndr_print_winbindd_cm_conn(struct ndr_print *ndr,
+                               const char *name,
+                               const struct winbindd_cm_conn *r)
+{
+       ndr_print_struct(ndr, name, "winbindd_cm_conn");
+       ndr->depth++;
+       ndr_print_ptr(ndr, "cli", r->cli);
+       ndr_print_ptr(ndr, "samr_pipe", r->samr_pipe);
+       ndr_print_policy_handle(ndr, "sam_connect_handle", 
&r->sam_connect_handle);
+       ndr_print_policy_handle(ndr, "sam_domain_handle", 
&r->sam_domain_handle);
+       ndr_print_ptr(ndr, "lsa_pipe", r->lsa_pipe);
+       ndr_print_policy_handle(ndr, "lsa_policy", &r->lsa_policy);
+       ndr_print_ptr(ndr, "netlogon_pipe", r->netlogon_pipe);
+       ndr->depth--;
+}
+
+/****************************************************************
+****************************************************************/
+
+void ndr_print_winbindd_methods(struct ndr_print *ndr,
+                               const char *name,
+                               const struct winbindd_methods *r)
+{
+       extern struct winbindd_methods ads_methods;
+       extern struct winbindd_methods msrpc_methods;
+       extern struct winbindd_methods passdb_methods;
+       extern struct winbindd_methods reconnect_methods;
+       extern struct winbindd_methods cache_methods;
+
+       ndr_print_struct(ndr, name, "winbindd_methods");
+       ndr->depth++;
+
+       if (r == NULL) {
+               ndr_print_string(ndr, name, "(NULL)");
+               ndr->depth--;
+               return;
+       }
+
+       if (r == &ads_methods) {
+               ndr_print_string(ndr, name, "ads_methods");
+       } else if (r == &msrpc_methods) {
+               ndr_print_string(ndr, name, "msrpc_methods");
+       } else if (r == &passdb_methods) {
+               ndr_print_string(ndr, name, "passdb_methods");
+       } else if (r == &reconnect_methods) {
+               ndr_print_string(ndr, name, "reconnect_methods");
+       } else if (r == &cache_methods) {
+               ndr_print_string(ndr, name, "cache_methods");
+       } else {
+               ndr_print_string(ndr, name, "UNKNOWN");
+       }
+       ndr->depth--;
+}
+
+/****************************************************************
+****************************************************************/
+
+void ndr_print_winbindd_domain(struct ndr_print *ndr,
+                              const char *name,
+                              const struct winbindd_domain *r)
+{
+       if (!r) {
+               return;
+       }
+
+       ndr_print_struct(ndr, name, "winbindd_domain");
+       ndr->depth++;
+       ndr_print_string(ndr, "name", r->name);
+       ndr_print_string(ndr, "alt_name", r->alt_name);
+       ndr_print_string(ndr, "forest_name", r->forest_name);
+       ndr_print_dom_sid(ndr, "sid", &r->sid);
+       ndr_print_netr_TrustFlags(ndr, "domain_flags", r->domain_flags);
+       ndr_print_netr_TrustType(ndr, "domain_type", r->domain_type);
+       ndr_print_netr_TrustAttributes(ndr, "domain_trust_attribs", 
r->domain_trust_attribs);
+       ndr_print_bool(ndr, "initialized", r->initialized);
+       ndr_print_bool(ndr, "native_mode", r->native_mode);
+       ndr_print_bool(ndr, "active_directory", r->active_directory);
+       ndr_print_bool(ndr, "primary", r->primary);
+       ndr_print_bool(ndr, "internal", r->internal);
+       ndr_print_bool(ndr, "online", r->online);
+       ndr_print_time_t(ndr, "startup_time", r->startup_time);
+       ndr_print_bool(ndr, "startup", r->startup);
+       ndr_print_winbindd_methods(ndr, "methods", r->methods);
+       ndr_print_winbindd_methods(ndr, "backend", r->backend);
+       ndr_print_ptr(ndr, "private_data", r->private_data);
+       ndr_print_string(ndr, "dcname", r->dcname);
+       ndr_print_sockaddr_storage(ndr, "dcaddr", &r->dcaddr);
+       ndr_print_time_t(ndr, "last_seq_check", r->last_seq_check);
+       ndr_print_uint32(ndr, "sequence_number", r->sequence_number);
+       ndr_print_NTSTATUS(ndr, "last_status", r->last_status);
+       ndr_print_winbindd_cm_conn(ndr, "conn", &r->conn);
+       ndr_print_winbindd_child(ndr, "child", &r->child);
+       ndr_print_uint32(ndr, "check_online_timeout", r->check_online_timeout);
+       ndr_print_ptr(ndr, "check_online_event", r->check_online_event);
+       ndr->depth--;
+}


-- 
Samba Shared Repository

Reply via email to