diff options
author | Stefan Metzmacher <metze@samba.org> | 2007-10-08 12:25:57 +0000 |
---|---|---|
committer | Stefan Metzmacher <metze@sernet.de> | 2007-10-22 08:46:11 +0200 |
commit | 3d9a578064d46e595a51af5896a51db47bd2da4e (patch) | |
tree | 5d6a43d76c899d203c83a7f42df12ec0f468c551 | |
parent | 6ded271f7719483faee19aba502d787a279c1689 (diff) | |
download | samba-3d9a578064d46e595a51af5896a51db47bd2da4e.tar.gz samba-3d9a578064d46e595a51af5896a51db47bd2da4e.tar.bz2 samba-3d9a578064d46e595a51af5896a51db47bd2da4e.zip |
r25571: split up child_dispatch_table into domain, idmap and locator tables
metze
(cherry picked from commit abbb36a37c1dba2218a6c7ec31739eba5f250127)
(This used to be commit 5af1b45ed31043f952ec141d0f5f2973aec69d1a)
-rw-r--r-- | source3/winbindd/winbindd.h | 13 | ||||
-rw-r--r-- | source3/winbindd/winbindd_dual.c | 40 | ||||
-rw-r--r-- | source3/winbindd/winbindd_idmap.c | 30 | ||||
-rw-r--r-- | source3/winbindd/winbindd_locator.c | 18 | ||||
-rw-r--r-- | source3/winbindd/winbindd_util.c | 27 |
5 files changed, 87 insertions, 41 deletions
diff --git a/source3/winbindd/winbindd.h b/source3/winbindd/winbindd.h index 5fc083f7a9..e4b1396cac 100644 --- a/source3/winbindd/winbindd.h +++ b/source3/winbindd/winbindd.h @@ -134,6 +134,17 @@ struct winbindd_async_request; /* Async child */ +struct winbindd_domain; + +struct winbindd_child_dispatch_table { + enum winbindd_cmd cmd; + enum winbindd_result (*fn)(struct winbindd_domain *domain, + struct winbindd_cli_state *state); + const char *winbindd_cmd_name; +}; + +extern const struct winbindd_child_dispatch_table domain_dispatch_table[]; + struct winbindd_child { struct winbindd_child *next, *prev; @@ -144,6 +155,8 @@ struct winbindd_child { struct fd_event event; struct timed_event *lockout_policy_event; struct winbindd_async_request *requests; + + const struct winbindd_child_dispatch_table *table; }; /* Structures to hold per domain information */ diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c index 932fc328cf..c96941531a 100644 --- a/source3/winbindd/winbindd_dual.c +++ b/source3/winbindd/winbindd_dual.c @@ -408,23 +408,14 @@ void sendto_domain(struct winbindd_cli_state *state, recvfrom_child, state); } +const struct winbindd_child_dispatch_table domain_dispatch_table[] = { -struct winbindd_child_dispatch_table { - enum winbindd_cmd cmd; - enum winbindd_result (*fn)(struct winbindd_domain *domain, - struct winbindd_cli_state *state); - const char *winbindd_cmd_name; -}; - -static struct winbindd_child_dispatch_table child_dispatch_table[] = { - { WINBINDD_LOOKUPSID, winbindd_dual_lookupsid, "LOOKUPSID" }, { WINBINDD_LOOKUPNAME, winbindd_dual_lookupname, "LOOKUPNAME" }, { WINBINDD_LOOKUPRIDS, winbindd_dual_lookuprids, "LOOKUPRIDS" }, { WINBINDD_LIST_TRUSTDOM, winbindd_dual_list_trusted_domains, "LIST_TRUSTDOM" }, { WINBINDD_INIT_CONNECTION, winbindd_dual_init_connection, "INIT_CONNECTION" }, { WINBINDD_GETDCNAME, winbindd_dual_getdcname, "GETDCNAME" }, - { WINBINDD_DSGETDCNAME, winbindd_dual_dsgetdcname, "DSGETDCNAME" }, { WINBINDD_SHOW_SEQUENCE, winbindd_dual_show_sequence, "SHOW_SEQUENCE" }, { WINBINDD_PAM_AUTH, winbindd_dual_pam_auth, "PAM_AUTH" }, { WINBINDD_PAM_AUTH_CRAP, winbindd_dual_pam_auth_crap, "AUTH_CRAP" }, @@ -432,23 +423,7 @@ static struct winbindd_child_dispatch_table child_dispatch_table[] = { { WINBINDD_PAM_CHNG_PSWD_AUTH_CRAP,winbindd_dual_pam_chng_pswd_auth_crap,"CHNG_PSWD_AUTH_CRAP" }, { WINBINDD_PAM_CHAUTHTOK, winbindd_dual_pam_chauthtok, "PAM_CHAUTHTOK" }, { WINBINDD_CHECK_MACHACC, winbindd_dual_check_machine_acct, "CHECK_MACHACC" }, - { WINBINDD_DUAL_SID2UID, winbindd_dual_sid2uid, "DUAL_SID2UID" }, - { WINBINDD_DUAL_SID2GID, winbindd_dual_sid2gid, "DUAL_SID2GID" }, -#if 0 /* DISABLED until we fix the interface in Samba 3.0.26 --jerry */ - { WINBINDD_DUAL_SIDS2XIDS, winbindd_dual_sids2xids, "DUAL_SIDS2XIDS" }, -#endif /* end DISABLED */ - { WINBINDD_DUAL_UID2SID, winbindd_dual_uid2sid, "DUAL_UID2SID" }, - { WINBINDD_DUAL_GID2SID, winbindd_dual_gid2sid, "DUAL_GID2SID" }, - { WINBINDD_DUAL_UID2NAME, winbindd_dual_uid2name, "DUAL_UID2NAME" }, - { WINBINDD_DUAL_NAME2UID, winbindd_dual_name2uid, "DUAL_NAME2UID" }, - { WINBINDD_DUAL_GID2NAME, winbindd_dual_gid2name, "DUAL_GID2NAME" }, - { WINBINDD_DUAL_NAME2GID, winbindd_dual_name2gid, "DUAL_NAME2GID" }, - { WINBINDD_DUAL_SET_MAPPING, winbindd_dual_set_mapping, "DUAL_SET_MAPPING" }, - { WINBINDD_DUAL_SET_HWM, winbindd_dual_set_hwm, "DUAL_SET_HWMS" }, - { WINBINDD_DUAL_DUMP_MAPS, winbindd_dual_dump_maps, "DUAL_DUMP_MAPS" }, { WINBINDD_DUAL_USERINFO, winbindd_dual_userinfo, "DUAL_USERINFO" }, - { WINBINDD_ALLOCATE_UID, winbindd_dual_allocate_uid, "ALLOCATE_UID" }, - { WINBINDD_ALLOCATE_GID, winbindd_dual_allocate_gid, "ALLOCATE_GID" }, { WINBINDD_GETUSERDOMGROUPS, winbindd_dual_getuserdomgroups, "GETUSERDOMGROUPS" }, { WINBINDD_DUAL_GETSIDALIASES, winbindd_dual_getsidaliases, "GETSIDALIASES" }, { WINBINDD_CCACHE_NTLMAUTH, winbindd_dual_ccache_ntlm_auth, "CCACHE_NTLM_AUTH" }, @@ -457,10 +432,11 @@ static struct winbindd_child_dispatch_table child_dispatch_table[] = { { WINBINDD_NUM_CMDS, NULL, "NONE" } }; -static void child_process_request(struct winbindd_domain *domain, +static void child_process_request(struct winbindd_child *child, struct winbindd_cli_state *state) { - struct winbindd_child_dispatch_table *table; + struct winbindd_domain *domain = child->domain; + const struct winbindd_child_dispatch_table *table = child->table; /* Free response data - we may be interrupted and receive another command before being able to send this data off. */ @@ -473,7 +449,7 @@ static void child_process_request(struct winbindd_domain *domain, /* Process command */ - for (table = child_dispatch_table; table->fn; table++) { + for (; table->fn; table++) { if (state->request.cmd == table->cmd) { DEBUG(10,("process_request: request fn %s\n", table->winbindd_cmd_name )); @@ -483,7 +459,7 @@ static void child_process_request(struct winbindd_domain *domain, } if (!table->fn) { - DEBUG(10,("process_request: unknown request fn number %d\n", + DEBUG(1 ,("child_process_request: unknown request fn number %d\n", (int)state->request.cmd )); state->response.result = WINBINDD_ERROR; } @@ -491,6 +467,7 @@ static void child_process_request(struct winbindd_domain *domain, void setup_domain_child(struct winbindd_domain *domain, struct winbindd_child *child, + const struct winbindd_child_dispatch_table *table, const char *explicit_logfile) { if (explicit_logfile != NULL) { @@ -505,6 +482,7 @@ void setup_domain_child(struct winbindd_domain *domain, } child->domain = domain; + child->table = table; } struct winbindd_child *children = NULL; @@ -1106,7 +1084,7 @@ static bool fork_domain_child(struct winbindd_child *child) ZERO_STRUCT(state.response); state.request.null_term = '\0'; - child_process_request(child->domain, &state); + child_process_request(child, &state); SAFE_FREE(state.request.extra_data.data); diff --git a/source3/winbindd/winbindd_idmap.c b/source3/winbindd/winbindd_idmap.c index 1d6beb3778..437af41872 100644 --- a/source3/winbindd/winbindd_idmap.c +++ b/source3/winbindd/winbindd_idmap.c @@ -37,11 +37,16 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_WINBIND +static const struct winbindd_child_dispatch_table idmap_dispatch_table[]; + static struct winbindd_child static_idmap_child; void init_idmap_child(void) { - setup_domain_child(NULL, &static_idmap_child, "idmap"); + setup_domain_child(NULL, + &static_idmap_child, + idmap_dispatch_table, + "idmap"); } struct winbindd_child *idmap_child(void) @@ -788,3 +793,26 @@ enum winbindd_result winbindd_dual_dump_maps(struct winbindd_domain *domain, return WINBINDD_OK; } + +static const struct winbindd_child_dispatch_table idmap_dispatch_table[] = { + + { WINBINDD_DUAL_SID2UID, winbindd_dual_sid2uid, "DUAL_SID2UID" }, + { WINBINDD_DUAL_SID2GID, winbindd_dual_sid2gid, "DUAL_SID2GID" }, +#if 0 /* DISABLED until we fix the interface in Samba 3.0.26 --jerry */ + { WINBINDD_DUAL_SIDS2XIDS, winbindd_dual_sids2xids, "DUAL_SIDS2XIDS" }, +#endif /* end DISABLED */ + { WINBINDD_DUAL_UID2SID, winbindd_dual_uid2sid, "DUAL_UID2SID" }, + { WINBINDD_DUAL_GID2SID, winbindd_dual_gid2sid, "DUAL_GID2SID" }, + { WINBINDD_DUAL_UID2NAME, winbindd_dual_uid2name, "DUAL_UID2NAME" }, + { WINBINDD_DUAL_NAME2UID, winbindd_dual_name2uid, "DUAL_NAME2UID" }, + { WINBINDD_DUAL_GID2NAME, winbindd_dual_gid2name, "DUAL_GID2NAME" }, + { WINBINDD_DUAL_NAME2GID, winbindd_dual_name2gid, "DUAL_NAME2GID" }, + { WINBINDD_DUAL_SET_MAPPING, winbindd_dual_set_mapping, "DUAL_SET_MAPPING" }, + { WINBINDD_DUAL_SET_HWM, winbindd_dual_set_hwm, "DUAL_SET_HWMS" }, + { WINBINDD_DUAL_DUMP_MAPS, winbindd_dual_dump_maps, "DUAL_DUMP_MAPS" }, + { WINBINDD_ALLOCATE_UID, winbindd_dual_allocate_uid, "ALLOCATE_UID" }, + { WINBINDD_ALLOCATE_GID, winbindd_dual_allocate_gid, "ALLOCATE_GID" }, + /* End of list */ + + { WINBINDD_NUM_CMDS, NULL, "NONE" } +}; diff --git a/source3/winbindd/winbindd_locator.c b/source3/winbindd/winbindd_locator.c index 3fcb9de7a8..7db2e2ada0 100644 --- a/source3/winbindd/winbindd_locator.c +++ b/source3/winbindd/winbindd_locator.c @@ -26,11 +26,17 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_WINBIND + +static const struct winbindd_child_dispatch_table locator_dispatch_table[]; + static struct winbindd_child static_locator_child; void init_locator_child(void) { - setup_domain_child(NULL, &static_locator_child, "locator"); + setup_domain_child(NULL, + &static_locator_child, + locator_dispatch_table, + "locator"); } struct winbindd_child *locator_child(void) @@ -49,8 +55,8 @@ void winbindd_dsgetdcname(struct winbindd_cli_state *state) sendto_child(state, locator_child()); } -enum winbindd_result winbindd_dual_dsgetdcname(struct winbindd_domain *domain, - struct winbindd_cli_state *state) +static enum winbindd_result dual_dsgetdcname(struct winbindd_domain *domain, + struct winbindd_cli_state *state) { NTSTATUS result; struct DS_DOMAIN_CONTROLLER_INFO *info = NULL; @@ -88,3 +94,9 @@ enum winbindd_result winbindd_dual_dsgetdcname(struct winbindd_domain *domain, return WINBINDD_OK; } + +static const struct winbindd_child_dispatch_table locator_dispatch_table[] = { + { WINBINDD_DSGETDCNAME, dual_dsgetdcname, "DSGETDCNAME" }, + + { WINBINDD_NUM_CMDS, NULL, "NONE" } +}; diff --git a/source3/winbindd/winbindd_util.c b/source3/winbindd/winbindd_util.c index 54bb5a24b7..8970c1faf9 100644 --- a/source3/winbindd/winbindd_util.c +++ b/source3/winbindd/winbindd_util.c @@ -325,7 +325,10 @@ static void trustdom_recv(void *private_data, bool success) &cache_methods, &sid); if (domain) { - setup_domain_child(domain, &domain->child, NULL); + setup_domain_child(domain, + &domain->child, + domain_dispatch_table, + NULL); } } p=q; @@ -694,7 +697,10 @@ bool init_domain_list(void) domain = add_trusted_domain("BUILTIN", NULL, &passdb_methods, &global_sid_Builtin); if (domain) { - setup_domain_child(domain, &domain->child, NULL); + setup_domain_child(domain, + &domain->child, + domain_dispatch_table, + NULL); } /* Local SAM */ @@ -705,7 +711,10 @@ bool init_domain_list(void) if ( role != ROLE_DOMAIN_MEMBER ) { domain->primary = True; } - setup_domain_child(domain, &domain->child, NULL); + setup_domain_child(domain, + &domain->child, + domain_dispatch_table, + NULL); } /* Add ourselves as the first entry. */ @@ -722,8 +731,11 @@ bool init_domain_list(void) &cache_methods, &our_sid); if (domain) { domain->primary = True; - setup_domain_child(domain, &domain->child, NULL); - + setup_domain_child(domain, + &domain->child, + domain_dispatch_table, + NULL); + /* Even in the parent winbindd we'll need to talk to the DC, so try and see if we can contact it. Theoretically this isn't neccessary @@ -768,7 +780,10 @@ void check_domain_trusted( const char *name, const DOM_SID *user_sid ) domain->internal = False; domain->online = True; - setup_domain_child(domain, &domain->child, NULL); + setup_domain_child(domain, + &domain->child, + domain_dispatch_table, + NULL); wcache_tdc_add_domain( domain ); |