Browse code

core: auto_aliases to control rev DNS aliases

- parameter takes boolean value
- if set, rev dns results are added to aliases list
- default is set

Daniel-Constantin Mierla authored on 03/05/2009 11:04:49
Showing 5 changed files
... ...
@@ -273,6 +273,7 @@ LOGSTDERROR	log_stderror
273 273
 LOGFACILITY	log_facility
274 274
 LISTEN		listen
275 275
 ALIAS		alias
276
+SR_AUTO_ALIASES	auto_aliases
276 277
 DNS		 dns
277 278
 REV_DNS	 rev_dns
278 279
 DNS_TRY_IPV6	dns_try_ipv6
... ...
@@ -550,6 +551,8 @@ EAT_ABLE	[\ \t\b\r]
550 551
 <INITIAL>{LOGFACILITY}	{ yylval.strval=yytext; return LOGFACILITY; }
551 552
 <INITIAL>{LISTEN}	{ count(); yylval.strval=yytext; return LISTEN; }
552 553
 <INITIAL>{ALIAS}	{ count(); yylval.strval=yytext; return ALIAS; }
554
+<INITIAL>{SR_AUTO_ALIASES}	{ count(); yylval.strval=yytext;
555
+									return SR_AUTO_ALIASES; }
553 556
 <INITIAL>{DNS}	{ count(); yylval.strval=yytext; return DNS; }
554 557
 <INITIAL>{REV_DNS}	{ count(); yylval.strval=yytext; return REV_DNS; }
555 558
 <INITIAL>{DNS_TRY_IPV6}	{ count(); yylval.strval=yytext;
... ...
@@ -333,6 +333,7 @@ static int case_check_default(struct case_stms* stms);
333 333
 %token LOGFACILITY
334 334
 %token LISTEN
335 335
 %token ALIAS
336
+%token SR_AUTO_ALIASES
336 337
 %token DNS
337 338
 %token REV_DNS
338 339
 %token DNS_TRY_IPV6
... ...
@@ -1272,6 +1273,8 @@ assign_stm:
1272 1273
 		free_socket_id_lst($3);
1273 1274
 	}
1274 1275
 	| ALIAS  EQUAL error  { yyerror(" hostname expected"); }
1276
+	| SR_AUTO_ALIASES EQUAL NUMBER { sr_auto_aliases=$3; }
1277
+	| SR_AUTO_ALIASES EQUAL error  { yyerror("boolean value expected"); }
1275 1278
 	| ADVERTISED_ADDRESS EQUAL listen_id {
1276 1279
 		default_global_address.s=$3;
1277 1280
 		default_global_address.len=strlen($3);
... ...
@@ -117,6 +117,7 @@ extern int sock_gid;
117 117
 extern int sock_mode;
118 118
 extern char* chroot_dir;
119 119
 extern char* working_dir;
120
+extern int sr_auto_aliases;
120 121
 
121 122
 #ifdef USE_MCAST
122 123
 extern int mcast_loopback;
... ...
@@ -348,6 +348,8 @@ int mhomed=0;
348 348
 /* use dns and/or rdns or to see if we need to add
349 349
    a ;received=x.x.x.x to via: */
350 350
 int received_dns = 0;
351
+/* add or not the rev dns names to aliases list */
352
+int sr_auto_aliases=1;
351 353
 char* working_dir = 0;
352 354
 char* chroot_dir = 0;
353 355
 char* user=0;
... ...
@@ -822,7 +822,8 @@ static int fix_hostname(str* name, struct ip_addr* address, str* address_str,
822 822
 	}
823 823
 	/* check if we got the official name */
824 824
 	if (strcasecmp(he->h_name, name->s)!=0){
825
-		if (add_alias(name->s, name->len, s->port_no, s->proto)<0){
825
+		if (sr_auto_aliases && 
826
+				add_alias(name->s, name->len, s->port_no, s->proto)<0){
826 827
 			LOG(L_ERR, "ERROR: fix_hostname: add_alias failed\n");
827 828
 		}
828 829
 		/* change the official name */
... ...
@@ -836,9 +837,9 @@ static int fix_hostname(str* name, struct ip_addr* address, str* address_str,
836 837
 		strncpy(name->s, he->h_name, name->len+1);
837 838
 	}
838 839
 	/* add the aliases*/
839
-	for(h=he->h_aliases; h && *h; h++)
840
+	for(h=he->h_aliases; sr_auto_aliases && h && *h; h++)
840 841
 		if (add_alias(*h, strlen(*h), s->port_no, s->proto)<0){
841
-				LOG(L_ERR, "ERROR: fix_hostname: add_alias failed\n");
842
+			LOG(L_ERR, "ERROR: fix_hostname: add_alias failed\n");
842 843
 		}
843 844
 	hostent2ip_addr(address, he, 0); /*convert to ip_addr format*/
844 845
 	if (type_flags){
... ...
@@ -853,7 +854,7 @@ static int fix_hostname(str* name, struct ip_addr* address, str* address_str,
853 854
 	strncpy(address_str->s, tmp, strlen(tmp)+1);
854 855
 	/* set is_ip (1 if name is an ip address, 0 otherwise) */
855 856
 	address_str->len=strlen(tmp);
856
-	if ((address_str->len==name->len) &&
857
+	if (sr_auto_aliases && (address_str->len==name->len) &&
857 858
 		(strncasecmp(address_str->s, name->s, address_str->len)==0)){
858 859
 		*flags|=SI_IS_IP;
859 860
 		/* do rev. DNS on it (for aliases)*/