Author: obnox Date: 2007-08-31 15:24:43 +0000 (Fri, 31 Aug 2007) New Revision: 24843
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=24843 Log: Add a "validate-cache" control message to winbindd. So there is a new subcommand "smbcontrol winbindd validate-cache" now. This change provides the infrastructure: The function currently returns "true" unconditionally. The call of a real cache validation function will be incorporated in subsequent changes. Michael Modified: branches/SAMBA_3_2/source/include/messages.h branches/SAMBA_3_2/source/nsswitch/winbindd.c branches/SAMBA_3_2/source/utils/smbcontrol.c branches/SAMBA_3_2_0/source/include/messages.h branches/SAMBA_3_2_0/source/nsswitch/winbindd.c branches/SAMBA_3_2_0/source/utils/smbcontrol.c Changeset: Modified: branches/SAMBA_3_2/source/include/messages.h =================================================================== --- branches/SAMBA_3_2/source/include/messages.h 2007-08-31 15:01:50 UTC (rev 24842) +++ branches/SAMBA_3_2/source/include/messages.h 2007-08-31 15:24:43 UTC (rev 24843) @@ -96,6 +96,7 @@ #define MSG_WINBIND_ONLINESTATUS 0x0405 #define MSG_WINBIND_TRY_TO_GO_ONLINE 0x0406 #define MSG_WINBIND_FAILED_TO_GO_ONLINE 0x0407 +#define MSG_WINBIND_VALIDATE_CACHE 0x0408 /* event messages */ #define MSG_DUMP_EVENT_LIST 0x0500 Modified: branches/SAMBA_3_2/source/nsswitch/winbindd.c =================================================================== --- branches/SAMBA_3_2/source/nsswitch/winbindd.c 2007-08-31 15:01:50 UTC (rev 24842) +++ branches/SAMBA_3_2/source/nsswitch/winbindd.c 2007-08-31 15:24:43 UTC (rev 24843) @@ -202,6 +202,28 @@ do_sigterm = True; } + +static void winbind_msg_validate_cache(struct messaging_context *msg_ctx, + void *private_data, + uint32_t msg_type, + struct server_id server_id, + DATA_BLOB *data) +{ + uint8 ret; + + DEBUG(10, ("winbindd_msg_validate_cache: got validate-cache " + "message.\n")); + +#if 0 + ret = (uint8)winbindd_validate_cache_nobackup(); + DEBUG(10, ("winbindd_msg_validata_cache: got return value %d\n", ret)); +#else + ret = 0; +#endif + messaging_send_buf(msg_ctx, server_id, MSG_WINBIND_VALIDATE_CACHE, &ret, + (size_t)1); +} + static struct winbindd_dispatch_table { enum winbindd_cmd cmd; void (*fn)(struct winbindd_cli_state *state); @@ -1170,6 +1192,10 @@ messaging_register(winbind_messaging_context(), NULL, MSG_DUMP_EVENT_LIST, winbind_msg_dump_event_list); + messaging_register(winbind_messaging_context(), NULL, + MSG_WINBIND_VALIDATE_CACHE, + winbind_msg_validate_cache); + netsamlogon_cache_init(); /* Non-critical */ /* clear the cached list of trusted domains */ Modified: branches/SAMBA_3_2/source/utils/smbcontrol.c =================================================================== --- branches/SAMBA_3_2/source/utils/smbcontrol.c 2007-08-31 15:01:50 UTC (rev 24842) +++ branches/SAMBA_3_2/source/utils/smbcontrol.c 2007-08-31 15:24:43 UTC (rev 24843) @@ -1012,7 +1012,49 @@ return send_message(msg_ctx, pid, MSG_DUMP_EVENT_LIST, NULL, 0); } +static void winbind_validate_cache_cb(struct messaging_context *msg, + void *private_data, + uint32_t msg_type, + struct server_id pid, + DATA_BLOB *data) +{ + char *src_string = procid_str(NULL, &pid); + printf("Winbindd cache is %svalid. (answer from pid %s)\n", + (*(data->data) == 0 ? "" : "NOT "), src_string); + TALLOC_FREE(src_string); + num_replies++; +} +static BOOL do_winbind_validate_cache(struct messaging_context *msg_ctx, + const struct server_id pid, + const int argc, const char **argv) +{ + struct server_id myid = pid_to_procid(sys_getpid()); + + if (argc != 1) { + fprintf(stderr, "Usage: smbcontrol winbindd validate-cache\n"); + return False; + } + + messaging_register(msg_ctx, NULL, MSG_WINBIND_VALIDATE_CACHE, + winbind_validate_cache_cb); + + if (!send_message(msg_ctx, pid, MSG_WINBIND_VALIDATE_CACHE, &myid, + sizeof(myid))) { + return False; + } + + wait_replies(msg_ctx, procid_to_pid(&pid) == 0); + + if (num_replies == 0) { + printf("No replies received\n"); + } + + messaging_deregister(msg_ctx, MSG_WINBIND_VALIDATE_CACHE, NULL); + + return num_replies; +} + static BOOL do_reload_config(struct messaging_context *msg_ctx, const struct server_id pid, const int argc, const char **argv) @@ -1110,6 +1152,8 @@ { "offline", do_winbind_offline, "Ask winbind to go into offline state"}, { "onlinestatus", do_winbind_onlinestatus, "Request winbind online status"}, { "dump-event-list", do_dump_event_list, "Dump event list"}, + { "validate-cache" , do_winbind_validate_cache, + "Validate winbind's credential cache" }, { "noop", do_noop, "Do nothing" }, { NULL } }; Modified: branches/SAMBA_3_2_0/source/include/messages.h =================================================================== --- branches/SAMBA_3_2_0/source/include/messages.h 2007-08-31 15:01:50 UTC (rev 24842) +++ branches/SAMBA_3_2_0/source/include/messages.h 2007-08-31 15:24:43 UTC (rev 24843) @@ -96,6 +96,7 @@ #define MSG_WINBIND_ONLINESTATUS 0x0405 #define MSG_WINBIND_TRY_TO_GO_ONLINE 0x0406 #define MSG_WINBIND_FAILED_TO_GO_ONLINE 0x0407 +#define MSG_WINBIND_VALIDATE_CACHE 0x0408 /* event messages */ #define MSG_DUMP_EVENT_LIST 0x0500 Modified: branches/SAMBA_3_2_0/source/nsswitch/winbindd.c =================================================================== --- branches/SAMBA_3_2_0/source/nsswitch/winbindd.c 2007-08-31 15:01:50 UTC (rev 24842) +++ branches/SAMBA_3_2_0/source/nsswitch/winbindd.c 2007-08-31 15:24:43 UTC (rev 24843) @@ -207,6 +207,28 @@ do_sigterm = True; } + +static void winbind_msg_validate_cache(struct messaging_context *msg_ctx, + void *private_data, + uint32_t msg_type, + struct server_id server_id, + DATA_BLOB *data) +{ + uint8 ret; + + DEBUG(10, ("winbindd_msg_validate_cache: got validate-cache " + "message.\n")); + +#if 0 + ret = (uint8)winbindd_validate_cache_nobackup(); + DEBUG(10, ("winbindd_msg_validata_cache: got return value %d\n", ret)); +#else + ret = 0; +#endif + messaging_send_buf(msg_ctx, server_id, MSG_WINBIND_VALIDATE_CACHE, &ret, + (size_t)1); +} + static struct winbindd_dispatch_table { enum winbindd_cmd cmd; void (*fn)(struct winbindd_cli_state *state); @@ -1136,6 +1158,10 @@ messaging_register(winbind_messaging_context(), NULL, MSG_DUMP_EVENT_LIST, winbind_msg_dump_event_list); + messaging_register(winbind_messaging_context(), NULL, + MSG_WINBIND_VALIDATE_CACHE, + winbind_msg_validate_cache); + netsamlogon_cache_init(); /* Non-critical */ /* clear the cached list of trusted domains */ Modified: branches/SAMBA_3_2_0/source/utils/smbcontrol.c =================================================================== --- branches/SAMBA_3_2_0/source/utils/smbcontrol.c 2007-08-31 15:01:50 UTC (rev 24842) +++ branches/SAMBA_3_2_0/source/utils/smbcontrol.c 2007-08-31 15:24:43 UTC (rev 24843) @@ -1012,7 +1012,49 @@ return send_message(msg_ctx, pid, MSG_DUMP_EVENT_LIST, NULL, 0); } +static void winbind_validate_cache_cb(struct messaging_context *msg, + void *private_data, + uint32_t msg_type, + struct server_id pid, + DATA_BLOB *data) +{ + char *src_string = procid_str(NULL, &pid); + printf("Winbindd cache is %svalid. (answer from pid %s)\n", + (*(data->data) == 0 ? "" : "NOT "), src_string); + TALLOC_FREE(src_string); + num_replies++; +} +static BOOL do_winbind_validate_cache(struct messaging_context *msg_ctx, + const struct server_id pid, + const int argc, const char **argv) +{ + struct server_id myid = pid_to_procid(sys_getpid()); + + if (argc != 1) { + fprintf(stderr, "Usage: smbcontrol winbindd validate-cache\n"); + return False; + } + + messaging_register(msg_ctx, NULL, MSG_WINBIND_VALIDATE_CACHE, + winbind_validate_cache_cb); + + if (!send_message(msg_ctx, pid, MSG_WINBIND_VALIDATE_CACHE, &myid, + sizeof(myid))) { + return False; + } + + wait_replies(msg_ctx, procid_to_pid(&pid) == 0); + + if (num_replies == 0) { + printf("No replies received\n"); + } + + messaging_deregister(msg_ctx, MSG_WINBIND_VALIDATE_CACHE, NULL); + + return num_replies; +} + static BOOL do_reload_config(struct messaging_context *msg_ctx, const struct server_id pid, const int argc, const char **argv) @@ -1110,6 +1152,8 @@ { "offline", do_winbind_offline, "Ask winbind to go into offline state"}, { "onlinestatus", do_winbind_onlinestatus, "Request winbind online status"}, { "dump-event-list", do_dump_event_list, "Dump event list"}, + { "validate-cache" , do_winbind_validate_cache, + "Validate winbind's credential cache" }, { "noop", do_noop, "Do nothing" }, { NULL } };