s3:libnet_join: split libnet_join_post_processing_ads() into modify/sync
authorStefan Metzmacher <metze@samba.org>
Thu, 18 May 2017 13:50:49 +0000 (15:50 +0200)
committerStefan Metzmacher <metze@samba.org>
Tue, 27 Jun 2017 14:57:44 +0000 (16:57 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12782

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/libnet/libnet_join.c

index 780c26c..7493ac8 100644 (file)
@@ -871,8 +871,8 @@ static bool libnet_join_derive_salting_principal(TALLOC_CTX *mem_ctx,
 /****************************************************************
 ****************************************************************/
 
-static ADS_STATUS libnet_join_post_processing_ads(TALLOC_CTX *mem_ctx,
-                                                 struct libnet_JoinCtx *r)
+static ADS_STATUS libnet_join_post_processing_ads_modify(TALLOC_CTX *mem_ctx,
+                                                        struct libnet_JoinCtx *r)
 {
        ADS_STATUS status;
        bool need_etype_update = false;
@@ -964,6 +964,12 @@ static ADS_STATUS libnet_join_post_processing_ads(TALLOC_CTX *mem_ctx,
                return ADS_ERROR_NT(NT_STATUS_UNSUCCESSFUL);
        }
 
+       return ADS_SUCCESS;
+}
+
+static ADS_STATUS libnet_join_post_processing_ads_sync(TALLOC_CTX *mem_ctx,
+                                                       struct libnet_JoinCtx *r)
+{
        if (r->out.krb5_salt != NULL) {
                bool ok;
 
@@ -2214,6 +2220,18 @@ static WERROR libnet_join_post_processing(TALLOC_CTX *mem_ctx,
                return WERR_OK;
        }
 
+#ifdef HAVE_ADS
+       if (r->out.domain_is_ad &&
+           !(r->in.join_flags & WKSSVC_JOIN_FLAGS_JOIN_UNSECURE)) {
+               ADS_STATUS ads_status;
+
+               ads_status  = libnet_join_post_processing_ads_modify(mem_ctx, r);
+               if (!ADS_ERR_OK(ads_status)) {
+                       return WERR_GEN_FAILURE;
+               }
+       }
+#endif /* HAVE_ADS */
+
        saf_join_store(r->out.netbios_domain_name, r->in.dc_name);
        if (r->out.dns_domain_name) {
                saf_join_store(r->out.dns_domain_name, r->in.dc_name);
@@ -2224,7 +2242,7 @@ static WERROR libnet_join_post_processing(TALLOC_CTX *mem_ctx,
            !(r->in.join_flags & WKSSVC_JOIN_FLAGS_JOIN_UNSECURE)) {
                ADS_STATUS ads_status;
 
-               ads_status  = libnet_join_post_processing_ads(mem_ctx, r);
+               ads_status  = libnet_join_post_processing_ads_sync(mem_ctx, r);
                if (!ADS_ERR_OK(ads_status)) {
                        return WERR_GEN_FAILURE;
                }