winbindd: add find_trust_from_{name,sid}_noinit()
authorStefan Metzmacher <metze@samba.org>
Wed, 29 Nov 2017 14:23:36 +0000 (15:23 +0100)
committerKarolin Seeger <kseeger@samba.org>
Sat, 13 Jan 2018 11:55:07 +0000 (12:55 +0100)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/winbindd/winbindd_proto.h
source3/winbindd/winbindd_util.c

index 8af79324c6928611f33982c741617cd77972dbc5..dd6767a02ab52b8f47293e23cf38770165bff98f 100644 (file)
@@ -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);
index 3b8fae141bb13423e7876968db74a5de81b7c029..9c8e39f79c151b746281a6e0fe1cf75a6bba0c55 100644 (file)
@@ -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)