From: Stefan Metzmacher Date: Wed, 29 Nov 2017 14:23:36 +0000 (+0100) Subject: winbindd: add find_trust_from_{name,sid}_noinit() X-Git-Tag: samba-4.8.0rc1~60 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2385e719ba4835ca254eedbdfeffdd875912ec27;p=thirdparty%2Fsamba.git winbindd: add find_trust_from_{name,sid}_noinit() Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme --- diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h index 8af79324c69..dd6767a02ab 100644 --- a/source3/winbindd/winbindd_proto.h +++ b/source3/winbindd/winbindd_proto.h @@ -445,8 +445,10 @@ enum winbindd_result winbindd_dual_init_connection(struct winbindd_domain *domai struct winbindd_cli_state *state); bool init_domain_list(void); struct winbindd_domain *find_domain_from_name_noinit(const char *domain_name); +struct winbindd_domain *find_trust_from_name_noinit(const char *domain_name); struct winbindd_domain *find_domain_from_name(const char *domain_name); struct winbindd_domain *find_domain_from_sid_noinit(const struct dom_sid *sid); +struct winbindd_domain *find_trust_from_sid_noinit(const struct dom_sid *sid); struct winbindd_domain *find_domain_from_sid(const struct dom_sid *sid); struct winbindd_domain *find_our_domain(void); struct winbindd_domain *find_lookup_domain_from_sid(const struct dom_sid *sid); diff --git a/source3/winbindd/winbindd_util.c b/source3/winbindd/winbindd_util.c index 3b8fae141bb..9c8e39f79c1 100644 --- a/source3/winbindd/winbindd_util.c +++ b/source3/winbindd/winbindd_util.c @@ -1082,6 +1082,28 @@ struct winbindd_domain *find_domain_from_name_noinit(const char *domain_name) return NULL; } +/** + * Given a domain name, return the struct winbindd domain if it's a direct + * outgoing trust + * + * @return The domain structure for the named domain, if it is a direct outgoing trust + */ +struct winbindd_domain *find_trust_from_name_noinit(const char *domain_name) +{ + struct winbindd_domain *domain = NULL; + + domain = find_domain_from_name_noinit(domain_name); + if (domain == NULL) { + return NULL; + } + + if (domain->secure_channel_type != SEC_CHAN_NULL) { + return domain; + } + + return NULL; +} + struct winbindd_domain *find_domain_from_name(const char *domain_name) { struct winbindd_domain *domain; @@ -1115,6 +1137,28 @@ struct winbindd_domain *find_domain_from_sid_noinit(const struct dom_sid *sid) return NULL; } +/** + * Given a domain sid, return the struct winbindd domain if it's a direct + * outgoing trust + * + * @return The domain structure for the specified domain, if it is a direct outgoing trust + */ +struct winbindd_domain *find_trust_from_sid_noinit(const struct dom_sid *sid) +{ + struct winbindd_domain *domain = NULL; + + domain = find_domain_from_sid_noinit(sid); + if (domain == NULL) { + return NULL; + } + + if (domain->secure_channel_type != SEC_CHAN_NULL) { + return domain; + } + + return NULL; +} + /* Given a domain sid, return the struct winbindd domain info for it */ struct winbindd_domain *find_domain_from_sid(const struct dom_sid *sid)