diff options
Diffstat (limited to 'source3/nsswitch/winbindd_util.c')
-rw-r--r-- | source3/nsswitch/winbindd_util.c | 58 |
1 files changed, 55 insertions, 3 deletions
diff --git a/source3/nsswitch/winbindd_util.c b/source3/nsswitch/winbindd_util.c index 225c6b5be1..a29ea38145 100644 --- a/source3/nsswitch/winbindd_util.c +++ b/source3/nsswitch/winbindd_util.c @@ -1366,24 +1366,40 @@ BOOL winbindd_internal_child(struct winbindd_child *child) return False; } +void winbindd_set_locator_kdc_envs(const struct winbindd_domain *domain); +void winbindd_unset_locator_kdc_env(const struct winbindd_domain *domain); + +#ifdef HAVE_KRB5_LOCATE_PLUGIN_H + /********************************************************************* ********************************************************************/ -void winbindd_set_locator_kdc_env(const struct winbindd_domain *domain) +static void winbindd_set_locator_kdc_env(const struct winbindd_domain *domain) { char *var = NULL; const char *kdc = NULL; + int lvl = 11; + + if (!domain || !domain->alt_name || !*domain->alt_name) { + return; + } - if (!domain) { + if (domain->initialized && !domain->active_directory) { + DEBUG(lvl,("winbindd_set_locator_kdc_env: %s not AD\n", + domain->alt_name)); return; } kdc = inet_ntoa(domain->dcaddr.sin_addr); if (!kdc) { + DEBUG(lvl,("winbindd_set_locator_kdc_env: %s no DC IP\n", + domain->alt_name)); kdc = domain->dcname; } if (!kdc || !*kdc) { + DEBUG(lvl,("winbindd_set_locator_kdc_env: %s no DC at all\n", + domain->alt_name)); return; } @@ -1392,9 +1408,45 @@ void winbindd_set_locator_kdc_env(const struct winbindd_domain *domain) return; } - DEBUG(10,("winbindd_set_locator_kdc_env: setting var: %s to: %s\n", + DEBUG(lvl,("winbindd_set_locator_kdc_env: setting var: %s to: %s\n", var, kdc)); setenv(var, kdc, 1); free(var); } + +/********************************************************************* + ********************************************************************/ + +void winbindd_set_locator_kdc_envs(const struct winbindd_domain *domain) +{ + struct winbindd_domain *our_dom = find_our_domain(); + + winbindd_set_locator_kdc_env(domain); + + if (domain != our_dom) { + winbindd_set_locator_kdc_env(our_dom); + } +} + +/********************************************************************* + ********************************************************************/ + +void winbindd_unset_locator_kdc_env(const struct winbindd_domain *domain) +{ + char *var = NULL; + + if (!domain || !domain->alt_name || !*domain->alt_name) { + return; + } + + if (asprintf(&var, "%s_%s", WINBINDD_LOCATOR_KDC_ADDRESS, + strupper_static(domain->alt_name)) == -1) { + return; + } + + unsetenv(var); + free(var); +} + +#endif /* HAVE_KRB5_LOCATE_PLUGIN_H */ |