diff -urpN john-1.7.8-jumbo-6a/src/config.c john-1.7.8-jumbo-6b/src/config.c
--- john-1.7.8-jumbo-6a/src/config.c	2011-08-31 16:05:32.234375000 +0000
+++ john-1.7.8-jumbo-6b/src/config.c	2011-08-31 15:56:19.171875000 +0000
@@ -67,6 +67,7 @@ static void cfg_add_line(char *line, int
 
 	entry->data = str_alloc_copy(line);
 	entry->number = number;
+	entry->cfg_name = cfg_name;
 
 	list = cfg_database->list;
 	if (list->tail)
@@ -132,21 +133,24 @@ void cfg_init(char *name, int allow_miss
 
 	if (cfg_database && !cfg_recursion) return;
 
-	if (!(file = fopen(path_expand(name), "r")) && 
-		!(file = fopen(path_expand_ex(name), "r"))) {
-		if (allow_missing && errno == ENOENT) return;
-		pexit("fopen: %s", path_expand(name));
+	cfg_name = str_alloc_copy(path_expand(name));
+	file = fopen(cfg_name, "r");
+	if (!file) {
+		cfg_name = str_alloc_copy(path_expand_ex(name));
+		file = fopen(cfg_name, "r");
+		if (!file) {
+			if (allow_missing && errno == ENOENT) return;
+			pexit("fopen: %s", cfg_name);
+		}
 	}
 
 	number = 0;
 	while (fgetl(line, sizeof(line), file))
-	if (cfg_process_line(line, ++number)) cfg_error(name, number);
+	if (cfg_process_line(line, ++number)) cfg_error(cfg_name, number);
 
 	if (ferror(file)) pexit("fgets");
 
 	if (fclose(file)) pexit("fclose");
-
-	cfg_name = str_alloc_copy(path_expand(name));
 }
 
 static struct cfg_section *cfg_get_section(char *section, char *subsection)
@@ -287,7 +291,7 @@ static int cfg_process_directive_include
 // Handle a .include "file"   or a .include <file>
 static int cfg_process_directive_include_config(char *line, int number)
 {
-	char *p, *p2;
+	char *p, *p2, *saved_fname;
 	char Name[PATH_BUFFER_SIZE+1];
 	// Ok, we are including a file.
 	if (!strncmp(line, ".include \"", 10)) {
@@ -315,9 +319,11 @@ static int cfg_process_directive_include
 		fprintf(stderr, "ERROR, .include recursion too deep in john.ini processing file .include \"%s\"\n", p);
 		return 1;
 	}
+	saved_fname = cfg_name;
 	cfg_recursion++;
 	cfg_init(Name, 0);
 	cfg_recursion--;
+	cfg_name = saved_fname;
 	return 0;
 }
 
diff -urpN john-1.7.8-jumbo-6a/src/config.h john-1.7.8-jumbo-6b/src/config.h
--- john-1.7.8-jumbo-6a/src/config.h	2009-12-25 17:10:22.000000000 +0000
+++ john-1.7.8-jumbo-6b/src/config.h	2011-08-31 15:20:38.343750000 +0000
@@ -25,6 +25,7 @@ struct cfg_line {
 	struct cfg_line *next;
 	char *data;
 	int number;
+	char *cfg_name;
 };
 
 /*
diff -urpN john-1.7.8-jumbo-6a/src/external.c john-1.7.8-jumbo-6b/src/external.c
--- john-1.7.8-jumbo-6a/src/external.c	2011-06-07 23:57:38.000000000 +0000
+++ john-1.7.8-jumbo-6b/src/external.c	2011-08-31 15:20:38.390625000 +0000
@@ -88,7 +88,7 @@ void ext_init(char *mode)
 		if (mpi_id == 0)
 #endif
 		fprintf(stderr, "Compiler error in %s at line %d: %s\n",
-			cfg_name, ext_line->number,
+			ext_line->cfg_name, ext_line->number,
 			c_errors[c_errno]);
 		error();
 	}
diff -urpN john-1.7.8-jumbo-6a/src/md5_gen_parser.c john-1.7.8-jumbo-6b/src/md5_gen_parser.c
--- john-1.7.8-jumbo-6a/src/md5_gen_parser.c	2011-08-03 16:16:49.000000000 +0000
+++ john-1.7.8-jumbo-6b/src/md5_gen_parser.c	2011-08-31 15:43:10.000000000 +0000
@@ -273,9 +273,10 @@ char *GetFld(char **out, char *in)
 	return cp;
 }
 
-int md5_gen_LOAD_PARSER_FUNCTIONS_LoadLINE(char *Line)
+int md5_gen_LOAD_PARSER_FUNCTIONS_LoadLINE(struct cfg_line *_line)
 {
 	int nConst, j;
+	char *Line = _line->data;
 	char c = *Line;
 	if (c >= 'A' && c <= 'Z')
 		c ^= 0x20; // lower case.
@@ -286,7 +287,7 @@ int md5_gen_LOAD_PARSER_FUNCTIONS_LoadLI
 		cp = GetFld(&(Setup.pPreloads[nPreloadCnt].ciphertext), cp);
 		if (!Setup.pPreloads[nPreloadCnt].ciphertext ||
 			strncmp(Setup.pPreloads[nPreloadCnt].ciphertext, SetupName, strlen(SetupName)))
-			return !!fprintf(stderr, "Error, invalid test line (wrong generic type):  %s\n", Line);
+			return !fprintf(stderr, "Error, invalid test line (wrong generic type):  %s\n", Line);
 		cp = GetFld(&(Setup.pPreloads[nPreloadCnt].plaintext), cp);
 		Setup.pPreloads[nPreloadCnt].plaintext = md5_gen_Demangle(Setup.pPreloads[nPreloadCnt].plaintext);
 		Setup.pPreloads[nPreloadCnt].flds[1] = str_alloc_copy(Setup.pPreloads[nPreloadCnt].ciphertext);
@@ -306,7 +307,7 @@ int md5_gen_LOAD_PARSER_FUNCTIONS_LoadLI
 		cp = GetFld(&(Setup.pPreloads[nPreloadCnt].ciphertext), cp);
 		if (!Setup.pPreloads[nPreloadCnt].ciphertext ||
 			strncmp(Setup.pPreloads[nPreloadCnt].ciphertext, SetupName, strlen(SetupName)))
-			return !!fprintf(stderr, "Error, invalid test line (wrong generic type):  %s\n", Line);
+			return !fprintf(stderr, "Error, invalid test line (wrong generic type):  %s\n", Line);
 		cp = GetFld(&(Setup.pPreloads[nPreloadCnt].plaintext), cp);
 		Setup.pPreloads[nPreloadCnt].plaintext = md5_gen_Demangle(Setup.pPreloads[nPreloadCnt].plaintext);
 		Setup.pPreloads[nPreloadCnt].flds[1] = str_alloc_copy(Setup.pPreloads[nPreloadCnt].ciphertext);
@@ -326,7 +327,7 @@ int md5_gen_LOAD_PARSER_FUNCTIONS_LoadLI
 		cp = GetFld(&(Setup.pPreloads[nPreloadCnt].ciphertext), cp);
 		if (!Setup.pPreloads[nPreloadCnt].ciphertext ||
 			strncmp(Setup.pPreloads[nPreloadCnt].ciphertext, SetupName, strlen(SetupName)))
-			return !!fprintf(stderr, "Error, invalid test line (wrong generic type):  %s\n", Line);
+			return !fprintf(stderr, "Error, invalid test line (wrong generic type):  %s\n", Line);
 		cp = GetFld(&(Setup.pPreloads[nPreloadCnt].plaintext), cp);
 		Setup.pPreloads[nPreloadCnt].plaintext = md5_gen_Demangle(Setup.pPreloads[nPreloadCnt].plaintext);
 		Setup.pPreloads[nPreloadCnt].flds[1] = str_alloc_copy(Setup.pPreloads[nPreloadCnt].ciphertext);
@@ -342,7 +343,7 @@ int md5_gen_LOAD_PARSER_FUNCTIONS_LoadLI
 	{
 		char *tmp = md5_gen_Demangle(&Line[10]);
 		if (!tmp)
-			return !!fprintf(stderr, "Error, invalid test line: %s\n", Line);
+			return !fprintf(stderr, "Error, invalid test line: %s\n", Line);
 		options.loader.field_sep_char = *tmp;
 		return 1;
 	}
@@ -357,7 +358,7 @@ int md5_gen_LOAD_PARSER_FUNCTIONS_LoadLI
 				return 1;
 			}
 		}
-		return !!fprintf(stderr, "Error, unknown function:  %s\n", Line);
+		return !fprintf(stderr, "Error, unknown function:  %s\n", Line);
 	}
 	if (c == 'f' && !strncasecmp(Line, "Flag=", 5))
 	{
@@ -378,19 +379,19 @@ int md5_gen_LOAD_PARSER_FUNCTIONS_LoadLI
 				return 1;
 			}
 		}
-		return !!fprintf(stderr, "Error, unknown flag:  %s\n", Line);
+		return !fprintf(stderr, "Error, unknown flag:  %s\n", Line);
 	}
 	if (c == 's' && !strncasecmp(Line, "SaltLen=", 8))
 	{
 		if (sscanf(&Line[7], "=%d", &Setup.SaltLen) == 1)
 			return 1;
-		return !!fprintf(stderr, "Error, Invalid SaltLen= line:  %s  \n", Line);
+		return !fprintf(stderr, "Error, Invalid SaltLen= line:  %s  \n", Line);
 	}
 	if (c == 'm' && !strncasecmp(Line, "MaxInputLen=", 12))
 	{
 		if (sscanf(&Line[11], "=%d", &Setup.MaxInputLen) == 1)
 			return 1;
-		return !!fprintf(stderr, "Error, Invalid MaxInputLen= line:  %s  \n", Line);
+		return !fprintf(stderr, "Error, Invalid MaxInputLen= line:  %s  \n", Line);
 	}
 	if (c == 'e' && !strncasecmp(Line, "Expression=", 11))
 	{
@@ -402,17 +403,17 @@ int md5_gen_LOAD_PARSER_FUNCTIONS_LoadLI
 	if (c == 'c' && !strncasecmp(Line, "const", 5))
 	{
 		if (sscanf(&Line[5], "%d=", &nConst)!=1)
-			return !!fprintf(stderr, "Error, invalid const line.   Line: %s\n", Line);
+			return !fprintf(stderr, "Error, invalid const line.   Line: %s\n", Line);
 		if (nConst < 1 || nConst > 8)
-			return !!fprintf(stderr, "Error, only constants from 1 to 8 are valid.   Line: %s\n", Line);
+			return !fprintf(stderr, "Error, only constants from 1 to 8 are valid.   Line: %s\n", Line);
 		if (strlen(Line) == 7)
-			return !!fprintf(stderr, "Error, a 'blank' constant is not valid.   Line: %s\n", Line);
+			return !fprintf(stderr, "Error, a 'blank' constant is not valid.   Line: %s\n", Line);
 		if (Setup.pConstants[nConst-1].Const)
-			return !!fprintf(stderr, "Error, this constant has already entered.   Line: %s\n", Line);
+			return !fprintf(stderr, "Error, this constant has already entered.   Line: %s\n", Line);
 		Setup.pConstants[nConst-1].Const = md5_gen_Demangle(&Line[7]);
 		return 1;
 	}
-	return !!fprintf(stderr, "Error, unknown line:   %s\n", Line);
+	return !fprintf(stderr, "Error, unknown line:   %s\n", Line);
 }
 
 char *md5_gen_LOAD_PARSER_SIGNATURE(int which)
@@ -531,12 +532,12 @@ int md5_gen_LOAD_PARSER_FUNCTIONS(int wh
 
 	while (gen_line)
 	{
-		if (!md5_gen_LOAD_PARSER_FUNCTIONS_LoadLINE(gen_line->data))
+		if (!md5_gen_LOAD_PARSER_FUNCTIONS_LoadLINE(gen_line))
 		{
 #ifdef HAVE_MPI
 			if (mpi_id == 0)
 #endif
-			fprintf(stderr, "Error parsing section [List.Generic:md5_gen(%d)] in the john.ini/conf file\n", which);
+			fprintf(stderr, "Error parsing section [List.Generic:md5_gen(%d)]\nError in line %d file is %s\n", which, gen_line->number, gen_line->cfg_name);
 			error();
 		}
 		gen_line = gen_line->next;
diff -urpN john-1.7.8-jumbo-6a/src/rules.c john-1.7.8-jumbo-6b/src/rules.c
--- john-1.7.8-jumbo-6a/src/rules.c	2011-08-30 14:57:27.578125000 +0000
+++ john-1.7.8-jumbo-6b/src/rules.c	2011-08-31 15:47:00.671875000 +0000
@@ -1331,7 +1331,7 @@ int rules_count(struct rpp_context *star
 		if (mpi_id == 0)
 #endif
 		fprintf(stderr, "Invalid rule in %s at line %d: %s\n",
-			cfg_name, rules_line,
+			start->input->cfg_name, rules_line,
 			rules_errors[rules_errno]);
 		error();
 	}
