Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 130701790bf2d95e902edf16031ff596 > files > 218

autofs-5.0.1-0.rc2.164.el5_8.src.rpm

diff -up autofs-5.0.1/include/defaults.h.add-ferror-check autofs-5.0.1/include/defaults.h
--- autofs-5.0.1/include/defaults.h.add-ferror-check	2007-10-19 14:07:39.000000000 +0800
+++ autofs-5.0.1/include/defaults.h	2007-10-19 14:08:18.000000000 +0800
@@ -41,7 +41,7 @@
 struct ldap_schema;
 struct ldap_searchdn;
 
-unsigned int defaults_read_config(void);
+unsigned int defaults_read_config(unsigned int);
 const char *defaults_get_master_map(void);
 unsigned int defaults_get_timeout(void);
 unsigned int defaults_get_browse_mode(void);
diff -up autofs-5.0.1/modules/lookup_file.c.add-ferror-check autofs-5.0.1/modules/lookup_file.c
--- autofs-5.0.1/modules/lookup_file.c.add-ferror-check	2007-10-19 14:07:38.000000000 +0800
+++ autofs-5.0.1/modules/lookup_file.c	2007-10-19 14:08:18.000000000 +0800
@@ -446,6 +446,11 @@ int lookup_read_master(struct master *ma
 		if (!entry) {
 			if (feof(f))
 				break;
+			if (ferror(f)) {
+				warn(LOGOPT_ANY, MODPREFIX
+				     "error reading map %s", ctxt->mapname);
+				break;
+			}
 			continue;
 		}
 
@@ -687,6 +692,11 @@ int lookup_read_map(struct autofs_point 
 		if (!entry) {
 			if (feof(f))
 				break;
+			if (ferror(f)) {
+				warn(LOGOPT_ANY, MODPREFIX
+				      "error reading map %s", ctxt->mapname);
+				break;
+			}
 			continue;
 		}
 			
@@ -852,6 +862,12 @@ static int lookup_one(struct autofs_poin
 
 		if (feof(f))
 			break;
+
+		if (ferror(f)) {
+			warn(LOGOPT_ANY, MODPREFIX
+			      "error reading map %s", ctxt->mapname);
+			break;
+		}		
 	}
 
 	fclose(f);
@@ -911,6 +927,12 @@ static int lookup_wild(struct autofs_poi
 
 		if (feof(f))
 			break;
+
+		if (ferror(f)) {
+			warn(LOGOPT_ANY, MODPREFIX
+			      "error reading map %s", ctxt->mapname);
+			break;
+		}		
 	}
 
 	fclose(f);
diff -up autofs-5.0.1/daemon/automount.c.add-ferror-check autofs-5.0.1/daemon/automount.c
--- autofs-5.0.1/daemon/automount.c.add-ferror-check	2007-10-19 14:07:39.000000000 +0800
+++ autofs-5.0.1/daemon/automount.c	2007-10-19 14:08:18.000000000 +0800
@@ -957,7 +957,7 @@ static void *do_read_master(void *arg)
 	if (status)
 		fatal(status);
 
-	defaults_read_config();
+	defaults_read_config(1);
 
 	status = master_read_master(master, age, readall);
 
@@ -1444,7 +1444,7 @@ int main(int argc, char *argv[])
 
 	program = argv[0];
 
-	defaults_read_config();
+	defaults_read_config(0);
 
 	timeout = defaults_get_timeout();
 	ghost = defaults_get_browse_mode();
diff -up autofs-5.0.1/lib/defaults.c.add-ferror-check autofs-5.0.1/lib/defaults.c
--- autofs-5.0.1/lib/defaults.c.add-ferror-check	2007-10-19 14:07:39.000000000 +0800
+++ autofs-5.0.1/lib/defaults.c	2007-10-19 14:08:18.000000000 +0800
@@ -280,7 +280,7 @@ struct list_head *defaults_get_uris(void
  * is valid bourne shell script without spaces around "="
  * and that it has valid values.
  */
-unsigned int defaults_read_config(void)
+unsigned int defaults_read_config(unsigned int to_syslog)
 {
 	FILE *f;
 	char buf[MAX_LINE_LEN];
@@ -312,9 +312,16 @@ unsigned int defaults_read_config(void)
 			;
 	}
 
-	if (!feof(f)) {
-		fprintf(stderr, "fgets returned error %d while reading %s\n",
-			ferror(f), DEFAULTS_CONFIG_FILE);
+	if (!feof(f) || ferror(f)) {
+		if (!to_syslog) {
+			fprintf(stderr,
+				"fgets returned error %d while reading %s\n",
+				ferror(f), DEFAULTS_CONFIG_FILE);
+		} else {
+			error(LOGOPT_ANY,
+			      "fgets returned error %d while reading %s",
+			      ferror(f), DEFAULTS_CONFIG_FILE);
+		}
 		fclose(f);
 		return 0;
 	}