Ensure all calls to rk_dns_lookup are headed by a block_dns check.
Exception: In lib/kafs/common.c, we don't have a krb5_context in which to check.
This commit is contained in:
		
				
					committed by
					
						
						Nico Williams
					
				
			
			
				
	
			
			
			
						parent
						
							fd77c4000d
						
					
				
				
					commit
					19505537fd
				
			@@ -167,6 +167,13 @@ ad_connect(krb5_context context,
 | 
				
			|||||||
    } *s, *servers = NULL;
 | 
					    } *s, *servers = NULL;
 | 
				
			||||||
    size_t i, num_servers = 0;
 | 
					    size_t i, num_servers = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (krb5_config_get_bool(context, NULL, "libdefaults", "block_dns",
 | 
				
			||||||
 | 
						    NULL)) {
 | 
				
			||||||
 | 
						ret = KRB5KDC_ERR_SVC_UNAVAILABLE;
 | 
				
			||||||
 | 
					        krb5_set_error_message(context, ret, "DNS blocked when finding AD DC");
 | 
				
			||||||
 | 
						return ret;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        struct rk_dns_reply *r;
 | 
					        struct rk_dns_reply *r;
 | 
				
			||||||
        struct rk_resource_record *rr;
 | 
					        struct rk_resource_record *rr;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -116,6 +116,14 @@ dns_find_realm(krb5_context context,
 | 
				
			|||||||
    char **config_labels;
 | 
					    char **config_labels;
 | 
				
			||||||
    int i, ret = 0;
 | 
					    int i, ret = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (krb5_config_get_bool(context, NULL, "libdefaults", "block_dns",
 | 
				
			||||||
 | 
						    NULL)) {
 | 
				
			||||||
 | 
						ret = KRB5_KDC_UNREACH;
 | 
				
			||||||
 | 
					        krb5_set_error_message(context, ret,
 | 
				
			||||||
 | 
						    "Realm lookup failed: DNS blocked");
 | 
				
			||||||
 | 
						return ret;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    config_labels = krb5_config_get_strings(context, NULL, "libdefaults",
 | 
					    config_labels = krb5_config_get_strings(context, NULL, "libdefaults",
 | 
				
			||||||
					    "dns_lookup_realm_labels", NULL);
 | 
										    "dns_lookup_realm_labels", NULL);
 | 
				
			||||||
    if(config_labels != NULL)
 | 
					    if(config_labels != NULL)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -795,7 +795,9 @@ kdc_get_next(krb5_context context,
 | 
				
			|||||||
	return KRB5_KDC_UNREACH;
 | 
						return KRB5_KDC_UNREACH;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if(context->srv_lookup) {
 | 
					    if (krb5_config_get_bool(context, NULL, "libdefaults", "block_dns",
 | 
				
			||||||
 | 
						    NULL) &&
 | 
				
			||||||
 | 
						context->srv_lookup) {
 | 
				
			||||||
	if(kd->sitename && (kd->flags & KD_SITE_SRV_TCP) == 0) {
 | 
						if(kd->sitename && (kd->flags & KD_SITE_SRV_TCP) == 0) {
 | 
				
			||||||
	    srv_get_hosts(context, kd, kd->sitename, "tcp", "kerberos");
 | 
						    srv_get_hosts(context, kd, kd->sitename, "tcp", "kerberos");
 | 
				
			||||||
	    kd->flags |= KD_SITE_SRV_TCP;
 | 
						    kd->flags |= KD_SITE_SRV_TCP;
 | 
				
			||||||
@@ -867,7 +869,9 @@ admin_get_next(krb5_context context,
 | 
				
			|||||||
	return KRB5_KDC_UNREACH;
 | 
						return KRB5_KDC_UNREACH;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if(context->srv_lookup) {
 | 
					    if (krb5_config_get_bool(context, NULL, "libdefaults", "block_dns",
 | 
				
			||||||
 | 
						    NULL) &&
 | 
				
			||||||
 | 
						context->srv_lookup) {
 | 
				
			||||||
	if((kd->flags & KD_SRV_TCP) == 0) {
 | 
						if((kd->flags & KD_SRV_TCP) == 0) {
 | 
				
			||||||
	    srv_get_hosts(context, kd, NULL, "tcp", kd->srv_label);
 | 
						    srv_get_hosts(context, kd, NULL, "tcp", kd->srv_label);
 | 
				
			||||||
	    kd->flags |= KD_SRV_TCP;
 | 
						    kd->flags |= KD_SRV_TCP;
 | 
				
			||||||
@@ -921,7 +925,9 @@ kpasswd_get_next(krb5_context context,
 | 
				
			|||||||
	return KRB5_KDC_UNREACH;
 | 
						return KRB5_KDC_UNREACH;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if(context->srv_lookup) {
 | 
					    if (krb5_config_get_bool(context, NULL, "libdefaults", "block_dns",
 | 
				
			||||||
 | 
						    NULL) &&
 | 
				
			||||||
 | 
						context->srv_lookup) {
 | 
				
			||||||
	if((kd->flags & KD_SRV_UDP) == 0) {
 | 
						if((kd->flags & KD_SRV_UDP) == 0) {
 | 
				
			||||||
	    srv_get_hosts(context, kd, NULL, "udp", kd->srv_label);
 | 
						    srv_get_hosts(context, kd, NULL, "udp", kd->srv_label);
 | 
				
			||||||
	    kd->flags |= KD_SRV_UDP;
 | 
						    kd->flags |= KD_SRV_UDP;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user