--- nagios-2.7/xdata/xodtemplate.c	2007-01-19 14:02:01.000000000 -0800
+++ nagios-2.7.new/xdata/xodtemplate.c	2007-02-13 07:56:49.000000000 -0800
@@ -3829,6 +3829,7 @@
 	xodtemplate_serviceextinfo *temp_serviceextinfo;
 	char *host_name="";
 	int first_item;
+	int same_host_servicedependency;
 #ifdef NSCORE
 	char temp_buffer[MAX_XODTEMPLATE_INPUT_BUFFER];
 #endif
@@ -4131,13 +4132,11 @@
 
 		/* get list of dependent host names */
 		dependent_hostlist=xodtemplate_expand_hostgroups_and_hosts(temp_servicedependency->dependent_hostgroup_name,temp_servicedependency->dependent_host_name);
+		same_host_servicedependency=FALSE;
 		if(dependent_hostlist==NULL){
-#ifdef NSCORE
-			snprintf(temp_buffer,sizeof(temp_buffer)-1,"Error: Could not expand dependent hostgroups and/or hosts specified in service dependency (config file '%s', starting on line %d)\n",xodtemplate_config_file_name(temp_servicedependency->_config_file),temp_servicedependency->_start_line);
-			temp_buffer[sizeof(temp_buffer)-1]='\x0';
-			write_to_logs_and_console(temp_buffer,NSLOG_CONFIG_ERROR,TRUE);
-#endif
-			return ERROR;
+			/* Dependent host names not defined: set same-host servicedependency and use master host names */
+			same_host_servicedependency=TRUE;
+			dependent_hostlist=xodtemplate_expand_hostgroups_and_hosts(temp_servicedependency->hostgroup_name,temp_servicedependency->host_name);
 		        }
 
 		/* duplicate the dependency definitions */
@@ -4146,6 +4145,9 @@
 
 			for(this_hostlist=dependent_hostlist;this_hostlist!=NULL;this_hostlist=this_hostlist->next){
 
+				if(same_host_servicedependency==TRUE && strcmp(temp_hostlist->host_name,this_hostlist->host_name)!=0)
+					continue;
+
 				/* existing definition gets first names */
 				if(first_item==TRUE){
 					free(temp_servicedependency->host_name);
