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 550
 <INITIAL>{LOGFACILITY}	{ yylval.strval=yytext; return LOGFACILITY; }
551 551
 <INITIAL>{LISTEN}	{ count(); yylval.strval=yytext; return LISTEN; }
552 552
 <INITIAL>{ALIAS}	{ count(); yylval.strval=yytext; return ALIAS; }
553
+<INITIAL>{SR_AUTO_ALIASES}	{ count(); yylval.strval=yytext;
554
+									return SR_AUTO_ALIASES; }
553 555
 <INITIAL>{DNS}	{ count(); yylval.strval=yytext; return DNS; }
554 556
 <INITIAL>{REV_DNS}	{ count(); yylval.strval=yytext; return REV_DNS; }
555 557
 <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 1272
 		free_socket_id_lst($3);
1273 1273
 	}
1274 1274
 	| ALIAS  EQUAL error  { yyerror(" hostname expected"); }
1275
+	| SR_AUTO_ALIASES EQUAL NUMBER { sr_auto_aliases=$3; }
1276
+	| SR_AUTO_ALIASES EQUAL error  { yyerror("boolean value expected"); }
1275 1277
 	| ADVERTISED_ADDRESS EQUAL listen_id {
1276 1278
 		default_global_address.s=$3;
1277 1279
 		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 836
 		strncpy(name->s, he->h_name, name->len+1);
837 837
 	}
838 838
 	/* add the aliases*/
839
-	for(h=he->h_aliases; h && *h; h++)
839
+	for(h=he->h_aliases; sr_auto_aliases && h && *h; h++)
840 840
 		if (add_alias(*h, strlen(*h), s->port_no, s->proto)<0){
841
-				LOG(L_ERR, "ERROR: fix_hostname: add_alias failed\n");
841
+			LOG(L_ERR, "ERROR: fix_hostname: add_alias failed\n");
842 842
 		}
843 843
 	hostent2ip_addr(address, he, 0); /*convert to ip_addr format*/
844 844
 	if (type_flags){
... ...
@@ -853,7 +854,7 @@ static int fix_hostname(str* name, struct ip_addr* address, str* address_str,
853 853
 	strncpy(address_str->s, tmp, strlen(tmp)+1);
854 854
 	/* set is_ip (1 if name is an ip address, 0 otherwise) */
855 855
 	address_str->len=strlen(tmp);
856
-	if ((address_str->len==name->len) &&
856
+	if (sr_auto_aliases && (address_str->len==name->len) &&
857 857
 		(strncasecmp(address_str->s, name->s, address_str->len)==0)){
858 858
 		*flags|=SI_IS_IP;
859 859
 		/* do rev. DNS on it (for aliases)*/